EFGlobalEnergy Class Reference

#include <EFGlobalEnergy.h>

Inheritance diagram for EFGlobalEnergy:

IEFAlgorithm List of all members.

Public Member Functions

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

Protected Attributes

int m_output
float m_beam
PropertyMgr m_propMgr
bool m_run
HltStoreSvcm_HltStoreSvc
IRawDataProviderSvcm_rawDigiSvc
EFResultm_ef

Private Attributes

CriteriaItemValuem_etot
CriteriaItemValuem_ebar
CriteriaItemValuem_eend
CriteriaItemValuem_ebal
IEmcCalibConstSvcm_emcCalibConstSvc

Detailed Description

Definition at line 16 of file EFGlobalEnergy.h.


Constructor & Destructor Documentation

EFGlobalEnergy::EFGlobalEnergy ( const std::string name,
ISvcLocator *  pSvcLocator 
)

Definition at line 16 of file EFGlobalEnergy.cxx.

References m_ebal, m_ebar, m_eend, m_etot, IEFAlgorithm::m_output, msgSvc(), and output.

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]

Definition at line 28 of file EFGlobalEnergy.cxx.

References m_ebal, m_ebar, m_eend, and m_etot.

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


Member Function Documentation

StatusCode EFGlobalEnergy::execute (  ) 

Definition at line 81 of file EFGlobalEnergy.cxx.

References abs, EFResult::addToEFVec(), EFResult::appToEFVec(), EmcID::barrel_ec(), cos(), EmcRawDataProvider::CutTime, Bes_Common::DEBUG, EmcRawDataProvider::DropDead, EmcRawDataProvider::DropHot, EmcRawDataProvider::DropLow, electron, RawDataUtil::EmcCharge(), calibUtil::ERROR, Bes_Common::FATAL, IEmcCalibConstSvc::getDigiCalibConst(), IRawDataProviderSvc::getEmcDigiVec(), IEmcCalibConstSvc::getIndex(), Bes_Common::INFO, IRawDataProviderSvc::isOnlineMode(), IEFAlgorithm::m_beam, m_ebal, m_ebar, m_eend, IEFAlgorithm::m_ef, m_emcCalibConstSvc, m_etot, IEFAlgorithm::m_rawDigiSvc, IEFAlgorithm::m_run, msgSvc(), EmcID::phi_module(), positron, EmcRawDataProvider::Redo, CriteriaItemValue::setValue(), EFResult::setVecBit(), sin(), and EmcID::theta_module().

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.1&&e2>0.1&&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       log << MSG::DEBUG << "adc= " << adc << " and calibration constant: " << adc2e << " at " << idBarrel_Endcap << " " << itheta << " " << iphi << endreq;
00158       adc *= adc2e;
00159     }
00160     //tdc=(*iterEMC)->getTimeChannel();            !not used
00161     etot += adc;
00162     double theta=0,phi=0;
00163     //Estimate hits position(theta,phi)
00164     if(idBarrel_Endcap==1){
00165       theta=(34.+112.*(itheta+0.5)/44.)/180.*3.1415926;
00166       phi=(iphi+0.5)/120.*6.2831852;
00167       ebarrel +=adc;
00168       if(itheta<22)  eeast+=adc;
00169       else           ewest+=adc;
00170     }
00171     else{
00172       theta=(90.+(90.-(itheta+0.5)/6.*(34.-21.56)+21.56)*(idBarrel_Endcap-1))
00173         /180.*3.1415926;
00174       if(itheta==0||itheta==1)phi=(iphi+0.5)/64.*6.2831852;
00175       if(itheta==2||itheta==3)phi=(iphi+0.5)/80.*6.2831852;
00176       if(itheta==4||itheta==5)phi=(iphi+0.5)/96.*6.2831852;
00177       eendcap +=adc;
00178       if(idBarrel_Endcap==0) {
00179         eeast+=adc;
00180       }
00181       else {
00182         ewest+=adc;
00183       }
00184     }
00185     energyx +=adc*sin(theta)*cos(phi);
00186     energyy +=adc*sin(theta)*sin(phi);
00187     energyz +=adc*cos(theta);
00188     //log << MSG::DEBUG << "Energy:" << idBarrel_Endcap <<","<<itheta << "," << iphi 
00189     //  << ":" << adc <<endreq;
00190     iterEMC++;
00191   }
00192   if(etot>0)
00193     ebalance=sqrt(energyx*energyx+energyy*energyy+energyz*energyz)/etot;
00194   else
00195     ebalance=0;
00196 
00197   log << MSG::INFO << "etot=" << etot << "(" << etot/2./abs(m_beam) << "); ebarrel=" <<ebarrel 
00198       <<"; eendcap="<<eendcap  <<"; ebalanece="<<ebalance<<endreq;
00199 
00200   //Part 4: Put the criteria item(s) to HltStoreSvc here
00201   m_etot->setValue(etot/2./abs(m_beam));
00202   m_ebar->setValue(ebarrel/2./abs(m_beam));
00203   m_eend->setValue(eendcap/2./abs(m_beam));
00204   m_ebal->setValue(ebalance);
00205 
00206   m_ef->appToEFVec(etot, 31);
00207   m_ef->appToEFVec(ebalance,34);
00208   m_ef->appToEFVec(ebarrel,32);
00209   m_ef->appToEFVec(eendcap,33);
00210   m_ef->appToEFVec(eeast,35);
00211   m_ef->appToEFVec(ewest,36);
00212   m_ef->setVecBit(true, 0, 1);
00213   m_ef->addToEFVec(7<<16,1);
00214   m_run=1;
00215 
00216   return StatusCode::SUCCESS;
00217 }

