ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/mschen/SusyAnalysis/code/muon.h
Revision: 1.1
Committed: Mon Mar 28 09:23:54 2011 UTC (14 years, 1 month ago) by mschen
Content type: text/plain
Branch: MAIN
CVS Tags: V2010_data_analysis_effModelInPaper, V2010_data_analysis, HEAD
Error occurred while calculating annotation data.
Log Message:
2010 same sign analysis codeing

File Contents

# Content
1 #ifndef Muon_h
2 #define Muon_h
3
4 #include <TLorentzVector.h>
5
6 #include "init.h"
7 #include "mcParticle.h"
8 #include "track.h"
9 #include <fstream>
10
11 using namespace std;
12
13 struct Segment{
14 float phi, eta, x, y, z;
15 uint32_t det;
16 Segment(){}
17 Segment(float a, float b, float c, float d, float e, uint32_t f):phi(a), eta(b), x(c), y(d), z(e), det(f){}
18 Segment(const Segment& seg):phi(seg.phi),eta(seg.eta),x(seg.x),y(seg.y), z(seg.z), det(seg.det){}
19 };
20
21 class Muon:public mcParticle {
22
23 private:
24 double ecalIso_, hcalIso_, trkIso_;
25 int type_, typeTrk_;
26 double calEm_, calHm_, compat_, d0_, Chi2N_;
27 int nHit_;
28 double outZ_, outR_;
29
30 double parentDR_;
31 int parentI_, parentI2_, parentClass, parentPDG;
32
33 bool globalMuonPromptTight_;
34 TLorentzVector staMom;
35 TLorentzVector trkMom;
36 int staCharge, trkCharge;
37 float staNdof, trkNdof;
38 bool isTrackValid, isStandAloneValid;
39
40 bool GlobalMuon_, TrackerMuon_, CaloMuon_, StandAloneMuon_, GlobalMuonPromptTight_, TM2DCompatibilityLoose_, TMOneStationLoose_;
41 bool TMLastStationOptimizedLowPtLoose_, TMLastStationOptimizedLowPtTight_;
42 bool TM2DCompatibilityTight_;
43 bool Good_;
44 bool TMLastStationAngTight_;
45 bool TMOneStationAngTight_;
46 bool TMOneStationAngLoose_;
47
48 double ndof_;
49 double trkChi2N, trkD0, trkNHit;
50
51 short numberOfValidMuonHits_;
52
53 float caloCompatibility_;
54 float segmentCompatibility_;
55 bool TrackerMuonArbitrated_;
56 bool AllArbitrated_;
57
58
59 int numberOfChambers_;
60 int numberOfMatches_;
61
62 Track track_;
63
64 float weight_;
65
66 // --- need FIXME put Arbitrated bits on the muon collection
67
68 vector<Segment> segments_;
69
70 float gen_pt, gen_eta, gen_phi;
71 int gen_q, gen_index;
72
73 double d0PV_;
74
75 public:
76 //Muon() {};
77 Muon(
78 int index,
79 int q,
80 TLorentzVector mom,
81 TLorentzVector vtx,
82
83 double ecalIso,
84 double hcalIso,
85 double trkIso,
86
87 int type,
88 int typeTrk,
89 double calEm,
90 double calHm,
91 double compat,
92
93 double d0,
94 double Chi2N,
95 int nHit,
96 double outZ,
97 double outR
98 )
99 :mcParticle(
100 index,
101 13,
102 q,
103 mom,
104 0,
105 vtx
106 ),
107 ecalIso_(ecalIso),
108 hcalIso_(hcalIso),
109 trkIso_(trkIso),
110
111 type_(type),
112 typeTrk_(typeTrk),
113 calEm_(calEm),
114 calHm_(calHm),
115 compat_(compat),
116 d0_(d0),
117 Chi2N_(Chi2N),
118 nHit_(nHit),
119 outZ_(outZ),
120 outR_(outR)
121 {
122 parentDR_ = -1;
123 parentI_ = -1;
124 parentI2_ = -1;
125 parentClass = -1;
126 parentPDG = -1;
127 isTrackValid=false;
128 isStandAloneValid=false;
129 caloCompatibility_=-1;
130 segmentCompatibility_=-1;
131 weight_=1; // if it's a pseudo muon, then we will assign weight for it
132 // FIXME dirty coding here...
133 segments_.clear();
134 numberOfValidMuonHits_ = 0;
135 gen_pt = -1; gen_eta = -99.0; gen_phi=-99.0; gen_q = -99; gen_index = -1;
136 };
137 ~Muon() {};
138
139
140 double ecalIso() const {return ecalIso_;};
141 double hcalIso() const {return hcalIso_;};
142 double trkIso() const {return trkIso_;};
143 double isolSumNorm(int type=1) const
144 {
145 if(type==1){ return (trkIso_ + ecalIso_ + hcalIso_)/pt();}
146 else { return (trkIso_ + ecalIso_ + hcalIso_)/(pt()>20?pt():20); }
147 };
148 double isolSum() const
149 {
150 return (trkIso_ + ecalIso_ + hcalIso_);
151 };
152
153 void putParentDR(double dr) {parentDR_ = dr;};
154 void putParentI(int i) {parentI_ = i;};//i from full PYTHIA list
155 void putParentI2(int i) {parentI2_ = i;};//same; or i from genMu list if matched
156 void putParentPDGid(int i) {parentPDG = i;};
157 void defineParent(int i) {parentClass = defineParentClass(i);};
158 void putParentClass(int i) {parentClass = i;};
159
160 int getParentClass() {return parentClass;};
161 int getParentPDG() {return parentPDG;};
162 int getMatchedIndex() {return parentI_;};
163 double getDr() {return parentDR_;};
164
165 int type() {return type_;};
166 double calEm() {return calEm_;};
167 double calHm() {return calHm_;};
168 double compat() {return compat_;};
169 double d0() {return d0_;};
170 double Chi2N() {return Chi2N_;};
171 double nHit() {return nHit_;};
172 double outZ() {return outZ_;};
173 double outR() {return outR_;};
174
175
176
177 void Set_staMom(TLorentzVector pp){staMom=pp; isStandAloneValid=true;};
178 void Set_trkMom(TLorentzVector pp){trkMom=pp; isTrackValid=true;};
179 TLorentzVector getStaMom(){return staMom;};
180 TLorentzVector getTrkMom(){return trkMom;};
181 void Set_staCharge(int c){staCharge=c;};
182 void Set_trkCharge(int c){trkCharge=c;};
183 int getStaCharge(){return staCharge;};
184 int getTrkCharge(){return trkCharge;};
185 bool getTrackValid(){return isTrackValid;};
186 bool getStandAloneValid(){return isStandAloneValid;};
187
188 void printRec();
189 void printRec(ofstream &fout);
190
191 bool isGlobalMuon(){return GlobalMuon_;};
192 bool isTrackerMuon(){return TrackerMuon_;};
193 bool isCaloMuon(){return CaloMuon_;}
194 bool isStandAloneMuon(){return StandAloneMuon_;};
195 bool isGlobalMuonPromptTight(){return GlobalMuonPromptTight_;};
196 bool isTM2DCompatibilityLoose(){TM2DCompatibilityLoose_;};
197 bool isTM2DCompatibilityTight(){TM2DCompatibilityTight_;};
198 bool isTMOneStationLoose(){return TMOneStationLoose_;};
199 void setGlobalMuon(bool b){ GlobalMuon_=b;};
200 void setTrackerMuon(bool b){ TrackerMuon_=b;};
201 void setCaloMuon(bool b){ CaloMuon_=b;}
202 void setStandAloneMuon(bool b){ StandAloneMuon_=b;};
203 void setGlobalMuonPromptTight(bool b){ GlobalMuonPromptTight_=b;};
204 void setTM2DCompatibilityLoose(bool b){TM2DCompatibilityLoose_=b;};
205 void setTM2DCompatibilityTight(bool b){TM2DCompatibilityTight_=b;};
206 void setTMOneStationLoose(bool b){ TMOneStationLoose_=b;};
207 void setTMLastStationOptimizedLowPtLoose(bool b){ TMLastStationOptimizedLowPtLoose_=b;};
208 void setTMLastStationOptimizedLowPtTight(bool b){ TMLastStationOptimizedLowPtTight_=b;};
209 bool isTMLastStationOptimizedLowPtTight(){return TMLastStationOptimizedLowPtTight_;};
210 bool isTMLastStationOptimizedLowPtLoose(){return TMLastStationOptimizedLowPtLoose_;};
211 void setTMLastStationAngTight(bool b){ TMLastStationAngTight_=b;};
212 bool isTMLastStationAngTight(){return TMLastStationAngTight_;};
213 void setTMOneStationAngTight(bool b){ TMOneStationAngTight_=b;};
214 bool isTMOneStationAngTight(){return TMOneStationAngTight_;};
215 void setTMOneStationAngLoose(bool b){ TMOneStationAngLoose_=b;};
216 bool isTMOneStationAngLoose(){return TMOneStationAngLoose_;};
217
218 double ndof(){return ndof_;};
219 void set_ndof(double n){ndof_=n;};
220 double getStaNdof(){return staNdof;};
221 double getTrkNdof(){return trkNdof;};
222 void Set_staNdof(float n){staNdof=n;};
223 void Set_trkNdof(float n){trkNdof=n;};
224 void setTrackQuantities(int charge, TLorentzVector mom, double d0, double Chi2N, int nHit, double ndof){
225 trkMom=mom; trkD0=d0; trkChi2N=Chi2N; trkNHit=nHit; trkNdof=ndof; trkCharge=charge; isTrackValid=true;
226 };
227 double getTrkChi2N(){return trkChi2N;};
228
229 void Set_numberOfValidMuonHits(short n) {numberOfValidMuonHits_ = n;};
230 short numberOfValidMuonHits(){return numberOfValidMuonHits_;};
231
232 float caloCompatibility(){return caloCompatibility_;};
233 void setCaloCompatibility(float input){caloCompatibility_=input;};
234 float segmentCompatibility(){return segmentCompatibility_;};
235 bool TrackerMuonArbitrated(){return TrackerMuonArbitrated_;};
236 bool AllArbitrated(){return AllArbitrated_;};
237 void setSegmentCompatibility(float c){segmentCompatibility_=c;};
238 void setTrackerMuonArbitrated(bool b){TrackerMuonArbitrated_=b;};
239 void setAllArbitrated(bool b){AllArbitrated_=b;};
240
241 void setTrack(Track& trk){track_=trk; isTrackValid=true;};
242 Track track(){return track_;};
243
244 void setWeight(float w){weight_=w;};
245 float weight(){return weight_;};
246
247 void setGood(bool b) {Good_=b;};
248 bool isGood(){return Good_;};
249
250 void setD0PV(double d){d0PV_=d;};
251 double d0PV(){return d0PV_;};
252
253 void setNumberOfMatches(int n){numberOfMatches_=n;};
254 void setNumberOfChambers(int n){numberOfChambers_=n;};
255 int numberOfMatches(){return numberOfMatches_;};
256 int numberOfChambers(){return numberOfChambers_;};
257
258 void setSegments(vector<Segment> segs){segments_=segs;};
259 vector<Segment> getSegments(){return segments_;};
260
261 static const int kDetOffset = 28;
262 static const int kSubdetOffset = 25;
263 static const int DT= 1;
264 static const int CSC=2;
265 static const int RPC=3;
266 enum Detector { Tracker=1,MuonDet=2,Ecal=3,Hcal=4,Calo=5 };
267
268 // The maximum numbers of various parts
269 enum eMaxNum{ MAX_ENDCAP=2, MAX_STATION=4, MAX_RING=4, MAX_CHAMBER=36, MAX_LAYER=6 };
270 // // We count from 1
271 enum eMinNum{ MIN_ENDCAP=1, MIN_STATION=1, MIN_RING=1, MIN_CHAMBER=1, MIN_LAYER=1 };
272 //
273 // // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
274 // // Keep as multiples of 3 so that number can be easily decodable from octal
275 enum eNumBitDet{ BITS_ENDCAP=3, BITS_STATION=3, BITS_RING=3, BITS_CHAMBER=6, BITS_LAYER=3 };
276 //
277 // // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
278 enum eMaskBitDet{ MASK_ENDCAP=07, MASK_STATION=07, MASK_RING=07, MASK_CHAMBER=077, MASK_LAYER=07 };
279 //
280 // // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
281 enum eStartBitDet{ START_CHAMBER=BITS_LAYER, START_RING=START_CHAMBER+BITS_CHAMBER,
282 START_STATION=START_RING+BITS_RING, START_ENDCAP=START_STATION+BITS_STATION };
283
284 /**
285 * * Return Chamber label.
286 * *
287 * */
288 int chamber(uint32_t id_) const {
289 return ( (id_>>START_CHAMBER) & MASK_CHAMBER ); };
290
291 /**
292 * * Return Ring label.
293 * *
294 * */
295 int ring(uint32_t id_) const {
296 if (((id_>>START_STATION) & MASK_STATION) == 1)
297 return ( detIdToInt((id_>>START_RING) & MASK_RING ));
298 else
299 return (((id_>>START_RING) & MASK_RING ));
300 };
301
302 /**
303 * * Return Station label.
304 * *
305 * */
306 int station(uint32_t id_) const {
307 return ( (id_>>START_STATION) & MASK_STATION ); };
308
309 /**
310 * * Return Endcap label. 1=forward (+Z); 2=backward (-Z)
311 * *
312 * */
313 int endcap(uint32_t id_) const {
314 return ( (id_>>START_ENDCAP) & MASK_ENDCAP ); };
315
316 static int detIdToInt(int iring) {
317 // reverse intToDetId: change 1, 2, 3, 4 inside the DetId to 4, 1, 2, 3 for external use
318 // // i.e. output ring # 1, 2, 3, 4 in ME1 means ME1b, ME12, ME13, ME1a as usual in the offline software.
319 int i = (iring-1);
320 if (i == 0)
321 i = 4;
322 return i;
323 };
324
325
326
327 /// get the detector field from this detid
328 Detector det(uint32_t id_) const { return Detector((id_>>kDetOffset)&0xF); };
329 /// get the contents of the subdetector field (not cast into any detector's numbering enum)
330 int subdetId(uint32_t id_) const { return ((id_>>kSubdetOffset)&0x7); };
331
332
333 void SetGenPt(float a) {gen_pt=a;};
334 void SetGenEta(float a) {gen_eta=a;};
335 void SetGenPhi(float a) {gen_phi=a;};
336 void SetGenQ(int a) {gen_q = a;};
337 void SetGenIndex(int a){gen_index=a;};
338
339 float GetGenPt() {return gen_pt;};
340 float GetGenEta() {return gen_eta;};
341 float GetGenPhi() {return gen_phi;};
342 int GetGenQ() {return gen_q;};
343 int GetGenIndex(){return gen_index;};
344 };
345
346
347
348 #endif // #ifdef Muon_cxx