20 DTdigiTag(conf.getParameter<edm::
InputTag>(
"DTdigiTag")),
21 DTdigisimlinkTag(conf.getParameter<edm::
InputTag>(
"DTdigisimlinkTag")),
22 DTrechitTag(conf.getParameter<edm::
InputTag>(
"DTrechitTag")),
25 dumpDT(conf.getParameter<bool>(
"dumpDT")),
27 crossingframe(conf.getParameter<bool>(
"crossingframe")),
29 links_exist(conf.getParameter<bool>(
"links_exist")),
32 associatorByWire(conf.getParameter<bool>(
"associatorByWire")) {
46 LogTrace(
"DTHitAssociator") <<
"*** WARNING in DTHitAssociator::DTHitAssociator: associatorByWire "
48 <<
" \t (missing DTDigiSimLinkCollection ?)";
83 LogTrace(
"DTHitAssociator") <<
"... size = " << DTsimhits->size();
85 for (isimhit = DTsimhits->begin(); isimhit != DTsimhits->end(); isimhit++) {
86 DTWireId wireid((*isimhit).detUnitId());
87 takeHit =
SimHitOK(muonGeom, *isimhit);
88 mapOfSimHit[wireid].push_back(make_pair(*isimhit, takeHit));
93 LogTrace(
"DTHitAssociator") <<
"... size = " << DTsimhits.size();
94 edm::PSimHitContainer::const_iterator isimhit;
95 for (isimhit = DTsimhits.begin(); isimhit != DTsimhits.end(); isimhit++) {
96 DTWireId wireid((*isimhit).detUnitId());
97 takeHit =
SimHitOK(muonGeom, *isimhit);
98 mapOfSimHit[wireid].push_back(make_pair(*isimhit, takeHit));
110 const DTLayerId &layerid = (*detUnit).first;
114 for (digi = range.first; digi != range.second; ++digi) {
115 DTWireId wireid(layerid, (*digi).wire());
120 LogTrace(
"DTHitAssociator") <<
"... NO DTDigi collection found !";
132 const DTLayerId &layerid = (*detUnit).first;
136 for (link = range.first; link != range.second; ++link) {
137 DTWireId wireid(layerid, (*link).wire());
147 LogTrace(
"DTHitAssociator") <<
"... size = " << DTrechits.size();
152 for (rechit = DTrechits.begin(); rechit != DTrechits.end(); ++rechit) {
153 DTWireId wireid = (*rechit).wireId();
158 LogTrace(
"DTHitAssociator") <<
"\n *** Dump DT PSimHit's ***";
163 for (SimHitMap::const_iterator mapIT =
mapOfSimHit.begin(); mapIT !=
mapOfSimHit.end(); ++mapIT, jwire++) {
165 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
169 LogTrace(
"DTHitAssociator") <<
"PSimHit " << ihit <<
", wire " << wireid
176 LogTrace(
"DTHitAssociator") <<
"\n *** There are NO DT PSimHit's ***";
183 for (DigiMap::const_iterator mapIT =
mapOfDigi.begin(); mapIT !=
mapOfDigi.end(); ++mapIT, jwire++) {
184 LogTrace(
"DTHitAssociator") <<
"\n *** Dump DT digis ***";
189 LogTrace(
"DTHitAssociator") <<
"DTDigi " << ihit <<
", wire " << wireid <<
", number = " << hitIT->number()
190 <<
", TDC counts = " << hitIT->countsTDC();
194 LogTrace(
"DTHitAssociator") <<
"\n *** There are NO DTDigi's ***";
198 LogTrace(
"DTHitAssociator") <<
"\n *** Analyze DTRecHitCollection by DTWireId ***";
201 for (RecHitMap::const_iterator mapIT =
mapOfRecHit.begin(); mapIT !=
mapOfRecHit.end(); ++mapIT, iwire++) {
203 LogTrace(
"DTHitAssociator") <<
"\n======================================="
204 "============================";
205 LogTrace(
"DTHitAssociator") <<
"wire index = " << iwire <<
" *** DTWireId = "
206 <<
" (" << wireid <<
")";
209 LogTrace(
"DTHitAssociator") <<
"\n" <<
mapOfSimHit[wireid].size() <<
" SimHits (PSimHit):";
211 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
215 tId << (hitIT->first).trackId();
216 string simhitlog =
"\t SimTrack Id = " + tId.str();
218 simhitlog = simhitlog +
"\t -VALID HIT-";
220 simhitlog = simhitlog +
"\t -not valid hit-";
221 LogTrace(
"DTHitAssociator") << simhitlog;
226 LogTrace(
"DTHitAssociator") <<
"\n" <<
mapOfLinks[wireid].size() <<
" Links (DTDigiSimLink):";
228 for (vector<DTDigiSimLink>::const_iterator hitIT =
mapOfLinks[wireid].
begin();
231 LogTrace(
"DTHitAssociator") <<
"\t digi number = " << hitIT->number() <<
", time = " << hitIT->time()
232 <<
", SimTrackId = " << hitIT->SimTrackId();
237 LogTrace(
"DTHitAssociator") <<
"\n" <<
mapOfDigi[wireid].size() <<
" Digis (DTDigi):";
240 LogTrace(
"DTHitAssociator") <<
"\t digi number = " << hitIT->number() <<
", time = " << hitIT->time();
244 LogTrace(
"DTHitAssociator") <<
"\n" << (*mapIT).second.size() <<
" RecHits (DTRecHit1DPair):";
245 for (vector<DTRecHit1DPair>::const_iterator vIT = (*mapIT).second.begin(); vIT != (*mapIT).second.end(); ++vIT) {
246 LogTrace(
"DTHitAssociator") <<
"\t digi time = " << vIT->digiTime();
254 std::vector<SimHitIdpr> simtrackids;
261 LogTrace(
"DTHitAssociator") <<
"*** WARNING in DTHitAssociator::associateHitId, null dynamic_cast "
268 std::vector<SimHitIdpr> matched;
277 for (vector<PSimHit_withFlag>::const_iterator hitIT =
found->second.begin(); hitIT !=
found->second.end();
279 bool valid_hit = hitIT->second;
280 PSimHit this_hit = hitIT->first;
284 matched.push_back(currentId);
293 float theTime = dtrechit->
digiTime();
305 for (vector<DTDigiSimLink>::const_iterator linkIT =
found->second.begin(); linkIT !=
found->second.end();
307 float digitime = linkIT->time();
308 if (fabs(digitime - theTime) < 0.1) {
309 theNumber = linkIT->number();
317 for (vector<DTDigiSimLink>::const_iterator linkIT =
found->second.begin(); linkIT !=
found->second.end();
319 int digiNr = linkIT->number();
320 if (digiNr == theNumber) {
321 SimHitIdpr currentId(linkIT->SimTrackId(), linkIT->eventId());
322 matched.push_back(currentId);
327 LogTrace(
"DTHitAssociator") <<
"*** ERROR in DTHitAssociator::associateDTHitId - DTRecHit1D: " << *dtrechit
328 <<
" has no associated DTDigiSimLink !" << endl;
337 std::vector<PSimHit> simhits;
338 std::vector<SimHitIdpr> simtrackids;
351 for (vector<PSimHit_withFlag>::const_iterator hitIT =
found->second.begin(); hitIT !=
found->second.end();
353 bool valid_hit = hitIT->second;
355 simhits.push_back(hitIT->first);
363 for (vector<SimHitIdpr>::const_iterator idIT = simtrackids.begin(); idIT != simtrackids.end(); ++idIT) {
364 uint32_t trId = idIT->first;
369 for (vector<PSimHit_withFlag>::const_iterator hitIT =
found->second.begin(); hitIT !=
found->second.end();
371 if (hitIT->first.trackId() == trId && hitIT->first.eventId() == evId)
372 simhits.push_back(hitIT->first);
379 LogTrace(
"DTHitAssociator") <<
"*** WARNING in DTHitAssociator::associateHit, null dynamic_cast !";
388 const DTLayer *dtlayer = muongeom->layer(wireid.layerId());
391 const DTTopology &topo = dtlayer->specificTopology();
393 float xEntry = entryP.
x() - xwire;
394 float xExit = exitP.
x() - xwire;
398 bool noParametrisation =
404 if (noParametrisation) {
412 if (fabs(hitPos.
z()) < 0.002) {
414 x = hitPos.
x() - xwire;
416 x = xEntry - (entryP.
z() * (xExit - xEntry)) / (exitP.
z() - entryP.
z());
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &hit) const
edm::InputTag DTdigisimlinkTag
std::pair< uint32_t, EncodedEventId > SimHitIdpr
int event() const
get the contents of the subdetector field (should be protected?)
Config(const edm::ParameterSet &, edm::ConsumesCollector iC)
Side onWhichBorder(float x, float y, float z) const
edm::EDGetTokenT< DTDigiCollection > DTdigiToken
std::vector< PSimHit > associateHit(const TrackingRecHit &hit) const
DTHitAssociator(const edm::Event &, const edm::EventSetup &, const Config &, bool printRtS)
const uint16_t range(const Frame &aFrame)
C::const_iterator const_iterator
constant access iterator type
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Local3DPoint localPosition() const
int bunchCrossing() const
get the detector field from this detid
edm::InputTag DTsimhitsXFTag
edm::EDGetTokenT< DTRecHitCollection > DTrechitToken
edm::EDGetTokenT< DTDigiSimLinkCollection > DTdigisimlinkToken
float digiTime() const
Return the time (ns) of the digi used to build the rechit.
bool get(ProductID const &oid, Handle< PROD > &result) const
edm::InputTag DTrechitTag
edm::ESGetToken< DTGeometry, MuonGeometryRecord > geomToken
EncodedEventId eventId() const
edm::EDGetTokenT< edm::PSimHitContainer > DTsimhitsToken
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
unsigned short processType() const
edm::InputTag DTsimhitsTag
void initEvent(const edm::Event &, const edm::EventSetup &)
unsigned int trackId() const
std::vector< PSimHit > PSimHitContainer
edm::EDGetTokenT< CrossingFrame< PSimHit > > DTsimhitsXFToken
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
bool SimHitOK(const edm::ESHandle< DTGeometry > &, const PSimHit &)
DigiRangeIterator end() const
Local3DPoint entryPoint() const
Entry point in the local Det frame.
std::vector< SimHitIdpr > associateDTHitId(const DTRecHit1D *dtrechit) const
unsigned int detUnitId() const
DigiRangeIterator begin() const
DTWireId wireId() const
Return the wireId.
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...