LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LCTOOLS.cc
Go to the documentation of this file.
1 #include "UTIL/LCTOOLS.h"
2 #include "UTIL/Operators.h"
3 #include "UTIL/LCObjectHandle.h"
4 #include "UTIL/LCTime.h"
5 #include "UTIL/CellIDDecoder.h"
6 #include "UTIL/PIDHandler.h"
7 
8 #include "EVENT/LCCollection.h"
10 #include "EVENT/CalorimeterHit.h"
12 #include "EVENT/SimTrackerHit.h"
13 #include "EVENT/TrackerHit.h"
14 #include "EVENT/TrackerHitPlane.h"
16 #include "EVENT/TPCHit.h"
17 #include "EVENT/TrackerRawData.h"
18 #include "EVENT/TrackerData.h"
19 #include "EVENT/TrackerPulse.h"
20 #include "EVENT/LCIO.h"
21 #include "EVENT/MCParticle.h"
22 #include "EVENT/LCFloatVec.h"
23 #include "EVENT/LCIntVec.h"
24 #include "EVENT/Track.h"
25 #include "EVENT/Cluster.h"
27 #include "EVENT/Vertex.h"
28 #include "EVENT/LCGenericObject.h"
29 #include "EVENT/LCRelation.h"
30 
31 //#include "IMPL/LCFlagImpl.h"
32 #include "UTIL/BitSet32.h"
33 #include "LCIOSTLTypes.h"
34 
35 #include <map>
36 #include <set>
37 #include <cstdio>
38 
39 
41 
42 using namespace std ;
43 using namespace EVENT ;
44 using namespace IMPL ;
45 
46 
47 namespace UTIL {
48 
49  static const int MAX_HITS = 1000 ;
50 
51  void LCTOOLS::dumpEvent(const LCEvent* evt){
52 
53  // the event:
54  cout << "///////////////////////////////////" << endl;
55  cout << "EVENT: " << evt->getEventNumber() << endl
56  << "RUN: " << evt->getRunNumber() << endl
57  << "DETECTOR: " << evt->getDetectorName() << endl
58  << "COLLECTIONS: (see below)" << endl;
59  cout << "///////////////////////////////////" << endl << endl;
60 
61  cout << "---------------------------------------------------------------------------" << endl;
62  cout.width(30); cout << left << "COLLECTION NAME";
63  cout.width(25); cout << left << "COLLECTION TYPE";
64  cout.width(20); cout << left << "NUMBER OF ELEMENTS" << endl;
65  cout << "===========================================================================" << endl;
66 
67  const std::vector< std::string >* strVec = evt->getCollectionNames() ;
68 
69  // loop over collections:
70  for( std::vector< std::string >::const_iterator name = strVec->begin() ; name != strVec->end() ; name++){
71 
72  cout.width(30); cout << left << *name;
73  cout.width(25); cout << left << evt->getCollection( *name )->getTypeName();
74  cout.width(9); cout << right << evt->getCollection( *name )->getNumberOfElements();
75  cout << endl;
76  //cout << "---------------------------------------------------------------------------" << endl;
77  }
78  cout << "---------------------------------------------------------------------------" << endl;
79  cout << endl << endl << endl;
80  }
81 
82 
83  void LCTOOLS::dumpEventDetailed(const LCEvent* evt){
84 
85  // the event:
86  cout << endl
87  << "============================================================================" << endl ;
88  cout << " Event : " << evt->getEventNumber()
89  << " - run: " << evt->getRunNumber()
90  << " - timestamp " << evt->getTimeStamp()
91  << " - weight " << evt->getWeight()
92  << endl ;
93  cout << "============================================================================" << endl ;
94 
95  LCTime evtTime( evt->getTimeStamp() ) ;
96  cout << " date: " << evtTime.getDateString() << endl ;
97  cout << " detector : " << evt->getDetectorName() << endl ;
98 
99  cout << " event parameters: " << endl ;
100 
101  printParameters( evt->getParameters() ) ;
102 
103 
104  const std::vector< std::string >* strVec = evt->getCollectionNames() ;
105 
106  // loop over all collections:
108 
109  for( name = strVec->begin() ; name != strVec->end() ; name++){
110 
111  LCCollection* col = evt->getCollection( *name ) ;
112 
113  cout << endl
114  << " collection name : " << *name
115  << endl
116  << " parameters: " << endl ;
117 
118  // printParameters( col->getParameters() ) ;
119 
120 
121 
122  // call the detailed print functions depending on type name
123  if( evt->getCollection( *name )->getTypeName() == LCIO::MCPARTICLE ){
124 
125  printMCParticles( col ) ;
126 
127  }
128  else if( evt->getCollection( *name )->getTypeName() == LCIO::SIMTRACKERHIT ){
129 
130  printSimTrackerHits( col ) ;
131 
132  }
133  else if( evt->getCollection( *name )->getTypeName() == LCIO::TPCHIT ){
134 
135  printTPCHits( col ) ;
136 
137  }
138  else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERHIT ){
139 
140  printTrackerHits( col ) ;
141 
142  }
143  else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERHITPLANE ){
144 
145  printTrackerHitPlane( col ) ;
146 
147  }
148  else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERHITZCYLINDER ){
149 
150  printTrackerHitZCylinder( col ) ;
151 
152  }
153  else if( evt->getCollection( *name )->getTypeName() == LCIO::SIMCALORIMETERHIT ){
154 
155  printSimCalorimeterHits( col ) ;
156 
157  }
158  else if( evt->getCollection( *name )->getTypeName() == LCIO::CALORIMETERHIT ){
159 
160  printCalorimeterHits( col ) ;
161 
162  }
163  else if( evt->getCollection( *name )->getTypeName() == LCIO::RAWCALORIMETERHIT ){
164 
165  printRawCalorimeterHits( col ) ;
166 
167  }
168  else if( evt->getCollection( *name )->getTypeName() == LCIO::LCFLOATVEC ){
169 
170  printLCFloatVecs( col ) ;
171 
172  }
173  else if( evt->getCollection( *name )->getTypeName() == LCIO::LCINTVEC ){
174 
175  printLCIntVecs( col ) ;
176 
177  }
178  else if( evt->getCollection( *name )->getTypeName() == LCIO::LCSTRVEC ){
179 
180  printLCStrVecs( col ) ;
181 
182  }
183  else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACK ){
184 
185  printTracks( col ) ;
186 
187  }
188  else if( evt->getCollection( *name )->getTypeName() == LCIO::CLUSTER ){
189 
190  printClusters( col ) ;
191 
192  }
193  else if( evt->getCollection( *name )->getTypeName() == LCIO::RECONSTRUCTEDPARTICLE ){
194 
195  printReconstructedParticles( col ) ;
196 
197  }
198  else if( evt->getCollection( *name )->getTypeName() == LCIO::VERTEX ){
199 
200  printVertices( col ) ;
201 
202  }
203  else if( evt->getCollection( *name )->getTypeName() == LCIO::LCGENERICOBJECT ){
204 
205  printLCGenericObjects( col ) ;
206 
207  }
208  else if( evt->getCollection( *name )->getTypeName() == LCIO::LCRELATION ){
209 
210  printRelation( col ) ;
211  }
212  else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERRAWDATA ){
213 
214  printTrackerRawData( col ) ;
215  }
216  else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERDATA ){
217 
218  printTrackerData( col ) ;
219  }
220  else if( evt->getCollection( *name )->getTypeName() == LCIO::TRACKERPULSE ){
221 
222  printTrackerPulse( col ) ;
223  }
224 
225  }
226 
227  }
228 
229  void LCTOOLS::printTracks(const EVENT::LCCollection* col ){
230  if( col->getTypeName() != LCIO::TRACK ){
231 
232  cout << " collection not of type " << LCIO::TRACK << endl ;
233  return ;
234  }
235  cout << endl
236  << "--------------- " << "print out of " << LCIO::TRACK << " collection "
237  << "--------------- " << endl ;
238 
239  cout << endl
240  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
241 
242  printParameters( col->getParameters() ) ;
243 
244  BitSet32 flag( col->getFlag() ) ;
245  cout << " LCIO::TRBIT_HITS : " << flag.test( LCIO::TRBIT_HITS ) << endl ;
246 
247  int nTracks = col->getNumberOfElements() ;
248  int nPrint = nTracks > MAX_HITS ? MAX_HITS : nTracks ;
249 
250  cout << endl;
251  Track* trk=NULL;
252  cout << header(trk);
253  cout << tail(trk);
254 
255  for( int i=0 ; i< nPrint ; i++ ){
256  trk = dynamic_cast<Track*>( col->getElementAt( i ));
258  cout << tail(trk);
259  }
260  }
261 
262  void LCTOOLS::printSimTrackerHits(const EVENT::LCCollection* col ){
263  if( col->getTypeName() != LCIO::SIMTRACKERHIT ){
264 
265  cout << " collection not of type " << LCIO::SIMTRACKERHIT << endl ;
266  return ;
267  }
268 
269  cout << endl
270  << "--------------- " << "print out of " << LCIO::SIMTRACKERHIT << " collection "
271  << "--------------- " << endl ;
272 
273  cout << endl
274  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
275 
276  printParameters( col->getParameters() ) ;
277 
278  BitSet32 flag( col->getFlag() ) ;
279  cout << " LCIO::THBIT_BARREL : " << flag.test( LCIO::THBIT_BARREL ) << endl ;
280  cout << " LCIO::THBIT_MOMENTUM : " << flag.test( LCIO::THBIT_MOMENTUM ) << endl ;
281  cout << LCTOOLS::getQualityBits() << endl;
282 
283  int nHits = col->getNumberOfElements() ;
284  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
285 
286  cout << endl;
287  SimTrackerHit* hit=NULL;
288  cout << header(hit);
289  cout << tail(hit);
290  for( int i=0 ; i< nPrint ; i++ ){
291  hit = dynamic_cast<SimTrackerHit*>(col->getElementAt(i)) ;
293  }
294  cout << tail(hit) << endl;
295  }
296 
297  void LCTOOLS::printTrackerHits(const EVENT::LCCollection* col ){
298 
299  if( col->getTypeName() != LCIO::TRACKERHIT ){
300 
301  cout << " collection not of type " << LCIO::TRACKERHIT << endl ;
302  return ;
303  }
304 
305  cout << endl
306  << "--------------- " << "print out of " << LCIO::TRACKERHIT << " collection "
307  << "--------------- " << endl ;
308 
309  cout << endl
310  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
311 
312  printParameters( col->getParameters() ) ;
313 
314  BitSet32 flag( col->getFlag() ) ;
315  cout << " LCIO::THBIT_BARREL : " << flag.test( LCIO::THBIT_BARREL ) << endl ;
316 
317 
318  int nHits = col->getNumberOfElements() ;
319  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
320 
321  cout << endl;
322  TrackerHit* hit=NULL;
323  cout << header(hit);
324  cout << tail(hit);
325  for( int i=0 ; i< nPrint ; i++ ){
326  hit = dynamic_cast<TrackerHit*>(col->getElementAt(i)) ;
328  // const LCObjectVec& rawHits = hit->getRawHits() ;
329  // cout << " rawHits: " ;
330  // try{
331  // for( unsigned j=0 ; j < rawHits.size() ; j++ ) {
332  // cout << dec << "[" << rawHits[j]->id() << "], " << dec ;
333  // }
334  // cout << endl;
335  // }catch(std::exception& e){}
336  }
337  cout << tail(hit) << endl;
338  }
339 
340  void LCTOOLS::printTrackerHitPlane(const EVENT::LCCollection* col ){
341 
342  if( col->getTypeName() != LCIO::TRACKERHITPLANE ){
343 
344  cout << " collection not of type " << LCIO::TRACKERHITPLANE << endl ;
345  return ;
346  }
347 
348  cout << endl
349  << "--------------- " << "print out of " << LCIO::TRACKERHITPLANE << " collection "
350  << "--------------- " << endl ;
351 
352  cout << endl
353  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
354 
355  printParameters( col->getParameters() ) ;
356 
357  BitSet32 flag( col->getFlag() ) ;
358  cout << " LCIO::THBIT_BARREL : " << flag.test( LCIO::THBIT_BARREL ) << endl ;
359 
360 
361  int nHits = col->getNumberOfElements() ;
362  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
363 
364  cout << endl;
365  TrackerHitPlane* hit=NULL;
366  cout << header(hit);
367  cout << tail(hit);
368  for( int i=0 ; i< nPrint ; i++ ){
369  hit = dynamic_cast<TrackerHitPlane*>(col->getElementAt(i)) ;
371  // const LCObjectVec& rawHits = hit->getRawHits() ;
372  // cout << " rawHits: " ;
373  // try{
374  // for( unsigned j=0 ; j < rawHits.size() ; j++ ) {
375  // cout << dec << "[" << rawHits[j]->id() << "], " << dec ;
376  // }
377  // cout << endl;
378  // }catch(std::exception& e){}
379  }
380  cout << tail(hit) << endl;
381  }
382 
383  void LCTOOLS::printTrackerHitZCylinder(const EVENT::LCCollection* col ){
384 
385  if( col->getTypeName() != LCIO::TRACKERHITZCYLINDER ){
386 
387  cout << " collection not of type " << LCIO::TRACKERHITZCYLINDER << endl ;
388  return ;
389  }
390 
391  cout << endl
392  << "--------------- " << "print out of " << LCIO::TRACKERHITZCYLINDER << " collection "
393  << "--------------- " << endl ;
394 
395  cout << endl
396  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
397 
398  printParameters( col->getParameters() ) ;
399 
400  BitSet32 flag( col->getFlag() ) ;
401  cout << " LCIO::THBIT_BARREL : " << flag.test( LCIO::THBIT_BARREL ) << endl ;
402 
403 
404  int nHits = col->getNumberOfElements() ;
405  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
406 
407  cout << endl;
408  TrackerHitZCylinder* hit=NULL;
409  cout << header(hit);
410  cout << tail(hit);
411  for( int i=0 ; i< nPrint ; i++ ){
412  hit = dynamic_cast<TrackerHitZCylinder*>(col->getElementAt(i)) ;
414  // const LCObjectVec& rawHits = hit->getRawHits() ;
415  // cout << " rawHits: " ;
416  // try{
417  // for( unsigned j=0 ; j < rawHits.size() ; j++ ) {
418  // cout << dec << "[" << rawHits[j]->id() << "], " << dec ;
419  // }
420  // cout << endl;
421  // }catch(std::exception& e){}
422  }
423  cout << tail(hit) << endl;
424  }
425 
426  void LCTOOLS::printTrackerRawData(const EVENT::LCCollection* col ) {
427 
428  if( col->getTypeName() != LCIO::TRACKERRAWDATA ){
429 
430  cout << " collection not of type " << LCIO::TRACKERRAWDATA << endl ;
431  return ;
432  }
433 
434  cout << endl
435  << "--------------- " << "print out of " << LCIO::TRACKERRAWDATA << " collection "
436  << "--------------- " << endl ;
437 
438  cout << endl
439  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
440 
441  BitSet32 flag( col->getFlag() ) ;
442  cout << " LCIO::TRAWBIT_ID1 : " << flag.test( LCIO::TRAWBIT_ID1 ) << endl ;
443 
444  printParameters( col->getParameters() ) ;
445 
447 
448  int nHits = col->getNumberOfElements() ;
449  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
450 
451  cout << endl;
452  TrackerRawData* hit=NULL;
453  cout << header(hit);
454  cout << tail(hit);
455  for( int i=0 ; i< nPrint ; i++ ){
456  hit = dynamic_cast<TrackerRawData*>(col->getElementAt(i)) ;
458  }
459  cout << tail(hit);
460  }
461 
462  void LCTOOLS::printTrackerData(const EVENT::LCCollection* col ) {
463 
464  if( col->getTypeName() != LCIO::TRACKERDATA ){
465 
466  cout << " collection not of type " << LCIO::TRACKERDATA << endl ;
467  return ;
468  }
469 
470  cout << endl
471  << "--------------- " << "print out of " << LCIO::TRACKERDATA << " collection "
472  << "--------------- " << endl ;
473 
474  cout << endl
475  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
476 
477  BitSet32 flag( col->getFlag() ) ;
478  cout << " LCIO::TRAWBIT_ID1 : " << flag.test( LCIO::TRAWBIT_ID1 ) << endl ;
479 
480  printParameters( col->getParameters() ) ;
481 
482  int nHits = col->getNumberOfElements() ;
483  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
484 
485  CellIDDecoder<TrackerData> id( col ) ;
486 
487  cout << endl;
488  TrackerData* hit=NULL;
489  cout << header(hit);
490  cout << tail(hit);
491  for( int i=0 ; i< nPrint ; i++ ){
492  hit = dynamic_cast<TrackerData*>(col->getElementAt(i)) ;
494  }
495  cout << tail(hit);
496  }
497 
498  void LCTOOLS::printTrackerPulse(const EVENT::LCCollection* col ) {
499 
500  if( col->getTypeName() != LCIO::TRACKERPULSE ){
501 
502  cout << " collection not of type " << LCIO::TRACKERPULSE << endl ;
503  return ;
504  }
505 
506  cout << endl
507  << "--------------- " << "print out of " << LCIO::TRACKERPULSE << " collection "
508  << "--------------- " << endl ;
509 
510  cout << endl
511  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
512 
513  BitSet32 flag( col->getFlag() ) ;
514  cout << " LCIO::TRAWBIT_ID1 : " << flag.test( LCIO::TRAWBIT_ID1 )
515  << " LCIO::TRAWBIT_CM : " << flag.test( LCIO::TRAWBIT_CM ) << endl ;
516 
517  printParameters( col->getParameters() ) ;
518 
519  int nHits = col->getNumberOfElements() ;
520  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
521 
522  CellIDDecoder<TrackerPulse> id( col ) ;
523 
524  cout << endl;
525  TrackerPulse* pul=NULL;
526  cout << header(pul);
527  cout << tail(pul);
528  for( int i=0 ; i< nPrint ; i++ ){
529  pul = dynamic_cast<TrackerPulse*>(col->getElementAt(i)) ;
531  }
532  cout << tail(pul);
533  }
534 
535  void LCTOOLS::printTPCHits(const EVENT::LCCollection* col ) { //tpc hit is deprecated
536 
537  if( col->getTypeName() != LCIO::TPCHIT ){
538 
539  cout << " collection not of type " << LCIO::TPCHIT << endl ;
540  return ;
541  }
542 
543  cout << endl
544  << "--------------- " << "print out of " << LCIO::TPCHIT << " collection "
545  << "--------------- " << endl ;
546 
547  cout << endl
548  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
549 
550  printParameters( col->getParameters() ) ;
551 
552  BitSet32 flag( col->getFlag() ) ;
553  cout << " -> LCIO::TPCBIT_RAW : " << flag.test( LCIO::TPCBIT_RAW ) << endl ;
554  cout << " -> LCIO::TPCBIT_NO_PTR : " << flag.test( LCIO::TPCBIT_NO_PTR ) << endl ;
555 
556  int nHits = col->getNumberOfElements() ;
557  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
558 
559  std::cout << endl
560  << " [ id ] | cellId0 | time | charge | quality "
561  << endl << " -> raw data (bytes) : "
562  << endl
563  << endl ;
564 
565  for( int i=0 ; i< nPrint ; i++ ){
566 
567  TPCHit* hit =
568  dynamic_cast<TPCHit*>( col->getElementAt( i ) ) ;
569 
570  int id0 = hit->getCellID() ;
571  // std::cout << hit->getCellID() << " | "
572  printf( " [%8.8x] |", hit->id() ) ;
574  << ((id0& 0x00ff0000)>>16) << "/"
575  << ((id0& 0x0000ff00)>> 8) << "/"
576  << ((id0& 0x000000ff)>> 0) << " | "
577  << hit->getTime() << " | "
578  << hit->getCharge() << " | ["
579  << hit->getQuality() << "] "
580  << std::endl ;
581  if( flag.test( LCIO::TPCBIT_RAW ) ){
582 
583  int nWords = hit->getNRawDataWords() ;
584  std::cout << " -> " ;
585 
586  for(int j=0;j<nWords;j++){
587  int rawData = hit->getRawDataWord( j ) ;
589  << ((rawData& 0x00ff0000)>>16) << ", "
590  << ((rawData& 0x0000ff00)>> 8) << ", "
591  << ((rawData& 0x000000ff)>> 0) ;
592  if( j < nWords-1) std::cout << ", " ;
593  }
594 
595  std::cout << std::endl ;
596 
597  }
598  }
599  cout << endl
600  << "-------------------------------------------------------------------------------- "
601  << endl ;
602  }
603 
604  void LCTOOLS::printLCStrVecs( const EVENT::LCCollection* col ) {
605 
606  if( col->getTypeName() != LCIO::LCSTRVEC ){
607 
608  cout << " collection not of type " << LCIO::LCSTRVEC << endl ;
609  return ;
610  }
611 
612  cout << endl
613  << "--------------- " << "print out of " << LCIO::LCSTRVEC << " collection (user extension) "
614  << "--------------- " << endl ;
615 
616  cout << endl
617  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
618 
619  printParameters( col->getParameters() ) ;
620 
621  int nHits = col->getNumberOfElements() ;
622  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
623 
624 
625 
626  std::cout << endl
627  << " element index: val0, val1, ..."
628  << endl
629  << endl ;
630 
631  for( int i=0 ; i< nPrint ; i++ ){
632 
633  LCStrVec* vec =
634  dynamic_cast<LCStrVec*>( col->getElementAt( i ) ) ;
635 
636  std::cout << i << ": " ;
637  for(unsigned int j=0;j< vec->size();j++){
638 
639  std::cout << (*vec)[j] ;
640  if( j<vec->size()-1) std::cout << ", " ;
641 
642  if( ! ( (j+1) % 10) ) std::cout << endl << " " ;
643  }
644  std::cout << std::endl ;
645  }
646  cout << endl
647  << "-------------------------------------------------------------------------------- "
648  << endl ;
649 
650  }
651 
652  void LCTOOLS::printLCFloatVecs( const EVENT::LCCollection* col ) {
653 
654  if( col->getTypeName() != LCIO::LCFLOATVEC ){
655 
656  cout << " collection not of type " << LCIO::LCFLOATVEC << endl ;
657  return ;
658  }
659 
660  cout << endl
661  << "--------------- " << "print out of " << LCIO::LCFLOATVEC << " collection (user extension) "
662  << "--------------- " << endl ;
663 
664  cout << endl
665  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
666 
667  printParameters( col->getParameters() ) ;
668 
669  int nHits = col->getNumberOfElements() ;
670  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
671 
672  cout << endl;
673  LCFloatVec* vec=NULL;
674  cout << header(vec);
675  cout << tail(vec);
676  for( int i=0 ; i< nPrint ; i++ ){
677  vec = dynamic_cast<LCFloatVec*>(col->getElementAt(i)) ;
679  }
680  cout << tail(vec);
681  }
682 
683  void LCTOOLS::printLCIntVecs( const EVENT::LCCollection* col ) {
684 
685  if( col->getTypeName() != LCIO::LCINTVEC ){
686 
687  cout << " collection not of type " << LCIO::LCINTVEC << endl ;
688  return ;
689  }
690 
691  cout << endl
692  << "--------------- " << "print out of " << LCIO::LCINTVEC << " collection (user extension) "
693  << "--------------- " << endl ;
694 
695  cout << endl
696  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
697 
698  printParameters( col->getParameters() ) ;
699 
700  int nHits = col->getNumberOfElements() ;
701  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
702  cout << endl;
703  LCIntVec* vec=NULL;
704  cout << header(vec);
705  cout << tail(vec);
706  for( int i=0 ; i< nPrint ; i++ ){
707  vec = dynamic_cast<LCIntVec*>(col->getElementAt(i)) ;
709  }
710  cout << tail(vec);
711  }
712 
713  void LCTOOLS::printSimCalorimeterHits(const EVENT::LCCollection* col ){
714 
715  if( col->getTypeName() != LCIO::SIMCALORIMETERHIT ){
716 
717  cout << " collection not of type " << LCIO::SIMCALORIMETERHIT << endl ;
718  return ;
719  }
720 
721  cout << endl
722  << "--------------- " << "print out of " << LCIO::SIMCALORIMETERHIT << " collection "
723  << "--------------- " << endl ;
724 
725  cout << endl
726  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
727 
728  printParameters( col->getParameters() ) ;
729 
730  BitSet32 flag( col->getFlag() ) ;
731  cout << " -> LCIO::CHBIT_LONG : " << flag.test( LCIO::CHBIT_LONG ) << endl ;
732  cout << " LCIO::CHBIT_BARREL : " << flag.test( LCIO::CHBIT_BARREL ) << endl ;
733  cout << " LCIO::CHBIT_ID1 : " << flag.test( LCIO::CHBIT_ID1 ) << endl ;
734  cout << " LCIO::CHBIT_STEP : " << flag.test( LCIO::CHBIT_STEP ) << endl ;
735 
736  int nHits = col->getNumberOfElements() ;
737  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
738 
739 
740  CellIDDecoder<SimCalorimeterHit> idDecoder( col ) ;
741 
742  cout << endl;
743  SimCalorimeterHit* hit=NULL;
744  cout << header(hit);
745  cout << tail(hit);
746  for( int i=0 ; i< nPrint ; i++ ){
747  hit = dynamic_cast<SimCalorimeterHit*>(col->getElementAt(i)) ;
749  }
750  cout << tail(hit);
751  }
752 
753  void LCTOOLS::printCalorimeterHits(const EVENT::LCCollection* col ){
754 
755  if( col->getTypeName() != LCIO::CALORIMETERHIT ){
756 
757  cout << " collection not of type " << LCIO::CALORIMETERHIT << endl ;
758  return ;
759  }
760 
761  cout << endl
762  << "--------------- " << "print out of " << LCIO::CALORIMETERHIT << " collection "
763  << "--------------- " << endl ;
764 
765  cout << endl
766  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
767 
768  printParameters( col->getParameters() ) ;
769 
770  BitSet32 flag( col->getFlag() ) ;
771  cout << " -> LCIO::RCHBIT_LONG : " << flag.test( LCIO::RCHBIT_LONG ) << endl ;
772  cout << " LCIO::RCHBIT_BARREL : " << flag.test( LCIO::RCHBIT_BARREL ) << endl ;
773  cout << " LCIO::RCHBIT_ID1 : " << flag.test( LCIO::RCHBIT_ID1 ) << endl ;
774  cout << " LCIO::RCHBIT_TIME : " << flag.test( LCIO::RCHBIT_TIME ) << endl ;
775  cout << " LCIO::RCHBIT_NO_PTR : " << flag.test( LCIO::RCHBIT_NO_PTR ) << endl ;
776  cout << " LCIO::RCHBIT_ENERGY_ERROR : " << flag.test( LCIO::RCHBIT_ENERGY_ERROR ) << endl ;
777 
778  int nHits = col->getNumberOfElements() ;
779  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
780 
781  CellIDDecoder<CalorimeterHit> idDecoder( col ) ;
782 
783  cout << endl;
784  CalorimeterHit* hit=NULL;
785  cout << header(hit);
786  cout << tail(hit);
787  for( int i=0 ; i< nPrint ; i++ ){
788  hit = dynamic_cast<CalorimeterHit*>(col->getElementAt(i)) ;
790  }
791  cout << tail(hit);
792  }
793 
794  void LCTOOLS::printRawCalorimeterHits(const EVENT::LCCollection* col ){
795 
796  if( col->getTypeName() != LCIO::RAWCALORIMETERHIT ){
797 
798  cout << " collection not of type " << LCIO::RAWCALORIMETERHIT << endl ;
799  return ;
800  }
801 
802  cout << endl
803  << "--------------- " << "print out of " << LCIO::RAWCALORIMETERHIT << " collection "
804  << "--------------- " << endl ;
805 
806  cout << endl
807  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
808 
809  printParameters( col->getParameters() ) ;
810 
811  BitSet32 flag( col->getFlag() ) ;
812 
813  cout << " LCIO::RCHBIT_ID1 : " << flag.test( LCIO::RCHBIT_ID1 ) << endl ;
814  cout << " LCIO::RCHBIT_TIME : " << flag.test( LCIO::RCHBIT_TIME ) << endl ;
815  cout << " LCIO::RCHBIT_NO_PTR : " << flag.test( LCIO::RCHBIT_NO_PTR ) << endl ;
816 
817  int nHits = col->getNumberOfElements() ;
818  int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
819 
820 
821  CellIDDecoder<RawCalorimeterHit> idDecoder( col ) ;
822 
823  cout << endl;
824  RawCalorimeterHit* hit=NULL;
825  cout << header(hit);
826  cout << tail(hit);
827  for( int i=0 ; i< nPrint ; i++ ){
828  hit = dynamic_cast<RawCalorimeterHit*>(col->getElementAt(i)) ;
830  }
831  cout << tail(hit);
832  }
833 
834  void LCTOOLS::printClusters(const EVENT::LCCollection* col ){
835  if( col->getTypeName() != LCIO::CLUSTER ){
836 
837  cout << " collection not of type " << LCIO::CLUSTER << endl ;
838  return ;
839  }
840  cout << endl
841  << "--------------- " << "print out of " << LCIO::CLUSTER << " collection "
842  << "--------------- " << endl ;
843 
844  cout << endl
845  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
846 
847  printParameters( col->getParameters() ) ;
848 
849  BitSet32 flag( col->getFlag() ) ;
850  cout << " LCIO::CLBIT_HITS : " << flag.test( LCIO::CLBIT_HITS ) << endl ;
851 
852  int nClusters = col->getNumberOfElements() ;
853  int nPrint = nClusters > MAX_HITS ? MAX_HITS : nClusters ;
854 
855  cout << endl;
856  Cluster* clu = NULL;
857  cout << header(clu);
858  cout << tail(clu);
859  for( int i=0 ; i< nPrint ; i++ ){
860  clu = dynamic_cast<Cluster*>(col->getElementAt(i)) ;
862  }
863  cout << tail(clu);
864 
865  // --- detailed PID info:
866 
867  cout << endl
868  << " ------------ detailed PID info: --- " << endl << endl
869  << " algorithms : "
870  << endl ;
871 
872 
873  PIDHandler pidH( col ) ;
874 
875  try{
876  const IntVec& ids = pidH.getAlgorithmIDs() ;
877 
878  for(unsigned i=0; i<ids.size() ; ++i){
879 
880  cout << " [id: " << ids[i] << "] "
881  << pidH.getAlgorithmName( ids[i] )
882  << " - params: " ;
883 
884  const StringVec& pNames = pidH.getParameterNames( ids[i] ) ;
885 
886  for( StringVec::const_iterator it = pNames.begin() ; it != pNames.end() ; ++it ){
887 
888  cout << " " << *it ;
889  }
890  cout << endl ;
891  }
892  cout << endl ;
893  }
894  catch( UnknownAlgorithm &e ){
895  cout << "- NA - ";
896  }
897 
898  std::cout << endl
899  << " [cluster ] | PDG | likelihood | type | algoId | parameters : " << endl
900  << " | | | | | "
901  << endl ;
902 
903 
904  for( int i=0 ; i< nPrint ; i++ ){
905 
906  Cluster* clu1 =
907  dynamic_cast<Cluster*>( col->getElementAt( i ) ) ;
908 
909  printf(" [%8.8x] " , clu1->id() ) ;
910 
911 
912  for(unsigned int l=0;l<clu1->getParticleIDs().size();l++){
913 
914  if( l!=0)
915  printf(" " ) ;
916 
917  ParticleID* pid = clu1->getParticleIDs()[l] ;
918  try{
919  printf("| %6d | %6.4e | %6.6d | %8d | [",
920  pid->getPDG() ,
921  pid->getLikelihood() ,
922  pid->getType() ,
923  pid->getAlgorithmType()
924  ) ;
925 
926 
927  const StringVec& pNames = pidH.getParameterNames( pid->getAlgorithmType() ) ;
928 
929  for(unsigned j=0;j< pNames.size() ;++j){
930 
931  cout << " " << pNames[j]
932  << " : " << pid->getParameters()[j] << "," ;
933 
934  }
935  }
936  catch( UnknownAlgorithm &e ){
937  cout << "- NA - ";
938  }
939 
940  cout << "]"<< endl ;
941  }
942  cout << endl ;
943 
944  }
945 
946  cout << endl
947  << "-------------------------------------------------------------------------------- "
948  << endl ;
949  }
950 
951  void LCTOOLS::printVertices( const EVENT::LCCollection* col ){
952  if( col->getTypeName() != LCIO::VERTEX ){
953 
954  cout << " collection not of type " << LCIO::VERTEX << endl ;
955  return ;
956  }
957  cout << endl
958  << "--------------- " << "print out of " << LCIO::VERTEX << " collection "
959  << "--------------- " << endl << endl;
960 
961  printParameters( col->getParameters() ) ;
962 
963  int nVertices = col->getNumberOfElements() ;
964  int nPrint = nVertices > MAX_HITS ? MAX_HITS : nVertices ;
965 
966  for( int i=0 ; i< nPrint ; i++ ){
967  Vertex* v = dynamic_cast<Vertex*>( col->getElementAt( i ) ) ;
968 
969  if( i==0) { cout<<header(v); }
970  //cout<<lcshort(v,col);
971  cout << lcshort(v);
972  if(i==nPrint-1){ cout<<tail(v); }
973  }
974  }
975 
976  void LCTOOLS::printReconstructedParticles( const EVENT::LCCollection* col ){
977 
978  if( col->getTypeName() != LCIO::RECONSTRUCTEDPARTICLE ){
979 
980  cout << " collection not of type " << LCIO::RECONSTRUCTEDPARTICLE << endl ;
981  return ;
982  }
983  cout << endl
984  << "--------------- " << "print out of " << LCIO::RECONSTRUCTEDPARTICLE << " collection "
985  << "--------------- " << endl ;
986 
987  cout << endl
988  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
989 
990  printParameters( col->getParameters() ) ;
991 
992  int nReconstructedParticles = col->getNumberOfElements() ;
993  int nPrint = nReconstructedParticles > MAX_HITS ? MAX_HITS : nReconstructedParticles ;
994 
995  cout << endl;
996  ReconstructedParticle* recP=NULL;
997  cout << header(recP);
998  cout << tail(recP);
999 
1000  for( int i=0 ; i< nPrint ; i++ ){
1001  recP = dynamic_cast<ReconstructedParticle*>( col->getElementAt( i ));
1003  }
1004  cout << tail(recP);
1005 
1006  // --- detailed PID info:
1007 
1008  cout << endl
1009  << " ------------ detailed PID info: --- " << endl << endl
1010  << " algorithms : "
1011  << endl ;
1012 
1013 
1014  PIDHandler pidH( col ) ;
1015 
1016  try{
1017  const IntVec& ids = pidH.getAlgorithmIDs() ;
1018 
1019  for(unsigned i=0; i<ids.size() ; ++i){
1020 
1021  cout << " [id: " << ids[i] << "] "
1022  << pidH.getAlgorithmName( ids[i] )
1023  << " - params: " ;
1024 
1025  const StringVec& pNames = pidH.getParameterNames( ids[i] ) ;
1026 
1027  for( StringVec::const_iterator it = pNames.begin() ; it != pNames.end() ; ++it ){
1028 
1029  cout << " " << *it ;
1030  }
1031  cout << endl ;
1032  }
1033  cout << endl ;
1034  }
1035  catch( UnknownAlgorithm &e ){
1036  cout << "- NA - " << std::endl ;
1037  }
1038 
1039  std::cout << endl
1040  << " [particle] | PDG | likelihood | type | algoId | parameters : " << endl
1041  << " | | | | | "
1042  << endl ;
1043 
1044 
1045  for( int i=0 ; i< nPrint ; i++ ){
1046 
1047  ReconstructedParticle* recP1 =
1048  dynamic_cast<ReconstructedParticle*>( col->getElementAt( i ) ) ;
1049 
1050  printf(" [%8.8x] " , recP1->id() ) ;
1051 
1052 
1053  for(unsigned int l=0;l<recP1->getParticleIDs().size();l++){
1054 
1055  if( l!=0)
1056  printf(" " ) ;
1057 
1058  ParticleID* pid = recP1->getParticleIDs()[l] ;
1059  try{
1060  printf("| %6d | %6.4e | %6.6d | %8d | [",
1061  pid->getPDG() ,
1062  pid->getLikelihood() ,
1063  pid->getType() ,
1064  pid->getAlgorithmType()
1065  ) ;
1066 
1067  const StringVec& pNames = pidH.getParameterNames( pid->getAlgorithmType() ) ;
1068 
1069  if( pNames.size() == pid->getParameters().size() ) {
1070  for(unsigned j=0;j< pNames.size() ;++j){
1071 
1072  cout << " " << pNames[j]
1073  << " : " << pid->getParameters()[j] << "," ;
1074  }
1075  }
1076 
1077  cout << "]"<< endl ;
1078 
1079  }
1080  catch( UnknownAlgorithm &e ){
1081  cout << "- NA - " << std::endl ;
1082  }
1083 
1084  }
1085  cout << endl ;
1086 
1087  }
1088 
1089  cout << endl
1090  << "-------------------------------------------------------------------------------- "
1091  << endl ;
1092 
1093  }
1094 
1095  void LCTOOLS::printLCGenericObjects( const EVENT::LCCollection* col ){
1096 
1097  if( col->getTypeName() != LCIO::LCGENERICOBJECT ){
1098 
1099  cout << " collection not of type " << LCIO::LCGENERICOBJECT
1100  << " [ " << col->getParameters().getStringVal("TypeName") << " ] "
1101  << endl ;
1102 
1103  return ;
1104  }
1105  cout << endl
1106  << "--------------- " << "print out of " << LCIO::LCGENERICOBJECT << " collection "
1107  << "--------------- " << endl ;
1108 
1109  cout << endl
1110  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
1111 
1112  printParameters( col->getParameters() ) ;
1113 
1114  int nLCGenericObjects = col->getNumberOfElements() ;
1115  int nPrint = nLCGenericObjects > MAX_HITS ? MAX_HITS : nLCGenericObjects ;
1116 
1117  //bool isFixedSize = BitSet32( col->getFlag() ).test( LCIO::GOBIT_FIXED );
1118 
1119  cout << endl;
1120  LCGenericObject* obj=NULL;
1121  cout << header(obj, col);
1122  cout << tail(obj);
1123 
1124  for( int i=0 ; i< nPrint ; i++ ){
1125  obj = dynamic_cast<LCGenericObject*>( col->getElementAt( i ));
1127  cout << tail(obj);
1128  }
1129  cout << endl;
1130  }
1131 
1132 
1133  void LCTOOLS::printMCParticles(const EVENT::LCCollection* col ) {
1134 
1135  if( col->getTypeName() != LCIO::MCPARTICLE ){
1136 
1137  cout << " collection not of type " << LCIO::MCPARTICLE << endl ;
1138  return ;
1139  }
1140 
1141  cout << endl
1142  << "--------------- " << "print out of " << LCIO::MCPARTICLE << " collection "
1143  << "--------------- " << endl ;
1144 
1145  cout << endl
1146  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
1147 
1148  printParameters( col->getParameters() ) ;
1149 
1150  int nParticles = col->getNumberOfElements() ;
1151 
1152 
1153  cout << " " << getSimulatorStatusString() << std::endl ;
1154 
1155  // fill map with particle pointers and collection indices
1156  typedef std::map< MCParticle*, int > PointerToIndexMap ;
1157  PointerToIndexMap p2i_map ;
1159 
1160  /*
1161  cout << endl;
1162  MCParticle* part=NULL;
1163  cout << header(part);
1164  cout << tail(part);
1165 
1166  for( int i=0 ; i< nParticles ; i++ ){
1167  part = dynamic_cast<MCParticle*>( col->getElementAt( i ));
1168  cout << lcio_short<EVENT::MCParticle>(part, col); //WARNING!
1169  //not exact the same output as the code below:
1170  //<< lcio_short prints the id's of the parents/daughters particles,
1171  //the "old" version prints the position in the collection
1172  }
1173  */
1174 
1175  for( int k=0; k<nParticles; k++){
1176  MCParticle* part = dynamic_cast<MCParticle*>( col->getElementAt( k ) ) ;
1177  p2i_map[ part ] = k ;
1178 
1179  moms.push_back( part ) ;
1180  }
1181 
1182  std::cout << endl
1183  << "[ id ]index| PDG | px, py, pz | px_ep, py_ep , pz_ep | energy |gen|[simstat ]| vertex x, y , z | endpoint x, y , z | mass | charge | spin | colorflow | [parents] - [daughters]"
1184  << endl
1185  << endl ;
1186 
1187  // loop over collection - preserve order
1188  for( int index = 0 ; index < nParticles ; index++){
1189 
1190  MCParticle* part = dynamic_cast<MCParticle*>( col->getElementAt( index ) ) ;
1191 
1192  printf("[%8.8d]", part->id() );
1193  printf("%5d|" , index );
1194  printf("%10d|" , part->getPDG() );
1195  printf("% 1.2e,% 1.2e,% 1.2e|" ,
1196  part->getMomentum()[0] ,
1197  part->getMomentum()[1] ,
1198  part->getMomentum()[2] );
1199  printf("% 1.2e,% 1.2e,% 1.2e|" ,
1200  part->getMomentumAtEndpoint()[0] ,
1201  part->getMomentumAtEndpoint()[1] ,
1202  part->getMomentumAtEndpoint()[2] );
1203  printf("% 1.2e|" , part->getEnergy() ) ;
1204 
1205  printf(" %1d |" , part->getGeneratorStatus() );
1206  printf("%s|" , getSimulatorStatusString( part ).c_str() );
1207  printf("% 1.2e,% 1.2e,% 1.2e|" ,
1208  part->getVertex()[0] ,
1209  part->getVertex()[1] ,
1210  part->getVertex()[2] );
1211  printf("% 1.2e,% 1.2e,% 1.2e|" ,
1212  part->getEndpoint()[0] ,
1213  part->getEndpoint()[1] ,
1214  part->getEndpoint()[2] );
1215  printf("% 1.2e|" , part->getMass() ) ;
1216  printf("% 1.2e|" , part->getCharge() ) ;
1217 
1218  printf("% 1.2e,% 1.2e,% 1.2e|" ,
1219  part->getSpin()[0] ,
1220  part->getSpin()[1] ,
1221  part->getSpin()[2] );
1222 
1223  printf(" (%d, %d) |" ,
1224  part->getColorFlow()[0] ,
1225  part->getColorFlow()[1] );
1226 
1227  cout << " [" ;
1228 
1229  for(unsigned int k=0;k<part->getParents().size();k++){
1230  if(k>0) cout << "," ;
1231  cout << p2i_map[ part->getParents()[k] ] ;
1232  }
1233  cout << "] - [" ;
1234  for(unsigned int k=0;k<part->getDaughters().size();k++){
1235  if(k>0) cout << "," ;
1236  cout << p2i_map[ part->getDaughters()[k] ] ;
1237  }
1238  cout << "] " << endl ;
1239  }
1240 
1241  cout << endl
1242  << "-------------------------------------------------------------------------------- "
1243  << endl ;
1244  }
1245 
1246  void LCTOOLS::printRelation( const EVENT::LCCollection* col ) {
1247 
1248  if( col->getTypeName() != LCIO::LCRELATION ){
1249  cout << " collection not of type " << LCIO::LCRELATION << endl ;
1250  return ;
1251  }
1252 
1253  cout << endl
1254  << "--------------- " << "print out of " << LCIO::LCRELATION << " collection "
1255  << "--------------- " << endl ;
1256 
1257  cout << endl
1258  << " flag: 0x" << hex << col->getFlag() << dec << endl ;
1259 
1260  printParameters( col->getParameters() ) ;
1261 
1262  int nRel = col->getNumberOfElements() ;
1263 
1264  cout << " fromType : " << col->getParameters().getStringVal("FromType") << endl ;
1265  cout << " toType : " << col->getParameters().getStringVal("ToType") << endl ;
1266 
1267  cout << endl;
1268  LCRelation* rel=NULL;
1269  cout << header(rel);
1270  cout << tail(rel);
1271 
1272  for( int i=0; i< nRel; i++ ){
1273  rel = dynamic_cast<LCRelation*>( col->getElementAt( i ));
1275  }
1276 
1277 
1278  }
1279 
1280 
1281  int LCTOOLS::printDaughterParticles(const MCParticle* part, int index){
1282 
1283  int motherIndex = index - 1 ;
1284  // print this particles daughters
1285  for(unsigned int i=0; i<part->getDaughters().size();i++){
1286 
1287  MCParticle* d = part->getDaughters()[i] ;
1288 
1289  cout << index++ << " [" << motherIndex << "] "
1290  << d->getPDG() << " | ("
1291  << d->getMomentum()[0] << ", "
1292  << d->getMomentum()[1] << ", "
1293  << d->getMomentum()[2] << ") | "
1294  << part->getGeneratorStatus() << " | "
1295  << part->getSimulatorStatus() << " | ("
1296  << d->getVertex()[0] << ", "
1297  << d->getVertex()[1] << ", "
1298  << d->getVertex()[2] << ") | (" ;
1299  if( part->getEndpoint() != 0 ){
1300  cout << part->getEndpoint()[0] << ", "
1301  << part->getEndpoint()[1] << ", "
1302  << part->getEndpoint()[2] << ") | " ;
1303  }else{
1304  cout << " not set ) | " ;
1305  }
1306  cout << d->getMass() << " | "
1307  << d->getCharge() << " | "
1308  << d->getEnergy()
1309  << endl ;
1310 
1311  index = printDaughterParticles( part->getDaughters()[i] , index ) ;
1312  }
1313  return index ;
1314 
1315  }
1316 
1317  void LCTOOLS::printParameters( const EVENT::LCParameters& params ){
1318 
1319  StringVec intKeys ;
1320  int nIntParameters = params.getIntKeys( intKeys ).size() ;
1321  for(int i=0; i< nIntParameters ; i++ ){
1322  IntVec intVec ;
1323  params.getIntVals( intKeys[i], intVec ) ;
1324  int nInt = intVec.size() ;
1325  cout << " parameter " << intKeys[i] << " [int]: " ;
1326 
1327  if( nInt == 0 ){
1328  cout << " [empty] " << std::endl ;
1329  }
1330  for(int j=0; j< nInt ; j++ ){
1331  cout << intVec[j] << ", " ;
1332  }
1333  cout << endl ;
1334  }
1335  StringVec floatKeys ;
1336  int nFloatParameters = params.getFloatKeys( floatKeys ).size() ;
1337  for(int i=0; i< nFloatParameters ; i++ ){
1338  FloatVec floatVec ;
1339  params.getFloatVals( floatKeys[i], floatVec ) ;
1340  int nFloat = floatVec.size() ;
1341  cout << " parameter " << floatKeys[i] << " [float]: " ;
1342  if( nFloat == 0 ){
1343  cout << " [empty] " << std::endl ;
1344  }
1345  for(int j=0; j< nFloat ; j++ ){
1346  cout << floatVec[j] << ", " ;
1347  }
1348  cout << endl ;
1349  }
1350  StringVec doubleKeys ;
1351  int nDoubleParameters = params.getDoubleKeys( doubleKeys ).size() ;
1352  for(int i=0; i< nDoubleParameters ; i++ ){
1353  DoubleVec doubleVec ;
1354  params.getDoubleVals( doubleKeys[i], doubleVec ) ;
1355  int nDouble = doubleVec.size() ;
1356  cout << " parameter " << doubleKeys[i] << " [double]: " ;
1357  if( nDouble == 0 ){
1358  cout << " [empty] " << std::endl ;
1359  }
1360  for(int j=0; j< nDouble ; j++ ){
1361  cout << doubleVec[j] << ", " ;
1362  }
1363  cout << endl ;
1364  }
1365  StringVec stringKeys ;
1366  int nStringParameters = params.getStringKeys( stringKeys ).size() ;
1367  for(int i=0; i< nStringParameters ; i++ ){
1368  StringVec stringVec ;
1369  params.getStringVals( stringKeys[i], stringVec ) ;
1370  int nString = stringVec.size() ;
1371  cout << " parameter " << stringKeys[i] << " [string]: " ;
1372  if( nString == 0 ){
1373  cout << " [empty] " << std::endl ;
1374  }
1375  for(int j=0; j< nString ; j++ ){
1376  cout << stringVec[j] << ", " ;
1377  }
1378  cout << endl ;
1379  }
1380 
1381  }
1382 
1383  void LCTOOLS::dumpRunHeader(const EVENT::LCRunHeader* run) {
1384  cout << " Run : " << run->getRunNumber()
1385  << " - " << run->getDetectorName()
1386  << ": " << run->getDescription() << endl ;
1387 
1388  printParameters( const_cast<EVENT::LCRunHeader*>(run)->parameters() ) ;
1389 
1390  cout << " --------------------------------------------------------------- " << endl ;
1391  }
1392 
1393 
1394 
1395  std::string LCTOOLS::getSimulatorStatusString(const MCParticle* mcp){
1396 
1397  if( mcp == 0 ) {
1398 
1399  std::stringstream str ;
1400 
1401  str << "simulator status bits: [sbvtcls] "
1402  << " s: created in simulation"
1403  << " b: backscatter"
1404  << " v: vertex is not endpoint of parent"
1405  << " t: decayed in tracker"
1406  << " c: decayed in calorimeter"
1407  << " l: has left detector"
1408  << " s: stopped"
1409  << " o: overlay"
1410  << std::endl ;
1411 
1412  return str.str() ;
1413  }
1414 
1415  std::string s("[ 0 ]") ;
1416 
1417  if( mcp->getSimulatorStatus() == 0 )
1418 
1419  return s ;
1420 
1421  if( mcp->isCreatedInSimulation() )
1422  s[1]='s' ;
1423  else
1424  s[1]=' ' ;
1425  if( mcp->isBackscatter() )
1426  s[2]='b' ;
1427  else
1428  s[2]=' ' ;
1429  if( mcp->vertexIsNotEndpointOfParent() )
1430  s[3]='v' ;
1431  else
1432  s[3]=' ' ;
1433  if( mcp->isDecayedInTracker() )
1434  s[4]='t' ;
1435  else
1436  s[4]=' ' ;
1437  if( mcp->isDecayedInCalorimeter() )
1438  s[5]='c' ;
1439  else
1440  s[5]=' ' ;
1441  if( mcp->hasLeftDetector() )
1442  s[6]='l' ;
1443  else
1444  s[6]=' ' ;
1445  if( mcp->isStopped() )
1446  s[7]='s' ;
1447  else
1448  s[7]=' ' ;
1449  if( mcp->isOverlay() )
1450  s[8]='o' ;
1451  else
1452  s[8]=' ' ;
1453 
1454  return s ;
1455  }
1456 
1457 
1458  std::string LCTOOLS::getQualityBits(const SimTrackerHit* sth){
1459 
1460  if( sth == 0 ) {
1461 
1462  std::stringstream str ;
1463 
1464  str << " quality bits: [os......] "
1465  << " o: hit from overlay"
1466  << " s: hit from secondary not from the MCParticle associated to it"
1467  << std::endl ;
1468 
1469  return str.str() ;
1470  }
1471 
1472 
1473  if( sth->getQuality() == 0 )
1474  return "[ 0 ]";
1475 
1476  std::string s("[ ]");
1477  if( sth->isOverlay() )
1478  s[1]='o' ;
1479  else
1480  s[1]=' ' ;
1481  if( sth->isProducedBySecondary() )
1482  s[2]='s' ;
1483  else
1484  s[2]=' ' ;
1485 
1486  return s ;
1487  }
1488 
1489 } // namespace
1490 
virtual DoubleVec & getDoubleVals(const std::string &key, DoubleVec &values) const =0
Adds all double values for the given key to values.
virtual const ParticleIDVec & getParticleIDs() const =0
The particle Id&#39;s sorted by their likelihood.
const std::string & header(const EVENT::Vertex *)
operator for detailed output of a vertex object (e.g.
Definition: Operators.cc:2756
A generic tracker hit to be used by pattern recognition.
Definition: TrackerHit.h:26
virtual const MCParticleVec & getParents() const =0
Returns the parents of this particle.
virtual int getNRawDataWords() const =0
Return the number of raw data (32-bit) words stored for the hit.
The generic simulated calorimeter hit.
virtual const StringVec & getIntKeys(StringVec &keys) const =0
Returns a list of all keys of integer parameters.
virtual int getType() const =0
Type - userdefined.
The Vertex class for LCIO.
Definition: Vertex.h:34
virtual const StringVec & getStringKeys(StringVec &keys) const =0
Returns a list of all keys of string parameters.
virtual const LCParameters & getParameters() const =0
Parameters defined for this event.
Exception for unknown algorithms.
Definition: PIDHandler.h:136
virtual int id() const =0
Returns an object id for internal (debugging) use in LCIO.
virtual const std::string & getDetectorName() const =0
Returns the name of the detector setup used in the simulation.
virtual double getWeight() const =0
Returns the event weight.
virtual const double * getMomentumAtEndpoint() const =0
Returns the particle&#39;s 3-momentum at the endpoint in [GeV] Only float used in files.
Interface for the run header.
Definition: LCRunHeader.h:23
virtual int getRawDataWord(int i) const =0
Return the raw data (32-bit) word at i.
virtual float getCharge() const =0
Returns the integrated charge of the hit.
lcio_short< T > lcshort(const T *t, const EVENT::LCCollection *b=NULL)
Definition: Operators.h:74
virtual bool isCreatedInSimulation() const =0
True if the particle has been created by the simulation program (rather than the generator).
virtual int getQuality() const =0
Returns a quality flag for the hit.
virtual bool isDecayedInCalorimeter() const =0
True if the particle decayed or interacted (non-continuous interaction, particle terminated) in non-t...
Convenient class for setting and retrieving particle id information attached to ReconstructedParticle...
Definition: PIDHandler.h:33
A tracker hit on a planar surface - the hit is stored as: x,y,z, u(theta, phi), v(theta,phi), du, dv where (x,y,z) is the position in global cartesian coordinates, u,v are the the meassurement directions (unit vectors, spanning the plane) and du,dv are the measurement errors along these directions.
A generic simulated tracker hit.
Definition: SimTrackerHit.h:23
virtual const float * getSpin() const =0
Returns the spin (helicity) vector of the particle.
T endl(T...args)
T left(T...args)
virtual float getTime() const =0
Returns the time of the hit.
const EVENT::StringVec & getParameterNames(int algorithmID)
The names of parameters for the algorithm with algorithmID - throws UnknownAlgoritm.
Definition: PIDHandler.cc:212
virtual int getPDG() const =0
Returns the PDG code of the particle.
T end(T...args)
virtual const FloatVec & getParameters() const =0
Parameters associated with this hypothesis.
virtual int getRunNumber() const =0
Return the run number off this event.
virtual const std::vector< std::string > * getCollectionNames() const =0
Returns the names of the collections in the event.
virtual float getLikelihood() const =0
The likelihood of this hypothesis - in a user defined normalization.
Convenient helper class for setting single bits in a 32bit-field, such as collection flags or hit typ...
Definition: BitSet32.h:31
virtual bool isProducedBySecondary() const =0
True if the particle has been created by a secondary particle that is not stored in the MCParticle co...
TrackerData contains the corrected (calibrated) raw tracker data.
Definition: TrackerData.h:23
virtual bool isStopped() const =0
True if the particle lost all kinetic energy inside the world volume and did not decay.
virtual const int * getColorFlow() const =0
Returns the color flow as defined by the generator.
virtual double getMass() const =0
Returns the mass of the particle in [GeV] - only float used in files.
virtual const StringVec & getDoubleKeys(StringVec &keys) const =0
Returns a list of all keys of double parameters.
virtual bool hasLeftDetector() const =0
True if the particle left the world volume undecayed.
virtual bool isBackscatter() const =0
True if the particle was created by the simulator as a result of an interaction or decay in non-track...
std::vector< std::string > LCStrVec
Header file for the f77-wrapper functions for stl vectors.
Definition: lcvec.h:17
const std::string & getAlgorithmName(int algoID)
Return the name of the algorithm with id - throws UnknownAlgorithm.
Definition: PIDHandler.cc:170
virtual long64 getTimeStamp() const =0
Returns the time stamp of the event.
virtual LCObject * getElementAt(int index) const =0
Returns pointer to element at index - no range check, use getNumberOfEntries().
STL class.
Helper class that allows to convert time stamps as defined in LCEvent::getTimeStamp() ( ns since 1...
Definition: LCTime.h:19
virtual int getFlag() const =0
Returns flag word for collection.
virtual double getEnergy() const =0
Returns the energy of the particle (at the vertex) in [GeV] computed from the particle&#39;s momentum and...
T push_back(T...args)
Tracker pulses as computed from TrackerData objects or as directly measured by a specific subdetector...
Definition: TrackerPulse.h:26
Deprecated.
Definition: TPCHit.h:22
virtual bool isDecayedInTracker() const =0
True if the particle decayed or interacted in a tracking region.
const EVENT::IntVec & getAlgorithmIDs()
Return the IDs of all known Algorithms.
Definition: PIDHandler.cc:225
virtual int getGeneratorStatus() const =0
Returns the status for particles as defined by the generator, typically 0 empty line 1 undecayed ...
virtual int getRunNumber() const =0
Returns the run number.
virtual LCCollection * getCollection(const std::string &name) const =0
Returns the collection for the given name.
virtual const double * getVertex() const =0
Returns the production vertex of the particle in [mm].
Simple interface to store generic named parameters of type int, float and string. ...
Definition: LCParameters.h:28
The LCIO cluster.
Definition: Cluster.h:30
virtual int getSimulatorStatus() const =0
Returns the status for particles from the simulation, e.g.
static const int MAX_HITS
Definition: LCTOOLS.cc:49
The LCIO track class.
Definition: Track.h:33
Convenient class for decoding cellIDs from collection parameter LCIO::CellIDEncoding.
Definition: CellIDDecoder.h:29
virtual const ParticleIDVec & getParticleIDs() const =0
The particle Id&#39;s sorted by their likelihood.
T str(T...args)
Int vector used for user extensions.
Definition: LCIntVec.h:24
Float vector used for user extensions.
Definition: LCFloatVec.h:25
virtual const std::string & getTypeName() const =0
Returns the type name of the collection - valid names are defined in LCIO.
Simple interface to store generic user data.
virtual const std::string & getDetectorName() const =0
Returns the name of the detector setup used in the simulation.
The LCIO reconstructedParticle.
The LCIO Monte Carlo particle.
Definition: MCParticle.h:27
virtual int getQuality() const =0
The quality bit flag of the hit.
virtual int getNumberOfElements() const =0
Returns the number of elements in the collection.
Persistent interface for LCIO ParticleIDs.
Definition: ParticleID.h:28
virtual const StringVec & getFloatKeys(StringVec &keys) const =0
Returns a list of all keys of float parameters.
A single weighted relationship between two LCObjects.
Definition: LCRelation.h:29
T size(T...args)
const std::string & tail(const EVENT::Vertex *)
Definition: Operators.cc:2761
virtual float getCharge() const =0
Returns the particle&#39;s charge.
virtual StringVec & getStringVals(const std::string &key, StringVec &values) const =0
Adds all string values for the given key to values.
The generic calorimeter hit for real data (or simulation thereof).
The main event interface.
Definition: LCEvent.h:31
Generic class for raw tracker data.
The generic collection used in LCIO.
Definition: LCCollection.h:29
A tracker hit on a cylindrical surface that runs parallel to the z-axis - the hit is stored as: x...
T begin(T...args)
virtual int getAlgorithmType() const =0
Type of the algorithm/module that created this hypothesis - NOTE: must be unique within one collectio...
virtual int getEventNumber() const =0
Returns this event&#39;s number .
virtual const std::string & getDescription() const =0
Description of the simulation, physics channels etc.
virtual IntVec & getIntVals(const std::string &key, IntVec &values) const =0
Adds all integer values for the given key to values.
T hex(T...args)
virtual const double * getEndpoint() const =0
Returns the endpoint of the particle in [mm] if the endpoint has been set explicetly.
virtual const std::string & getStringVal(const std::string &key) const =0
Returns the first string value for the given key.
virtual const LCParameters & getParameters() const =0
Parameters defined for this collection.
void dumpEvent(EVENT::LCEvent *event)
virtual const double * getMomentum() const =0
Returns the particle&#39;s 3-momentum at the production vertex in [GeV].
virtual bool isOverlay() const =0
True if the particle has been overlayed by the simulation (or digitization) program.
virtual const MCParticleVec & getDaughters() const =0
Returns the daughters of this particle.
The generic calorimeter hit - created from SimCalorimeterHit or RawCalorimeterHit.
virtual bool vertexIsNotEndpointOfParent() const =0
True if the particle was created as a result of a continuous process where the parent particle contin...
T printf(T...args)
virtual int getCellID() const =0
Returns the detector specific cell id.
virtual FloatVec & getFloatVals(const std::string &key, FloatVec &values) const =0
Adds all float values for the given key to values.
virtual bool isOverlay() const =0
True if the hit has been overlayed by the simulation (or digitization) program.
String vector used for user extensions.
Definition: LCStrVec.h:24
virtual int getPDG() const =0
The PDG code of this id - UnknownPDG ( 999999 ) if unknown.