ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runPhysicsExample.C
Revision: 1.12
Committed: Wed Nov 17 19:38:29 2010 UTC (14 years, 5 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1
Changes since 1.11: +7 -4 lines
Log Message:
new xs

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