42 : Algorithm( name, pSvcLocator ) {
43 declareProperty(
"jpsiCrossSection", jpsiCrossSection = 249.7 );
44 declareProperty(
"jpsiMCEff", jpsiMCEff = 0.07145 );
45 declareProperty(
"jpsiMCEffBoost", jpsiMCEffBoost = 0.07099 );
47 declareProperty(
"psi2sCrossSection", psi2sCrossSection = 180.8 );
48 declareProperty(
"psi2sMCEff", psi2sMCEff = 0.07159 );
49 declareProperty(
"psi2sMCEffBoost", psi2sMCEffBoost = 0.07123 );
51 declareProperty(
"psi3770CrossSection", psi3770CrossSection = 173.4 );
52 declareProperty(
"psi3770MCEff", psi3770MCEff = 0.071725 );
53 declareProperty(
"psi3770MCEffBoost", psi3770MCEffBoost = 0.0713125 );
55 declareProperty(
"CrossSection", CrossSection );
56 declareProperty(
"MCEff", MCEff );
57 declareProperty(
"MCEffBoost", MCEffBoost );
59 declareProperty(
"boostPhimin", boostPhimin = 2.5 );
60 declareProperty(
"boostPhimax", boostPhimax = 5 );
61 declareProperty(
"boostMinEmin", boostMinEmin );
62 declareProperty(
"boostMinEmax", boostMinEmax );
64 declareProperty(
"RunModel", RunModel = 2000 );
65 declareProperty(
"dPhiMin", dPhiMin = -7 );
66 declareProperty(
"dPhiMax", dPhiMax = 5 );
67 declareProperty(
"dPhiMinSig", dPhiMinSig = -4 );
68 declareProperty(
"dPhiMaxSig", dPhiMaxSig = 2 );
70 declareProperty(
"flag", flag =
true );
71 declareProperty(
"E_cms", E_cms );
75 MsgStream log(
msgSvc(), name() );
76 log << MSG::INFO <<
"in initialize()" << endmsg;
80 CrossSection = jpsiCrossSection;
82 MCEffBoost = jpsiMCEffBoost;
88 else if ( RunModel == 2 )
90 CrossSection = psi2sCrossSection;
92 MCEffBoost = psi2sMCEffBoost;
98 else if ( RunModel == 3 )
100 CrossSection = psi3770CrossSection;
101 MCEff = psi3770MCEff;
102 MCEffBoost = psi3770MCEffBoost;
113 StatusCode ssc = service(
"THistSvc", m_thsvc );
114 if ( ssc.isFailure() )
116 log << MSG::FATAL <<
"DiGamAlg:Couldn't get THistSvc" << endmsg;
119 h_lum =
new TH1F(
"lum",
"lum", 4, 0.5, 4.5 );
121 StatusCode scBeamEnergy = service(
"BeamEnergySvc", m_BeamEnergySvc );
123 if ( scBeamEnergy.isFailure() )
125 log << MSG::FATAL <<
"can not use BeamEnergySvc" << endmsg;
131 NTuplePtr nt2(
ntupleSvc(),
"DQAFILE/zhsDiGam" );
132 if ( nt2 ) m_tuple2 = nt2;
136 ntupleSvc()->book(
"DQAFILE/zhsDiGam", CLID_ColumnWiseTuple,
"ks N-Tuple example" );
139 status = m_tuple2->addItem(
"ETol", m_tot );
140 status = m_tuple2->addItem(
"maxE", m_maxE );
141 status = m_tuple2->addItem(
"minE", m_minE );
142 status = m_tuple2->addItem(
"maxTheta", m_maxTheta );
143 status = m_tuple2->addItem(
"minTheta", m_minTheta );
144 status = m_tuple2->addItem(
"maxPhi", m_maxPhi );
145 status = m_tuple2->addItem(
"minPhi", m_minPhi );
146 status = m_tuple2->addItem(
"delTheta", m_delTheta );
147 status = m_tuple2->addItem(
"delPhi", m_delPhi );
148 status = m_tuple2->addItem(
"angle", m_angle );
149 status = m_tuple2->addItem(
"boostAngle", m_boostAngle );
150 status = m_tuple2->addItem(
"boostMaxE", m_boostMaxE );
151 status = m_tuple2->addItem(
"boostMinE", m_boostMinE );
152 status = m_tuple2->addItem(
"boostDelPhi", m_boostDelPhi );
153 status = m_tuple2->addItem(
"boostDelTheta", m_boostDelTheta );
154 status = m_tuple2->addItem(
"boostM", m_boostM );
155 status = m_tuple2->addItem(
"boostIM", m_boostIM );
156 status = m_tuple2->addItem(
"m", m_m );
157 status = m_tuple2->addItem(
"IM", m_IM );
159 status = m_tuple2->addItem(
"run", m_run );
160 status = m_tuple2->addItem(
"rec", m_rec );
161 status = m_tuple2->addItem(
"indexmc", m_idxmc, 0, 100 );
162 status = m_tuple2->addIndexedItem(
"pdgid", m_idxmc, m_pdgid );
163 status = m_tuple2->addIndexedItem(
"motheridx", m_idxmc, m_motheridx );
167 log << MSG::FATAL <<
"Cannot book N-tuple:" << long( m_tuple2 ) << endmsg;
168 return StatusCode::FAILURE;
172 return StatusCode::SUCCESS;
176 MsgStream log(
msgSvc(), name() );
177 log << MSG::INFO <<
"in execute()" << endmsg;
179 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
180 runNo = eventHeader->runNumber();
181 int event = eventHeader->eventNumber();
182 log << MSG::INFO <<
"run,evtnum=" << runNo <<
"," <<
event << endmsg;
183 m_run = eventHeader->runNumber();
184 m_rec = eventHeader->eventNumber();
189 log << MSG::DEBUG <<
"setting parameter" << endmsg;
191 m_BeamEnergySvc->getBeamEnergyInfo();
192 if ( !m_BeamEnergySvc->isRunValid() )
return StatusCode::FAILURE;
193 E_cms = 2 * m_BeamEnergySvc->getbeamE();
194 log << MSG::DEBUG <<
"cms energy is " << E_cms << endmsg;
205 log << MSG::DEBUG <<
"parameters: " << CrossSection <<
" " << MCEff << endmsg;
209 log << MSG::INFO <<
"ncharg,nneu,tottks=" << evtRecEvent->totalCharged() <<
","
210 << evtRecEvent->totalNeutral() <<
"," << evtRecEvent->totalTracks() << endmsg;
212 std::vector<int> iGam;
215 for (
int i = evtRecEvent->totalCharged(); i < evtRecEvent->totalTracks(); i++ )
218 if ( !( *itTrk )->isEmcShowerValid() )
continue;
220 if ( emcTrk->
energy() < 0.6 )
continue;
221 if ( fabs(
cos( emcTrk->
theta() ) ) > 0.83 )
continue;
222 iGam.push_back( ( *itTrk )->trackId() );
224 if ( iGam.size() < 2 )
return StatusCode::SUCCESS;
226 double energy1 = 0.5;
227 double energy2 = 0.5;
230 for (
int i = 0; i < iGam.size(); i++ )
235 if ( emcTrk->
energy() > energy1 )
239 energy1 = emcTrk->
energy();
242 else if ( emcTrk->
energy() > energy2 )
244 energy2 = emcTrk->
energy();
248 if ( gam1 == -9999 || gam2 == -9999 )
return StatusCode::SUCCESS;
250 m_tot = energy1 + energy2;
251 RecEmcShower* maxEmc = ( *( evtRecTrkCol->begin() + gam1 ) )->emcShower();
252 RecEmcShower* minEmc = ( *( evtRecTrkCol->begin() + gam2 ) )->emcShower();
253 m_maxE = maxEmc->
energy();
254 m_minE = minEmc->
energy();
255 m_maxTheta = maxEmc->
theta();
256 m_minTheta = minEmc->
theta();
257 m_maxPhi = maxEmc->
phi();
258 m_minPhi = minEmc->
phi();
259 m_delPhi = ( fabs( m_maxPhi - m_minPhi ) -
pai ) * 180. /
pai;
260 m_delTheta = ( fabs( m_maxTheta + m_minTheta ) -
pai ) * 180. /
pai;
262 HepLorentzVector
max,
min;
263 max.setPx( m_maxE *
sin( m_maxTheta ) *
cos( m_maxPhi ) );
264 max.setPy( m_maxE *
sin( m_maxTheta ) *
sin( m_maxPhi ) );
265 max.setPz( m_maxE *
cos( m_maxTheta ) );
267 min.setPx( m_minE *
sin( m_minTheta ) *
cos( m_minPhi ) );
268 min.setPy( m_minE *
sin( m_minTheta ) *
sin( m_minPhi ) );
269 min.setPz( m_minE *
cos( m_minTheta ) );
271 m_angle =
max.angle(
min.vect() ) * 180. /
pai;
273 m_IM =
max.invariantMass(
min );
275 if ( m_minE >= boostMinEmin && m_delPhi > dPhiMin && m_delPhi < dPhiMax &&
276 m_minE <= boostMinEmax )
278 if ( m_minE >= boostMinEmin && m_delPhi > dPhiMinSig && m_delPhi < dPhiMaxSig &&
279 m_minE <= boostMinEmax )
284 HepLorentzVector boost1 =
max.boost( -0.011, 0, 0 );
285 HepLorentzVector boost2 =
min.boost( -0.011, 0, 0 );
286 m_boostAngle = boost1.angle( boost2.vect() ) * 180. /
pai;
287 m_boostMaxE = boost1.e();
288 m_boostMinE = boost2.e();
289 m_boostDelPhi = ( fabs( boost1.phi() - boost2.phi() ) -
pai ) * 180. /
pai;
290 m_boostDelTheta = ( fabs( boost1.theta() + boost2.theta() ) -
pai ) * 180. /
pai;
291 m_boostM = ( boost1 + boost2 ).m();
292 m_boostIM = boost1.invariantMass( boost2 );
293 log << MSG::INFO <<
"num Good Photon " << iGam.size() << endmsg;
294 if ( m_boostMinE >= boostMinEmin && m_boostMinE <= boostMinEmax &&
295 fabs( m_boostDelPhi ) <= boostPhimin )
297 if ( m_boostMinE >= boostMinEmin && m_boostMinE <= boostMinEmax &&
298 fabs( m_boostDelPhi ) <= boostPhimax )
301 if ( eventHeader->runNumber() < 0 )
303 SmartDataPtr<Event::McParticleCol> mcParticleCol( eventSvc(),
"/Event/MC/McParticleCol" );
304 int m_numParticle = 0;
305 if ( !mcParticleCol )
308 return StatusCode::FAILURE;
312 bool jpsipDecay =
false;
314 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
315 for ( ; iter_mc != mcParticleCol->end(); iter_mc++ )
317 if ( ( *iter_mc )->primaryParticle() )
continue;
318 if ( !( *iter_mc )->decayFromGenerator() )
continue;
320 if ( ( *iter_mc )->particleProperty() == 443 )
323 rootIndex = ( *iter_mc )->trackIndex();
325 if ( !jpsipDecay )
continue;
326 int mcidx = ( ( *iter_mc )->mother() ).trackIndex() - rootIndex;
327 int pdgid = ( *iter_mc )->particleProperty();
328 m_pdgid[m_numParticle] = pdgid;
329 m_motheridx[m_numParticle] = mcidx;
333 m_idxmc = m_numParticle;
336 m_tuple2->write().ignore();
337 return StatusCode::SUCCESS;
341 MsgStream log(
msgSvc(), name() );
342 log << MSG::INFO <<
"in finalize()" << endmsg;
346 double boost_ssg = 0.;
347 double boost_lum = 0.;
349 if ( flag ==
false && ( CrossSection * MCEff == 0 || CrossSection * MCEffBoost == 0 ) )
351 log << MSG::FATAL <<
"DiGam Error: cross_section or MC_eff is not correct!" << endmsg;
356 ssg = ( signal - ( tot - signal ) ) * 1.0;
358 lum = ( ssg ) / ( CrossSection * MCEff );
360 boost_ssg = ( boost_signal - ( boost_tot - boost_signal ) ) * 1.0;
362 boost_lum = ( boost_ssg ) / ( CrossSection * MCEffBoost );
366 log << MSG::DEBUG <<
"E_cms = " << E_cms << endmsg;
368 log << MSG::DEBUG <<
"N0 = " <<
N0 << endmsg;
369 log << MSG::DEBUG <<
"minE, phi in:" << boostMinEmin <<
" ~ " << boostMinEmax <<
", "
370 << boostPhimin <<
" ~ " << boostPhimax << endmsg;
371 log << MSG::DEBUG <<
"sigma, eff = " << CrossSection <<
"," << MCEff << endmsg;
372 log << MSG::DEBUG <<
"sigma, effBoost = " << CrossSection <<
", " << MCEffBoost << endmsg;
373 log << MSG::DEBUG <<
"Nsignal, lum, Nsig_boost, boost_lum = " << ssg <<
", " <<
lum <<
", "
374 << boost_ssg <<
", " << boost_lum << endmsg;
375 h_lum->SetBinContent( 1,
lum );
376 h_lum->SetBinContent( 2, ssg );
377 h_lum->SetBinContent( 3, boost_lum );
378 h_lum->SetBinContent( 4, boost_ssg );
379 if ( m_thsvc->regHist(
"/DQAHist/zhsLUM/lum", h_lum ).isFailure() )
381 log << MSG::FATAL <<
"DiGam Error:can't write data to LUM!" << endmsg;
384 return StatusCode::SUCCESS;