81 {
82
83
84
85
86 MsgStream log(
msgSvc(), name());
87
88 float e1=0,e2=0;
89 char*
electron=getenv(
"BEPCII_INFO.BER_PRB");
92 }
93 else{
94 log << MSG::ERROR << "Cannot get beam energy (e-)! Please call online people" << endreq;
95 }
96 char* positron=getenv("BEPCII_INFO.BPR_PRB");
97 if(positron){
98 e2=atof(positron);
99 }
100 else{
101 log << MSG::ERROR << "Cannot get beam energy (e+)! Please call online people" << endreq;
102 }
103 if(e1>0.1&&e2>0.1&&
m_beam>0) {
105 }
106 else{
107
108 }
109 log << MSG::INFO <<
"beam energy = " <<
m_beam << endreq;
110
111
112 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
113 if (!eventHeader) {
114 log << MSG::FATAL << "Could not find Event Header" << endreq;
115 return( StatusCode::FAILURE);
116 }
117
118
119
120 bool calFlag=false;
125 calFlag = true;
126 }
127 }
128 if(!emcDigiCol){
129 SmartDataPtr<EmcDigiCol> emcDigi(eventSvc(),"/Event/Digi/EmcDigiCol");
130 if (!emcDigi) {
131 log << MSG::FATAL << "Could not find Emc digi!!" << endreq;
132 return( StatusCode::FAILURE);
133 }
134
135 emcDigiCol=emcDigi;
136 }
137
139 double adc,etot=0.,ebarrel=0.,eendcap=0.;
140 double energyx=0.,energyy=0.,energyz=0.;
141 double ebalance;
142 unsigned int idBarrel_Endcap,itheta,iphi;
143 double ewest=0.,eeast=0.;
144
145
146 EmcDigiCol::iterator iterEMC=emcDigiCol->begin();
147 while(iterEMC!= emcDigiCol->end()) {
148 id=(*iterEMC)->identify();
153 adc /= 1000. ;
154 if(!calFlag&&m_emcCalibConstSvc) {
155 int index = m_emcCalibConstSvc->
getIndex(idBarrel_Endcap,itheta,iphi);
157 log << MSG::DEBUG << "adc= " << adc << " and calibration constant: " << adc2e << " at " << idBarrel_Endcap << " " << itheta << " " << iphi << endreq;
158 adc *= adc2e;
159 }
160
161 etot += adc;
162 double theta=0,phi=0;
163
164 if(idBarrel_Endcap==1){
165 theta=(34.+112.*(itheta+0.5)/44.)/180.*3.1415926;
166 phi=(iphi+0.5)/120.*6.2831852;
167 ebarrel +=adc;
168 if(itheta<22) eeast+=adc;
169 else ewest+=adc;
170 }
171 else{
172 theta=(90.+(90.-(itheta+0.5)/6.*(34.-21.56)+21.56)*(idBarrel_Endcap-1))
173 /180.*3.1415926;
174 if(itheta==0||itheta==1)phi=(iphi+0.5)/64.*6.2831852;
175 if(itheta==2||itheta==3)phi=(iphi+0.5)/80.*6.2831852;
176 if(itheta==4||itheta==5)phi=(iphi+0.5)/96.*6.2831852;
177 eendcap +=adc;
178 if(idBarrel_Endcap==0) {
179 eeast+=adc;
180 }
181 else {
182 ewest+=adc;
183 }
184 }
185 energyx +=adc*
sin(theta)*
cos(phi);
186 energyy +=adc*
sin(theta)*
sin(phi);
187 energyz +=adc*
cos(theta);
188
189
190 iterEMC++;
191 }
192 if(etot>0)
193 ebalance=sqrt(energyx*energyx+energyy*energyy+energyz*energyz)/etot;
194 else
195 ebalance=0;
196
197 log << MSG::INFO <<
"etot=" << etot <<
"(" << etot/2./
abs(
m_beam) <<
"); ebarrel=" <<ebarrel
198 <<"; eendcap="<<eendcap <<"; ebalanece="<<ebalance<<endreq;
199
200
205
215
216 return StatusCode::SUCCESS;
217}
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< EmcDigi > EmcDigiCol
void setValue(float value)
bool addToEFVec(uint32_t val, uint32_t pos)
bool appToEFVec(double val, uint32_t pos)
bool setVecBit(uint32_t val, uint32_t vecpos, uint32_t bbegin, uint32_t bend)
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
virtual double getDigiCalibConst(int No) const =0
virtual int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const =0
virtual EmcDigiCol & getEmcDigiVec(uint32_t control=0)=0
virtual bool isOnlineMode()=0
static double EmcCharge(int measure, int chargeChannel)