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.22 by khahn, Mon May 14 17:27:34 2012 UTC vs.
Revision 1.26 by khahn, Wed May 23 13:33:15 2012 UTC

# Line 37 | Line 37 | using namespace std;
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 "Names.h"
# Line 96 | Line 97 | vector<bool>   PFnoPUflag;;
97   //
98   // prototypes
99   //----------------------------------------------------------------------------
99 bool setPV(ControlFlags,const mithep::Array<mithep::Vertex>*, mithep::Vertex& );
100   void initPUWeights();
101   double getPUWeight(unsigned npu);
102   void setEffiencyWeights(EventData&, WeightStruct& );
# Line 104 | Line 104 | void initRunLumiRangeMap();
104   void initEvtRhoMap(map<unsigned,float> &);
105   unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
106                           vector<bool> &pfNoPileUpFlag,
107 <                         mithep::Array<Vertex>      * vtxArr );
107 >                         const mithep::VertexCol     * vtxArr );
108   //----------------------------------------------------------------------------
109  
110  
# Line 116 | Line 116 | int main(int argc, char** argv)
116   {
117    cutstrs.push_back(string("skim0"));              //0
118    cutstrs.push_back(string("skim1"));              //1
119 +  cutstrs.push_back(string("skim2"));              //1
120    cutstrs.push_back(string("trigger"));            //2
121    // -------------------------------------------------
122    cutstrs.push_back(string("Z candidate"));        //3
# Line 127 | Line 128 | int main(int argc, char** argv)
128    cutstrs.push_back(string("ZZ 20/10"));           //8
129    cutstrs.push_back(string("resonance"));          //9
130    cutstrs.push_back(string("m4l>70"));             //10
131 <  cutstrs.push_back(string("m4l>100"));            //11
131 >  cutstrs.push_back(string("m4l>100, mZ2 > 12"));                  //11
132  
133  
134  
# Line 267 | Line 268 | int main(int argc, char** argv)
268    //  mithep::TGenInfo    *ginfo  = new mithep::TGenInfo();
269    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
270    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
271 <  mithep::Array<mithep::Vertex>               *vtxArr        = new mithep::Array<mithep::Vertex>();
271 >  const mithep::VertexCol              *vtxArr        = 0;//new mithep::Array<mithep::Vertex>();
272    mithep::Array<mithep::PFCandidate>          *pfArr         = new mithep::Array<mithep::PFCandidate>();
273    mithep::Array<mithep::PileupInfo>           *puArr         = new mithep::Array<mithep::PileupInfo>();
274    mithep::Array<mithep::PileupEnergyDensity>  *puDArr        = new mithep::Array<mithep::PileupEnergyDensity>();
275    mithep::Array<mithep::Track>                *trkArr        = new mithep::Array<mithep::Track>();
276 +  mithep::Array<mithep::MCParticle>           *mcArr         = new mithep::Array<mithep::MCParticle>();
277    mithep::TriggerMask                         *trigMask      = new mithep::TriggerMask();
278    mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable();
279    vector<string>                              *hltTableStrings  = new vector<string>();
# Line 284 | Line 286 | int main(int argc, char** argv)
286    TString fPileupInfoName(Names::gkPileupInfoBrn);
287    TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn);
288    TString fTrackName(Names::gkTrackBrn);
289 +  TString fMCParticleName(Names::gkMCPartBrn);
290    TString fTriggerMaskName(Names::gkHltBitBrn);
291    TString fTriggerTableName(Names::gkHltTableBrn);
292    
# Line 292 | Line 295 | int main(int argc, char** argv)
295    chain->SetBranchAddress(fMuonName,        &muonArr);
296    chain->SetBranchAddress(fPrimVtxName,     &vtxArr);
297    chain->SetBranchAddress(fPFCandidateName, &pfArr);
298 <  if( ctrl.mc ) chain->SetBranchAddress(fPileupInfoName,  &puArr);
298 >  if( ctrl.mc ) {
299 >    chain->SetBranchAddress(fPileupInfoName,  &puArr);
300 >    chain->SetBranchAddress(fMCParticleName,  &mcArr);
301 >  }
302    chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr);
303    chain->SetBranchAddress(fTrackName, &trkArr);
304    chain->SetBranchAddress(fTriggerMaskName, &trigMask);
# Line 325 | Line 331 | int main(int argc, char** argv)
331      {
332        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 &&
# Line 340 | Line 365 | int main(int argc, char** argv)
365        */
366  
367        if(!(ientry%1000)) cerr << "entry: " << ientry << endl;
343      setPV( ctrl, vtxArr, vtx);
368        //if (!(setPV( ctrl, vtxArr, vtx)) ) continue;
369  
370        float rho = evtrhoMap[info->EvtNum()];
# Line 360 | Line 384 | int main(int argc, char** argv)
384          //
385          // xsec & PU weights
386          //
387 <        weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
387 >        weights.w = 1;//getWeight(xstab,entrymap,chain)/ctrl.totalMC;
388 >        cout << "xsec weight: " << weights.w << endl;
389          int npu = -1;
390          for(int i=0;i<puArr->GetEntries();i++) {
391            if(puArr->At(i)->GetBunchCrossing() == 0)
# Line 424 | Line 449 | int main(int argc, char** argv)
449        passingLeptons.clear();
450        EventData ret4l =
451  
452 <        /*
452 >
453 >        // reference
454          apply_HZZ4L_reference2_selection(ctrl, info,
455 <                                         vtx,
455 >                                         vtxArr,
456                                           pfArr,
457 <                                         //rho,
457 > #ifdef HACKED_RHOS
458 >                                         rho,
459 > #else
460                                           puDArr,
461 + #endif
462                                           electronArr,
463                                           &electronReferencePreSelection,
464 <                                         &electronReferenceIDMVASelection,
464 >                                         &electronReferenceIDMVASelectionV1,
465                                           &electronReferenceIsoSelection,
466                                           muonArr,
467                                           &muonReferencePreSelection,
468                                           &muonIDPFSelection,
469                                           &muonReferenceIsoSelection);
470 <        */
470 >
471 >      /*
472 >        // evolved
473          apply_HZZ4L_reference2_selection(ctrl, info,
474                                           vtx,
475                                           pfArr,
# Line 446 | Line 477 | int main(int argc, char** argv)
477                                           puDArr,
478                                           electronArr,
479                                           &electronReferencePreSelection,
480 +                                         //&electronPreSelection,
481                                           &electronReferenceIDMVASelection,
482                                           &electronIsoMVASelection,
483                                           muonArr,
484                                           &muonReferencePreSelection,
485 +                                         //&muonPreSelection,
486                                           &muonIDPFSelection,
487                                           &muonIsoMVASelection);
488 <
456 <
457 <
488 >      */
489  
490        if( ctrl.debug ) cout << endl;
491  
# Line 551 | Line 582 | int main(int argc, char** argv)
582  
583   }
584  
554 //----------------------------------------------------------------------------
555 //
556 // Get primary vertices
557 // Assumes primary vertices are ordered by sum-pT^2 (as should be in CMSSW)
558 // NOTE: if no PV is found from fitting tracks, the beamspot is used
559 //
560 //----------------------------------------------------------------------------
561 bool setPV(ControlFlags ctrl,
562           const mithep::Array<mithep::Vertex> * vtxArr,
563           mithep::Vertex & vtx)
564 //----------------------------------------------------------------------------
565 {
566  const Vertex *bestPV = 0;
567  float best_sumpt=-1;
568
569  // good PV requirements
570  const UInt_t   fMinNTracksFit = 0;
571  const Double_t fMinNdof       = 4;
572  const Double_t fMaxAbsZ       = 24;
573  const Double_t fMaxRho        = 2;
574  
575  for(int i=0; i<vtxArr->GetEntries(); ++i) {
576    const Vertex *pv = (Vertex*)(vtxArr->At(i));
577    if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl;
578    
579    // Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used
580    if(!pv->IsValid())                                continue;
581    if(pv->NTracksFit()       < fMinNTracksFit)       continue;
582    if(pv->Ndof()                 < fMinNdof)         continue;
583    if(fabs(pv->Z()) > fMaxAbsZ)                      continue;
584    if(pv->Position().Rho()   > fMaxRho)              continue;    
585    
586    // take the first ...
587    bestPV = pv;
588    break;
589
590    // this never reached ...    
591    float tmp_sumpt=0;
592    for( int t=0; t<pv->NTracks(); t++ )
593      tmp_sumpt += pv->Trk(t)->Pt();
594    
595    if( tmp_sumpt > best_sumpt  ) {
596      bestPV = pv;
597      best_sumpt = tmp_sumpt;
598      if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl;
599    }
600  }
601  // sync
602  if(!bestPV) bestPV = vtxArr->At(0);
603  //if(!bestPV) return false;
604  vtx.SetPosition(bestPV->X(),bestPV->Y(),bestPV->Z());
605  vtx.SetErrors(bestPV->XErr(),bestPV->YErr(),bestPV->ZErr());
606  return true;
607 };
608
585  
586  
587   //----------------------------------------------------------------------------
# Line 698 | Line 674 | void initEvtRhoMap( map<unsigned, float>
674    cout << "initialzing EvtRhoMap ";
675    //FILE * f = fopen("evtrho.dat", "r");
676    //  FILE * f = fopen("allrho.cali.uniq.dat", "r");
677 <  FILE * f = fopen("allrhoAA.cali.uniq.dat", "r");
677 >  FILE * f = fopen("/data/blue/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r");
678    int lcount=0;
679    while( fscanf( f, "%u:%f", &evt, &rho ) ) {
680      if( feof(f) ) break;
# Line 712 | Line 688 | void initEvtRhoMap( map<unsigned, float>
688   //----------------------------------------------------------------------------
689   unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates,
690                       vector<bool> &pfNoPileUpflag,
691 <                     mithep::Array<Vertex>      * vtxArr )
691 >                     const mithep::VertexCol      * vtxArr )
692   //----------------------------------------------------------------------------
693   {
694    for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines