CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
Roads Class Reference

#include <Roads.h>

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
 
iterator end ()
 
const_iterator end () const
 
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 ()
 
 Roads (std::string ascii_file, const Rings *rings)
 
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.

45  {
46  RPhi,
47  ZPhi
48  };

Constructor & Destructor Documentation

Roads::Roads ( )

Definition at line 33 of file Roads.cc.

33  {
34 
35 }
Roads::Roads ( std::string  ascii_file,
const Rings rings 
)

Definition at line 37 of file Roads.cc.

References readInFromAsciiFile().

37  : rings_(rings) {
38 
39  readInFromAsciiFile(ascii_filename);
40 
41 }
const Rings * rings_
Definition: Roads.h:96
void readInFromAsciiFile(std::string ascii_file)
Definition: Roads.cc:47
Roads::~Roads ( )

Definition at line 43 of file Roads.cc.

43  {
44 
45 }

Member Function Documentation

iterator Roads::begin ( void  )
inline

Definition at line 58 of file Roads.h.

References roadMap_.

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

58 { return roadMap_.begin(); }
RoadMap roadMap_
Definition: Roads.h:97
const_iterator Roads::begin ( void  ) const
inline

Definition at line 61 of file Roads.h.

References roadMap_.

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

Definition at line 173 of file Roads.cc.

References dumpHeader(), relativeConstraints::ring, roadMap_, and runtimedef::set().

Referenced by RoadMapMakerESProducer::produce().

173  {
174 
175  std::ofstream stream(ascii_filename.c_str());
176 
177  dumpHeader(stream);
178 
179  stream << "### Road information ###" << std::endl;
180  stream << roadMap_.size() << std::endl;
181 
182  unsigned int counter = 0;
183 
184  for ( const_iterator roaditerator = roadMap_.begin();
185  roaditerator != roadMap_.end();
186  ++roaditerator ) {
187 
188  ++counter;
189 
190  stream << "### RoadMap Entry " << counter << " ###" << std::endl;
191 
192  RoadSeed seed = (*roaditerator).first;
193  RoadSet set = (*roaditerator).second;
194 
195  stream << "### RoadSeed First Ring ###" << std::endl;
196  stream << seed.first.size() << std::endl;
197  for (std::vector<const Ring*>::const_iterator ring = seed.first.begin();
198  ring != seed.first.end();
199  ++ring ) {
200  stream << (*ring)->getindex() << std::endl;
201  }
202  stream << "### RoadSeed Second Ring ###" << std::endl;
203  stream << seed.second.size() << std::endl;
204  for (std::vector<const Ring*>::const_iterator ring = seed.second.begin();
205  ring != seed.second.end();
206  ++ring ) {
207  stream << (*ring)->getindex() << std::endl;
208  }
209 
210  stream << "### RoadSet ###" << std::endl;
211  stream << set.size() << std::endl;
212  for ( RoadSet::const_iterator layer = set.begin(); layer != set.end(); ++layer ) {
213  stream << "### Layer ###" << std::endl;
214  stream << layer->size() << std::endl;
215  for ( std::vector<const Ring*>::const_iterator ring = layer->begin();
216  ring != layer->end();
217  ++ring ) {
218  stream << (*ring)->getindex() << std::endl;
219  }
220  }
221  }
222 }
void dumpHeader(std::ofstream &stream) const
Definition: Roads.cc:224
RoadMap roadMap_
Definition: Roads.h:97
std::vector< std::vector< const Ring * > > RoadSet
Definition: Roads.h:39
std::pair< std::vector< const Ring * >, std::vector< const Ring * > > RoadSeed
Definition: Roads.h:38
RoadMap::const_iterator const_iterator
Definition: Roads.h:43
void set(const std::string &name, int value)
set the flag, with a run-time name
void Roads::dumpHeader ( std::ofstream &  stream) const

Definition at line 224 of file Roads.cc.

