CGEM BOSS 6.6.5.g
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
23{}
24
26{}
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 ein *= emcCalibConstSvc->getDigiCalibConst(index);
77
78 }
79
80 // Correct electronic noise bias. Not used now.
81 if(ein<Para.ElecBias(4)) {
82 ecorr=Para.ElecBias(0)*log(ein/Para.ElecBias(1)); //noise=0.5
83 } else {
84 ecorr=Para.ElecBias(2)+Para.ElecBias(3)*ein;
85 }
86 eout=ein;
87 aHit.Energy(eout/GeV);
88
89 aHit.Time(aDigit.TDC());
90 // For some reason, there are 0 energy hit.
91 // Avoid this to happen, dangerous!
92 if(aHit.getEnergy()>=Para.ElectronicsNoiseLevel()){// &&
93 //(aHit.time()>=Para.TimeMin()) &&
94 //(aHit.time()<=Para.TimeMax()))
95 aHitMap[aHit.getCellId()]=aHit;
96 }
97 }
98
99}
100
101void EmcRecDigit2Hit::Output(const RecEmcHitMap& aHitMap) const
102{
103 unsigned int module,theta,phi;
104 RecEmcID id;
105 RecEmcHitMap::const_iterator ci_HitMap;
106 RecEmcEnergy e;
107 int ie;
108
109 //cout<<"Output a hitmap:"<<endl;
110
111 module=EmcID::EmcID::getBARREL();
112
113 //cout<<"Barrel:"<<endl;
114 //cout<<"+--------------------------------------------+"<<endl;
115 for(phi=EmcID::getPHI_BARREL_MAX();
117 --phi) {
118 //cout<<"|";
119 for(theta=EmcID::getTHETA_BARREL_MIN();
121 ++theta) {
122 id=EmcID::crystal_id(module,theta,phi);
123 ci_HitMap=aHitMap.find(id);
124 if(ci_HitMap!=aHitMap.end()) {
125 e=ci_HitMap->second.getEnergy();
126 ie=(int)(e*10);
127 if(ie>9) {
128 ie=9;
129 }
130 //cout<<ie;
131 } else {
132 //cout<<" ";
133 }
134 }
135 //cout<<"|"<<endl;
136 }
137 //cout<<"+--------------------------------------------+"<<endl;
138
139 module=EmcID::EmcID::getENDCAP_EAST();
140 OutputEndcap(aHitMap,module);
141 module=EmcID::EmcID::getENDCAP_WEST();
142 OutputEndcap(aHitMap,module);
143}
144
145void EmcRecDigit2Hit::OutputEndcap(const RecEmcHitMap& aHitMap, const unsigned int module_ew) const
146{
147 unsigned int module,theta,phi;
148 RecEmcID id;
149 RecEmcHitMap::const_iterator ci_HitMap;
150 RecEmcEnergy e;
151 int ie;
152
153 module=module_ew;
154 if(module==EmcID::EmcID::getENDCAP_EAST()){
155 //cout<<"East endcap:"<<endl;
156 }
157 else if(module==EmcID::EmcID::getENDCAP_WEST()){
158 //cout<<"West endcap:"<<endl;
159 }
160
161 //cout<<"+--------------------------------------------------------+"<<endl;
162 for(theta=EmcID::getTHETA_ENDCAP_MAX();
164 theta--){
165 //cout<<"|";
166 for(phi=(EmcID::getPHI_ENDCAP_MAX(theta)-1)/2;
168 phi--) {
169 id=EmcID::crystal_id(module,theta,phi);
170 ci_HitMap=aHitMap.find(id);
171 if(ci_HitMap!=aHitMap.end()) {
172 e=ci_HitMap->second.getEnergy();
173 ie=(int)(e*10);
174 if(ie>9) {
175 ie=9;
176 }
177 if((theta<4) &&
178 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==(EmcID::getPHI_ENDCAP_MAX(theta)+1)/16-1)){
179 //cout<<"*";
180 }
181 //cout<<ie;
182 if((theta==0||theta==1)&&(phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
183 //cout<<"*";
184 }
185 }
186 else{
187 if((theta<4) &&
188 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==(EmcID::getPHI_ENDCAP_MAX(theta)+1)/16-1)){
189 //cout<<" ";
190 }
191 //cout<<" ";
192 if((theta==0||theta==1)&&(phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
193 //cout<<" ";
194 }
195 }
196 if(phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0){
197 //cout<<"|";
198 }
199 if(phi==(EmcID::getPHI_ENDCAP_MAX(theta)+1)/4){
200 //cout<<"|";
201 }
202 }
203 //cout<<endl;
204 }
205 //cout<<"+--------------------------------------------------------+"<<endl;
206
207 for(theta=EmcID::getTHETA_ENDCAP_MIN();
209 theta++){
210 //cout<<"|";
211 for(phi=(EmcID::getPHI_ENDCAP_MAX(theta)+1)/2;
212 phi!=EmcID::getPHI_ENDCAP_MAX(theta)+1;
213 phi++) {
214 id=EmcID::crystal_id(module,theta,phi);
215 ci_HitMap=aHitMap.find(id);
216 if(ci_HitMap!=aHitMap.end()) {
217 e=ci_HitMap->second.getEnergy();
218 ie=(int)(e*10);
219 if(ie>9) {
220 ie=9;
221 }
222 if((theta<4) &&
223 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
224 //cout<<"*";
225 }
226 //cout<<ie;
227 if((theta==0||theta==1)&&((phi+1)%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
228 //cout<<"*";
229 }
230 }
231 else{
232 if((theta<4) &&
233 (phi%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
234 //cout<<" ";
235 }
236 //cout<<" ";
237 if((theta==0||theta==1)&&((phi+1)%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0)){
238 //cout<<" ";
239 }
240 }
241 if((phi+1)%((EmcID::getPHI_ENDCAP_MAX(theta)+1)/16)==0){
242 //cout<<"|";
243 }
244 if(phi==3*(EmcID::getPHI_ENDCAP_MAX(theta)+1)/4-1){
245 //cout<<"|";
246 }
247 }
248 //cout<<endl;
249 }
250 //cout<<"+--------------------------------------------------------+"<<endl;
251
252}
253
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
virtual double getDigiCalibConst(int No) const =0
virtual int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const =0
virtual bool isOnlineMode()=0
RecEmcADC ADC() const
Definition: RecEmcDigit.cxx:59
RecEmcTDC TDC() const
Definition: RecEmcDigit.cxx:64
RecEmcID CellId() const
Definition: RecEmcDigit.cxx:54
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