CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Protected Member Functions
CTPPSRPAlignmentCorrectionsMethods Class Reference

#include <CTPPSRPAlignmentCorrectionsMethods.h>

Public Member Functions

 CTPPSRPAlignmentCorrectionsMethods ()
 

Static Public Member Functions

static std::string iovValueToString (const edm::IOVSyncValue &)
 
static CTPPSRPAlignmentCorrectionsDataSequence loadFromXML (const std::string &fileName)
 loads sequence of alignment corrections from XML file More...
 
static edm::IOVSyncValue stringToIOVValue (const std::string &)
 
static void writeToXML (const CTPPSRPAlignmentCorrectionsDataSequence &seq, const std::string &fileName, bool precise=false, bool wrErrors=true, bool wrSh_xy=true, bool wrSh_z=false, bool wrRot_xy=false, bool wrRot_z=true)
 writes sequence of alignment corrections into a single XML file More...
 
static void writeToXML (const CTPPSRPAlignmentCorrectionsData &ad, const std::string &fileName, bool precise=false, bool wrErrors=true, bool wrSh_xy=true, bool wrSh_z=false, bool wrRot_xy=false, bool wrRot_z=true)
 writes alignment corrections into a single XML file, assigning infinite interval of validity More...
 

Static Protected Member Functions

static CTPPSRPAlignmentCorrectionsData getCorrectionsData (xercesc::DOMNode *)
 load corrections data corresponding to one IOV More...
 
static void writeXML (const CTPPSRPAlignmentCorrectionData &data, FILE *f, bool precise, bool wrErrors, bool wrSh_xy, bool wrSh_z, bool wrRot_xy, bool wrRot_z)
 writes data of a correction in XML format More...
 
static void writeXMLBlock (const CTPPSRPAlignmentCorrectionsData &, FILE *, bool precise=false, bool wrErrors=true, bool wrSh_xy=true, bool wrSh_z=false, bool wrRot_xy=false, bool wrRot_z=true)
 writes a block of corrections into a file More...
 

Detailed Description

Definition at line 22 of file CTPPSRPAlignmentCorrectionsMethods.h.

Constructor & Destructor Documentation

CTPPSRPAlignmentCorrectionsMethods::CTPPSRPAlignmentCorrectionsMethods ( )
inline

Member Function Documentation

CTPPSRPAlignmentCorrectionsData CTPPSRPAlignmentCorrectionsMethods::getCorrectionsData ( xercesc::DOMNode *  )
staticprotected

load corrections data corresponding to one IOV

Definition at line 209 of file CTPPSRPAlignmentCorrectionsMethods.cc.

References a, CTPPSRPAlignmentCorrectionsData::addRPCorrection(), CTPPSRPAlignmentCorrectionsData::addSensorCorrection(), class-composition::children, MillePedeFileConverter_cfg::e, Exception, mps_fire::i, mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toDouble(), cms::xerces::toString(), and cms::xerces::toUInt().

Referenced by loadFromXML(), and writeToXML().

210 {
212 
213  DOMNodeList *children = root->getChildNodes();
214  for ( unsigned int i = 0; i < children->getLength(); i++ )
215  {
216  DOMNode *node = children->item( i );
217  if ( node->getNodeType() != DOMNode::ELEMENT_NODE )
218  continue;
219 
220  const std::string node_name = cms::xerces::toString( node->getNodeName() );
221 
222  // check node type
223  unsigned char nodeType = 0;
224  if ( node_name == "det" ) nodeType = 1;
225  else if ( node_name == "rp" ) nodeType = 2;
226 
227  if ( nodeType == 0 )
228  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "Unknown node `" << cms::xerces::toString( node->getNodeName() ) << "'.";
229 
230  // check children
231  if ( node->getChildNodes()->getLength() > 0 )
232  {
233  edm::LogProblem("CTPPSRPAlignmentCorrectionsMethods") << "LoadXMLFile > Warning: tag `" <<
234  cms::xerces::toString( node->getNodeName() ) << "' has " << node->getChildNodes()->getLength() << " children nodes - they will be all ignored.";
235  }
236 
237  // default values
238  double sh_x = 0., sh_y = 0., sh_z = 0., rot_x = 0., rot_y = 0., rot_z = 0.;
239  double sh_x_e = 0., sh_y_e = 0., sh_z_e = 0., rot_x_e = 0., rot_y_e = 0., rot_z_e = 0.;
240  unsigned int id = 0;
241  bool idSet = false;
242 
243  // get attributes
244  DOMNamedNodeMap* attr = node->getAttributes();
245  for ( unsigned int j = 0; j < attr->getLength(); j++ )
246  {
247  DOMNode *a = attr->item( j );
248  const std::string node_name = cms::xerces::toString( a->getNodeName() );
249 
250  if ( node_name == "id" )
251  {
252  id = cms::xerces::toUInt( a->getNodeValue() );
253  idSet = true;
254  }
255  else if ( node_name == "sh_x" ) sh_x = cms::xerces::toDouble( a->getNodeValue() );
256  else if ( node_name == "sh_x_e" ) sh_x_e = cms::xerces::toDouble( a->getNodeValue() );
257  else if ( node_name == "sh_y" ) sh_y = cms::xerces::toDouble( a->getNodeValue() );
258  else if ( node_name == "sh_y_e" ) sh_y_e = cms::xerces::toDouble( a->getNodeValue() );
259  else if ( node_name == "sh_z" ) sh_z = cms::xerces::toDouble( a->getNodeValue() );
260  else if ( node_name == "sh_z_e" ) sh_z_e = cms::xerces::toDouble( a->getNodeValue() );
261  else if ( node_name == "rot_x" ) rot_x = cms::xerces::toDouble( a->getNodeValue() );
262  else if ( node_name == "rot_x_e" ) rot_x_e = cms::xerces::toDouble( a->getNodeValue() );
263  else if ( node_name == "rot_y" ) rot_y = cms::xerces::toDouble( a->getNodeValue() );
264  else if ( node_name == "rot_y_e" ) rot_y_e = cms::xerces::toDouble( a->getNodeValue() );
265  else if ( node_name == "rot_z" ) rot_z = cms::xerces::toDouble( a->getNodeValue() );
266  else if ( node_name == "rot_z_e" ) rot_z_e = cms::xerces::toDouble( a->getNodeValue() );
267  else
268  edm::LogProblem("CTPPSRPAlignmentCorrectionsMethods") << ">> CTPPSRPAlignmentCorrectionsMethods::getCorrectionsData > Warning: unknown attribute `"
269  << cms::xerces::toString( a->getNodeName() ) << "'.";
270  }
271 
272  // id must be set
273  if ( !idSet )
274  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "Id not set for tag `" << cms::xerces::toString( node->getNodeName() ) << "'.";
275 
276  // build alignment
277  const CTPPSRPAlignmentCorrectionData align_corr(
278  sh_x*1e-3, sh_x_e*1e-3,
279  sh_y*1e-3, sh_y_e*1e-3,
280  sh_z*1e-3, sh_z_e*1e-3,
281  rot_x*1e-3, rot_x_e*1e-3,
282  rot_y*1e-3, rot_y_e*1e-3,
283  rot_z*1e-3, rot_z_e*1e-3
284  );
285 
286  // add the alignment to the right list
287  if ( nodeType == 1 ) result.addSensorCorrection( id, align_corr, true );
288  if ( nodeType == 2 ) result.addRPCorrection( id, align_corr, true );
289  }
290 
291  return result;
292 }
void addSensorCorrection(unsigned int, const CTPPSRPAlignmentCorrectionData &, bool sumErrors=true, bool addSh=true, bool addRot=true)
adds (merges) a RP correction on top of the current value
double toDouble(XMLCh const *toTranscode)
std::string toString(XMLCh const *toTranscode)
unsigned int toUInt(XMLCh const *toTranscode)
void addRPCorrection(unsigned int, const CTPPSRPAlignmentCorrectionData &, bool sumErrors=true, bool addSh=true, bool addRot=true)
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
double a
Definition: hdecay.h:121
Alignment correction for an element of the CT-PPS detector. Within the geometry description, every sensor (more generally every element) is given its translation and rotation. These two quantities shall be understood in local-to-global coordinate transform. That is, if r_l is a point in local coordinate system and x_g in global, then it holds.
std::string CTPPSRPAlignmentCorrectionsMethods::iovValueToString ( const edm::IOVSyncValue val)
static

Definition at line 92 of file CTPPSRPAlignmentCorrectionsMethods.cc.

References edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime(), edm::IOVSyncValue::eventID(), edm::EventID::luminosityBlock(), and edm::EventID::run().

Referenced by CTPPSRPAlignmentCorrectionsDataESSourceXML::Merge(), CTPPSRPAlignmentCorrectionsDataESSourceXML::setIntervalFor(), and writeToXML().

93 {
94  if (val == edm::IOVSyncValue::beginOfTime())
95  return "-inf";
96 
97  if (val == edm::IOVSyncValue::endOfTime())
98  return "+inf";
99 
100  char buf[50];
101  sprintf(buf, "%u:%u", val.eventID().run(), val.eventID().luminosityBlock());
102  return buf;
103 }
RunNumber_t run() const
Definition: EventID.h:39
const EventID & eventID() const
Definition: IOVSyncValue.h:40
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
CTPPSRPAlignmentCorrectionsDataSequence CTPPSRPAlignmentCorrectionsMethods::loadFromXML ( const std::string &  fileName)
static

loads sequence of alignment corrections from XML file

Definition at line 108 of file CTPPSRPAlignmentCorrectionsMethods.cc.

References edm::IOVSyncValue::beginOfTime(), class-composition::children, edm::IOVSyncValue::endOfTime(), Exception, plotBeamSpotDB::first, getCorrectionsData(), mps_fire::i, CTPPSRPAlignmentCorrectionsDataSequence::insert(), plotBeamSpotDB::last, convertSQLitetoXML_cfg::output, writedatasetfile::parser, AlCaHLTBitMon_QueryRunRegistry::string, stringToIOVValue(), and cms::xerces::toString().

Referenced by CTPPSRPAlignmentCorrectionsMethods(), and CTPPSRPAlignmentCorrectionsDataESSourceXML::PrepareSequence().

