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.43 by khahn, Mon Jun 18 21:02:55 2012 UTC vs.
Revision 1.44 by dkralph, Tue Jun 19 08:35:51 2012 UTC

# Line 44 | Line 44 | using namespace std;
44   #include "TriggerObjectRel.h"
45   #include "Names.h"
46   #include "BaseMod.h"
47 + #include "TriggerObjectsTable.h"
48  
49   //
50   // our headers
# Line 98 | Line 99 | vector<bool>   PFnoPUflag;;
99   void initPUWeights();
100   double getPUWeight(unsigned npu);
101   void initRunLumiRangeMap();
101 void setHLTObjectRelations( mithep::Array<mithep::TriggerObject>        *hltObjArr,
102                            mithep::Array<mithep::TriggerObjectRel>     *hltRelsArr,
103                            vector<string> * fHLTTab,
104                            vector<string> * fHLTLab );
102   //----------------------------------------------------------------------------
103  
104  
# Line 172 | Line 169 | int main(int argc, char** argv)
169    TChain * hltchain = new TChain("HLT");
170  
171    string fname;
172 +  unsigned total_unskimmed=0;
173    if( !ctrl.inputfiles.empty() ) {
174      ifstream f(ctrl.inputfiles.c_str());
175      while (f >> fname) {
# Line 179 | Line 177 | int main(int argc, char** argv)
177        cout << "adding inputfile : " << fname.c_str() << endl;
178        entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str());
179        cout << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl;
180 +      total_unskimmed += entrymap[string(fname.c_str())];
181        chain->AddFile(fname.c_str());
182        hltchain->AddFile(fname.c_str());
183      }
184    } else {
185      cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl;
186 <    unsigned tmpent = unskimmedEntries(ctrl.inputfile.c_str());
187 <    cout << "tmpent: " << tmpent << endl;
188 <    entrymap[string(ctrl.inputfile.c_str())] = unskimmedEntries(ctrl.inputfile.c_str());
189 <    cout << "unskimmed entries: " << entrymap[string(ctrl.inputfile.c_str())] << endl;
186 >    unsigned unsk_ents = unskimmedEntries(ctrl.inputfile.c_str());
187 >    entrymap[string(ctrl.inputfile.c_str())] = unsk_ents;
188 >    cout << "unskimmed entries: " << unsk_ents << endl;
189 >    total_unskimmed += unsk_ents;
190      chain->AddFile(ctrl.inputfile.c_str());
191      hltchain->AddFile(ctrl.inputfile.c_str());
192    }
193 +  // // write the total number of unskimmed events that went into making this output file to a text file
194 +  // writeEntries(ctrl,total_unskimmed);
195  
196    const char * ofname;
197    if( strcmp( ctrl.outputfile.c_str(), "") ) {
# Line 204 | Line 205 | int main(int argc, char** argv)
205    SimpleTable xstab(xspath.c_str());
206  
207  
208 +
209    //
210    // Setup
211    //--------------------------------------------------------------------------------------------------------------
# Line 248 | Line 250 | int main(int argc, char** argv)
250    initElectronIDMVAV1();
251    initTrigger();
252  
251  
253    //
254    // Setup tree I/O
255    //--------------------------------------------------------------------------------------------------------------
# Line 256 | Line 257 | int main(int argc, char** argv)
257    TTree *eventTree=0;  
258    string currentFile("");
259  
260 +  UInt_t fNMaxTriggers = 1024;
261    mithep::EventHeader *info    = new mithep::EventHeader();
262    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
263    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
# Line 267 | Line 269 | int main(int argc, char** argv)
269    mithep::Array<mithep::MCParticle>           *mcArr         = new mithep::Array<mithep::MCParticle>();
270    mithep::MCEventInfo                         *mcEvtInfo     = new mithep::MCEventInfo();
271    mithep::TriggerMask                         *trigMask      = new mithep::TriggerMask();
272 <  mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable();
272 >  mithep::TriggerTable                        *hltTable      = new mithep::TriggerTable(fNMaxTriggers);
273    vector<string>                              *hltTableStrings  = new vector<string>();
274    vector<string>                              *hltLabelStrings  = new vector<string>();
275    mithep::Array<mithep::TriggerObject>        *hltObjArr     = new mithep::Array<mithep::TriggerObject>();
276    mithep::Array<mithep::TriggerObjectRel>     *hltRelsArr    = new mithep::Array<mithep::TriggerObjectRel>();
277    std::vector<std::string>                    *hltTab        = new vector<string>();
278 <  std::vector<std::string>                    *hltLab        = new vector<string>();
278 >  std::vector<std::string>                    *hltLab        = new vector<string>();
279 >  TriggerObjectsTable                         *fTrigObjs     = new TriggerObjectsTable(hltTable,fNMaxTriggers);
280  
281  
282    TString fElectronName(Names::gkElectronBrn);
# Line 299 | Line 302 | int main(int argc, char** argv)
302   //   TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data()));
303  
304  
305 <
305 >  
306    chain->SetBranchAddress(fInfoName,        &info);
307    chain->SetBranchAddress(fElectronName,    &electronArr);
308    chain->SetBranchAddress(fMuonName,        &muonArr);
# Line 347 | Line 350 | int main(int argc, char** argv)
350      {
351        chain->GetEntry(ientry);
352        if(!(ientry%1000)) cerr << "entry: " << ientry << endl;
353 <      
353 >
354        if( ctrl.debug ) {
355          cout << "-----------------------------------------------------------------" << endl;
356          cout << "-----------------------------------------------------------------" << endl;
# Line 425 | Line 428 | int main(int argc, char** argv)
428            passes_HLT_MC = false;
429          }
430  
431 <        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings );
429 <        for( int i=0; i<hltObjArr->GetEntries(); i++ ) {
430 <          const mithep::TriggerObject *to = (*hltObjArr)[i];
431 <          to->Print();
432 <        }
433 <
431 >        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
432  
433        } else {
434          //
# Line 443 | Line 441 | int main(int argc, char** argv)
441              continue;
442            }
443          }
444 <
444 >        
445          //
446          // trigger
447          //
# Line 456 | Line 454 | int main(int argc, char** argv)
454            fillTriggerNames(hltTable, hltTableStrings );
455          }
456  
457 <        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings );
458 <        for( int i=0; i<hltObjArr->GetEntries(); i++ ) {
461 <          const mithep::TriggerObject *to = (*hltObjArr)[i];
462 <          to->Print();
463 <        }
457 >        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
458 >        printTriggerObjs( hltTable, fTrigObjs );
459  
460          if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
461          /*
# Line 521 | Line 516 | int main(int argc, char** argv)
516          fillEventInfo(info,evtinfo);
517          if( ctrl.mc) {
518            if( std::string(ctrl.efftype) != std::string("WTF?")) {
519 <          setEffiencyWeights(ret4l, weights);
519 >            setEffiencyWeights(ret4l, weights);
520            } else {
521              weights.won = weights.woff = 1.;
522            }
523 <           if(ctrl.debug)
524 <             cout << "w: " << weights.w << "\t"
525 <                  << "won: " << weights.won << "\t"
526 <                  << "woff: " << weights.woff << endl;
523 >          if(ctrl.debug)
524 >            cout << "w: " << weights.w << "\t"
525 >                 << "won: " << weights.won << "\t"
526 >                 << "woff: " << weights.woff << endl;
527          }
528          
529  
# Line 627 | Line 622 | double getPUWeight(unsigned npu)
622   {
623    return hpu->GetBinContent(hpu->FindBin(npu));
624   }
630
631 //----------------------------------------------------------------------------
632 void setHLTObjectRelations( mithep::Array<mithep::TriggerObject>    *hltObjArr,
633                            mithep::Array<mithep::TriggerObjectRel> *hltRelsArr,
634                            vector<string> * fHLTTab,
635                            vector<string> * fHLTLab )
636 //----------------------------------------------------------------------------
637 {
638
639  const int n = hltRelsArr->GetEntries();
640  for (int i=0; i<n; ++i) {
641    const TriggerObjectRel *rel = hltRelsArr->At(i);
642    if (!rel) continue;
643
644 //     const TriggerObjectBase *ob = hltObjArr->At(rel->ObjInd());
645 //     if (!ob) continue;
646
647    hltObjArr->At(rel->ObjInd())->SetTrigName(fHLTTab->at(rel->TrgId()).c_str());
648    hltObjArr->At(rel->ObjInd())->SetModuleName(fHLTLab->at(rel->ModInd()).c_str());
649    hltObjArr->At(rel->ObjInd())->SetFilterName(fHLTLab->at(rel->FilterInd()).c_str());
650    if (hltObjArr->At(rel->ObjInd())->TagInd()>=0)
651      hltObjArr->At(rel->ObjInd())->SetTagName(fHLTLab->at(hltObjArr->At(rel->ObjInd())->TagInd()).c_str());
652    else
653      hltObjArr->At(rel->ObjInd())->SetTagName("Unknown");
654  }
655 };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines