CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

Roads Class Reference

#include <Roads.h>

List of all members.

Public Types

typedef RoadMap::const_iterator const_iterator
typedef RoadMap::iterator iterator
typedef std::multimap
< RoadSeed, RoadSet,
RoadMapSorting
RoadMap
typedef std::pair< std::vector
< const Ring * >, std::vector
< const Ring * > > 
RoadSeed
typedef std::vector
< std::vector< const Ring * > > 
RoadSet
enum  type { RPhi, ZPhi }

Public Member Functions

iterator begin ()
const_iterator begin () const
void dump (std::string ascii_filename="roads.dat") const
void dumpHeader (std::ofstream &stream) const
const_iterator end () const
iterator end ()
void erase (iterator entry)
const RinggetRing (DetId id, double phi=999999., double z=999999.) const
const Ring::type getRingType (DetId id) const
const RoadSeedgetRoadSeed (DetId InnerSeedRing, DetId OuterSeedRing, double InnerSeedRingPhi=999999., double OuterSeedRingPhi=999999., double dphi_scalefactor=1.5) const
const RoadSeedgetRoadSeed (std::vector< DetId > seedRingDetIds, std::vector< double > seedRingHitsPhi, double dphi_scalefactor=1.5) const
const_iterator getRoadSet (const RoadSeed *seed) const
const type getRoadType (const RoadSeed *const seed) const
void insert (RoadSeed *seed, RoadSet *set)
void insert (RoadSeed seed, RoadSet set)
void readInFromAsciiFile (std::string ascii_file)
 Roads (std::string ascii_file, const Rings *rings)
 Roads ()
RoadMap::size_type size () const
 ~Roads ()

Private Attributes

const Ringsrings_
RoadMap roadMap_

Detailed Description

Definition at line 34 of file Roads.h.


Member Typedef Documentation

typedef RoadMap::const_iterator Roads::const_iterator

Definition at line 43 of file Roads.h.

typedef RoadMap::iterator Roads::iterator

Definition at line 42 of file Roads.h.

Definition at line 40 of file Roads.h.

typedef std::pair<std::vector<const Ring*>, std::vector<const Ring*> > Roads::RoadSeed

Definition at line 38 of file Roads.h.

typedef std::vector<std::vector<const Ring*> > Roads::RoadSet

Definition at line 39 of file Roads.h.


Member Enumeration Documentation

Enumerator:
RPhi 
ZPhi 

Definition at line 45 of file Roads.h.

            {
    RPhi,
    ZPhi
  };

Constructor & Destructor Documentation

Roads::Roads ( )

Definition at line 33 of file Roads.cc.

             {

}
Roads::Roads ( std::string  ascii_file,
const Rings rings 
)

Definition at line 37 of file Roads.cc.

References readInFromAsciiFile().

                                                         : rings_(rings) {

  readInFromAsciiFile(ascii_filename);

}
Roads::~Roads ( )

Definition at line 43 of file Roads.cc.

              { 

}

Member Function Documentation

iterator Roads::begin ( void  ) [inline]

Definition at line 58 of file Roads.h.

References roadMap_.

Referenced by RoadMaker::AddRoad(), dump(), and RoadSearchSeedFinderAlgorithm::run().

{ return roadMap_.begin(); }
const_iterator Roads::begin ( void  ) const [inline]

Definition at line 61 of file Roads.h.

References roadMap_.

{ return roadMap_.begin(); }
void Roads::dump ( std::string  ascii_filename = "roads.dat") const

Definition at line 173 of file Roads.cc.

References begin(), dumpHeader(), relativeConstraints::ring, and roadMap_.

