CMS 3D CMS Logo

TotemRPGeometryESModule.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * Authors:
4 * Jan Kaspar (jan.kaspar@gmail.com)
5 * Dominik Mierzejewski <dmierzej@cern.ch>
6 *
7 ****************************************************************************/
8 
16 
27 
36 
38 
39 #include <TMatrixD.h>
40 
53 {
54  public:
56  virtual ~TotemRPGeometryESModule();
57 
58  std::unique_ptr<DetGeomDesc> produceIdealGD(const IdealGeometryRecord &);
59 
60  std::unique_ptr<DetGeomDesc> produceRealGD(const VeryForwardRealGeometryRecord &);
61  std::unique_ptr<TotemRPGeometry> produceRealTG(const VeryForwardRealGeometryRecord &);
62 
63  std::unique_ptr<DetGeomDesc> produceMisalignedGD(const VeryForwardMisalignedGeometryRecord &);
64  std::unique_ptr<TotemRPGeometry> produceMisalignedTG(const VeryForwardMisalignedGeometryRecord &);
65 
66  protected:
67  unsigned int verbosity;
68 
70  DetGeomDesc* &newGD);
71 };
72 
73 
74 using namespace std;
75 using namespace edm;
76 
77 //----------------------------------------------------------------------------------------------------
78 //----------------------------------------------------------------------------------------------------
79 
81 {
82  verbosity = p.getUntrackedParameter<unsigned int>("verbosity", 1);
83 
85 
88 
91 }
92 
93 //----------------------------------------------------------------------------------------------------
94 
96 {
97 }
98 
99 //----------------------------------------------------------------------------------------------------
100 
102  const ESHandle<RPAlignmentCorrectionsData> &alignments, DetGeomDesc* &newGD)
103 {
104  newGD = new DetGeomDesc( *(idealGD.product()) );
105  deque<const DetGeomDesc *> buffer;
106  deque<DetGeomDesc *> bufferNew;
107  buffer.push_back(idealGD.product());
108  bufferNew.push_back(newGD);
109 
110  while (buffer.size() > 0)
111  {
112  const DetGeomDesc *sD = buffer.front();
113  DetGeomDesc *pD = bufferNew.front();
114  buffer.pop_front();
115  bufferNew.pop_front();
116 
117  // Is it sensor? If yes, apply full sensor alignments
118  if ( pD->name().name().compare( DDD_TOTEM_RP_DETECTOR_NAME) == 0
119  or pD->name().name().compare( DDD_CTPPS_DIAMONDS_DETECTOR_NAME ) == 0 )
120  {
121  unsigned int plId = pD->geographicalID();
122 
123  if (alignments.isValid())
124  {
125  const RPAlignmentCorrectionData& ac = alignments->GetFullSensorCorrection(plId);
126  pD->ApplyAlignment(ac);
127  }
128  }
129 
130  // Is it RP box? If yes, apply RP alignments
131  if (! pD->name().name().compare(DDD_TOTEM_RP_PRIMARY_VACUUM_NAME))
132  {
133  unsigned int rpId = pD->geographicalID();
134 
135  if (alignments.isValid())
136  {
137  const RPAlignmentCorrectionData& ac = alignments->GetRPCorrection(rpId);
138  pD->ApplyAlignment(ac);
139  }
140  }
141 
142  // create and add children
143  for (unsigned int i = 0; i < sD->components().size(); i++)
144  {
145  const DetGeomDesc *sDC = sD->components()[i];
146  buffer.push_back(sDC);
147 
148  // create new node with the same information as in sDC and add it as a child of pD
149  DetGeomDesc * cD = new DetGeomDesc(*sDC);
150  pD->addComponent(cD);
151 
152  bufferNew.push_back(cD);
153  }
154  }
155 }
156 
157 //----------------------------------------------------------------------------------------------------
158 
159 std::unique_ptr<DetGeomDesc> TotemRPGeometryESModule::produceIdealGD(const IdealGeometryRecord &iRecord)
160 {
161  // get the DDCompactView from EventSetup
163  iRecord.get("XMLIdealGeometryESSource_CTPPS", cpv);
164 
165  // construct the tree of DetGeomDesc
166  DDDTotemRPContruction worker;
167  return std::unique_ptr<DetGeomDesc>( const_cast<DetGeomDesc*>( worker.construct(&(*cpv)) ) );
168 }
169 
170 //----------------------------------------------------------------------------------------------------
171 
172 std::unique_ptr<DetGeomDesc> TotemRPGeometryESModule::produceRealGD(const VeryForwardRealGeometryRecord &iRecord)
173 {
174  // get the input GeometricalDet
176  iRecord.getRecord<IdealGeometryRecord>().get(idealGD);
177 
178  // load alignments
180  try { iRecord.getRecord<RPRealAlignmentRecord>().get(alignments); }
181  catch (...) {}
182 
183  if (alignments.isValid())
184  {
185  if (verbosity)
186  LogVerbatim("TotemRPGeometryESModule::produceRealGD")
187  << ">> TotemRPGeometryESModule::produceRealGD > Real geometry: "
188  << alignments->GetRPMap().size() << " RP and "
189  << alignments->GetSensorMap().size() << " sensor alignments applied.";
190  } else {
191  if (verbosity)
192  LogVerbatim("TotemRPGeometryESModule::produceRealGD")
193  << ">> TotemRPGeometryESModule::produceRealGD > Real geometry: No alignments applied.";
194  }
195 
196  DetGeomDesc* newGD = NULL;
197  ApplyAlignments(idealGD, alignments, newGD);
198  return std::unique_ptr<DetGeomDesc>(newGD);
199 }
200 
201 //----------------------------------------------------------------------------------------------------
202 
204 {
205  // get the input GeometricalDet
207  iRecord.getRecord<IdealGeometryRecord>().get(idealGD);
208 
209  // load alignments
211  try { iRecord.getRecord<RPMisalignedAlignmentRecord>().get(alignments); }
212  catch (...) {}
213 
214  if (alignments.isValid())
215  {
216  if (verbosity)
217  LogVerbatim("TotemRPGeometryESModule::produceMisalignedGD")
218  << ">> TotemRPGeometryESModule::produceMisalignedGD > Misaligned geometry: "
219  << alignments->GetRPMap().size() << " RP and "
220  << alignments->GetSensorMap().size() << " sensor alignments applied.";
221  } else {
222  if (verbosity)
223  LogVerbatim("TotemRPGeometryESModule::produceMisalignedGD")
224  << ">> TotemRPGeometryESModule::produceMisalignedGD > Misaligned geometry: No alignments applied.";
225  }
226 
227  DetGeomDesc* newGD = NULL;
228  ApplyAlignments(idealGD, alignments, newGD);
229  return std::unique_ptr<DetGeomDesc>(newGD);
230 }
231 
232 //----------------------------------------------------------------------------------------------------
233 
234 std::unique_ptr<TotemRPGeometry> TotemRPGeometryESModule::produceRealTG(const VeryForwardRealGeometryRecord &iRecord)
235 {
237  iRecord.get(gD);
238 
239  return std::make_unique<TotemRPGeometry>( gD.product());
240 }
241 
242 //----------------------------------------------------------------------------------------------------
243 
245 {
247  iRecord.get(gD);
248 
249  return std::make_unique<TotemRPGeometry>( gD.product());
250 }
251 
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< TotemRPGeometry > produceMisalignedTG(const VeryForwardMisalignedGeometryRecord &)
Builds structure of DetGeomDesc objects out of DDCompactView (resp. DDFilteredView).
const mapType & GetSensorMap() const
returns the map of sensor alignment corrections
const mapType & GetRPMap() const
returns the map of RP alignment corrections
const char DDD_TOTEM_RP_PRIMARY_VACUUM_NAME[]
DDD name of RP.
#define NULL
Definition: scimark2.h:8
Event setup record containing the real (actual) geometry information.
const DetGeomDesc * construct(const DDCompactView *cpv)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void ApplyAlignment(const RPAlignmentCorrectionData &)
alignment
Definition: DetGeomDesc.cc:184
virtual ConstContainer components() const
access to the tree structure
Definition: DetGeomDesc.cc:121
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Builds ideal, real and misaligned geometries.
void get(HolderT &iHolder) const
Geometrical description of a detector.
Definition: DetGeomDesc.h:40
std::unique_ptr< DetGeomDesc > produceRealGD(const VeryForwardRealGeometryRecord &)
Alignment correction or result of alignment procedure for a single RP sensor. Within the geometry des...
RPAlignmentCorrectionData GetFullSensorCorrection(unsigned int id, bool useRPErrors=false) const
DDName name() const
Definition: DetGeomDesc.h:90
const char DDD_CTPPS_DIAMONDS_DETECTOR_NAME[]
TotemRPGeometryESModule(const edm::ParameterSet &p)
virtual DetId geographicalID() const
Definition: DetGeomDesc.h:64
std::unique_ptr< DetGeomDesc > produceMisalignedGD(const VeryForwardMisalignedGeometryRecord &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
std::unique_ptr< TotemRPGeometry > produceRealTG(const VeryForwardRealGeometryRecord &)
RPAlignmentCorrectionData & GetRPCorrection(unsigned int id)
returns the correction value from the RP map
void ApplyAlignments(const edm::ESHandle< DetGeomDesc > &idealGD, const edm::ESHandle< RPAlignmentCorrectionsData > &alignments, DetGeomDesc *&newGD)
HLT enums.
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
std::unique_ptr< DetGeomDesc > produceIdealGD(const IdealGeometryRecord &)
const char DDD_TOTEM_RP_DETECTOR_NAME[]
DDD name of RP detector.
bool isValid() const
Definition: ESHandle.h:47
T const * product() const
Definition: ESHandle.h:86
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:159
const std::string & name() const
Returns the name.
Definition: DDName.cc:90