CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GeometryInfoModule.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * Authors:
4 * Jan Kašpar (jan.kaspar@gmail.com)
5 *
6 ****************************************************************************/
7 
16 
21 
22 //----------------------------------------------------------------------------------------------------
23 
31 {
32  public:
33  explicit GeometryInfoModule(const edm::ParameterSet&);
35 
36  struct MeanRPData
37  {
38  unsigned int N, N_u, N_v;
39  double Sx, Sy, Sz, Sdx_u, Sdx_v, Sdy_u, Sdy_v;
40 
41  MeanRPData() : N(0), N_u(0), N_v(0), Sx(0.), Sy(0.), Sz(0.), Sdx_u(0.), Sdx_v(0.), Sdy_u(0.), Sdy_v(0.) {}
42 
43  void Fill(double x, double y, double z, bool uDir, double dx, double dy)
44  {
45  N++;
46  Sx += x;
47  Sy += y;
48  Sz += z;
49 
50  if (uDir)
51  {
52  N_u++;
53  Sdx_u += dx;
54  Sdy_u += dy;
55  } else {
56  N_v++;
57  Sdx_v += dx;
58  Sdy_v += dy;
59  }
60  }
61  };
62 
63  private:
65 
67 
71 
72  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
73  virtual void analyze(const edm::Event&, const edm::EventSetup&);
74  virtual void endJob();
75 
76  void PrintGeometry(const TotemRPGeometry &, const edm::Event&);
77 };
78 
79 using namespace edm;
80 using namespace std;
81 
82 
83 //----------------------------------------------------------------------------------------------------
84 
86  geometryType(ps.getUntrackedParameter<string>("geometryType", "real")),
87  printRPInfo(ps.getUntrackedParameter<bool>("printRPInfo", true)),
88  printSensorInfo(ps.getUntrackedParameter<bool>("printSensorInfo", true)),
89  printMeanSensorInfo(ps.getUntrackedParameter<bool>("printMeanSensorInfo", true))
90 {
91 }
92 
93 //----------------------------------------------------------------------------------------------------
94 
96 {
97 }
98 
99 //----------------------------------------------------------------------------------------------------
100 
102 {
103 }
104 
105 //----------------------------------------------------------------------------------------------------
106 
108 {
109 }
110 
111 //----------------------------------------------------------------------------------------------------
112 
114 {
116 
117  if (!geometryType.compare("ideal"))
118  {
119  if (watcherIdealGeometry.check(es))
120  {
121  es.get<IdealGeometryRecord>().get(geometry);
122  PrintGeometry(*geometry, event);
123  }
124  return;
125  }
126 
127  if (!geometryType.compare("real"))
128  {
129  if (watcherRealGeometry.check(es))
130  {
131  es.get<VeryForwardRealGeometryRecord>().get(geometry);
132  PrintGeometry(*geometry, event);
133  }
134  return;
135  }
136 
137  if (!geometryType.compare("misaligned"))
138  {
140  {
141  es.get<VeryForwardMisalignedGeometryRecord>().get(geometry);
142  PrintGeometry(*geometry, event);
143  }
144  return;
145  }
146 
147  throw cms::Exception("GeometryInfoModule") << "Unknown geometry type: `" << geometryType << "'.";
148 }
149 
150 //----------------------------------------------------------------------------------------------------
151 
153 {
154  time_t unixTime = event.time().unixTime();
155  char timeStr[50];
156  strftime(timeStr, 50, "%F %T", localtime(&unixTime));
157  printf(">> GeometryInfoModule::PrintGeometry\n\tnew %s geometry found in run=%u, event=%llu, UNIX timestamp=%lu (%s)\n",
158  geometryType.c_str(), event.id().run(), event.id().event(), unixTime, timeStr);
159 
160  // RP geometry
161  if (printRPInfo)
162  {
163  printf("\n* RPs:\n");
164  printf(" ID | x (mm) | y (mm) | z (m) |\n");
165  for (TotemRPGeometry::RPDeviceMapType::const_iterator it = geometry.beginRP(); it != geometry.endRP(); ++it)
166  {
167  const DDTranslation &t = it->second->translation();
168  printf(" %3i | %+11.3f | %+11.3f | %+9.4f |\n", it->first, t.x(), t.y(), t.z() * 1E-3);
169  }
170  }
171 
172  // sensor geometry
173  if (printSensorInfo)
174  {
175  printf("\n* silicon sensors:\n");
176  printf("DetId | detector center | readout direction |\n");
177  printf(" | x (mm) | y (mm) | z (m) | dx | dy |\n");
178  for (TotemRPGeometry::mapType::const_iterator it = geometry.beginDet(); it != geometry.endDet(); ++it)
179  {
180  TotemRPDetId id(it->first);
181 
182  double x = it->second->translation().x();
183  double y = it->second->translation().y();
184  double z = it->second->translation().z() * 1E-3;
185 
186  double dx = 0., dy = 0.;
187  geometry.GetReadoutDirection(it->first, dx, dy);
188 
189  printf("%4i | %8.3f | %8.3f | %9.4f | %8.3f | %8.3f |\n", id.getPlaneDecimalId(), x, y, z, dx, dy);
190  }
191  }
192 
193  // sensor geometry averaged over 1 RP
195  {
196  printf("\n* average over silicon sensors of 1 RP:\n");
197 
198  map<unsigned int, MeanRPData> data; // map: RP Id --> sums of geometrical info
199 
200  for (TotemRPGeometry::mapType::const_iterator it = geometry.beginDet(); it != geometry.endDet(); ++it)
201  {
202  TotemRPDetId plId(it->first);
203  unsigned int rpDecId = plId.getRPDecimalId();
204  bool uDirection = plId.isStripsCoordinateUDirection();
205 
206  double x = it->second->translation().x();
207  double y = it->second->translation().y();
208  double z = it->second->translation().z() * 1E-3;
209 
210  double dx = 0., dy = 0.;
211  geometry.GetReadoutDirection(it->first, dx, dy);
212 
213  data[rpDecId].Fill(x, y, z, uDirection, dx, dy);
214  }
215 
216  printf("RPId | center | U direction | V direction |\n");
217  printf(" | x (mm) | y (mm) | z (m) | dx | dy | dx | dy |\n");
218 
219  for (map<unsigned int, MeanRPData>::iterator it = data.begin(); it != data.end(); ++it)
220  {
221  const MeanRPData &d = it->second;
222 
223  double mx = (d.N > 0) ? d.Sx / d.N : 0.;
224  double my = (d.N > 0) ? d.Sy / d.N : 0.;
225  double mz = (d.N > 0) ? d.Sz / d.N : 0.;
226 
227  double mdx_u = (d.N_u > 0) ? d.Sdx_u / d.N_u : 0.;
228  double mdy_u = (d.N_u > 0) ? d.Sdy_u / d.N_u : 0.;
229 
230  double mdx_v = (d.N_v > 0) ? d.Sdx_v / d.N_v : 0.;
231  double mdy_v = (d.N_v > 0) ? d.Sdy_v / d.N_v : 0.;
232 
233 
234  printf(" %3i | %8.3f | %8.3f | %9.4f | %8.3f | %8.3f | %8.3f | %8.3f |\n", it->first, mx, my, mz, mdx_u, mdy_u, mdx_v, mdy_v);
235  }
236  }
237 }
238 
240 
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
edm::ESWatcher< IdealGeometryRecord > watcherIdealGeometry
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
RPDeviceMapType::const_iterator endRP() const
end iterator over RPs
uint32_t getRPDecimalId() const
Definition: TotemRPDetId.h:93
bool isStripsCoordinateUDirection() const
Definition: TotemRPDetId.h:80
void GetReadoutDirection(unsigned int id, double &dx, double &dy) const
Event setup record containing the real (actual) geometry information.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
mapType::const_iterator endDet() const
end iterator over (silicon) detectors
tuple d
Definition: ztail.py:151
RPDeviceMapType::const_iterator beginRP() const
begin iterator over RPs
GeometryInfoModule(const edm::ParameterSet &)
Class to print out information on current geometry.
edm::ESWatcher< VeryForwardRealGeometryRecord > watcherRealGeometry
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void Fill(double x, double y, double z, bool uDir, double dx, double dy)
const T & get() const
Definition: EventSetup.h:56
The manager class for TOTEM RP geometry.
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
ESHandle< TrackerGeometry > geometry
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void PrintGeometry(const TotemRPGeometry &, const edm::Event &)
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
mapType::const_iterator beginDet() const
begin iterator over (silicon) detectors
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::ESWatcher< VeryForwardMisalignedGeometryRecord > watcherMisalignedGeometry
Definition: Run.h:43