CMS 3D CMS Logo

SimpleTHA Class Reference

Inheritance diagram for SimpleTHA:

edm::EDAnalyzer

List of all members.

Public Member Functions

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

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (const edm::EventSetup &)
std::string particleString (int) const
std::string vertexString (HepMC::GenVertex::particles_in_const_iterator, HepMC::GenVertex::particles_in_const_iterator, HepMC::GenVertex::particles_out_const_iterator, HepMC::GenVertex::particles_out_const_iterator) const
std::string vertexString (TrackingParticleRefVector, TrackingParticleRefVector) const

Private Attributes

TrackClassifier classifier_
edm::ESHandle< ParticleDataTablepdt_
std::size_t totalTracks_
edm::InputTag trackProducer_


Detailed Description

Definition at line 36 of file SimpleTHA.cc.


Constructor & Destructor Documentation

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

Definition at line 74 of file SimpleTHA.cc.

References edm::ParameterSet::getUntrackedParameter(), and trackProducer_.

00074                                                   : classifier_(config)
00075 {
00076     trackProducer_ = config.getUntrackedParameter<edm::InputTag> ( "trackProducer" );
00077 }

SimpleTHA::~SimpleTHA (  ) 

Definition at line 80 of file SimpleTHA.cc.

00080 { }


Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 83 of file SimpleTHA.cc.

References classifier_, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), TrackClassifier::evaluate(), TrackCategories::Fake, TrackClassifier::flags(), genParticles_cfi::genParticles, TrackHistory::genParticleTrail(), TrackHistory::genVertexTrail(), TrackClassifier::history(), index, TrackClassifier::is(), TrackClassifier::newEvent(), particleString(), TrackHistory::simParticleTrail(), TrackHistory::simVertexTrail(), trackProducer_, and vertexString().

00084 {
00085     // Track collection
00086     edm::Handle<edm::View<reco::Track> > trackCollection;
00087     event.getByLabel(trackProducer_, trackCollection);
00088 
00089     // Set the classifier for a new event
00090     classifier_.newEvent(event, setup);
00091 
00092     // Get a constant reference to the track history associated to the classifier
00093     TrackHistory const & tracer = classifier_.history();
00094 
00095     // Loop over the track collection.
00096     for (std::size_t index = 0; index < trackCollection->size(); index++)
00097     {
00098         std::cout << std::endl << "History for track #" << index << " : " << std::endl;
00099 
00100         // Classify the track and detect for fakes
00101         if ( ! classifier_.evaluate( edm::RefToBase<reco::Track>(trackCollection, index) ).is(TrackCategories::Fake) )
00102         {
00103             // Get the list of TrackingParticles associated to
00104             TrackHistory::SimParticleTrail simParticles(tracer.simParticleTrail());
00105 
00106             // Loop over all simParticles
00107             for (std::size_t hindex=0; hindex<simParticles.size(); hindex++)
00108             {
00109                 std::cout << "  simParticles [" << hindex << "] : "
00110                           << particleString(simParticles[hindex]->pdgId())
00111                           << std::endl;
00112             }
00113 
00114             // Get the list of TrackingVertexes associated to
00115             TrackHistory::SimVertexTrail simVertexes(tracer.simVertexTrail());
00116 
00117             // Loop over all simVertexes
00118             if ( !simVertexes.empty() )
00119             {
00120                 for (std::size_t hindex=0; hindex<simVertexes.size(); hindex++)
00121                 {
00122                     std::cout << "  simVertex    [" << hindex << "] : "
00123                               << vertexString(
00124                                   simVertexes[hindex]->sourceTracks(),
00125                                   simVertexes[hindex]->daughterTracks()
00126                               )
00127                               << std::endl;
00128                 }
00129             }
00130             else
00131                 std::cout << "  simVertex no found" << std::endl;
00132 
00133             // Get the list of GenParticles associated to
00134             TrackHistory::GenParticleTrail genParticles(tracer.genParticleTrail());
00135 
00136             // Loop over all genParticles
00137             for (std::size_t hindex=0; hindex<genParticles.size(); hindex++)
00138             {
00139                 std::cout << "  genParticles [" << hindex << "] : "
00140                           << particleString(genParticles[hindex]->pdg_id())
00141                           << std::endl;
00142             }
00143 
00144             // Get the list of TrackingVertexes associated to
00145             TrackHistory::GenVertexTrail genVertexes(tracer.genVertexTrail());
00146 
00147             // Loop over all simVertexes
00148             if ( !genVertexes.empty() )
00149             {
00150                 for (std::size_t hindex=0; hindex<genVertexes.size(); hindex++)
00151                 {
00152                     std::cout << "  genVertex    [" << hindex << "] : "
00153                               << vertexString(
00154                                   genVertexes[hindex]->particles_in_const_begin(),
00155                                   genVertexes[hindex]->particles_in_const_end(),
00156                                   genVertexes[hindex]->particles_out_const_begin(),
00157                                   genVertexes[hindex]->particles_out_const_end()
00158                               )
00159                               << std::endl;
00160                 }
00161             }
00162             else
00163                 std::cout << "  genVertex no found" << std::endl;
00164         }
00165         else
00166             std::cout << "  fake track" << std::endl;
00167 
00168         std::cout << "  track categories : " << classifier_.flags();
00169         std::cout << std::endl;
00170     }
00171 }

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

Reimplemented from edm::EDAnalyzer.

Definition at line 175 of file SimpleTHA.cc.

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