StatusCode EFGlobalEnergy::finalize (  ) 

Definition at line 219 of file EFGlobalEnergy.cxx.

References Bes_Common::INFO, and msgSvc().

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

StatusCode EFGlobalEnergy::initialize (  )  [virtual]

Reimplemented from IEFAlgorithm.

Definition at line 35 of file EFGlobalEnergy.cxx.

References cbeam, calibUtil::ERROR, Bes_Common::INFO, IEFAlgorithm::initialize(), IRawDataProviderSvc::isOnlineMode(), IEFAlgorithm::m_beam, m_ebal, m_ebar, m_eend, m_emcCalibConstSvc, m_etot, IEFAlgorithm::m_HltStoreSvc, IEFAlgorithm::m_rawDigiSvc, msgSvc(), and HltStoreSvc::put().

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.

Definition at line 225 of file EFGlobalEnergy.cxx.

References m_ebal, m_ebar, m_eend, m_etot, IEFAlgorithm::m_run, and CriteriaItemValue::reset().

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


Member Data Documentation

float IEFAlgorithm::m_beam [protected, inherited]

Definition at line 17 of file IEFAlgorithm.h.

Referenced by EFProcessCluster::execute(), execute(), IEFAlgorithm::IEFAlgorithm(), and initialize().

CriteriaItemValue* EFGlobalEnergy::m_ebal [private]

Definition at line 29 of file EFGlobalEnergy.h.

Referenced by EFGlobalEnergy(), execute(), initialize(), reset(), and ~EFGlobalEnergy().

CriteriaItemValue* EFGlobalEnergy::m_ebar [private]

Definition at line 27 of file EFGlobalEnergy.h.

Referenced by EFGlobalEnergy(), execute(), initialize(), reset(), and ~EFGlobalEnergy().

CriteriaItemValue* EFGlobalEnergy::m_eend [private]

Definition at line 28 of file EFGlobalEnergy.h.

Referenced by EFGlobalEnergy(), execute(), initialize(), reset(), and ~EFGlobalEnergy().

EFResult* IEFAlgorithm::m_ef [protected, inherited]

Definition at line 22 of file IEFAlgorithm.h.

Referenced by EFSectorHits::execute(), EFProcessCluster::execute(), execute(), EFFlightTime::execute(), EFDetectorHits::execute(), EFChargedTrack::execute(), and IEFAlgorithm::initialize().

IEmcCalibConstSvc* EFGlobalEnergy::m_emcCalibConstSvc [private]

Definition at line 31 of file EFGlobalEnergy.h.

Referenced by execute(), and initialize().

CriteriaItemValue* EFGlobalEnergy::m_etot [private]

Definition at line 26 of file EFGlobalEnergy.h.

Referenced by EFGlobalEnergy(), execute(), initialize(), reset(), and ~EFGlobalEnergy().

HltStoreSvc* IEFAlgorithm::m_HltStoreSvc [protected, inherited]

Definition at line 20 of file IEFAlgorithm.h.

Referenced by EFSectorHits::execute(), IEFAlgorithm::initialize(), EFSectorHits::initialize(), EFProcessCluster::initialize(), initialize(), EFFlightTime::initialize(), EFDetectorHits::initialize(), and EFChargedTrack::initialize().

int IEFAlgorithm::m_output [protected, inherited]

Definition at line 16 of file IEFAlgorithm.h.

Referenced by EFChargedTrack::EFChargedTrack(), EFDetectorHits::EFDetectorHits(), EFFlightTime::EFFlightTime(), EFGlobalEnergy(), EFProcessCluster::EFProcessCluster(), EFSectorHits::EFSectorHits(), and IEFAlgorithm::IEFAlgorithm().

PropertyMgr IEFAlgorithm::m_propMgr [protected, inherited]

Definition at line 18 of file IEFAlgorithm.h.

Referenced by IEFAlgorithm::IEFAlgorithm().

IRawDataProviderSvc* IEFAlgorithm::m_rawDigiSvc [protected, inherited]

Definition at line 21 of file IEFAlgorithm.h.

Referenced by execute(), EFFlightTime::execute(), EFDetectorHits::execute(), IEFAlgorithm::initialize(), and initialize().

bool IEFAlgorithm::m_run [protected, inherited]

Definition at line 19 of file IEFAlgorithm.h.

Referenced by EFSectorHits::execute(), EFProcessCluster::execute(), execute(), EFFlightTime::execute(), EFDetectorHits::execute(), EFChargedTrack::execute(), IEFAlgorithm::initialize(), EFSectorHits::reset(), EFProcessCluster::reset(), reset(), EFFlightTime::reset(), EFDetectorHits::reset(), and EFChargedTrack::reset().


Generated on Tue Nov 29 23:18:36 2016 for BOSS_7.0.2 by  doxygen 1.4.7