Skip to content

Commit 004b2bf

Browse files
author
mstoye
committed
Merge pull request #1 from mstoye/origin/master
made it simple with eos example
2 parents 23aa7a2 + dc9d4b2 commit 004b2bf

File tree

4 files changed

+88
-32
lines changed

4 files changed

+88
-32
lines changed

SUSYLooperHists.C

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include <TF1.h>
99
#include <TMath.h>
10-
#include <HTransformToCS.c>
1110
#include <TMatrixF.h>
1211
#include <TVectorF.h>
1312

@@ -40,19 +39,24 @@ TFile* SUSYLooperHists::Loop()
4039

4140
if (fChain == 0) return NULL;
4241
Long64_t nentries = fChain->GetEntriesFast();
43-
HTransformToCS mtCS;
44-
mtCS.SetCmsEnergy(8000);
45-
46-
42+
4743
TFile* myFile = new TFile(outputFileName,"recreate");
44+
// checks the Mtt mass ++ simple plot example ++
4845
TH1D* LepTwoZmass= new TH1D("LepTwoZmass",";approximate Z(#tau#tau) mass [GeV];",100,0,2000);
46+
LepTwoZmass->Sumw2();
47+
48+
// baseline plots +++++++++++++++++++++
49+
// allow to fill cutflow to sychronize to others
50+
TH1D* CutFlow = new TH1D("CutFlow",";CutFlow [unweighted];",20,-0.5,19.5);
51+
CutFlow->Sumw2();
52+
53+
// a scan should be filled without weights before any cut to get the efficiency. The reason is that for a scan each points have different x-section, which are not accessable during the loop
4954
TH2D* scan = new TH2D("scan","scan",8,112.5,312.5,40,112.5,312.5);
55+
// fill after some cuts the scans to get efficiency, i.e. ->Divide(scan) after the loop
5056
TH2D* scanA = new TH2D("scanA","scan",8,112.5,312.5,40,112.5,312.5);
5157
TH2D* scanB = new TH2D("scanB","scan",8,112.5,312.5,40,112.5,312.5);
5258
TH2D* scanC = new TH2D("scanC","scan",8,112.5,312.5,40,112.5,312.5);
53-
// baseline plots +++++++++++++++++++++
54-
TH1D* CutFlowAntonis = new TH1D("CutFlowAntonis",";P(l);",20,-0.5,19.5);
55-
CutFlowAntonis->Sumw2();
59+
5660