109 {
110  // prepare output
112 
113  // load DOM tree
114  try {
115  XMLPlatformUtils::Initialize();
116  } catch ( const XMLException& toCatch ) {
117  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "An XMLException caught with message: " << cms::xerces::toString( toCatch.getMessage() ) << ".";
118  }
119 
120  auto parser = std::make_unique<XercesDOMParser>();
121  parser->setValidationScheme( XercesDOMParser::Val_Always );
122  parser->setDoNamespaces( true );
123  parser->parse( fileName.c_str() );
124 
125  if ( !parser )
126  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "Cannot parse file `" << fileName << "' (parser = NULL).";
127 
128  DOMDocument* xmlDoc = parser->getDocument();
129 
130  if ( !xmlDoc )
131  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "Cannot parse file `" << fileName << "' (xmlDoc = NULL).";
132 
133  DOMElement* elementRoot = xmlDoc->getDocumentElement();
134  if ( !elementRoot )
135  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "File `" << fileName << "' is empty.";
136 
137  // extract useful information form the DOM tree
138  DOMNodeList* children = elementRoot->getChildNodes();
139  for ( unsigned int i = 0; i < children->getLength(); i++ )
140  {
141  DOMNode* node = children->item( i );
142  if ( node->getNodeType() != DOMNode::ELEMENT_NODE )
143  continue;
144 
145  const std::string node_name = cms::xerces::toString( node->getNodeName() );
146 
147  // check node type
148  unsigned char nodeType = 0;
149  if ( node_name == "iov" ) nodeType = 1;
150  else if ( node_name == "det" ) nodeType = 2;
151  else if ( node_name == "rp" ) nodeType = 3;
152 
153  if ( nodeType == 0 )
154  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "Unknown node `" << node_name << "'.";
155 
156  // for backward compatibility: support files with no iov block
157  if ( nodeType == 2 || nodeType == 3 )
158  {
160  output.insert(iov, getCorrectionsData(elementRoot));
161  break;
162  }
163 
164  // get attributes
166  bool first_set = false, last_set = false;
167  DOMNamedNodeMap* attrs = node->getAttributes();
168  for ( unsigned int j = 0; j < attrs->getLength(); j++ )
169  {
170  const DOMNode* attr = attrs->item( j );
171  const std::string attr_name = cms::xerces::toString( attr->getNodeName() );
172 
173  if ( attr_name == "first" )
174  {
175  first_set = true;
176  first = stringToIOVValue( cms::xerces::toString( attr->getNodeValue() ) );
177  }
178  else if ( attr_name == "last" ) {
179  last_set = true;
180  last = stringToIOVValue( cms::xerces::toString( attr->getNodeValue() ) );
181  }
182  else
183  edm::LogProblem("CTPPSRPAlignmentCorrectionsMethods") << ">> CTPPSRPAlignmentCorrectionsDataSequence::loadFromXML > Warning: unknown attribute `"
184  << attr_name << "'.";
185  }
186 
187  // interval of validity must be set
188  if ( !first_set || !last_set )
189  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "iov tag must have `first' and `last' attributes set.";
190 
191  // process data
193 
194  // save result
195  output.insert(edm::ValidityInterval(first, last), corrections);
196  }
197 
198  // clean up
199  parser.reset();
200  XMLPlatformUtils::Terminate();
201 
202  return output;
203 }
static edm::IOVSyncValue stringToIOVValue(const std::string &)
Time sequence of alignment corrections. I/O methods have been factored out to: CondFormats/CTPPSReado...
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::string toString(XMLCh const *toTranscode)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void insert(const edm::ValidityInterval &iov, const CTPPSRPAlignmentCorrectionsData &data)
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
static CTPPSRPAlignmentCorrectionsData getCorrectionsData(xercesc::DOMNode *)
load corrections data corresponding to one IOV
edm::IOVSyncValue CTPPSRPAlignmentCorrectionsMethods::stringToIOVValue ( const std::string &  str)
static

STRUCTURE OF CTPPS ALINGMENT XML FILE The file has the following structure <xml> <iov first="run:ls" last="run:ls"> <tag> <tag> ... </iov> <iov first="run:ls" last="run:ls"> ... </iov></xml> The time intervals are specified by the `first' and `last' run-lumisection pairs. If the <iov> tag is not present, an infinite validty is assumed for all the tags. The tag can be either "det" - the alignment correction is applied to one detector or "rp" - the alignment correction id applied to one RP Each tag must have an "id" attribute set. In addition the following attributes are recognized: sh_x - shift in x sh_x_e - the uncertainty of sh_x determination sh_y - shift in y sh_y_e - the uncertainty of sh_y determination sh_z - shift in z sh_z_e - the uncertainty of sh_z determination rot_x - rotation around x rot_x_e - the uncertainty of rot_x determination rot_y - rotation around y rot_y_e - the uncertainty of rot_y determination rot_z - rotation around z rot_z_e - the uncertainty of rot_z determination UNITS: shifts are in um, rotations are in mrad.

Definition at line 75 of file CTPPSRPAlignmentCorrectionsMethods.cc.

References edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by loadFromXML(), and writeToXML().

76 {
77  if (str == "-inf")
79 
80  if (str == "+inf")
82 
83  size_t sep_pos = str.find(":");
84  const std::string &runStr = str.substr(0, sep_pos);
85  const std::string &lsStr = str.substr(sep_pos+1);
86 
87  return edm::IOVSyncValue(edm::EventID(atoi(runStr.c_str()), atoi(lsStr.c_str()), 1));
88 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
#define str(s)
void CTPPSRPAlignmentCorrectionsMethods::writeToXML ( const CTPPSRPAlignmentCorrectionsDataSequence seq,
const std::string &  fileName,
bool  precise = false,
bool  wrErrors = true,
bool  wrSh_xy = true,
bool  wrSh_z = false,
bool  wrRot_xy = false,
bool  wrRot_z = true 
)
static

writes sequence of alignment corrections into a single XML file

Definition at line 299 of file CTPPSRPAlignmentCorrectionsMethods.cc.

References Exception, iovValueToString(), AlCaHLTBitMon_ParallelJobs::p, and writeXMLBlock().

Referenced by CTPPSRPAlignmentCorrectionsMethods(), and writeToXML().

301 {
302  FILE* rf = fopen( fileName.c_str(), "w" );
303  if ( !rf )
304  throw cms::Exception("CTPPSRPAlignmentCorrectionsMethods") << "Cannot open file `" << fileName << "' to save alignments.";
305 
306  fprintf( rf, "<!-- Shifts in um, rotations in mrad. -->\n" );
307  fprintf( rf, "<xml DocumentType=\"AlignmentDescription\">\n" );
308 
309  // write all IOVs
310  for ( const auto &p : data )
311  {
312  fprintf( rf, "\t<iov first=\"%s\" last=\"%s\">\n",
313  iovValueToString(p.first.first()).c_str(),
314  iovValueToString(p.first.last()).c_str()
315  );
316 
317  writeXMLBlock( p.second, rf, precise, wrErrors, wrSh_xy, wrSh_z, wrRot_xy, wrRot_z );
318 
319  fprintf( rf, "\t</iov>\n" );
320  }
321 
322  fprintf( rf, "</xml>\n" );
323  fclose( rf );
324 }
static std::string iovValueToString(const edm::IOVSyncValue &)
static void writeXMLBlock(const CTPPSRPAlignmentCorrectionsData &, FILE *, bool precise=false, bool wrErrors=true, bool wrSh_xy=true, bool wrSh_z=false, bool wrRot_xy=false, bool wrRot_z=true)
writes a block of corrections into a file
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static void CTPPSRPAlignmentCorrectionsMethods::writeToXML ( const CTPPSRPAlignmentCorrectionsData ad,
const std::string &  fileName,
bool  precise = false,
bool  wrErrors = true,
bool  wrSh_xy = true,
bool  wrSh_z = false,
bool  wrRot_xy = false,
bool  wrRot_z = true 
)
inlinestatic

writes alignment corrections into a single XML file, assigning infinite interval of validity

Definition at line 36 of file CTPPSRPAlignmentCorrectionsMethods.h.

References edm::IOVSyncValue::beginOfTime(), data, edm::IOVSyncValue::endOfTime(), f, getCorrectionsData(), CTPPSRPAlignmentCorrectionsDataSequence::insert(), iovValueToString(), hiDetachedQuadStep_cff::precise, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, stringToIOVValue(), writeToXML(), writeXML(), and writeXMLBlock().

39  {
42  s.insert(iov, ad);
43  writeToXML(s, fileName, precise, wrErrors, wrSh_xy, wrSh_z, wrRot_xy, wrRot_z);
44  }
Time sequence of alignment corrections. I/O methods have been factored out to: CondFormats/CTPPSReado...
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void insert(const edm::ValidityInterval &iov, const CTPPSRPAlignmentCorrectionsData &data)
static void writeToXML(const CTPPSRPAlignmentCorrectionsDataSequence &seq, const std::string &fileName, bool precise=false, bool wrErrors=true, bool wrSh_xy=true, bool wrSh_z=false, bool wrRot_xy=false, bool wrRot_z=true)
writes sequence of alignment corrections into a single XML file
void CTPPSRPAlignmentCorrectionsMethods::writeXML ( const CTPPSRPAlignmentCorrectionData data,
FILE *  f,
bool  precise,
bool  wrErrors,
bool  wrSh_xy,
bool  wrSh_z,
bool  wrRot_xy,
bool  wrRot_z 
)
staticprotected

writes data of a correction in XML format

Definition at line 412 of file CTPPSRPAlignmentCorrectionsMethods.cc.

References CTPPSRPAlignmentCorrectionData::getRotX(), CTPPSRPAlignmentCorrectionData::getRotXUnc(), CTPPSRPAlignmentCorrectionData::getRotY(), CTPPSRPAlignmentCorrectionData::getRotYUnc(), CTPPSRPAlignmentCorrectionData::getRotZ(), CTPPSRPAlignmentCorrectionData::getRotZUnc(), CTPPSRPAlignmentCorrectionData::getShX(), CTPPSRPAlignmentCorrectionData::getShXUnc(), CTPPSRPAlignmentCorrectionData::getShY(), CTPPSRPAlignmentCorrectionData::getShYUnc(), CTPPSRPAlignmentCorrectionData::getShZ(), CTPPSRPAlignmentCorrectionData::getShZUnc(), and WRITE.

Referenced by writeToXML(), and writeXMLBlock().

414 {
415  if ( wrSh_xy )
416  {
417  WRITE( data.getShX(), "sh_x", 2, 0.1 );
418  WRITE( data.getShY(), "sh_y", 2, 0.1 );
419  if ( wrErrors )
420  {
421  WRITE( data.getShXUnc(), "sh_x_e", 2, 0.1 );
422  WRITE( data.getShYUnc(), "sh_y_e", 2, 0.1 );
423  }
424  }
425 
426  if ( wrSh_z )
427  {
428  WRITE( data.getShZ(), "sh_z", 2, 0.1 );
429  if ( wrErrors )
430  {
431  WRITE( data.getShZUnc(), "sh_z_e", 2, 0.1 );
432  }
433  }
434 
435  if ( wrRot_xy )
436  {
437  WRITE( data.getRotX(), "rot_x", 3, 0.01 );
438  WRITE( data.getRotY(), "rot_y", 3, 0.01 );
439  if ( wrErrors )
440  {
441  WRITE( data.getRotXUnc(), "rot_x_e", 3, 0.01 );
442  WRITE( data.getRotYUnc(), "rot_y_e", 3, 0.01 );
443  }
444  }
445 
446  if ( wrRot_z )
447  {
448  WRITE( data.getRotZ(), "rot_z", 3, 0.01 );
449  if ( wrErrors )
450  {
451  WRITE( data.getRotZUnc(), "rot_z_e", 3, 0.01 );
452  }
453  }
454 }
#define WRITE(q, tag, dig, lim)
void CTPPSRPAlignmentCorrectionsMethods::writeXMLBlock ( const CTPPSRPAlignmentCorrectionsData data,
FILE *  rf,
bool  precise = false,
bool  wrErrors = true,
bool  wrSh_xy = true,
bool  wrSh_z = false,
bool  wrRot_xy = false,
bool  wrRot_z = true 
)
staticprotected

writes a block of corrections into a file

Definition at line 327 of file CTPPSRPAlignmentCorrectionsMethods.cc.

References CTPPSDetId::arm(), protons_cff::decRPId, CTPPSDetId::getRPId(), CTPPSRPAlignmentCorrectionsData::getRPMap(), CTPPSRPAlignmentCorrectionsData::getSensorMap(), CTPPSPixelDetId::plane(), CTPPSDiamondDetId::plane(), TotemRPDetId::plane(), CTPPSDetId::rp(), year_2016_postTS2_cff::rpId, CTPPSDetId::sdTimingDiamond, CTPPSDetId::sdTrackingPixel, CTPPSDetId::sdTrackingStrip, CTPPSDetId::station(), DetId::subdetId(), and writeXML().

Referenced by writeToXML().

329 {
330  bool firstRP = true;
331  unsigned int prevRP = 0;
332  std::set<unsigned int> writtenRPs;
333 
334  const auto &sensors = data.getSensorMap();
335  const auto &rps = data.getRPMap();
336 
337  for (auto it = sensors.begin(); it != sensors.end(); ++it)
338  {
339  CTPPSDetId sensorId(it->first);
340  unsigned int rpId = sensorId.getRPId();
341  unsigned int decRPId = sensorId.arm()*100 + sensorId.station()*10 + sensorId.rp();
342 
343  // start a RP block
344  if (firstRP || prevRP != rpId)
345  {
346  if (!firstRP)
347  fprintf(rf, "\n");
348  firstRP = false;
349 
350  fprintf(rf, "\t<!-- RP %3u -->\n", decRPId);
351 
352  auto rit = rps.find(rpId);
353  if (rit != rps.end())
354  {
355  fprintf(rf, "\t<rp id=\"%u\" ", rit->first);
356  writeXML( rit->second , rf, precise, wrErrors, wrSh_xy, wrSh_z, wrRot_xy, wrRot_z );
357  fprintf(rf, "/>\n");
358  writtenRPs.insert(rpId);
359  }
360  }
361  prevRP = rpId;
362 
363  // write plane id
364  unsigned int planeIdx = 1000;
365  if (sensorId.subdetId() == CTPPSDetId::sdTrackingStrip) planeIdx = TotemRPDetId(it->first).plane();
366  if (sensorId.subdetId() == CTPPSDetId::sdTrackingPixel) planeIdx = CTPPSPixelDetId(it->first).plane();
367  if (sensorId.subdetId() == CTPPSDetId::sdTimingDiamond) planeIdx = CTPPSDiamondDetId(it->first).plane();
368  fprintf(rf, "\t<!-- plane %u --> ", planeIdx);
369 
370  // write the correction
371  fprintf(rf, "<det id=\"%u\"", it->first);
372  writeXML(it->second, rf, precise, wrErrors, wrSh_xy, wrSh_z, wrRot_xy, wrRot_z);
373  fprintf(rf, "/>\n");
374  }
375 
376  // write remaining RPs
377  for (auto it = rps.begin(); it != rps.end(); ++it)
378  {
379  std::set<unsigned int>::iterator wit = writtenRPs.find(it->first);
380  if (wit == writtenRPs.end())
381  {
382  CTPPSDetId rpId(it->first);
383  unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp();
384 
385  if (!firstRP)
386  fprintf(rf, "\n");
387  firstRP = false;
388 
389  fprintf(rf, "\t<!-- RP %3u -->\n", decRPId);
390 
391  fprintf(rf, "\t<rp id=\"%u\" ", it->first);
392  writeXML(it->second, rf, precise, wrErrors, wrSh_xy, wrSh_z, wrRot_xy, wrRot_z);
393  fprintf(rf, "/>\n");
394  }
395  }
396  }
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
uint32_t plane() const
uint32_t plane() const
Definition: TotemRPDetId.h:46
const mapType & getRPMap() const
returns the map of RP alignment corrections
uint32_t plane() const
const mapType & getSensorMap() const
returns the map of sensor alignment corrections
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
static void writeXML(const CTPPSRPAlignmentCorrectionData &data, FILE *f, bool precise, bool wrErrors, bool wrSh_xy, bool wrSh_z, bool wrRot_xy, bool wrRot_z)
writes data of a correction in XML format