CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::auto_ptr<DetGeomDesc> produceIdealGD(const IdealGeometryRecord &);
59 
60  std::auto_ptr<DetGeomDesc> produceRealGD(const VeryForwardRealGeometryRecord &);
61  std::auto_ptr<TotemRPGeometry> produceRealTG(const VeryForwardRealGeometryRecord &);
62 
63  std::auto_ptr<DetGeomDesc> produceMisalignedGD(const VeryForwardMisalignedGeometryRecord &);
64  std::auto_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 
84  setWhatProduced(this, &TotemRPGeometryESModule::produceIdealGD);
85 
86  setWhatProduced(this, &TotemRPGeometryESModule::produceRealGD);
87  setWhatProduced(this, &TotemRPGeometryESModule::produceRealTG);
88 
89  setWhatProduced(this, &TotemRPGeometryESModule::produceMisalignedGD);
90  setWhatProduced(this, &TotemRPGeometryESModule::produceMisalignedTG);
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::auto_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 auto_ptr<DetGeomDesc>( const_cast<DetGeomDesc*>( worker.construct(&(*cpv)) ) );
168 }
169 
170 //----------------------------------------------------------------------------------------------------
171 
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::auto_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::auto_ptr<DetGeomDesc>(newGD);
230 }
231 
232 //----------------------------------------------------------------------------------------------------
233 
234 std::auto_ptr<TotemRPGeometry> TotemRPGeometryESModule::produceRealTG(const VeryForwardRealGeometryRecord &iRecord)
235 {
237  iRecord.get(gD);
238 
239  std::auto_ptr<TotemRPGeometry> rpG( new TotemRPGeometry(gD.product()) );
240  return rpG;
241 }
242 
243 //----------------------------------------------------------------------------------------------------
244 
246 {
248  iRecord.get(gD);
249 
250  std::auto_ptr<TotemRPGeometry> rpG( new TotemRPGeometry(gD.product()) );
251  return rpG;
252 }
253 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< DetGeomDesc > produceIdealGD(const IdealGeometryRecord &)
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Builds structure of DetGeomDesc objects out of DDCompactView (resp. DDFilteredView).
std::auto_ptr< TotemRPGeometry > produceRealTG(const VeryForwardRealGeometryRecord &)
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 ApplyAlignment(const RPAlignmentCorrectionData &)
alignment
Definition: DetGeomDesc.cc:184
virtual ConstContainer components() const
access to the tree structure
Definition: DetGeomDesc.cc:121
Builds ideal, real and misaligned geometries.
void get(HolderT &iHolder) const
Geometrical description of a detector.
Definition: DetGeomDesc.h:40
Alignment correction or result of alignment procedure for a single RP sensor. Within the geometry des...
DDName name() const
Definition: DetGeomDesc.h:90
std::auto_ptr< DetGeomDesc > produceRealGD(const VeryForwardRealGeometryRecord &)
const char DDD_CTPPS_DIAMONDS_DETECTOR_NAME[]
TotemRPGeometryESModule(const edm::ParameterSet &p)
virtual DetId geographicalID() const
Definition: DetGeomDesc.h:64
T const * product() const
Definition: ESHandle.h:86
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
The manager class for TOTEM RP geometry.
void ApplyAlignments(const edm::ESHandle< DetGeomDesc > &idealGD, const edm::ESHandle< RPAlignmentCorrectionsData > &alignments, DetGeomDesc *&newGD)
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
const char DDD_TOTEM_RP_DETECTOR_NAME[]
DDD name of RP detector.
bool isValid() const
Definition: ESHandle.h:47
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:159
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
std::auto_ptr< TotemRPGeometry > produceMisalignedTG(const VeryForwardMisalignedGeometryRecord &)
std::auto_ptr< DetGeomDesc > produceMisalignedGD(const VeryForwardMisalignedGeometryRecord &)