ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runPhysicsExample.C
Revision: 1.14
Committed: Wed Apr 20 13:00:21 2011 UTC (14 years ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_021pre1
Changes since 1.13: +66 -63 lines
Log Message:
new default analysis macro

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.14 // $Id: runPhysicsExample.C,v 1.13 2010/12/22 20:20:40 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     const char *dataset = "p11-h160ww2l-gf-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.14 TString fInputFilenameKF = "/home/ceballos/releases/CMSSW_4_1_3_patch2/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.14 runLumiSelectionMod->AddJSONFile("/home/ceballos/releases/CMSSW_4_1_3_patch2/src/json/json_DCSONLY_ManualCert.txt"); // L = 23.2
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.4 hltmod->AddTrigger("HLT_Mu9");
128 ceballos 1.7 hltmod->AddTrigger("!HLT_Mu9");
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     hltmod->AddTrigger("HLT_Mu17_Ele8_CaloIdL_v2",161179,999999);
134     hltmod->AddTrigger("HLT_Mu8_Ele17_CaloIdL_v2",161179,999999);
135     }
136     else if(isData == true && isDataDMuon == true) {
137     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v1&!HLT_Mu17_Ele8_CaloIdL_v1&HLT_DoubleMu7_v1",150000,161176);
138     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v2&!HLT_Mu17_Ele8_CaloIdL_v2&HLT_DoubleMu7_v1",161179,999999);
139     }
140     else if(isData == true && isDataSMuon == true) {
141     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v1&!HLT_Mu17_Ele8_CaloIdL_v1&!HLT_DoubleMu7_v1&HLT_Mu15_v2",150000,161176);
142     hltmod->AddTrigger("!HLT_Mu8_Ele17_CaloIdL_v2&!HLT_Mu17_Ele8_CaloIdL_v2&!HLT_DoubleMu7_v1&HLT_Mu15_v2",161179,999999);
143     }
144     else if(isData == true && isDataDElectron == true) {
145     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);
146     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,999999);
147 ceballos 1.5 }
148 ceballos 1.14 else if(isData == true && isDataSElectron == true) {
149     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);
150     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,999999);
151 bendavid 1.1 }
152     hltmod->SetTrigObjsName("myhltobjs");
153    
154     //------------------------------------------------------------------------------------------------
155     // publisher Mod
156     //------------------------------------------------------------------------------------------------
157 ceballos 1.5 PublisherMod<PFJet,Jet> *pubJet = new PublisherMod<PFJet,Jet>("JetPub");
158     pubJet->SetInputName("AKt5PFJets");
159     pubJet->SetOutputName("PubAKt5PFJets");
160 bendavid 1.1
161 ceballos 1.14 PublisherMod<PFMet,Met> *pubMet = new PublisherMod<PFMet,Met>("MetPub");
162     pubMet->SetInputName("PFMet");
163     pubMet->SetOutputName("PubPFMet");
164 ceballos 1.4
165 bendavid 1.1 //------------------------------------------------------------------------------------------------
166 ceballos 1.4 // Apply Jet Corrections
167 bendavid 1.1 //------------------------------------------------------------------------------------------------
168 bendavid 1.3 JetCorrectionMod *jetCorr = new JetCorrectionMod;
169 ceballos 1.14 jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_4_1_3_patch2/src/MitPhysics/data/START38_V13_AK5PF_L2Relative.txt");
170     jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_4_1_3_patch2/src/MitPhysics/data/START38_V13_AK5PF_L3Absolute.txt");
171 ceballos 1.12 if(isData == true){
172 ceballos 1.14 jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_4_1_3_patch2/src/MitPhysics/data/START38_V13_AK5PF_L2L3Residual.txt");
173 ceballos 1.12 }
174 bendavid 1.1 jetCorr->SetInputName(pubJet->GetOutputName());
175 ceballos 1.14 jetCorr->ApplyL1FastJetCorrection(5.0);
176 ceballos 1.4 jetCorr->SetCorrectedName("CorrectedJets");
177 bendavid 1.1
178 ceballos 1.4 //------------------------------------------------------------------------------------------------
179 bendavid 1.1 // object id and cleaning sequence
180     //------------------------------------------------------------------------------------------------
181 ceballos 1.14 MuonIDMod *muonID = new MuonIDMod;
182 ceballos 1.5 muonID->SetClassType("Global");
183 ceballos 1.11 muonID->SetIDType("WWMuId");
184 ceballos 1.14 muonID->SetIsoType("TrackCaloSlidingNoCorrection");
185 ceballos 1.5 muonID->SetApplyD0Cut(kTRUE);
186 ceballos 1.14 muonID->SetApplyDZCut(kTRUE);
187     muonID->SetWhichVertex(0);
188 ceballos 1.5
189 ceballos 1.14 ElectronIDMod *electronID = new ElectronIDMod;
190     electronID->SetIDType("VBTFWorkingPointLowPtId");
191     electronID->SetIsoType("TrackJuraSlidingNoCorrection");
192     electronID->SetApplyConversionFilterType1(kTRUE);
193     electronID->SetApplyConversionFilterType2(kFALSE);
194 ceballos 1.5 electronID->SetChargeFilter(kFALSE);
195     electronID->SetApplyD0Cut(kTRUE);
196 ceballos 1.14 electronID->SetApplyDZCut(kTRUE);
197     electronID->SetWhichVertex(0);
198 ceballos 1.5 electronID->SetNExpectedHitsInnerCut(0);
199    
200 ceballos 1.11 // Object ID and Cleaning Sequence
201 ceballos 1.4 PhotonIDMod *photonID = new PhotonIDMod;
202     TauIDMod *tauID = new TauIDMod;
203     JetIDMod *jetID = new JetIDMod;
204     jetID->SetInputName(jetCorr->GetOutputName());
205 ceballos 1.14 jetID->SetPtCut(30.0);
206 bendavid 1.1 jetID->SetEtaMaxCut(5.0);
207 ceballos 1.5 jetID->SetJetEEMFractionMinCut(0.0);
208 ceballos 1.4 jetID->SetOutputName("GoodJets");
209 ceballos 1.14 jetID->SetApplyBetaCut(kFALSE);
210 ceballos 1.4
211 bendavid 1.1 ElectronCleaningMod *electronCleaning = new ElectronCleaningMod;
212     PhotonCleaningMod *photonCleaning = new PhotonCleaningMod;
213     TauCleaningMod *tauCleaning = new TauCleaningMod;
214     JetCleaningMod *jetCleaning = new JetCleaningMod;
215 ceballos 1.4 jetCleaning->SetGoodJetsName("GoodJets");
216     jetCleaning->SetCleanJetsName("CleanJets");
217 bendavid 1.1
218 ceballos 1.7 JetIDMod *jetIDNoPtCut = new JetIDMod;
219     jetIDNoPtCut->SetInputName(jetCorr->GetOutputName());
220     jetIDNoPtCut->SetPtCut(0.0);
221     jetIDNoPtCut->SetEtaMaxCut(5.0);
222     jetIDNoPtCut->SetJetEEMFractionMinCut(0.0);
223     jetIDNoPtCut->SetOutputName("GoodJetsNoPtCut");
224 ceballos 1.14 jetIDNoPtCut->SetApplyBetaCut(kFALSE);
225 ceballos 1.7
226     JetCleaningMod *jetCleaningNoPtCut = new JetCleaningMod;
227     jetCleaningNoPtCut->SetGoodJetsName("GoodJetsNoPtCut");
228     jetCleaningNoPtCut->SetCleanJetsName("CleanJetsNoPtCut");
229    
230 bendavid 1.1 //------------------------------------------------------------------------------------------------
231     // merge modules
232     //------------------------------------------------------------------------------------------------
233     MergeLeptonsMod *mergeLeptonsMod = new MergeLeptonsMod;
234     mergeLeptonsMod->SetMuonsName(muonID->GetOutputName());
235     mergeLeptonsMod->SetElectronsName(electronCleaning->GetOutputName());
236    
237     //------------------------------------------------------------------------------------------------
238     // analyses modules
239     //------------------------------------------------------------------------------------------------
240 ceballos 1.13 HwwExampleAnalysisMod *WWanalysisMod = new HwwExampleAnalysisMod;
241     WWanalysisMod->SetMetName(pubMet->GetOutputName());
242     WWanalysisMod->SetCleanJetsName(jetCleaning->GetOutputName());
243     WWanalysisMod->SetCleanJetsNoPtCutName(jetCleaningNoPtCut->GetOutputName());
244    
245     WBFExampleAnalysisMod *WBFanalysisMod = new WBFExampleAnalysisMod;
246     WBFanalysisMod->SetMetName(pubMet->GetOutputName());
247     WBFanalysisMod->SetCleanJetsName(jetCleaning->GetOutputName());
248 bendavid 1.1
249     //------------------------------------------------------------------------------------------------
250     // making analysis chain
251     //------------------------------------------------------------------------------------------------
252 ceballos 1.5 generatorMod->Add(hKFactorProducer);
253     hKFactorProducer->Add(runLumiSelectionMod);
254     runLumiSelectionMod->Add(goodPVFilterMod);
255     goodPVFilterMod->Add(hltmod);
256 ceballos 1.4 hltmod->Add(muonID);
257 bendavid 1.1 muonID->Add(electronID);
258     electronID->Add(photonID);
259     photonID->Add(tauID);
260     tauID->Add(pubJet);
261 bendavid 1.3 pubJet->Add(pubMet);
262 ceballos 1.14 pubMet->Add(jetCorr);
263     jetCorr->Add(jetID);
264 bendavid 1.1 jetID->Add(electronCleaning);
265     electronCleaning->Add(photonCleaning);
266     photonCleaning->Add(tauCleaning);
267     tauCleaning->Add(jetCleaning);
268 ceballos 1.7 jetCleaning->Add(jetIDNoPtCut);
269     jetIDNoPtCut->Add(jetCleaningNoPtCut);
270     jetCleaningNoPtCut->Add(mergeLeptonsMod);
271 ceballos 1.13 mergeLeptonsMod->Add(WWanalysisMod);
272     WWanalysisMod->Add(WBFanalysisMod);
273 bendavid 1.1
274     //------------------------------------------------------------------------------------------------
275     // setup analysis
276     //------------------------------------------------------------------------------------------------
277     Analysis *ana = new Analysis;
278 ceballos 1.4 ana->SetUseHLT(kTRUE);
279     ana->SetKeepHierarchy(kFALSE);
280 bendavid 1.1 if (nEvents >= 0)
281     ana->SetProcessNEvents(nEvents);
282     ana->SetSuperModule(generatorMod);
283 ceballos 1.4 ana->SetPrintScale(100);
284 bendavid 1.1
285     //------------------------------------------------------------------------------------------------
286     // organize input
287     //------------------------------------------------------------------------------------------------
288     printf("\nRely on Catalog: %s\n",catalogDir);
289     printf(" -> Book: %s Dataset: %s Skim: %s Fileset: %s <-\n\n",book,dataset,skim,fileset);
290     Catalog *c = new Catalog(catalogDir);
291     TString skimdataset = TString(dataset)+TString("/") +TString(skim);
292     Dataset *d = NULL;
293     if (TString(skim).CompareTo("noskim") == 0)
294     d = c->FindDataset(book,dataset,fileset);
295     else
296     d = c->FindDataset(book,skimdataset.Data(),fileset);
297 bendavid 1.2 ana->AddDataset(d);
298 bendavid 1.1
299     //------------------------------------------------------------------------------------------------
300     // organize output
301     //------------------------------------------------------------------------------------------------
302     TString rootFile = TString(outputName);
303     rootFile += TString("_") + TString(dataset) + TString("_") + TString(skim);
304     if (TString(fileset) != TString(""))
305     rootFile += TString("_") + TString(fileset);
306     rootFile += TString(".root");
307     printf("\nRoot output: %s\n\n",rootFile.Data());
308     ana->SetOutputName(rootFile.Data());
309 ceballos 1.5 ana->SetCacheSize(64*1024*1024);
310 bendavid 1.1
311     //------------------------------------------------------------------------------------------------
312     // run the analysis after successful initialisation
313     //------------------------------------------------------------------------------------------------
314     ana->Run(!gROOT->IsBatch());
315    
316     return;
317     }