00001 #include "RootIO/RootIoAlg.h"
00002 #include "GaudiKernel/MsgStream.h"
00003 #include "GaudiKernel/AlgFactory.h"
00004 #include "GaudiKernel/ISvcLocator.h"
00005 #include "GaudiKernel/SmartDataPtr.h"
00006 #include "GaudiKernel/IDataProviderSvc.h"
00007 #include "GaudiKernel/PropertyMgr.h"
00008 #include "EventModel/Event.h"
00009 #include "EventModel/EventHeader.h"
00010 #include "MdcRawEvent/MdcDigi.h"
00011 #include "TofRawEvent/TofDigi.h"
00012 #include "EmcRawEvent/EmcDigi.h"
00013 #include "McTruth/McKine.h"
00014
00015 #include "DstEvent/DstTofTrack.h"
00016 #include "DstEvent/DstMdcTrack.h"
00017 #include "DstEvent/DstEmcShower.h"
00018 #include "DstEvent/DstMucTrack.h"
00019 #include "DstEvent/DstMdcDedx.h"
00020 #include "DstEvent/DstExtTrack.h"
00021 #include "DstEvent/DstMdcKalTrack.h"
00022
00023 #include "ReconEvent/ReconEvent.h"
00024
00025 #include "CLHEP/Matrix/Vector.h"
00026 #include "CLHEP/Matrix/SymMatrix.h"
00027 #include "CLHEP/Vector/ThreeVector.h"
00028
00029
00030
00031
00032 #include "Identifier/Identifier.h"
00033 #include <vector>
00034 #include <iostream>
00035
00036 using namespace std;
00037
00038
00039
00040
00041
00043
00044 RootIoAlg::RootIoAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00045 Algorithm(name, pSvcLocator)
00046 {
00047
00048
00049
00050 }
00051
00052
00053 StatusCode RootIoAlg::initialize(){
00054
00055 MsgStream log(msgSvc(), name());
00056 log << MSG::INFO << "in initialize()" << endreq;
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 return StatusCode::SUCCESS;
00070 }
00071
00072
00073 StatusCode RootIoAlg::execute() {
00074
00075 MsgStream log(msgSvc(), name());
00076 log << MSG::INFO << "in execute()" << endreq;
00077
00078
00079
00080 int event, run;
00081
00082
00083 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00084 if (!eventHeader) {
00085 log << MSG::FATAL << "Could not find Event Header" << endreq;
00086 return( StatusCode::FAILURE);
00087 }
00088 log << MSG::INFO << "RootIoAlg: retrieved event: " << eventHeader->eventNumber() << " run: " << eventHeader->runNumber() << endreq;
00089
00090
00091 int digiId;
00092
00093
00094 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc(),"/Event/Digi/MdcDigiCol");
00095 if (!mdcDigiCol) {
00096 log << MSG::INFO << "Could not find MDC digi" << endreq;
00097
00098 }
00099 else {
00100 MdcDigiCol::iterator iter1 = mdcDigiCol->begin();
00101 digiId = 0;
00102 for (;iter1 != mdcDigiCol->end(); iter1++, digiId++) {
00103 log << MSG::INFO << "MDC digit No: " << digiId << endreq;
00104
00105 log << MSG::INFO
00106 << " time_channel = " << (*iter1)->getTimeChannel()
00107 << " charge_channel = " << (*iter1)->getChargeChannel()
00108 << endreq;
00109 }
00110 }
00111
00112
00113
00114 SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc(),"/Event/Digi/TofDigiCol");
00115 if (!tofDigiCol) {
00116 log <<MSG::INFO << "Could not find TOF digi" << endreq;
00117
00118 }
00119 else {
00120 TofDigiCol::iterator iter2 = tofDigiCol->begin();
00121 digiId = 0;
00122 for (;iter2 != tofDigiCol->end(); iter2++, digiId++) {
00123 log << MSG::INFO << "TOF digit No: " << digiId << endreq;
00124 log << MSG::INFO
00125 << " time_channel = " << (*iter2)->getTimeChannel()
00126 << " charge_channel = " << (*iter2)->getChargeChannel()
00127 << endreq;
00128
00129
00130 }
00131 }
00132
00133 SmartDataPtr<EmcDigiCol> emcDigiCol(eventSvc(),"/Event/Digi/EmcDigiCol");
00134 if (!emcDigiCol) {
00135 log <<MSG::INFO << "Could not find EMC digi" << endreq;
00136
00137 }
00138 else {
00139 EmcDigiCol::iterator iter3 = emcDigiCol->begin();
00140 digiId = 0;
00141 for (;iter3 != emcDigiCol->end(); iter3++, digiId++) {
00142 log << MSG::INFO << "Emc digit No: " << digiId << endreq;
00143
00144 log << MSG::INFO
00145 << " time_channel = " << (*iter3)->getTimeChannel()
00146 << " charge_channel = " << (*iter3)->getChargeChannel()
00147 << endreq;
00148 }
00149 }
00150
00151
00152
00153 SmartDataPtr<DstTofTrackCol> dstTofTrackCol(eventSvc(),EventModel::Dst::DstTofTrackCol);
00154 if (!dstTofTrackCol) {
00155 log <<MSG::INFO << "Could not find Dst Tof Track" << endreq;
00156
00157 }
00158 else {
00159 DstTofTrackCol::iterator iter4 = dstTofTrackCol->begin();
00160 digiId = 0;
00161 for (;iter4 != dstTofTrackCol->end(); iter4++, digiId++) {
00162 log << MSG::INFO << "Dst Tof No: " << digiId << endreq;
00163
00164 log << MSG::INFO
00165 <<" TrackID = " << (*iter4)->trackID()
00166 <<" TofID = " <<(*iter4)->tofID()
00167 <<" TofTrackID = " <<(*iter4)->tofTrackID()
00168 <<" Beta = " << (*iter4)->beta()
00169 << endreq;
00170 }
00171 }
00172
00173
00174 SmartDataPtr<DstEmcShowerCol> dstEmcShowerCol(eventSvc(),EventModel::Dst::DstEmcShowerCol);
00175 if (!dstEmcShowerCol) {
00176 log <<MSG::INFO << "Could not find Dst Emc Track" << endreq;
00177
00178 }
00179 else {
00180 DstEmcShowerCol::iterator iter5 = dstEmcShowerCol->begin();
00181 digiId = 0;
00182 for (;iter5 != dstEmcShowerCol->end(); iter5++, digiId++) {
00183 log << MSG::INFO << "Dst Emc No: " << digiId << endreq;
00184
00185 log << MSG::INFO
00186 << " Track ID = " << (*iter5)->trackId()
00187 <<" Cell ID = " << (*iter5)->cellId()
00188 <<" Total energy observed in Emc = " << (*iter5)->energy()
00189 << endreq ;
00190 }
00191 }
00192
00193
00194 SmartDataPtr<DstMdcTrackCol> dstMdcTrackCol(eventSvc(),EventModel::Dst::DstMdcTrackCol);
00195 if (!dstMdcTrackCol) {
00196 log <<MSG::INFO << "Could not find Dst Mdc Track" << endreq;
00197
00198 }
00199 else {
00200 DstMdcTrackCol::iterator iter6 = dstMdcTrackCol->begin();
00201 digiId = 0;
00202 for (;iter6 != dstMdcTrackCol->end(); iter6++, digiId++) {
00203 log << MSG::INFO << "Dst Mdc No: " << digiId << endreq;
00204
00205 log << MSG::INFO
00206 << " Track ID = " << (*iter6)->trackId()
00207 <<" number of total hits contained = " << (*iter6)->nster()
00208 <<"px = "<<(*iter6)->px()
00209 <<"p = "<<(*iter6)->p()
00210 <<endreq;
00211 }
00212 }
00213
00214
00215 SmartDataPtr<DstMdcDedxCol> dstMdcDedxCol(eventSvc(),EventModel::Dst::DstMdcDedxCol);
00216 if (!dstMdcDedxCol) {
00217 log << MSG::INFO << "Could not find Dst Mdc Dedx " << endreq;
00218
00219 }
00220 else {
00221 DstMdcDedxCol::iterator iter7 = dstMdcDedxCol->begin();
00222 digiId = 0;
00223 for (;iter7 != dstMdcDedxCol->end(); iter7++, digiId++) {
00224 log << MSG::INFO << "Dst Mdc Dedx No: " << digiId << endreq;
00225
00226 log << MSG::INFO
00227 << " Track ID = " << (*iter7)->trackId()
00228 <<"Chi of E = " << (*iter7)->chi(0)
00229 <<"Chi of Mu = " << (*iter7)->chi(1)
00230 <<"Chi of Pi = " << (*iter7)->chi(2)
00231 <<endreq;
00232 }
00233 }
00234
00235
00236 SmartDataPtr<DstMucTrackCol> dstMucTrackCol(eventSvc(),EventModel::Dst::DstMucTrackCol);
00237 if (!dstMucTrackCol) {
00238 log <<MSG::INFO << "Could not find Muc Track " << endreq;
00239
00240 }
00241 else {
00242 DstMucTrackCol::iterator iter8 = dstMucTrackCol->begin();
00243 digiId = 0;
00244 for (;iter8 != dstMucTrackCol->end(); iter8++, digiId++) {
00245 log << MSG::INFO << "Dst Muc Track No: " << digiId << endreq;
00246
00247 log << MSG::INFO
00248 << " Track ID = " << (*iter8)->trackId()
00249 <<" Number of hits on track = " << (*iter8)->numHits()
00250 <<" maxHitsInLayer " << (*iter8)->maxHitsInLayer()
00251 <<" xPos = " << (*iter8)->xPos()
00252 <<" yPos = " << (*iter8)->yPos()
00253 <<" zPos = " << (*iter8)->zPos()
00254 << endreq;
00255 }
00256 }
00257
00258
00259 SmartDataPtr<DstExtTrackCol> dstExtTrackCol(eventSvc(),EventModel::Dst::DstExtTrackCol);
00260 if (!dstExtTrackCol) {
00261 log <<MSG::INFO << "Could not find DstExt Track " << endreq;
00262
00263 }
00264 else {
00265 DstExtTrackCol::iterator iter9 = dstExtTrackCol->begin();
00266
00267 digiId = 0;
00268 for (;iter9 != dstExtTrackCol->end(); iter9++, digiId++) {
00269 log << MSG::INFO << "Dst Ext Track No: " << digiId << endreq;
00270 log << MSG::INFO
00271 << "volume name of Tof1= "<< (*iter9)->tof1VolumeName()
00272 << "volume number of Tof1 = "<< (*iter9)->tof1VolumeNumber()
00273 << "Tof1 = "<< (*iter9)->tof1()
00274 <<endreq;
00275 log << MSG::INFO
00276 << "volume name of Tof2= "<< (*iter9)->tof2VolumeName()
00277 << "volume number of Tof2 = "<< (*iter9)->tof2VolumeNumber()
00278 << "Tof2 = "<< (*iter9)->tof2()
00279 <<endreq;
00280 log << MSG::INFO
00281 <<" Ext Tof1 Error Z = " << (*iter9)->tof1PosSigmaAlongZ()
00282 <<" Ext Tof2 Error Z = " << (*iter9)->tof2PosSigmaAlongZ()
00283 <<" Ext Emc Error theta = " << (*iter9)->emcPosSigmaAlongTheta()
00284 <<" Ext Muc Error Z = " << (*iter9)->mucPosSigmaAlongZ()
00285 << endreq;
00286 }
00287 }
00288
00289 SmartDataPtr<DstMdcKalTrackCol> dstMdcKalTrackCol(eventSvc(),EventModel::Dst::DstMdcKalTrackCol);
00290 if (!dstMdcKalTrackCol) {
00291 log <<MSG::INFO << "Could not find DstMdcKal Track " << endreq;
00292 }
00293 else {
00294 DstMdcKalTrackCol::iterator iter10 = dstMdcKalTrackCol->begin();
00295 digiId = 0;
00296 for (;iter10 != dstMdcKalTrackCol->end(); iter10++, digiId++) {
00297
00298
00299
00300
00301
00302
00303 }
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 return StatusCode::SUCCESS;
00427 }
00428
00429
00430 StatusCode RootIoAlg::finalize() {
00431
00432 MsgStream log(msgSvc(), name());
00433 log << MSG::INFO << "in finalize()" << endreq;
00434
00435 return StatusCode::SUCCESS;
00436 }