ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runPhysicsExample.C
Revision: 1.13
Committed: Wed Dec 22 20:20:40 2010 UTC (14 years, 4 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_020d, TMit_020d, Mit_020c, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018
Changes since 1.12: +19 -13 lines
Log Message:
some fixes

File Contents

# Content
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 // $Id: runPhysicsExample.C,v 1.12 2010/11/17 19:38:29 ceballos Exp $
4
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 #include "MitAna/PhysicsMod/interface/RunLumiSelectionMod.h"
14 #include "MitPhysics/Init/interface/ModNames.h"
15 #include "MitPhysics/Mods/interface/GoodPVFilterMod.h"
16 #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 #include "MitAna/DataTree/interface/PFJetCol.h"
32 #include "MitAna/DataTree/interface/MetCol.h"
33 #include "MitAna/DataTree/interface/CaloMetCol.h"
34 #include "MitPhysics/SelMods/interface/HwwExampleAnalysisMod.h"
35 #include "MitPhysics/SelMods/interface/WBFExampleAnalysisMod.h"
36 #endif
37
38 //--------------------------------------------------------------------------------------------------
39 void runPhysicsExample(const char *catalogDir = "/home/ceballos/catalog",
40 const char *book = "cern/filler/015",
41 const char *dataset = "f10-h150ww2l-wbf-z2-v12",
42 const char *fileset = "0000",
43 const char *skim = "noskim",
44 const char *outputName = "histo",
45 int sampleID = -1,
46 int nEvents = 10000)
47 {
48 //------------------------------------------------------------------------------------------------
49 // some global setups
50 //------------------------------------------------------------------------------------------------
51 using namespace mithep;
52 gDebugMask = Debug::kAnalysis;
53 gDebugLevel = 3;
54
55 //------------------------------------------------------------------------------------------------
56 // set up information
57 //------------------------------------------------------------------------------------------------
58 Bool_t applyISRFilter = kFALSE;
59 Bool_t applyMllGenCut = kFALSE;
60 Bool_t isData = kFALSE;
61 Bool_t isElData = kFALSE;
62 int processId = -999999999; // use 999 for MCatNLO MC sample, 102 for H->WW
63 TString fInputFilenameKF = "/home/ceballos/releases/CMSSW_3_9_7/src/MitPhysics/data/HWW_KFactors_160_10TeV.dat";
64
65 if(sampleID > 1000) isData = kTRUE;
66 if(sampleID > 2000) isElData = kTRUE;
67
68 //------------------------------------------------------------------------------------------------
69 // generator information
70 //------------------------------------------------------------------------------------------------
71 GeneratorMod *generatorMod = new GeneratorMod;
72 generatorMod->SetPrintDebug(kFALSE);
73 generatorMod->SetPtLeptonMin(0.0);
74 generatorMod->SetEtaLeptonMax(2.7);
75 generatorMod->SetPtPhotonMin(15.0);
76 generatorMod->SetEtaPhotonMax(2.7);
77 generatorMod->SetPtRadPhotonMin(10.0);
78 generatorMod->SetEtaRadPhotonMax(2.7);
79 generatorMod->SetIsData(isData);
80 generatorMod->SetFillHist(!isData);
81 if(applyMllGenCut == kTRUE){
82 generatorMod->SetPdgIdCut(23);
83 generatorMod->SetMassMinCut( 0.);
84 generatorMod->SetMassMaxCut(50.);
85 }
86 generatorMod->SetApplyISRFilter(applyISRFilter);
87
88 HKFactorProducer *hKFactorProducer = new HKFactorProducer;
89 hKFactorProducer->SetProcessID(processId);
90 hKFactorProducer->SetInputFilename(fInputFilenameKF);
91 hKFactorProducer->SetIsData(isData);
92 hKFactorProducer->SetFillHist(!isData);
93
94 //------------------------------------------------------------------------------------------------
95 // Run RunLumiSelectionMod
96 //------------------------------------------------------------------------------------------------
97 RunLumiSelectionMod *runLumiSelectionMod = new RunLumiSelectionMod;
98 runLumiSelectionMod->SetAcceptMC(!isData);
99 runLumiSelectionMod->AddJSONFile("/home/ceballos/releases/CMSSW_3_9_7/src/json/merged_JsonReRecoSep17_JsonStreamExpressV2.txt");
100
101 //------------------------------------------------------------------------------------------------
102 // PV filter selection
103 //------------------------------------------------------------------------------------------------
104 GoodPVFilterMod *goodPVFilterMod = new GoodPVFilterMod;
105 goodPVFilterMod->SetMinVertexNTracks(0);
106 goodPVFilterMod->SetMinNDof(4);
107 goodPVFilterMod->SetMaxAbsZ(24.0);
108 goodPVFilterMod->SetMaxRho(2.0);
109
110 //------------------------------------------------------------------------------------------------
111 // HLT information
112 //------------------------------------------------------------------------------------------------
113 HLTMod *hltmod = new HLTMod;
114
115 if (isData == kFALSE){
116 hltmod->AddTrigger("HLT_Mu9");
117 hltmod->AddTrigger("!HLT_Mu9");
118 }
119 else if(isElData == kFALSE){
120 hltmod->AddTrigger("HLT_Mu9",136033,147116);
121 hltmod->AddTrigger("HLT_Mu9&HLT_Ele10_LW_L1R",136033,139980);
122 hltmod->AddTrigger("HLT_Mu9&HLT_Ele15_SW_L1R",140058,141882);
123 hltmod->AddTrigger("HLT_Mu9&HLT_Ele15_SW_CaloEleId_L1R",141956,144114);
124 hltmod->AddTrigger("HLT_Mu9&HLT_Ele17_SW_CaloEleId_L1R",146428,147116);
125
126 hltmod->AddTrigger("HLT_Mu15_v1",147196,999999);
127 hltmod->AddTrigger("HLT_Mu15_v1&HLT_Ele17_SW_TightEleId_L1R",147196,148058);
128 hltmod->AddTrigger("HLT_Mu15_v1&HLT_Ele17_SW_TighterEleIdIsol_L1R_v2",148819,149064);
129 hltmod->AddTrigger("HLT_Mu15_v1&HLT_Ele17_SW_TighterEleIdIsol_L1R_v3",149181,999999);
130 }
131 else {
132 hltmod->AddTrigger("!HLT_Mu9&HLT_Ele10_LW_L1R",136033,139980);
133 hltmod->AddTrigger("!HLT_Mu9&HLT_Ele15_SW_L1R",140058,141882);
134 hltmod->AddTrigger("!HLT_Mu9&HLT_Ele15_SW_CaloEleId_L1R",141956,144114);
135 hltmod->AddTrigger("!HLT_Mu9&HLT_Ele17_SW_CaloEleId_L1R",146428,147116);
136
137 hltmod->AddTrigger("!HLT_Mu15_v1&HLT_Ele17_SW_TightEleId_L1R",147196,148058);
138 hltmod->AddTrigger("!HLT_Mu15_v1&HLT_Ele17_SW_TighterEleIdIsol_L1R_v2",148819,149064);
139 hltmod->AddTrigger("!HLT_Mu15_v1&HLT_Ele17_SW_TighterEleIdIsol_L1R_v3",149181,999999);
140 }
141 hltmod->SetTrigObjsName("myhltobjs");
142
143 //------------------------------------------------------------------------------------------------
144 // publisher Mod
145 //------------------------------------------------------------------------------------------------
146 PublisherMod<PFJet,Jet> *pubJet = new PublisherMod<PFJet,Jet>("JetPub");
147 pubJet->SetInputName("AKt5PFJets");
148 pubJet->SetOutputName("PubAKt5PFJets");
149
150 PublisherMod<Met,Met> *pubMet = new PublisherMod<Met,Met>("MetPub");
151 pubMet->SetInputName("TCMet");
152 pubMet->SetOutputName("PubTCMet");
153
154 PublisherMod<CaloMet> *pubCaloMet = new PublisherMod<CaloMet>;
155 pubCaloMet->SetName("CaloMetPub");
156 pubCaloMet->SetInputName("CorMuonMet");
157 pubCaloMet->SetOutputName("pubCaloMet");
158
159 //------------------------------------------------------------------------------------------------
160 // Apply Jet Corrections
161 //------------------------------------------------------------------------------------------------
162 JetCorrectionMod *jetCorr = new JetCorrectionMod;
163 jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_3_9_7/src/MitPhysics/data/START38_V13_AK5PF_L2Relative.txt");
164 jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_3_9_7/src/MitPhysics/data/START38_V13_AK5PF_L3Absolute.txt");
165 if(isData == true){
166 jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_3_9_7/src/MitPhysics/data/START38_V13_AK5PF_L2L3Residual.txt");
167 }
168 jetCorr->SetInputName(pubJet->GetOutputName());
169 jetCorr->SetCorrectedName("CorrectedJets");
170
171 //------------------------------------------------------------------------------------------------
172 // Apply Met Corrections
173 //------------------------------------------------------------------------------------------------
174 CaloMetCorrectionMod *metCaloCorr = new CaloMetCorrectionMod;
175 metCaloCorr->SetInputName(pubCaloMet->GetOutputName());
176 metCaloCorr->SetCorrectedJetsName(jetCorr->GetOutputName());
177 metCaloCorr->SetOutputName("pubCaloCorrectedMet");
178
179 //------------------------------------------------------------------------------------------------
180 // object id and cleaning sequence
181 //------------------------------------------------------------------------------------------------
182 MuonIDMod *muonID = new MuonIDMod;
183 muonID->SetClassType("Global");
184 muonID->SetIDType("WWMuId");
185 muonID->SetIsoType("TrackCaloSliding");
186 muonID->SetApplyD0Cut(kTRUE);
187
188 ElectronIDMod *electronID = new ElectronIDMod;
189 electronID->SetIDType("VBTFWorkingPoint80Id");
190 electronID->SetIsoType("TrackJuraSliding");
191 electronID->SetApplyConversionFilterType1(kFALSE);
192 electronID->SetApplyConversionFilterType2(kTRUE);
193 electronID->SetChargeFilter(kFALSE);
194 electronID->SetApplyD0Cut(kTRUE);
195 electronID->SetNExpectedHitsInnerCut(0);
196
197 // Object ID and Cleaning Sequence
198 PhotonIDMod *photonID = new PhotonIDMod;
199 TauIDMod *tauID = new TauIDMod;
200 JetIDMod *jetID = new JetIDMod;
201 jetID->SetInputName(jetCorr->GetOutputName());
202 jetID->SetPtCut(25.0);
203 jetID->SetEtaMaxCut(5.0);
204 jetID->SetJetEEMFractionMinCut(0.0);
205 jetID->SetOutputName("GoodJets");
206
207 ElectronCleaningMod *electronCleaning = new ElectronCleaningMod;
208 PhotonCleaningMod *photonCleaning = new PhotonCleaningMod;
209 TauCleaningMod *tauCleaning = new TauCleaningMod;
210 JetCleaningMod *jetCleaning = new JetCleaningMod;
211 jetCleaning->SetGoodJetsName("GoodJets");
212 jetCleaning->SetCleanJetsName("CleanJets");
213
214 JetIDMod *jetIDNoPtCut = new JetIDMod;
215 jetIDNoPtCut->SetInputName(jetCorr->GetOutputName());
216 jetIDNoPtCut->SetPtCut(0.0);
217 jetIDNoPtCut->SetEtaMaxCut(5.0);
218 jetIDNoPtCut->SetJetEEMFractionMinCut(0.0);
219 jetIDNoPtCut->SetOutputName("GoodJetsNoPtCut");
220
221 JetCleaningMod *jetCleaningNoPtCut = new JetCleaningMod;
222 jetCleaningNoPtCut->SetGoodJetsName("GoodJetsNoPtCut");
223 jetCleaningNoPtCut->SetCleanJetsName("CleanJetsNoPtCut");
224
225 //------------------------------------------------------------------------------------------------
226 // merge modules
227 //------------------------------------------------------------------------------------------------
228 MergeLeptonsMod *mergeLeptonsMod = new MergeLeptonsMod;
229 mergeLeptonsMod->SetMuonsName(muonID->GetOutputName());
230 mergeLeptonsMod->SetElectronsName(electronCleaning->GetOutputName());
231
232 //------------------------------------------------------------------------------------------------
233 // analyses modules
234 //------------------------------------------------------------------------------------------------
235 HwwExampleAnalysisMod *WWanalysisMod = new HwwExampleAnalysisMod;
236 WWanalysisMod->SetMetName(pubMet->GetOutputName());
237 WWanalysisMod->SetCleanJetsName(jetCleaning->GetOutputName());
238 WWanalysisMod->SetCleanJetsNoPtCutName(jetCleaningNoPtCut->GetOutputName());
239
240 WBFExampleAnalysisMod *WBFanalysisMod = new WBFExampleAnalysisMod;
241 WBFanalysisMod->SetMetName(pubMet->GetOutputName());
242 WBFanalysisMod->SetCleanJetsName(jetCleaning->GetOutputName());
243
244 //------------------------------------------------------------------------------------------------
245 // making analysis chain
246 //------------------------------------------------------------------------------------------------
247 generatorMod->Add(hKFactorProducer);
248 hKFactorProducer->Add(runLumiSelectionMod);
249 runLumiSelectionMod->Add(goodPVFilterMod);
250 goodPVFilterMod->Add(hltmod);
251 hltmod->Add(muonID);
252 muonID->Add(electronID);
253 electronID->Add(photonID);
254 photonID->Add(tauID);
255 tauID->Add(pubJet);
256 pubJet->Add(pubMet);
257 pubMet->Add(pubCaloMet);
258 pubCaloMet->Add(jetCorr);
259 jetCorr->Add(metCaloCorr);
260 metCaloCorr->Add(jetID);
261 jetID->Add(electronCleaning);
262 electronCleaning->Add(photonCleaning);
263 photonCleaning->Add(tauCleaning);
264 tauCleaning->Add(jetCleaning);
265 jetCleaning->Add(jetIDNoPtCut);
266 jetIDNoPtCut->Add(jetCleaningNoPtCut);
267 jetCleaningNoPtCut->Add(mergeLeptonsMod);
268 mergeLeptonsMod->Add(WWanalysisMod);
269 WWanalysisMod->Add(WBFanalysisMod);
270
271 //------------------------------------------------------------------------------------------------
272 // setup analysis
273 //------------------------------------------------------------------------------------------------
274 Analysis *ana = new Analysis;
275 ana->SetUseHLT(kTRUE);
276 ana->SetKeepHierarchy(kFALSE);
277 if (nEvents >= 0)
278 ana->SetProcessNEvents(nEvents);
279 ana->SetSuperModule(generatorMod);
280 ana->SetPrintScale(100);
281
282 //------------------------------------------------------------------------------------------------
283 // organize input
284 //------------------------------------------------------------------------------------------------
285 printf("\nRely on Catalog: %s\n",catalogDir);
286 printf(" -> Book: %s Dataset: %s Skim: %s Fileset: %s <-\n\n",book,dataset,skim,fileset);
287 Catalog *c = new Catalog(catalogDir);
288 TString skimdataset = TString(dataset)+TString("/") +TString(skim);
289 Dataset *d = NULL;
290 if (TString(skim).CompareTo("noskim") == 0)
291 d = c->FindDataset(book,dataset,fileset);
292 else
293 d = c->FindDataset(book,skimdataset.Data(),fileset);
294 ana->AddDataset(d);
295
296 //------------------------------------------------------------------------------------------------
297 // organize output
298 //------------------------------------------------------------------------------------------------
299 TString rootFile = TString(outputName);
300 rootFile += TString("_") + TString(dataset) + TString("_") + TString(skim);
301 if (TString(fileset) != TString(""))
302 rootFile += TString("_") + TString(fileset);
303 rootFile += TString(".root");
304 printf("\nRoot output: %s\n\n",rootFile.Data());
305 ana->SetOutputName(rootFile.Data());
306 ana->SetCacheSize(64*1024*1024);
307
308 //------------------------------------------------------------------------------------------------
309 // run the analysis after successful initialisation
310 //------------------------------------------------------------------------------------------------
311 ana->Run(!gROOT->IsBatch());
312
313 return;
314 }