ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/PixelHit.h
Revision: 1.3
Committed: Thu Nov 5 10:30:29 2009 UTC (15 years, 6 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_012a, Mit_012
Changes since 1.2: +5 -2 lines
Log Message:
Implemented forgotton getters

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: PixelHit.h,v 1.2 2009/09/28 14:15:34 loizides Exp $
3 //
4 // PixelHit
5 //
6 // PixelHit class implemented as a point in space holding fit error and additional information.
7 //
8 // Authors: C.Loizides
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITANA_DATATREE_PIXELHIT_H
12 #define MITANA_DATATREE_PIXELHIT_H
13
14 #include "MitCommon/DataFormats/interface/Vect3.h"
15 #include "MitAna/DataTree/interface/DataObject.h"
16 #include <TMath.h>
17
18 namespace mithep
19 {
20 class PixelHit : public DataObject
21 {
22 public:
23 enum EType {
24 kUnknown=0,
25 kBLayer1=1,
26 kBLayer2=2,
27 kBLayer3=3,
28 kFNegDisk1=-11,
29 kFPosDisk1=+11,
30 kFNegDisk2=-12,
31 kFPosDisk2=+12
32 };
33
34 class Packing { //adapted from SiPixelRecHitQuality
35 public:
36 Packing();
37 typedef UInt_t QualWordType;
38
39 inline Bool_t IsOnEdge(QualWordType qualWord) const {
40 return (qualWord >> fEdge_shift) & fEdge_mask;
41 }
42 inline Bool_t HasBadPixels(QualWordType qualWord) const {
43 return (qualWord >> fBad_shift) & fBad_mask;
44 }
45 inline Bool_t HasFilledProb(QualWordType qualWord) const {
46 return (qualWord >> fHasFilledProb_shift) & fHasFilledProb_mask;
47 }
48 inline Float_t ProbabilityX(QualWordType qualWord) const {
49 Int_t raw = (qualWord >> fProbX_shift) & fProbX_mask;
50 assert(raw>=0 && raw <=2047);
51 Float_t prob = 0;
52 if (raw==2047) prob = 0;
53 else prob = TMath::Power(fProbX_units,-raw) ;
54 return prob;
55 }
56 inline Float_t ProbabilityY(QualWordType qualWord) const {
57 Int_t raw = (qualWord >> fProbY_shift) & fProbY_mask;
58 assert(raw>=0 && raw <=2047);
59 Float_t prob = 0;
60 if (raw==2047) prob = 0;
61 else prob = TMath::Power(fProbY_units,-raw) ;
62 return prob;
63 }
64 inline Int_t QBin(QualWordType qualWord) const {
65 Int_t qbin = (qualWord >> fQBin_shift) & fQBin_mask;
66 assert(qbin>=0 && qbin <=7);
67 return qbin;
68 }
69 inline Bool_t SpansTwoROCs(QualWordType qualWord) const {
70 return (qualWord >> fTwoROC_shift) & fTwoROC_mask;
71 }
72 protected:
73 QualWordType fProbX_mask;
74 Int_t fProbX_shift;
75 Float_t fProbX_units;
76 Double_t fProbX_1_over_log_units;
77 Char_t fProbX_width;
78 QualWordType fProbY_mask;
79 Int_t fProbY_shift;
80 Float_t fProbY_units;
81 Double_t fProbY_1_over_log_units;
82 Char_t fProbY_width;
83 QualWordType fQBin_mask;
84 Int_t fQBin_shift;
85 Char_t fQBin_width;
86 QualWordType fEdge_mask;
87 Int_t fEdge_shift;
88 Char_t fEdge_width;
89 QualWordType fBad_mask;
90 Int_t fBad_shift;
91 Char_t fBad_width;
92 QualWordType fTwoROC_mask;
93 Int_t fTwoROC_shift;
94 Char_t fTwoROC_width;
95 QualWordType fHasFilledProb_mask;
96 Int_t fHasFilledProb_shift;
97 Char_t fHasFilledProb_width;
98 Char_t fSpare_width;
99 };
100
101 PixelHit() : fType(0), fQuality(0), fCharge(0), fSize(0) {}
102 PixelHit(Double_t x, Double_t y, Double_t z) :
103 fPosition(x,y,z), fType(0), fQuality(0), fCharge(0), fSize(0) {}
104 PixelHit(const ThreeVector &pos) :
105 fPosition(pos), fType(0), fQuality(0), fCharge(0), fSize(0) {}
106
107 UInt_t Charge() const { return fCharge; }
108 Bool_t IsOnEdge() const;
109 Bool_t HasBadPixels() const;
110 EObjType ObjType() const { return kPixelHit; }
111 const ThreeVector Position() const { return fPosition.V(); }
112 UInt_t Quality() const { return fQuality; }
113 void SetCharge(UInt_t u) { fCharge = u; }
114 void SetPosition(const ThreeVector &pos) { fPosition = pos; }
115 void SetPosition(Double_t x, Double_t y, Double_t z);
116 void SetQuality(UInt_t u) { fQuality = u; }
117 void SetType(Char_t t) { fType = t; }
118 void SetSize(UInt_t u) { fSize = u; }
119 UInt_t Size() const { return fSize; }
120 Bool_t SpansTwoROCs() const;
121 EType Type() const
122 { return static_cast<EType>(fType); }
123 Double_t X() const { return fPosition.X(); }
124 Double_t Y() const { return fPosition.Y(); }
125 Double_t Z() const { return fPosition.Z(); }
126
127 protected:
128 Vect3 fPosition; //point in space
129 Char_t fType; //pixel type
130 UInt_t fQuality; //quality word as defined by SiPixelRecHitQuality
131 UInt_t fCharge; //charge of assigned cluster
132 UInt_t fSize; //size of assigned cluster
133 static Packing fPacking; //!the (un)packing helper class
134
135 ClassDef(PixelHit, 1) // PixelHit class
136 };
137 }
138
139 //--------------------------------------------------------------------------------------------------
140 inline Bool_t mithep::PixelHit::IsOnEdge() const
141 {
142 // Return true if pixel hit is on edge.
143
144 return fPacking.IsOnEdge(fQuality);
145 }
146
147 //--------------------------------------------------------------------------------------------------
148 inline Bool_t mithep::PixelHit::HasBadPixels() const
149 {
150 // Return true if pixel hit contains bad pixels.
151
152 return fPacking.HasBadPixels(fQuality);
153 }
154
155 //--------------------------------------------------------------------------------------------------
156 inline void mithep::PixelHit::SetPosition(Double_t x, Double_t y, Double_t z)
157 {
158 // Set pixel hit position.
159
160 fPosition.SetXYZ(x,y,z);
161 }
162
163 //--------------------------------------------------------------------------------------------------
164 inline Bool_t mithep::PixelHit::SpansTwoROCs() const
165 {
166 // Return true if pixel hit spans two rocs (ie is large).
167
168 return fPacking.SpansTwoROCs(fQuality);
169 }
170 #endif