CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
TrackingTruthProducer Class Reference

#include <TrackingTruthProducer.h>

Inheritance diagram for TrackingTruthProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 TrackingTruthProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

typedef std::map
< EncodedEventId, unsigned int > 
EncodedEventIdToIndex
 
typedef std::map
< EncodedTruthId, unsigned int > 
EncodedTruthIdToIndex
 
typedef std::multimap
< EncodedTruthId, unsigned int > 
EncodedTruthIdToIndexes
 

Private Member Functions

void addCloseGenVertexes (TrackingVertex &)
 
void associator (std::vector< PSimHit > const &, EncodedTruthIdToIndexes &)
 
void associator (std::auto_ptr< MixCollection< SimTrack > > const &, EncodedTruthIdToIndex &)
 
void associator (std::auto_ptr< MixCollection< SimVertex > > const &, EncodedTruthIdToIndex &)
 
void createTrackingTruth ()
 
bool isBremsstrahlungVertex (TrackingVertex const &vertex, std::auto_ptr< TrackingParticleCollection > &tPC)
 
int LayerFromDetid (const unsigned int &)
 
void mergeBremsstrahlung ()
 
void produce (edm::Event &, const edm::EventSetup &)
 
bool setTrackingParticle (SimTrack const &, TrackingParticle &)
 
int setTrackingVertex (SimVertex const &, TrackingVertex &)
 

Private Attributes

edm::ParameterSet conf_
 
std::vector< std::string > dataLabels_
 
double distanceCut_
 
EncodedEventIdToIndex eventIdCounter_
 
std::vector< edm::Handle
< edm::HepMCProduct > > 
hepMCProducts_
 
std::vector< std::string > hitLabelsVector_
 
bool mergedBremsstrahlung_
 
std::auto_ptr
< TrackingParticleCollection
mergedTrackingParticles_
 
std::auto_ptr
< TrackingVertexCollection
mergedTrackingVertexes_
 
std::string MessageCategory_
 
MuonPSimHitSelector muonPSimHitSelector_
 
PixelPSimHitSelector pixelPSimHitSelector_
 
PSimHitSelector::PSimHitCollection pSimHits_
 
PSimHitSelector pSimHitSelector_
 
TrackingParticleRefProd refMergedTrackingParticles_
 
TrackingVertexRefProd refMergedTrackingVertexes_
 
TrackingParticleRefProd refTrackingParticles_
 
TrackingVertexRefProd refTrackingVertexes_
 
bool removeDeadModules_
 
TrackingParticleSelector selector_
 
bool selectorFlag_
 
std::string simHitLabel_
 
std::auto_ptr< MixCollection
< SimTrack > > 
simTracks_
 
std::auto_ptr< MixCollection
< SimVertex > > 
simVertexes_
 
TrackerPSimHitSelector trackerPSimHitSelector_
 
EncodedTruthIdToIndexes trackIdToHits_
 
EncodedTruthIdToIndex trackIdToIndex_
 
std::auto_ptr
< TrackingParticleCollection
trackingParticles_
 
std::auto_ptr
< TrackingVertexCollection
trackingVertexes_
 
bool useMultipleHepMCLabels_
 
EncodedTruthIdToIndex vertexIdToIndex_
 
double volumeRadius_
 
double volumeZ_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 35 of file TrackingTruthProducer.h.

Member Typedef Documentation

typedef std::map<EncodedEventId, unsigned int> TrackingTruthProducer::EncodedEventIdToIndex
private

Definition at line 87 of file TrackingTruthProducer.h.

typedef std::map<EncodedTruthId, unsigned int> TrackingTruthProducer::EncodedTruthIdToIndex
private

Definition at line 88 of file TrackingTruthProducer.h.

typedef std::multimap<EncodedTruthId, unsigned int> TrackingTruthProducer::EncodedTruthIdToIndexes
private

Definition at line 89 of file TrackingTruthProducer.h.

Constructor & Destructor Documentation

TrackingTruthProducer::TrackingTruthProducer ( const edm::ParameterSet config)
explicit

Definition at line 26 of file TrackingTruthProducer.cc.

References dataLabels_, distanceCut_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), mergedBremsstrahlung_, MessageCategory_, removeDeadModules_, selector_, selectorFlag_, simHitLabel_, useMultipleHepMCLabels_, volumeRadius_, and volumeZ_.

26  :
28 {
29  // Initialize global parameters
30  dataLabels_ = config.getParameter<std::vector<std::string> >("HepMCDataLabels");
31  useMultipleHepMCLabels_ = config.getParameter<bool>("useMultipleHepMCLabels");
32 
33  distanceCut_ = config.getParameter<double>("vertexDistanceCut");
34  volumeRadius_ = config.getParameter<double>("volumeRadius");
35  volumeZ_ = config.getParameter<double>("volumeZ");
36  mergedBremsstrahlung_ = config.getParameter<bool>("mergedBremsstrahlung");
37  removeDeadModules_ = config.getParameter<bool>("removeDeadModules");
38  simHitLabel_ = config.getParameter<std::string>("simHitLabel");
39 
40  // Initialize selection for building TrackingParticles
41  if ( config.exists("select") )
42  {
43  edm::ParameterSet param = config.getParameter<edm::ParameterSet>("select");
45  param.getParameter<double>("ptMinTP"),
46  param.getParameter<double>("minRapidityTP"),
47  param.getParameter<double>("maxRapidityTP"),
48  param.getParameter<double>("tipTP"),
49  param.getParameter<double>("lipTP"),
50  param.getParameter<int>("minHitTP"),
51  param.getParameter<bool>("signalOnlyTP"),
52  param.getParameter<bool>("chargedOnlyTP"),
53  param.getParameter<bool>("stableOnlyTP"),
54  param.getParameter<std::vector<int> >("pdgIdTP")
55  );
56  selectorFlag_ = true;
57  }
58  else
59  selectorFlag_ = false;
60 
61  MessageCategory_ = "TrackingTruthProducer";
62 
63  edm::LogInfo (MessageCategory_) << "Setting up TrackingTruthProducer";
64  edm::LogInfo (MessageCategory_) << "Vertex distance cut set to " << distanceCut_ << " mm";
65  edm::LogInfo (MessageCategory_) << "Volume radius set to " << volumeRadius_ << " mm";
66  edm::LogInfo (MessageCategory_) << "Volume Z set to " << volumeZ_ << " mm";
67 
68  if (useMultipleHepMCLabels_) edm::LogInfo (MessageCategory_) << "Collecting generator information from pileup.";
69  if (mergedBremsstrahlung_) edm::LogInfo (MessageCategory_) << "Merging electrom bremsstralung";
70  if (removeDeadModules_) edm::LogInfo (MessageCategory_) << "Removing psimhit from dead modules";
71 
72  if (!mergedBremsstrahlung_)
73  {
74  produces<TrackingVertexCollection>();
75  produces<TrackingParticleCollection>();
76  }
77  else
78  {
79  produces<TrackingVertexCollection>();
80  produces<TrackingParticleCollection>();
81  produces<TrackingVertexCollection>("MergedTrackTruth");
82  produces<TrackingParticleCollection>("MergedTrackTruth");
83  }
84 }
T getParameter(std::string const &) const
MuonPSimHitSelector muonPSimHitSelector_
PixelPSimHitSelector pixelPSimHitSelector_
bool exists(std::string const &parameterName) const
checks if a parameter exists
TrackerPSimHitSelector trackerPSimHitSelector_
TrackingParticleSelector selector_
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
PSimHitSelector pSimHitSelector_
std::vector< std::string > dataLabels_

Member Function Documentation

void TrackingTruthProducer::addCloseGenVertexes ( TrackingVertex trackingVertex)
private

Definition at line 803 of file TrackingTruthProducer.cc.

References TrackingVertex::addGenVertex(), distanceCut_, TrackingVertex::eventId(), MCTruth::genEvent, hepMCProducts_, mag2(), TrackingVertex::position(), EncodedEventId::rawId(), mathSSE::sqrt(), and useMultipleHepMCLabels_.

Referenced by setTrackingVertex().

804 {
805  // Get the generated particle
807  const HepMC::GenEvent * genEvent = hepmc->GetEvent();
808 
809  // Get the postion of the tv
810  Vector tvPosition(trackingVertex.position().x(), trackingVertex.position().y(), trackingVertex.position().z());
811 
812  // Find HepMC vertices, put them in a close TrackingVertex (this could conceivably add the same GenVertex to multiple TrackingVertices)
813  for (
814  HepMC::GenEvent::vertex_const_iterator iGenVertex = genEvent->vertices_begin();
815  iGenVertex != genEvent->vertices_end();
816  ++iGenVertex
817  )
818  {
819  // Get the position of the genVertex
820  HepMC::ThreeVector rawPosition = (*iGenVertex)->position();
821 
822  // Convert to cm
823  Vector genPosition(rawPosition.x()/10.0, rawPosition.y()/10.0, rawPosition.z()/10.0);
824 
825  // Calculate the dis
826  double distance = sqrt( (tvPosition - genPosition).mag2() );
827 
828  if (distance <= distanceCut_)
829  trackingVertex.addGenVertex( GenVertexRef(hepmc, (*iGenVertex)->barcode()) );
830  }
831 }
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:28
T sqrt(T t)
Definition: SSEVec.h:46
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
tuple genEvent
Definition: MCTruth.py:33
uint32_t rawId() const
get the raw id
std::vector< edm::Handle< edm::HepMCProduct > > hepMCProducts_
edm::Ref< edm::HepMCProduct, HepMC::GenVertex > GenVertexRef
void addGenVertex(const GenVertexRef &)
const EncodedEventId & eventId() const
const LorentzVector & position() const
void TrackingTruthProducer::associator ( std::vector< PSimHit > const &  pSimHits,
EncodedTruthIdToIndexes association 
)
private

Definition at line 193 of file TrackingTruthProducer.cc.

References i.

Referenced by produce().

197 {
198  // Clear the association map
199  association.clear();
200 
201  // Create a association from simtracks to overall index in the mix collection
202  for (std::size_t i = 0; i < pSimHits.size(); ++i)
203  {
204  EncodedTruthIdToIndexes::key_type objectId = EncodedTruthIdToIndexes::key_type(pSimHits[i].eventId(), pSimHits[i].trackId());
205  association.insert( std::make_pair(objectId, i) );
206  }
207 }
int i
Definition: DBlmapReader.cc:9
void TrackingTruthProducer::associator ( std::auto_ptr< MixCollection< SimTrack > > const &  mixCollection,
EncodedTruthIdToIndex association 
)
private

Definition at line 210 of file TrackingTruthProducer.cc.

References getHLTprescales::index.

214 {
215  int index = 0;
216  // Clear the association map
217  association.clear();
218  // Create a association from simtracks to overall index in the mix collection
219  for (MixCollection<SimTrack>::MixItr iterator = mixCollection->begin(); iterator != mixCollection->end(); ++iterator, ++index)
220  {
221  EncodedTruthId objectId = EncodedTruthId(iterator->eventId(), iterator->trackId());
222  association.insert( std::make_pair(objectId, index) );
223  }
224 }
void TrackingTruthProducer::associator ( std::auto_ptr< MixCollection< SimVertex > > const &  mixCollection,
EncodedTruthIdToIndex association 
)
private

Definition at line 227 of file TrackingTruthProducer.cc.

References getHLTprescales::index, and MessageCategory_.

231 {
232  int index = 0;
233 
234  // Solution to the problem of not having vertexId
235  bool useVertexId = true;
236  EncodedEventIdToIndex vertexId;
237  EncodedEventId oldEventId;
238  unsigned int oldVertexId = 0;
239 
240  // Loop for finding repeated vertexId (vertexId problem hack)
241  for (MixCollection<SimVertex>::MixItr iterator = mixCollection->begin(); iterator != mixCollection->end(); ++iterator, ++index)
242  {
243  if (!index || iterator->eventId() != oldEventId)
244  {
245  oldEventId = iterator->eventId();
246  oldVertexId = iterator->vertexId();
247  continue;
248  }
249 
250  if ( iterator->vertexId() == oldVertexId )
251  {
252  edm::LogWarning(MessageCategory_) << "Multiple vertexId found, no using vertexId.";
253  useVertexId = false;
254  break;
255  }
256  }
257 
258  // Reset the index
259  index = 0;
260 
261  // Clear the association map
262  association.clear();
263 
264  // Create a association from simvertexes to overall index in the mix collection
265  for (MixCollection<SimVertex>::MixItr iterator = mixCollection->begin(); iterator != mixCollection->end(); ++iterator, ++index)
266  {
267  EncodedTruthId objectId;
268  if (useVertexId)
269  objectId = EncodedTruthId(iterator->eventId(), iterator->vertexId());
270  else
271  objectId = EncodedTruthId(iterator->eventId(), vertexId[iterator->eventId()]++);
272  association.insert( std::make_pair(objectId, index) );
273  }
274 }
std::map< EncodedEventId, unsigned int > EncodedEventIdToIndex
void TrackingTruthProducer::createTrackingTruth ( )
private

Definition at line 471 of file TrackingTruthProducer.cc.

References CoreSimTrack::eventId(), eventIdCounter_, SimVertex::noParent(), SimTrack::noVertex(), SimVertex::parentIndex(), refTrackingParticles_, refTrackingVertexes_, setTrackingParticle(), setTrackingVertex(), simTracks_, simVertexes_, trackIdToIndex_, trackingParticles_, trackingVertexes_, vertexIdToIndex_, and SimTrack::vertIndex().

Referenced by produce().

472 {
473  // Reset the event counter (use for define vertexId)
474  eventIdCounter_.clear();
475 
476  // Define a container of vetoed traks
477  std::map<int,std::size_t> vetoedTracks;
478 
479  // Define map between parent simtrack and tv indexes
480  std::map<int,std::size_t> vetoedSimVertexes;
481 
482  for (int simTrackIndex = 0; simTrackIndex != simTracks_->size(); ++simTrackIndex)
483  {
484  // Check if the simTrack is excluded (includes non traceable and recovered by history)
485  if ( vetoedTracks.find(simTrackIndex) != vetoedTracks.end() ) continue;
486 
487  SimTrack const & simTrack = simTracks_->getObject(simTrackIndex);
488 
489  TrackingParticle trackingParticle;
490 
491  // Set a bare tp (only with the psimhit) with a given simtrack
492  // the function return true if it is tracable
493  if ( setTrackingParticle(simTrack, trackingParticle) )
494  {
495  // Follows the path upward recovering the history of the particle
496  SimTrack const * currentSimTrack = & simTrack;
497 
498  // Initial condition for the tp and tv indexes
499  int trackingParticleIndex = -1;
500  int trackingVertexIndex = -1;
501 
502  do
503  {
504  // Set a new tracking particle for the current simtrack
505  // and add it to the list of parent tracks of previous vertex
506  if (trackingParticleIndex >= 0)
507  {
508  setTrackingParticle(*currentSimTrack, trackingParticle);
509 
510  // Set the tp index to its new value
511  trackingParticleIndex = trackingParticles_->size();
512  // Push the tp in to the collection
513  trackingParticles_->push_back(trackingParticle);
514 
515  // Add the previous track to the list of decay vertexes of the new tp
516  trackingParticles_->at(trackingParticleIndex).addDecayVertex(
517  TrackingVertexRef(refTrackingVertexes_, trackingVertexIndex)
518  );
519 
520  // Add the new tp to the list of parent tracks of the previous tv
521  trackingVertexes_->at(trackingVertexIndex).addParentTrack(
522  TrackingParticleRef(refTrackingParticles_, trackingParticleIndex)
523  );
524  }
525  else
526  {
527  // Set the tp index to its new value
528  trackingParticleIndex = trackingParticles_->size();
529  // Push the tp in to the collection
530  trackingParticles_->push_back(trackingParticle);
531  // Vetoed the simTrack
532  vetoedTracks.insert( std::make_pair(simTrackIndex, trackingParticleIndex) );
533  }
534 
535  // Verify if the parent simVertex has a simTrack or if the source is a vetoSimVertex
536  if (currentSimTrack->noVertex()) break;
537 
538  // Get the simTrack parent index (it is implicit should be in the same event as current)
539  unsigned int parentSimVertexIndex = vertexIdToIndex_[
541  currentSimTrack->eventId(),
542  currentSimTrack->vertIndex()
543  )
544  ];
545  // Create a new tv
546  TrackingVertex trackingVertex;
547  // Get the parent simVertex associated to the current simTrack
548  SimVertex const * parentSimVertex = & simVertexes_->getObject(parentSimVertexIndex);
549 
550  bool vetoSimVertex = vetoedSimVertexes.find(parentSimVertexIndex) != vetoedSimVertexes.end();
551 
552  // Check for a already visited parent simTrack
553  if ( !vetoSimVertex )
554  {
555  // Set the tv by using simvertex
556  trackingVertexIndex = setTrackingVertex(*parentSimVertex, trackingVertex);
557 
558  // Check if a new vertex needs to be created
559  if (trackingVertexIndex < 0)
560  {
561  // Set the tv index ot its new value
562  trackingVertexIndex = trackingVertexes_->size();
563  // Push the new tv in to the collection
564  trackingVertexes_->push_back(trackingVertex);
565  }
566  else
567  {
568  // I removed the setVertex call here because it's actually useful to
569  // have the stored position vector different to the position of the
570  // referenced parent vertex. This "else" block is for when the vertex
571  // has been merged into another one within the configured distance of
572  // distanceCut_ (default is 30 microns). If that happens then we might
573  // as well keep the true position which will have been set when the
574  // TrackingParticle was initialised. Grimes 09/Aug/2013
575  }
576 
577  vetoedSimVertexes.insert( std::make_pair(parentSimVertexIndex, trackingVertexIndex) );
578  }
579  else
580  trackingVertexIndex = vetoedSimVertexes[parentSimVertexIndex];
581 
582  // Set the newly created tv as parent vertex
583  trackingParticles_->at(trackingParticleIndex).setParentVertex(
584  TrackingVertexRef(refTrackingVertexes_, trackingVertexIndex)
585  );
586 
587  // Add the newly created tp to the tv daughter list
588  trackingVertexes_->at(trackingVertexIndex).addDaughterTrack(
589  TrackingParticleRef(refTrackingParticles_, trackingParticleIndex)
590  );
591 
592  // Verify if the parent simVertex has a simTrack or if the source is a vetoSimVertex
593  if (parentSimVertex->noParent() || vetoSimVertex) break;
594 
595  // Get the next simTrack index (it is implicit should be in the same event as current).
596  unsigned int nextSimTrackIndex = trackIdToIndex_[
598  currentSimTrack->eventId(),
599  parentSimVertex->parentIndex()
600  )
601  ];
602 
603  // Check if the next track exist
604  if ( vetoedTracks.find(nextSimTrackIndex) != vetoedTracks.end() )
605  {
606  // Add to the newly created tv the existent next simtrack in to parent list.
607  trackingVertexes_->at(trackingVertexIndex).addParentTrack(
608  TrackingParticleRef(refTrackingParticles_, vetoedTracks[nextSimTrackIndex])
609  );
610  // Add the vertex to list of decay vertexes of the new tp
611  trackingParticles_->at(vetoedTracks[nextSimTrackIndex]).addDecayVertex(
612  TrackingVertexRef(refTrackingVertexes_, trackingVertexIndex)
613  );
614  break;
615  }
616 
617  // Vetoed the next simTrack
618  vetoedTracks.insert( std::make_pair(nextSimTrackIndex, trackingParticleIndex) );
619 
620  // Set the current simTrack as the next simTrack
621  currentSimTrack = & simTracks_->getObject(nextSimTrackIndex);
622  }
623  while (!currentSimTrack->noVertex());
624  }
625  }
626 }
std::auto_ptr< TrackingVertexCollection > trackingVertexes_
EncodedEventId eventId() const
Definition: CoreSimTrack.h:46
std::auto_ptr< TrackingParticleCollection > trackingParticles_
std::auto_ptr< MixCollection< SimTrack > > simTracks_
EncodedEventIdToIndex eventIdCounter_
TrackingParticleRefProd refTrackingParticles_
EncodedTruthIdToIndex trackIdToIndex_
TrackingVertexRefProd refTrackingVertexes_
int parentIndex() const
Definition: SimVertex.h:33
std::auto_ptr< MixCollection< SimVertex > > simVertexes_
bool noVertex() const
Definition: SimTrack.h:30
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
Definition: SimTrack.h:29
edm::Ref< TrackingVertexCollection > TrackingVertexRef
int setTrackingVertex(SimVertex const &, TrackingVertex &)
bool noParent() const
Definition: SimVertex.h:34
bool setTrackingParticle(SimTrack const &, TrackingParticle &)
edm::Ref< TrackingParticleCollection > TrackingParticleRef
EncodedTruthIdToIndex vertexIdToIndex_
bool TrackingTruthProducer::isBremsstrahlungVertex ( TrackingVertex const &  vertex,
std::auto_ptr< TrackingParticleCollection > &  tPC 
)
private

Definition at line 432 of file TrackingTruthProducer.cc.

