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

Comparing UserCode/MitHzz4l/Selection/src/applySelection.cc (file contents):
Revision 1.37 by dkralph, Wed Jun 13 13:39:12 2012 UTC vs.
Revision 1.52 by khahn, Wed Jul 11 18:24:39 2012 UTC

# Line 33 | Line 33 | using namespace std;
33   #include "Electron.h"
34   #include "Muon.h"
35   #include "Vertex.h"
36 + #include "PFMet.h"
37   #include "PFCandidate.h"
38   #include "PFCandidateCol.h"
39   #include "PileupInfoCol.h"
# Line 40 | Line 41 | using namespace std;
41   #include "MCParticle.h"
42   #include "TriggerMask.h"
43   #include "TriggerTable.h"
44 + #include "TriggerObject.h"
45 + #include "TriggerObjectRel.h"
46   #include "Names.h"
47   #include "BaseMod.h"
48 + #include "TriggerObjectsTable.h"
49  
50   //
51   // our headers
# Line 65 | Line 69 | using namespace std;
69   #include "RunLumiRangeMap.h"
70   #include "SampleWeight.h"
71   #include "EfficiencyWeightsInterface.h"
72 + #include "SelectionFuncs.h"
73  
74   #include "SimpleLepton.h"
75  
# Line 77 | Line 82 | using namespace mithep;
82   //
83   // globals
84   //----------------------------------------------------------------------------
85 < TH1D * hpu;
85 > TH1D *hpu_2011, *hpu_2012;
86   RunLumiRangeMap rlrm;
87   vector<SimpleLepton> failingLeptons ; // for fake estimation
88   vector<SimpleLepton> passingLeptons;      // for fake estimation
# Line 92 | Line 97 | vector<bool>   PFnoPUflag;;
97   //
98   // prototypes
99   //----------------------------------------------------------------------------
100 < void initPUWeights();
96 < double getPUWeight(unsigned npu);
97 < void setEra(string, ControlFlags&);
98 < void setEffiencyWeights(EventData&, WeightStruct& );
99 < void initRunLumiRangeMap();
100 < void initEvtRhoMap(map<unsigned,float> &);
101 < unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
102 <                         vector<bool> &pfNoPileUpFlag,
103 <                         const mithep::Array<mithep::Vertex>     * vtxArr );
100 > void initRunLumiRangeMap(ControlFlags &ctrl);
101   //----------------------------------------------------------------------------
102  
103  
# Line 171 | Line 168 | int main(int argc, char** argv)
168    TChain * hltchain = new TChain("HLT");
169  
170    string fname;
171 +  unsigned total_unskimmed=0;
172    if( !ctrl.inputfiles.empty() ) {
173      ifstream f(ctrl.inputfiles.c_str());
174      while (f >> fname) {
# Line 178 | Line 176 | int main(int argc, char** argv)
176        cout << "adding inputfile : " << fname.c_str() << endl;
177        entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str());
178        cout << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl;
179 +      total_unskimmed += entrymap[string(fname.c_str())];
180        chain->AddFile(fname.c_str());
181        hltchain->AddFile(fname.c_str());
182      }
183    } else {
184      cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl;
185 <    unsigned tmpent = unskimmedEntries(ctrl.inputfile.c_str());
186 <    cout << "tmpent: " << tmpent << endl;
187 <    entrymap[string(ctrl.inputfile.c_str())] = unskimmedEntries(ctrl.inputfile.c_str());
188 <    cout << "unskimmed entries: " << entrymap[string(ctrl.inputfile.c_str())] << endl;
185 >    unsigned unsk_ents = unskimmedEntries(ctrl.inputfile.c_str());
186 >    entrymap[string(ctrl.inputfile.c_str())] = unsk_ents;
187 >    cout << "unskimmed entries: " << unsk_ents << endl;
188 >    total_unskimmed += unsk_ents;
189      chain->AddFile(ctrl.inputfile.c_str());
190      hltchain->AddFile(ctrl.inputfile.c_str());
191    }
192 +  // // write the total number of unskimmed events that went into making this output file to a text file
193 +  // writeEntries(ctrl,total_unskimmed);
194  
195    const char * ofname;
196    if( strcmp( ctrl.outputfile.c_str(), "") ) {
# Line 203 | Line 204 | int main(int argc, char** argv)
204    SimpleTable xstab(xspath.c_str());
205  
206  
207 +
208    //
209    // Setup
210    //--------------------------------------------------------------------------------------------------------------
# Line 219 | Line 221 | int main(int argc, char** argv)
221  
222    
223    FOTuple foTree( nt.getFile(), (const char*)"FOtree");
224 +  foTree.makeInfoBranch(evtinfo);
225    foTree.makeFailedLeptonBranch(failingLeptons);
226    foTree.makePassedLeptonBranch(passingLeptons);
227  
# Line 240 | Line 243 | int main(int argc, char** argv)
243      }
244  
245    } else {
246 <    initRunLumiRangeMap();
246 >    initRunLumiRangeMap(ctrl);
247    }
248  
249    //  initMuonIDMVA();
250    initElectronIDMVAV1();
251    initTrigger();
252  
250  // hack
251  initEvtRhoMap(evtrhoMap);
252
253  
253    //
254    // Setup tree I/O
255    //--------------------------------------------------------------------------------------------------------------
# Line 258 | Line 257 | int main(int argc, char** argv)
257    TTree *eventTree=0;  
258    string currentFile("");
259  
260 +  UInt_t fNMaxTriggers = 1024;
261    mithep::EventHeader *info    = new mithep::EventHeader();
262 +  mithep::Array<mithep::PFMet>                *metArr        = new mithep::Array<mithep::PFMet>();
263    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
264    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
265    mithep::Array<mithep::Vertex>               *vtxArr        = new mithep::Array<mithep::Vertex>();
# Line 269 | Line 270 | int main(int argc, char** argv)
270    mithep::Array<mithep::MCParticle>           *mcArr         = new mithep::Array<mithep::MCParticle>();
271    mithep::MCEventInfo                         *mcEvtInfo     = new mithep::MCEventInfo();
272    mithep::TriggerMask                         *trigMask      = new mithep::TriggerMask();
273 <  mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable();
273 >  mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable(fNMaxTriggers);
274    vector<string>                              *hltTableStrings  = new vector<string>();
275 +  vector<string>                              *hltLabelStrings  = new vector<string>();
276 +  mithep::Array<mithep::TriggerObject>        *hltObjArr     = new mithep::Array<mithep::TriggerObject>();
277 +  mithep::Array<mithep::TriggerObjectRel>     *hltRelsArr    = new mithep::Array<mithep::TriggerObjectRel>();
278 +  std::vector<std::string>                    *hltTab        = new vector<string>();
279 +  std::vector<std::string>                    *hltLab        = new vector<string>();
280 +  TriggerObjectsTable                         *fTrigObjs     = new TriggerObjectsTable(hltTable,fNMaxTriggers);
281 +
282  
283    TString fElectronName(Names::gkElectronBrn);
284    TString fMuonName(Names::gkMuonBrn);
285    TString fInfoName(Names::gkEvtHeaderBrn);
286 +  TString fPFMetName("PFMet");
287    TString fPrimVtxName(Names::gkPVBrn);
288    TString fPFCandidateName(Names::gkPFCandidatesBrn);
289    TString fPileupInfoName(Names::gkPileupInfoBrn);
# Line 284 | Line 293 | int main(int argc, char** argv)
293    TString fMCEvtInfoName(Names::gkMCEvtInfoBrn);
294    TString fTriggerMaskName(Names::gkHltBitBrn);
295    TString fTriggerTableName(Names::gkHltTableBrn);
296 +  TString fTriggerLabelName(Names::gkHltLabelBrn);
297 +  TString fTriggerObjectName(Names::gkHltObjBrn);
298 +  TString fTriggerObjectRelsName(Form("HLTObjectsRelation"));
299 +
300 + //   TString fHLTLabName(Names::gkHltLabelBrn);
301 + //   TString fHLTTabName(Names::gkHltTableBrn);
302 + //   TString fHLTTabNamePub(Form("%sFwk",fHLTTabName.Data()));
303 + //   TString fHLTLabNamePub(Form("%sFwk",fHLTLabName.Data()));
304 + //   TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data()));
305 +
306 +
307    
308    chain->SetBranchAddress(fInfoName,        &info);
309 +  chain->SetBranchAddress(fPFMetName,       &metArr);
310    chain->SetBranchAddress(fElectronName,    &electronArr);
311    chain->SetBranchAddress(fMuonName,        &muonArr);
312    chain->SetBranchAddress(fPrimVtxName,     &vtxArr);
# Line 298 | Line 319 | int main(int argc, char** argv)
319    chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr);
320    chain->SetBranchAddress(fTrackName, &trkArr);
321    chain->SetBranchAddress(fTriggerMaskName, &trigMask);
322 +  chain->SetBranchAddress(fTriggerObjectName,  &hltObjArr);
323 +  chain->SetBranchAddress(fTriggerObjectRelsName,  &hltRelsArr);
324 +  //  chain->SetBranchAddress(fHLTTabNamePub,  &hltTab);
325 +  //  chain->SetBranchAddress(fHLTLabNamePub,  &hltLab);
326 +
327    cout << "hlttable: " << fTriggerTableName << endl;
328    hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
329 +  hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
330  
331    mithep::Vertex              vtx;          // best primary vertex in the event
332  
# Line 314 | Line 341 | int main(int argc, char** argv)
341  
342    // only 1 HLT table / file ???
343    hltchain->GetEntry(0);
317  cerr << "here... " << endl;
344  
345    int imax = chain->GetEntries();
346    cout << "nEntries: " << imax << endl;
347  
322
348    //
349    // Loop !!!!!!!!!
350    //--------------------------------------------------------------------------------------------------------------
# Line 328 | Line 353 | int main(int argc, char** argv)
353        chain->GetEntry(ientry);
354        if(!(ientry%1000)) cerr << "entry: " << ientry << endl;
355  
356 <      string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
357 <      setEra( fname, ctrl );
356 >      if( ctrl.debug ) {
357 >        cout << "-----------------------------------------------------------------" << endl;
358 >        cout << "-----------------------------------------------------------------" << endl;
359 >        cout << "Run: " << info->RunNum()
360 >             << "\tEvt: " << info->EvtNum()
361 >             << "\tLumi: " << info->LumiSec()
362 >             << endl;
363 >        cout << "-----------------------------------------------------------------" << endl;
364 >      }
365  
366  
367 +      string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
368 +      if(ctrl.debug) cout << "era is " << ctrl.era << endl;
369 +      if( ctrl.era == 0  ) {
370 +        setEra( fname, ctrl );
371 +        if(ctrl.debug) cout << "era is now " << ctrl.era << endl;
372 +      }
373 +
374        //
375        // pfNoPU
376        //
# Line 355 | Line 394 | int main(int argc, char** argv)
394          //
395          weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
396          cout << "xsec weight: " << weights.w << endl;
397 <        int npu = -1;
398 <        for(int i=0;i<puArr->GetEntries();i++) {
399 <          if(puArr->At(i)->GetBunchCrossing() == 0)
400 <            npu = puArr->At(i)->GetPU_NumInteractions();
401 <        }
402 <        assert(npu>=0);
364 <        evtinfo.npu;
365 <        weights.npuw = getPUWeight(evtinfo.npu);
366 <        
397 >
398 >        unsigned npu = getNPU(puArr, 0);
399 >        weights.npu  = npu;
400 >        weights.npuw = getPUWeight(ctrl.era,npu);
401 >        cerr << "weights.npuw: " <<  weights.npuw << endl;
402 >
403          //
404          // pt reweighting for Higgs < 140, F11
405          //
# Line 381 | Line 417 | int main(int argc, char** argv)
417          if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
418            currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
419            hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
420 +          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
421            hltchain->GetEntry(0);
422            hltTable->Clear();
423            fillTriggerNames(hltTable, hltTableStrings );
424 +          hltTable->Print();
425          }
426          if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
427          fillTriggerBits( hltTable, trigMask, triggerBits );
# Line 391 | Line 429 | int main(int argc, char** argv)
429          if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) {
430            passes_HLT_MC = false;
431          }
432 +
433 +        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
434 +
435        } else {
436          //
437          // JSON
438          //
439 <        // if(!(ctrl.noJSON) ) {
399 <        cout << "noJSON flag not in Control Flags" << endl;
400 <        assert(0);
439 >        if(!(ctrl.noJSON) ) {
440            RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec());      
441            if( !(rlrm.HasRunLumi(rl)) )  {
442 <            if( ctrl.debug ) cout << "\tfails JSON" << endl;
442 >            if( ctrl.debug ) cout << "fails JSON" << endl;
443              continue;
444 <          // }
444 >          }
445          }
446 <
446 >        
447          //
448          // trigger
449          //
450          if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
451            currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
452            hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
453 +          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
454            hltchain->GetEntry(0);
455            hltTable->Clear();
456            fillTriggerNames(hltTable, hltTableStrings );
457          }
458 +
459 +      setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
460 +
461          if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
462          /*
463          fillTriggerBits( hltTable, trigMask, triggerBits );
# Line 460 | Line 503 | int main(int argc, char** argv)
503          if( abs(ret4l.Z2leptons[0].type) == 13  ) Z2type = 13;
504        }  
505        
463 #ifdef SYNC
464      cout  << "bits: " << ret4l.status.selectionBits  << "\t"
465            << "Z1: " << Z1type << "\t"
466            << "Z2: " << Z2type << endl;
467      cout << endl;
468 #endif      
469      
506        if( ret4l.status.pass() ) {
507          fillAngles(ret4l,angles);
508          fillKinematics(ret4l,kinematics);
509          fillMassErrors(ret4l,muonArr,electronArr,kinematics);
510 <        fillEventInfo(info,evtinfo);
510 >        TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
511 >        fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0);
512          if( ctrl.mc) {
513 <          setEffiencyWeights(ret4l, weights);
514 <           if(ctrl.debug)
515 <             cout << "w: " << weights.w << "\t"
516 <                  << "won: " << weights.won << "\t"
517 <                  << "woff: " << weights.woff << endl;
513 >          setEffiencyWeights(ctrl.era, ret4l, triggerBits, hltTable, hltObjArr, fTrigObjs, weights);
514 >          if(ctrl.debug)
515 >            cout << "w: " << weights.w << "\t"
516 >                 << "npuw: " << weights.npuw << "\t"
517 >                 << "won: " << weights.won << "\t"
518 >                 << "woff: " << weights.woff << endl;
519          }
520          
521  
# Line 487 | Line 525 | int main(int argc, char** argv)
525                << "\trun: " << evtinfo.run
526                << "\tevt: " << evtinfo.evt
527                << "\tlumi: " << evtinfo.lumi
528 <              << "\tcostheta1: " << angles.costheta1
529 <              << "\tcostheta2: " << angles.costheta2
530 <              << "\tcostheta*: " << angles.costhetastar
531 <              << "\tbdt: " << angles.bdt
528 >              << "\tchannel: " << kinematics.channel
529 >              << "\tm4l: " << kinematics.m4l
530 >              << "\tmZ1: " << kinematics.mZ1
531 >              << "\tmZ2: " << kinematics.mZ2
532                << endl;
533          pass++;
534          //      if( pass > 3 ) break;
# Line 508 | Line 546 | int main(int argc, char** argv)
546                   << endl;
547            }
548          }
549 +        TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
550 +        fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0);
551          foTree.Fill();
552        } else {
553 <        cout << "failing with some other code : " << ret4l.status.selectionBits << endl;
553 >        if(ctrl.debug)
554 >          cout << "failing with some other code : " << ret4l.status.selectionBits << endl;
555        }
556      }  
557  
# Line 519 | Line 560 | int main(int argc, char** argv)
560    foTree.getTree()->Write();
561    nt.WriteClose();
562  
563 <  cout << endl;
564 <  cout << endl;
563 >  if(ctrl.debug)
564 >    cout << endl << endl;
565    for( int i=0; i<cutvec.size(); i++ ) {
566      cout << "cut: " << i << "\t"
567           << "pass: " << cutvec[i];
# Line 542 | Line 583 | int main(int argc, char** argv)
583   }
584  
585  
545
546 //----------------------------------------------------------------------------
547 void setEffiencyWeights(EventData & evtdat, WeightStruct & weights )
548 //----------------------------------------------------------------------------
549 {
550  vector<SimpleLepton> lepvec = evtdat.Z1leptons;
551  lepvec.insert(lepvec.end(), evtdat.Z2leptons.begin(), evtdat.Z2leptons.end());
552  double w_offline=-1, werr_offline=0;
553  double w_online=-1, werr_online=0;
554  
555  vector< pair <double,double> > wlegs; // pair here is eff & err
556  vector< pair <float,float> > mvec;  // pair here is eta & pt
557
558  //      vector< pair <float,float> > evec;  // pair here is eta & pt
559  // now deal with medium vs loose
560  vector< pair< bool, pair <float,float> > > evec;  // pair here is eta & pt
561  
562  for( int k=0; k<lepvec.size(); k++ ) {
563    if( abs(lepvec[k].type) == 13 ) {
564      mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
565      wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()),
566                                                          lepvec[k].vec.Pt() ) );
567    } else {
568      
569      // now deal with medium vs loose
570      //              evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
571      
572      std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt());
573      evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) );
574      
575      //              wlegs.push_back( elePerLegOfflineEfficiencyWeight(  fabs(lepvec[k].vec.Eta()),
576      //                                                                 lepvec[k].vec.Pt() ) );
577      
578      wlegs.push_back( elePerLegOfflineEfficiencyWeight(  fabs(lepvec[k].vec.Eta()),
579                                                          lepvec[k].vec.Pt(),
580                                                          lepvec[k].isTight ) );
581      
582    }
583  }
584  
585  pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs );
586  weights.woff    = offpair.first;
587  weights.werroff = offpair.second;
588  
589  pair<double,double> onpair  = getOnlineEfficiencyWeight( mvec, evec );
590  weights.won    = onpair.first;
591  weights.werron = onpair.second;
592 }
593
594
586   //----------------------------------------------------------------------------
587 < void initRunLumiRangeMap()
587 > void initRunLumiRangeMap(ControlFlags &ctrl)
588   //----------------------------------------------------------------------------
589   {
590    /*
# Line 607 | Line 598 | void initRunLumiRangeMap()
598    */
599  
600    // 2012 only for now ...
601 <  rlrm.AddJSONFile(std::string("./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt"));  
602 <
601 >  std::string jsonFile;
602 >  if(ctrl.jsonFile=="")
603 >    jsonFile = "./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt";
604 >  else
605 >    jsonFile = ctrl.jsonFile;
606 >  rlrm.AddJSONFile(jsonFile);  
607   };
613
614
615 //----------------------------------------------------------------------------
616 void initPUWeights()
617 //----------------------------------------------------------------------------
618 {
619  TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Full2011.root");
620  hpu = (TH1D*)(puf->Get("puWeights"));
621 }
622
623 //----------------------------------------------------------------------------
624 double getPUWeight(unsigned npu)
625 //----------------------------------------------------------------------------
626 {
627  return hpu->GetBinContent(hpu->FindBin(npu));
628 }
629
630 //----------------------------------------------------------------------------
631 void initEvtRhoMap( map<unsigned, float> & evtrhoMap )
632 //----------------------------------------------------------------------------
633 {
634  unsigned evt;
635  float rho;
636
637  cout << "initialzing EvtRhoMap ";
638  //FILE * f = fopen("evtrho.dat", "r");
639  //  FILE * f = fopen("allrho.cali.uniq.dat", "r");
640  FILE * f = fopen("/data/blue/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r");
641  int lcount=0;
642  while( fscanf( f, "%u:%f", &evt, &rho ) ) {
643    if( feof(f) ) break;
644    evtrhoMap[evt] = rho;
645    lcount++;
646    if( !(lcount%1000) ) cout << "."; flush(cout);
647  }
648  cout << " done" << endl;
649 }
650
651 //----------------------------------------------------------------------------
652 unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
653                         vector<bool> &pfNoPileUpflag,
654                         const mithep::Array<mithep::Vertex>      * vtxArr )
655 //----------------------------------------------------------------------------
656 {
657  for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) {
658    const PFCandidate *pf = fPFCandidates->At(i);
659    assert(pf);
660
661    if(pf->PFType() == PFCandidate::eHadron) {
662      if(pf->HasTrackerTrk() &&
663         vtxArr->At(0)->HasTrack(pf->TrackerTrk()) &&
664         vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) {
665
666        pfNoPileUpflag.push_back(1);
667
668      } else {
669
670        Bool_t vertexFound = kFALSE;
671        const Vertex *closestVtx = 0;
672        Double_t dzmin = 10000;
673        
674        // loop over vertices
675        for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) {
676          const Vertex *vtx = vtxArr->At(j);
677          assert(vtx);
678          
679          if(pf->HasTrackerTrk() &&
680             vtx->HasTrack(pf->TrackerTrk()) &&
681             vtx->TrackWeight(pf->TrackerTrk()) > 0) {
682            vertexFound = kTRUE;
683            closestVtx = vtx;
684            break;
685          }
686          Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z());
687          if(dz < dzmin) {
688            closestVtx = vtx;
689            dzmin = dz;
690          }
691        }
692
693        //      if(fCheckClosestZVertex) {
694        if(1) {
695          // Fallback: if track is not associated with any vertex,
696          // associate it with the vertex closest in z
697          if(vertexFound || closestVtx != vtxArr->At(0)) {
698            //      pfPileUp->Add(pf);
699            pfNoPileUpflag.push_back(0);
700          } else {
701            pfNoPileUpflag.push_back(1);
702          }
703        } else {
704          if(vertexFound && closestVtx != vtxArr->At(0)) {
705            //      pfPileUp->Add(pf);
706            pfNoPileUpflag.push_back(0);
707          } else {
708            //      PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is
709            pfNoPileUpflag.push_back(1);
710          }
711        }
712      } //hadron & trk stuff
713    } else { // hadron
714      //      PFCandidate * ptr = pfNoPileUp->AddNew();
715      pfNoPileUpflag.push_back(1);
716    }
717  } // Loop over PF candidates
718
719  return pfNoPileUpflag.size();
720 }
721
722 void setEra(string fname, ControlFlags &ctrl)
723 {
724  if( ctrl.mc && (fname.find("f11-") != string::npos)  ) ctrl.era=2011 ;
725  if( ctrl.mc && (fname.find("s12-") != string::npos)  ) ctrl.era=2012 ;
726  if( !ctrl.mc && (fname.find("r11-") != string::npos)  ) ctrl.era=2011 ;
727  if( !ctrl.mc && (fname.find("r12-") != string::npos)  ) ctrl.era=2012 ;
728 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines