ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/HLTAnalyzer.cc
Revision: 1.2
Committed: Wed Oct 1 16:07:11 2008 UTC (16 years, 7 months ago) by lethuill
Content type: text/plain
Branch: MAIN
CVS Tags: cmssw_1_6_12
Changes since 1.1: +1 -0 lines
Log Message:
setGlobalHLT in rootEvent

File Contents

# User Rev Content
1 mlethuil 1.1 #include "UserCode/Morgan/interface/HLTAnalyzer.h"
2    
3     using namespace std;
4    
5     void HLTAnalyzer::init(const edm::Event& iEvent, TRootEvent* rootEvent)
6     {
7     edm::Handle<edm::TriggerResults> trigResults;
8     try {iEvent.getByLabel(triggerResultsTag_,trigResults);} catch (...) {;}
9     triggerNames_.init(*trigResults);
10     hltNames_=triggerNames_.triggerNames();
11     const unsigned int n(hltNames_.size());
12     hltWasRun_.resize(n);
13     hltAccept_.resize(n);
14     hltErrors_.resize(n);
15     for (unsigned int i=0; i!=n; ++i)
16     {
17     hltWasRun_[i]=0;
18     hltAccept_[i]=0;
19     hltErrors_[i]=0;
20     }
21    
22     }
23    
24     void HLTAnalyzer::process(const edm::Event& iEvent, TRootEvent* rootEvent)
25     {
26     nEvents_++;
27     edm::Handle<edm::TriggerResults> trigResults;
28     try {iEvent.getByLabel(triggerResultsTag_,trigResults);} catch (...) {;}
29     if (trigResults.isValid()) {
30     if (trigResults->wasrun()) nWasRun_++;
31     const bool accept(trigResults->accept());
32     if(verbosity_>0) cout << "HLT decision: " << accept << endl;
33 lethuill 1.2 rootEvent->setGlobalHLT(accept);
34 mlethuil 1.1 if (accept) ++nAccept_;
35     if (trigResults->error() ) nErrors_++;
36     } else {
37     cout << "HLT results not found!" << endl;;
38     nErrors_++;
39     return;
40     }
41    
42     // decision for each HLT algorithm
43     const unsigned int n(hltNames_.size());
44     std::vector<Bool_t> hltDecision(n, false);
45     for (unsigned int i=0; i!=n; ++i)
46     {
47     if (trigResults->wasrun(i)) hltWasRun_[i]++;
48     if (trigResults->error(i) ) hltErrors_[i]++;
49     if (trigResults->accept(i))
50     {
51     hltAccept_[i]++;
52     hltDecision[i]=true;
53     }
54     }
55    
56     rootEvent->setTrigHLT(hltDecision);
57    
58     return;
59     }
60    
61    
62     void HLTAnalyzer::printStats()
63     {
64     // final printout of accumulated statistics
65     const unsigned int n(hltNames_.size());
66    
67     cout << dec << endl;
68     cout << "HLT-Report " << "---------- Event Summary ------------\n";
69     cout << "HLT-Report"
70     << " Events total = " << nEvents_
71     << " wasrun = " << nWasRun_
72     << " passed = " << nAccept_
73     << " errors = " << nErrors_
74     << "\n";
75    
76     cout << endl;
77     cout << "HLT-Report " << "---------- HLTrig Summary ------------\n";
78     cout << "HLT-Report "
79     << right << setw(10) << "HLT Bit#" << " "
80     << right << setw(10) << "WasRun" << " "
81     << right << setw(10) << "Passed" << " "
82     << right << setw(10) << "Errors" << " "
83     << "Name" << "\n";
84    
85     for (unsigned int i=0; i!=n; ++i) {
86     cout << "HLT-Report "
87     << right << setw(10) << i << " "
88     << right << setw(10) << hltWasRun_[i] << " "
89     << right << setw(10) << hltAccept_[i] << " "
90     << right << setw(10) << hltErrors_[i] << " "
91     << hltNames_[i] << "\n";
92     }
93    
94     cout << endl;
95     cout << "HLT-Report end!" << endl;
96     cout << endl;
97    
98     return;
99     }
100    
101     void HLTAnalyzer::copySummary(TRootRun* runInfos)
102     {
103     runInfos->setNHLTEvents(nEvents_) ;
104     runInfos->setNHLTWasRun(nWasRun_) ;
105     runInfos->setNHLTAccept(nAccept_) ;
106     runInfos->setNHLTErrors(nErrors_) ;
107    
108     runInfos->setHLTWasRun(hltWasRun_) ;
109     runInfos->setHLTAccept(hltAccept_) ;
110     runInfos->setHLTErrors(hltErrors_) ;
111     runInfos->setHLTNames(hltNames_) ;
112     }