Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EFGlobalEnergy Class Reference

#include <EFGlobalEnergy.h>

Inheritance diagram for EFGlobalEnergy:

IEFAlgorithm IEFAlgorithm List of all members.

Public Member Functions

 EFGlobalEnergy (const std::string &name, ISvcLocator *pSvcLocator)
 EFGlobalEnergy (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute ()
StatusCode execute ()
StatusCode finalize ()
StatusCode finalize ()
virtual StatusCode initialize ()
virtual StatusCode initialize ()
void reset ()
void reset ()
virtual ~EFGlobalEnergy ()
virtual ~EFGlobalEnergy ()

Protected Attributes

float m_beam
EFResultm_ef
EFResultm_ef
HltStoreSvcm_HltStoreSvc
HltStoreSvcm_HltStoreSvc
int m_output
PropertyMgr m_propMgr
IRawDataProviderSvcm_rawDigiSvc
IRawDataProviderSvcm_rawDigiSvc
bool m_run

Private Attributes

CriteriaItemValuem_ebal
CriteriaItemValuem_ebal
CriteriaItemValuem_ebar
CriteriaItemValuem_ebar
CriteriaItemValuem_eend
CriteriaItemValuem_eend
IEmcCalibConstSvcm_emcCalibConstSvc
IEmcCalibConstSvcm_emcCalibConstSvc
CriteriaItemValuem_etot
CriteriaItemValuem_etot

Constructor & Destructor Documentation

EFGlobalEnergy::EFGlobalEnergy const std::string &  name,
ISvcLocator *  pSvcLocator
 

00016                                                                               :
00017   IEFAlgorithm(name, pSvcLocator) {
00018   //declareProperty("OutputLevel",m_output = MSG::NIL);
00019   int output=(m_output%100000)/10000;
00020   MsgStream log(msgSvc(), name);
00021   msgSvc()->setOutputLevel(name,output);
00022   m_etot = new CriteriaItemValue;
00023   m_ebar = new CriteriaItemValue;
00024   m_eend = new CriteriaItemValue;
00025   m_ebal = new CriteriaItemValue;
00026 }

EFGlobalEnergy::~EFGlobalEnergy  )  [virtual]
 

00028                                 {
00029   delete m_etot;
00030   delete m_ebar;
00031   delete m_eend;
00032   delete m_ebal;
00033 }

EFGlobalEnergy::EFGlobalEnergy const std::string &  name,
ISvcLocator *  pSvcLocator
 

virtual EFGlobalEnergy::~EFGlobalEnergy  )  [virtual]
 


Member Function Documentation

StatusCode EFGlobalEnergy::execute  ) 
 

StatusCode EFGlobalEnergy::execute  ) 
 

00081                                    {
00082 
00083   //cout<<"m_run="<<m_run<<endl;
00084   //reset();
00085 
00086   MsgStream log(msgSvc(), name());
00087   //DataObject*  pObject;
00088   float e1=0,e2=0;
00089   char* electron=getenv("BEPCII_INFO.BER_PRB");
00090   if(electron){
00091     e1=atof(electron);
00092   }
00093   else{
00094     log << MSG::ERROR << "Cannot get beam energy (e-)! Please call online people" << endreq;
00095   }
00096   char* positron=getenv("BEPCII_INFO.BPR_PRB");
00097   if(positron){
00098     e2=atof(positron);
00099   }
00100   else{
00101     log << MSG::ERROR << "Cannot get beam energy (e+)! Please call online people" << endreq;
00102   }
00103   if(e1>0&&e2>0&&m_beam>0) {
00104     m_beam = 0.5*(e1+e2);
00105   }
00106   else{
00107  
00108   }
00109   log << MSG::INFO << "beam energy = " << m_beam << endreq;
00110   
00111   // Part 1: Get the event header, print out event and run number
00112   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00113   if (!eventHeader) {
00114     log << MSG::FATAL << "Could not find Event Header" << endreq;
00115     return( StatusCode::FAILURE);
00116   }
00117 
00118   //Part 2: Retrieve Hits Collection 
00119   //vector<EmcDigi*>* emcDigiCol=0;
00120   bool calFlag=false;
00121   EmcDigiCol* emcDigiCol=0;
00122   if(m_rawDigiSvc){
00123     if(m_rawDigiSvc->isOnlineMode()){
00124       emcDigiCol=&(m_rawDigiSvc->getEmcDigiVec(EmcRawDataProvider::DropLow|EmcRawDataProvider::CutTime|EmcRawDataProvider::DropHot|EmcRawDataProvider::DropDead|EmcRawDataProvider::Redo));
00125       calFlag = true;
00126     }
00127   }
00128   if(!emcDigiCol){
00129     SmartDataPtr<EmcDigiCol> emcDigi(eventSvc(),"/Event/Digi/EmcDigiCol");
00130     if (!emcDigi) {
00131       log << MSG::FATAL << "Could not find Emc digi!!" << endreq;
00132       return( StatusCode::FAILURE);
00133     }
00134     //emcDigiCol=dynamic_cast<vector<EmcDigi*>*> (&emcDigi);
00135     emcDigiCol=emcDigi;
00136   }
00137   //Part 3:Calculate total deposited energy and energy balance 
00138   Identifier id;
00139   double adc,etot=0.,ebarrel=0.,eendcap=0.; 
00140   double energyx=0.,energyy=0.,energyz=0.;
00141   double ebalance;
00142   unsigned int idBarrel_Endcap,itheta,iphi;
00143   double ewest=0.,eeast=0.;
00144   //double tdc;
00145 
00146   EmcDigiCol::iterator iterEMC=emcDigiCol->begin();
00147   while(iterEMC!= emcDigiCol->end()) {
00148     id=(*iterEMC)->identify();
00149     idBarrel_Endcap=EmcID::barrel_ec(id);
00150     itheta=EmcID::theta_module(id);
00151     iphi=EmcID::phi_module(id);
00152     adc=RawDataUtil::EmcCharge((*iterEMC)->getMeasure(),(*iterEMC)->getChargeChannel());
00153     adc /= 1000. ; //Mev->GeV
00154     if(calFlag&&m_emcCalibConstSvc) {
00155       int index = m_emcCalibConstSvc->getIndex(idBarrel_Endcap,itheta,iphi);
00156       double adc2e = m_emcCalibConstSvc->getDigiCalibConst(index);
00157       adc *= adc2e;
00158     }
00159     //tdc=(*iterEMC)->getTimeChannel();            !not used
00160     etot += adc;
00161     double theta=0,phi=0;
00162     //Estimate hits position(theta,phi)
00163     if(idBarrel_Endcap==1){
00164       theta=(34.+112.*(itheta+0.5)/44.)/180.*3.1415926;
00165       phi=(iphi+0.5)/120.*6.2831852;
00166       ebarrel +=adc;
00167       if(itheta<22)  eeast+=adc;
00168       else           ewest+=adc;
00169     }
00170     else{
00171       theta=(90.+(90.-(itheta+0.5)/6.*(34.-21.56)+21.56)*(idBarrel_Endcap-1))
00172         /180.*3.1415926;
00173       if(itheta==0||itheta==1)phi=(iphi+0.5)/64.*6.2831852;
00174       if(itheta==2||itheta==3)phi=(iphi+0.5)/80.*6.2831852;
00175       if(itheta==4||itheta==5)phi=(iphi+0.5)/96.*6.2831852;
00176       eendcap +=adc;
00177       if(idBarrel_Endcap==0) {
00178         eeast+=adc;
00179       }
00180       else {
00181         ewest+=adc;
00182       }
00183     }
00184     energyx +=adc*sin(theta)*cos(phi);
00185     energyy +=adc*sin(theta)*sin(phi);
00186     energyz +=adc*cos(theta);
00187     //log << MSG::DEBUG << "Energy:" << idBarrel_Endcap <<","<<itheta << "," << iphi 
00188     //  << ":" << adc <<endreq;
00189     iterEMC++;
00190   }
00191   if(etot>0)
00192     ebalance=sqrt(energyx*energyx+energyy*energyy+energyz*energyz)/etot;
00193   else
00194     ebalance=0;
00195 
00196   log << MSG::INFO << "etot=" << etot << "(" << etot/2./abs(m_beam) << "); ebarrel=" <<ebarrel 
00197       <<"; eendcap="<<eendcap  <<"; ebalanece="<<ebalance<<endreq;
00198 
00199   //Part 4: Put the criteria item(s) to HltStoreSvc here
00200   m_etot->setValue(etot/2./abs(m_beam));
00201   m_ebar->setValue(ebarrel/2./abs(m_beam));
00202   m_eend->setValue(eendcap/2./abs(m_beam));
00203   m_ebal->setValue(ebalance);
00204 
00205   m_ef->appToEFVec(etot, 31);
00206   m_ef->appToEFVec(ebalance,34);
00207   m_ef->appToEFVec(ebarrel,32);
00208   m_ef->appToEFVec(eendcap,33);
00209   m_ef->appToEFVec(eeast,35);
00210   m_ef->appToEFVec(ewest,36);
00211   m_ef->setVecBit(true, 0, 1);
00212   m_ef->addToEFVec(7<<16,1);
00213   m_run=1;
00214 
00215   return StatusCode::SUCCESS;
00216 }

StatusCode EFGlobalEnergy::finalize  ) 
 

