BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
BesRawDataWriter Class Reference

#include <BesRawDataWriter.hh>

Public Member Functions

 BesRawDataWriter ()
 
 ~BesRawDataWriter ()
 
void SaveDigits ()
 
void SaveMdcDigits ()
 
void SaveTofDigits ()
 
void SaveEmcDigits ()
 
void SaveMucDigits ()
 
 BesRawDataWriter ()
 
 ~BesRawDataWriter ()
 
void SaveDigits ()
 
void SaveMdcDigits ()
 
void SaveTofDigits ()
 
void SaveEmcDigits ()
 
void SaveMucDigits ()
 

Detailed Description

Constructor & Destructor Documentation

◆ BesRawDataWriter() [1/2]

BesRawDataWriter::BesRawDataWriter ( )

Definition at line 41 of file BesRawDataWriter.cc.

42{
43 m_DigiMan = G4DigiManager::GetDMpointer();
44 //yuany 2005-2-28
45 mdcGeoPointer=BesMdcGeoParameter::GetGeo();
46
47 IG4Svc* tmpSvc;
48 StatusCode sc=Gaudi::svcLocator()->service("G4Svc", tmpSvc);
49 if (!sc.isSuccess())
50 G4cout <<" BesRawDataWriter::Error,could not open G4Svc"<<G4endl;
51 m_G4Svc=dynamic_cast<G4Svc *>(tmpSvc);
52
53 IRealizationSvc *tmpReal;
54 StatusCode scReal = Gaudi::svcLocator()->service("RealizationSvc",tmpReal);
55 if (!scReal.isSuccess())
56 {
57 std::cout << " Could not initialize Realization Service in BesRawDataWriter" << std::endl;
58 }
59 else
60 {
61 m_RealizationSvc=dynamic_cast<RealizationSvc*>(tmpReal);
62 }
63
64}
static BesMdcGeoParameter * GetGeo(void)

◆ ~BesRawDataWriter() [1/2]

BesRawDataWriter::~BesRawDataWriter ( )

Definition at line 66 of file BesRawDataWriter.cc.

67{
68}

◆ BesRawDataWriter() [2/2]

BesRawDataWriter::BesRawDataWriter ( )

◆ ~BesRawDataWriter() [2/2]

BesRawDataWriter::~BesRawDataWriter ( )

Member Function Documentation

◆ SaveDigits() [1/2]

void BesRawDataWriter::SaveDigits ( )

Definition at line 70 of file BesRawDataWriter.cc.

71{
72 //interface to event data service
73 ISvcLocator* svcLocator = Gaudi::svcLocator();
74 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
75 if (sc.isFailure())
76 G4cout<<"Could not accesss EventDataSvc!"<<G4endl;
77
78 DigiEvent* aDigiEvent = new DigiEvent;
79 sc = m_evtSvc->registerObject("/Event/Digi",aDigiEvent);
80 if(sc!=StatusCode::SUCCESS) {
81 G4cout<< "Could not register DigiEvent" <<G4endl;
82 }
83
88}

Referenced by BesTDSWriter::SaveAll().

◆ SaveDigits() [2/2]

void BesRawDataWriter::SaveDigits ( )

◆ SaveEmcDigits() [1/2]

void BesRawDataWriter::SaveEmcDigits ( )

Definition at line 310 of file BesRawDataWriter.cc.

311{
312 //Emc digits collection defined in BOSS
313 EmcDigiCol* aEmcDigiCol = new EmcDigiCol;
314
315 G4int emcDigiCollID = -1;
316 emcDigiCollID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection");
317 if(emcDigiCollID>=0)
318 {
319 BesEmcDigitsCollection* emcDC = (BesEmcDigitsCollection*)m_DigiMan->GetDigiCollection(emcDigiCollID);
320 G4int nDigi = emcDC->entries();
321 if(nDigi>0)
322 {
323 //arrange digis in digitsCollection in order of trackIndex
324 BesEmcDigi* digi;
325 vector<BesEmcDigi*>* vecDC = emcDC->GetVector();
326 for(int i=0;i<nDigi-1;i++)
327 for(int j=i+1;j<nDigi;j++)
328 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex())
329 {
330 digi = (*vecDC)[i];
331 (*vecDC)[i] = (*vecDC)[j];
332 (*vecDC)[j] = digi;
333 }
334 //push back EmcDigi to EmcDigiCol in BOSS
335 for(int i=0;i<nDigi;i++)
336 {
337 digi = (*emcDC)[i];
338
339 int charge = RawDataUtil::EmcChargeChannel(digi->GetEnergy());
340 int measure = RawDataUtil::EmcChargeMeasure(digi->GetEnergy());
342 Identifier ident = EmcID::crystal_id (digi->GetPartId(), digi->GetThetaNb(), digi->GetPhiNb());
343 EmcDigi* emcDigi = new EmcDigi(ident, time, charge);
344 emcDigi->setTrackIndex(digi->GetTrackIndex());
345 emcDigi->setMeasure(measure);
346 aEmcDigiCol->push_back(emcDigi);
347 }
348 }
349 }
350
351 //register EMC digits collection to TDS
352 StatusCode scEmc = m_evtSvc->registerObject("/Event/Digi/EmcDigiCol", aEmcDigiCol);
353 if(scEmc!=StatusCode::SUCCESS)
354 G4cout<< "Could not register EMC digi collection" <<G4endl;
355
356 //retrieve EMC digits from TDS
357 /*SmartDataPtr<EmcDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/EmcDigiCol");
358 if(!aDigiCol)
359 G4cout<<"Could not retrieve EMC digi collection"<<G4endl;
360
361 EmcDigiCol::iterator iDigiCol;
362 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++)
363 {
364 const Identifier ident = (*iDigiCol)->identify();
365 G4cout<<"barrel_ec: "<<EmcID::barrel_ec(ident);
366 G4cout<<" theta: "<<EmcID::theta_module(ident);
367 G4cout<<" phi: "<<EmcID::phi_module(ident);
368 G4cout<<" charge: "<<(*iDigiCol)->getChargeChannel();
369 G4cout<<" time: "<<(*iDigiCol)->getTimeChannel()<<G4endl;
370 }
371 G4cout<<"end of retrieve EMC digits"<<G4endl;
372 */
373}
Double_t time
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
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.
Definition: EmcID.cxx:71
void setTrackIndex(const int trackIndex)
Definition: RawData.cxx:35

Referenced by SaveDigits().

◆ SaveEmcDigits() [2/2]

void BesRawDataWriter::SaveEmcDigits ( )

◆ SaveMdcDigits() [1/2]

void BesRawDataWriter::SaveMdcDigits ( )

Definition at line 90 of file BesRawDataWriter.cc.

91{
92 //mdc digis collection defined in BOSS
93 MdcDigiCol* aMdcDigiCol = new MdcDigiCol;
94
95 G4int mdcDigiCollID = -1;
96 mdcDigiCollID = m_DigiMan->GetDigiCollectionID("BesMdcDigisCollection");
97 if(mdcDigiCollID>=0)
98 {
99 BesMdcDigisCollection* mdcDC = (BesMdcDigisCollection*)m_DigiMan->GetDigiCollection(mdcDigiCollID);
100 G4int nDigi = mdcDC->entries();
101 if(nDigi>0)
102 {
103 //push back mdc digits to MdcDigiCol in BOSS
104 BesMdcDigi* mdcDigi;
105 for(int i=0;i<nDigi;i++)
106 {
107 mdcDigi=(*mdcDC)[i];
108 unsigned int charge;
109 if(m_G4Svc->GetMdcDedxFlag()==1){
110 charge = int(mdcDigi->GetEdep());
111 }else{
112 charge = RawDataUtil::MdcChargeChannel(mdcDigi->GetEdep());
113 }
114 unsigned int time = RawDataUtil::MdcTimeChannel(mdcDigi->GetDriftT());
115 const Identifier ident = MdcID::wire_id ( mdcDigi->GetLayerNo(), mdcDigi->GetCellNo() );
116
117 MdcDigi* aMdcDigi = new MdcDigi(ident, time, charge);
118 aMdcDigi->setTrackIndex(mdcDigi->GetTrackID());
119 aMdcDigiCol->push_back(aMdcDigi);
120 }
121 }
122 }
123
124 //register MDC digits collection to TDS
125 StatusCode scMdc = m_evtSvc->registerObject("/Event/Digi/MdcDigiCol", aMdcDigiCol);
126 if(scMdc!=StatusCode::SUCCESS)
127 G4cout<< "Could not register MDC digi collection" <<G4endl;
128
129 //retrieve MDC digits from TDS
130 /*SmartDataPtr<MdcDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/MdcDigiCol");
131 if(!aDigiCol)
132 G4cout<<"Could not retrieve MDC digi collection"<<G4endl;
133
134 MdcDigiCol::iterator iDigiCol;
135 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++)
136 {
137 const Identifier ident = (*iDigiCol)->identify();
138 G4cout<<"layer: "<<MdcID::layer(ident);
139 G4cout<<" cell: "<<MdcID::wire(ident);
140 G4cout<<" charge: "<<(*iDigiCol)->getChargeChannel();
141 G4cout<<" time: "<<(*iDigiCol)->getTimeChannel()<<G4endl;
142 }
143 G4cout<<"end of retrieve MDC digi collection"<<G4endl;
144 */
145}
ObjectVector< MdcDigi > MdcDigiCol
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
static Identifier wire_id(int wireType, int layer, int wire)
For a single wire.
Definition: MdcID.cxx:77

Referenced by SaveDigits().

◆ SaveMdcDigits() [2/2]

void BesRawDataWriter::SaveMdcDigits ( )

◆ SaveMucDigits() [1/2]

void BesRawDataWriter::SaveMucDigits ( )

Definition at line 375 of file BesRawDataWriter.cc.

376{
377 //Muc digits collection defined in BOSS
378 MucDigiCol* aMucDigiCol = new MucDigiCol;
379
380 G4int mucDigiCollID =-1;
381 mucDigiCollID = m_DigiMan->GetDigiCollectionID("BesMucDigisCollection");
382 if(mucDigiCollID>=0)
383 {
384 BesMucDigisCollection* mucDC = (BesMucDigisCollection*)m_DigiMan->GetDigiCollection(mucDigiCollID);
385 G4int nDigi = mucDC->entries();
386
387 if(nDigi > 0) {
388 BesMucDigi* digi;
389 for(int i = 0; i < nDigi; i++) {
390 digi = (*mucDC)[i];
391 Identifier ident = MucID::channel_id( digi->GetPartId(), digi->GetSegId(),digi->GetGapId(),digi->GetStripId() );
392 MucDigi* mucDigi = new MucDigi(ident);
393 mucDigi->setTrackIndex(digi->GetTrackIndex());
394 aMucDigiCol->push_back(mucDigi);
395 }
396 }
397 }
398
399 //register MUC digits collection to TDS
400 StatusCode scMuc = m_evtSvc->registerObject("/Event/Digi/MucDigiCol", aMucDigiCol);
401 if(scMuc!=StatusCode::SUCCESS)
402 G4cout<< "Could not register MUC digi collection" <<G4endl;
403
404 //retrieve MUC digits from TDS
405 /*SmartDataPtr<MucDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/MucDigiCol");
406 if(!aDigiCol)
407 G4cout<<"Could not retrieve MUC digi collection"<<G4endl;
408
409 MucDigiCol::iterator iDigiCol;
410 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++)
411 {
412 const Identifier ident = (*iDigiCol)->identify();
413 G4cout<<"Part: "<<MucID::part(ident);
414 G4cout<<" Seg: "<<MucID::seg(ident);
415 G4cout<<" Gap: "<<MucID::gap(ident);
416 G4cout<<" Strip: "<<MucID::strip(ident)<<G4endl;
417 }
418 G4cout<<"end of retrieve MUC digits"<<G4endl;
419 */
420}
ObjectVector< MucDigi > MucDigiCol
G4TDigiCollection< BesMucDigi > BesMucDigisCollection
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition: MucID.cxx:135

Referenced by SaveDigits().

◆ SaveMucDigits() [2/2]

void BesRawDataWriter::SaveMucDigits ( )

◆ SaveTofDigits() [1/2]

void BesRawDataWriter::SaveTofDigits ( )

Definition at line 147 of file BesRawDataWriter.cc.

147 {
148
149 //Tof digits collection defined in BOSS
150 TofDigiCol* aTofDigiCol = new TofDigiCol;
151
152 G4int tofDigiCollID = -1;
153 tofDigiCollID = m_DigiMan->GetDigiCollectionID("BesTofDigitsCollection");
154
155 if( tofDigiCollID>=0 ) {
156 BesTofDigitsCollection* tofDC = (BesTofDigitsCollection*)m_DigiMan->GetDigiCollection(tofDigiCollID);
157 G4int nDigi = tofDC->entries();
158 if( nDigi>0 ) {
159 //arrange digis in digitsCollection in order of trackIndex
160 BesTofDigi* digi;
161 vector<BesTofDigi*>* vecDC = tofDC->GetVector();
162 for( int i=0; i<nDigi-1; i++ ) {
163 for( int j=i+1; j<nDigi; j++ ) {
164 if( (*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex() ) {
165 digi = (*vecDC)[i];
166 (*vecDC)[i] = (*vecDC)[j];
167 (*vecDC)[j] = digi;
168 }
169 }
170 }
171
172 //push back tof digits to TofDigiCol in BOSS
173 for( int i=0; i<nDigi; i++ ) {
174 digi = (*tofDC)[i];
175
176 // for Scintillator, scinNum is the number of scintillator
177 // for MRPC, scinNum is the number of module
178 G4int scinNum = digi->GetScinNb();
179 // for Scintillator, barrel_ec is 0 for east endcap, 1 for barrel, and 2 for west endcap
180 // for MRPC, barrel_ec is 100 + module number for east, 200 + module number for west
181 G4int barrel_ec = digi->GetPartId();
182
183 if( TofID::is_scin( barrel_ec ) ) { // for Scintillator
184 unsigned int layer = 0;
185 if (TofID::is_barrel(barrel_ec) && scinNum > TofID::getPHI_BARREL_MAX()) {
186 layer = 1;
187 scinNum = scinNum - TofID::getPHI_BARREL_MAX() - 1;
188 }
189
190 // Store tofDigi for end==0
191 Identifier ident = TofID::cell_id ( barrel_ec, layer, scinNum, 0);
192 unsigned int time;
193 if( digi->GetForwTDC()>0 ) {
195 }
196 else {
197 time = 0;
198 }
199
200 unsigned int charge;
201 if( digi->GetForwADC()>0 ) {
202 // ADC linear conversion
203 charge = digi->GetForwADC(); // convert ADC(pC) of bTof into Q channel in Data
204 // Treat ADC overflow
205 if( charge>=8192 ) {
206 // The overlow flag is the 20th bit of the ADC_channel.
207 charge = (charge | 0x080000); // if ADC_channel>=8192, set overflow flag = 1.
208 }
209 charge = ( (time & 0x07e000) | charge ); // Store tclock into ADC_channel as qclock
210 }
211 else {
212 charge =0;
213 }
214
215 TofDigi* tofDigi = new TofDigi(ident, time, charge);
216 if( charge & 0x80000 ) {// Treat overflow flag(20th bit)
217 tofDigi->setOverflow(0x2);
218 }
219 tofDigi->setTrackIndex(digi->GetTrackIndex());
220 aTofDigiCol->push_back(tofDigi);
221
222 // Store tofDigi for end==1
223 ident = TofID::cell_id ( barrel_ec, layer, scinNum, 1);
224 if( digi->GetBackTDC()>0 ) {
226 }
227 else {
228 time = 0;
229 }
230
231 if( digi->GetBackADC()>0 ) {
232 // ADC linear conversion
233 charge = digi->GetBackADC();
234 // Treat ADC overflow
235 if( charge>=8192 ) {
236 // The overlow flag is the 20th bit of the ADC_channel.
237 charge = (charge | 0x080000); // if ADC_channel>=8192, set overflow flag = 1.
238 }
239 charge = ( (time & 0x07e000) | charge); // Store tclock into ADC_channel as qclock
240 }
241 else {
242 charge = 0;
243 }
244
245 tofDigi = new TofDigi(ident, time, charge);
246 if( charge & 0x80000 ) { // Treat overflow flag(20th bit)
247 tofDigi->setOverflow(0x2);
248 }
249 tofDigi->setTrackIndex(digi->GetTrackIndex());
250 aTofDigiCol->push_back(tofDigi);
251 } // end if is_scin
252 else { // for ETF(MRPC)
253 if( barrel_ec==3 || barrel_ec==4 ) {
254 unsigned int endcap = 0;
255 unsigned int module = digi->GetModule();
256 unsigned int strip = digi->GetStrip();
257 if( barrel_ec==4 ) { // west end cap
258 endcap = 1;
259 }
260
261 // Store tofDigi for end==0
262 Identifier ident = TofID::cell_id( 3, endcap, module, strip, 0 );
263 unsigned int tleading;
264 if( digi->GetForwT1() > 0 ) {
265 tleading = RawDataUtil::TofTimeChannel( digi->GetForwT1() );
266 }
267 else { tleading = 0; }
268 unsigned int ttrailing;
269 if( digi->GetForwT2() > 0 ) {
270 ttrailing = RawDataUtil::TofTimeChannel( digi->GetForwT2() );
271 }
272 else { ttrailing = 0; }
273 TofDigi* tofDigi = new TofDigi( ident, tleading, ttrailing );
274 tofDigi->setTrackIndex( digi->GetTrackIndex() );
275 aTofDigiCol->push_back( tofDigi );
276 /*
277 G4cout << " --------- BesRawDataWriter: TOF ------------------ " << G4endl;
278 G4cout << " endcap=" << endcap << " module=" << module << " strip=" << strip << G4endl;
279 G4cout << " tleading=" << tleading << " ttrailing=" << ttrailing << G4endl;
280 G4cout << " --------- BesRawDataWriter: TOF ------------------ " << G4endl;
281 */
282 // Store tofDigi for end==1
283 ident = TofID::cell_id( 3, endcap, module, strip, 1 );
284 if( digi->GetBackT1() > 0 ) {
285 tleading = RawDataUtil::TofTimeChannel( digi->GetBackT1() );
286 }
287 else { tleading = 0; }
288 if( digi->GetBackT2() > 0 ) {
289 ttrailing = RawDataUtil::TofTimeChannel( digi->GetBackT2() );
290 }
291 else { ttrailing = 0; }
292 tofDigi = new TofDigi( ident, tleading, ttrailing );
293 tofDigi->setTrackIndex( digi->GetTrackIndex() );
294 aTofDigiCol->push_back( tofDigi );
295 }
296 } // end if is_MRPC
297
298 }
299 }
300 }
301
302 //register TOF digits collection to TDS
303 StatusCode scTof = m_evtSvc->registerObject("/Event/Digi/TofDigiCol", aTofDigiCol);
304 if( scTof!=StatusCode::SUCCESS ) {
305 G4cout<< "Could not register TOF digi collection" <<G4endl;
306 }
307 return;
308}
ObjectVector< TofDigi > TofDigiCol
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
static unsigned int TofTimeChannel(double time)
void setOverflow(const unsigned int overflow)
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
Definition: TofID.cxx:143
static bool is_scin(const Identifier &id)
Definition: TofID.cxx:102
static value_type getPHI_BARREL_MAX()
Definition: TofID.cxx:217
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition: TofID.cxx:49

Referenced by SaveDigits().

◆ SaveTofDigits() [2/2]

void BesRawDataWriter::SaveTofDigits ( )

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