test
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 Attributes
TrackerHitAssociator Class Reference

#include <TrackerHitAssociator.h>

Public Types

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

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) const
 
std::vector< SimHitIdprassociateMatchedRecHit (const SiStripMatchedRecHit2D *matchedrechit) const
 
std::vector< PSimHitassociateMultiRecHit (const SiTrackerMultiRecHit *multirechit) const
 
std::vector< SimHitIdprassociateMultiRecHitId (const SiTrackerMultiRecHit *multirechit) const
 
void associatePixelRecHit (const SiPixelRecHit *pixelrechit, std::vector< SimHitIdpr > &simhitid) const
 
std::vector< SimHitIdprassociateProjectedRecHit (const ProjectedSiStripRecHit2D *projectedrechit) const
 
void associateSimpleRecHitCluster (const SiStripCluster *clust, const uint32_t &detID, std::vector< SimHitIdpr > &simtrackid) const
 
template<typename T >
void associateSiStripRecHit (const T *simplerechit, std::vector< SimHitIdpr > &simtrackid) const
 
 TrackerHitAssociator (const edm::Event &e)
 
 TrackerHitAssociator (const edm::Event &e, const edm::ParameterSet &conf)
 
virtual ~TrackerHitAssociator ()
 

Public Attributes

simhit_map SimHitMap
 

Private Types

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

Private Attributes

bool doPixel_
 
bool doStrip_
 
bool doTrackAssoc_
 
const edm::EventmyEvent_
 
edm::Handle< edm::DetSetVector
< PixelDigiSimLink > > 
pixeldigisimlink
 
edm::Handle< edm::DetSetVector
< StripDigiSimLink > > 
stripdigisimlink
 
vstring trackerContainers
 

Detailed Description

Definition at line 54 of file TrackerHitAssociator.h.

Member Typedef Documentation

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

Definition at line 83 of file TrackerHitAssociator.h.

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

Definition at line 88 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(), pixeldigisimlink, edm::Handle< T >::product(), SimHitMap, trackerHits::simHits, stripdigisimlink, and trackerContainers.

26  :
27  myEvent_(e),
28  doPixel_( true ),
29  doStrip_( true ),
30  doTrackAssoc_( false ) {
31  SimHitMap.clear();
32  trackerContainers.clear();
33  //
34  // Take by default all tracker SimHits
35  //
36  trackerContainers.push_back("g4SimHitsTrackerHitsTIBLowTof");
37  trackerContainers.push_back("g4SimHitsTrackerHitsTIBHighTof");
38  trackerContainers.push_back("g4SimHitsTrackerHitsTIDLowTof");
39  trackerContainers.push_back("g4SimHitsTrackerHitsTIDHighTof");
40  trackerContainers.push_back("g4SimHitsTrackerHitsTOBLowTof");
41  trackerContainers.push_back("g4SimHitsTrackerHitsTOBHighTof");
42  trackerContainers.push_back("g4SimHitsTrackerHitsTECLowTof");
43  trackerContainers.push_back("g4SimHitsTrackerHitsTECHighTof");
44  trackerContainers.push_back("g4SimHitsTrackerHitsPixelBarrelLowTof");
45  trackerContainers.push_back("g4SimHitsTrackerHitsPixelBarrelHighTof");
46  trackerContainers.push_back("g4SimHitsTrackerHitsPixelEndcapLowTof");
47  trackerContainers.push_back("g4SimHitsTrackerHitsPixelEndcapHighTof");
48 
49  // Step A: Get Inputs
50 
51  for(auto const& trackerContainer : trackerContainers) {
52 
54  edm::InputTag tag_cf("mix", trackerContainer);
56  edm::InputTag tag_hits("g4SimHits", trackerContainer);
57  if (e.getByLabel(tag_cf, cf_simhit)) {
58  std::auto_ptr<MixCollection<PSimHit> > thisContainerHits(new MixCollection<PSimHit>(cf_simhit.product()));
59  for (MixCollection<PSimHit>::iterator isim = thisContainerHits->begin();
60  isim != thisContainerHits->end(); isim++)
61  SimHitMap[(*isim).detUnitId()].push_back((*isim));
62  } else {
63  e.getByLabel(tag_hits, simHits);
64  for (std::vector<PSimHit>::const_iterator isim = simHits->begin();
65  isim != simHits->end(); isim++)
66  SimHitMap[(*isim).detUnitId()].push_back((*isim));
67  }
68  }
69 
70  if(doStrip_) e.getByLabel("simSiStripDigis", stripdigisimlink);
71  if(doPixel_) e.getByLabel("simSiPixelDigis", pixeldigisimlink);
72 }
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple simHits
Definition: trackerHits.py:16
T const * product() const
Definition: Handle.h:81
const edm::Event & myEvent_
TrackerHitAssociator::TrackerHitAssociator ( const edm::Event e,
const edm::ParameterSet conf 
)

