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 Attributes
SimTrackIdProducer Class Reference

#include <FastSimulation/SimTrackIdProducer/plugins/SimTrackIdProducer.cc>

Inheritance diagram for SimTrackIdProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &es) override
 
 SimTrackIdProducer (const edm::ParameterSet &conf)
 
virtual ~SimTrackIdProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool filterTracks_ = false
 
double maxChi2_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap< int > > > 
overrideTrkQuals_
 
reco::TrackBase::TrackQuality trackQuality_
 
edm::EDGetTokenT
< reco::TrackCollection
trackToken
 

Additional Inherited Members

- 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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: the class finds Ids of SimTracks by looping over all reco tracks, looking for a recHit in it, reading out the Id of the track, and storing it in SimTrackIds vector.

Definition at line 19 of file SimTrackIdProducer.h.

Constructor & Destructor Documentation

SimTrackIdProducer::SimTrackIdProducer ( const edm::ParameterSet conf)
explicit

Definition at line 30 of file SimTrackIdProducer.cc.

References edm::EDConsumerBase::consumes(), edm::ParameterSet::exists(), filterTracks_, edm::ParameterSet::getParameter(), maxChi2_, HLT_25ns14e33_v1_cff::overrideTrkQuals, overrideTrkQuals_, reco::TrackBase::qualityByName(), AlCaHLTBitMon_QueryRunRegistry::string, HLT_25ns14e33_v1_cff::trackQuality, trackQuality_, trackToken, and reco::TrackBase::undefQuality.

31 {
32  //Main products
33  produces<std::vector<unsigned int> >();
34 
35  // Input Tag
36  edm::InputTag trackCollectionTag = conf.getParameter<edm::InputTag>("trackCollection");
37 
38  maxChi2_ = conf.getParameter<double>("maxChi2");
39 
40 
41  if (conf.exists("overrideTrkQuals")) {
42  edm::InputTag overrideTrkQuals = conf.getParameter<edm::InputTag>("overrideTrkQuals");
43  if ( !(overrideTrkQuals==edm::InputTag("")) )
44  overrideTrkQuals_.push_back( consumes<edm::ValueMap<int> >(overrideTrkQuals) );
45  }
47  filterTracks_=false;
48  if (conf.exists("TrackQuality")){
49  filterTracks_=true;
50  std::string trackQuality = conf.getParameter<std::string>("TrackQuality");
51  if ( !trackQuality.empty() ) {
53  }
54  }
55 
56  // consumes
57  trackToken = consumes<reco::TrackCollection>(trackCollectionTag);
58 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > trackToken
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > overrideTrkQuals_
reco::TrackBase::TrackQuality trackQuality_
bool exists(std::string const &parameterName) const
checks if a parameter exists
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:123
virtual SimTrackIdProducer::~SimTrackIdProducer ( )
inlinevirtual

Definition at line 25 of file SimTrackIdProducer.h.

25 {}

Member Function Documentation

void SimTrackIdProducer::produce ( edm::Event e,
const edm::EventSetup es 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 61 of file SimTrackIdProducer.cc.

References reco::TrackBase::chi2(), filterTracks_, edm::Event::getByToken(), i, maxChi2_, overrideTrkQuals_, edm::Event::put(), reco::TrackBase::quality(), reco::Track::recHitsBegin(), SiTrackerGSMatchedRecHit2D::simtrackId(), HLT_25ns14e33_v3_cff::trackCollection, trackQuality_, and trackToken.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

62 {
63  // The produced object
64  std::auto_ptr<std::vector<unsigned int> > SimTrackIds(new std::vector<unsigned int>());
65 
66  // The input track collection handle
68  e.getByToken(trackToken,trackCollection);
69 
70  std::vector<edm::Handle<edm::ValueMap<int> > > quals;
71  if ( overrideTrkQuals_.size() > 0) {
72  quals.resize(1);
73  e.getByToken(overrideTrkQuals_[0],quals[0]);
74  }
75 
76  for (size_t i = 0 ; i!=trackCollection->size();++i)
77  {
78  const reco::Track & track = trackCollection->at(i);
79  reco::TrackRef trackRef(trackCollection,i);
80  if (filterTracks_) {
81  bool goodTk = true;
82 
83  if ( quals.size()!=0) {
84  int qual=(*(quals[0]))[trackRef];
85  //std::cout << qual << std::endl;
86  if ( qual < 0 ) {goodTk=false;}
87  //note that this does not work for some trackquals (goodIterative or undefQuality)
88  else
89  goodTk = ( qual & (1<<trackQuality_))>>trackQuality_;
90  }
91  else
92  goodTk=(track.quality(trackQuality_));
93  if ( !goodTk) continue;
94  }
95  if(track.chi2()>maxChi2_) continue ;
96 
97  const TrackingRecHit * hit = *(track.recHitsBegin());
98  if (hit)
99  {
100  const SiTrackerGSMatchedRecHit2D* fsimhit = dynamic_cast<const SiTrackerGSMatchedRecHit2D*>(hit);
101  if (fsimhit)
102  {
103  SimTrackIds->push_back(fsimhit->simtrackId());
104  }
105  }
106 
107  }
108  e.put(SimTrackIds);
109 }
edm::EDGetTokenT< reco::TrackCollection > trackToken
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > overrideTrkQuals_
reco::TrackBase::TrackQuality trackQuality_
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:512
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:473

Member Data Documentation

bool SimTrackIdProducer::filterTracks_ = false
private

Definition at line 36 of file SimTrackIdProducer.h.

Referenced by produce(), and SimTrackIdProducer().

double SimTrackIdProducer::maxChi2_
private

Definition at line 34 of file SimTrackIdProducer.h.

Referenced by produce(), and SimTrackIdProducer().

std::vector< edm::EDGetTokenT<edm::ValueMap<int> > > SimTrackIdProducer::overrideTrkQuals_
private

Definition at line 35 of file SimTrackIdProducer.h.

Referenced by produce(), and SimTrackIdProducer().

reco::TrackBase::TrackQuality SimTrackIdProducer::trackQuality_
private

Definition at line 37 of file SimTrackIdProducer.h.

Referenced by produce(), and SimTrackIdProducer().

edm::EDGetTokenT<reco::TrackCollection> SimTrackIdProducer::trackToken
private

Definition at line 33 of file SimTrackIdProducer.h.

Referenced by produce(), and SimTrackIdProducer().