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");
58 doPixel_( conf.getParameter<bool>(
"associatePixel") ),
59 doStrip_( conf.getParameter<bool>(
"associateStrip") ),
60 doTrackAssoc_( conf.getParameter<bool>(
"associateRecoTracks") ) {
79 for(
auto const& trackerContainer : trackerContainers) {
88 isim != thisContainerHits->end(); isim++) {
89 DetId theDet((*isim).detUnitId());
103 for (std::vector<PSimHit>::const_iterator isim = simHits->begin();
104 isim != simHits->end(); isim++) {
105 DetId theDet((*isim).detUnitId());
129 std::vector<PSimHit>
result;
134 std::vector<SimHitIdpr> simtrackid;
135 std::vector<simhitAddr> simhitCFPos;
139 uint32_t detID = detid.
rawId();
158 bool isMatchedHit =
false;
159 if(dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
162 for(
size_t i=0;
i<simhitCFPos.size();
i++) {
165 simhit_collectionMap::const_iterator it =
SimHitCollMap.find(theSimHitCollID);
167 unsigned int theSimHitIndex = theSimHitAddr.second;
168 if (theSimHitIndex < (it->second).size()) {
169 const PSimHit& theSimHit = (it->second)[theSimHitIndex];
172 unsigned int simHitid = theSimHit.
trackId();
174 for(
size_t i=0;
i<simtrackid.size();
i++) {
175 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
176 result.push_back(theSimHit);
180 result.push_back(theSimHit);
193 std::map<unsigned int, std::vector<PSimHit> >::const_iterator it =
SimHitMap.find(detID);
195 vector<PSimHit>::const_iterator simHitIter = (it->second).
begin();
196 vector<PSimHit>::const_iterator simHitIterEnd = (it->second).
end();
197 for (;simHitIter != simHitIterEnd; ++simHitIter) {
198 const PSimHit& ihit = *simHitIter;
199 unsigned int simHitid = ihit.
trackId();
204 for(
size_t i=0;
i<simtrackid.size();
i++) {
205 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
209 result.push_back(ihit);
219 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itrphi =
221 std::map<unsigned int, std::vector<PSimHit> >::const_iterator itster =
224 std::vector<PSimHit> simHitVector = itrphi->second;
225 simHitVector.insert(simHitVector.end(),(itster->second).
begin(),(itster->second).
end());
226 vector<PSimHit>::const_iterator simHitIter = simHitVector.begin();
227 vector<PSimHit>::const_iterator simHitIterEnd = simHitVector.end();
228 for (;simHitIter != simHitIterEnd; ++simHitIter) {
229 const PSimHit& ihit = *simHitIter;
230 unsigned int simHitid = ihit.
trackId();
232 for(
size_t i=0;
i<simtrackid.size();
i++) {
233 if(simHitid == simtrackid[
i].
first && simHiteid == simtrackid[
i].
second) {
237 result.push_back(ihit);
250 std::vector< SimHitIdpr > simhitid;
256 std::vector<simhitAddr>* simhitCFPos)
const
275 if(
const SiStripRecHit2D * rechit =
276 dynamic_cast<const SiStripRecHit2D *>(&thit))
281 else if(
const SiStripRecHit1D * rechit =
282 dynamic_cast<const SiStripRecHit1D *>(&thit))
287 else if(
const SiStripMatchedRecHit2D * rechit =
288 dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
293 else if(
const ProjectedSiStripRecHit2D * rechit =
294 dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
307 if(
const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
333 std::vector<SimHitIdpr>& simtrackid,
334 std::vector<simhitAddr>* simhitCFPos)
const {
336 uint32_t detID = detid.
rawId();
344 int last = first + clusiz;
349 std::vector<SimHitIdpr> idcachev;
350 std::vector<simhitAddr> CFposcachev;
352 if( (
int)(linkiter->channel()) >= first && (
int)(linkiter->channel()) < last ){
364 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
369 if(
find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
376 idcachev.push_back(currentId);
377 simtrackid.push_back(currentId);
380 if (simhitCFPos != 0) {
383 unsigned int currentCFPos = linkiter->CFposition();
384 unsigned int tofBin = linkiter->TofBin();
386 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
388 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr ) == CFposcachev.end()) {
397 CFposcachev.push_back(currentAddr);
398 simhitCFPos->push_back(currentAddr);
405 edm::LogError(
"TrackerHitAssociator")<<
"no cluster reference attached";
412 std::vector<SimHitIdpr> matched_mono;
413 std::vector<SimHitIdpr> matched_st;
415 const SiStripRecHit2D mono = matchedrechit->monoHit();
416 const SiStripRecHit2D st = matchedrechit->stereoHit();
422 std::vector<SimHitIdpr> simtrackid;
423 if(!matched_mono.empty() && !matched_st.empty()){
424 std::vector<SimHitIdpr> idcachev;
425 for(vector<SimHitIdpr>::iterator mhit=matched_mono.begin(); mhit != matched_mono.end(); mhit++){
427 if(
find(idcachev.begin(), idcachev.end(), (*mhit)) == idcachev.end()) {
428 idcachev.push_back(*mhit);
430 if(
find(matched_st.begin(), matched_st.end(), (*mhit)) != matched_st.end()) {
431 simtrackid.push_back(*mhit);
442 std::vector<simhitAddr>* simhitCFPos)
const
446 std::vector<SimHitIdpr> matched_mono;
448 const SiStripRecHit2D mono = projectedrechit->originalHit();
454 std::vector<SimHitIdpr> & simtrackid,
455 std::vector<simhitAddr>* simhitCFPos)
const
461 uint32_t detID = detid.
rawId();
466 SiPixelRecHit::ClusterRef
const& cluster = pixelrechit->cluster();
470 if(!(cluster.isNull())){
472 int minPixelRow = (*cluster).minPixelRow();
473 int maxPixelRow = (*cluster).maxPixelRow();
474 int minPixelCol = (*cluster).minPixelCol();
475 int maxPixelCol = (*cluster).maxPixelCol();
480 std::vector<SimHitIdpr> idcachev;
481 std::vector<simhitAddr> CFposcachev;
482 for( ; linkiter != link_detset.
data.end(); linkiter++) {
486 if( pixel_coord.first <= maxPixelRow &&
487 pixel_coord.first >= minPixelRow &&
488 pixel_coord.second <= maxPixelCol &&
489 pixel_coord.second >= minPixelCol ) {
492 SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
493 if(
find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
494 simtrackid.push_back(currentId);
495 idcachev.push_back(currentId);
498 if (simhitCFPos != 0) {
501 unsigned int currentCFPos = linkiter->CFposition();
502 unsigned int tofBin = linkiter->TofBin();
504 simhitAddr currentAddr = std::make_pair(theSimHitCollID, currentCFPos);
506 if(
find(CFposcachev.begin(), CFposcachev.end(), currentAddr) == CFposcachev.end()) {
507 CFposcachev.push_back(currentAddr);
508 simhitCFPos->push_back(currentAddr);
516 edm::LogError(
"TrackerHitAssociator")<<
"no Pixel cluster reference attached";
526 vector<SimHitIdpr> simtrackid;
529 simtrackid.push_back(currentId);
534 std::vector<const TrackingRecHit*> componenthits = multirechit->
recHits();
536 int size=multirechit->
weights().size(), idmostprobable=0;
539 if(multirechit->
weight(
i)>multirechit->
weight(idmostprobable)) idmostprobable=
i;
546 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;
553 std::vector< SimHitIdpr > simhitid;
554 associateHitId(*componenthits[idmostprobable], simhitid, simhitCFPos);
562 vector<SimHitIdpr> simtrackid;
565 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
TrackerHitAssociator(const edm::Event &e)
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
simhit_collectionMap SimHitCollMap
void makeMaps(const edm::Event &theEvent, const vstring trackerContainers)
const uint32_t & eeId() const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
T const * product() const
const uint32_t & eeId() const
static std::pair< int, int > channelToPixel(int ch)
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