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.67 by dkralph, Tue Jan 15 10:37:19 2013 UTC vs.
Revision 1.73 by anlevin, Tue Feb 5 09:53:47 2013 UTC

# Line 81 | Line 81 | using namespace std;
81  
82   #include "SimpleLepton.h"
83  
84 + #include "Cintex/Cintex.h"
85 +
86   #ifndef CMSSW_BASE
87   #define CMSSW_BASE "../"
88   #endif
# Line 107 | Line 109 | ElectronMomentumCorrection electron_mome
109   MuCorr *muCorr;
110   void addDummyZ2Lepotons(EventData &ret4l);
111   void setNtupleVals(ControlFlags &ctrl, EventData &ret4l, InfoStruct &evtinfo, Angles &angles, KinematicsStruct &kine,
112 <                   JetInfoStruct &ji, WeightStruct &weights, EventHeader *info, Array<PFJet> *jetArr, Array<PFMet> *metArr,
112 >                   JetInfoStruct &ji, WeightStruct &weights, EventHeader *info,  Array<Muon> *muonArr, Array<Electron> *electronArr, Array<PFJet> *jetArr, Array<PFMet> *metArr,
113                     vector<SimpleLepton> &simpleLeptonJets, FactorizedJetCorrector *fJetCorrector, Array<PileupInfo> *puArr,
114                     Array<PileupEnergyDensity> *puDArr, JetIDMVA *fJetIDMVA, Array<Vertex> *vtxArr, bitset<1024> &triggerBits,
115                     TriggerTable *hltTable, Array<TriggerObject> *hltObjArr, TriggerObjectsTable *fTrigObjs, AngleTuple *nt);
# Line 132 | Line 134 | void initRunLumiRangeMap(ControlFlags &c
134   int main(int argc, char** argv)
135   //----------------------------------------------------------------------------
136   {
137 +
138    vector<TString> cuts;
139    cuts.push_back("start"); // NOTE: is incremented in ReferenceSelection, so if you turn on JSONS be careful
140    cuts.push_back("trigger");
# Line 142 | Line 145 | int main(int argc, char** argv)
145    cuts.push_back("m4l>70");
146    cuts.push_back("mZ2>12");
147    cuts.push_back("m4l>100");
148 +  cuts.push_back("m4l > 100 && >= 1 jets");
149 +  cuts.push_back("m4l > 100 && 2 jets");
150 +  cuts.push_back("m4l > 100 && fisher > 0.4");
151  
152    for(unsigned icut=0; icut<cuts.size(); icut++)
153      counts[cuts[icut]] = new map<TString,int>;
# Line 222 | Line 228 | int main(int argc, char** argv)
228      if(ctrl.use_xs_weights) getWeight(xstab,entrymap,chain); // test *now* whether we've got the xs in here, so it fails before it creates the output
229    }
230  
231 +  //root will write to this temporary file instead of to memory and the selection will run faster
232 +
233    //
234    // Setup
235    //--------------------------------------------------------------------------------------------------------------
# Line 238 | Line 246 | int main(int argc, char** argv)
246    nt.makeKinematicsBranch(kine);
247    nt.makeInfoBranch(evtinfo);
248    nt.makeJetInfoBranch(ji);
249 <  nt.makeJetAngleBranches("DataStruct/data/jetAngleVars.txt");
249 >  //nt.makeJetAngleBranches("DataStruct/data/jetAngleVars.txt");
250  
251    FOTuple *foTree=0;
252    if(ctrl.fakeScheme != "none") {
# Line 268 | Line 276 | int main(int argc, char** argv)
276    initElectronIDMVAV1();
277    initTrigger();
278    initAnalysisTriggers(ti);
279 +  initMela(ctrl);
280 +  initMassErrors();
281    ti.dump();
282  
283 <  if(ctrl.do_escale) {
283 >  TFile tmp_file("tmp_file.root");
284 >
285 >  if(ctrl.do_eregression) {
286      string regPath("EGamma/EGammaAnalysisTools/data/eleEnergyRegWeights_V1.root");
287      // if(TString(getenv("HOSTNAME")).Contains(TRegexp("t3[bd][te][cs][hk]")))
288 <      regPath = cmsswpath + "/" + regPath;
288 >    regPath = cmsswpath + "/" + regPath;
289      electron_momentum_correction.initialize_regression(regPath);
290 +  }
291 +
292 +  if(ctrl.do_escale) {
293      if(ctrl.mc) {
294        if(ctrl.era == 2011) ctrl.smearing_scaling_dataset = "Fall11";
295        else                 ctrl.smearing_scaling_dataset = "Summer12_DR53X_HCP2012";
296      } else {
297        if(ctrl.era == 2011) ctrl.smearing_scaling_dataset = "Jan16ReReco";
298 <      else                 ctrl.smearing_scaling_dataset = "2012Jul13ReReco";
298 >      else                 ctrl.smearing_scaling_dataset = "Moriond2013";
299      }
300    }
301    if(ctrl.correct_muon_momentum) {
# Line 361 | Line 376 | int main(int argc, char** argv)
376      chain->GetEntry(ientry);
377      if(!(ientry%1000)) cerr << "entry: " << ientry << " ( / " << imax << " )" << endl;
378  
379 +    //if(info->EvtNum() != 217502611) continue;
380 +
381      increment(counts,"start");
382      if( ctrl.debug ) {
383        cout << "-----------------------------------------------------------------" << endl;
# Line 448 | Line 465 | int main(int argc, char** argv)
465  
466      if(ctrl.fakeScheme == "none") { // fill angletuple if event passes full selection
467        if( ret4l.status.pass() ) {
468 <        setNtupleVals(ctrl, ret4l, evtinfo, angles, kine, ji, weights, info, jetArr, metArr, simpleLeptonJets, fJetCorrector, puArr, puDArr, fJetIDMVA, vtxArr, triggerBits, hltTable, hltObjArr, fTrigObjs, &nt);
468 >        setNtupleVals(ctrl, ret4l, evtinfo, angles, kine, ji, weights, info, muonArr, electronArr, jetArr, metArr, simpleLeptonJets, fJetCorrector, puArr, puDArr, fJetIDMVA, vtxArr, triggerBits, hltTable, hltObjArr, fTrigObjs, &nt);
469          nt.Fill();
470 +    
471 +        int theZ1type = kine.l1type;
472 +        int theZ2type = kine.l3type;
473 +
474 +        if(ctrl.debug) cout << "simpleLeptonJets.size() = " << simpleLeptonJets.size() << endl;
475 +
476 +        if(kine.m4l > 100){
477 +          if(simpleLeptonJets.size() >= 1) {
478 +            increment(counts,"m4l > 100 && >= 1 jets",theZ1type,theZ2type);
479 +            if(simpleLeptonJets.size() == 2) {
480 +              increment(counts,"m4l > 100 && 2 jets",theZ1type,theZ2type);
481 +              SimpleLepton j1 = simpleLeptonJets[0];
482 +              SimpleLepton j2 = simpleLeptonJets[1];
483 +              double deta = abs(j1.vec.Eta()-j2.vec.Eta());
484 +              double mjj = (j1.vec + j2.vec).M();
485 +              double fisher = 0.09407 * deta  +0.00041581*mjj;
486 +              if(fisher > 0.4) increment(counts, "m4l > 100 && fisher > 0.4",theZ1type,theZ2type);
487 +            }
488 +          }
489 +        }
490 +
491 +        
492        } else {
493          if(ctrl.debug) cout << "failing with code : " << ret4l.status.selectionBits << endl;
494        }
# Line 459 | Line 498 | int main(int argc, char** argv)
498          unsigned nleps = passingLeptons.size() + failingLeptons.size();
499          if( (nleps>=3 && ctrl.fakeScheme=="ZPlusF" ) || (nleps>=4 && ctrl.fakeScheme=="ZPlusFF" ) ) {
500            addDummyZ2Lepotons(ret4l);
501 <          setNtupleVals(ctrl, ret4l, evtinfo, angles, kine, ji, weights, info, jetArr, metArr, simpleLeptonJets, fJetCorrector, puArr, puDArr, fJetIDMVA, vtxArr, triggerBits, hltTable, hltObjArr, fTrigObjs, &nt);
501 >          setNtupleVals(ctrl, ret4l, evtinfo, angles, kine, ji, weights, info, muonArr, electronArr, jetArr,  metArr, simpleLeptonJets, fJetCorrector, puArr, puDArr, fJetIDMVA, vtxArr, triggerBits, hltTable, hltObjArr, fTrigObjs, &nt);
502            nt.Fill();
503            foTree->Fill();
504          }
# Line 467 | Line 506 | int main(int argc, char** argv)
506          if(ctrl.debug) cout << "failing PASS_GOODZ1" << endl;
507        }
508      }
509 +
510 +    hltTable->Delete();
511 +
512    }
513  
514    if(ctrl.fakeScheme != "none") {
# Line 477 | Line 519 | int main(int argc, char** argv)
519  
520    for(unsigned icut=0; icut<cuts.size(); icut++) {
521      map<TString,int> thisCount(*(counts[cuts[icut]]));
522 <    cerr << setw(20) << cuts[icut] << "\t" << setw(9) << thisCount["all"] << "  ("
522 >    cerr << setw(25) << cuts[icut] << "\t" << setw(9) << thisCount["all"] << "  ("
523           << setw(9) << thisCount["4e"] << setw(9) << thisCount["4m"] << setw(9) << thisCount["2e2m"] << ")" << endl;
524    }
525 +
526 +  tmp_file.Close();
527 +
528   }
529   //----------------------------------------------------------------------------------------
530   void addDummyZ2Lepotons(EventData &ret4l)
# Line 493 | Line 538 | void addDummyZ2Lepotons(EventData &ret4l
538   }
539   //----------------------------------------------------------------------------------------
540   void setNtupleVals(ControlFlags &ctrl, EventData &ret4l, InfoStruct &evtinfo, Angles &angles, KinematicsStruct &kine,
541 <                   JetInfoStruct &ji, WeightStruct &weights, EventHeader *info, Array<PFJet> *jetArr, Array<PFMet> *metArr,
541 >                   JetInfoStruct &ji, WeightStruct &weights, EventHeader *info, Array<Muon> *muonArr, Array<Electron> *electronArr, Array<PFJet> *jetArr, Array<PFMet> *metArr,
542                     vector<SimpleLepton> &simpleLeptonJets, FactorizedJetCorrector *fJetCorrector, Array<PileupInfo> *puArr,
543                     Array<PileupEnergyDensity> *puDArr, JetIDMVA *fJetIDMVA, Array<Vertex> *vtxArr, bitset<1024> &triggerBits,
544                     TriggerTable *hltTable, Array<TriggerObject> *hltObjArr, TriggerObjectsTable *fTrigObjs, AngleTuple *nt)
545   {
546    fillKinematics(ret4l,kine);
547 <  // fillMassErrors(ret4l,muonArr,electronArr,kine);
547 >
548 >  //the last two arguments are usePt and useY respectively
549 >  fillMela(kine,0,0);
550 >
551 >  fillMassErrors(ctrl,ret4l,muonArr,electronArr,kine);
552 >
553    TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
554    fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0, vtxArr->GetEntries());
555    fillJets(ctrl, jetArr, simpleLeptonJets, fJetCorrector, puDArr, fJetIDMVA, vtxArr, ret4l);
556    fillJetInfo(simpleLeptonJets, ji, ctrl);
557 <  fillJetAngleBranches(ji, ret4l, nt, ctrl);
557 >  //fillJetAngleBranches(ji, ret4l, nt, ctrl);
558    evtinfo.status = 0;
559    evtinfo.status = setHltBits(ti, triggerBits);
560  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines