CMS 3D CMS Logo

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

#include <RecoVertex/NuclearInteractionProducer/interface/NuclearInteractionEDProducer.h>

Inheritance diagram for NuclearInteractionEDProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef edm::RefVector
< TrajectorySeedCollection
TrajectorySeedRefVector
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 NuclearInteractionEDProducer (const edm::ParameterSet &)
 
 ~NuclearInteractionEDProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
void findAdditionalSecondaryTracks (reco::NuclearInteraction &nucl, const edm::Handle< reco::TrackCollection > &additionalSecTracks)
 
bool isInside (const reco::TrackRef &track, const TrajectorySeedRefVector &seeds)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::string additionalSecondaryProducer_
 
edm::ParameterSet conf_
 
std::auto_ptr< NuclearLikelihoodlikelihoodCalculator
 
edm::ESWatcher
< IdealMagneticFieldRecord
magFieldWatcher_
 
std::string primaryProducer_
 
std::string secondaryProducer_
 
std::string seedsProducer_
 
edm::ESWatcher
< TransientTrackRecord
transientTrackWatcher_
 
std::auto_ptr
< NuclearVertexBuilder
vertexBuilder
 

Additional Inherited Members

- 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: Associate nuclear seeds to primary tracks and associate secondary tracks to primary tracks

Implementation: <Notes on="" implementation>="">

Definition at line 49 of file NuclearInteractionEDProducer.h.

Member Typedef Documentation

Definition at line 52 of file NuclearInteractionEDProducer.h.

Constructor & Destructor Documentation

NuclearInteractionEDProducer::NuclearInteractionEDProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 15 of file NuclearInteractionEDProducer.cc.

15  :
16 conf_(iConfig),
17 primaryProducer_(iConfig.getParameter<std::string>("primaryProducer")),
18 seedsProducer_(iConfig.getParameter<std::string>("seedsProducer")),
19 secondaryProducer_(iConfig.getParameter<std::string>("secondaryProducer")),
20 additionalSecondaryProducer_(iConfig.getParameter<std::string>("additionalSecondaryProducer"))
21 {
22  produces<reco::NuclearInteractionCollection>();
23 }
T getParameter(std::string const &) const
NuclearInteractionEDProducer::~NuclearInteractionEDProducer ( )

Definition at line 25 of file NuclearInteractionEDProducer.cc.

26 {
27 }

Member Function Documentation

void NuclearInteractionEDProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 129 of file NuclearInteractionEDProducer.cc.

130 {
131 }
void NuclearInteractionEDProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 133 of file NuclearInteractionEDProducer.cc.

133 {}
void NuclearInteractionEDProducer::findAdditionalSecondaryTracks ( reco::NuclearInteraction nucl,
const edm::Handle< reco::TrackCollection > &  additionalSecTracks 
)
private

Definition at line 142 of file NuclearInteractionEDProducer.cc.

References i, likelihoodCalculator, LogDebug, reco::NuclearInteraction::seeds(), and vertexBuilder.

Referenced by produce().

143  {
144 
145  LogDebug("NuclearInteractionMaker") << "Check if one of the " << additionalSecTracks->size()
146  << " additional secondary track is compatible";
147  reco::TrackRefVector allSecondary;
148  for(unsigned int i=0; i< additionalSecTracks->size(); i++) {
149  reco::TrackRef sec(additionalSecTracks, i);
150  if( vertexBuilder->isCompatible( sec ) ) {
151  // check if sec is already a secondary track (with id = tkId)
152  // else add this new track
153  vertexBuilder->addSecondaryTrack( sec );
154  }
155  }
156  likelihoodCalculator->calculate( vertexBuilder->getVertex() );
157 
158  nucl = reco::NuclearInteraction(nucl.seeds(), vertexBuilder->getVertex(), likelihoodCalculator->result() );
159 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const TrajectorySeedRefVector & seeds()
return the seeds
std::auto_ptr< NuclearLikelihood > likelihoodCalculator
std::auto_ptr< NuclearVertexBuilder > vertexBuilder
bool NuclearInteractionEDProducer::isInside ( const reco::TrackRef track,
const TrajectorySeedRefVector seeds 
)
private

Definition at line 136 of file NuclearInteractionEDProducer.cc.

References i, combine::key, edm::Ref< C, T, F >::key(), and edm::RefVector< C, T, F >::size().

Referenced by produce().

136  {
137  unsigned int seedKey = track->seedRef().key();
138  for (unsigned int i=0; i< seeds.size(); i++) { if( seeds[i].key() == seedKey ) return true; }
139  return false;
140 }
int i
Definition: DBlmapReader.cc:9
key_type key() const
Accessor for product key.
Definition: Ref.h:266
list key
Definition: combine.py:13
void NuclearInteractionEDProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Get magnetic field

Get the primary tracks

Get the primary trajectories (produced by the Refitter)

Get the AssociationMap between primary tracks and trajectories

Get the AssociationMap between seeds and primary trajectories

Get the secondary tracks

Definition of the output

Loop on all primary trajectories

  1. Get the primary track from the trajectory
  2. Get the seeds from the trajectory
  3. Get the secondary tracks
  4. Get the vertex and the likelihood
  5. Build the nuclear interaction
  6. Search for additional secondary tracks in an other track collection and recompute the nuclear interaction

Implements edm::EDProducer.

Definition at line 35 of file NuclearInteractionEDProducer.cc.

References additionalSecondaryProducer_, edm::ESWatcher< T >::check(), conf_, edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), findAdditionalSecondaryTracks(), edm::EventSetup::get(), edm::Event::getByLabel(), i, isInside(), edm::HandleBase::isValid(), gen::k, likelihoodCalculator, LogDebug, magFieldWatcher_, primaryProducer_, reco::print(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), secondaryProducer_, seedsProducer_, transientTrackWatcher_, edm::helpers::KeyVal< K, V >::val, and vertexBuilder.

