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 Types | Private Member Functions | Private Attributes
MuonCaloDistanceProducer Class Reference

#include <MuonCaloDistanceProducer.h>

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

Public Member Functions

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

Private Types

typedef std::map< uint32_t, float > detIdToFloatMap
 

Private Member Functions

void fillDistanceMap (edm::Event &, const edm::EventSetup &, const reco::Candidate *, detIdToFloatMap &, detIdToFloatMap &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag srcSelectedMuons_
 
TrackDetectorAssociator trackAssociator_
 
TrackAssociatorParameters trackAssociatorParameters_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Compute distance traversed by muon through calorimeter cells.

NOTE: The output of this class is used as input for MuonCaloCleanerByDistance.

Author
Tomasz Maciej Frueboes; Christian Veelken, LLR
Version
Revision:
1.3
Id:
MuonCaloDistanceProducer.h,v 1.3 2013/01/30 10:10:49 aburgmei Exp

Definition at line 30 of file MuonCaloDistanceProducer.h.

Member Typedef Documentation

typedef std::map<uint32_t, float> MuonCaloDistanceProducer::detIdToFloatMap
private

Definition at line 39 of file MuonCaloDistanceProducer.h.

Constructor & Destructor Documentation

MuonCaloDistanceProducer::MuonCaloDistanceProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 24 of file MuonCaloDistanceProducer.cc.

References edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::getParameter(), TrackAssociatorParameters::loadParameters(), trackAssociator_, trackAssociatorParameters_, and TrackDetectorAssociator::useDefaultPropagator().

25  : srcSelectedMuons_(cfg.getParameter<edm::InputTag>("selectedMuons"))
26 {
27  // maps of detId to distance traversed by muon through detector volume
28  produces<reco::CandidateCollection>("muons");
29  produces<detIdToFloatMap>("distancesMuPlus");
30  produces<detIdToFloatMap>("distancesMuMinus");
31  produces<detIdToFloatMap>("depositsMuPlus");
32  produces<detIdToFloatMap>("depositsMuMinus");
33 
34  edm::ParameterSet cfgTrackAssociator = cfg.getParameter<edm::ParameterSet>("trackAssociator");
36  trackAssociatorParameters_.loadParameters(cfgTrackAssociator, iC);
38 }
T getParameter(std::string const &) const
void useDefaultPropagator()
use the default propagator
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters trackAssociatorParameters_
MuonCaloDistanceProducer::~MuonCaloDistanceProducer ( )

Definition at line 40 of file MuonCaloDistanceProducer.cc.

41 {
42 // nothing to be done yet...
43 }

Member Function Documentation

void MuonCaloDistanceProducer::fillDistanceMap ( edm::Event evt,
const edm::EventSetup es,
const reco::Candidate muon,
detIdToFloatMap distanceMap,
detIdToFloatMap depositMap 
)
private

Definition at line 75 of file MuonCaloDistanceProducer.cc.

References assert(), TrackDetMatchInfo::crossedEcalIds, TrackDetMatchInfo::crossedEcalRecHits, TrackDetMatchInfo::crossedHcalIds, TrackDetMatchInfo::crossedHcalRecHits, TrackDetMatchInfo::crossedHOIds, TrackDetMatchInfo::crossedHORecHits, TrackDetMatchInfo::crossedPreshowerIds, CaloRecHit::detid(), EcalRecHit::detid(), CaloRecHit::energy(), EcalRecHit::energy(), edm::EventSetup::get(), TrackDetectorAssociator::getCachedTrajector(), CachedTrajectory::getEcalTrajectory(), CaloSubdetectorGeometry::getGeometry(), CachedTrajectory::getHcalTrajectory(), CachedTrajectory::getHOTrajectory(), CachedTrajectory::getPreshowerTrajectory(), getTrackDetMatchInfo(), CaloCellGeometry::inside(), point, DetId::rawId(), mathSSE::sqrt(), trackAssociator_, trackAssociatorParameters_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

76 {
78 
79  BOOST_FOREACH(const EcalRecHit * rh, trackDetMatchInfo.crossedEcalRecHits)
80  depositMap[rh->detid().rawId()]+=rh->energy();
81 
82  BOOST_FOREACH(const HBHERecHit * rh, trackDetMatchInfo.crossedHcalRecHits)
83  depositMap[rh->detid().rawId()]+=rh->energy();
84 
85  BOOST_FOREACH(const HORecHit * rh, trackDetMatchInfo.crossedHORecHits)
86  depositMap[rh->detid().rawId()]+=rh->energy();
87 
88  typedef std::map<std::string, const std::vector<DetId>*> CaloToDetIdMap;
89  CaloToDetIdMap caloToDetIdMap;
90  caloToDetIdMap["ecal"] = &(trackDetMatchInfo.crossedEcalIds);
91  caloToDetIdMap["hcal"] = &(trackDetMatchInfo.crossedHcalIds);
92  caloToDetIdMap["ho"] = &(trackDetMatchInfo.crossedHOIds);
93  caloToDetIdMap["es"] = &(trackDetMatchInfo.crossedPreshowerIds);
94 
95  edm::ESHandle<CaloGeometry> caloGeo;
96  es.get<CaloGeometryRecord>().get(caloGeo);
97 
98  for ( CaloToDetIdMap::const_iterator caloToDetIdEntry = caloToDetIdMap.begin();
99  caloToDetIdEntry != caloToDetIdMap.end(); ++caloToDetIdEntry ) {
100  std::vector<SteppingHelixStateInfo>::const_iterator itHelixState_first, itHelixState_last;
101  if ( caloToDetIdEntry->first == "ecal" ) {
102  itHelixState_first = trackAssociator_.getCachedTrajector().getEcalTrajectory().begin();
103  itHelixState_last = trackAssociator_.getCachedTrajector().getEcalTrajectory().end();
104  } else if ( caloToDetIdEntry->first == "hcal" ) {
105  itHelixState_first = trackAssociator_.getCachedTrajector().getHcalTrajectory().begin();
106  itHelixState_last = trackAssociator_.getCachedTrajector().getHcalTrajectory().end();
107  } else if ( caloToDetIdEntry->first == "ho" ) {
108  itHelixState_first = trackAssociator_.getCachedTrajector().getHOTrajectory().begin();
109  itHelixState_last = trackAssociator_.getCachedTrajector().getHOTrajectory().end();
110  } else if ( caloToDetIdEntry->first == "es" ) {
111  itHelixState_first = trackAssociator_.getCachedTrajector().getPreshowerTrajectory().begin();
112  itHelixState_last = trackAssociator_.getCachedTrajector().getPreshowerTrajectory().end();
113  } else assert(0);
114 
115  // copy trajectory points
116  std::vector<GlobalPoint> trajectory;
117  for ( std::vector<SteppingHelixStateInfo>::const_iterator helixState = itHelixState_first;
118  helixState != itHelixState_last; ++helixState ) {
119  trajectory.push_back(helixState->position());
120  }
121 
122  // iterate over crossed detIds
123  for ( std::vector<DetId>::const_iterator detId = caloToDetIdEntry->second->begin();
124  detId != caloToDetIdEntry->second->end(); ++detId ) {
125  if ( detId->rawId() == 0 ) continue;
126 
127  const CaloSubdetectorGeometry* subDetGeo = caloGeo->getSubdetectorGeometry(*detId);
128  const CaloCellGeometry* caloCellGeo = subDetGeo->getGeometry(*detId);
129  GlobalPoint previousPoint;
130  bool previousPoint_initialized;
131  float distanceWithinDetId = 0;
132  for ( std::vector<GlobalPoint>::const_iterator point = trajectory.begin();
133  point != trajectory.end(); ++point ) {
134  if ( previousPoint_initialized ) {
135  float dx = point->x() - previousPoint.x();
136  float dy = point->y() - previousPoint.y();
137  float dz = point->z() - previousPoint.z();
138  float distanceBetweenPoints = sqrt(dx*dx + dy*dy + dz*dz);
139  int numSteps = 100;
140  int numStepsWithinDetId = 0;
141  for ( int iStep = 0; iStep <= numSteps; ++iStep ){
142  float stepX = previousPoint.x() + iStep*dx/numSteps;
143  float stepY = previousPoint.y() + iStep*dy/numSteps;
144  float stepZ = previousPoint.z() + iStep*dz/numSteps;
145  GlobalPoint stepPoint(stepX, stepY, stepZ);
146  bool isWithinDetId = caloCellGeo->inside(stepPoint);
147  if ( isWithinDetId ) ++numStepsWithinDetId;
148  }
149  distanceWithinDetId += (numStepsWithinDetId/float(numSteps + 1))*distanceBetweenPoints;
150  }
151  previousPoint = (*point);
152  previousPoint_initialized = true;
153  }
154  distanceMap[detId->rawId()] = distanceWithinDetId;
155  }
156  }
157 }
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
assert(m_qm.get())
T y() const
Definition: PV3DBase.h:63
TrackDetMatchInfo getTrackDetMatchInfo(const edm::Event &, const edm::EventSetup &, TrackDetectorAssociator &, const TrackAssociatorParameters &, const reco::Candidate *)
const std::vector< SteppingHelixStateInfo > & getPreshowerTrajectory() const
const CachedTrajectory & getCachedTrajector() const
trajector information
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
#define end
Definition: vmac.h:37
Definition: DetId.h:18
bool inside(const GlobalPoint &point) const
Returns true if the specified point is inside this cell.
string const
Definition: compareJSON.py:14
#define begin
Definition: vmac.h:30
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters trackAssociatorParameters_
for(const auto &isodef:isoDefs)
T x() const
Definition: PV3DBase.h:62
T get(const Candidate &c)
Definition: component.h:55
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void MuonCaloDistanceProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 45 of file MuonCaloDistanceProducer.cc.

References fillDistanceMap(), getSelMuons(), getTheMuMinus(), getTheMuPlus(), edm::RefToBase< T >::isNonnull(), patZpeak::muons, edm::Event::put(), and srcSelectedMuons_.

46 {
47  std::auto_ptr<detIdToFloatMap> distanceMuPlus(new detIdToFloatMap());
48  std::auto_ptr<detIdToFloatMap> distanceMuMinus(new detIdToFloatMap());
49  std::auto_ptr<detIdToFloatMap> depositMuPlus(new detIdToFloatMap());
50  std::auto_ptr<detIdToFloatMap> depositMuMinus(new detIdToFloatMap());
51 
52  std::vector<reco::CandidateBaseRef> selMuons = getSelMuons(evt, srcSelectedMuons_);
53  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
54  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
55 
56  if ( muPlus.isNonnull() ) fillDistanceMap(evt, es, &(*muPlus), *distanceMuPlus, *depositMuPlus);
57  if ( muMinus.isNonnull() ) fillDistanceMap(evt, es, &(*muMinus), *distanceMuMinus, *depositMuMinus);
58 
59  std::auto_ptr<reco::CandidateCollection> muons(new reco::CandidateCollection);
60  if ( muPlus.isNonnull() ) muons->push_back(new reco::ShallowCloneCandidate(muPlus));
61  if ( muMinus.isNonnull() ) muons->push_back(new reco::ShallowCloneCandidate(muMinus));
62 
63  // References to the muons themselves
64  evt.put(muons, "muons");
65 
66  // maps of detId to distance traversed by muon through calorimeter cell
67  evt.put(distanceMuPlus, "distancesMuPlus");
68  evt.put(distanceMuMinus, "distancesMuMinus");
69 
70  // maps of detId to energy deposited in calorimeter cell
71  evt.put(depositMuPlus, "depositsMuPlus");
72  evt.put(depositMuMinus, "depositsMuMinus");
73 }
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
std::map< uint32_t, float > detIdToFloatMap
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:279
void fillDistanceMap(edm::Event &, const edm::EventSetup &, const reco::Candidate *, detIdToFloatMap &, detIdToFloatMap &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
tuple muons
Definition: patZpeak.py:38
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)

Member Data Documentation

edm::InputTag MuonCaloDistanceProducer::srcSelectedMuons_
private

Definition at line 42 of file MuonCaloDistanceProducer.h.

Referenced by produce().

TrackDetectorAssociator MuonCaloDistanceProducer::trackAssociator_
private

Definition at line 44 of file MuonCaloDistanceProducer.h.

Referenced by fillDistanceMap(), and MuonCaloDistanceProducer().

TrackAssociatorParameters MuonCaloDistanceProducer::trackAssociatorParameters_
private

Definition at line 45 of file MuonCaloDistanceProducer.h.

Referenced by fillDistanceMap(), and MuonCaloDistanceProducer().