ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/PixelHit.h
Revision: 1.2
Committed: Mon Sep 28 14:15:34 2009 UTC (15 years, 7 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_011a
Changes since 1.1: +100 -2 lines
Log Message:
Added packing class

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: PixelHit.h,v 1.1 2009/09/25 08:39:10 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 Bool_t IsOnEdge() const;
108 Bool_t HasBadPixels() const;
109 const ThreeVector Position() const { return fPosition.V(); }
110 EObjType ObjType() const { return kPixelHit; }
111 void SetCharge(UInt_t u) { fCharge = u; }
112 void SetPosition(const ThreeVector &pos) { fPosition = pos; }
113 void SetPosition(Double_t x, Double_t y, Double_t z);
114 void SetQuality(UInt_t u) { fQuality = u; }
115 void SetType(Char_t t) { fType = t; }
116 void SetSize(UInt_t u) { fSize = u; }
117 Bool_t SpansTwoROCs() const;
118 EType Type() const
119 { return static_cast<EType>(fType); }
120 Double_t X() const { return fPosition.X(); }
121 Double_t Y() const { return fPosition.Y(); }
122 Double_t Z() const { return fPosition.Z(); }
123
124 protected:
125 Vect3 fPosition; //point in space
126 Char_t fType; //pixel type
127 UInt_t fQuality; //quality word as defined by SiPixelRecHitQuality
128 UInt_t fCharge; //charge of assigned cluster
129 UInt_t fSize; //size of assigned cluster
130 static Packing fPacking; //!the (un)packing helper class
131
132 ClassDef(PixelHit, 1) // PixelHit class
133 };
134 }
135
136 //--------------------------------------------------------------------------------------------------
137 inline Bool_t mithep::PixelHit::IsOnEdge() const
138 {
139 // Return true if pixel hit is on edge.
140
141 return fPacking.IsOnEdge(fQuality);
142 }
143
144 //--------------------------------------------------------------------------------------------------
145 inline Bool_t mithep::PixelHit::HasBadPixels() const
146 {
147 // Return true if pixel hit contains bad pixels.
148
149 return fPacking.HasBadPixels(fQuality);
150 }
151
152 //--------------------------------------------------------------------------------------------------
153 inline void mithep::PixelHit::SetPosition(Double_t x, Double_t y, Double_t z)
154 {
155 // Set pixel hit position.
156
157 fPosition.SetXYZ(x,y,z);
158 }
159
160 //--------------------------------------------------------------------------------------------------
161 inline Bool_t mithep::PixelHit::SpansTwoROCs() const
162 {
163 // Return true if pixel hit spans two rocs (ie is large).
164
165 return fPacking.SpansTwoROCs(fQuality);
166 }
167 #endif