CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

Rings Class Reference

#include <Rings.h>

List of all members.

Public Types

typedef RingMap::const_iterator const_iterator
typedef RingMap::iterator iterator
typedef std::multimap< double,
Ring
RingMap

Public Member Functions

iterator begin ()
const_iterator begin () const
void dump (std::string ascii_filename="rings.dat") const
void dumpHeader (std::ofstream &stream) const
const_iterator end () const
iterator end ()
const RinggetPXBRing (unsigned int layer, unsigned int detector) const
const RinggetPXFRing (unsigned int fw_bw, unsigned int disk, unsigned int panel, unsigned int module) const
const RinggetRing (DetId id, double phi=999999., double z=999999.) const
const RinggetRing (unsigned int ringIndex, double z=999999.) const
const RinggetTECRing (unsigned int fw_bw, unsigned int wheel, unsigned int ring) const
const RinggetTIBRing (unsigned int layer, unsigned int fw_bw, unsigned int ext_int, unsigned int detector) const
const RinggetTIDRing (unsigned int fw_bw, unsigned int wheel, unsigned int ring) const
const RinggetTOBRing (unsigned int layer, unsigned int rod_fw_bw, unsigned int detector) const
void insert (double z, Ring &ring)
iterator lower_bound (double z)
const_iterator lower_bound (double z) const
void readInFromAsciiFile (std::string ascii_file)
 Rings (std::string ascii_file)
 Rings ()
iterator upper_bound (double z)
const_iterator upper_bound (double z) const
 ~Rings ()

Private Attributes

RingMap ringMap_

Detailed Description

Definition at line 27 of file Rings.h.


Member Typedef Documentation

typedef RingMap::const_iterator Rings::const_iterator

Definition at line 33 of file Rings.h.

typedef RingMap::iterator Rings::iterator

Definition at line 32 of file Rings.h.

typedef std::multimap<double,Ring> Rings::RingMap

Definition at line 31 of file Rings.h.


Constructor & Destructor Documentation

Rings::Rings ( )

Definition at line 36 of file Rings.cc.

             {
  //
  // default constructor
  //
}
Rings::Rings ( std::string  ascii_file)

Definition at line 42 of file Rings.cc.

References readInFromAsciiFile().

                                     {
  //
  // constructor reading in ascii file
  //

  readInFromAsciiFile(ascii_filename);

}
Rings::~Rings ( )

Definition at line 51 of file Rings.cc.

              { 
  //
  // default destructor
  //
}

Member Function Documentation

iterator Rings::begin ( void  ) [inline]

Definition at line 42 of file Rings.h.

References ringMap_.

Referenced by RoadMaker::RingsCompatibleWithSeed().

{ return ringMap_.begin(); }
const_iterator Rings::begin ( void  ) const [inline]

Definition at line 44 of file Rings.h.

References ringMap_.

{ return ringMap_.begin(); }
void Rings::dump ( std::string  ascii_filename = "rings.dat") const

Definition at line 105 of file Rings.cc.

References dumpHeader(), relativeConstraints::ring, and ringMap_.

Referenced by RingMakerESProducer::produce().

                                               {
  //
  // dump all rings in ascii file
  //

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

  dumpHeader(stream);

  for ( const_iterator ring = ringMap_.begin(); ring != ringMap_.end(); ++ring ) {

    stream << ring->second.dump();

  }

}
void Rings::dumpHeader ( std::ofstream &  stream) const

Definition at line 122 of file Rings.cc.

Referenced by dump().

                                                {
  //
  // header with general information about content of rings ascii file
  //

  stream << "#" << std::endl;
  stream << "# Rings 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 all Rings:" << std::endl;
  stream << "#" << std::endl;
  stream << "# Ring   : index, rmin, rmax, zmin, zmax, std::multimap<phi,DetId>: Ring of DetUnits mapped in phi" << std::endl;
  stream << "# " << std::endl;
  stream << "# Ascii-Format:" << std::endl;
  stream << "# " << std::endl;
  stream << "# Ring:" << std::endl;
  stream << "#" << std::endl;
  stream << "#       ### Ring: <index> ###" << std::endl;
  stream << "#       <index> <rmin> <rmax> <zmin> <zmax>" << std::endl;
  stream << "#       <number of DetId's in std::vector<DetId> >" << std::endl;
  stream << "#       <phi of DetUnit described by DetId> <DetId::rawId()>" << std::endl;
  stream << "#       <phi of DetUnit described by DetId> <DetId::rawId()>" << std::endl;
  stream << "#            ..." << std::endl;
  stream << "#" << std::endl;
  stream << "#" << std::endl;
  
}
const_iterator Rings::end ( void  ) const [inline]

Definition at line 45 of file Rings.h.

References ringMap_.

{ return ringMap_.end();   }
iterator Rings::end ( void  ) [inline]

Definition at line 43 of file Rings.h.

References ringMap_.

Referenced by RoadMaker::RingsCompatibleWithSeed().

{ return ringMap_.end();   }
const Ring * Rings::getPXBRing ( unsigned int  layer,
unsigned int  detector 
) const

Definition at line 317 of file Rings.cc.

References getRing().

                                                     {

  // construct DetID from info using else the first of all entities and return Ring
  unsigned int ladder = 0;

  PXBDetId id(layer,ladder,detector);

  return getRing(DetId(id.rawId()));
}
const Ring * Rings::getPXFRing ( unsigned int  fw_bw,
unsigned int  disk,
unsigned int  panel,
unsigned int  module 
) const

Definition at line 329 of file Rings.cc.

References getRing().

                                                   {
  
  // construct DetID from info using else the first of all entities and return Ring
  unsigned int detector = 0;
  
  PXFDetId id(fw_bw+1,disk+1,detector+1,panel+1,module+1);
  
  return getRing(DetId(id.rawId()));
}
const Ring * Rings::getRing ( DetId  id,
double  phi = 999999.,
double  z = 999999. 
) const

Definition at line 152 of file Rings.cc.

References relativeConstraints::ring, and ringMap_.

Referenced by getPXBRing(), getPXFRing(), Roads::getRing(), getTECRing(), getTIBRing(), getTIDRing(), getTOBRing(), and Roads::readInFromAsciiFile().

                                                              {
  //
  // loop over rings to discover ring which contains DetId id
  // loop is restricted to window in z

  // calculate window around given z (if z == 999999. set window to maximum)
  // window is += 1.5 times the longest sensor in z (TOB: ~20 cm)
  double z_min = -999999.;
  double z_max = 999999.;
  double delta_z = 1.5 * 20.;
  if ( z != 999999. ) {
    z_min = z - delta_z;
    z_max = z + delta_z;
  }

  // loop over rings
  for ( const_iterator ring = ringMap_.lower_bound(z_min); ring != ringMap_.upper_bound(z_max); ++ring ) {
    if ( ring->second.containsDetId(id,phi) ) {
      return &(ring->second);
    }
  }
      
  return 0;
}
const Ring * Rings::getRing ( unsigned int  ringIndex,
double  z = 999999. 
) const

Definition at line 177 of file Rings.cc.

References relativeConstraints::ring, and ringMap_.

                                                                 {
  //
  // loop over rings to discover ring which has RingIndex ringIndex
  // loop is restricted to window in z

  // calculate window around given z (if z == 999999. set window to maximum)
  // window is += 1.5 times the longest sensor in z (TOB: ~20 cm)
  double z_min = -999999.;
  double z_max = 999999.;
  double delta_z = 1.5 * 20.;
  if ( z != 999999. ) {
    z_min = z - delta_z;
    z_max = z + delta_z;
  }

  for ( const_iterator ring = ringMap_.lower_bound(z_min); ring != ringMap_.upper_bound(z_max); ++ring ) {
    if ( ring->second.getindex() == ringIndex ) {
      return &(ring->second);
    }
  }
      
  return 0;
}
const Ring * Rings::getTECRing ( unsigned int  fw_bw,
unsigned int  wheel,
unsigned int  ring 
) const

Definition at line 257 of file Rings.cc.

References getRing().