Referenced by dump().

224  {
225 
226  stream << "#" << std::endl;
227  stream << "# Roads for the RoadSearch tracking algorithm" << std::endl;
228  stream << "# Ascii Dump" << std::endl;
229  stream << "# " << std::endl;
230  stream << "# Content:" << std::endl;
231  stream << "# " << std::endl;
232  stream << "# a dump of the RoadMap structure:" << std::endl;
233  stream << "#" << std::endl;
234  stream << "# Road Information: <number of roads>" << std::endl;
235  stream << "# Ring: index, rmin, rmax, zmin, zmax, std::vector<DetId>: Ring of DetUnits in phi taken from ring service" << std::endl;
236  stream << "# RoadSeed: std::pair<std::vector<const Ring*>,std::vector<const Ring*> >: inner and outer Ring Seed for the Road" << std::endl;
237  stream << "# RoadSet : std::vector<std::vectro<const Ring*> >: all Rings belonging to a road structured in layers" << std::endl;
238  stream << "# RoadMap: std::multimap<RoadSeed,RoadSet>: main container for the Roads" << std::endl;
239  stream << "# " << std::endl;
240  stream << "# Ascii-Format:" << std::endl;
241  stream << "# " << std::endl;
242  stream << "# Road Information:" << std::endl;
243  stream << "# <number of roads>" << std::endl;
244  stream << "#" << std::endl;
245  stream << "# RoadMap for each road:" << std::endl;
246  stream << "#" << std::endl;
247  stream << "# ### RoadMap Entry ###" << std::endl;
248  stream << "# ### RoadSeed First Ring ###" << std::endl;
249  stream << "# <number of inner seed rings>" << std::endl;
250  stream << "# <index>" << std::endl;
251  stream << "# <index>" << std::endl;
252  stream << "# ..." << std::endl;
253  stream << "# ### RoadSeed Second Ring ###" << std::endl;
254  stream << "# <number of outer seed rings>" << std::endl;
255  stream << "# <index>" << std::endl;
256  stream << "# <index>" << std::endl;
257  stream << "# ..." << std::endl;
258  stream << "# ### RoadSet ###" << std::endl;
259  stream << "# <number of Layers in RoadSet>" << std::endl;
260  stream << "# ### Layer ###" << std::endl;
261  stream << "# <number of rings in layer>" << std::endl;
262  stream << "# <index>" << std::endl;
263  stream << "# <index>" << std::endl;
264  stream << "# ..." << std::endl;
265  stream << "# ### Layer ###" << std::endl;
266  stream << "# ..." << std::endl;
267  stream << "#" << std::endl;
268  stream << "#" << std::endl;
269 
270 }
iterator Roads::end ( void  )
inline

Definition at line 59 of file Roads.h.

References roadMap_.

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

59 { return roadMap_.end(); }
RoadMap roadMap_
Definition: Roads.h:97
const_iterator Roads::end ( void  ) const
inline

Definition at line 62 of file Roads.h.

References roadMap_.

62 { return roadMap_.end(); }
RoadMap roadMap_
Definition: Roads.h:97
void Roads::erase ( iterator  entry)
inline

Definition at line 88 of file Roads.h.

References roadMap_.

Referenced by RoadMaker::AddRoad().

88 { roadMap_.erase(entry); }
RoadMap roadMap_
Definition: Roads.h:97
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
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 detailsBasic3DVector::z.

90  {
91  return rings_->getRing(id,phi,z);
92  }
const Rings * rings_
Definition: Roads.h:96
const Ring * getRing(DetId id, double phi=999999., double z=999999.) const
Definition: Rings.cc:152
double double double z
Definition: DDAxes.h:10
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, Ring::TECRing, StripSubdetector::TIB, Ring::TIBRing, StripSubdetector::TID, Ring::TIDRing, StripSubdetector::TOB, Ring::TOBRing, and Ring::Unspecified.

Referenced by getRoadSeed().

390  {
391 
393 
394  if ( (unsigned int)id.subdetId() == StripSubdetector::TIB ) {
395  type = Ring::TIBRing;
396  } else if ( (unsigned int)id.subdetId() == StripSubdetector::TOB ) {
397  type = Ring::TOBRing;
398  } else if ( (unsigned int)id.subdetId() == StripSubdetector::TID ) {
399  type = Ring::TIDRing;
400  } else if ( (unsigned int)id.subdetId() == StripSubdetector::TEC ) {
401  type = Ring::TECRing;
402  } else if ( (unsigned int)id.subdetId() == PixelSubdetector::PixelBarrel ) {
403  type = Ring::PXBRing;
404  } else if ( (unsigned int)id.subdetId() == PixelSubdetector::PixelEndcap ) {
405  type = Ring::PXFRing;
406  }
407 
408  return type;
409 
410 }
type
Definition: HCALResponse.h:22
type
Definition: Roads.h:45
type
Definition: Ring.h:41
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_.

276  {
277 
278  // loop over seed Ring pairs
279 
280  // determine ringtype for inner seed ring detid
281  Ring::type innerSeedRingType = getRingType(InnerSeedRing);
282  Ring::type outerSeedRingType = getRingType(OuterSeedRing);
283 
284  for ( const_iterator road = roadMap_.begin(); road != roadMap_.end(); ++road ) {
285  for ( std::vector<const Ring*>::const_iterator innerRing = road->first.first.begin();
286  innerRing != road->first.first.end();
287  ++innerRing ) {
288  if ( (*innerRing)->getType() == innerSeedRingType ) {
289  for ( std::vector<const Ring*>::const_iterator outerRing = road->first.second.begin();
290  outerRing != road->first.second.end();
291  ++outerRing ) {
292  if ( (*outerRing)->getType() == outerSeedRingType ) {
293  if ( (*innerRing)->containsDetId(InnerSeedRing,InnerSeedRingPhi,dphi_scalefactor) &&
294  (*outerRing)->containsDetId(OuterSeedRing,OuterSeedRingPhi,dphi_scalefactor) ) {
295  return &(road->first);
296  }
297  }
298  }
299  }
300  }
301  }
302 
303  edm::LogError("RoadSearch") << "RoadSeed could not be found for inner SeedRing type: " << innerSeedRingType << " DetId: " << InnerSeedRing.rawId()
304  << " at " << InnerSeedRingPhi
305  << " and outer SeedRing type : " << outerSeedRingType << " DetID: " << OuterSeedRing.rawId()
306  << " at " << OuterSeedRingPhi;
307  return 0;
308 }
RoadMap roadMap_
Definition: Roads.h:97
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
RoadMap::const_iterator const_iterator
Definition: Roads.h:43
const Ring::type getRingType(DetId id) const
Definition: Roads.cc:390
type
Definition: Ring.h:41
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_.