36 {
37  if ( magFieldWatcher_.check(iSetup) || transientTrackWatcher_.check(iSetup) ) {
40  iSetup.get<IdealMagneticFieldRecord>().get(magField);
41 
43  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
44 
45  vertexBuilder = std::auto_ptr< NuclearVertexBuilder >(new NuclearVertexBuilder( magField.product(), builder.product(), conf_) );
46  likelihoodCalculator = std::auto_ptr< NuclearLikelihood >(new NuclearLikelihood);
47  }
48 
50  edm::Handle<reco::TrackCollection> primaryTrackCollection;
51  iEvent.getByLabel( primaryProducer_, primaryTrackCollection );
52 
54  edm::Handle< TrajectoryCollection > primaryTrajectoryCollection;
55  iEvent.getByLabel( primaryProducer_, primaryTrajectoryCollection );
56 
59  iEvent.getByLabel( primaryProducer_, refMapH );
60  const TrajTrackAssociationCollection& refMap = *(refMapH.product());
61 
64  iEvent.getByLabel(seedsProducer_, nuclMapH);
65  const TrajectoryToSeedsMap& nuclMap = *(nuclMapH.product());
66 
68  edm::Handle<reco::TrackCollection> secondaryTrackCollection;
69  iEvent.getByLabel( secondaryProducer_, secondaryTrackCollection );
70 
71  // Get eventual additional secondary tracks
72  edm::Handle<reco::TrackCollection> additionalSecTracks;
73  iEvent.getByLabel( additionalSecondaryProducer_, additionalSecTracks);
74 
76  std::auto_ptr<reco::NuclearInteractionCollection> theNuclearInteractions(new reco::NuclearInteractionCollection);
77 
78  typedef edm::Ref<TrajectoryCollection> TrajectoryRef;
79 
81  for(unsigned int i = 0; i < primaryTrajectoryCollection->size() ; i++) {
82 
83  TrajectoryRef trajRef( primaryTrajectoryCollection, i );
84 
86  TrajTrackAssociationCollection::const_iterator itPrimTrack = refMap.find( trajRef );
87  if( itPrimTrack == refMap.end() || (itPrimTrack->val).isNull() ) continue;
88  const reco::TrackRef& primary_track = itPrimTrack->val;
89 
91  TrajectoryToSeedsMap::const_iterator itSeeds = nuclMap.find( trajRef );
92  if( itSeeds == nuclMap.end() || (itSeeds->val).isNull()) continue;
93  const TrajectorySeedRefVector& seeds = itSeeds->val;
94 
96  std::vector<reco::TrackRef> secondary_tracks;
97  for( unsigned int k=0; k < secondaryTrackCollection->size(); k++) {
98  reco::TrackRef currentTrk(secondaryTrackCollection, k);
99  if( isInside( currentTrk, seeds ) ) secondary_tracks.push_back(currentTrk);
100  }
101 
103  vertexBuilder->build(primary_track, secondary_tracks);
104  likelihoodCalculator->calculate( vertexBuilder->getVertex() );
105 
107  reco::NuclearInteraction nuclInter(seeds, vertexBuilder->getVertex(), likelihoodCalculator->result() );
108 
111  if( additionalSecTracks.isValid() )
112  findAdditionalSecondaryTracks(nuclInter, additionalSecTracks);
113 
114  theNuclearInteractions->push_back( nuclInter );
115 
116  std::ostringstream str;
117  print(str, nuclInter, vertexBuilder);
118  edm::LogInfo("NuclearInteractionMaker") << str.str();
119 
120  }
121 
122 
123  LogDebug("NuclearInteractionMaker") << "End of NuclearInteractionMaker - Number of nuclear interactions found :" << theNuclearInteractions->size();
124  iEvent.put(theNuclearInteractions);
125 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
bool isInside(const reco::TrackRef &track, const TrajectorySeedRefVector &seeds)
edm::ESWatcher< TransientTrackRecord > transientTrackWatcher_
const_iterator end() const
last iterator over the map (read only)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
const_iterator find(const key_type &k) const
find element with specified reference key
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
std::vector< NuclearInteraction > NuclearInteractionCollection
collection of NuclearInteractions
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
int k[5][pyjets_maxn]
void findAdditionalSecondaryTracks(reco::NuclearInteraction &nucl, const edm::Handle< reco::TrackCollection > &additionalSecTracks)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
edm::ESWatcher< IdealMagneticFieldRecord > magFieldWatcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
std::auto_ptr< NuclearLikelihood > likelihoodCalculator
edm::RefVector< TrajectorySeedCollection > TrajectorySeedRefVector
std::auto_ptr< NuclearVertexBuilder > vertexBuilder

Member Data Documentation

std::string NuclearInteractionEDProducer::additionalSecondaryProducer_
private

Definition at line 71 of file NuclearInteractionEDProducer.h.

Referenced by produce().

edm::ParameterSet NuclearInteractionEDProducer::conf_
private

Definition at line 67 of file NuclearInteractionEDProducer.h.

Referenced by produce().

std::auto_ptr< NuclearLikelihood > NuclearInteractionEDProducer::likelihoodCalculator
private

Definition at line 74 of file NuclearInteractionEDProducer.h.

Referenced by findAdditionalSecondaryTracks(), and produce().

edm::ESWatcher<IdealMagneticFieldRecord> NuclearInteractionEDProducer::magFieldWatcher_
private

Definition at line 76 of file NuclearInteractionEDProducer.h.

Referenced by produce().

std::string NuclearInteractionEDProducer::primaryProducer_
private

Definition at line 68 of file NuclearInteractionEDProducer.h.

Referenced by produce().

std::string NuclearInteractionEDProducer::secondaryProducer_
private

Definition at line 70 of file NuclearInteractionEDProducer.h.

Referenced by produce().

std::string NuclearInteractionEDProducer::seedsProducer_
private

Definition at line 69 of file NuclearInteractionEDProducer.h.

Referenced by produce().

edm::ESWatcher<TransientTrackRecord> NuclearInteractionEDProducer::transientTrackWatcher_
private

Definition at line 77 of file NuclearInteractionEDProducer.h.

Referenced by produce().

std::auto_ptr< NuclearVertexBuilder > NuclearInteractionEDProducer::vertexBuilder
private

Definition at line 73 of file NuclearInteractionEDProducer.h.

Referenced by findAdditionalSecondaryTracks(), and produce().