ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/ActiveSamples.C
Revision: 1.43
Committed: Mon Dec 3 18:14:38 2012 UTC (12 years, 5 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.42: +1 -2 lines
Log Message:
New way to add samples using JSON files; much cleaner and with more features! Easy grouping through SplitByX in ActiveSamples and much more

File Contents

# Content
1 #include <iostream>
2 #include <vector>
3 #include <sys/stat.h>
4 #include <unistd.h>
5
6 #include <TMath.h>
7 #include <TColor.h>
8 #include <TPaveText.h>
9 #include <TRandom.h>
10 #include <TF1.h>
11
12 #ifndef SampleClassLoaded
13 #include "ActiveSamples.C"
14 #endif
15
16 #ifndef Verbosity
17 #define Verbosity 0
18 #endif
19 #ifndef HUSH
20 #define HUSH 1
21 #endif
22
23 void define_SMS_sample(bool showList, samplecollection &allsamples, samplecollection &signalsamples, samplecollection &scansample, bool loadall=false)
24 {
25 char hostname[1023];
26 gethostname(hostname,1023);
27
28 SanityChecks();
29
30 /*
31
32 CRUCIAL: The NAME needs to contain either "SMS" or "mSUGRA" for the SUSY scan algorithm (to be able to distinguish the two) -- this is now done automatically based on PlottingSetup::ScanSampleDirectory
33
34 */
35
36 string prefix="/shome/";
37 if((int)((string)hostname).find("falda")>-1) prefix="/scratch/";
38 string mSUGRAorSMS="mSUGRA";
39 if((int)((string)PlottingSetup::ScanSampleDirectory).find("SMS")>-1) mSUGRAorSMS="SMS";
40 if((int)((string)PlottingSetup::ScanSampleDirectory).find("GMSB")>-1) mSUGRAorSMS="GMSB";
41
42 /// NEW: Only indicate the very first file - please place scans in ntuples/SMS/ and adapt the name here and in SUSYScan.C (the files are loaded when needed avoiding high memory usage and startup times)
43 /// If you have different scans (e.g. you have a T5zzl one as well) you can create an additional directory such as SMS_T5zzl, but you need to change that below and in SUSYScan.C as well (where the files are loaded)
44 // scansample.AddSample(prefix+"buchmann/ntuples/"+PlottingSetup::ScanSampleDirectory+"/"+mSUGRAorSMS+"_clean_splitup_0_0.root",mSUGRAorSMS,1,1,false,true,0,kRed); // there is only one sample in the scan; we give each event weight "1"
45 // scansample.AddSample("/scratch/buchmann/buchmann/AllSamplesStartingAt10GeV_rest5_mSUGRA/mSUGRA_dilepton_m0-220to3000_m12-100to1000_tanb-10andA0-0_7TeV-Pythia6Z/output_8.root","mSUGRA",1,1,false,true,0,kRed); // there is only one sample in the scan; we give each event weight "1"
46 // scansample.AddSample("/shome/lbaeni/jzb/DileptonmSUGRAScan__pieces/mSUGRA_M0_400__M12_400.root","mSUGRA",1,1,false,true,0,kRed); // there is only one sample in the scan; we give each event weight "1"
47
48
49
50
51 if(loadall) {
52 for(int ix=0;ix<PlottingSetup::ScanXzones;ix++) {
53 for(int iy=1;iy<PlottingSetup::ScanYzones;iy++) {//note: the "zero-zero" sample is already loaded above!
54 scansample.AddSample((prefix+"buchmann/ntuples/"+PlottingSetup::ScanSampleDirectory+"/"+mSUGRAorSMS+"_clean_splitup_"+any2string(ix)+"_"+any2string(iy)+".root"),mSUGRAorSMS,1,1,false,true,ix*PlottingSetup::ScanXzones+iy,kRed); // there is only one sample in the scan; we give each event weight "1"
55 }
56 }
57 }
58
59
60 flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
61 if(PlottingSetup::RestrictToMassPeak==false) {
62 PlottingSetup::cutmass=PlottingSetup::openmasscut;
63 // PlottingSetup::sidebandcut=TCut("mll<2&&mll>3");//impossible cut - because we don't want any sidebands!
64 PlottingSetup::sidebandcut=TCut("SideBandsHaveBeenCalledForOffPeakAnalysis__ERROR==1");//this will trigger errors whenever sidebands are called - perfect for checking any remaining uses (checked, and no uses were found).
65 PlottingSetup::genMassCut=PlottingSetup::openGenmasscut;//impossible cut - because we don't want any sidebands!
66 PlottingSetup::requireZ=false;
67 }
68 dout << "Currently configuration: The mass cut is \"" << PlottingSetup::cutmass << "\" and RestrictToMassPeak is currently set to " << PlottingSetup::RestrictToMassPeak << endl;
69
70
71 }
72
73
74 void define_samples(bool showList, samplecollection &allsamples, samplecollection &signalsamples, samplecollection &scansample, samplecollection &raresample, samplecollection &systsamples, samplecollection &qcdsamples, samplecollection &comparesamples)
75 {
76 SanityChecks();
77
78
79 flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
80 if(!PlottingSetup::RestrictToMassPeak) {
81 PlottingSetup::cutmass=PlottingSetup::openmasscut;
82 PlottingSetup::sidebandcut=TCut("mll<2&&mll>3");//impossible cut - because we don't want any sidebands!
83 PlottingSetup::genMassCut=PlottingSetup::openGenmasscut;//impossible cut - because we don't want any sidebands!
84 }
85 if(PlottingSetup::RestrictToMassPeak&&!PlottingSetup::UseSidebandsForcJZB) {
86 PlottingSetup::sidebandcut=TCut("mll<2&&mll>3");
87 }
88
89
90
91
92
93 bool SplitByJetFlavor=false;
94 bool SplitByLeptonFlavor=true;
95 bool SplitDibosons=false;
96 bool SplitOthers=true; // splits others into "Dibosons","W+Jets", and "Single-top"
97
98 if(PlottingSetup::IsJZBAnalysis) {
99 //our main analysis
100 SplitByJetFlavor=false;
101 SplitByLeptonFlavor=true;
102 SplitDibosons=false;
103 SplitOthers=false;
104 }
105
106 if(PlottingSetup::IsWZAnalysis) {
107 //WZ cross check for main analysis
108 SplitByJetFlavor=false;
109 SplitByLeptonFlavor=false;
110 SplitDibosons=true;
111 SplitOthers=true;
112 }
113 if(PlottingSetup::IsZbAnalysis) {
114 //b-jet residual correction calculation
115 SplitByJetFlavor=true;
116 SplitByLeptonFlavor=false;
117 SplitDibosons=false;
118 SplitOthers=true;
119 }
120
121 if(!PlottingSetup::is2012) {
122 // 2011 Data and MC
123 PlottingSetup::emuncertOFFPEAK=0.1;
124 write_info(__FUNCTION__,"Have set emu uncertainty to 10% which is the 2011 value - for 2012 this is 25% at the moment due to the low stats ttbar sample");
125 LoadSamplesFromJSON("Samples2011.samples",SplitByJetFlavor,SplitByLeptonFlavor,SplitDibosons,SplitOthers);
126 } else {
127 // 2012 Data and MC
128 write_info(__FUNCTION__,"Setting up 2012 configuration - once you've stopped looking at 2011 data please make this the default!");
129 // Don't use this for the "essential cut", because we want to plot nJets as well as mll in the inclusive case; we thus use it as an addition nJets cut.
130 PlottingSetup::basicqualitycut=TCut("(pfJetGoodNum40>=2&&pfJetGoodID[0]!=0)&&(pfJetGoodNum40>=2&&pfJetGoodID[1]!=0)"&&PlottingSetup::basiccut);
131 PlottingSetup::cutnJets=TCut("pfJetGoodNum40>=3"&&PlottingSetup::basicqualitycut);
132
133 PlottingSetup::luminosity=PlottingSetup::luminosity2012;
134 PlottingSetup::lumiuncert=PlottingSetup::lumiuncert2012;
135
136 // Values for 5.1 /fb (2012, cJZB)
137 PlottingSetup::jzbvariabledata="(jzb[1]+0.061016*pt)";
138 PlottingSetup::jzbvariablemc="(jzb[1]+0.035264*pt)";
139
140 // Values for 5.1 /fb (2012, iJZB)
141 if(!PlottingSetup::RestrictToMassPeak) {
142 PlottingSetup::jzbvariabledata="(jzb[1]+0.061016*pt)";
143 PlottingSetup::jzbvariablemc="(jzb[1]+0.035264*pt)";
144 }
145
146
147 if(PlottingSetup::RestrictToMassPeak) {
148 PlottingSetup::passtrig=TCut("pt1>20&&pt2>20"&&PlottingSetup::passtrig);
149 }
150
151 if ( !PlottingSetup::is53reco ) {
152 //52 reco samples
153 LoadSamplesFromJSON("Samples52.samples",SplitByJetFlavor,SplitByLeptonFlavor,SplitDibosons,SplitOthers);
154 } else {
155 LoadSamplesFromJSON("Samples53.samples",SplitByJetFlavor,SplitByLeptonFlavor,SplitDibosons,SplitOthers);
156 }
157 }
158
159 if(PlottingSetup::is2012) {
160 cutWeight=TCut("(weight*(weight<1000)*(is_data+(!is_data)*((id1==id2)*0.95+(id1!=id2)*0.94)))");
161 }
162
163 // XS taken from:
164 // https://twiki.cern.ch/twiki/bin/view/CMS/QCDGammaPlusJetQCD11005
165
166 if(!PlottingSetup::RestrictToMassPeak) {
167 PlottingSetup::cutmass=PlottingSetup::openmasscut;
168 PlottingSetup::sidebandcut=TCut("SideBandsHaveBeenCalledForOffPeakAnalysis__ERROR==1");//this will trigger errors whenever sidebands are called - perfect for checking any remaining uses (checked, and no uses were found).
169 PlottingSetup::genMassCut=PlottingSetup::openGenmasscut;
170 PlottingSetup::requireZ=false;
171 }
172 if(PlottingSetup::RestrictToMassPeak&&!PlottingSetup::UseSidebandsForcJZB) {
173 PlottingSetup::sidebandcut=TCut("SideBandsHaveBeenCalledForOnPeakAnalysisWithoutSidebands__ERROR==1");
174 PlottingSetup::requireZ=true;
175 }
176
177 if(PlottingSetup::DoBTag) {
178 PlottingSetup::cutnJets=PlottingSetup::cutnJets&&PlottingSetup::bTagRequirement;
179 }
180
181
182
183 if(showList) {
184 allsamples.ListSamples();
185 signalsamples.ListSamples();
186 systsamples.ListSamples();
187 }
188
189 }
190
191
192
193 void define_Zb_samples(bool showList, samplecollection &allsamples, samplecollection &signalsamples, samplecollection &scansample, samplecollection &raresample, samplecollection &systsamples, samplecollection &qcdsamples)
194 {
195 SanityChecks();
196
197 float ZJetsCrossSection = 3503.71;
198 float LowZJetsCrossSection = 11050*0.069*1.15; // LO xs * filter eff * k-factor (same as ZJets)
199
200 float TTbarCrossSection = 225.197;
201 float WJetsCrossSection = 31314.0;//NNLO-------3.131e4; //NNLO------------
202 float ZnunuCrossSection = 5760.0;//NNLO -------4.5e+3; //(LO);------------
203 float SingleTopSCrossSection = 4.63; // NLO;----------------------------------
204 float SingleTopTCrossSection = 64.57; // NLO;--------------------------------
205 float SingleTopUCrossSection = 15.74; // NLO;----------------------------------
206 float VVJetsCrossSection = 4.8; // LO;-------------------------------------
207
208 long totEventsZjets = 32005720;//summer11
209 long totEventslowZjets = 10272470;
210
211 long totEventsTTbar = 3701947;//summer11
212 long totEventsWJets = 56674902;//summer11
213 long totEventsZnunu = 2106977;//2167964.0; //ZinvisibleJets_7TeV-madgraph.root
214 long totEventsVVJets = 959076;//509072.0;
215 long totEventsSingleTopS = 493868;//489472.0;
216 long totEventsSingleTopT = 475460;//477610.0;
217 long totEventsSingleTopU = 489417;//477599.0;
218
219 Int_t nice_blue = TColor::GetColor("#2E9AFE");
220 Int_t nice_green = TColor::GetColor("#81f781");
221 Int_t nice_pink = TColor::GetColor("#F781BE");
222 Int_t nice_orange= TColor::GetColor("#F7BE81");//#FA9624
223 Int_t nice_black = TColor::GetColor("#2A0A1B");//black with a bit of purple :-)
224
225 Int_t dy_color = nice_blue;
226 Int_t wjets_color = kGray;
227 Int_t ttbar_color = nice_green;
228 Int_t singletop_color = nice_orange;
229 Int_t qcd_color = nice_black;
230 Int_t diboson_color = nice_pink;
231 Int_t lm_color = kRed;
232
233 dy_color = kYellow;
234 wjets_color = kGray;
235 ttbar_color = kMagenta+2;
236 singletop_color = kBlue;
237 qcd_color = kPink;
238 diboson_color = kGreen+2;
239 lm_color = kViolet+7;
240
241 char hostname[1023];
242 gethostname(hostname,1023);
243
244 string prefix="/shome/";
245 if((int)((string)hostname).find("falda")>-1) prefix="/scratch/";
246
247 PlottingSetup::luminosity=PlottingSetup::luminosity2012;
248 PlottingSetup::lumiuncert=PlottingSetup::lumiuncert2012;
249
250 SingleTopSCrossSection=5.55;//Top mass: m(top)=173GeV, Default scales: muF=muR=mt, PDF: MSTW2008 NNLO
251 SingleTopTCrossSection=87.1;//Top mass: m(top)=173GeV, Default scales: muF=muR=mt, PDF: MSTW2008 NNLO
252 SingleTopUCrossSection=22.2;//Top mass: m(top)=173GeV, Default scales: muF=muR=mt, PDF: MSTW2008 NNLO
253
254 allsamples.AddSample("/shome/buchmann/ntuples/Data/Data_5100ipb_ZbReady.root","Data",1,1,true,false,0,kBlack);
255
256 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/SplitUp/Zbb_Full_DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball-Summer12-PU_S7_START52_V9-v2.root","Z+b",0,ZJetsCrossSection,false,false,8,dy_color);
257 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/SplitUp/Zcc_Full_DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball-Summer12-PU_S7_START52_V9-v2.root","Z+c",0,ZJetsCrossSection,false,false,9,lm_color);
258 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/SplitUp/Zll_Full_DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball-Summer12-PU_S7_START52_V9-v2.root","Z+l",0,ZJetsCrossSection,false,false,10,qcd_color);
259
260 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/TTJets_TuneZ2star_8TeV-madgraph-tauola-Summer12-PU_S7_START52_V9-v1.root","t#bar{t}",0,TTbarCrossSection,false,false,1,ttbar_color);
261 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/WJetsToLNu_TuneZ2Star_8TeV-madgraph-tarball-Summer12-PU_S7_START52_V9-v1.root","W+Jets",0,36257.2,false,false,3,wjets_color);
262
263 // SINGLE-TOP
264 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/T_s-channel_TuneZ2star_8TeV-powheg-tauola-Summer12-PU_S7_START52_V9-v1.root","Single-top",0,1.76,false,false,2,singletop_color);
265 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/Tbar_s-channel_TuneZ2star_8TeV-powheg-tauola-Summer12-PU_S7_START52_V9-v1.root","Single-top",0,3.79,false,false,2,singletop_color);
266 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/Tbar_t-channel_TuneZ2star_8TeV-powheg-tauola-Summer12-PU_S7_START52_V9-v1.root","Single-top",0,56.4,false,false,2,singletop_color);
267 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/Tbar_tW-channel-DR_TuneZ2star_8TeV-powheg-tauola-Summer12-PU_S7_START52_V9-v1.root","Single-top",0,SingleTopUCrossSection,false,false,2,singletop_color);
268
269 // DIBOSONS: LO with a k-factor
270 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/ZZJetsTo4L_TuneZ2star_8TeV-madgraph-tauola-Summer12-PU_S7_START52_V9-v3.root","Dibosons",0,0.181,false,false,4,diboson_color);
271
272 allsamples.AddSample("/shome/buchmann/ntuples/MC8tev/MCSamples5p1/WZJetsTo3LNu_TuneZ2_8TeV-madgraph-tauola-Summer12-PU_S7_START52_V9-v2.root","Dibosons",0,1.06,false,false,4,diboson_color);
273
274 // cutWeight=TCut("(weight*Efficiencyweightonly*(weight<1000)*(is_data+(!is_data)*((id1==id2&&id1==0)*0.95+(id1==id2&&id1==1)*0.88+(id1!=id2)*0.92)))");
275 TCut bTagWeight=TCut("((EventFlavor!=5&&EventFlavor!=4)+(EventFlavor==5||EventFlavor==4)*(((Zb30_bTagProbCSVBP[0]>0.15&&Zb30_bTagProbCSVBP[0]<0.95)*(-0.113472343605*Zb30_bTagProbCSVBP[0] + 1.04926963159)) + ((Zb30_bTagProbCSVBP[0]>1.2&&Zb30_bTagProbCSVBP[0]<20.0)*(0.00066342906116*Zb30_bTagProbCSVBP[0] + 0.93334455507)) + (Zb30_bTagProbCSVBP[0]<0.15||Zb30_bTagProbCSVBP[0]>20) + (Zb30_bTagProbCSVBP[0]>0.95&&Zb30_bTagProbCSVBP[0]<1.2)))");
276
277
278 cutWeight=TCut("(weight*(weight<1000)*(is_data+(!is_data)*((id1==id2&&id1==0)*0.95+(id1==id2&&id1==1)*0.88+(id1!=id2)*0.92)))"*bTagWeight);
279 write_error(__FUNCTION__,"Trigger efficiency off!!!!");
280 if(showList) {
281 allsamples.ListSamples();
282 }
283 }