StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcRawHit.cxx
1 /***************************************************************************
2  *
3  * $Id: StEmcRawHit.cxx,v 2.11 2013/01/15 23:21:05 fisyak Exp $
4  *
5  * Author: Akio Ogawa, Jan 2000
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StEmcRawHit.cxx,v $
13  * Revision 2.11 2013/01/15 23:21:05 fisyak
14  * improve printouts
15  *
16  * Revision 2.10 2012/10/23 20:18:33 fisyak
17  * Add/modify print outs
18  *
19  * Revision 2.9 2012/09/16 21:33:57 fisyak
20  * Add print out
21  *
22  * Revision 2.8 2007/01/25 02:52:35 ullrich
23  * Changes to modEtaSub() and sub() implemented by Adam Kocoloski.
24  * sub() now returns 1 instead of -1.
25  *
26  * Revision 2.7 2004/07/20 17:07:49 perev
27  * Pavlinov corrs for TBrowser
28  *
29  * Revision 2.6 2004/07/15 16:36:24 ullrich
30  * Removed all clone() declerations and definitions. Use StObject::clone() only.
31  *
32  * Revision 2.5 2001/04/05 04:00:49 ullrich
33  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
34  *
35  * Revision 2.4 2001/03/24 03:34:46 perev
36  * clone() -> clone() const
37  *
38  * Revision 2.3 2000/07/28 19:49:28 akio
39  * Change in Detector Id for Endcap SMD
40  *
41  * Revision 2.2 2000/05/22 19:21:54 akio
42  * Bug fix, add delta into EMcPoint, wider bits for Eta in RawHit
43  *
44  * Revision 2.1 2000/02/23 17:34:12 ullrich
45  * Initial Revision
46  *
47  **************************************************************************/
48 #include "StEmcRawHit.h"
49 #include "StEmcUtil/geometry/StEmcGeom.h"
50 
51 static const char rcsid[] = "$Id: StEmcRawHit.cxx,v 2.11 2013/01/15 23:21:05 fisyak Exp $";
52 
53 ClassImp(StEmcRawHit)
54 
55 StEmcGeom* StEmcRawHit::mGeom=0;
56 
58 {
59  mId = 0;
60  mAdc = 0;
61  mEnergy = 0;
62 }
63 
64 StEmcRawHit::StEmcRawHit(StDetectorId d, unsigned int m, unsigned int e, unsigned int s, unsigned int a)
65 {
66  setId(d, m, e, s);
67  setAdc(a);
68  setEnergy(0.0);
69 }
70 
71 StEmcRawHit::StEmcRawHit(StDetectorId d, unsigned int m, unsigned int e, unsigned int s, unsigned int a, float ene)
72 {
73  setId(d, m, e, s);
74  setAdc(a);
75  setEnergy(ene);
76 }
77 
78 StEmcRawHit::StEmcRawHit(const StEmcRawHit& h) : StObject(h){
79  mId = h.mId;
80  mAdc = h.mAdc;
81  mEnergy = h.mEnergy;
82 }
83 
84 StEmcRawHit::~StEmcRawHit() {/* noop */}
85 
86 unsigned int
87 StEmcRawHit::bits(unsigned int bit, unsigned int nbits) const
88 {
89  return (mId>>bit) & ~(~0UL<<nbits);
90 }
91 
92 void
93 StEmcRawHit::setCalibrationType(unsigned int t){
94  if(t<256){
95  mId = mId & 0xffffff;
96  mId += t << 24;
97  }
98 }
99 
100 void
101 StEmcRawHit::setId(StDetectorId d, unsigned int m, unsigned int e, unsigned int s)
102 {
103  mId = static_cast<unsigned int>(d - kBarrelEmcTowerId) << 20;
104  mId += m << 13;
105  mId += e << 4;
106  mId += s;
107 }
108 
109 unsigned int
110 StEmcRawHit::calibrationType() const {return bits(24, 8);} // bits 24-31
111 
112 StDetectorId
113 StEmcRawHit::detector() const
114 {
115  return static_cast<StDetectorId>(bits(20, 4)+kBarrelEmcTowerId); // bits 20-24
116 }
117 
118 unsigned int
119 StEmcRawHit::module() const {return bits(13, 7);} // bits 13-19
120 
121 unsigned int
122 StEmcRawHit::eta() const {return bits( 4, 9);} // bits 4-12
123 
124 unsigned int
125 StEmcRawHit::softId(int det) const
126 {
127  mGeom = StEmcGeom::instance(det);
128  if(mGeom==0) return 0;
129 
130  int id=0, m=0, e=0, s=0;
131  modEtaSub(m,e,s);
132  mGeom->getId(m, e, s, id);
133  return id;
134 }
135 
136 void StEmcRawHit::modEtaSub(int &m, int &e, int &s) const
137 {
138  m = module();
139  e = eta();
140  s = sub();
141 }
142 
143 int
144 StEmcRawHit::sub() const {
145  int sub;
146  switch(detector()){
147  case kBarrelSmdEtaStripId: // sub is irrelevant for these
148  case kEndcapSmdUStripId:
149  case kEndcapSmdVStripId:
150  sub = 1;
151  break;
152  default:
153  sub = bits(0, 4); // bits 0-3
154  }
155  return sub;
156 }
157 
158 unsigned int
159 StEmcRawHit::adc() const {return mAdc;}
160 
161 float
162 StEmcRawHit::energy() const {return mEnergy;}
163 
164 void
165 StEmcRawHit::setAdc(const unsigned int adc) {mAdc=adc;}
166 
167 void
168 StEmcRawHit::setEnergy(const float energy) {mEnergy=energy;}
169 
170 ostream& operator<<(ostream& os, const StEmcRawHit& v) {
171  os << Form("EmcRawHit d/m %3i/%3i eta/sub %3i/%3i adc/enery %4i/%f",v.detector(),v.module(), v.eta(), v.sub(), v.adc(), v.energy());
172  if (v.detector() == kBarrelEmcTowerId || v.detector() == kEndcapEmcTowerId) {
173  if (v.energy() <= 0.0) os << " Junk";
174  else if (v.energy() <= 0.1) os << " Noise";
175  else if (v.energy() <= 0.5) os << " MIP";
176  else if (v.energy() <= 1.0) os << " Hadron?";
177  else if (v.energy() <= 4.0) os << " electron";// lowest HT threshold (4 GeV for Run7)
178  else if (v.energy() <= 10.0) os << " Tower";// lowest HT threshold (4 GeV for Run7)
179  else if (v.energy() <= 20.0) os << " W";// lowest HT threshold (4 GeV for Run7)
180  else if (v.energy() <=100.0) os << " Z";// lowest HT threshold (4 GeV for Run7)
181  else os << " Hot ?";
182  }
183  return os;
184 }
185 void StEmcRawHit::Print(Option_t *option) const {cout << *this << endl;}