81 {
82
83
84
85
86 MsgStream log(
msgSvc(), name());
87
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){
99 }
100 else{
101 log << MSG::ERROR << "Cannot get beam energy (e+)! Please call online people" << endreq;
102 }
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 adc *= adc2e;
158 }
159
161 double theta=0,phi=0;
162
163 if(idBarrel_Endcap==1){
164 theta=(34.+112.*(itheta+0.5)/44.)/180.*3.1415926;
165 phi=(iphi+0.5)/120.*6.2831852;
166 ebarrel +=adc;
167 if(itheta<22) eeast+=adc;
168 else ewest+=adc;
169 }
170 else{
171 theta=(90.+(90.-(itheta+0.5)/6.*(34.-21.56)+21.56)*(idBarrel_Endcap-1))
172 /180.*3.1415926;
173 if(itheta==0||itheta==1)phi=(iphi+0.5)/64.*6.2831852;
174 if(itheta==2||itheta==3)phi=(iphi+0.5)/80.*6.2831852;
175 if(itheta==4||itheta==5)phi=(iphi+0.5)/96.*6.2831852;
176 eendcap +=adc;
177 if(idBarrel_Endcap==0) {
178 eeast+=adc;
179 }
180 else {
181 ewest+=adc;
182 }
183 }
184 energyx +=adc*
sin(theta)*
cos(phi);
185 energyy +=adc*
sin(theta)*
sin(phi);
186 energyz +=adc*
cos(theta);
187
188
189 iterEMC++;
190 }
192 ebalance=sqrt(energyx*energyx+energyy*energyy+energyz*energyz)/
etot;
193 else
194 ebalance=0;
195
196 log << MSG::INFO <<
"etot=" <<
etot <<
"(" <<
etot/2./
abs(
m_beam) <<
"); ebarrel=" <<ebarrel
197 <<"; eendcap="<<eendcap <<"; ebalanece="<<ebalance<<endreq;
198
199
204
214
215 return StatusCode::SUCCESS;
216}
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< EmcDigi > EmcDigiCol
double abs(const EvtComplex &c)
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)