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();
180 <<
"DTDigi "<<ihit<<
", wire "<<wireid<<
", number = "<<hitIT->number()<<
", TDC counts = "<<hitIT->countsTDC();
184 LogTrace(
"DTHitAssociator")<<
"\n *** There are NO DTDigi's ***";
188 edm::LogVerbatim(
"DTHitAssociator")<<
"\n *** Analyze DTRecHitCollection by DTWireId ***";
191 for(RecHitMap::const_iterator mapIT=
mapOfRecHit.begin();
196 edm::LogVerbatim(
"DTHitAssociator")<<
"\n===================================================================";
197 edm::LogVerbatim(
"DTHitAssociator")<<
"wire index = "<<iwire<<
" *** DTWireId = "<<
" ("<<wireid<<
")";
202 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
206 tId << (hitIT->first).trackId();
207 string simhitlog =
"\t SimTrack Id = "+tId.str();
208 if (hitIT->second) simhitlog = simhitlog +
"\t -VALID HIT-";
209 else simhitlog = simhitlog +
"\t -not valid hit-";
217 for (vector<DTDigiSimLink>::const_iterator hitIT =
mapOfLinks[wireid].
begin();
221 <<
"\t digi number = "<<hitIT->number()<<
", time = "<<hitIT->time()<<
", SimTrackId = "<<hitIT->SimTrackId();
227 for (vector<DTDigi>::const_iterator hitIT =
mapOfDigi[wireid].
begin();
230 edm::LogVerbatim(
"DTHitAssociator")<<
"\t digi number = "<<hitIT->number()<<
", time = "<<hitIT->time();
234 edm::LogVerbatim(
"DTHitAssociator")<<
"\n"<<(*mapIT).second.size()<<
" RecHits (DTRecHit1DPair):";
235 for(vector<DTRecHit1DPair>::const_iterator vIT =(*mapIT).second.begin();
236 vIT !=(*mapIT).second.end();
247 std::vector<SimHitIdpr> simtrackids;
254 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::associateHitId, null dynamic_cast !";
261 std::vector<SimHitIdpr> matched;
269 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
273 bool valid_hit = hitIT->second;
274 PSimHit this_hit = hitIT->first;
278 matched.push_back(currentId);
287 float theTime = dtrechit->
digiTime();
295 for (vector<DTDigiSimLink>::const_iterator linkIT =
mapOfLinks[wireid].
begin();
298 float digitime = linkIT->time();
299 if (fabs(digitime-theTime)<0.1) {
300 theNumber = linkIT->number();
306 for (vector<DTDigiSimLink>::const_iterator linkIT =
mapOfLinks[wireid].
begin();
310 int digiNr = linkIT->number();
311 if (digiNr == theNumber) {
312 SimHitIdpr currentId(linkIT->SimTrackId(), linkIT->eventId());
313 matched.push_back(currentId);
318 edm::LogError(
"DTHitAssociator")<<
"*** ERROR in DTHitAssociator::associateDTHitId - DTRecHit1D: "
319 <<*dtrechit<<
" has no associated DTDigiSimLink !"<<endl;
329 std::vector<PSimHit> simhits;
330 std::vector<SimHitIdpr> simtrackids;
342 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
346 bool valid_hit = hitIT->second;
347 if (valid_hit) simhits.push_back(hitIT->first);
356 for (vector<SimHitIdpr>::const_iterator idIT = simtrackids.begin(); idIT != simtrackids.end(); ++idIT) {
357 uint32_t trId = idIT->first;
361 for (vector<PSimHit_withFlag>::const_iterator hitIT =
mapOfSimHit[wireid].
begin();
365 if (hitIT->first.trackId() == trId &&
366 hitIT->first.eventId() == evId)
367 simhits.push_back(hitIT->first);
374 edm::LogWarning(
"DTHitAssociator")<<
"*** WARNING in DTHitAssociator::associateHit, null dynamic_cast !";
384 const DTLayer* dtlayer = muongeom->layer(wireid.layerId());
387 const DTTopology &topo = dtlayer->specificTopology();
389 float xEntry = entryP.
x() - xwire;
390 float xExit = exitP.
x() - xwire;
394 bool noParametrisation =
396 (entrySide == exitSide) ||
401 if (noParametrisation)
410 if(fabs(hitPos.
z()) < 0.002) {
412 x = hitPos.
x() - xwire;
414 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.