Definition at line 77 of file TrackerHitAssociator.cc.

References doPixel_, doStrip_, doTrackAssoc_, edm::Event::getByLabel(), edm::ParameterSet::getParameter(), pixeldigisimlink, edm::Handle< T >::product(), SimHitMap, trackerHits::simHits, stripdigisimlink, and trackerContainers.

77  :
78  myEvent_(e),
79  doPixel_( conf.getParameter<bool>("associatePixel") ),
80  doStrip_( conf.getParameter<bool>("associateStrip") ),
81  doTrackAssoc_( conf.getParameter<bool>("associateRecoTracks") ) {
82  SimHitMap.clear();
83 
84  //if track association there is no need to access the input collections
85  if(!doTrackAssoc_) {
86 
87  trackerContainers.clear();
88  trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
89 
90  // Step A: Get Inputs
91  // The collections are specified via ROUList in the configuration, and can
92  // be either crossing frames (e.g., mix/g4SimHitsTrackerHitsTIBLowTof)
93  // or just PSimHits (e.g., g4SimHits/TrackerHitsTIBLowTof)
94 
95  for(auto const& trackerContainer : trackerContainers) {
96 
98  edm::InputTag tag_cf("mix", trackerContainer);
100  edm::InputTag tag_hits("g4SimHits", trackerContainer);
101  int Nhits = 0;
102  if (e.getByLabel(tag_cf, cf_simhit)) {
103  std::auto_ptr<MixCollection<PSimHit> > thisContainerHits(new MixCollection<PSimHit>(cf_simhit.product()));
104  for (MixCollection<PSimHit>::iterator isim = thisContainerHits->begin();
105  isim != thisContainerHits->end(); isim++) {
106  SimHitMap[(*isim).detUnitId()].push_back((*isim));
107  Nhits++;
108  }
109 // std::cout << "simHits from crossing frames; map size = " << SimHitMap.size() << ", Hit count = " << Nhits << std::endl;
110  } else {
111  e.getByLabel(tag_hits, simHits);
112  for (std::vector<PSimHit>::const_iterator isim = simHits->begin();
113  isim != simHits->end(); isim++) {
114  SimHitMap[(*isim).detUnitId()].push_back((*isim));
115  Nhits++;
116  }
117 // std::cout << "simHits from prompt collection; map size = " << SimHitMap.size() << ", Hit count = " << Nhits << std::endl;
118  }
119  }
120  }
121 
122  if(doStrip_) e.getByLabel("simSiStripDigis", stripdigisimlink);
123  if(doPixel_) e.getByLabel("simSiPixelDigis", pixeldigisimlink);
124 }
T getParameter(std::string const &) const
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple simHits
Definition: trackerHits.py:16
T const * product() const
Definition: Handle.h:81
const edm::Event & myEvent_
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 481 of file TrackerHitAssociator.cc.

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

Referenced by associateHitId().

482 {
483  //GSRecHit is the FastSimulation RecHit that contains the TrackId already
484 
485  vector<SimHitIdpr> simtrackid;
486  simtrackid.clear();
487  SimHitIdpr currentId(gsmrechit->simtrackId(), EncodedEventId(gsmrechit->eeId()));
488  simtrackid.push_back(currentId);
489  return simtrackid;
490 }
std::pair< uint32_t, EncodedEventId > SimHitIdpr
const uint32_t & eeId() const
std::vector< SimHitIdpr > TrackerHitAssociator::associateGSRecHit ( const SiTrackerGSRecHit2D gsrechit) const

Definition at line 447 of file TrackerHitAssociator.cc.

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

Referenced by associateHitId().

448 {
449  //GSRecHit is the FastSimulation RecHit that contains the TrackId already
450 
451  vector<SimHitIdpr> simtrackid;
452  simtrackid.clear();
453  SimHitIdpr currentId(gsrechit->simtrackId(), EncodedEventId(gsrechit->eeId()));
454  simtrackid.push_back(currentId);
455  return simtrackid;
456 }
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 126 of file TrackerHitAssociator.cc.

