19 DTsimhitsTag(conf.getParameter<edm::InputTag>(
"DTsimhitsTag")),
20 DTsimhitsXFTag(conf.getParameter<edm::InputTag>(
"DTsimhitsXFTag")),
21 DTdigiTag(conf.getParameter<edm::InputTag>(
"DTdigiTag")),
22 DTdigisimlinkTag(conf.getParameter<edm::InputTag>(
"DTdigisimlinkTag")),
23 DTrechitTag(conf.getParameter<edm::InputTag>(
"DTrechitTag")),
26 dumpDT(conf.getParameter<bool>(
"dumpDT")),
28 crossingframe(conf.getParameter<bool>(
"crossingframe")),
30 links_exist(conf.getParameter<bool>(
"links_exist")),
32 associatorByWire(conf.getParameter<bool>(
"associatorByWire")),
55 DTsimhitsTag(conf.getParameter<edm::InputTag>(
"DTsimhitsTag")),
56 DTsimhitsXFTag(conf.getParameter<edm::InputTag>(
"DTsimhitsXFTag")),
57 DTdigiTag(conf.getParameter<edm::InputTag>(
"DTdigiTag")),
58 DTdigisimlinkTag(conf.getParameter<edm::InputTag>(
"DTdigisimlinkTag")),
59 DTrechitTag(conf.getParameter<edm::InputTag>(
"DTrechitTag")),
62 dumpDT(conf.getParameter<bool>(
"dumpDT")),
64 crossingframe(conf.getParameter<bool>(
"crossingframe")),
66 links_exist(conf.getParameter<bool>(
"links_exist")),
68 associatorByWire(conf.getParameter<bool>(
"associatorByWire")),
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 auto_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;
309 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
313 bool valid_hit = hitIT->second;
314 PSimHit this_hit = hitIT->first;
318 matched.push_back(currentId);
327 float theTime = dtrechit->
digiTime();
335 for (vector<DTDigiSimLink>::const_iterator linkIT =
mapOfLinks[wireid].
begin();
338 float digitime = linkIT->time();
339 if (fabs(digitime-theTime)<0.1) {
340 theNumber = linkIT->number();
346 for (vector<DTDigiSimLink>::const_iterator linkIT =
mapOfLinks[wireid].
begin();
350 int digiNr = linkIT->number();
351 if (digiNr == theNumber) {
352 SimHitIdpr currentId(linkIT->SimTrackId(), linkIT->eventId());
353 matched.push_back(currentId);
358 edm::LogError(
"DTHitAssociator")<<
"*** ERROR in DTHitAssociator::associateDTHitId - DTRecHit1D: "
359 <<*dtrechit<<
" has no associated DTDigiSimLink !"<<endl;
369 std::vector<PSimHit> simhits;
370 std::vector<SimHitIdpr> simtrackids;
382 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
386 bool valid_hit = hitIT->second;
387 if (valid_hit) simhits.push_back(hitIT->first);
396 for (vector<SimHitIdpr>::const_iterator idIT = simtrackids.begin(); idIT != simtrackids.end(); ++idIT) {
397 uint32_t trId = idIT->first;
401 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
405 if (hitIT->first.trackId() == trId &&
406 hitIT->first.eventId() == evId)
407 simhits.push_back(hitIT->first);
414 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::associateHit, null dynamic_cast !";
424 const DTLayer* dtlayer = muongeom->layer(wireid.layerId());
427 const DTTopology &topo = dtlayer->specificTopology();
429 float xEntry = entryP.
x() - xwire;
430 float xExit = exitP.
x() - xwire;
434 bool noParametrisation =
436 (entrySide == exitSide) ||
441 if (noParametrisation)
450 if(fabs(hitPos.
z()) < 0.002) {
452 x = hitPos.
x() - xwire;
454 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::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)
edm::InputTag DTsimhitsTag
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
std::vector< SimHitIdpr > associateDTHitId(const DTRecHit1D *dtrechit)
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 &)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
unsigned int detUnitId() const
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &hit)
DTWireId wireId() const
Return the wireId.