CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
NuclearInteractionEDProducer Class Reference

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

Inheritance diagram for NuclearInteractionEDProducer:
edm::stream::EDProducer<>

Public Types

typedef edm::RefVector< TrajectorySeedCollectionTrajectorySeedRefVector
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

 NuclearInteractionEDProducer (const edm::ParameterSet &)
 
 ~NuclearInteractionEDProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void findAdditionalSecondaryTracks (reco::NuclearInteraction &nucl, const edm::Handle< reco::TrackCollection > &additionalSecTracks) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Static Private Member Functions

static bool isInside (const reco::TrackRef &track, const TrajectorySeedRefVector &seeds)
 

Private Attributes

edm::ParameterSet conf_
 
std::unique_ptr< NuclearLikelihoodlikelihoodCalculator
 
edm::ESWatcher< IdealMagneticFieldRecordmagFieldWatcher_
 
edm::EDGetTokenT< reco::TrackCollectiontoken_additionalSecTracks
 
edm::EDGetTokenT< TrajectoryToSeedsMaptoken_nuclMapH
 
edm::EDGetTokenT< reco::TrackCollectiontoken_primaryTrack
 
edm::EDGetTokenT< TrajectoryCollectiontoken_primaryTrajectory
 
edm::EDGetTokenT< TrajTrackAssociationCollectiontoken_refMapH
 
edm::EDGetTokenT< reco::TrackCollectiontoken_secondaryTrack
 
edm::ESWatcher< TransientTrackRecordtransientTrackWatcher_
 
std::unique_ptr< NuclearVertexBuildervertexBuilder
 

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 17 of file NuclearInteractionEDProducer.cc.

References edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, token_additionalSecTracks, token_nuclMapH, token_primaryTrack, token_primaryTrajectory, token_refMapH, and token_secondaryTrack.

17  :
18 conf_(iConfig)
19 {
20  token_primaryTrack = consumes<reco::TrackCollection>(iConfig.getParameter<std::string>("primaryProducer"));
21  token_secondaryTrack = consumes<reco::TrackCollection>(iConfig.getParameter<std::string>("secondaryProducer"));
22  token_additionalSecTracks = consumes<reco::TrackCollection>(iConfig.getParameter<std::string>("additionalSecondaryProducer"));
23  token_primaryTrajectory = consumes<TrajectoryCollection>(iConfig.getParameter<std::string>("primaryProducer"));
24  token_refMapH = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<std::string>("primaryProducer"));
25  token_nuclMapH = consumes<TrajectoryToSeedsMap>(iConfig.getParameter<std::string>("seedsProducer"));
26 
27  produces<reco::NuclearInteractionCollection>();
28 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > token_additionalSecTracks
edm::EDGetTokenT< TrajTrackAssociationCollection > token_refMapH
edm::EDGetTokenT< TrajectoryCollection > token_primaryTrajectory
edm::EDGetTokenT< reco::TrackCollection > token_secondaryTrack
edm::EDGetTokenT< reco::TrackCollection > token_primaryTrack
edm::EDGetTokenT< TrajectoryToSeedsMap > token_nuclMapH
NuclearInteractionEDProducer::~NuclearInteractionEDProducer ( )
override

Definition at line 30 of file NuclearInteractionEDProducer.cc.

31 {
32 }

Member Function Documentation

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

Definition at line 139 of file NuclearInteractionEDProducer.cc.

References NuclearVertexBuilder::closestApproach(), ClosestApproachInRPhi::distance(), mps_fire::i, reco::NuclearInteraction::likelihood(), likelihoodCalculator, LogDebug, MillePedeFileConverter_cfg::out, reco::Vertex::position(), reco::NuclearInteraction::primaryTrack(), edm::print(), reco::NuclearInteraction::secondaryTracks_begin(), reco::NuclearInteraction::secondaryTracks_end(), reco::NuclearInteraction::secondaryTracksSize(), reco::NuclearInteraction::seeds(), reco::NuclearInteraction::seedsSize(), reco::NuclearInteraction::vertex(), and vertexBuilder.

Referenced by produce().

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

