ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonPairSelector.cc
Revision: 1.9
Committed: Thu Sep 8 15:51:23 2011 UTC (13 years, 8 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025pre1
Changes since 1.8: +66 -16 lines
Log Message:
Add tool and required changes for photon energy regression

File Contents

# User Rev Content
1 fabstoec 1.1 #include "MitPhysics/Mods/interface/PhotonPairSelector.h"
2     #include "MitAna/DataTree/interface/PhotonCol.h"
3     #include "MitAna/DataTree/interface/PFCandidateCol.h"
4 bendavid 1.8 #include "MitAna/DataTree/interface/StableData.h"
5     #include "MitAna/DataTree/interface/StableParticle.h"
6 fabstoec 1.1 #include "MitPhysics/Init/interface/ModNames.h"
7     #include "MitPhysics/Utils/interface/IsolationTools.h"
8     #include "MitPhysics/Utils/interface/PhotonTools.h"
9     #include "MitPhysics/Utils/interface/VertexTools.h"
10 bendavid 1.6 #include "MitPhysics/Utils/interface/PhotonFix.h"
11 bendavid 1.5 #include "TDataMember.h"
12 fabstoec 1.1 #include <TNtuple.h>
13     #include <TRandom3.h>
14 bendavid 1.6 #include <TSystem.h>
15 bendavid 1.9 #include <TH1D.h>
16 fabstoec 1.1
17     using namespace mithep;
18    
19     ClassImp(mithep::PhotonPairSelector)
20    
21     //--------------------------------------------------------------------------------------------------
22     PhotonPairSelector::PhotonPairSelector(const char *name, const char *title) :
23     // Base Module...
24     BaseMod (name,title),
25    
26     // define all the Branches to load
27     fPhotonBranchName (Names::gkPhotonBrn),
28     fElectronName (Names::gkElectronBrn),
29 bendavid 1.8 fGoodElectronName (Names::gkElectronBrn),
30 fabstoec 1.1 fConversionName (Names::gkMvfConversionBrn),
31     fTrackBranchName (Names::gkTrackBrn),
32     fPileUpDenName (Names::gkPileupEnergyDensityBrn),
33     fPVName (Names::gkPVBeamSpotBrn),
34     fBeamspotName (Names::gkBeamSpotBrn),
35     fPFCandName (Names::gkPFCandidatesBrn),
36     // MC specific stuff...
37     fMCParticleName (Names::gkMCPartBrn),
38     fPileUpName (Names::gkPileupInfoBrn),
39    
40     fGoodPhotonsName (ModNames::gkGoodPhotonsName),
41    
42     // ----------------------------------------
43     // Selection Types
44     fPhotonSelType ("NoSelection"),
45     fVertexSelType ("StdSelection"),
46     fPhSelType (kNoPhSelection),
47     fVtxSelType (kStdVtxSelection),
48    
49     // ----------------------------------------
50     fPhotonPtMin (20.0),
51     fPhotonEtaMax (2.5),
52    
53     fLeadingPtMin (40.0),
54     fTrailingPtMin (30.0),
55    
56     fIsData (false),
57     fPhotonsFromBranch (true),
58     fPVFromBranch (true),
59 bendavid 1.8 fGoodElectronsFromBranch (kTRUE),
60    
61 fabstoec 1.1 // ----------------------------------------
62     // collections....
63     fPhotons (0),
64     fElectrons (0),
65     fConversions (0),
66     fTracks (0),
67     fPileUpDen (0),
68     fPV (0),
69     fBeamspot (0),
70     fPFCands (0),
71     fMCParticles (0),
72     fPileUp (0),
73    
74     // ---------------------------------------
75     fDataEnCorr_EB_hR9 (0.),
76     fDataEnCorr_EB_lR9 (0.),
77     fDataEnCorr_EE_hR9 (0.),
78     fDataEnCorr_EE_lR9 (0.),
79    
80     fRunStart (0),
81     fRunEnd (0),
82    
83     fMCSmear_EB_hR9 (0.),
84     fMCSmear_EB_lR9 (0.),
85     fMCSmear_EE_hR9 (0.),
86     fMCSmear_EE_lR9 (0.),
87    
88     // ---------------------------------------
89     rng (new TRandom3()),
90 bendavid 1.9 fDoRegression (kFALSE),
91     fPhFixString ("4_2"),
92     fEBWeights ("/mnt/hadoop/bendavid/weights-Base/TMVARegressionebph_BDTG.weights.xml"),
93     fEBVarWeights ("/mnt/hadoop/bendavid/weights-Base/TMVARegressionVarianceebph_BDTG.weights.xml"),
94     fEEWeights ("/mnt/hadoop/bendavid/weights-Base/TMVARegressioneeph_BDTG.weights.xml"),
95     fEEVarWeights ("/mnt/hadoop/bendavid/weights-Base/TMVARegressionVarianceeeph_BDTG.weights.xml"),
96     fEtaCorrections (0),
97 fabstoec 1.1 // ---------------------------------------
98     fDoDataEneCorr (true),
99     fDoMCSmear (true),
100 fabstoec 1.2 fDoVtxSelection (true),
101     fApplyEleVeto (true),
102 bendavid 1.8 fInvertElectronVeto(kFALSE)
103 fabstoec 1.1 {
104     // Constructor.
105     }
106    
107     PhotonPairSelector::~PhotonPairSelector(){
108     if(rng) delete rng;
109     }
110    
111     //--------------------------------------------------------------------------------------------------
112     void PhotonPairSelector::Process()
113     {
114     // ------------------------------------------------------------
115     // Process entries of the tree.
116     LoadEventObject(fPhotonBranchName, fPhotons);
117 bendavid 1.8
118     // -----------------------------------------------------------
119     // OUtput Photon Collection. It will ALWAYS conatrin either 0 or 2 Photons
120     PhotonOArr *GoodPhotons = new PhotonOArr;
121     GoodPhotons->SetName(fGoodPhotonsName);
122     GoodPhotons->SetOwner(kTRUE);
123     // add to event for other modules to use
124     AddObjThisEvt(GoodPhotons);
125    
126     if (fPhotons->GetEntries()<2) return;
127    
128 fabstoec 1.1 LoadEventObject(fElectronName, fElectrons);
129 bendavid 1.8 LoadEventObject(fGoodElectronName, fGoodElectrons);
130 fabstoec 1.1 LoadEventObject(fConversionName, fConversions);
131     LoadEventObject(fTrackBranchName, fTracks);
132     LoadEventObject(fPileUpDenName, fPileUpDen);
133     LoadEventObject(fPVName, fPV);
134     LoadEventObject(fBeamspotName, fBeamspot);
135     LoadEventObject(fPFCandName, fPFCands);
136    
137 bendavid 1.6
138 fabstoec 1.1
139 bendavid 1.8
140 fabstoec 1.1
141    
142     // ------------------------------------------------------------
143     // load event based information
144 bendavid 1.4 Int_t _numPU = -1.; // some sensible default values....
145     Int_t _numPUminus = -1.; // some sensible default values....
146     Int_t _numPUplus = -1.; // some sensible default values....
147    
148 fabstoec 1.1 Float_t _tRho = -99.;
149 fabstoec 1.2 if( fPileUpDen->GetEntries() > 0 )
150     _tRho = (Double_t) fPileUpDen->At(0)->RhoRandomLowEta();
151 bendavid 1.6
152    
153 fabstoec 1.2
154 fabstoec 1.1 const BaseVertex *bsp = dynamic_cast<const BaseVertex*>(fBeamspot->At(0));
155    
156     // ------------------------------------------------------------
157     // Get Event header for Run info etc.
158     const EventHeader* evtHead = this->GetEventHeader();
159     unsigned int evtNum = evtHead->EvtNum();
160 fabstoec 1.7 //Float_t _evtNum1 = (Float_t) ( (int) (evtNum/10000.) );
161     //Float_t _evtNum2 = (Float_t) ( (int) (evtNum % 10000) );
162 fabstoec 1.1 UInt_t runNumber = evtHead->RunNum();
163     Float_t _runNum = (Float_t) runNumber;
164     Float_t _lumiSec = (Float_t) evtHead->LumiSec();
165    
166     // ------------------------------------------------------------
167     // here we'll store the preselected Photons (and which CiCCategory they are...)
168     PhotonOArr* preselPh = new PhotonOArr;
169     std::vector<PhotonTools::CiCBaseLineCats> preselCat;
170     preselCat.resize(0);
171    
172     // 1. we do the pre-selection; but keep the non-passing photons in a secont container...
173     for (UInt_t i=0; i<fPhotons->GetEntries(); ++i) {
174     const Photon *ph = fPhotons->At(i);
175    
176     if(ph->SCluster()->AbsEta()>= fPhotonEtaMax || (ph->SCluster()->AbsEta()>=1.4442 && ph->SCluster()->AbsEta()<=1.566)) continue;
177     if(ph->Et() < fPhotonPtMin) continue;
178     if(ph->HadOverEm() > 0.15) continue;
179     if(ph->IsEB()) {
180     if(ph->CoviEtaiEta() > 0.013) continue;
181     } else {
182     if(ph->CoviEtaiEta() > 0.03) continue;
183     }
184     preselPh->Add(ph);
185 fabstoec 1.2 }
186    
187 bendavid 1.8 if (preselPh->GetEntries()<2) return;
188    
189 fabstoec 1.2 // Sorry... need the second loop here in order to sort & assign the right Categories..
190     preselPh->Sort();
191     for(unsigned int iPh = 0; iPh <preselPh->GetEntries(); ++iPh) {
192     const Photon* ph = preselPh->At(iPh);
193 fabstoec 1.1 preselCat.push_back(PhotonTools::CiCBaseLineCat(ph));
194     }
195    
196     // ------------------------------------------------------------
197     // compute how many pairs there are ...
198     unsigned int numPairs = 0;
199     if( preselPh->GetEntries() > 0) numPairs = (preselPh->GetEntries()-1)*preselPh->GetEntries()/2;
200     // ... and create all possible pairs of pre-selected photons
201     std::vector<unsigned int> idx1st;
202     std::vector<unsigned int> idx2nd;
203     std::vector<PhotonTools::CiCBaseLineCats> cat1st;
204     std::vector<PhotonTools::CiCBaseLineCats> cat2nd;
205     // ... this will be used to store whether a givne pair passes the cuts
206     std::vector<bool> pairPasses;
207    
208     if(numPairs > 0) {
209     for(unsigned int i1st = 0; i1st <preselPh->GetEntries() - 1; ++i1st) {
210     for(unsigned int i2nd = i1st + 1; i2nd <preselPh->GetEntries(); ++i2nd) {
211     idx1st.push_back(i1st);
212     idx2nd.push_back(i2nd);
213     pairPasses.push_back(true);
214     }
215     }
216     }
217    
218     // ------------------------------------------------------------
219     // array to store the index of 'chosen Vtx' for each pair
220     const Vertex** theVtx = new const Vertex*[numPairs]; // holds the 'chosen' Vtx for each Pair
221     Photon** fixPh1st = new Photon*[numPairs]; // holds the 1st Photon for each Pair
222     Photon** fixPh2nd = new Photon*[numPairs]; // holds the 2nd photon for each Pair
223    
224    
225     // store pair-indices for pairs passing the selection
226     std::vector<unsigned int> passPairs;
227     passPairs.resize(0);
228    
229     // ------------------------------------------------------------
230     // Loop over all Pairs and to the 'incredible machine' running....
231     for(unsigned int iPair = 0; iPair < numPairs; ++iPair) {
232    
233     // first we need a hard copy of the incoming photons
234     fixPh1st[iPair] = new Photon(*preselPh->At(idx1st[iPair]));
235     fixPh2nd[iPair] = new Photon(*preselPh->At(idx2nd[iPair]));
236     // we also store the category, so we don't have to ask all the time...
237     cat1st.push_back(preselCat[idx1st[iPair]]);
238     cat2nd.push_back(preselCat[idx2nd[iPair]]);
239 bendavid 1.9
240     if (fDoRegression) {
241     if (!egcor.IsInitialized()) {
242     //egcor.Initialize(!fIsData,"4_2",gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFixGRPV22.dat"),"/scratch/bendavid/root/weights-Base/TMVARegressionebph_BDTG.weights.xml","/scratch/bendavid/root/weights-Base/TMVARegressionVarianceebph_BDTG.weights.xml","/scratch/bendavid/root/weights-Base/TMVARegressioneeph_BDTG.weights.xml","/scratch/bendavid/root/weights-Base/TMVARegressionVarianceeeph_BDTG.weights.xml");
243     egcor.Initialize(!fIsData,fPhFixString,fPhFixFile,fEBWeights,fEBVarWeights,fEEWeights,fEEVarWeights);
244     }
245    
246     egcor.CorrectEnergyWithError(fixPh1st[iPair]);
247     egcor.CorrectEnergyWithError(fixPh2nd[iPair]);
248    
249     ThreeVectorC scpos1 = fixPh1st[iPair]->SCluster()->Point();
250     ThreeVectorC scpos2 = fixPh2nd[iPair]->SCluster()->Point();
251    
252     fixPh1st[iPair]->SetCaloPosXYZ(scpos1.X(),scpos1.Y(),scpos1.Z());
253     fixPh2nd[iPair]->SetCaloPosXYZ(scpos2.X(),scpos2.Y(),scpos2.Z());
254    
255    
256     }
257 fabstoec 1.1
258     // now we dicide if we either scale (Data) or Smear (MC) the Photons
259     if (fIsData) {
260     if(fDoDataEneCorr) {
261     // statring with scale = 1.
262     double scaleFac1 = 1.;
263     double scaleFac2 = 1.;
264 bendavid 1.9
265     //eta-dependent corrections
266     if (fEtaCorrections) {
267     double etacor1 = fEtaCorrections->GetBinContent(fEtaCorrections->GetXaxis()->FindFixBin(fixPh1st[iPair]->SCluster()->Eta()));
268     double etacor2 = fEtaCorrections->GetBinContent(fEtaCorrections->GetXaxis()->FindFixBin(fixPh2nd[iPair]->SCluster()->Eta()));
269    
270     scaleFac1 *= (etacor1*etacor1);
271     scaleFac2 *= (etacor2*etacor2);
272     }
273    
274 fabstoec 1.1 // checking the run Rangees ...
275     Int_t runRange = FindRunRangeIdx(runNumber);
276     if(runRange > -1) {
277 bendavid 1.9 scaleFac1 /= (1.0+GetDataEnCorr(runRange, cat1st[iPair]));
278     scaleFac2 /= (1.0+GetDataEnCorr(runRange, cat2nd[iPair]));
279 fabstoec 1.1 }
280     PhotonTools::ScalePhoton(fixPh1st[iPair], scaleFac1);
281     PhotonTools::ScalePhoton(fixPh2nd[iPair], scaleFac2);
282     }
283 bendavid 1.9 }
284    
285     if(fDoMCSmear) {
286    
287     double width1 = GetMCSmearFac(cat1st[iPair]);
288     double width2 = GetMCSmearFac(cat2nd[iPair]);
289    
290     if (!fIsData) {
291     // get the seed to do deterministic smearing...
292     UInt_t seedBase = (UInt_t) evtNum + (UInt_t) _runNum + (UInt_t) _lumiSec;
293     UInt_t seed1 = seedBase + (UInt_t) fixPh1st[iPair]->E() + (UInt_t) (TMath::Abs(10.*fixPh1st[iPair]->SCluster()->Eta()));
294     UInt_t seed2 = seedBase + (UInt_t) fixPh2nd[iPair]->E() + (UInt_t) (TMath::Abs(10.*fixPh2nd[iPair]->SCluster()->Eta()));
295     // get the smearing for MC photons..
296 fabstoec 1.3
297 bendavid 1.9 PhotonTools::SmearPhoton(fixPh1st[iPair], rng, width1, seed1);
298     PhotonTools::SmearPhoton(fixPh2nd[iPair], rng, width2, seed2);
299 fabstoec 1.1 }
300 bendavid 1.9
301    
302     PhotonTools::SmearPhotonError(fixPh1st[iPair], width1);
303     PhotonTools::SmearPhotonError(fixPh2nd[iPair], width2);
304    
305 fabstoec 1.1 }
306 bendavid 1.9
307 fabstoec 1.1
308     // store the vertex for this pair
309     switch( fVtxSelType ){
310     case kStdVtxSelection:
311     theVtx[iPair] = fPV->At(0);
312     break;
313     case kCiCVtxSelection:
314     theVtx[iPair] = VertexTools::findVtxBasicRanking(fixPh1st[iPair],fixPh2nd[iPair], bsp, fPV, fConversions);
315     break;
316     case kMITVtxSelection:
317     // need PFCandidate Collection
318     theVtx[iPair] = VertexTools::BestVtx(fPFCands, fPV, bsp, mithep::FourVector((fixPh1st[iPair]->Mom()+fixPh2nd[iPair]->Mom())));
319     break;
320     default:
321     theVtx[iPair] = fPV->At(0);
322 fabstoec 1.2
323 fabstoec 1.1 }
324 bendavid 1.8
325     //set PV ref in photons
326     fixPh1st[iPair]->SetPV(theVtx[iPair]);
327     fixPh2nd[iPair]->SetPV(theVtx[iPair]);
328 fabstoec 1.2
329 fabstoec 1.1 // fix the kinematics for both events
330     FourVectorM newMom1st = fixPh1st[iPair]->MomVtx(theVtx[iPair]->Position());
331     FourVectorM newMom2nd = fixPh2nd[iPair]->MomVtx(theVtx[iPair]->Position());
332     fixPh1st[iPair]->SetMom(newMom1st.X(), newMom1st.Y(), newMom1st.Z(), newMom1st.E());
333     fixPh2nd[iPair]->SetMom(newMom2nd.X(), newMom2nd.Y(), newMom2nd.Z(), newMom2nd.E());
334    
335     // check if both photons pass the CiC selection
336     // FIX-ME: Add other possibilities....
337     bool pass1 = false;
338     bool pass2 = false;
339 bendavid 1.8 switch( fPhSelType ){
340 fabstoec 1.1 case kNoPhSelection:
341     pass1 = ( fixPh1st[iPair]->Pt() > fLeadingPtMin );
342     pass2 = ( fixPh2nd[iPair]->Pt() > fTrailingPtMin );
343     break;
344     case kCiCPhSelection:
345 fabstoec 1.3
346    
347 fabstoec 1.2 pass1 = PhotonTools::PassCiCSelection(fixPh1st[iPair], theVtx[iPair], fTracks, fElectrons, fPV, _tRho, fLeadingPtMin, fApplyEleVeto);
348     if(pass1) pass2 = PhotonTools::PassCiCSelection(fixPh2nd[iPair], theVtx[iPair], fTracks, fElectrons, fPV, _tRho, fTrailingPtMin, fApplyEleVeto);
349 fabstoec 1.3
350 fabstoec 1.1 break;
351     case kMITPhSelection:
352 fabstoec 1.3 // FIX-ME: This is a place-holder.. MIT guys: Please work hard... ;)
353 fabstoec 1.1 pass1 = ( fixPh1st[iPair]->Pt() > fLeadingPtMin );
354     pass2 = ( fixPh2nd[iPair]->Pt() > fTrailingPtMin );
355     break;
356     default:
357     pass1 = true;
358     pass2 = true;
359     }
360 bendavid 1.8
361     //match to good electrons if requested
362     if (fInvertElectronVeto) {
363     pass1 &= !PhotonTools::PassElectronVeto(fixPh1st[iPair],fGoodElectrons);
364     pass2 &= !PhotonTools::PassElectronVeto(fixPh2nd[iPair],fGoodElectrons);
365     }
366 fabstoec 1.1 // finally, if both Photons pass the selections, add the pair to the 'passing Pairs)
367     if( pass1 && pass2 ) passPairs.push_back(iPair);
368     }
369    
370    
371     // ---------------------------------------------------------------
372     // ... we're almost done, stau focused...
373     // loop over all passing pairs and find the one with the highest sum Et
374     const Vertex* _theVtx = NULL;
375     Photon* phHard = NULL;
376     Photon* phSoft = NULL;
377    
378     PhotonTools::CiCBaseLineCats catPh1 = PhotonTools::kCiCNoCat;
379     PhotonTools::CiCBaseLineCats catPh2 = PhotonTools::kCiCNoCat;
380    
381     double maxSumEt = 0.;
382     for(unsigned int iPair=0; iPair<passPairs.size(); ++iPair){
383     double sumEt = fixPh1st[passPairs[iPair]]->Et();
384     sumEt += fixPh2nd[passPairs[iPair]]->Et();
385     if( sumEt > maxSumEt ) {
386     maxSumEt = sumEt;
387     phHard = fixPh1st[passPairs[iPair]];
388     phSoft = fixPh2nd[passPairs[iPair]];
389     catPh1 = cat1st[passPairs[iPair]];
390     catPh2 = cat2nd[passPairs[iPair]];
391     _theVtx = theVtx[iPair];
392     }
393     }
394    
395     // ---------------------------------------------------------------
396     // we have the Photons (*PARTY*)... compute some useful qunatities
397    
398 bendavid 1.8
399 fabstoec 1.1
400     if(phHard && phSoft) {
401     GoodPhotons->AddOwned(phHard);
402     GoodPhotons->AddOwned(phSoft);
403     }
404    
405    
406     // sort according to pt
407     GoodPhotons->Sort();
408    
409     // delete auxiliary photon collection...
410     delete preselPh;
411     delete[] theVtx;
412 bendavid 1.4
413 fabstoec 1.1 return;
414    
415     }
416    
417     //--------------------------------------------------------------------------------------------------
418     void PhotonPairSelector::SlaveBegin()
419     {
420     // Run startup code on the computer (slave) doing the actual analysis. Here,
421     // we just request the photon collection branch.
422    
423     ReqEventObject(fPhotonBranchName, fPhotons, fPhotonsFromBranch);
424     ReqEventObject(fTrackBranchName, fTracks, true);
425     ReqEventObject(fElectronName, fElectrons, true);
426 bendavid 1.8 ReqEventObject(fGoodElectronName, fGoodElectrons, fGoodElectronsFromBranch);
427 fabstoec 1.1 ReqEventObject(fPileUpDenName, fPileUpDen, true);
428     ReqEventObject(fPVName, fPV, fPVFromBranch);
429     ReqEventObject(fConversionName, fConversions,true);
430     ReqEventObject(fBeamspotName, fBeamspot, true);
431     ReqEventObject(fPFCandName, fPFCands, true);
432    
433     if (!fIsData) {
434     ReqBranch(fPileUpName, fPileUp);
435     ReqBranch(fMCParticleName, fMCParticles);
436     }
437    
438     if (fPhotonSelType.CompareTo("CiCSelection") == 0)
439     fPhSelType = kCiCPhSelection;
440     else if (fPhotonSelType.CompareTo("MITSelection") == 0)
441     fPhSelType = kMITPhSelection;
442     else
443     fPhSelType = kNoPhSelection;
444    
445     if (fVertexSelType.CompareTo("CiCSelection") == 0)
446     fVtxSelType = kCiCVtxSelection;
447     else if (fVertexSelType.CompareTo("MITSelection") == 0)
448     fVtxSelType = kMITVtxSelection;
449     else
450     fVtxSelType = kStdVtxSelection;
451    
452 bendavid 1.9 if (fIsData) {
453     fPhFixFile = gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFixGRPV22.dat");
454     }
455     else {
456     fPhFixFile = gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat");
457     }
458    
459 fabstoec 1.1 }
460    
461     // ----------------------------------------------------------------------------------------
462     // some helpfer functions....
463 bendavid 1.8 void PhotonPairSelector::FindHiggsPtAndZ(Float_t& pt, Float_t& decayZ, Float_t& mass) {
464 fabstoec 1.1
465     pt = -999.;
466     decayZ = -999.;
467 bendavid 1.8 mass = -999.;
468 fabstoec 1.1
469     // loop over all GEN particles and look for status 1 photons
470     for(UInt_t i=0; i<fMCParticles->GetEntries(); ++i) {
471     const MCParticle* p = fMCParticles->At(i);
472 bendavid 1.8 if( p->Is(MCParticle::kH) || (!fApplyEleVeto && p->AbsPdgId()==23) ) {
473     pt=p->Pt();
474     decayZ = p->DecayVertex().Z();
475     mass = p->Mass();
476     break;
477     }
478 fabstoec 1.1 }
479    
480     return;
481     }
482    
483     // this routine looks for the idx of the run-range
484     Int_t PhotonPairSelector::FindRunRangeIdx(UInt_t run) {
485     Int_t runRange=-1;
486     for(UInt_t iRun = 0; iRun<fRunStart.size(); ++iRun) {
487     if( run >= fRunStart[iRun] && run <= fRunEnd[iRun]) {
488     runRange = (Int_t) iRun;
489     return runRange;
490     }
491     }
492     return runRange;
493     }
494    
495    
496     Double_t PhotonPairSelector::GetDataEnCorr(Int_t runRange, PhotonTools::CiCBaseLineCats cat) {
497     switch( cat ) {
498     case PhotonTools::kCiCCat1:
499     return fDataEnCorr_EB_hR9[runRange];
500     case PhotonTools::kCiCCat2:
501     return fDataEnCorr_EB_lR9[runRange];
502     case PhotonTools::kCiCCat3:
503     return fDataEnCorr_EE_hR9[runRange];
504     case PhotonTools::kCiCCat4:
505     return fDataEnCorr_EE_lR9[runRange];
506     default:
507     return 1.;
508     }
509     }
510    
511    
512     Double_t PhotonPairSelector::GetMCSmearFac(PhotonTools::CiCBaseLineCats cat) {
513     switch( cat ) {
514     case PhotonTools::kCiCCat1:
515     return fMCSmear_EB_hR9;
516     case PhotonTools::kCiCCat2:
517     return fMCSmear_EB_lR9;
518     case PhotonTools::kCiCCat3:
519     return fMCSmear_EE_hR9;
520     case PhotonTools::kCiCCat4:
521     return fMCSmear_EE_lR9;
522     default:
523     return 1.;
524     }
525     }
526    
527     Float_t PhotonPairSelector::GetEventCat(PhotonTools::CiCBaseLineCats cat1, PhotonTools::CiCBaseLineCats cat2) {
528    
529     bool ph1IsEB = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat2);
530     bool ph2IsEB = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat2);
531    
532     bool ph1IsHR9 = (cat1 == PhotonTools::kCiCCat1 || cat1 == PhotonTools::kCiCCat3);
533     bool ph2IsHR9 = (cat2 == PhotonTools::kCiCCat1 || cat2 == PhotonTools::kCiCCat3);
534    
535     if( ph1IsEB && ph2IsEB )
536     return ( ph1IsHR9 && ph2IsHR9 ? 0. : 1.);
537    
538     return ( ph1IsHR9 && ph2IsHR9 ? 2. : 3.);
539     }
540 bendavid 1.4