312  {
313  //
314  // loop over roads and return first road which contains all seedRingDetIds
315  //
316 
317  for ( const_iterator road = roadMap_.begin(); road != roadMap_.end(); ++road ) {
318  unsigned int found = 0;
319  for ( unsigned int detIdCounter = 0;
320  detIdCounter < seedRingDetIds.size();
321  ++detIdCounter ) {
322  DetId id = RoadSearchDetIdHelper::ReturnRPhiId(seedRingDetIds[detIdCounter]);
323  double phi = seedRingHitsPhi[detIdCounter];
325 
326  bool foundInInnerRing = false;
327  for ( std::vector<const Ring*>::const_iterator innerRing = road->first.first.begin();
328  innerRing != road->first.first.end();
329  ++innerRing ) {
330  if ( (*innerRing)->getType() == type ) {
331  if ( (*innerRing)->containsDetId(id,phi,dphi_scalefactor) ) {
332  ++found;
333  foundInInnerRing = true;
334  }
335  }
336  }
337 
338  if ( !foundInInnerRing ) {
339  for ( std::vector<const Ring*>::const_iterator outerRing = road->first.second.begin();
340  outerRing != road->first.second.end();
341  ++outerRing ) {
342  if ( (*outerRing)->getType() == type ) {
343  if ( (*outerRing)->containsDetId(id,phi,dphi_scalefactor) ) {
344  ++found;
345  }
346  }
347  }
348  }
349 
350  if ( found == seedRingDetIds.size() ) {
351  return &(road->first);
352  }
353  }
354  }
355 
356  std::ostringstream ost;
357 
358  ost << "RoadSeed could not be found for following hits:\n";
359  for ( unsigned int detIdCounter = 0;
360  detIdCounter < seedRingDetIds.size();
361  ++detIdCounter ) {
362  ost << "Hit DetId: " << seedRingDetIds[detIdCounter].rawId() << " phi: " << seedRingHitsPhi[detIdCounter] << "\n";
363  }
364 
365  edm::LogError("RoadSearch") << ost.str();
366 
367  return 0;
368 }
type
Definition: HCALResponse.h:22
static DetId ReturnRPhiId(const DetId id)
RoadMap roadMap_
Definition: Roads.h:97
Definition: DetId.h:20
RoadMap::const_iterator const_iterator
Definition: Roads.h:43
const Ring::type getRingType(DetId id) const
Definition: Roads.cc:390
type
Definition: Roads.h:45
type
Definition: Ring.h:41
Definition: DDAxes.h:10
const_iterator Roads::getRoadSet ( const RoadSeed seed) const
inline

Definition at line 82 of file Roads.h.

References roadMap_.

82 { return roadMap_.find(*seed); }
RoadMap roadMap_
Definition: Roads.h:97
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.

370  {
371  //
372  // check if one of the outer rings is in TOB, then mark as RPhi
373  // problematic for transition region
374  bool TOBRing = false;
375  for ( std::vector<const Ring*>::const_iterator ring = seed->second.begin();
376  ring != seed->second.end();
377  ++ring) {
378  if ( (*ring)->getType() == Ring::TOBRing) {
379  TOBRing = true;
380  }
381  }
382  if ( TOBRing ) {
383  return Roads::RPhi;
384  } else {
385  return Roads::ZPhi;
386  }
387 }
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().

55 { roadMap_.insert(make_pair(*seed,*set)); }
RoadMap roadMap_
Definition: Roads.h:97
void set(const std::string &name, int value)
set the flag, with a run-time name
void Roads::insert ( RoadSeed  seed,
RoadSet  set 
)
inline

Definition at line 56 of file Roads.h.

References roadMap_.

56 { roadMap_.insert(make_pair(seed,set)); }
RoadMap roadMap_
Definition: Roads.h:97
void set(const std::string &name, int value)
set the flag, with a run-time name
void Roads::readInFromAsciiFile ( std::string  ascii_file)

Definition at line 47 of file Roads.cc.

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

Referenced by Roads().

47  {
48 
49  // input file
50  std::ifstream input(ascii_filename.c_str());
51 
52  // variable declaration
53  unsigned int counter = 0;
54  std::istringstream stream;
55  std::string line;
56  unsigned int nroads = 0;
57  unsigned int nrings = 0;
58  unsigned int nlayers = 0;
59  unsigned int index = 0;
60 
61  // read in number of roads
62  std::getline(input,line);
63  while (std::isspace(line[0]) || (line[0] == 35) ) {
64  std::getline(input,line);
65  }
66  stream.str(line);
67  stream.clear();
68  stream >> nroads;
69 
70  for (unsigned int road = 0;
71  road < nroads;
72  ++road ) {
73  // read in number of inner seed rings
74  std::getline(input,line);
75  while (std::isspace(line[0]) || (line[0] == 35) ) {
76  std::getline(input,line);
77  }
78  std::vector<const Ring*> innerSeedRings;
79  stream.str(line);
80  stream.clear();
81  stream >> nrings;
82  for ( unsigned int i = 0;
83  i < nrings;
84  ++i ) {
85 
86  // read in ring indices for inner seed rings
87  std::getline(input,line);
88  while (std::isspace(line[0]) || (line[0] == 35) ) {
89  std::getline(input,line);
90  }
91  stream.str(line);
92  stream.clear();
93  stream >> index;
94  innerSeedRings.push_back(rings_->getRing(index));
95  }
96 
97  // read in number of outer seed rings
98  std::getline(input,line);
99  while (std::isspace(line[0]) || (line[0] == 35) ) {
100  std::getline(input,line);
101  }
102  std::vector<const Ring*> outerSeedRings;
103  stream.str(line);
104  stream.clear();
105  stream >> nrings;
106  for ( unsigned int i = 0;
107  i < nrings;
108  ++i ) {
109 
110  // read in ring indices for outer seed rings
111  std::getline(input,line);
112  while (std::isspace(line[0]) || (line[0] == 35) ) {
113  std::getline(input,line);
114  }
115  stream.str(line);
116  stream.clear();
117  stream >> index;
118  outerSeedRings.push_back(rings_->getRing(index));
119  }
120 
121  // RoadSeed
122  RoadSeed seed(innerSeedRings,outerSeedRings);
123 
124  // RoadSet
125  RoadSet set;
126 
127  // number of layers in road set
128  std::getline(input,line);
129  while (std::isspace(line[0]) || (line[0] == 35) ) {
130  std::getline(input,line);
131  }
132  stream.str(line);
133  stream.clear();
134  stream >> nlayers;
135 
136  for ( unsigned int i = 0;
137  i < nlayers;
138  ++i ) {
139 
140  std::vector<const Ring*> layer;
141 
142  // number of rings in layer
143  std::getline(input,line);
144  while (std::isspace(line[0]) || (line[0] == 35) ) {
145  std::getline(input,line);
146  }
147  stream.str(line);
148  stream.clear();
149  stream >> nrings;
150  for ( unsigned int j = 0; j < nrings; ++j ) {
151  std::getline(input,line);
152  while (std::isspace(line[0]) || (line[0] == 35) ) {
153  std::getline(input,line);
154  }
155  stream.str(line);
156  stream.clear();
157  stream >> index;
158  layer.push_back(rings_->getRing(index));
159  }
160  set.push_back(layer);
161  }
162 
163 
164  // add seed and set to map
165  roadMap_.insert(make_pair(seed,set));
166  ++counter;
167  }
168 
169  edm::LogInfo("RoadSearch") << "Read in: " << counter << " RoadSets from file: " << ascii_filename;
170 
171 }
const Rings * rings_
Definition: Roads.h:96
const Ring * getRing(DetId id, double phi=999999., double z=999999.) const
Definition: Rings.cc:152
int i
Definition: DBlmapReader.cc:9
RoadMap roadMap_
Definition: Roads.h:97
std::vector< std::vector< const Ring * > > RoadSet
Definition: Roads.h:39
int j
Definition: DBlmapReader.cc:9
std::pair< std::vector< const Ring * >, std::vector< const Ring * > > RoadSeed
Definition: Roads.h:38
void set(const std::string &name, int value)
set the flag, with a run-time name
RoadMap::size_type Roads::size ( void  ) const
inline

Definition at line 64 of file Roads.h.

References roadMap_.

Referenced by RoadMaker::constructRoads().

64 { return roadMap_.size(); }
RoadMap roadMap_
Definition: Roads.h:97

Member Data Documentation

const Rings* Roads::rings_
private

Definition at line 96 of file Roads.h.

Referenced by getRing(), and readInFromAsciiFile().

RoadMap Roads::roadMap_
private

Definition at line 97 of file Roads.h.

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