CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

DetHitAccess Class Reference

#include <DetHitAccess.h>

List of all members.

Public Types

enum  accessMode { standard, rphi, rphi_stereo }

Public Member Functions

 DetHitAccess ()
 DetHitAccess (const SiStripRecHit2DCollection *rphiRecHits, const SiStripRecHit2DCollection *stereoRecHits, const SiStripMatchedRecHit2DCollection *matchedRecHits, const SiPixelRecHitCollection *pixelRecHits)
std::vector< TrackingRecHit * > getHitVector (const DetId *detid)
void setCollections (const SiStripRecHit2DCollection *rphiRecHits, const SiStripRecHit2DCollection *stereoRecHits, const SiStripMatchedRecHit2DCollection *matchedRecHits, const SiPixelRecHitCollection *pixelRecHits)
void setMode (accessMode input)
void use_rphiRecHits (bool input)
void use_stereoRecHits (bool input)
 ~DetHitAccess ()

Private Attributes

accessMode accessMode_
const
SiStripMatchedRecHit2DCollection
matchedHits_
const SiPixelRecHitCollectionpixelHits_
const SiStripRecHit2DCollectionrphiHits_
const SiStripRecHit2DCollectionstereoHits_
bool use_rphiRecHits_
bool use_stereoRecHits_

Detailed Description

Definition at line 22 of file DetHitAccess.h.


Member Enumeration Documentation

Enumerator:
standard 
rphi 
rphi_stereo 

Definition at line 26 of file DetHitAccess.h.


Constructor & Destructor Documentation

DetHitAccess::DetHitAccess ( )

Definition at line 15 of file DetHitAccess.cc.

References accessMode_, standard, and use_rphiRecHits_.

                           {
  // default for access mode
  accessMode_ = standard;

  use_rphiRecHits_ = true;
  use_rphiRecHits_ = true;
}
DetHitAccess::~DetHitAccess ( )

Definition at line 23 of file DetHitAccess.cc.

                           {
}
DetHitAccess::DetHitAccess ( const SiStripRecHit2DCollection rphiRecHits,
const SiStripRecHit2DCollection stereoRecHits,
const SiStripMatchedRecHit2DCollection matchedRecHits,
const SiPixelRecHitCollection pixelRecHits 
)

Definition at line 26 of file DetHitAccess.cc.

References accessMode_, setCollections(), standard, use_rphiRecHits_, and use_stereoRecHits_.

                                                                        {
  
  // default for access mode
  accessMode_ = standard;

  use_rphiRecHits_   = true;
  use_stereoRecHits_ = true;

  // set collections
  setCollections(rphiRecHits,stereoRecHits,matchedRecHits,pixelRecHits);
  
}

Member Function Documentation

std::vector< TrackingRecHit * > DetHitAccess::getHitVector ( const DetId detid)

Definition at line 55 of file DetHitAccess.cc.

References accessMode_, edmNew::DetSet< T >::begin(), detSetOrEmpty(), edmNew::DetSet< T >::end(), StripSubdetector::glued(), matchedHits_, PixelSubdetector::PixelBarrel, GeomDetEnumerators::PixelEndcap, pixelHits_, rphi, rphi_stereo, rphiHits_, TrackingRecHit::some, stereoHits_, DetId::subdetId(), sistripsummary::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, use_rphiRecHits_, and use_stereoRecHits_.

Referenced by RoadSearchSeedFinderAlgorithm::calculateCircleSeedsFromRingsOneInnerOneOuter(), RoadSearchSeedFinderAlgorithm::calculateCircleSeedsFromRingsOneInnerTwoOuter(), RoadSearchSeedFinderAlgorithm::calculateCircleSeedsFromRingsTwoInnerOneOuter(), and RoadSearchCloudMakerAlgorithm::FillRecHitsIntoCloudGeneral().

                                                                        {
  //
  //DetId that is given to getHitVector is *always* rphi
  //
  
  std::vector<TrackingRecHit*> RecHitVec;
  
  if ( (unsigned int)detid->subdetId() == StripSubdetector::TIB  
       || (unsigned int)detid->subdetId() == StripSubdetector::TOB  
       || (unsigned int)detid->subdetId() == StripSubdetector::TID  
       || (unsigned int)detid->subdetId() == StripSubdetector::TEC )  { 
    
    StripSubdetector StripDetId(*detid);


    if (accessMode_ == rphi ) {
      //
      //return only r-phi RecHits; in case of double modules eliminate recurring r-phi RecHits
      //
      if( !StripDetId.glued() ) {
        if ( rphiHits_ != 0 ) {
          SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, *detid);
          for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
                rphiDetHit != rphiDetHits.end(); 
                ++rphiDetHit ) {
            RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
          }
        } else {
          edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
        }
      } else {
        /* 
         * VI January 2012 not supported anymore (at least in this form)
         * and (by-the-way) is infinitely slow with such a double loop!!!!!
         *
        if ( matchedHits_ != 0 ) {
          DetId useDetId(StripDetId.glued());
          SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, useDetId);
          for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
                matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
            bool add = true;
            TrackingRecHit *rphi = (TrackingRecHit*)matchedDetHit->monoHit();
            for ( std::vector<TrackingRecHit*>::iterator hit = RecHitVec.begin();
                  hit != RecHitVec.end();
                  ++hit ) {
              if ((*hit)->localPosition().x() == rphi->localPosition().x()) {
                if ((*hit)->localPosition().y() == rphi->localPosition().y()) {
                  add = false;
                  break;
                }
              }
            }
            if ( add ) {
              RecHitVec.push_back(rphi);
            }
          }
        } else {
          edm::LogWarning("RoadSearch") << "matched RecHit collection not set properly";
        }
        */
      }
    } else if (accessMode_ == rphi_stereo ) {
      //
      //return only r-phi and stereo RecHits
      //
      if( !StripDetId.glued() ) {
        if ( rphiHits_ != 0 ) {
          SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, *detid);
          for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
                rphiDetHit != rphiDetHits.end(); 
                ++rphiDetHit ) {
            RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
          }
        } else {
          edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
        }
        
      } else {
        DetId rphiDetId(StripDetId.glued()+2);
        if ( rphiHits_ != 0 ) {
          SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, rphiDetId);
          for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
                rphiDetHit != rphiDetHits.end(); 
                ++rphiDetHit ) {
            RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
          }
        } else {
          edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
        }

        DetId stereoDetId(StripDetId.glued()+1);
        if ( stereoHits_ != 0 ) {
          SiStripRecHit2DCollection::DetSet stereoDetHits = detSetOrEmpty(*stereoHits_, stereoDetId);
          for ( SiStripRecHit2DCollection::DetSet::const_iterator stereoDetHit = stereoDetHits.begin();
                stereoDetHit != stereoDetHits.end(); 
                ++stereoDetHit ) {
            RecHitVec.push_back((TrackingRecHit*)(&(*stereoDetHit)));
          }
        } else {
          edm::LogWarning("RoadSearch") << "stereo RecHit collection not set properly";
        }
      }
    } else if (accessMode_ == standard ) {
      //
      //single modules: return r-phi RecHits
      //double modules: return matched RecHits + r-phi RecHits that are not used by matched RecHits
      //
      if( !StripDetId.glued() ) {
        if ( rphiHits_ != 0 ) {
          SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, *detid);
          for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
                rphiDetHit != rphiDetHits.end(); 
                ++rphiDetHit ) {
            RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
          }
        } else {
          edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
        }
      } else {
        if ( matchedHits_ != 0 ) {
          DetId useDetId(StripDetId.glued());
          SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, useDetId);
          for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
                matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
            RecHitVec.push_back((TrackingRecHit*)(&(*matchedDetHit)));
          }
        } else {
          edm::LogWarning("RoadSearch") << "matched RecHit collection not set properly";
        }
        
        //check for additional r-phi RecHits (not used by matched RecHits)
        if(use_rphiRecHits_) {
          DetId rphiDetId(StripDetId.glued()+2);
          if ( rphiHits_ != 0 ) {
            SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, rphiDetId);
            for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
                  rphiDetHit != rphiDetHits.end(); ++rphiDetHit ) {
              bool use_rphi=true;
              DetId useDetId(StripDetId.glued());
              SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, useDetId);
              //SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, *detid);
              for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
                    matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) { 
                if (rphiDetHit->sharesInput((TrackingRecHit*)(&(*matchedDetHit)), TrackingRecHit::some)) {
                  use_rphi=false;
                  break;
                }
              }
              if(use_rphi) RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
            }
          } else {
            edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
          }
        }
          
        //check for additional stereo RecHits (not used by matched RecHits)
        if(use_stereoRecHits_) {
          DetId stereoDetId(StripDetId.glued()+1);
          if ( stereoHits_ != 0 ) {
            SiStripRecHit2DCollection::DetSet stereoDetHits = detSetOrEmpty(*stereoHits_, stereoDetId);
            for ( SiStripRecHit2DCollection::DetSet::const_iterator stereoDetHit = stereoDetHits.begin();
                  stereoDetHit != stereoDetHits.end(); ++stereoDetHit ) {
              bool use_stereo=true;
              DetId useDetId(StripDetId.glued());
              SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, useDetId);
              //SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, *detid);
              for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
                    matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) { 
                if (stereoDetHit->sharesInput((TrackingRecHit*)(&(*matchedDetHit)), TrackingRecHit::some)) {
                  use_stereo=false;
                  break;
                }
              }
              if(use_stereo) RecHitVec.push_back((TrackingRecHit*)(&(*stereoDetHit)));
            }
          } else {
            edm::LogWarning("RoadSearch") << "stereo RecHit collection not set properly";
          }  
        }
      }
    }
    
  } else if (    (unsigned int)detid->subdetId() == PixelSubdetector::PixelBarrel 
                 || (unsigned int)detid->subdetId() == PixelSubdetector::PixelEndcap) {
    
    if ( pixelHits_ != 0 ) {
      SiPixelRecHitCollection::DetSet pixelDetHits = detSetOrEmpty(*pixelHits_, *detid);
      for ( SiPixelRecHitCollection::DetSet::const_iterator pixelDetHit = pixelDetHits.begin(); 
            pixelDetHit!= pixelDetHits.end(); ++pixelDetHit) {
        RecHitVec.push_back((TrackingRecHit*)(&(*pixelDetHit)));
      }
    } else {
      edm::LogWarning("RoadSearch") << "pixel RecHit collection not set properly";
    } 
  } else {
    
    edm::LogError("RoadSearch") << "NEITHER PIXEL NOR STRIP DETECTOR ID";

  }
  
  
  return RecHitVec;
}
void DetHitAccess::setCollections ( const SiStripRecHit2DCollection rphiRecHits,
const SiStripRecHit2DCollection stereoRecHits,
const SiStripMatchedRecHit2DCollection matchedRecHits,
const SiPixelRecHitCollection pixelRecHits 
)

Definition at line 42 of file DetHitAccess.cc.

References matchedHits_, pixelHits_, rphiHits_, and stereoHits_.

Referenced by DetHitAccess(), RoadSearchSeedFinderAlgorithm::run(), and RoadSearchCloudMakerAlgorithm::run().

                                                                               {
  
  rphiHits_ = rphiRecHits;
  stereoHits_ = stereoRecHits;
  matchedHits_ = matchedRecHits;
  pixelHits_ = pixelRecHits;

}
void DetHitAccess::setMode ( accessMode  input) [inline]
void DetHitAccess::use_rphiRecHits ( bool  input) [inline]
void DetHitAccess::use_stereoRecHits ( bool  input) [inline]

Member Data Documentation

Definition at line 50 of file DetHitAccess.h.

Referenced by DetHitAccess(), getHitVector(), and setMode().

Definition at line 57 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

Definition at line 58 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

Definition at line 55 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

Definition at line 56 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

Definition at line 52 of file DetHitAccess.h.

Referenced by DetHitAccess(), getHitVector(), and use_rphiRecHits().

Definition at line 53 of file DetHitAccess.h.

Referenced by DetHitAccess(), getHitVector(), and use_stereoRecHits().