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.27 by anlevin, Wed May 23 22:06:40 2012 UTC vs.
Revision 1.28 by khahn, Thu May 24 17:48:15 2012 UTC

# Line 60 | Line 60 | using namespace std;
60   #include "Angles.h"
61   #include "KinematicsStruct.h"
62   #include "InfoStruct.h"
63 < //#include "GenInfoStruct.h"
63 > #include "GenInfoStruct.h"
64   #include "WeightStruct.h"
65   //#include "GlobalDataAndFuncs.h"
66   #include "RunLumiRangeMap.h"
# Line 99 | Line 99 | vector<bool>   PFnoPUflag;;
99   //----------------------------------------------------------------------------
100   void initPUWeights();
101   double getPUWeight(unsigned npu);
102 + void setEra(string, ControlFlags&);
103   void setEffiencyWeights(EventData&, WeightStruct& );
104   void initRunLumiRangeMap();
105   void initEvtRhoMap(map<unsigned,float> &);
106   unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
107                           vector<bool> &pfNoPileUpFlag,
108 <                         const mithep::VertexCol     * vtxArr );
108 >                         const mithep::Array<mithep::Vertex>     * vtxArr );
109   //----------------------------------------------------------------------------
110  
111  
# Line 214 | Line 215 | int main(int argc, char** argv)
215    KinematicsStruct kinematics;
216    InfoStruct evtinfo;
217    WeightStruct weights;
218 <  //  GenInfoStruct geninfo;
218 >  GenInfoStruct geninfo;
219  
220    AngleTuple nt( (const char*)ofname, (const char*)"zznt");
221    nt.makeAngleBranch(angles);
# Line 225 | Line 226 | int main(int argc, char** argv)
226    foTree.makeFailedLeptonBranch(failingLeptons);
227    foTree.makeZLeptonBranch(passingLeptons);
228  
229 <  TH1F * h_w_hpt;
229 >  TH1F * h_wf11_hpt;
230    if(ctrl.mc) {
231      nt.makeWeightBranch(weights);
232 <    //    nt.makeGenInfoBranch(geninfo);
232 >    nt.makeGenInfoBranch(geninfo);
233      initEfficiencyWeights();
234      initPUWeights();
235 <    /*
235 >
236      // Higgs only, pt reweighting
237      if( ctrl.mH <= 140 ) {
238        char wptname[256];
# Line 239 | Line 240 | int main(int argc, char** argv)
240        TFile * f_hpt = new TFile(wptname);
241        f_hpt->Print();
242        sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH);
243 <      h_w_hpt  = (TH1F*)(f_hpt->FindObjectAny(wptname));
243 <      h_w_hpt->Print();
243 >      h_wf11_hpt  = (TH1F*)(f_hpt->FindObjectAny(wptname));
244      }
245 <    */
245 >
246    } else {
247      initRunLumiRangeMap();
248    }
# Line 265 | Line 265 | int main(int argc, char** argv)
265    string currentFile("");
266  
267    mithep::EventHeader *info    = new mithep::EventHeader();
268  //  mithep::TGenInfo    *ginfo  = new mithep::TGenInfo();
268    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
269    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
270 <  const mithep::VertexCol              *vtxArr        = 0;//new mithep::Array<mithep::Vertex>();
270 >  mithep::Array<mithep::Vertex>               *vtxArr        = new mithep::Array<mithep::Vertex>();
271    mithep::Array<mithep::PFCandidate>          *pfArr         = new mithep::Array<mithep::PFCandidate>();
272    mithep::Array<mithep::PileupInfo>           *puArr         = new mithep::Array<mithep::PileupInfo>();
273    mithep::Array<mithep::PileupEnergyDensity>  *puDArr        = new mithep::Array<mithep::PileupEnergyDensity>();
274    mithep::Array<mithep::Track>                *trkArr        = new mithep::Array<mithep::Track>();
275    mithep::Array<mithep::MCParticle>           *mcArr         = new mithep::Array<mithep::MCParticle>();
276 +  mithep::MCEventInfo                         *mcEvtInfo     = new mithep::MCEventInfo();
277    mithep::TriggerMask                         *trigMask      = new mithep::TriggerMask();
278    mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable();
279    vector<string>                              *hltTableStrings  = new vector<string>();
# Line 287 | Line 287 | int main(int argc, char** argv)
287    TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn);
288    TString fTrackName(Names::gkTrackBrn);
289    TString fMCParticleName(Names::gkMCPartBrn);
290 +  TString fMCEvtInfoName(Names::gkMCEvtInfoBrn);
291    TString fTriggerMaskName(Names::gkHltBitBrn);
292    TString fTriggerTableName(Names::gkHltTableBrn);
293    
# Line 298 | Line 299 | int main(int argc, char** argv)
299    if( ctrl.mc ) {
300      chain->SetBranchAddress(fPileupInfoName,  &puArr);
301      chain->SetBranchAddress(fMCParticleName,  &mcArr);
302 +    chain->SetBranchAddress(fMCEvtInfoName,  &mcEvtInfo);
303    }
304    chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr);
305    chain->SetBranchAddress(fTrackName, &trkArr);
# Line 330 | Line 332 | int main(int argc, char** argv)
332    for(UInt_t ientry=0; ientry<imax; ientry++)
333      {
334        chain->GetEntry(ientry);
333
334      /*
335      bool found_tau=false;
336      if( ctrl.mc) {  // && ctrl.debug
337        cout << "nparticles: " << mcArr->GetEntries() << endl;
338        cout << "-----------------------------------" << endl;
339        for( int i=0; i<mcArr->GetEntries(); i++ ) {
340          const mithep::MCParticle *mc = mcArr->At(i);
341          cout << "i: " << i << "\t"
342               << "id: " << mc->AbsPdgId()
343               << endl;
344          if( mc->Is(MCParticle::kTau) ) {
345            found_tau=true;
346          }
347        }
348      }
349      cout << "-----------------------------------" << endl;
350      cout << "found tau: " << found_tau << endl;
351      */
352
353      // events that fail bc ele overlaps w/ reco mu
354      /*
355      if( info->EvtNum() != 67315 &&
356          info->EvtNum() != 288693 ) continue;
357      */
358
359      // events where they apparently don't veto electrons ...
360      /*
361      if( info->EvtNum() != 141713 &&
362          info->EvtNum() != 178019 &&
363          info->EvtNum() != 60823 &&
364          info->EvtNum() != 192795 ) continue;
365      */
366
335        if(!(ientry%1000)) cerr << "entry: " << ientry << endl;
368      //if (!(setPV( ctrl, vtxArr, vtx)) ) continue;
336  
337 + #ifdef HACKED_RHOS
338        float rho = evtrhoMap[info->EvtNum()];
339 + #endif
340 +      string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
341 +      setEra( fname, ctrl );
342 +
343  
344        //
345        // pfNoPU
# Line 382 | Line 354 | int main(int argc, char** argv)
354        //
355        if(ctrl.mc) {
356          //
357 +        // gen info
358 +        //
359 +        if(ctrl.fillGen)
360 +          fillGenInfo( mcArr, mcEvtInfo, geninfo, ESampleType::kHZZ, ctrl);
361 +
362 +        //
363          // xsec & PU weights
364          //
365 <        weights.w = 1;//getWeight(xstab,entrymap,chain)/ctrl.totalMC;
365 >        weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
366          cout << "xsec weight: " << weights.w << endl;
367          int npu = -1;
368          for(int i=0;i<puArr->GetEntries();i++) {
# Line 394 | Line 372 | int main(int argc, char** argv)
372          assert(npu>=0);
373          evtinfo.npu;
374          weights.npuw = getPUWeight(evtinfo.npu);
375 <        //      cout << "weight: " << weights.w << endl;
375 >        
376 >        //
377 >        // pt reweighting for Higgs < 140, F11
378 >        //
379 >        if( ctrl.fillGen ) {
380 >          if( (fname.find("f11-h115zz4l") != string::npos) ||
381 >              (fname.find("f11-h120zz4l") != string::npos) ||
382 >              (fname.find("f11-h130zz4l") != string::npos)  ) {
383 >            weights.w *= h_wf11_hpt->GetBinContent(h_wf11_hpt->FindBin(geninfo.pt_zz));
384 >          }
385 >        }
386 >
387          //
388          // trigger
389          //
# Line 520 | Line 509 | int main(int argc, char** argv)
509                    << "woff: " << weights.woff << endl;
510          }
511          
512 <        /*
524 <        // only for Higgs < 140
525 <        geninfo.weight *= h_w_hpt->GetBinContent(h_w_hpt->FindBin(geninfo.pt_zz));
526 <        angles.bdt = reader->EvaluateMVA("BDTG");
527 <        */
512 >
513          nt.Fill();
514          
515          cerr  << "PASS:: "
# Line 687 | Line 672 | void initEvtRhoMap( map<unsigned, float>
672  
673   //----------------------------------------------------------------------------
674   unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
675 <                     vector<bool> &pfNoPileUpflag,
676 <                     const mithep::VertexCol      * vtxArr )
675 >                         vector<bool> &pfNoPileUpflag,
676 >                         const mithep::Array<mithep::Vertex>      * vtxArr )
677   //----------------------------------------------------------------------------
678   {
679    for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) {
# Line 756 | Line 741 | unsigned makePFnoPUArray(mithep::Array<P
741    return pfNoPileUpflag.size();
742   }
743  
744 + void setEra(string fname, ControlFlags &ctrl)
745 + {
746 +  if( ctrl.mc && (fname.find("f11-") != string::npos)  ) ctrl.era=2011 ;
747 +  if( ctrl.mc && (fname.find("s12-") != string::npos)  ) ctrl.era=2012 ;
748 +  if( !ctrl.mc && (fname.find("r11-") != string::npos)  ) ctrl.era=2011 ;
749 +  if( !ctrl.mc && (fname.find("r12-") != string::npos)  ) ctrl.era=2012 ;
750 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines