CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CocoaAnalyzer Class Reference
Inheritance diagram for CocoaAnalyzer:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
 CocoaAnalyzer (edm::ParameterSet const &p)
 
 CocoaAnalyzer (int i)
 
 ~CocoaAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void correctAllOpticalAlignments (std::vector< OpticalAlignInfo > &allDBOpticalAlignments)
 
void correctOpticalAlignmentParameter (OpticalAlignParam &myXMLParam, const OpticalAlignParam &myDBParam)
 
std::vector< OpticalAlignInforeadCalibrationDB (const edm::EventSetup &evts)
 
void readXMLFile (const edm::EventSetup &evts)
 
void runCocoa ()
 

Private Attributes

OpticalAlignMeasurements measList_
 
OpticalAlignments oaList_
 
std::string theCocoaDaqRootFileName_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 30 of file CocoaAnalyzer.cc.

Constructor & Destructor Documentation

◆ CocoaAnalyzer() [1/2]

CocoaAnalyzer::CocoaAnalyzer ( edm::ParameterSet const &  p)
explicit

◆ CocoaAnalyzer() [2/2]

CocoaAnalyzer::CocoaAnalyzer ( int  i)
inlineexplicit

Definition at line 33 of file CocoaAnalyzer.cc.

33 {}

◆ ~CocoaAnalyzer()

CocoaAnalyzer::~CocoaAnalyzer ( )
inlineoverride

Definition at line 34 of file CocoaAnalyzer.cc.

34 {}

Member Function Documentation

◆ analyze()

void CocoaAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 68 of file CocoaAnalyzer.cc.

68  {
70 
71  // Get ideal geometry description + measurements for simulation.
72  readXMLFile(evts);
73 
74  // Correct ideal geometry with data from DB.
75  std::vector<OpticalAlignInfo> oaListCalib = readCalibrationDB(evts);
76  correctAllOpticalAlignments(oaListCalib);
77 
78  // Run the least-squared fit and store results in DB.
79  runCocoa();
80 }

References ALIUtils::setDebugVerbosity().

◆ beginJob()

void CocoaAnalyzer::beginJob ( )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 66 of file CocoaAnalyzer.cc.

66 {}

◆ correctAllOpticalAlignments()

void CocoaAnalyzer::correctAllOpticalAlignments ( std::vector< OpticalAlignInfo > &  allDBOpticalAlignments)
private

Definition at line 475 of file CocoaAnalyzer.cc.

475  {
476  if (ALIUtils::debug >= 3) {
477  edm::LogInfo("Alignment") << "$$$ CocoaAnalyzer::correctAllOpticalAlignments: ";
478  }
479 
480  for (const auto& myDBInfo : allDBOpticalAlignments) {
481  if (ALIUtils::debug >= 5) {
482  edm::LogInfo("Alignment") << "CocoaAnalyzer::findOpticalAlignInfoXML: Looking for OAI " << myDBInfo.name_;
483  }
484 
485  std::vector<OpticalAlignInfo>& allXMLOpticalAlignments = oaList_.opticalAlignments_;
486  const auto& myXMLInfo = std::find_if(
487  allXMLOpticalAlignments.begin(), allXMLOpticalAlignments.end(), [&](const auto& myXMLInfoCandidate) {
488  return myXMLInfoCandidate.name_ == myDBInfo.name_;
489  });
490 
491  if (myXMLInfo != allXMLOpticalAlignments.end()) {
492  if (ALIUtils::debug >= 4) {
493  edm::LogInfo("Alignment") << "CocoaAnalyzer::findOpticalAlignInfoXML: OAI found " << myXMLInfo->name_;
494  edm::LogInfo("Alignment")
495  << "CocoaAnalyzer::correctAllOpticalAlignments: correcting data from XML with DB info.";
496  }
497  correctOpticalAlignmentParameter(myXMLInfo->x_, myDBInfo.x_);
498  correctOpticalAlignmentParameter(myXMLInfo->y_, myDBInfo.y_);
499  correctOpticalAlignmentParameter(myXMLInfo->z_, myDBInfo.z_);
500  correctOpticalAlignmentParameter(myXMLInfo->angx_, myDBInfo.angx_);
501  correctOpticalAlignmentParameter(myXMLInfo->angy_, myDBInfo.angy_);
502  correctOpticalAlignmentParameter(myXMLInfo->angz_, myDBInfo.angz_);
503 
504  // Also correct extra entries
505  const std::vector<OpticalAlignParam>& allDBExtraEntries = myDBInfo.extraEntries_;
506  std::vector<OpticalAlignParam>& allXMLExtraEntries = myXMLInfo->extraEntries_;
507  for (const auto& myDBExtraEntry : allDBExtraEntries) {
508  const auto& myXMLExtraEntry = std::find_if(
509  allXMLExtraEntries.begin(), allXMLExtraEntries.end(), [&](const auto& myXMLExtraEntryCandidate) {
510  return myXMLExtraEntryCandidate.name_ == myDBExtraEntry.name_;
511  });
512 
513  if (myXMLExtraEntry != allXMLExtraEntries.end()) {
514  correctOpticalAlignmentParameter(*myXMLExtraEntry, myDBExtraEntry);
515  } else {
516  if (myDBExtraEntry.name_ != "None") {
517  if (ALIUtils::debug >= 2) {
518  edm::LogError("Alignment")
519  << "CocoaAnalyzer::correctAllOpticalAlignments: extra entry read from DB is not present in XML "
520  << myDBExtraEntry << " in object " << myDBInfo;
521  }
522  }
523  }
524  }
525 
526  if (ALIUtils::debug >= 5) {
527  edm::LogInfo("Alignment") << "CocoaAnalyzer::correctAllOpticalAlignments: corrected OpticalAlingInfo "
528  << oaList_;
529  }
530  } else {
531  if (ALIUtils::debug >= 2) {
532  edm::LogError("Alignment") << "CocoaAnalyzer::correctAllOpticalAlignments: OpticalAlignInfo read from DB "
533  << myDBInfo << " is not present in XML.";
534  }
535  }
536  }
537 }

References ALIUtils::debug.

◆ correctOpticalAlignmentParameter()

void CocoaAnalyzer::correctOpticalAlignmentParameter ( OpticalAlignParam myXMLParam,
const OpticalAlignParam myDBParam 
)
private

Definition at line 542 of file CocoaAnalyzer.cc.

543  {
544  if (myDBParam.value_ != -9.999E9) {
545  const std::string& type = myDBParam.dimType();
546  double dimFactor = 1.;
547 
548  if (type == "centre" || type == "length") {
549  dimFactor = 1. / 1._m; // in DB it is in cm
550  } else if (type == "angles" || type == "angle" || type == "nodim") {
551  dimFactor = 1.;
552  } else {
553  edm::LogError("Alignment") << "Incorrect OpticalAlignParam type = " << type;
554  }
555 
556  const double correctedValue = myDBParam.value_ * dimFactor;
557  if (ALIUtils::debug >= 4) {
558  edm::LogInfo("Alignment") << "CocoaAnalyzer::correctOpticalAlignmentParameter old value= " << myXMLParam.value_
559  << " new value= " << correctedValue;
560  }
561  myXMLParam.value_ = correctedValue;
562  }
563 }

References ALIUtils::debug, OpticalAlignParam::dimType(), AlCaHLTBitMon_QueryRunRegistry::string, and OpticalAlignParam::value_.

◆ readCalibrationDB()

std::vector< OpticalAlignInfo > CocoaAnalyzer::readCalibrationDB ( const edm::EventSetup evts)
private

Definition at line 451 of file CocoaAnalyzer.cc.

451  {
452  if (ALIUtils::debug >= 3) {
453  edm::LogInfo("Alignment") << "$$$ CocoaAnalyzer::readCalibrationDB: ";
454  }
455 
456  using namespace edm::eventsetup;
458  evts.get<OpticalAlignmentsRcd>().get(pObjs);
459  const std::vector<OpticalAlignInfo>& infoFromDB = pObjs.product()->opticalAlignments_;
460 
461  if (ALIUtils::debug >= 5) {
462  edm::LogInfo("Alignment") << "CocoaAnalyzer::readCalibrationDB: Number of OpticalAlignInfo READ "
463  << infoFromDB.size();
464  for (const auto& myInfoFromDB : infoFromDB) {
465  edm::LogInfo("Alignment") << "CocoaAnalyzer::readCalibrationDB: OpticalAlignInfo READ " << myInfoFromDB;
466  }
467  }
468 
469  return infoFromDB;
470 }

References ALIUtils::debug, edm::EventSetup::get(), get, OpticalAlignments::opticalAlignments_, and edm::ESHandle< T >::product().

◆ readXMLFile()

void CocoaAnalyzer::readXMLFile ( const edm::EventSetup evts)
private

Definition at line 87 of file CocoaAnalyzer.cc.

