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.49 by khahn, Fri Jun 22 03:10:32 2012 UTC vs.
Revision 1.53 by dkralph, Tue Jul 24 11:54:17 2012 UTC

# Line 91 | Line 91 | vector<vector<unsigned> > zcutvec;
91   vector<vector<unsigned> > zzcutvec;
92   map<unsigned,float>       evtrhoMap;
93   vector<string> cutstrs;
94 < bool passes_HLT_MC;
94 > bool passes_HLT_MC,passes_HLT;
95   vector<bool>   PFnoPUflag;;
96  
97   //
# Line 166 | Line 166 | int main(int argc, char** argv)
166    //--------------------------------------------------------------------------------------------------------------
167    TChain * chain = new TChain("Events");
168    TChain * hltchain = new TChain("HLT");
169 +  TChain * runchain = new TChain(Names::gkRunTreeName);
170  
171    string fname;
172    unsigned total_unskimmed=0;
# Line 179 | Line 180 | int main(int argc, char** argv)
180        total_unskimmed += entrymap[string(fname.c_str())];
181        chain->AddFile(fname.c_str());
182        hltchain->AddFile(fname.c_str());
183 +      runchain->AddFile(fname.c_str());
184      }
185    } else {
186      cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl;
# Line 188 | Line 190 | int main(int argc, char** argv)
190      total_unskimmed += unsk_ents;
191      chain->AddFile(ctrl.inputfile.c_str());
192      hltchain->AddFile(ctrl.inputfile.c_str());
193 +    runchain->AddFile(ctrl.inputfile.c_str());
194    }
195    // // write the total number of unskimmed events that went into making this output file to a text file
196 <  // writeEntries(ctrl,total_unskimmed);
196 >  writeEntries(ctrl,total_unskimmed);
197  
198    const char * ofname;
199    if( strcmp( ctrl.outputfile.c_str(), "") ) {
# Line 221 | Line 224 | int main(int argc, char** argv)
224  
225    
226    FOTuple foTree( nt.getFile(), (const char*)"FOtree");
227 +  foTree.makeInfoBranch(evtinfo);
228    foTree.makeFailedLeptonBranch(failingLeptons);
229    foTree.makePassedLeptonBranch(passingLeptons);
230  
# Line 242 | Line 246 | int main(int argc, char** argv)
246      }
247  
248    } else {
249 <    initRunLumiRangeMap();
249 >    initRunLumiRangeMap(ctrl);
250    }
251  
252    //  initMuonIDMVA();
253    initElectronIDMVAV1();
254    initTrigger();
255 +  TrigInfo ti;
256 +  initAnalysisTriggers(ti);
257  
258    //
259    // Setup tree I/O
# Line 257 | Line 263 | int main(int argc, char** argv)
263    string currentFile("");
264  
265    UInt_t fNMaxTriggers = 1024;
266 <  mithep::EventHeader *info    = new mithep::EventHeader();
266 >  mithep::EventHeader                         *info          = new mithep::EventHeader();
267    mithep::Array<mithep::PFMet>                *metArr        = new mithep::Array<mithep::PFMet>();
268    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
269    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
# Line 278 | Line 284 | int main(int argc, char** argv)
284    std::vector<std::string>                    *hltLab        = new vector<string>();
285    TriggerObjectsTable                         *fTrigObjs     = new TriggerObjectsTable(hltTable,fNMaxTriggers);
286  
287 +  RunInfo                                     *runInfo       = new RunInfo();
288  
289    TString fElectronName(Names::gkElectronBrn);
290    TString fMuonName(Names::gkMuonBrn);
# Line 327 | Line 334 | int main(int argc, char** argv)
334    hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
335    hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
336  
337 +  runchain->SetBranchAddress(Names::gkRunInfoBrn, &runInfo);
338 +
339    mithep::Vertex              vtx;          // best primary vertex in the event
340  
341    //  ginfo = NULL;
# Line 347 | Line 356 | int main(int argc, char** argv)
356    //
357    // Loop !!!!!!!!!
358    //--------------------------------------------------------------------------------------------------------------
359 +  int lastHltEntry=-2;
360    for(UInt_t ientry=0; ientry<imax; ientry++)
361      {
362        chain->GetEntry(ientry);
# Line 359 | Line 369 | int main(int argc, char** argv)
369               << "\tEvt: " << info->EvtNum()
370               << "\tLumi: " << info->LumiSec()
371               << endl;
372 +        cerr << "Run: " << info->RunNum()
373 +             << "\tEvt: " << info->EvtNum()
374 +             << "\tLumi: " << info->LumiSec()
375 +             << endl;
376          cout << "-----------------------------------------------------------------" << endl;
377        }
378  
379 <
379 >      runchain->GetEvent(info->RunEntry());
380 >      hltchain->GetEntry(runInfo->HltEntry());
381 >      hltTable->Clear();
382 >      fillTriggerNames(hltTable, hltTableStrings );
383 >      if(ctrl.debug && (lastHltEntry != runInfo->HltEntry())) hltTable->Print();
384 >      lastHltEntry = runInfo->HltEntry();
385 >      fillTriggerBits( hltTable, trigMask, triggerBits );
386 >      setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
387 >      // printTriggerObjs( hltTable, fTrigObjs);
388 >      
389        string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
390        if(ctrl.debug) cout << "era is " << ctrl.era << endl;
391        if( ctrl.era == 0  ) {
# Line 379 | Line 402 | int main(int argc, char** argv)
402        assert(pfnopu_size == pfArr->GetEntries());
403  
404        //
405 +      // trigger
406 +      //
407 +      if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
408 +        currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
409 +      }
410 +      if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
411 +
412 +      //
413        // data/MC
414        //
415        if(ctrl.mc) {
# Line 410 | Line 441 | int main(int argc, char** argv)
441            }
442          }
443  
444 <        //
414 <        // trigger
415 <        //
416 <        if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
417 <          currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
418 <          hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
419 <          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
420 <          hltchain->GetEntry(0);
421 <          hltTable->Clear();
422 <          fillTriggerNames(hltTable, hltTableStrings );
423 <        }
424 <        if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
425 <        fillTriggerBits( hltTable, trigMask, triggerBits );
444 >        // trigger
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  
431        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
432
450        } else {
451          //
452          // JSON
# Line 442 | Line 459 | int main(int argc, char** argv)
459            }
460          }
461          
445        //
462          // trigger
463 <        //
464 <        if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) {
465 <          currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile());
450 <          hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
451 <          hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings);
452 <          hltchain->GetEntry(0);
453 <          hltTable->Clear();
454 <          fillTriggerNames(hltTable, hltTableStrings );
463 >        passes_HLT = true;
464 >        if( !passHLT(ctrl, triggerBits,ti,info->RunNum()) ) {
465 >          passes_HLT = false;
466          }
467  
457        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
458
459        if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
460        /*
461        fillTriggerBits( hltTable, trigMask, triggerBits );
462        if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) {
463          if( ctrl.debug ) cout << "\tfails trigger ... " << endl;
464          continue;
465        }
466        */
468        }
469  
470        //
# Line 501 | Line 502 | int main(int argc, char** argv)
502          if( abs(ret4l.Z2leptons[0].type) == 13  ) Z2type = 13;
503        }  
504        
504 #ifdef SYNC
505      if(ctrl.debug)
506        cout  << "bits: " << ret4l.status.selectionBits  << "\t"
507              << "Z1: " << Z1type << "\t"
508              << "Z2: " << Z2type << endl << endl;
509 #endif      
510      
505        if( ret4l.status.pass() ) {
506          fillAngles(ret4l,angles);
507          fillKinematics(ret4l,kinematics);
# Line 515 | Line 509 | int main(int argc, char** argv)
509          TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
510          fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0);
511          if( ctrl.mc) {
512 <          //      if( std::string(ctrl.efftype) != std::string("WTF?")) {
519 <            setEffiencyWeights(ctrl.era, ret4l, weights);
520 <            //    } else {
521 <            //      weights.won = weights.woff = 1.;
522 <            //    }
512 >          setEffiencyWeights(ctrl.era, ret4l, triggerBits, hltTable, hltObjArr, fTrigObjs, weights);
513            if(ctrl.debug)
514              cout << "w: " << weights.w << "\t"
515                   << "npuw: " << weights.npuw << "\t"
# Line 555 | Line 545 | int main(int argc, char** argv)
545                   << endl;
546            }
547          }
548 +        TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
549 +        fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0);
550          foTree.Fill();
551        } else {
552          if(ctrl.debug)
553            cout << "failing with some other code : " << ret4l.status.selectionBits << endl;
554        }
555 <    }  
555 >      if(ctrl.debug)
556 >        cout << "passes HLT: " << passes_HLT << endl;
557 >    }
558  
559    
560    foTree.getFile()->cd();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines