CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes
TrackerHitAssociator Class Reference

#include <TrackerHitAssociator.h>

Public Types

typedef std::map
< simHitCollectionID,
std::vector< PSimHit > > 
simhit_collectionMap
 
typedef std::map< unsigned int,
std::vector< PSimHit > > 
simhit_map
 
typedef std::pair
< simHitCollectionID, unsigned
int > 
simhitAddr
 
typedef std::pair< unsigned
int, unsigned int > 
simHitCollectionID
 

Public Member Functions

std::vector< SimHitIdprassociateGSMatchedRecHit (const SiTrackerGSMatchedRecHit2D *gsmrechit) const
 
std::vector< SimHitIdprassociateGSRecHit (const SiTrackerGSRecHit2D *gsrechit) const
 
std::vector< PSimHitassociateHit (const TrackingRecHit &thit) const
 
std::vector< SimHitIdprassociateHitId (const TrackingRecHit &thit) const
 
void associateHitId (const TrackingRecHit &thit, std::vector< SimHitIdpr > &simhitid, std::vector< simhitAddr > *simhitCFPos=0) const
 
std::vector< SimHitIdprassociateMatchedRecHit (const SiStripMatchedRecHit2D *matchedrechit, std::vector< simhitAddr > *simhitCFPos=0) const
 
std::vector< PSimHitassociateMultiRecHit (const SiTrackerMultiRecHit *multirechit) const
 
std::vector< SimHitIdprassociateMultiRecHitId (const SiTrackerMultiRecHit *multirechit, std::vector< simhitAddr > *simhitCFPos=0) const
 
void associatePixelRecHit (const SiPixelRecHit *pixelrechit, std::vector< SimHitIdpr > &simhitid, std::vector< simhitAddr > *simhitCFPos=0) const
 
std::vector< SimHitIdprassociateProjectedRecHit (const ProjectedSiStripRecHit2D *projectedrechit, std::vector< simhitAddr > *simhitCFPos=0) const
 
void associateSimpleRecHitCluster (const SiStripCluster *clust, const DetId &detid, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
 
template<typename T >
void associateSiStripRecHit (const T *simplerechit, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
 
 TrackerHitAssociator (const edm::Event &e)
 
 TrackerHitAssociator (const edm::Event &e, const edm::ParameterSet &conf)
 
virtual ~TrackerHitAssociator ()
 

Public Attributes

simhit_collectionMap SimHitCollMap
 
simhit_map SimHitMap
 

Private Types

typedef std::vector< std::string > vstring
 

Private Member Functions

void makeMaps (const edm::Event &theEvent, const vstring trackerContainers)
 

Private Attributes

bool assocHitbySimTrack_
 
bool doPixel_
 
bool doStrip_
 
bool doTrackAssoc_
 
edm::Handle< edm::DetSetVector
< PixelDigiSimLink > > 
pixeldigisimlink
 
edm::Handle< edm::DetSetVector
< StripDigiSimLink > > 
stripdigisimlink
 

Detailed Description

Definition at line 54 of file TrackerHitAssociator.h.

Member Typedef Documentation

Definition at line 88 of file TrackerHitAssociator.h.

typedef std::map<unsigned int, std::vector<PSimHit> > TrackerHitAssociator::simhit_map

Definition at line 86 of file TrackerHitAssociator.h.

typedef std::pair<simHitCollectionID, unsigned int> TrackerHitAssociator::simhitAddr

Definition at line 66 of file TrackerHitAssociator.h.

typedef std::pair<unsigned int, unsigned int> TrackerHitAssociator::simHitCollectionID

Definition at line 65 of file TrackerHitAssociator.h.

typedef std::vector<std::string> TrackerHitAssociator::vstring
private

Definition at line 92 of file TrackerHitAssociator.h.

Constructor & Destructor Documentation

TrackerHitAssociator::TrackerHitAssociator ( const edm::Event e)

Definition at line 26 of file TrackerHitAssociator.cc.

References doPixel_, doStrip_, edm::Event::getByLabel(), makeMaps(), pixeldigisimlink, and stripdigisimlink.

26  :
27  doPixel_( true ),
28  doStrip_( true ),
29  doTrackAssoc_( false ),
30  assocHitbySimTrack_( false ) {
31  //
32  // Take by default all tracker SimHits
33  //
34  vstring trackerContainers;
35  trackerContainers.push_back("g4SimHitsTrackerHitsTIBLowTof");
36  trackerContainers.push_back("g4SimHitsTrackerHitsTIBHighTof");
37  trackerContainers.push_back("g4SimHitsTrackerHitsTIDLowTof");
38  trackerContainers.push_back("g4SimHitsTrackerHitsTIDHighTof");
39  trackerContainers.push_back("g4SimHitsTrackerHitsTOBLowTof");
40  trackerContainers.push_back("g4SimHitsTrackerHitsTOBHighTof");
41  trackerContainers.push_back("g4SimHitsTrackerHitsTECLowTof");
42  trackerContainers.push_back("g4SimHitsTrackerHitsTECHighTof");
43  trackerContainers.push_back("g4SimHitsTrackerHitsPixelBarrelLowTof");
44  trackerContainers.push_back("g4SimHitsTrackerHitsPixelBarrelHighTof");
45  trackerContainers.push_back("g4SimHitsTrackerHitsPixelEndcapLowTof");
46  trackerContainers.push_back("g4SimHitsTrackerHitsPixelEndcapHighTof");
47 
48  makeMaps(e, trackerContainers);
49 
50  if(doStrip_) e.getByLabel("simSiStripDigis", stripdigisimlink);
51  if(doPixel_) e.getByLabel("simSiPixelDigis", pixeldigisimlink);
52 }
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
vector< string > vstring
Definition: ExoticaDQM.cc:75
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
void makeMaps(const edm::Event &theEvent, const vstring trackerContainers)
TrackerHitAssociator::TrackerHitAssociator ( const edm::Event e,
const edm::ParameterSet conf 
)

Definition at line 57 of file TrackerHitAssociator.cc.

References assocHitbySimTrack_, doPixel_, doStrip_, doTrackAssoc_, edm::ParameterSet::existsAs(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), makeMaps(), pixeldigisimlink, and stripdigisimlink.

57  :
58  doPixel_( conf.getParameter<bool>("associatePixel") ),
59  doStrip_( conf.getParameter<bool>("associateStrip") ),
60  doTrackAssoc_( conf.getParameter<bool>("associateRecoTracks") ) {
61  assocHitbySimTrack_ = conf.existsAs<bool>("associateHitbySimTrack") ? conf.getParameter<bool>("associateHitbySimTrack") : false;
62 
63  //if track association there is no need to access the input collections
64  if(!doTrackAssoc_) {
65  vstring trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
66  makeMaps(e, trackerContainers);
67  }
68 
69  if(doStrip_) e.getByLabel("simSiStripDigis", stripdigisimlink);
70  if(doPixel_) e.getByLabel("simSiPixelDigis", pixeldigisimlink);
71 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
vector< string > vstring
Definition: ExoticaDQM.cc:75
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
void makeMaps(const edm::Event &theEvent, const vstring trackerContainers)
virtual TrackerHitAssociator::~TrackerHitAssociator ( )
inlinevirtual

Definition at line 63 of file TrackerHitAssociator.h.

63 {}

Member Function Documentation

std::vector< SimHitIdpr > TrackerHitAssociator::associateGSMatchedRecHit ( const SiTrackerGSMatchedRecHit2D gsmrechit) const

Definition at line 558 of file TrackerHitAssociator.cc.

References SiTrackerGSMatchedRecHit2D::eeId(), and SiTrackerGSMatchedRecHit2D::simtrackId().

Referenced by associateHitId().

559 {
560  //GSRecHit is the FastSimulation RecHit that contains the TrackId already
561 
562  vector<SimHitIdpr> simtrackid;
563  simtrackid.clear();
564  SimHitIdpr currentId(gsmrechit->simtrackId(), EncodedEventId(gsmrechit->eeId()));
565  simtrackid.push_back(currentId);
566  return simtrackid;
567 }
std::pair< uint32_t, EncodedEventId > SimHitIdpr
const uint32_t & eeId() const
std::vector< SimHitIdpr > TrackerHitAssociator::associateGSRecHit ( const SiTrackerGSRecHit2D gsrechit) const

Definition at line 522 of file TrackerHitAssociator.cc.

References SiTrackerGSRecHit2D::eeId(), and SiTrackerGSRecHit2D::simtrackId().

Referenced by associateHitId().

523 {
524  //GSRecHit is the FastSimulation RecHit that contains the TrackId already
525 
526  vector<SimHitIdpr> simtrackid;
527  simtrackid.clear();
528  SimHitIdpr currentId(gsrechit->simtrackId(), EncodedEventId(gsrechit->eeId()));
529  simtrackid.push_back(currentId);
530  return simtrackid;
531 }
const int & simtrackId() const
const uint32_t & eeId() const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
std::vector< PSimHit > TrackerHitAssociator::associateHit ( const TrackingRecHit thit) const

Check if it's the gluedDet.

Definition at line 121 of file TrackerHitAssociator.cc.

References assocHitbySimTrack_, associateHitId(), associateMultiRecHit(), begin, cond::rpcobgas::detid, doTrackAssoc_, end, PSimHit::eventId(), first, TrackingRecHit::geographicalId(), i, DetId::rawId(), query::result, edm::second(), SimHitCollMap, SimHitMap, and PSimHit::trackId().

Referenced by CkfDebugger::analyseCompatibleMeasurements(), SiPixelRecHitsValid::analyze(), TestHits::analyze(), TestSmoothHits::analyze(), TestTrackHits::analyze(), TestOutliers::analyze(), SiPixelErrorEstimation::analyze(), SiPixelTrackingRecHitsValid::analyze(), analyzer::SiPixelLorentzAngle::analyze(), CkfDebugger::associated(), associateMultiRecHit(), CkfDebugger::correctTrajectory(), GlobalRecHitsAnalyzer::fillTrk(), GlobalRecHitsProducer::fillTrk(), spr::matchedSimTrack(), CkfDebugger::nextCorrectHits(), SiStripRecHitsValid::rechitanalysis(), SiStripTrackingRecHitsValid::rechitanalysis(), SiStripRecHitsValid::rechitanalysis_matched(), SiStripTrackingRecHitsValid::rechitanalysis_matched(), and CkfDebugger::testSeed().

122 {
123 
124  if (const SiTrackerMultiRecHit * rechit = dynamic_cast<const SiTrackerMultiRecHit *>(&thit)){
125  return associateMultiRecHit(rechit);
126  }
127 
128  //vector with the matched SimHit
129  std::vector<PSimHit> result;
130 
131  if(doTrackAssoc_) return result;
132 
133  // Vectors to contain lists of matched simTracks, simHits
134  std::vector<SimHitIdpr> simtrackid;
135  std::vector<simhitAddr> simhitCFPos;
136 
137  //get the Detector type of the rechit
138  DetId detid= thit.geographicalId();
139  uint32_t detID = detid.rawId();
140 
141  // Get the vectors of simtrackIDs and simHit indices associated with this rechit
142  associateHitId(thit, simtrackid, &simhitCFPos);
143  // std::cout << "recHit subdet, detID = " << detid.subdetId() << ", " << detID << ", (bnch, evt, trk) = ";
144  // for (size_t i=0; i<simtrackid.size(); ++i)
145  // std::cout << ", (" << simtrackid[i].second.bunchCrossing() << ", "
146  // << simtrackid[i].second.event() << ", " << simtrackid[i].first << ")";
147  // std::cout << std::endl;
148 
149  // Get the vector of simHits associated with this rechit
150 
151  if (!assocHitbySimTrack_ && simhitCFPos.size() > 0) {
152  // We use the indices to the simHit collections taken
153  // from the DigiSimLinks and returned in simhitCFPos.
154  // simhitCFPos[i] contains the full address of the ith simhit:
155  // <collection, index> = <<subdet, tofBin>, index>
156 
157  //check if the recHit is a SiStripMatchedRecHit2D
158  bool isMatchedHit = false;
159  if(dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
160  isMatchedHit = true;
161 
162  for(size_t i=0; i<simhitCFPos.size(); i++) {
163  simhitAddr theSimHitAddr = simhitCFPos[i];
164  simHitCollectionID theSimHitCollID = theSimHitAddr.first;
165  simhit_collectionMap::const_iterator it = SimHitCollMap.find(theSimHitCollID);
166  if (it!= SimHitCollMap.end()) {
167  unsigned int theSimHitIndex = theSimHitAddr.second;
168  if (theSimHitIndex < (it->second).size()) {
169  const PSimHit& theSimHit = (it->second)[theSimHitIndex];
170  if (isMatchedHit) {
171  // Try to remove ghosts by requiring a match to the simTrack also
172  unsigned int simHitid = theSimHit.trackId();
173  EncodedEventId simHiteid = theSimHit.eventId();
174  for(size_t i=0; i<simtrackid.size();i++) {
175  if(simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second) {
176  result.push_back(theSimHit);
177  }
178  }
179  } else {
180  result.push_back(theSimHit);
181  }
182  // std::cout << "by CFpos, simHit detId = " << theSimHit.detUnitId() << " address = (" << (theSimHitAddr.first).first
183  // << ", " << (theSimHitAddr.first).second << ", " << theSimHitIndex
184  // << "), process = " << theSimHit.processType() << " (" << theSimHit.eventId().bunchCrossing()
185  // << ", " << theSimHit.eventId().event() << ", " << theSimHit.trackId() << ")" << std::endl;
186  }
187  }
188  }
189  return result;
190  }
191 
192  // Get the SimHit from the trackid instead
193  std::map<unsigned int, std::vector<PSimHit> >::const_iterator it = SimHitMap.find(detID);
194  if (it!= SimHitMap.end()) {
195  vector<PSimHit>::const_iterator simHitIter = (it->second).begin();
196  vector<PSimHit>::const_iterator simHitIterEnd = (it->second).end();
197  for (;simHitIter != simHitIterEnd; ++simHitIter) {
198  const PSimHit& ihit = *simHitIter;
199  unsigned int simHitid = ihit.trackId();
200  EncodedEventId simHiteid = ihit.eventId();
201  // std::cout << "by simTk, simHit, process = " << ihit.processType() << " (" << ihit.eventId().bunchCrossing()
202  // << ", " << ihit.eventId().event() << ", " << ihit.trackId() << ")";
203 
204  for(size_t i=0; i<simtrackid.size();i++) {
205  if(simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second) {
206 // cout << "Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x()
207 // << " y= " << ihit.localPosition().y() << " z= " << ihit.localPosition().x() << endl;
208  // std::cout << " matches";
209  result.push_back(ihit);
210  break;
211  }
212  }
213  // std::cout << std::endl;
214  }
215 
216  }else{
217 
219  std::map<unsigned int, std::vector<PSimHit> >::const_iterator itrphi =
220  SimHitMap.find(detID+2); //iterator to the simhit in the rphi module
221  std::map<unsigned int, std::vector<PSimHit> >::const_iterator itster =
222  SimHitMap.find(detID+1);//iterator to the simhit in the stereo module
223  if (itrphi!= SimHitMap.end()&&itster!=SimHitMap.end()) {
224  std::vector<PSimHit> simHitVector = itrphi->second;
225  simHitVector.insert(simHitVector.end(),(itster->second).begin(),(itster->second).end());
226  vector<PSimHit>::const_iterator simHitIter = simHitVector.begin();
227  vector<PSimHit>::const_iterator simHitIterEnd = simHitVector.end();
228  for (;simHitIter != simHitIterEnd; ++simHitIter) {
229  const PSimHit& ihit = *simHitIter;
230  unsigned int simHitid = ihit.trackId();
231  EncodedEventId simHiteid = ihit.eventId();
232  for(size_t i=0; i<simtrackid.size();i++) {
233  if(simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second) {
234 // if(simHitid == simtrackid[i].first && simHiteid.bunchCrossing() == simtrackid[i].second.bunchCrossing()) {
235  // cout << "GluedDet Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x()
236  // << " y= " << ihit.localPosition().y() << " z= " << ihit.localPosition().x() << endl;
237  result.push_back(ihit);
238  break;
239  }
240  }
241  }
242  }
243  }
244 
245  return result;
246 }
int i
Definition: DBlmapReader.cc:9
std::vector< PSimHit > associateMultiRecHit(const SiTrackerMultiRecHit *multirechit) const
std::pair< simHitCollectionID, unsigned int > simhitAddr
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
U second(std::pair< T, U > const &p)
tuple result
Definition: query.py:137
EncodedEventId eventId() const
Definition: PSimHit.h:105
#define end
Definition: vmac.h:37
bool first
Definition: L1TdeRCT.cc:75
simhit_collectionMap SimHitCollMap
Definition: DetId.h:18
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
#define begin
Definition: vmac.h:30
unsigned int trackId() const
Definition: PSimHit.h:102
DetId geographicalId() const
std::pair< unsigned int, unsigned int > simHitCollectionID
std::vector< SimHitIdpr > TrackerHitAssociator::associateHitId ( const TrackingRecHit thit) const
void TrackerHitAssociator::associateHitId ( const TrackingRecHit thit,
std::vector< SimHitIdpr > &  simhitid,
std::vector< simhitAddr > *  simhitCFPos = 0 
) const

Definition at line 255 of file TrackerHitAssociator.cc.

References associateGSMatchedRecHit(), associateGSRecHit(), associateMatchedRecHit(), associateMultiRecHitId(), associatePixelRecHit(), associateProjectedRecHit(), associateSiStripRecHit(), cond::rpcobgas::detid, TrackingRecHit::geographicalId(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

257 {
258 
259  simtkid.clear();
260 
261  //get the Detector type of the rechit
262  DetId detid= thit.geographicalId();
263  if (const SiTrackerMultiRecHit * rechit = dynamic_cast<const SiTrackerMultiRecHit *>(&thit)){
264  simtkid=associateMultiRecHitId(rechit, simhitCFPos);
265  }
266 
267  //cout << "Associator ---> get Detid " << detID << endl;
268  //check we are in the strip tracker
269  if(detid.subdetId() == StripSubdetector::TIB ||
270  detid.subdetId() == StripSubdetector::TOB ||
271  detid.subdetId() == StripSubdetector::TID ||
272  detid.subdetId() == StripSubdetector::TEC)
273  {
274  //check if it is a simple SiStripRecHit2D
275  if(const SiStripRecHit2D * rechit =
276  dynamic_cast<const SiStripRecHit2D *>(&thit))
277  {
278  associateSiStripRecHit(rechit, simtkid, simhitCFPos);
279  }
280  //check if it is a SiStripRecHit1D
281  else if(const SiStripRecHit1D * rechit =
282  dynamic_cast<const SiStripRecHit1D *>(&thit))
283  {
284  associateSiStripRecHit(rechit, simtkid, simhitCFPos);
285  }
286  //check if it is a SiStripMatchedRecHit2D
287  else if(const SiStripMatchedRecHit2D * rechit =
288  dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
289  {
290  simtkid = associateMatchedRecHit(rechit, simhitCFPos);
291  }
292  //check if it is a ProjectedSiStripRecHit2D
293  else if(const ProjectedSiStripRecHit2D * rechit =
294  dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
295  {
296  simtkid = associateProjectedRecHit(rechit, simhitCFPos);
297  }
298  else{
299  //std::cout << "associate to invalid" << std::endl;
300  //throw cms::Exception("Unknown RecHit Type") << "TrackerHitAssociator failed second casting of " << typeid(thit).name() << " type ";
301  }
302  }
303  //check we are in the pixel tracker
304  else if( (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelBarrel ||
305  (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelEndcap)
306  {
307  if(const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
308  {
309  associatePixelRecHit(rechit, simtkid, simhitCFPos);
310  }
311  }
312  //check if these are GSRecHits (from FastSim)
313  if(const SiTrackerGSRecHit2D * rechit = dynamic_cast<const SiTrackerGSRecHit2D *>(&thit))
314  {
315  simtkid = associateGSRecHit(rechit);
316  }
317  if(const SiTrackerGSMatchedRecHit2D * rechit = dynamic_cast<const SiTrackerGSMatchedRecHit2D *>(&thit))
318  {
319  simtkid = associateGSMatchedRecHit(rechit);
320  }
321 
322 }
std::vector< SimHitIdpr > associateMultiRecHitId(const SiTrackerMultiRecHit *multirechit, std::vector< simhitAddr > *simhitCFPos=0) const
void associatePixelRecHit(const SiPixelRecHit *pixelrechit, std::vector< SimHitIdpr > &simhitid, std::vector< simhitAddr > *simhitCFPos=0) const
std::vector< SimHitIdpr > associateGSMatchedRecHit(const SiTrackerGSMatchedRecHit2D *gsmrechit) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
std::vector< SimHitIdpr > associateProjectedRecHit(const ProjectedSiStripRecHit2D *projectedrechit, std::vector< simhitAddr > *simhitCFPos=0) const
std::vector< SimHitIdpr > associateGSRecHit(const SiTrackerGSRecHit2D *gsrechit) const
DetId geographicalId() const
std::vector< SimHitIdpr > associateMatchedRecHit(const SiStripMatchedRecHit2D *matchedrechit, std::vector< simhitAddr > *simhitCFPos=0) const
void associateSiStripRecHit(const T *simplerechit, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
Our base class.
Definition: SiPixelRecHit.h:23
std::vector< SimHitIdpr > TrackerHitAssociator::associateMatchedRecHit ( const SiStripMatchedRecHit2D matchedrechit,
std::vector< simhitAddr > *  simhitCFPos = 0 
) const

Definition at line 410 of file TrackerHitAssociator.cc.

References associateSiStripRecHit(), spr::find(), SiStripMatchedRecHit2D::monoHit(), and SiStripMatchedRecHit2D::stereoHit().

Referenced by associateHitId().

411 {
412  std::vector<SimHitIdpr> matched_mono;
413  std::vector<SimHitIdpr> matched_st;
414 
415  const SiStripRecHit2D mono = matchedrechit->monoHit();
416  const SiStripRecHit2D st = matchedrechit->stereoHit();
417  //associate the two simple hits separately
418  associateSiStripRecHit(&mono, matched_mono, simhitCFPos);
419  associateSiStripRecHit(&st, matched_st, simhitCFPos);
420 
421  //save in a vector all the simtrack-id's that are common to mono and stereo hits
422  std::vector<SimHitIdpr> simtrackid;
423  if(!matched_mono.empty() && !matched_st.empty()){
424  std::vector<SimHitIdpr> idcachev;
425  for(vector<SimHitIdpr>::iterator mhit=matched_mono.begin(); mhit != matched_mono.end(); mhit++){
426  //save only once the ID
427  if(find(idcachev.begin(), idcachev.end(), (*mhit)) == idcachev.end()) {
428  idcachev.push_back(*mhit);
429  //save if the stereoID matched the monoID
430  if(find(matched_st.begin(), matched_st.end(), (*mhit)) != matched_st.end()) {
431  simtrackid.push_back(*mhit);
432  }
433  }
434  }
435  }
436 
437  return simtrackid;
438 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
SiStripRecHit2D stereoHit() const
SiStripRecHit2D monoHit() const
void associateSiStripRecHit(const T *simplerechit, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
std::vector< PSimHit > TrackerHitAssociator::associateMultiRecHit ( const SiTrackerMultiRecHit multirechit) const

Definition at line 533 of file TrackerHitAssociator.cc.

References associateHit(), i, SiTrackerMultiRecHit::recHits(), findQualityFiles::size, SiTrackerMultiRecHit::weight(), and SiTrackerMultiRecHit::weights().

Referenced by associateHit().

533  {
534  std::vector<const TrackingRecHit*> componenthits = multirechit->recHits();
535  // std::vector<PSimHit> assimhits;
536  int size=multirechit->weights().size(), idmostprobable=0;
537 
538  for (int i=0; i<size; i++){
539  if(multirechit->weight(i)>multirechit->weight(idmostprobable)) idmostprobable=i;
540  }
541 
542  return associateHit(*componenthits[idmostprobable]);
543 }
int i
Definition: DBlmapReader.cc:9
float weight(unsigned int i) const
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
std::vector< float > const & weights() const
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
tuple size
Write out results.
std::vector< SimHitIdpr > TrackerHitAssociator::associateMultiRecHitId ( const SiTrackerMultiRecHit multirechit,
std::vector< simhitAddr > *  simhitCFPos = 0 
) const

Definition at line 545 of file TrackerHitAssociator.cc.

References associateHitId(), i, SiTrackerMultiRecHit::recHits(), findQualityFiles::size, SiTrackerMultiRecHit::weight(), and SiTrackerMultiRecHit::weights().

Referenced by associateHitId().

545  {
546  std::vector<const TrackingRecHit*> componenthits = multirechit->recHits();
547  int size=multirechit->weights().size(), idmostprobable=0;
548 
549  for (int i=0; i<size; i++){
550  if(multirechit->weight(i)>multirechit->weight(idmostprobable)) idmostprobable=i;
551  }
552 
553  std::vector< SimHitIdpr > simhitid;
554  associateHitId(*componenthits[idmostprobable], simhitid, simhitCFPos);
555  return simhitid;
556 }
int i
Definition: DBlmapReader.cc:9
float weight(unsigned int i) const
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
std::vector< float > const & weights() const
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
tuple size
Write out results.
void TrackerHitAssociator::associatePixelRecHit ( const SiPixelRecHit pixelrechit,
std::vector< SimHitIdpr > &  simhitid,
std::vector< simhitAddr > *  simhitCFPos = 0 
) const

Definition at line 453 of file TrackerHitAssociator.cc.

References PixelDigi::channelToPixel(), SiPixelRecHit::cluster(), edm::DetSet< T >::data, cond::rpcobgas::detid, spr::find(), TrackingRecHit::geographicalId(), edm::Ref< C, T, F >::isNull(), pixeldigisimlink, DetId::rawId(), and DetId::subdetId().

Referenced by associateHitId().

456 {
457  //
458  // Pixel associator
459  //
460  DetId detid= pixelrechit->geographicalId();
461  uint32_t detID = detid.rawId();
462 
464  if(isearch != pixeldigisimlink->end()) { //if it is not empty
465  edm::DetSet<PixelDigiSimLink> link_detset = (*isearch);
466  SiPixelRecHit::ClusterRef const& cluster = pixelrechit->cluster();
467 
468  //check the reference is valid
469 
470  if(!(cluster.isNull())){//if the cluster is valid
471 
472  int minPixelRow = (*cluster).minPixelRow();
473  int maxPixelRow = (*cluster).maxPixelRow();
474  int minPixelCol = (*cluster).minPixelCol();
475  int maxPixelCol = (*cluster).maxPixelCol();
476  //std::cout << " Cluster minRow " << minPixelRow << " maxRow " << maxPixelRow << std::endl;
477  //std::cout << " Cluster minCol " << minPixelCol << " maxCol " << maxPixelCol << std::endl;
478  edm::DetSet<PixelDigiSimLink>::const_iterator linkiter = link_detset.data.begin();
479  int dsl = 0;
480  std::vector<SimHitIdpr> idcachev;
481  std::vector<simhitAddr> CFposcachev;
482  for( ; linkiter != link_detset.data.end(); linkiter++) {
483  dsl++;
484  std::pair<int,int> pixel_coord = PixelDigi::channelToPixel(linkiter->channel());
485  //std::cout << " " << dsl << ") Digi link: row " << pixel_coord.first << " col " << pixel_coord.second << std::endl;
486  if( pixel_coord.first <= maxPixelRow &&
487  pixel_coord.first >= minPixelRow &&
488  pixel_coord.second <= maxPixelCol &&
489  pixel_coord.second >= minPixelCol ) {
490  //std::cout << " !-> trackid " << linkiter->SimTrackId() << endl;
491  //std::cout << " fraction " << linkiter->fraction() << endl;
492  SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
493  if(find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
494  simtrackid.push_back(currentId);
495  idcachev.push_back(currentId);
496  }
497 
498  if (simhitCFPos != 0) {
499  //create a vector that contains all the position (in the MixCollection) of the SimHits that contributed to the RecHit
500  //write position only once
501  unsigned int currentCFPos = linkiter->CFposition();
502  unsigned int tofBin = linkiter->TofBin();
503  simHitCollectionID theSimHitCollID = std::make_pair(detid.subdetId(), tofBin);
504  simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
505 
506  if(find(CFposcachev.begin(), CFposcachev.end(), currentAddr) == CFposcachev.end()) {
507  CFposcachev.push_back(currentAddr);
508  simhitCFPos->push_back(currentAddr);
509  }
510  }
511 
512  }
513  }
514  }
515  else{
516  edm::LogError("TrackerHitAssociator")<<"no Pixel cluster reference attached";
517 
518  }
519  }
520 }
std::pair< simHitCollectionID, unsigned int > simhitAddr
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool isNull() const
Checks for null.
Definition: Ref.h:247
Definition: DetId.h:18
std::pair< uint32_t, EncodedEventId > SimHitIdpr
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
static std::pair< int, int > channelToPixel(int ch)
Definition: PixelDigi.h:62
collection_type data
Definition: DetSet.h:78
DetId geographicalId() const
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
std::pair< unsigned int, unsigned int > simHitCollectionID
std::vector< SimHitIdpr > TrackerHitAssociator::associateProjectedRecHit ( const ProjectedSiStripRecHit2D projectedrechit,
std::vector< simhitAddr > *  simhitCFPos = 0 
) const

Definition at line 441 of file TrackerHitAssociator.cc.

References associateSiStripRecHit(), and ProjectedSiStripRecHit2D::originalHit().

Referenced by associateHitId().

443 {
444  //projectedRecHit is a "matched" rechit with only one component
445 
446  std::vector<SimHitIdpr> matched_mono;
447 
448  const SiStripRecHit2D mono = projectedrechit->originalHit();
449  associateSiStripRecHit(&mono, matched_mono, simhitCFPos);
450  return matched_mono;
451 }
SiStripRecHit2D originalHit() const
void associateSiStripRecHit(const T *simplerechit, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
void TrackerHitAssociator::associateSimpleRecHitCluster ( const SiStripCluster clust,
const DetId detid,
std::vector< SimHitIdpr > &  simtrackid,
std::vector< simhitAddr > *  simhitCFPos = 0 
) const

Definition at line 331 of file TrackerHitAssociator.cc.

References SiStripCluster::amplitudes(), edm::DetSet< T >::data, spr::find(), first, SiStripCluster::firstStrip(), prof2calltree::last, DetId::rawId(), stripdigisimlink, and DetId::subdetId().

Referenced by associateSiStripRecHit(), and TrackClusterSplitter::splitCluster().

334  {
335 
336  uint32_t detID = detid.rawId();
338  if(isearch != stripdigisimlink->end()) { //if it is not empty
339  edm::DetSet<StripDigiSimLink> link_detset = (*isearch);
340 
341  if(clust!=0){//the cluster is valid
342  int clusiz = clust->amplitudes().size();
343  int first = clust->firstStrip();
344  int last = first + clusiz;
345 
346 // std::cout << "CLUSTERSIZE " << clusiz << " first strip = " << first << " last strip = " << last-1 << std::endl;
347 // std::cout << " detID = " << detID << " DETSET size = " << link_detset.data.size() << std::endl;
348  //use a vector
349  std::vector<SimHitIdpr> idcachev;
350  std::vector<simhitAddr> CFposcachev;
351  for(edm::DetSet<StripDigiSimLink>::const_iterator linkiter = link_detset.data.begin(); linkiter != link_detset.data.end(); linkiter++){
352  if( (int)(linkiter->channel()) >= first && (int)(linkiter->channel()) < last ){
353 
354  //check this digisimlink
355 // printf("%s%4d%s%8d%s%3d%s%8.4f\n", "CHANNEL = ", linkiter->channel(), " TrackID = ", linkiter->SimTrackId(),
356 // " tofBin = ", linkiter->TofBin(), " fraction = ", linkiter->fraction());
357  /*
358  std::cout << "CHECKING CHANNEL = " << linkiter->channel() << std::endl;
359  std::cout << "TrackID = " << linkiter->SimTrackId() << std::endl;
360  std::cout << "Position = " << linkiter->CFposition() << std::endl;
361  std::cout << " fraction = " << linkiter->fraction() << std::endl;
362  */
363 
364  SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
365 
366  //create a vector with the list of SimTrack ID's of the tracks that contributed to the RecHit
367  //write the id only once in the vector
368 
369  if(find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
370  /*
371  std::cout << " Adding track id = " << currentId.first
372  << " Event id = " << currentId.second.event()
373  << " Bunch Xing = " << currentId.second.bunchCrossing()
374  << std::endl;
375  */
376  idcachev.push_back(currentId);
377  simtrackid.push_back(currentId);
378  }
379 
380  if (simhitCFPos != 0) {
381  //create a vector that contains all the position (in the MixCollection) of the SimHits that contributed to the RecHit
382  //write position only once
383  unsigned int currentCFPos = linkiter->CFposition();
384  unsigned int tofBin = linkiter->TofBin();
385  simHitCollectionID theSimHitCollID = std::make_pair(detid.subdetId(), tofBin);
386  simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
387 
388  if(find(CFposcachev.begin(), CFposcachev.end(), currentAddr ) == CFposcachev.end()) {
389 // std::cout << "CHECKING CHANNEL = " << linkiter->channel() << std::endl;
390 // std::cout << "\tTrackID = " << linkiter->SimTrackId() << "\tCFPos = " << currentCFPos <<"\ttofBin = " << tofBin << std::endl;
391 // simhit_collectionMap::const_iterator it = SimHitCollMap.find(theSimHitCollID);
392 // if (it!= SimHitCollMap.end()) {
393 // PSimHit theSimHit = it->second[currentCFPos];
394 // std::cout << "\tLocal Pos = " << theSimHit.localPosition()
395 // << "\tProcess = " << theSimHit.processType() << std::endl;
396 // }
397  CFposcachev.push_back(currentAddr);
398  simhitCFPos->push_back(currentAddr);
399  }
400  }
401  }
402  }
403  }
404  else {
405  edm::LogError("TrackerHitAssociator")<<"no cluster reference attached";
406  }
407  }
408 }
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
std::pair< simHitCollectionID, unsigned int > simhitAddr
uint16_t firstStrip() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
bool first
Definition: L1TdeRCT.cc:75
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::pair< uint32_t, EncodedEventId > SimHitIdpr
collection_type data
Definition: DetSet.h:78
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
const std::vector< uint8_t > & amplitudes() const
std::pair< unsigned int, unsigned int > simHitCollectionID
template<typename T >
void TrackerHitAssociator::associateSiStripRecHit ( const T simplerechit,
std::vector< SimHitIdpr > &  simtrackid,
std::vector< simhitAddr > *  simhitCFPos = 0 
) const

Definition at line 325 of file TrackerHitAssociator.cc.

References associateSimpleRecHitCluster().

Referenced by associateHitId(), associateMatchedRecHit(), and associateProjectedRecHit().

326 {
327  const SiStripCluster* clust = &(*simplerechit->cluster());
328  associateSimpleRecHitCluster(clust, simplerechit->geographicalId(), simtrackid, simhitCFPos);
329 }
void associateSimpleRecHitCluster(const SiStripCluster *clust, const DetId &detid, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
void TrackerHitAssociator::makeMaps ( const edm::Event theEvent,
const vstring  trackerContainers 
)
private

Definition at line 73 of file TrackerHitAssociator.cc.

References assocHitbySimTrack_, edm::Event::getByLabel(), StripDigiSimLink::HighTof, StripDigiSimLink::LowTof, edm::Handle< T >::product(), SimHitCollMap, SimHitMap, trackerHits::simHits, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TrackerHitAssociator().

73  {
74  // Step A: Get Inputs
75  // The collections are specified via ROUList in the configuration, and can
76  // be either crossing frames (e.g., mix/g4SimHitsTrackerHitsTIBLowTof)
77  // or just PSimHits (e.g., g4SimHits/TrackerHitsTIBLowTof)
78 
79  for(auto const& trackerContainer : trackerContainers) {
81  edm::InputTag tag_cf("mix", trackerContainer);
83  edm::InputTag tag_hits("g4SimHits", trackerContainer);
84  int Nhits = 0;
85  if (theEvent.getByLabel(tag_cf, cf_simhit)) {
86  std::auto_ptr<MixCollection<PSimHit> > thisContainerHits(new MixCollection<PSimHit>(cf_simhit.product()));
87  for (MixCollection<PSimHit>::iterator isim = thisContainerHits->begin();
88  isim != thisContainerHits->end(); isim++) {
89  DetId theDet((*isim).detUnitId());
90  if (assocHitbySimTrack_) {
91  SimHitMap[theDet].push_back((*isim));
92  } else {
93  unsigned int tofBin = StripDigiSimLink::LowTof;
94  if (trackerContainer.find(std::string("HighTof")) != std::string::npos) tofBin = StripDigiSimLink::HighTof;
95  simHitCollectionID theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin);
96  SimHitCollMap[theSimHitCollID].push_back((*isim));
97  }
98  Nhits++;
99  }
100  // std::cout << "simHits from crossing frames; map size = " << SimHitCollMap.size() << ", Hit count = " << Nhits << std::endl;
101  } else {
102  theEvent.getByLabel(tag_hits, simHits);
103  for (std::vector<PSimHit>::const_iterator isim = simHits->begin();
104  isim != simHits->end(); isim++) {
105  DetId theDet((*isim).detUnitId());
106  if (assocHitbySimTrack_) {
107  SimHitMap[theDet].push_back((*isim));
108  } else {
109  unsigned int tofBin = StripDigiSimLink::LowTof;
110  if (trackerContainer.find(std::string("HighTof")) != std::string::npos) tofBin = StripDigiSimLink::HighTof;
111  simHitCollectionID theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin);
112  SimHitCollMap[theSimHitCollID].push_back((*isim));
113  }
114  Nhits++;
115  }
116  // std::cout << "simHits from prompt collections; map size = " << SimHitCollMap.size() << ", Hit count = " << Nhits << std::endl;
117  }
118  }
119 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
simhit_collectionMap SimHitCollMap
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
tuple simHits
Definition: trackerHits.py:16
std::pair< unsigned int, unsigned int > simHitCollectionID

Member Data Documentation

bool TrackerHitAssociator::assocHitbySimTrack_
private

Definition at line 99 of file TrackerHitAssociator.h.

Referenced by associateHit(), makeMaps(), and TrackerHitAssociator().

bool TrackerHitAssociator::doPixel_
private

Definition at line 99 of file TrackerHitAssociator.h.

Referenced by TrackerHitAssociator().

bool TrackerHitAssociator::doStrip_
private

Definition at line 99 of file TrackerHitAssociator.h.

Referenced by TrackerHitAssociator().

bool TrackerHitAssociator::doTrackAssoc_
private

Definition at line 99 of file TrackerHitAssociator.h.

Referenced by associateHit(), and TrackerHitAssociator().

edm::Handle< edm::DetSetVector<PixelDigiSimLink> > TrackerHitAssociator::pixeldigisimlink
private

Definition at line 97 of file TrackerHitAssociator.h.

Referenced by associatePixelRecHit(), and TrackerHitAssociator().

simhit_collectionMap TrackerHitAssociator::SimHitCollMap

Definition at line 89 of file TrackerHitAssociator.h.

Referenced by associateHit(), and makeMaps().

simhit_map TrackerHitAssociator::SimHitMap
edm::Handle< edm::DetSetVector<StripDigiSimLink> > TrackerHitAssociator::stripdigisimlink
private

Definition at line 96 of file TrackerHitAssociator.h.

Referenced by associateSimpleRecHitCluster(), and TrackerHitAssociator().