References associateHitId(), begin, cond::rpcobgas::detid, doTrackAssoc_, end, PSimHit::eventId(), first, TrackingRecHit::geographicalId(), i, DetId::rawId(), query::result, edm::second(), 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().

127 {
128 
129  //vector with the matched SimHit
130  std::vector<PSimHit> result;
131 
132  if(doTrackAssoc_) return result;
133 
134  //initialize vectors!
135  std::vector<SimHitIdpr> simtrackid;
136 
137  //get the Detector type of the rechit
138  DetId detid= thit.geographicalId();
139  uint32_t detID = detid.rawId();
140 
141  // Get the vector of simtrackIDs associated with this rechit
142  simtrackid = associateHitId(thit);
143 
144  //
145  //Save the SimHits in a vector. for the matched hits both the rphi and stereo simhits are saved.
146  //
147  //now get the SimHit from the trackid
148  vector<PSimHit> simHit;
149  std::map<unsigned int, std::vector<PSimHit> >::const_iterator it = SimHitMap.find(detID);
150  simHit.clear();
151  if (it!= SimHitMap.end()) {
152  simHit = it->second;
153  vector<PSimHit>::const_iterator simHitIter = simHit.begin();
154  vector<PSimHit>::const_iterator simHitIterEnd = simHit.end();
155  for (;simHitIter != simHitIterEnd; ++simHitIter) {
156  const PSimHit ihit = *simHitIter;
157  unsigned int simHitid = ihit.trackId();
158  EncodedEventId simHiteid = ihit.eventId();
159 
160  for(size_t i=0; i<simtrackid.size();i++) {
161  if(simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second) {
162 // cout << "Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x()
163 // << " y= " << ihit.localPosition().y() << " z= " << ihit.localPosition().x() << endl;
164  result.push_back(ihit);
165  break;
166  }
167  }
168  }
169 
170  }else{
171 
173  std::map<unsigned int, std::vector<PSimHit> >::const_iterator itrphi =
174  SimHitMap.find(detID+2); //iterator to the simhit in the rphi module
175  std::map<unsigned int, std::vector<PSimHit> >::const_iterator itster =
176  SimHitMap.find(detID+1);//iterator to the simhit in the stereo module
177  if (itrphi!= SimHitMap.end()&&itster!=SimHitMap.end()) {
178  simHit = itrphi->second;
179  simHit.insert(simHit.end(),(itster->second).begin(),(itster->second).end());
180  vector<PSimHit>::const_iterator simHitIter = simHit.begin();
181  vector<PSimHit>::const_iterator simHitIterEnd = simHit.end();
182  for (;simHitIter != simHitIterEnd; ++simHitIter) {
183  const PSimHit ihit = *simHitIter;
184  unsigned int simHitid = ihit.trackId();
185  EncodedEventId simHiteid = ihit.eventId();
186  for(size_t i=0; i<simtrackid.size();i++) {
187  if(simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second) {
188  // cout << "GluedDet Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x()
189  // << " y= " << ihit.localPosition().y() << " z= " << ihit.localPosition().x() << endl;
190  result.push_back(ihit);
191  break;
192  }
193  }
194  }
195  }
196  }
197 
198  return result;
199 }
int i
Definition: DBlmapReader.cc:9
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
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::vector< SimHitIdpr > TrackerHitAssociator::associateHitId ( const TrackingRecHit thit) const
void TrackerHitAssociator::associateHitId ( const TrackingRecHit thit,
std::vector< SimHitIdpr > &  simhitid 
) const

Definition at line 208 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.

209 {
210 
211  simtkid.clear();
212 
213  //get the Detector type of the rechit
214  DetId detid= thit.geographicalId();
215  if (const SiTrackerMultiRecHit * rechit = dynamic_cast<const SiTrackerMultiRecHit *>(&thit)){
216  simtkid=associateMultiRecHitId(rechit);
217  }
218 
219  //cout << "Associator ---> get Detid " << detID << endl;
220  //check we are in the strip tracker
221  if(detid.subdetId() == StripSubdetector::TIB ||
222  detid.subdetId() == StripSubdetector::TOB ||
223  detid.subdetId() == StripSubdetector::TID ||
224  detid.subdetId() == StripSubdetector::TEC)
225  {
226  //check if it is a simple SiStripRecHit2D
227  if(const SiStripRecHit2D * rechit =
228  dynamic_cast<const SiStripRecHit2D *>(&thit))
229  {
230  associateSiStripRecHit(rechit, simtkid);
231  }
232  //check if it is a matched SiStripMatchedRecHit2D
233  else if(const SiStripRecHit1D * rechit =
234  dynamic_cast<const SiStripRecHit1D *>(&thit))
235  {
236  associateSiStripRecHit(rechit,simtkid);
237  }
238  //check if it is a matched SiStripMatchedRecHit2D
239  else if(const SiStripMatchedRecHit2D * rechit =
240  dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
241  {
242  simtkid = associateMatchedRecHit(rechit);
243  }
244  //check if it is a ProjectedSiStripRecHit2D
245  else if(const ProjectedSiStripRecHit2D * rechit =
246  dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
247  {
248  simtkid = associateProjectedRecHit(rechit);
249  }
250  else{
251  //std::cout << "associate to invalid" << std::endl;
252  //throw cms::Exception("Unknown RecHit Type") << "TrackerHitAssociator failed second casting of " << typeid(thit).name() << " type ";
253  }
254  }
255  //check we are in the pixel tracker
256  else if( (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelBarrel ||
257  (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelEndcap)
258  {
259  if(const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
260  {
261  associatePixelRecHit(rechit,simtkid );
262  }
263  }
264  //check if these are GSRecHits (from FastSim)
265  if(const SiTrackerGSRecHit2D * rechit = dynamic_cast<const SiTrackerGSRecHit2D *>(&thit))
266  {
267  simtkid = associateGSRecHit(rechit);
268  }
269  if(const SiTrackerGSMatchedRecHit2D * rechit = dynamic_cast<const SiTrackerGSMatchedRecHit2D *>(&thit))
270  {
271  simtkid = associateGSMatchedRecHit(rechit);
272  }
273 
274 }
std::vector< SimHitIdpr > associateProjectedRecHit(const ProjectedSiStripRecHit2D *projectedrechit) const
std::vector< SimHitIdpr > associateMultiRecHitId(const SiTrackerMultiRecHit *multirechit) 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
void associatePixelRecHit(const SiPixelRecHit *pixelrechit, std::vector< SimHitIdpr > &simhitid) const
std::vector< SimHitIdpr > associateGSRecHit(const SiTrackerGSRecHit2D *gsrechit) const
DetId geographicalId() const
std::vector< SimHitIdpr > associateMatchedRecHit(const SiStripMatchedRecHit2D *matchedrechit) const
void associateSiStripRecHit(const T *simplerechit, std::vector< SimHitIdpr > &simtrackid) const
Our base class.
Definition: SiPixelRecHit.h:23
std::vector< SimHitIdpr > TrackerHitAssociator::associateMatchedRecHit ( const SiStripMatchedRecHit2D matchedrechit) const

Definition at line 349 of file TrackerHitAssociator.cc.

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

Referenced by associateHitId().

350 {
351  vector<SimHitIdpr> matched_mono;
352  vector<SimHitIdpr> matched_st;
353  matched_mono.clear();
354  matched_st.clear();
355 
356  const SiStripRecHit2D mono = matchedrechit->monoHit();
357  const SiStripRecHit2D st = matchedrechit->stereoHit();
358  //associate the two simple hits separately
359  associateSiStripRecHit(&mono,matched_mono );
360  associateSiStripRecHit(&st, matched_st );
361 
362  //save in a vector all the simtrack-id's that are common to mono and stereo hits
363  std::vector<SimHitIdpr> simtrackid;
364  if(!matched_mono.empty() && !matched_st.empty()){
365  std::vector<SimHitIdpr> idcachev;
366  for(vector<SimHitIdpr>::iterator mhit=matched_mono.begin(); mhit != matched_mono.end(); mhit++){
367  //save only once the ID
368  if(find(idcachev.begin(), idcachev.end(),(*mhit)) == idcachev.end()) {
369  idcachev.push_back(*mhit);
370  //save if the stereoID matched the monoID
371  if(find(matched_st.begin(), matched_st.end(),(*mhit))!=matched_st.end()){
372  simtrackid.push_back(*mhit);
373  //std::cout << "matched case: saved ID " << (*mhit) << std::endl;
374  }
375  }
376  }
377  }
378  return simtrackid;
379 }
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) const
std::vector< PSimHit > TrackerHitAssociator::associateMultiRecHit ( const SiTrackerMultiRecHit multirechit) const

Definition at line 458 of file TrackerHitAssociator.cc.

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

458  {
459  std::vector<const TrackingRecHit*> componenthits = multirechit->recHits();
460  // std::vector<PSimHit> assimhits;
461  int size=multirechit->weights().size(), idmostprobable=0;
462 
463  for (int i=0; i<size; i++){
464  if(multirechit->weight(i)>multirechit->weight(idmostprobable)) idmostprobable=i;
465  }
466 
467  return associateHit(*componenthits[idmostprobable]);
468 }
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) const

Definition at line 470 of file TrackerHitAssociator.cc.

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

Referenced by associateHitId().

470  {
471  std::vector<const TrackingRecHit*> componenthits = multirechit->recHits();
472  int size=multirechit->weights().size(), idmostprobable=0;
473 
474  for (int i=0; i<size; i++){
475  if(multirechit->weight(i)>multirechit->weight(idmostprobable)) idmostprobable=i;
476  }
477 
478  return associateHitId(*componenthits[idmostprobable]);
479 }
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 
) const

Definition at line 395 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, and DetId::rawId().

Referenced by associateHitId().

396 {
397  //
398  // Pixel associator
399  //
400  DetId detid= pixelrechit->geographicalId();
401  uint32_t detID = detid.rawId();
402 
404  if(isearch != pixeldigisimlink->end()) { //if it is not empty
405  edm::DetSet<PixelDigiSimLink> link_detset = (*isearch);
406  SiPixelRecHit::ClusterRef const& cluster = pixelrechit->cluster();
407 
408  //check the reference is valid
409 
410  if(!(cluster.isNull())){//if the cluster is valid
411 
412  int minPixelRow = (*cluster).minPixelRow();
413  int maxPixelRow = (*cluster).maxPixelRow();
414  int minPixelCol = (*cluster).minPixelCol();
415  int maxPixelCol = (*cluster).maxPixelCol();
416  //std::cout << " Cluster minRow " << minPixelRow << " maxRow " << maxPixelRow << std::endl;
417  //std::cout << " Cluster minCol " << minPixelCol << " maxCol " << maxPixelCol << std::endl;
418  edm::DetSet<PixelDigiSimLink>::const_iterator linkiter = link_detset.data.begin();
419  int dsl = 0;
420  std::vector<SimHitIdpr> idcachev;
421  for( ; linkiter != link_detset.data.end(); linkiter++) {
422  dsl++;
423  std::pair<int,int> pixel_coord = PixelDigi::channelToPixel(linkiter->channel());
424  //std::cout << " " << dsl << ") Digi link: row " << pixel_coord.first << " col " << pixel_coord.second << std::endl;
425  if( pixel_coord.first <= maxPixelRow &&
426  pixel_coord.first >= minPixelRow &&
427  pixel_coord.second <= maxPixelCol &&
428  pixel_coord.second >= minPixelCol ) {
429  //std::cout << " !-> trackid " << linkiter->SimTrackId() << endl;
430  //std::cout << " fraction " << linkiter->fraction() << endl;
431  SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
432  // if(find(idcachev.begin(),idcachev.end(),linkiter->SimTrackId()) == idcachev.end()){
433  if(find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
434  simtrackid.push_back(currentId);
435  idcachev.push_back(currentId);
436  }
437  }
438  }
439  }
440  else{
441  edm::LogError("TrackerHitAssociator")<<"no Pixel cluster reference attached";
442 
443  }
444  }
445 }
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
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:106
std::vector< SimHitIdpr > TrackerHitAssociator::associateProjectedRecHit ( const ProjectedSiStripRecHit2D projectedrechit) const

Definition at line 382 of file TrackerHitAssociator.cc.

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

Referenced by associateHitId().

383 {
384  //projectedRecHit is a "matched" rechit with only one component
385 
386  vector<SimHitIdpr> matched_mono;
387  matched_mono.clear();
388 
389  const SiStripRecHit2D mono = projectedrechit->originalHit();
390  associateSiStripRecHit(&mono, matched_mono);
391  return matched_mono;
392 }
SiStripRecHit2D originalHit() const
void associateSiStripRecHit(const T *simplerechit, std::vector< SimHitIdpr > &simtrackid) const
void TrackerHitAssociator::associateSimpleRecHitCluster ( const SiStripCluster clust,
const uint32_t &  detID,
std::vector< SimHitIdpr > &  simtrackid 
) const

Definition at line 283 of file TrackerHitAssociator.cc.

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

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

285  {
286  // std::cout <<"ASSOCIATE SIMPLE RECHIT" << std::endl;
287 
288  //to store temporary charge information
289  std::vector<SimHitIdpr> cache_simtrackid;
290  cache_simtrackid.clear();
291 
292  std::map<SimHitIdpr, vector<float> > temp_simtrackid;
293  temp_simtrackid.clear();
294 
296  if(isearch != stripdigisimlink->end()) { //if it is not empty
297  edm::DetSet<StripDigiSimLink> link_detset = (*isearch);
298 
299  if(clust!=0){//the cluster is valid
300  int clusiz = clust->amplitudes().size();
301  int first = clust->firstStrip();
302  int last = first + clusiz;
303 
304 // std::cout << "CLUSTERSIZE " << clusiz << " first strip = " << first << " last strip = " << last-1 << std::endl;
305 // std::cout << " detID = " << detID << " DETSET size = " << link_detset.data.size() << std::endl;
306  //use a vector
307  std::vector<SimHitIdpr> idcachev;
308  for(edm::DetSet<StripDigiSimLink>::const_iterator linkiter = link_detset.data.begin(); linkiter != link_detset.data.end(); linkiter++){
309  //StripDigiSimLink link = *linkiter;
310 
311  if( (int)(linkiter->channel()) >= first && (int)(linkiter->channel()) < last ){
312 
313  //check this digisimlink
314 // printf("%s%4d%s%8d%s%3d%s%8.4f\n", "CHANNEL = ", linkiter->channel(), " TrackID = ", linkiter->SimTrackId(),
315 // " Process = ", TrackerHits.getObject(linkiter->CFposition()-1).processType(), " fraction = ", linkiter->fraction());
316  /*
317  std::cout << "CHECKING CHANNEL = " << linkiter->channel() << std::endl;
318  std::cout << "TrackID = " << linkiter->SimTrackId() << std::endl;
319  std::cout << "Position = " << linkiter->CFposition() << std::endl;
320  std::cout << " POS -1 = " << TrackerHits.getObject(linkiter->CFposition()-1).localPosition() << std::endl;
321  std::cout << " Process = " << TrackerHits.getObject(linkiter->CFposition()-1).processType() << std::endl;
322  std::cout << " fraction = " << linkiter->fraction() << std::endl;
323  */
324 
325  SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
326 
327  //create a vector with the list of SimTrack ID's of the tracks that contributed to the RecHit
328  //write the id only once in the vector
329 
330  if(find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
331  /*
332  std::cout << " Adding track id = " << currentId.first
333  << " Event id = " << currentId.second.event()
334  << " Bunch Xing = " << currentId.second.bunchCrossing()
335  << std::endl;
336  */
337  idcachev.push_back(currentId);
338  simtrackid.push_back(currentId);
339  }
340  }
341  }
342  }
343  else {
344  edm::LogError("TrackerHitAssociator")<<"no cluster reference attached";
345  }
346  }
347 }
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
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
bool first
Definition: L1TdeRCT.cc:75
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:106
const std::vector< uint8_t > & amplitudes() const
template<typename T >
void TrackerHitAssociator::associateSiStripRecHit ( const T simplerechit,
std::vector< SimHitIdpr > &  simtrackid 
) const

Definition at line 277 of file TrackerHitAssociator.cc.

References associateSimpleRecHitCluster().

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

278 {
279  const SiStripCluster* clust = &(*simplerechit->cluster());
280  associateSimpleRecHitCluster(clust,simplerechit->geographicalId(),simtrackid);
281 }
void associateSimpleRecHitCluster(const SiStripCluster *clust, const uint32_t &detID, std::vector< SimHitIdpr > &simtrackid) const

Member Data Documentation

bool TrackerHitAssociator::doPixel_
private

Definition at line 94 of file TrackerHitAssociator.h.

Referenced by TrackerHitAssociator().

bool TrackerHitAssociator::doStrip_
private

Definition at line 94 of file TrackerHitAssociator.h.

Referenced by TrackerHitAssociator().

bool TrackerHitAssociator::doTrackAssoc_
private

Definition at line 94 of file TrackerHitAssociator.h.

Referenced by associateHit(), and TrackerHitAssociator().

const edm::Event& TrackerHitAssociator::myEvent_
private

Definition at line 87 of file TrackerHitAssociator.h.

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

Definition at line 92 of file TrackerHitAssociator.h.

Referenced by associatePixelRecHit(), and TrackerHitAssociator().

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

Definition at line 91 of file TrackerHitAssociator.h.

Referenced by associateSimpleRecHitCluster(), and TrackerHitAssociator().

vstring TrackerHitAssociator::trackerContainers
private

Definition at line 89 of file TrackerHitAssociator.h.

Referenced by TrackerHitAssociator().