References abs, TrackingVertex::daughterTracks_begin(), TrackingVertex::daughterTracks_end(), parents, benchmark_cfg::pdgId, and TrackingVertex::sourceTracks().

Referenced by mergeBremsstrahlung().

436 {
437  const TrackingParticleRefVector parents(vertex.sourceTracks());
438 
439  // Check for the basic parent conditions
440  if ( parents.size() != 1)
441  return false;
442 
443  // Check for the parent particle is a |electron| (electron or positron)
444  if ( std::abs( tPC->at(parents.begin()->key()).pdgId() ) != 11 )
445  return false;
446 
447  unsigned int nElectrons = 0;
448  unsigned int nOthers = 0;
449 
450  // Loop over the daughter particles and counts the number of |electrons|, others (non photons)
451  for ( TrackingVertex::tp_iterator it = vertex.daughterTracks_begin(); it != vertex.daughterTracks_end(); ++it )
452  {
453  // Stronger rejection for looping particles
454  if ( parents[0] == *it )
455  return false;
456 
457  if ( std::abs( tPC->at(it->key()).pdgId() ) == 11 )
458  nElectrons++;
459  else if ( tPC->at(it->key()).pdgId() != 22 )
460  nOthers++;
461  }
462 
463  // Condition to be a Bremsstrahlung Vertex
464  if (nElectrons == 1 && nOthers == 0)
465  return true;
466 
467  return false;
468 }
TPRegexp parents
Definition: eve_filter.cc:24
#define abs(x)
Definition: mlp_lapack.h:159
int TrackingTruthProducer::LayerFromDetid ( const unsigned int &  detid)
private

Definition at line 834 of file TrackingTruthProducer.cc.

