00001 #include "lcio.h"
00002
00003 #include "IO/LCWriter.h"
00004 #include "IO/LCReader.h"
00005 #include "IO/LCEventListener.h"
00006 #include "IO/LCRunListener.h"
00007
00008 #include "EVENT/LCIO.h"
00009 #include "EVENT/TrackerRawData.h"
00010
00011 #include "IMPL/LCEventImpl.h"
00012 #include "IMPL/LCCollectionVec.h"
00013 #include "IMPL/SimCalorimeterHitImpl.h"
00014 #include "IMPL/CalorimeterHitImpl.h"
00015 #include "IMPL/MCParticleImpl.h"
00016 #include "IMPL/TrackerHitImpl.h"
00017 #include "IMPL/TrackImpl.h"
00018 #include "IMPL/ClusterImpl.h"
00019 #include "IMPL/ReconstructedParticleImpl.h"
00020 #include "IMPL/VertexImpl.h"
00021
00022 #include "IMPL/LCFlagImpl.h"
00023 #include "UTIL/LCTOOLS.h"
00024 #include "UTIL/PIDHandler.h"
00025
00026 #include "IMPL/LCRelationImpl.h"
00027
00028 #include "UTIL/LCRelationNavigator.h"
00029
00030 #include "CalibrationConstant.h"
00031
00032
00033 #define M_PI 3.14159265358979323846
00034
00035 #include <iostream>
00036 #include <algorithm>
00037
00038 using namespace std ;
00039 using namespace lcio ;
00040
00041 static std::string FILEN = "simjob.slcio" ;
00042 static std::string OUTFILEN = "recjob.slcio" ;
00043 static const int NHITS = 50 ;
00044 static const int nRecP = 10 ;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 class RunEventProcessor : public LCRunListener, public LCEventListener{
00058
00059 protected:
00060 LCWriter* lcWrt ;
00061 int nEvent ;
00062
00063 public:
00064
00065 RunEventProcessor() : nEvent(0) {
00066
00067
00068 lcWrt = LCFactory::getInstance()->createLCWriter() ;
00069
00070 try{
00071 lcWrt->setCompressionLevel( 9 ) ;
00072 lcWrt->open( OUTFILEN , LCIO::WRITE_NEW ) ;
00073 }
00074
00075 catch(IOException& e){
00076 cout << "[RunEventProcessor()] Can't open file for writing - "
00077 << e.what() << endl ;
00078 exit(1) ;
00079 }
00080
00081 }
00082
00083 ~RunEventProcessor(){
00084
00085
00086 lcWrt->close() ;
00087
00088 cout << endl
00089 << " added collection: 'SomeClusters' and 'SomeTracks'"
00090 << " to " << nEvent <<" events"
00091 << " and added one extra MCParticle to each event."
00092 << endl << endl ;
00093 delete lcWrt ;
00094 }
00095
00096 void processEvent( LCEvent * evt ) {
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 std::string tpcHitName( "TrackerRawDataExample" ) ;
00121
00122
00123
00124
00125 LCCollection* tpcHits = evt->getCollection( tpcHitName) ;
00126
00127
00128
00129
00130
00131
00132
00133
00134 LCCollectionVec* trkhitVec = new LCCollectionVec( LCIO::TRACKERHIT ) ;
00135 int nTrackerRawDatas = tpcHits->getNumberOfElements() ;
00136
00137 for(int j=0;j<nTrackerRawDatas;j++){
00138 TrackerHitImpl* trkHit = new TrackerHitImpl ;
00139
00140 TrackerRawData* tpcRawHit = dynamic_cast<TrackerRawData*> ( tpcHits->getElementAt(j) ) ;
00141
00142 trkHit->setTime( tpcRawHit->getTime() ) ;
00143
00144 int cellID = tpcRawHit->getCellID0() ;
00145 double pos[3] = { (cellID & 0xff) , (cellID & 0xff00)>>8 , (cellID & 0xff0000)>>16 } ;
00146 trkHit->setPosition( pos ) ;
00147
00148 trkHit->rawHits().push_back( tpcRawHit ) ;
00149 trkHit->rawHits().push_back( tpcRawHit ) ;
00150
00151 FloatVec cov(6) ;
00152 cov[0] = 1. ;
00153 cov[1] = 2. ;
00154 cov[2] = 3. ;
00155 cov[3] = 4. ;
00156 cov[4] = 5. ;
00157 cov[5] = 6. ;
00158 trkHit->setCovMatrix( cov ) ;
00159
00160 trkhitVec->addElement( trkHit ) ;
00161 }
00162
00163
00164
00165
00166
00167 StringVec typeNames ;
00168 IntVec typeValues ;
00169 typeNames.push_back( LCIO::TPCHIT ) ;
00170 typeValues.push_back( 1 ) ;
00171 trkhitVec->parameters().setValues("TrackerHitTypeNames" , typeNames ) ;
00172 trkhitVec->parameters().setValues("TrackerHitTypeValues" , typeValues ) ;
00173
00174
00175 evt->addCollection( trkhitVec , "TrackerHits") ;
00176
00177
00178 LCCollectionVec* trkVec = new LCCollectionVec( LCIO::TRACK ) ;
00179
00180
00181 LCFlagImpl trkFlag(0) ;
00182 trkFlag.setBit( LCIO::TRBIT_HITS ) ;
00183 trkVec->setFlag( trkFlag.getFlag() ) ;
00184
00185
00186 int nTrk = 5 ;
00187 for( int i=0; i < nTrk ; i ++ ){
00188
00189 TrackImpl* trk = new TrackImpl ;
00190 trk->setTypeBit( 7 ) ;
00191 trk->setOmega( (i+1)*1.1 ) ;
00192 trk->setTanLambda( (i+1)* M_PI / 10. ) ;
00193 trk->setPhi( (i+1)* M_PI / 5. ) ;
00194 trk->setD0( i+1 ) ;
00195 trk->setZ0( (i+1)*10. ) ;
00196 trk->setChi2( 1.01 ) ;
00197 trk->setNdf( 42 ) ;
00198
00199 trk->setRadiusOfInnermostHit( 3.141592 ) ;
00200
00201
00202 const int NTRACKER = 3 ;
00203 const int VTXINDEX = 0 ;
00204 const int SITINDEX = 1 ;
00205 const int TPCINDEX = 2 ;
00206 StringVec trackerNames ;
00207 trackerNames.resize( NTRACKER ) ;
00208 trackerNames[VTXINDEX] = "VTX" ;
00209 trackerNames[SITINDEX] = "SIT" ;
00210 trackerNames[TPCINDEX] = "TPC" ;
00211
00212 trkVec->parameters().setValues( "TrackSubdetectorNames" , trackerNames ) ;
00213
00214 trk->subdetectorHitNumbers().resize( NTRACKER ) ;
00215 trk->subdetectorHitNumbers()[ VTXINDEX ] = 12 ;
00216 trk->subdetectorHitNumbers()[ SITINDEX ] = 24 ;
00217 trk->subdetectorHitNumbers()[ TPCINDEX ] = 36 ;
00218
00219 trk->setdEdx( 3.14159 ) ;
00220 trk->setdEdxError( 42. ) ;
00221 float cov[15] = { 1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15. } ;
00222 trk->setCovMatrix( cov ) ;
00223 float ref[3] = { 12. ,123456789. , .0987654321 } ;
00224 trk->setReferencePoint( ref ) ;
00225
00226
00227 int iHit1 = (int) ( double (trkhitVec->size()) * rand() / RAND_MAX ) ;
00228 int iHit2 = (int) ( double (trkhitVec->size()) * rand() / RAND_MAX ) ;
00229 int iHit3 = (int) ( double (trkhitVec->size()) * rand() / RAND_MAX ) ;
00230
00231 trk->addHit( dynamic_cast<TrackerHit*>( (*trkhitVec)[iHit1] ) ) ;
00232 trk->addHit( dynamic_cast<TrackerHit*>( (*trkhitVec)[iHit2] ) ) ;
00233 trk->addHit( dynamic_cast<TrackerHit*>( (*trkhitVec)[iHit3] ) ) ;
00234
00235
00236
00237 if( trkVec->size() > 1 ){
00238 trk->addTrack( dynamic_cast<TrackImpl*> ( (*trkVec)[ trkVec->size() - 1 ] ) ) ;
00239 trk->addTrack( dynamic_cast<TrackImpl*> ( (*trkVec)[ trkVec->size() - 2 ] ) ) ;
00240 }
00241
00242 trkVec->addElement( trk ) ;
00243 }
00244
00245
00246 evt->addCollection( trkVec , "SomeTracks" ) ;
00247
00248
00249
00250 std::string simcalHitName( "ECAL007" ) ;
00251
00252 LCCollection* simcalHits = evt->getCollection( simcalHitName ) ;
00253
00254
00255
00256
00257
00258 LCCollectionVec* clusterVec = new LCCollectionVec( LCIO::CLUSTER ) ;
00259 LCCollectionVec* calHits = new LCCollectionVec( LCIO::CALORIMETERHIT ) ;
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 LCCollectionVec* scRel = new LCCollectionVec(LCIO::LCRELATION ) ;
00273 scRel->parameters().setValue( "RelationFromType" , LCIO::CALORIMETERHIT ) ;
00274 scRel->parameters().setValue( "RelationToType" , LCIO::SIMCALORIMETERHIT ) ;
00275
00276 int nSimHits = simcalHits->getNumberOfElements() ;
00277 for(int j=0;j<nSimHits;j++){
00278
00279 CalorimeterHitImpl* calHit = new CalorimeterHitImpl ;
00280 SimCalorimeterHit* simcalHit = dynamic_cast<SimCalorimeterHit*> ( simcalHits->getElementAt(j) ) ;
00281
00282
00283
00284 calHit->setEnergy( simcalHit->getEnergy() ) ;
00285 calHit->setCellID0( simcalHit->getCellID0() ) ;
00286 calHit->setPosition( simcalHit->getPosition()) ;
00287
00288
00289
00290 scRel->addElement( new LCRelationImpl( calHit , simcalHit , 0.5 ) ) ;
00291 scRel->addElement( new LCRelationImpl( calHit , simcalHit , 0.5 ) ) ;
00292 scRel->addElement( new LCRelationImpl( calHit , simcalHit , 0.5 ) ) ;
00293 calHits->addElement( calHit ) ;
00294
00295
00296
00297
00298
00299
00300 }
00301 evt->addCollection( calHits , "CalorimeterHits") ;
00302
00303
00304 LCFlagImpl relFlag(0) ;
00305 relFlag.setBit( LCIO::LCREL_WEIGHTED ) ;
00306 scRel->setFlag( relFlag.getFlag() ) ;
00307
00308 evt->addCollection( scRel , "CalorimeterHitsSimRel" ) ;
00309
00310
00311
00312
00313
00314 if( evt->getEventNumber() == 0 && evt->getRunNumber() == 0 ) {
00315
00316
00317
00318
00319 LCRelationNavigator rel( scRel ) ;
00320
00321 std::cout << "Relation example for first event: "
00322 << " [" << rel.getFromType() << " - " << rel.getToType() << "] "
00323 << std::endl ;
00324
00325 int nCalHits = calHits->getNumberOfElements() ;
00326 for(int j=0; j < nCalHits ; j++){
00327 CalorimeterHit* calHit = dynamic_cast<CalorimeterHit*>( calHits->getElementAt(j) ) ;
00328
00329 std::cout << " relations for object " << hex << calHit->id()
00330 ;
00331
00332 const LCObjectVec& simHits = rel.getRelatedToObjects( calHit ) ;
00333 const FloatVec& weights = rel.getRelatedToWeights( calHit ) ;
00334
00335 int nSimHits = simHits.size() ;
00336 for(int k=0;k<nSimHits;k++){
00337
00338 std::cout << " [" << simHits[k]->id() << "] ("
00339 << weights[k] << ") " ;
00340 }
00341 std::cout << dec << std::endl ;
00342 }
00343
00344
00345
00346
00347
00348
00349 LCCollectionVec* calVec = new LCCollectionVec( LCIO::LCGENERICOBJECT ) ;
00350 for(int j=0;j<nCalHits;j++){
00351
00352 CalorimeterHit* calHit = dynamic_cast<CalorimeterHit*>( calHits->getElementAt(j) ) ;
00353
00354 CalibrationConstant* cCon = new CalibrationConstant( calHit->getCellID0() ,
00355 1.*j , 0.01*j );
00356 calVec->addElement( cCon ) ;
00357 }
00358
00359 evt->addCollection( calVec , "Calibration" ) ;
00360 }
00361
00362
00363 LCCollectionVec* emtpyCol = new LCCollectionVec( LCIO::LCGENERICOBJECT ) ;
00364 evt->addCollection( emtpyCol , "EmptyLCGenericObject" ) ;
00365
00366
00367
00368
00369 LCFlagImpl clusterFlag(0) ;
00370 clusterFlag.setBit( LCIO::CLBIT_HITS ) ;
00371 clusterVec->setFlag( clusterFlag.getFlag() ) ;
00372
00373 StringVec shapeParams ;
00374 shapeParams.push_back("Shape_trans") ;
00375 shapeParams.push_back("Shape_long") ;
00376 shapeParams.push_back("Shape_axis_x") ;
00377 shapeParams.push_back("Shape_axis_y") ;
00378 shapeParams.push_back("Shape_axis_z") ;
00379 shapeParams.push_back("Shape_quality") ;
00380
00381 clusterVec->parameters().setValues( "ClusterShapeParameters" , shapeParams ) ;
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 if( calHits ){
00405
00406 int nHits = calHits->getNumberOfElements() ;
00407 int nCluster = nHits / 10 ;
00408
00409
00410
00411 PIDHandler cluPidHandler( clusterVec ) ;
00412
00413 StringVec pNames ;
00414 pNames.push_back( "param0" );
00415 pNames.push_back( "param1" );
00416 pNames.push_back( "param2" );
00417
00418 IntVec algoIDs(3) ;
00419 algoIDs[0] = cluPidHandler.addAlgorithm( "recojobRunEventProcessor" , pNames ) ;
00420 algoIDs[1] = cluPidHandler.addAlgorithm( "anotherAlgorithm" , pNames ) ;
00421 algoIDs[2] = cluPidHandler.addAlgorithm( "andYetAnotherAlgorithm" , pNames ) ;
00422
00423 for( int i=0; i < nCluster ; i ++ ){
00424
00425 ClusterImpl* cluster = new ClusterImpl ;
00426
00427
00428 cluster->setTypeBit( 1 ) ;
00429 cluster->setTypeBit( 7 ) ;
00430 cluster->setTypeBit( 11 ) ;
00431
00432 cluster->setEnergy( (i+1)*1.1 ) ;
00433 float pos[3] = { 12. ,123456789. , .0987654321 } ;
00434 cluster->setPosition( pos ) ;
00435 float errpos[6] = { 1.,2.,3.,4.,5.,6.} ;
00436 cluster->setPositionError( errpos ) ;
00437 cluster->setITheta( (i+1)* M_PI / 10. ) ;
00438 cluster->setIPhi( (i+1)* M_PI / 5. ) ;
00439 float errdir[6] = { 1.,2.,3.} ;
00440 cluster->setDirectionError( errdir ) ;
00441
00442
00443 float shapeArray[6] = { 1.,2.,3.,3.,2.,1.} ;
00444 FloatVec shape ;
00445 copy( &shapeArray[0] , &shapeArray[5] , back_inserter( shape ) ) ;
00446 cluster->setShape( shape ) ;
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463 int nPID = algoIDs.size() ;
00464
00465 for(int j=0;j<nPID;j++){
00466
00467
00468
00469 FloatVec fv( pNames.size() ) ;
00470 for( unsigned k=0 ; k < pNames.size() ; k++){
00471 fv[k] = j*1000.+k*.1 ;
00472 }
00473
00474 cluPidHandler.setParticleID( cluster,
00475 j ,
00476 22 ,
00477 1.*j / nPID ,
00478 algoIDs[j] ,
00479 fv ) ;
00480
00481 }
00482
00483
00484
00485 const int NCALORIMETER = 2 ;
00486 const int ECALINDEX = 0 ;
00487 const int HCALINDEX = 1 ;
00488 StringVec detNames ;
00489 detNames.resize( NCALORIMETER ) ;
00490 detNames[ECALINDEX] = "Ecal" ;
00491 detNames[HCALINDEX] = "Hcal" ;
00492 clusterVec->parameters().setValues( "ClusterSubdetectorNames" , detNames ) ;
00493
00494
00495 cluster->subdetectorEnergies().resize( NCALORIMETER ) ;
00496 cluster->subdetectorEnergies()[ ECALINDEX ] = 42.42 ;
00497 cluster->subdetectorEnergies()[ HCALINDEX ] = 24.24 ;
00498
00499
00500 int iHit1 = (int) ( double (calHits->size()) * rand() / RAND_MAX ) ;
00501 int iHit2 = (int) ( double (calHits->size()) * rand() / RAND_MAX ) ;
00502 int iHit3 = (int) ( double (calHits->size()) * rand() / RAND_MAX ) ;
00503
00504 cluster->addHit( dynamic_cast<CalorimeterHit*>( (*calHits)[iHit1] ) , 1.0 ) ;
00505 cluster->addHit( dynamic_cast<CalorimeterHit*>( (*calHits)[iHit2] ) , 2.0 ) ;
00506 cluster->addHit( dynamic_cast<CalorimeterHit*>( (*calHits)[iHit3] ) , 3.0 ) ;
00507
00508
00509 if( clusterVec->size() > 1 ){
00510 cluster->addCluster( dynamic_cast<ClusterImpl*>
00511 ( (*clusterVec)[ clusterVec->size() - 1 ] ) ) ;
00512 cluster->addCluster( dynamic_cast<ClusterImpl*>
00513 ( (*clusterVec)[ clusterVec->size() - 2 ] ) ) ;
00514 }
00515
00516
00517 clusterVec->addElement( cluster ) ;
00518 }
00519 }
00520
00521 evt->addCollection( clusterVec , "SomeClusters" ) ;
00522
00523
00524 LCCollectionVec* vertexVec = new LCCollectionVec( LCIO::VERTEX ) ;
00525
00526
00527
00528
00529 for(int i=0; i < (nRecP+1); i++){
00530 VertexImpl* vtx = new VertexImpl ;
00531 if(i==0){
00532 vtx->setPrimary(true);
00533 }else{
00534 vtx->setPrimary(false);
00535 }
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548 switch(rand()%7){
00549 case 0: vtx->setAlgorithmType( "ZvTop" ); break;
00550 case 1: vtx->setAlgorithmType( "ZvKin" ); break;
00551 case 2: vtx->setAlgorithmType( "42" ); break;
00552 case 3: vtx->setAlgorithmType( "SimAnnealing" ); break;
00553 case 5: vtx->setAlgorithmType( "_Test" ); break;
00554 default: break;
00555 }
00556
00557 vtx->setChi2(1+i*.01);
00558 vtx->setProbability(0.0032+i*.01);
00559 vtx->setPosition(0.3453+i*.01,.45345354+i*.01,2.345354+i*.01);
00560
00561 FloatVec cov(6) ;
00562 cov[0] = 1. ;
00563 cov[1] = 2. ;
00564 cov[2] = 3. ;
00565 cov[3] = 4. ;
00566 cov[4] = 5. ;
00567 cov[5] = 6. ;
00568 vtx->setCovMatrix( cov ) ;
00569 for(int j=0;j<3;j++){
00570 vtx->addParameter( j*.1 ) ;
00571 }
00572
00573 vertexVec->addElement ( vtx ) ;
00574 }
00575
00576 evt->addCollection( vertexVec, "SomeVertices" ) ;
00577
00578
00579 LCCollectionVec* particleVec = new LCCollectionVec( LCIO::RECONSTRUCTEDPARTICLE ) ;
00580
00581
00582
00583 if( particleVec ){
00584
00585 PIDHandler recPIDHandler ( particleVec ) ;
00586
00587 StringVec pNames ;
00588 pNames.push_back( "param0" );
00589 pNames.push_back( "param1" );
00590 pNames.push_back( "param2" );
00591 pNames.push_back( "param3" );
00592 pNames.push_back( "param4" );
00593
00594 IntVec aIDs(4) ;
00595 aIDs[0] = recPIDHandler.addAlgorithm( "recojobRunEventProcessor" , pNames ) ;
00596 aIDs[1] = recPIDHandler.addAlgorithm( "anotherAlgorithm" , pNames ) ;
00597 aIDs[2] = recPIDHandler.addAlgorithm( "andYetAnotherAlgorithm" , pNames ) ;
00598 aIDs[3] = recPIDHandler.addAlgorithm( "andEvenAFourthAlgorithm" , pNames ) ;
00599
00600 for(int i=0;i<nRecP;i++){
00601 ReconstructedParticleImpl * part = new ReconstructedParticleImpl ;
00602 part->setType( 42 ) ;
00603
00604 float p[3] = { 1.1 , 2.2 , 3.3 } ;
00605 part->setMomentum( p ) ;
00606 part->setEnergy( i*101.101 ) ;
00607
00608 float covA[] = { 1.,2.,3.,4.,5.,6.,7.,8.,9.,10. } ;
00609 FloatVec cov(10) ;
00610 for(int j=0;j<10;j++) cov[j] = covA[j] ;
00611
00612
00613 part->setCovMatrix( cov) ;
00614 part->setMass( 0.511*i ) ;
00615 part->setCharge( -2./3. ) ;
00616 float x[3] = { 10.,20.,30. } ;
00617 part->setReferencePoint( x ) ;
00618
00619
00620 part->setStartVertex( dynamic_cast<Vertex*>( vertexVec->getElementAt(i) ) ) ;
00621 VertexImpl* v = dynamic_cast<VertexImpl*>( vertexVec->getElementAt(i+1) ) ;
00622
00623
00624 v->setAssociatedParticle( dynamic_cast<ReconstructedParticle*>( part ) ) ;
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643 int nPID = aIDs.size() ;
00644
00645 for(int j=0;j<nPID;j++){
00646
00647
00648 FloatVec fv( pNames.size() ) ;
00649 for( unsigned k=0 ; k < pNames.size() ; k++){
00650 fv[k] = j*1000.+k*.1 ;
00651 }
00652
00653 recPIDHandler.setParticleID( part,
00654 j*j ,
00655 -11 ,
00656 42.*j / nPID ,
00657 aIDs[j] ,
00658 fv ) ;
00659
00660 if( j == 2 )
00661
00662 recPIDHandler.setParticleIDUsed( part, aIDs[j] ) ;
00663
00664 }
00665
00666 part->setGoodnessOfPID( 0.7 ) ;
00667
00668
00669 if( i > 1 ){
00670 ReconstructedParticle* p1 =
00671 dynamic_cast<ReconstructedParticle*> ( particleVec->getElementAt(i-1) ) ;
00672 ReconstructedParticle* p2 =
00673 dynamic_cast<ReconstructedParticle*> ( particleVec->getElementAt(i-2) ) ;
00674 part->addParticle( p1 ) ;
00675 part->addParticle( p2 ) ;
00676 }
00677
00678 int iTrk = (int) ( double (trkVec->size()) * rand() / RAND_MAX ) ;
00679 Track* trk = dynamic_cast<Track*> ( trkVec->getElementAt( iTrk ) ) ;
00680 part->addTrack( trk ) ;
00681
00682
00683 int iClu = (int) ( double (clusterVec->size()) * rand() / RAND_MAX ) ;
00684 Cluster* clu = dynamic_cast<Cluster*> ( clusterVec->getElementAt( iClu ) ) ;
00685 part->addCluster( clu ) ;
00686
00687
00688
00689
00690
00691
00692
00693 particleVec->addElement( part ) ;
00694 }
00695 }
00696
00697 evt->addCollection( particleVec, "ReconstructedParticle" ) ;
00698
00699 nEvent ++ ;
00700
00701
00702
00703 LCTOOLS::dumpEvent( evt ) ;
00704
00705
00706 lcWrt->writeEvent( evt ) ;
00707 }
00708
00709 void modifyEvent( LCEvent * evt ) {
00710
00711
00712 LCCollection* mcVec = evt->getCollection( LCIO::MCPARTICLE ) ;
00713 int NMCPART = mcVec->getNumberOfElements() ;
00714 for(int i=0 ; i< NMCPART ; i++ ){
00715
00716
00717 MCParticleImpl* part = dynamic_cast<MCParticleImpl*>( mcVec->getElementAt(i)) ;
00718 part->setPDG(1234) ;
00719 }
00720
00721 MCParticleImpl* part = new MCParticleImpl ;
00722 part->setPDG( 1234 ) ;
00723 part->addParent( dynamic_cast<MCParticle*>( mcVec->getElementAt(0) )) ;
00724 mcVec->addElement( part ) ;
00725
00726 }
00727
00728
00729 void processRunHeader( LCRunHeader* run){
00730
00731
00732 lcWrt->writeRunHeader( run ) ;
00733 }
00734
00735 void modifyRunHeader(LCRunHeader* run){;}
00736
00737
00738 } ;
00739
00740
00741
00742 int main(int argc, char** argv ){
00743
00744 srand(1234) ;
00745
00746
00747 LCReader* lcReader = LCFactory::getInstance()->createLCReader() ;
00748
00749
00750
00751 if( argc > 1 ) { FILEN = argv[1] ; }
00752 if( argc > 2 ) { OUTFILEN = argv[2] ; }
00753
00754 lcReader->open( FILEN ) ;
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 {
00766 RunEventProcessor evtProc ;
00767
00768 lcReader->registerLCRunListener( &evtProc ) ;
00769 lcReader->registerLCEventListener( &evtProc ) ;
00770
00771 lcReader->readStream() ;
00772
00773
00774
00775
00776 }
00777
00778 lcReader->close() ;
00779 delete lcReader ;
00780 return 0 ;
00781 }
00782
00783
00784