CMS 3D CMS Logo

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

#include <Alignment/CommonAlignmentProducer/plugins/AlignmentMuonHIPTrajectorySelector.cc>

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

Public Member Functions

 AlignmentMuonHIPTrajectorySelector (const edm::ParameterSet &)
 
 ~AlignmentMuonHIPTrajectorySelector () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool m_hists
 
edm::InputTag m_input
 
double m_maxMuonResidual
 
double m_maxTrackerForwardRedChi2
 
double m_minPt
 
int m_minTrackerDOF
 
TH1F * m_pt
 
TH1F * m_resid_after
 
TH1F * m_resid_before
 
TH1F * m_tracker_dof
 
TH1F * m_tracker_forwardredchi2
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

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

Definition at line 54 of file AlignmentMuonHIPTrajectorySelector.cc.

Constructor & Destructor Documentation

◆ AlignmentMuonHIPTrajectorySelector()

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

Definition at line 85 of file AlignmentMuonHIPTrajectorySelector.cc.

86  : m_input(iConfig.getParameter<edm::InputTag>("input")),
87  m_minPt(iConfig.getParameter<double>("minPt")),
88  m_maxTrackerForwardRedChi2(iConfig.getParameter<double>("maxTrackerForwardRedChi2")),
89  m_minTrackerDOF(iConfig.getParameter<int>("minTrackerDOF")),
90  m_maxMuonResidual(iConfig.getParameter<double>("maxMuonResidual")),
91  m_hists(iConfig.getParameter<bool>("hists")),
92  m_pt(nullptr),
93  m_tracker_forwardredchi2(nullptr),
94  m_tracker_dof(nullptr) {
95  produces<TrajTrackAssociationCollection>();
96 
97  if (m_hists) {
99  m_pt = fs->make<TH1F>("pt", "Transverse momentum (GeV)", 100, 0., 100.);
101  fs->make<TH1F>("trackerForwardRedChi2", "forward-biased reduced chi2 in tracker", 100, 0., 5.);
102  m_tracker_dof = fs->make<TH1F>("trackerDOF", "DOF in tracker", 61, -0.5, 60.5);
103  m_resid_before = fs->make<TH1F>("residBefore", "muon residuals before cut (cm)", 100, -20, 20);
104  m_resid_after = fs->make<TH1F>("residAfter", "muon residuals after cut (cm)", 100, -20, 20);
105  }
106 }

References m_hists, m_pt, m_resid_after, m_resid_before, m_tracker_dof, m_tracker_forwardredchi2, and TFileService::make().

◆ ~AlignmentMuonHIPTrajectorySelector()

AlignmentMuonHIPTrajectorySelector::~AlignmentMuonHIPTrajectorySelector ( )
override

Definition at line 108 of file AlignmentMuonHIPTrajectorySelector.cc.

108 {}

Member Function Documentation

◆ produce()

void AlignmentMuonHIPTrajectorySelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 115 of file AlignmentMuonHIPTrajectorySelector.cc.

