test
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 
22 
23 //----------------------------------------------------------------------------------------------------
24 
32 {
33  public:
34  explicit GeometryInfoModule(const edm::ParameterSet&);
36 
37  struct MeanRPData
38  {
39  unsigned int N, N_u, N_v;
40  double Sx, Sy, Sz, Sdx_u, Sdx_v, Sdy_u, Sdy_v;
41 
42  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.) {}
43 
44  void Fill(double x, double y, double z, bool uDir, double dx, double dy)
45  {
46  N++;
47  Sx += x;
48  Sy += y;
49  Sz += z;
50 
51  if (uDir)
52  {
53  N_u++;
54  Sdx_u += dx;
55  Sdy_u += dy;
56  } else {
57  N_v++;
58  Sdx_v += dx;
59  Sdy_v += dy;
60  }
61  }
62  };
63 
64  private:
66 
68 
73 
74  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
75  virtual void analyze(const edm::Event&, const edm::EventSetup&);
76  virtual void endJob();
77 
78  void PrintGeometry(const TotemRPGeometry &, const edm::Event&);
79 };
80 
81 using namespace edm;
82 using namespace std;
83 
84 
85 //----------------------------------------------------------------------------------------------------
86 
88  geometryType(ps.getUntrackedParameter<string>("geometryType", "real")),
89  printRPInfo(ps.getUntrackedParameter<bool>("printRPInfo", true)),
90  printSensorInfo(ps.getUntrackedParameter<bool>("printSensorInfo", true)),
91  printMeanSensorInfo(ps.getUntrackedParameter<bool>("printMeanSensorInfo", true))
92 {
93 }
94 
95 //----------------------------------------------------------------------------------------------------
96 
98 {
99 }
100 
101 //----------------------------------------------------------------------------------------------------
102 
104 {
105 }
106 
107 //----------------------------------------------------------------------------------------------------
108 
110 {
111 }
112 
113 //----------------------------------------------------------------------------------------------------
114 
116 {
118 
119  if (!geometryType.compare("ideal"))
120  {
121  if (watcherIdealGeometry.check(es))
122  {
123  es.get<IdealGeometryRecord>().get(geometry);
124  PrintGeometry(*geometry, event);
125  }
126  return;
127  }
128 
129  if (!geometryType.compare("measured"))
130  {
132  {
133  es.get<VeryForwardMeasuredGeometryRecord>().get(geometry);
134  PrintGeometry(*geometry, event);
135  }
136  return;
137  }
138 
139  if (!geometryType.compare("real"))
140  {
141  if (watcherRealGeometry.check(es))
142  {
143  es.get<VeryForwardRealGeometryRecord>().get(geometry);
144  PrintGeometry(*geometry, event);
145  }
146  return;
147  }
148 
149  if (!geometryType.compare("misaligned"))
150  {
152  {
153  es.get<VeryForwardMisalignedGeometryRecord>().get(geometry);
154  PrintGeometry(*geometry, event);
155  }
156  return;
157  }
158 
159  throw cms::Exception("GeometryInfoModule") << "Unknown geometry type: `" << geometryType << "'.";
160 }
161 
162 //----------------------------------------------------------------------------------------------------
163 
165 {
166  time_t unixTime = event.time().unixTime();
167  char timeStr[50];
168  strftime(timeStr, 50, "%F %T", localtime(&unixTime));
169  printf(">> GeometryInfoModule::PrintGeometry\n\tnew %s geometry found in run=%u, event=%llu, UNIX timestamp=%lu (%s)\n",
170  geometryType.c_str(), event.id().run(), event.id().event(), unixTime, timeStr);
171 
172  // RP geometry
173  if (printRPInfo)
174  {
175  printf("\n* RPs:\n");
176  printf(" ID | x (mm) | y (mm) | z (m) |\n");
177  for (TotemRPGeometry::RPDeviceMapType::const_iterator it = geometry.beginRP(); it != geometry.endRP(); ++it)
178  {
179  const DDTranslation &t = it->second->translation();
180  printf(" %3i | %+11.3f | %+11.3f | %+9.4f |\n", it->first, t.x(), t.y(), t.z() * 1E-3);
181  }
182  }
183 
184  // sensor geometry
185  if (printSensorInfo)
186  {
187  printf("\n* silicon sensors:\n");
188  printf("DetId | detector center | readout direction |\n");
189  printf(" | x (mm) | y (mm) | z (m) | dx | dy |\n");
190  for (TotemRPGeometry::mapType::const_iterator it = geometry.beginDet(); it != geometry.endDet(); ++it)
191  {
192  TotemRPDetId id(it->first);
193 
194  double x = it->second->translation().x();
195  double y = it->second->translation().y();
196  double z = it->second->translation().z() * 1E-3;
197 
198  double dx = 0., dy = 0.;
199  geometry.GetReadoutDirection(it->first, dx, dy);
200 
201  printf("%4i | %8.3f | %8.3f | %9.4f | %8.3f | %8.3f |\n", id.getPlaneDecimalId(), x, y, z, dx, dy);
202  }
203  }
204 
205  // sensor geometry averaged over 1 RP
207  {
208  printf("\n* average over silicon sensors of 1 RP:\n");
209 
210  map<unsigned int, MeanRPData> data; // map: RP Id --> sums of geometrical info
211 
212  for (TotemRPGeometry::mapType::const_iterator it = geometry.beginDet(); it != geometry.endDet(); ++it)
213  {
214  TotemRPDetId plId(it->first);
215  unsigned int rpDecId = plId.getRPDecimalId();
216  bool uDirection = plId.isStripsCoordinateUDirection();
217 
218  double x = it->second->translation().x();
219  double y = it->second->translation().y();
220  double z = it->second->translation().z() * 1E-3;
221 
222  double dx = 0., dy = 0.;
223  geometry.GetReadoutDirection(it->first, dx, dy);
224 
225  data[rpDecId].Fill(x, y, z, uDirection, dx, dy);
226  }
227 
228  printf("RPId | center | U direction | V direction |\n");
229  printf(" | x (mm) | y (mm) | z (m) | dx | dy | dx | dy |\n");
230 
231  for (map<unsigned int, MeanRPData>::iterator it = data.begin(); it != data.end(); ++it)
232  {
233  const MeanRPData &d = it->second;
234 
235  double mx = (d.N > 0) ? d.Sx / d.N : 0.;
236  double my = (d.N > 0) ? d.Sy / d.N : 0.;
237  double mz = (d.N > 0) ? d.Sz / d.N : 0.;
238 
239  double mdx_u = (d.N_u > 0) ? d.Sdx_u / d.N_u : 0.;
240  double mdy_u = (d.N_u > 0) ? d.Sdy_u / d.N_u : 0.;
241 
242  double mdx_v = (d.N_v > 0) ? d.Sdx_v / d.N_v : 0.;
243  double mdy_v = (d.N_v > 0) ? d.Sdy_v / d.N_v : 0.;
244 
245 
246  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);
247  }
248  }
249 }
250 
252 
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
edm::ESWatcher< VeryForwardMeasuredGeometryRecord > watcherMeasuredGeometry
Event setup record containing the Measured (measured) geometry information.
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:42