References DetId::det(), PXFDetId::disk(), PXBDetId::layer(), TOBDetId::layer(), TIBDetId::layer(), align::tib::layerNumber(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::rawId(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, DetId::Tracker, TIDDetId::wheel(), and TECDetId::wheel().

Referenced by setTrackingParticle().

835 {
836  DetId detId = DetId(detid);
837 
838  if ( detId.det() != DetId::Tracker ) return 0;
839 
840  int layerNumber=0;
841  unsigned int subdetId = static_cast<unsigned int>(detId.subdetId());
842 
843  if ( subdetId == StripSubdetector::TIB)
844  {
845  TIBDetId tibid(detId.rawId());
846  layerNumber = tibid.layer();
847  }
848  else if ( subdetId == StripSubdetector::TOB )
849  {
850  TOBDetId tobid(detId.rawId());
851  layerNumber = tobid.layer();
852  }
853  else if ( subdetId == StripSubdetector::TID)
854  {
855  TIDDetId tidid(detId.rawId());
856  layerNumber = tidid.wheel();
857  }
858  else if ( subdetId == StripSubdetector::TEC )
859  {
860  TECDetId tecid(detId.rawId());
861  layerNumber = tecid.wheel();
862  }
863  else if ( subdetId == PixelSubdetector::PixelBarrel )
864  {
865  PXBDetId pxbid(detId.rawId());
866  layerNumber = pxbid.layer();
867  }
868  else if ( subdetId == PixelSubdetector::PixelEndcap )
869  {
870  PXFDetId pxfid(detId.rawId());
871  layerNumber = pxfid.disk();
872  }
873  else
874  edm::LogVerbatim("TrackingTruthProducer") << "Unknown subdetid: " << subdetId;
875 
876  return layerNumber;
877 }
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
unsigned int layerNumber(align::ID)
Layer number increases with rho from 1 to 8.
Definition: TIBNameSpace.h:85
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
unsigned int disk() const
disk id
Definition: PXFDetId.h:43
Definition: DetId.h:20
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50
void TrackingTruthProducer::mergeBremsstrahlung ( )
private

Definition at line 277 of file TrackingTruthProducer.cc.

References abs, TrackingVertex::addDaughterTrack(), TrackingParticle::addDecayVertex(), TrackingParticle::addG4Track(), TrackingVertex::addParentTrack(), TrackingParticle::addPSimHit(), edm::RefVector< C, T, F >::begin(), TrackingVertex::clearDaughterTracks(), TrackingParticle::clearDecayVertices(), TrackingVertex::clearParentTracks(), TrackingParticle::clearParentVertex(), TrackingParticle::decayVertices(), TrackingParticle::decayVertices_begin(), TrackingParticle::decayVertices_end(), edm::RefVector< C, T, F >::end(), TrackingParticle::g4Track_begin(), TrackingParticle::g4Track_end(), getHLTprescales::index, isBremsstrahlungVertex(), edm::Ref< C, T, F >::key(), mergedTrackingParticles_, mergedTrackingVertexes_, MessageCategory_, TrackingParticle::parentVertex(), TrackingParticle::pdgId(), TrackingParticle::pSimHit_begin(), TrackingParticle::pSimHit_end(), refMergedTrackingParticles_, refMergedTrackingVertexes_, TrackingParticle::setParentVertex(), TrackingVertex::sourceTracks(), trackingParticles_, and trackingVertexes_.

Referenced by produce().

278 {
279  unsigned int index = 0;
280 
281  std::set<unsigned int> excludedTV, excludedTP;
282 
283  // Merge Bremsstrahlung vertexes
284  for (TrackingVertexCollection::iterator iVC = trackingVertexes_->begin(); iVC != trackingVertexes_->end(); ++iVC, ++index)
285  {
286  // Check Bremsstrahlung vertex
288  {
289  // Get a pointer to the source track (A Ref<> cannot be use with a product!)
290  TrackingParticle * track = &trackingParticles_->at(iVC->sourceTracks_begin()->key());
291  // Get a Ref<> to the source track
292  TrackingParticleRef trackRef = *iVC->sourceTracks_begin();
293  // Pointer to electron daughter
294  TrackingParticle * daughter = 0;
295  // Ref<> to electron daughter
296  TrackingParticleRef daughterRef;
297 
298  // Select the electron daughter and redirect the photon
299  for (TrackingVertex::tp_iterator idaughter = iVC->daughterTracks_begin(); idaughter != iVC->daughterTracks_end(); ++idaughter)
300  {
301  TrackingParticle * pointer = &trackingParticles_->at(idaughter->key());
302  if ( std::abs( pointer->pdgId() ) == 11 )
303  {
304  // Set pointer to the electron daughter
305  daughter = pointer;
306  // Set Ref<> to the electron daughter
307  daughterRef = *idaughter;
308  }
309  else if ( pointer->pdgId() == 22 )
310  {
311  // Delete the photon original parent vertex
312  pointer->clearParentVertex();
313  // Set the new parent vertex to the vertex of the source track
314  pointer->setParentVertex( track->parentVertex() );
315  // Get a non-const pointer to the parent vertex
316  TrackingVertex * vertex = &trackingVertexes_->at( track->parentVertex().key() );
317  // Add the photon to the doughter list of the parent vertex
318  vertex->addDaughterTrack( *idaughter );
319  }
320  }
321 
322  // Add the electron segments from the electron daughter
323  // track must not be the same particle as daughter
324  // if (track != daughter)
325  for (TrackingParticle::g4t_iterator isegment = daughter->g4Track_begin(); isegment != daughter->g4Track_end(); ++isegment)
326  track->addG4Track(*isegment);
327 
328  // Copy all the simhits to the new track
329  for (std::vector<PSimHit>::const_iterator ihit = daughter->pSimHit_begin(); ihit != daughter->pSimHit_end(); ++ihit)
330  track->addPSimHit(*ihit);
331 
332  // Make a copy of the decay vertexes of the track
333  TrackingVertexRefVector decayVertices( track->decayVertices() );
334 
335  // Clear the decay vertex list
336  track->clearDecayVertices();
337 
338  // Add the remaining vertexes
339  for (TrackingVertexRefVector::const_iterator idecay = decayVertices.begin(); idecay != decayVertices.end(); ++idecay)
340  if ( (*idecay).key() != index ) track->addDecayVertex(*idecay);
341 
342  // Redirect all the decay source vertexes to those in the electron daughter
343  for (TrackingParticle::tv_iterator idecay = daughter->decayVertices_begin(); idecay != daughter->decayVertices_end(); ++idecay)
344  {
345  // Add the vertexes to the decay list of the source particles
346  track->addDecayVertex(*idecay);
347  // Get a reference to decay vertex
348  TrackingVertex * vertex = &trackingVertexes_->at( idecay->key() );
349  // Copy all the source tracks from of the decay vertex
350  TrackingParticleRefVector sources( vertex->sourceTracks() );
351  // Clear the source track references
352  vertex->clearParentTracks();
353  // Add the new source tracks by excluding the one with the segment merged
354  for (TrackingVertex::tp_iterator isource = sources.begin(); isource != sources.end(); ++isource)
355  if (*isource != daughterRef)
356  vertex->addParentTrack(*isource);
357  // Add the track reference to the list of sources
358  vertex->addParentTrack(trackRef);
359  }
360 
361  // Adding the vertex to the exlusion list
362  excludedTV.insert(index);
363 
364  // Adding the electron segment tp into the exlusion list
365  excludedTP.insert( daughterRef.key() );
366  }
367  }
368 
369  edm::LogInfo(MessageCategory_) << "Generating the merged collection." << std::endl;
370 
371  // Reserved the same amount of memory for the merged collections
373  mergedTrackingVertexes_->reserve(trackingVertexes_->size());
374 
375  index = 0;
376  std::map<unsigned int, unsigned int> vertexMap;
377 
378  // Copy non-excluded vertices discarding parent & child tracks
379  for (TrackingVertexCollection::const_iterator iVC = trackingVertexes_->begin(); iVC != trackingVertexes_->end(); ++iVC, ++index)
380  {
381  if ( excludedTV.find(index) != excludedTV.end() ) continue;
382  // Save the new location of the non excluded vertexes (take in consideration those were removed)
383  vertexMap.insert( std::make_pair(index, mergedTrackingVertexes_->size()) );
384  // Copy those vertexes are not excluded
385  TrackingVertex newVertex = (*iVC);
386  newVertex.clearDaughterTracks();
387  newVertex.clearParentTracks();
388  mergedTrackingVertexes_->push_back(newVertex);
389  }
390 
391  index = 0;
392 
393  // Copy and cross reference the non-excluded tp to the merged collection
394  for (TrackingParticleCollection::const_iterator iTP = trackingParticles_->begin(); iTP != trackingParticles_->end(); ++iTP, ++index)
395  {
396  if ( excludedTP.find(index) != excludedTP.end() ) continue;
397 
398  TrackingVertexRef sourceV = iTP->parentVertex();
399  TrackingVertexRefVector decayVs = iTP->decayVertices();
400  TrackingParticle newTrack = *iTP;
401 
402  newTrack.clearParentVertex();
403  newTrack.clearDecayVertices();
404 
405  // Set vertex indices for new vertex product and track references in those vertices
406 
407  // Index of parent vertex in vertex container
408  unsigned int parentIndex = vertexMap[sourceV.key()];
409  // Index of this track in track container
410  unsigned int tIndex = mergedTrackingParticles_->size();
411 
412  // Add vertex to track
414  // Add track to vertex
415  (mergedTrackingVertexes_->at(parentIndex)).addDaughterTrack(TrackingParticleRef(refMergedTrackingParticles_, tIndex));
416 
417  for (TrackingVertexRefVector::const_iterator iDecayV = decayVs.begin(); iDecayV != decayVs.end(); ++iDecayV)
418  {
419  // Index of decay vertex in vertex container
420  unsigned int daughterIndex = vertexMap[iDecayV->key()];
421  // Add vertex to track
422  newTrack.addDecayVertex( TrackingVertexRef(refMergedTrackingVertexes_, daughterIndex) );
423  // Add track to vertex
424  (mergedTrackingVertexes_->at(daughterIndex)).addParentTrack( TrackingParticleRef(refMergedTrackingParticles_, tIndex) );
425  }
426 
427  mergedTrackingParticles_->push_back(newTrack);
428  }
429 }
std::auto_ptr< TrackingVertexCollection > trackingVertexes_
const TrackingParticleRefVector & sourceTracks() const
tv_iterator decayVertices_end() const
std::auto_ptr< TrackingParticleCollection > trackingParticles_
tv_iterator decayVertices_begin() const
TrackingParticleRefProd refMergedTrackingParticles_
std::auto_ptr< TrackingVertexCollection > mergedTrackingVertexes_
std::auto_ptr< TrackingParticleCollection > mergedTrackingParticles_
g4t_iterator g4Track_begin() const
int pdgId() const
PDG id, signal source, crossing number.
const std::vector< PSimHit >::const_iterator pSimHit_begin() const
#define abs(x)
Definition: mlp_lapack.h:159
void addDaughterTrack(const TrackingParticleRef &)
const std::vector< PSimHit >::const_iterator pSimHit_end() const
void clearDaughterTracks()
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
void addParentTrack(const TrackingParticleRef &)
TrackingVertexRefProd refMergedTrackingVertexes_
bool isBremsstrahlungVertex(TrackingVertex const &vertex, std::auto_ptr< TrackingParticleCollection > &tPC)
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
void addPSimHit(const PSimHit &)
void addDecayVertex(const TrackingVertexRef &)
const TrackingVertexRef & parentVertex() const
std::vector< SimTrack >::const_iterator g4t_iterator
edm::Ref< TrackingVertexCollection > TrackingVertexRef
void clearParentTracks()
key_type key() const
Accessor for product key.
Definition: Ref.h:266
void addG4Track(const SimTrack &)
g4t_iterator g4Track_end() const
const TrackingVertexRefVector & decayVertices() const
void setParentVertex(const TrackingVertexRef &)
edm::Ref< TrackingParticleCollection > TrackingParticleRef
void TrackingTruthProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 87 of file TrackingTruthProducer.cc.

References associator(), createTrackingTruth(), dataLabels_, edm::Event::getByLabel(), hepMCProducts_, mergeBremsstrahlung(), mergedBremsstrahlung_, mergedTrackingParticles_, mergedTrackingVertexes_, MessageCategory_, muonPSimHitSelector_, pixelPSimHitSelector_, edm::Handle< T >::product(), pSimHits_, pSimHitSelector_, refMergedTrackingParticles_, refMergedTrackingVertexes_, refTrackingParticles_, refTrackingVertexes_, removeDeadModules_, PixelPSimHitSelector::select(), TrackerPSimHitSelector::select(), MuonPSimHitSelector::select(), PSimHitSelector::select(), simHitLabel_, simTracks_, simVertexes_, LaserTracksInput_cfi::source, trackerPSimHitSelector_, trackIdToHits_, trackIdToIndex_, trackingParticles_, trackingVertexes_, useMultipleHepMCLabels_, and vertexIdToIndex_.

88 {
89  // Clean the list of hepmc products
90  hepMCProducts_.clear();
91 
92  // Collect all the HepMCProducts
94 
95  for (std::vector<std::string>::const_iterator source = dataLabels_.begin(); source != dataLabels_.end(); ++source)
96  {
97  if ( event.getByLabel(*source, hepMCHandle) )
98  {
99  hepMCProducts_.push_back(hepMCHandle);
100  edm::LogInfo (MessageCategory_) << "Using HepMC source " << *source;
101  if (!useMultipleHepMCLabels_) break;
102  }
103  }
104 
105  if ( hepMCProducts_.empty() )
106  {
107  edm::LogWarning (MessageCategory_) << "No HepMC source found";
108  return;
109  }
110  else if (hepMCProducts_.size() > 1 || useMultipleHepMCLabels_)
111  {
112  edm::LogInfo (MessageCategory_) << "You are using more than one HepMC source.";
113  edm::LogInfo (MessageCategory_) << "If the labels are not in the same order as the events in the crossing frame (i.e. signal, pileup(s) ) ";
114  edm::LogInfo (MessageCategory_) << "or there are fewer labels than events in the crossing frame";
115  edm::LogInfo (MessageCategory_) << MessageCategory_ << " may try to access data in the wrong HepMCProduct and crash.";
116  }
117 
118  // Collect all the simtracks from the crossing frame
120  event.getByLabel("mix", simHitLabel_, cfSimTracks);
121 
122  // Create a mix collection from one simtrack collection
123  simTracks_ = std::auto_ptr<MixCollection<SimTrack> >( new MixCollection<SimTrack>(cfSimTracks.product()) );
124 
125  // Collect all the simvertex from the crossing frame
126  edm::Handle<CrossingFrame<SimVertex> > cfSimVertexes;
127  event.getByLabel("mix", simHitLabel_, cfSimVertexes);
128 
129  // Create a mix collection from one simvertex collection
130  simVertexes_ = std::auto_ptr<MixCollection<SimVertex> >( new MixCollection<SimVertex>(cfSimVertexes.product()) );
131 
132  // Create collections of things we will put in event
133  trackingParticles_ = std::auto_ptr<TrackingParticleCollection>( new TrackingParticleCollection );
134  trackingVertexes_ = std::auto_ptr<TrackingVertexCollection>( new TrackingVertexCollection );
135 
136  // Get references before put so we can cross reference
137  refTrackingParticles_ = event.getRefBeforePut<TrackingParticleCollection>();
138  refTrackingVertexes_ = event.getRefBeforePut<TrackingVertexCollection>();
139 
140  // Create a list of psimhits
141  if (removeDeadModules_)
142  {
143  pSimHits_.clear();
144  pixelPSimHitSelector_.select(pSimHits_, event, setup);
146  muonPSimHitSelector_.select(pSimHits_, event, setup);
147  }
148  else
149  {
150  pSimHits_.clear();
151  pSimHitSelector_.select(pSimHits_, event, setup);
152  }
153 
154  // Create a multimap between trackId and hit indices
156 
157  // Create a map between trackId and track index
159 
160  // Create a map between vertexId and vertex index
162 
164 
166  {
167  // Create collections of things we will put in event,
168  mergedTrackingParticles_ = std::auto_ptr<TrackingParticleCollection>( new TrackingParticleCollection );
169  mergedTrackingVertexes_ = std::auto_ptr<TrackingVertexCollection>( new TrackingVertexCollection );
170 
171  // Get references before put so we can cross reference
172  refMergedTrackingParticles_ = event.getRefBeforePut<TrackingParticleCollection>("MergedTrackTruth");
173  refMergedTrackingVertexes_ = event.getRefBeforePut<TrackingVertexCollection>("MergedTrackTruth");
174 
175  // Merged brem electrons
177 
178  // Put TrackingParticles and TrackingVertices in event
179  event.put(mergedTrackingParticles_, "MergedTrackTruth");
180  event.put(mergedTrackingVertexes_, "MergedTrackTruth");
181  event.put(trackingParticles_);
182  event.put(trackingVertexes_);
183  }
184  else
185  {
186  // Put TrackingParticles and TrackingVertices in event
187  event.put(trackingParticles_);
188  event.put(trackingVertexes_);
189  }
190 }
std::auto_ptr< TrackingVertexCollection > trackingVertexes_
std::auto_ptr< TrackingParticleCollection > trackingParticles_
TrackingParticleRefProd refMergedTrackingParticles_
std::auto_ptr< MixCollection< SimTrack > > simTracks_
std::vector< TrackingParticle > TrackingParticleCollection
std::auto_ptr< TrackingVertexCollection > mergedTrackingVertexes_
MuonPSimHitSelector muonPSimHitSelector_
std::auto_ptr< TrackingParticleCollection > mergedTrackingParticles_
PixelPSimHitSelector pixelPSimHitSelector_
TrackingParticleRefProd refTrackingParticles_
EncodedTruthIdToIndexes trackIdToHits_
TrackerPSimHitSelector trackerPSimHitSelector_
TrackingVertexRefProd refMergedTrackingVertexes_
EncodedTruthIdToIndex trackIdToIndex_
TrackingVertexRefProd refTrackingVertexes_
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Pre-process event information.
void associator(std::vector< PSimHit > const &, EncodedTruthIdToIndexes &)
std::auto_ptr< MixCollection< SimVertex > > simVertexes_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
PSimHitSelector::PSimHitCollection pSimHits_
std::vector< edm::Handle< edm::HepMCProduct > > hepMCProducts_
PSimHitSelector pSimHitSelector_
std::vector< TrackingVertex > TrackingVertexCollection
std::vector< std::string > dataLabels_
T const * product() const
Definition: Handle.h:74
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Pre-process event information.
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Select the psimhit add them to a PSimHitCollection.
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Pre-process event information.
EncodedTruthIdToIndex vertexIdToIndex_
bool TrackingTruthProducer::setTrackingParticle ( SimTrack const &  simTrack,
TrackingParticle trackingParticle 
)
private

Definition at line 629 of file TrackingTruthProducer.cc.

References TrackingParticle::addG4Track(), TrackingParticle::addGenParticle(), TrackingParticle::addPSimHit(), EncodedEventId::bunchCrossing(), CoreSimTrack::charge(), PSimHit::detUnitId(), EncodedEventId::event(), CoreSimTrack::eventId(), configurableAnalysis::GenParticle, SimTrack::genpartIndex(), hepMCProducts_, init, LayerFromDetid(), CoreSimTrack::momentum(), SimTrack::noVertex(), PSimHit::particleType(), benchmark_cfg::pdgId, position, PSimHit::processType(), pSimHits_, EncodedEventId::rawId(), selector_, selectorFlag_, TrackingParticle::setMatchedHit(), simVertexes_, ntuplemaker::status, DetId::subdetId(), CoreSimTrack::trackId(), trackIdToHits_, CoreSimTrack::type(), useMultipleHepMCLabels_, vertexIdToIndex_, and SimTrack::vertIndex().

Referenced by createTrackingTruth().

633 {
634  // Get the eventid associated to the track
635  EncodedEventId trackEventId = simTrack.eventId();
636  // Get the simtrack id
637  EncodedTruthId simTrackId = EncodedTruthId( trackEventId, simTrack.trackId() );
638 
639  // Location of the parent vertex
641  // If not parent then location is (0,0,0,0)
642  if (simTrack.noVertex())
643  position = LorentzVector(0, 0, 0, 0);
644  else
645  {
646  unsigned int parentSimVertexIndex = vertexIdToIndex_[ EncodedTruthId( simTrack.eventId(), simTrack.vertIndex() ) ];
647  position = simVertexes_->getObject(parentSimVertexIndex).position();
648  }
649 
650  // Define the default status and pdgid
651  int status = -99;
652  int pdgId = simTrack.type();
653 
654  int genParticleIndex = simTrack.genpartIndex();
655  bool signalEvent = (trackEventId.event() == 0 && trackEventId.bunchCrossing() == 0);
656 
657  // In the case of a existing generated particle and track
658  // event is signal redefine status a pdgId
659 
661 
662  if (genParticleIndex >= 0 && (signalEvent || useMultipleHepMCLabels_) )
663  {
664  // Get the generated particle
665  hepmc = (useMultipleHepMCLabels_) ? hepMCProducts_.at(trackEventId.rawId()) : hepmc = hepMCProducts_.at(0);
666 
667  const HepMC::GenParticle * genParticle = hepmc->GetEvent()->barcode_to_particle(genParticleIndex);
668 
669  if (genParticle)
670  {
671  status = genParticle->status();
672  pdgId = genParticle->pdg_id();
673  }
674  }
675 
676  // Create a tp from the simtrack
677  trackingParticle = TrackingParticle(
678  (char) simTrack.charge(),
679  simTrack.momentum(),
680  Vector(position.x(), position.y(), position.z()),
681  position.t(),
682  pdgId,
683  status,
684  trackEventId
685  );
686 
687  bool init = true;
688 
689  int processType = 0;
690  int particleType = 0;
691 
692  // Counting the TP hits using the layers (as in ORCA).
693  // Does seem to find less hits. maybe b/c layer is a number now, not a pointer
694  int totalSimHits = 0;
695  int oldLayer = 0;
696  int newLayer = 0;
697  int oldDetector = 0;
698  int newDetector = 0;
699 
700  // Loop over the associated hits per track
701  for (
702  EncodedTruthIdToIndexes::const_iterator iEntry = trackIdToHits_.lower_bound(simTrackId);
703  iEntry != trackIdToHits_.upper_bound(simTrackId);
704  ++iEntry
705  )
706  {
707  // Get a constant reference to the simhit
708  PSimHit const & pSimHit = pSimHits_.at(iEntry->second);
709 
710  // Initial condition for consistent simhit selection
711  if (init)
712  {
713  processType = pSimHit.processType();
714  particleType = pSimHit.particleType();
715  init = false;
716  }
717 
718  // Check for delta and interaction products discards
719  if (processType == pSimHit.processType() && particleType == pSimHit.particleType() && pdgId == pSimHit.particleType() )
720  {
721  trackingParticle.addPSimHit(pSimHit);
722 
723  unsigned int detectorIdIndex = pSimHit.detUnitId();
724  DetId detectorId = DetId(detectorIdIndex);
725  oldLayer = newLayer;
726  oldDetector = newDetector;
727  newLayer = LayerFromDetid(detectorIdIndex);
728  newDetector = detectorId.subdetId();
729 
730  // Count hits using layers for glued detectors
731  // newlayer !=0 excludes Muon layers set to 0 by LayerFromDetid
732  if ( ( oldLayer != newLayer || (oldLayer==newLayer && oldDetector!=newDetector ) ) && newLayer != 0 ) totalSimHits++;
733  }
734  }
735 
736  // Set the number of matched simhits
737  trackingParticle.setMatchedHit(totalSimHits);
738 
739  // Add the simtrack associated to the tp
740  trackingParticle.addG4Track(simTrack);
741 
742  // Add the generator information
743  if ( genParticleIndex >= 0 && (signalEvent || useMultipleHepMCLabels_) )
744  trackingParticle.addGenParticle( GenParticleRef(hepmc, genParticleIndex) );
745 
746  if (selectorFlag_) return selector_(trackingParticle);
747 
748  return true;
749 }
int event() const
get the contents of the subdetector field (should be protected?)
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:28
int LayerFromDetid(const unsigned int &)
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
int init
Definition: HydjetWrapper.h:63
math::XYZTLorentzVector LorentzVector
EncodedTruthIdToIndexes trackIdToHits_
TrackingParticleSelector selector_
void setMatchedHit(const int &)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void addPSimHit(const PSimHit &)
std::auto_ptr< MixCollection< SimVertex > > simVertexes_
int bunchCrossing() const
get the detector field from this detid
uint32_t rawId() const
get the raw id
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
PSimHitSelector::PSimHitCollection pSimHits_
std::vector< edm::Handle< edm::HepMCProduct > > hepMCProducts_
Definition: DetId.h:20
unsigned short processType() const
Definition: PSimHit.h:118
int particleType() const
Definition: PSimHit.h:85
void addGenParticle(const GenParticleRef &)
void addG4Track(const SimTrack &)
tuple status
Definition: ntuplemaker.py:245
unsigned int detUnitId() const
Definition: PSimHit.h:93
math::PtEtaPhiELorentzVectorF LorentzVector
EncodedTruthIdToIndex vertexIdToIndex_
int TrackingTruthProducer::setTrackingVertex ( SimVertex const &  simVertex,
TrackingVertex trackingVertex 
)
private

Definition at line 752 of file TrackingTruthProducer.cc.

References abs, addCloseGenVertexes(), TrackingVertex::addG4Vertex(), distanceCut_, CoreSimVertex::eventId(), eventIdCounter_, P, CoreSimVertex::position(), position, trackingVertexes_, volumeRadius_, and volumeZ_.

Referenced by createTrackingTruth().

756 {
757  LorentzVector const & position = simVertex.position();
758 
759  // Look for close by vertexes
760  for (std::size_t trackingVertexIndex = 0; trackingVertexIndex < trackingVertexes_->size(); ++trackingVertexIndex)
761  {
762  // Calculate the distance
763  double distance = (position - trackingVertexes_->at(trackingVertexIndex).position()).P();
764  // If the distance is under a given cut return the trackingVertex index (vertex merging)
765  if (distance <= distanceCut_)
766  {
767  // Add simvertex to the pre existent tv
768  trackingVertexes_->at(trackingVertexIndex).addG4Vertex(simVertex);
769  // return tv index
770  return trackingVertexIndex;
771  }
772  }
773 
774  // Get the event if from the simvertex
775  EncodedEventId simVertexEventId = simVertex.eventId();
776 
777  // Initialize the event counter
778  if (eventIdCounter_.find(simVertexEventId) == eventIdCounter_.end())
779  eventIdCounter_[simVertexEventId] = 0;
780 
781  // Get the simVertex id
782  EncodedTruthId simVertexId = EncodedTruthId(simVertexEventId, eventIdCounter_[simVertexEventId]);
783 
784  // Calculate if the vertex is in the tracker volume (it needs to be review for other detectors)
785  bool inVolume = (position.Pt() < volumeRadius_ && std::abs(position.z()) < volumeZ_); // In or out of Tracker
786 
787  // Initialize the new vertex
788  trackingVertex = TrackingVertex(position, inVolume, simVertexId);
789 
790  // Find the the closest GenVertexes to the created tv
791  addCloseGenVertexes(trackingVertex);
792 
793  // Add the g4 vertex to the tv
794  trackingVertex.addG4Vertex(simVertex);
795 
796  // Initialize the event counter
797  eventIdCounter_[simVertexEventId]++;
798 
799  return -1;
800 }
std::auto_ptr< TrackingVertexCollection > trackingVertexes_
EncodedEventIdToIndex eventIdCounter_
math::XYZTLorentzVector LorentzVector
#define abs(x)
Definition: mlp_lapack.h:159
#define P
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void addG4Vertex(const SimVertex &)
void addCloseGenVertexes(TrackingVertex &)

Member Data Documentation

edm::ParameterSet TrackingTruthProducer::conf_
private

Definition at line 48 of file TrackingTruthProducer.h.

std::vector<std::string> TrackingTruthProducer::dataLabels_
private

Definition at line 50 of file TrackingTruthProducer.h.

Referenced by produce(), and TrackingTruthProducer().

double TrackingTruthProducer::distanceCut_
private
EncodedEventIdToIndex TrackingTruthProducer::eventIdCounter_
private

Definition at line 91 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), and setTrackingVertex().

std::vector<edm::Handle<edm::HepMCProduct> > TrackingTruthProducer::hepMCProducts_
private

Definition at line 64 of file TrackingTruthProducer.h.

Referenced by addCloseGenVertexes(), produce(), and setTrackingParticle().

std::vector<std::string> TrackingTruthProducer::hitLabelsVector_
private

Definition at line 53 of file TrackingTruthProducer.h.

bool TrackingTruthProducer::mergedBremsstrahlung_
private

Definition at line 56 of file TrackingTruthProducer.h.

Referenced by produce(), and TrackingTruthProducer().

std::auto_ptr<TrackingParticleCollection> TrackingTruthProducer::mergedTrackingParticles_
private

Definition at line 82 of file TrackingTruthProducer.h.

Referenced by mergeBremsstrahlung(), and produce().

std::auto_ptr<TrackingVertexCollection> TrackingTruthProducer::mergedTrackingVertexes_
private

Definition at line 83 of file TrackingTruthProducer.h.

Referenced by mergeBremsstrahlung(), and produce().

std::string TrackingTruthProducer::MessageCategory_
private
MuonPSimHitSelector TrackingTruthProducer::muonPSimHitSelector_
private

Definition at line 71 of file TrackingTruthProducer.h.

Referenced by produce().

PixelPSimHitSelector TrackingTruthProducer::pixelPSimHitSelector_
private

Definition at line 69 of file TrackingTruthProducer.h.

Referenced by produce().

PSimHitSelector::PSimHitCollection TrackingTruthProducer::pSimHits_
private

Definition at line 66 of file TrackingTruthProducer.h.

Referenced by produce(), and setTrackingParticle().

PSimHitSelector TrackingTruthProducer::pSimHitSelector_
private

Definition at line 68 of file TrackingTruthProducer.h.

Referenced by produce().

TrackingParticleRefProd TrackingTruthProducer::refMergedTrackingParticles_
private

Definition at line 84 of file TrackingTruthProducer.h.

Referenced by mergeBremsstrahlung(), and produce().

TrackingVertexRefProd TrackingTruthProducer::refMergedTrackingVertexes_
private

Definition at line 85 of file TrackingTruthProducer.h.

Referenced by mergeBremsstrahlung(), and produce().

TrackingParticleRefProd TrackingTruthProducer::refTrackingParticles_
private

Definition at line 79 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), and produce().