00176 {
00177     // Get the particles table.
00178     setup.getData( pdt_ );
00179 
00180     totalTracks_ = 0;
00181 }

std::string SimpleTHA::particleString ( int  pdgId  )  const [private]

Definition at line 184 of file SimpleTHA.cc.

References gen_jpsi2muons_cfg::ParticleID, and pdt_.

Referenced by analyze().

00185 {
00186     ParticleData const * pid;
00187 
00188     std::ostringstream vDescription;
00189 
00190     HepPDT::ParticleID particleType(pdgId);
00191 
00192     if (particleType.isValid())
00193     {
00194         pid = pdt_->particle(particleType);
00195         if (pid)
00196             vDescription << pid->name();
00197         else
00198             vDescription << pdgId;
00199     }
00200     else
00201         vDescription << pdgId;
00202 
00203     return vDescription.str();
00204 }

std::string SimpleTHA::vertexString ( HepMC::GenVertex::particles_in_const_iterator  in_begin,
HepMC::GenVertex::particles_in_const_iterator  in_end,
HepMC::GenVertex::particles_out_const_iterator  out_begin,
HepMC::GenVertex::particles_out_const_iterator  out_end 
) const [private]

Definition at line 264 of file SimpleTHA.cc.

References in, j, out, gen_jpsi2muons_cfg::ParticleID, and pdt_.

00270 {
00271     ParticleData const * pid;
00272 
00273     std::ostringstream vDescription;
00274 
00275     std::size_t j = 0;
00276 
00277     HepMC::GenVertex::particles_in_const_iterator in, itmp;
00278 
00279     for (in = in_begin; in != in_end; in++, j++)
00280     {
00281         if (!j) vDescription << "(";
00282 
00283         HepPDT::ParticleID particleType((*in)->pdg_id());
00284 
00285         if (particleType.isValid())
00286         {
00287             pid = pdt_->particle(particleType);
00288             if (pid)
00289                 vDescription << pid->name();
00290             else
00291                 vDescription << (*in)->pdg_id();
00292         }
00293         else
00294             vDescription << (*in)->pdg_id();
00295 
00296         itmp = in;
00297 
00298         if (++itmp == in_end) vDescription << ")";
00299         else vDescription << ",";
00300     }
00301 
00302     vDescription << "->";
00303     j = 0;
00304 
00305     HepMC::GenVertex::particles_out_const_iterator out, otmp;
00306 
00307     for (out = out_begin; out != out_end; out++, j++)
00308     {
00309         if (!j) vDescription << "(";
00310 
00311         HepPDT::ParticleID particleType((*out)->pdg_id());
00312 
00313         if (particleType.isValid())
00314         {
00315             pid = pdt_->particle(particleType);
00316             if (pid)
00317                 vDescription << pid->name();
00318             else
00319                 vDescription << (*out)->pdg_id();
00320         }
00321         else
00322             vDescription << (*out)->pdg_id();
00323 
00324         otmp = out;
00325 
00326         if (++otmp == out_end) vDescription << ")";
00327         else vDescription << ",";
00328     }
00329 
00330     return vDescription.str();
00331 }

std::string SimpleTHA::vertexString ( TrackingParticleRefVector  in,
TrackingParticleRefVector  out 
) const [private]

Definition at line 207 of file SimpleTHA.cc.

References j, gen_jpsi2muons_cfg::ParticleID, pdt_, and edm::RefVector< C, T, F >::size().

Referenced by analyze().

00211 {
00212     ParticleData const * pid;
00213 
00214     std::ostringstream vDescription;
00215 
00216     for (std::size_t j = 0; j < in.size(); j++)
00217     {
00218         if (!j) vDescription << "(";
00219 
00220         HepPDT::ParticleID particleType(in[j]->pdgId());
00221 
00222         if (particleType.isValid())
00223         {
00224             pid = pdt_->particle(particleType);
00225             if (pid)
00226                 vDescription << pid->name();
00227             else
00228                 vDescription << in[j]->pdgId();
00229         }
00230         else
00231             vDescription << in[j]->pdgId();
00232 
00233         if (j == in.size() - 1) vDescription << ")";
00234         else vDescription << ",";
00235     }
00236 
00237     vDescription << "->";
00238 
00239     for (std::size_t j = 0; j < out.size(); j++)
00240     {
00241         if (!j) vDescription << "(";
00242 
00243         HepPDT::ParticleID particleType(out[j]->pdgId());
00244 
00245         if (particleType.isValid())
00246         {
00247             pid = pdt_->particle(particleType);
00248             if (pid)
00249                 vDescription << pid->name();
00250             else
00251                 vDescription << out[j]->pdgId();
00252         }
00253         else
00254             vDescription << out[j]->pdgId();
00255 
00256         if (j == out.size() - 1) vDescription << ")";
00257         else vDescription << ",";
00258     }
00259 
00260     return vDescription.str();
00261 }


Member Data Documentation

TrackClassifier SimpleTHA::classifier_ [private]

Definition at line 58 of file SimpleTHA.cc.

Referenced by analyze().

edm::ESHandle<ParticleDataTable> SimpleTHA::pdt_ [private]

Definition at line 54 of file SimpleTHA.cc.

Referenced by beginJob(), particleString(), and vertexString().

std::size_t SimpleTHA::totalTracks_ [private]

Definition at line 52 of file SimpleTHA.cc.

Referenced by beginJob().

edm::InputTag SimpleTHA::trackProducer_ [private]

Definition at line 50 of file SimpleTHA.cc.

Referenced by analyze(), and SimpleTHA().


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