115  {
116  // input
117  edm::Handle<TrajTrackAssociationCollection> originalTrajTrackMap;
118  iEvent.getByLabel(m_input, originalTrajTrackMap);
119 
120  // output
121  auto newTrajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
122 
123  TrajectoryStateCombiner tsoscomb;
124 
125  for (TrajTrackAssociationCollection::const_iterator iPair = originalTrajTrackMap->begin();
126  iPair != originalTrajTrackMap->end();
127  ++iPair) {
128  if (m_hists) {
129  m_pt->Fill((*(*iPair).val).pt());
130  }
131 
132  if ((*(*iPair).val).pt() > m_minPt) {
133  std::vector<TrajectoryMeasurement> measurements = (*(*iPair).key).measurements();
134 
135  bool has_bad_residual = false;
136 
137  double tracker_forwardchi2 = 0.;
138  double tracker_dof = 0.;
139  for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end();
140  ++im) {
141  const TrajectoryMeasurement meas = *im;
142  auto hit = &(*meas.recHit());
143  const DetId id = hit->geographicalId();
144 
145  if (hit->isValid() && id.det() == DetId::Tracker) {
146  if (hit->dimension() == 1) {
147  double residual = meas.forwardPredictedState().localPosition().x() - hit->localPosition().x();
148  double error2 =
149  meas.forwardPredictedState().localError().positionError().xx() + hit->localPositionError().xx();
150 
151  tracker_forwardchi2 += residual * residual / error2;
152  tracker_dof += 1.;
153  } else if (hit->dimension() == 2) {
154  double residualx = meas.forwardPredictedState().localPosition().x() - hit->localPosition().x();
155  double residualy = meas.forwardPredictedState().localPosition().y() - hit->localPosition().y();
156  double errorxx2 =
157  meas.forwardPredictedState().localError().positionError().xx() + hit->localPositionError().xx();
158  double errorxy2 =
159  meas.forwardPredictedState().localError().positionError().xy() + hit->localPositionError().xy();
160  double erroryy2 =
161  meas.forwardPredictedState().localError().positionError().yy() + hit->localPositionError().yy();
162 
163  tracker_forwardchi2 +=
164  (residualx * residualx + residualy * residualy) / (errorxx2 + 2. * errorxy2 + erroryy2);
165  tracker_dof += 2.;
166  }
167  } // end if a tracker hit
168 
169  if (hit->isValid() && id.det() == DetId::Muon &&
170  (id.subdetId() == MuonSubdetId::DT || id.subdetId() == MuonSubdetId::CSC)) {
172  tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
173  double residual = tsosc.localPosition().x() - hit->localPosition().x();
174  m_resid_before->Fill(residual);
175  if (fabs(residual) > m_maxMuonResidual) {
176  has_bad_residual = true;
177  }
178  } // end if a muon hit
179  }
180  tracker_dof -= 5.;
181  double tracker_forwardredchi2 = tracker_forwardchi2 / tracker_dof;
182 
183  if (m_hists) {
184  m_tracker_forwardredchi2->Fill(tracker_forwardredchi2);
185  m_tracker_dof->Fill(tracker_dof);
186 
187  for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end();
188  ++im) {
189  const TrajectoryMeasurement meas = *im;
190  auto hit = &(*meas.recHit());
191  const DetId id = hit->geographicalId();
192 
193  if (!has_bad_residual) {
194  if (hit->isValid() && id.det() == DetId::Muon &&
195  (id.subdetId() == MuonSubdetId::DT || id.subdetId() == MuonSubdetId::CSC)) {
197  tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
198  double residual = tsosc.localPosition().x() - hit->localPosition().x();
199  m_resid_after->Fill(residual);
200  }
201  } // end if residuals pass cut
202  } // end second loop over hits
203  } // end if filling histograms
204 
205  if (tracker_forwardredchi2 < m_maxTrackerForwardRedChi2 && tracker_dof >= m_minTrackerDOF && !has_bad_residual) {
206  newTrajTrackMap->insert((*iPair).key, (*iPair).val);
207  } // end if passes tracker cuts
208  } // end if passes pT cut
209  } // end loop over original trajTrackMap
210 
211  // put it in the Event
212  iEvent.put(std::move(newTrajTrackMap));
213 }

References TrajectoryMeasurement::backwardPredictedState(), edm::AssociationMap< Tag >::begin(), TrajectoryStateCombiner::combine(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, MuonSubdetId::CSC, MuonSubdetId::DT, edm::AssociationMap< Tag >::end(), TrajectoryMeasurement::forwardPredictedState(), iEvent, TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localPosition(), m_hists, m_input, m_maxMuonResidual, m_minPt, m_minTrackerDOF, m_pt, m_resid_after, m_resid_before, m_tracker_dof, m_tracker_forwardredchi2, eostools::move(), DetId::Muon, LocalTrajectoryError::positionError(), TrajectoryMeasurement::recHit(), DetId::Tracker, PV3DBase< T, PVType, FrameType >::x(), hit::x, LocalError::xx(), LocalError::xy(), PV3DBase< T, PVType, FrameType >::y(), hit::y, and LocalError::yy().

Member Data Documentation

◆ m_hists

bool AlignmentMuonHIPTrajectorySelector::m_hists
private

◆ m_input

edm::InputTag AlignmentMuonHIPTrajectorySelector::m_input
private

Definition at line 63 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

◆ m_maxMuonResidual

double AlignmentMuonHIPTrajectorySelector::m_maxMuonResidual
private

Definition at line 67 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

◆ m_maxTrackerForwardRedChi2

double AlignmentMuonHIPTrajectorySelector::m_maxTrackerForwardRedChi2
private

Definition at line 65 of file AlignmentMuonHIPTrajectorySelector.cc.

◆ m_minPt

double AlignmentMuonHIPTrajectorySelector::m_minPt
private

Definition at line 64 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

◆ m_minTrackerDOF

int AlignmentMuonHIPTrajectorySelector::m_minTrackerDOF
private

Definition at line 66 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

◆ m_pt

TH1F* AlignmentMuonHIPTrajectorySelector::m_pt
private

◆ m_resid_after

TH1F * AlignmentMuonHIPTrajectorySelector::m_resid_after
private

◆ m_resid_before

TH1F* AlignmentMuonHIPTrajectorySelector::m_resid_before
private

◆ m_tracker_dof

TH1F * AlignmentMuonHIPTrajectorySelector::m_tracker_dof
private

◆ m_tracker_forwardredchi2

TH1F * AlignmentMuonHIPTrajectorySelector::m_tracker_forwardredchi2
private
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
hit::y
double y
Definition: SiStripHitEffFromCalibTree.cc:90
LocalTrajectoryError::positionError
LocalError positionError() const
Definition: LocalTrajectoryError.h:81
LocalError::xy
float xy() const
Definition: LocalError.h:23
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
AlignmentMuonHIPTrajectorySelector::m_input
edm::InputTag m_input
Definition: AlignmentMuonHIPTrajectorySelector.cc:63
edm::Handle
Definition: AssociativeIterator.h:50
hit::x
double x
Definition: SiStripHitEffFromCalibTree.cc:89
DetId
Definition: DetId.h:17
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
AlignmentMuonHIPTrajectorySelector::m_maxTrackerForwardRedChi2
double m_maxTrackerForwardRedChi2
Definition: AlignmentMuonHIPTrajectorySelector.cc:65
AlignmentMuonHIPTrajectorySelector::m_tracker_forwardredchi2
TH1F * m_tracker_forwardredchi2
Definition: AlignmentMuonHIPTrajectorySelector.cc:70
TrajectoryMeasurement::backwardPredictedState
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
Definition: TrajectoryMeasurement.h:179
LocalError::xx
float xx() const
Definition: LocalError.h:22
TrajectoryMeasurement::forwardPredictedState
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
Definition: TrajectoryMeasurement.h:177
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
AlignmentMuonHIPTrajectorySelector::m_pt
TH1F * m_pt
Definition: AlignmentMuonHIPTrajectorySelector.cc:70
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
TrajectoryStateCombiner
Definition: TrajectoryStateCombiner.h:13
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
DetId::Tracker
Definition: DetId.h:25
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
AlignmentMuonHIPTrajectorySelector::m_maxMuonResidual
double m_maxMuonResidual
Definition: AlignmentMuonHIPTrajectorySelector.cc:67
AlignmentMuonHIPTrajectorySelector::m_minTrackerDOF
int m_minTrackerDOF
Definition: AlignmentMuonHIPTrajectorySelector.cc:66
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::AssociationMap::begin
const_iterator begin() const
first iterator over the map (read only)
Definition: AssociationMap.h:169
TrajectoryStateCombiner::combine
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
Definition: TrajectoryStateCombiner.cc:6
AlignmentMuonHIPTrajectorySelector::m_resid_after
TH1F * m_resid_after
Definition: AlignmentMuonHIPTrajectorySelector.cc:71
AlignmentMuonHIPTrajectorySelector::m_minPt
double m_minPt
Definition: AlignmentMuonHIPTrajectorySelector.cc:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentMuonHIPTrajectorySelector::m_resid_before
TH1F * m_resid_before
Definition: AlignmentMuonHIPTrajectorySelector.cc:71
DetId::Muon
Definition: DetId.h:26
AlignmentMuonHIPTrajectorySelector::m_tracker_dof
TH1F * m_tracker_dof
Definition: AlignmentMuonHIPTrajectorySelector.cc:70
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
LocalError::yy
float yy() const
Definition: LocalError.h:24
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
AlignmentMuonHIPTrajectorySelector::m_hists
bool m_hists
Definition: AlignmentMuonHIPTrajectorySelector.cc:69