ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/AnaMenu.cc
Revision: 1.7
Committed: Wed Apr 24 19:54:35 2013 UTC (12 years ago) by konec
Content type: text/plain
Branch: MAIN
CVS Tags: Artur_11_07_2013_B, Artur_11_07_2013_A, Artur_11_07_2013, Artur_28_06_2013, HEAD
Changes since 1.6: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 konec 1.1 #include "UserCode/L1RpcTriggerAnalysis/interface/AnaMenu.h"
2     #include "TObjArray.h"
3     #include "TH1D.h"
4     #include "TH2D.h"
5     #include "TGraphErrors.h"
6     #include "UserCode/L1RpcTriggerAnalysis/interface/MuonObj.h"
7     #include "UserCode/L1RpcTriggerAnalysis/interface/EventObj.h"
8 konec 1.2 #include "UserCode/L1RpcTriggerAnalysis/interface/Utilities.h"
9     #include "UserCode/L1RpcTriggerAnalysis/interface/TriggerMenuResultObj.h"
10 konec 1.1 #include <sstream>
11     #include <iostream>
12 konec 1.2 #include <cmath>
13 konec 1.1
14     namespace {
15 konec 1.2 TH1D *hMuonPt_MEN, *hMuonEta_MEN, *hMuonPhi_MEN;
16 konec 1.1 }
17    
18    
19 konec 1.4 void AnaMenu::updateMenu(const std::vector<std::string> & menuL1, const std::vector<std::string> & menuHLT)
20     {
21     if (menuL1.size() != 0) theMenuL1 = menuL1;
22     if (menuHLT.size() != 0) theMenuHLT = menuHLT;
23     }
24    
25 konec 1.1 bool AnaMenu::filter( const EventObj* ev, const MuonObj* muon,
26 konec 1.2 const TriggerMenuResultObj *bitsL1,
27     const TriggerMenuResultObj *bitsHLT)
28    
29 konec 1.1 {
30 konec 1.2 const std::vector<unsigned int> & algosL1 = bitsL1->firedAlgos;
31     const std::vector<unsigned int> & algosHLT = bitsHLT->firedAlgos;
32    
33 konec 1.4 typedef std::vector<unsigned int>::const_iterator CIT;
34 konec 1.2
35 konec 1.1
36 konec 1.4 bool okL1 = false;
37 konec 1.6
38 konec 1.7 // debug = true;
39 konec 1.6 if (debug) std::cout <<"--------------------------------------------------------------"<<std::endl;
40     if (debug) std::cout << "================== L1 names: "<< std::endl;
41 konec 1.5 std::vector<std::string> acceptL1_Names = theConfig.exists("acceptL1_Names") ? theConfig.getParameter<std::vector<std::string> >("acceptL1_Names") : std::vector<std::string>();
42 konec 1.1 for (CIT it=algosL1.begin(); it != algosL1.end(); ++it) {
43 konec 1.6 bool aokL1 = false;
44 konec 1.4 std::string nameAlgo = theMenuL1[*it];
45 konec 1.1 if (theAlgosL1.find(nameAlgo) == theAlgosL1.end()) theAlgosL1[nameAlgo]=0;
46     bool isMu = ( nameAlgo.find("Mu") != std::string::npos);
47 konec 1.6 if (theConfig.getParameter<bool>("acceptL1_OtherThanMu") && !isMu ) aokL1 = true;
48     if (theConfig.getParameter<bool>("acceptL1_Mu") && isMu) aokL1 = true;
49     for ( std::vector<std::string>::const_iterator is=acceptL1_Names.begin(); is != acceptL1_Names.end(); ++is) if (nameAlgo==(*is)) aokL1 = true;
50     if (debug) {std::cout <<nameAlgo; if (aokL1) std::cout <<" <--"; std::cout << std::endl; }
51     if (aokL1) okL1=true;
52 konec 1.1 }
53    
54 konec 1.4 bool okHLT = false;
55 konec 1.6 if (debug) std::cout << "================== L1 names: "<< std::endl;
56 konec 1.1 for (CIT it=algosHLT.begin(); it != algosHLT.end(); ++it) {
57 konec 1.6 bool aokHLT = false;
58 konec 1.4 std::string nameAlgo = theMenuHLT[*it];
59 konec 1.1 if (theAlgosHLT.find(nameAlgo) == theAlgosHLT.end()) theAlgosHLT[nameAlgo]=0;
60 konec 1.5 bool isMu = ( ( (nameAlgo.find("Mu") != std::string::npos )
61     && (nameAlgo.find("Multi") == std::string::npos) )
62     || ( nameAlgo.find("muon") != std::string::npos ) );
63     if ( theConfig.getParameter<bool>("acceptHLT_OtherThanMuPhysicsAlCa")
64     && !isMu
65     && (nameAlgo.find("Physics") == std::string::npos)
66 konec 1.6 && (nameAlgo.find("AlCa") == std::string::npos) ) aokHLT = true;
67     if (theConfig.getParameter<bool>("acceptHLT_Mu") && isMu) aokHLT = true;
68     if (theConfig.getParameter<bool>("acceptHLT_L1") && (nameAlgo.find("HLT_L1") != std::string::npos) ) aokHLT = true;
69     if (theConfig.getParameter<bool>("acceptHLT_Physics") && (nameAlgo.find("Physics") != std::string::npos) ) aokHLT = true;
70     if (theConfig.getParameter<bool>("acceptHLT_ZeroBias") && (nameAlgo.find("ZeroBias") != std::string::npos) ) aokHLT = true;
71     if (debug) {std::cout <<nameAlgo; if (aokHLT) std::cout <<" <--"; std::cout << std::endl; }
72     if (aokHLT) okHLT=true;
73 konec 1.1 }
74    
75 konec 1.4 if (okL1 && okHLT) {
76     for (CIT it=algosL1.begin(); it != algosL1.end(); ++it) theAlgosL1[ theMenuL1[*it] ]++;
77     for (CIT it=algosHLT.begin(); it != algosHLT.end(); ++it) theAlgosHLT[ theMenuHLT[*it] ]++;
78 konec 1.2 if (hMuonPt_MEN) hMuonPt_MEN->Fill(muon->pt());
79     if (hMuonEta_MEN) hMuonEta_MEN->Fill(muon->eta());
80     if (hMuonPhi_MEN) hMuonPhi_MEN->Fill(muon->phi());
81 konec 1.4 return true;
82     } else return false;
83 konec 1.1
84     }
85    
86     void AnaMenu::resume(TObjArray& histos)
87     {
88     unsigned int sizeL1 = theAlgosL1.size();
89     unsigned int sizeHLT = theAlgosHLT.size();
90     TH1D *hMenuAlgosL1 = new TH1D( "hMenuAlgosL1", "hMenuAlgosL1", sizeL1, 1., 1.+sizeL1); histos.Add(hMenuAlgosL1);
91     TH1D *hMenuAlgosHLT = new TH1D("hMenuAlgosHLT","hMenuAlgosHLT",sizeHLT, 1., 1.+sizeHLT); histos.Add(hMenuAlgosHLT);
92     unsigned int ibin = 0;
93     typedef std::map< std::string, unsigned int>::const_iterator CIM;
94     for (CIM it=theAlgosL1.begin(); it != theAlgosL1.end(); ++it) {
95     ibin++;
96     hMenuAlgosL1->GetXaxis()->SetBinLabel(ibin, (*it).first.c_str());
97     hMenuAlgosL1->SetBinContent(ibin, (*it).second);
98 konec 1.2 // std::cout <<" BIN "<<ibin<<" LABEL: "<<(*it).first.c_str()<<" ENTRIES:"<<(*it).second<<std::endl;
99 konec 1.1 }
100     ibin = 0;
101     for (CIM it=theAlgosHLT.begin(); it != theAlgosHLT.end(); ++it) {
102     ibin++;
103     hMenuAlgosHLT->GetXaxis()->SetBinLabel(ibin, (*it).first.c_str());
104     hMenuAlgosHLT->SetBinContent(ibin, (*it).second);
105 konec 1.2 // std::cout <<" BIN "<<ibin<<" LABEL: "<<(*it).first.c_str()<<" ENTRIES:"<<(*it).second<<std::endl;
106 konec 1.1 }
107     }
108    
109    
110     void AnaMenu::init(TObjArray& histos)
111     {
112 konec 1.2 hMuonPt_MEN = new TH1D("hMuonPt_MEN","All global muons Pt;Glb.muon p_{T} [GeV];Muons / bin",L1PtScale::nPtBins,L1PtScale::ptBins); histos.Add(hMuonPt_MEN);
113     hMuonEta_MEN = new TH1D("hMuonEta_MEN","All global muons Eta;Glb.muon #eta;Muons / bin",96, -2.4, 2.4); histos.Add(hMuonEta_MEN);
114     hMuonPhi_MEN = new TH1D("hMuonPhi_MEN","All global muons Phi;Glb.muon #phi [rad];Muons / bin",90,-M_PI,M_PI); histos.Add(hMuonPhi_MEN);
115 konec 1.1 }