CMS 3D CMS Logo

TrackerHitAssociator.cc

Go to the documentation of this file.
00001 // File: TrackerHitAssociator.cc
00002 
00003 #include <memory>
00004 #include <string>
00005 #include <vector>
00006 
00007 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
00008 //--- for Geometry:
00009 #include "DataFormats/Common/interface/Ref.h"
00010 #include "DataFormats/DetId/interface/DetId.h"
00011 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00012 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00013 
00014 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00015 
00016 //for accumulate
00017 #include <numeric>
00018 #include <iostream>
00019 
00020 using namespace std;
00021 using namespace edm;
00022 
00023 //
00024 // Constructor 
00025 //
00026 TrackerHitAssociator::TrackerHitAssociator(const edm::Event& e)  : 
00027   myEvent_(e), 
00028   doPixel_( true ),
00029   doStrip_( true ), 
00030   doTrackAssoc_( false ) {
00031   trackerContainers.clear();
00032   //
00033   // Take by default all tracker SimHits
00034   //
00035   trackerContainers.push_back("g4SimHitsTrackerHitsTIBLowTof");
00036   trackerContainers.push_back("g4SimHitsTrackerHitsTIBHighTof");
00037   trackerContainers.push_back("g4SimHitsTrackerHitsTIDLowTof");
00038   trackerContainers.push_back("g4SimHitsTrackerHitsTIDHighTof");
00039   trackerContainers.push_back("g4SimHitsTrackerHitsTOBLowTof");
00040   trackerContainers.push_back("g4SimHitsTrackerHitsTOBHighTof");
00041   trackerContainers.push_back("g4SimHitsTrackerHitsTECLowTof");
00042   trackerContainers.push_back("g4SimHitsTrackerHitsTECHighTof");
00043   trackerContainers.push_back("g4SimHitsTrackerHitsPixelBarrelLowTof");
00044   trackerContainers.push_back("g4SimHitsTrackerHitsPixelBarrelHighTof");
00045   trackerContainers.push_back("g4SimHitsTrackerHitsPixelEndcapLowTof");
00046   trackerContainers.push_back("g4SimHitsTrackerHitsPixelEndcapHighTof");
00047 
00048   // Step A: Get Inputs
00049   //MAKE THIS PRIVATE MEMBERS 
00050   //  edm::Handle<CrossingFrame<PSimHit> > cf_simhit;
00051   //  std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
00052 
00053   for(uint32_t i = 0; i< trackerContainers.size();i++){
00054     e.getByLabel("mix",trackerContainers[i],cf_simhit);
00055     cf_simhitvec.push_back(cf_simhit.product());
00056   }
00057   
00058   std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
00059   TrackerHits = (*allTrackerHits);
00060 
00061  //Loop on PSimHit
00062   SimHitMap.clear();
00063   
00064   MixCollection<PSimHit>::iterator isim;
00065   for (isim=allTrackerHits->begin(); isim!= allTrackerHits->end();isim++) {
00066     SimHitMap[(*isim).detUnitId()].push_back((*isim));
00067   }
00068   
00069   if(doStrip_) e.getByLabel("simSiStripDigis", stripdigisimlink);
00070   if(doPixel_) e.getByLabel("simSiPixelDigis", pixeldigisimlink);
00071   
00072 }
00073 
00074 //
00075 // Constructor with configurables
00076 //
00077 TrackerHitAssociator::TrackerHitAssociator(const edm::Event& e, const edm::ParameterSet& conf)  : 
00078   myEvent_(e), 
00079   doPixel_( conf.getParameter<bool>("associatePixel") ),
00080   doStrip_( conf.getParameter<bool>("associateStrip") ),
00081   doTrackAssoc_( conf.getParameter<bool>("associateRecoTracks") ){
00082   
00083   trackerContainers.clear();
00084   trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
00085 
00086   //if track association there is no need to acces the CrossingFrame
00087   if(!doTrackAssoc_) {
00088     
00089     // Step A: Get Inputs
00090     //    edm::Handle<CrossingFrame<PSimHit> > cf_simhit;
00091     //    std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
00092     for(uint32_t i = 0; i< trackerContainers.size();i++){
00093       e.getByLabel("mix",trackerContainers[i],cf_simhit);
00094       cf_simhitvec.push_back(cf_simhit.product());
00095     }
00096 
00097     //  std::cout << "SIMHITVEC SIZE = " <<  cf_simhitvec.size() << std::endl;
00098     
00099     //    TrackerHits = new MixCollection<PSimHit>(cf_simhitvec);
00100     //std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(TrackerHits);
00101     //   std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
00102     std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
00103     TrackerHits = (*allTrackerHits);
00104     
00105     //Loop on PSimHit
00106     SimHitMap.clear();
00107     
00108     MixCollection<PSimHit>::iterator isim;
00109     for (isim=allTrackerHits->begin(); isim!= allTrackerHits->end();isim++) {
00110       SimHitMap[(*isim).detUnitId()].push_back((*isim));
00111     }
00112     
00113   }
00114 
00115   if(doStrip_) e.getByLabel("simSiStripDigis", stripdigisimlink);
00116   if(doPixel_) e.getByLabel("simSiPixelDigis", pixeldigisimlink);
00117   
00118 }
00119 
00120 std::vector<PSimHit> TrackerHitAssociator::associateHit(const TrackingRecHit & thit) 
00121 {
00122   
00123   //check in case of TTRH
00124   if(const TransientTrackingRecHit * ttrh = dynamic_cast<const TransientTrackingRecHit *>(&thit)) {
00125       return associateHit(*ttrh->hit());
00126   }
00127  
00128   //vector with the matched SimHit
00129   std::vector<PSimHit> result; 
00130   //  std::vector<PSimHit> result_old; 
00131   //initialize vectors!
00132   simtrackid.clear();
00133   simhitCFPos.clear();
00134   StripHits = false;
00135   
00136   //get the Detector type of the rechit
00137   DetId detid=  thit.geographicalId();
00138   uint32_t detID = detid.rawId();
00139 
00140   //  cout << "Associator ---> get Detid " << detID << endl;
00141   //check we are in the strip tracker
00142   if(detid.subdetId() == StripSubdetector::TIB ||
00143      detid.subdetId() == StripSubdetector::TOB || 
00144      detid.subdetId() == StripSubdetector::TID ||
00145      detid.subdetId() == StripSubdetector::TEC) 
00146     {
00147       //check if it is a simple SiStripRecHit2D
00148       if(const SiStripRecHit2D * rechit = 
00149          dynamic_cast<const SiStripRecHit2D *>(&thit))
00150         {         
00151           simtrackid = associateSimpleRecHit(rechit);
00152         }
00153       //check if it is a matched SiStripMatchedRecHit2D
00154       if(const SiStripMatchedRecHit2D * rechit = 
00155          dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
00156         {         
00157           simtrackid = associateMatchedRecHit(rechit);
00158         }
00159       //check if it is a  ProjectedSiStripRecHit2D
00160       if(const ProjectedSiStripRecHit2D * rechit = 
00161          dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
00162         {         
00163           simtrackid = associateProjectedRecHit(rechit);
00164           detid = rechit->originalHit().geographicalId();
00165           detID = detid.rawId();
00166         }
00167 
00168     }
00169   //check we are in the pixel tracker
00170   if( (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelBarrel || 
00171       (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelEndcap) 
00172     {
00173       if(const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
00174         {         
00175           simtrackid = associatePixelRecHit(rechit);
00176         }
00177     }
00178   //check if these are GSRecHits (from FastSim)
00179   
00180   if(const SiTrackerGSRecHit2D * rechit = dynamic_cast<const SiTrackerGSRecHit2D *>(&thit))
00181     {
00182       simtrackid = associateGSRecHit(rechit);
00183     }
00184   if (const SiTrackerMultiRecHit * rechit = dynamic_cast<const SiTrackerMultiRecHit *>(&thit)){
00185     return associateMultiRecHit(rechit);
00186   }
00187   
00188   //check if these are GSMatchedRecHits (from FastSim)
00189   if(const SiTrackerGSMatchedRecHit2D * rechit = dynamic_cast<const SiTrackerGSMatchedRecHit2D *>(&thit))
00190     {
00191       simtrackid = associateGSMatchedRecHit(rechit);
00192     }
00193   
00194   //
00195   //Save the SimHits in a vector. for the macthed hits both the rphi and stereo simhits are saved. 
00196   //
00197   
00198   if(StripHits){
00199     //USE THIS FOR STRIPS
00200     //  std::cout << "NEW SIZE =  " << simhitCFPos.size() << std::endl;
00201     
00202     for(size_t i=0; i<simhitCFPos.size(); i++){
00203       //std::cout << "NEW CFPOS " << simhitCFPos[i] << endl;
00204       //std::cout << "NEW LOCALPOS " <<  TrackerHits.getObject(simhitCFPos[i]).localPosition()  << endl;
00205       result.push_back( TrackerHits.getObject(simhitCFPos[i]));
00206     }
00207   }else {
00208     
00209     //now get the SimHit from the trackid
00210     vector<PSimHit> simHit; 
00211     std::map<unsigned int, std::vector<PSimHit> >::const_iterator it = SimHitMap.find(detID);
00212     simHit.clear();
00213     if (it!= SimHitMap.end()){
00214       simHit = it->second;
00215       vector<PSimHit>::const_iterator simHitIter = simHit.begin();
00216       vector<PSimHit>::const_iterator simHitIterEnd = simHit.end();
00217       for (;simHitIter != simHitIterEnd; ++simHitIter) {
00218         const PSimHit ihit = *simHitIter;
00219         unsigned int simHitid = ihit.trackId();
00220         EncodedEventId simHiteid = ihit.eventId();
00221         
00222         for(size_t i=0; i<simtrackid.size();i++){
00223           if(simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second){ 
00224             //    cout << "Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x() 
00225             //         << " y= " <<  ihit.localPosition().y() << " z= " <<  ihit.localPosition().x() << endl; 
00226             result.push_back(ihit);
00227           }
00228         }
00229       }
00230     }else{
00232       std::map<unsigned int, std::vector<PSimHit> >::const_iterator itrphi = 
00233         SimHitMap.find(detID+2);//iterator to the simhit in the rphi module
00234       std::map<unsigned int, std::vector<PSimHit> >::const_iterator itster = 
00235         SimHitMap.find(detID+1);//iterator to the simhit in the stereo module
00236       if (itrphi!= SimHitMap.end()&&itster!=SimHitMap.end()){
00237         simHit = itrphi->second;
00238         simHit.insert(simHit.end(),(itster->second).begin(),(itster->second).end());
00239         vector<PSimHit>::const_iterator simHitIter = simHit.begin();
00240         vector<PSimHit>::const_iterator simHitIterEnd = simHit.end();
00241         for (;simHitIter != simHitIterEnd; ++simHitIter) {
00242           const PSimHit ihit = *simHitIter;
00243           unsigned int simHitid = ihit.trackId();
00244           EncodedEventId simHiteid = ihit.eventId();
00245           
00246           //===>>>>>change here!!!!
00247           //    for(size_t i=0; i<simtrackid.size();i++){
00248           //  cout << " GluedDet Associator -->  check sihit id's = " << simHitid <<"; compared id's = "<< simtrackid[i] <<endl;
00249           // if(simHitid == simtrackid[i]){ //exclude the geant particles. they all have the same id
00250           for(size_t i=0; i<simtrackid.size();i++){
00251             if(simHitid == simtrackid[i].first && simHiteid == simtrackid[i].second){ 
00252               //          cout << "GluedDet Associator ---> ID" << ihit.trackId() << " Simhit x= " << ihit.localPosition().x() 
00253               //               << " y= " <<  ihit.localPosition().y() << " z= " <<  ihit.localPosition().x() << endl; 
00254               result.push_back(ihit);
00255             }
00256           }
00257         }
00258       }
00259     }
00260   }
00261 
00262 
00263   return result;  
00264 }
00265 
00266 //std::vector<unsigned int> TrackerHitAssociator::associateHitId(const TrackingRecHit & thit) 
00267 std::vector< SimHitIdpr > TrackerHitAssociator::associateHitId(const TrackingRecHit & thit) 
00268 {
00269   
00270   //check in case of TTRH
00271   if(const TransientTrackingRecHit * ttrh = dynamic_cast<const TransientTrackingRecHit *>(&thit)) {
00272       return associateHitId(*ttrh->hit());
00273   }
00274    
00275   //vector with the associated SimTrackID 
00276   simtrackid.clear();
00277   //vector with the CF position of the associated simhits
00278   simhitCFPos.clear();
00279 
00280   //get the Detector type of the rechit
00281   DetId detid=  thit.geographicalId();
00282   //apparently not used
00283   //  uint32_t detID = detid.rawId();
00284   if (const SiTrackerMultiRecHit * rechit = dynamic_cast<const SiTrackerMultiRecHit *>(&thit)){
00285         return associateMultiRecHitId(rechit);
00286   }
00287 
00288   //cout << "Associator ---> get Detid " << detID << endl;
00289   //check we are in the strip tracker
00290   if(detid.subdetId() == StripSubdetector::TIB ||
00291      detid.subdetId() == StripSubdetector::TOB || 
00292      detid.subdetId() == StripSubdetector::TID ||
00293      detid.subdetId() == StripSubdetector::TEC) 
00294     {
00295       //check if it is a simple SiStripRecHit2D
00296       if(const SiStripRecHit2D * rechit = 
00297          dynamic_cast<const SiStripRecHit2D *>(&thit))
00298         {         
00299           simtrackid = associateSimpleRecHit(rechit);
00300         }
00301       //check if it is a matched SiStripMatchedRecHit2D
00302       else  if(const SiStripMatchedRecHit2D * rechit = 
00303          dynamic_cast<const SiStripMatchedRecHit2D *>(&thit))
00304         {         
00305           simtrackid = associateMatchedRecHit(rechit);
00306         }
00307       //check if it is a  ProjectedSiStripRecHit2D
00308       else if(const ProjectedSiStripRecHit2D * rechit = 
00309          dynamic_cast<const ProjectedSiStripRecHit2D *>(&thit))
00310         {         
00311           simtrackid = associateProjectedRecHit(rechit);
00312         }
00313     }
00314   //check we are in the pixel tracker
00315   else if( (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelBarrel || 
00316            (unsigned int)(detid.subdetId()) == PixelSubdetector::PixelEndcap) 
00317     {
00318       if(const SiPixelRecHit * rechit = dynamic_cast<const SiPixelRecHit *>(&thit))
00319         {         
00320           simtrackid = associatePixelRecHit(rechit);
00321         }
00322     }
00323   //check if these are GSRecHits (from FastSim)
00324   if(const SiTrackerGSRecHit2D * rechit = dynamic_cast<const SiTrackerGSRecHit2D *>(&thit))
00325     {
00326       simtrackid = associateGSRecHit(rechit);
00327     }  
00328   if(const SiTrackerGSMatchedRecHit2D * rechit = dynamic_cast<const SiTrackerGSMatchedRecHit2D *>(&thit))
00329     {
00330       simtrackid = associateGSMatchedRecHit(rechit);
00331     }
00332 
00333  
00334   return simtrackid;  
00335 }
00336 
00337 
00338 std::vector<SimHitIdpr>  TrackerHitAssociator::associateSimpleRecHit(const SiStripRecHit2D * simplerechit)
00339 {
00340   //  std::cout <<"ASSOCIATE SIMPLE RECHIT" << std::endl;           
00341   StripHits =true;        
00342 
00343   DetId detid=  simplerechit->geographicalId();
00344   uint32_t detID = detid.rawId();
00345 
00346   //to store temporary charge information
00347   std::vector<SimHitIdpr> cache_simtrackid; 
00348   cache_simtrackid.clear();
00349 
00350   std::map<SimHitIdpr, vector<float> > temp_simtrackid;
00351   temp_simtrackid.clear();
00352 
00353   edm::DetSetVector<StripDigiSimLink>::const_iterator isearch = stripdigisimlink->find(detID); 
00354   if(isearch != stripdigisimlink->end()) {  //if it is not empty
00355     //link_detset is a structure, link_detset.data is a std::vector<StripDigiSimLink>
00356     edm::DetSet<StripDigiSimLink> link_detset = (*stripdigisimlink)[detID];
00357     
00358     //Modification for regional clustering from Jean-Roch Vlimant
00359     const SiStripCluster* clust = 0; 
00360     if(simplerechit->cluster().isNonnull())
00361     {
00362       clust=&(*simplerechit->cluster());
00363     }else if(simplerechit->cluster_regional().isNonnull())
00364        {
00365          clust=&(*simplerechit->cluster_regional());
00366        } 
00367     else 
00368       {
00369         edm::LogError("TrackerHitAssociator")<<"no cluster reference attached";
00370         return simtrackid;
00371       }
00372   //    const edm::Ref<edm::DetSetVector<SiStripCluster>, SiStripCluster, edm::refhelper::FindForDetSetVector<SiStripCluster> > clust=simplerechit->cluster();
00373   
00374     //float chg;
00375     int clusiz = clust->amplitudes().size();
00376     int first  = clust->firstStrip();     
00377     int last   = first + clusiz;
00378 
00379     //    std::cout << "CLUSTERSIZE " << clusiz << " first strip = " << first << " last strip = " << last << std::endl;
00380     //   std::cout << " DETSET size = " << link_detset.data.size() << std::endl;
00381     //use a vector
00382     std::vector<SimHitIdpr> idcachev;
00383     std::vector<int> CFposcachev;
00384     for(edm::DetSet<StripDigiSimLink>::const_iterator linkiter = link_detset.data.begin(); linkiter != link_detset.data.end(); linkiter++){
00385       StripDigiSimLink link = *linkiter;
00386 
00387       if( (int)(link.channel()) >= first  && (int)(link.channel()) < last ){
00388         
00389         //check this digisimlink
00390         /*
00391         std::cout << "CHECKING CHANNEL  = " << link.channel()   << std::endl;
00392         std::cout << "TrackID  = " << link.SimTrackId()  << std::endl;
00393         std::cout << "Position = " << link.CFposition()  << std::endl;
00394         std::cout << " POS -1 = " << TrackerHits.getObject(link.CFposition()-1).localPosition() << std::endl;
00395         std::cout << " Process = " << TrackerHits.getObject(link.CFposition()-1).processType() << std::endl;
00396         */
00397 
00398         SimHitIdpr currentId(link.SimTrackId(), link.eventId());
00399 
00400         //create a vector with the list of SimTrack ID's of the tracks that contributed to the RecHit
00401         //write the id only once in the vector
00402 
00403         if(find(idcachev.begin(),idcachev.end(),currentId ) == idcachev.end()){
00404           /*
00405           std::cout << " Adding track id  = " << currentId.first  
00406                     << " Event id = " << currentId.second.event() 
00407                     << " Bunch Xing = " << currentId.second.bunchCrossing() 
00408                     << std::endl;
00409           */
00410           idcachev.push_back(currentId);
00411           simtrackid.push_back(currentId);
00412         }
00413 
00414         //create a vector that contains all the position (in the MixCollection) of the SimHits that contributed to the RecHit
00415         //write position only once
00416         int currentCFPos = link.CFposition()-1;
00417         if(find(CFposcachev.begin(),CFposcachev.end(),currentCFPos ) == CFposcachev.end()){
00418           /*
00419           std::cout << "CHECKING CHANNEL  = " << link.channel()   << std::endl;
00420           std::cout << "\tTrackID  = " << link.SimTrackId()  << "\tCFPos = " << currentCFPos  << std::endl;
00421           std::cout << "\tLocal Pos = " << TrackerHits.getObject(currentCFPos).localPosition() 
00422                     << "\tProcess = " << TrackerHits.getObject(currentCFPos).processType() << std::endl;
00423           */
00424           CFposcachev.push_back(currentCFPos);
00425           simhitCFPos.push_back(currentCFPos);
00426           //      simhitassoc.push_back( TrackerHits.getObject(currentCFPos));
00427         }
00428       }
00429     }    
00430   }
00431   return simtrackid;
00432   
00433 }
00434 
00435 std::vector<SimHitIdpr>  TrackerHitAssociator::associateMatchedRecHit(const SiStripMatchedRecHit2D * matchedrechit)
00436 {
00437 
00438   StripHits = true;
00439 
00440 
00441   vector<SimHitIdpr> matched_mono;
00442   vector<SimHitIdpr> matched_st;
00443   matched_mono.clear();
00444   matched_st.clear();
00445 
00446   const SiStripRecHit2D *mono = matchedrechit->monoHit();
00447   const SiStripRecHit2D *st = matchedrechit->stereoHit();
00448   //associate the two simple hits separately
00449   matched_mono = associateSimpleRecHit(mono);
00450   matched_st   = associateSimpleRecHit(st);
00451   
00452   //save in a vector all the simtrack-id's that are common to mono and stereo hits
00453   if(!matched_mono.empty() && !matched_st.empty()){
00454     simtrackid.clear(); //final result vector
00455     //    std::vector<unsigned int> idcachev;
00456     std::vector<SimHitIdpr> idcachev;
00457     //for(vector<unsigned int>::iterator mhit=matched_mono.begin(); mhit != matched_mono.end(); mhit++){
00458     for(vector<SimHitIdpr>::iterator mhit=matched_mono.begin(); mhit != matched_mono.end(); mhit++){
00459       //save only once the ID
00460       if(find(idcachev.begin(), idcachev.end(),(*mhit)) == idcachev.end()) {
00461         idcachev.push_back(*mhit);
00462         //save if the stereoID matched the monoID
00463         if(find(matched_st.begin(), matched_st.end(),(*mhit))!=matched_st.end()){
00464           simtrackid.push_back(*mhit);
00465           //std::cout << "matched case: saved ID " << (*mhit) << std::endl; 
00466         }
00467       }
00468     }
00469   }
00470   return simtrackid;
00471 }
00472 
00473 
00474 std::vector<SimHitIdpr>  TrackerHitAssociator::associateProjectedRecHit(const ProjectedSiStripRecHit2D * projectedrechit)
00475 {
00476   StripHits = true;
00477 
00478 
00479   //projectedRecHit is a "matched" rechit with only one component
00480 
00481   vector<SimHitIdpr> matched_mono;
00482   matched_mono.clear();
00483  
00484   const SiStripRecHit2D mono = projectedrechit->originalHit();
00485   matched_mono = associateSimpleRecHit(&mono);
00486   return matched_mono;
00487 }
00488 
00489 //std::vector<unsigned int>  TrackerHitAssociator::associatePixelRecHit(const SiPixelRecHit * pixelrechit)
00490 std::vector<SimHitIdpr>  TrackerHitAssociator::associatePixelRecHit(const SiPixelRecHit * pixelrechit)
00491 {
00492   StripHits = false;
00493 
00494   //
00495   // Pixel associator
00496   //
00497   DetId detid=  pixelrechit->geographicalId();
00498   uint32_t detID = detid.rawId();
00499   edm::DetSetVector<PixelDigiSimLink>::const_iterator isearch = pixeldigisimlink->find(detID); 
00500   if(isearch != pixeldigisimlink->end()) {  //if it is not empty
00501     edm::DetSet<PixelDigiSimLink> link_detset = (*pixeldigisimlink)[detID];
00502     //    edm::Ref< edm::DetSetVector<SiPixelCluster>, SiPixelCluster> const& cluster = pixelrechit->cluster();
00503     SiPixelRecHit::ClusterRef const& cluster = pixelrechit->cluster();
00504 
00505     //check the reference is valid
00506 
00507     if(pixelrechit->cluster().isNull()){
00508       edm::LogError("TrackerHitAssociator")<<"no Pixel cluster reference attached";
00509       return simtrackid;
00510     }
00511     
00512 
00513 
00514     int minPixelRow = (*cluster).minPixelRow();
00515     int maxPixelRow = (*cluster).maxPixelRow();
00516     int minPixelCol = (*cluster).minPixelCol();
00517     int maxPixelCol = (*cluster).maxPixelCol();    
00518     //std::cout << "    Cluster minRow " << minPixelRow << " maxRow " << maxPixelRow << std::endl;
00519     //std::cout << "    Cluster minCol " << minPixelCol << " maxCol " << maxPixelCol << std::endl;
00520     edm::DetSet<PixelDigiSimLink>::const_iterator linkiter = link_detset.data.begin();
00521     int dsl = 0;
00522     //    std::vector<unsigned int> idcachev;
00523     std::vector<SimHitIdpr> idcachev;
00524     for( ; linkiter != link_detset.data.end(); linkiter++) {
00525       dsl++;
00526       std::pair<int,int> pixel_coord = PixelDigi::channelToPixel(linkiter->channel());
00527       //std::cout << "    " << dsl << ") Digi link: row " << pixel_coord.first << " col " << pixel_coord.second << std::endl;      
00528       if(  pixel_coord.first  <= maxPixelRow && 
00529            pixel_coord.first  >= minPixelRow &&
00530            pixel_coord.second <= maxPixelCol &&
00531            pixel_coord.second >= minPixelCol ) {
00532         //std::cout << "      !-> trackid   " << linkiter->SimTrackId() << endl;
00533         //std::cout << "          fraction  " << linkiter->fraction()   << endl;
00534         SimHitIdpr currentId(linkiter->SimTrackId(), linkiter->eventId());
00535         //      if(find(idcachev.begin(),idcachev.end(),linkiter->SimTrackId()) == idcachev.end()){
00536         if(find(idcachev.begin(),idcachev.end(),currentId) == idcachev.end()){
00537           //      simtrackid.push_back(linkiter->SimTrackId());
00538           //idcachev.push_back(linkiter->SimTrackId());
00539           simtrackid.push_back(currentId);
00540           idcachev.push_back(currentId);
00541         }
00542       } 
00543     }
00544   }
00545   
00546   return simtrackid;
00547 }
00548 
00549 std::vector<SimHitIdpr>  TrackerHitAssociator::associateGSRecHit(const SiTrackerGSRecHit2D * gsrechit)
00550 {
00551   StripHits = false;
00552   //GSRecHit is the FastSimulation RecHit that contains the TrackId already
00553 
00554   vector<SimHitIdpr> simtrackid;
00555   simtrackid.clear();
00556   SimHitIdpr currentId(gsrechit->simtrackId(), EncodedEventId(gsrechit->eeId()));
00557   simtrackid.push_back(currentId);
00558   return simtrackid;
00559 }
00560 
00561 std::vector<PSimHit> TrackerHitAssociator::associateMultiRecHit(const SiTrackerMultiRecHit * multirechit){
00562         std::vector<const TrackingRecHit*> componenthits = multirechit->recHits();
00563         std::vector<PSimHit> assimhits;
00564         std::vector<const TrackingRecHit*>::const_iterator iter;
00565         for (iter = componenthits.begin(); iter != componenthits.end(); iter ++){
00566                 std::vector<PSimHit> asstocurrent = associateHit(**iter);
00567                 assimhits.insert(assimhits.end(), asstocurrent.begin(), asstocurrent.end());
00568         }
00569         //std::cout << "Returning " << assimhits.size() << " simhits" << std::endl;
00570         return assimhits;
00571 }
00572 
00573 std::vector<SimHitIdpr> TrackerHitAssociator::associateMultiRecHitId(const SiTrackerMultiRecHit * multirechit){
00574 
00575         std::vector<const TrackingRecHit*> componenthits = multirechit->recHits();
00576         std::vector<SimHitIdpr> assimhits;
00577         std::vector<const TrackingRecHit*>::const_iterator iter;
00578         for (iter = componenthits.begin(); iter != componenthits.end(); iter ++){
00579           std::vector<SimHitIdpr> asstocurrent = associateHitId(**iter);
00580           assimhits.insert(assimhits.end(), asstocurrent.begin(), asstocurrent.end());
00581         }
00582         //std::cout << "Returning " << assimhits.size() << " simhits" << std::endl;
00583         return assimhits;
00584 }
00585 
00586 std::vector<SimHitIdpr>  TrackerHitAssociator::associateGSMatchedRecHit(const SiTrackerGSMatchedRecHit2D * gsmrechit)
00587 {
00588   StripHits = false;
00589   //GSRecHit is the FastSimulation RecHit that contains the TrackId already
00590   
00591   vector<SimHitIdpr> simtrackid;
00592   simtrackid.clear();
00593   SimHitIdpr currentId(gsmrechit->simtrackId(), EncodedEventId(gsmrechit->eeId()));
00594   simtrackid.push_back(currentId);
00595   return simtrackid;
00596 }
00597 

Generated on Tue Jun 9 17:47:55 2009 for CMSSW by  doxygen 1.5.4