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

# 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.13 // $Id: runPhysicsExample.C,v 1.12 2010/11/17 19:38:29 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     #include "MitAna/DataTree/interface/CaloMetCol.h"
34 ceballos 1.5 #include "MitPhysics/SelMods/interface/HwwExampleAnalysisMod.h"
35 ceballos 1.13 #include "MitPhysics/SelMods/interface/WBFExampleAnalysisMod.h"
36 bendavid 1.1 #endif
37    
38     //--------------------------------------------------------------------------------------------------
39 ceballos 1.11 void runPhysicsExample(const char *catalogDir = "/home/ceballos/catalog",
40     const char *book = "cern/filler/015",
41 ceballos 1.13 const char *dataset = "f10-h150ww2l-wbf-z2-v12",
42 ceballos 1.4 const char *fileset = "0000",
43     const char *skim = "noskim",
44     const char *outputName = "histo",
45     int sampleID = -1,
46 ceballos 1.13 int nEvents = 10000)
47 bendavid 1.1 {
48     //------------------------------------------------------------------------------------------------
49     // some global setups
50     //------------------------------------------------------------------------------------------------
51     using namespace mithep;
52     gDebugMask = Debug::kAnalysis;
53 ceballos 1.5 gDebugLevel = 3;
54 bendavid 1.1
55     //------------------------------------------------------------------------------------------------
56     // set up information
57     //------------------------------------------------------------------------------------------------
58 ceballos 1.4 Bool_t applyISRFilter = kFALSE;
59     Bool_t applyMllGenCut = kFALSE;
60     Bool_t isData = kFALSE;
61 ceballos 1.5 Bool_t isElData = kFALSE;
62     int processId = -999999999; // use 999 for MCatNLO MC sample, 102 for H->WW
63 ceballos 1.13 TString fInputFilenameKF = "/home/ceballos/releases/CMSSW_3_9_7/src/MitPhysics/data/HWW_KFactors_160_10TeV.dat";
64 bendavid 1.1
65 ceballos 1.5 if(sampleID > 1000) isData = kTRUE;
66     if(sampleID > 2000) isElData = kTRUE;
67 ceballos 1.4
68 bendavid 1.1 //------------------------------------------------------------------------------------------------
69     // generator information
70     //------------------------------------------------------------------------------------------------
71     GeneratorMod *generatorMod = new GeneratorMod;
72 ceballos 1.4 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 ceballos 1.5 generatorMod->SetMassMinCut( 0.);
84 ceballos 1.4 generatorMod->SetMassMaxCut(50.);
85     }
86     generatorMod->SetApplyISRFilter(applyISRFilter);
87 bendavid 1.1
88 ceballos 1.5 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 ceballos 1.13 runLumiSelectionMod->AddJSONFile("/home/ceballos/releases/CMSSW_3_9_7/src/json/merged_JsonReRecoSep17_JsonStreamExpressV2.txt");
100 ceballos 1.5
101     //------------------------------------------------------------------------------------------------
102     // PV filter selection
103     //------------------------------------------------------------------------------------------------
104     GoodPVFilterMod *goodPVFilterMod = new GoodPVFilterMod;
105     goodPVFilterMod->SetMinVertexNTracks(0);
106 ceballos 1.9 goodPVFilterMod->SetMinNDof(4);
107 ceballos 1.5 goodPVFilterMod->SetMaxAbsZ(24.0);
108     goodPVFilterMod->SetMaxRho(2.0);
109    
110 bendavid 1.1 //------------------------------------------------------------------------------------------------
111     // HLT information
112     //------------------------------------------------------------------------------------------------
113     HLTMod *hltmod = new HLTMod;
114 ceballos 1.10
115 ceballos 1.5 if (isData == kFALSE){
116 ceballos 1.4 hltmod->AddTrigger("HLT_Mu9");
117 ceballos 1.7 hltmod->AddTrigger("!HLT_Mu9");
118 ceballos 1.5 }
119     else if(isElData == kFALSE){
120 ceballos 1.10 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 ceballos 1.5 }
131     else {
132 ceballos 1.10 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 bendavid 1.1 }
141     hltmod->SetTrigObjsName("myhltobjs");
142    
143     //------------------------------------------------------------------------------------------------
144     // publisher Mod
145     //------------------------------------------------------------------------------------------------
146 ceballos 1.5 PublisherMod<PFJet,Jet> *pubJet = new PublisherMod<PFJet,Jet>("JetPub");
147     pubJet->SetInputName("AKt5PFJets");
148     pubJet->SetOutputName("PubAKt5PFJets");
149 bendavid 1.1
150     PublisherMod<Met,Met> *pubMet = new PublisherMod<Met,Met>("MetPub");
151     pubMet->SetInputName("TCMet");
152     pubMet->SetOutputName("PubTCMet");
153    
154 ceballos 1.4 PublisherMod<CaloMet> *pubCaloMet = new PublisherMod<CaloMet>;
155     pubCaloMet->SetName("CaloMetPub");
156     pubCaloMet->SetInputName("CorMuonMet");
157     pubCaloMet->SetOutputName("pubCaloMet");
158    
159 bendavid 1.1 //------------------------------------------------------------------------------------------------
160 ceballos 1.4 // Apply Jet Corrections
161 bendavid 1.1 //------------------------------------------------------------------------------------------------
162 bendavid 1.3 JetCorrectionMod *jetCorr = new JetCorrectionMod;
163 ceballos 1.13 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 ceballos 1.12 if(isData == true){
166 ceballos 1.13 jetCorr->AddCorrectionFromFile("/home/ceballos/releases/CMSSW_3_9_7/src/MitPhysics/data/START38_V13_AK5PF_L2L3Residual.txt");
167 ceballos 1.12 }
168 bendavid 1.1 jetCorr->SetInputName(pubJet->GetOutputName());
169 ceballos 1.4 jetCorr->SetCorrectedName("CorrectedJets");
170 bendavid 1.1
171 ceballos 1.4 //------------------------------------------------------------------------------------------------
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 bendavid 1.1
179     //------------------------------------------------------------------------------------------------
180     // object id and cleaning sequence
181     //------------------------------------------------------------------------------------------------
182 ceballos 1.4 MuonIDMod *muonID = new MuonIDMod;
183 ceballos 1.5 muonID->SetClassType("Global");
184 ceballos 1.11 muonID->SetIDType("WWMuId");
185 ceballos 1.5 muonID->SetIsoType("TrackCaloSliding");
186     muonID->SetApplyD0Cut(kTRUE);
187    
188 ceballos 1.4 ElectronIDMod *electronID = new ElectronIDMod;
189 ceballos 1.5 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 ceballos 1.11 // Object ID and Cleaning Sequence
198 ceballos 1.4 PhotonIDMod *photonID = new PhotonIDMod;
199     TauIDMod *tauID = new TauIDMod;
200     JetIDMod *jetID = new JetIDMod;
201     jetID->SetInputName(jetCorr->GetOutputName());
202 ceballos 1.5 jetID->SetPtCut(25.0);
203 bendavid 1.1 jetID->SetEtaMaxCut(5.0);
204 ceballos 1.5 jetID->SetJetEEMFractionMinCut(0.0);
205 ceballos 1.4 jetID->SetOutputName("GoodJets");
206    
207 bendavid 1.1 ElectronCleaningMod *electronCleaning = new ElectronCleaningMod;
208     PhotonCleaningMod *photonCleaning = new PhotonCleaningMod;
209     TauCleaningMod *tauCleaning = new TauCleaningMod;
210     JetCleaningMod *jetCleaning = new JetCleaningMod;
211 ceballos 1.4 jetCleaning->SetGoodJetsName("GoodJets");
212     jetCleaning->SetCleanJetsName("CleanJets");
213 bendavid 1.1
214 ceballos 1.7 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 bendavid 1.1 //------------------------------------------------------------------------------------------------
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 ceballos 1.13 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 bendavid 1.1
244     //------------------------------------------------------------------------------------------------
245     // making analysis chain
246     //------------------------------------------------------------------------------------------------
247 ceballos 1.5 generatorMod->Add(hKFactorProducer);
248     hKFactorProducer->Add(runLumiSelectionMod);
249     runLumiSelectionMod->Add(goodPVFilterMod);
250     goodPVFilterMod->Add(hltmod);
251 ceballos 1.4 hltmod->Add(muonID);
252 bendavid 1.1 muonID->Add(electronID);
253     electronID->Add(photonID);
254     photonID->Add(tauID);
255     tauID->Add(pubJet);
256 bendavid 1.3 pubJet->Add(pubMet);
257 ceballos 1.4 pubMet->Add(pubCaloMet);
258     pubCaloMet->Add(jetCorr);
259     jetCorr->Add(metCaloCorr);
260     metCaloCorr->Add(jetID);
261 bendavid 1.1 jetID->Add(electronCleaning);
262     electronCleaning->Add(photonCleaning);
263     photonCleaning->Add(tauCleaning);
264     tauCleaning->Add(jetCleaning);
265 ceballos 1.7 jetCleaning->Add(jetIDNoPtCut);
266     jetIDNoPtCut->Add(jetCleaningNoPtCut);
267     jetCleaningNoPtCut->Add(mergeLeptonsMod);
268 ceballos 1.13 mergeLeptonsMod->Add(WWanalysisMod);
269     WWanalysisMod->Add(WBFanalysisMod);
270 bendavid 1.1
271     //------------------------------------------------------------------------------------------------
272     // setup analysis
273     //------------------------------------------------------------------------------------------------
274     Analysis *ana = new Analysis;
275 ceballos 1.4 ana->SetUseHLT(kTRUE);
276     ana->SetKeepHierarchy(kFALSE);
277 bendavid 1.1 if (nEvents >= 0)
278     ana->SetProcessNEvents(nEvents);
279     ana->SetSuperModule(generatorMod);
280 ceballos 1.4 ana->SetPrintScale(100);
281 bendavid 1.1
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 bendavid 1.2 ana->AddDataset(d);
295 bendavid 1.1
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 ceballos 1.5 ana->SetCacheSize(64*1024*1024);
307 bendavid 1.1
308     //------------------------------------------------------------------------------------------------
309     // run the analysis after successful initialisation
310     //------------------------------------------------------------------------------------------------
311     ana->Run(!gROOT->IsBatch());
312    
313     return;
314     }