ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runPhysicsExample.C
Revision: 1.17
Committed: Mon Jun 13 20:36:39 2011 UTC (13 years, 10 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_029c, Mit_029b, Mit_029a, Mit_028a, Mit_028, Mit_027, Mit_027a, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, HEAD
Changes since 1.16: +12 -12 lines
Log Message:
update for the new selection

File Contents

# User Rev Content
1 bendavid 1.1 //root -l -q -b $CMSSW_BASE/src/MitHiggs/macros/runMacros/runHwwExampleAnalysis.C+\(\"0000\",\"noskim\",\"s8-h190ww2l-gf-mc3\",\"mit/filler/011\",\"/home/mitprod/catalog\",\"HwwExampleAnalysis\",1000,1\)
2    
3 ceballos 1.17 // $Id: runPhysicsExample.C,v 1.16 2011/04/29 16:18:16 ceballos Exp $
4 bendavid 1.1
5     #if !defined(__CINT__) || defined(__MAKECINT__)
6     #include <TROOT.h>
7     #include <exception>
8     #include "MitAna/DataUtil/interface/Debug.h"
9     #include "MitAna/Catalog/interface/Catalog.h"
10     #include "MitAna/TreeMod/interface/Analysis.h"
11     #include "MitAna/TreeMod/interface/HLTMod.h"
12     #include "MitAna/PhysicsMod/interface/PublisherMod.h"
13 bendavid 1.3 #include "MitAna/PhysicsMod/interface/RunLumiSelectionMod.h"
14 bendavid 1.1 #include "MitPhysics/Init/interface/ModNames.h"
15 ceballos 1.5 #include "MitPhysics/Mods/interface/GoodPVFilterMod.h"
16 bendavid 1.1 #include "MitPhysics/Mods/interface/GeneratorMod.h"
17     #include "MitPhysics/Mods/interface/HKFactorProducer.h"
18     #include "MitPhysics/Mods/interface/JetCorrectionMod.h"
19     #include "MitPhysics/Mods/interface/CaloMetCorrectionMod.h"
20     #include "MitPhysics/Mods/interface/MuonIDMod.h"
21     #include "MitPhysics/Mods/interface/ElectronIDMod.h"
22     #include "MitPhysics/Mods/interface/PhotonIDMod.h"
23     #include "MitPhysics/Mods/interface/TauIDMod.h"
24     #include "MitPhysics/Mods/interface/JetIDMod.h"
25     #include "MitPhysics/Mods/interface/ElectronCleaningMod.h"
26     #include "MitPhysics/Mods/interface/PhotonCleaningMod.h"
27     #include "MitPhysics/Mods/interface/TauCleaningMod.h"
28     #include "MitPhysics/Mods/interface/JetCleaningMod.h"
29     #include "MitPhysics/Mods/interface/MergeLeptonsMod.h"
30     #include "MitAna/DataTree/interface/JetCol.h"
31 ceballos 1.5 #include "MitAna/DataTree/interface/PFJetCol.h"
32 bendavid 1.1 #include "MitAna/DataTree/interface/MetCol.h"
33 ceballos 1.14 #include "MitAna/DataTree/interface/PFMetCol.h"
34 bendavid 1.1 #include "MitAna/DataTree/interface/CaloMetCol.h"
35 ceballos 1.5 #include "MitPhysics/SelMods/interface/HwwExampleAnalysisMod.h"
36 ceballos 1.13 #include "MitPhysics/SelMods/interface/WBFExampleAnalysisMod.h"
37 bendavid 1.1 #endif
38    
39     //--------------------------------------------------------------------------------------------------
40 ceballos 1.14 void runPhysicsExample(const char *catalogDir = "/home/mitprod/catalog",
41     const char *book = "cern/filefi/020",
42 ceballos 1.16 const char *dataset = "p11-ww2l-v1g1-pu",
43 ceballos 1.4 const char *fileset = "0000",
44     const char *skim = "noskim",
45     const char *outputName = "histo",
46     int sampleID = -1,
47 ceballos 1.13 int nEvents = 10000)
48 bendavid 1.1 {
49     //------------------------------------------------------------------------------------------------
50     // some global setups
51     //------------------------------------------------------------------------------------------------
52     using namespace mithep;
53     gDebugMask = Debug::kAnalysis;
54 ceballos 1.5 gDebugLevel = 3;
55 bendavid 1.1
56     //------------------------------------------------------------------------------------------------
57     // set up information
58     //------------------------------------------------------------------------------------------------
59 ceballos 1.14 Bool_t applyISRFilter = kFALSE;
60     Bool_t applyMllGenCut = kFALSE;
61     Bool_t isData = kFALSE;
62     Bool_t isDataMuonElectron = kFALSE;
63     Bool_t isDataDMuon = kFALSE;
64     Bool_t isDataSMuon = kFALSE;
65     Bool_t isDataDElectron = kFALSE;
66     Bool_t isDataSElectron = kFALSE;
67 ceballos 1.5 int processId = -999999999; // use 999 for MCatNLO MC sample, 102 for H->WW
68 ceballos 1.15 TString fInputFilenameKF = "/home/ceballos/releases/CMSSW_4_2_2/src/MitPhysics/data/HWW_KFactors_160_10TeV.dat";
69 bendavid 1.1
70 ceballos 1.14 if(sampleID >= 1000) isData = kTRUE;
71    
72     if(sampleID >= 1000) isDataMuonElectron = kTRUE;
73     if(sampleID >= 2000) isDataDMuon = kTRUE;
74     if(sampleID >= 3000) isDataSMuon = kTRUE;
75     if(sampleID >= 4000) isDataDElectron = kTRUE;
76     if(sampleID >= 5000) isDataSElectron = kTRUE;
77 ceballos 1.4
78 bendavid 1.1 //------------------------------------------------------------------------------------------------
79     // generator information
80     //------------------------------------------------------------------------------------------------
81     GeneratorMod *generatorMod = new GeneratorMod;
82 ceballos 1.4 generatorMod->SetPrintDebug(kFALSE);
83     generatorMod->SetPtLeptonMin(0.0);
84     generatorMod->SetEtaLeptonMax(2.7);
85     generatorMod->SetPtPhotonMin(15.0);
86     generatorMod->SetEtaPhotonMax(2.7);
87     generatorMod->SetPtRadPhotonMin(10.0);
88     generatorMod->SetEtaRadPhotonMax(2.7);
89     generatorMod->SetIsData(isData);
90     generatorMod->SetFillHist(!isData);
91     if(applyMllGenCut == kTRUE){
92     generatorMod->SetPdgIdCut(23);
93 ceballos 1.5 generatorMod->SetMassMinCut( 0.);
94 ceballos 1.4 generatorMod->SetMassMaxCut(50.);
95     }
96     generatorMod->SetApplyISRFilter(applyISRFilter);
97 bendavid 1.1
98 ceballos 1.5 HKFactorProducer *hKFactorProducer = new HKFactorProducer;
99     hKFactorProducer->SetProcessID(processId);
100     hKFactorProducer->SetInputFilename(fInputFilenameKF);
101     hKFactorProducer->SetIsData(isData);
102     hKFactorProducer->SetFillHist(!isData);
103    
104     //------------------------------------------------------------------------------------------------
105     // Run RunLumiSelectionMod
106     //------------------------------------------------------------------------------------------------
107     RunLumiSelectionMod *runLumiSelectionMod = new RunLumiSelectionMod;
108     runLumiSelectionMod->SetAcceptMC(!isData);
109 ceballos 1.17 runLumiSelectionMod->AddJSONFile("/home/ceballos/releases/CMSSW_4_2_2/src/json/Cert_160404-166502_7TeV_PromptReco_Collisions11_JSON.txt");
110 ceballos 1.5
111     //------------------------------------------------------------------------------------------------
112     // PV filter selection
113     //------------------------------------------------------------------------------------------------
114     GoodPVFilterMod *goodPVFilterMod = new GoodPVFilterMod;
115     goodPVFilterMod->SetMinVertexNTracks(0);
116 ceballos 1.9 goodPVFilterMod->SetMinNDof(4);
117 ceballos 1.5 goodPVFilterMod->SetMaxAbsZ(24.0);
118     goodPVFilterMod->SetMaxRho(2.0);
119 ceballos 1.14 goodPVFilterMod->SetVertexesName("DAPrimaryVertexes");
120 ceballos 1.5
121 bendavid 1.1 //------------------------------------------------------------------------------------------------
122     // HLT information
123     //------------------------------------------------------------------------------------------------
124     HLTMod *hltmod = new HLTMod;
125 ceballos 1.10
126 ceballos 1.5 if (isData == kFALSE){
127 ceballos 1.16 hltmod->AddTrigger("HLT_Mu15_v1");
128     hltmod->AddTrigger("!HLT_Mu15_v1");
129 ceballos 1.5 }
130 ceballos 1.14 else if(isData == true && isDataMuonElectron == true) {
131     hltmod->AddTrigger("HLT_Mu17_Ele8_CaloIdL_v1",150000,161176);
132     hltmod->AddTrigger("HLT_Mu8_Ele17_CaloIdL_v1",150000,161176);
133 ceballos 1.16 hltmod->AddTrigger("HLT_Mu17_Ele8_CaloIdL_v2",161179,163261);
134     hltmod->AddTrigger("HLT_Mu8_Ele17_CaloIdL_v2",161179,163261);
135     hltmod->AddTrigger("HLT_Mu17_Ele8_CaloIdL_v3",163262,999999);
136     hltmod->AddTrigger("HLT_Mu8_Ele17_CaloIdL_v3",163262,999999);
137 ceballos 1.14 }
138     else if(isData == true && isDataDMuon == true) {
139     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v1&!HLT_Mu17_Ele8_CaloIdL_v1&HLT_DoubleMu7_v1",150000,161176);
140 ceballos 1.16 hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v2&!HLT_Mu17_Ele8_CaloIdL_v2&HLT_DoubleMu7_v1",161179,163261);
141     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v3&!HLT_Mu17_Ele8_CaloIdL_v3&HLT_DoubleMu7_v2",163262,999999);
142 ceballos 1.14 }
143     else if(isData == true && isDataSMuon == true) {
144     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v1&!HLT_Mu17_Ele8_CaloIdL_v1&!HLT_DoubleMu7_v1&HLT_Mu15_v2",150000,161176);
145 ceballos 1.16 hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v2&!HLT_Mu17_Ele8_CaloIdL_v2&!HLT_DoubleMu7_v1&HLT_Mu15_v2",161179,163261);
146     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v3&!HLT_Mu17_Ele8_CaloIdL_v3&!HLT_DoubleMu7_v2&HLT_Mu24_v2",163262,999999);
147     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v3&!HLT_Mu17_Ele8_CaloIdL_v3&!HLT_DoubleMu7_v2&HLT_IsoMu17_v6",163262,999999);
148 ceballos 1.14 }
149     else if(isData == true && isDataDElectron == true) {
150     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v1&!HLT_Mu17_Ele8_CaloIdL_v1&!HLT_DoubleMu7_v1&!HLT_Mu15_v2&HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v1",150000,161176);
151 ceballos 1.16 hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v2&!HLT_Mu17_Ele8_CaloIdL_v2&!HLT_DoubleMu7_v1&!HLT_Mu15_v2&HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v2",161179,163261);
152     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v3&!HLT_Mu17_Ele8_CaloIdL_v3&!HLT_DoubleMu7_v2&!HLT_Mu24_v2&!HLT_IsoMu17_v6&HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v3",163262,999999);
153 ceballos 1.5 }
154 ceballos 1.14 else if(isData == true && isDataSElectron == true) {
155     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v1&!HLT_Mu17_Ele8_CaloIdL_v1&!HLT_DoubleMu7_v1&!HLT_Mu15_v2&!HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v1&HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v1",150000,161176);
156 ceballos 1.16 hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v2&!HLT_Mu17_Ele8_CaloIdL_v2&!HLT_DoubleMu7_v1&!HLT_Mu15_v2&!HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v2&HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v2",161179,163261);
157     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v3&!HLT_Mu17_Ele8_CaloIdL_v3&!HLT_DoubleMu7_v2&!HLT_Mu24_v2&!HLT_IsoMu17_v6&!HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v3&HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v3",163262,999999);
158 bendavid 1.1 }
159     hltmod->SetTrigObjsName("myhltobjs");
160    
161     //------------------------------------------------------------------------------------------------
162     // publisher Mod
163     //------------------------------------------------------------------------------------------------
164 ceballos 1.5 PublisherMod<PFJet,Jet> *pubJet = new PublisherMod<PFJet,Jet>("JetPub");
165     pubJet->SetInputName("AKt5PFJets");
166     pubJet->SetOutputName("PubAKt5PFJets");
167 bendavid 1.1
168 ceballos 1.14 PublisherMod<PFMet,Met> *pubMet = new PublisherMod<PFMet,Met>("MetPub");
169     pubMet->SetInputName("PFMet");
170     pubMet->SetOutputName("PubPFMet");
171 ceballos 1.4
172 bendavid 1.1 //------------------------------------------------------------------------------------------------
173 ceballos 1.4 // Apply Jet Corrections
174 bendavid 1.1 //------------------------------------------------------------------------------------------------
175 bendavid 1.3 JetCorrectionMod *jetCorr = new JetCorrectionMod;
176 ceballos 1.17 jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_4_2_2/src/MitPhysics/data/START41_V0_AK5PF_L1FastJet.txt");
177     jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_4_2_2/src/MitPhysics/data/START41_V0_AK5PF_L2Relative.txt");
178     jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_4_2_2/src/MitPhysics/data/START41_V0_AK5PF_L3Absolute.txt");
179     if(isData == true){
180     jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_4_2_2/src/MitPhysics/data/START41_V0_AK5PF_L2L3Residual.txt");
181 ceballos 1.12 }
182 ceballos 1.17 jetCorr->SetInputName(pubJet1->GetOutputName());
183 ceballos 1.4 jetCorr->SetCorrectedName("CorrectedJets");
184 bendavid 1.1
185 ceballos 1.4 //------------------------------------------------------------------------------------------------
186 bendavid 1.1 // object id and cleaning sequence
187     //------------------------------------------------------------------------------------------------
188 ceballos 1.14 MuonIDMod *muonID = new MuonIDMod;
189 ceballos 1.17 muonID->SetClassType("GlobalTracker");
190     muonID->SetIDType("WWMuIdV2");
191     muonID->SetIsoType("PFIso");
192 ceballos 1.5 muonID->SetApplyD0Cut(kTRUE);
193 ceballos 1.14 muonID->SetApplyDZCut(kTRUE);
194     muonID->SetWhichVertex(0);
195 ceballos 1.5
196 ceballos 1.14 ElectronIDMod *electronID = new ElectronIDMod;
197     electronID->SetIDType("VBTFWorkingPointLowPtId");
198 ceballos 1.17 electronID->SetIsoType("PFIso");
199 ceballos 1.14 electronID->SetApplyConversionFilterType1(kTRUE);
200     electronID->SetApplyConversionFilterType2(kFALSE);
201 ceballos 1.5 electronID->SetChargeFilter(kFALSE);
202     electronID->SetApplyD0Cut(kTRUE);
203 ceballos 1.14 electronID->SetApplyDZCut(kTRUE);
204     electronID->SetWhichVertex(0);
205 ceballos 1.5 electronID->SetNExpectedHitsInnerCut(0);
206    
207 ceballos 1.11 // Object ID and Cleaning Sequence
208 ceballos 1.4 PhotonIDMod *photonID = new PhotonIDMod;
209     TauIDMod *tauID = new TauIDMod;
210     JetIDMod *jetID = new JetIDMod;
211     jetID->SetInputName(jetCorr->GetOutputName());
212 ceballos 1.14 jetID->SetPtCut(30.0);
213 bendavid 1.1 jetID->SetEtaMaxCut(5.0);
214 ceballos 1.5 jetID->SetJetEEMFractionMinCut(0.0);
215 ceballos 1.4 jetID->SetOutputName("GoodJets");
216 ceballos 1.14 jetID->SetApplyBetaCut(kFALSE);
217 ceballos 1.4
218 bendavid 1.1 ElectronCleaningMod *electronCleaning = new ElectronCleaningMod;
219     PhotonCleaningMod *photonCleaning = new PhotonCleaningMod;
220     TauCleaningMod *tauCleaning = new TauCleaningMod;
221     JetCleaningMod *jetCleaning = new JetCleaningMod;
222 ceballos 1.4 jetCleaning->SetGoodJetsName("GoodJets");
223     jetCleaning->SetCleanJetsName("CleanJets");
224 bendavid 1.1
225 ceballos 1.7 JetIDMod *jetIDNoPtCut = new JetIDMod;
226     jetIDNoPtCut->SetInputName(jetCorr->GetOutputName());
227     jetIDNoPtCut->SetPtCut(0.0);
228     jetIDNoPtCut->SetEtaMaxCut(5.0);
229     jetIDNoPtCut->SetJetEEMFractionMinCut(0.0);
230     jetIDNoPtCut->SetOutputName("GoodJetsNoPtCut");
231 ceballos 1.14 jetIDNoPtCut->SetApplyBetaCut(kFALSE);
232 ceballos 1.7
233     JetCleaningMod *jetCleaningNoPtCut = new JetCleaningMod;
234     jetCleaningNoPtCut->SetGoodJetsName("GoodJetsNoPtCut");
235     jetCleaningNoPtCut->SetCleanJetsName("CleanJetsNoPtCut");
236    
237 bendavid 1.1 //------------------------------------------------------------------------------------------------
238     // merge modules
239     //------------------------------------------------------------------------------------------------
240     MergeLeptonsMod *mergeLeptonsMod = new MergeLeptonsMod;
241     mergeLeptonsMod->SetMuonsName(muonID->GetOutputName());
242     mergeLeptonsMod->SetElectronsName(electronCleaning->GetOutputName());
243    
244     //------------------------------------------------------------------------------------------------
245     // analyses modules
246     //------------------------------------------------------------------------------------------------
247 ceballos 1.13 HwwExampleAnalysisMod *WWanalysisMod = new HwwExampleAnalysisMod;
248     WWanalysisMod->SetMetName(pubMet->GetOutputName());
249     WWanalysisMod->SetCleanJetsName(jetCleaning->GetOutputName());
250     WWanalysisMod->SetCleanJetsNoPtCutName(jetCleaningNoPtCut->GetOutputName());
251    
252     WBFExampleAnalysisMod *WBFanalysisMod = new WBFExampleAnalysisMod;
253     WBFanalysisMod->SetMetName(pubMet->GetOutputName());
254     WBFanalysisMod->SetCleanJetsName(jetCleaning->GetOutputName());
255 bendavid 1.1
256     //------------------------------------------------------------------------------------------------
257     // making analysis chain
258     //------------------------------------------------------------------------------------------------
259 ceballos 1.5 generatorMod->Add(hKFactorProducer);
260     hKFactorProducer->Add(runLumiSelectionMod);
261     runLumiSelectionMod->Add(goodPVFilterMod);
262     goodPVFilterMod->Add(hltmod);
263 ceballos 1.4 hltmod->Add(muonID);
264 bendavid 1.1 muonID->Add(electronID);
265     electronID->Add(photonID);
266     photonID->Add(tauID);
267     tauID->Add(pubJet);
268 bendavid 1.3 pubJet->Add(pubMet);
269 ceballos 1.14 pubMet->Add(jetCorr);
270     jetCorr->Add(jetID);
271 bendavid 1.1 jetID->Add(electronCleaning);
272     electronCleaning->Add(photonCleaning);
273     photonCleaning->Add(tauCleaning);
274     tauCleaning->Add(jetCleaning);
275 ceballos 1.7 jetCleaning->Add(jetIDNoPtCut);
276     jetIDNoPtCut->Add(jetCleaningNoPtCut);
277     jetCleaningNoPtCut->Add(mergeLeptonsMod);
278 ceballos 1.13 mergeLeptonsMod->Add(WWanalysisMod);
279     WWanalysisMod->Add(WBFanalysisMod);
280 bendavid 1.1
281     //------------------------------------------------------------------------------------------------
282     // setup analysis
283     //------------------------------------------------------------------------------------------------
284     Analysis *ana = new Analysis;
285 ceballos 1.4 ana->SetUseHLT(kTRUE);
286     ana->SetKeepHierarchy(kFALSE);
287 bendavid 1.1 if (nEvents >= 0)
288     ana->SetProcessNEvents(nEvents);
289     ana->SetSuperModule(generatorMod);
290 ceballos 1.4 ana->SetPrintScale(100);
291 bendavid 1.1
292     //------------------------------------------------------------------------------------------------
293     // organize input
294     //------------------------------------------------------------------------------------------------
295     printf("\nRely on Catalog: %s\n",catalogDir);
296     printf(" -> Book: %s Dataset: %s Skim: %s Fileset: %s <-\n\n",book,dataset,skim,fileset);
297     Catalog *c = new Catalog(catalogDir);
298     TString skimdataset = TString(dataset)+TString("/") +TString(skim);
299     Dataset *d = NULL;
300     if (TString(skim).CompareTo("noskim") == 0)
301     d = c->FindDataset(book,dataset,fileset);
302     else
303     d = c->FindDataset(book,skimdataset.Data(),fileset);
304 bendavid 1.2 ana->AddDataset(d);
305 bendavid 1.1
306     //------------------------------------------------------------------------------------------------
307     // organize output
308     //------------------------------------------------------------------------------------------------
309     TString rootFile = TString(outputName);
310     rootFile += TString("_") + TString(dataset) + TString("_") + TString(skim);
311     if (TString(fileset) != TString(""))
312     rootFile += TString("_") + TString(fileset);
313     rootFile += TString(".root");
314     printf("\nRoot output: %s\n\n",rootFile.Data());
315     ana->SetOutputName(rootFile.Data());
316 ceballos 1.5 ana->SetCacheSize(64*1024*1024);
317 bendavid 1.1
318     //------------------------------------------------------------------------------------------------
319     // run the analysis after successful initialisation
320     //------------------------------------------------------------------------------------------------
321     ana->Run(!gROOT->IsBatch());
322    
323     return;
324     }