Referenced by RoadMaker::collectInnerTECSeedRings(), RoadMaker::collectInnerTECSeedRings1(), RoadMaker::collectInnerTECSeedRings2(), RoadMaker::collectOuterTECSeedRings(), and RoadMaker::collectOuterTECSeedRings1().

                                                       {
  
  // try to construct first detid from fw_bw, wheel, ring
  // set petal and module to 1 (zero in c-array terms)
  // check for combination if petal_fw_bw is valid, otherwise set to 0 is valid
  // if not, increase them to get a valid id

  int petal_fw_bw = 1;
  int petal       = 1;
  int module      = 1;

  const Ring* int_ring = 0;
  
  // first try stereo = 0, then stereo = 2, then fail
  TECDetId id(fw_bw,wheel,petal_fw_bw,petal,ring,module,0);
  int_ring = getRing(DetId(id.rawId()));
  if ( int_ring == 0 ) {
    TECDetId id(fw_bw,wheel,petal_fw_bw,petal,ring,module,2);
    int_ring = getRing(DetId(id.rawId()));
  }
  
  if ( int_ring == 0 ) {
    edm::LogError("RoadSearch") << "TEC Ring for fw_bw: " << fw_bw
                                << " wheel: " << wheel
                                << " ring: " << ring
                                << " with rawId: " << id.rawId()
                                << " could not be found.";
  }

  return int_ring;
}
const Ring * Rings::getTIBRing ( unsigned int  layer,
unsigned int  fw_bw,
unsigned int  ext_int,
unsigned int  detector 
) const

Definition at line 201 of file Rings.cc.

References getRing(), and relativeConstraints::ring.

Referenced by RoadMaker::collectInnerTIBSeedRings(), RoadMaker::collectInnerTIBSeedRings1(), RoadMaker::collectInnerTIBSeedRings2(), RoadMaker::collectOuterTIBSeedRings(), and RoadMaker::collectOuterTIBSeedRings1().

                                                           {
  
  // construct DetID from info using else the first of all entities and return Ring

  const Ring* ring = 0;

  // first try stereo = 0, then stereo = 2, then fail
  TIBDetId id(layer,fw_bw,ext_int,1,detector,0);
  ring = getRing(DetId(id.rawId()));
  if ( ring == 0 ) {
    TIBDetId id(layer,fw_bw,ext_int,1,detector,2);
    ring = getRing(DetId(id.rawId()));
  }

  if ( ring == 0 ) {
    edm::LogError("RoadSearch") << "TIB Ring for layer: " << layer
                                << " fw_bw: " << fw_bw
                                << " ext_int: " << ext_int
                                << " detector: " << detector 
                                << " with rawId: " << id.rawId()
                                << " could not be found.";
  }

  return ring;
}
const Ring * Rings::getTIDRing ( unsigned int  fw_bw,
unsigned int  wheel,
unsigned int  ring 
) const

Definition at line 230 of file Rings.cc.

References getRing().

Referenced by RoadMaker::collectInnerTIDSeedRings(), RoadMaker::collectInnerTIDSeedRings1(), and RoadMaker::collectInnerTIDSeedRings2().

                                                       {
  
  // construct DetID from info using else the first of all entities and return Ring
  
  const Ring* int_ring = 0;
  
  // first try stereo = 0, then stereo = 2, then fail
  TIDDetId id(fw_bw,wheel,ring,1,1,0);
  int_ring = getRing(DetId(id.rawId()));
  if ( int_ring == 0 ) {
    TIDDetId id(fw_bw,wheel,ring,1,1,2);
    int_ring = getRing(DetId(id.rawId()));
  }
  
  if ( int_ring == 0 ) {
    edm::LogError("RoadSearch") << "TID Ring for fw_bw: " << fw_bw
                                << " wheel: " << wheel
                                << " ring: " << ring
                                << " with rawId: " << id.rawId()
                                << " could not be found.";
  }
  
  return int_ring;
}
const Ring * Rings::getTOBRing ( unsigned int  layer,
unsigned int  rod_fw_bw,
unsigned int  detector 
) const

Definition at line 291 of file Rings.cc.

References getRing(), and relativeConstraints::ring.

Referenced by RoadMaker::collectInnerTOBSeedRings(), RoadMaker::collectInnerTOBSeedRings1(), RoadMaker::collectInnerTOBSeedRings2(), RoadMaker::collectOuterTOBSeedRings(), and RoadMaker::collectOuterTOBSeedRings1().

                                                           {
    
  // construct DetID from info using else the first of all entities and return Ring
  const Ring* ring = 0;
  
  // first try stereo = 0, then stereo = 2, then fail
  TOBDetId id(layer,rod_fw_bw,1,detector,0);
  ring = getRing(DetId(id.rawId()));
  if ( ring == 0 ) {
    TOBDetId id(layer,rod_fw_bw,1,detector,2);
    ring = getRing(DetId(id.rawId()));
  }
  
  if ( ring == 0 ) {
    edm::LogError("RoadSearch") << "TOB Ring for layer: " << layer
                                << " rod_fw_bw: " << rod_fw_bw
                                << " detector: " << detector 
                                << " with rawId: " << id.rawId()
                                << " could not be found.";
  }
  
  return ring;
}
void Rings::insert ( double  z,
Ring ring 
) [inline]
iterator Rings::lower_bound ( double  z) [inline]

Definition at line 46 of file Rings.h.

References ringMap_.

{ return ringMap_.lower_bound(z); }
const_iterator Rings::lower_bound ( double  z) const [inline]

Definition at line 48 of file Rings.h.

References ringMap_.

{ return ringMap_.lower_bound(z); }
void Rings::readInFromAsciiFile ( std::string  ascii_file)

Definition at line 57 of file Rings.cc.

References Ring::addId(), cond::rpcobgas::detid, i, getHLTprescales::index, LaserDQM_cfg::input, geometryCSVtoXML::line, phi, relativeConstraints::ring, ringMap_, AlCaHLTBitMon_QueryRunRegistry::string, SiStripMonitorClusterAlca_cfi::zmax, and SiStripMonitorClusterAlca_cfi::zmin.

Referenced by Rings().

                                                        {
  // 
  // read in all rings stored in ascii file
  //

  std::ifstream input(ascii_filename.c_str());
  std::istringstream stream;
  std::string line;
  unsigned int index, type;
  float rmin,rmax,zmin,zmax;
  unsigned int ndetid = 0;
  double phi;
  unsigned int detid;
  
  while ( std::getline(input,line) ) {
    if ( !std::isspace(line[0]) && !(line[0] == 35) ) {

      // ring
      stream.str(line);
      stream.clear();
      stream >> index >> rmin >> rmax >> zmin >> zmax >> type;
      Ring ring(index,rmin,rmax,zmin,zmax,type);
      std::getline(input,line);
      while (std::isspace(line[0]) || (line[0] == 35) ) {
        std::getline(input,line);
      }
      stream.str(line);
      stream.clear();
      stream >> ndetid;
      for (unsigned int i = 0; i < ndetid; ++i ) {
        std::getline(input,line);
        while (std::isspace(line[0]) || (line[0] == 35) ) {
          std::getline(input,line);
        }
        stream.str(line);
        stream.clear();
        stream >> phi >> detid;
        ring.addId(phi,DetId(detid));
      }
      double center_z = zmin + ((zmax-zmin)/2);
      ringMap_.insert(std::make_pair(center_z,ring));
    }
  }

  edm::LogInfo("RoadSearch") << "Read in: " << ringMap_.size() << " Rings from file: " << ascii_filename;

}
const_iterator Rings::upper_bound ( double  z) const [inline]

Definition at line 49 of file Rings.h.

References ringMap_.

{ return ringMap_.upper_bound(z); }
iterator Rings::upper_bound ( double  z) [inline]

Definition at line 47 of file Rings.h.

References ringMap_.

{ return ringMap_.upper_bound(z); }

Member Data Documentation

Definition at line 80 of file Rings.h.

Referenced by begin(), dump(), end(), getRing(), insert(), lower_bound(), readInFromAsciiFile(), and upper_bound().