87  {
89  evts.get<IdealGeometryRecord>().get(myCompactView);
90 
91  const cms::DDDetector* mySystem = myCompactView->detector();
92 
93  if (mySystem) {
94  // Always store world volume first.
95  const dd4hep::Volume& worldVolume = mySystem->worldVolume();
96 
97  if (ALIUtils::debug >= 3) {
98  edm::LogInfo("Alignment") << "CocoaAnalyzer::ReadXML: world object = " << worldVolume.name();
99  }
100 
101  OpticalAlignInfo worldInfo;
102  worldInfo.ID_ = 0;
103  worldInfo.name_ = worldVolume.name();
104  worldInfo.type_ = "system";
105  worldInfo.parentName_ = "";
106  worldInfo.x_.value_ = 0.;
107  worldInfo.x_.error_ = 0.;
108  worldInfo.x_.quality_ = 0;
109  worldInfo.y_.value_ = 0.;
110  worldInfo.y_.error_ = 0.;
111  worldInfo.y_.quality_ = 0;
112  worldInfo.z_.value_ = 0.;
113  worldInfo.z_.error_ = 0.;
114  worldInfo.z_.quality_ = 0;
115  worldInfo.angx_.value_ = 0.;
116  worldInfo.angx_.error_ = 0.;
117  worldInfo.angx_.quality_ = 0;
118  worldInfo.angy_.value_ = 0.;
119  worldInfo.angy_.error_ = 0.;
120  worldInfo.angy_.quality_ = 0;
121  worldInfo.angz_.value_ = 0.;
122  worldInfo.angz_.error_ = 0.;
123  worldInfo.angz_.quality_ = 0;
124  oaList_.opticalAlignments_.emplace_back(worldInfo);
125 
126  // This gathers all the 'SpecPar' sections from the loaded XMLs.
127  // NB: Definition of a SpecPar section:
128  // It is a block in the XML file(s), containing paths to specific volumes,
129  // and ALLOWING THE ASSOCIATION OF SPECIFIC PARAMETERS AND VALUES TO THESE VOLUMES.
130  const cms::DDSpecParRegistry& allSpecParSections = myCompactView->specpars();
131 
132  // CREATION OF A COCOA FILTERED VIEW
133  // Creation of the dd4hep-based filtered view.
134  // NB: not filtered yet!
135  cms::DDFilteredView myFilteredView(mySystem, worldVolume);
136  // Declare a container which will gather all the filtered SpecPar sections.
137  cms::DDSpecParRefs cocoaParameterSpecParSections;
138  // Define a COCOA filter
139  const std::string cocoaParameterAttribute = "COCOA";
140  const std::string cocoaParameterValue = "COCOA";
141  // All the COCOA SpecPar sections are filtered from allSpecParSections,
142  // and assigned to cocoaParameterSpecParSections.
143  allSpecParSections.filter(cocoaParameterSpecParSections, cocoaParameterAttribute, cocoaParameterValue);
144  // This finally allows to filter the filtered view, with the COCOA filter.
145  // This means that we now have, in myFilteredView, all volumes whose paths were selected:
146  // ie all volumes with "COCOA" parameter and value in a SpecPar section from a loaded XML.
147  myFilteredView.mergedSpecifics(cocoaParameterSpecParSections);
148 
149  // Loop on parts
150  int nObjects = 0;
151  bool doCOCOA = myFilteredView.firstChild();
152 
153  // Loop on all COCOA volumes from filtered view
154  while (doCOCOA) {
155  ++nObjects;
156 
157  OpticalAlignInfo oaInfo;
158  OpticalAlignParam oaParam;
160 
161  // Current volume
162  const dd4hep::PlacedVolume& myPlacedVolume = myFilteredView.volume();
163  const std::string& name = myPlacedVolume.name();
164  const std::string& nodePath = myFilteredView.path();
165  oaInfo.name_ = nodePath;
166 
167  // Parent name
168  oaInfo.parentName_ = nodePath.substr(0, nodePath.rfind('/', nodePath.length()));
169 
170  if (ALIUtils::debug >= 4) {
171  edm::LogInfo("Alignment") << " CocoaAnalyzer::ReadXML reading object " << name;
172  edm::LogInfo("Alignment") << " @@ Name built= " << oaInfo.name_ << " short_name= " << name
173  << " parent= " << oaInfo.parentName_;
174  }
175 
176  // TRANSLATIONS
177 
178  // A) GET TRANSLATIONS FROM DDETECTOR.
179  // Directly get translation from parent to child volume
180  const dd4hep::Direction& transl = myPlacedVolume.position();
181 
182  if (ALIUtils::debug >= 4) {
183  edm::LogInfo("Alignment") << "Local translation in cm = " << transl;
184  }
185 
186  // B) READ INFO FROM XMLS
187  // X
188  oaInfo.x_.name_ = "X";
189  oaInfo.x_.dim_type_ = "centre";
190  oaInfo.x_.value_ = transl.x() / (1._m); // COCOA units are m
191  oaInfo.x_.error_ = cms::getParameterValueFromSpecParSections<double>(allSpecParSections,
192  nodePath,
193  "centre_X_sigma",
194  0) /
195  (1._m); // COCOA units are m
196  oaInfo.x_.quality_ = static_cast<int>(
197  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "centre_X_quality", 0));
198  // Y
199  oaInfo.y_.name_ = "Y";
200  oaInfo.y_.dim_type_ = "centre";
201  oaInfo.y_.value_ = transl.y() / (1._m); // COCOA units are m
202  oaInfo.y_.error_ = cms::getParameterValueFromSpecParSections<double>(allSpecParSections,
203  nodePath,
204  "centre_Y_sigma",
205  0) /
206  (1._m); // COCOA units are m
207  oaInfo.y_.quality_ = static_cast<int>(
208  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "centre_Y_quality", 0));
209  // Z
210  oaInfo.z_.name_ = "Z";
211  oaInfo.z_.dim_type_ = "centre";
212  oaInfo.z_.value_ = transl.z() / (1._m); // COCOA units are m
213  oaInfo.z_.error_ = cms::getParameterValueFromSpecParSections<double>(allSpecParSections,
214  nodePath,
215  "centre_Z_sigma",
216  0) /
217  (1._m); // COCOA units are m
218  oaInfo.z_.quality_ = static_cast<int>(
219  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "centre_Z_quality", 0));
220 
221  // ROTATIONS
222 
223  // A) GET ROTATIONS FROM DDETECTOR.
224 
225  // Unlike in the initial code, here we manage to directly get the rotation matrix placement
226  // of the child in parent, EXPRESSED IN THE PARENT FRAME OF REFERENCE.
227  // Hence the (ugly) initial block of code is replaced by just 2 lines.
228  // PlacedVolume::matrix() returns the rotation matrix IN THE PARENT FRAME OF REFERENCE.
229  // NB: Not using DDFilteredView::rotation(),
230  // because it returns the rotation matrix IN THE WORLD FRAME OF REFERENCE.
231  const TGeoHMatrix parentToChild = myPlacedVolume.matrix();
232  // COCOA convention is FROM CHILD TO PARENT
233  const TGeoHMatrix& childToParent = parentToChild.Inverse();
234 
235  // Convert it to CLHEP::Matrix
236  // Below is not my code, below block is untouched (apart from bug fix).
237  // I would just directly use childToParent...
238  const Double_t* rot = childToParent.GetRotationMatrix();
239  const double xx = rot[0];
240  const double xy = rot[1];
241  const double xz = rot[2];
242  const double yx = rot[3];
243  const double yy = rot[4];
244  const double yz = rot[5];
245  const double zx = rot[6];
246  const double zy = rot[7];
247  const double zz = rot[8];
248  if (ALIUtils::debug >= 4) {
249  edm::LogInfo("Alignment") << "Local rotation = ";
250  edm::LogInfo("Alignment") << xx << " " << xy << " " << xz;
251  edm::LogInfo("Alignment") << yx << " " << yy << " " << yz;
252  edm::LogInfo("Alignment") << zx << " " << zy << " " << zz;
253  }
254  const CLHEP::Hep3Vector colX(xx, yx, zx);
255  const CLHEP::Hep3Vector colY(xy, yy, zy);
256  const CLHEP::Hep3Vector colZ(xz, yz, zz);
257  const CLHEP::HepRotation rotclhep(colX, colY, colZ);
258  const std::vector<double>& angles = ALIUtils::getRotationAnglesFromMatrix(rotclhep, 0., 0., 0.);
259 
260  // B) READ INFO FROM XMLS
261  // X
262  oaInfo.angx_.name_ = "X";
263  oaInfo.angx_.dim_type_ = "angles";
264  oaInfo.angx_.value_ =
265  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_X_value", 0);
266  oaInfo.angx_.error_ =
267  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_X_sigma", 0);
268  oaInfo.angx_.quality_ = static_cast<int>(
269  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_X_quality", 0));
270  // Y
271  oaInfo.angy_.name_ = "Y";
272  oaInfo.angy_.dim_type_ = "angles";
273  oaInfo.angy_.value_ =
274  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_Y_value", 0);
275  oaInfo.angy_.error_ =
276  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_Y_sigma", 0);
277  oaInfo.angy_.quality_ = static_cast<int>(
278  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_Y_quality", 0));
279  // Z
280  oaInfo.angz_.name_ = "Z";
281  oaInfo.angz_.dim_type_ = "angles";
282  oaInfo.angz_.value_ =
283  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_Z_value", 0);
284  oaInfo.angz_.error_ =
285  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_Z_sigma", 0);
286  oaInfo.angz_.quality_ = static_cast<int>(
287  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "angles_Z_quality", 0));
288 
289  oaInfo.type_ =
290  cms::getParameterValueFromSpecParSections<std::string>(allSpecParSections, nodePath, "cocoa_type", 0);
291 
292  oaInfo.ID_ = static_cast<int>(
293  cms::getParameterValueFromSpecParSections<double>(allSpecParSections, nodePath, "cmssw_ID", 0));
294 
295  if (ALIUtils::debug >= 4) {
296  edm::LogInfo("Alignment") << "CocoaAnalyzer::ReadXML OBJECT " << oaInfo.name_ << " pos/angles read ";
297  }
298 
299  // Check that rotations match with values from XMLs.
300  // Same, that ugly code is not mine ;p
301  if (fabs(oaInfo.angx_.value_ - angles[0]) > 1.E-9 || fabs(oaInfo.angy_.value_ - angles[1]) > 1.E-9 ||
302  fabs(oaInfo.angz_.value_ - angles[2]) > 1.E-9) {
303  edm::LogError("Alignment") << " WRONG ANGLE IN OBJECT " << oaInfo.name_ << oaInfo.angx_.value_ << " =? "
304  << angles[0] << oaInfo.angy_.value_ << " =? " << angles[1] << oaInfo.angz_.value_
305  << " =? " << angles[2];
306  }
307 
308  // EXTRA PARAM ENTRIES (FROM XMLS)
309  // Here initial code to define the containers was fully removed, this is much more compact.
310  const std::vector<std::string>& names =
311  cms::getAllParameterValuesFromSpecParSections<std::string>(allSpecParSections, nodePath, "extra_entry");
312  const std::vector<std::string>& dims =
313  cms::getAllParameterValuesFromSpecParSections<std::string>(allSpecParSections, nodePath, "dimType");
314  const std::vector<double>& values =
315  cms::getAllParameterValuesFromSpecParSections<double>(allSpecParSections, nodePath, "value");
316  const std::vector<double>& errors =
317  cms::getAllParameterValuesFromSpecParSections<double>(allSpecParSections, nodePath, "sigma");
318  const std::vector<double>& quality =
319  cms::getAllParameterValuesFromSpecParSections<double>(allSpecParSections, nodePath, "quality");
320 
321  if (ALIUtils::debug >= 4) {
322  edm::LogInfo("Alignment") << " CocoaAnalyzer::ReadXML: Fill extra entries with read parameters ";
323  }
324 
325  if (names.size() == dims.size() && dims.size() == values.size() && values.size() == errors.size() &&
326  errors.size() == quality.size()) {
327  for (size_t i = 0; i < names.size(); ++i) {
328  double dimFactor = 1.;
329  const std::string& type = dims[i];
330  if (type == "centre" || type == "length") {
331  dimFactor = 1. / (1._m); // was converted to cm with getParameterValueFromSpecPar, COCOA unit is m
332  } else if (type == "angles" || type == "angle" || type == "nodim") {
333  dimFactor = 1.;
334  }
335  oaParam.value_ = values[i] * dimFactor;
336  oaParam.error_ = errors[i] * dimFactor;
337  oaParam.quality_ = static_cast<int>(quality[i]);
338  oaParam.name_ = names[i];
339  oaParam.dim_type_ = dims[i];
340  oaInfo.extraEntries_.emplace_back(oaParam);
341  oaParam.clear();
342  }
343 
344  oaList_.opticalAlignments_.emplace_back(oaInfo);
345  } else {
346  edm::LogInfo("Alignment") << "WARNING FOR NOW: sizes of extra parameters (names, dimType, value, quality) do"
347  << " not match! Did not add " << nObjects << " item to OpticalAlignments.";
348  }
349 
350  // MEASUREMENTS (FROM XMLS)
351  const std::vector<std::string>& measNames =
352  cms::getAllParameterValuesFromSpecParSections<std::string>(allSpecParSections, nodePath, "meas_name");
353  const std::vector<std::string>& measTypes =
354  cms::getAllParameterValuesFromSpecParSections<std::string>(allSpecParSections, nodePath, "meas_type");
355 
356  std::map<std::string, std::vector<std::string>> measObjectNames;
357  std::map<std::string, std::vector<std::string>> measParamNames;
358  std::map<std::string, std::vector<double>> measParamValues;
359  std::map<std::string, std::vector<double>> measParamSigmas;
360  std::map<std::string, std::vector<double>> measIsSimulatedValue;
361  for (const auto& name : measNames) {
362  measObjectNames[name] = cms::getAllParameterValuesFromSpecParSections<std::string>(
363  allSpecParSections, nodePath, "meas_object_name_" + name);
364  measParamNames[name] = cms::getAllParameterValuesFromSpecParSections<std::string>(
365  allSpecParSections, nodePath, "meas_value_name_" + name);
366  measParamValues[name] =
367  cms::getAllParameterValuesFromSpecParSections<double>(allSpecParSections, nodePath, "meas_value_" + name);
368  measParamSigmas[name] =
369  cms::getAllParameterValuesFromSpecParSections<double>(allSpecParSections, nodePath, "meas_sigma_" + name);
370  measIsSimulatedValue[name] = cms::getAllParameterValuesFromSpecParSections<double>(
371  allSpecParSections, nodePath, "meas_is_simulated_value_" + name);
372  }
373 
374  if (ALIUtils::debug >= 4) {
375  edm::LogInfo("Alignment") << " CocoaAnalyzer::ReadXML: Fill measurements with read parameters ";
376  }
377 
378  if (measNames.size() == measTypes.size()) {
379  for (size_t i = 0; i < measNames.size(); ++i) {
380  oaMeas.ID_ = i;
381  oaMeas.name_ = measNames[i];
382  oaMeas.type_ = measTypes[i];
383  oaMeas.measObjectNames_ = measObjectNames[oaMeas.name_];
384  if (measParamNames.size() == measParamValues.size() && measParamValues.size() == measParamSigmas.size()) {
385  for (size_t i2 = 0; i2 < measParamNames[oaMeas.name_].size(); i2++) {
386  oaParam.name_ = measParamNames[oaMeas.name_][i2];
387  oaParam.value_ = measParamValues[oaMeas.name_][i2];
388  oaParam.error_ = measParamSigmas[oaMeas.name_][i2];
389  oaParam.quality_ = 2;
390  if (oaMeas.type_ == "SENSOR2D" || oaMeas.type_ == "COPS" || oaMeas.type_ == "DISTANCEMETER" ||
391  oaMeas.type_ == "DISTANCEMETER!DIM" || oaMeas.type_ == "DISTANCEMETER3DIM") {
392  oaParam.dim_type_ = "length";
393  } else if (oaMeas.type_ == "TILTMETER") {
394  oaParam.dim_type_ = "angle";
395  } else {
396  edm::LogError("Alignment") << "CocoaAnalyzer::readXMLFile. Invalid measurement type: " << oaMeas.type_;
397  }
398 
399  oaMeas.values_.emplace_back(oaParam);
400  oaMeas.isSimulatedValue_.emplace_back(measIsSimulatedValue[oaMeas.name_][i2]);
401  if (ALIUtils::debug >= 5) {
402  edm::LogInfo("Alignment") << oaMeas.name_ << " copying issimu "
403  << oaMeas.isSimulatedValue_[oaMeas.isSimulatedValue_.size() - 1] << " = "
404  << measIsSimulatedValue[oaMeas.name_][i2];
405  }
406  oaParam.clear();
407  }
408  } else {
409  if (ALIUtils::debug >= 2) {
410  edm::LogWarning("Alignment") << "WARNING FOR NOW: sizes of measurement parameters (name, value, sigma) do"
411  << " not match! for measurement " << oaMeas.name_
412  << " !Did not fill parameters for this measurement ";
413  }
414  }
415  measList_.oaMeasurements_.emplace_back(oaMeas);
416  if (ALIUtils::debug >= 5) {
417  edm::LogInfo("Alignment") << "CocoaAnalyser: MEASUREMENT " << oaMeas.name_ << " extra entries read "
418  << oaMeas;
419  }
420  oaMeas.clear();
421  }
422 
423  } else {
424  if (ALIUtils::debug >= 2) {
425  edm::LogWarning("Alignment") << "WARNING FOR NOW: sizes of measurements (names, types do"
426  << " not match! Did not add " << nObjects << " item to XXXMeasurements";
427  }
428  }
429 
430  oaInfo.clear();
431  doCOCOA = myFilteredView.firstChild();
432  } // while (doCOCOA)
433 
434  if (ALIUtils::debug >= 3) {
435  edm::LogInfo("Alignment") << "CocoaAnalyzer::ReadXML: Finished building " << nObjects + 1
436  << " OpticalAlignInfo objects"
437  << " and " << measList_.oaMeasurements_.size()
438  << " OpticalAlignMeasurementInfo objects ";
439  }
440  if (ALIUtils::debug >= 5) {
441  edm::LogInfo("Alignment") << " @@@@@@ OpticalAlignments " << oaList_;
442  edm::LogInfo("Alignment") << " @@@@@@ OpticalMeasurements " << measList_;
443  }
444  }
445 }

