88 {
89
90
91
92
93 MsgStream log(
msgSvc(), name() );
94
96 char*
electron = getenv(
"BEPCII_INFO.BER_PRB" );
98 else
99 { log << MSG::ERROR << "Cannot get beam energy (e-)! Please call online people" << endmsg; }
100 char* positron = getenv( "BEPCII_INFO.BPR_PRB" );
101 if ( positron ) {
e2 = atof( positron ); }
102 else
103 { log << MSG::ERROR << "Cannot get beam energy (e+)! Please call online people" << endmsg; }
105 else {}
106 log << MSG::INFO <<
"beam energy = " <<
m_beam << endmsg;
107
108
109 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
110 if ( !eventHeader )
111 {
112 log << MSG::FATAL << "Could not find Event Header" << endmsg;
113 return ( StatusCode::FAILURE );
114 }
115
116
117
118 bool calFlag = false;
121 {
123 {
128 calFlag = true;
129 }
130 }
131 if ( !emcDigiCol )
132 {
133 SmartDataPtr<EmcDigiCol> emcDigi( eventSvc(), "/Event/Digi/EmcDigiCol" );
134 if ( !emcDigi )
135 {
136 log << MSG::FATAL << "Could not find Emc digi!!" << endmsg;
137 return ( StatusCode::FAILURE );
138 }
139
140 emcDigiCol = emcDigi;
141 }
142
143 Identifier id;
144 double adc,
etot = 0., ebarrel = 0., eendcap = 0.;
145 double energyx = 0., energyy = 0., energyz = 0.;
146 double ebalance;
147 unsigned int idBarrel_Endcap, itheta, iphi;
148 double ewest = 0., eeast = 0.;
149
150
151 EmcDigiCol::iterator iterEMC = emcDigiCol->begin();
152 while ( iterEMC != emcDigiCol->end() )
153 {
154 id = ( *iterEMC )->identify();
158 adc =
160 adc /= 1000.;
161 if ( !calFlag && m_emcCalibConstSvc )
162 {
163 int index = m_emcCalibConstSvc->getIndex( idBarrel_Endcap, itheta, iphi );
164 double adc2e = m_emcCalibConstSvc->getDigiCalibConst( index );
165 log << MSG::DEBUG << "adc= " << adc << " and calibration constant: " << adc2e << " at "
166 << idBarrel_Endcap << " " << itheta << " " << iphi << endmsg;
167 adc *= adc2e;
168 }
169
171 double theta = 0, phi = 0;
172
173 if ( idBarrel_Endcap == 1 )
174 {
175 theta = ( 34. + 112. * ( itheta + 0.5 ) / 44. ) / 180. * 3.1415926;
176 phi = ( iphi + 0.5 ) / 120. * 6.2831852;
177 ebarrel += adc;
178 if ( itheta < 22 ) eeast += adc;
179 else ewest += adc;
180 }
181 else
182 {
183 theta = ( 90. + ( 90. - ( itheta + 0.5 ) / 6. * ( 34. - 21.56 ) + 21.56 ) *
184 ( idBarrel_Endcap - 1 ) ) /
185 180. * 3.1415926;
186 if ( itheta == 0 || itheta == 1 ) phi = ( iphi + 0.5 ) / 64. * 6.2831852;
187 if ( itheta == 2 || itheta == 3 ) phi = ( iphi + 0.5 ) / 80. * 6.2831852;
188 if ( itheta == 4 || itheta == 5 ) phi = ( iphi + 0.5 ) / 96. * 6.2831852;
189 eendcap += adc;
190 if ( idBarrel_Endcap == 0 ) { eeast += adc; }
191 else { ewest += adc; }
192 }
193 energyx += adc *
sin( theta ) *
cos( phi );
194 energyy += adc *
sin( theta ) *
sin( phi );
195 energyz += adc *
cos( theta );
196
197
198 iterEMC++;
199 }
201 ebalance = sqrt( energyx * energyx + energyy * energyy + energyz * energyz ) /
etot;
202 else ebalance = 0;
203
205 << "); ebarrel=" << ebarrel << "; eendcap=" << eendcap << "; ebalanece=" << ebalance
206 << endmsg;
207
208
210 m_ebar->setValue( ebarrel / 2. /
abs(
m_beam ) );
211 m_eend->setValue( eendcap / 2. /
abs(
m_beam ) );
212 m_ebal->setValue( ebalance );
213
215 m_ef->appToEFVec( ebalance, 34 );
216 m_ef->appToEFVec( ebarrel, 32 );
217 m_ef->appToEFVec( eendcap, 33 );
218 m_ef->appToEFVec( eeast, 35 );
219 m_ef->appToEFVec( ewest, 36 );
220 m_ef->setVecBit(
true, 0, 1 );
221 m_ef->addToEFVec( 7 << 16, 1 );
223
224 return StatusCode::SUCCESS;
225}
ObjectVector< EmcDigi > EmcDigiCol
double sin(const BesAngle a)
double cos(const BesAngle a)
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
IRawDataProviderSvc * m_rawDigiSvc
static double EmcCharge(int measure, int chargeChannel)