29 doTrackAssoc_(
false ),
30 assocHitbySimTrack_(
false ) {
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");
55 doPixel_( conf.getParameter<bool>(
"associatePixel") ),
56 doStrip_( conf.getParameter<bool>(
"associateStrip") ),
57 doTrackAssoc_( conf.getParameter<bool>(
"associateRecoTracks") ) {
69 doPixel_( conf.getParameter<bool>(
"associatePixel") ),
70 doStrip_( conf.getParameter<bool>(
"associateStrip") ),
71 doTrackAssoc_( conf.getParameter<bool>(
"associateRecoTracks") ) {
90 for(
auto const& trackerContainer : trackerContainers) {
99 isim != thisContainerHits->end(); isim++) {
100 DetId theDet((*isim).detUnitId());
114 for (std::vector<PSimHit>::const_iterator isim = simHits->begin();
115 isim != simHits->end(); isim++) {
116 DetId theDet((*isim).detUnitId());
140 std::vector<PSimHit>
result;
145 std::vector<SimHitIdpr> simtrackid;
146 std::vector<simhitAddr> simhitCFPos;
150 uint32_t detID = detid.
rawId();
169 bool isMatchedHit =
false;
170 if(dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
173 for(
size_t i=0;
i<simhitCFPos.size();
i++) {
176 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
178 unsigned int theSimHitIndex = theSimHitAddr.second;
179 if (theSimHitIndex < (it->second).size()) {
180 const PSimHit& theSimHit = (it->second)[theSimHitIndex];
183 unsigned int simHitid = theSimHit.
trackId();
185 for(
size_t i=0;
i<simtrackid.size();
i++) {
186 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
187 result.push_back(theSimHit);
191 result.push_back(theSimHit);
204 std::map<unsigned int, std::vector<PSimHit> >::const_iterator it =
SimHitMap.find(detID);
206 vector<PSimHit>::const_iterator simHitIter = (it->second).
begin();
207 vector<PSimHit>::const_iterator simHitIterEnd = (it->second).
end();
208 for (;simHitIter != simHitIterEnd; ++simHitIter) {
209 const PSimHit& ihit = *simHitIter;
210 unsigned int simHitid = ihit.
trackId();
215 for(
size_t i=0;
i<simtrackid.size();
i++) {
216 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
220 result.push_back(ihit);
230 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itrphi =
232 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itster =
235 std::vector<PSimHit> simHitVector = itrphi->second;
236 simHitVector.insert(simHitVector.end(),(itster->second).
begin(),(itster->second).
end());
237 vector<PSimHit>::const_iterator simHitIter = simHitVector.begin();
238 vector<PSimHit>::const_iterator simHitIterEnd = simHitVector.end();
239 for (;simHitIter != simHitIterEnd; ++simHitIter) {
240 const PSimHit& ihit = *simHitIter;
241 unsigned int simHitid = ihit.
trackId();
243 for(
size_t i=0;
i<simtrackid.size();
i++) {
244 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
248 result.push_back(ihit);
261 std::vector< SimHitIdpr > simhitid;
267 std::vector<simhitAddr>* simhitCFPos)
const
287 dynamic_cast<const SiStripRecHit2D *>(&thit))
293 dynamic_cast<const SiStripRecHit1D *>(&thit))
299 dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
305 dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
318 if(
const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
347 std::vector<SimHitIdpr>& simtrackid,
348 std::vector<PSimHit>& simhit)
const {
349 std::vector<simhitAddr> simhitCFPos;
352 for(
size_t i=0;
i<simhitCFPos.size();
i++) {
355 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
357 unsigned int theSimHitIndex = theSimHitAddr.second;
358 if (theSimHitIndex < (it->second).size()) simhit.push_back((it->second)[theSimHitIndex]);
370 std::vector<SimHitIdpr>& simtrackid,
371 std::vector<simhitAddr>* simhitCFPos)
const {
373 uint32_t detID = detid.
rawId();
381 int last = first + clusiz;
386 std::vector<SimHitIdpr> idcachev;
387 std::vector<simhitAddr> CFposcachev;
389 if( (
int)(linkiter->channel()) >= first && (
int)(linkiter->channel()) < last ){
401 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
406 if(
find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
413 idcachev.push_back(currentId);
414 simtrackid.push_back(currentId);
417 if (simhitCFPos != 0) {
420 unsigned int currentCFPos = linkiter->CFposition();
421 unsigned int tofBin = linkiter->TofBin();
423 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
425 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr ) == CFposcachev.end()) {
434 CFposcachev.push_back(currentAddr);
435 simhitCFPos->push_back(currentAddr);
442 edm::LogError(
"TrackerHitAssociator")<<
"no cluster reference attached";
449 std::vector<SimHitIdpr> matched_mono;
450 std::vector<SimHitIdpr> matched_st;
459 std::vector<SimHitIdpr> simtrackid;
460 if(!matched_mono.empty() && !matched_st.empty()){
461 std::vector<SimHitIdpr> idcachev;
462 for(vector<SimHitIdpr>::iterator mhit=matched_mono.begin(); mhit != matched_mono.end(); mhit++){
464 if(
find(idcachev.begin(), idcachev.end(), (*mhit)) == idcachev.end()) {
465 idcachev.push_back(*mhit);
467 if(
find(matched_st.begin(), matched_st.end(), (*mhit)) != matched_st.end()) {
468 simtrackid.push_back(*mhit);
479 std::vector<simhitAddr>* simhitCFPos)
const
483 std::vector<SimHitIdpr> matched_mono;
491 std::vector<SimHitIdpr> & simtrackid,
492 std::vector<simhitAddr>* simhitCFPos)
const
498 uint32_t detID = detid.
rawId();
509 int minPixelRow = (*cluster).minPixelRow();
510 int maxPixelRow = (*cluster).maxPixelRow();
511 int minPixelCol = (*cluster).minPixelCol();
512 int maxPixelCol = (*cluster).maxPixelCol();
517 std::vector<SimHitIdpr> idcachev;
518 std::vector<simhitAddr> CFposcachev;
519 for( ; linkiter != link_detset.
data.end(); linkiter++) {
523 if( pixel_coord.first <= maxPixelRow &&
524 pixel_coord.first >= minPixelRow &&
525 pixel_coord.second <= maxPixelCol &&
526 pixel_coord.second >= minPixelCol ) {
529 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
530 if(
find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
531 simtrackid.push_back(currentId);
532 idcachev.push_back(currentId);
535 if (simhitCFPos != 0) {
538 unsigned int currentCFPos = linkiter->CFposition();
539 unsigned int tofBin = linkiter->TofBin();
541 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
543 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr) == CFposcachev.end()) {
544 CFposcachev.push_back(currentAddr);
545 simhitCFPos->push_back(currentAddr);
553 edm::LogError(
"TrackerHitAssociator")<<
"no Pixel cluster reference attached";
563 vector<SimHitIdpr> simtrackid;
566 simtrackid.push_back(currentId);
571 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
573 int size=multirechit->
weights().size(), idmostprobable=0;
576 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
583 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
584 int size=multirechit->
weights().size(), idmostprobable=0;
587 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
590 std::vector< SimHitIdpr > simhitid;
591 associateHitId(*componenthits[idmostprobable], simhitid, simhitCFPos);
599 vector<SimHitIdpr> simtrackid;
602 simtrackid.push_back(currentId);
T getParameter(std::string const &) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
std::vector< SimHitIdpr > associateMultiRecHitId(const SiTrackerMultiRecHit *multirechit, std::vector< simhitAddr > *simhitCFPos=0) const
edm::Handle< edm::DetSetVector< StripDigiSimLink > > stripdigisimlink
std::vector< PSimHit > associateMultiRecHit(const SiTrackerMultiRecHit *multirechit) const
std::vector< std::string > vstring
std::pair< simHitCollectionID, unsigned int > simhitAddr
void associatePixelRecHit(const SiPixelRecHit *pixelrechit, std::vector< SimHitIdpr > &simhitid, std::vector< simhitAddr > *simhitCFPos=0) const
uint16_t firstStrip() const
edm::Handle< edm::DetSetVector< PixelDigiSimLink > > pixeldigisimlink
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void associateSimpleRecHitCluster(const SiStripCluster *clust, const DetId &detid, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
float weight(unsigned int i) const
const int & simtrackId() const
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
const int & simtrackId() const
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
std::vector< float > const & weights() const
std::vector< SimHitIdpr > associateGSMatchedRecHit(const SiTrackerGSMatchedRecHit2D *gsmrechit) const
EncodedEventId eventId() const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool isNull() const
Checks for null.
TrackerHitAssociator(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
simhit_collectionMap SimHitCollMap
SiStripRecHit2D originalHit() const
void makeMaps(const edm::Event &theEvent, const vstring trackerContainers)
void associateCluster(const SiStripCluster *clust, const DetId &detid, std::vector< SimHitIdpr > &simtrackid, std::vector< PSimHit > &simhit) const
const uint32_t & eeId() const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
SiStripRecHit2D stereoHit() const
T const * product() const
const uint32_t & eeId() const
ClusterRef cluster() const
static std::pair< int, int > channelToPixel(int ch)
SiStripRecHit2D monoHit() const
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
std::vector< SimHitIdpr > associateProjectedRecHit(const ProjectedSiStripRecHit2D *projectedrechit, std::vector< simhitAddr > *simhitCFPos=0) const
unsigned int trackId() const
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
std::vector< SimHitIdpr > associateGSRecHit(const SiTrackerGSRecHit2D *gsrechit) const
DetId geographicalId() const
volatile std::atomic< bool > shutdown_flag false
collection_type::const_iterator const_iterator
collection_type::const_iterator const_iterator
std::vector< SimHitIdpr > associateMatchedRecHit(const SiStripMatchedRecHit2D *matchedrechit, std::vector< simhitAddr > *simhitCFPos=0) const
tuple size
Write out results.
void associateSiStripRecHit(const T *simplerechit, std::vector< SimHitIdpr > &simtrackid, std::vector< simhitAddr > *simhitCFPos=0) const
const std::vector< uint8_t > & amplitudes() const
std::pair< unsigned int, unsigned int > simHitCollectionID