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.62 by dkralph, Mon Dec 17 17:12:21 2012 UTC vs.
Revision 1.73 by anlevin, Tue Feb 5 09:53:47 2013 UTC

# Line 67 | Line 67 | using namespace std;
67  
68   #include "TriggerUtils.h"
69   #include "PassHLT.h"
70 #include "Angles.h"
70   #include "KinematicsStruct.h"
71   #include "InfoStruct.h"
72   #include "GenInfoStruct.h"
73   #include "WeightStruct.h"
74   #include "AngleTuple.h"
76 #include "JetInfoStruct.h"
75   #include "FOTuple.h"
76  
77   #include "RunLumiRangeMap.h"
# Line 83 | 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 109 | 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 134 | 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 144 | 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 221 | Line 225 | int main(int argc, char** argv)
225    cout << "xspath: " << xspath.c_str() << endl;
226    SimpleTable xstab(xspath.c_str());
227    if(ctrl.mc) {
228 <    getWeight(xstab,entrymap,chain); // test *now* whether we've got the xs in here, so it fails before it creates the output
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 240 | 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 261 | Line 267 | int main(int argc, char** argv)
267        } else
268          nt.makeGenInfoBranch(geninfo);
269      }
270 <    initEfficiencyWeights();
265 <    // initPUWeights();
270 >    if(ctrl.use_eff_weights) initEfficiencyWeights();
271    } else {
272      if(!(ctrl.noJSON) )
273        initRunLumiRangeMap(ctrl);
# Line 271 | 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 364 | 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 412 | Line 426 | int main(int argc, char** argv)
426      if(ctrl.mc) {
427        if(ctrl.fillGen) fillGenInfo( mcArr, mcEvtInfo, geninfo, genSampleType, ctrl);
428        // NOTE: xs weight and npuw are reset in merge.cc
429 <      weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
430 <      if(ctrl.debug) cout ;
429 >      if(ctrl.use_xs_weights)
430 >        weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
431 >      else
432 >        weights.w = 1;
433        weights.npu = getNPU(puArr, 0);
434        weights.npuw = getPUWeight(ctrl.era, fname, weights.npu);
435      } else {
# Line 449 | 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 460 | 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 468 | 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 478 | 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 494 | 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  
# Line 513 | Line 562 | void setNtupleVals(ControlFlags &ctrl, E
562      fillAngles(ret4l,angles);
563  
564      if( ctrl.mc) {
565 <      setEfficiencyWeights(ctrl, ctrl.era, ret4l, triggerBits, hltTable, hltObjArr, fTrigObjs, weights);
565 >      if(ctrl.use_eff_weights) setEfficiencyWeights(ctrl, ctrl.era, ret4l, triggerBits, hltTable, hltObjArr, fTrigObjs, weights);
566        if(ctrl.debug)
567          cout << "w: " << weights.w << "\t" << "npuw: " << weights.npuw << "\t" << "won: " << weights.won << "\t" << "woff: " << weights.woff << endl;
568      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines