CMS 3D CMS Logo

RecoTOA Class Reference

Inheritance diagram for RecoTOA:

edm::EDAnalyzer

List of all members.

Public Member Functions

 RecoTOA (const edm::ParameterSet &)
 ~RecoTOA ()

Private Types

typedef std::pair< int,
std::size_t > 
counter_buffer_pair_t
typedef std::map< int,
std::size_t > 
counter_buffer_t
typedef std::pair< int, intcounter_index_pair_t
typedef std::map< int, intcounter_index_t
typedef std::pair
< counter_info_t, std::size_t > 
counter_pair_t
typedef std::map
< counter_info_t, std::size_t > 
counter_t
typedef std::set< intsint
typedef std::vector< double > vdouble
typedef std::vector
< edm::ParameterSet
vParameterSet
typedef std::vector< std::string > vstring
typedef std::vector< vstringvvstring

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (const edm::EventSetup &)
void Count (int barcode=0, int pdgId=0)
virtual void endJob ()
void InitCounter ()
void UpdateCounter ()

Private Attributes

bool antiparticles_
counter_t counter_
counter_buffer_t counter_buffer_
counter_index_t counter_index_
edm::ESHandle
< HepPDT::ParticleDataTable
pdt_
std::string rootFile_
bool status_
TrackHistory tracer_
edm::InputTag trackProducer_
vvstring vetoList_

Classes

struct  counter_info_t


Detailed Description

Definition at line 41 of file RecoTOA.cc.


Member Typedef Documentation

typedef std::pair<int,std::size_t> RecoTOA::counter_buffer_pair_t [private]

Definition at line 104 of file RecoTOA.cc.

typedef std::map<int,std::size_t> RecoTOA::counter_buffer_t [private]

Definition at line 103 of file RecoTOA.cc.

typedef std::pair<int,int> RecoTOA::counter_index_pair_t [private]

Definition at line 101 of file RecoTOA.cc.

typedef std::map<int,int> RecoTOA::counter_index_t [private]

Definition at line 100 of file RecoTOA.cc.

typedef std::pair<counter_info_t,std::size_t> RecoTOA::counter_pair_t [private]

Definition at line 107 of file RecoTOA.cc.

typedef std::map<counter_info_t,std::size_t> RecoTOA::counter_t [private]

Definition at line 106 of file RecoTOA.cc.

typedef std::set<int> RecoTOA::sint [private]

Definition at line 57 of file RecoTOA.cc.

typedef std::vector<double> RecoTOA::vdouble [private]

Definition at line 58 of file RecoTOA.cc.

typedef std::vector<edm::ParameterSet> RecoTOA::vParameterSet [private]

Definition at line 61 of file RecoTOA.cc.

typedef std::vector<std::string> RecoTOA::vstring [private]

Definition at line 59 of file RecoTOA.cc.

typedef std::vector<vstring> RecoTOA::vvstring [private]

Definition at line 60 of file RecoTOA.cc.


Constructor & Destructor Documentation

RecoTOA::RecoTOA ( const edm::ParameterSet config  )  [explicit]

Definition at line 122 of file RecoTOA.cc.

References antiparticles_, edm::ParameterSet::getUntrackedParameter(), i, python::EventAnalyzer_cfg::pset, rootFile_, status_, trackProducer_, and vetoList_.

00122                                               : tracer_(config)
00123 {
00124     trackProducer_ = config.getUntrackedParameter<edm::InputTag> ( "trackProducer" );
00125 
00126     rootFile_ = config.getUntrackedParameter<std::string> ( "rootFile" );
00127 
00128     antiparticles_ = config.getUntrackedParameter<bool> ( "antiparticles" );
00129 
00130     status_ = config.getUntrackedParameter<bool> ( "status2" );
00131 
00132     edm::ParameterSet pset = config.getUntrackedParameter<edm::ParameterSet> ( "veto" );
00133 
00134     vstring vetoListNames = pset.getParameterNames();
00135 
00136     vetoList_.reserve(vetoListNames.size());
00137 
00138     for (std::size_t i=0; i < vetoListNames.size(); i++)
00139         vetoList_.push_back(pset.getUntrackedParameter<vstring> (vetoListNames[i]));
00140 }

RecoTOA::~RecoTOA (  ) 

Definition at line 142 of file RecoTOA.cc.

00142 { }


Member Function Documentation