References particleFlowDisplacedVertex_cfi::angles, OpticalAlignInfo::angx_, OpticalAlignInfo::angy_, OpticalAlignInfo::angz_, OpticalAlignMeasurementInfo::clear(), OpticalAlignParam::clear(), OpticalAlignInfo::clear(), ALIUtils::debug, cms::DDCompactView::detector(), OpticalAlignParam::dim_type_, OpticalAlignParam::error_, OpticalAlignInfo::extraEntries_, cms::DDFilteredView::firstChild(), edm::EventSetup::get(), get, ALIUtils::getRotationAnglesFromMatrix(), mps_fire::i, testProducerWithPsetDescEmpty_cfi::i2, OpticalAlignMeasurementInfo::ID_, OpticalAlignInfo::ID_, OpticalAlignMeasurementInfo::isSimulatedValue_, OpticalAlignMeasurementInfo::measObjectNames_, cms::DDFilteredView::mergedSpecifics(), Skims_PA_cff::name, OpticalAlignMeasurementInfo::name_, OpticalAlignParam::name_, OpticalAlignInfo::name_, names, OpticalAlignInfo::parentName_, cms::DDFilteredView::path(), qcdUeDQM_cfi::quality, OpticalAlignParam::quality_, makeMuonMisalignmentScenario::rot, cms::DDCompactView::specpars(), AlCaHLTBitMon_QueryRunRegistry::string, OpticalAlignMeasurementInfo::type_, OpticalAlignInfo::type_, OpticalAlignParam::value_, contentValuesCheck::values, OpticalAlignMeasurementInfo::values_, cms::DDFilteredView::volume(), cms::DDDetector::worldVolume(), OpticalAlignInfo::x_, geometryCSVtoXML::xx, geometryCSVtoXML::xy, geometryCSVtoXML::xz, OpticalAlignInfo::y_, geometryCSVtoXML::yy, geometryCSVtoXML::yz, OpticalAlignInfo::z_, and geometryCSVtoXML::zz.

