BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EFGlobalEnergy Class Reference

#include <EFGlobalEnergy.h>

Inheritance diagram for EFGlobalEnergy:

Public Member Functions

 EFGlobalEnergy (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~EFGlobalEnergy ()
virtual StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
void reset ()
Public Member Functions inherited from IEFAlgorithm
 IEFAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~IEFAlgorithm ()

Additional Inherited Members

Protected Attributes inherited from IEFAlgorithm
int m_output
float m_beam
PropertyMgr m_propMgr
bool m_run
HltStoreSvcm_HltStoreSvc
IRawDataProviderSvcm_rawDigiSvc
EFResultm_ef

Detailed Description

Definition at line 16 of file EFGlobalEnergy.h.

Constructor & Destructor Documentation

◆ EFGlobalEnergy()

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

Definition at line 16 of file EFGlobalEnergy.cxx.

17 : IEFAlgorithm( name, pSvcLocator ) {
18 // declareProperty("OutputLevel",m_output = MSG::NIL);
19 int output = ( m_output % 100000 ) / 10000;
20 MsgStream log( msgSvc(), name );
21 msgSvc()->setOutputLevel( name, output );
22 m_etot = new CriteriaItemValue;
23 m_ebar = new CriteriaItemValue;
24 m_eend = new CriteriaItemValue;
25 m_ebal = new CriteriaItemValue;
26}
*******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
Definition FoamA.h:89
IMessageSvc * msgSvc()
IEFAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)

◆ ~EFGlobalEnergy()

EFGlobalEnergy::~EFGlobalEnergy ( )
virtual

Definition at line 28 of file EFGlobalEnergy.cxx.

28 {
29 delete m_etot;
30 delete m_ebar;
31 delete m_eend;
32 delete m_ebal;
33}

Member Function Documentation

◆ execute()

StatusCode EFGlobalEnergy::execute ( )

Definition at line 88 of file EFGlobalEnergy.cxx.

