ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runPhysicsExample.C
Revision: 1.11
Committed: Thu Nov 11 21:27:00 2010 UTC (14 years, 5 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.10: +6 -5 lines
Log Message:
fixing m id

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