◆ runCocoa()

void CocoaAnalyzer::runCocoa ( )
private

Definition at line 568 of file CocoaAnalyzer.cc.

568  {
569  if (ALIUtils::debug >= 3) {
570  edm::LogInfo("Alignment") << "$$$ CocoaAnalyzer::runCocoa: ";
571  }
572 
573  // Geometry model built from XML file (corrected with values from DB)
575  model.BuildSystemDescriptionFromOA(oaList_);
576 
577  if (ALIUtils::debug >= 3) {
578  edm::LogInfo("Alignment") << "$$ CocoaAnalyzer::runCocoa: geometry built ";
579  }
580 
581  // Build measurements
582  model.BuildMeasurementsFromOA(measList_);
583 
584  if (ALIUtils::debug >= 3) {
585  edm::LogInfo("Alignment") << "$$ CocoaAnalyzer::runCocoa: measurements built ";
586  }
587 
588  // Do fit and store results in DB
590  Fit::startFit();
591 
592  if (ALIUtils::debug >= 0)
593  edm::LogInfo("Alignment") << "............ program ended OK";
594  if (ALIUtils::report >= 1) {
596  fileout << "............ program ended OK";
597  }
598 }

References ALIUtils::debug, ALIFileOut::getInstance(), Fit::getInstance(), Model::getInstance(), ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi::model, ALIUtils::report, Model::ReportFName(), and Fit::startFit().

