11#include "BesCgemDigi.hh"
16#include "G4DigiManager.hh"
20#include "Randomize.hh"
22#include "GaudiKernel/IDataProviderSvc.h"
23#include "GaudiKernel/ISvcLocator.h"
24#include "GaudiKernel/Bootstrap.h"
25#include "GaudiKernel/RegistryEntry.h"
26#include "GaudiKernel/MsgStream.h"
43#include "GaudiKernel/SmartDataPtr.h"
48 m_DigiMan = G4DigiManager::GetDMpointer();
53 StatusCode sc=Gaudi::svcLocator()->service(
"CgemGeomSvc", ISvc);
55 G4cout <<
" BesRawDataWriter::Error,could not open CgemGeomSvc"<<G4endl;
59 sc=Gaudi::svcLocator()->service(
"G4Svc", tmpSvc);
61 G4cout <<
" BesRawDataWriter::Error,could not open G4Svc"<<G4endl;
62 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
65 StatusCode scReal = Gaudi::svcLocator()->service(
"RealizationSvc",tmpReal);
66 if (!scReal.isSuccess())
68 std::cout <<
" Could not initialize Realization Service in BesRawDataWriter" << std::endl;
84 ISvcLocator* svcLocator = Gaudi::svcLocator();
85 StatusCode sc=svcLocator->service(
"EventDataSvc", m_evtSvc);
87 G4cout<<
"Could not accesss EventDataSvc!"<<G4endl;
90 sc = m_evtSvc->registerObject(
"/Event/Digi",aDigiEvent);
91 if(sc!=StatusCode::SUCCESS) {
92 G4cout<<
"Could not register DigiEvent" <<G4endl;
107 G4int mdcDigiCollID = -1;
108 mdcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMdcDigisCollection");
112 G4int nDigi = mdcDC->entries();
117 for(
int i=0;i<nDigi;i++)
122 charge = int(mdcDigi->
GetEdep());
131 aMdcDigiCol->push_back(aMdcDigi);
137 StatusCode scMdc = m_evtSvc->registerObject(
"/Event/Digi/MdcDigiCol", aMdcDigiCol);
138 if(scMdc!=StatusCode::SUCCESS)
139 G4cout<<
"Could not register MDC digi collection" <<G4endl;
161 bool printFlag=
false;
163 G4cout <<
"|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" << G4endl;
164 G4cout <<
"INFO : BesSim::BesRawDataWriter::SaveCgemDigits(), Begin!" << G4endl;
170 G4int cgemDigiCollID = -1;
171 cgemDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesCgemDigisCollection");
172 if (cgemDigiCollID >= 0)
175 G4int nDigi = cgemDC->entries();
180 for(
int i=0;i<nDigi;i++)
182 cgemDigi=(*cgemDC)[i];
186 G4double frandom = G4UniformRand();
189 if(frandom > stripEff)
continue;
216 <<
" charge=" << charge
217 <<
" time_ns=" << T_in_ns
218 <<
" charge_fc=" << Q_in_fC << G4endl;
226 aCgemDigiCol->push_back(aCgemDigi);
233 StatusCode scCgem = m_evtSvc->registerObject(
"/Event/Digi/CgemDigiCol", aCgemDigiCol);
234 if(scCgem!=StatusCode::SUCCESS)
236 G4cout <<
"ERROR : BesSim::BesRawDataWriter::SaveCgemDigits(), Could not register CGEM digi collection! " << G4endl;
273 G4int tofDigiCollID = -1;
274 tofDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesTofDigitsCollection");
279 G4int nDigi = tofDC->entries();
286 vector<BesTofDigi*>* vecDC = tofDC->GetVector();
287 for(
int i=0;i<nDigi-1;i++)
288 for(
int j=i+1;j<nDigi;j++)
289 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
292 (*vecDC)[i] = (*vecDC)[j];
299 for(
int i=0;i<nDigi;i++)
318 unsigned int layer = 0;
320 unsigned int time =0;
325 if(barrel_ec == 0 || barrel_ec == 1 || barrel_ec == 2)
354 charge = (charge | 0x080000);
360 charge = ( (
time & 0x07e000) | charge) ;
368 if( charge & 0x80000 )
372 aTofDigiCol->push_back(tofDigi);
375 if(barrel_ec == 0 || barrel_ec == 1 || barrel_ec == 2)
402 charge = (charge | 0x080000);
404 charge = ( (
time & 0x07e000) | charge) ;
413 if( charge & 0x80000 )
417 aTofDigiCol->push_back(tofDigi);
430 else if(barrel_ec == 3 || barrel_ec == 4 || barrel_ec == 5 || barrel_ec == 6)
509 aTofDigiCol->push_back(tofDigi);
531 StatusCode scTof = m_evtSvc->registerObject(
"/Event/Digi/TofDigiCol", aTofDigiCol);
532 if(scTof!=StatusCode::SUCCESS)
533 G4cout<<
"Could not register TOF digi collection" <<G4endl;
563 G4int emcDigiCollID = -1;
564 emcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
568 G4int nDigi = emcDC->entries();
573 vector<BesEmcDigi*>* vecDC = emcDC->GetVector();
574 for(
int i=0;i<nDigi-1;i++)
575 for(
int j=i+1;j<nDigi;j++)
576 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
579 (*vecDC)[i] = (*vecDC)[j];
583 for(
int i=0;i<nDigi;i++)
594 aEmcDigiCol->push_back(emcDigi);
600 StatusCode scEmc = m_evtSvc->registerObject(
"/Event/Digi/EmcDigiCol", aEmcDigiCol);
601 if(scEmc!=StatusCode::SUCCESS)
602 G4cout<<
"Could not register EMC digi collection" <<G4endl;
628 G4int mucDigiCollID =-1;
629 mucDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMucDigisCollection");
633 G4int nDigi = mucDC->entries();
637 for(
int i = 0; i < nDigi; i++) {
642 aMucDigiCol->push_back(mucDigi);
648 StatusCode scMuc = m_evtSvc->registerObject(
"/Event/Digi/MucDigiCol", aMucDigiCol);
649 if(scMuc!=StatusCode::SUCCESS)
650 G4cout<<
"Could not register MUC digi collection" <<G4endl;
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
G4TDigiCollection< BesMucDigi > BesMucDigisCollection
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
ObjectVector< CgemDigi > CgemDigiCol
G4TDigiCollection< BesCgemDigi > BesCgemDigisCollection
ObjectVector< EmcDigi > EmcDigiCol
ObjectVector< MdcDigi > MdcDigiCol
ObjectVector< MucDigi > MucDigiCol
ObjectVector< TofDigi > TofDigiCol
G4double GetGlobalTime() const
G4double GetEnergyDeposit() const
G4int GetStripType() const
static BesMdcGeoParameter * GetGeo(void)
void setCharge_fc(double q)
void setTime_ns(double t)
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)
static Identifier strip_id(int f_layer, int f_sheet, int f_strip_type, int f_strip)
void setMeasure(const unsigned int measure)
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
value_type get_value() const
static Identifier wire_id(int wireType, int layer, int wire)
For a single wire.
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
static int EmcChargeChannel(double charge)
static int CgemTimeChannel(double time)
static int MdcTimeChannel(double time)
static int EmcChargeMeasure(double charge)
static int MdcChargeChannel(double charge)
static unsigned int TofTimeChannel(double time)
static int EmcTimeChannel(double time)
static int CgemChargeChannel(double charge)
void setTrackIndex(const int trackIndex)
void setOverflow(const unsigned int overflow)
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
static value_type getPHI_BARREL_MAX()
static bool is_barrel(const Identifier &id)
Test for barrel.
static Identifier cell_id_mrpc(int partID, int scinNum)