00001 #include "BesVisAlg/BesVisAlg.h"
00002 #include "RootEventData/TRecTrackEvent.h"
00003 #include "RootEventData/TDigiEvent.h"
00004 #include "RootEventData/TEvtHeader.h"
00005 #include "RootEventData/TTrigEvent.h"
00006 #include "RootCnvSvc/Rec/RecTrackCnv.h"
00007 #include "RootCnvSvc/Digi/DigiCnv.h"
00008 #include "RootCnvSvc/EvtHeaderCnv.h"
00009 #include "RootCnvSvc/Trig/TrigCnv.h"
00010 #include "RootCnvSvc/Trig/TrigDataCnv.h"
00011 #include "EventModel/EventHeader.h"
00012 #include "EventModel/Event.h"
00013 #include "EventModel/EventModel.h"
00014 #include <assert.h>
00016 int BesVisAlg::counter = 0;
00017
00018 BesVisAlg::BesVisAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00019 Algorithm(name, pSvcLocator)
00020 {
00021
00022 declareProperty("TestVec",testVec);
00023 declareProperty("OutputShareFile", f_rootOutputFile);
00024 declareProperty("InputGeometryFile", f_geoInputFile);
00025 declareProperty("DisplayMode", m_mode=0);
00026
00027
00028 start_val[0] = 1;
00029 start_val[1] = 0;
00030
00031
00032 acquire.sem_num = 0;
00033 acquire.sem_op = -1;
00034 acquire.sem_flg = SEM_UNDO;
00035
00036
00037 release.sem_num = 0;
00038 release.sem_op = 1;
00039 release.sem_flg = SEM_UNDO;
00040
00041 recdis = NULL;
00042 recTrack1 = NULL;
00043 mdchit = NULL;
00044 tofTrack = NULL;
00045 muctrk = NULL;
00046
00047 }
00048
00049
00050 BesVisAlg::~BesVisAlg(){
00051
00052 MsgStream log(msgSvc(), name());
00053 log << MSG::INFO << " BesVisAlg ~BesVisAlg()" << endreq;
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 }
00069
00070
00071 StatusCode BesVisAlg::initialize(){
00072
00073
00074 MsgStream log(msgSvc(), name());
00075 log << MSG::INFO << " BesVisAlg initialize()" << endreq;
00076 StatusCode status = StatusCode::SUCCESS;
00077
00078
00079
00080 IService* isvc = 0;
00081 status = serviceLocator()->service("RootCnvSvc", isvc, false);
00082 if ( !status.isSuccess() )
00083 status = serviceLocator()->service("EventCnvSvc", isvc, true);
00084 if ( status.isSuccess() )
00085 status = isvc->queryInterface(IID_IRootCnvSvc, (void**)&m_cnvSvc);
00086 status = hasWrite();
00087 if ( status.isSuccess()){
00088 log << MSG::INFO << "share file writed -- success"
00089 << endreq;
00090 }
00091 else {
00092 log << MSG::ERROR << "share file writed -- ERROR!!!!!"
00093 << endreq;
00094 }
00095
00096
00097
00098 log << MSG::INFO << " OutputFile = " << f_rootOutputFile << endreq;
00099
00100 for (unsigned int i=0; i<testVec.size(); i++) {
00101 log << MSG::INFO << " MyStringVec[" << i << "] = "
00102 << testVec[i] << endreq;
00103 }
00104
00105
00106 m_pid = getpid();
00107 log << MSG::ERROR << "BesVisAlg process PID: [" << m_pid << "]"
00108 << endreq;
00109
00110 log << MSG::ERROR << "Create and initialize semaphore" << endreq;
00111 if ((semid = semget((int)m_pid, 2, IPC_CREAT | IPC_EXCL | 0666)) != -1){
00112 arg.array = start_val;
00113 log << MSG::ERROR << "Semaphore ID:" << semid << endreq;
00114
00115 if (semctl(semid, 0, SETALL, arg) == -1){
00116 log << MSG::ERROR << "semctl -- parent -- initialization"
00117 << endreq;
00118 exit(1);
00119 }
00120
00121 if ((sem_value_F = semctl(semid, FREE_SPACE, GETVAL, 0)) == -1){
00122 log << MSG::ERROR << "semctl -- GETVAL" << endreq;
00123 exit(1);
00124 }
00125
00126 if ((sem_value_O = semctl(semid, OUTPUT_STORE, GETVAL, 0)) == -1){
00127 log << MSG::ERROR << "semctl -- GETVAL" << endreq;
00128 exit(1);
00129 }
00130 }
00131 else {
00132 log << MSG::INFO << "semget -- parent -- creation" << endreq;
00133 exit(2);
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143 if ((c_pid = fork()) == -1){
00144 log << MSG::ERROR << "fork -- consumer" << endreq;
00145 exit(5);
00146 }
00147 else if (c_pid == 0){
00148
00149 log << MSG::INFO << "Parent fork consumer: ppid = " << getppid()
00150 << "; pid = " << getpid() << endreq;
00151
00152
00153 char msg_pid[25];
00154 sprintf(msg_pid, "%d", m_pid);
00155
00156 const char *msg_sleep = testVec[1].c_str();
00157
00158 log << MSG::INFO << "msg_pid: " << msg_pid << endreq;
00159 log << MSG::INFO << "Consumer sleep time: " << msg_sleep
00160 << " seconds." << endreq;
00161
00162
00163 execlp("besvis.exe", "besvis.exe",
00164 "-B", msg_pid, "-e", f_rootOutputFile.c_str(),
00165 "-g", f_geoInputFile.c_str(), (char *)NULL );
00166
00167
00168 log << MSG::ERROR << "exec -- consumer" << endreq;
00169 exit(6);
00170 }
00171
00172
00173 return StatusCode::SUCCESS;
00174 }
00175
00176
00177
00178 StatusCode BesVisAlg::execute() {
00179
00180
00181 MsgStream log(msgSvc(), name());
00182 log << MSG::INFO << "BesVisAlg execute()" << endreq;
00183
00184
00185 const char *msg_sleep = testVec[0].c_str();
00186 producer(atoi(msg_sleep));
00187
00188 return StatusCode::SUCCESS;
00189 }
00190
00191
00192
00193 StatusCode BesVisAlg::finalize() {
00194
00195
00196 MsgStream log(msgSvc(), name());
00197 log << MSG::INFO << "BesVisAlg finalize()" << endreq;
00198
00199
00200
00201 while (1){
00202 if (hasRead()) break;
00203 else sleep(5);
00204 }
00205
00206
00207 if (semctl(semid, 0, IPC_RMID, 0) == -1)
00208 log << MSG::ERROR << "Delete semaphore" << endreq;
00209 else
00210 log << MSG::INFO << "Delete semaphore" << endreq;
00211
00212 int status;
00213 pid_t wait_pid;
00214 cout << "wait for besvis terminate" << endl;
00215 while ( wait_pid = waitpid(c_pid, &status, 0) ){
00216 log << MSG::INFO << "Wait on PID: " << c_pid << " returns status of: "
00217 << status << endreq;
00218 if (wait_pid == -1) break;
00219 sleep(5);
00220 }
00221 cout << "finalize" << endl;
00222 return StatusCode::SUCCESS;
00223 }
00224
00225
00226 StatusCode BesVisAlg::producer(int p_sleep){
00227
00228 MsgStream log(msgSvc(), name());
00229 log << MSG::INFO << "Producer work" << endreq;
00230 StatusCode status = StatusCode::SUCCESS;
00231
00232
00233 acquire.sem_num = FREE_SPACE;
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 if (semop(semid, &acquire, 1) == -1){
00262 log << MSG::ERROR << "Producer -- decrease -- freeSpace"
00263 << endreq;
00264 exit(2);
00265 }
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
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 DataObject* obj = 0;
00324 IOpaqueAddress *pAddress = 0;
00325
00326 status = m_pDataProvider->retrieveObject("/Event", obj);
00327 if ( status.isSuccess() ) {
00328 status = m_pConversionSvc->createRep(obj, pAddress);
00329 }
00330
00331 obj = 0;
00332 pAddress = 0;
00333 status = m_pDataProvider->retrieveObject("/Event/Trig", obj);
00334 if ( status.isSuccess() ) {
00335 status = m_pConversionSvc->createRep(obj, pAddress);
00336 }
00337 obj = 0;
00338 pAddress = 0;
00339 status = m_pDataProvider->retrieveObject("/Event/Trig/TrigData", obj);
00340 if ( status.isSuccess() ) {
00341 status = m_pConversionSvc->createRep(obj, pAddress);
00342 }
00343 obj = 0;
00344 pAddress = 0;
00345 status = m_pDataProvider->retrieveObject("/Event/EventHeader", obj);
00346 if ( status.isSuccess() ) {
00347 status = m_pConversionSvc->createRep(obj, pAddress);
00348 }
00349 obj = 0;
00350 pAddress = 0;
00351 status = m_pDataProvider->retrieveObject("/Event/Digi", obj);
00352 if ( status.isSuccess() ) {
00353 status = m_pConversionSvc->createRep(obj, pAddress);
00354 }
00355 obj = 0;
00356 pAddress = 0;
00357 status = m_pDataProvider->retrieveObject("/Event/Digi/MdcDigiCol", obj);
00358 if ( status.isSuccess() ) {
00359 status = m_pConversionSvc->createRep(obj, pAddress);
00360 }
00361 obj = 0;
00362 pAddress = 0;
00363 status = m_pDataProvider->retrieveObject("/Event/Digi/TofDigiCol", obj);
00364 if ( status.isSuccess() ) {
00365 status = m_pConversionSvc->createRep(obj, pAddress);
00366 }
00367 obj = 0;
00368 pAddress = 0;
00369 status = m_pDataProvider->retrieveObject("/Event/Digi/EmcDigiCol", obj);
00370 if ( status.isSuccess() ) {
00371 status = m_pConversionSvc->createRep(obj, pAddress);
00372 }
00373 obj = 0;
00374 pAddress = 0;
00375 status = m_pDataProvider->retrieveObject("/Event/Digi/MucDigiCol", obj);
00376 if ( status.isSuccess() ) {
00377 status = m_pConversionSvc->createRep(obj, pAddress);
00378 }
00379 obj = 0;
00380 pAddress = 0;
00381 status = m_pDataProvider->retrieveObject("/Event/Recon", obj);
00382 if ( status.isSuccess() ) {
00383 status = m_pConversionSvc->createRep(obj, pAddress);
00384 }
00385 obj = 0;
00386 pAddress = 0;
00387 status = m_pDataProvider->retrieveObject("/Event/Recon/RecMdcHitCol", obj);
00388 if ( status.isSuccess() ) {
00389 status = m_pConversionSvc->createRep(obj, pAddress);
00390 }
00391 obj = 0;
00392 pAddress = 0;
00393 status = m_pDataProvider->retrieveObject("/Event/Recon/RecMdcTrackCol", obj);
00394 if ( status.isSuccess() ) {
00395 status = m_pConversionSvc->createRep(obj, pAddress);
00396 }
00397 obj = 0;
00398 pAddress = 0;
00399 status = m_pDataProvider->retrieveObject("/Event/Recon/MdcHOTCol", obj);
00400 if ( status.isSuccess() ) {
00401 status = m_pConversionSvc->createRep(obj, pAddress);
00402 }
00403 obj = 0;
00404 pAddress = 0;
00405 status = m_pDataProvider->retrieveObject("/Event/Recon/RecMdcDedxCol", obj);
00406 if ( status.isSuccess() ) {
00407 status = m_pConversionSvc->createRep(obj, pAddress);
00408 }
00409 obj = 0;
00410 pAddress = 0;
00411 status = m_pDataProvider->retrieveObject("/Event/Recon/RecTofTrackCol", obj);
00412 if ( status.isSuccess() ) {
00413 status = m_pConversionSvc->createRep(obj, pAddress);
00414 }
00415
00416 obj = 0;
00417 pAddress = 0;
00418 status = m_pDataProvider->retrieveObject("/Event/Recon/RecEmcShowerCol", obj);
00419 if ( status.isSuccess() ) {
00420 status = m_pConversionSvc->createRep(obj, pAddress);
00421 }
00422 obj = 0;
00423 pAddress = 0;
00424 status = m_pDataProvider->retrieveObject("/Event/Recon/RecMucTrackCol", obj);
00425 if ( status.isSuccess() ) {
00426 status = m_pConversionSvc->createRep(obj, pAddress);
00427 }
00428 TRecTrackEvent *recEvt = m_cnvSvc->getRecTrackCnv()->getWriteObject();
00429 TTrigEvent *trigEvt = m_cnvSvc->getTrigCnv()->getWriteObject();
00430 TEvtHeader *evtHeader = m_cnvSvc->getEvtHeaderCnv()->getWriteObject();
00431 TDigiEvent *digiEvt = m_cnvSvc->getDigiCnv()->getWriteObject();
00432
00433 if (recTrack1){
00434 delete [] recTrack1;
00435 recTrack1 = NULL;
00436 }
00437 if (recdis){
00438 delete recdis;
00439 recdis = NULL;
00440 }
00441 recdis = new TDisTrack();
00442
00443 recTrack1 = new TRecMdcTrack[20];
00444 int no = 0;
00445 no=(recEvt->getRecMdcTrackCol())->GetEntries();
00446
00447 std::cout<<" mdc trk number ="<< no <<std::endl;
00448 if (no>20) no=20;
00449 for (int i=0;i<no;i++){
00450 const TRecMdcTrack* recTrack =recEvt->getRecMdcTrack(i);
00451
00452
00453
00454 (recTrack1+i)->setTRecMdcTrack(recTrack);
00455 recdis->addRecMdcTrack(recTrack1+i);
00456 }
00457
00458
00459 if (tofTrack){
00460 delete [] tofTrack;
00461 tofTrack = NULL;
00462 }
00463 tofTrack = new TRecTofTrack[200];
00464 no=0;
00465 no = (recEvt->getTofTrackCol())->GetEntries();
00466 std::cout<<" tof trk number ="<< no <<std::endl;
00467 if (no>200) no =200;
00468 for (int i=0;i<no;i++){
00469 const TRecTofTrack* tofTrack1 =recEvt->getTofTrack(i);
00470 (tofTrack+i)->setTRecTofTrack(tofTrack1);
00471 recdis->addTofTrack(tofTrack+i);
00472 }
00473
00474
00475 if (mdchit){
00476 delete [] mdchit;
00477 mdchit = NULL;
00478 }
00479 mdchit = new TRecMdcHit[1000];
00480 no=0;
00481 no = (recEvt->getRecMdcHitCol())->GetEntries();
00482 std::cout<<" mdc hits number ="<< no <<std::endl;
00483 if (no>1000) no =1000;
00484 for (int i=0;i<no;i++){
00485 const TRecMdcHit* mdchit1 =recEvt->getRecMdcHit(i);
00486 (mdchit+i)->setTRecMdcHit(mdchit1);
00487 recdis->addRecMdcHit(mdchit+i);
00488 }
00489
00490 if (muctrk){
00491 delete [] muctrk;
00492 muctrk = NULL;
00493 }
00494 muctrk = new TRecMucTrack[20];
00495 no=0;
00496 no = (recEvt->getMucTrackCol())->GetEntries();
00497
00498 std::cout<<" muc trk number ="<< no <<std::endl;
00499 if (no>20) no=20;
00500 for (int i=0;i<no;i++){
00501 const TRecMucTrack* mucTrack1 =recEvt->getMucTrack(i);
00502 (muctrk+i)->setTRecMucTrack(mucTrack1);
00503 recdis->addMucTrack(muctrk+i);
00504 }
00505
00506
00507 if (emcshower){
00508 delete [] emcshower;
00509 emcshower=NULL;
00510 }
00511 emcshower = new TRecEmcShower[20];
00512 no=0;
00513 no = (recEvt->getEmcShowerCol())->GetEntries();
00514 std::cout<<" emc trk number ="<< no <<std::endl;
00515 if (no>20) no=20;
00516 for (int i=0;i<no;i++){
00517 const TRecEmcShower* rec_emc =recEvt->getEmcShower(i);
00518 (emcshower+i)->setTRecEmcShower(rec_emc);
00519 recdis->addEmcShower(emcshower+i);
00520 }
00521
00522
00523 TFile file(f_rootOutputFile.c_str(),"RECREATE");
00524 TTree tree("Event","Event");
00525 tree.Branch("TDisTrack","TDisTrack",&recdis,64000,1);
00526 tree.Branch("TDigiEvent", "TDigiEvent", &digiEvt, 64000, 1);
00527 tree.Branch("TEvtHeader","TEvtHeader",&evtHeader,64000,1);
00528 tree.Branch("TTrigEvent","TTrigEvent",&trigEvt,64000,1);
00529 tree.Fill();
00530 file.Write();
00531 file.Close();
00532 recdis->Clear();
00533
00534 if (m_mode == 1){
00535 commonData tmp;
00536 tmp.clear();
00537 }
00538
00539
00540
00541
00542
00543 release.sem_num = OUTPUT_STORE;
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571 if (semop(semid, &release, 1) == -1){
00572 log << MSG::ERROR << "Producer -- increase -- storage"
00573 << endreq;
00574 exit(4);
00575 }
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603 return status;
00604 }
00605
00606
00607 bool BesVisAlg::hasRead(){
00608
00609 MsgStream log(msgSvc(), name());
00610 log << MSG::INFO << "hadRead()" << endreq;
00611
00612
00613 if ((sem_value_F = semctl(semid, FREE_SPACE, GETVAL, 0)) == -1){
00614 log << MSG::ERROR << "semctl: GETVAL -- FREE_SPACE"
00615 << endreq;
00616 exit(5);
00617 }
00618 log << MSG::INFO << "Semaphore FREE_SPACE has value of " <<
00619 sem_value_F << endreq;
00620
00621 if ((sem_value_O = semctl(semid, OUTPUT_STORE, GETVAL, 0)) == -1){
00622 log << MSG::ERROR << "semctl: GETVAL -- OUTPUT_STORE"
00623 << endreq;
00624 exit(5);
00625 }
00626 log << MSG::INFO << "Semaphore OUTPUT_STORE has value of " <<
00627 sem_value_O << endreq;
00628
00629 if ((sem_value_F == 1) && (sem_value_O == 0)) return true;
00630 else return false;
00631
00632 }
00633
00634
00635 StatusCode BesVisAlg::hasWrite(){
00636 MsgStream log(msgSvc(), name());
00637 log << MSG::INFO << "hasWrite()" << endreq;
00638 StatusCode status = StatusCode::SUCCESS;
00639
00640 int statusCode;
00641
00642
00643
00644 status = getSvc();
00645 if ( !status.isSuccess()){
00646 log <<MSG::ERROR << "getSvc() error!" << endreq;
00647 return StatusCode::SUCCESS;
00648 }
00649
00650
00651 status = collectObjects();
00652 if ( !status.isSuccess()){
00653 log <<MSG::ERROR << "collectObjects() error!" << endreq;
00654 return StatusCode::SUCCESS;
00655 }
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673 return status;
00674
00675 }
00676
00677
00678 StatusCode BesVisAlg::getSvc(){
00679 MsgStream log(msgSvc(), name());
00680 log << MSG::INFO << "getSvc()" << endreq;
00681 StatusCode status = StatusCode::SUCCESS;
00682
00683
00684 ItemNames m_itemNames;
00685 m_itemNames.push_back("/Event#1");
00686 m_itemNames.push_back("/Event/EventHeader#1");
00687
00688 m_itemNames.push_back("/Event/Digi#1");
00689 m_itemNames.push_back("/Event/Digi/MdcDigiCol#1");
00690 m_itemNames.push_back("/Event/Digi/TofDigiCol#1");
00691 m_itemNames.push_back("/Event/Digi/EmcDigiCol#1");
00692 m_itemNames.push_back("/Event/Digi/MucDigiCol#1");
00693
00694 m_itemNames.push_back("/Event/Recon#1");
00695 m_itemNames.push_back("/Event/Recon/RecMdcHitCol#1");
00696 m_itemNames.push_back("/Event/Recon/RecMdcTrackCol#1");
00697
00698 m_itemNames.push_back("/Event/Trig#1");
00699 m_itemNames.push_back("/Event/Trig/TrigData#1");
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 clearItems(m_itemList);
00722 ItemNames::iterator i;
00723 for (i = m_itemNames.begin(); i != m_itemNames.end(); i++){
00724 addItem(m_itemList, *i);
00725 }
00726
00727 status = serviceLocator()->service("EventDataSvc", m_pDataManager, true);
00728 if ( !status.isSuccess() ) {
00729 log << MSG::FATAL << "Unable to locate IDataManagerSvc interface"
00730 << endreq;
00731 return status;
00732 }
00733
00734 status = serviceLocator()->service("EventDataSvc", m_pDataProvider, true);
00735 if ( !status.isSuccess() ) {
00736 log << MSG::FATAL << "Unable to locate IDataProviderSvc interface"
00737 << endreq;
00738 return status;
00739 }
00740
00741 status = serviceLocator()->service("EventCnvSvc", m_pConversionSvc, true);
00742 if ( !status.isSuccess() ) {
00743 log << MSG::FATAL << "Unable to locate IConversionSvc interface"
00744 << endreq;
00745 return status;
00746 }
00747
00748 return status;
00749 }
00750
00751
00752 StatusCode BesVisAlg::finishSvc(){
00753 MsgStream log(msgSvc(), name());
00754 log << MSG::INFO << "finishSvc()" << endreq;
00755 StatusCode status = StatusCode::SUCCESS;
00756
00757 status = m_pRootInterface->f_finalize();
00758 if ( !status.isSuccess())
00759 log << MSG::ERROR << "f_finalize() error" << endreq;
00760
00761 status = m_pConversionSvc->commitOutput(f_rootOutputFile.c_str(), true);
00762 if ( !status.isSuccess())
00763 log << MSG::ERROR << "commitOutput() error" << endreq;
00764
00765 clearItems(m_itemList);
00766
00767 return StatusCode::SUCCESS;
00768 }
00769
00770
00771
00772 void BesVisAlg::addItem(Items& itms, const std::string& descriptor) {
00773 MsgStream log(msgSvc(), name());
00774 int level = 0;
00775 size_t sep = descriptor.rfind("#");
00776 std::string obj_path (descriptor,0,sep);
00777 std::string slevel (descriptor,sep+1,descriptor.length());
00778 if ( slevel == "*" ) {
00779 level = 9999999;
00780 }
00781 else {
00782 level = atoi(slevel.c_str());
00783 }
00784 size_t idx = obj_path.find("/",1);
00785 while (idx != std::string::npos) {
00786 std::string sub_item = obj_path.substr(0,idx);
00787 if ( 0 == findItem(sub_item) ) {
00788 addItem(itms, sub_item+"#1");
00789 }
00790 idx = obj_path.find("/",idx+1);
00791 }
00792 DataStoreItem* item = new DataStoreItem(obj_path, level);
00793 log << MSG::DEBUG << "Adding OutputStream item " << item->path()
00794 << " with " << item->depth()
00795 << " level(s)." << endreq;
00796 itms.push_back( item );
00797 }
00798
00799
00800 void BesVisAlg::clearItems(Items& itms) {
00801 for ( Items::iterator i = itms.begin(); i != itms.end(); i++ ) {
00802 delete (*i);
00803 }
00804 itms.erase(itms.begin(), itms.end());
00805 }
00806
00807
00808
00809 DataStoreItem*
00810 BesVisAlg::findItem(const std::string& path) {
00811 for (Items::const_iterator i=m_itemList.begin(); i != m_itemList.end(); ++i) {
00812 if ( (*i)->path() == path ) return (*i);
00813 }
00814 return 0;
00815 }
00816
00817
00818 StatusCode BesVisAlg::collectObjects(){
00819 MsgStream log(msgSvc(), name());
00820 StatusCode status = StatusCode::SUCCESS;
00821 Items::iterator i;
00822
00823
00824
00825 for ( i = m_itemList.begin(); i != m_itemList.end(); i++ ) {
00826 DataObject* obj = 0;
00827 IOpaqueAddress *pAddress = 0;
00828 m_currentItem = (*i);
00829
00830 status = m_pDataProvider->retrieveObject(m_currentItem->path(), obj);
00831 if ( status.isSuccess() ) {
00832 status = m_pConversionSvc->createRep(obj, pAddress);
00833 }
00834 else {
00835 log << MSG::WARNING << "Cannot write mandatory object(s) (Not found): "
00836 << m_currentItem->path() << endreq;
00837 }
00838 }
00839
00840
00841 return StatusCode::SUCCESS;
00842 }
00843
00844 StatusCode BesVisAlg::write2file(){
00845 MsgStream log(msgSvc(), name());
00846 StatusCode status = StatusCode::SUCCESS;
00847
00848 log << MSG::INFO << "write2file()" << endreq;
00849
00850 const std::string treename("Event");
00851
00852
00853
00854
00855
00856
00857
00858
00859 TDigiEvent *pTRawEvent = commonData::m_recEvt;
00860 if ( pTRawEvent == 0) {
00861 log << MSG::WARNING << "Can not get point TDigiEvent" << endreq;
00862 }
00863
00864 const std::string rawBranchname("TDigiEvent");
00865 int branchnr = -1;
00866
00867 m_pRootInterface = RootInterface::Instance(log);
00868 m_pRootInterface->f_addOutput(treename, f_rootOutputFile.c_str(), 1, 64000, 1);
00869
00870 if (pTRawEvent != 0) m_pRootInterface->f_createBranch(treename, rawBranchname,
00871 pTRawEvent->ClassName(),
00872 &pTRawEvent, branchnr);
00873
00874
00875
00876
00877 TEvtHeader *pTEvtHeader = commonData::m_EvtHeader;
00878 if ( pTEvtHeader == 0) {
00879 log << MSG::WARNING << "Can not get point TEvtHeader" << endreq;
00880 }
00881
00882 const std::string headerBranchname("TEvtHeader");
00883 branchnr = -1;
00884 if (pTEvtHeader != 0) m_pRootInterface->f_createBranch(treename, headerBranchname,
00885 pTEvtHeader->ClassName(),
00886 &pTEvtHeader, branchnr);
00887
00888
00889
00890
00891 TTrigEvent *pTTrigEvent = commonData::m_trigEvt;
00892 if ( pTTrigEvent == 0) {
00893 log << MSG::WARNING << "Can not get point TTrigEvent" << endreq;
00894 }
00895
00896 const std::string trigBranchname("TTrigEvent");
00897 branchnr = -1;
00898 if (pTTrigEvent != 0) m_pRootInterface->f_createBranch(treename, trigBranchname,
00899 pTTrigEvent->ClassName(),
00900 &pTTrigEvent, branchnr);
00901
00902
00903
00904
00905
00906 TRecTrackEvent *pTRecEvent = commonData::m_rectrackEvt;
00907 if ( pTRecEvent == 0) {
00908 log << MSG::WARNING << "Can not get point TRecEvent" << endreq;
00909 }
00910
00911 const std::string recBranchname("TRecEvent");
00912 branchnr = -1;
00913 if (pTRecEvent != 0) m_pRootInterface->f_createBranch(treename, recBranchname,
00914 pTRecEvent->ClassName(),
00915 &pTRecEvent, branchnr);
00916
00917
00918
00919 status = m_pRootInterface->f_fillTrees();
00920 if (status.isFailure())
00921 log << MSG::ERROR << "No Root tree was filled" << endreq;
00922
00923
00924
00925 return status;
00926
00927 }