TrackingVertexRefProd TrackingTruthProducer::refTrackingVertexes_
private

Definition at line 80 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), and produce().

bool TrackingTruthProducer::removeDeadModules_
private

Definition at line 57 of file TrackingTruthProducer.h.

Referenced by produce(), and TrackingTruthProducer().

TrackingParticleSelector TrackingTruthProducer::selector_
private

Definition at line 97 of file TrackingTruthProducer.h.

Referenced by setTrackingParticle(), and TrackingTruthProducer().

bool TrackingTruthProducer::selectorFlag_
private

Definition at line 96 of file TrackingTruthProducer.h.

Referenced by setTrackingParticle(), and TrackingTruthProducer().

std::string TrackingTruthProducer::simHitLabel_
private

Definition at line 58 of file TrackingTruthProducer.h.

Referenced by produce(), and TrackingTruthProducer().

std::auto_ptr<MixCollection<SimTrack> > TrackingTruthProducer::simTracks_
private

Definition at line 73 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), and produce().

std::auto_ptr<MixCollection<SimVertex> > TrackingTruthProducer::simVertexes_
private

Definition at line 74 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), produce(), and setTrackingParticle().

TrackerPSimHitSelector TrackingTruthProducer::trackerPSimHitSelector_
private

Definition at line 70 of file TrackingTruthProducer.h.

Referenced by produce().

EncodedTruthIdToIndexes TrackingTruthProducer::trackIdToHits_
private

Definition at line 92 of file TrackingTruthProducer.h.

Referenced by produce(), and setTrackingParticle().

EncodedTruthIdToIndex TrackingTruthProducer::trackIdToIndex_
private

Definition at line 93 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), and produce().

std::auto_ptr<TrackingParticleCollection> TrackingTruthProducer::trackingParticles_
private

Definition at line 76 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), mergeBremsstrahlung(), and produce().

std::auto_ptr<TrackingVertexCollection> TrackingTruthProducer::trackingVertexes_
private
bool TrackingTruthProducer::useMultipleHepMCLabels_
private
EncodedTruthIdToIndex TrackingTruthProducer::vertexIdToIndex_
private

Definition at line 94 of file TrackingTruthProducer.h.

Referenced by createTrackingTruth(), produce(), and setTrackingParticle().

double TrackingTruthProducer::volumeRadius_
private

Definition at line 54 of file TrackingTruthProducer.h.

Referenced by setTrackingVertex(), and TrackingTruthProducer().

double TrackingTruthProducer::volumeZ_
private

Definition at line 55 of file TrackingTruthProducer.h.

Referenced by setTrackingVertex(), and TrackingTruthProducer().