ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/src/HistosElecs.cc
(Generate patch)

Comparing UserCode/HbbAnalysis/src/HistosElecs.cc (file contents):
Revision 1.2 by amagnan, Fri Apr 17 14:26:35 2009 UTC vs.
Revision 1.6 by amagnan, Mon Jun 1 13:57:48 2009 UTC

# Line 1 | Line 1
1   #include <iostream>
2   #include <fstream>
3  
4 //#include "DataFormats/EgammaReco/interface/Electron.h"
5
6
4   #include "FWCore/MessageLogger/interface/MessageLogger.h"
5  
6   #include "UserCode/HbbAnalysis/interface/HistosElecs.hh"
# Line 15 | Line 12 | namespace HbbAnalysis {//namespace
12      doGenMatched_ = aDoGenMatched;
13      CreateHistos(aName,aDir);
14  
15 <    p_nElectrons = aDir.make<TH1F>("p_nElectrons",";N_{electrons};N_{entries}",20,0,20);
15 >    p_nElectrons = aDir.make<TH1F>("p_nElectrons",";N_{electrons};N_{entries}",10,0,10);
16 >
17 >    p_electronID = aDir.make<TH1F>("p_electronID",";electronID;N_{entries}",8,0,8);
18 >
19 >    p_scSigmaEtaEta = aDir.make<TH1F>("p_scSigmaEtaEta",";#sigma_{#eta,#eta};N_{entries}",500,0,0.1);
20 >    p_scSigmaIEtaIEta = aDir.make<TH1F>("p_scSigmaIEtaIEta",";#sigma_{i#eta,i#eta};N_{entries}",500,0,0.1);
21 >    p_scE1x5 = aDir.make<TH1F>("p_scE1x5",";E_{sc}^{1#times 5} (GeV);N_{entries}",500,0,500);
22 >    p_scE2x5Max = aDir.make<TH1F>("p_scE2x5Max",";E_{sc}^{2#times 5} (GeV);N_{entries}",500,0,500);
23 >    p_scE5x5 = aDir.make<TH1F>("p_scE5x5",";E_{sc}^{5#times 5} (GeV);N_{entries}",500,0,500);
24 >    p_scE1x5OverscE5x5 = aDir.make<TH1F>("p_scE1x5OverscE5x5",";E_{sc}^{1#times 5}/E_{sc}^{5#times 5};N_{entries}",500,0,2);
25 >    p_scE2x5MaxOverscE5x5 = aDir.make<TH1F>("p_scE2x5MaxOverscE5x5",";E_{sc}^{2#times 5}/E_{sc}^{5#times 5};N_{entries}",500,0,2);
26 >
27 >    p_eSuperClusterOverP = aDir.make<TH1F>("p_eSuperClusterOverP",";E_{sc}/p_{track};N_{entries}",100,0.5,2);
28 >
29 >    p_HoverE = aDir.make<TH1F>("p_HoverE",";E_{had}/E_{em};N_{entries}",150,0,0.15);
30 >    p_deltaPhiIn = aDir.make<TH1F>("p_deltaPhiIn",";#Delta#phi_{in};N_{entries}",150,0,0.15);
31 >    p_deltaEtaIn = aDir.make<TH1F>("p_deltaEtaIn",";#Delta#eta_{in};N_{entries}",150,0,0.03);
32 >
33 >    p_caloIso = aDir.make<TH1F>("p_caloIso",";caloIso;N_{entries}",400,0,20);
34 >    p_hcalIso = aDir.make<TH1F>("p_hcalIso",";hcalIso;N_{entries}",400,0,20);
35 >
36 >    p_trackIso = aDir.make<TH1F>("p_trackIso",";trackIso (GeV);N_{entries}",400,0,20);
37 >    p_trackIsoOverEt = aDir.make<TH1F>("p_trackIsoOverEt",";trackIso/E_{T};N_{entries}",400,0,1);
38 >    p_ecalIso = aDir.make<TH1F>("p_ecalIso",";ecalIso (GeV);N_{entries}",400,0,20);
39 >    p_ecalIsoOverEt = aDir.make<TH1F>("p_ecalIsoOverEt",";ecalIso/E_{T};N_{entries}",400,0,1);
40 >    p_combIso = aDir.make<TH1F>("p_combIso",";combIso (GeV);N_{entries}",400,0,40);
41 >    p_combIsoOverEt = aDir.make<TH1F>("p_combIsoOverEt",";combIso/E_{T};N_{entries}",400,0,1);
42 >
43 >    p_gsfTrk_pT = aDir.make<TH1F>("p_gsfTrk_pT",";p_{T}^{trk} (GeV);N_{entries}",200,0,200);
44 >    p_gsfTrk_IPxy = aDir.make<TH1F>("p_gsfTrk_IPxy",";IP_{xy}^{trk};N_{entries}",100,-0.1,0.1);
45 >    p_gsfTrk_IPz = aDir.make<TH1F>("p_gsfTrk_IPz",";IP_{z}^{trk};N_{entries}",100,-1,1);
46 >
47 >    //efficiency curves vs cut value
48 >    peff_eIso[0] = aDir.make<TH1F>("peff_eIso_trkIso",";trkIso (GeV);N_{sel}/N_{tot}",50,0,5);
49 >    peff_eIso[1] = aDir.make<TH1F>("peff_eIso_trkIsoOverEt",";trkIso/E_{T};N_{sel}/N_{tot}",50,0,1);
50 >    peff_eIso[2] = aDir.make<TH1F>("peff_eIso_ecalIso",";ecalIso (GeV);N_{sel}/N_{tot}",50,0,5);
51 >    peff_eIso[3] = aDir.make<TH1F>("peff_eIso_ecalIsoOverEt",";ecalIso/E_{T};N_{sel}/N_{tot}",50,0,1);
52 >    peff_eIso[4] = aDir.make<TH1F>("peff_eIso_combIso",";combIso (GeV);N_{sel}/N_{tot}",50,0,10);
53 >    peff_eIso[5] = aDir.make<TH1F>("peff_eIso_combIsoOverEt",";combIso/E_{T};N_{sel}/N_{tot}",50,0,1);
54 >
55 >    //efficiency curves vs pT muon
56 >    peff_eEt[0] = aDir.make<TH1F>("peff_eEt_trkIso",";E_{T} (GeV);N_{sel}/N_{tot}",18,10,100);
57 >    const unsigned int lNBinsPt = peff_eEt[0]->GetNbinsX();
58 >    const double lMinPt = peff_eEt[0]->GetXaxis()->GetXmin();
59 >    const double lMaxPt = peff_eEt[0]->GetXaxis()->GetXmax();
60 >    peff_eEt[1] = aDir.make<TH1F>("peff_eEt_trkIsoOverEt",";E_{T} (GeV);N_{sel}/N_{tot}",lNBinsPt,lMinPt,lMaxPt);
61 >    peff_eEt[2] = aDir.make<TH1F>("peff_eEt_ecalIso",";E_{T} (GeV);N_{sel}/N_{tot}",lNBinsPt,lMinPt,lMaxPt);
62 >    peff_eEt[3] = aDir.make<TH1F>("peff_eEt_ecalIsoOverEt",";E_{T} (GeV);N_{sel}/N_{tot}",lNBinsPt,lMinPt,lMaxPt);
63 >    peff_eEt[4] = aDir.make<TH1F>("peff_eEt_combIso",";E_{T} (GeV);N_{sel}/N_{tot}",lNBinsPt,lMinPt,lMaxPt);
64 >    peff_eEt[5] = aDir.make<TH1F>("peff_eEt_combIsoOverEt",";E_{T} (GeV);N_{sel}/N_{tot}",lNBinsPt,lMinPt,lMaxPt);
65 >
66 >
67 >    //efficiency curves vs eta muon
68 >    peff_eEta[0] = aDir.make<TH1F>("peff_eEta_trkIso",";#eta;N_{sel}/N_{tot}",42,-2.1,2.1);
69 >    const unsigned int lNBinsEta = peff_eEta[0]->GetNbinsX();
70 >    const double lMinEta = peff_eEta[0]->GetXaxis()->GetXmin();
71 >    const double lMaxEta = peff_eEta[0]->GetXaxis()->GetXmax();
72 >    peff_eEta[1] = aDir.make<TH1F>("peff_eEta_trkIsoOverEt",";#eta;N_{sel}/N_{tot}",lNBinsEta,lMinEta,lMaxEta);
73 >    peff_eEta[2] = aDir.make<TH1F>("peff_eEta_ecalIso",";#eta;N_{sel}/N_{tot}",lNBinsEta,lMinEta,lMaxEta);
74 >    peff_eEta[3] = aDir.make<TH1F>("peff_eEta_ecalIsoOverEt",";#eta;N_{sel}/N_{tot}",lNBinsEta,lMinEta,lMaxEta);
75 >    peff_eEta[4] = aDir.make<TH1F>("peff_eEta_combIso",";#eta;N_{sel}/N_{tot}",lNBinsEta,lMinEta,lMaxEta);
76 >    peff_eEta[5] = aDir.make<TH1F>("peff_eEta_combIsoOverEt",";#eta;N_{sel}/N_{tot}",lNBinsEta,lMinEta,lMaxEta);
77 >
78 >    //efficiency calculation tool
79 >    for (unsigned int i(0); i<6; i++){
80 >      const unsigned int lNBins = peff_eIso[i]->GetNbinsX();
81 >      const double lMin = peff_eIso[i]->GetXaxis()->GetXmin();
82 >      const double lMax = peff_eIso[i]->GetXaxis()->GetXmax();
83 >      isoEff_[i].initialise(lNBins,lMin,lMax);
84 >      isoEffEt_[i].initialise(lNBinsPt,lMinPt,lMaxPt);
85 >      isoEffEta_[i].initialise(lNBinsEta,lMinEta,lMaxEta);
86 >    }
87  
20    p_nChambers = aDir.make<TH1F>("p_nChambers",";n_{chambers};n_{entries}",20,0,20);
88  
89    }
90  
91 <  void HistosElecs::FillEventHistograms(edm::Handle<std::vector<pat::Electron> > aCol){
91 >  void HistosElecs::FillEventHistograms(const edm::Handle<std::vector<pat::Electron> > & aCol){
92  
93      if (doGenMatched_) {
94        unsigned int nMatched = 0;
# Line 37 | Line 104 | namespace HbbAnalysis {//namespace
104  
105    }
106  
107 <  void HistosElecs::FillHistograms(const pat::Electron & aElec, bool isLead){//FillHistograms
107 >  void HistosElecs::FillHistograms(const pat::Electron & aElec, const edm::Handle<std::vector<reco::Vertex> >& aRecoVertices, bool isLead){//FillHistograms
108  
109      bool lIsGenMatched = !doGenMatched_ || (doGenMatched_ && MatchesGenElectron(aElec));
110      if (lIsGenMatched) {//genMatched
111        if (isLead) {//isLead
112 <        FillBaseHistograms(aElec.pt(),aElec.eta(),aElec.phi());
112 >        FillBaseHistograms(aElec.pt(),aElec.eta(),aElec.phi(),aElec.charge());
113 >
114 >        if ( aElec.gsfTrack().isAvailable() && !aElec.gsfTrack().isNull() ) {
115 >          p_gsfTrk_pT->Fill(aElec.gsfTrack()->pt());
116 >          if ( aRecoVertices->size() >= 1 ) {
117 >            const reco::Vertex & thePrimaryEventVertex = (*aRecoVertices->begin());
118 >            p_gsfTrk_IPxy->Fill(aElec.gsfTrack()->dxy(thePrimaryEventVertex.position()));
119 >            p_gsfTrk_IPz->Fill(aElec.gsfTrack()->dz(thePrimaryEventVertex.position()));
120 >          }
121 >        }
122 >
123 >        std::vector<std::pair<std::string,float> > lIds = aElec.electronIDs();
124 >        if (lIds.size() > 5) std::cout << "--- WARNING: histo will be out-of-range, number of electron IDs = " << lIds.size() << std::endl;
125 >        for (unsigned int iId(0); iId<lIds.size(); iId++){
126 >          const std::string & lName =  lIds.at(iId).first;
127 >          //std::cout << "--- ElectronID : Bin " << iId << ", id name = " << lName << std::endl;
128 >          if (aElec.isElectronIDAvailable(lName)){
129 >            p_electronID->Fill(2*iId+aElec.electronID(lName));
130 >            assert (aElec.electronID(lName) ==  lIds.at(iId).second);
131 >          }
132 >        }
133 >    
134 >        p_scSigmaEtaEta->Fill(aElec.scSigmaEtaEta());
135 >        p_scSigmaIEtaIEta->Fill(aElec.scSigmaIEtaIEta());
136 >        p_scE1x5->Fill(aElec.scE1x5());
137 >        p_scE2x5Max->Fill(aElec.scE2x5Max());
138 >        p_scE5x5->Fill(aElec.scE5x5());
139 >
140 >        p_eSuperClusterOverP->Fill(aElec.eSuperClusterOverP());
141 >
142 >        p_HoverE->Fill(aElec.hadronicOverEm());
143 >        p_deltaPhiIn->Fill(aElec.deltaPhiSuperClusterTrackAtVtx());
144 >        p_deltaEtaIn->Fill(aElec.deltaEtaSuperClusterTrackAtVtx());
145 >
146 >        if (aElec.scE5x5() > 0) {
147 >          p_scE1x5OverscE5x5->Fill(aElec.scE1x5()/aElec.scE5x5());
148 >          p_scE2x5MaxOverscE5x5->Fill(aElec.scE2x5Max()/aElec.scE5x5());
149 >        }
150 >
151 >        p_caloIso->Fill(aElec.caloIso());
152 >        p_hcalIso->Fill(aElec.hcalIso());
153 >
154 >        double lIsoVar[6] = {
155 >          aElec.trackIso(),
156 >          aElec.trackIso()/aElec.et(),
157 >          aElec.ecalIso(),
158 >          aElec.ecalIso()/aElec.et(),
159 >          aElec.trackIso()+aElec.ecalIso()+aElec.hcalIso(),
160 >          (aElec.trackIso()+aElec.ecalIso()+aElec.hcalIso())/aElec.et()
161 >        };
162 >
163 >        p_trackIso->Fill(lIsoVar[0]);
164 >        p_trackIsoOverEt->Fill(lIsoVar[1]);
165 >        p_ecalIso->Fill(lIsoVar[2]);
166 >        p_ecalIsoOverEt->Fill(lIsoVar[3]);
167 >        p_combIso->Fill(lIsoVar[4]);
168 >        p_combIsoOverEt->Fill(lIsoVar[5]);
169 >
170 >        double lIsoCut[6] = {1.,0.1,4.,0.1,5.,0.2};
171 >
172 >        for (unsigned int i(0); i<6; i++){//loop on iso variables
173 >
174 >          for (unsigned int lBin(0); lBin<isoEff_[i].numberOfBins(); lBin++){
175 >            double lCut = isoEff_[i].xMin()+isoEff_[i].stepSize()*lBin;
176 >
177 >            isoEff_[i].incrementTotal(lBin);
178 >            if (lIsoVar[i] <= lCut){
179 >              isoEff_[i].incrementPass(lBin);
180 >            }
181 >          }
182 >  
183 >          //eff vs pT
184 >          for (unsigned int lBin(0); lBin<isoEffEt_[i].numberOfBins(); lBin++){
185 >            double lCutMin = isoEffEt_[i].xMin()+isoEffEt_[i].stepSize()*lBin;
186 >            double lCutMax = isoEffEt_[i].xMin()+isoEffEt_[i].stepSize()*(lBin+1);
187 >
188 >            if (aElec.et() >= lCutMin && aElec.et() < lCutMax){
189 >              isoEffEt_[i].incrementTotal(lBin);
190 >
191 >              if (lIsoVar[i] <= lIsoCut[i]){
192 >                isoEffEt_[i].incrementPass(lBin);
193 >              }
194 >            }
195 >          }
196 >
197 >          //eff vs eta
198 >          for (unsigned int lBin(0); lBin<isoEffEta_[i].numberOfBins(); lBin++){
199 >            double lCutMin = isoEffEta_[i].xMin()+isoEffEta_[i].stepSize()*lBin;
200 >            double lCutMax = isoEffEta_[i].xMin()+isoEffEta_[i].stepSize()*(lBin+1);
201 >
202 >            if (aElec.eta() >= lCutMin && aElec.eta() < lCutMax){
203 >              isoEffEta_[i].incrementTotal(lBin);
204 >
205 >              if (lIsoVar[i] <= lIsoCut[i]){
206 >                isoEffEta_[i].incrementPass(lBin);
207 >              }
208 >            }
209 >          }
210 >
211 >
212 >        }//loop on iso variables
213 >
214 >
215  
216        }//isLead
217      }//genMatched
218  
219    }//FillHistograms
220  
221 +
222 +
223 +  void HistosElecs::FillEffHistograms(){//FillEffHistograms
224 +
225 +    for (unsigned int i(0); i<6; i++){//loop on iso variables
226 +
227 +      for (unsigned int lBin(0); lBin<isoEff_[i].numberOfBins(); lBin++){
228 +        peff_eIso[i]->SetBinContent(lBin+1,isoEff_[i].getRatio(lBin));
229 +        peff_eIso[i]->SetBinError(lBin+1,isoEff_[i].getRatioError(lBin));
230 +      }
231 +      //eff vs pT
232 +      for (unsigned int lBin(0); lBin<isoEffEt_[i].numberOfBins(); lBin++){
233 +        peff_eEt[i]->SetBinContent(lBin+1,isoEffEt_[i].getRatio(lBin));
234 +        peff_eEt[i]->SetBinError(lBin+1,isoEffEt_[i].getRatioError(lBin));
235 +      }
236 +
237 +      //eff vs eta
238 +      for (unsigned int lBin(0); lBin<isoEffEta_[i].numberOfBins(); lBin++){
239 +        peff_eEta[i]->SetBinContent(lBin+1,isoEffEta_[i].getRatio(lBin));
240 +        peff_eEta[i]->SetBinError(lBin+1,isoEffEta_[i].getRatioError(lBin));
241 +      }
242 +
243 +    }//loop on iso variables
244 +
245 +  }//FillEffHistograms
246 +
247 +
248    bool HistosElecs::MatchesGenElectron(const pat::Electron& aPatElec)
249    {
250      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines