ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/src/L1ObjColl.cc
Revision: 1.5
Committed: Tue Nov 6 12:56:51 2012 UTC (12 years, 6 months ago) by konec
Content type: text/plain
Branch: MAIN
Changes since 1.4: +96 -6 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 konec 1.1 #include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjColl.h"
2 konec 1.2 #include <iostream>
3 konec 1.1
4     ClassImp(L1Obj)
5     ClassImp(L1ObjColl)
6    
7 konec 1.5
8     L1ObjColl L1ObjColl::selectByType( TYPE t) const
9     {
10     L1ObjColl result;
11     for (unsigned int i=0; i<theL1Obj.size(); i++) if (theL1Obj[i].type == t) result.push_back( theL1Obj[i], theL1Matching[i], theDeltaR[i]);
12     return result;
13     }
14    
15     L1ObjColl L1ObjColl::selectByPtMin( double ptMin) const
16     {
17     L1ObjColl result;
18     const double epsilon = 1.e-9;
19     for (unsigned int i=0; i<theL1Obj.size(); i++) if ( theL1Obj[i].pt > (ptMin-epsilon) ) result.push_back( theL1Obj[i], theL1Matching[i], theDeltaR[i]);
20     return result;
21     }
22    
23     L1ObjColl L1ObjColl::selectByEta( double etaMin, double etaMax) const
24     {
25     L1ObjColl result;
26     for (unsigned int i=0; i<theL1Obj.size(); i++) if ( etaMin < theL1Obj[i].eta && theL1Obj[i].eta <= etaMax) result.push_back( theL1Obj[i], theL1Matching[i], theDeltaR[i]);
27     return result;
28     }
29    
30     L1ObjColl L1ObjColl::selectByBx( int bxMin, int bxMax) const
31     {
32     L1ObjColl result;
33     for (unsigned int i=0; i<theL1Obj.size(); i++) if ( bxMin <= theL1Obj[i].bx && theL1Obj[i].bx <= bxMax) result.push_back( theL1Obj[i], theL1Matching[i], theDeltaR[i]);
34     return result;
35     }
36    
37     L1ObjColl L1ObjColl::selectByQuality( int qMin, int qMax) const
38     {
39     L1ObjColl result;
40     for (unsigned int i=0; i<theL1Obj.size(); i++) if ( qMin <= theL1Obj[i].q && theL1Obj[i].q <= qMax) result.push_back( theL1Obj[i], theL1Matching[i], theDeltaR[i]);
41     return result;
42     }
43    
44     L1ObjColl L1ObjColl::selectByMatched() const
45     {
46     L1ObjColl result;
47     for (unsigned int i=0; i<theL1Obj.size(); i++) if (theL1Matching[i]) result.push_back( theL1Obj[i], theL1Matching[i], theDeltaR[i]);
48     return result;
49     }
50    
51     L1ObjColl L1ObjColl::selectByDeltaR( double deltaRMax) const
52     {
53     L1ObjColl result;
54     for (unsigned int i=0; i<theL1Obj.size(); i++) if ( theDeltaR[i] <= deltaRMax) result.push_back( theL1Obj[i], theL1Matching[i], theDeltaR[i]);
55     return result;
56     }
57    
58     L1ObjColl L1ObjColl::operator+(const L1ObjColl &o) const
59     {
60     L1ObjColl result = *this;
61     for (unsigned int i=0; i<o.theL1Obj.size(); i++) result.push_back( o.theL1Obj[i], o.theL1Matching[i], o.theDeltaR[i]);
62     return result;
63     }
64    
65     void L1ObjColl::push_back(const L1Obj & obj, bool match, double deltaR)
66     {
67     theL1Obj.push_back(obj);
68     theL1Matching.push_back(match);
69     theDeltaR.push_back(deltaR);
70     }
71    
72    
73    
74    
75    
76 konec 1.3 std::vector<L1Obj> L1ObjColl::typeSelector(const std::vector<L1Obj> & col,
77     TYPE t1, TYPE t2, TYPE t3, TYPE t4)
78     {
79     std::vector<L1Obj> result;
80     for (std::vector<L1Obj>::const_iterator it= col.begin(); it != col.end(); ++it) {
81     if ( it->type == t1 || it->type == t2 || it->type == t3 ||it->type == t4 ) result.push_back(*it);
82     }
83     return result;
84     }
85 konec 1.2
86 konec 1.1 std::vector<L1Obj> L1ObjColl::getL1ObjsMatched(double ptMin) const
87     {
88     std::vector<L1Obj> result;
89     unsigned int nObj = theL1Obj.size();
90     unsigned int nCom = theL1Matching.size();
91    
92     for (unsigned int i=0; i<nObj && i<nCom; ++i)
93     if (theL1Matching[i] && theL1Obj[i].pt >= ptMin) result.push_back(theL1Obj[i]);
94    
95     return result;
96     }
97 konec 1.2
98     std::vector<L1Obj> L1ObjColl::getL1ObjsSelected(
99     bool requireMatched,
100     bool requireNonMatched,
101     double ptMin, double ptMax,
102     int bxMin, int bxMax,
103     double etaMin, double etaMax,
104     double phiMin, double phiMax,
105     int qMin, int qMax) const
106     {
107     std::vector<L1Obj> result;
108     unsigned int nMS = theL1Matching.size();
109     for (unsigned int i=0; i<theL1Obj.size(); ++i) {
110     bool isMatched = ( (i<nMS) && theL1Matching[i] );
111     if (requireMatched && !isMatched ) continue;
112     if (requireNonMatched && isMatched) continue;
113     if (theL1Obj[i].pt < ptMin) continue;
114     if (theL1Obj[i].pt > ptMax) continue;
115     if (theL1Obj[i].bx < bxMin) continue;
116     if (theL1Obj[i].bx > bxMax) continue;
117     if (theL1Obj[i].eta < etaMin) continue;
118     if (theL1Obj[i].eta > etaMax) continue;
119     if (theL1Obj[i].phi < phiMin) continue;
120     if (theL1Obj[i].phi > phiMax) continue;
121     if (theL1Obj[i].q < qMin) continue;
122     if (theL1Obj[i].q > qMax) continue;
123     result.push_back(theL1Obj[i]);
124     }
125     return result;
126     }
127    
128 konec 1.5
129     ostream & operator<< (ostream &out, const L1ObjColl &col)
130     {
131     for (unsigned int i=0; i< col.theL1Obj.size(); ++i) {
132     out <<"("<<i<<")"<<col.theL1Obj[i];
133     out <<" matched: "<< col.theL1Matching[i]<<" deltaR: "<< col.theDeltaR[i];
134     if (i != col.theL1Obj.size()-1) out <<std::endl;
135     }
136     return out;
137     }
138    
139     ostream & operator<< (ostream &out, const L1Obj &o)
140 konec 1.2 {
141 konec 1.5 out<<"L1Obj: ";
142     switch (o.type) {
143     case L1Obj::RPCb: { out <<"RPCb "; break; }
144     case L1Obj::RPCf: { out <<"RPCf "; break; }
145     case L1Obj::DT: { out <<"DT "; break; }
146     case L1Obj::CSC: { out <<"CSC "; break; }
147     case L1Obj::GMT: { out <<"GMT "; break; }
148     case L1Obj::RPCb_emu: { out <<"RPCb_emu"; break; }
149     case L1Obj::RPCf_emu: { out <<"RPCf_emu"; break; }
150     case L1Obj::GMT_emu: { out <<"GMT_emu "; break; }
151     case L1Obj::NONE : { out <<"NONE "; break; }
152     default: out <<"Unknown";
153     };
154     out <<" pt: "<<o.pt<<", eta: "<<o.eta<<", phi: "<<o.phi<<", q: "<<o.q<<", bx: "<<o.bx;
155     return out;
156 konec 1.2 }