ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/macros/examples/runHgg2011.C
Revision: 1.6
Committed: Thu Aug 2 12:58:53 2012 UTC (12 years, 9 months ago) by fabstoec
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_029c, Mit_029b, Mit_029a, HEAD
Changes since 1.5: +10 -4 lines
Error occurred while calculating annotation data.
Log Message:
added Rho Choice function

File Contents

# Content
1 // $Id: runHgg2011.C,v 1.5 2012/07/24 15:47:05 bendavid Exp $
2 #if !defined(__CINT__) || defined(__MAKECINT__)
3 #include <TSystem.h>
4 #include <TProfile.h>
5 #include "MitAna/DataUtil/interface/Debug.h"
6 #include "MitAna/Catalog/interface/Catalog.h"
7 #include "MitAna/TreeMod/interface/Analysis.h"
8 #include "MitAna/TreeMod/interface/HLTMod.h"
9 #include "MitAna/PhysicsMod/interface/RunLumiSelectionMod.h"
10 #include "MitAna/PhysicsMod/interface/MCProcessSelectionMod.h"
11 #include "MitAna/PhysicsMod/interface/PublisherMod.h"
12 #include "MitAna/DataTree/interface/JetCol.h"
13 #include "MitAna/DataTree/interface/PFJetCol.h"
14 #include "MitPhysics/Init/interface/ModNames.h"
15 #include "MitPhysics/Mods/interface/GoodPVFilterMod.h"
16 #include "MitPhysics/Mods/interface/MuonIDMod.h"
17 #include "MitPhysics/Mods/interface/ElectronIDMod.h"
18 #include "MitPhysics/Mods/interface/ElectronCleaningMod.h"
19 #include "MitPhysics/Mods/interface/PhotonIDMod.h"
20 #include "MitPhysics/Mods/interface/PhotonPairSelector.h"
21 #include "MitPhysics/Mods/interface/PhotonTreeWriter.h"
22 #include "MitPhysics/Mods/interface/PhotonCleaningMod.h"
23 #include "MitPhysics/Mods/interface/MergeLeptonsMod.h"
24 #include "MitPhysics/Mods/interface/JetCorrectionMod.h"
25 #include "MitPhysics/Mods/interface/PhotonMvaMod.h"
26 #include "MitPhysics/Mods/interface/MVASystematicsMod.h"
27 #include "MitPhysics/Utils/interface/RhoUtilities.h"
28
29 #endif
30
31 //--------------------------------------------------------------------------------------------------
32 void runHgg2011(const char *fileset = "0000",
33 const char *skim = "noskim",
34 //const char *dataset = "f11--h120gg-gf-v14b-pu",
35 //const char *dataset = "r11a-pho-j16-v1",
36 //const char *dataset = "s12-h124gg-gf-v9",
37 //const char *dataset = "s12-pj40-2em-v9",
38 //const char *dataset = "s12-zllm50-v9",
39 const char *dataset = "f11--h121gg-gf-v14b-pu",
40 const char *book = "local/filefi/025",
41 const char *catalogDir = "/home/cmsprod/catalog",
42 const char *outputName = "hgg",
43 int nEvents = 100)
44 {
45 //------------------------------------------------------------------------------------------------
46 // some parameters get passed through the environment
47 //------------------------------------------------------------------------------------------------
48 char json[1024], overlap[1024];
49 float overlapCut = -1;
50
51 if (gSystem->Getenv("MIT_PROD_JSON"))
52 sprintf(json, "%s",gSystem->Getenv("MIT_PROD_JSON"));
53 else {
54 sprintf(json, "%s", "~");
55 //printf(" JSON file was not properly defined. EXIT!\n");
56 //return;
57 }
58
59 TString jsonFile = TString("/home/mingyang/cms/json/") + TString(json);
60 //TString jsonFile = TString("/home/mingyang/cms/json/") + TString("Cert_136033-149442_7TeV_Dec22ReReco_Collisions10_JSON_v4.txt");
61 Bool_t isData = ( (jsonFile.CompareTo("/home/mingyang/cms/json/~") != 0) );
62
63 if (gSystem->Getenv("MIT_PROD_OVERLAP")) {
64 sprintf(overlap,"%s",gSystem->Getenv("MIT_PROD_OVERLAP"));
65 if (EOF == sscanf(overlap,"%f",&overlapCut)) {
66 printf(" Overlap was not properly defined. EXIT!\n");
67 return;
68 }
69 }
70 else {
71 sprintf(overlap,"%s", "-1.0");
72 //printf(" OVERLAP file was not properly defined. EXIT!\n");
73 //return;
74 }
75
76 printf("\n Initialization worked. \n\n");
77
78 //------------------------------------------------------------------------------------------------
79 // some global setups
80 //------------------------------------------------------------------------------------------------
81 using namespace mithep;
82 gDebugMask = Debug::kGeneral;
83 gDebugLevel = 3;
84
85 //------------------------------------------------------------------------------------------------
86 // set up information
87 //------------------------------------------------------------------------------------------------
88 RunLumiSelectionMod *runLumiSel = new RunLumiSelectionMod;
89 runLumiSel->SetAcceptMC(kTRUE); // Monte Carlo events are always accepted
90
91 MCProcessSelectionMod *mcselmod = new MCProcessSelectionMod;
92
93 MVASystematicsMod *sysMod = new MVASystematicsMod;
94 sysMod->SetMCR9Scale(1.0035, 1.0035);
95 sysMod->SetIsData(isData);
96
97 // only select on run- and lumisection numbers when valid json file present
98 if ((jsonFile.CompareTo("/home/mingyang/cms/json/~") != 0) &&
99 (jsonFile.CompareTo("/home/mingyang/cms/json/-") != 0) ) {
100 runLumiSel->AddJSONFile(jsonFile.Data());
101 }
102 if ((jsonFile.CompareTo("/home/mingyang/cms/json/-") == 0) ) {
103 printf("\n WARNING -- Looking at data without JSON file: always accept.\n\n");
104 runLumiSel->SetAbortIfNotAccepted(kFALSE); // accept all events if there is no valid JSON file
105 }
106
107 printf("\n Run lumi worked. \n\n");
108
109 //------------------------------------------------------------------------------------------------
110 // HLT information
111 //------------------------------------------------------------------------------------------------
112 HLTMod *hltModM = new HLTMod("HLTModM");
113 hltModM->AddTrigger("HLT_Mu9");
114 hltModM->AddTrigger("HLT_Mu11");
115 hltModM->AddTrigger("HLT_Mu15_v1");
116 hltModM->SetTrigObjsName("MyHltMuonObjs");
117 hltModM->SetAbortIfNotAccepted(kFALSE);
118
119 HLTMod *hltModE = new HLTMod("HLTModE");
120 hltModE->AddTrigger("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v1",150000,161176);
121 hltModE->AddTrigger("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v2",161179,163261);
122 hltModE->AddTrigger("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v3",163262,164237);
123 hltModE->AddTrigger("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v4",165085,165888);
124 hltModE->AddTrigger("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v5",165900,166967);
125 hltModE->AddTrigger("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v6",166968,170053);
126 hltModE->AddTrigger("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v6",170054,170759);
127 hltModE->AddTrigger("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v7",170760,173198);
128 hltModE->AddTrigger("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v8",173199,178380);
129 hltModE->AddTrigger("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v9",178381,179889);
130 hltModE->AddTrigger("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v10",179890,189999);
131 hltModE->AddTrigger("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v*",190000,999999);
132 hltModE->SetTrigObjsName("MyHltElecObjs");
133 hltModE->SetAbortIfNotAccepted(isData);
134
135 HLTMod *hltModES = new HLTMod("HLTModES");
136 hltModES->AddTrigger("HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v*",160000,189999);
137 hltModES->AddTrigger("HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v2",160000,189999);
138 hltModES->AddTrigger("HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v3",160000,189999);
139 hltModES->AddTrigger("HLT_Ele25_WP80_PFMT40_v*",160000,189999);
140 hltModES->AddTrigger("HLT_Ele27_WP80_PFMT50_v*",160000,189999);
141 hltModES->AddTrigger("HLT_Ele27_WP80_v*",190000,999999);
142 hltModES->SetTrigObjsName("MyHltElecSObjs");
143 hltModES->SetAbortIfNotAccepted(isData);
144
145 HLTMod *hltModP = new HLTMod("HLTModP");
146
147 hltModP->AddTrigger("HLT_Photon26_CaloIdL_IsoVL_Photon18_CaloIdL_IsoVL_v*",160000,161176);
148
149 hltModP->AddTrigger("HLT_Photon26_CaloIdL_IsoVL_Photon18_CaloIdL_IsoVL_v*",161216,165633);
150 hltModP->AddTrigger("HLT_Photon26_CaloIdL_IsoVL_Photon18_R9Id_v*",161216,165633);
151 hltModP->AddTrigger("HLT_Photon26_R9Id_Photon18_CaloIdL_IsoVL_v*",161216,165633);
152 hltModP->AddTrigger("HLT_Photon20_R9Id_Photon18_R9Id_v*",161216,165633);
153
154 hltModP->AddTrigger("HLT_Photon26_CaloIdL_IsoVL_Photon18_CaloIdL_IsoVL_v*",165970,173198);
155 hltModP->AddTrigger("HLT_Photon26_CaloIdL_IsoVL_Photon18_R9Id_v*",165970,173198);
156 hltModP->AddTrigger("HLT_Photon26_R9Id_Photon18_CaloIdL_IsoVL_v*",165970,173198);
157 hltModP->AddTrigger("HLT_Photon26_R9Id_Photon18_R9Id_v*",165970,173198);
158 hltModP->AddTrigger("HLT_Photon36_CaloIdL_IsoVL_Photon22_CaloIdL_IsoVL_v*",165970,173198);
159 hltModP->AddTrigger("HLT_Photon36_R9Id_Photon22_CaloIdL_IsoVL_v*",165970,173198);
160 hltModP->AddTrigger("HLT_Photon36_R9Id_Photon22_R9Id_v*",165970,173198);
161
162 hltModP->AddTrigger("HLT_Photon36_CaloId_IsoVL_Photon22_R9Id_v*",165970,166967);
163 hltModP->AddTrigger("HLT_Photon36_CaloIdL_IsoVL_Photon22_R9Id_v*",167039,173198);
164
165 hltModP->AddTrigger("HLT_Photon26_CaloIdXL_IsoXL_Photon18_CaloIdXL_IsoXL_v*",173236,178380);
166 hltModP->AddTrigger("HLT_Photon26_CaloIdXL_IsoXL_Photon18_R9Id_v*",173236,178380);
167 hltModP->AddTrigger("HLT_Photon26_R9Id_Photon18_CaloIdXL_IsoXL_v*",173236,178380);
168 hltModP->AddTrigger("HLT_Photon26_R9Id_Photon18_R9Id_v*",173236,178380);
169 hltModP->AddTrigger("HLT_Photon36_CaloIdL_IsoVL_Photon22_CaloIdL_IsoVL_v*",173236,178380);
170 hltModP->AddTrigger("HLT_Photon36_CaloIdL_IsoVL_Photon22_R9Id_v*",173236,178380);
171 hltModP->AddTrigger("HLT_Photon36_R9Id_Photon22_CaloIdL_IsoVL_v*",173236,178380);
172 hltModP->AddTrigger("HLT_Photon36_R9Id_Photon22_R9Id_v*",173236,178380);
173
174 hltModP->AddTrigger("HLT_Photon26_CaloIdXL_IsoXL_Photon18_CaloIdXL_IsoXL_Mass60_v*",178420,189999);
175 hltModP->AddTrigger("HLT_Photon26_CaloIdXL_IsoXL_Photon18_R9IdT_Mass60_v*",178420,189999);
176 hltModP->AddTrigger("HLT_Photon26_R9IdT_Photon18_CaloIdXL_IsoXL_Mass60_v*",178420,189999);
177 hltModP->AddTrigger("HLT_Photon26_R9IdT_Photon18_R9IdT_Mass60_v*",178420,189999);
178 hltModP->AddTrigger("HLT_Photon36_CaloIdL_IsoVL_Photon22_CaloIdL_IsoVL_v*",178420,189999);
179 hltModP->AddTrigger("HLT_Photon36_CaloIdL_IsoVL_Photon22_R9Id_v*",178420,189999);
180 hltModP->AddTrigger("HLT_Photon36_R9Id_Photon22_CaloIdL_IsoVL_v*",178420,189999);
181 hltModP->AddTrigger("HLT_Photon36_R9Id_Photon22_R9Id_v*",178420,189999);
182
183 hltModP->SetTrigObjsName("MyHltPhotObjs");
184 hltModP->SetAbortIfNotAccepted(isData);
185
186 //------------------------------------------------------------------------------------------------
187 // select events with a good primary vertex
188 //------------------------------------------------------------------------------------------------
189 GoodPVFilterMod *goodPVFilterMod = new GoodPVFilterMod;
190 goodPVFilterMod->SetMinVertexNTracks(0);
191 goodPVFilterMod->SetMinNDof (4.0);
192 goodPVFilterMod->SetMaxAbsZ (24.0);
193 goodPVFilterMod->SetMaxRho (2.0);
194 goodPVFilterMod->SetAbortIfNotAccepted(kFALSE);
195 goodPVFilterMod->SetIsMC(!isData);
196
197 GoodPVFilterMod *goodPVFilterModE = new GoodPVFilterMod("GoodPVFilterModE");
198 goodPVFilterModE->SetOutputName("GoodVertexesE");
199 goodPVFilterModE->SetMinVertexNTracks(0);
200 goodPVFilterModE->SetMinNDof (4.0);
201 goodPVFilterModE->SetMaxAbsZ (24.0);
202 goodPVFilterModE->SetMaxRho (2.0);
203 goodPVFilterModE->SetIsMC(!isData);
204
205 GoodPVFilterMod *goodPVFilterModES = new GoodPVFilterMod("GoodPVFilterModES");
206 goodPVFilterModES->SetOutputName("GoodVertexesES");
207 goodPVFilterModES->SetMinVertexNTracks(0);
208 goodPVFilterModES->SetMinNDof (4.0);
209 goodPVFilterModES->SetMaxAbsZ (24.0);
210 goodPVFilterModES->SetMaxRho (2.0);
211
212
213 //------------------------------------------------------------------------------------------------
214 // object id and cleaning sequence
215 //------------------------------------------------------------------------------------------------
216 MuonIDMod *muonId = new MuonIDMod;
217 muonId->SetClassType ("Global");
218 muonId->SetIDType ("ZMuId");
219 muonId->SetIsoType ("TrackCaloSliding");
220 muonId->SetApplyD0Cut(kTRUE);
221
222
223 PublisherMod<PFJet,Jet> *pubJet = new PublisherMod<PFJet,Jet>("JetPub");
224 pubJet->SetInputName("AKt5PFJets");
225 pubJet->SetOutputName("PubAKt5PFJets");
226
227 PublisherMod<PFJet,Jet> *pubJetOpen = new PublisherMod<PFJet,Jet>("JetPubOpen");
228 pubJetOpen->SetInputName("AKt5PFJets");
229 pubJetOpen->SetOutputName("PubAKt5PFJetsOpen");
230
231 JetCorrectionMod *jetCorr = new JetCorrectionMod;
232 jetCorr->AddCorrectionFromFile(std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/GR_R_42_V23_AK5PF_L1FastJet.txt")).Data()));
233 jetCorr->AddCorrectionFromFile(std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/GR_R_42_V23_AK5PF_L2Relative.txt")).Data()));
234 jetCorr->AddCorrectionFromFile(std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/GR_R_42_V23_AK5PF_L3Absolute.txt")).Data()));
235 if(isData){
236 jetCorr->AddCorrectionFromFile(std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/GR_R_42_V23_AK5PF_L2L3Residual.txt")).Data()));
237 }
238 jetCorr->SetInputName(pubJet->GetOutputName());
239 jetCorr->SetCorrectedName("CorrectedJets");
240
241 Bool_t excludedoubleprompt = kFALSE;
242 if (TString(dataset).Contains("-pj")) {
243 mcselmod->ExcludeProcess(18);
244 mcselmod->ExcludeProcess(114);
245 excludedoubleprompt = kTRUE;
246 }
247
248 if (TString(dataset).Contains("-qcd2em") || TString(dataset).Contains("-qcd-2em")) {
249 excludedoubleprompt = kTRUE;
250 }
251
252 Bool_t is25 = kFALSE;
253 if (TString(book).Contains("025")) is25 = kTRUE;
254
255 PhotonMvaMod *photreg = new PhotonMvaMod;
256 photreg->SetOutputName("GoodPhotonsRegr");
257 photreg->SetIsData(isData);
258
259
260 PhotonPairSelector *photcic = new PhotonPairSelector("PhotonPairSelectorCiC");
261 photcic->SetOutputName("GoodPhotonsCIC");
262 photcic->SetOutputVtxName("OutVtxCiC");
263 photcic->SetPhotonSelType("CiCSelection");
264 photcic->SetVertexSelType("CiCMVASelection");
265 photcic->DoMCSmear(kTRUE);
266 photcic->DoDataEneCorr(kTRUE);
267 photcic->SetPhotonsFromBranch(kFALSE);
268 photcic->SetInputPhotonsName(photreg->GetOutputName());
269 photcic->SetMCSmearFactors(0.0089, 0.0089, 0.0109, 0.0156, 0.0203,0.0303,0.0326,0.0318,0.0331);
270 photcic->AddEnCorrPerRun(160000,167913,0.9905,0.9905,0.9971,0.9976,1.0094,0.9994,1.0044,0.9968,1.0079);
271 photcic->AddEnCorrPerRun(170249,172619,0.9909,0.9909,0.9975,0.9994,1.0112,0.9962,1.0012,0.9962,1.0072);
272 photcic->AddEnCorrPerRun(172620,173692,0.9909,0.9909,0.9975,0.9977,1.0096,0.9963,1.0013,0.9947,1.0057);
273 photcic->AddEnCorrPerRun(175860,177139,0.9911,0.9911,0.9977,0.9990,1.0109,0.9922,0.9973,0.9967,1.0077);
274 photcic->AddEnCorrPerRun(177140,178421,0.9910,0.9910,0.9975,0.9987,1.0105,0.9921,0.9972,0.9975,1.0085);
275 photcic->AddEnCorrPerRun(178424,999999,0.9903,0.9903,0.9969,0.9976,1.0095,0.9889,0.9940,0.9976,1.0086);
276 //photcic->SetMCR9Scale(1.0048, 1.00492);
277 photcic->SetJetsName(jetCorr->GetOutputName());
278 photcic->SetIsData(isData);
279 photcic->SetDoShowerShapeScaling(kTRUE);
280 photcic->SetShowerShapeType("2011ShowerShape");
281 photcic->SetRhoType(RhoUtilities::DEFAULT);
282
283 PhotonPairSelector *photcicnoeleveto = new PhotonPairSelector("PhotonPairSelectorCiCInvertEleVeto");
284 photcicnoeleveto->SetOutputName("GoodPhotonsCICNoEleVeto");
285 photcicnoeleveto->SetOutputVtxName("OutVtxCiCInvertEleVeto");
286 photcicnoeleveto->SetPhotonSelType("CiCSelection");
287 photcicnoeleveto->SetVertexSelType("CiCMVASelection");
288 photcicnoeleveto->DoMCSmear(kTRUE);
289 photcicnoeleveto->DoDataEneCorr(kTRUE);
290 photcicnoeleveto->SetPhotonsFromBranch(kFALSE);
291 photcicnoeleveto->SetInputPhotonsName(photreg->GetOutputName());
292 photcicnoeleveto->SetMCSmearFactors(0.0089, 0.0089, 0.0109, 0.0156, 0.0203,0.0303,0.0326,0.0318,0.0331);
293 photcicnoeleveto->AddEnCorrPerRun(160000,167913,0.9905,0.9905,0.9971,0.9976,1.0094,0.9994,1.0044,0.9968,1.0079);
294 photcicnoeleveto->AddEnCorrPerRun(170249,172619,0.9909,0.9909,0.9975,0.9994,1.0112,0.9962,1.0012,0.9962,1.0072);
295 photcicnoeleveto->AddEnCorrPerRun(172620,173692,0.9909,0.9909,0.9975,0.9977,1.0096,0.9963,1.0013,0.9947,1.0057);
296 photcicnoeleveto->AddEnCorrPerRun(175860,177139,0.9911,0.9911,0.9977,0.9990,1.0109,0.9922,0.9973,0.9967,1.0077);
297 photcicnoeleveto->AddEnCorrPerRun(177140,178421,0.9910,0.9910,0.9975,0.9987,1.0105,0.9921,0.9972,0.9975,1.0085);
298 photcicnoeleveto->AddEnCorrPerRun(178424,999999,0.9903,0.9903,0.9969,0.9976,1.0095,0.9889,0.9940,0.9976,1.0086);
299 // photcicnoeleveto->SetMCR9Scale(1.0048, 1.00492);
300 photcicnoeleveto->SetApplyEleVeto(kFALSE);
301 photcicnoeleveto->SetInvertElectronVeto(kTRUE);
302 photcicnoeleveto->SetJetsName(jetCorr->GetOutputName());
303 photcicnoeleveto->SetIsData(isData);
304 photcicnoeleveto->SetDoShowerShapeScaling(kTRUE);
305 photcicnoeleveto->SetShowerShapeType("2011ShowerShape");
306 photcicnoeleveto->SetRhoType(RhoUtilities::DEFAULT);
307
308 PhotonPairSelector *photpresel = new PhotonPairSelector("PhotonPairSelectorPresel");
309 photpresel->SetOutputName("GoodPhotonsPresel");
310 photpresel->SetPhotonSelType("MITSelection");
311 photpresel->SetVertexSelType("CiCMVASelection");
312 photpresel->SetIdMVAType("2011IdMVA");
313 //photpresel->SetVertexSelType("MetSigSelection");
314 photpresel->DoMCSmear(kTRUE);
315 photpresel->DoDataEneCorr(kTRUE);
316 photpresel->SetPhotonsFromBranch(kFALSE);
317 photpresel->SetInputPhotonsName(photreg->GetOutputName());
318 //photpresel->SetMCSmearFactors(0.0045, 0.0084, 0.0109, 0.0156, 0.0203,0.0303,0.0326,0.0318,0.0331);
319 photpresel->SetMCSmearFactors(0.0067,0.0077,0.0096,0.0141,0.0196,0.0268,0.0279,0.0293,0.0301);//ming:smear(sigE/E)
320 //photpresel->AddEnCorrPerRun(160000,167913,0.9905,0.9905,0.9971,0.9976,1.0094,0.9994,1.0044,0.9968,1.0079);
321 //photpresel->AddEnCorrPerRun(170249,172619,0.9909,0.9909,0.9975,0.9994,1.0112,0.9962,1.0012,0.9962,1.0072);
322 //photpresel->AddEnCorrPerRun(172620,173692,0.9909,0.9909,0.9975,0.9977,1.0096,0.9963,1.0013,0.9947,1.0057);
323 //photpresel->AddEnCorrPerRun(175860,177139,0.9911,0.9911,0.9977,0.9990,1.0109,0.9922,0.9973,0.9967,1.0077);
324 //photpresel->AddEnCorrPerRun(177140,178421,0.9910,0.9910,0.9975,0.9987,1.0105,0.9921,0.9972,0.9975,1.0085);
325 //photpresel->AddEnCorrPerRun(178424,999999,0.9903,0.9903,0.9969,0.9976,1.0095,0.9889,0.9940,0.9976,1.0086);
326 photpresel->AddEnCorrPerRun(160431,167913,0.9941,0.9941,1.0004,0.9916,1.0045,1.0033,1.0082,0.9958,1.0064);//ming:Emc/Edata
327 photpresel->AddEnCorrPerRun(170000,172619,0.9954,0.9954,1.0016,0.9937,1.0066,0.9976,1.0025,0.9940,1.0046);
328 photpresel->AddEnCorrPerRun(172620,173692,0.9955,0.9955,1.0017,0.9929,1.0058,0.9986,1.0035,0.9923,1.0029);
329 photpresel->AddEnCorrPerRun(175830,177139,0.9958,0.9958,1.0021,0.9944,1.0073,0.9968,1.0017,0.9933,1.004);
330 photpresel->AddEnCorrPerRun(177140,178421,0.9962,0.9962,1.0025,0.9946,1.0075,0.9960,1.0010,0.9944,1.005);
331 photpresel->AddEnCorrPerRun(178424,180252,0.9961,0.9961,1.0024,0.9942,1.0071,0.9921,0.9970,0.9953,1.0059);
332 photpresel->SetJetsName(jetCorr->GetOutputName());
333 photpresel->SetIsData(isData);
334 photpresel->SetDoShowerShapeScaling(kTRUE);
335 photpresel->SetShowerShapeType("2011ShowerShape");
336 photpresel->SetRhoType(RhoUtilities::DEFAULT);
337
338 PhotonPairSelector *photpreselinverteleveto = new PhotonPairSelector("PhotonPairSelectorPreselInvertEleVeto");
339 photpreselinverteleveto->SetOutputName("GoodPhotonsPreselInvertEleVeto");
340 photpreselinverteleveto->SetOutputVtxName("OutVtxPreselInvertEleVeto");
341 photpreselinverteleveto->SetPhotonSelType("MITSelection");
342 photpreselinverteleveto->SetVertexSelType("CiCMVASelection");
343 photpreselinverteleveto->SetIdMVAType("2011IdMVA");
344 photpreselinverteleveto->DoMCSmear(kTRUE);
345 photpreselinverteleveto->DoDataEneCorr(kTRUE);
346 photpreselinverteleveto->SetPhotonsFromBranch(kFALSE);
347 photpreselinverteleveto->SetInputPhotonsName(photreg->GetOutputName());
348 photpreselinverteleveto->SetMCSmearFactors(0.0045, 0.0084, 0.0109, 0.0156, 0.0203,0.0303,0.0326,0.0318,0.0331);
349 photpreselinverteleveto->AddEnCorrPerRun(160000,167913,0.9905,0.9905,0.9971,0.9976,1.0094,0.9994,1.0044,0.9968,1.0079);
350 photpreselinverteleveto->AddEnCorrPerRun(170249,172619,0.9909,0.9909,0.9975,0.9994,1.0112,0.9962,1.0012,0.9962,1.0072);
351 photpreselinverteleveto->AddEnCorrPerRun(172620,173692,0.9909,0.9909,0.9975,0.9977,1.0096,0.9963,1.0013,0.9947,1.0057);
352 photpreselinverteleveto->AddEnCorrPerRun(175860,177139,0.9911,0.9911,0.9977,0.9990,1.0109,0.9922,0.9973,0.9967,1.0077);
353 photpreselinverteleveto->AddEnCorrPerRun(177140,178421,0.9910,0.9910,0.9975,0.9987,1.0105,0.9921,0.9972,0.9975,1.0085);
354 photpreselinverteleveto->AddEnCorrPerRun(178424,999999,0.9903,0.9903,0.9969,0.9976,1.0095,0.9889,0.9940,0.9976,1.0086);
355 photpreselinverteleveto->SetApplyEleVeto(kFALSE);
356 photpreselinverteleveto->SetInvertElectronVeto(kTRUE);
357 photpreselinverteleveto->SetJetsName(jetCorr->GetOutputName());
358 photpreselinverteleveto->SetIsData(isData);
359 photpreselinverteleveto->SetDoShowerShapeScaling(kTRUE);
360 photpreselinverteleveto->SetShowerShapeType("2011ShowerShape");
361 photpreselinverteleveto->SetRhoType(RhoUtilities::DEFAULT);
362
363 PhotonPairSelector *photpreselnosmear = new PhotonPairSelector("PhotonPairSelectorPreselNoSmear");
364 photpreselnosmear->SetOutputName("GoodPhotonsPreselNoSmear");
365 photpreselnosmear->SetPhotonSelType("MITSelection");
366 photpreselnosmear->SetVertexSelType("CiCMVASelection");
367 photpreselnosmear->SetIdMVAType("2011IdMVA");
368 photpreselnosmear->SetPhotonsFromBranch(kFALSE);
369 photpreselnosmear->SetInputPhotonsName(photreg->GetOutputName());
370 photpreselnosmear->SetJetsName(jetCorr->GetOutputName());
371 photpreselnosmear->SetOutputVtxName("OutVtxNoSmear");
372 photpreselnosmear->SetIsData(isData);
373 photpreselnosmear->SetDoShowerShapeScaling(kTRUE);
374 photpreselnosmear->SetShowerShapeType("2011ShowerShape");
375 photpreselnosmear->SetRhoType(RhoUtilities::DEFAULT);
376
377 PhotonTreeWriter *phottreecic = new PhotonTreeWriter("PhotonTreeWriterCiC");
378 phottreecic->SetPhotonsFromBranch(kFALSE);
379 phottreecic->SetInputPhotonsName(photcic->GetOutputName());
380 phottreecic->SetEnableJets(kTRUE);
381 phottreecic->SetPFJetsFromBranch(kFALSE);
382 phottreecic->SetPFJetName(jetCorr->GetOutputName());
383 phottreecic->SetExcludeDoublePrompt(excludedoubleprompt);
384 phottreecic->SetIsData(isData);
385 if (is25) phottreecic->SetEnablePFPhotons(kFALSE);
386
387 PhotonTreeWriter *phottreecicnoeleveto = new PhotonTreeWriter("PhotonTreeWriterCiCInvertEleVeto");
388 phottreecicnoeleveto->SetPhotonsFromBranch(kFALSE);
389 phottreecicnoeleveto->SetInputPhotonsName(photcicnoeleveto->GetOutputName());
390 phottreecicnoeleveto->SetEnableJets(kTRUE);
391 phottreecicnoeleveto->SetPFJetsFromBranch(kFALSE);
392 phottreecicnoeleveto->SetPFJetName(jetCorr->GetOutputName());
393 phottreecicnoeleveto->SetApplyElectronVeto(kFALSE);
394 phottreecicnoeleveto->SetExcludeDoublePrompt(excludedoubleprompt);
395 phottreecicnoeleveto->SetIsData(isData);
396 if (is25) phottreecicnoeleveto->SetEnablePFPhotons(kFALSE);
397
398 PhotonTreeWriter *phottreepresel = new PhotonTreeWriter("PhotonTreeWriterPresel");
399 phottreepresel->SetPhotonsFromBranch(kFALSE);
400 phottreepresel->SetInputPhotonsName(photpresel->GetOutputName());
401 phottreepresel->SetEnableJets(kTRUE);
402 phottreepresel->SetPFJetsFromBranch(kFALSE);
403 phottreepresel->SetPFJetName(jetCorr->GetOutputName());
404 phottreepresel->SetExcludeDoublePrompt(excludedoubleprompt);
405 phottreepresel->SetIsData(isData);
406 if (is25) phottreepresel->SetEnablePFPhotons(kFALSE);
407
408 PhotonTreeWriter *phottreepreselinverteleveto = new PhotonTreeWriter("PhotonTreeWriterPreselInvertEleVeto");
409 phottreepreselinverteleveto->SetPhotonsFromBranch(kFALSE);
410 phottreepreselinverteleveto->SetInputPhotonsName(photpreselinverteleveto->GetOutputName());
411 phottreepreselinverteleveto->SetEnableJets(kTRUE);
412 phottreepreselinverteleveto->SetPFJetsFromBranch(kFALSE);
413 phottreepreselinverteleveto->SetPFJetName(jetCorr->GetOutputName());
414 phottreepreselinverteleveto->SetApplyElectronVeto(kFALSE);
415 phottreepreselinverteleveto->SetExcludeDoublePrompt(excludedoubleprompt);
416 phottreepreselinverteleveto->SetIsData(isData);
417 if (is25) phottreepreselinverteleveto->SetEnablePFPhotons(kFALSE);
418
419 PhotonTreeWriter *phottreepreselnosmear = new PhotonTreeWriter("PhotonTreeWriterPreselNoSmear");
420 phottreepreselnosmear->SetPhotonsFromBranch(kFALSE);
421 phottreepreselnosmear->SetInputPhotonsName(photpreselnosmear->GetOutputName());
422 phottreepreselnosmear->SetEnableJets(kTRUE);
423 phottreepreselnosmear->SetPFJetsFromBranch(kFALSE);
424 phottreepreselnosmear->SetPFJetName(jetCorr->GetOutputName());
425 phottreepreselnosmear->SetExcludeDoublePrompt(excludedoubleprompt);
426 phottreepreselnosmear->SetIsData(isData);
427 if (is25) phottreepreselnosmear->SetEnablePFPhotons(kFALSE);
428
429 PhotonIDMod *photidpresel = new PhotonIDMod("PhotonIDModPresel");
430 photidpresel->SetPtMin(25.0);
431 photidpresel->SetOutputName("GoodPhotonsPreselid");
432 photidpresel->SetIDType("MITSelection");
433 photidpresel->SetApplyElectronVeto(kTRUE);
434 photidpresel->SetIsData(isData);
435
436 PhotonIDMod *photidpreselinvert = new PhotonIDMod("PhotonIDModPreselInvert");
437 photidpreselinvert->SetPtMin(25.0);
438 photidpreselinvert->SetOutputName("GoodPhotonsPreselidInvert");
439 photidpreselinvert->SetIDType("MITSelection");
440 photidpreselinvert->SetApplyElectronVeto(kFALSE);
441 photidpreselinvert->SetInvertElectronVeto(kTRUE);
442 photidpreselinvert->SetIsData(isData);
443
444 PhotonTreeWriter *phottreesingle = new PhotonTreeWriter("PhotonTreeWriterSingle");
445 phottreesingle->SetWriteDiphotonTree(kFALSE);
446 phottreesingle->SetPhotonsFromBranch(kFALSE);
447 phottreesingle->SetInputPhotonsName(photidpresel->GetOutputName());
448 phottreesingle->SetEnableJets(kTRUE);
449 phottreesingle->SetPFJetsFromBranch(kFALSE);
450 phottreesingle->SetPFJetName(jetCorr->GetOutputName());
451 phottreesingle->SetIsData(isData);
452 if (is25) phottreesingle->SetEnablePFPhotons(kFALSE);
453
454 PhotonTreeWriter *phottreesingleinvert = new PhotonTreeWriter("PhotonTreeWriterSingleInvert");
455 phottreesingleinvert->SetWriteDiphotonTree(kTRUE);
456 phottreesingleinvert->SetPhotonsFromBranch(kFALSE);
457 phottreesingleinvert->SetInputPhotonsName(photidpreselinvert->GetOutputName());
458 phottreesingleinvert->SetEnableJets(kTRUE);
459 phottreesingleinvert->SetPFJetsFromBranch(kFALSE);
460 phottreesingleinvert->SetPFJetName(pubJetOpen->GetOutputName());
461 phottreesingleinvert->SetApplyElectronVeto(kFALSE);
462 phottreesingleinvert->SetIsData(isData);
463 if (is25) phottreesingleinvert->SetEnablePFPhotons(kFALSE);
464
465
466 //------------------------------------------------------------------------------------------------
467 // making analysis chain
468 //------------------------------------------------------------------------------------------------
469 // this is how it always starts
470 runLumiSel ->Add(mcselmod);
471
472 if (TString(dataset).Contains("-h")) {
473 mcselmod ->Add(sysMod);
474 }
475
476 // high level trigger is always first
477 //mcselmod ->Add(hltModES);
478 mcselmod ->Add(hltModP);
479 mcselmod ->Add(hltModE);
480
481 hltModP ->Add(goodPVFilterMod);
482 hltModE ->Add(goodPVFilterModE);
483 //hltModES ->Add(goodPVFilterModES);
484
485 //goodPVFilterMod ->Add(muonId);
486 goodPVFilterMod->Add(photreg);
487 photreg->Add(pubJet);
488 pubJet->Add(jetCorr);
489
490 // simple object id modules
491 goodPVFilterModE -> Add(pubJetOpen);
492 pubJetOpen -> Add(photidpreselinvert);
493 //goodPVFilterModES ->Add(elecIdS);
494
495
496 jetCorr ->Add(photcic);
497 jetCorr ->Add(photcicnoeleveto);
498 jetCorr ->Add(photpresel);
499 jetCorr ->Add(photpreselinverteleveto);
500 jetCorr ->Add(photpreselnosmear);
501
502 photcic ->Add(phottreecic);
503 photcicnoeleveto ->Add(phottreecicnoeleveto);
504 photpresel ->Add(phottreepresel);
505 photpreselinverteleveto ->Add(phottreepreselinverteleveto);
506 photpreselnosmear ->Add(phottreepreselnosmear);
507
508
509 jetCorr ->Add(photidpresel);
510 photidpresel ->Add(phottreesingle);
511
512 photidpreselinvert ->Add(phottreesingleinvert);
513 //elecIdS->Add(phottreeES);
514
515
516 TFile::SetOpenTimeout(0);
517 //TFile::SetCacheFileDir("./rootfilecache",kTRUE,kTRUE);
518 TFile::SetReadaheadSize(128*1024*1024);
519
520 //------------------------------------------------------------------------------------------------
521 // setup analysis
522 //------------------------------------------------------------------------------------------------
523 Analysis *ana = new Analysis;
524 ana->SetUseHLT(kTRUE);
525 ana->SetKeepHierarchy(kTRUE);
526 ana->SetSuperModule(runLumiSel);
527 ana->SetPrintScale(100);
528 if (nEvents >= 0)
529 ana->SetProcessNEvents(nEvents);
530
531 //------------------------------------------------------------------------------------------------
532 // organize input
533 //------------------------------------------------------------------------------------------------
534 Catalog *c = new Catalog(catalogDir);
535 TString skimdataset = TString(dataset)+TString("/") +TString(skim);
536 Dataset *d = NULL;
537 TString bookstr = book;
538 //if (TString(dataset).Contains("s11-h")) bookstr.ReplaceAll("local","t2mit");
539 if (TString(skim).CompareTo("noskim") == 0)
540 d = c->FindDataset(bookstr,dataset,fileset);
541 else
542 d = c->FindDataset(bookstr,skimdataset.Data(),fileset);
543 ana->AddDataset(d);
544 //ana->AddFile("/mnt/hadoop/cmsprod/filefi/025/r11b-pho-n30-v1/4863E9D1-BC1C-E111-99BA-001A92810AF4.root");
545
546 //------------------------------------------------------------------------------------------------
547 // organize output
548 //------------------------------------------------------------------------------------------------
549 TString rootFile = TString(outputName);
550 rootFile += TString("_") + TString(dataset) + TString("_") + TString(skim);
551 if (TString(fileset) != TString(""))
552 rootFile += TString("_") + TString(fileset);
553 rootFile += TString(".root");
554 ana->SetOutputName(rootFile.Data());
555 //ana->SetCacheSize(64*1024*1024);
556 ana->SetCacheSize(0);
557
558 //------------------------------------------------------------------------------------------------
559 // Say what we are doing
560 //------------------------------------------------------------------------------------------------
561 printf("\n==== PARAMETER SUMMARY FOR THIS JOB ====\n");
562 printf("\n JSON file: %s\n and overlap cut: %f (%s)\n",jsonFile.Data(),overlapCut,overlap);
563 printf("\n Rely on Catalog: %s\n",catalogDir);
564 printf(" -> Book: %s Dataset: %s Skim: %s Fileset: %s <-\n",book,dataset,skim,fileset);
565 printf("\n Root output: %s\n\n",rootFile.Data());
566 printf("\n========================================\n");
567
568 //------------------------------------------------------------------------------------------------
569 // run the analysis after successful initialisation
570 //------------------------------------------------------------------------------------------------
571 ana->Run(!gROOT->IsBatch());
572
573 return;
574 }