22 #include <boost/foreach.hpp>
25 : srcSelectedMuons_(cfg.getParameter<edm::InputTag>(
"selectedMuons"))
28 produces<reco::CandidateCollection>(
"muons");
29 produces<detIdToFloatMap>(
"distancesMuPlus");
30 produces<detIdToFloatMap>(
"distancesMuMinus");
31 produces<detIdToFloatMap>(
"depositsMuPlus");
32 produces<detIdToFloatMap>(
"depositsMuMinus");
63 evt.
put(muons,
"muons");
66 evt.
put(distanceMuPlus,
"distancesMuPlus");
67 evt.
put(distanceMuMinus,
"distancesMuMinus");
70 evt.
put(depositMuPlus,
"depositsMuPlus");
71 evt.
put(depositMuMinus,
"depositsMuMinus");
87 typedef std::map<std::string, const std::vector<DetId>*> CaloToDetIdMap;
88 CaloToDetIdMap caloToDetIdMap;
91 caloToDetIdMap[
"ho"] = &(trackDetMatchInfo.
crossedHOIds);
97 for ( CaloToDetIdMap::const_iterator caloToDetIdEntry = caloToDetIdMap.begin();
98 caloToDetIdEntry != caloToDetIdMap.end(); ++caloToDetIdEntry ) {
99 std::vector<SteppingHelixStateInfo>::const_iterator itHelixState_first, itHelixState_last;
100 if ( caloToDetIdEntry->first ==
"ecal" ) {
103 }
else if ( caloToDetIdEntry->first ==
"hcal" ) {
106 }
else if ( caloToDetIdEntry->first ==
"ho" ) {
109 }
else if ( caloToDetIdEntry->first ==
"es" ) {
115 std::vector<GlobalPoint> trajectory;
116 for ( std::vector<SteppingHelixStateInfo>::const_iterator helixState = itHelixState_first;
117 helixState != itHelixState_last; ++helixState ) {
118 trajectory.push_back(helixState->position());
122 for ( std::vector<DetId>::const_iterator detId = caloToDetIdEntry->second->begin();
123 detId != caloToDetIdEntry->second->end(); ++detId ) {
124 if ( detId->rawId() == 0 )
continue;
129 bool previousPoint_initialized;
130 float distanceWithinDetId = 0;
131 for ( std::vector<GlobalPoint>::const_iterator
point = trajectory.begin();
133 if ( previousPoint_initialized ) {
134 float dx =
point->x() - previousPoint.
x();
135 float dy =
point->y() - previousPoint.
y();
136 float dz =
point->z() - previousPoint.
z();
137 float distanceBetweenPoints =
sqrt(dx*dx + dy*dy + dz*dz);
139 int numStepsWithinDetId = 0;
140 for (
int iStep = 0; iStep <= numSteps; ++iStep ){
141 float stepX = previousPoint.
x() + iStep*dx/numSteps;
142 float stepY = previousPoint.
y() + iStep*dy/numSteps;
143 float stepZ = previousPoint.
z() + iStep*dz/numSteps;
145 bool isWithinDetId = caloCellGeo->
inside(stepPoint);
146 if ( isWithinDetId ) ++numStepsWithinDetId;
148 distanceWithinDetId += (numStepsWithinDetId/float(numSteps + 1))*distanceBetweenPoints;
150 previousPoint = (*point);
151 previousPoint_initialized =
true;
153 distanceMap[detId->rawId()] = distanceWithinDetId;
std::vector< DetId > crossedPreshowerIds
T getParameter(std::string const &) const
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
std::vector< const HBHERecHit * > crossedHcalRecHits
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
const DetId & detid() const
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
#define DEFINE_FWK_MODULE(type)
std::vector< DetId > crossedEcalIds
void useDefaultPropagator()
use the default propagator
std::map< uint32_t, float > detIdToFloatMap
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< DetId > crossedHcalIds
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.
uint32_t rawId() const
get the raw id
virtual void produce(edm::Event &, const edm::EventSetup &)
void fillDistanceMap(edm::Event &, const edm::EventSetup &, const reco::Candidate *, detIdToFloatMap &, detIdToFloatMap &)
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
~MuonCaloDistanceProducer()
std::vector< DetId > crossedHOIds
bool inside(const GlobalPoint &point) const
Returns true if the specified point is inside this cell.
TrackDetectorAssociator trackAssociator_
std::vector< const HORecHit * > crossedHORecHits
MuonCaloDistanceProducer(const edm::ParameterSet &)
TrackAssociatorParameters trackAssociatorParameters_
edm::InputTag srcSelectedMuons_
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
bool isNonnull() const
Checks for non-null.
*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
void loadParameters(const edm::ParameterSet &)