CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TrackingTruthAccumulator Class Reference

Replacement for TrackingTruthProducer in the new pileup mixing setup. More...

#include <TrackingTruthAccumulator.h>

Inheritance diagram for TrackingTruthAccumulator:
DigiAccumulatorMixMod

Classes

struct  OutputCollections
 

Public Member Functions

 TrackingTruthAccumulator (const edm::ParameterSet &config, edm::stream::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from DigiAccumulatorMixMod
virtual void accumulate (edm::Event const &event, edm::EventSetup const &setup)=0
 
virtual void accumulate (PileUpEventPrincipal const &event, edm::EventSetup const &setup, edm::StreamID const &)=0
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
 
virtual void beginRun (edm::Run const &run, edm::EventSetup const &setup)
 
 DigiAccumulatorMixMod ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
 
virtual void endRun (edm::Run const &run, edm::EventSetup const &setup)
 
virtual void finalizeBunchCrossing (edm::Event &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual void finalizeEvent (edm::Event &event, edm::EventSetup const &setup)=0
 
virtual PileupMixingContentgetEventPileupInfo ()
 
virtual void initializeBunchCrossing (edm::Event const &event, edm::EventSetup const &setup, int bunchCrossing)
 
virtual void initializeEvent (edm::Event const &event, edm::EventSetup const &setup)=0
 
virtual void StorePileupInformation (std::vector< int > &numInteractionList, std::vector< int > &bunchCrossingList, std::vector< float > &TrueInteractionList, std::vector< edm::EventID > &eventList, int bunchSpace)
 
virtual ~DigiAccumulatorMixMod ()
 

Private Member Functions

virtual void accumulate (const edm::Event &event, const edm::EventSetup &setup)
 
virtual void accumulate (const PileUpEventPrincipal &event, const edm::EventSetup &setup, edm::StreamID const &)
 
template<class T >
void accumulateEvent (const T &event, const edm::EventSetup &setup, const edm::Handle< edm::HepMCProduct > &hepMCproduct)
 Both forms of accumulate() delegate to this templated method. More...
 
template<class T >
void fillSimHits (std::vector< const PSimHit * > &returnValue, const T &event, const edm::EventSetup &setup)
 Fills the supplied vector with pointers to the SimHits, checking for bad modules if required. More...
 
virtual void finalizeEvent (edm::Event &event, const edm::EventSetup &setup)
 
virtual void initializeEvent (const edm::Event &event, const edm::EventSetup &setup)
 

Private Attributes

const bool addAncestors_
 Whether or not to add the full parentage of any TrackingParticle that is inserted in the collection. More...
 
bool allowDifferentProcessTypeForDifferentDetectors_
 When counting hits, allows hits in different detectors to have a different process type. More...
 
bool chargedOnly_
 Uses the same config as selector_, but can be used to drop out early since selector_ requires the TrackingParticle to be created first. More...
 
std::vector< edm::InputTagcollectionTags_
 
const bool createInitialVertexCollection_
 Whether or not to create a separate collection for just the initial interaction vertices. More...
 
const bool createMergedCollection_
 
const bool createUnmergedCollection_
 If bremsstrahlung merging, whether to also add the unmerged collection to the event or not. More...
 
edm::InputTag genParticleLabel_
 
edm::InputTag hepMCproductLabel_
 Needed to add HepMC::GenVertex to SimVertex. More...
 
const bool ignoreTracksOutsideVolume_
 
const unsigned int maximumPreviousBunchCrossing_
 
const unsigned int maximumSubsequentBunchCrossing_
 
OutputCollections mergedOutput_
 
const std::string messageCategory_
 The message category used to send messages to MessageLogger. More...
 
std::unique_ptr< TrackingVertexCollectionpInitialVertices_
 
const bool removeDeadModules_
 As of 11/Feb/2013 this option hasn't been implemented yet. More...
 
TrackingParticleSelector selector_
 
bool selectorFlag_
 
bool signalOnly_
 Uses the same config as selector_, but can be used to drop out early since selector_ requires the TrackingParticle to be created first. More...
 
const edm::InputTag simTrackLabel_
 
const edm::InputTag simVertexLabel_
 
OutputCollections unmergedOutput_
 
const double vertexDistanceCut_
 maximum distance for HepMC::GenVertex to be added to SimVertex More...
 
const double volumeRadius_
 
const double volumeZ_
 

Detailed Description

Replacement for TrackingTruthProducer in the new pileup mixing setup.

The configuration parameters are:

Parameter name Type Description
volumeRadius double The volume radius in cm used if ignoreTracksOutsideVolume is true.
volumeZ double The volume z in cm used if ignoreTracksOutsideVolume is true.
ignoreTracksOutsideVolume bool If true, sim tracks that have a production vertex outside the volume specified by volumeRadius and volumeZ won't be turned into TrackingParticles. Doesn't make much difference to be honest, over a huge range of volume sizes so there must be a cut earlier in the simulation.
maximumPreviousBunchCrossing unsigned int Bunch crossings before this number (inclusive; use positive integer) won't be included. Setting to zero means only in-time.
maximumSubsequentBunchCrossing unsigned int Bunch crossings after this won't create any TrackingParticles.
createUnmergedCollection bool Whether to create the TrackingParticle collection without bremsstrahlung merged.
createMergedBremsstrahlung bool Whether to create the TrackingParticle collection with bremsstrahlung merged. At least one of createUnmergedCollection or createMergedBremsstrahlung should be true otherwise nothing will be produced.
createInitialVertexCollection bool Whether to create a collection of just the initial vertices. You can usually get this information from one of the other collections (merged or unmerged bremsstrahlung), but for this collection no selection is applied. Hence you will always have all of the initial vertices regardless of how tightly you select TrackingParticles with the "select" parameter. Note that the collection will have no links to the products of these vertices. If you want to know what came off these vertices you will have to look in one of the other collections. The name of the collection will be "InitialVertices".
alwaysAddAncestors bool If a sim track passes selection and is turned into a TrackingParticle, all of it's parents will also be created even if they fail the selection. This was the default behaviour for the old TrackingParticleProducer.
removeDeadModules bool Hasn't been implemented yet (as of 22/May/2013).
simTrackCollection edm::InputTag The input SimTrack collection
simVertexCollection edm::InputTag The input SimVerted collection
simHitCollections edm::ParameterSet A ParameterSet of vectors of InputTags that are the input PSimHits
genParticleCollection edm::InputTag The input reco::GenParticle collection. Note that there's a difference between reco::GenParticle and HepMC::GenParticle; the old TrackingTruthProducer used to use HepMC::GenParticle.
allowDifferentSimHitProcesses bool Should be false for FullSim and true for FastSim. There's more documentation in the code if you're really interested.
select edm::ParameterSet A ParameterSet used to configure a TrackingParticleSelector. If the TrackingParticle doesn't pass this selector then it's not added to the output.

Author
Mark Grimes (mark..nosp@m.grim.nosp@m.es@br.nosp@m.isto.nosp@m.l.ac..nosp@m.uk)
Date
11/Oct/2012

Definition at line 75 of file TrackingTruthAccumulator.h.

Constructor & Destructor Documentation

TrackingTruthAccumulator::TrackingTruthAccumulator ( const edm::ParameterSet config,
edm::stream::EDProducerBase mixMod,
edm::ConsumesCollector iC 
)
explicit

Definition at line 224 of file TrackingTruthAccumulator.cc.

References chargedOnly_, collectionTags_, edm::ConsumesCollector::consumes(), createInitialVertexCollection_, createMergedCollection_, createUnmergedCollection_, edm::ParameterSet::exists(), genParticleLabel_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::ParameterSet::getParameterSet(), hepMCproductLabel_, messageCategory_, selector_, selectorFlag_, signalOnly_, simTrackLabel_, and simVertexLabel_.

224  :
225  messageCategory_("TrackingTruthAccumulator"),
226  volumeRadius_( config.getParameter<double>("volumeRadius") ),
227  volumeZ_( config.getParameter<double>("volumeZ") ),
228  vertexDistanceCut_( config.getParameter<double>("vertexDistanceCut") ),
229  ignoreTracksOutsideVolume_( config.getParameter<bool>("ignoreTracksOutsideVolume") ),
230  maximumPreviousBunchCrossing_( config.getParameter<unsigned int>("maximumPreviousBunchCrossing") ),
231  maximumSubsequentBunchCrossing_( config.getParameter<unsigned int>("maximumSubsequentBunchCrossing") ),
232  createUnmergedCollection_( config.getParameter<bool>("createUnmergedCollection") ),
233  createMergedCollection_(config.getParameter<bool>("createMergedBremsstrahlung") ),
234  createInitialVertexCollection_(config.getParameter<bool>("createInitialVertexCollection") ),
235  addAncestors_( config.getParameter<bool>("alwaysAddAncestors") ),
236  removeDeadModules_( config.getParameter<bool>("removeDeadModules") ),
237  simTrackLabel_( config.getParameter<edm::InputTag>("simTrackCollection") ),
238  simVertexLabel_( config.getParameter<edm::InputTag>("simVertexCollection") ),
239  collectionTags_( ),
240  genParticleLabel_( config.getParameter<edm::InputTag>("genParticleCollection") ),
241  hepMCproductLabel_( config.getParameter<edm::InputTag>("HepMCProductLabel") ),
242  allowDifferentProcessTypeForDifferentDetectors_( config.getParameter<bool>("allowDifferentSimHitProcesses") )
243 {
244  //
245  // Make sure at least one of the merged and unmerged collections have been set
246  // to be created.
247  //
249  edm::LogError(messageCategory_) << "Both \"createUnmergedCollection\" and \"createMergedBremsstrahlung\" have been"
250  << "set to false, which means no collections will be created";
251 
252  // Initialize selection for building TrackingParticles
253  //
254  if( config.exists( "select" ) )
255  {
256  edm::ParameterSet param=config.getParameter<edm::ParameterSet>("select");
257  selector_=TrackingParticleSelector( param.getParameter<double>( "ptMinTP" ),
258  param.getParameter<double>( "ptMaxTP" ),
259  param.getParameter<double>( "minRapidityTP" ),
260  param.getParameter<double>( "maxRapidityTP" ),
261  param.getParameter<double>( "tipTP" ),
262  param.getParameter<double>( "lipTP" ),
263  param.getParameter<int>( "minHitTP" ),
264  param.getParameter<bool>( "signalOnlyTP" ),
265  param.getParameter<bool>( "intimeOnlyTP" ),
266  param.getParameter<bool>( "chargedOnlyTP" ),
267  param.getParameter<bool>( "stableOnlyTP" ),
268  param.getParameter<std::vector<int> >("pdgIdTP") );
269  selectorFlag_=true;
270 
271  // Also set these two variables, which are used to drop out early if the SimTrack doesn't conform.
272  // The selector_ requires a full TrackingParticle object, but these two variables can veto things early.
273  chargedOnly_=param.getParameter<bool>( "chargedOnlyTP" );
274  signalOnly_=param.getParameter<bool>( "signalOnlyTP" );
275  }
276  else
277  {
278  selectorFlag_=false;
279  chargedOnly_=false;
280  signalOnly_=false;
281  }
282 
283  //
284  // Need to state what collections are going to be added to the event. This
285  // depends on which of the merged and unmerged collections have been configured
286  // to be created.
287  //
289  {
290  mixMod.produces<TrackingVertexCollection>();
291  mixMod.produces<TrackingParticleCollection>();
292  }
293 
295  {
296  mixMod.produces<TrackingParticleCollection>("MergedTrackTruth");
297  mixMod.produces<TrackingVertexCollection>("MergedTrackTruth");
298  }
299 
301  {
302  mixMod.produces<TrackingVertexCollection>("InitialVertices");
303  }
304 
305  iC.consumes<std::vector<SimTrack> >(simTrackLabel_);
306  iC.consumes<std::vector<SimVertex> >(simVertexLabel_);
307  iC.consumes<std::vector<reco::GenParticle> >(genParticleLabel_);
308  iC.consumes<std::vector<int> >(genParticleLabel_);
309  iC.consumes<std::vector<int> >(hepMCproductLabel_);
310 
311  // Fill the collection tags
312  const edm::ParameterSet& simHitCollectionConfig=config.getParameterSet("simHitCollections");
313  std::vector<std::string> parameterNames=simHitCollectionConfig.getParameterNames();
314 
315  for( const auto& parameterName : parameterNames )
316  {
317  std::vector<edm::InputTag> tags=simHitCollectionConfig.getParameter<std::vector<edm::InputTag> >(parameterName);
318  collectionTags_.insert(collectionTags_.end(), tags.begin(), tags.end());
319  }
320 
321  for( const auto& collectionTag : collectionTags_ ) {
322  iC.consumes<std::vector<PSimHit> >(collectionTag);
323  }
324 
325 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< TrackingParticle > TrackingParticleCollection
const bool removeDeadModules_
As of 11/Feb/2013 this option hasn&#39;t been implemented yet.
const bool addAncestors_
Whether or not to add the full parentage of any TrackingParticle that is inserted in the collection...
bool exists(std::string const &parameterName) const
checks if a parameter exists
const double vertexDistanceCut_
maximum distance for HepMC::GenVertex to be added to SimVertex
bool signalOnly_
Uses the same config as selector_, but can be used to drop out early since selector_ requires the Tra...
const unsigned int maximumSubsequentBunchCrossing_
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
const std::string messageCategory_
The message category used to send messages to MessageLogger.
std::vector< std::string > getParameterNames() const
bool allowDifferentProcessTypeForDifferentDetectors_
When counting hits, allows hits in different detectors to have a different process type...
const bool createInitialVertexCollection_
Whether or not to create a separate collection for just the initial interaction vertices.
ParameterSet const & getParameterSet(std::string const &) const
std::vector< TrackingVertex > TrackingVertexCollection
const unsigned int maximumPreviousBunchCrossing_
bool chargedOnly_
Uses the same config as selector_, but can be used to drop out early since selector_ requires the Tra...
const bool createUnmergedCollection_
If bremsstrahlung merging, whether to also add the unmerged collection to the event or not...
TrackingParticleSelector selector_
edm::InputTag hepMCproductLabel_
Needed to add HepMC::GenVertex to SimVertex.
std::vector< edm::InputTag > collectionTags_

Member Function Documentation

virtual void TrackingTruthAccumulator::accumulate ( const edm::Event event,
const edm::EventSetup setup 
)
privatevirtual

Referenced by initializeEvent().

virtual void TrackingTruthAccumulator::accumulate ( const PileUpEventPrincipal event,
const edm::EventSetup setup,
edm::StreamID const &   
)
privatevirtual
template<class T >
void TrackingTruthAccumulator::accumulateEvent ( const T event,
const edm::EventSetup setup,
const edm::Handle< edm::HepMCProduct > &  hepMCproduct 
)
private

Both forms of accumulate() delegate to this templated method.

Definition at line 409 of file TrackingTruthAccumulator.cc.

References addAncestors_, allowDifferentProcessTypeForDifferentDetectors_, EncodedEventId::bunchCrossing(), CoreSimTrack::charge(), chargedOnly_, createInitialVertexCollection_, createMergedCollection_, createUnmergedCollection_, EncodedEventId::event(), CoreSimTrack::eventId(), cppFunctionSkipper::exception, fillSimHits(), genParticleLabel_, edm::EventSetup::get(), ignoreTracksOutsideVolume_, diffTreeTool::index, mergedOutput_, NULL, pInitialVertices_, CoreSimVertex::position(), edm::ESHandle< T >::product(), selector_, selectorFlag_, signalOnly_, simTrackMatching_cfi::simTrack, simTrackLabel_, ecalDetailedTimeRecHit_cfi::simVertex, simVertexLabel_, unmergedOutput_, vertexDistanceCut_, SimVertex::vertexId(), volumeRadius_, and volumeZ_.

Referenced by initializeEvent().

410 {
411  //
412  // Get the collections
413  //
415  edm::Handle<std::vector<SimVertex> > hSimVertices;
417  edm::Handle< std::vector<int> > hGenParticleIndices;
418 
419  event.getByLabel( simTrackLabel_, hSimTracks );
420  event.getByLabel( simVertexLabel_, hSimVertices );
421 
422  try
423  {
424  event.getByLabel( genParticleLabel_, hGenParticles );
425  event.getByLabel( genParticleLabel_, hGenParticleIndices );
426  }
427  catch( cms::Exception& exception )
428  {
429  //
430  // The Monte Carlo is not always available, e.g. for pileup events. The information
431  // is only used if it's available, but for some reason the PileUpEventPrincipal
432  // wrapper throws an exception here rather than waiting to see if the handle is
433  // used (as is the case for edm::Event). So I just want to catch this exception
434  // and use the normal handle checking later on.
435  //
436  }
437 
438  //Retrieve tracker topology from geometry
439  edm::ESHandle<TrackerTopology> tTopoHandle;
440  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
441  const TrackerTopology* const tTopo = tTopoHandle.product();
442 
443 
444  // Run through the collections and work out the decay chain of each track/vertex. The
445  // information in SimTrack and SimVertex only allows traversing upwards, but this will
446  // allow traversal in both directions. This is required for things like grouping electrons
447  // that bremsstrahlung as one TrackingParticle if "mergedBremsstrahlung" is set in the
448  // config file.
449  DecayChain decayChain( *hSimTracks, *hSimVertices );
450 
451  // I only want to create these collections if they're actually required
452  std::unique_ptr< ::OutputCollectionWrapper> pUnmergedCollectionWrapper;
453  std::unique_ptr< ::OutputCollectionWrapper> pMergedCollectionWrapper;
454  if( createUnmergedCollection_ ) pUnmergedCollectionWrapper.reset( new ::OutputCollectionWrapper( decayChain, unmergedOutput_ ) );
455  if( createMergedCollection_ ) pMergedCollectionWrapper.reset( new ::OutputCollectionWrapper( decayChain, mergedOutput_ ) );
456 
457  std::vector<const PSimHit*> simHitPointers;
458  fillSimHits( simHitPointers, event, setup );
459  TrackingParticleFactory objectFactory( decayChain, hGenParticles, hepMCproduct, hGenParticleIndices, simHitPointers, volumeRadius_, volumeZ_, vertexDistanceCut_, allowDifferentProcessTypeForDifferentDetectors_ );
460 
461 #if defined(DO_DEBUG_TESTING)
462  // While I'm testing, perform some checks.
463  // TODO - drop this call once I'm happy it works in all situations.
464  decayChain.integrityCheck();
465 #endif
466 
467  TrackingParticleSelector* pSelector=NULL;
468  if( selectorFlag_ ) pSelector=&selector_;
469 
470  // Run over all of the SimTracks, but because I'm interested in the decay hierarchy
471  // do it through the DecayChainTrack objects. These are looped over in sequence here
472  // but they have the hierarchy information for the functions called to traverse the
473  // decay chain.
474 
475  for( size_t index=0; index<decayChain.decayTracksSize; ++index )
476  {
477  ::DecayChainTrack* pDecayTrack=&decayChain.decayTracks[index];
478  const SimTrack& simTrack=hSimTracks->at(pDecayTrack->simTrackIndex);
479 
480 
481  // Perform some quick checks to see if we can drop out early. Note that these are
482  // a subset of the cuts in the selector_ so the created TrackingParticle could still
483  // fail. The selector_ requires the full TrackingParticle to be made however, which
484  // can be computationally expensive.
485  if( chargedOnly_ && simTrack.charge()==0 ) continue;
486  if( signalOnly_ && (simTrack.eventId().bunchCrossing()!=0 || simTrack.eventId().event()!=0) ) continue;
487 
488  // Also perform a check to see if the production vertex is inside the tracker volume (if required).
490  {
491  const SimVertex& simVertex=hSimVertices->at( pDecayTrack->pParentVertex->simVertexIndex );
492  if( !objectFactory.vectorIsInsideVolume( simVertex.position() ) ) continue;
493  }
494 
495 
496  // This function creates the TrackinParticle and adds it to the collection if it
497  // passes the selection criteria specified in the configuration. If the config
498  // specifies adding ancestors, the function is called recursively to do that.
499  ::addTrack( pDecayTrack, pSelector, pUnmergedCollectionWrapper.get(), pMergedCollectionWrapper.get(), objectFactory, addAncestors_, tTopo );
500  }
501 
502  // If configured to create a collection of initial vertices, add them from this bunch
503  // crossing. No selection is applied on this collection, but it also has no links to
504  // the TrackingParticle decay products.
505  // There are a lot of "initial vertices", I'm not entirely sure what they all are
506  // (nuclear interactions in the detector maybe?), but the one for the main event is
507  // the one with vertexId==0.
509  {
510  // Pretty sure the one with vertexId==0 is always the first one, but doesn't hurt to check
511  for( const auto& pRootVertex : decayChain.rootVertices )
512  {
513  const SimVertex& vertex=hSimVertices->at(decayChain.rootVertices[0]->simVertexIndex);
514  if( vertex.vertexId()!=0 ) continue;
515 
516  pInitialVertices_->push_back( objectFactory.createTrackingVertex(pRootVertex) );
517  break;
518  }
519  }
520 }
std::unique_ptr< TrackingVertexCollection > pInitialVertices_
EncodedEventId eventId() const
Definition: CoreSimTrack.h:31
int event() const
get the contents of the subdetector field (should be protected?)
const bool addAncestors_
Whether or not to add the full parentage of any TrackingParticle that is inserted in the collection...
const double vertexDistanceCut_
maximum distance for HepMC::GenVertex to be added to SimVertex
#define NULL
Definition: scimark2.h:8
float charge() const
charge
Definition: CoreSimTrack.cc:18
bool signalOnly_
Uses the same config as selector_, but can be used to drop out early since selector_ requires the Tra...
void fillSimHits(std::vector< const PSimHit * > &returnValue, const T &event, const edm::EventSetup &setup)
Fills the supplied vector with pointers to the SimHits, checking for bad modules if required...
simTrack
per collection params
int bunchCrossing() const
get the detector field from this detid
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:26
unsigned int vertexId() const
Definition: SimVertex.h:37
bool allowDifferentProcessTypeForDifferentDetectors_
When counting hits, allows hits in different detectors to have a different process type...
const bool createInitialVertexCollection_
Whether or not to create a separate collection for just the initial interaction vertices.
const T & get() const
Definition: EventSetup.h:55
bool chargedOnly_
Uses the same config as selector_, but can be used to drop out early since selector_ requires the Tra...
const bool createUnmergedCollection_
If bremsstrahlung merging, whether to also add the unmerged collection to the event or not...
TrackingParticleSelector selector_
T const * product() const
Definition: ESHandle.h:86
Definition: event.py:1
template<class T >
void TrackingTruthAccumulator::fillSimHits ( std::vector< const PSimHit * > &  returnValue,
const T event,
const edm::EventSetup setup 
)
private

Fills the supplied vector with pointers to the SimHits, checking for bad modules if required.

Definition at line 522 of file TrackingTruthAccumulator.cc.

References a, funct::abs(), TrackingVertex::addDaughterTrack(), TrackingParticle::addDecayVertex(), TrackingParticle::addG4Track(), TrackingVertex::addG4Vertex(), TrackingParticle::addGenParticle(), TrackingVertex::addParentTrack(), allowDifferentProcessTypeForDifferentDetectors_, b, EncodedEventId::bunchCrossing(), collectionTags_, gather_cfg::cout, DEFINE_DIGI_ACCUMULATOR, DetId::det(), end, EncodedEventId::event(), CoreSimVertex::eventId(), CoreSimTrack::eventId(), spr::find(), TrackingParticle::g4Tracks(), MCTruth::genEvent, TrackingParticle::genParticles(), SimTrack::genpartIndex(), edm::getRef(), diffTreeTool::index, init, edm::isFinite(), TrackerTopology::layer(), mag2(), hpstanc_transforms::max, SimTrack::noVertex(), NULL, nullptr, TrackingParticle::numberOfHits(), TrackingParticle::numberOfTrackerHits(), TrackingParticle::numberOfTrackerLayers(), TrackingParticle::parentVertex(), objects.autophobj::particleType, cosmictrackingParticleSelector_cfi::pdgId, TrackingParticle::pdgId(), CoreSimVertex::position(), position, TrackingParticle::setNumberOfHits(), TrackingParticle::setNumberOfTrackerHits(), TrackingParticle::setNumberOfTrackerLayers(), TrackingParticle::setParentVertex(), rpcPointValidation_cfi::simHit, trackerHits::simHits, simTrackMatching_cfi::simTrack, ecalDetailedTimeRecHit_cfi::simVertex, DetId::subdetId(), PSimHit::timeOfFlight(), findElectronsInSiStrips_cfi::trackCollection, DetId::Tracker, CoreSimTrack::trackId(), CoreSimTrack::type(), particleFlowSuperClusterECAL_cfi::vertexCollection, trackingTruthProducer_cfi::vertexDistanceCut, trackingTruthProducer_cfi::volumeRadius, volumeRadius_, trackingTruthProducer_cfi::volumeZ, and volumeZ_.

Referenced by accumulateEvent().

523 {
524  // loop over the collections
525  for( const auto& collectionTag : collectionTags_ )
526  {
528  event.getByLabel( collectionTag, hSimHits );
529 
530  // TODO - implement removing the dead modules
531  for( const auto& simHit : *hSimHits )
532  {
533  returnValue.push_back( &simHit );
534  }
535 
536  } // end of loop over InputTags
537 
538  // sort the SimHits according to their time of flight,
539  // necessary for looping over them "in order" in
540  // TrackingParticleFactory::createTrackingParticle()
541  std::sort(returnValue.begin(), returnValue.end(), [](const PSimHit *a, const PSimHit *b) {
542  const auto atof = edm::isFinite(a->timeOfFlight()) ? a->timeOfFlight() : std::numeric_limits<decltype(a->timeOfFlight())>::max();
543  const auto btof = edm::isFinite(b->timeOfFlight()) ? b->timeOfFlight() : std::numeric_limits<decltype(b->timeOfFlight())>::max();
544  return atof < btof;
545  });
546 }
bool isFinite(T x)
float timeOfFlight() const
Definition: PSimHit.h:69
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
std::vector< edm::InputTag > collectionTags_
void TrackingTruthAccumulator::finalizeEvent ( edm::Event event,
const edm::EventSetup setup 
)
privatevirtual

Definition at line 380 of file TrackingTruthAccumulator.cc.

References createInitialVertexCollection_, createMergedCollection_, createUnmergedCollection_, mergedOutput_, eostools::move(), pInitialVertices_, TrackingTruthAccumulator::OutputCollections::pTrackingParticles, TrackingTruthAccumulator::OutputCollections::pTrackingVertices, and unmergedOutput_.

381 {
382 
384  {
385  edm::LogInfo("TrackingTruthAccumulator") << "Adding " << unmergedOutput_.pTrackingParticles->size() << " TrackingParticles and " << unmergedOutput_.pTrackingVertices->size()
386  << " TrackingVertexs to the event.";
387 
390  }
391 
393  {
394  edm::LogInfo("TrackingTruthAccumulator") << "Adding " << mergedOutput_.pTrackingParticles->size() << " merged TrackingParticles and " << mergedOutput_.pTrackingVertices->size()
395  << " merged TrackingVertexs to the event.";
396 
397  event.put(std::move(mergedOutput_.pTrackingParticles), "MergedTrackTruth" );
398  event.put(std::move(mergedOutput_.pTrackingVertices), "MergedTrackTruth" );
399  }
400 
402  {
403  edm::LogInfo("TrackingTruthAccumulator") << "Adding " << pInitialVertices_->size() << " initial TrackingVertexs to the event.";
404 
405  event.put(std::move(pInitialVertices_), "InitialVertices" );
406  }
407 }
std::unique_ptr< TrackingParticleCollection > pTrackingParticles
std::unique_ptr< TrackingVertexCollection > pInitialVertices_
std::unique_ptr< TrackingVertexCollection > pTrackingVertices
const bool createInitialVertexCollection_
Whether or not to create a separate collection for just the initial interaction vertices.
const bool createUnmergedCollection_
If bremsstrahlung merging, whether to also add the unmerged collection to the event or not...
def move(src, dest)
Definition: eostools.py:510
void TrackingTruthAccumulator::initializeEvent ( const edm::Event event,
const edm::EventSetup setup 
)
privatevirtual

Definition at line 327 of file TrackingTruthAccumulator.cc.

References accumulate(), accumulateEvent(), PileUpEventPrincipal::bunchCrossing(), createInitialVertexCollection_, createMergedCollection_, createUnmergedCollection_, event(), hepMCproductLabel_, maximumPreviousBunchCrossing_, maximumSubsequentBunchCrossing_, mergedOutput_, messageCategory_, pInitialVertices_, TrackingTruthAccumulator::OutputCollections::pTrackingParticles, TrackingTruthAccumulator::OutputCollections::pTrackingVertices, TrackingTruthAccumulator::OutputCollections::refTrackingParticles, TrackingTruthAccumulator::OutputCollections::refTrackingVertexes, GeneralSetup::setup(), and unmergedOutput_.

328 {
330  {
333  unmergedOutput_.refTrackingParticles=const_cast<edm::Event&>( event ).getRefBeforePut<TrackingParticleCollection>();
334  unmergedOutput_.refTrackingVertexes=const_cast<edm::Event&>( event ).getRefBeforePut<TrackingVertexCollection>();
335  }
336 
338  {
341  mergedOutput_.refTrackingParticles=const_cast<edm::Event&>( event ).getRefBeforePut<TrackingParticleCollection>("MergedTrackTruth");
342  mergedOutput_.refTrackingVertexes=const_cast<edm::Event&>( event ).getRefBeforePut<TrackingVertexCollection>("MergedTrackTruth");
343  }
344 
346  {
348  }
349 }
std::unique_ptr< TrackingParticleCollection > pTrackingParticles
std::unique_ptr< TrackingVertexCollection > pInitialVertices_
std::unique_ptr< TrackingVertexCollection > pTrackingVertices
std::vector< TrackingParticle > TrackingParticleCollection
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const bool createInitialVertexCollection_
Whether or not to create a separate collection for just the initial interaction vertices.
std::vector< TrackingVertex > TrackingVertexCollection
const bool createUnmergedCollection_
If bremsstrahlung merging, whether to also add the unmerged collection to the event or not...

Member Data Documentation

const bool TrackingTruthAccumulator::addAncestors_
private

Whether or not to add the full parentage of any TrackingParticle that is inserted in the collection.

Definition at line 111 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent().

bool TrackingTruthAccumulator::allowDifferentProcessTypeForDifferentDetectors_
private

When counting hits, allows hits in different detectors to have a different process type.

Fast sim PSimHits seem to have a peculiarity where the process type (as reported by PSimHit::processType()) is different for the tracker than the muons. When counting how many hits there are, the code usually only counts the number of hits that have the same process type as the first hit. Setting this to true will also count hits that have the same process type as the first hit in the second detector.

Definition at line 136 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and fillSimHits().

bool TrackingTruthAccumulator::chargedOnly_
private

Uses the same config as selector_, but can be used to drop out early since selector_ requires the TrackingParticle to be created first.

Definition at line 125 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and TrackingTruthAccumulator().

std::vector<edm::InputTag> TrackingTruthAccumulator::collectionTags_
private

Definition at line 117 of file TrackingTruthAccumulator.h.

Referenced by fillSimHits(), and TrackingTruthAccumulator().

const bool TrackingTruthAccumulator::createInitialVertexCollection_
private

Whether or not to create a separate collection for just the initial interaction vertices.

Definition at line 109 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), initializeEvent(), and TrackingTruthAccumulator().

const bool TrackingTruthAccumulator::createMergedCollection_
private
const bool TrackingTruthAccumulator::createUnmergedCollection_
private

If bremsstrahlung merging, whether to also add the unmerged collection to the event or not.

Definition at line 106 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), initializeEvent(), and TrackingTruthAccumulator().

edm::InputTag TrackingTruthAccumulator::genParticleLabel_
private

Definition at line 118 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and TrackingTruthAccumulator().

edm::InputTag TrackingTruthAccumulator::hepMCproductLabel_
private

Needed to add HepMC::GenVertex to SimVertex.

Definition at line 120 of file TrackingTruthAccumulator.h.

Referenced by initializeEvent(), and TrackingTruthAccumulator().

const bool TrackingTruthAccumulator::ignoreTracksOutsideVolume_
private

Definition at line 97 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent().

const unsigned int TrackingTruthAccumulator::maximumPreviousBunchCrossing_
private

The maximum bunch crossing BEFORE the signal crossing to create TrackinParticles for. Use positive values. If set to zero no previous bunches are added and only in-time, signal and after bunches (defined by maximumSubsequentBunchCrossing_) are used.

Definition at line 101 of file TrackingTruthAccumulator.h.

Referenced by initializeEvent().

const unsigned int TrackingTruthAccumulator::maximumSubsequentBunchCrossing_
private

The maximum bunch crossing AFTER the signal crossing to create TrackinParticles for. E.g. if set to zero only uses the signal and in time pileup (and previous bunches defined by the maximumPreviousBunchCrossing_ parameter).

Definition at line 104 of file TrackingTruthAccumulator.h.

Referenced by initializeEvent().

OutputCollections TrackingTruthAccumulator::mergedOutput_
private

Definition at line 149 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

const std::string TrackingTruthAccumulator::messageCategory_
private

The message category used to send messages to MessageLogger.

Definition at line 91 of file TrackingTruthAccumulator.h.

Referenced by initializeEvent(), and TrackingTruthAccumulator().

std::unique_ptr<TrackingVertexCollection> TrackingTruthAccumulator::pInitialVertices_
private

Definition at line 150 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

const bool TrackingTruthAccumulator::removeDeadModules_
private

As of 11/Feb/2013 this option hasn't been implemented yet.

Definition at line 114 of file TrackingTruthAccumulator.h.

TrackingParticleSelector TrackingTruthAccumulator::selector_
private

Definition at line 123 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and TrackingTruthAccumulator().

bool TrackingTruthAccumulator::selectorFlag_
private

Definition at line 122 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and TrackingTruthAccumulator().

bool TrackingTruthAccumulator::signalOnly_
private

Uses the same config as selector_, but can be used to drop out early since selector_ requires the TrackingParticle to be created first.

Definition at line 127 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and TrackingTruthAccumulator().

const edm::InputTag TrackingTruthAccumulator::simTrackLabel_
private

Definition at line 115 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and TrackingTruthAccumulator().

const edm::InputTag TrackingTruthAccumulator::simVertexLabel_
private

Definition at line 116 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and TrackingTruthAccumulator().

OutputCollections TrackingTruthAccumulator::unmergedOutput_
private

Definition at line 148 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), finalizeEvent(), and initializeEvent().

const double TrackingTruthAccumulator::vertexDistanceCut_
private

maximum distance for HepMC::GenVertex to be added to SimVertex

Definition at line 96 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent().

const double TrackingTruthAccumulator::volumeRadius_
private

Definition at line 93 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and fillSimHits().

const double TrackingTruthAccumulator::volumeZ_
private

Definition at line 94 of file TrackingTruthAccumulator.h.

Referenced by accumulateEvent(), and fillSimHits().