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

Comparing UserCode/MitHzz4l/ElectronStudies/src/ZeeTreeWriterMod.cc (file contents):
Revision 1.2 by anlevin, Wed Jul 18 09:31:12 2012 UTC vs.
Revision 1.3 by anlevin, Wed Jul 18 12:35:13 2012 UTC

# Line 1 | Line 1
1   #include "ZeeTreeWriterMod.h"
2 + #include "SelectionFuncs.h"
3  
4   const Float_t g_electron_mass = 0.51099892e-3;
5   const Float_t g_muon_mass = 105.658369e-3;
6  
7   vector<bool>   PFnoPUflag;
8  
9 < unsigned makePFnoPUArray(const mithep::Array<mithep::PFCandidate> * fPFCandidates,
10 <                         vector<bool> &pfNoPileUpFlag,
11 <                         const mithep::Array<mithep::Vertex>     * vtxArr );
11 <
9 > //these externs are used in SelectionFuncs.h
10 > TH1D* hpu_2011;
11 > TH1D* hpu_2012;
12  
13   void mithep::ZeeTreeWriterMod::SlaveBegin()
14   {
# Line 320 | Line 320 | void mithep::ZeeTreeWriterMod::Process()
320      }
321    }  
322   }
323
324 unsigned makePFnoPUArray(const mithep::Array<mithep::PFCandidate> * fPFCandidates,
325                         vector<bool> &pfNoPileUpflag,
326                         const mithep::Array<mithep::Vertex>      * vtxArr )
327 {
328  for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) {
329    const mithep::PFCandidate *pf = fPFCandidates->At(i);
330    assert(pf);
331
332    if(pf->PFType() == mithep::PFCandidate::eHadron) {
333      if(pf->HasTrackerTrk() &&
334         vtxArr->At(0)->HasTrack(pf->TrackerTrk()) &&
335         vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) {
336
337        pfNoPileUpflag.push_back(1);
338
339      } else {
340
341        Bool_t vertexFound = kFALSE;
342        const mithep::Vertex *closestVtx = 0;
343        Double_t dzmin = 10000;
344        
345        // loop over vertices
346        for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) {
347          const mithep::Vertex *vtx = vtxArr->At(j);
348          assert(vtx);
349          
350          if(pf->HasTrackerTrk() &&
351             vtx->HasTrack(pf->TrackerTrk()) &&
352             vtx->TrackWeight(pf->TrackerTrk()) > 0) {
353            vertexFound = kTRUE;
354            closestVtx = vtx;
355            break;
356          }
357          Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z());
358          if(dz < dzmin) {
359            closestVtx = vtx;
360            dzmin = dz;
361          }
362        }
363
364        //      if(fCheckClosestZVertex) {
365        if(1) {
366          // Fallback: if track is not associated with any vertex,
367          // associate it with the vertex closest in z
368          if(vertexFound || closestVtx != vtxArr->At(0)) {
369            //      pfPileUp->Add(pf);
370            pfNoPileUpflag.push_back(0);
371          } else {
372            pfNoPileUpflag.push_back(1);
373          }
374        } else {
375          if(vertexFound && closestVtx != vtxArr->At(0)) {
376            //      pfPileUp->Add(pf);
377            pfNoPileUpflag.push_back(0);
378          } else {
379            //      PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is
380            pfNoPileUpflag.push_back(1);
381          }
382        }
383      } //hadron & trk stuff
384    } else { // hadron
385      //      PFCandidate * ptr = pfNoPileUp->AddNew();
386      pfNoPileUpflag.push_back(1);
387    }
388  } // Loop over PF candidates
389
390  return pfNoPileUpflag.size();
391 }
392

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines