2#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/SmartDataPtr.h"
6#include "EventModel/Event.h"
7#include "EventModel/EventHeader.h"
8#include "Identifier/Identifier.h"
9#include "EmcRawEvent/EmcDigi.h"
10#include "Identifier/EmcID.h"
11#include "RawEvent/RawDataUtil.h"
12#include "HltAlgorithms/EFGlobalEnergy.h"
20 MsgStream log(
msgSvc(), name);
37 MsgStream log(
msgSvc(), name());
38 log << MSG::INFO <<
"in initialize()" << endreq;
44 if ( sc.isFailure() ) {
45 log << MSG::ERROR <<
"m_HltStoreSvc->put(etot) wrong" << endreq;
49 if ( sc.isFailure() ) {
50 log << MSG::ERROR <<
"m_HltStoreSvc->put(ebar) wrong" << endreq;
54 if ( sc.isFailure() ) {
55 log << MSG::ERROR <<
"m_HltStoreSvc->put(eend) wrong" << endreq;
59 if ( sc.isFailure() ) {
60 log << MSG::ERROR <<
"m_HltStoreSvc->put(ebal) wrong" << endreq;
64 sc = service(
"EmcCalibConstSvc", m_emcCalibConstSvc);
65 if(sc != StatusCode::SUCCESS) {
66 log << MSG::ERROR <<
"Can't get EmcCalibConstSvc." << endreq;
74 setenv(
"BEPCII_INFO.BER_PRB",
cbeam,0);
75 setenv(
"BEPCII_INFO.BPR_PRB",
cbeam,0);
86 MsgStream log(
msgSvc(), name());
89 char*
electron=getenv(
"BEPCII_INFO.BER_PRB");
94 log << MSG::ERROR <<
"Cannot get beam energy (e-)! Please call online people" << endreq;
96 char* positron=getenv(
"BEPCII_INFO.BPR_PRB");
101 log << MSG::ERROR <<
"Cannot get beam energy (e+)! Please call online people" << endreq;
109 log << MSG::INFO <<
"beam energy = " <<
m_beam << endreq;
112 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
114 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
115 return( StatusCode::FAILURE);
129 SmartDataPtr<EmcDigiCol> emcDigi(eventSvc(),
"/Event/Digi/EmcDigiCol");
131 log << MSG::FATAL <<
"Could not find Emc digi!!" << endreq;
132 return( StatusCode::FAILURE);
139 double adc,
etot=0.,ebarrel=0.,eendcap=0.;
140 double energyx=0.,energyy=0.,energyz=0.;
142 unsigned int idBarrel_Endcap,itheta,iphi;
143 double ewest=0.,eeast=0.;
146 EmcDigiCol::iterator iterEMC=emcDigiCol->begin();
147 while(iterEMC!= emcDigiCol->end()) {
148 id=(*iterEMC)->identify();
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;
162 double theta=0,phi=0;
164 if(idBarrel_Endcap==1){
165 theta=(34.+112.*(itheta+0.5)/44.)/180.*3.1415926;
166 phi=(iphi+0.5)/120.*6.2831852;
168 if(itheta<22) eeast+=adc;
172 theta=(90.+(90.-(itheta+0.5)/6.*(34.-21.56)+21.56)*(idBarrel_Endcap-1))
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;
178 if(idBarrel_Endcap==0) {
185 energyx +=adc*
sin(theta)*
cos(phi);
186 energyy +=adc*
sin(theta)*
sin(phi);
187 energyz +=adc*
cos(theta);
193 ebalance=sqrt(energyx*energyx+energyy*energyy+energyz*energyz)/
etot;
197 log << MSG::INFO <<
"etot=" <<
etot <<
"(" <<
etot/2./
abs(
m_beam) <<
"); ebarrel=" <<ebarrel
198 <<
"; eendcap="<<eendcap <<
"; ebalanece="<<ebalance<<endreq;
216 return StatusCode::SUCCESS;
220 MsgStream log(
msgSvc(), name());
221 log << MSG::INFO <<
"in finalize()" << endmsg;
222 return StatusCode::SUCCESS;
ObjectVector< EmcDigi > EmcDigiCol
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in output
double sin(const BesAngle a)
double cos(const BesAngle a)
void setValue(float value)
virtual ~EFGlobalEnergy()
EFGlobalEnergy(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize()
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)
bool put(const std::string &name, const T &value)
virtual StatusCode initialize()
IRawDataProviderSvc * m_rawDigiSvc
HltStoreSvc * m_HltStoreSvc
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)
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)