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.14 by khahn, Sat May 5 21:43:55 2012 UTC vs.
Revision 1.41 by khahn, Mon Jun 18 20:42:47 2012 UTC

# Line 5 | Line 5
5   #include <iostream>                 // standard I/O
6   #include <iomanip>                  // functions to format standard I/O
7   #include <bitset>  
8 + #include <map>  
9   using namespace std;
10  
11   //
# Line 34 | Line 35 | using namespace std;
35   #include "Vertex.h"
36   #include "PFCandidate.h"
37   #include "PFCandidateCol.h"
38 + #include "PileupInfoCol.h"
39 + #include "PileupEnergyDensity.h"
40 + #include "MCParticle.h"
41   #include "TriggerMask.h"
42   #include "TriggerTable.h"
43 + #include "TriggerObject.h"
44 + #include "TriggerObjectRel.h"
45   #include "Names.h"
46   #include "BaseMod.h"
47 <
47 > #include "MitAna/TreeMod/interface/HLTFwkMod.h"
48   //
49   // our headers
50   //
# Line 46 | Line 52 | using namespace std;
52   #include "MuonSelection.h"
53   #include "ElectronSelection.h"
54   #include "IsolationSelection.h"
49
50 //#include "Selection.h"
55   #include "ReferenceSelection.h"
56  
57   #include "TriggerUtils.h"
# Line 55 | Line 59 | using namespace std;
59   #include "Angles.h"
60   #include "KinematicsStruct.h"
61   #include "InfoStruct.h"
62 < //#include "GenInfoStruct.h"
62 > #include "GenInfoStruct.h"
63   #include "WeightStruct.h"
60 #include "GlobalDataAndFuncs.h"
64   #include "AngleTuple.h"
65 + #include "FOTuple.h"
66  
67 + #include "RunLumiRangeMap.h"
68   #include "SampleWeight.h"
69   #include "EfficiencyWeightsInterface.h"
70 + #include "SelectionFuncs.h"
71 +
72 + #include "SimpleLepton.h"
73  
74   #ifndef CMSSW_BASE
75   #define CMSSW_BASE "../"
# Line 69 | Line 77 | using namespace std;
77  
78   using namespace mithep;
79  
80 + //
81 + // globals
82 + //----------------------------------------------------------------------------
83 + TH1D * hpu;
84 + RunLumiRangeMap rlrm;
85 + vector<SimpleLepton> failingLeptons ; // for fake estimation
86 + vector<SimpleLepton> passingLeptons;      // for fake estimation
87 + vector<unsigned> cutvec;
88 + vector<vector<unsigned> > zcutvec;
89 + vector<vector<unsigned> > zzcutvec;
90 + map<unsigned,float>       evtrhoMap;
91 + vector<string> cutstrs;
92 + bool passes_HLT_MC;
93 + vector<bool>   PFnoPUflag;;
94  
95 + //
96 + // prototypes
97   //----------------------------------------------------------------------------
98 < bool setPV(ControlFlags,const mithep::Array<mithep::Vertex>*, mithep::Vertex& );
98 > void initPUWeights();
99 > double getPUWeight(unsigned npu);
100 > void initRunLumiRangeMap();
101 > void setHLTObjectRelations( mithep::Array<mithep::TriggerObject>        *hltObjArr,
102 >                            mithep::Array<mithep::TriggerObjectRel>     *hltRelsArr,
103 >                            vector<string> * fHLTTab,
104 >                            vector<string> * fHLTLab )
105 > {
106 >
107 >  const int n = hltRelsArr->GetEntries();
108 >  for (int i=0; i<n; ++i) {
109 >    const TriggerObjectRel *rel = hltRelsArr->At(i);
110 >    if (!rel) continue;
111 >
112 >    const TriggerObjectBase *ob = hltObjArr->At(rel->ObjInd());
113 >    if (!ob) continue;
114 >
115 >    hltObjArr->At(rel->ObjInd())->SetTrigName(fHLTTab->at(rel->TrgId()).c_str());
116 >    hltObjArr->At(rel->ObjInd())->SetModuleName(fHLTLab->at(rel->ModInd()).c_str());
117 >    hltObjArr->At(rel->ObjInd())->SetFilterName(fHLTLab->at(rel->FilterInd()).c_str());
118 >    if (hltObjArr->At(rel->ObjInd())->TagInd()>=0)
119 >      hltObjArr->At(rel->ObjInd())->SetTagName(fHLTLab->at(hltObjArr->At(rel->ObjInd())->TagInd()).c_str());
120 >    else
121 >      hltObjArr->At(rel->ObjInd())->SetTagName("Unknown");
122 >  }
123 > };
124 >
125   //----------------------------------------------------------------------------
126  
127 < //=== MAIN =================================================================================================
127 >
128 > //
129 > // MAIN
130 > //----------------------------------------------------------------------------
131   int main(int argc, char** argv)
132 + //----------------------------------------------------------------------------
133   {
134 +  cutstrs.push_back(string("skim0"));              //0
135 +  cutstrs.push_back(string("skim1"));              //1
136 +  cutstrs.push_back(string("skim2"));              //1
137 +  cutstrs.push_back(string("trigger"));            //2
138 +  // -------------------------------------------------
139 +  cutstrs.push_back(string("Z candidate"));        //3
140 +  cutstrs.push_back(string("good Z1"));            //4
141 +  // -------------------------------------------------
142 +  cutstrs.push_back(string("4l"));                 //5  
143 +  cutstrs.push_back(string("ZZ candidate"));       //6
144 +  cutstrs.push_back(string("good Z2"));            //7
145 +  cutstrs.push_back(string("ZZ 20/10"));           //8
146 +  cutstrs.push_back(string("resonance"));          //9
147 +  cutstrs.push_back(string("m4l>70"));             //10
148 +  cutstrs.push_back(string("m4l>100, mZ2 > 12"));                  //11
149 +
150 +
151 +
152 +
153    string cmsswpath(CMSSW_BASE);
154    cmsswpath.append("/src");
155    std::bitset<1024> triggerBits;
156    vector<vector<string> > inputFiles;
157    inputFiles.push_back(vector<string>());
158 <  map<string,double> entrymap; // number of unskimmed entries in each file
158 >  map<string,unsigned> entrymap; // number of unskimmed entries in each file
159 >  for( int i=0; i<cutstrs.size(); i++ ) cutvec.push_back(0);
160 >  for( int i=0; i<2; i++ )  {
161 >    zcutvec.push_back(vector<unsigned>());
162 >    for( int j=0; j<cutstrs.size(); j++ ) zcutvec[i].push_back(0);
163 >  }
164 >  for( int i=0; i<3; i++ )  {
165 >    zzcutvec.push_back(vector<unsigned>());
166 >    for( int j=0; j<cutstrs.size(); j++ ) zzcutvec[i].push_back(0);
167 >  }
168 >
169  
170    //
171    // args
# Line 99 | Line 182 | int main(int argc, char** argv)
182        return 1;
183      }
184    ctrl.dump();
102  assert( ctrl.mH != 0 );
185  
186  
187  
# Line 116 | Line 198 | int main(int argc, char** argv)
198        if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines
199        cout << "adding inputfile : " << fname.c_str() << endl;
200        entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str());
201 +      cout << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl;
202        chain->AddFile(fname.c_str());
203        hltchain->AddFile(fname.c_str());
204      }
205    } else {
206      cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl;
207 +    unsigned tmpent = unskimmedEntries(ctrl.inputfile.c_str());
208 +    cout << "tmpent: " << tmpent << endl;
209      entrymap[string(ctrl.inputfile.c_str())] = unskimmedEntries(ctrl.inputfile.c_str());
210 +    cout << "unskimmed entries: " << entrymap[string(ctrl.inputfile.c_str())] << endl;
211      chain->AddFile(ctrl.inputfile.c_str());
212      hltchain->AddFile(ctrl.inputfile.c_str());
213    }
# Line 145 | Line 231 | int main(int argc, char** argv)
231    KinematicsStruct kinematics;
232    InfoStruct evtinfo;
233    WeightStruct weights;
234 <  //  GenInfoStruct geninfo;
234 >  GenInfoStruct geninfo;
235  
236    AngleTuple nt( (const char*)ofname, (const char*)"zznt");
237    nt.makeAngleBranch(angles);
238    nt.makeKinematicsBranch(kinematics);
239    nt.makeInfoBranch(evtinfo);
240  
241 <  TH1F * h_w_hpt;
241 >  
242 >  FOTuple foTree( nt.getFile(), (const char*)"FOtree");
243 >  foTree.makeFailedLeptonBranch(failingLeptons);
244 >  foTree.makePassedLeptonBranch(passingLeptons);
245 >
246 >  TH1F * h_wf11_hpt;
247    if(ctrl.mc) {
248      nt.makeWeightBranch(weights);
249 <    //    nt.makeGenInfoBranch(geninfo);
250 <    initEfficiencyWeights();
251 <    /*
249 >    if(ctrl.fillGen ) nt.makeGenInfoBranch(geninfo);
250 >    if(ctrl.efftype != string("WTF?")) initEfficiencyWeights();
251 >    initPUWeights();
252 >
253      // Higgs only, pt reweighting
254      if( ctrl.mH <= 140 ) {
255        char wptname[256];
# Line 165 | Line 257 | int main(int argc, char** argv)
257        TFile * f_hpt = new TFile(wptname);
258        f_hpt->Print();
259        sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH);
260 <      h_w_hpt  = (TH1F*)(f_hpt->FindObjectAny(wptname));
169 <      h_w_hpt->Print();
260 >      h_wf11_hpt  = (TH1F*)(f_hpt->FindObjectAny(wptname));
261      }
262 <    */
262 >
263    } else {
264      initRunLumiRangeMap();
265    }
266  
267    //  initMuonIDMVA();
268 <  initMuonIsoMVA();
178 <  initElectronIDMVA();
179 <  initElectronIsoMVA();
268 >  initElectronIDMVAV1();
269    initTrigger();
270 <  
182 <  
183 <  //##########################################################################
184 <  // Setup tree I/O
185 <  //##########################################################################
270 >
271    
272    //
273 <  // Access samples and fill histograms
273 >  // Setup tree I/O
274 >  //--------------------------------------------------------------------------------------------------------------
275    TFile *inputFile=0;
276    TTree *eventTree=0;  
277    string currentFile("");
278  
193  // Data structures to store info from TTrees
279    mithep::EventHeader *info    = new mithep::EventHeader();
195  //  mithep::TGenInfo    *ginfo  = new mithep::TGenInfo();
280    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
281    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
282    mithep::Array<mithep::Vertex>               *vtxArr        = new mithep::Array<mithep::Vertex>();
283    mithep::Array<mithep::PFCandidate>          *pfArr         = new mithep::Array<mithep::PFCandidate>();
284 <  mithep::Array<mithep::PileupEnergyDensity>  *puArr         = new mithep::Array<mithep::PileupEnergyDensity>();
284 >  mithep::Array<mithep::PileupInfo>           *puArr         = new mithep::Array<mithep::PileupInfo>();
285 >  mithep::Array<mithep::PileupEnergyDensity>  *puDArr        = new mithep::Array<mithep::PileupEnergyDensity>();
286    mithep::Array<mithep::Track>                *trkArr        = new mithep::Array<mithep::Track>();
287 +  mithep::Array<mithep::MCParticle>           *mcArr         = new mithep::Array<mithep::MCParticle>();
288 +  mithep::MCEventInfo                         *mcEvtInfo     = new mithep::MCEventInfo();
289    mithep::TriggerMask                         *trigMask      = new mithep::TriggerMask();
290    mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable();
291    vector<string>                              *hltTableStrings  = new vector<string>();
292 +  vector<string>                              *hltLabelStrings  = new vector<string>();
293 +  mithep::Array<mithep::TriggerObject>        *hltObjArr     = new mithep::Array<mithep::TriggerObject>();
294 +  mithep::Array<mithep::TriggerObjectRel>     *hltRelsArr    = new mithep::Array<mithep::TriggerObjectRel>();
295 +  std::vector<std::string>                    *hltTab        = new vector<string>();
296 +  std::vector<std::string>                    *hltLab        = new vector<string>();
297 +
298  
299    TString fElectronName(Names::gkElectronBrn);
300    TString fMuonName(Names::gkMuonBrn);
301    TString fInfoName(Names::gkEvtHeaderBrn);
302    TString fPrimVtxName(Names::gkPVBrn);
303    TString fPFCandidateName(Names::gkPFCandidatesBrn);
304 +  TString fPileupInfoName(Names::gkPileupInfoBrn);
305    TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn);
306    TString fTrackName(Names::gkTrackBrn);
307 +  TString fMCParticleName(Names::gkMCPartBrn);
308 +  TString fMCEvtInfoName(Names::gkMCEvtInfoBrn);
309    TString fTriggerMaskName(Names::gkHltBitBrn);
310    TString fTriggerTableName(Names::gkHltTableBrn);
311 <  
311 >  TString fTriggerLabelName(Names::gkHltLabelBrn);
312 >  TString fTriggerObjectName(Names::gkHltObjBrn);
313 >  TString fTriggerObjectRelsName(Form("HLTObjectsRelation"));
314 >
315 >  TString fHLTLabName(Names::gkHltLabelBrn);
316 >  TString fHLTTabName(Names::gkHltTableBrn);
317 >  TString fHLTTabNamePub(Form("%sFwk",fHLTTabName.Data()));
318 >  TString fHLTLabNamePub(Form("%sFwk",fHLTLabName.Data()));
319 >  TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data()));
320 >
321 >
322 >
323    chain->SetBranchAddress(fInfoName,        &info);
324    chain->SetBranchAddress(fElectronName,    &electronArr);
325    chain->SetBranchAddress(fMuonName,        &muonArr);
326    chain->SetBranchAddress(fPrimVtxName,     &vtxArr);
327    chain->SetBranchAddress(fPFCandidateName, &pfArr);
328 <  chain->SetBranchAddress(fPileupEnergyDensityName, &puArr);
328 >  if( ctrl.mc ) {
329 >    chain->SetBranchAddress(fPileupInfoName,  &puArr);
330 >    chain->SetBranchAddress(fMCParticleName,  &mcArr);
331 >    chain->SetBranchAddress(fMCEvtInfoName,  &mcEvtInfo);
332 >  }
333 >  chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr);
334    chain->SetBranchAddress(fTrackName, &trkArr);
335    chain->SetBranchAddress(fTriggerMaskName, &trigMask);
336 +  chain->SetBranchAddress(fTriggerObjectName,  &hltObjArr);
337 +  chain->SetBranchAddress(fTriggerObjectRelsName,  &hltRelsArr);
338 +  chain->SetBranchAddress(fHLTTabNamePub,  &hltTab);
339 +  chain->SetBranchAddress(fHLTLabNamePub,  &hltLab);
340 +
341    cout << "hlttable: " << fTriggerTableName << endl;
342    hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
343 +  hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
344  
345    mithep::Vertex              vtx;          // best primary vertex in the event
346  
# Line 242 | Line 360 | int main(int argc, char** argv)
360    int imax = chain->GetEntries();
361    cout << "nEntries: " << imax << endl;
362  
363 +  HLTFwkMod stupid;
364  
365 <  //##########################################################################
366 <  // Loop !!!!!!!!! should alternate events here and +1 in the training ...
367 <  //##########################################################################
365 >  //
366 >  // Loop !!!!!!!!!
367 >  //--------------------------------------------------------------------------------------------------------------
368    for(UInt_t ientry=0; ientry<imax; ientry++)
369      {
370        chain->GetEntry(ientry);
371        if(!(ientry%1000)) cerr << "entry: " << ientry << endl;
372 +      
373 +      if( ctrl.debug ) {
374 +        cout << "-----------------------------------------------------------------" << endl;
375 +        cout << "-----------------------------------------------------------------" << endl;
376 +        cout << "Run: " << info->RunNum()
377 +             << "\tEvt: " << info->EvtNum()
378 +             << "\tLumi: " << info->LumiSec()
379 +             << endl;
380 +        cout << "-----------------------------------------------------------------" << endl;
381 +      }
382 +
383 +
384 +      string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
385 +      setEra( fname, ctrl );
386  
254      setPV( ctrl, vtxArr, vtx);
387  
388 +
389 +      //
390 +      // pfNoPU
391 +      //
392 +      //mithep::Array<PFCandidate> pfNoPileUp;
393 +      PFnoPUflag.clear();
394 +      int pfnopu_size = makePFnoPUArray( pfArr, PFnoPUflag, vtxArr );
395 +      assert(pfnopu_size == pfArr->GetEntries());
396 +
397 +      //
398 +      // data/MC
399 +      //
400        if(ctrl.mc) {
401 <        weights.w = getWeight(xstab,entrymap,chain);
401 >        //
402 >        // gen info
403 >        //
404 >        if( ctrl.fillGen )
405 >          fillGenInfo( mcArr, mcEvtInfo, geninfo, ESampleType::kHZZ, ctrl);
406 >
407 >        //
408 >        // xsec & PU weights
409 >        //
410 >        weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
411 >        cout << "xsec weight: " << weights.w << endl;
412 >        int npu = -1;
413 >        for(int i=0;i<puArr->GetEntries();i++) {
414 >          if(puArr->At(i)->GetBunchCrossing() == 0)
415 >            npu = puArr->At(i)->GetPU_NumInteractions();
416 >        }
417 >        assert(npu>=0);
418 >        evtinfo.npu;
419 >        weights.npuw = getPUWeight(evtinfo.npu);
420 >        
421 >        //
422 >        // pt reweighting for Higgs < 140, F11
423 >        //
424 >        if( ctrl.fillGen ) {
425 >          if( (fname.find("f11-h115zz4l") != string::npos) ||
426 >              (fname.find("f11-h120zz4l") != string::npos) ||
427 >              (fname.find("f11-h130zz4l") != string::npos)  ) {
428 >            weights.w *= h_wf11_hpt->GetBinContent(h_wf11_hpt->FindBin(geninfo.pt_zz));
429 >          }
430 >        }
431 >
432 >        //
433 >        // trigger
434 >        //
435 >        if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
436 >          currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
437 >          hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
438 >          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
439 >          hltchain->GetEntry(0);
440 >          hltTable->Clear();
441 >          fillTriggerNames(hltTable, hltTableStrings );
442 >        }
443 >        if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
444 >        fillTriggerBits( hltTable, trigMask, triggerBits );
445 >        passes_HLT_MC = true; // passed to apply as extern global, just for sync
446 >        if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) {
447 >          passes_HLT_MC = false;
448 >        }
449 >
450 >        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings );
451 >        for( int i=0; i<hltObjArr->GetEntries(); i++ ) {
452 >          const mithep::TriggerObject *to = (*hltObjArr)[i];
453 >          to->Print();
454 >        }
455 >
456 >
457        } else {
458 +        //
459 +        // JSON
460 +        //
461 +        if(!(ctrl.noJSON) ) {
462 +          RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec());      
463 +          if( !(rlrm.HasRunLumi(rl)) )  {
464 +            if( ctrl.debug ) cout << "fails JSON" << endl;
465 +            continue;
466 +          }
467 +        }
468 +
469 +        //
470 +        // trigger
471 +        //
472          if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
473            currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
474            hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
475 +          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
476            hltchain->GetEntry(0);
477            hltTable->Clear();
478 <          fillTriggerBits(hltTable, hltTableStrings );
478 >          fillTriggerNames(hltTable, hltTableStrings );
479 >        }
480 >
481 >        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings );
482 >        for( int i=0; i<hltObjArr->GetEntries(); i++ ) {
483 >          const mithep::TriggerObject *to = (*hltObjArr)[i];
484 >          to->Print();
485          }
486 +
487          if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
488 +        /*
489          fillTriggerBits( hltTable, trigMask, triggerBits );
268      }
269      
270      
271      //
272      // trigger
273      //
274      if( !ctrl.mc ) {
490          if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) {
491            if( ctrl.debug ) cout << "\tfails trigger ... " << endl;
492            continue;
493          }
494 +        */
495        }
496 <      
496 >
497        //
498        // lepton/kinematic selection ...
499        //
500 +      failingLeptons.clear();
501 +      passingLeptons.clear();
502        EventData ret4l =
503 +
504 +
505 +        // reference
506          apply_HZZ4L_reference_selection(ctrl, info,
507 <                              vtx,
508 <                              pfArr,
509 <                              puArr,
510 <                              electronArr,
511 <                              &electronReferencePreSelection,
512 <                              &electronReferenceIDMVASelection,
513 <                              &electronReferenceIsoSelection,
514 <                              muonArr,
515 <                              &muonReferencePreSelection,
516 <                              &muonIDPFSelection,
517 <                              &muonReferenceIsoSelection);
507 >                                        vtxArr,
508 >                                        pfArr,
509 >                                        puDArr,
510 >                                        electronArr,
511 >                                        &electronReferencePreSelection,
512 >                                        &electronReferenceIDMVASelectionV1,
513 >                                        &electronReferenceIsoSelection,
514 >                                        muonArr,
515 >                                        &muonReferencePreSelection,
516 >                                        &muonIDPFSelection,
517 >                                        &muonReferenceIsoSelection);
518 >      
519        if( ctrl.debug ) cout << endl;
520  
521 <      cout << "bits: " << ret4l.status.selectionBits << endl;
521 >
522 >      int Z1type=0, Z2type=0;
523 >      if( ret4l.status.selectionBits.to_ulong() >= PASS_ZCANDIDATE ) {
524 >        if( abs(ret4l.Z1leptons[0].type) == 11  ) Z1type = 11;
525 >        if( abs(ret4l.Z1leptons[0].type) == 13  ) Z1type = 13;
526 >      }  
527 >      if( ret4l.status.selectionBits.to_ulong() >= PASS_ZZCANDIDATE ) {
528 >        if( abs(ret4l.Z2leptons[0].type) == 11  ) Z2type = 11;
529 >        if( abs(ret4l.Z2leptons[0].type) == 13  ) Z2type = 13;
530 >      }  
531 >      
532 > #ifdef SYNC
533 >      cout  << "bits: " << ret4l.status.selectionBits  << "\t"
534 >            << "Z1: " << Z1type << "\t"
535 >            << "Z2: " << Z2type << endl;
536 >      cout << endl;
537 > #endif      
538        
539        if( ret4l.status.pass() ) {
302        
540          fillAngles(ret4l,angles);
541          fillKinematics(ret4l,kinematics);
542 +        fillMassErrors(ret4l,muonArr,electronArr,kinematics);
543          fillEventInfo(info,evtinfo);
544 <        //if(ctrl.mc) fillGenInfo(ginfo,geninfo);
544 >        if( ctrl.mc) {
545 >          if( std::string(ctrl.efftype) != std::string("WTF?")) {
546 >          setEffiencyWeights(ret4l, weights);
547 >          } else {
548 >            weights.won = weights.woff = 1.;
549 >          }
550 >           if(ctrl.debug)
551 >             cout << "w: " << weights.w << "\t"
552 >                  << "won: " << weights.won << "\t"
553 >                  << "woff: " << weights.woff << endl;
554 >        }
555          
556 <        /*
309 <        // only for Higgs < 140
310 <        geninfo.weight *= h_w_hpt->GetBinContent(h_w_hpt->FindBin(geninfo.pt_zz));
311 <        angles.bdt = reader->EvaluateMVA("BDTG");
312 <        */
556 >
557          nt.Fill();
558          
559          cerr  << "PASS:: "
# Line 324 | Line 568 | int main(int argc, char** argv)
568          pass++;
569          //      if( pass > 3 ) break;
570  
571 <      }
571 >      } else if( ret4l.status.selectionBits.test(PASS_GOODZ1) &&
572 >                 ret4l.status.selectionBits.to_ulong() < (1UL<<PASS_4L)) { // save for fakes ...
573 >        if(ctrl.debug) {
574 >          cout << "failingLeptons : " << failingLeptons.size() << endl;
575 >          for( int f=0; f<failingLeptons.size(); f++ ) {
576 >            SimpleLepton  l = failingLeptons[f];
577 >            cout << "f: " << f << "\t"
578 >                 << "type: " << l.type << "\t"
579 >                 << "pT: " << l.vec.Pt()  << "\t"
580 >                 << "eta: " << l.vec.Eta()
581 >                 << endl;
582 >          }
583 >        }
584 >        foTree.Fill();
585 >      } else {
586 >        cout << "failing with some other code : " << ret4l.status.selectionBits << endl;
587 >      }
588      }  
589  
590 +  
591 +  foTree.getFile()->cd();
592 +  foTree.getTree()->Write();
593    nt.WriteClose();
594 +
595 +  cout << endl;
596 +  cout << endl;
597 +  for( int i=0; i<cutvec.size(); i++ ) {
598 +    cout << "cut: " << i << "\t"
599 +         << "pass: " << cutvec[i];
600 +
601 +    if( i>PASS_TRIGGER&&i<=PASS_GOODZ1 )
602 +      cout << "\t2e: " << zcutvec[0][i]
603 +           << "\t2m: " << zcutvec[1][i];
604 +
605 +    if( i>PASS_ZCANDIDATE )
606 +      cout << "\t4e: " << zzcutvec[0][i]
607 +           << "\t4m: " << zzcutvec[1][i]
608 +           << "\t2e2m: " << zzcutvec[2][i];
609 +
610 +    cout << "\t" << cutstrs[i] << endl;
611 +
612 +    cout << endl;
613 +  }
614 +
615   }
616  
617 +
618   //----------------------------------------------------------------------------
619 < //
620 < // Get primary vertices
621 < // Assumes primary vertices are ordered by sum-pT^2 (as should be in CMSSW)
622 < // NOTE: if no PV is found from fitting tracks, the beamspot is used
623 < //
624 < //----------------------------------------------------------------------------
625 < bool setPV(ControlFlags ctrl,
626 <           const mithep::Array<mithep::Vertex> * vtxArr,
627 <           mithep::Vertex & vtx)
628 < //----------------------------------------------------------------------------
629 < {
630 <  const Vertex *bestPV = 0;
631 <  float best_sumpt=-1;
632 <
633 <  // good PV requirements
634 <  const UInt_t   fMinNTracksFit = 0;
350 <  const Double_t fMinNdof       = 4;
351 <  const Double_t fMaxAbsZ       = 24;
352 <  const Double_t fMaxRho        = 2;
353 <  
354 <  for(int i=0; i<vtxArr->GetEntries(); ++i) {
355 <    const Vertex *pv = (Vertex*)(vtxArr->At(i));
356 <    if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl;
357 <    
358 <    // Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used
359 <    //  if(!pv->IsValid()) continue;
360 <    if(pv->NTracksFit()       < fMinNTracksFit)       continue;
361 <    if(pv->Ndof()                 < fMinNdof)         continue;
362 <    if(fabs(pv->Z()) > fMaxAbsZ)                      continue;
363 <    if(pv->Position().Rho()   > fMaxRho)              continue;    
364 <    
365 <    // take the first ...
366 <    bestPV = pv;
367 <    break;
368 <
369 <    // this never reached ...    
370 <    float tmp_sumpt=0;
371 <    for( int t=0; t<pv->NTracks(); t++ )
372 <      tmp_sumpt += pv->Trk(t)->Pt();
373 <    
374 <    if( tmp_sumpt > best_sumpt  ) {
375 <      bestPV = pv;
376 <      best_sumpt = tmp_sumpt;
377 <      if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl;
378 <    }
379 <  }
380 <  
381 <  if(!bestPV) bestPV = vtxArr->At(0);
382 <  vtx.SetPosition(bestPV->X(),bestPV->Y(),bestPV->Z());
383 <  vtx.SetErrors(bestPV->XErr(),bestPV->YErr(),bestPV->ZErr());
384 <  return true;
619 > void initRunLumiRangeMap()
620 > //----------------------------------------------------------------------------
621 > {
622 >  /*
623 >  rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
624 >  //  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
625 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
626 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));  
627 >  rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));  
628 >  // r11b
629 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt"));  
630 >  */
631 >
632 >  // 2012 only for now ...
633 >  rlrm.AddJSONFile(std::string("./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt"));  
634 >
635   };
636 +
637 +
638 + //----------------------------------------------------------------------------
639 + void initPUWeights()
640 + //----------------------------------------------------------------------------
641 + {
642 +  TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Full2011.root");
643 +  hpu = (TH1D*)(puf->Get("puWeights"));
644 + }
645 +
646 + //----------------------------------------------------------------------------
647 + double getPUWeight(unsigned npu)
648 + //----------------------------------------------------------------------------
649 + {
650 +  return hpu->GetBinContent(hpu->FindBin(npu));
651 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines