Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:01

0001 
0002 {
0003 
0004    gSystem->Load("libFWCoreFWLite") ;
0005    FWLiteEnabler::enable() ;
0006    
0007    TFile* f = new TFile("pgun.root") ;
0008    
0009    TTree* tevt = f->Get("Events") ;
0010    
0011    int nevt = tevt->GetEntries() ;
0012    std::cout << "Number of Events = " << nevt << std::endl ;
0013 
0014    edm::HepMCProduct EvtProd ;
0015    TBranch* bhepmc =
0016       tevt->GetBranch( "edmHepMCProduct_source__PROD.obj") ;
0017 
0018    bhepmc->SetAddress( & EvtProd ) ;
0019    
0020    HepMC::GenEvent*  Evt = 0 ;
0021    HepMC::GenVertex* Vtx = 0 ;
0022    int               NVtx = 0 ;
0023    TH1D*             VtxZSpread = new TH1D("VtxZSpread", "test", 
0024                                             50, -250., 250. ) ;
0025    
0026    for ( int iev=0; iev<nevt; iev++ )
0027    {
0028       bhepmc->GetEntry(iev) ;
0029       Evt = EvtProd->GetEvent() ;
0030       NVtx = Evt->vertices_size() ;
0031       for ( int iv=-1; iv>=-NVtx; iv-- )
0032       {
0033          Vtx = Evt->barcode_to_vertex( iv ) ;
0034          // std::cout << " Z = " << Vtx->position().z() << std::endl ; 
0035      VtxZSpread->Fill( Vtx->position().z() ) ;
0036       }
0037    }
0038    
0039    VtxZSpread->Draw() ;
0040    
0041 }