Referenced by RoadMapMakerESProducer::produce().

                                               {

  std::ofstream stream(ascii_filename.c_str());
  
  dumpHeader(stream);

  stream << "### Road information ###" << std::endl;
  stream << roadMap_.size() << std::endl;

  unsigned int counter = 0;

  for ( const_iterator roaditerator = roadMap_.begin(); 
        roaditerator != roadMap_.end(); 
        ++roaditerator ) {

    ++counter;

    stream << "### RoadMap Entry " << counter << " ###" << std::endl;

    RoadSeed seed = (*roaditerator).first;
    RoadSet  set  = (*roaditerator).second;

    stream << "### RoadSeed First Ring ###" << std::endl;
    stream << seed.first.size() << std::endl;
    for (std::vector<const Ring*>::const_iterator ring = seed.first.begin();
         ring != seed.first.end();
         ++ring ) {
      stream << (*ring)->getindex() << std::endl;
    }
    stream << "### RoadSeed Second Ring ###" << std::endl;
    stream << seed.second.size() << std::endl;
    for (std::vector<const Ring*>::const_iterator ring = seed.second.begin();
         ring != seed.second.end();
         ++ring ) {
      stream << (*ring)->getindex() << std::endl;
    }

    stream << "### RoadSet ###" << std::endl;
    stream << set.size() << std::endl;
    for ( RoadSet::const_iterator layer = set.begin(); layer != set.end(); ++layer ) {
      stream << "### Layer ###" << std::endl;
      stream << layer->size() << std::endl;
      for ( std::vector<const Ring*>::const_iterator ring = layer->begin();
            ring != layer->end();
            ++ring ) {
        stream << (*ring)->getindex() << std::endl;
      }
    }
  }
}
void Roads::dumpHeader ( std::ofstream &  stream) const

Definition at line 224 of file Roads.cc.

Referenced by dump().

                                                {

  stream << "#" << std::endl;
  stream << "# Roads for the RoadSearch tracking algorithm" << std::endl;
  stream << "# Ascii Dump" << std::endl;
  stream << "# " << std::endl;
  stream << "# Content:" << std::endl;
  stream << "# " << std::endl;
  stream << "# a dump of the RoadMap structure:" << std::endl;
  stream << "#" << std::endl;
  stream << "# Road Information: <number of roads>" << std::endl;
  stream << "# Ring: index, rmin, rmax, zmin, zmax, std::vector<DetId>: Ring of DetUnits in phi taken from ring service" << std::endl;
  stream << "# RoadSeed: std::pair<std::vector<const Ring*>,std::vector<const Ring*> >: inner and outer Ring Seed for the Road" << std::endl;
  stream << "# RoadSet : std::vector<std::vectro<const Ring*> >: all Rings belonging to a road structured in layers" << std::endl;
  stream << "# RoadMap: std::multimap<RoadSeed,RoadSet>: main container for the Roads" << std::endl;
  stream << "# " << std::endl;
  stream << "# Ascii-Format:" << std::endl;
  stream << "# " << std::endl;
  stream << "# Road Information:" << std::endl;
  stream << "#       <number of roads>" << std::endl;
  stream << "#" << std::endl;
  stream << "# RoadMap for each road:" << std::endl;
  stream << "#" << std::endl;
  stream << "#       ### RoadMap Entry ###" << std::endl;
  stream << "#       ### RoadSeed First Ring ###" << std::endl;
  stream << "#       <number of inner seed rings>" << std::endl;
  stream << "#       <index>" << std::endl;
  stream << "#       <index>" << std::endl;
  stream << "#       ..." << std::endl;
  stream << "#       ### RoadSeed Second Ring ###" << std::endl;
  stream << "#       <number of outer seed rings>" << std::endl;
  stream << "#       <index>" << std::endl;
  stream << "#       <index>" << std::endl;
  stream << "#       ..." << std::endl;
  stream << "#       ### RoadSet ###" << std::endl;
  stream << "#       <number of Layers in RoadSet>" << std::endl;
  stream << "#       ### Layer ###" << std::endl;
  stream << "#       <number of rings in layer>" << std::endl;
  stream << "#       <index>" << std::endl;
  stream << "#       <index>" << std::endl;
  stream << "#        ..." << std::endl;
  stream << "#       ### Layer ###" << std::endl;
  stream << "#        ..." << std::endl;
  stream << "#" << std::endl;
  stream << "#" << std::endl;
  
}
iterator Roads::end ( void  ) [inline]

Definition at line 59 of file Roads.h.

References roadMap_.

Referenced by RoadMaker::AddRoad(), and RoadSearchSeedFinderAlgorithm::run().

{ return roadMap_.end();   }
const_iterator Roads::end ( void  ) const [inline]

Definition at line 62 of file Roads.h.

References roadMap_.

{ return roadMap_.end();   }
void Roads::erase ( iterator  entry) [inline]

Definition at line 88 of file Roads.h.

References roadMap_.

Referenced by RoadMaker::AddRoad().

{ roadMap_.erase(entry); }
const Ring* Roads::getRing ( DetId  id,
double  phi = 999999.,
double  z = 999999. 
) const [inline]

Definition at line 90 of file Roads.h.

References Rings::getRing(), phi, rings_, and z.

                                                                                       {
    return rings_->getRing(id,phi,z);
  }
const Ring::type Roads::getRingType ( DetId  id) const

Definition at line 390 of file Roads.cc.

References PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, Ring::PXBRing, Ring::PXFRing, StripSubdetector::TEC, align::TECRing, StripSubdetector::TIB, Ring::TIBRing, StripSubdetector::TID, align::TIDRing, StripSubdetector::TOB, Ring::TOBRing, and Ring::Unspecified.

Referenced by getRoadSeed().

                                                {

  Ring::type type = Ring::Unspecified;

  if ( (unsigned int)id.subdetId() == StripSubdetector::TIB ) {
    type = Ring::TIBRing;
  } else if ( (unsigned int)id.subdetId() == StripSubdetector::TOB ) {
    type = Ring::TOBRing;
  } else if ( (unsigned int)id.subdetId() == StripSubdetector::TID ) {
    type = Ring::TIDRing;
  } else if ( (unsigned int)id.subdetId() == StripSubdetector::TEC ) {
    type = Ring::TECRing;
  } else if ( (unsigned int)id.subdetId() == PixelSubdetector::PixelBarrel ) {
    type = Ring::PXBRing;
  } else if ( (unsigned int)id.subdetId() == PixelSubdetector::PixelEndcap ) {
    type = Ring::PXFRing;
  }

  return type;

}
const Roads::RoadSeed * Roads::getRoadSeed ( DetId  InnerSeedRing,
DetId  OuterSeedRing,
double  InnerSeedRingPhi = 999999.,
double  OuterSeedRingPhi = 999999.,
double  dphi_scalefactor = 1.5 
) const

Definition at line 272 of file Roads.cc.

References getRingType(), DetId::rawId(), and roadMap_.

                                                                         {

  // loop over seed Ring pairs

  // determine ringtype for inner seed ring detid
  Ring::type innerSeedRingType = getRingType(InnerSeedRing);
  Ring::type outerSeedRingType = getRingType(OuterSeedRing);

  for ( const_iterator road = roadMap_.begin(); road != roadMap_.end(); ++road ) {
    for ( std::vector<const Ring*>::const_iterator innerRing = road->first.first.begin();
          innerRing != road->first.first.end();
          ++innerRing ) {
      if ( (*innerRing)->getType() == innerSeedRingType ) {
        for ( std::vector<const Ring*>::const_iterator outerRing = road->first.second.begin();
              outerRing != road->first.second.end();
              ++outerRing ) {
          if ( (*outerRing)->getType() == outerSeedRingType ) {
            if ( (*innerRing)->containsDetId(InnerSeedRing,InnerSeedRingPhi,dphi_scalefactor) &&
                 (*outerRing)->containsDetId(OuterSeedRing,OuterSeedRingPhi,dphi_scalefactor) ) {
              return &(road->first);
            }
          }
        }
      }
    }
  }
      
  edm::LogError("RoadSearch") << "RoadSeed could not be found for inner SeedRing type: " << innerSeedRingType << " DetId: " << InnerSeedRing.rawId() 
                              << " at " << InnerSeedRingPhi
                              << " and outer SeedRing type : " << outerSeedRingType << " DetID: " << OuterSeedRing.rawId() 
                              << " at " << OuterSeedRingPhi;
  return 0;
}
const Roads::RoadSeed * Roads::getRoadSeed ( std::vector< DetId seedRingDetIds,
std::vector< double >  seedRingHitsPhi,
double  dphi_scalefactor = 1.5 
) const

Definition at line 310 of file Roads.cc.

References newFWLiteAna::found, getRingType(), phi, RoadSearchDetIdHelper::ReturnRPhiId(), and roadMap_.

                                                                         {
  //
  // loop over roads and return first road which contains all seedRingDetIds
  //

  for ( const_iterator road = roadMap_.begin(); road != roadMap_.end(); ++road ) {
    unsigned int found = 0;
    for ( unsigned int detIdCounter = 0;
          detIdCounter < seedRingDetIds.size();
          ++detIdCounter ) {
      DetId      id   = RoadSearchDetIdHelper::ReturnRPhiId(seedRingDetIds[detIdCounter]);
      double     phi  = seedRingHitsPhi[detIdCounter];
      Ring::type type = getRingType(id);

      bool foundInInnerRing = false;
      for ( std::vector<const Ring*>::const_iterator innerRing = road->first.first.begin();
            innerRing != road->first.first.end();
            ++innerRing ) {
        if ( (*innerRing)->getType() == type ) {
          if ( (*innerRing)->containsDetId(id,phi,dphi_scalefactor) ) {
            ++found;
            foundInInnerRing = true;
          }
        }
      }

      if ( !foundInInnerRing ) {
        for ( std::vector<const Ring*>::const_iterator outerRing = road->first.second.begin();
              outerRing != road->first.second.end();
              ++outerRing ) {
          if ( (*outerRing)->getType() == type ) {
            if ( (*outerRing)->containsDetId(id,phi,dphi_scalefactor) ) {
              ++found;
            }
          }
        }
      }

      if ( found == seedRingDetIds.size() ) {
              return &(road->first);
      }
    }
  }

  std::ostringstream ost;
  
  ost << "RoadSeed could not be found for following hits:\n";
  for ( unsigned int detIdCounter = 0;
        detIdCounter < seedRingDetIds.size();
        ++detIdCounter ) {
    ost << "Hit DetId: " << seedRingDetIds[detIdCounter].rawId() << " phi: " << seedRingHitsPhi[detIdCounter] << "\n";
  }
  
  edm::LogError("RoadSearch") << ost.str();
  
  return 0;
}
const_iterator Roads::getRoadSet ( const RoadSeed seed) const [inline]

Definition at line 82 of file Roads.h.

References roadMap_.

{ return roadMap_.find(*seed); }
const Roads::type Roads::getRoadType ( const RoadSeed *const  seed) const

Definition at line 370 of file Roads.cc.

References relativeConstraints::ring, RPhi, Ring::TOBRing, and ZPhi.

                                                                   {
  //
  // check if one of the outer rings is in TOB, then mark as RPhi
  // problematic for transition region
  bool TOBRing = false;
  for ( std::vector<const Ring*>::const_iterator ring = seed->second.begin();
        ring != seed->second.end();
        ++ring) {
    if ( (*ring)->getType() == Ring::TOBRing) {
      TOBRing = true;
    }
  }
  if ( TOBRing ) {
    return Roads::RPhi;
  } else {
    return Roads::ZPhi;
  }
}
void Roads::insert ( RoadSeed seed,
RoadSet set 
) [inline]

Definition at line 55 of file Roads.h.

References roadMap_.

Referenced by RoadMaker::AddRoad(), and RoadMaker::constructRoads().

{ roadMap_.insert(make_pair(*seed,*set)); }
void Roads::insert ( RoadSeed  seed,
RoadSet  set 
) [inline]

Definition at line 56 of file Roads.h.

References roadMap_.

{ roadMap_.insert(make_pair(seed,set)); }
void Roads::readInFromAsciiFile ( std::string  ascii_file)

Definition at line 47 of file Roads.cc.

References Rings::getRing(), i, getHLTprescales::index, collect_tpl::input, j, geometryCSVtoXML::line, rings_, and roadMap_.

Referenced by Roads().

                                                        {

  // input file
  std::ifstream input(ascii_filename.c_str());

  // variable declaration
  unsigned int counter         = 0;
  std::istringstream stream;
  std::string line;
  unsigned int nroads          = 0;
  unsigned int nrings          = 0;
  unsigned int nlayers         = 0;
  unsigned int index           = 0;

  // read in number of roads
  std::getline(input,line);
  while (std::isspace(line[0]) || (line[0] == 35) ) {
    std::getline(input,line);
  }
  stream.str(line);
  stream.clear();
  stream >> nroads;

  for (unsigned int road = 0; 
       road < nroads;
       ++road ) {
    // read in number of inner seed rings
    std::getline(input,line);
    while (std::isspace(line[0]) || (line[0] == 35) ) {
      std::getline(input,line);
    }
    std::vector<const Ring*> innerSeedRings;
    stream.str(line);
    stream.clear();
    stream >> nrings;
    for ( unsigned int i = 0;
          i < nrings;
          ++i ) {

      // read in ring indices for inner seed rings
      std::getline(input,line);
      while (std::isspace(line[0]) || (line[0] == 35) ) {
        std::getline(input,line);
      }
      stream.str(line);
      stream.clear();
      stream >> index;
      innerSeedRings.push_back(rings_->getRing(index));
    }

    // read in number of outer seed rings
    std::getline(input,line);
    while (std::isspace(line[0]) || (line[0] == 35) ) {
      std::getline(input,line);
    }
    std::vector<const Ring*> outerSeedRings;
    stream.str(line);
    stream.clear();
    stream >> nrings;
    for ( unsigned int i = 0;
          i < nrings;
          ++i ) {

      // read in ring indices for outer seed rings
      std::getline(input,line);
      while (std::isspace(line[0]) || (line[0] == 35) ) {
        std::getline(input,line);
      }
      stream.str(line);
      stream.clear();
      stream >> index;
      outerSeedRings.push_back(rings_->getRing(index));
    }

    // RoadSeed
    RoadSeed seed(innerSeedRings,outerSeedRings);

    // RoadSet
    RoadSet set;

    // number of layers in road set
    std::getline(input,line);
    while (std::isspace(line[0]) || (line[0] == 35) ) {
      std::getline(input,line);
    }
    stream.str(line);
    stream.clear();
    stream >> nlayers;

    for ( unsigned int i = 0;
          i < nlayers;
          ++i ) {

      std::vector<const Ring*> layer;

      // number of rings in layer
      std::getline(input,line);
      while (std::isspace(line[0]) || (line[0] == 35) ) {
        std::getline(input,line);
      }
      stream.str(line);
      stream.clear();
      stream >> nrings;
      for ( unsigned int j = 0; j < nrings; ++j ) {
        std::getline(input,line);
        while (std::isspace(line[0]) || (line[0] == 35) ) {
          std::getline(input,line);
        }
        stream.str(line);
        stream.clear();
        stream >> index;
        layer.push_back(rings_->getRing(index));
      }
      set.push_back(layer);
    }
      

    // add seed and set to map
    roadMap_.insert(make_pair(seed,set));
    ++counter;
  }
  
  edm::LogInfo("RoadSearch") << "Read in: " << counter << " RoadSets from file: " << ascii_filename;

}
RoadMap::size_type Roads::size ( void  ) const [inline]

Definition at line 64 of file Roads.h.

References roadMap_.

Referenced by RoadMaker::constructRoads().

{ return roadMap_.size(); }

Member Data Documentation

const Rings* Roads::rings_ [private]

Definition at line 96 of file Roads.h.

Referenced by getRing(), and readInFromAsciiFile().

Definition at line 97 of file Roads.h.

Referenced by begin(), dump(), end(), erase(), getRoadSeed(), getRoadSet(), insert(), readInFromAsciiFile(), and size().