258{
259 MsgStream log(
msgSvc(), name());
260 log << MSG::INFO << "in execute()" << endreq;
261
262 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
263 if (!eventHeader)
264 {
265 log << MSG::FATAL << "Could not find Event Header" << endreq;
266 return StatusCode::FAILURE;
267 }
268
269 cout << "" << endl;
270 cout << "Event: " << eventHeader->eventNumber() << endl;
271 int iEvt = eventHeader->eventNumber();
272 int iRun = eventHeader->runNumber();
273
274 m_run = iRun;
275 m_evt = iEvt;
276 cout<<" Run : "<<m_run<<"Event : "<<m_evt<<endl;
277
278 if (m_F_McTruth == 1)
279 {
280 SmartDataPtr<Event::CgemMcHitCol> lv_CgemMcHitCol(eventSvc(), "/Event/MC/CgemMcHitCol");
281 if (!lv_CgemMcHitCol)
282 {
283 log << MSG::WARNING << "Could not find event" << endreq;
284 return StatusCode::FAILURE;
285 }
286
287 Event::CgemMcHitCol::iterator iter_truth = lv_CgemMcHitCol->begin();
288 int i=0;
289 for(; iter_truth != lv_CgemMcHitCol->end(); ++iter_truth)
290 {
291 m_output_McTruth << left << setw( 5) << (*iter_truth)->GetTrackID()
292 << left << setw( 3) << (*iter_truth)->GetLayerID()
293 << left << setw(12) << (*iter_truth)->GetTotalEnergyDeposit()
294 << left << setw(12) << (*iter_truth)->GetPositionXOfPrePoint()
295 << left << setw(12) << (*iter_truth)->GetPositionYOfPrePoint()
296 << left << setw(12) << (*iter_truth)->GetPositionZOfPrePoint()
297 << left << setw(12) << (*iter_truth)->GetPositionXOfPostPoint()
298 << left << setw(12) << (*iter_truth)->GetPositionYOfPostPoint()
299 << left << setw(12) << (*iter_truth)->GetPositionZOfPostPoint()
300 << left << setw(12) << (*iter_truth)->GetMomentumXOfPrePoint()
301 << left << setw(12) << (*iter_truth)->GetMomentumYOfPrePoint()
302 << left << setw(12) << (*iter_truth)->GetMomentumZOfPrePoint()
303 << left << setw(12) << (*iter_truth)->GetMomentumXOfPostPoint()
304 << left << setw(12) << (*iter_truth)->GetMomentumYOfPostPoint()
305 << left << setw(12) << (*iter_truth)->GetMomentumZOfPostPoint()
306 << endl;
307
308
309 m_mc_ID_track[i]=(*iter_truth)->GetTrackID();
310 m_mc_ID_layer[i]=(*iter_truth)->GetLayerID();
311 m_mc_E_deposit[i]=(*iter_truth)->GetTotalEnergyDeposit();
312 m_mc_XYZ_pre_X[i] =(*iter_truth)->GetPositionXOfPrePoint() ;
313 m_mc_XYZ_pre_Y[i] =(*iter_truth)->GetPositionYOfPrePoint() ;
314 m_mc_XYZ_pre_Z[i] =(*iter_truth)->GetPositionZOfPrePoint() ;
315 m_mc_XYZ_post_X[i]=(*iter_truth)->GetPositionXOfPostPoint();
316 m_mc_XYZ_post_Y[i]=(*iter_truth)->GetPositionYOfPostPoint();
317 m_mc_XYZ_post_Z[i]=(*iter_truth)->GetPositionZOfPostPoint();
318 m_mc_P_pre_X[i]=(*iter_truth)->GetMomentumXOfPrePoint() ;
319 m_mc_P_pre_Y[i]=(*iter_truth)->GetMomentumYOfPrePoint() ;
320 m_mc_P_pre_Z[i]=(*iter_truth)->GetMomentumZOfPrePoint() ;
321 m_mc_P_post_X[i]=(*iter_truth)->GetMomentumXOfPostPoint();
322 m_mc_P_post_Y[i]=(*iter_truth)->GetMomentumYOfPostPoint();
323 m_mc_P_post_Z[i]=(*iter_truth)->GetMomentumZOfPostPoint();
324 i++;
325 }
326
327 m_mc_nHit=i;
328 cout<<" mc_Hit "<<m_mc_nHit<<endl;
329 mc_tuple->write();
330 }
331
332
333 if (m_F_Digi == 1)
334 {
335 SmartDataPtr<CgemDigiCol> lv_CgemDigiCol(eventSvc(),"/Event/Digi/CgemDigiCol");
336
337 if ( !lv_CgemDigiCol )
338 {
339 log << MSG::WARNING << "Could not find event" << endreq;
340 return StatusCode::FAILURE;
341 }
342
343 CgemDigiCol::iterator iter_digi = lv_CgemDigiCol->begin();
345 int j = 0,x_flag;
346 int m_X=0,m_V=0;
347 bool xflag;
348 for( ; iter_digi != lv_CgemDigiCol->end(); ++iter_digi)
349 {
350 x_flag = 0;
351 m_output_Digi << left << setw( 8) << (*iter_digi)->getTrackIndex()
352 << left << setw( 8) <<
CgemID::layer((*iter_digi)->identify())
353 << left << setw( 8) <<
CgemID::sheet((*iter_digi)->identify())
354 << left << setw( 8) <<
CgemID::strip((*iter_digi)->identify())
355 << left << setw(16) << (*iter_digi)->getTimeChannel()
356 << left << setw(16) << (*iter_digi)->getChargeChannel()
357 << endl;
358 xflag=cgemid->
is_xstrip((*iter_digi)->identify());
359
360
361
362
363
364
365
366
367 m_ID_track[j]=(*iter_digi)->getTrackIndex();
371 m_globle_time[j]= (*iter_digi)->getTimeChannel();
372 m_E_deposit[j]= (*iter_digi)->getChargeChannel();
373 j++;
374 if (xflag){
375 m_E_X[m_X]=(*iter_digi)->getChargeChannel();
376 m_X++;
377 }
378 else{
379 m_E_V[m_V]=(*iter_digi)->getChargeChannel();
380 m_V++;
381 }
382
383 }
384 m_nHit=j;
385 m_Xnstrip=m_X;
386 m_Vnstrip=m_V;
387
388
389
390 m_tuple->write();
391 }
392
393 if (m_F_McParticle == 1 )
394 {
395 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
396 if (!mcParticleCol)
397 {
398 cout<< "Could not retrieve McParticelCol" << endl;
399 }
400
401 Event::McParticleCol::iterator iter_mcP = mcParticleCol->begin();
402 int ii=0;
403 for (; iter_mcP != mcParticleCol->end(); iter_mcP++)
404 {
405 m_trkindex[ii]=(*iter_mcP)->trackIndex();
406 m_mcParticle_x[ii]=((*iter_mcP)->initialPosition()).x();
407 m_mcParticle_y[ii]=((*iter_mcP)->initialPosition()).y();
408 m_mcParticle_z[ii]=((*iter_mcP)->initialPosition()).z();
409 m_mcParticle_px[ii]=((*iter_mcP)->initialFourMomentum()).x();
410 m_mcParticle_py[ii]=((*iter_mcP)->initialFourMomentum()).y();
411 m_mcParticle_pz[ii]=((*iter_mcP)->initialFourMomentum()).z();
412 m_mcParticle_E[ii]=((*iter_mcP)->initialFourMomentum()).e();
413 m_mcParticle_phi[ii]=((*iter_mcP)->initialFourMomentum()).phi();
414 m_mcParticle_costheta[ii]=((*iter_mcP)->initialFourMomentum()).cosTheta();
415 m_mcParticle_theta[ii]=((*iter_mcP)->initialFourMomentum()).theta();
416 m_mcParticle_pt[ii]=(((*iter_mcP)->initialFourMomentum()).mag())*
sin(m_mcParticle_theta[ii]);
417
418 m_output_McParticle << left << setw( 8) << (*iter_mcP)->trackIndex()
419 <<left<<setw(10)<<((*iter_mcP)->initialPosition()).x()
420 <<left<<setw(10)<<((*iter_mcP)->initialPosition()).y()
421 <<left<<setw(10)<<((*iter_mcP)->initialPosition()).z()
422 <<left<<setw(10)<<((*iter_mcP)->initialFourMomentum()).px()
423 <<left<<setw(10)<<((*iter_mcP)->initialFourMomentum()).py()
424 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).pz()
425 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).e()
426 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).phi()
427 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).cosTheta()
428 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).theta()
429 <<left<<setw(12)<<m_mcParticle_pt[ii]
430 <<endl;
431
432 ofstream outoneevt("evtput.txt",ios::app);
433
434 outoneevt<<left<<setw(7)<<m_evt
435
436
437 <<left << setw( 5) << (*iter_mcP)->trackIndex()
438 <<left<<setw(10)<<((*iter_mcP)->initialPosition()).x()
439 <<left<<setw(10)<<((*iter_mcP)->initialPosition()).y()
440 <<left<<setw(10)<<((*iter_mcP)->initialPosition()).z()
441 <<left<<setw(10)<<((*iter_mcP)->initialFourMomentum()).px()
442 <<left<<setw(10)<<((*iter_mcP)->initialFourMomentum()).py()
443 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).pz()
444 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).e()
445 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).phi()
446 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).cosTheta()
447 <<left<<setw(12)<<((*iter_mcP)->initialFourMomentum()).theta()
448 <<left<<setw(12)<<m_mcParticle_pt[ii]
449 <<endl;
450 outoneevt.close();
451
452 ii++;
453 }
454 Nparticle=ii;
455 mcP_tuple->write();
456 }
457 return StatusCode::SUCCESS;
458}
double sin(const BesAngle a)
static int strip(const Identifier &id)
static int sheet(const Identifier &id)
static int layer(const Identifier &id)
static bool is_xstrip(const Identifier &id)