20 DTsimhitsTag(conf.getParameter<edm::InputTag>(
"DTsimhitsTag")),
21 DTsimhitsXFTag(conf.getParameter<edm::InputTag>(
"DTsimhitsXFTag")),
22 DTdigiTag(conf.getParameter<edm::InputTag>(
"DTdigiTag")),
23 DTdigisimlinkTag(conf.getParameter<edm::InputTag>(
"DTdigisimlinkTag")),
24 DTrechitTag(conf.getParameter<edm::InputTag>(
"DTrechitTag")),
27 dumpDT(conf.getParameter<bool>(
"dumpDT")),
29 crossingframe(conf.getParameter<bool>(
"crossingframe")),
31 links_exist(conf.getParameter<bool>(
"links_exist")),
33 associatorByWire(conf.getParameter<bool>(
"associatorByWire")),
38 LogTrace(
"DTHitAssociator") <<
"DTHitAssociator constructor: dumpDT = "<<
dumpDT
43 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::DTHitAssociator: associatorByWire reset to TRUE !"
44 <<
" \t (missing DTDigiSimLinkCollection ?)";
45 associatorByWire =
true;
60 auto_ptr<MixCollection<PSimHit> >
62 LogTrace(
"DTHitAssociator") <<
"... size = "<<DTsimhits->size();
64 for (isimhit=DTsimhits->
begin(); isimhit!= DTsimhits->
end(); isimhit++) {
65 DTWireId wireid((*isimhit).detUnitId());
66 takeHit =
SimHitOK(muonGeom, *isimhit);
67 mapOfSimHit[wireid].push_back(make_pair(*isimhit,takeHit));
74 LogTrace(
"DTHitAssociator") <<
"... size = "<<DTsimhits->size();
75 edm::PSimHitContainer::const_iterator isimhit;
76 for (isimhit=DTsimhits->begin(); isimhit!= DTsimhits->end(); isimhit++) {
77 DTWireId wireid((*isimhit).detUnitId());
78 takeHit =
SimHitOK(muonGeom, *isimhit);
79 mapOfSimHit[wireid].push_back(make_pair(*isimhit,takeHit));
92 const DTLayerId& layerid = (*detUnit).first;
96 for (digi = range.first; digi != range.second; ++digi){
97 DTWireId wireid(layerid,(*digi).wire());
102 LogTrace(
"DTHitAssociator") <<
"... NO DTDigi collection found !";
113 detUnit !=digisimlinks->end();
115 const DTLayerId& layerid = (*detUnit).first;
119 for (link=range.first; link!=range.second; ++link){
120 DTWireId wireid(layerid,(*link).wire());
132 LogTrace(
"DTHitAssociator") <<
"... size = "<<DTrechits->size();
137 for(rechit=DTrechits->begin(); rechit!=DTrechits->end(); ++rechit) {
138 DTWireId wireid = (*rechit).wireId();
148 for(SimHitMap::const_iterator mapIT=
mapOfSimHit.begin();
153 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
158 <<
"PSimHit "<<ihit <<
", wire "<<wireid
164 edm::LogVerbatim(
"DTHitAssociator")<<
"\n *** There are NO DT PSimHit's ***";
172 for(DigiMap::const_iterator mapIT=
mapOfDigi.begin(); mapIT!=
mapOfDigi.end(); ++mapIT , jwire++) {
176 for (vector<DTDigi>::const_iterator hitIT =
mapOfDigi[wireid].
begin();
181 <<
"DTDigi "<<ihit<<
", wire "<<wireid<<
", number = "<<hitIT->number()<<
", TDC counts = "<<hitIT->countsTDC();
185 LogTrace(
"DTHitAssociator")<<
"\n *** There are NO DTDigi's ***";
189 edm::LogVerbatim(
"DTHitAssociator")<<
"\n *** Analyze DTRecHitCollection by DTWireId ***";
192 for(RecHitMap::const_iterator mapIT=
mapOfRecHit.begin();
197 edm::LogVerbatim(
"DTHitAssociator")<<
"\n===================================================================";
198 edm::LogVerbatim(
"DTHitAssociator")<<
"wire index = "<<iwire<<
" *** DTWireId = "<<
" ("<<wireid<<
")";
203 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
207 tId << (hitIT->first).trackId();
208 string simhitlog =
"\t SimTrack Id = "+tId.str();
209 if (hitIT->second) simhitlog = simhitlog +
"\t -VALID HIT-";
210 else simhitlog = simhitlog +
"\t -not valid hit-";
218 for (vector<DTDigiSimLink>::const_iterator hitIT =
mapOfLinks[wireid].
begin();
222 <<
"\t digi number = "<<hitIT->number()<<
", time = "<<hitIT->time()<<
", SimTrackId = "<<hitIT->SimTrackId();
228 for (vector<DTDigi>::const_iterator hitIT =
mapOfDigi[wireid].
begin();
231 edm::LogVerbatim(
"DTHitAssociator")<<
"\t digi number = "<<hitIT->number()<<
", time = "<<hitIT->time();
235 edm::LogVerbatim(
"DTHitAssociator")<<
"\n"<<(*mapIT).second.size()<<
" RecHits (DTRecHit1DPair):";
236 for(vector<DTRecHit1DPair>::const_iterator vIT =(*mapIT).second.begin();
237 vIT !=(*mapIT).second.end();
248 std::vector<SimHitIdpr> simtrackids;
255 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::associateHitId, null dynamic_cast !";
262 std::vector<SimHitIdpr> matched;
270 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
274 bool valid_hit = hitIT->second;
275 PSimHit this_hit = hitIT->first;
279 matched.push_back(currentId);
288 float theTime = dtrechit->
digiTime();
296 for (vector<DTDigiSimLink>::const_iterator linkIT =
mapOfLinks[wireid].
begin();
299 float digitime = linkIT->time();
300 if (fabs(digitime-theTime)<0.1) {
301 theNumber = linkIT->number();
307 for (vector<DTDigiSimLink>::const_iterator linkIT =
mapOfLinks[wireid].
begin();
311 int digiNr = linkIT->number();
312 if (digiNr == theNumber) {
313 SimHitIdpr currentId(linkIT->SimTrackId(), linkIT->eventId());
314 matched.push_back(currentId);
319 edm::LogError(
"DTHitAssociator")<<
"*** ERROR in DTHitAssociator::associateDTHitId - DTRecHit1D: "
320 <<*dtrechit<<
" has no associated DTDigiSimLink !"<<endl;
330 std::vector<PSimHit> simhits;
331 std::vector<SimHitIdpr> simtrackids;
343 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
347 bool valid_hit = hitIT->second;
348 if (valid_hit) simhits.push_back(hitIT->first);
357 for (vector<SimHitIdpr>::const_iterator idIT = simtrackids.begin(); idIT != simtrackids.end(); ++idIT) {
358 uint32_t trId = idIT->first;
362 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
366 if (hitIT->first.trackId() == trId &&
367 hitIT->first.eventId() == evId)
368 simhits.push_back(hitIT->first);
375 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::associateHit, null dynamic_cast !";
385 const DTLayer* dtlayer = muongeom->layer(wireid.layerId());
388 const DTTopology &topo = dtlayer->specificTopology();
390 float xEntry = entryP.
x() - xwire;
391 float xExit = exitP.
x() - xwire;
395 bool noParametrisation =
397 (entrySide == exitSide) ||
402 if (noParametrisation)
411 if(fabs(hitPos.
z()) < 0.002) {
413 x = hitPos.
x() - xwire;
415 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
std::string link(std::string &nm, std::string &ns)
C::const_iterator const_iterator
constant access iterator type
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
edm::InputTag DTdigisimlinkTag
std::vector< DigiType >::const_iterator const_iterator
T const * product() const
unsigned short processType() const
std::vector< SimHitIdpr > associateDTHitId(const DTRecHit1D *dtrechit)
DTHitAssociator(const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &, bool printRtS)
unsigned int trackId() const
std::pair< const_iterator, const_iterator > Range
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.