15#include "G4DigiManager.hh"
21#include "GaudiKernel/IDataProviderSvc.h"
22#include "GaudiKernel/ISvcLocator.h"
23#include "GaudiKernel/Bootstrap.h"
24#include "GaudiKernel/RegistryEntry.h"
25#include "GaudiKernel/MsgStream.h"
40#include "GaudiKernel/SmartDataPtr.h"
45 m_DigiMan = G4DigiManager::GetDMpointer();
50 StatusCode sc=Gaudi::svcLocator()->service(
"G4Svc", tmpSvc);
52 G4cout <<
" BesRawDataWriter::Error,could not open G4Svc"<<G4endl;
53 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
56 StatusCode scReal = Gaudi::svcLocator()->service(
"RealizationSvc",tmpReal);
57 if (!scReal.isSuccess())
59 std::cout <<
" Could not initialize Realization Service in BesRawDataWriter" << std::endl;
75 ISvcLocator* svcLocator = Gaudi::svcLocator();
76 StatusCode sc=svcLocator->service(
"EventDataSvc", m_evtSvc);
78 G4cout<<
"Could not accesss EventDataSvc!"<<G4endl;
81 sc = m_evtSvc->registerObject(
"/Event/Digi",aDigiEvent);
82 if(sc!=StatusCode::SUCCESS) {
83 G4cout<<
"Could not register DigiEvent" <<G4endl;
97 G4int mdcDigiCollID = -1;
98 mdcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMdcDigisCollection");
102 G4int nDigi = mdcDC->entries();
107 for(
int i=0;i<nDigi;i++)
112 charge = int(mdcDigi->
GetEdep());
121 aMdcDigiCol->push_back(aMdcDigi);
127 StatusCode scMdc = m_evtSvc->registerObject(
"/Event/Digi/MdcDigiCol", aMdcDigiCol);
128 if(scMdc!=StatusCode::SUCCESS)
129 G4cout<<
"Could not register MDC digi collection" <<G4endl;
154 G4int tofDigiCollID = -1;
155 tofDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesTofDigitsCollection");
160 G4int nDigi = tofDC->entries();
167 vector<BesTofDigi*>* vecDC = tofDC->GetVector();
168 for(
int i=0;i<nDigi-1;i++)
169 for(
int j=i+1;j<nDigi;j++)
170 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
173 (*vecDC)[i] = (*vecDC)[j];
180 for(
int i=0;i<nDigi;i++)
199 unsigned int layer = 0;
201 unsigned int time =0;
206 if(barrel_ec == 0 || barrel_ec == 1 || barrel_ec == 2)
235 charge = (charge | 0x080000);
241 charge = ( (
time & 0x07e000) | charge) ;
249 if( charge & 0x80000 )
253 aTofDigiCol->push_back(tofDigi);
256 if(barrel_ec == 0 || barrel_ec == 1 || barrel_ec == 2)
283 charge = (charge | 0x080000);
285 charge = ( (
time & 0x07e000) | charge) ;
294 if( charge & 0x80000 )
298 aTofDigiCol->push_back(tofDigi);
311 else if(barrel_ec == 3 || barrel_ec == 4 || barrel_ec == 5 || barrel_ec == 6)
390 aTofDigiCol->push_back(tofDigi);
412 StatusCode scTof = m_evtSvc->registerObject(
"/Event/Digi/TofDigiCol", aTofDigiCol);
413 if(scTof!=StatusCode::SUCCESS)
414 G4cout<<
"Could not register TOF digi collection" <<G4endl;
444 G4int emcDigiCollID = -1;
445 emcDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
449 G4int nDigi = emcDC->entries();
454 vector<BesEmcDigi*>* vecDC = emcDC->GetVector();
455 for(
int i=0;i<nDigi-1;i++)
456 for(
int j=i+1;j<nDigi;j++)
457 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
460 (*vecDC)[i] = (*vecDC)[j];
464 for(
int i=0;i<nDigi;i++)
475 aEmcDigiCol->push_back(emcDigi);
481 StatusCode scEmc = m_evtSvc->registerObject(
"/Event/Digi/EmcDigiCol", aEmcDigiCol);
482 if(scEmc!=StatusCode::SUCCESS)
483 G4cout<<
"Could not register EMC digi collection" <<G4endl;
509 G4int mucDigiCollID =-1;
510 mucDigiCollID = m_DigiMan->GetDigiCollectionID(
"BesMucDigisCollection");
514 G4int nDigi = mucDC->entries();
518 for(
int i = 0; i < nDigi; i++) {
523 aMucDigiCol->push_back(mucDigi);
529 StatusCode scMuc = m_evtSvc->registerObject(
"/Event/Digi/MucDigiCol", aMucDigiCol);
530 if(scMuc!=StatusCode::SUCCESS)
531 G4cout<<
"Could not register MUC digi collection" <<G4endl;
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
G4TDigiCollection< BesMucDigi > BesMucDigisCollection
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
ObjectVector< EmcDigi > EmcDigiCol
ObjectVector< MdcDigi > MdcDigiCol
ObjectVector< MucDigi > MucDigiCol
ObjectVector< TofDigi > TofDigiCol
static BesMdcGeoParameter * GetGeo(void)
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.
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 MdcTimeChannel(double time)
static int EmcChargeMeasure(double charge)
static int MdcChargeChannel(double charge)
static unsigned int TofTimeChannel(double time)
static int EmcTimeChannel(double time)
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)