Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

LCTOOLS.cc

Go to the documentation of this file.
00001 #include "UTIL/LCTOOLS.h"
00002 #include "UTIL/Operators.h"
00003 
00004 #include "EVENT/LCCollection.h"
00005 #include "EVENT/SimCalorimeterHit.h"
00006 #include "EVENT/CalorimeterHit.h"
00007 #include "EVENT/RawCalorimeterHit.h"
00008 #include "EVENT/SimTrackerHit.h"
00009 #include "EVENT/TPCHit.h"
00010 #include "EVENT/TrackerRawData.h"
00011 #include "EVENT/TrackerData.h"
00012 #include "EVENT/TrackerPulse.h"
00013 #include "EVENT/LCIO.h"
00014 #include "EVENT/MCParticle.h"
00015 #include "EVENT/LCFloatVec.h"
00016 #include "EVENT/LCIntVec.h"
00017 #include "IMPL/LCFlagImpl.h"
00018 #include "EVENT/Track.h"
00019 #include "EVENT/Cluster.h"
00020 #include "EVENT/ReconstructedParticle.h"
00021 #include "EVENT/Vertex.h"
00022 #include "EVENT/LCGenericObject.h"
00023 
00024 #include "EVENT/LCRelation.h"
00025 #include "LCIOSTLTypes.h"
00026 
00027 #ifdef USE_CLHEP
00028 #include "UTIL/LCFourVector.h"
00029 #endif
00030 #include "UTIL/LCObjectHandle.h"
00031 #include "UTIL/LCTime.h"
00032 #include "UTIL/CellIDDecoder.h"
00033 #include <map>
00034 #include <set>
00035 #include <cstdio>
00036 
00037 
00038 typedef std::vector<std::string> LCStrVec ;
00039 
00040 using namespace std ;
00041 using namespace EVENT ;
00042 using namespace IMPL ;
00043 
00044 
00045 namespace UTIL {
00046 
00047   static int MAX_HITS = 1000 ;
00048 
00049 
00050   void LCTOOLS::dumpEvent(const LCEvent* evt){
00051     
00052     // the event:
00053     cout << "///////////////////////////////////" << endl;
00054     cout << "EVENT: " << evt->getEventNumber() << endl
00055          << "RUN: " << evt->getRunNumber() << endl
00056          << "DETECTOR: " << evt->getDetectorName() << endl
00057          << "COLLECTIONS: (see below)" << endl;
00058     cout << "///////////////////////////////////" << endl << endl;
00059      
00060     cout << "---------------------------------------------------------------------------" << endl;
00061     cout.width(30); cout << left << "COLLECTION NAME";
00062     cout.width(25); cout << left << "COLLECTION TYPE";
00063     cout.width(20); cout << left << "NUMBER OF ELEMENTS" << endl;
00064     cout << "===========================================================================" << endl;
00065     
00066     const std::vector< std::string >* strVec = evt->getCollectionNames() ;
00067 
00068     // loop over collections:
00069     for( std::vector< std::string >::const_iterator name = strVec->begin() ; name != strVec->end() ; name++){
00070     
00071       cout.width(30); cout << left << *name;
00072       cout.width(25); cout << left << evt->getCollection( *name )->getTypeName();
00073       cout.width(9); cout << right << evt->getCollection( *name )->getNumberOfElements();
00074       cout << endl;
00075       //cout << "---------------------------------------------------------------------------" << endl;
00076     }
00077     cout << "---------------------------------------------------------------------------" << endl;
00078     cout << endl << endl << endl;
00079   }
00080 
00081   
00082   void LCTOOLS::dumpEventDetailed(const LCEvent* evt){
00083     
00084     // the event:
00085     cout << endl 
00086          << "==============================================================" << endl ;
00087     cout << "        Event  : " << evt->getEventNumber() 
00088          << " - run:  "         << evt->getRunNumber()
00089          << " - timestamp "     << evt->getTimeStamp()   
00090          << endl ;
00091     cout << "==============================================================" << endl ;    
00092 
00093     LCTime evtTime( evt->getTimeStamp() ) ;
00094     cout << " date:      "      << evtTime.getDateString() << endl ;     
00095     cout << " detector : "      << evt->getDetectorName() << endl ;
00096     
00097     cout << " event parameters: " << endl ; 
00098 
00099     printParameters( evt->getParameters() ) ;
00100 
00101 
00102     const std::vector< std::string >* strVec = evt->getCollectionNames() ;
00103 
00104     // loop over all collections:
00105     std::vector< std::string >::const_iterator name ;
00106     
00107     for( name = strVec->begin() ; name != strVec->end() ; name++){
00108     
00109       LCCollection* col = evt->getCollection( *name ) ;
00110     
00111       cout << endl 
00112            << " collection name : " << *name 
00113            << endl 
00114            << " parameters: " << endl ;
00115 
00116       //      printParameters( col->getParameters() ) ;
00117 
00118 
00119 
00120       // call the detailed print functions depending on type name
00121       if( evt->getCollection( *name )->getTypeName() == LCIO::MCPARTICLE ){
00122           
00123         printMCParticles( col ) ;
00124 
00125       }
00126       else if( evt->getCollection( *name )->getTypeName() == LCIO::SIMTRACKERHIT ){
00127           
00128         printSimTrackerHits( col ) ;
00129 
00130       }
00131       else if( evt->getCollection( *name )->getTypeName() == LCIO::TPCHIT ){
00132           
00133         printTPCHits( col ) ;
00134 
00135       }
00136       else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERHIT ){
00137           
00138         printTrackerHits( col ) ;
00139 
00140       }
00141       else if( evt->getCollection( *name )->getTypeName() == LCIO::SIMCALORIMETERHIT ){
00142           
00143         printSimCalorimeterHits( col ) ;
00144 
00145       }
00146       else if( evt->getCollection( *name )->getTypeName() == LCIO::CALORIMETERHIT ){
00147           
00148         printCalorimeterHits( col ) ;
00149 
00150       }
00151       else if( evt->getCollection( *name )->getTypeName() == LCIO::RAWCALORIMETERHIT ){
00152           
00153         printRawCalorimeterHits( col ) ;
00154 
00155       }
00156       else if( evt->getCollection( *name )->getTypeName() == LCIO::LCFLOATVEC ){
00157           
00158         printLCFloatVecs( col ) ;
00159 
00160       }
00161       else if( evt->getCollection( *name )->getTypeName() == LCIO::LCINTVEC ){
00162           
00163         printLCIntVecs( col ) ;                               
00164 
00165       }
00166       else if( evt->getCollection( *name )->getTypeName() == LCIO::LCSTRVEC ){
00167           
00168         printLCStrVecs( col ) ;                                 
00169 
00170       }
00171       else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACK ){
00172           
00173         printTracks( col ) ;
00174 
00175       }
00176       else if( evt->getCollection( *name )->getTypeName() == LCIO::CLUSTER ){
00177           
00178         printClusters( col ) ;
00179 
00180       }
00181       else if( evt->getCollection( *name )->getTypeName() == LCIO::RECONSTRUCTEDPARTICLE ){
00182           
00183         printReconstructedParticles( col ) ;
00184 
00185       }
00186       else if( evt->getCollection( *name )->getTypeName() == LCIO::VERTEX ){
00187           
00188         printVertices( col ) ;
00189 
00190       }
00191       else if( evt->getCollection( *name )->getTypeName() == LCIO::LCGENERICOBJECT ){
00192           
00193         printLCGenericObjects( col ) ;
00194 
00195       }
00196       else if( evt->getCollection( *name )->getTypeName() == LCIO::LCRELATION ){
00197           
00198         printRelation( col ) ;
00199       }
00200       else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERRAWDATA ){
00201           
00202         printTrackerRawData( col ) ;
00203       }
00204       else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERDATA ){
00205           
00206         printTrackerData( col ) ;
00207       }
00208       else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERPULSE ){
00209           
00210         printTrackerPulse( col ) ;
00211       }
00212 
00213     }
00214 
00215     // now dump the relations in the event
00216 //     const StringVec* relVec = evt->getRelationNames() ;
00217 //     for(StringVec::const_iterator name = relVec->begin() ; name != relVec->end() ; name++){
00218 //       LCRelation* rel = evt->getRelation( *name ) ;
00219 //       cout << endl 
00220 //         << " relation name : " << *name 
00221 //         << endl ;
00222       
00223 //       printRelation( rel ) ;
00224 //     }
00225 
00226   }
00227 
00228   void LCTOOLS::printTracks(const EVENT::LCCollection* col ){
00229     if( col->getTypeName() != LCIO::TRACK ){
00230       
00231       cout << " collection not of type " << LCIO::TRACK << endl ;
00232       return ;
00233     }
00234     cout << endl 
00235          << "--------------- " << "print out of "  << LCIO::TRACK << " collection "
00236          << "--------------- " << endl ;
00237     
00238     cout << endl 
00239          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00240     
00241     printParameters( col->getParameters() ) ;
00242 
00243     LCFlagImpl flag( col->getFlag() ) ;
00244     cout << "     LCIO::TRBIT_HITS : " << flag.bitSet( LCIO::TRBIT_HITS ) << endl ;
00245 
00246     int nTracks =  col->getNumberOfElements() ;
00247     int nPrint = nTracks > MAX_HITS ? MAX_HITS : nTracks ;
00248     
00249     std::cout << endl
00250               << " [   id   ] |   type   |    d0    |  phi     | omega    |    z0     | tan lambda|   reference point(x,y,z)        |    dEdx  |  dEdxErr |   chi2   "
00251               << endl 
00252               << "------------|----------|----------|----------|----------|-----------|-----------|---------------------------------|----------|----------|-------- "
00253               << endl ;
00254     
00255     for( int i=0 ; i< nPrint ; i++ ){
00256       
00257       Track* trk = 
00258         dynamic_cast<Track*>( col->getElementAt( i ) ) ;
00259       
00260       printf(" [%8.8x] | %8.8x | %4.2e | %4.2e | %4.2e | %5.3e | %5.3e | (%5.3e,%5.3e,%5.3e) | %4.2e | %4.2e | %4.2e \n"
00261              , trk->id()
00262              , trk->getType() 
00263              , trk->getD0() 
00264              , trk->getPhi()
00265              , trk->getOmega() 
00266              , trk->getZ0() 
00267              , trk->getTanLambda()
00268 //           , trk->getMomentum() 
00269 //           , trk->getTheta() 
00270 //           , trk->getPhi()
00271 //           , trk->getD0() 
00272 //           , trk->getZ0() 
00273              , trk->getReferencePoint()[0]
00274              , trk->getReferencePoint()[1]
00275              , trk->getReferencePoint()[2]
00276              , trk->getdEdx() 
00277              , trk->getdEdxError() 
00278              , trk->getChi2() 
00279              ) ;
00280       cout << " errors: " ;
00281       for(int l=0;l<15;l++){
00282         printf("%4.2e, ", trk->getCovMatrix()[l] ) ; 
00283       }
00284       cout << endl << " tracks(id): " ;
00285       const TrackVec& tracks = trk->getTracks() ;
00286 
00287       for(unsigned int l=0;l<tracks.size();l++){
00288                 printf("[%8.8x], ",  tracks[l]->id() ) ; 
00289       }
00290       cout << endl ;
00291       if( flag.bitSet( LCIO::TRBIT_HITS ) ) {
00292         cout << " hits ->" ;
00293         //      const StringVec& hitColNames = trk->getHitCollectionNames() ;
00294         //      for(unsigned int j=0;j<hitColNames.size();j++){
00295         //        cout << " " << hitColNames[j] << ": " ;
00296         //        const IntVec& hits = trk->getHitIndicesForCollection( hitColNames[j] ) ;
00297         //        for(unsigned int k=0;k<hits.size();k++){
00298         //          cout << hits[k] <<"," ;
00299         //        }
00300         //      }
00301         const TrackerHitVec& hits= trk->getTrackerHits() ; 
00302         for(unsigned int k=0;k<hits.size();k++){
00303           printf("[%8.8x] ", hits[k]->id() ) ;
00304           //      cout << "[" << hits[k]->id() <<"] " ;
00305         }
00306         cout << endl  ;
00307       }
00308       cout << " radius of innermost hit " << trk->getRadiusOfInnermostHit() << " / mm , "   
00309         << " subdetector Hit numbers : " ;
00310       for( unsigned int i=0 ; i< trk->getSubdetectorHitNumbers().size() ; i++) {
00311         cout << trk->getSubdetectorHitNumbers()[i] << ", " ;
00312       }
00313       cout << endl ;
00314 //       cout << trk->getType()     << " | "
00315 //         << trk->getMomentum() << " | "
00316 //         << trk->getTheta()     << " | "
00317 //         << trk->getPhi()     << " | "
00318 //         << trk->getD0()     << " | "
00319 //         << trk->getZ0()     << " | "
00320 //         << endl ;
00321 
00322       cout << "------------|----------|----------|----------|----------|-----------|-----------|---------------------------------|----------|----------|-------- "
00323            << endl ;
00324     }
00325   }
00326   
00327   void LCTOOLS::printSimTrackerHits(const EVENT::LCCollection* col ){
00328     
00329     if( col->getTypeName() != LCIO::SIMTRACKERHIT ){
00330       
00331       cout << " collection not of type " << LCIO::SIMTRACKERHIT << endl ;
00332       return ;
00333     }
00334     
00335     cout << endl 
00336          << "--------------- " << "print out of "  << LCIO::SIMTRACKERHIT << " collection "
00337          << "--------------- " << endl ;
00338     
00339     cout << endl 
00340          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00341 
00342     printParameters( col->getParameters() ) ;
00343     
00344     LCFlagImpl flag( col->getFlag() ) ;
00345     cout << "     LCIO::THBIT_BARREL : " << flag.bitSet( LCIO::THBIT_BARREL ) << endl ;
00346     cout << "     LCIO::THBIT_MOMENTUM : " << flag.bitSet( LCIO::THBIT_MOMENTUM ) << endl ;
00347     
00348     bool pStored = flag.bitSet( LCIO::THBIT_MOMENTUM ) ;
00349 
00350     int nHits =  col->getNumberOfElements() ;
00351     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00352     
00353     std::cout << endl
00354               << " cellID[indices] | position (x,y,z) | dEdx | time  | PDG of MCParticle"  ;
00355 
00356     if( pStored ) 
00357       std::cout  << " | (px, py, pz) | pathLength "  ;
00358         
00359     std::cout  << endl 
00360                << endl ;
00361     
00362     CellIDDecoder<SimTrackerHit> id( col ) ;
00363 
00364     for( int i=0 ; i< nPrint ; i++ ){
00365       
00366       SimTrackerHit* hit = 
00367         dynamic_cast<SimTrackerHit*>( col->getElementAt( i ) ) ;
00368       
00369 //       int id0 = hit->getCellID() ;
00370 
00371       int pdgid = 0;
00372       if( hit->getMCParticle() )
00373         pdgid = hit->getMCParticle()->getPDG() ;
00374       
00375       cout << i << ": "
00376            << hex << hit->getCellID() << dec << "[" 
00377            << id( hit ).valueString() << "] | ("
00378            << hit->getPosition()[0] << ", "
00379            << hit->getPosition()[1] << ", "
00380            << hit->getPosition()[2] << ") | " 
00381            << hit->getdEdx () << " | "
00382            << hit->getTime () << " | "
00383            << pdgid ; 
00384 
00385       if( pStored ) 
00386         cout << " | (" 
00387              << hit->getMomentum()[0] << ", "   
00388              << hit->getMomentum()[1] << ", "
00389              << hit->getMomentum()[2] << ") | " 
00390              << hit->getPathLength() ; 
00391 
00392       cout << endl ;
00393       
00394     }
00395     cout << endl 
00396          << "-------------------------------------------------------------------------------- " 
00397          << endl ;
00398     
00399   }
00400 
00401   void LCTOOLS::printTrackerHits(const EVENT::LCCollection* col ){
00402     
00403     if( col->getTypeName() != LCIO::TRACKERHIT ){
00404       
00405       cout << " collection not of type " << LCIO::TRACKERHIT << endl ;
00406       return ;
00407     }
00408     
00409     cout << endl 
00410          << "--------------- " << "print out of "  << LCIO::TRACKERHIT << " collection "
00411          << "--------------- " << endl ;
00412     
00413     cout << endl 
00414          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00415     
00416     printParameters( col->getParameters() ) ;
00417 
00418     LCFlagImpl flag( col->getFlag() ) ;
00419     cout << "     LCIO::THBIT_BARREL : " << flag.bitSet( LCIO::THBIT_BARREL ) << endl ;
00420     
00421     
00422     int nHits =  col->getNumberOfElements() ;
00423     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00424     
00425     std::cout << endl
00426               << " [   id   ] | position (x,y,z)                | dEdx      | time     |  type" 
00427               << endl 
00428               << endl ;
00429     
00430     for( int i=0 ; i< nPrint ; i++ ){
00431       
00432       TrackerHit* hit = 
00433         dynamic_cast<TrackerHit*>( col->getElementAt( i ) ) ;
00434       
00435       //       int rawHitId = 0 ;
00436       //       if( hit->getRawDataHit() != 0 ) 
00437       //        rawHitId = hit->getRawDataHit()->id()  ;
00438       
00439       printf(" [%8.8x] | (%5.3e,%5.3e,%5.3e) | %5.3e | %5.3e | [%d] \n" 
00440              , hit->id() 
00441              , hit->getPosition()[0] 
00442              , hit->getPosition()[1] 
00443              , hit->getPosition()[2] 
00444              , hit->getdEdx() 
00445              , hit->getTime() 
00446              , hit->getType() 
00447              ) ;
00448       const LCObjectVec& rawHits = hit->getRawHits() ;
00449       cout << "    rawHits: " ;
00450       try{
00451         for( unsigned j=0 ; j < rawHits.size() ; j++ ) {
00452           cout << hex << "[" << rawHits[j]->id() << "], " <<  dec ;
00453         }
00454       }catch(std::exception& e){}
00455       cout << endl ;
00456     }
00457     cout << endl 
00458          << "-------------------------------------------------------------------------------- " 
00459          << endl ;
00460     
00461   }
00462   
00463 void LCTOOLS::printTrackerRawData(const EVENT::LCCollection* col ) {
00464 
00465     if( col->getTypeName() != LCIO::TRACKERRAWDATA ){
00466 
00467       cout << " collection not of type " << LCIO::TRACKERRAWDATA << endl ;
00468       return ;
00469     }
00470     
00471     cout << endl 
00472          << "--------------- " << "print out of "  << LCIO::TRACKERRAWDATA << " collection "
00473          << "--------------- " << endl ;
00474     
00475     cout << endl 
00476          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00477 
00478     LCFlagImpl flag( col->getFlag() ) ;
00479     cout << "     LCIO::TRAWBIT_ID1    : " << flag.bitSet( LCIO::TRAWBIT_ID1 ) << endl ;
00480     
00481     printParameters( col->getParameters() ) ;
00482 
00483 //     LCFlagImpl flag( col->getFlag() ) ;
00484 //     cout << "     LCIO::THBIT_BARREL : " << flag.bitSet( LCIO::THBIT_BARREL ) << endl ;
00485     
00486     int nHits =  col->getNumberOfElements() ;
00487     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00488     
00489     std::cout << endl
00490               << " [   id   ] |  cellid0 |  cellid1 |   time    | chargeADC "
00491               << endl 
00492               << endl ;
00493     
00494     for( int i=0 ; i< nPrint ; i++ ){
00495       
00496       TrackerRawData* hit = 
00497         dynamic_cast<TrackerRawData*>( col->getElementAt( i ) ) ;
00498       
00499       printf(" [%8.8x] | %8.8x | %8.8x | %10d | " 
00500              , hit->id() 
00501              , hit->getCellID0()                 
00502              , hit->getCellID1()                 
00503              , hit->getTime ()  
00504              ) ;
00505       const ShortVec& charge = hit->getADCValues() ;
00506       for( unsigned j=0 ; j < charge.size() ; j++ ) {
00507         cout << charge[j] << "," ;
00508       }
00509       cout << endl ;
00510     }
00511     cout << endl 
00512          << "-------------------------------------------------------------------------------- " 
00513          << endl ;
00514     
00515   }
00516 
00517   void LCTOOLS::printTrackerData(const EVENT::LCCollection* col ) {
00518 
00519     if( col->getTypeName() != LCIO::TRACKERDATA ){
00520 
00521       cout << " collection not of type " << LCIO::TRACKERDATA << endl ;
00522       return ;
00523     }
00524     
00525     cout << endl 
00526          << "--------------- " << "print out of "  << LCIO::TRACKERDATA << " collection "
00527          << "--------------- " << endl ;
00528     
00529     cout << endl 
00530          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00531 
00532     LCFlagImpl flag( col->getFlag() ) ;
00533     cout << "     LCIO::TRAWBIT_ID1    : " << flag.bitSet( LCIO::TRAWBIT_ID1 ) << endl ;
00534     
00535     printParameters( col->getParameters() ) ;
00536 
00537 //     LCFlagImpl flag( col->getFlag() ) ;
00538 //     cout << "     LCIO::THBIT_BARREL : " << flag.bitSet( LCIO::THBIT_BARREL ) << endl ;
00539     
00540     int nHits =  col->getNumberOfElements() ;
00541     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00542     
00543     std::cout << endl
00544               << " [   id   ] |  cellid0 |  cellid1 |   time    | chargeADC "
00545               << endl 
00546               << endl ;
00547     
00548     for( int i=0 ; i< nPrint ; i++ ){
00549       
00550       TrackerData* hit = 
00551         dynamic_cast<TrackerData*>( col->getElementAt( i ) ) ;
00552       
00553       printf(" [%8.8x] | %8.8x | %8.8x | %5.3f  | " 
00554              , hit->id() 
00555              , hit->getCellID0()                 
00556              , hit->getCellID1()                 
00557              , hit->getTime ()  
00558              ) ;
00559       const FloatVec& charge = hit->getChargeValues() ;
00560       for( unsigned j=0 ; j < charge.size() ; j++ ) {
00561         cout << charge[j] << "," ;
00562       }
00563       cout << endl ;
00564     }
00565     cout << endl 
00566          << "-------------------------------------------------------------------------------- " 
00567          << endl ;
00568 
00569   }
00570 
00571   void LCTOOLS::printTrackerPulse(const EVENT::LCCollection* col ) {
00572 
00573     if( col->getTypeName() != LCIO::TRACKERPULSE ){
00574 
00575       cout << " collection not of type " << LCIO::TRACKERPULSE << endl ;
00576       return ;
00577     }
00578     
00579     cout << endl 
00580          << "--------------- " << "print out of "  << LCIO::TRACKERPULSE << " collection "
00581          << "--------------- " << endl ;
00582     
00583     cout << endl 
00584          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00585 
00586     LCFlagImpl flag( col->getFlag() ) ;
00587     cout << "     LCIO::TRAWBIT_ID1    : " << flag.bitSet( LCIO::TRAWBIT_ID1 ) << endl ;
00588     
00589     printParameters( col->getParameters() ) ;
00590 
00591     int nHits =  col->getNumberOfElements() ;
00592     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00593     
00594     std::cout << endl
00595               << " [   id   ] |  cha.id  |  time | charge| quality  | corr.Data  "
00596               << endl 
00597               << endl ;
00598     
00599     for( int i=0 ; i< nPrint ; i++ ){
00600       
00601       TrackerPulse* hit = 
00602         dynamic_cast<TrackerPulse*>( col->getElementAt( i ) ) ;
00603       
00604       printf(" [%8.8x] | %8.8x | %8.8x | %5.3f | %5.3f | %8.8x | " 
00605              , hit->id() 
00606              , hit->getCellID0()                 
00607              , hit->getCellID1()                 
00608              , hit->getTime()  
00609              , hit->getCharge()  
00610              , hit->getQuality()  
00611              ) ;
00612 
00613       TrackerData* corr =  hit->getTrackerData() ;
00614 //       if( corr != 0 )
00615 //      std::cout << corr->id() 
00616 
00617       printf("[%8.8x] ",   ( corr != 0 ? corr->id() : 0 ) ) ;
00618 
00619       cout << endl ;
00620     }
00621     cout << endl 
00622          << "-------------------------------------------------------------------------------- " 
00623          << endl ;
00624     
00625   }
00626 
00627   void LCTOOLS::printTPCHits(const EVENT::LCCollection* col ) {
00628     
00629     if( col->getTypeName() != LCIO::TPCHIT ){
00630       
00631       cout << " collection not of type " << LCIO::TPCHIT << endl ;
00632       return ;
00633     }
00634     
00635     cout << endl 
00636          << "--------------- " << "print out of "  << LCIO::TPCHIT << " collection "
00637          << "--------------- " << endl ;
00638     
00639     cout << endl 
00640          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00641     
00642     printParameters( col->getParameters() ) ;
00643 
00644     LCFlagImpl flag( col->getFlag() ) ;
00645     cout << "  -> LCIO::TPCBIT_RAW   : " << flag.bitSet( LCIO::TPCBIT_RAW ) << endl ;
00646     cout << "  -> LCIO::TPCBIT_NO_PTR   : " << flag.bitSet( LCIO::TPCBIT_NO_PTR ) << endl ;
00647     
00648     int nHits =  col->getNumberOfElements() ;
00649     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00650     
00651     std::cout << endl
00652               << " [   id   ]  | cellId0 | time | charge | quality " 
00653               << endl << "  -> raw data (bytes) : "
00654               << endl 
00655               << endl ;
00656     
00657     for( int i=0 ; i< nPrint ; i++ ){
00658       
00659       TPCHit* hit = 
00660         dynamic_cast<TPCHit*>( col->getElementAt( i ) ) ;
00661       
00662       int id0 = hit->getCellID()  ;
00663       //      std::cout << hit->getCellID() << " | " 
00664       printf( " [%8.8x] |", hit->id() ) ;
00665       std::cout << ((id0& 0xff000000)>>24) << "/" 
00666                 << ((id0& 0x00ff0000)>>16) << "/" 
00667                 << ((id0& 0x0000ff00)>> 8) << "/" 
00668                 << ((id0& 0x000000ff)>> 0) << " | "
00669                 << hit->getTime() << " | "
00670                 << hit->getCharge() << " | ["
00671                 << hit->getQuality() << "] "
00672                 << std::endl ;
00673       if( flag.bitSet( LCIO::TPCBIT_RAW ) ){
00674 
00675         int nWords = hit->getNRawDataWords() ;
00676         std::cout << "  ->  " ;
00677 
00678         for(int  j=0;j<nWords;j++){
00679           int rawData = hit->getRawDataWord( j ) ;
00680           std::cout << ((rawData& 0xff000000)>>24) << ", " 
00681                     << ((rawData& 0x00ff0000)>>16) << ", " 
00682                     << ((rawData& 0x0000ff00)>> 8) << ", " 
00683                     << ((rawData& 0x000000ff)>> 0)  ;
00684           if( j < nWords-1) std::cout << ", " ;
00685         }
00686 
00687         std::cout << std::endl ;
00688 
00689       }
00690     }
00691     cout << endl 
00692          << "-------------------------------------------------------------------------------- " 
00693          << endl ;
00694   }
00695 
00696   void LCTOOLS::printLCStrVecs( const EVENT::LCCollection* col ) {
00697 
00698     if( col->getTypeName() != LCIO::LCSTRVEC ){
00699 
00700       cout << " collection not of type " << LCIO::LCSTRVEC << endl ;
00701       return ;
00702     }
00703 
00704     cout << endl 
00705          << "--------------- " << "print out of "  << LCIO::LCSTRVEC << " collection (user extension) "
00706          << "--------------- " << endl ;
00707 
00708     cout << endl 
00709          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00710  
00711     printParameters( col->getParameters() ) ;
00712 
00713     int nHits =  col->getNumberOfElements() ;
00714     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00715 
00716     std::cout << endl
00717               << " element index: val0, val1, ..." 
00718               << endl 
00719               << endl ;
00720     
00721     for( int i=0 ; i< nPrint ; i++ ){
00722       
00723       LCStrVec* vec =
00724         dynamic_cast<LCStrVec*>( col->getElementAt( i ) ) ;
00725       
00726       std::cout << i << ": " ;
00727       for(unsigned int j=0;j< vec->size();j++){
00728 
00729         std::cout << (*vec)[j] ;
00730         if( j<vec->size()-1) std::cout << ", " ;
00731 
00732         if( ! ( (j+1) % 10)  ) std::cout << endl << "     " ;
00733       }
00734       std::cout << std::endl ;
00735     }
00736     cout << endl 
00737          << "-------------------------------------------------------------------------------- " 
00738          << endl ;
00739 
00740   }
00741 
00742   void LCTOOLS::printLCFloatVecs( const EVENT::LCCollection* col ) {
00743 
00744     if( col->getTypeName() != LCIO::LCFLOATVEC ){
00745 
00746       cout << " collection not of type " << LCIO::LCFLOATVEC << endl ;
00747       return ;
00748     }
00749 
00750     cout << endl 
00751          << "--------------- " << "print out of "  << LCIO::LCFLOATVEC << " collection (user extension) "
00752          << "--------------- " << endl ;
00753 
00754     cout << endl 
00755          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00756  
00757     printParameters( col->getParameters() ) ;
00758 
00759     int nHits =  col->getNumberOfElements() ;
00760     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00761 
00762     std::cout << endl
00763               << " element index: val0, val1, ..." 
00764               << endl 
00765               << endl ;
00766     
00767     for( int i=0 ; i< nPrint ; i++ ){
00768       
00769       LCFloatVec* vec = 
00770         dynamic_cast<LCFloatVec*>( col->getElementAt( i ) ) ;
00771       
00772       std::cout << i << ": " ;
00773       for(unsigned int j=0;j< vec->size();j++){
00774 
00775         std::cout << (*vec)[j] ;
00776         if( j<vec->size()-1) std::cout << ", " ;
00777 
00778         if( ! ( (j+1) % 10)  ) std::cout << endl << "     " ;
00779       }
00780       std::cout << std::endl ;
00781     }
00782     cout << endl 
00783          << "-------------------------------------------------------------------------------- " 
00784          << endl ;
00785 
00786   }
00787   void LCTOOLS::printLCIntVecs( const EVENT::LCCollection* col ) {
00788 
00789     if( col->getTypeName() != LCIO::LCINTVEC ){
00790 
00791       cout << " collection not of type " << LCIO::LCINTVEC << endl ;
00792       return ;
00793     }
00794 
00795     cout << endl 
00796          << "--------------- " << "print out of "  << LCIO::LCINTVEC << " collection (user extension) "
00797          << "--------------- " << endl ;
00798 
00799     cout << endl 
00800          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00801  
00802     printParameters( col->getParameters() ) ;
00803 
00804     int nHits =  col->getNumberOfElements() ;
00805     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00806 
00807     std::cout << endl
00808               << " element index: val0, val1, ..." 
00809               << endl 
00810               << endl ;
00811     
00812     for( int i=0 ; i< nPrint ; i++ ){
00813       
00814       LCIntVec* vec = 
00815         dynamic_cast<LCIntVec*>( col->getElementAt( i ) ) ;
00816       
00817       std::cout << i << ": " ;
00818       for(unsigned int j=0;j< vec->size();j++){
00819 
00820         std::cout << (*vec)[j] ;
00821         if( j<vec->size()-1) std::cout << ", " ;
00822 
00823         if( ! ( (j+1) % 10)  ) std::cout << endl << "     " ;
00824       }
00825       std::cout << std::endl ;
00826     }
00827     cout << endl 
00828          << "-------------------------------------------------------------------------------- " 
00829          << endl ;
00830 
00831   }
00832 
00833   void LCTOOLS::printSimCalorimeterHits(const EVENT::LCCollection* col ){
00834     
00835     if( col->getTypeName() != LCIO::SIMCALORIMETERHIT ){
00836       
00837       cout << " collection not of type " << LCIO::SIMCALORIMETERHIT << endl ;
00838       return ;
00839     }
00840 
00841     cout << endl 
00842          << "--------------- " << "print out of "  << LCIO::SIMCALORIMETERHIT << " collection "
00843          << "--------------- " << endl ;
00844 
00845     cout << endl 
00846          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00847  
00848     printParameters( col->getParameters() ) ;
00849 
00850     LCFlagImpl flag( col->getFlag() ) ;
00851     cout << "  -> LCIO::CHBIT_LONG   : " << flag.bitSet( LCIO::CHBIT_LONG ) << endl ;
00852     cout << "     LCIO::CHBIT_BARREL : " << flag.bitSet( LCIO::CHBIT_BARREL ) << endl ;
00853     cout << "     LCIO::CHBIT_ID1   :  " << flag.bitSet( LCIO::CHBIT_ID1 ) << endl ;
00854     cout << "     LCIO::CHBIT_PDG    : " << flag.bitSet( LCIO::CHBIT_PDG ) << endl ;
00855 
00856     int nHits =  col->getNumberOfElements() ;
00857     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00858 
00859     
00860     CellIDDecoder<SimCalorimeterHit> idDecoder( col ) ; 
00861 
00862     // std::cout << "Note: ( M, S, I, J, K) are decoded using the Mokka convention ! " 
00863     // << std::endl ; 
00864 
00865     std::cout << endl
00866               << " [   id   ] |  cellId0 | cellId1  |   energy  |        position (x,y,z)          | nMCParticles "
00867               << endl << "           -> MC contribution: prim. PDG |  energy | time | sec. PDG  "
00868               << endl 
00869               << endl ;
00870 
00871     for( int i=0 ; i< nPrint ; i++ ){
00872       
00873       SimCalorimeterHit* hit = 
00874         dynamic_cast<SimCalorimeterHit*>( col->getElementAt( i ) ) ;
00875       
00876       int id0 = hit->getCellID0() ;
00877       int id1 = hit->getCellID1() ;
00878             
00879       
00880       if( flag.bitSet( LCIO::CHBIT_LONG ) ){
00881         printf( " [%8.8x] | %8.8x | %8.8x |"
00882                 " %5.3e | (%5.3e,%5.3e,%5.3e)| %d\n" , 
00883                 hit->id(), 
00884                 id0,
00885                 id1,
00886                 hit->getEnergy() ,
00887                 hit->getPosition()[0] ,
00888                 hit->getPosition()[1] ,
00889                 hit->getPosition()[2] ,
00890                 hit->getNMCContributions()
00891                 ) ;
00892       } else{
00893         printf( " [%8.8x] | %8.8x | %8.8x |"
00894                 " %5.3e |    no position available         | %d\n" , 
00895                 hit->id(), 
00896                 id0,
00897                 id1,
00898                 hit->getEnergy() ,
00899                 hit->getNMCContributions()
00900                 ) ;
00901        }
00902       std::cout << "        id-fields: (" << idDecoder( hit ).valueString() << ")" << std::endl ; 
00903 
00904       //-------- example : acessing cell id components, e.g. layer: 
00905 //       int layer =  idDecoder( hit )["K-1"] + 1  ;
00906 //       cout << "  ---- debug  ---  hit layer : " <<  layer << std::endl ;
00907 
00908       for(int k=0;k < hit->getNMCContributions();k++){
00909 
00910         try{
00911           cout << "           ->   " 
00912                << hit->getParticleCont( k)->getPDG() << ": " 
00913                << hit->getEnergyCont( k)             << " | " 
00914                << hit->getTimeCont( k)               << " | " ;
00915 
00916           if( flag.bitSet( LCIO::CHBIT_PDG ) )
00917             cout << hit->getPDGCont( k) << " | " << endl ;
00918           else
00919             cout << " no PDG" << endl ;
00920         } 
00921 
00922         catch(exception& e){
00923           cout << e.what() << endl ;
00924         }
00925 
00926       }
00927 
00928 
00929     }
00930     cout << endl 
00931          << "-------------------------------------------------------------------------------- " 
00932          << endl ;
00933   }
00934 
00935   void LCTOOLS::printCalorimeterHits(const EVENT::LCCollection* col ){
00936 
00937     if( col->getTypeName() != LCIO::CALORIMETERHIT ){
00938 
00939       cout << " collection not of type " << LCIO::CALORIMETERHIT << endl ;
00940       return ;
00941     }
00942 
00943     cout << endl 
00944          << "--------------- " << "print out of "  << LCIO::CALORIMETERHIT << " collection "
00945          << "--------------- " << endl ;
00946 
00947     cout << endl 
00948          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
00949  
00950     printParameters( col->getParameters() ) ;
00951 
00952     LCFlagImpl flag( col->getFlag() ) ;
00953     cout << "  -> LCIO::RCHBIT_LONG   : " << flag.bitSet( LCIO::RCHBIT_LONG ) << endl ;
00954     cout << "     LCIO::RCHBIT_BARREL : " << flag.bitSet( LCIO::RCHBIT_BARREL ) << endl ;
00955     cout << "     LCIO::RCHBIT_ID1    : " << flag.bitSet( LCIO::RCHBIT_ID1 ) << endl ;
00956     cout << "     LCIO::RCHBIT_TIME   : " << flag.bitSet( LCIO::RCHBIT_TIME ) << endl ;
00957     cout << "     LCIO::RCHBIT_NO_PTR : " << flag.bitSet( LCIO::RCHBIT_NO_PTR ) << endl ;
00958 
00959     int nHits =  col->getNumberOfElements() ;
00960     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
00961 
00962     CellIDDecoder<CalorimeterHit> idDecoder( col ) ; 
00963 
00964 //     std::cout << "Note: ( M, S, I, J, K) are decoded using the Mokka convention ! " << std::endl ; 
00965 
00966 
00967     std::cout << endl
00968               << " [   id   ] |  cellId0 | cellId1  |   energy  |        position (x,y,z)          |"
00969               << endl ;
00970 
00971     for( int i=0 ; i< nPrint ; i++ ){
00972       
00973       CalorimeterHit* hit = 
00974         dynamic_cast<CalorimeterHit*>( col->getElementAt( i ) ) ;
00975       
00976       int id0 = hit->getCellID0() ;
00977       int id1 = hit->getCellID1() ;
00978       
00979       if( flag.bitSet( LCIO::CHBIT_LONG ) ){
00980         printf( " [%8.8x] | %8.8x | %8.8x |"
00981                 " %5.3e | (%5.3e,%5.3e,%5.3e)|\n" , 
00982                 hit->id(), 
00983                 id0,
00984                 id1,
00985                 hit->getEnergy() ,
00986                 hit->getPosition()[0] ,
00987                 hit->getPosition()[1] ,
00988                 hit->getPosition()[2]
00989                 ) ;
00990       } else{
00991         printf( " [%8.8x] | %8.8x | %8.8x |"
00992                 " %5.3e |    no position available         \n" , 
00993                 hit->id(), 
00994                 id0,
00995                 id1,
00996                 hit->getEnergy()
00997                 ) ;
00998       }
00999       std::cout << "        id-fields: (" << idDecoder( hit ).valueString() << ")" << std::endl ; 
01000 
01001 
01002     }
01003     cout << endl 
01004          << "-------------------------------------------------------------------------------- " 
01005          << endl ;
01006   }
01007   void LCTOOLS::printRawCalorimeterHits(const EVENT::LCCollection* col ){
01008 
01009     if( col->getTypeName() != LCIO::RAWCALORIMETERHIT ){
01010 
01011       cout << " collection not of type " << LCIO::RAWCALORIMETERHIT << endl ;
01012       return ;
01013     }
01014 
01015     cout << endl 
01016          << "--------------- " << "print out of "  << LCIO::RAWCALORIMETERHIT << " collection "
01017          << "--------------- " << endl ;
01018 
01019     cout << endl 
01020          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
01021  
01022     printParameters( col->getParameters() ) ;
01023 
01024     LCFlagImpl flag( col->getFlag() ) ;
01025 
01026     cout << "     LCIO::RCHBIT_ID1    : " << flag.bitSet( LCIO::RCHBIT_ID1 ) << endl ;
01027     cout << "     LCIO::RCHBIT_TIME   : " << flag.bitSet( LCIO::RCHBIT_TIME ) << endl ;
01028     cout << "     LCIO::RCHBIT_NO_PTR : " << flag.bitSet( LCIO::RCHBIT_NO_PTR ) << endl ;
01029 
01030     int nHits =  col->getNumberOfElements() ;
01031     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
01032 
01033 
01034     CellIDDecoder<RawCalorimeterHit> idDecoder( col ) ; 
01035 
01036     std::cout << endl
01037               << " [   id   ] |  cellId0 ( M, S, I, J, K) | cellId1  | amplitude |  time  "
01038               << endl ;
01039     
01040     for( int i=0 ; i< nPrint ; i++ ){
01041       
01042       RawCalorimeterHit* hit = 
01043         dynamic_cast<RawCalorimeterHit*>( col->getElementAt( i ) ) ;
01044       
01045       int id0 = hit->getCellID0() ;
01046       int id1 = hit->getCellID1() ;
01047       
01048       printf( " [%8.8x] | %8.8x | %8.8x |"
01049               " %10d |  %10d \n" , 
01050               hit->id(), 
01051               id0,
01052               id1,
01053               hit->getAmplitude() ,
01054               hit->getTimeStamp()
01055               ) ;
01056       std::cout << "        id-fields: (" << idDecoder( hit ).valueString() << ")" << std::endl ; 
01057 
01058 
01059 
01060     }
01061     cout << endl 
01062          << "-------------------------------------------------------------------------------- " 
01063          << endl ;
01064   }
01065 
01066   void LCTOOLS::printClusters(const EVENT::LCCollection* col ){
01067     if( col->getTypeName() != LCIO::CLUSTER ){
01068       
01069       cout << " collection not of type " << LCIO::CLUSTER << endl ;
01070       return ;
01071     }
01072     cout << endl 
01073          << "--------------- " << "print out of "  << LCIO::CLUSTER << " collection "
01074          << "--------------- " << endl ;
01075     
01076     cout << endl 
01077          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
01078     
01079     printParameters( col->getParameters() ) ;
01080 
01081     LCFlagImpl flag( col->getFlag() ) ;
01082     cout << "     LCIO::CLBIT_HITS : " << flag.bitSet( LCIO::CLBIT_HITS ) << endl ;
01083     
01084     int nClusters =  col->getNumberOfElements() ;
01085     int nPrint = nClusters > MAX_HITS ? MAX_HITS : nClusters ;
01086     
01087     std::cout << endl
01088               << " [   id   ] |  type | energy    |      position ( x,y,z)          |  itheta   |  iphi "
01089 //    | EMweight |HADweight |MUweight"
01090               << endl         
01091               << "------------|-------|-----------|---------------------------------|----------|----------|----------|----------|---------"
01092               << endl ;
01093     
01094     for( int i=0 ; i< nPrint ; i++ ){
01095       
01096       Cluster* clu = 
01097         dynamic_cast<Cluster*>( col->getElementAt( i ) ) ;
01098       
01099       printf(" [%8.8x] |0x%5x| %5.3e | (%5.3e,%5.3e,%5.3e) | %4.2e | %4.2e \n"// | %4.2e | %4.2e | %4.2e \n"
01100              , clu->id()
01101              , clu->getType() 
01102              , clu->getEnergy() 
01103              , clu->getPosition()[0]
01104              , clu->getPosition()[1]
01105              , clu->getPosition()[2]
01106              , clu->getITheta() 
01107              , clu->getIPhi()
01108 //           , clu->getParticleType()[0] 
01109 //           , clu->getParticleType()[1] 
01110 //           , clu->getParticleType()[2] 
01111              ) ;
01112       cout << " errors (6 pos)/( 3 dir): (" ;
01113       for(int l=0;l<6;l++){
01114         printf("%4.2e, ", clu->getPositionError()[l] ) ; 
01115       }
01116       cout << ")/("  ;
01117       for(int l=0;l<3;l++){
01118         printf("%4.2e, ", clu->getDirectionError()[l] ) ; 
01119       }
01120       cout << ")" << endl ;
01121       cout << " clusters(e): " ;
01122       const ClusterVec& clusters = clu->getClusters() ;
01123 
01124       for(unsigned int l=0;l<clusters.size();l++){
01125                 printf("%4.2e, ",  clusters[l]->getEnergy() ) ; 
01126       }
01127       cout << endl ;
01128       if( flag.bitSet( LCIO::CLBIT_HITS ) ) {
01129         cout << " hits ->";
01130 //      const StringVec& hitColNames = clu->getHitCollectionNames() ;
01131 //      for(unsigned int j=0;j<hitColNames.size();j++){
01132 //        cout << " " << hitColNames[j] << ": " ;
01133 
01134 //        const IntVec& hits = clu->getHitIndicesForCollection( hitColNames[j] ) ;
01135 //        const FloatVec& wgts = clu->getHitContributionsForCollection( hitColNames[j] ) ;
01136 
01137 //        for(unsigned int k=0;k<hits.size();k++){
01138 //          cout << hits[k] <<" ["<< wgts[k] <<"], " ;
01139 //        }
01140 //      }
01141 
01142         const CalorimeterHitVec& hits= clu->getCalorimeterHits() ; 
01143         const FloatVec& contr = clu->getHitContributions() ; 
01144         for(unsigned int k=0;k<hits.size();k++){
01145           printf( " [%8.8x] (%4.3e), " , hits[k]->id(), contr[k] ) ;
01146           //      cout << "0x" << hits[k]  << "(" << contr[k] << "), " ;
01147         }
01148         cout << dec << endl  ;
01149 
01150 
01151       }
01152       cout << endl 
01153            << "-------|-----------|---------------------------------|----------|----------|----------|----------|---------"
01154            << endl ;
01155     }
01156       cout << endl 
01157            << "-------------------------------------------------------------------------------- " 
01158            << endl ;
01159   }
01160 
01161   void LCTOOLS::printVertices( const EVENT::LCCollection* col ){
01162     if( col->getTypeName() != LCIO::VERTEX ){
01163       
01164       cout << " collection not of type " << LCIO::VERTEX << endl ;
01165       return ;
01166     }
01167     cout << endl 
01168          << "--------------- " << "print out of "  << LCIO::VERTEX << " collection "
01169          << "--------------- " << endl << endl;
01170     
01171     printParameters( col->getParameters() ) ;
01172     
01173     int nVertices = col->getNumberOfElements() ;
01174     int nPrint = nVertices > MAX_HITS ? MAX_HITS : nVertices ;
01175     
01176     for( int i=0 ; i< nPrint ; i++ ){
01177       Vertex* v = dynamic_cast<Vertex*>( col->getElementAt( i ) ) ;
01178       
01179       if( i==0) { cout<<header(v); }
01180       //cout<<lcshort(v,col);
01181       cout<<lcshort(v);
01182       if(i==nPrint-1){ cout<<tail(v); }
01183     }
01184   }
01185 
01186   void LCTOOLS::printReconstructedParticles( const EVENT::LCCollection* col ){
01187 
01188     if( col->getTypeName() != LCIO::RECONSTRUCTEDPARTICLE ){
01189       
01190       cout << " collection not of type " << LCIO::RECONSTRUCTEDPARTICLE << endl ;
01191       return ;
01192     }
01193     cout << endl 
01194          << "--------------- " << "print out of "  << LCIO::RECONSTRUCTEDPARTICLE << " collection "
01195          << "--------------- " << endl ;
01196     
01197     cout << endl 
01198          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
01199     
01200     printParameters( col->getParameters() ) ;
01201 
01202 //     LCFlagImpl flag( col->getFlag() ) ;
01203 //     cout << "     LCIO::CLBIT_HITS : " << flag.bitSet( LCIO::CLBIT_HITS ) << endl ;
01204     
01205     int nReconstructedParticles =  col->getNumberOfElements() ;
01206     int nPrint = nReconstructedParticles > MAX_HITS ? MAX_HITS : nReconstructedParticles ;
01207     
01208     std::cout << endl
01209               << " [   id   ] |com|type|     momentum( px,py,pz)         | energy   | mass     | charge    |          position ( x,y,z)       | [pidUsed] "
01210               << endl         
01211               << "  ----------|---|----|---------------------------------|----------|----------|-----------|----------------------------------|-----------"
01212               << endl ;
01213     
01214     for( int i=0 ; i< nPrint ; i++ ){
01215       
01216 #ifdef USE_CLHEP
01217       ReconstructedParticle4V recP( col->getElementAt( i ) ) ;
01218 #else
01219       ReconstructedParticle* recP = 
01220         dynamic_cast<ReconstructedParticle*>( col->getElementAt( i ) ) ;
01221 #endif
01222 
01223       
01224       int compound = recP->isCompound() ;
01225       int type =  recP->getType() ;
01226 
01227 
01228       int pidUsed = 0 ;
01229 
01230       if(  recP->getParticleIDUsed() != 0 ) 
01231         pidUsed  = recP->getParticleIDUsed()->id() ;
01232       
01233       printf(" [%8.8x] | %1d | %2d | (%5.3e,%5.3e,%5.3e) | %4.2e | %4.2e | %4.2e | (%5.3e,%5.3e,%5.3e) | [%8.8x]\n"
01234              //      , reinterpret_cast<int> ( recP )
01235              , recP->id()
01236              , compound
01237              , type
01238              , recP->getMomentum()[0]
01239              , recP->getMomentum()[1]
01240              , recP->getMomentum()[2]
01241              , recP->getEnergy() 
01242              , recP->getMass() 
01243              , recP->getCharge()
01244              , recP->getReferencePoint()[0] 
01245              , recP->getReferencePoint()[1] 
01246              , recP->getReferencePoint()[2] 
01247              , pidUsed
01248              //, (recP->getStartVertex()!=NULL?recP->getStartVertex()->id():0)
01249              //, (recP->getEndVertex()!=NULL?recP->getEndVertex()->id():0)
01250              ) ;
01251       cout << "    covariance( px,py,pz,E) : (" ;
01252       for(int l=0;l<10;l++){
01253         printf("%4.2e, ", recP->getCovMatrix()[l] ) ; 
01254       }
01255       cout << ")" << endl ;
01256 
01257       cout << "    particles ( [   id   ] ):" ;
01258       for(unsigned int l=0;l<recP->getParticles().size();l++){
01259         printf("[%8.8x], ", recP->getParticles()[l]->id() ) ;
01260         //,  recP->getParticleWeights()[l]  ) ; 
01261       }
01262       cout << endl ;
01263       cout << "    tracks ( [   id   ] ): " ;
01264       for(unsigned int l=0;l<recP->getTracks().size();l++){
01265         printf("[%8.8x], ",  recP->getTracks()[l]->id() );
01266         //,            recP->getTrackWeights()[l]  ) ; 
01267       }
01268       cout << endl ;
01269       cout << "    clusters ( [   id   ] ): " ;
01270       for(unsigned int l=0;l<recP->getClusters().size();l++){
01271         printf("[%8.8x], ",  recP->getClusters()[l]->id() );
01272         //,       recP->getClusterWeights()[l]  ) ; 
01273       }
01274       cout << endl ;
01275       cout << "    particle ids ( [id], PDG, (type)): " ;
01276       for(unsigned int l=0;l<recP->getParticleIDs().size();l++){
01277         ParticleID* pid = recP->getParticleIDs()[l] ;
01278         printf("[%8.8x], %6.6d, (%6.6d)  ",  pid->id() , pid->getPDG() , pid->getType() ) ;
01279       }
01280       cout << endl ;
01281       
01282       Vertex* sv = dynamic_cast<Vertex*>(recP->getStartVertex());
01283       Vertex* ev = dynamic_cast<Vertex*>(recP->getEndVertex());
01284       ReconstructedParticle* svr=0;
01285       ReconstructedParticle* evr=0;
01286       
01287       if(sv!=0){
01288          svr = dynamic_cast<ReconstructedParticle*>(sv->getAssociatedParticle());
01289       }
01290       if(ev!=0){
01291          evr = dynamic_cast<ReconstructedParticle*>(ev->getAssociatedParticle());
01292       }
01293       
01294       printf("    vertices: startVertex( id:[%8.8x], id_aRP:[%8.8x] )   endVertex( id:[%8.8x], id_aRP:[%8.8x] ) "
01295         , ( sv != 0 ? sv->id() : 0 )
01296         , ((sv != 0 && svr != 0) ? svr->id() : 0 )
01297         , ( ev != 0 ? ev->id() : 0 )
01298         , ((ev != 0 && evr != 0) ? evr->id() : 0 )
01299       ) ;
01300      
01301       cout << endl ;
01302 
01303 //       cout << "    MCParticles ( [   id   ] (weight) ): " ;
01304 //       for(unsigned int l=0;l<recP->getMCParticles().size();l++){
01305 //      printf("[%8.8x] (%f), ",  recP->getMCParticles()[l]->id() ,
01306 //             recP->getMCParticleWeights()[l]  ) ; 
01307 //       }
01308       cout << endl ;
01309 
01310 //       cout << endl ;
01311 //       if( flag.bitSet( LCIO::CLBIT_HITS ) ) {
01312 //      cout << " hits ->";
01313 //      const StringVec& hitColNames = recP->getHitCollectionNames() ;
01314 //      for(unsigned int j=0;j<hitColNames.size();j++){
01315 //        cout << " " << hitColNames[j] << ": " ;
01316 
01317 //        const IntVec& hits = recP->getHitIndicesForCollection( hitColNames[j] ) ;
01318 //        const FloatVec& wgts = recP->getHitContributionsForCollection( hitColNames[j] ) ;
01319 
01320 //        for(unsigned int k=0;k<hits.size();k++){
01321 //          cout << hits[k] <<" ["<< wgts[k] <<"], " ;
01322 //        }
01323 //      }
01324 //       }
01325       cout  << "------------|---|----|---------------------------------|----------|----------|-----------|---------------------------------|-----------|"
01326             << endl ;
01327     }
01328       cout << endl 
01329            << "-------------------------------------------------------------------------------- " 
01330            << endl ;
01331     
01332   }
01333 
01334   void LCTOOLS::printLCGenericObjects( const EVENT::LCCollection* col ){
01335     
01336     if( col->getTypeName() != LCIO::LCGENERICOBJECT ){
01337       
01338       cout << " collection not of type " << LCIO::LCGENERICOBJECT 
01339            << " [ " <<  col->getParameters().getStringVal("TypeName") << " ] " 
01340            << endl ;
01341       
01342       return ;
01343     }
01344     cout << endl 
01345          << "--------------- " << "print out of "  << LCIO::LCGENERICOBJECT << " collection "
01346          << "--------------- " << endl ;
01347     
01348     cout << endl 
01349          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
01350 
01351     printParameters( col->getParameters() ) ;
01352 
01353     int nLCGenericObjects =  col->getNumberOfElements() ;
01354     int nPrint = nLCGenericObjects > MAX_HITS ? MAX_HITS : nLCGenericObjects ;
01355     
01356     bool isFixedSize  =  LCFlagImpl( col->getFlag() ).bitSet( LCIO::GOBIT_FIXED ) ;
01357     
01358     cout << endl
01359          << " [   id   ] " <<  col->getParameters().getStringVal("DataDescription") 
01360          << " - isFixedSize: "   <<  ( isFixedSize ? "true" : "false" )
01361          << endl ;
01362     
01363     for( int i=0 ; i< nPrint ; i++ ){
01364       
01365       LCGenericObject* obj = dynamic_cast<LCGenericObject*> ( col->getElementAt(i) );
01366       
01367       printf("[%8.8x] ", obj->id() ) ;
01368       
01369       for(int j=0;j<obj->getNInt();j++)
01370         cout << "i:" << obj->getIntVal( j ) << "; " ;
01371       for(int j=0;j<obj->getNFloat();j++)
01372         cout << "f:" << obj->getFloatVal( j ) << "; " ;
01373       for(int j=0;j<obj->getNDouble();j++)
01374         cout << "d:" << obj->getDoubleVal( j ) << "; " ;
01375       
01376       cout << endl ;
01377       
01378     }
01379     cout << endl 
01380            << "-------------------------------------------------------------------------------- " 
01381            << endl ;
01382       
01383    
01384   }
01385 
01386 
01387   void LCTOOLS::printMCParticles(const EVENT::LCCollection* col ) {
01388     
01389     if( col->getTypeName() != LCIO::MCPARTICLE ){
01390       
01391       cout << " collection not of type " << LCIO::MCPARTICLE << endl ;
01392       return ;
01393     }
01394     
01395     cout << endl 
01396          << "--------------- " << "print out of "  << LCIO::MCPARTICLE << " collection "
01397          << "--------------- " << endl ;
01398     
01399     cout << endl 
01400          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
01401     
01402     printParameters( col->getParameters() ) ;
01403 
01404     int nParticles =  col->getNumberOfElements() ;
01405 
01406 
01407 
01408     // fill map with particle pointers and collection indices
01409     typedef std::map< MCParticle*, int > PointerToIndexMap ;
01410     PointerToIndexMap p2i_map ;
01411     std::vector<MCParticle*> moms ;
01412 
01413     for( int k=0; k<nParticles; k++){
01414 
01415       MCParticle* part =  dynamic_cast<MCParticle*>( col->getElementAt( k ) ) ;
01416       p2i_map[ part ] = k ; 
01417 
01418       moms.push_back( part ) ;
01419     }
01420 
01421     std::cout << endl
01422               << " [   id   ] | index [parents] | [daughters] | PDG | (px, py, pz) | GenStatus | SimStatus | vertex (x,y,z) | endpoint(x,y,z)" 
01423               << " | mass | charge | energy"
01424               << endl 
01425               << endl ;
01426 
01427 
01428 //    // now loop over mothers and print daughters recursively
01429 //     int index = 0 ;
01430 //     std::vector<MCParticle*>::const_iterator  mom ; 
01431 //     for( mom = moms.begin() ; mom != moms.end() ; mom++){
01432 
01433 // loop over collection - preserve order
01434     for(  int index = 0 ; index < nParticles ; index++){
01435       
01436 
01437 #ifdef USE_CLHEP
01438       MCParticle4V part( col->getElementAt( index ) ) ;
01439 #else
01440       MCParticle* part =  dynamic_cast<MCParticle*>( col->getElementAt( index ) ) ;
01441 #endif
01442       printf(" [%8.8x] |", part->id() );
01443       cout << index << " [" ;
01444       for(unsigned int k=0;k<part->getParents().size();k++){
01445         if(k>0) cout << "," ;
01446         cout << p2i_map[ part->getParents()[k] ]  ;
01447       }
01448       cout << "] | [" ;
01449       for(unsigned int k=0;k<part->getDaughters().size();k++){
01450         if(k>0) cout << "," ;
01451         cout << p2i_map[ part->getDaughters()[k] ]  ;
01452       }
01453       cout << "] | " ;
01454       cout <<  part->getPDG() << " | ("
01455            <<  part->getMomentum()[0]  << ", "
01456            <<  part->getMomentum()[1]  << ", "
01457            <<  part->getMomentum()[2]  << ") | "
01458            <<  part->getGeneratorStatus() << " | "
01459            <<  hex << part->getSimulatorStatus() << dec << " | ("
01460            <<  part->getVertex()[0]    << ", "
01461            <<  part->getVertex()[1]    << ", "
01462            <<  part->getVertex()[2]    << ") | (" ;
01463 
01464       if( part->getEndpoint() != 0 ){
01465         cout <<  part->getEndpoint()[0]  << ", "
01466              <<  part->getEndpoint()[1]  << ", "
01467              <<  part->getEndpoint()[2]  << ") | " ;
01468       }else{
01469         cout << " not set ) | " ; 
01470       }
01471       cout <<  part->getMass()         << " | " 
01472            <<  part->getCharge()       << " | " 
01473            <<  part->getEnergy()      
01474 #ifdef USE_CLHEP
01475         //---- DEBUG
01476            << " m(4V) : " << part.m()
01477            << " e(4V) : " << part.e()
01478         //---- DEBUG
01479 #endif
01480            << endl ;    
01481 
01482 
01483     }
01484 
01485     cout << endl 
01486          << "-------------------------------------------------------------------------------- " 
01487          << endl ;
01488   }
01489 //   void LCTOOLS::printMCParticles(const EVENT::LCCollection* col ) {
01490     
01491 //     if( col->getTypeName() != LCIO::MCPARTICLE ){
01492       
01493 //       cout << " collection not of type " << LCIO::MCPARTICLE << endl ;
01494 //       return ;
01495 //     }
01496     
01497 //     cout << endl 
01498 //       << "--------------- " << "print out of "  << LCIO::MCPARTICLE << " collection "
01499 //       << "--------------- " << endl ;
01500     
01501 //     cout << endl 
01502 //       << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
01503     
01504 //     int nParticles =  col->getNumberOfElements() ;
01505 
01506 //     // get a list of all mother particles
01507 //     std::vector<MCParticle*> moms ; 
01508 //     for( int k=0; k<nParticles; k++){
01509 
01510 //       // get the particle from the collection - needs a cast !
01511 //       MCParticle* part =  dynamic_cast<MCParticle*>( col->getElementAt( k ) ) ;
01512       
01513 //       if( part->getParents().size() == 0 )
01514 //      moms.push_back( part ) ;
01515 //     }
01516 
01517 //     std::cout << endl
01518 //            << " index [motherIndex] | (px, py, pz) | HepEvtStatus | vertex (x,y,z) | endpoint(x,y,z)" 
01519 //            << " | mass | charge | energy"
01520 //            << endl 
01521 //            << endl ;
01522 
01523 
01524 //     // now loop over mothers and print daughters recursively
01525 //     int index = 0 ;
01526 //     std::vector<MCParticle*>::const_iterator  mom ; 
01527 //     for( mom = moms.begin() ; mom != moms.end() ; mom++){
01528 
01529 //       cout << index++ << " [-] "
01530 //         <<  (*mom)->getPDG() << " | ("
01531 //         <<  (*mom)->getMomentum()[0]  << ", "
01532 //         <<  (*mom)->getMomentum()[1]  << ", "
01533 //         <<  (*mom)->getMomentum()[2]  << ") | "
01534 //         <<  (*mom)->getHepEvtStatus() << " | ("
01535 //         <<  (*mom)->getVertex()[0]    << ", "
01536 //         <<  (*mom)->getVertex()[1]    << ", "
01537 //         <<  (*mom)->getVertex()[2]    << ") | ("
01538 //         <<  (*mom)->getEndpoint()[0]  << ", "
01539 //         <<  (*mom)->getEndpoint()[1]  << ", "
01540 //         <<  (*mom)->getEndpoint()[2]  << ") | "
01541 //         <<  (*mom)->getMass()         << " | " 
01542 //         <<  (*mom)->getCharge()       << " | " 
01543 //         <<  (*mom)->getEnergy()      
01544 //         << endl ;    
01545 
01546 
01547 //       index  = printDaughterParticles( *mom, index ) ;
01548 //     }
01549 
01550 //     cout << endl 
01551 //       << "-------------------------------------------------------------------------------- " 
01552 //       << endl ;
01553 //   }
01554 
01555 
01556   void LCTOOLS::printRelation( const EVENT::LCCollection* col ) {
01557     
01558     if( col->getTypeName() != LCIO::LCRELATION ){
01559       cout << " collection not of type " << LCIO::LCRELATION << endl ;
01560       return ;
01561     }
01562     
01563     cout << endl 
01564          << "--------------- " << "print out of "  << LCIO::LCRELATION << " collection "
01565          << "--------------- " << endl ;
01566     
01567     cout << endl 
01568          << "  flag:  0x" << hex  << col->getFlag() << dec << endl ;
01569     
01570     printParameters( col->getParameters() ) ;
01571 
01572     int nRel =  col->getNumberOfElements() ;
01573     
01574     cout << " fromType : " << col->getParameters().getStringVal("FromType")  << endl ;
01575     cout << " toType : "   << col->getParameters().getStringVal("ToType")    << endl ;
01576 
01577     cout << endl <<  " |  [from_id]  |  [to_id]   | weight "  << endl ;
01578     
01579 
01580     for( int i=0; i < nRel ; i++ ){
01581         
01582       LCRelation* rel = dynamic_cast<LCRelation*>( col->getElementAt(i) ) ;
01583       printf(" | [%8.8x] |  [[%8.8x]   | %5.3e \n" 
01584              , rel->getFrom()->id() 
01585              , rel->getTo()->id() 
01586              , rel->getWeight()
01587              );
01588       
01589     }
01590 
01591   }
01592 
01593 
01594 //   void LCTOOLS::printRelation( const EVENT::LCRelation* rel_const ) {
01595 
01596 //     LCRelation* rel = const_cast< LCRelation* >( rel_const )  ; 
01597     
01598 //     cout << " relation from " << rel->getFromType() << " to " << rel->getToType() << endl ; 
01599     
01600 //     int nRel = rel->numberOfRelations() ;
01601     
01602 //     cout <<  " |  [from_id]  |  [to_id]   | weight "  << endl ;
01603     
01604 //     // need to get a set of from objects first
01605 //     set<LCObject*> objs ;
01606 //     for( int i=0; i<nRel ; i++ ) {
01607 //       objs.insert( rel->getRelation( i )  ) ;
01608 //     } 
01609 
01610 //     for( std::set< LCObject* >::const_iterator iter = objs.begin() ; iter != objs.end() ; iter++ ){
01611 
01612 //       LCObject* from = *iter ;
01613       
01614 //       for( int j=0; j < rel->numberOfRelations( from ) ; j++ ){
01615         
01616 //      printf(" | [%8.8x] |  [[%8.8x]   | %5.3e \n" 
01617 //             , from->id() 
01618 //             , rel->getRelation( from, j )->id()  
01619 //             , rel->getWeight(  from, j )
01620 //             );
01621         
01622 //       }
01623       
01624 //     }
01625 //   }
01626 
01627   int LCTOOLS::printDaughterParticles(const MCParticle* part, int index){
01628 
01629     int motherIndex = index - 1 ;
01630     // print this particles daughters
01631     for(unsigned int i=0; i<part->getDaughters().size();i++){
01632       
01633       MCParticle* d =  part->getDaughters()[i] ;
01634 
01635       cout << index++ << " [" << motherIndex << "] " 
01636            <<  d->getPDG() << " | ("
01637            <<  d->getMomentum()[0]  << ", "
01638            <<  d->getMomentum()[1]  << ", "
01639            <<  d->getMomentum()[2]  << ") | "
01640            <<  part->getGeneratorStatus() << " | "
01641            <<  part->getSimulatorStatus() << " | ("
01642            <<  d->getVertex()[0]    << ", "
01643            <<  d->getVertex()[1]    << ", "
01644            <<  d->getVertex()[2]    << ") | (" ;
01645       if( part->getEndpoint() != 0 ){
01646         cout <<  part->getEndpoint()[0]  << ", "
01647              <<  part->getEndpoint()[1]  << ", "
01648              <<  part->getEndpoint()[2]  << ") | " ;
01649       }else{
01650         cout << " not set ) | " ; 
01651       }
01652       cout <<  d->getMass()         << " | " 
01653            <<  d->getCharge()       << " | " 
01654            <<  d->getEnergy()      
01655            << endl ;    
01656 
01657       index = printDaughterParticles( part->getDaughters()[i] , index ) ;
01658     }
01659     return index ;
01660 
01661   }
01662   
01663   void LCTOOLS::printParameters( const EVENT::LCParameters& params ){
01664 
01665     StringVec intKeys ;
01666     int nIntParameters = params.getIntKeys( intKeys ).size() ;
01667     for(int i=0; i< nIntParameters ; i++ ){
01668       IntVec intVec ;
01669       params.getIntVals(  intKeys[i], intVec ) ;
01670       int nInt  = intVec.size()  ;   
01671       cout << " parameter " << intKeys[i] << " [int]: " ; 
01672       
01673       if( nInt == 0 ){ 
01674         cout << " [empty] " << std::endl ;
01675       }
01676       for(int j=0; j< nInt ; j++ ){
01677         cout << intVec[j] << ", " ;
01678       }
01679       cout << endl ;
01680     }
01681     StringVec floatKeys ;
01682     int nFloatParameters = params.getFloatKeys( floatKeys ).size() ;
01683     for(int i=0; i< nFloatParameters ; i++ ){
01684       FloatVec floatVec ;
01685       params.getFloatVals(  floatKeys[i], floatVec ) ;
01686       int nFloat  = floatVec.size()  ;   
01687       cout << " parameter " << floatKeys[i] << " [float]: " ; 
01688       if( nFloat == 0 ){ 
01689         cout << " [empty] " << std::endl ;
01690       }
01691       for(int j=0; j< nFloat ; j++ ){
01692         cout << floatVec[j] << ", " ;
01693       }
01694       cout << endl ;
01695     }
01696     StringVec stringKeys ;
01697     int nStringParameters = params.getStringKeys( stringKeys ).size() ;
01698     for(int i=0; i< nStringParameters ; i++ ){
01699       StringVec stringVec ;
01700       params.getStringVals(  stringKeys[i], stringVec ) ;
01701       int nString  = stringVec.size()  ;   
01702       cout << " parameter " << stringKeys[i] << " [string]: " ; 
01703       if( nString == 0 ){ 
01704         cout << " [empty] " << std::endl ;
01705       }
01706       for(int j=0; j< nString ; j++ ){
01707         cout << stringVec[j] << ", " ;
01708       }
01709       cout << endl ;
01710     }
01711 
01712   }
01713 
01714   void LCTOOLS::dumpRunHeader(const EVENT::LCRunHeader* run) {
01715     
01716     //    cout  << " --------------------------------------------------------------- " << endl ;
01717       
01718     cout  << "  Run : " << run->getRunNumber() 
01719           << " - "      << run->getDetectorName() 
01720           << ":  "      << run->getDescription()  << endl ;
01721     
01722     printParameters( const_cast<EVENT::LCRunHeader*>(run)->parameters() ) ;
01723     
01724     cout  << " --------------------------------------------------------------- " << endl ;
01725   }
01726 
01727 } // namespace
01728 

Generated on Sun Jun 3 06:32:05 2007 for A TPC Tracking Environment by  doxygen 1.3.9.1