30 assocHitbySimTrack_(
false) {
35 std::vector<std::string> trackerContainers;
37 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTIBLowTof");
38 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTIBHighTof");
39 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTIDLowTof");
40 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTIDHighTof");
41 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTOBLowTof");
42 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTOBHighTof");
43 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTECLowTof");
44 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsTECHighTof");
45 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsPixelBarrelLowTof");
46 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsPixelBarrelHighTof");
47 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsPixelEndcapLowTof");
48 trackerContainers.emplace_back(
"g4SimHitsTrackerHitsPixelEndcapHighTof");
49 cfTokens_.reserve(trackerContainers.size());
51 for(
auto const& trackerContainer : trackerContainers) {
62 doPixel_( conf.getParameter<bool>(
"associatePixel") ),
63 doStrip_( conf.getParameter<bool>(
"associateStrip") ),
64 doTrackAssoc_( conf.getParameter<bool>(
"associateRecoTracks") ),
65 assocHitbySimTrack_(conf.existsAs<bool>(
"associateHitbySimTrack") ? conf.getParameter<bool>(
"associateHitbySimTrack") :
false) {
70 std::vector<std::string> trackerContainers(conf.
getParameter<std::vector<std::string> >(
"ROUList"));
71 cfTokens_.reserve(trackerContainers.size());
73 for(
auto const& trackerContainer : trackerContainers) {
102 const char*
const highTag =
"HighTof";
106 for(
auto const& cfToken : config.
cfTokens_) {
109 if (theEvent.
getByToken(cfToken, cf_simhit)) {
117 for (
auto const& isim : *thisContainerHits) {
118 DetId theDet(isim.detUnitId());
128 if(theEvent.
getByToken(simHitToken, simHits)) {
135 for (
auto const& isim : *simHits) {
136 DetId theDet(isim.detUnitId());
145 for(
auto const& cfToken : config.
cfTokens_) {
148 if (theEvent.
getByToken(cfToken, cf_simhit)) {
156 for (
auto const& isim : *thisContainerHits) {
157 DetId theDet(isim.detUnitId());
158 theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin);
168 if(theEvent.
getByToken(simHitToken, simHits)) {
175 for (
auto const& isim : *simHits) {
176 DetId theDet(isim.detUnitId());
177 theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin);
195 std::vector<PSimHit>
result;
200 std::vector<SimHitIdpr> simtrackid;
201 std::vector<simhitAddr> simhitCFPos;
205 uint32_t detID = detid.
rawId();
224 bool isMatchedHit =
false;
225 if(dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
228 size_t simtrackidSize = simtrackid.size();
229 for(
size_t i=0, simhitCFPosSize = simhitCFPos.size();
i<simhitCFPosSize; ++
i) {
232 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
234 unsigned int theSimHitIndex = theSimHitAddr.second;
235 if (theSimHitIndex < (it->second).size()) {
236 const PSimHit& theSimHit = (it->second)[theSimHitIndex];
239 unsigned int simHitid = theSimHit.
trackId();
241 for(
size_t i=0;
i<simtrackidSize;++
i) {
242 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
243 result.push_back(theSimHit);
247 result.push_back(theSimHit);
260 std::map<unsigned int, std::vector<PSimHit> >::const_iterator it =
SimHitMap.find(detID);
262 vector<PSimHit>::const_iterator simHitIter = (it->second).
begin();
263 vector<PSimHit>::const_iterator simHitIterEnd = (it->second).
end();
264 size_t simtrackidSize = simtrackid.size();
265 for (;simHitIter != simHitIterEnd; ++simHitIter) {
266 const PSimHit& ihit = *simHitIter;
267 unsigned int simHitid = ihit.
trackId();
272 for(
size_t i=0;
i<simtrackidSize;++
i) {
273 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
277 result.push_back(ihit);
287 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itrphi =
289 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itster =
292 std::vector<PSimHit> simHitVector = itrphi->second;
293 simHitVector.insert(simHitVector.end(),(itster->second).
begin(),(itster->second).
end());
294 vector<PSimHit>::const_iterator simHitIter = simHitVector.begin();
295 vector<PSimHit>::const_iterator simHitIterEnd = simHitVector.end();
296 size_t simtrackidSize = simtrackid.size();
297 for (;simHitIter != simHitIterEnd; ++simHitIter) {
298 const PSimHit& ihit = *simHitIter;
299 unsigned int simHitid = ihit.
trackId();
301 for(
size_t i=0;
i<simtrackidSize; ++
i) {
302 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
306 result.push_back(ihit);
319 std::vector< SimHitIdpr > simhitid;
325 std::vector<simhitAddr>* simhitCFPos)
const
345 dynamic_cast<const SiStripRecHit2D *>(&thit))
351 dynamic_cast<const SiStripRecHit1D *>(&thit))
357 dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
363 dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
376 if(
const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
405 std::vector<SimHitIdpr>& simtrackid,
406 std::vector<PSimHit>& simhit)
const {
407 std::vector<simhitAddr> simhitCFPos;
410 for(
size_t i=0, simhitCFPosSize = simhitCFPos.size();
i<simhitCFPosSize; ++
i) {
413 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
415 unsigned int theSimHitIndex = theSimHitAddr.second;
416 if (theSimHitIndex < (it->second).size()) simhit.push_back((it->second)[theSimHitIndex]);
428 std::vector<SimHitIdpr>& simtrackid,
429 std::vector<simhitAddr>* simhitCFPos)
const {
431 uint32_t detID = detid.
rawId();
439 int last = first + clusiz;
444 std::vector<SimHitIdpr> idcachev;
445 std::vector<simhitAddr> CFposcachev;
447 if( (
int)(linkiter->channel()) >= first && (
int)(linkiter->channel()) < last ){
459 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
464 if(
find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
471 idcachev.push_back(currentId);
472 simtrackid.push_back(currentId);
475 if (simhitCFPos != 0) {
478 unsigned int currentCFPos = linkiter->CFposition();
479 unsigned int tofBin = linkiter->TofBin();
481 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
483 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr ) == CFposcachev.end()) {
492 CFposcachev.push_back(currentAddr);
493 simhitCFPos->push_back(currentAddr);
500 edm::LogError(
"TrackerHitAssociator")<<
"no cluster reference attached";
507 std::vector<SimHitIdpr> matched_mono;
508 std::vector<SimHitIdpr> matched_st;
517 std::vector<SimHitIdpr> simtrackid;
518 if(!matched_mono.empty() && !matched_st.empty()){
519 std::vector<SimHitIdpr> idcachev;
520 for(vector<SimHitIdpr>::iterator mhit=matched_mono.begin(), mhitEnd = matched_mono.end(); mhit != mhitEnd; ++mhit){
522 if(
find(idcachev.begin(), idcachev.end(), (*mhit)) == idcachev.end()) {
523 idcachev.push_back(*mhit);
525 if(
find(matched_st.begin(), matched_st.end(), (*mhit)) != matched_st.end()) {
526 simtrackid.push_back(*mhit);
537 std::vector<simhitAddr>* simhitCFPos)
const
541 std::vector<SimHitIdpr> matched_mono;
549 std::vector<SimHitIdpr> & simtrackid,
550 std::vector<simhitAddr>* simhitCFPos)
const
556 uint32_t detID = detid.
rawId();
567 int minPixelRow = (*cluster).minPixelRow();
568 int maxPixelRow = (*cluster).maxPixelRow();
569 int minPixelCol = (*cluster).minPixelCol();
570 int maxPixelCol = (*cluster).maxPixelCol();
575 std::vector<SimHitIdpr> idcachev;
576 std::vector<simhitAddr> CFposcachev;
577 for( ; linkiter != linkEnd; ++linkiter) {
581 if( pixel_coord.first <= maxPixelRow &&
582 pixel_coord.first >= minPixelRow &&
583 pixel_coord.second <= maxPixelCol &&
584 pixel_coord.second >= minPixelCol ) {
587 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
588 if(
find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
589 simtrackid.push_back(currentId);
590 idcachev.push_back(currentId);
593 if (simhitCFPos != 0) {
596 unsigned int currentCFPos = linkiter->CFposition();
597 unsigned int tofBin = linkiter->TofBin();
599 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
601 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr) == CFposcachev.end()) {
602 CFposcachev.push_back(currentAddr);
603 simhitCFPos->push_back(currentAddr);
611 edm::LogError(
"TrackerHitAssociator")<<
"no Pixel cluster reference attached";
621 vector<SimHitIdpr> simtrackid;
624 simtrackid.push_back(currentId);
629 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
631 int size=multirechit->
weights().size(), idmostprobable=0;
634 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
641 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
642 int size=multirechit->
weights().size(), idmostprobable=0;
645 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
648 std::vector< SimHitIdpr > simhitid;
649 associateHitId(*componenthits[idmostprobable], simhitid, simhitCFPos);
657 vector<SimHitIdpr> simtrackid;
660 simtrackid.push_back(currentId);
void labelsForToken(EDGetToken const &iToken, ProductLabels &oLabels) const
T getParameter(std::string const &) const
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< edm::EDGetTokenT< CrossingFrame< PSimHit > > > cfTokens_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > pixelToken_
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)
void makeMaps(const edm::Event &theEvent, const Config &config)
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 isNull() const
Checks for null.
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > stripToken_
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
simhit_collectionMap SimHitCollMap
SiStripRecHit2D originalHit() const
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)
TrackerHitAssociator(const edm::Event &e, const Config &config)
SiStripRecHit2D monoHit() const
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
char const * productInstance
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
Config(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
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