ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runPhysicsExample.C
Revision: 1.6
Committed: Tue Oct 5 06:50:20 2010 UTC (14 years, 7 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_015b, Mit_015a, Mit_015
Changes since 1.5: +1 -2 lines
Log Message:
small update

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.6 // $Id: runPhysicsExample.C,v 1.5 2010/10/05 06:37:16 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.5 void runPhysicsExample(const char *catalogDir = "/home/ceballos/catalog",
39     const char *book = "cern/filler/014a",
40     const char *dataset = "p10-ww2l-v26",
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.5 int nEvents = 10000)
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     TString fInputFilenameKF = "/home/ceballos/releases/CMSSW_3_8_4/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     runLumiSelectionMod->AddJSONFile("/home/ceballos/releases/CMSSW_3_8_4/src/json/Cert_132440-144114_7TeV_StreamExpress_Collisions10_JSON.txt");
99    
100     //------------------------------------------------------------------------------------------------
101     // PV filter selection
102     //------------------------------------------------------------------------------------------------
103     GoodPVFilterMod *goodPVFilterMod = new GoodPVFilterMod;
104     goodPVFilterMod->SetMinVertexNTracks(0);
105     goodPVFilterMod->SetMinNDof(5);
106     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.5 if (isData == kFALSE){
114 ceballos 1.4 hltmod->AddTrigger("HLT_Mu9");
115 ceballos 1.5 hltmod->AddTrigger("HLT_Photon10_L1R",132440,137028);
116     hltmod->AddTrigger("HLT_Photon15_Cleaned_L1R",138564,140401);
117     hltmod->AddTrigger("HLT_Ele15_SW_CaloEleId_L1R",141956,999999);
118     hltmod->AddTrigger("HLT_Ele15_LW_L1R",1,1);
119     }
120     else if(isElData == kFALSE){
121 ceballos 1.4 hltmod->AddTrigger("HLT_Mu9");
122 ceballos 1.5 hltmod->AddTrigger("HLT_Mu9&HLT_Photon10_L1R",132440,137028);
123     hltmod->AddTrigger("HLT_Mu9&HLT_Photon15_Cleaned_L1R",138564,140401);
124     hltmod->AddTrigger("HLT_Mu9&HLT_Ele15_SW_CaloEleId_L1R",141956,999999);
125     hltmod->AddTrigger("HLT_Mu9&HLT_Ele15_LW_L1R",1,1);
126     }
127     else {
128     hltmod->AddTrigger("!HLT_Mu9&HLT_Photon10_L1R",132440,137028);
129     hltmod->AddTrigger("!HLT_Mu9&HLT_Photon15_Cleaned_L1R",138564,140401);
130     hltmod->AddTrigger("!HLT_Mu9&HLT_Ele15_SW_CaloEleId_L1R",141956,999999);
131     hltmod->AddTrigger("!HLT_Mu9&HLT_Ele15_LW_L1R",1,1);
132 bendavid 1.1 }
133     hltmod->SetTrigObjsName("myhltobjs");
134    
135     //------------------------------------------------------------------------------------------------
136     // publisher Mod
137     //------------------------------------------------------------------------------------------------
138 ceballos 1.5 PublisherMod<PFJet,Jet> *pubJet = new PublisherMod<PFJet,Jet>("JetPub");
139     pubJet->SetInputName("AKt5PFJets");
140     pubJet->SetOutputName("PubAKt5PFJets");
141 bendavid 1.1
142     PublisherMod<Met,Met> *pubMet = new PublisherMod<Met,Met>("MetPub");
143     pubMet->SetInputName("TCMet");
144     pubMet->SetOutputName("PubTCMet");
145    
146 ceballos 1.4 PublisherMod<CaloMet> *pubCaloMet = new PublisherMod<CaloMet>;
147     pubCaloMet->SetName("CaloMetPub");
148     pubCaloMet->SetInputName("CorMuonMet");
149     pubCaloMet->SetOutputName("pubCaloMet");
150    
151 bendavid 1.1 //------------------------------------------------------------------------------------------------
152 ceballos 1.4 // Apply Jet Corrections
153 bendavid 1.1 //------------------------------------------------------------------------------------------------
154 bendavid 1.3 JetCorrectionMod *jetCorr = new JetCorrectionMod;
155 ceballos 1.5 jetCorr->AddCorrectionFromRelease("CondFormats/JetMETObjects/data/Spring10_L2Relative_AK5PF.txt");
156     jetCorr->AddCorrectionFromRelease("CondFormats/JetMETObjects/data/Spring10_L3Absolute_AK5PF.txt");
157 bendavid 1.1 jetCorr->SetInputName(pubJet->GetOutputName());
158 ceballos 1.4 jetCorr->SetCorrectedName("CorrectedJets");
159 bendavid 1.1
160 ceballos 1.4 //------------------------------------------------------------------------------------------------
161     // Apply Met Corrections
162     //------------------------------------------------------------------------------------------------
163     CaloMetCorrectionMod *metCaloCorr = new CaloMetCorrectionMod;
164     metCaloCorr->SetInputName(pubCaloMet->GetOutputName());
165     metCaloCorr->SetCorrectedJetsName(jetCorr->GetOutputName());
166     metCaloCorr->SetOutputName("pubCaloCorrectedMet");
167 bendavid 1.1
168     //------------------------------------------------------------------------------------------------
169     // object id and cleaning sequence
170     //------------------------------------------------------------------------------------------------
171 ceballos 1.4 MuonIDMod *muonID = new MuonIDMod;
172 ceballos 1.5 muonID->SetClassType("Global");
173     muonID->SetIDType("Minimal");
174     muonID->SetIsoType("TrackCaloSliding");
175     muonID->SetApplyD0Cut(kTRUE);
176    
177 ceballos 1.4 ElectronIDMod *electronID = new ElectronIDMod;
178 ceballos 1.5 electronID->SetIDType("VBTFWorkingPoint80Id");
179     electronID->SetIsoType("TrackJuraSliding");
180     electronID->SetApplyConversionFilterType1(kFALSE);
181     electronID->SetApplyConversionFilterType2(kTRUE);
182     electronID->SetChargeFilter(kFALSE);
183     electronID->SetApplyD0Cut(kTRUE);
184     electronID->SetNExpectedHitsInnerCut(0);
185    
186 ceballos 1.4 PhotonIDMod *photonID = new PhotonIDMod;
187     TauIDMod *tauID = new TauIDMod;
188     JetIDMod *jetID = new JetIDMod;
189     jetID->SetInputName(jetCorr->GetOutputName());
190 ceballos 1.5 jetID->SetPtCut(25.0);
191 bendavid 1.1 jetID->SetEtaMaxCut(5.0);
192 ceballos 1.5 jetID->SetJetEEMFractionMinCut(0.0);
193 ceballos 1.4 jetID->SetOutputName("GoodJets");
194    
195 bendavid 1.1 ElectronCleaningMod *electronCleaning = new ElectronCleaningMod;
196     PhotonCleaningMod *photonCleaning = new PhotonCleaningMod;
197     TauCleaningMod *tauCleaning = new TauCleaningMod;
198     JetCleaningMod *jetCleaning = new JetCleaningMod;
199 ceballos 1.4 jetCleaning->SetGoodJetsName("GoodJets");
200     jetCleaning->SetCleanJetsName("CleanJets");
201 bendavid 1.1
202     //------------------------------------------------------------------------------------------------
203     // merge modules
204     //------------------------------------------------------------------------------------------------
205     MergeLeptonsMod *mergeLeptonsMod = new MergeLeptonsMod;
206     mergeLeptonsMod->SetMuonsName(muonID->GetOutputName());
207     mergeLeptonsMod->SetElectronsName(electronCleaning->GetOutputName());
208    
209     //------------------------------------------------------------------------------------------------
210     // analyses modules
211     //------------------------------------------------------------------------------------------------
212 ceballos 1.5 HwwExampleAnalysisMod *analysisMod = new HwwExampleAnalysisMod;
213     analysisMod->SetMetName(pubMet->GetOutputName());
214     analysisMod->SetCleanJetsName(jetCleaning->GetOutputName());
215 bendavid 1.1
216     //------------------------------------------------------------------------------------------------
217     // making analysis chain
218     //------------------------------------------------------------------------------------------------
219 ceballos 1.5 generatorMod->Add(hKFactorProducer);
220     hKFactorProducer->Add(runLumiSelectionMod);
221     runLumiSelectionMod->Add(goodPVFilterMod);
222     goodPVFilterMod->Add(hltmod);
223 ceballos 1.4 hltmod->Add(muonID);
224 bendavid 1.1 muonID->Add(electronID);
225     electronID->Add(photonID);
226     photonID->Add(tauID);
227     tauID->Add(pubJet);
228 bendavid 1.3 pubJet->Add(pubMet);
229 ceballos 1.4 pubMet->Add(pubCaloMet);
230     pubCaloMet->Add(jetCorr);
231     jetCorr->Add(metCaloCorr);
232     metCaloCorr->Add(jetID);
233 bendavid 1.1 jetID->Add(electronCleaning);
234     electronCleaning->Add(photonCleaning);
235     photonCleaning->Add(tauCleaning);
236     tauCleaning->Add(jetCleaning);
237     jetCleaning->Add(mergeLeptonsMod);
238     mergeLeptonsMod->Add(analysisMod);
239    
240     //------------------------------------------------------------------------------------------------
241     // setup analysis
242     //------------------------------------------------------------------------------------------------
243     Analysis *ana = new Analysis;
244 ceballos 1.4 ana->SetUseHLT(kTRUE);
245     ana->SetKeepHierarchy(kFALSE);
246 bendavid 1.1 if (nEvents >= 0)
247     ana->SetProcessNEvents(nEvents);
248     ana->SetSuperModule(generatorMod);
249 ceballos 1.4 ana->SetPrintScale(100);
250 bendavid 1.1
251     //------------------------------------------------------------------------------------------------
252     // organize input
253     //------------------------------------------------------------------------------------------------
254     printf("\nRely on Catalog: %s\n",catalogDir);
255     printf(" -> Book: %s Dataset: %s Skim: %s Fileset: %s <-\n\n",book,dataset,skim,fileset);
256     Catalog *c = new Catalog(catalogDir);
257     TString skimdataset = TString(dataset)+TString("/") +TString(skim);
258     Dataset *d = NULL;
259     if (TString(skim).CompareTo("noskim") == 0)
260     d = c->FindDataset(book,dataset,fileset);
261     else
262     d = c->FindDataset(book,skimdataset.Data(),fileset);
263 bendavid 1.2 ana->AddDataset(d);
264 bendavid 1.1
265     //------------------------------------------------------------------------------------------------
266     // organize output
267     //------------------------------------------------------------------------------------------------
268     TString rootFile = TString(outputName);
269     rootFile += TString("_") + TString(dataset) + TString("_") + TString(skim);
270     if (TString(fileset) != TString(""))
271     rootFile += TString("_") + TString(fileset);
272     rootFile += TString(".root");
273     printf("\nRoot output: %s\n\n",rootFile.Data());
274     ana->SetOutputName(rootFile.Data());
275 ceballos 1.5 ana->SetCacheSize(64*1024*1024);
276 bendavid 1.1
277     //------------------------------------------------------------------------------------------------
278     // run the analysis after successful initialisation
279     //------------------------------------------------------------------------------------------------
280     ana->Run(!gROOT->IsBatch());
281    
282     return;
283     }