CMS 3D CMS Logo

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

#include <SimTracker/TrackAssociatorProducers/plugins/QuickTrackAssociatorByHitsProducer.cc>

Inheritance diagram for QuickTrackAssociatorByHitsProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 QuickTrackAssociatorByHitsProducer (const edm::ParameterSet &)
 
 ~QuickTrackAssociatorByHitsProducer ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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
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 ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
virtual void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

bool absoluteNumberOfHits_
 
edm::EDGetTokenT
< ClusterTPAssociationList
cluster2TPToken_
 
double cutRecoToSim_
 
edm::ParameterSet hitAssociatorParameters_
 
double puritySimToReco_
 
double qualitySimToReco_
 
QuickTrackAssociatorByHitsImpl::SimToRecoDenomType simToRecoDenominator_
 
bool threeHitTracksAreSpecial_
 
bool useClusterTPAssociation_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 46 of file QuickTrackAssociatorByHitsProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 83 of file QuickTrackAssociatorByHitsProducer.cc.

References edm::ParameterSet::addParameter(), cluster2TPToken_, edm::EDConsumerBase::consumesCollector(), QuickTrackAssociatorByHitsImpl::denomreco, QuickTrackAssociatorByHitsImpl::denomsim, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), hitAssociatorParameters_, LogDebug, simToRecoDenominator_, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and useClusterTPAssociation_.

83  :
84  qualitySimToReco_( iConfig.getParameter<double>( "Quality_SimToReco" ) ),
85  puritySimToReco_( iConfig.getParameter<double>( "Purity_SimToReco" ) ),
86  cutRecoToSim_( iConfig.getParameter<double>( "Cut_RecoToSim" ) ),
87  threeHitTracksAreSpecial_( iConfig.getParameter<bool>( "ThreeHitTracksAreSpecial" ) ),
88  useClusterTPAssociation_( iConfig.getParameter<bool>( "useClusterTPAssociation" ) ),
89  absoluteNumberOfHits_( iConfig.getParameter<bool>( "AbsoluteNumberOfHits" ) )
90 {
91 
92  //
93  // Check whether the denominator when working out the percentage of shared hits should
94  // be the number of simulated hits or the number of reconstructed hits.
95  //
96  std::string denominatorString=iConfig.getParameter<std::string>("SimToRecoDenominator");
98  else if( denominatorString=="reco" ) simToRecoDenominator_=QuickTrackAssociatorByHitsImpl::denomreco;
99  else throw cms::Exception( "QuickTrackAssociatorByHitsImpl" ) << "SimToRecoDenominator not specified as sim or reco";
100 
101  //
102  // Set up the parameter set for the hit associator
103  //
104  hitAssociatorParameters_.addParameter<bool>( "associatePixel", iConfig.getParameter<bool>("associatePixel") );
105  hitAssociatorParameters_.addParameter<bool>( "associateStrip", iConfig.getParameter<bool>("associateStrip") );
106  // This is the important one, it stops the hit associator searching through the list of sim hits.
107  // I only want to use the hit associator methods that work on the hit IDs (i.e. the uint32_t trackId
108  // and the EncodedEventId eventId) so I'm not interested in matching that to the PSimHit objects.
109  hitAssociatorParameters_.addParameter<bool>("associateRecoTracks",true);
110 
112 
113  //
114  // Do some checks on whether UseGrouped or UseSplitting have been set. They're not used
115  // unlike the standard TrackAssociatorByHits so show a warning.
116  //
117  bool useGrouped, useSplitting;
118  if( iConfig.exists("UseGrouped") ) useGrouped=iConfig.getParameter<bool>("UseGrouped");
119  else useGrouped=true;
120 
121  if( iConfig.exists("UseSplitting") ) useSplitting=iConfig.getParameter<bool>("UseSplitting");
122  else useSplitting=true;
123 
124  // This associator works as though both UseGrouped and UseSplitting were set to true, so show a
125  // warning if this isn't the case.
126  if( !(useGrouped && useSplitting) )
127  {
128  LogDebug("QuickTrackAssociatorByHitsImpl") << "UseGrouped and/or UseSplitting has been set to false, but this associator ignores that setting.";
129  }
130 
131  //register your products
132  produces<reco::TrackToTrackingParticleAssociator>();
133 
135  cluster2TPToken_ = consumes<ClusterTPAssociationList>(iConfig.getParameter < edm::InputTag > ("cluster2TPSrc"));
136  }
137 
138 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:143
edm::EDGetTokenT< ClusterTPAssociationList > cluster2TPToken_
QuickTrackAssociatorByHitsImpl::SimToRecoDenomType simToRecoDenominator_
QuickTrackAssociatorByHitsProducer::~QuickTrackAssociatorByHitsProducer ( )

Definition at line 141 of file QuickTrackAssociatorByHitsProducer.cc.

142 {
143 
144  // do anything here that needs to be done at desctruction time
145  // (e.g. close files, deallocate resources etc.)
146 
147 }

Member Function Documentation

void QuickTrackAssociatorByHitsProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 197 of file QuickTrackAssociatorByHitsProducer.cc.

198 {
199 }
void QuickTrackAssociatorByHitsProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 203 of file QuickTrackAssociatorByHitsProducer.cc.

203  {
204 }
void QuickTrackAssociatorByHitsProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 209 of file QuickTrackAssociatorByHitsProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

209  {
210  //The following says we do not know what parameters are allowed so do no validation
211  // Please change this to state exactly what you do use, even if it is no parameters
213  desc.setUnknown();
214  descriptions.addDefault(desc);
215 }
void addDefault(ParameterSetDescription const &psetDescription)
void QuickTrackAssociatorByHitsProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 156 of file QuickTrackAssociatorByHitsProducer.cc.

References absoluteNumberOfHits_, cluster2TPToken_, clusterTPAssociationListGreater(), cutRecoToSim_, edm::Event::getByToken(), hitAssociatorParameters_, iEvent, edm::HandleBase::isValid(), eostools::move(), puritySimToReco_, edm::Event::put(), qualitySimToReco_, simToRecoDenominator_, python.multivaluedict::sort(), threeHitTracksAreSpecial_, convertXMLtoSQLite_cfg::toPut, and useClusterTPAssociation_.

157 {
158  using namespace edm;
159 
160  std::shared_ptr<ClusterTPAssociationList> clusterAssoc;
161  std::shared_ptr<TrackerHitAssociator> trackAssoc;
163  edm::Handle<ClusterTPAssociationList> clusterAssocHandle;
164  iEvent.getByToken(cluster2TPToken_,clusterAssocHandle);
165 
166  if(clusterAssocHandle.isValid()) {
167  clusterAssoc = std::make_shared<ClusterTPAssociationList>(*clusterAssocHandle);
168 
169  //make sure it is properly sorted
170  std::sort(clusterAssoc->begin(),clusterAssoc->end(),clusterTPAssociationListGreater);
171  } else {
172  edm::LogInfo( "TrackAssociator" ) << "ClusterTPAssociationList not found. Using DigiSimLink based associator";
173  }
174  }
175  if(not clusterAssoc) {
176  // If control got this far then either useClusterTPAssociation_ was false or getting the cluster
177  // to TrackingParticle association from the event failed. Either way I need to create a hit associator.
178  trackAssoc = std::make_shared<TrackerHitAssociator>(iEvent, hitAssociatorParameters_);
179  }
180 
181  std::unique_ptr<reco::TrackToTrackingParticleAssociatorBaseImpl> impl(
183  std::move(clusterAssoc),
190 
191  std::unique_ptr<reco::TrackToTrackingParticleAssociator> toPut( new reco::TrackToTrackingParticleAssociator(std::move(impl)));
192  iEvent.put(std::move(toPut));
193 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
def move
Definition: eostools.py:508
edm::EDGetTokenT< ClusterTPAssociationList > cluster2TPToken_
bool isValid() const
Definition: HandleBase.h:75
bool clusterTPAssociationListGreater(std::pair< OmniClusterRef, TrackingParticleRef > i, std::pair< OmniClusterRef, TrackingParticleRef > j)
TrackToTrackingParticleAssociator that associates by hits a bit quicker than the normal TrackAssociat...
QuickTrackAssociatorByHitsImpl::SimToRecoDenomType simToRecoDenominator_

Member Data Documentation

bool QuickTrackAssociatorByHitsProducer::absoluteNumberOfHits_
private

Definition at line 67 of file QuickTrackAssociatorByHitsProducer.cc.

Referenced by produce().

edm::EDGetTokenT<ClusterTPAssociationList> QuickTrackAssociatorByHitsProducer::cluster2TPToken_
private
double QuickTrackAssociatorByHitsProducer::cutRecoToSim_
private

Definition at line 63 of file QuickTrackAssociatorByHitsProducer.cc.

Referenced by produce().

edm::ParameterSet QuickTrackAssociatorByHitsProducer::hitAssociatorParameters_
private
double QuickTrackAssociatorByHitsProducer::puritySimToReco_
private

Definition at line 62 of file QuickTrackAssociatorByHitsProducer.cc.

Referenced by produce().

double QuickTrackAssociatorByHitsProducer::qualitySimToReco_
private

Definition at line 61 of file QuickTrackAssociatorByHitsProducer.cc.

Referenced by produce().

QuickTrackAssociatorByHitsImpl::SimToRecoDenomType QuickTrackAssociatorByHitsProducer::simToRecoDenominator_
private
bool QuickTrackAssociatorByHitsProducer::threeHitTracksAreSpecial_
private

Definition at line 65 of file QuickTrackAssociatorByHitsProducer.cc.

Referenced by produce().

bool QuickTrackAssociatorByHitsProducer::useClusterTPAssociation_
private