Definition at line 133 of file NuclearInteractionEDProducer.cc.

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

Referenced by produce().

133  {
134  unsigned int seedKey = track->seedRef().key();
135  for (unsigned int i=0; i< seeds.size(); i++) { if( seeds[i].key() == seedKey ) return true; }
136  return false;
137 }
key_type key() const
Accessor for product key.
Definition: Ref.h:263
void NuclearInteractionEDProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

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

Definition at line 40 of file NuclearInteractionEDProducer.cc.

References edm::ESWatcher< T >::check(), conf_, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), findAdditionalSecondaryTracks(), edm::EventSetup::get(), edm::Event::getByToken(), mps_fire::i, isInside(), edm::HandleBase::isValid(), gen::k, likelihoodCalculator, LogDebug, magFieldWatcher_, eostools::move(), ntupleEnum::nuclInter, edm::print(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), str, token_additionalSecTracks, token_nuclMapH, token_primaryTrack, token_primaryTrajectory, token_refMapH, token_secondaryTrack, transientTrackWatcher_, edm::helpers::KeyVal< K, V >::val, and vertexBuilder.

41 {
42  if ( magFieldWatcher_.check(iSetup) || transientTrackWatcher_.check(iSetup) ) {
45  iSetup.get<IdealMagneticFieldRecord>().get(magField);
46 
48  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
49 
50  vertexBuilder = std::make_unique< NuclearVertexBuilder >(magField.product(), builder.product(), conf_);
51  likelihoodCalculator = std::make_unique< NuclearLikelihood >();
52  }
53 
55  edm::Handle<reco::TrackCollection> primaryTrackCollection;
56  iEvent.getByToken(token_primaryTrack, primaryTrackCollection);
57 
59  edm::Handle< TrajectoryCollection > primaryTrajectoryCollection;
60  iEvent.getByToken(token_primaryTrajectory, primaryTrajectoryCollection);
61 
64  iEvent.getByToken(token_refMapH, refMapH);
65  const TrajTrackAssociationCollection& refMap = *(refMapH.product());
66 
69  iEvent.getByToken(token_nuclMapH, nuclMapH);
70  const TrajectoryToSeedsMap& nuclMap = *(nuclMapH.product());
71 
73  edm::Handle<reco::TrackCollection> secondaryTrackCollection;
74  iEvent.getByToken(token_secondaryTrack, secondaryTrackCollection);
75 
76  // Get eventual additional secondary tracks
77  edm::Handle<reco::TrackCollection> additionalSecTracks;
78  iEvent.getByToken(token_additionalSecTracks, additionalSecTracks);
79 
81  auto theNuclearInteractions = std::make_unique<reco::NuclearInteractionCollection>();
82 
83  typedef edm::Ref<TrajectoryCollection> TrajectoryRef;
84 
86  for(unsigned int i = 0; i < primaryTrajectoryCollection->size() ; i++) {
87 
88  TrajectoryRef trajRef( primaryTrajectoryCollection, i );
89 
91  TrajTrackAssociationCollection::const_iterator itPrimTrack = refMap.find( trajRef );
92  if( itPrimTrack == refMap.end() || (itPrimTrack->val).isNull() ) continue;
93  const reco::TrackRef& primary_track = itPrimTrack->val;
94 
96  TrajectoryToSeedsMap::const_iterator itSeeds = nuclMap.find( trajRef );
97  if( itSeeds == nuclMap.end() || (itSeeds->val).isNull()) continue;
98  const TrajectorySeedRefVector& seeds = itSeeds->val;
99 
101  std::vector<reco::TrackRef> secondary_tracks;
102  for( unsigned int k=0; k < secondaryTrackCollection->size(); k++) {
103  reco::TrackRef currentTrk(secondaryTrackCollection, k);
104  if( isInside( currentTrk, seeds ) ) secondary_tracks.push_back(currentTrk);
105  }
106 
108  vertexBuilder->build(primary_track, secondary_tracks);
109  likelihoodCalculator->calculate( vertexBuilder->getVertex() );
110 
112  reco::NuclearInteraction nuclInter(seeds, vertexBuilder->getVertex(), likelihoodCalculator->result() );
113 
116  if( additionalSecTracks.isValid() )
117  findAdditionalSecondaryTracks(nuclInter, additionalSecTracks);
118 
119  theNuclearInteractions->push_back( nuclInter );
120 
121  std::ostringstream str;
122  print(str, nuclInter, *vertexBuilder);
123  edm::LogInfo("NuclearInteractionMaker") << str.str();
124 
125  }
126 
127 
128  LogDebug("NuclearInteractionMaker") << "End of NuclearInteractionMaker - Number of nuclear interactions found :" << theNuclearInteractions->size();
129  iEvent.put(std::move(theNuclearInteractions));
130 }
#define LogDebug(id)
std::unique_ptr< NuclearLikelihood > likelihoodCalculator
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
static bool isInside(const reco::TrackRef &track, const TrajectorySeedRefVector &seeds)
edm::ESWatcher< TransientTrackRecord > transientTrackWatcher_
edm::EDGetTokenT< reco::TrackCollection > token_additionalSecTracks
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const_iterator find(const key_type &k) const
find element with specified reference key
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
edm::EDGetTokenT< TrajTrackAssociationCollection > token_refMapH
std::unique_ptr< NuclearVertexBuilder > vertexBuilder
edm::EDGetTokenT< TrajectoryCollection > token_primaryTrajectory
void findAdditionalSecondaryTracks(reco::NuclearInteraction &nucl, const edm::Handle< reco::TrackCollection > &additionalSecTracks) const
bool isValid() const
Definition: HandleBase.h:74
int k[5][pyjets_maxn]
T const * product() const
Definition: Handle.h:74
edm::ESWatcher< IdealMagneticFieldRecord > magFieldWatcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::EDGetTokenT< reco::TrackCollection > token_secondaryTrack
T get() const
Definition: EventSetup.h:71
edm::RefVector< TrajectorySeedCollection > TrajectorySeedRefVector
edm::EDGetTokenT< reco::TrackCollection > token_primaryTrack
edm::EDGetTokenT< TrajectoryToSeedsMap > token_nuclMapH
#define str(s)
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::ParameterSet NuclearInteractionEDProducer::conf_
private

Definition at line 65 of file NuclearInteractionEDProducer.h.

Referenced by produce().

std::unique_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().

edm::EDGetTokenT<reco::TrackCollection> NuclearInteractionEDProducer::token_additionalSecTracks
private

Definition at line 68 of file NuclearInteractionEDProducer.h.

Referenced by NuclearInteractionEDProducer(), and produce().

edm::EDGetTokenT<TrajectoryToSeedsMap> NuclearInteractionEDProducer::token_nuclMapH
private

Definition at line 71 of file NuclearInteractionEDProducer.h.

Referenced by NuclearInteractionEDProducer(), and produce().

edm::EDGetTokenT<reco::TrackCollection> NuclearInteractionEDProducer::token_primaryTrack
private

Definition at line 66 of file NuclearInteractionEDProducer.h.

Referenced by NuclearInteractionEDProducer(), and produce().

edm::EDGetTokenT<TrajectoryCollection> NuclearInteractionEDProducer::token_primaryTrajectory
private

Definition at line 69 of file NuclearInteractionEDProducer.h.

Referenced by NuclearInteractionEDProducer(), and produce().

edm::EDGetTokenT<TrajTrackAssociationCollection> NuclearInteractionEDProducer::token_refMapH
private

Definition at line 70 of file NuclearInteractionEDProducer.h.

Referenced by NuclearInteractionEDProducer(), and produce().

edm::EDGetTokenT<reco::TrackCollection> NuclearInteractionEDProducer::token_secondaryTrack
private

Definition at line 67 of file NuclearInteractionEDProducer.h.

Referenced by NuclearInteractionEDProducer(), and produce().

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

Definition at line 77 of file NuclearInteractionEDProducer.h.

Referenced by produce().

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

Definition at line 73 of file NuclearInteractionEDProducer.h.

Referenced by findAdditionalSecondaryTracks(), and produce().