StatusCode EFGlobalEnergy::finalize  ) 
 

00218                                     {
00219   MsgStream log(msgSvc(), name());
00220   log << MSG::INFO << "in finalize()" << endmsg;
00221   return StatusCode::SUCCESS;
00222 }

virtual StatusCode EFGlobalEnergy::initialize  )  [virtual]
 

Reimplemented from IEFAlgorithm.

StatusCode EFGlobalEnergy::initialize  )  [virtual]
 

Reimplemented from IEFAlgorithm.

00035                                      {
00036 
00037   MsgStream log(msgSvc(), name());
00038   log << MSG::INFO << "in initialize()" << endreq;
00039 
00040   IEFAlgorithm::initialize();
00041 
00042   StatusCode sc;
00043   sc = m_HltStoreSvc->put("etot", m_etot);
00044   if ( sc.isFailure() ) {
00045     log << MSG::ERROR << "m_HltStoreSvc->put(etot) wrong" << endreq;
00046     return sc;
00047   }
00048   sc = m_HltStoreSvc->put("ebar", m_ebar);
00049   if ( sc.isFailure() ) {
00050     log << MSG::ERROR << "m_HltStoreSvc->put(ebar) wrong" << endreq;
00051     return sc;
00052   }
00053   sc = m_HltStoreSvc->put("eend", m_eend);
00054   if ( sc.isFailure() ) {
00055     log << MSG::ERROR << "m_HltStoreSvc->put(eend) wrong" << endreq;
00056     return sc;
00057   }
00058   sc = m_HltStoreSvc->put("ebal", m_ebal);
00059   if ( sc.isFailure() ) {
00060     log << MSG::ERROR << "m_HltStoreSvc->put(ebal) wrong" << endreq;
00061     return sc;
00062   }
00063 
00064   sc = service("EmcCalibConstSvc", m_emcCalibConstSvc);
00065   if(sc != StatusCode::SUCCESS) {
00066     log << MSG::ERROR << "Can't get EmcCalibConstSvc." << endreq;
00067     m_emcCalibConstSvc=0;
00068   }
00069 
00070   if(m_rawDigiSvc){
00071     if(m_rawDigiSvc->isOnlineMode()){
00072       char cbeam[20];
00073       sprintf(cbeam,"%f", m_beam);
00074       setenv("BEPCII_INFO.BER_PRB",cbeam,0);
00075       setenv("BEPCII_INFO.BPR_PRB",cbeam,0);
00076     }
00077   }
00078   return sc;
00079 }

void EFGlobalEnergy::reset  )  [virtual]
 

Implements IEFAlgorithm.

void EFGlobalEnergy::reset  )  [virtual]
 

Implements IEFAlgorithm.

00224                            {
00225   
00226   if(m_run) {
00227     m_etot->reset();
00228     m_ebar->reset();
00229     m_eend->reset();
00230     m_ebal->reset();
00231     m_run=0;
00232   }
00233   return;
00234 }


Member Data Documentation

float IEFAlgorithm::m_beam [protected, inherited]
 

CriteriaItemValue* EFGlobalEnergy::m_ebal [private]
 

CriteriaItemValue* EFGlobalEnergy::m_ebal [private]
 

CriteriaItemValue* EFGlobalEnergy::m_ebar [private]
 

CriteriaItemValue* EFGlobalEnergy::m_ebar [private]
 

CriteriaItemValue* EFGlobalEnergy::m_eend [private]
 

CriteriaItemValue* EFGlobalEnergy::m_eend [private]
 

EFResult* IEFAlgorithm::m_ef [protected, inherited]
 

EFResult* IEFAlgorithm::m_ef [protected, inherited]
 

IEmcCalibConstSvc* EFGlobalEnergy::m_emcCalibConstSvc [private]
 

IEmcCalibConstSvc* EFGlobalEnergy::m_emcCalibConstSvc [private]
 

CriteriaItemValue* EFGlobalEnergy::m_etot [private]
 

CriteriaItemValue* EFGlobalEnergy::m_etot [private]
 

HltStoreSvc* IEFAlgorithm::m_HltStoreSvc [protected, inherited]
 

HltStoreSvc* IEFAlgorithm::m_HltStoreSvc [protected, inherited]
 

int IEFAlgorithm::m_output [protected, inherited]
 

PropertyMgr IEFAlgorithm::m_propMgr [protected, inherited]
 

IRawDataProviderSvc* IEFAlgorithm::m_rawDigiSvc [protected, inherited]
 

IRawDataProviderSvc* IEFAlgorithm::m_rawDigiSvc [protected, inherited]
 

bool IEFAlgorithm::m_run [protected, inherited]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:00:54 2011 for BOSS6.5.5 by  doxygen 1.3.9.1