void RecoTOA::analyze ( const edm::Event event,
const edm::EventSetup setup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 145 of file RecoTOA.cc.

References Count(), TrackHistory::depth(), TrackHistory::evaluate(), TrackHistory::genParticle(), index, InitCounter(), TrackHistory::newEvent(), status_, tracer_, trackProducer_, and UpdateCounter().

00146 {
00147     // Track collection
00148     edm::Handle<edm::View<reco::Track> > trackCollection;
00149     // Get reco::TrackCollection from the file.
00150     event.getByLabel(trackProducer_,trackCollection);
00151 
00152     // Initialive the TrackHistory object.
00153     if (status_)
00154         tracer_.depth(-2);
00155     else
00156         tracer_.depth(-1);
00157 
00158     // Set the tracer for a new event
00159     tracer_.newEvent(event, setup);
00160 
00161     // Initialize and reset the temporal counters
00162     InitCounter();
00163 
00164     // Loop over the track collection.
00165     for (std::size_t index = 0; index < trackCollection->size(); index++)
00166     {
00167         // If the track is not fake then get the orginal particles
00168         if ( tracer_.evaluate( edm::RefToBase<reco::Track>(trackCollection, index) ))
00169         {
00170             //TrackingParticle::GenParticleRefVector particles = tracer.genParticles();
00171             const HepMC::GenParticle * particle = tracer_.genParticle();
00172             // If the origin can be determined then take the first particle as the original
00173             if (particle)
00174                 Count(particle->barcode(), particle->pdg_id());
00175         }
00176         else
00177             Count(0,0);
00178     }
00179     UpdateCounter();
00180 }

void RecoTOA::beginJob ( const edm::EventSetup setup  )  [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 184 of file RecoTOA.cc.

References edm::EventSetup::getData(), and pdt_.

00185 {
00186     // Get the particles table.
00187     setup.getData( pdt_ );
00188 }

void RecoTOA::Count ( int  barcode = 0,
int  pdgId = 0 
) [private]

Definition at line 296 of file RecoTOA.cc.

References counter_buffer_, counter_index_, and it.

Referenced by analyze().

00297 {
00298     counter_buffer_t::iterator it = counter_buffer_.find(barcode);
00299 
00300     if ( it != counter_buffer_.end() )
00301     {
00302         it->second++;
00303     }
00304     else
00305     {
00306         counter_buffer_.insert( counter_buffer_pair_t(barcode, 1) );
00307         counter_index_.insert( counter_index_pair_t(barcode, pdgId) );
00308     }
00309 }

void RecoTOA::endJob ( void   )  [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 192 of file RecoTOA.cc.

References begin, counter_, GenMuonPlsPt100GeV_cfg::cout, end, lat::endl(), file, find(), i, it, gen_jpsi2muons_cfg::ParticleID, pdt_, rootFile_, reco::JTATagInfo::tracks(), v, and vetoList_.

00193 {
00194     TFile file(rootFile_.c_str(), "RECREATE");
00195     file.cd();
00196 
00197     double vetoedVals;
00198     double totalVals;
00199 
00200     std::cout << "List of all long lived particle found" << std::endl;
00201     for ( counter_t::iterator it = counter_.begin(); it != counter_.end(); it++)
00202     {
00203         if ( !it->first.pdgId )
00204             std::cout << " fake tracks -> " << it->second << std::endl;
00205         else
00206             std::cout << " particle " <<pdt_->particle(HepPDT::ParticleID(it->first.pdgId))->name();
00207         std::cout << " associated to " << it->first.tracks << " tracks -> " << it->second << std::endl;
00208     }
00209 
00210     std::multimap<double, std::string> particleTypes;
00211 
00212     for (std::size_t cid = 0; cid < vetoList_.size(); cid++)
00213     {
00214         particleTypes.clear();
00215         vetoedVals = 0;
00216         totalVals = 0;
00217 
00218         for (counter_t::iterator it = counter_.begin(); it != counter_.end(); it++)
00219         {
00220             std::ostringstream particle;
00221 
00222             if ( !it->first.pdgId )
00223                 particle << "Fake" << std::endl;
00224             else
00225                 particle << pdt_->particle(HepPDT::ParticleID(it->first.pdgId))->name();
00226 
00227             if (
00228                 std::find (
00229                     vetoList_[cid].begin(),
00230                     vetoList_[cid].end(),
00231                     particle.str()
00232                 ) == vetoList_[cid].end()
00233             )
00234             {
00235                 particle << "#" << it->first.tracks;
00236                 particleTypes.insert(std::pair<double,std::string>(it->second, particle.str()));
00237                 totalVals += it->second;
00238             }
00239             else
00240             {
00241                 vetoedVals += it->second;
00242                 totalVals += it->second;
00243             }
00244         }
00245 
00246         std::cout << "Veto list #" << cid << std::endl;
00247         std::cout << " number of vetoed tracks " << vetoedVals << std::endl;
00248         std::cout << " total number of tracks " << totalVals << std::endl;
00249         std::cout << " % of vetoed tracks " << ((vetoedVals/totalVals) * 100) << std::endl;
00250 
00251         std::ostringstream hName, hTitle;
00252 
00253         hTitle << "Track origins for the whole track collection";
00254         hName  << "recoTrackCollection";
00255 
00256         for (std::size_t v=0; v < vetoList_[cid].size(); v++)
00257         {
00258             hTitle << "_" << vetoList_[cid][v];
00259             hName << "_" << vetoList_[cid][v];
00260         }
00261 
00262         // creating and saving the pie
00263         TH1D histogram(
00264             hName.str().c_str(),
00265             hTitle.str().c_str(),
00266             particleTypes.size(),
00267             0.,
00268             Double_t(particleTypes.size())
00269         );
00270 
00271         int i = 1;
00272 
00273         std::cout << "Particle size " <<  particleTypes.size() << std::endl;
00274 
00275         std::map<double, std::string>::const_iterator it;
00276 
00277         for (it = particleTypes.begin(); it != particleTypes.end(); it++, i++)
00278         {
00279             histogram.GetXaxis()->SetBinLabel(i, it->second.c_str());
00280             histogram.SetBinContent(i, Double_t(it->first));
00281         }
00282 
00283         histogram.Write();
00284         file.Flush();
00285     }
00286 }

void RecoTOA::InitCounter (  )  [private]

Definition at line 289 of file RecoTOA.cc.

References counter_buffer_, and counter_index_.

Referenced by analyze().

00290 {
00291     counter_buffer_.clear();
00292     counter_index_.clear();
00293 }

void RecoTOA::UpdateCounter (  )  [private]

Definition at line 312 of file RecoTOA.cc.

References funct::abs(), antiparticles_, counter_, counter_buffer_, counter_index_, and info.

Referenced by analyze().

00313 {
00314     counter_buffer_t::const_iterator csi = counter_buffer_.begin();
00315 
00316     std::size_t particleType;
00317 
00318     for (; csi != counter_buffer_.end(); csi++)
00319     {
00320         if (antiparticles_)
00321             particleType = counter_index_[csi->first];
00322         else
00323             particleType = abs(counter_index_[csi->first]);
00324         if ( !particleType )
00325         {
00326             counter_info_t info (particleType, 1);
00327             counter_t::iterator ci = counter_.find( info );
00328             if ( ci != counter_.end() )
00329                 ci->second += csi->second;
00330             else
00331                 counter_.insert( counter_pair_t (info, csi->second) );
00332         }
00333         else
00334         {
00335             counter_info_t info = counter_info_t (particleType, csi->second);
00336             counter_t::iterator ci = counter_.find( info );
00337             if ( ci != counter_.end() )
00338                 ci->second++;
00339             else
00340                 counter_.insert( counter_pair_t (info, 1) );
00341         }
00342     }
00343 }


Member Data Documentation

bool RecoTOA::antiparticles_ [private]

Definition at line 66 of file RecoTOA.cc.

Referenced by RecoTOA(), and UpdateCounter().

counter_t RecoTOA::counter_ [private]

Definition at line 109 of file RecoTOA.cc.

Referenced by endJob(), and UpdateCounter().

counter_buffer_t RecoTOA::counter_buffer_ [private]

Definition at line 111 of file RecoTOA.cc.

Referenced by Count(), InitCounter(), and UpdateCounter().

counter_index_t RecoTOA::counter_index_ [private]

Definition at line 110 of file RecoTOA.cc.

Referenced by Count(), InitCounter(), and UpdateCounter().

edm::ESHandle<HepPDT::ParticleDataTable> RecoTOA::pdt_ [private]

Definition at line 113 of file RecoTOA.cc.

Referenced by beginJob(), and endJob().

std::string RecoTOA::rootFile_ [private]

Definition at line 65 of file RecoTOA.cc.

Referenced by endJob(), and RecoTOA().

bool RecoTOA::status_ [private]

Definition at line 67 of file RecoTOA.cc.

Referenced by analyze(), and RecoTOA().

TrackHistory RecoTOA::tracer_ [private]

Definition at line 71 of file RecoTOA.cc.

Referenced by analyze().

edm::InputTag RecoTOA::trackProducer_ [private]

Definition at line 63 of file RecoTOA.cc.

Referenced by analyze(), and RecoTOA().

vvstring RecoTOA::vetoList_ [private]

Definition at line 69 of file RecoTOA.cc.

Referenced by endJob(), and RecoTOA().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:30:41 2009 for CMSSW by  doxygen 1.5.4