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))
344 std::vector<SimHitIdpr>& simtrackid,
345 std::vector<simhitAddr>* simhitCFPos)
const {
347 uint32_t detID = detid.
rawId();
355 int last = first + clusiz;
360 std::vector<SimHitIdpr> idcachev;
361 std::vector<simhitAddr> CFposcachev;
363 if( (
int)(linkiter->channel()) >= first && (
int)(linkiter->channel()) < last ){
375 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
380 if(
find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
387 idcachev.push_back(currentId);
388 simtrackid.push_back(currentId);
391 if (simhitCFPos != 0) {
394 unsigned int currentCFPos = linkiter->CFposition();
395 unsigned int tofBin = linkiter->TofBin();
397 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
399 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr ) == CFposcachev.end()) {
408 CFposcachev.push_back(currentAddr);
409 simhitCFPos->push_back(currentAddr);
416 edm::LogError(
"TrackerHitAssociator")<<
"no cluster reference attached";
423 std::vector<SimHitIdpr> matched_mono;
424 std::vector<SimHitIdpr> matched_st;
433 std::vector<SimHitIdpr> simtrackid;
434 if(!matched_mono.empty() && !matched_st.empty()){
435 std::vector<SimHitIdpr> idcachev;
436 for(vector<SimHitIdpr>::iterator mhit=matched_mono.begin(); mhit != matched_mono.end(); mhit++){
438 if(
find(idcachev.begin(), idcachev.end(), (*mhit)) == idcachev.end()) {
439 idcachev.push_back(*mhit);
441 if(
find(matched_st.begin(), matched_st.end(), (*mhit)) != matched_st.end()) {
442 simtrackid.push_back(*mhit);
453 std::vector<simhitAddr>* simhitCFPos)
const
457 std::vector<SimHitIdpr> matched_mono;
465 std::vector<SimHitIdpr> & simtrackid,
466 std::vector<simhitAddr>* simhitCFPos)
const
472 uint32_t detID = detid.
rawId();
483 int minPixelRow = (*cluster).minPixelRow();
484 int maxPixelRow = (*cluster).maxPixelRow();
485 int minPixelCol = (*cluster).minPixelCol();
486 int maxPixelCol = (*cluster).maxPixelCol();
491 std::vector<SimHitIdpr> idcachev;
492 std::vector<simhitAddr> CFposcachev;
493 for( ; linkiter != link_detset.
data.end(); linkiter++) {
497 if( pixel_coord.first <= maxPixelRow &&
498 pixel_coord.first >= minPixelRow &&
499 pixel_coord.second <= maxPixelCol &&
500 pixel_coord.second >= minPixelCol ) {
503 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
504 if(
find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
505 simtrackid.push_back(currentId);
506 idcachev.push_back(currentId);
509 if (simhitCFPos != 0) {
512 unsigned int currentCFPos = linkiter->CFposition();
513 unsigned int tofBin = linkiter->TofBin();
515 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
517 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr) == CFposcachev.end()) {
518 CFposcachev.push_back(currentAddr);
519 simhitCFPos->push_back(currentAddr);
527 edm::LogError(
"TrackerHitAssociator")<<
"no Pixel cluster reference attached";
537 vector<SimHitIdpr> simtrackid;
540 simtrackid.push_back(currentId);
545 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
547 int size=multirechit->
weights().size(), idmostprobable=0;
550 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
557 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
558 int size=multirechit->
weights().size(), idmostprobable=0;
561 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
564 std::vector< SimHitIdpr > simhitid;
565 associateHitId(*componenthits[idmostprobable], simhitid, simhitCFPos);
573 vector<SimHitIdpr> simtrackid;
576 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)
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