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

Comparing UserCode/MitHzz4l/NonMCBackground/src/MuonFakeRateMod.cc (file contents):
Revision 1.2 by anlevin, Thu Jul 5 14:26:26 2012 UTC vs.
Revision 1.9 by anlevin, Wed Sep 12 12:13:26 2012 UTC

# Line 1 | Line 1
1   #include "MuonFakeRateMod.h"
2 + #include "SelectionFuncs.h"
3  
4  
5   //needed because of externs
# Line 7 | Line 8 | Float_t computePFMuonIso(const mithep::M
8                          const mithep::Vertex * vtx,
9                          const mithep::Array<mithep::PFCandidate> * pfCandidates,
10                          const Double_t dRMax);
11 <                        
11 < unsigned makePFnoPUArray(const mithep::Array<mithep::PFCandidate> * fPFCandidates,
12 <                         vector<bool> &pfNoPileUpFlag,
13 <                         const mithep::Array<mithep::Vertex>     * vtxArr );
14 <                        
11 >                                                
12   Bool_t passMuonDenominatorCuts(const mithep::Muon *mu, const mithep::Vertex * vtx, Int_t DenominatorType);
13  
14   string IntToString(int i) {
# Line 30 | Line 27 | const Float_t g_muon_mass = 105.658369e-
27  
28   void mithep::MuonFakeRateMod::SlaveBegin()
29   {
30 +
31    denominatorType.push_back(1);
32    denominatorType.push_back(2);
33  
# Line 85 | Line 83 | void mithep::MuonFakeRateMod::SlaveBegin
83    }
84    
85    rlrm.AddJSONFile("/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions12/8TeV/Prompt/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt");
86 +
87   }
88  
89   void mithep::MuonFakeRateMod::SlaveTerminate()
# Line 126 | Line 125 | void mithep::MuonFakeRateMod::Process()
125    
126    fillTriggerBits( GetHLTTable(), fTrigMask, fTriggerBits );
127    
128 +  PFnoPUflag.clear();
129    makePFnoPUArray(fPFCandidates, PFnoPUflag, fPrimVerts );
130      
131    if(fPFMet->At(0)->Et() >25) return;
# Line 139 | Line 139 | void mithep::MuonFakeRateMod::Process()
139        if (passMuonDenominatorCuts(mu, fPrimVerts->At(0), denominatorType[denominatorTypeIndex]))  
140          nMuons[denominatorTypeIndex]++;
141      }
142 <    ControlFlags ctrl;
143 <    ctrl.era = 2012;
142 >        
143      if ( //maybe you should do a loop to make sure the muon passes all of the denominators? right now this is ok because 2 is tighter...
144          passMuonDenominatorCuts(mu, fPrimVerts->At(0), denominatorType[1])
145          &&
146 <        muon2012CutBasedIDTight(ctrl,mu,fPrimVerts->At(0),fPFCandidates,fPileupEnergyDensity,mithep::MuonTools::kMuEAData2012)    
146 >        muonPOG2012CutBasedIDTight(mu,fPrimVerts->At(0),fPFCandidates,fPileupEnergyDensity)      
147          )  
148        goodMuons.push_back(mu);
149      
150    }
151    for(Int_t i=0; i<fElectrons->GetEntries(); i++) {
152      const Electron *ele = fElectrons->At(i);
153 <      ControlFlags ctrl;
155 <    ctrl.era = 2012;
156 <    if(electron2012CutBasedIDMedium(ctrl,ele, fPrimVerts->At(0), fPFCandidates, fConversions, fPileupEnergyDensity,mithep::ElectronTools::kEleEAData2012)) goodElectrons.push_back(ele);
153 >    if(electronPOG2012CutBasedIDMedium(ele, fPrimVerts->At(0), fPFCandidates, fConversions, fPileupEnergyDensity->At(0)->RhoLowEta(), mithep::ElectronTools::kEleEAData2011)) goodElectrons.push_back(ele);
154  
155    }    
156    
# Line 293 | Line 290 | void mithep::MuonFakeRateMod::Process()
290          if(!muonIDPFSelection(ctrl,  mu, fPrimVerts->At(0), fPFCandidates ).looseID()) passNumerator = kFALSE;
291          if(fabs(mu->Ip3dPVSignificance()) > 4) passNumerator = kFALSE;  
292          if(!muonReferenceIsoSelection(ctrl,mu,fPrimVerts->At(0),fPFCandidates,fPileupEnergyDensity,eraMu,photonsToVeto).passLooseIso()) passNumerator = kFALSE;                
293 <        
294 <        if (passNumerator)
298 <          fake_muon_pass[denominatorTypeIndex] = passNumerator ? 1 : 0;
293 >      
294 >        fake_muon_pass[denominatorTypeIndex] = passNumerator ? 1 : 0;
295          
296          fOutputTrees[denominatorTypeIndex]->Fill();
297          
# Line 304 | Line 300 | void mithep::MuonFakeRateMod::Process()
300    } //loop over muons
301   }
302  
307 unsigned makePFnoPUArray(const mithep::Array<mithep::PFCandidate> * fPFCandidates,
308                         vector<bool> &pfNoPileUpflag,
309                         const mithep::Array<mithep::Vertex>      * vtxArr )
310 {
311  for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) {
312    const mithep::PFCandidate *pf = fPFCandidates->At(i);
313    assert(pf);
314
315    if(pf->PFType() == mithep::PFCandidate::eHadron) {
316      if(pf->HasTrackerTrk() &&
317         vtxArr->At(0)->HasTrack(pf->TrackerTrk()) &&
318         vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) {
319
320        pfNoPileUpflag.push_back(1);
321
322      } else {
323
324        Bool_t vertexFound = kFALSE;
325        const mithep::Vertex *closestVtx = 0;
326        Double_t dzmin = 10000;
327        
328        // loop over vertices
329        for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) {
330          const mithep::Vertex *vtx = vtxArr->At(j);
331          assert(vtx);
332          
333          if(pf->HasTrackerTrk() &&
334             vtx->HasTrack(pf->TrackerTrk()) &&
335             vtx->TrackWeight(pf->TrackerTrk()) > 0) {
336            vertexFound = kTRUE;
337            closestVtx = vtx;
338            break;
339          }
340          Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z());
341          if(dz < dzmin) {
342            closestVtx = vtx;
343            dzmin = dz;
344          }
345        }
346
347        //      if(fCheckClosestZVertex) {
348        if(1) {
349          // Fallback: if track is not associated with any vertex,
350          // associate it with the vertex closest in z
351          if(vertexFound || closestVtx != vtxArr->At(0)) {
352            //      pfPileUp->Add(pf);
353            pfNoPileUpflag.push_back(0);
354          } else {
355            pfNoPileUpflag.push_back(1);
356          }
357        } else {
358          if(vertexFound && closestVtx != vtxArr->At(0)) {
359            //      pfPileUp->Add(pf);
360            pfNoPileUpflag.push_back(0);
361          } else {
362            //      PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is
363            pfNoPileUpflag.push_back(1);
364          }
365        }
366      } //hadron & trk stuff
367    } else { // hadron
368      //      PFCandidate * ptr = pfNoPileUp->AddNew();
369      pfNoPileUpflag.push_back(1);
370    }
371  } // Loop over PF candidates
372
373  return pfNoPileUpflag.size();
374 }
375
303   std::bitset<1024> mithep::MuonFakeRateMod::GetHLTMatchBits(const Double_t pt, const Double_t eta, const Double_t phi)
304   {
305    std::bitset<1024> object_bitset;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines