BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcTCFinder Class Reference

#include <EmcTCFinder.h>

Public Member Functions

 EmcTCFinder ()
 ~EmcTCFinder ()
void setEmcDigi (EmcDigiCol *emcDigiCol)
void setEmcTC (std::vector< uint32_t > vTC)
void setEmcBE (std::vector< double > vBE)
int getTCPhiId (int partId, int ThetaNb, int PhiNb)
int getTCThetaId (int partId, int ThetaNb, int PhiNb)
int getBLKId (int TCTheta, int TCPhi) const
double & getBTCEnergy (int i, int j)
double & getEETCEnergy (int i, int j)
double & getWETCEnergy (int i, int j)
int & getBTC (int i, int j)
int & getEETC (int i, int j)
int & getWETC (int i, int j)
double & getBTC_ADC (int i, int j)
double & getEETC_ADC (int i, int j)
double & getWETC_ADC (int i, int j)
double getBLKE (int i)

Static Public Member Functions

static EmcTCFinderget_Emc (void)

Detailed Description

Definition at line 11 of file EmcTCFinder.h.

Constructor & Destructor Documentation

◆ EmcTCFinder()

EmcTCFinder::EmcTCFinder ( )

Definition at line 37 of file EmcTCFinder.cxx.

37 {
38 ISvcLocator* svcLocator = Gaudi::svcLocator();
39 IRealizationSvc* tmpReal;
40 StatusCode status = svcLocator->service( "RealizationSvc", tmpReal );
41 if ( !status.isSuccess() )
42 { cout << "FATAL: Could not initialize Realization Service" << endl; }
43 else { m_RealizationSvc = dynamic_cast<RealizationSvc*>( tmpReal ); }
44
45 // Get EmcCalibConstSvc.
46 status = svcLocator->service( "EmcCalibConstSvc", emcCalibConstSvc );
47 if ( status != StatusCode::SUCCESS )
48 { cout << "EmcRecDigit2Hit Error: Can't get EmcCalibConstSvc." << endl; }
49}

Referenced by get_Emc().

◆ ~EmcTCFinder()

EmcTCFinder::~EmcTCFinder ( )

Definition at line 50 of file EmcTCFinder.cxx.

50{}

Member Function Documentation

◆ get_Emc()

EmcTCFinder * EmcTCFinder::get_Emc ( void )
static

Definition at line 32 of file EmcTCFinder.cxx.

32 {
33 if ( !emc_Pointer ) emc_Pointer = new EmcTCFinder();
34 return emc_Pointer;
35}

Referenced by EmcCCount::EmcCCount(), EmcESum::EmcESum(), and BesTrigL1::initialize().

◆ getBLKE()

double EmcTCFinder::getBLKE ( int i)
inline

Definition at line 35 of file EmcTCFinder.h.

35{ return BlkE[i]; }

◆ getBLKId()

int EmcTCFinder::getBLKId ( int TCTheta,
int TCPhi ) const

Definition at line 278 of file EmcTCFinder.cxx.

278 {
279 int id, parity;
280 parity = (int)TCPhi / 5;
281 if ( parity % 2 == 0 )
282 {
283 if ( TCTheta < 6 ) id = parity;
284 if ( TCTheta >= 6 ) id = parity + 6;
285 }
286 if ( parity % 2 != 0 )
287 {
288 if ( TCTheta < 5 ) id = parity;
289 if ( TCTheta >= 5 ) id = parity + 6;
290 }
291
292 return id;
293}

◆ getBTC()

int & EmcTCFinder::getBTC ( int i,
int j )
inline

Definition at line 27 of file EmcTCFinder.h.

27{ return BTC[i][j]; }

◆ getBTC_ADC()

double & EmcTCFinder::getBTC_ADC ( int i,
int j )
inline

Definition at line 31 of file EmcTCFinder.h.

31{ return BTCEnergy_adc[i][j]; }

◆ getBTCEnergy()

double & EmcTCFinder::getBTCEnergy ( int i,
int j )
inline

Definition at line 23 of file EmcTCFinder.h.

23{ return BTCEnergy[i][j]; }

◆ getEETC()

int & EmcTCFinder::getEETC ( int i,
int j )
inline

Definition at line 28 of file EmcTCFinder.h.

28{ return EETC[i][j]; }

◆ getEETC_ADC()

double & EmcTCFinder::getEETC_ADC ( int i,
int j )
inline

Definition at line 32 of file EmcTCFinder.h.

32{ return EETCEnergy_adc[i][j]; }

◆ getEETCEnergy()

double & EmcTCFinder::getEETCEnergy ( int i,
int j )
inline

Definition at line 24 of file EmcTCFinder.h.

24{ return EETCEnergy[i][j]; }

◆ getTCPhiId()

int EmcTCFinder::getTCPhiId ( int partId,
int ThetaNb,
int PhiNb )

Definition at line 219 of file EmcTCFinder.cxx.

219 {
220 if ( partId == 1 ) TCPhiNb = int( PhiNb / 4 );
221 /*
222 //trigger cell in endcaps theta*phi = 2*16
223 if(partId==0)
224 {
225 if(ThetaNb<2) TCPhiNb = int(PhiNb/4);
226 if(ThetaNb>=2&&ThetaNb<4) TCPhiNb = int(PhiNb/5);
227 if(ThetaNb>=4) TCPhiNb = int(PhiNb/6);
228 }
229 if(partId==2)
230 {
231 if(ThetaNb<2) TCPhiNb = int(PhiNb/4);
232 if(ThetaNb>=2&&ThetaNb<4) TCPhiNb = int(PhiNb/5);
233 if(ThetaNb>=4) TCPhiNb = int(PhiNb/6);
234 }
235 */
236 // trigger cell in endcaps theta*phi = 1*32
237 if ( partId == 0 )
238 {
239 if ( ThetaNb < 2 ) TCPhiNb = int( PhiNb / 2 );
240 if ( ThetaNb == 2 )
241 {
242 int quot = int( PhiNb / 5 );
243 int rema = PhiNb % 5;
244 if ( rema <= 1 ) TCPhiNb = 2 * quot;
245 if ( rema > 1 ) TCPhiNb = 2 * quot + 1;
246 }
247 if ( ThetaNb == 3 )
248 {
249 int quot = int( PhiNb / 5 );
250 int rema = PhiNb % 5;
251 if ( rema <= 2 ) TCPhiNb = 2 * quot;
252 if ( rema > 2 ) TCPhiNb = 2 * quot + 1;
253 }
254 if ( ThetaNb >= 4 ) TCPhiNb = int( PhiNb / 3 );
255 }
256 if ( partId == 2 )
257 {
258 if ( ThetaNb < 2 ) TCPhiNb = int( PhiNb / 2 );
259 if ( ThetaNb == 2 )
260 {
261 int quot = int( PhiNb / 5 );
262 int rema = PhiNb % 5;
263 if ( rema <= 1 ) TCPhiNb = 2 * quot;
264 if ( rema > 1 ) TCPhiNb = 2 * quot + 1;
265 }
266 if ( ThetaNb == 3 )
267 {
268 int quot = int( PhiNb / 5 );
269 int rema = PhiNb % 5;
270 if ( rema <= 2 ) TCPhiNb = 2 * quot;
271 if ( rema > 2 ) TCPhiNb = 2 * quot + 1;
272 }
273 if ( ThetaNb >= 4 ) TCPhiNb = int( PhiNb / 3 );
274 }
275
276 return TCPhiNb;
277}

Referenced by setEmcDigi().

◆ getTCThetaId()

int EmcTCFinder::getTCThetaId ( int partId,
int ThetaNb,
int PhiNb )

Definition at line 177 of file EmcTCFinder.cxx.

177 {
178 // Note: There are 44*120(theta*phi) crystals and they are divided 11*30 trigger cell in
179 // barrel emc. So each trigger cell includes 4*4 crystals
180 if ( partId == 1 )
181 {
182 // if(ThetaNb<2)
183 // TCThetaNb = 0;
184 // else if(ThetaNb>41)
185 // TCThetaNb = 11;
186 // else
187 // TCThetaNb = int((ThetaNb+2)/4);
188 TCThetaNb = (int)ThetaNb / 4;
189 }
190 /* if(partId==0)
191 {
192 if(ThetaNb<3) TCThetaNb = 0;
193 if(ThetaNb>3) TCThetaNb = 1;
194 if(ThetaNb==3)
195 {
196 int n = PhiNb%10;
197 if(n>2&&n<7)
198 TCThetaNb = 0;
199 else TCThetaNb = 1;
200 }
201 }
202 if(partId==2)
203 {
204 if(ThetaNb<3) TCThetaNb = 0;
205 if(ThetaNb>3) TCThetaNb = 1;
206 if(ThetaNb==3)
207 {
208 int n = PhiNb%10;
209 if(n>2&&n<7)
210 TCThetaNb = 0;
211 else TCThetaNb = 1;
212 }
213 }
214 */
215 if ( partId == 0 ) TCThetaNb = 0;
216 if ( partId == 2 ) TCThetaNb = 0;
217 return TCThetaNb;
218}

Referenced by setEmcDigi().

◆ getWETC()

int & EmcTCFinder::getWETC ( int i,
int j )
inline

Definition at line 29 of file EmcTCFinder.h.

29{ return WETC[i][j]; }

◆ getWETC_ADC()

double & EmcTCFinder::getWETC_ADC ( int i,
int j )
inline

Definition at line 33 of file EmcTCFinder.h.

33{ return WETCEnergy_adc[i][j]; }

◆ getWETCEnergy()

double & EmcTCFinder::getWETCEnergy ( int i,
int j )
inline

Definition at line 25 of file EmcTCFinder.h.

25{ return WETCEnergy[i][j]; }

◆ setEmcBE()

void EmcTCFinder::setEmcBE ( std::vector< double > vBE)

Definition at line 164 of file EmcTCFinder.cxx.

164 {
165 // reset block energy
166 for ( int i = 0; i < 16; i++ ) { BlkE[i] = 0; }
167 if ( vBE.size() != 0 )
168 {
169 if ( vBE.size() != 16 )
170 std::cerr << "The number of block is not equal 16, please check it (in "
171 "EmcTCFinder::setEmcBE() )"
172 << std::endl;
173 for ( int i = 0; i < vBE.size(); i++ ) { BlkE[i] = vBE[i]; }
174 }
175}

◆ setEmcDigi()

void EmcTCFinder::setEmcDigi ( EmcDigiCol * emcDigiCol)

Definition at line 51 of file EmcTCFinder.cxx.

51 {
52 // double energy;
53 double tot_adc = 0.;
54 double adc = 0., adc1 = 0., tdc = 0.;
55 unsigned int measure;
56 // reset tc energy of barrel and endcap
57 for ( int i = 0; i < TrigConf::TCTHETANO_B; i++ )
58 for ( int j = 0; j < TrigConf::TCPHINO_B; j++ )
59 {
60 BTCEnergy[i][j] = 0;
61 BTCEnergy_adc[i][j] = 0;
62 }
63 for ( int i = 0; i < TrigConf::TCTHETANO_E; i++ )
64 for ( int j = 0; j < TrigConf::TCPHINO_E; j++ )
65 {
66 EETCEnergy[i][j] = 0;
67 WETCEnergy[i][j] = 0;
68 EETCEnergy_adc[i][j] = 0;
69 WETCEnergy_adc[i][j] = 0;
70 }
71 EmcDigiCol::iterator iter3;
72 Identifier id;
73 for ( iter3 = emcDigiCol->begin(); iter3 != emcDigiCol->end(); iter3++ )
74 {
75 id = ( *iter3 )->identify();
76
77 unsigned int module;
78 unsigned int theta;
79 unsigned int phi;
80 module = EmcID::barrel_ec( id );
81 theta = EmcID::theta_module( id );
82 phi = EmcID::phi_module( id );
83 adc = double( ( *iter3 )->getChargeChannel() );
84 adc1 = double( ( *iter3 )->getChargeChannel() );
85 measure = ( *iter3 )->getMeasure();
86 tdc = ( *iter3 )->getTimeChannel();
87
88 int index = emcCalibConstSvc->getIndex( module, theta, phi );
89 // divided by electronics calibration constants and times trigger gain
90 // double trgGain = ((50./255.)*(m_RealizationSvc->getTrgGain(index))/60.)*5*0.5;
91 double trgGain = m_RealizationSvc->getTrgGain( index );
92 std::cout << "partId, thetaId, phiId, trgGain: " << module << ", " << theta << ", " << phi
93 << ", " << trgGain << std::endl;
94 // if((*iter3)->getMeasure()==0) adc =
95 // adc*(m_RealizationSvc->getEleCalib(index,7))*(trgGain)*800.*2/65535; else
96 // if((*iter3)->getMeasure()==1) adc =
97 // adc*(m_RealizationSvc->getEleCalib(index,4))*(trgGain)*800.*2/65535; else adc =
98 // adc*(m_RealizationSvc->getEleCalib(index,1))*(trgGain)*800.*2/65535;
99 if ( ( *iter3 )->getMeasure() == 0 ) adc = adc * 2 * 800. * 2 / 65535. * ( trgGain );
100 else if ( ( *iter3 )->getMeasure() == 1 ) adc = adc * 16 * 800. * 2 / 65535 * ( trgGain );
101 else adc = adc * 64 * 800. * 2 / 65535 * ( trgGain );
102
103 // double trgConst = m_RealizationSvc->getTrgConst(index);
104 // if((*iter3)->getMeasure()==0) adc1 = adc1*2*800.*2/65535.*(trgConst)*0.333;
105 // else if((*iter3)->getMeasure()==1) adc1 = adc1*16*800.*2/65535*(trgConst)*0.333;
106 // else adc1 = adc1*64*800.*2/65535*(trgConst)*0.333;
107
108 // std::cout << "eCalib: " << m_RealizationSvc->getEleCalib(index,7) << "," <<
109 // m_RealizationSvc->getEleCalib(index,4) << "," << m_RealizationSvc->getEleCalib(index,1)
110 // << " TrigGain: " << m_RealizationSvc->getTrgGain(index) << std::endl; std::cout << "
111 // TrgGain: " << trgGain << " adc: " << adc << std::endl; adc =
112 // RawDataUtil::EmcCharge(measure,adc); //MeV energy = RandGauss::shoot(energy,0.1*energy);
113 // //add 10% smear in each ADC channel
114
115 int TCThetaId = getTCThetaId( module, theta, phi );
116 int TCPhiId = getTCPhiId( module, theta, phi );
117 // Get energy of each trigger cell
118 if ( module == 1 ) BTCEnergy[TCThetaId][TCPhiId] += adc;
119 if ( module == 0 ) EETCEnergy[TCThetaId][TCPhiId] += adc;
120 if ( module == 2 ) WETCEnergy[TCThetaId][TCPhiId] += adc;
121 if ( module == 1 ) BTCEnergy_adc[TCThetaId][TCPhiId] += adc;
122 if ( module == 0 ) EETCEnergy_adc[TCThetaId][TCPhiId] += adc;
123 if ( module == 2 ) WETCEnergy_adc[TCThetaId][TCPhiId] += adc;
124 }
125
126 // subtract ped
127 /*
128 for(int i=0;i<TrigConf::TCTHETANO_B;i++)
129 for(int j=0;j<TrigConf::TCPHINO_B;j++) {
130 if((BTCEnergy[i][j] - 0x0a) < 0) BTCEnergy[i][j] = 0;
131 else BTCEnergy[i][j] = BTCEnergy[i][j] - 0x0a;
132 }
133 for(int i=0;i<TrigConf::TCTHETANO_E;i++)
134 for(int j=0;j<TrigConf::TCPHINO_E;j++)
135 {
136 if((EETCEnergy[i][j] - 0x0a) < 0) EETCEnergy[i][j] = 0;
137 else EETCEnergy[i][j] = EETCEnergy[i][j] - 0x0a;
138 if((WETCEnergy[i][j] - 0x0a) < 0) WETCEnergy[i][j] = 0;
139 else WETCEnergy[i][j] = WETCEnergy[i][j] - 0x0a;
140 }*/
141}
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:41
static unsigned int phi_module(const Identifier &id)
Definition EmcID.cxx:46
int getTCThetaId(int partId, int ThetaNb, int PhiNb)
int getTCPhiId(int partId, int ThetaNb, int PhiNb)

◆ setEmcTC()

void EmcTCFinder::setEmcTC ( std::vector< uint32_t > vTC)

Definition at line 143 of file EmcTCFinder.cxx.

143 {
144 // reset tc energy of barrel and endcap
145 for ( int i = 0; i < TrigConf::TCTHETANO_B; i++ )
146 for ( int j = 0; j < TrigConf::TCPHINO_B; j++ ) { BTC[i][j] = 0; }
147 for ( int i = 0; i < TrigConf::TCTHETANO_E; i++ )
148 for ( int j = 0; j < TrigConf::TCPHINO_E; j++ )
149 {
150 EETC[i][j] = 0;
151 WETC[i][j] = 0;
152 }
153 for ( std::vector<uint32_t>::iterator iter = vTC.begin(); iter != vTC.end(); iter++ )
154 {
155 int par_TC = ( *iter & 0xFF0000 ) >> 16;
156 int the_TC = ( *iter & 0xFF00 ) >> 8;
157 int phi_TC = ( *iter & 0xFF );
158 if ( par_TC == 0 ) EETC[the_TC][phi_TC] = 1;
159 if ( par_TC == 1 ) BTC[the_TC][phi_TC] = 1;
160 if ( par_TC == 2 ) WETC[the_TC][phi_TC] = 1;
161 }
162}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)

The documentation for this class was generated from the following files: