#include <BesRawDataWriter.hh>
Public Member Functions | |
BesRawDataWriter () | |
BesRawDataWriter () | |
void | SaveDigits () |
void | SaveDigits () |
void | SaveEmcDigits () |
void | SaveEmcDigits () |
void | SaveMdcDigits () |
void | SaveMdcDigits () |
void | SaveMucDigits () |
void | SaveMucDigits () |
void | SaveTofDigits () |
void | SaveTofDigits () |
~BesRawDataWriter () | |
~BesRawDataWriter () | |
Private Attributes | |
G4DigiManager * | m_DigiMan |
G4DigiManager * | m_DigiMan |
IDataProviderSvc * | m_evtSvc |
IDataProviderSvc * | m_evtSvc |
G4Svc * | m_G4Svc |
G4Svc * | m_G4Svc |
RealizationSvc * | m_RealizationSvc |
RealizationSvc * | m_RealizationSvc |
BesMdcGeoParameter * | mdcGeoPointer |
BesMdcGeoParameter * | mdcGeoPointer |
|
00042 { 00043 m_DigiMan = G4DigiManager::GetDMpointer(); 00044 //yuany 2005-2-28 00045 mdcGeoPointer=BesMdcGeoParameter::GetGeo(); 00046 00047 IG4Svc* tmpSvc; 00048 StatusCode sc=Gaudi::svcLocator()->service("G4Svc", tmpSvc); 00049 if (!sc.isSuccess()) 00050 G4cout <<" BesRawDataWriter::Error,could not open G4Svc"<<G4endl; 00051 m_G4Svc=dynamic_cast<G4Svc *>(tmpSvc); 00052 00053 IRealizationSvc *tmpReal; 00054 StatusCode scReal = Gaudi::svcLocator()->service("RealizationSvc",tmpReal); 00055 if (!scReal.isSuccess()) 00056 { 00057 std::cout << " Could not initialize Realization Service in BesRawDataWriter" << std::endl; 00058 } 00059 else 00060 { 00061 m_RealizationSvc=dynamic_cast<RealizationSvc*>(tmpReal); 00062 } 00063 00064 }
|
|
00067 { 00068 }
|
|
|
|
|
|
|
|
00071 { 00072 //interface to event data service 00073 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00074 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc); 00075 if (sc.isFailure()) 00076 G4cout<<"Could not accesss EventDataSvc!"<<G4endl; 00077 00078 DigiEvent* aDigiEvent = new DigiEvent; 00079 sc = m_evtSvc->registerObject("/Event/Digi",aDigiEvent); 00080 if(sc!=StatusCode::SUCCESS) { 00081 G4cout<< "Could not register DigiEvent" <<G4endl; 00082 } 00083 00084 SaveMdcDigits(); 00085 SaveTofDigits(); 00086 SaveEmcDigits(); 00087 SaveMucDigits(); 00088 }
|
|
|
|
00278 { 00279 //Emc digits collection defined in BOSS 00280 EmcDigiCol* aEmcDigiCol = new EmcDigiCol; 00281 00282 G4int emcDigiCollID = -1; 00283 emcDigiCollID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection"); 00284 if(emcDigiCollID>=0) 00285 { 00286 BesEmcDigitsCollection* emcDC = (BesEmcDigitsCollection*)m_DigiMan->GetDigiCollection(emcDigiCollID); 00287 G4int nDigi = emcDC->entries(); 00288 if(nDigi>0) 00289 { 00290 //arrange digis in digitsCollection in order of trackIndex 00291 BesEmcDigi* digi; 00292 vector<BesEmcDigi*>* vecDC = emcDC->GetVector(); 00293 for(int i=0;i<nDigi-1;i++) 00294 for(int j=i+1;j<nDigi;j++) 00295 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex()) 00296 { 00297 digi = (*vecDC)[i]; 00298 (*vecDC)[i] = (*vecDC)[j]; 00299 (*vecDC)[j] = digi; 00300 } 00301 //push back EmcDigi to EmcDigiCol in BOSS 00302 for(int i=0;i<nDigi;i++) 00303 { 00304 digi = (*emcDC)[i]; 00305 00306 int charge = RawDataUtil::EmcChargeChannel(digi->GetEnergy()); 00307 int measure = RawDataUtil::EmcChargeMeasure(digi->GetEnergy()); 00308 int time = RawDataUtil::EmcTimeChannel(digi->GetTime()); 00309 Identifier ident = EmcID::crystal_id (digi->GetPartId(), digi->GetThetaNb(), digi->GetPhiNb()); 00310 EmcDigi* emcDigi = new EmcDigi(ident, time, charge); 00311 emcDigi->setTrackIndex(digi->GetTrackIndex()); 00312 emcDigi->setMeasure(measure); 00313 aEmcDigiCol->push_back(emcDigi); 00314 } 00315 } 00316 } 00317 00318 //register EMC digits collection to TDS 00319 StatusCode scEmc = m_evtSvc->registerObject("/Event/Digi/EmcDigiCol", aEmcDigiCol); 00320 if(scEmc!=StatusCode::SUCCESS) 00321 G4cout<< "Could not register EMC digi collection" <<G4endl; 00322 00323 //retrieve EMC digits from TDS 00324 /*SmartDataPtr<EmcDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/EmcDigiCol"); 00325 if(!aDigiCol) 00326 G4cout<<"Could not retrieve EMC digi collection"<<G4endl; 00327 00328 EmcDigiCol::iterator iDigiCol; 00329 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++) 00330 { 00331 const Identifier ident = (*iDigiCol)->identify(); 00332 G4cout<<"barrel_ec: "<<EmcID::barrel_ec(ident); 00333 G4cout<<" theta: "<<EmcID::theta_module(ident); 00334 G4cout<<" phi: "<<EmcID::phi_module(ident); 00335 G4cout<<" charge: "<<(*iDigiCol)->getChargeChannel(); 00336 G4cout<<" time: "<<(*iDigiCol)->getTimeChannel()<<G4endl; 00337 } 00338 G4cout<<"end of retrieve EMC digits"<<G4endl; 00339 */ 00340 }
|
|
|
|
00091 { 00092 //mdc digis collection defined in BOSS 00093 MdcDigiCol* aMdcDigiCol = new MdcDigiCol; 00094 00095 G4int mdcDigiCollID = -1; 00096 mdcDigiCollID = m_DigiMan->GetDigiCollectionID("BesMdcDigisCollection"); 00097 if(mdcDigiCollID>=0) 00098 { 00099 BesMdcDigisCollection* mdcDC = (BesMdcDigisCollection*)m_DigiMan->GetDigiCollection(mdcDigiCollID); 00100 G4int nDigi = mdcDC->entries(); 00101 if(nDigi>0) 00102 { 00103 //push back mdc digits to MdcDigiCol in BOSS 00104 BesMdcDigi* mdcDigi; 00105 for(int i=0;i<nDigi;i++) 00106 { 00107 mdcDigi=(*mdcDC)[i]; 00108 unsigned int charge; 00109 if(m_G4Svc->GetMdcDedxFlag()==1){ 00110 charge = int(mdcDigi->GetEdep()); 00111 }else{ 00112 charge = RawDataUtil::MdcChargeChannel(mdcDigi->GetEdep()); 00113 } 00114 unsigned int time = RawDataUtil::MdcTimeChannel(mdcDigi->GetDriftT()); 00115 const Identifier ident = MdcID::wire_id ( mdcDigi->GetLayerNo(), mdcDigi->GetCellNo() ); 00116 00117 MdcDigi* aMdcDigi = new MdcDigi(ident, time, charge); 00118 aMdcDigi->setTrackIndex(mdcDigi->GetTrackID()); 00119 aMdcDigiCol->push_back(aMdcDigi); 00120 } 00121 } 00122 } 00123 00124 //register MDC digits collection to TDS 00125 StatusCode scMdc = m_evtSvc->registerObject("/Event/Digi/MdcDigiCol", aMdcDigiCol); 00126 if(scMdc!=StatusCode::SUCCESS) 00127 G4cout<< "Could not register MDC digi collection" <<G4endl; 00128 00129 //retrieve MDC digits from TDS 00130 /*SmartDataPtr<MdcDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/MdcDigiCol"); 00131 if(!aDigiCol) 00132 G4cout<<"Could not retrieve MDC digi collection"<<G4endl; 00133 00134 MdcDigiCol::iterator iDigiCol; 00135 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++) 00136 { 00137 const Identifier ident = (*iDigiCol)->identify(); 00138 G4cout<<"layer: "<<MdcID::layer(ident); 00139 G4cout<<" cell: "<<MdcID::wire(ident); 00140 G4cout<<" charge: "<<(*iDigiCol)->getChargeChannel(); 00141 G4cout<<" time: "<<(*iDigiCol)->getTimeChannel()<<G4endl; 00142 } 00143 G4cout<<"end of retrieve MDC digi collection"<<G4endl; 00144 */ 00145 }
|
|
|
|
00343 { 00344 //Muc digits collection defined in BOSS 00345 MucDigiCol* aMucDigiCol = new MucDigiCol; 00346 00347 G4int mucDigiCollID =-1; 00348 mucDigiCollID = m_DigiMan->GetDigiCollectionID("BesMucDigisCollection"); 00349 if(mucDigiCollID>=0) 00350 { 00351 BesMucDigisCollection* mucDC = (BesMucDigisCollection*)m_DigiMan->GetDigiCollection(mucDigiCollID); 00352 G4int nDigi = mucDC->entries(); 00353 00354 if(nDigi > 0) { 00355 BesMucDigi* digi; 00356 for(int i = 0; i < nDigi; i++) { 00357 digi = (*mucDC)[i]; 00358 Identifier ident = MucID::channel_id( digi->GetPartId(), digi->GetSegId(),digi->GetGapId(),digi->GetStripId() ); 00359 MucDigi* mucDigi = new MucDigi(ident); 00360 mucDigi->setTrackIndex(digi->GetTrackIndex()); 00361 aMucDigiCol->push_back(mucDigi); 00362 } 00363 } 00364 } 00365 00366 //register MUC digits collection to TDS 00367 StatusCode scMuc = m_evtSvc->registerObject("/Event/Digi/MucDigiCol", aMucDigiCol); 00368 if(scMuc!=StatusCode::SUCCESS) 00369 G4cout<< "Could not register MUC digi collection" <<G4endl; 00370 00371 //retrieve MUC digits from TDS 00372 /*SmartDataPtr<MucDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/MucDigiCol"); 00373 if(!aDigiCol) 00374 G4cout<<"Could not retrieve MUC digi collection"<<G4endl; 00375 00376 MucDigiCol::iterator iDigiCol; 00377 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++) 00378 { 00379 const Identifier ident = (*iDigiCol)->identify(); 00380 G4cout<<"Part: "<<MucID::part(ident); 00381 G4cout<<" Seg: "<<MucID::seg(ident); 00382 G4cout<<" Gap: "<<MucID::gap(ident); 00383 G4cout<<" Strip: "<<MucID::strip(ident)<<G4endl; 00384 } 00385 G4cout<<"end of retrieve MUC digits"<<G4endl; 00386 */ 00387 }
|
|
|
|
00148 { 00149 //Tof digits collection defined in BOSS 00150 TofDigiCol* aTofDigiCol = new TofDigiCol; 00151 00152 G4int tofDigiCollID = -1; 00153 tofDigiCollID = m_DigiMan->GetDigiCollectionID("BesTofDigitsCollection"); 00154 00155 if(tofDigiCollID>=0) 00156 { 00157 BesTofDigitsCollection* tofDC = (BesTofDigitsCollection*)m_DigiMan->GetDigiCollection(tofDigiCollID); 00158 G4int nDigi = tofDC->entries(); 00159 if(nDigi>0) 00160 { 00161 //arrange digis in digitsCollection in order of trackIndex 00162 BesTofDigi* digi; 00163 vector<BesTofDigi*>* vecDC = tofDC->GetVector(); 00164 for(int i=0;i<nDigi-1;i++) 00165 for(int j=i+1;j<nDigi;j++) 00166 if((*vecDC)[i]->GetTrackIndex()>(*vecDC)[j]->GetTrackIndex()) 00167 { 00168 digi = (*vecDC)[i]; 00169 (*vecDC)[i] = (*vecDC)[j]; 00170 (*vecDC)[j] = digi; 00171 } 00172 //push back tof digits to TofDigiCol in BOSS 00173 for(int i=0;i<nDigi;i++) 00174 { 00175 digi = (*tofDC)[i]; 00176 00177 G4int scinNum = digi->GetScinNb(); 00178 G4int barrel_ec = digi->GetPartId(); 00179 unsigned int layer = 0; 00180 if (TofID::is_barrel(barrel_ec) && scinNum > TofID::getPHI_BARREL_MAX()) { 00181 layer = 1; 00182 scinNum = scinNum - TofID::getPHI_BARREL_MAX() - 1; 00183 } 00184 00185 // Store tofDigi for end==0 00186 Identifier ident = TofID::cell_id ( barrel_ec, layer, scinNum, 0); 00187 unsigned int time; 00188 if(digi->GetForwTDC() > 0 ) 00189 time = RawDataUtil::TofTimeChannel(digi->GetForwTDC()); 00190 else 00191 time = 0; 00192 00193 unsigned int charge; 00194 //int runId = m_RealizationSvc->getRunId(); 00195 00196 if(digi->GetForwADC() > 0 ) 00197 { 00198 // ADC linear conversion 00199 charge = digi->GetForwADC(); // convert ADC(pC) of bTof into Q channel in Data 00200 00201 // Treat ADC overflow 00202 if(charge>=8192) 00203 { 00204 // The overlow flag is the 20th bit of the ADC_channel. 00205 charge = (charge | 0x080000);// if ADC_channel>=8192, set overflow flag = 1. 00206 } 00207 charge = ( (time & 0x07e000) | charge) ; // Store tclock into ADC_channel as qclock 00208 00209 } 00210 else 00211 charge =0; 00212 00213 00214 TofDigi* tofDigi = new TofDigi(ident, time, charge); 00215 if( charge & 0x80000 ) // Treat overflow flag(20th bit) 00216 tofDigi->setOverflow(0x2); 00217 tofDigi->setTrackIndex(digi->GetTrackIndex()); 00218 aTofDigiCol->push_back(tofDigi); 00219 00220 // Store tofDigi for end==1 00221 ident = TofID::cell_id ( barrel_ec, layer, scinNum, 1); 00222 if(digi->GetBackTDC()>0) 00223 time = RawDataUtil::TofTimeChannel(digi->GetBackTDC()); 00224 else 00225 time = 0; 00226 00227 if(digi->GetBackADC()>0 ) 00228 { 00229 // ADC linear conversion 00230 charge = digi->GetBackADC(); 00231 00232 // Treat ADC overflow 00233 if(charge>=8192) 00234 { 00235 // The overlow flag is the 20th bit of the ADC_channel. 00236 charge = (charge | 0x080000);// if ADC_channel>=8192, set overflow flag = 1. 00237 } 00238 charge = ( (time & 0x07e000) | charge) ; // Store tclock into ADC_channel as qclock 00239 } 00240 else 00241 charge = 0; 00242 00243 tofDigi = new TofDigi(ident, time, charge); 00244 if( charge & 0x80000 ) // Treat overflow flag(20th bit) 00245 tofDigi->setOverflow(0x2); 00246 tofDigi->setTrackIndex(digi->GetTrackIndex()); 00247 aTofDigiCol->push_back(tofDigi); 00248 } 00249 } 00250 } 00251 00252 //register TOF digits collection to TDS 00253 StatusCode scTof = m_evtSvc->registerObject("/Event/Digi/TofDigiCol", aTofDigiCol); 00254 if(scTof!=StatusCode::SUCCESS) 00255 G4cout<< "Could not register TOF digi collection" <<G4endl; 00256 00257 //retrieve TOF digits from TDS 00258 /*SmartDataPtr<TofDigiCol> aDigiCol(m_evtSvc,"/Event/Digi/TofDigiCol"); 00259 if(!aDigiCol) 00260 G4cout<<"Could not retrieve TOF digi collection"<<G4endl; 00261 00262 TofDigiCol::iterator iDigiCol; 00263 for(iDigiCol=aDigiCol->begin(); iDigiCol!=aDigiCol->end(); iDigiCol++) 00264 { 00265 const Identifier ident = (*iDigiCol)->identify(); 00266 G4cout<<"partId: "<<TofID::barrel_ec(ident); 00267 G4cout<<" layer: "<<TofID::layer(ident); 00268 G4cout<<" scinNb: "<<TofID::phi_module(ident); 00269 // G4cout<<" end: "<<TofID::end(ident); 00270 G4cout<<" charge: "<<(*iDigiCol)->getChargeChannel(); 00271 G4cout<<" time: "<<(*iDigiCol)->getTimeChannel()<<G4endl; 00272 } 00273 G4cout<<"end of retrieve TOF digits"<<G4endl; 00274 */ 00275 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|