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) {
103 for(
auto const& cfToken : config.
cfTokens_) {
106 if (theEvent.
getByToken(cfToken, cf_simhit)) {
108 for (
auto const& isim : *thisContainerHits) {
109 DetId theDet(isim.detUnitId());
119 if(theEvent.
getByToken(simHitToken, simHits)) {
120 for (
auto const& isim : *simHits) {
121 DetId theDet(isim.detUnitId());
129 const char*
const highTag =
"HighTof";
133 for(
auto const& cfToken : config.
cfTokens_) {
136 if (theEvent.
getByToken(cfToken, cf_simhit)) {
144 for (
auto const& isim : *thisContainerHits) {
145 DetId theDet(isim.detUnitId());
146 theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin);
156 if(theEvent.
getByToken(simHitToken, simHits)) {
163 for (
auto const& isim : *simHits) {
164 DetId theDet(isim.detUnitId());
165 theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin);
183 std::vector<PSimHit>
result;
188 std::vector<SimHitIdpr> simtrackid;
189 std::vector<simhitAddr> simhitCFPos;
193 uint32_t detID = detid.
rawId();
212 if(dynamic_cast<const SiStripMatchedRecHit2D *>(&thit)) {
213 for(
auto const& theSimHitAddr : simhitCFPos) {
215 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
217 unsigned int theSimHitIndex = theSimHitAddr.second;
218 if (theSimHitIndex < (it->second).size()) {
219 const PSimHit& theSimHit = (it->second)[theSimHitIndex];
221 unsigned int simHitid = theSimHit.
trackId();
223 for(
auto const&
id : simtrackid) {
224 if(simHitid ==
id.
first && simHiteid ==
id.
second) {
225 result.push_back(theSimHit);
236 for(
auto const& theSimHitAddr : simhitCFPos) {
238 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
240 unsigned int theSimHitIndex = theSimHitAddr.second;
241 if (theSimHitIndex < (it->second).size()) {
242 result.push_back((it->second)[theSimHitIndex]);
255 std::map<unsigned int, std::vector<PSimHit> >::const_iterator it =
SimHitMap.find(detID);
257 vector<PSimHit>::const_iterator simHitIter = (it->second).
begin();
258 vector<PSimHit>::const_iterator simHitIterEnd = (it->second).
end();
259 for (;simHitIter != simHitIterEnd; ++simHitIter) {
260 const PSimHit& ihit = *simHitIter;
261 unsigned int simHitid = ihit.
trackId();
265 for(
auto id : simtrackid) {
266 if(simHitid ==
id.
first && simHiteid ==
id.
second) {
270 result.push_back(ihit);
280 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itrphi =
282 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itster =
285 std::vector<PSimHit> simHitVector = itrphi->second;
286 simHitVector.insert(simHitVector.end(),(itster->second).
begin(),(itster->second).
end());
287 vector<PSimHit>::const_iterator simHitIter = simHitVector.begin();
288 vector<PSimHit>::const_iterator simHitIterEnd = simHitVector.end();
289 for (;simHitIter != simHitIterEnd; ++simHitIter) {
290 const PSimHit& ihit = *simHitIter;
291 unsigned int simHitid = ihit.
trackId();
293 for(
auto const&
id : simtrackid) {
294 if(simHitid ==
id.
first && simHiteid ==
id.
second) {
298 result.push_back(ihit);
311 std::vector< SimHitIdpr > simhitid;
317 std::vector<simhitAddr>* simhitCFPos)
const
337 dynamic_cast<const SiStripRecHit2D *>(&thit))
343 dynamic_cast<const SiStripRecHit1D *>(&thit))
349 dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
355 dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
368 if(
const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
392 std::vector<SimHitIdpr>& simtrackid,
393 std::vector<PSimHit>& simhit)
const {
394 std::vector<simhitAddr> simhitCFPos;
397 for(
auto const& theSimHitAddr : simhitCFPos ) {
399 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
401 unsigned int theSimHitIndex = theSimHitAddr.second;
402 if (theSimHitIndex < (it->second).size()) simhit.push_back((it->second)[theSimHitIndex]);
414 std::vector<SimHitIdpr>& simtrackid,
415 std::vector<simhitAddr>* simhitCFPos)
const {
417 uint32_t detID = detid.
rawId();
425 int last = first + clusiz;
430 std::vector<SimHitIdpr> idcachev;
431 std::vector<simhitAddr> CFposcachev;
435 channel = (int)(linkiter->channel());
436 if( channel >= first && channel < last ){
448 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
453 if(
find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
460 idcachev.push_back(currentId);
461 simtrackid.push_back(currentId);
464 if (simhitCFPos != 0) {
467 unsigned int currentCFPos = linkiter->CFposition();
468 unsigned int tofBin = linkiter->TofBin();
470 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
472 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr ) == CFposcachev.end()) {
481 CFposcachev.push_back(currentAddr);
482 simhitCFPos->push_back(currentAddr);
489 edm::LogError(
"TrackerHitAssociator")<<
"no cluster reference attached";
496 std::vector<SimHitIdpr> matched_mono;
497 std::vector<SimHitIdpr> matched_st;
506 std::vector<SimHitIdpr> simtrackid;
507 if(!(matched_mono.empty() || matched_st.empty())){
508 std::vector<SimHitIdpr> idcachev;
509 for(
auto const& mhit: matched_mono){
511 if(
find(idcachev.begin(), idcachev.end(), mhit) == idcachev.end()) {
512 idcachev.push_back(mhit);
514 if(
find(matched_st.begin(), matched_st.end(), mhit) != matched_st.end()) {
515 simtrackid.push_back(mhit);
526 std::vector<simhitAddr>* simhitCFPos)
const
530 std::vector<SimHitIdpr> matched_mono;
538 std::vector<SimHitIdpr> & simtrackid,
539 std::vector<simhitAddr>* simhitCFPos)
const
545 uint32_t detID = detid.
rawId();
556 int minPixelRow = (*cluster).minPixelRow();
557 int maxPixelRow = (*cluster).maxPixelRow();
558 int minPixelCol = (*cluster).minPixelCol();
559 int maxPixelCol = (*cluster).maxPixelCol();
564 std::vector<SimHitIdpr> idcachev;
565 std::vector<simhitAddr> CFposcachev;
566 for( ; linkiter != linkEnd; ++linkiter) {
570 if( pixel_coord.first <= maxPixelRow &&
571 pixel_coord.first >= minPixelRow &&
572 pixel_coord.second <= maxPixelCol &&
573 pixel_coord.second >= minPixelCol ) {
576 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
577 if(
find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
578 simtrackid.push_back(currentId);
579 idcachev.push_back(currentId);
582 if (simhitCFPos != 0) {
585 unsigned int currentCFPos = linkiter->CFposition();
586 unsigned int tofBin = linkiter->TofBin();
588 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
590 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr) == CFposcachev.end()) {
591 CFposcachev.push_back(currentAddr);
592 simhitCFPos->push_back(currentAddr);
600 edm::LogError(
"TrackerHitAssociator")<<
"no Pixel cluster reference attached";
607 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
609 int size=multirechit->
weights().size(), idmostprobable=0;
612 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
619 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
620 int size=multirechit->
weights().size(), idmostprobable=0;
623 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
626 std::vector< SimHitIdpr > simhitid;
627 associateHitId(*componenthits[idmostprobable], simhitid, simhitCFPos);
634 vector<SimHitIdpr> simtrackid;
638 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
std::vector< SimHitIdpr > associateFastRecHit(const FastTrackerRecHit *rechit) const
uint16_t firstStrip() const
virtual int32_t simTrackEventId(size_t i) 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
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
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
virtual int32_t simTrackId(size_t i) const
EncodedEventId eventId() const
bool isFast(TrackingRecHit const &hit)
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
std::pair< uint32_t, EncodedEventId > SimHitIdpr
SiStripRecHit2D stereoHit() const
T const * product() const
ClusterRef cluster() const
static std::pair< int, int > channelToPixel(int ch)
virtual size_t nSimTrackIds() const
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
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