88 {
89
90 // cout<<"m_run="<<m_run<<endl;
91 // reset();
92
93 MsgStream log( msgSvc(), name() );
94 // DataObject* pObject;
95 float e1 = 0, e2 = 0;
96 char* electron = getenv( "BEPCII_INFO.BER_PRB" );
97 if ( electron ) { e1 = atof( electron ); }
98 else
99 { log << MSG::ERROR << "Cannot get beam energy (e-)! Please call online people" << endmsg; }
100 char* positron = getenv( "BEPCII_INFO.BPR_PRB" );
101 if ( positron ) { e2 = atof( positron ); }
102 else
103 { log << MSG::ERROR << "Cannot get beam energy (e+)! Please call online people" << endmsg; }
104 if ( e1 > 0.1 && e2 > 0.1 && m_beam > 0 ) { m_beam = 0.5 * ( e1 + e2 ); }
105 else {}
106 log << MSG::INFO << "beam energy = " << m_beam << endmsg;
107
108 // Part 1: Get the event header, print out event and run number
109 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
110 if ( !eventHeader )
111 {
112 log << MSG::FATAL << "Could not find Event Header" << endmsg;
113 return ( StatusCode::FAILURE );
114 }
115
116 // Part 2: Retrieve Hits Collection
117 // vector<EmcDigi*>* emcDigiCol=0;
118 bool calFlag = false;
119 EmcDigiCol* emcDigiCol = 0;
120 if ( m_rawDigiSvc )
121 {
122 if ( m_rawDigiSvc->isOnlineMode() )
123 {
124 emcDigiCol = &( m_rawDigiSvc->getEmcDigiVec(
128 calFlag = true;
129 }
130 }
131 if ( !emcDigiCol )
132 {
133 SmartDataPtr<EmcDigiCol> emcDigi( eventSvc(), "/Event/Digi/EmcDigiCol" );
134 if ( !emcDigi )
135 {
136 log << MSG::FATAL << "Could not find Emc digi!!" << endmsg;
137 return ( StatusCode::FAILURE );
138 }
139 // emcDigiCol=dynamic_cast<vector<EmcDigi*>*> (&emcDigi);
140 emcDigiCol = emcDigi;
141 }
142 // Part 3:Calculate total deposited energy and energy balance
143 Identifier id;
144 double adc, etot = 0., ebarrel = 0., eendcap = 0.;
145 double energyx = 0., energyy = 0., energyz = 0.;
146 double ebalance;
147 unsigned int idBarrel_Endcap, itheta, iphi;
148 double ewest = 0., eeast = 0.;
149 // double tdc;
150
151 EmcDigiCol::iterator iterEMC = emcDigiCol->begin();
152 while ( iterEMC != emcDigiCol->end() )
153 {
154 id = ( *iterEMC )->identify();
155 idBarrel_Endcap = EmcID::barrel_ec( id );
156 itheta = EmcID::theta_module( id );
157 iphi = EmcID::phi_module( id );
158 adc =
159 RawDataUtil::EmcCharge( ( *iterEMC )->getMeasure(), ( *iterEMC )->getChargeChannel() );
160 adc /= 1000.; // Mev->GeV
161 if ( !calFlag && m_emcCalibConstSvc )
162 {
163 int index = m_emcCalibConstSvc->getIndex( idBarrel_Endcap, itheta, iphi );
164 double adc2e = m_emcCalibConstSvc->getDigiCalibConst( index );
165 log << MSG::DEBUG << "adc= " << adc << " and calibration constant: " << adc2e << " at "
166 << idBarrel_Endcap << " " << itheta << " " << iphi << endmsg;
167 adc *= adc2e;
168 }
169 // tdc=(*iterEMC)->getTimeChannel(); !not used
170 etot += adc;
171 double theta = 0, phi = 0;
172 // Estimate hits position(theta,phi)
173 if ( idBarrel_Endcap == 1 )
174 {
175 theta = ( 34. + 112. * ( itheta + 0.5 ) / 44. ) / 180. * 3.1415926;
176 phi = ( iphi + 0.5 ) / 120. * 6.2831852;
177 ebarrel += adc;
178 if ( itheta < 22 ) eeast += adc;
179 else ewest += adc;
180 }
181 else
182 {
183 theta = ( 90. + ( 90. - ( itheta + 0.5 ) / 6. * ( 34. - 21.56 ) + 21.56 ) *
184 ( idBarrel_Endcap - 1 ) ) /
185 180. * 3.1415926;
186 if ( itheta == 0 || itheta == 1 ) phi = ( iphi + 0.5 ) / 64. * 6.2831852;
187 if ( itheta == 2 || itheta == 3 ) phi = ( iphi + 0.5 ) / 80. * 6.2831852;
188 if ( itheta == 4 || itheta == 5 ) phi = ( iphi + 0.5 ) / 96. * 6.2831852;
189 eendcap += adc;
190 if ( idBarrel_Endcap == 0 ) { eeast += adc; }
191 else { ewest += adc; }
192 }
193 energyx += adc * sin( theta ) * cos( phi );
194 energyy += adc * sin( theta ) * sin( phi );
195 energyz += adc * cos( theta );
196 // log << MSG::DEBUG << "Energy:" << idBarrel_Endcap <<","<<itheta << "," << iphi
197 // << ":" << adc <<endmsg;
198 iterEMC++;
199 }
200 if ( etot > 0 )
201 ebalance = sqrt( energyx * energyx + energyy * energyy + energyz * energyz ) / etot;
202 else ebalance = 0;
203
204 log << MSG::INFO << "etot=" << etot << "(" << etot / 2. / abs( m_beam )
205 << "); ebarrel=" << ebarrel << "; eendcap=" << eendcap << "; ebalanece=" << ebalance
206 << endmsg;
207
208 // Part 4: Put the criteria item(s) to HltStoreSvc here
209 m_etot->setValue( etot / 2. / abs( m_beam ) );
210 m_ebar->setValue( ebarrel / 2. / abs( m_beam ) );
211 m_eend->setValue( eendcap / 2. / abs( m_beam ) );
212 m_ebal->setValue( ebalance );
213
214 m_ef->appToEFVec( etot, 31 );
215 m_ef->appToEFVec( ebalance, 34 );
216 m_ef->appToEFVec( ebarrel, 32 );
217 m_ef->appToEFVec( eendcap, 33 );
218 m_ef->appToEFVec( eeast, 35 );
219 m_ef->appToEFVec( ewest, 36 );
220 m_ef->setVecBit( true, 0, 1 );
221 m_ef->addToEFVec( 7 << 16, 1 );
222 m_run = 1;
223
224 return StatusCode::SUCCESS;
225}
Double_t etot
Double_t e1
Double_t e2
ObjectVector< EmcDigi > EmcDigiCol
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
Definition EmcID.cxx:36
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:41
static unsigned int phi_module(const Identifier &id)
Definition EmcID.cxx:46
EFResult * m_ef
IRawDataProviderSvc * m_rawDigiSvc
static double EmcCharge(int measure, int chargeChannel)

◆ finalize()

StatusCode EFGlobalEnergy::finalize ( )

Definition at line 227 of file EFGlobalEnergy.cxx.

227 {
228 MsgStream log( msgSvc(), name() );
229 log << MSG::INFO << "in finalize()" << endmsg;
230 return StatusCode::SUCCESS;
231}

◆ initialize()

StatusCode EFGlobalEnergy::initialize ( )
virtual

Reimplemented from IEFAlgorithm.

Definition at line 35 of file EFGlobalEnergy.cxx.

35 {
36
37 MsgStream log( msgSvc(), name() );
38 log << MSG::INFO << "in initialize()" << endmsg;
39
41
42 StatusCode sc;
43 sc = m_HltStoreSvc->put( "etot", m_etot );
44 if ( sc.isFailure() )
45 {
46 log << MSG::ERROR << "m_HltStoreSvc->put(etot) wrong" << endmsg;
47 return sc;
48 }
49 sc = m_HltStoreSvc->put( "ebar", m_ebar );
50 if ( sc.isFailure() )
51 {
52 log << MSG::ERROR << "m_HltStoreSvc->put(ebar) wrong" << endmsg;
53 return sc;
54 }
55 sc = m_HltStoreSvc->put( "eend", m_eend );
56 if ( sc.isFailure() )
57 {
58 log << MSG::ERROR << "m_HltStoreSvc->put(eend) wrong" << endmsg;
59 return sc;
60 }
61 sc = m_HltStoreSvc->put( "ebal", m_ebal );
62 if ( sc.isFailure() )
63 {
64 log << MSG::ERROR << "m_HltStoreSvc->put(ebal) wrong" << endmsg;
65 return sc;
66 }
67
68 sc = service( "EmcCalibConstSvc", m_emcCalibConstSvc );
69 if ( sc != StatusCode::SUCCESS )
70 {
71 log << MSG::ERROR << "Can't get EmcCalibConstSvc." << endmsg;
72 m_emcCalibConstSvc = 0;
73 }
74
75 if ( m_rawDigiSvc )
76 {
77 if ( m_rawDigiSvc->isOnlineMode() )
78 {
79 char cbeam[20];
80 sprintf( cbeam, "%f", m_beam );
81 setenv( "BEPCII_INFO.BER_PRB", cbeam, 0 );
82 setenv( "BEPCII_INFO.BPR_PRB", cbeam, 0 );
83 }
84 }
85 return sc;
86}
double cbeam[56]
Definition AbsCor.cxx:52
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)
virtual StatusCode initialize()
HltStoreSvc * m_HltStoreSvc

◆ reset()

void EFGlobalEnergy::reset ( )
virtual

Implements IEFAlgorithm.

Definition at line 233 of file EFGlobalEnergy.cxx.

233 {
234
235 if ( m_run )
236 {
237 m_etot->reset();
238 m_ebar->reset();
239 m_eend->reset();
240 m_ebal->reset();
241 m_run = 0;
242 }
243 return;
244}

The documentation for this class was generated from the following files: