BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecDigit2Hit.cxx
Go to the documentation of this file.
1//
2// Convert from Digit Map to Hit Map
3//
4// Wang.Zhe 2004, 3, 29
5// He.Miao 2005
6//
7#include <iostream>
8
11
15#include "GaudiKernel/Bootstrap.h"
16#include "GaudiKernel/ISvcLocator.h"
17
18// tianhl for mt
19#include "GaudiKernel/ThreadGaudi.h"
20// tianhl for mt
21// Constructors and destructors
24
27
29 RecEmcHitMap& aHitMap)
30{
31 RecEmcDigitMap::const_iterator ciDigitMap;
32 RecEmcHit aHit;
33
35
36 StatusCode sc;
37 // Get EmcCalibConstSvc.
38 IEmcCalibConstSvc *emcCalibConstSvc;
39 sc= Gaudi::svcLocator()->service("EmcCalibConstSvc", emcCalibConstSvc);
40 if(sc != StatusCode::SUCCESS) {
41 //cout << "EmcRecDigit2Hit Error: Can't get EmcCalibConstSvc." << endl;
42 }
43
44 // Get RawDataProviderSvc
45 IRawDataProviderSvc *rawDataProviderSvc;
46 // tianhl for mt
47 std::string rawDataProviderSvc_name("RawDataProviderSvc");
48 if(isGaudiThreaded(m_algName)) {
49 rawDataProviderSvc_name += getGaudiThreadIDfromName(m_algName);
50 }
51 // tianhl for mt
52 sc = Gaudi::svcLocator()->service(rawDataProviderSvc_name.c_str(), rawDataProviderSvc);
53 if(sc != StatusCode::SUCCESS) {
54 //cout << "EmcRecDigit2Hit Error: Can't get RawDataProviderSvc." << endl;
55 }
56
57 for(ciDigitMap=aDigitMap.begin();
58 ciDigitMap!=aDigitMap.end();
59 ++ciDigitMap) {
60
61 const RecEmcDigit &aDigit=ciDigitMap->second;
62
63 aHit.CellId(aDigit.CellId());
64
65 double ein,ecorr,eout;
66 ein=aDigit.ADC();
67
68 //Times the calibration constant in offline mode
69 if(!(rawDataProviderSvc->isOnlineMode()) && Para.DigiCalib()) {
70
71 unsigned int partId = EmcID::barrel_ec(aDigit.CellId());
72 unsigned int theta = EmcID::theta_module(aDigit.CellId());
73 unsigned int phi = EmcID::phi_module(aDigit.CellId());
74
75 int index = emcCalibConstSvc->getIndex(partId,theta,phi);
76
77 //liucx
78
79 double adc2e = emcCalibConstSvc->getDigiCalibConst(index);
80
81 if(Para.DataMode()==0) {
82 if(Para.ElecSaturation()==1){
83 double emaxData = emcCalibConstSvc->getCrystalEmaxData(index);
84 if (emaxData>0) {
85 // cout<<adc2e<<"\t"<<emaxData/2.5<<endl;
86 adc2e=emaxData/2.5;
87 }
88 }
89 }
90
91 ein *= adc2e ;
92 //liucx
93
94 //liucx ein *= emcCalibConstSvc->getDigiCalibConst(index);
95
96 }
97
98 // Correct electronic noise bias. Not used now.
99 if(ein<Para.ElecBias(4)) {
100 ecorr=Para.ElecBias(0)*log(ein/Para.ElecBias(1)); //noise=0.5
101 } else {
102 ecorr=Para.ElecBias(2)+Para.ElecBias(3)*ein;
103 }
104 eout=ein;
105 aHit.Energy(eout/GeV);
106
107 aHit.Time(aDigit.TDC());
108 // For some reason, there are 0 energy hit.
109 // Avoid this to happen, dangerous!
110 if(aHit.getEnergy()>=Para.ElectronicsNoiseLevel()){// &&
111 //(aHit.time()>=Para.TimeMin()) &&
112 //(aHit.time()<=Para.TimeMax()))
113 aHitMap[aHit.getCellId()]=aHit;
114 }
115 }
116
117}
118
119void EmcRecDigit2Hit::Output(const RecEmcHitMap& aHitMap) const
120{
121 unsigned int module,theta,phi;
122 RecEmcID id;
123 RecEmcHitMap::const_iterator ci_HitMap;
124 RecEmcEnergy e;
125 int ie;
126
127 //cout<<"Output a hitmap:"<<endl;
128
129 module=EmcID::EmcID::getBARREL();
130
131 //cout<<"Barrel:"<<endl;
132 //cout<<"+--------------------------------------------+"<<endl;
133 for(phi=EmcID::getPHI_BARREL_MAX();
135 --phi) {
136 //cout<<"|";
137 for(theta=EmcID::getTHETA_BARREL_MIN();
139 ++theta) {
140 id=EmcID::crystal_id(module,theta,phi);
141 ci_HitMap=aHitMap.find(id);
142 if(ci_HitMap!=aHitMap.end()) {
143 e=ci_HitMap->second.getEnergy();
144 ie=(int)(e*10);
145 if(ie>9) {
146 ie=9;
147 }
148 //cout<<ie;
149 } else {
150 //cout<<" ";
151 }
152 }
153 //cout<<"|"<<endl;
154 }
155 //cout<<"+--------------------------------------------+"<<endl;
156
157 module=EmcID::EmcID::getENDCAP_EAST();
158 OutputEndcap(aHitMap,module);
159 module=EmcID::EmcID::getENDCAP_WEST();
160 OutputEndcap(aHitMap,module);
161}
162
163void EmcRecDigit2Hit::OutputEndcap(const RecEmcHitMap& aHitMap, const unsigned int module_ew) const
164{
165 unsigned int module,theta,phi;
166 RecEmcID id;
167 RecEmcHitMap::const_iterator ci_HitMap;
168 RecEmcEnergy e;
169 int ie;
170
171 module=module_ew;
172 if(module==EmcID::EmcID::getENDCAP_EAST()){
173 //cout<<"East endcap:"<<endl;
174 }
175 else if(module==EmcID::EmcID::getENDCAP_WEST()){
176 //cout<<"West endcap:"<<endl;
177 }
178
179 //cout<<"+--------------------------------------------------------+"<<endl;
180 for(theta=EmcID::getTHETA_ENDCAP_MAX();
182 theta--){
183 //cout<<"|";
184 for(phi=(EmcID::getPHI_ENDCAP_MAX(theta)-1)/2;
186 phi--) {
187 id=EmcID::crystal_id(module,theta,phi);
188 ci_HitMap=aHitMap.find(id);
189 if(ci_HitMap!=aHitMap.end()) {
190 e=ci_HitMap->second.getEnergy();
191 ie=(int)(e*10);
192 if(ie>9) {
193 ie=9;
194 }
195 if((theta<4) &&
196 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==(EmcID::getPHI_ENDCAP_MAX(theta)+1)/16-1)){
197 //cout<<"*";
198 }
199 //cout<<ie;
200 if((theta==0||theta==1)&&(phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
201 //cout<<"*";
202 }
203 }
204 else{
205 if((theta<4) &&
206 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==(EmcID::getPHI_ENDCAP_MAX(theta)+1)/16-1)){
207 //cout<<" ";
208 }
209 //cout<<" ";
210 if((theta==0||theta==1)&&(phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
211 //cout<<" ";
212 }
213 }
214 if(phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0){
215 //cout<<"|";
216 }
217 if(phi==(EmcID::getPHI_ENDCAP_MAX(theta)+1)/4){
218 //cout<<"|";
219 }
220 }
221 //cout<<endl;
222 }
223 //cout<<"+--------------------------------------------------------+"<<endl;
224
225 for(theta=EmcID::getTHETA_ENDCAP_MIN();
227 theta++){
228 //cout<<"|";
229 for(phi=(EmcID::getPHI_ENDCAP_MAX(theta)+1)/2;
230 phi!=EmcID::getPHI_ENDCAP_MAX(theta)+1;
231 phi++) {
232 id=EmcID::crystal_id(module,theta,phi);
233 ci_HitMap=aHitMap.find(id);
234 if(ci_HitMap!=aHitMap.end()) {
235 e=ci_HitMap->second.getEnergy();
236 ie=(int)(e*10);
237 if(ie>9) {
238 ie=9;
239 }
240 if((theta<4) &&
241 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
242 //cout<<"*";
243 }
244 //cout<<ie;
245 if((theta==0||theta==1)&&((phi+1)%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
246 //cout<<"*";
247 }
248 }
249 else{
250 if((theta<4) &&
251 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
252 //cout<<" ";
253 }
254 //cout<<" ";
255 if((theta==0||theta==1)&&((phi+1)%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
256 //cout<<" ";
257 }
258 }
259 if((phi+1)%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0){
260 //cout<<"|";
261 }
262 if(phi==3*(EmcID::getPHI_ENDCAP_MAX(theta)+1)/4-1){
263 //cout<<"|";
264 }
265 }
266 //cout<<endl;
267 }
268 //cout<<"+--------------------------------------------------------+"<<endl;
269
270}
271
double RecEmcEnergy
map< RecEmcID, RecEmcDigit, less< RecEmcID > > RecEmcDigitMap
Definition RecEmcDigit.h:59
map< RecEmcID, RecEmcHit, less< RecEmcID > > RecEmcHitMap
Definition RecEmcHit.h:75
static unsigned int getPHI_BARREL_MAX()
Definition EmcID.cxx:107
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
Definition EmcID.cxx:71
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition EmcID.cxx:38
static unsigned int getTHETA_ENDCAP_MIN()
Definition EmcID.cxx:103
static unsigned int getTHETA_ENDCAP_MAX()
Definition EmcID.cxx:99
static unsigned int getTHETA_BARREL_MIN()
Definition EmcID.cxx:95
static unsigned int getTHETA_BARREL_MAX()
Definition EmcID.cxx:91
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:43
static unsigned int getPHI_ENDCAP_MAX(const unsigned int theta)
Definition EmcID.cxx:115
static unsigned int getPHI_ENDCAP_MIN()
Definition EmcID.cxx:128
static unsigned int getPHI_BARREL_MIN()
Definition EmcID.cxx:111
static unsigned int phi_module(const Identifier &id)
Definition EmcID.cxx:48
void Convert(const RecEmcDigitMap &aDigitMap, RecEmcHitMap &aHitMap)
void OutputEndcap(const RecEmcHitMap &aHitMap, const unsigned int module_ew) const
void Output(const RecEmcHitMap &aHitMap) const
static EmcRecParameter & GetInstance()
double ElectronicsNoiseLevel() const
bool DigiCalib() const
double ElecBias(int n) const
int ElecSaturation() const
double DataMode() const
virtual double getDigiCalibConst(int No) const =0
virtual int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const =0
virtual double getCrystalEmaxData(int Index) const =0
virtual bool isOnlineMode()=0
RecEmcADC ADC() const
RecEmcTDC TDC() const
RecEmcID CellId() const
RecEmcEnergy getEnergy() const
Definition RecEmcHit.h:48
RecEmcEnergy Energy(const RecEmcEnergy &Energy)
Definition RecEmcHit.cxx:87
RecEmcID CellId(const RecEmcID &CellId)
Definition RecEmcHit.cxx:81
RecEmcID getCellId() const
Definition RecEmcHit.h:47
RecEmcTime Time(const RecEmcTime &Time)
Definition RecEmcHit.cxx:93