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