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.32 by anlevin, Sat Jun 2 12:17:29 2012 UTC vs.
Revision 1.51 by dkralph, Fri Jul 6 15:28:19 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 59 | Line 63 | using namespace std;
63   #include "InfoStruct.h"
64   #include "GenInfoStruct.h"
65   #include "WeightStruct.h"
62 //#include "GlobalDataAndFuncs.h"
63 #include "RunLumiRangeMap.h"
64
66   #include "AngleTuple.h"
67   #include "FOTuple.h"
68  
69 + #include "RunLumiRangeMap.h"
70   #include "SampleWeight.h"
71   #include "EfficiencyWeightsInterface.h"
72 + #include "SelectionFuncs.h"
73  
74   #include "SimpleLepton.h"
75  
# Line 79 | 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 94 | Line 97 | vector<bool>   PFnoPUflag;;
97   //
98   // prototypes
99   //----------------------------------------------------------------------------
100 < void initPUWeights();
98 < double getPUWeight(unsigned npu);
99 < void setEra(string, ControlFlags&);
100 < void setEffiencyWeights(EventData&, WeightStruct& );
101 < void initRunLumiRangeMap();
102 < void initEvtRhoMap(map<unsigned,float> &);
103 < unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
104 <                         vector<bool> &pfNoPileUpFlag,
105 <                         const mithep::Array<mithep::Vertex>     * vtxArr );
100 > void initRunLumiRangeMap(ControlFlags &ctrl);
101   //----------------------------------------------------------------------------
102  
103  
# Line 173 | 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 180 | 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 205 | Line 204 | int main(int argc, char** argv)
204    SimpleTable xstab(xspath.c_str());
205  
206  
207 +
208    //
209    // Setup
210    //--------------------------------------------------------------------------------------------------------------
# Line 219 | Line 219 | int main(int argc, char** argv)
219    nt.makeKinematicsBranch(kinematics);
220    nt.makeInfoBranch(evtinfo);
221  
222 +  
223    FOTuple foTree( nt.getFile(), (const char*)"FOtree");
224    foTree.makeFailedLeptonBranch(failingLeptons);
225 <  foTree.makeZLeptonBranch(passingLeptons);
225 >  foTree.makePassedLeptonBranch(passingLeptons);
226  
227    TH1F * h_wf11_hpt;
228    if(ctrl.mc) {
229      nt.makeWeightBranch(weights);
230 <    nt.makeGenInfoBranch(geninfo);
230 >    if(ctrl.fillGen ) nt.makeGenInfoBranch(geninfo);
231      initEfficiencyWeights();
232      initPUWeights();
233  
# Line 241 | Line 242 | int main(int argc, char** argv)
242      }
243  
244    } else {
245 <    initRunLumiRangeMap();
245 >    initRunLumiRangeMap(ctrl);
246    }
247  
248    //  initMuonIDMVA();
249 <  initMuonIsoMVA();
249 <  initElectronIDMVA();
250 <  initElectronIsoMVA();
249 >  initElectronIDMVAV1();
250    initTrigger();
251  
253  // hack
254  initEvtRhoMap(evtrhoMap);
255
256  
252    //
253    // Setup tree I/O
254    //--------------------------------------------------------------------------------------------------------------
# Line 261 | Line 256 | int main(int argc, char** argv)
256    TTree *eventTree=0;  
257    string currentFile("");
258  
259 +  UInt_t fNMaxTriggers = 1024;
260    mithep::EventHeader *info    = new mithep::EventHeader();
261 +  mithep::Array<mithep::PFMet>                *metArr        = new mithep::Array<mithep::PFMet>();
262    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
263    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
264    mithep::Array<mithep::Vertex>               *vtxArr        = new mithep::Array<mithep::Vertex>();
# Line 272 | Line 269 | int main(int argc, char** argv)
269    mithep::Array<mithep::MCParticle>           *mcArr         = new mithep::Array<mithep::MCParticle>();
270    mithep::MCEventInfo                         *mcEvtInfo     = new mithep::MCEventInfo();
271    mithep::TriggerMask                         *trigMask      = new mithep::TriggerMask();
272 <  mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable();
272 >  mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable(fNMaxTriggers);
273    vector<string>                              *hltTableStrings  = new vector<string>();
274 +  vector<string>                              *hltLabelStrings  = new vector<string>();
275 +  mithep::Array<mithep::TriggerObject>        *hltObjArr     = new mithep::Array<mithep::TriggerObject>();
276 +  mithep::Array<mithep::TriggerObjectRel>     *hltRelsArr    = new mithep::Array<mithep::TriggerObjectRel>();
277 +  std::vector<std::string>                    *hltTab        = new vector<string>();
278 +  std::vector<std::string>                    *hltLab        = new vector<string>();
279 +  TriggerObjectsTable                         *fTrigObjs     = new TriggerObjectsTable(hltTable,fNMaxTriggers);
280 +
281  
282    TString fElectronName(Names::gkElectronBrn);
283    TString fMuonName(Names::gkMuonBrn);
284    TString fInfoName(Names::gkEvtHeaderBrn);
285 +  TString fPFMetName("PFMet");
286    TString fPrimVtxName(Names::gkPVBrn);
287    TString fPFCandidateName(Names::gkPFCandidatesBrn);
288    TString fPileupInfoName(Names::gkPileupInfoBrn);
# Line 287 | Line 292 | int main(int argc, char** argv)
292    TString fMCEvtInfoName(Names::gkMCEvtInfoBrn);
293    TString fTriggerMaskName(Names::gkHltBitBrn);
294    TString fTriggerTableName(Names::gkHltTableBrn);
295 +  TString fTriggerLabelName(Names::gkHltLabelBrn);
296 +  TString fTriggerObjectName(Names::gkHltObjBrn);
297 +  TString fTriggerObjectRelsName(Form("HLTObjectsRelation"));
298 +
299 + //   TString fHLTLabName(Names::gkHltLabelBrn);
300 + //   TString fHLTTabName(Names::gkHltTableBrn);
301 + //   TString fHLTTabNamePub(Form("%sFwk",fHLTTabName.Data()));
302 + //   TString fHLTLabNamePub(Form("%sFwk",fHLTLabName.Data()));
303 + //   TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data()));
304 +
305 +
306    
307    chain->SetBranchAddress(fInfoName,        &info);
308 +  chain->SetBranchAddress(fPFMetName,       &metArr);
309    chain->SetBranchAddress(fElectronName,    &electronArr);
310    chain->SetBranchAddress(fMuonName,        &muonArr);
311    chain->SetBranchAddress(fPrimVtxName,     &vtxArr);
# Line 301 | Line 318 | int main(int argc, char** argv)
318    chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr);
319    chain->SetBranchAddress(fTrackName, &trkArr);
320    chain->SetBranchAddress(fTriggerMaskName, &trigMask);
321 +  chain->SetBranchAddress(fTriggerObjectName,  &hltObjArr);
322 +  chain->SetBranchAddress(fTriggerObjectRelsName,  &hltRelsArr);
323 +  //  chain->SetBranchAddress(fHLTTabNamePub,  &hltTab);
324 +  //  chain->SetBranchAddress(fHLTLabNamePub,  &hltLab);
325 +
326    cout << "hlttable: " << fTriggerTableName << endl;
327    hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
328 +  hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
329  
330    mithep::Vertex              vtx;          // best primary vertex in the event
331  
# Line 317 | Line 340 | int main(int argc, char** argv)
340  
341    // only 1 HLT table / file ???
342    hltchain->GetEntry(0);
320  cerr << "here... " << endl;
343  
344    int imax = chain->GetEntries();
345    cout << "nEntries: " << imax << endl;
346  
325
347    //
348    // Loop !!!!!!!!!
349    //--------------------------------------------------------------------------------------------------------------
# Line 331 | Line 352 | int main(int argc, char** argv)
352        chain->GetEntry(ientry);
353        if(!(ientry%1000)) cerr << "entry: " << ientry << endl;
354  
355 < #ifdef HACKED_RHOS
356 <      float rho = evtrhoMap[info->EvtNum()];
357 < #endif
358 <      string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
359 <      setEra( fname, ctrl );
355 >      if( ctrl.debug ) {
356 >        cout << "-----------------------------------------------------------------" << endl;
357 >        cout << "-----------------------------------------------------------------" << endl;
358 >        cout << "Run: " << info->RunNum()
359 >             << "\tEvt: " << info->EvtNum()
360 >             << "\tLumi: " << info->LumiSec()
361 >             << endl;
362 >        cout << "-----------------------------------------------------------------" << endl;
363 >      }
364  
365  
366 +      string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
367 +      if(ctrl.debug) cout << "era is " << ctrl.era << endl;
368 +      if( ctrl.era == 0  ) {
369 +        setEra( fname, ctrl );
370 +        if(ctrl.debug) cout << "era is now " << ctrl.era << endl;
371 +      }
372 +
373        //
374        // pfNoPU
375        //
# Line 361 | Line 393 | int main(int argc, char** argv)
393          //
394          weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
395          cout << "xsec weight: " << weights.w << endl;
396 <        int npu = -1;
397 <        for(int i=0;i<puArr->GetEntries();i++) {
398 <          if(puArr->At(i)->GetBunchCrossing() == 0)
399 <            npu = puArr->At(i)->GetPU_NumInteractions();
400 <        }
401 <        assert(npu>=0);
370 <        evtinfo.npu;
371 <        weights.npuw = getPUWeight(evtinfo.npu);
372 <        
396 >
397 >        unsigned npu = getNPU(puArr, 0);
398 >        weights.npu  = npu;
399 >        weights.npuw = getPUWeight(ctrl.era,npu);
400 >        cerr << "weights.npuw: " <<  weights.npuw << endl;
401 >
402          //
403          // pt reweighting for Higgs < 140, F11
404          //
# Line 387 | Line 416 | int main(int argc, char** argv)
416          if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
417            currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
418            hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
419 +          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
420            hltchain->GetEntry(0);
421            hltTable->Clear();
422            fillTriggerNames(hltTable, hltTableStrings );
# Line 397 | Line 427 | int main(int argc, char** argv)
427          if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) {
428            passes_HLT_MC = false;
429          }
430 +
431 +        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
432 +
433        } else {
434          //
435          // JSON
436          //
437 <        /*
438 <        RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec());      
439 <        if( !(rlrm.HasRunLumi(rl)) )  {
440 <          if( ctrl.debug ) cout << "\tfails JSON" << endl;
441 <          continue;
437 >        if(!(ctrl.noJSON) ) {
438 >          RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec());      
439 >          if( !(rlrm.HasRunLumi(rl)) )  {
440 >            if( ctrl.debug ) cout << "fails JSON" << endl;
441 >            continue;
442 >          }
443          }
444 <        */
444 >        
445          //
446          // trigger
447          //
448          if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
449            currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
450            hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
451 +          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
452            hltchain->GetEntry(0);
453            hltTable->Clear();
454            fillTriggerNames(hltTable, hltTableStrings );
455          }
456 +
457 +      setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
458 +
459          if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
460          /*
461          fillTriggerBits( hltTable, trigMask, triggerBits );
# Line 438 | Line 476 | int main(int argc, char** argv)
476  
477          // reference
478          apply_HZZ4L_reference_selection(ctrl, info,
479 <                                         vtxArr,
480 <                                         pfArr,
481 < #ifdef HACKED_RHOS
482 <                                         rho,
483 < #else
484 <                                         puDArr,
485 < #endif
486 <                                         electronArr,
487 <                                         &electronReferencePreSelection,
488 <                                         &electronReferenceIDMVASelectionV1,
489 <                                         &electronReferenceIsoSelection,
490 <                                         muonArr,
453 <                                         &muonReferencePreSelection,
454 <                                         &muonIDPFSelection,
455 <                                         &muonReferenceIsoSelection);
456 <
457 <      /*
458 <        // evolved
459 <        apply_HZZ4L_reference2_selection(ctrl, info,
460 <                                         vtx,
461 <                                         pfArr,
462 <                                         //rho,
463 <                                         puDArr,
464 <                                         electronArr,
465 <                                         &electronReferencePreSelection,
466 <                                         //&electronPreSelection,
467 <                                         &electronReferenceIDMVASelection,
468 <                                         &electronIsoMVASelection,
469 <                                         muonArr,
470 <                                         &muonReferencePreSelection,
471 <                                         //&muonPreSelection,
472 <                                         &muonIDPFSelection,
473 <                                         &muonIsoMVASelection);
474 <      */
475 <
479 >                                        vtxArr,
480 >                                        pfArr,
481 >                                        puDArr,
482 >                                        electronArr,
483 >                                        &electronReferencePreSelection,
484 >                                        &electronReferenceIDMVASelectionV1,
485 >                                        &electronReferenceIsoSelection,
486 >                                        muonArr,
487 >                                        &muonReferencePreSelection,
488 >                                        &muonIDPFSelection,
489 >                                        &muonReferenceIsoSelection);
490 >      
491        if( ctrl.debug ) cout << endl;
492  
493  
# Line 486 | Line 501 | int main(int argc, char** argv)
501          if( abs(ret4l.Z2leptons[0].type) == 13  ) Z2type = 13;
502        }  
503        
489 #ifdef SYNC
490      cout  << "bits: " << ret4l.status.selectionBits  << "\t"
491            << "Z1: " << Z1type << "\t"
492            << "Z2: " << Z2type << endl;
493      cout << endl;
494 #endif      
495      
504        if( ret4l.status.pass() ) {
505          fillAngles(ret4l,angles);
506          fillKinematics(ret4l,kinematics);
507          fillMassErrors(ret4l,muonArr,electronArr,kinematics);
508 <        fillEventInfo(info,evtinfo);
508 >        TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
509 >        fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0);
510          if( ctrl.mc) {
511 <          setEffiencyWeights(ret4l, weights);
512 <           if(ctrl.debug)
513 <             cout << "w: " << weights.w << "\t"
514 <                  << "won: " << weights.won << "\t"
515 <                  << "woff: " << weights.woff << endl;
511 >          //      if( std::string(ctrl.efftype) != std::string("WTF?")) {
512 >            setEffiencyWeights(ctrl.era, ret4l, weights);
513 >            //    } else {
514 >            //      weights.won = weights.woff = 1.;
515 >            //    }
516 >          if(ctrl.debug)
517 >            cout << "w: " << weights.w << "\t"
518 >                 << "npuw: " << weights.npuw << "\t"
519 >                 << "won: " << weights.won << "\t"
520 >                 << "woff: " << weights.woff << endl;
521          }
522          
523  
# Line 513 | Line 527 | int main(int argc, char** argv)
527                << "\trun: " << evtinfo.run
528                << "\tevt: " << evtinfo.evt
529                << "\tlumi: " << evtinfo.lumi
530 <              << "\tcostheta1: " << angles.costheta1
531 <              << "\tcostheta2: " << angles.costheta2
532 <              << "\tcostheta*: " << angles.costhetastar
533 <              << "\tbdt: " << angles.bdt
530 >              << "\tchannel: " << kinematics.channel
531 >              << "\tm4l: " << kinematics.m4l
532 >              << "\tmZ1: " << kinematics.mZ1
533 >              << "\tmZ2: " << kinematics.mZ2
534                << endl;
535          pass++;
536          //      if( pass > 3 ) break;
537  
538 <      } else if( ret4l.status.selectionBits.test(PASS_GOODZ1) ) { // save for fakes ...
539 <        //      if(ctrl.debug) {
538 >      } else if( ret4l.status.selectionBits.test(PASS_GOODZ1) &&
539 >                 ret4l.status.selectionBits.to_ulong() < (1UL<<PASS_4L)) { // save for fakes ...
540 >        if(ctrl.debug) {
541            cout << "failingLeptons : " << failingLeptons.size() << endl;
542            for( int f=0; f<failingLeptons.size(); f++ ) {
543              SimpleLepton  l = failingLeptons[f];
# Line 531 | Line 546 | int main(int argc, char** argv)
546                   << "pT: " << l.vec.Pt()  << "\t"
547                   << "eta: " << l.vec.Eta()
548                   << endl;
549 <            //    }
549 >          }
550          }
551          foTree.Fill();
552 +      } else {
553 +        if(ctrl.debug)
554 +          cout << "failing with some other code : " << ret4l.status.selectionBits << endl;
555        }
556      }  
557  
# Line 542 | 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 565 | Line 583 | int main(int argc, char** argv)
583   }
584  
585  
568
569 //----------------------------------------------------------------------------
570 void setEffiencyWeights(EventData & evtdat, WeightStruct & weights )
571 //----------------------------------------------------------------------------
572 {
573  vector<SimpleLepton> lepvec = evtdat.Z1leptons;
574  lepvec.insert(lepvec.end(), evtdat.Z2leptons.begin(), evtdat.Z2leptons.end());
575  double w_offline=-1, werr_offline=0;
576  double w_online=-1, werr_online=0;
577  
578  vector< pair <double,double> > wlegs; // pair here is eff & err
579  vector< pair <float,float> > mvec;  // pair here is eta & pt
580
581  //      vector< pair <float,float> > evec;  // pair here is eta & pt
582  // now deal with medium vs loose
583  vector< pair< bool, pair <float,float> > > evec;  // pair here is eta & pt
584  
585  for( int k=0; k<lepvec.size(); k++ ) {
586    if( abs(lepvec[k].type) == 13 ) {
587      mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
588      wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()),
589                                                          lepvec[k].vec.Pt() ) );
590    } else {
591      
592      // now deal with medium vs loose
593      //              evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
594      
595      std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt());
596      evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) );
597      
598      //              wlegs.push_back( elePerLegOfflineEfficiencyWeight(  fabs(lepvec[k].vec.Eta()),
599      //                                                                 lepvec[k].vec.Pt() ) );
600      
601      wlegs.push_back( elePerLegOfflineEfficiencyWeight(  fabs(lepvec[k].vec.Eta()),
602                                                          lepvec[k].vec.Pt(),
603                                                          lepvec[k].isTight ) );
604      
605    }
606  }
607  
608  pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs );
609  weights.woff    = offpair.first;
610  weights.werroff = offpair.second;
611  
612  pair<double,double> onpair  = getOnlineEfficiencyWeight( mvec, evec );
613  weights.won    = onpair.first;
614  weights.werron = onpair.second;
615 }
616
617
586   //----------------------------------------------------------------------------
587 < void initRunLumiRangeMap()
587 > void initRunLumiRangeMap(ControlFlags &ctrl)
588   //----------------------------------------------------------------------------
589   {
590    /*
# Line 628 | Line 596 | void initRunLumiRangeMap()
596    // r11b
597    rlrm.AddJSONFile(std::string("./data/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt"));  
598    */
631 };
599  
600 <
601 < //----------------------------------------------------------------------------
602 < void initPUWeights()
603 < //----------------------------------------------------------------------------
604 < {
605 <  TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Full2011.root");
606 <  hpu = (TH1D*)(puf->Get("puWeights"));
607 < }
641 <
642 < //----------------------------------------------------------------------------
643 < double getPUWeight(unsigned npu)
644 < //----------------------------------------------------------------------------
645 < {
646 <  return hpu->GetBinContent(hpu->FindBin(npu));
647 < }
648 <
649 < //----------------------------------------------------------------------------
650 < void initEvtRhoMap( map<unsigned, float> & evtrhoMap )
651 < //----------------------------------------------------------------------------
652 < {
653 <  unsigned evt;
654 <  float rho;
655 <
656 <  cout << "initialzing EvtRhoMap ";
657 <  //FILE * f = fopen("evtrho.dat", "r");
658 <  //  FILE * f = fopen("allrho.cali.uniq.dat", "r");
659 <  FILE * f = fopen("/data/blue/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r");
660 <  int lcount=0;
661 <  while( fscanf( f, "%u:%f", &evt, &rho ) ) {
662 <    if( feof(f) ) break;
663 <    evtrhoMap[evt] = rho;
664 <    lcount++;
665 <    if( !(lcount%1000) ) cout << "."; flush(cout);
666 <  }
667 <  cout << " done" << endl;
668 < }
669 <
670 < //----------------------------------------------------------------------------
671 < unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
672 <                         vector<bool> &pfNoPileUpflag,
673 <                         const mithep::Array<mithep::Vertex>      * vtxArr )
674 < //----------------------------------------------------------------------------
675 < {
676 <  for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) {
677 <    const PFCandidate *pf = fPFCandidates->At(i);
678 <    assert(pf);
679 <
680 <    if(pf->PFType() == PFCandidate::eHadron) {
681 <      if(pf->HasTrackerTrk() &&
682 <         vtxArr->At(0)->HasTrack(pf->TrackerTrk()) &&
683 <         vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) {
684 <
685 <        pfNoPileUpflag.push_back(1);
686 <
687 <      } else {
688 <
689 <        Bool_t vertexFound = kFALSE;
690 <        const Vertex *closestVtx = 0;
691 <        Double_t dzmin = 10000;
692 <        
693 <        // loop over vertices
694 <        for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) {
695 <          const Vertex *vtx = vtxArr->At(j);
696 <          assert(vtx);
697 <          
698 <          if(pf->HasTrackerTrk() &&
699 <             vtx->HasTrack(pf->TrackerTrk()) &&
700 <             vtx->TrackWeight(pf->TrackerTrk()) > 0) {
701 <            vertexFound = kTRUE;
702 <            closestVtx = vtx;
703 <            break;
704 <          }
705 <          Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z());
706 <          if(dz < dzmin) {
707 <            closestVtx = vtx;
708 <            dzmin = dz;
709 <          }
710 <        }
711 <
712 <        //      if(fCheckClosestZVertex) {
713 <        if(1) {
714 <          // Fallback: if track is not associated with any vertex,
715 <          // associate it with the vertex closest in z
716 <          if(vertexFound || closestVtx != vtxArr->At(0)) {
717 <            //      pfPileUp->Add(pf);
718 <            pfNoPileUpflag.push_back(0);
719 <          } else {
720 <            pfNoPileUpflag.push_back(1);
721 <          }
722 <        } else {
723 <          if(vertexFound && closestVtx != vtxArr->At(0)) {
724 <            //      pfPileUp->Add(pf);
725 <            pfNoPileUpflag.push_back(0);
726 <          } else {
727 <            //      PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is
728 <            pfNoPileUpflag.push_back(1);
729 <          }
730 <        }
731 <      } //hadron & trk stuff
732 <    } else { // hadron
733 <      //      PFCandidate * ptr = pfNoPileUp->AddNew();
734 <      pfNoPileUpflag.push_back(1);
735 <    }
736 <  } // Loop over PF candidates
737 <
738 <  return pfNoPileUpflag.size();
739 < }
740 <
741 < void setEra(string fname, ControlFlags &ctrl)
742 < {
743 <  if( ctrl.mc && (fname.find("f11-") != string::npos)  ) ctrl.era=2011 ;
744 <  if( ctrl.mc && (fname.find("s12-") != string::npos)  ) ctrl.era=2012 ;
745 <  if( !ctrl.mc && (fname.find("r11-") != string::npos)  ) ctrl.era=2011 ;
746 <  if( !ctrl.mc && (fname.find("r12-") != string::npos)  ) ctrl.era=2012 ;
747 < }
600 >  // 2012 only for now ...
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 > };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines