ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runPhysicsExample.C
Revision: 1.3
Committed: Mon May 10 16:17:02 2010 UTC (14 years, 11 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_014pre2, Mit_014pre1
Changes since 1.2: +16 -7 lines
Log Message:
Update with new Jet Correction syntax

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 bendavid 1.3 // $Id: runPhysicsExample.C,v 1.2 2010/03/15 14:20:56 bendavid 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     #include "MitPhysics/Mods/interface/GeneratorMod.h"
16     #include "MitPhysics/Mods/interface/PDFProducerMod.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/CaloJetCol.h"
32     #include "MitAna/DataTree/interface/MetCol.h"
33     #include "MitAna/DataTree/interface/CaloMetCol.h"
34     #include "MitAna/PhysicsMod/interface/FullExampleMod.h"
35     #endif
36    
37     //--------------------------------------------------------------------------------------------------
38     void executePhysicsExample(const char *fileset = "",
39     const char *skim = "",
40     const char *dataset = "",
41     const char *book = "",
42     const char *catalogDir = "",
43     const char *outputName = "",
44     int sampleID = -1,
45     int nEvents = -1)
46     {
47     //------------------------------------------------------------------------------------------------
48     // some global setups
49     //------------------------------------------------------------------------------------------------
50     using namespace mithep;
51     gDebugMask = Debug::kAnalysis;
52     gDebugLevel = 1;
53    
54     //------------------------------------------------------------------------------------------------
55     // set up information
56     //------------------------------------------------------------------------------------------------
57     Bool_t isFastSim = kFALSE;
58     if(sampleID >= 100) isFastSim = kTRUE;
59    
60     bool useHLTE29 = true;
61    
62 bendavid 1.3 // RunLumiSelectionMod *runLumiSelectionMod = new RunLumiSelectionMod;
63     // runLumiSelectionMod->SetAcceptMC(kTRUE);
64     // runLumiSelectionMod->AddJSONFile("Cert_132440-133511_StreamExpress_Commissioning10-Express_DQM_JSON.txt");
65    
66 bendavid 1.1 //------------------------------------------------------------------------------------------------
67     // generator information
68     //------------------------------------------------------------------------------------------------
69     GeneratorMod *generatorMod = new GeneratorMod;
70    
71     //------------------------------------------------------------------------------------------------
72     // HLT information
73     //------------------------------------------------------------------------------------------------
74     HLTMod *hltmod = new HLTMod;
75     if(useHLTE29 == false) {
76     hltmod->AddTrigger("HLT_Ele10_SW_L1R");
77     hltmod->AddTrigger("HLT_Ele15_SW_LooseTrackIso_L1R");
78     hltmod->AddTrigger("HLT_Ele15_SW_EleId_L1R");
79     hltmod->AddTrigger("HLT_Ele15_LW_L1R");
80     hltmod->AddTrigger("HLT_Ele15_SC10_LW_L1R");
81     hltmod->AddTrigger("HLT_Ele20_SW_L1R");
82     hltmod->AddTrigger("HLT_IsoMu9");
83     } else {
84     hltmod->AddTrigger("HLT_Ele10_LW_EleId_L1R");
85     hltmod->AddTrigger("HLT_Mu9");
86     hltmod->SetBitsName("HLTBits_E29");
87     }
88     hltmod->SetTrigObjsName("myhltobjs");
89    
90    
91     //------------------------------------------------------------------------------------------------
92     // publisher Mod
93     //------------------------------------------------------------------------------------------------
94     PublisherMod<CaloJet,Jet> *pubJet = new PublisherMod<CaloJet,Jet>("JetPub");
95     pubJet->SetInputName("AKt5Jets");
96     pubJet->SetOutputName("PubAKt5Jets");
97    
98     PublisherMod<Met,Met> *pubMet = new PublisherMod<Met,Met>("MetPub");
99     pubMet->SetInputName("TCMet");
100     pubMet->SetOutputName("PubTCMet");
101    
102     //------------------------------------------------------------------------------------------------
103     // Apply Jet/Met Corrections
104     //------------------------------------------------------------------------------------------------
105 bendavid 1.3 JetCorrectionMod *jetCorr = new JetCorrectionMod;
106     jetCorr->AddCorrectionFromRelease("CondFormats/JetMETObjects/data/Summer09_7TeV_ReReco332_L2Relative_AK5Calo.txt");
107     jetCorr->AddCorrectionFromRelease("CondFormats/JetMETObjects/data/Summer09_7TeV_ReReco332_L3Absolute_AK5Calo.txt");
108 bendavid 1.1 jetCorr->SetInputName(pubJet->GetOutputName());
109    
110     CaloMetCorrectionMod *metCorr = new CaloMetCorrectionMod;
111     metCorr->SetInputName(pubMet->GetOutputName());
112     metCorr->SetCorrectedJetsName(jetCorr->GetOutputName());
113    
114    
115     //------------------------------------------------------------------------------------------------
116     // object id and cleaning sequence
117     //------------------------------------------------------------------------------------------------
118     MuonIDMod *muonID = new MuonIDMod;
119     ElectronIDMod *electronID = new ElectronIDMod;
120     electronID->SetIDType(TString("CustomTight"));
121     PhotonIDMod *photonID = new PhotonIDMod;
122     photonID->SetIDType(TString("Custom"));
123     TauIDMod *tauID = new TauIDMod;
124     JetIDMod *jetID = new JetIDMod;
125 bendavid 1.3 jetID->SetInputName(pubJet->GetOutputName());
126 bendavid 1.1 jetID->SetUseCorrection(kTRUE);
127     jetID->SetPtCut(30.0);
128     jetID->SetEtaMaxCut(5.0);
129     jetID->SetOutputName(ModNames::gkGoodJetsName);
130     ElectronCleaningMod *electronCleaning = new ElectronCleaningMod;
131     PhotonCleaningMod *photonCleaning = new PhotonCleaningMod;
132     TauCleaningMod *tauCleaning = new TauCleaningMod;
133     JetCleaningMod *jetCleaning = new JetCleaningMod;
134     jetCleaning->SetGoodJetsName(ModNames::gkGoodJetsName);
135     jetCleaning->SetCleanJetsName(ModNames::gkCleanJetsName);
136    
137     //------------------------------------------------------------------------------------------------
138     // merge modules
139     //------------------------------------------------------------------------------------------------
140     MergeLeptonsMod *mergeLeptonsMod = new MergeLeptonsMod;
141     mergeLeptonsMod->SetMuonsName(muonID->GetOutputName());
142     mergeLeptonsMod->SetElectronsName(electronCleaning->GetOutputName());
143    
144     //------------------------------------------------------------------------------------------------
145     // analyses modules
146     //------------------------------------------------------------------------------------------------
147     FullExampleMod *analysisMod = new FullExampleMod;
148     analysisMod->SetMuonName(muonID->GetOutputName());
149     analysisMod->SetMuonsFromBranch(kFALSE);
150     analysisMod->SetElectronName(electronID->GetOutputName());
151     analysisMod->SetElectronsFromBranch(kFALSE);
152    
153    
154     //------------------------------------------------------------------------------------------------
155     // making analysis chain
156     //------------------------------------------------------------------------------------------------
157 bendavid 1.3 //generatorMod->Add(muonID);
158 bendavid 1.1 generatorMod->Add(muonID);
159     muonID->Add(electronID);
160     electronID->Add(photonID);
161     photonID->Add(tauID);
162     tauID->Add(pubJet);
163 bendavid 1.3 pubJet->Add(pubMet);
164 bendavid 1.1 pubMet->Add(jetCorr);
165     jetCorr->Add(metCorr);
166     metCorr->Add(jetID);
167 bendavid 1.3 //pubJet->Add(jetID);
168 bendavid 1.1 jetID->Add(electronCleaning);
169     electronCleaning->Add(photonCleaning);
170     photonCleaning->Add(tauCleaning);
171     tauCleaning->Add(jetCleaning);
172     jetCleaning->Add(mergeLeptonsMod);
173     mergeLeptonsMod->Add(analysisMod);
174    
175     //------------------------------------------------------------------------------------------------
176     // setup analysis
177     //------------------------------------------------------------------------------------------------
178     Analysis *ana = new Analysis;
179     ana->SetUseHLT(kFALSE);
180     ana->SetKeepHierarchy(kTRUE);
181     if (nEvents >= 0)
182     ana->SetProcessNEvents(nEvents);
183     ana->SetSuperModule(generatorMod);
184    
185     //------------------------------------------------------------------------------------------------
186     // organize input
187     //------------------------------------------------------------------------------------------------
188     printf("\nRely on Catalog: %s\n",catalogDir);
189     printf(" -> Book: %s Dataset: %s Skim: %s Fileset: %s <-\n\n",book,dataset,skim,fileset);
190     Catalog *c = new Catalog(catalogDir);
191     TString skimdataset = TString(dataset)+TString("/") +TString(skim);
192     Dataset *d = NULL;
193     if (TString(skim).CompareTo("noskim") == 0)
194     d = c->FindDataset(book,dataset,fileset);
195     else
196     d = c->FindDataset(book,skimdataset.Data(),fileset);
197 bendavid 1.2 ana->AddDataset(d);
198 bendavid 1.3 //ana->AddFile("root://castorcms//castor/cern.ch/user/p/paus/filler/011/s09-ttbar-7-mc3/*.root");
199     //ana->AddFile("/build/bendavid/XX-MITDATASET-XX_000-valskim-Run132605.root");
200 bendavid 1.1
201     //------------------------------------------------------------------------------------------------
202     // organize output
203     //------------------------------------------------------------------------------------------------
204     TString rootFile = TString(outputName);
205     rootFile += TString("_") + TString(dataset) + TString("_") + TString(skim);
206     if (TString(fileset) != TString(""))
207     rootFile += TString("_") + TString(fileset);
208     rootFile += TString(".root");
209     printf("\nRoot output: %s\n\n",rootFile.Data());
210     ana->SetOutputName(rootFile.Data());
211    
212     //------------------------------------------------------------------------------------------------
213     // run the analysis after successful initialisation
214     //------------------------------------------------------------------------------------------------
215     ana->Run(!gROOT->IsBatch());
216    
217     return;
218     }
219    
220     //--------------------------------------------------------------------------------------------------
221     void runPhysicsExample(const char *fileset = "",
222     const char *skim = "noskim",
223 bendavid 1.3 const char *dataset = "s09-ttbar-7-mc3",
224 bendavid 1.1 const char *book = "cern/filler/011",
225     const char *catalogDir = "/home/mitprod/catalog",
226     const char *outputName = "PhysicsExample",
227     int nEvents = 10000,
228     int runTypeIndex = -1)
229     {
230     TString outfileName = TString(outputName);
231     executePhysicsExample(fileset,skim,dataset,book,catalogDir,outfileName,runTypeIndex,nEvents);
232     }