5761
Long64_t nbytes = 0, nb = 0;
5862
for (Long64_t jentry=0; jentry<nentries;jentry++) {
@@ -61,7 +65,7 @@ TFile* SUSYLooperHists::Loop()
6165
if (ientry < 0) break;
6266
nb = fChain->GetEntry(jentry); nbytes += nb;
6367

64-
if(jentry%10000==0) cout << "Event: "<<jentry <<" weight: " << weight <<endl;
68+
if(jentry%100000==0) cout << "Event: "<<jentry <<endl;
6569
scan->Fill(GenSusyMStop,GenSusyMNeutralino);
6670
// select lepton and put it into TLorentzvector
6771

@@ -109,28 +113,28 @@ TFile* SUSYLooperHists::Loop()
109113

110114
// preselection syncronizd to Antonis ++++++++++++++++++++
111115
if( nLepGood == 0 ) continue;
112-
CutFlowAntonis->Fill(0.);
116+
CutFlow->Fill(0.);
113117
if(met.Pt()<200) continue;
114118
if(nLepGood<2) continue;
115119
if(nJet==0) continue;
116120
if(nTauGood!=0) continue;
117-
CutFlowAntonis->Fill(1.);
121+
CutFlow->Fill(1.);
118122
if(fabs(LepGood_pdgId[0]* LepGood_pdgId[1])<122) continue;
119-
CutFlowAntonis->Fill(2.);
123+
CutFlow->Fill(2.);
120124
if(lep.Pt()<5||fabs(lep.Eta())>1.5||lep.Pt()>60) continue;
121-
CutFlowAntonis->Fill(3.);
125+
CutFlow->Fill(3.);
122126
if(fabs(LepGood_pdgId[0])==11&&lep.Pt()<7) continue;
123-
CutFlowAntonis->Fill(4.);
127+
CutFlow->Fill(4.);
124128
// check that a cut was ahead in nLepton !!!!!!!!
125129
TLorentzVector secondLep;
126130
secondLep.SetPtEtaPhiM(LepGood_pt[1], LepGood_eta[1], LepGood_phi[1],0.1);
127131
if(secondLep.Pt()<3||fabs(secondLep.Eta())>1.5||secondLep.Pt()>60) continue;
128-
CutFlowAntonis->Fill(5.);
132+
CutFlow->Fill(5.);
129133
// lepton cuts
130134
if(LepGood_relIso[0]*lep.Pt()>10.) continue;
131135
if(LepGood_relIso[1]*secondLep.Pt()>5.) continue;
132136
if(LepGood_relIso[1]>.5) continue;
133-
CutFlowAntonis->Fill(6.);
137+
CutFlow->Fill(6.);
134138
// JET CUTS
135139
if(nJet>0){
136140
if (Jet_pt[0] < 150) continue;
@@ -139,28 +143,30 @@ TFile* SUSYLooperHists::Loop()
139143
if(nJet>2){
140144
if (Jet_pt[2] > 60) continue;
141145
}
142-
CutFlowAntonis->Fill(7.);
146+
CutFlow->Fill(7.);
143147
if(met.Pt()/HT30<2./3.) continue;
144148
if(nb40!=0) continue;
145-
CutFlowAntonis->Fill(9.);
146-
// preselection syncronizd to Antonis ++++++++++++++++++++
149+
CutFlow->Fill(9.);
150+
// preselection syncronizd to ++++++++++++++++++++
147151

148152
if(MT>60&&MT<100) continue;
149153

150154

151155
float pairmass = DiTau_InvMass(met,lep,secondLep,0);
152156
if(lep.Pt()>25||secondLep.Pt()>15) continue;
157+
158+
// define some over and underflow
153159
if (pairmass>2000) pairmass=1999.;
154160
if (pairmass<0) pairmass=0.;
155161

156-
LepTwoZmass->Fill(pairmass,weight);
162+
LepTwoZmass->Fill(pairmass,weight*puWeight);
157163

158164

159165
if((LepGood_pdgId[0]* LepGood_pdgId[1]<-121))
160166
{
161167

162168
if(pairmass>160||pairmass<20){
163-
CutFlowAntonis->Fill(10., weight*puWeight);
169+
CutFlow->Fill(10., weight*puWeight);
164170
scanB->Fill(GenSusyMStop,GenSusyMNeutralino);
165171

166172
if(nb30L==0)
@@ -191,7 +197,7 @@ TFile* SUSYLooperHists::Loop()
191197
scanB->Divide(scan);
192198
scanC->Divide(scan);
193199

194-
CutFlowAntonis->DrawCopy();
200+
CutFlow->DrawCopy();
195201

196202
myFile->Write();
197203
return (myFile);

SUSYLooperHists.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,14 @@ public :
262262
SUSYLooperHists::SUSYLooperHists(SampleInfo mySample, float Mstop_ , float MLSP_ )
263263
{
264264

265-
TFile *f = new TFile(mySample.SamplePath);
265+
TFile *f = TFile::Open(mySample.FilePath);
266266
TTree* tree = (TTree*) f->Get("markusTreeProducer");
267-
outputFileName = mySample.SampleName+".root";
267+
outputFileName = mySample.OutputFileNameTag+".root";
268268
weight = mySample.weight();
269-
cout << "weight again " << weight <<endl;;
270269
Mstop= Mstop_;
271270
MLSP=MLSP_;
272-
maxEvents = mySample.TotalEvNum;
273271
Init(tree);
272+
cout << "looping over: \""<< mySample.FilePath<< "\" to put plots into: \""<< outputFileName<<"\""<<endl;;
274273

275274
}
276275

@@ -443,6 +442,7 @@ Int_t SUSYLooperHists::Cut(Long64_t entry)
443442
{
444443
// This function may be called from Loop.
445444
// returns 1 if entry is accepted.
445+
cout << " can be used to put preselection cuts for " << entry<<endl;
446446
// returns -1 otherwise.
447447
return 1;
448448
}

SampleInfo.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef SampleInfo_h
2+
#define SampleInfo_h
3+
4+
#include "TString.h"
5+
6+
class SampleInfo
7+
{
8+
9+
public:
10+
SampleInfo( float Lumi_,float NEvents_,float CrossSection_,TString FilePath_, TString LegendLabel_,TString OutputFileNameTag_,int color_): Lumi(Lumi_),NEvents(NEvents_), CrossSection(CrossSection_),FilePath(FilePath_),LegendLabel(LegendLabel_),OutputFileNameTag(OutputFileNameTag_), color(color_)
11+
{;}
12+
;
13+
float weight();
14+
15+
16+
private:
17+
float Lumi;
18+
float NEvents; // number of events before any skimmming in MC
19+
float CrossSection; // put -1 for data
20+
TString FilePath;
21+
TString LegendLabel;
22+
TString OutputFileNameTag;
23+
int color;
24+
25+
};
26+
27+
28+
float SampleInfo::weight()
29+
{
30+
if(CrossSection==-1) return 1.; // for data
31+
else
32+
{
33+
return (CrossSection/NEvents*Lumi);
34+
}
35+
};
36+
#endif

myplots.C

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,41 @@
44

55
void myplots()
66
{
7+
// all files are at eos, so start with these
8+
SampleInfo eosZll(40.5,2655795,19.7,TString("root://eoscms.cern.ch//eos/cms/store/cmst3/group/susy/markus/preliminary_samples_11thApril_2014/DYJetsToLLPtZ100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Zll"),TString("Z(ll)"),5);
79

10+
// You can copy them over to your local directory to gain speed
11+
SampleInfo Zll(40.5,2655795,19.7,TString("../data_test_antonios/DYJetsToLLPtZ100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Zll"),TString("Z(ll)"),5);;
812

9-
//
13+
// pathes below to local directories
1014
SampleInfo wjet(282,12742383,19.7 ,TString("../data_test_antonios/WPT100JETS/markusTreeProducer/markusTreeProducer_tree.root"),TString("W_PT_100"),TString("W PT 100"),2);
1115
SampleInfo ttsemi(106.15,320./963.*24895259,19.7,TString("../data_test_antonios/myhaddedFileTsemi.root"),TString("TTbarSemiLep"),TString("tt(l)"),4);
12-
SampleInfo ttlep(25.8,11947326*0.467,19.7,TString("../data_test_antonios/myhaddedFileTlep.root"),TString("TTbarFullyLep"),TString("tt(l)"),5);
13-
SampleInfo Zll(40.5,2655795,19.7,TString("../data_test_antonios/DYJetsToLLPtZ100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Zll"),TString("Z(ll)"),5);
16+
SampleInfo ttlep(25.8,11947326*0.467,19.7,TString("../data_test_antonios/myhaddedFileTlep.root"),TString("TTbarFullyLep"),TString("tt(ll)"),5);
1417
SampleInfo Znunu50(435.71,4040980,19.7,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu50"),TString("Z(#nu#nu)"),5);
1518
SampleInfo Znunu100(186.84,4416646,19.7,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu100"),TString("Z(#nu#nu)"),5);
1619
SampleInfo Znunu200(45.60,5055885,19.7,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu200"),TString("Z(#nu#nu)"),5);
1720
SampleInfo Znunu400(6.25,1006928,19.7,TString("../data_test_antonios/ZJetsToNuNu100/markusTreeProducer/markusTreeProducer_tree.root"),TString("Znunu400"),TString("Z(#nu#nu)"),5);
1821
SampleInfo ZZ4mu(6.25,1006928,19.7,TString("/afs/cern.ch/work/m/mstoye/CMGTools_SUSY/CMSSW_5_3_14/src/CMGTools/TTHAnalysis/cfg/Zz4mu/ZZTo4mu/markusTreeProducer/markusTreeProducer_tree.root"),TString("ZZ4m"),TString("Z(#nu#nu)"),5);
19-
SampleInfo ZZ(6.25,1006928,19.7,TString("ZZpythia.root"),TString("ZZ4m"),TString("Z(#nu#nu)"),5);
22+
// SampleInfo ZZ(6.25,1006928,19.7,TString("ZZpythia.root"),TString("ZZ4m"),TString("Z(#nu#nu)"),5);
2023

2124

2225
vector <TFile*> Files;
2326
vector <SampleInfo> Names;
24-
SUSYLooperHists myZll(Zll);
27+
28+
SUSYLooperHists myZll(eosZll);
2529
TFile* myZllfile = myZll.Loop();
26-
Files.push_back(myZll);
30+
Files.push_back(myZllfile);
31+
Names.push_back(eosZll);
32+
33+
cout << endl<< "see the difference local vs. eos" <<endl <<endl;
34+
35+
SUSYLooperHists myLocalZll(Zll);
36+
TFile* myLocalZllfile = myLocalZll.Loop();
37+
Files.push_back(myLocalZllfile);
2738
Names.push_back(Zll);
39+
40+
cout <<" further samples "<<endl;
41+
2842
SUSYLooperHists mytt2l(ttlep);
2943
TFile* myttlep = mytt2l.Loop();
3044
Files.push_back(myttlep);

0 commit comments

Comments
 (0)