CMS 3D CMS Logo

HSCPDeDxInfoProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HSCPDeDxInfoProducer
4 // Class: HSCPDeDxInfoProducer
5 //
13 //
14 // Original Author: andrea
15 // Created: Thu May 31 14:09:02 CEST 2007
16 // Code Updates: loic Quertenmont (querten)
17 // Created: Thu May 10 14:09:02 CEST 2008
18 //
19 //
20 
22 
23 // system include files
24 
25 using namespace reco;
26 using namespace std;
27 using namespace edm;
28 
30  produces<ValueMap<susybsm::HSCPDeDxInfo> >();
31 
32  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips", 255);
33  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits", 4);
34  MinTrackMomentum = iConfig.getUntrackedParameter<double>("minTrackMomentum", 0.0);
35  MaxTrackMomentum = iConfig.getUntrackedParameter<double>("maxTrackMomentum", 99999.0);
36  MinTrackEta = iConfig.getUntrackedParameter<double>("minTrackEta", -5.0);
37  MaxTrackEta = iConfig.getUntrackedParameter<double>("maxTrackEta", 5.0);
38 
39  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
40  m_trajTrackAssociationTag =
41  consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation"));
42  useTrajectory = iConfig.getUntrackedParameter<bool>("UseTrajectory", true);
43 
44  usePixel = iConfig.getParameter<bool>("UsePixel");
45  useStrip = iConfig.getParameter<bool>("UseStrip");
46  meVperADCPixel = iConfig.getParameter<double>("MeVperADCPixel");
47  meVperADCStrip = iConfig.getParameter<double>("MeVperADCStrip");
48 
49  shapetest = iConfig.getParameter<bool>("ShapeTest");
50  useCalibration = iConfig.getParameter<bool>("UseCalibration");
51  m_calibrationPath = iConfig.getParameter<string>("calibrationPath");
52 
53  // Reccord = iConfig.getUntrackedParameter<std::string> ("Reccord" , "SiStripDeDxMip_3D_Rcd");
54  // ProbabilityMode = iConfig.getUntrackedParameter<std::string> ("ProbabilityMode" , "Accumulation");
55  // Prob_ChargePath = NULL;
56 
57  if (!usePixel && !useStrip)
58  edm::LogWarning("DeDxHitsProducer")
59  << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
60 }
61 
63 
64 // ------------ method called once each job just before starting event loop ------------
66  if (useCalibration && calibGains.empty()) {
68  iSetup.get<TrackerDigiGeometryRecord>().get(tkGeom);
69  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
70 
71  DeDxTools::makeCalibrationMap(m_calibrationPath, *tkGeom, calibGains, m_off);
72  }
73 
74  // DeDxTools::buildDiscrimMap(run, iSetup, Reccord, ProbabilityMode, Prob_ChargePath);
75 }
76 
78  unique_ptr<ValueMap<susybsm::HSCPDeDxInfo> > trackDeDxAssociation(new ValueMap<susybsm::HSCPDeDxInfo>);
79  ValueMap<susybsm::HSCPDeDxInfo>::Filler filler(*trackDeDxAssociation);
80 
81  edm::Handle<reco::TrackCollection> trackCollectionHandle;
82  iEvent.getByToken(m_tracksTag, trackCollectionHandle);
83 
84  Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
85  if (useTrajectory)
86  iEvent.getByToken(m_trajTrackAssociationTag, trajTrackAssociationHandle);
87 
88  std::vector<susybsm::HSCPDeDxInfo> dEdxInfos(trackCollectionHandle->size());
89 
91  if (useTrajectory)
92  cit = trajTrackAssociationHandle->begin();
93  for (unsigned int j = 0; j < trackCollectionHandle->size(); j++) {
94  const reco::TrackRef track = reco::TrackRef(trackCollectionHandle.product(), j);
95 
96  susybsm::HSCPDeDxInfo hscpDeDxInfo;
97 
98  if (useTrajectory) { //trajectory allows to take into account the local direction of the particle on the module sensor --> muc much better 'dx' measurement
99  const edm::Ref<std::vector<Trajectory> > traj = cit->key;
100  cit++;
101  const vector<TrajectoryMeasurement>& measurements = traj->measurements();
102  for (vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it != measurements.end(); it++) {
103  TrajectoryStateOnSurface trajState = it->updatedState();
104  if (!trajState.isValid())
105  continue;
106 
107  const TrackingRecHit* recHit = (*it->recHit()).hit();
108  if (!recHit)
109  continue;
110  LocalVector trackDirection = trajState.localDirection();
111  float cosine = trackDirection.z() / trackDirection.mag();
112 
113  processHit(recHit, trajState.localMomentum().mag(), cosine, hscpDeDxInfo, trajState.localPosition());
114  }
115 
116  } else { //assume that the particles trajectory is a straight line originating from the center of the detector (can be improved)
117  for (unsigned int h = 0; h < track->recHitsSize(); h++) {
118  const TrackingRecHit* recHit = &(*(track->recHit(h)));
119  auto const& thit = static_cast<BaseTrackerRecHit const&>(*recHit);
120  if (!thit.isValid())
121  continue; //make sure it's a tracker hit
122 
123  const GlobalVector& ModuleNormal = recHit->detUnit()->surface().normalVector();
124  float cosine =
125  (track->px() * ModuleNormal.x() + track->py() * ModuleNormal.y() + track->pz() * ModuleNormal.z()) /
126  track->p();
127 
128  processHit(recHit, track->p(), cosine, hscpDeDxInfo, LocalPoint(0.0, 0.0));
129  }
130  }
131 
132  dEdxInfos[j] = hscpDeDxInfo;
133  }
135 
136  filler.insert(trackCollectionHandle, dEdxInfos.begin(), dEdxInfos.end());
137  filler.fill();
138  iEvent.put(std::move(trackDeDxAssociation));
139 }
140 
142  float trackMomentum,
143  float& cosine,
144  susybsm::HSCPDeDxInfo& hscpDeDxInfo,
145  LocalPoint HitLocalPos) {
146  auto const& thit = static_cast<BaseTrackerRecHit const&>(*recHit);
147  if (!thit.isValid())
148  return;
149 
150  auto const& clus = thit.firstClusterRef();
151  if (!clus.isValid())
152  return;
153 
154  if (clus.isPixel()) {
155  if (!usePixel)
156  return;
157 
158  auto& detUnit = *(recHit->detUnit());
159  float pathLen = detUnit.surface().bounds().thickness() / fabs(cosine);
160  float chargeAbs = clus.pixelCluster().charge();
161  hscpDeDxInfo.charges.push_back(chargeAbs);
162  hscpDeDxInfo.pathlengths.push_back(pathLen);
163  hscpDeDxInfo.detIds.push_back(thit.geographicalId());
164  hscpDeDxInfo.localPosXs.push_back(HitLocalPos.x());
165  hscpDeDxInfo.localPosYs.push_back(HitLocalPos.y());
166  hscpDeDxInfo.clusterIndices.push_back(clus.key());
167  } else if (clus.isStrip() && !thit.isMatched()) {
168  if (!useStrip)
169  return;
170 
171  auto& detUnit = *(recHit->detUnit());
172  int NSaturating = 0;
173  float pathLen = detUnit.surface().bounds().thickness() / fabs(cosine);
174  float chargeAbs = DeDxTools::getCharge(&(clus.stripCluster()), NSaturating, detUnit, calibGains, m_off);
175  hscpDeDxInfo.charges.push_back(chargeAbs);
176  hscpDeDxInfo.pathlengths.push_back(pathLen);
177  hscpDeDxInfo.detIds.push_back(thit.geographicalId());
178  hscpDeDxInfo.localPosXs.push_back(HitLocalPos.x());
179  hscpDeDxInfo.localPosYs.push_back(HitLocalPos.y());
180  hscpDeDxInfo.clusterIndices.push_back(clus.key());
181  } else if (clus.isStrip() && thit.isMatched()) {
182  if (!useStrip)
183  return;
184  const SiStripMatchedRecHit2D* matchedHit = dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
185  if (!matchedHit)
186  return;
187 
188  auto& detUnitM = *(matchedHit->monoHit().detUnit());
189  int NSaturating = 0;
190  float pathLen = detUnitM.surface().bounds().thickness() / fabs(cosine);
191  float chargeAbs =
192  DeDxTools::getCharge(&(matchedHit->monoHit().stripCluster()), NSaturating, detUnitM, calibGains, m_off);
193  hscpDeDxInfo.charges.push_back(chargeAbs);
194  hscpDeDxInfo.pathlengths.push_back(pathLen);
195  hscpDeDxInfo.detIds.push_back(thit.geographicalId());
196  hscpDeDxInfo.localPosXs.push_back(HitLocalPos.x());
197  hscpDeDxInfo.localPosYs.push_back(HitLocalPos.y());
198  const OmniClusterRef monoClusterRef = matchedHit->monoClusterRef();
199  hscpDeDxInfo.clusterIndices.push_back(monoClusterRef.key());
200 
201  auto& detUnitS = *(matchedHit->stereoHit().detUnit());
202  NSaturating = 0;
203  pathLen = detUnitS.surface().bounds().thickness() / fabs(cosine);
204  chargeAbs =
205  DeDxTools::getCharge(&(matchedHit->stereoHit().stripCluster()), NSaturating, detUnitS, calibGains, m_off);
206  hscpDeDxInfo.charges.push_back(chargeAbs);
207  hscpDeDxInfo.pathlengths.push_back(pathLen);
208  hscpDeDxInfo.detIds.push_back(thit.geographicalId());
209  hscpDeDxInfo.localPosXs.push_back(HitLocalPos.x());
210  hscpDeDxInfo.localPosYs.push_back(HitLocalPos.y());
211  const OmniClusterRef stereoClusterRef = matchedHit->stereoClusterRef();
212  hscpDeDxInfo.clusterIndices.push_back(stereoClusterRef.key());
213  }
214 }
215 
216 //define this as a plug-in
Vector3DBase< float, LocalTag >
HSCPDeDxInfoProducer
Definition: HSCPDeDxInfoProducer.h:33
TrajectoryStateOnSurface::localMomentum
LocalVector localMomentum() const
Definition: TrajectoryStateOnSurface.h:75
edm::Handle::product
T const * product() const
Definition: Handle.h:70
DeDxTools::makeCalibrationMap
void makeCalibrationMap(const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float > > &calibGains, const unsigned int &m_off)
Definition: DeDxTools.cc:252
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
dedxEstimators_cff.useCalibration
useCalibration
Definition: dedxEstimators_cff.py:16
conversionTrackProducer_cfi.useTrajectory
useTrajectory
Definition: conversionTrackProducer_cfi.py:7
TrackerSingleRecHit::stripCluster
SiStripCluster const & stripCluster() const
Definition: TrackerSingleRecHit.h:55
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
HLT_2018_cff.MaxTrackEta
MaxTrackEta
Definition: HLT_2018_cff.py:24932
susybsm::HSCPDeDxInfo::pathlengths
std::vector< float > pathlengths
Definition: HSCPDeDxInfo.h:16
edm::Handle< reco::TrackCollection >
OmniClusterRef
Definition: OmniClusterRef.h:12
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
susybsm::HSCPDeDxInfo::localPosYs
std::vector< float > localPosYs
Definition: HSCPDeDxInfo.h:19
edm::Ref< TrackCollection >
DeDxTools::getCharge
int getCharge(const SiStripCluster *cluster, int &nSatStrip, const GeomDetUnit &detUnit, const std::vector< std::vector< float > > &calibGains, const unsigned int &m_off)
Definition: DeDxTools.cc:214
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
GeomDetEnumerators::PixelBarrel
Definition: GeomDetEnumerators.h:11
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HSCPDeDxInfoProducer::~HSCPDeDxInfoProducer
~HSCPDeDxInfoProducer() override
Definition: HSCPDeDxInfoProducer.cc:62
TrajectoryStateOnSurface::localDirection
LocalVector localDirection() const
Definition: TrajectoryStateOnSurface.h:76
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< TrackerGeometry >
reco::btau::trackMomentum
Definition: TaggingVariable.h:41
HSCPDeDxInfoProducer.h
SiStripMatchedRecHit2D::stereoHit
SiStripRecHit2D stereoHit() const
Definition: SiStripMatchedRecHit2D.h:25
Point3DBase< float, LocalTag >
dedxEstimators_cff.useStrip
useStrip
Definition: dedxEstimators_cff.py:11
HLT_2018_cff.MinTrackHits
MinTrackHits
Definition: HLT_2018_cff.py:24928
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
edm::LogWarning
Definition: MessageLogger.h:141
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
edm::ParameterSet
Definition: ParameterSet.h:36
susybsm::HSCPDeDxInfo::charges
std::vector< float > charges
Definition: HSCPDeDxInfo.h:15
SiStripMatchedRecHit2D::stereoClusterRef
OmniClusterRef const & stereoClusterRef() const
Definition: SiStripMatchedRecHit2D.h:34
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
HSCPDeDxInfoProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HSCPDeDxInfoProducer.cc:77
SiStripMatchedRecHit2D::monoHit
SiStripRecHit2D monoHit() const
Definition: SiStripMatchedRecHit2D.h:26
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
SiStripMatchedRecHit2D::monoClusterRef
OmniClusterRef const & monoClusterRef() const
Definition: SiStripMatchedRecHit2D.h:35
reco::get
T get(const Candidate &c)
Definition: component.h:60
TrackingRecHit
Definition: TrackingRecHit.h:21
SiStripFineDelayHit_cfi.MinTrackMomentum
MinTrackMomentum
Definition: SiStripFineDelayHit_cfi.py:15
susybsm::HSCPDeDxInfo::detIds
std::vector< uint32_t > detIds
Definition: HSCPDeDxInfo.h:17
HSCPDeDxInfoProducer::HSCPDeDxInfoProducer
HSCPDeDxInfoProducer(const edm::ParameterSet &)
Definition: HSCPDeDxInfoProducer.cc:29
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HSCPDeDxInfoProducer::processHit
void processHit(const TrackingRecHit *recHit, float trackMomentum, float &cosine, susybsm::HSCPDeDxInfo &hscpDeDxInfo, LocalPoint HitLocalPos)
Definition: HSCPDeDxInfoProducer.cc:141
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripMatchedRecHit2D
Definition: SiStripMatchedRecHit2D.h:8
edm::ValueMap
Definition: ValueMap.h:107
edm::AssociationMap::begin
const_iterator begin() const
first iterator over the map (read only)
Definition: AssociationMap.h:169
susybsm::HSCPDeDxInfo::localPosXs
std::vector< float > localPosXs
Definition: HSCPDeDxInfo.h:18
susybsm::HSCPDeDxInfo::clusterIndices
std::vector< uint32_t > clusterIndices
Definition: HSCPDeDxInfo.h:20
susybsm::HSCPDeDxInfo
Definition: HSCPDeDxInfo.h:13
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
HSCPDeDxInfoProducer::beginRun
void beginRun(edm::Run const &run, const edm::EventSetup &) override
Definition: HSCPDeDxInfoProducer.cc:65
edm::helper::Filler
Definition: ValueMap.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
TrackerGeometry::offsetDU
unsigned int offsetDU(SubDetector sid) const
Definition: TrackerGeometry.h:72
OmniClusterRef::key
unsigned int key() const
Definition: OmniClusterRef.h:70
edm::InputTag
Definition: InputTag.h:15
dedxEstimators_cff.usePixel
usePixel
Definition: dedxEstimators_cff.py:12
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
hit
Definition: SiStripHitEffFromCalibTree.cc:88
TrackerSingleRecHit::detUnit
const GeomDetUnit * detUnit() const override
Definition: TrackerSingleRecHit.h:36