21 DTdigiTag(conf.getParameter<
edm::InputTag>(
"DTdigiTag")),
26 dumpDT(conf.getParameter<bool>(
"dumpDT")),
30 links_exist(conf.getParameter<bool>(
"links_exist")),
57 DTdigiTag(conf.getParameter<
edm::InputTag>(
"DTdigiTag")),
62 dumpDT(conf.getParameter<bool>(
"dumpDT")),
66 links_exist(conf.getParameter<bool>(
"links_exist")),
78 LogTrace(
"DTHitAssociator") <<
"DTHitAssociator constructor: dumpDT = "<<
dumpDT 83 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::DTHitAssociator: associatorByWire reset to TRUE !" 84 <<
" \t (missing DTDigiSimLinkCollection ?)";
85 associatorByWire =
true;
100 unique_ptr<MixCollection<PSimHit> >
102 LogTrace(
"DTHitAssociator") <<
"... size = "<<DTsimhits->size();
104 for (isimhit=DTsimhits->begin(); isimhit!= DTsimhits->end(); isimhit++) {
105 DTWireId wireid((*isimhit).detUnitId());
106 takeHit =
SimHitOK(muonGeom, *isimhit);
107 mapOfSimHit[wireid].push_back(make_pair(*isimhit,takeHit));
114 LogTrace(
"DTHitAssociator") <<
"... size = "<<DTsimhits->size();
115 edm::PSimHitContainer::const_iterator isimhit;
116 for (isimhit=DTsimhits->begin(); isimhit!= DTsimhits->end(); isimhit++) {
117 DTWireId wireid((*isimhit).detUnitId());
118 takeHit =
SimHitOK(muonGeom, *isimhit);
119 mapOfSimHit[wireid].push_back(make_pair(*isimhit,takeHit));
132 const DTLayerId& layerid = (*detUnit).first;
136 for (digi = range.first; digi != range.second; ++digi){
137 DTWireId wireid(layerid,(*digi).wire());
142 LogTrace(
"DTHitAssociator") <<
"... NO DTDigi collection found !";
153 detUnit !=digisimlinks->
end();
155 const DTLayerId& layerid = (*detUnit).first;
159 for (link=range.first; link!=range.second; ++link){
160 DTWireId wireid(layerid,(*link).wire());
172 LogTrace(
"DTHitAssociator") <<
"... size = "<<DTrechits->size();
177 for(rechit=DTrechits->begin(); rechit!=DTrechits->end(); ++rechit) {
178 DTWireId wireid = (*rechit).wireId();
188 for(SimHitMap::const_iterator mapIT=
mapOfSimHit.begin();
193 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
198 <<
"PSimHit "<<ihit <<
", wire "<<wireid
204 edm::LogVerbatim(
"DTHitAssociator")<<
"\n *** There are NO DT PSimHit's ***";
212 for(DigiMap::const_iterator mapIT=
mapOfDigi.begin(); mapIT!=
mapOfDigi.end(); ++mapIT , jwire++) {
216 for (vector<DTDigi>::const_iterator hitIT =
mapOfDigi[wireid].
begin();
220 <<
"DTDigi "<<ihit<<
", wire "<<wireid<<
", number = "<<hitIT->number()<<
", TDC counts = "<<hitIT->countsTDC();
224 LogTrace(
"DTHitAssociator")<<
"\n *** There are NO DTDigi's ***";
228 edm::LogVerbatim(
"DTHitAssociator")<<
"\n *** Analyze DTRecHitCollection by DTWireId ***";
231 for(RecHitMap::const_iterator mapIT=
mapOfRecHit.begin();
236 edm::LogVerbatim(
"DTHitAssociator")<<
"\n===================================================================";
237 edm::LogVerbatim(
"DTHitAssociator")<<
"wire index = "<<iwire<<
" *** DTWireId = "<<
" ("<<wireid<<
")";
242 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
246 tId << (hitIT->first).trackId();
247 string simhitlog =
"\t SimTrack Id = "+tId.str();
248 if (hitIT->second) simhitlog = simhitlog +
"\t -VALID HIT-";
249 else simhitlog = simhitlog +
"\t -not valid hit-";
257 for (vector<DTDigiSimLink>::const_iterator hitIT =
mapOfLinks[wireid].
begin();
261 <<
"\t digi number = "<<hitIT->number()<<
", time = "<<hitIT->time()<<
", SimTrackId = "<<hitIT->SimTrackId();
267 for (vector<DTDigi>::const_iterator hitIT =
mapOfDigi[wireid].
begin();
270 edm::LogVerbatim(
"DTHitAssociator")<<
"\t digi number = "<<hitIT->number()<<
", time = "<<hitIT->time();
274 edm::LogVerbatim(
"DTHitAssociator")<<
"\n"<<(*mapIT).second.size()<<
" RecHits (DTRecHit1DPair):";
275 for(vector<DTRecHit1DPair>::const_iterator vIT =(*mapIT).second.begin();
276 vIT !=(*mapIT).second.end();
287 std::vector<SimHitIdpr> simtrackids;
294 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::associateHitId, null dynamic_cast !";
301 std::vector<SimHitIdpr>
matched;
310 for (vector<PSimHit_withFlag>::const_iterator hitIT =
found->second.begin();
311 hitIT !=
found->second.end();
314 bool valid_hit = hitIT->second;
315 PSimHit this_hit = hitIT->first;
319 matched.push_back(currentId);
328 float theTime = dtrechit->
digiTime();
338 for (vector<DTDigiSimLink>::const_iterator linkIT =
found->second.begin();
339 linkIT !=
found->second.end();
341 float digitime = linkIT->time();
342 if (fabs(digitime-theTime)<0.1) {
343 theNumber = linkIT->number();
349 for (vector<DTDigiSimLink>::const_iterator linkIT =
found->second.begin();
350 linkIT !=
found->second.end();
353 int digiNr = linkIT->number();
354 if (digiNr == theNumber) {
355 SimHitIdpr currentId(linkIT->SimTrackId(), linkIT->eventId());
356 matched.push_back(currentId);
361 edm::LogError(
"DTHitAssociator")<<
"*** ERROR in DTHitAssociator::associateDTHitId - DTRecHit1D: " 362 <<*dtrechit<<
" has no associated DTDigiSimLink !"<<endl;
372 std::vector<PSimHit> simhits;
373 std::vector<SimHitIdpr> simtrackids;
386 for (vector<PSimHit_withFlag>::const_iterator hitIT =
found->second.begin();
387 hitIT !=
found->second.end();
390 bool valid_hit = hitIT->second;
391 if (valid_hit) simhits.push_back(hitIT->first);
400 for (vector<SimHitIdpr>::const_iterator idIT = simtrackids.begin(); idIT != simtrackids.end(); ++idIT) {
401 uint32_t trId = idIT->first;
406 for (vector<PSimHit_withFlag>::const_iterator hitIT =
found->second.begin();
407 hitIT !=
found->second.end();
410 if (hitIT->first.trackId() == trId &&
411 hitIT->first.eventId() == evId)
412 simhits.push_back(hitIT->first);
419 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::associateHit, null dynamic_cast !";
429 const DTLayer* dtlayer = muongeom->
layer(wireid.layerId());
432 const DTTopology &topo = dtlayer->specificTopology();
434 float xEntry = entryP.
x() - xwire;
435 float xExit = exitP.
x() - xwire;
439 bool noParametrisation =
441 (entrySide == exitSide) ||
446 if (noParametrisation)
455 if(fabs(hitPos.
z()) < 0.002) {
457 x = hitPos.
x() - xwire;
459 x = xEntry - (entryP.
z()*(xExit-xEntry))/(exitP.
z()-entryP.
z());
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
std::pair< uint32_t, EncodedEventId > SimHitIdpr
int event() const
get the contents of the subdetector field (should be protected?)
Side onWhichBorder(float x, float y, float z) const
std::vector< PSimHit > associateHit(const TrackingRecHit &hit) const
edm::InputTag DTsimhitsTag
const DTLayer * layer(DTLayerId id) const
Return a layer given its id.
Local3DPoint exitPoint() const
Exit point in the local Det frame.
edm::InputTag DTrechitTag
Local3DPoint localPosition() const
int bunchCrossing() const
get the detector field from this detid
float digiTime() const
Return the time (ns) of the digi used to build the rechit.
EncodedEventId eventId() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const
edm::InputTag DTdigisimlinkTag
std::vector< DTDigi >::const_iterator const_iterator
unsigned short processType() const
void initEvent(const edm::Event &, const edm::EventSetup &)
DTHitAssociator(const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &, bool printRtS)
unsigned int trackId() const
std::pair< const_iterator, const_iterator > Range
std::vector< PSimHit > PSimHitContainer
edm::InputTag DTsimhitsXFTag
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.