{

    gSystem->Load("libFWCoreFWLite.so");
    AutoLibraryLoader::enable();
    gSystem->Load("libDataFormatsFWLite.so");             // Load the DataFormat about FWLite.
    #include "DataFormats/FWLite/interface/Handle.h"      // Include a handler about FWLite
    TFile file("PythiaH190ZZ4mu_cfi_py_GEN.root");
    TH1F* hist_muPt = new TH1F("hist_muPt","Genparticle p_{T}",100,0,100);
    fwlite::Event ev(&file);                                              // Get the event 'ev' using file. ( & means itself<no copy>. ) 
    // `ev.toBegin()` means `ev=*ev[0]`, `!ev.atEnd()` means ev<ev[last] 
    for( ev.toBegin();  ! ev.atEnd(); ++ev)              
    {
        fwlite::Handle<std::vector<reco::GenParticle> > objs;  // Using handler as reco::GenParticle
        objs.getByLabel(ev,"genParticles");
        for ( int i =0 ; i< objs.ptr()->size(); ++i) 
        {
            std::vector<reco::GenParticle> const & genparticle = *objs;
            hist_muPt->Fill( genparticle[i].pt() );
        }
        //now can access data
    }
    hist_muPt->Draw();
}

Geneparticles_P_t.jpg

-- GunmoRyu - 13 Mar 2009

Topic attachments
I Attachment History Action Size Date Who Comment
JPEGjpg Geneparticle_P_t.jpg r1 manage 30.5 K 2009-03-13 - 08:19 UnknownUser It is a pt distribution of GenParticles?
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2009-03-13 - GunmoRyu
 
KOREA-CMS
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding KoreaCmsWiki? Send feedback