1 |
amagnan |
1.1 |
#include <iostream>
|
2 |
|
|
#include <fstream>
|
3 |
|
|
|
4 |
amagnan |
1.2 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
|
6 |
amagnan |
1.1 |
#include "UserCode/HbbAnalysis/interface/HistosElecs.hh"
|
7 |
|
|
|
8 |
|
|
namespace HbbAnalysis {//namespace
|
9 |
|
|
|
10 |
amagnan |
1.2 |
void HistosElecs::Initialise(TFileDirectory & aDir, std::string aName, bool aDoGenMatched){
|
11 |
amagnan |
1.1 |
|
12 |
amagnan |
1.2 |
doGenMatched_ = aDoGenMatched;
|
13 |
amagnan |
1.1 |
CreateHistos(aName,aDir);
|
14 |
|
|
|
15 |
amagnan |
1.2 |
p_nElectrons = aDir.make<TH1F>("p_nElectrons",";N_{electrons};N_{entries}",20,0,20);
|
16 |
|
|
|
17 |
amagnan |
1.3 |
p_electronID = aDir.make<TH1F>("p_electronID",";electronID;N_{entries}",10,0,10);
|
18 |
|
|
|
19 |
|
|
p_scSigmaEtaEta = aDir.make<TH1F>("p_scSigmaEtaEta",";;N_{entries}",100,0,0.1);
|
20 |
|
|
p_scSigmaIEtaIEta = aDir.make<TH1F>("p_scSigmaIEtaIEta",";;N_{entries}",100,0,0.1);
|
21 |
amagnan |
1.4 |
p_scE1x5 = aDir.make<TH1F>("p_scE1x5",";;N_{entries}",500,0,500);
|
22 |
|
|
p_scE2x5Max = aDir.make<TH1F>("p_scE2x5Max",";;N_{entries}",500,0,500);
|
23 |
amagnan |
1.3 |
p_scE5x5 = aDir.make<TH1F>("p_scE5x5",";;N_{entries}",500,0,500);
|
24 |
amagnan |
1.4 |
p_scE1x5OverscE5x5 = aDir.make<TH1F>("p_scE1x5OverscE5x5",";;N_{entries}",500,0,1);
|
25 |
|
|
p_scE2x5MaxOverscE5x5 = aDir.make<TH1F>("p_scE2x5MaxOverscE5x5",";;N_{entries}",500,0,1);
|
26 |
amagnan |
1.3 |
|
27 |
|
|
p_trackIso = aDir.make<TH1F>("p_trackIso",";;N_{entries}",400,0,20);
|
28 |
|
|
p_caloIso = aDir.make<TH1F>("p_caloIso",";;N_{entries}",400,0,20);
|
29 |
|
|
p_ecalIso = aDir.make<TH1F>("p_ecalIso",";;N_{entries}",400,0,20);
|
30 |
|
|
p_hcalIso = aDir.make<TH1F>("p_hcalIso",";;N_{entries}",400,0,20);
|
31 |
|
|
|
32 |
|
|
p_gsfTrk_pT = aDir.make<TH1F>("p_gsfTrk_pT",";;N_{entries}",200,0,200);
|
33 |
|
|
p_gsfTrk_IPxy = aDir.make<TH1F>("p_gsfTrk_IPxy",";;N_{entries}",100,-0.1,0.1);
|
34 |
|
|
p_gsfTrk_IPz = aDir.make<TH1F>("p_gsfTrk_IPz",";;N_{entries}",100,-1,1);
|
35 |
|
|
|
36 |
amagnan |
1.1 |
|
37 |
|
|
}
|
38 |
|
|
|
39 |
amagnan |
1.2 |
void HistosElecs::FillEventHistograms(edm::Handle<std::vector<pat::Electron> > aCol){
|
40 |
|
|
|
41 |
|
|
if (doGenMatched_) {
|
42 |
|
|
unsigned int nMatched = 0;
|
43 |
|
|
for (std::vector<pat::Electron>::const_iterator iElec = aCol->begin();
|
44 |
|
|
iElec != aCol->end();
|
45 |
|
|
iElec++)
|
46 |
|
|
{
|
47 |
|
|
if (MatchesGenElectron(*iElec)) nMatched++;
|
48 |
|
|
}
|
49 |
|
|
p_nElectrons->Fill(nMatched);
|
50 |
|
|
}
|
51 |
|
|
else p_nElectrons->Fill(aCol->size());
|
52 |
|
|
|
53 |
|
|
}
|
54 |
|
|
|
55 |
amagnan |
1.3 |
void HistosElecs::FillHistograms(const pat::Electron & aElec, edm::Handle<std::vector<reco::Vertex> > aRecoVertices, bool isLead){//FillHistograms
|
56 |
amagnan |
1.1 |
|
57 |
amagnan |
1.2 |
bool lIsGenMatched = !doGenMatched_ || (doGenMatched_ && MatchesGenElectron(aElec));
|
58 |
|
|
if (lIsGenMatched) {//genMatched
|
59 |
|
|
if (isLead) {//isLead
|
60 |
|
|
FillBaseHistograms(aElec.pt(),aElec.eta(),aElec.phi());
|
61 |
amagnan |
1.1 |
|
62 |
amagnan |
1.3 |
if ( aElec.gsfTrack().isAvailable() && !aElec.gsfTrack().isNull() ) {
|
63 |
|
|
p_gsfTrk_pT->Fill(aElec.gsfTrack()->pt());
|
64 |
|
|
if ( aRecoVertices->size() >= 1 ) {
|
65 |
|
|
const reco::Vertex & thePrimaryEventVertex = (*aRecoVertices->begin());
|
66 |
|
|
p_gsfTrk_IPxy->Fill(aElec.gsfTrack()->dxy(thePrimaryEventVertex.position()));
|
67 |
|
|
p_gsfTrk_IPz->Fill(aElec.gsfTrack()->dz(thePrimaryEventVertex.position()));
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
std::vector<std::pair<std::string,float> > lIds = aElec.electronIDs();
|
72 |
|
|
if (lIds.size() > 5) std::cout << "--- WARNING: histo will be out-of-range, number of electron IDs = " << lIds.size() << std::endl;
|
73 |
|
|
for (unsigned int iId(0); iId<lIds.size(); iId++){
|
74 |
|
|
const std::string & lName = lIds.at(iId).first;
|
75 |
amagnan |
1.4 |
//std::cout << "--- ElectronID : Bin " << iId << ", id name = " << lName << std::endl;
|
76 |
amagnan |
1.3 |
if (aElec.isElectronIDAvailable(lName)){
|
77 |
|
|
p_electronID->Fill(2*iId+aElec.electronID(lName));
|
78 |
|
|
assert (aElec.electronID(lName) == lIds.at(iId).second);
|
79 |
|
|
}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
p_scSigmaEtaEta->Fill(aElec.scSigmaEtaEta());
|
83 |
|
|
p_scSigmaIEtaIEta->Fill(aElec.scSigmaIEtaIEta());
|
84 |
|
|
p_scE1x5->Fill(aElec.scE1x5());
|
85 |
|
|
p_scE2x5Max->Fill(aElec.scE2x5Max());
|
86 |
|
|
p_scE5x5->Fill(aElec.scE5x5());
|
87 |
|
|
|
88 |
amagnan |
1.4 |
if (aElec.scE5x5() > 0) {
|
89 |
|
|
p_scE1x5OverscE5x5->Fill(aElec.scE1x5()/aElec.scE5x5());
|
90 |
|
|
p_scE2x5MaxOverscE5x5->Fill(aElec.scE2x5Max()/aElec.scE5x5());
|
91 |
|
|
}
|
92 |
|
|
|
93 |
amagnan |
1.3 |
p_trackIso->Fill(aElec.trackIso());
|
94 |
|
|
p_caloIso->Fill(aElec.caloIso());
|
95 |
|
|
p_ecalIso->Fill(aElec.ecalIso());
|
96 |
|
|
p_hcalIso->Fill(aElec.hcalIso());
|
97 |
|
|
|
98 |
|
|
|
99 |
amagnan |
1.2 |
}//isLead
|
100 |
|
|
}//genMatched
|
101 |
amagnan |
1.1 |
|
102 |
|
|
}//FillHistograms
|
103 |
|
|
|
104 |
amagnan |
1.2 |
bool HistosElecs::MatchesGenElectron(const pat::Electron& aPatElec)
|
105 |
|
|
{
|
106 |
|
|
|
107 |
|
|
bool isGenMatched = false;
|
108 |
|
|
|
109 |
|
|
const std::vector<reco::GenParticleRef> & lVec = aPatElec.genParticleRefs();
|
110 |
|
|
for ( std::vector<reco::GenParticleRef>::const_iterator it = lVec.begin();
|
111 |
|
|
it != lVec.end(); ++it ) {
|
112 |
|
|
if ( it->ref().isNonnull() && it->ref().isValid() ) {
|
113 |
|
|
const reco::GenParticleRef & genParticle = (*it);
|
114 |
|
|
if ( genParticle->pdgId() == -11 || genParticle->pdgId() == +11 ) isGenMatched = true;
|
115 |
|
|
} else {
|
116 |
|
|
edm::LogWarning("MatchesGenElectron") << " edm::Ref of genParticle associated to pat::Electron is invalid !!";
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
return isGenMatched;
|
120 |
|
|
}
|
121 |
|
|
|
122 |
amagnan |
1.1 |
}//namespace
|
123 |
|
|
|
124 |
|
|
|