Member Data Documentation

◆ measList_

OpticalAlignMeasurements CocoaAnalyzer::measList_
private

Definition at line 50 of file CocoaAnalyzer.cc.

◆ oaList_

OpticalAlignments CocoaAnalyzer::oaList_
private

Definition at line 49 of file CocoaAnalyzer.cc.

◆ theCocoaDaqRootFileName_

std::string CocoaAnalyzer::theCocoaDaqRootFileName_
private

Definition at line 51 of file CocoaAnalyzer.cc.

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
mps_fire.i
i
Definition: mps_fire.py:428
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
geometryCSVtoXML.yz
yz
Definition: geometryCSVtoXML.py:19
OpticalAlignInfo::name_
std::string name_
Definition: OpticalAlignInfo.h:92
OpticalAlignMeasurementInfo::ID_
unsigned int ID_
Definition: OpticalAlignMeasurementInfo.h:36
OpticalAlignParam::error_
double error_
Definition: OpticalAlignInfo.h:47
CocoaAnalyzer::readCalibrationDB
std::vector< OpticalAlignInfo > readCalibrationDB(const edm::EventSetup &evts)
Definition: CocoaAnalyzer.cc:451
ALIFileOut::getInstance
static ALIFileOut & getInstance(const ALIstring &filename)
Definition: ALIFileOut.cc:18
GlobalOptionMgr::getInstance
static GlobalOptionMgr * getInstance()
Definition: GlobalOptionMgr.cc:18
cms::DDSpecParRefs
dd4hep::SpecParRefs DDSpecParRefs
Definition: DDCompactView.h:29
CocoaAnalyzer::theCocoaDaqRootFileName_
std::string theCocoaDaqRootFileName_
Definition: CocoaAnalyzer.cc:51
OpticalAlignments::opticalAlignments_
std::vector< OpticalAlignInfo > opticalAlignments_
Definition: OpticalAlignments.h:30
CocoaAnalyzer::readXMLFile
void readXMLFile(const edm::EventSetup &evts)
Definition: CocoaAnalyzer.cc:87
OpticalAlignInfo
Definition: OpticalAlignInfo.h:71
OpticalAlignMeasurementInfo::values_
std::vector< OpticalAlignParam > values_
Definition: OpticalAlignMeasurementInfo.h:35
OpticalAlignParam::dimType
std::string dimType() const
Definition: OpticalAlignInfo.h:43
OpticalAlignMeasurementInfo::isSimulatedValue_
std::vector< bool > isSimulatedValue_
Definition: OpticalAlignMeasurementInfo.h:33
OpticalAlignInfo::parentName_
std::string parentName_
Definition: OpticalAlignInfo.h:93
cms::PlacedVolume
dd4hep::PlacedVolume PlacedVolume
Definition: DDFilteredView.h:48
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
OpticalAlignInfo::clear
void clear()
Definition: OpticalAlignInfo.h:95
cms::DDFilteredView
Definition: DDFilteredView.h:70
ALIFileOut
Definition: ALIFileOut.h:21
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.model
model
Definition: ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.py:11
OpticalAlignMeasurementInfo::measObjectNames_
std::vector< std::string > measObjectNames_
Definition: OpticalAlignMeasurementInfo.h:32
OpticalAlignParam::clear
void clear()
Definition: OpticalAlignInfo.h:52
cms::DDSpecParRegistry
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
errors
Definition: errors.py:1
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
Model::ReportFName
static ALIstring & ReportFName()
the name of the report File
Definition: Model.h:99
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
OpticalAlignParam::name_
std::string name_
Definition: OpticalAlignInfo.h:49
OpticalAlignMeasurementInfo::name_
std::string name_
Definition: OpticalAlignMeasurementInfo.h:31
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
edm::ESHandle
Definition: DTSurvey.h:22
OpticalAlignInfo::angx_
OpticalAlignParam angx_
Definition: OpticalAlignInfo.h:89
OpticalAlignMeasurementInfo::clear
void clear()
Definition: OpticalAlignMeasurementInfo.h:38
GlobalOptionMgr::setDefaultGlobalOptions
void setDefaultGlobalOptions()
Set the list of default global options.
Definition: GlobalOptionMgr.cc:27
CocoaAnalyzer::correctOpticalAlignmentParameter
void correctOpticalAlignmentParameter(OpticalAlignParam &myXMLParam, const OpticalAlignParam &myDBParam)
Definition: CocoaAnalyzer.cc:542
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
OpticalAlignInfo::angz_
OpticalAlignParam angz_
Definition: OpticalAlignInfo.h:89
OpticalAlignInfo::y_
OpticalAlignParam y_
Definition: OpticalAlignInfo.h:89
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
OpticalAlignInfo::type_
std::string type_
Definition: OpticalAlignInfo.h:91
OpticalAlignParam
Definition: OpticalAlignInfo.h:34
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
OpticalAlignInfo::extraEntries_
std::vector< OpticalAlignParam > extraEntries_
Definition: OpticalAlignInfo.h:90
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
CocoaAnalyzer::oaList_
OpticalAlignments oaList_
Definition: CocoaAnalyzer.cc:49
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
geometryCSVtoXML.xz
xz
Definition: geometryCSVtoXML.py:19
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
cms::DDDetector::worldVolume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:40
OpticalAlignInfo::angy_
OpticalAlignParam angy_
Definition: OpticalAlignInfo.h:89
OpticalAlignMeasurements::oaMeasurements_
std::vector< OpticalAlignMeasurementInfo > oaMeasurements_
Definition: OpticalAlignMeasurements.h:27
OpticalAlignInfo::x_
OpticalAlignParam x_
Definition: OpticalAlignInfo.h:89
CocoaAnalyzer::runCocoa
void runCocoa()
Definition: CocoaAnalyzer.cc:568
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
Fit::getInstance
static Fit & getInstance()
Definition: Fit.cc:69
GlobalOptionMgr::setGlobalOption
void setGlobalOption(const ALIstring go, const ALIdouble val, ALIFileIn &filein)
Definition: GlobalOptionMgr.cc:137
CocoaAnalyzer::measList_
OpticalAlignMeasurements measList_
Definition: CocoaAnalyzer.cc:50
cms::DDCompactView::specpars
DDSpecParRegistry const & specpars() const
Definition: DDCompactView.h:35
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
Model
Definition: Model.h:54
CocoaAnalyzer::correctAllOpticalAlignments
void correctAllOpticalAlignments(std::vector< OpticalAlignInfo > &allDBOpticalAlignments)
Definition: CocoaAnalyzer.cc:475
particleFlowDisplacedVertex_cfi.angles
angles
Definition: particleFlowDisplacedVertex_cfi.py:84
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
OpticalAlignMeasurementInfo
Definition: OpticalAlignMeasurementInfo.h:28
ALIUtils::report
static ALIint report
Definition: ALIUtils.h:33
Model::getInstance
static Model & getInstance()
-------— Gets the only instance of this class
Definition: Model.cc:82
cms::DDDetector
Definition: DDDetector.h:12
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Data_TkAlMinBias_Run2018C_PromptReco_v3_cff.maxEvents
maxEvents
Definition: Data_TkAlMinBias_Run2018C_PromptReco_v3_cff.py:3
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
OpticalAlignmentsRcd
Definition: OpticalAlignmentsRcd.h:9
ALIUtils::setDebugVerbosity
static void setDebugVerbosity(ALIint val)
Definition: ALIUtils.h:38
edm::eventsetup
Definition: ES_DDDetector.cc:16
OpticalAlignParam::value_
double value_
Definition: OpticalAlignInfo.h:46
OpticalAlignInfo::ID_
unsigned int ID_
Definition: OpticalAlignInfo.h:94
OpticalAlignParam::quality_
int quality_
Definition: OpticalAlignInfo.h:48
OpticalAlignInfo::z_
OpticalAlignParam z_
Definition: OpticalAlignInfo.h:89
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
OpticalAlignMeasurementInfo::type_
std::string type_
Definition: OpticalAlignMeasurementInfo.h:30
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
ALIUtils::getRotationAnglesFromMatrix
static std::vector< double > getRotationAnglesFromMatrix(const CLHEP::HepRotation &rmLocal, double origAngleX, double origAngleY, double origAngleZ)
Definition: ALIUtils.cc:549
OpticalAlignParam::dim_type_
std::string dim_type_
Definition: OpticalAlignInfo.h:50
Fit::startFit
static void startFit()
Definition: Fit.cc:103