CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CocoaAnalyzer Class Reference

#include <CocoaAnalyzer.h>

Inheritance diagram for CocoaAnalyzer:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
virtual void beginJob () override
 
 CocoaAnalyzer (edm::ParameterSet const &p)
 
 CocoaAnalyzer (int i)
 
virtual ~CocoaAnalyzer ()
 
- 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
 
- 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool CorrectOaParam (OpticalAlignParam *oaParamXML, const OpticalAlignParam &oaParamDB)
 
void CorrectOptAlignments (std::vector< OpticalAlignInfo > &oaListCalib)
 
OpticalAlignInfoFindOpticalAlignInfoXML (const OpticalAlignInfo &oaInfo)
 
OpticalAlignInfo GetOptAlignInfoFromOptO (OpticalObject *opto)
 
double myFetchDbl (const DDsvalues_type &dvst, const std::string &spName, const size_t &vecInd)
 
std::string myFetchString (const DDsvalues_type &dvst, const std::string &spName, const size_t &vecInd)
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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 ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 41 of file CocoaAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file CocoaAnalyzer.cc.

References GlobalOptionMgr::getInstance(), edm::ParameterSet::getParameter(), Data_TkAlMinBias_Run2018C_PromptReco_v3_cff::maxEvents, GlobalOptionMgr::setDefaultGlobalOptions(), GlobalOptionMgr::setGlobalOption(), AlCaHLTBitMon_QueryRunRegistry::string, and theCocoaDaqRootFileName.

28 {
29  theCocoaDaqRootFileName = pset.getParameter< std::string >("cocoaDaqRootFile");
30 
31  int maxEvents = pset.getParameter< int32_t >("maxEvents");
33  GlobalOptionMgr::getInstance()->setGlobalOption("maxEvents",maxEvents);
34  GlobalOptionMgr::getInstance()->setGlobalOption("writeDBAlign",1);
35  GlobalOptionMgr::getInstance()->setGlobalOption("writeDBOptAlign",1);
36  usesResource("CocoaAnalyzer");
37 }
std::string theCocoaDaqRootFileName
Definition: CocoaAnalyzer.h:75
static GlobalOptionMgr * getInstance()
void setGlobalOption(const ALIstring go, const ALIdouble val, ALIFileIn &filein)
void setDefaultGlobalOptions()
Set the list of default global options.
CocoaAnalyzer::CocoaAnalyzer ( int  i)
inlineexplicit

Definition at line 46 of file CocoaAnalyzer.h.

46 { }
virtual CocoaAnalyzer::~CocoaAnalyzer ( )
inlinevirtual

Member Function Documentation

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

Definition at line 578 of file CocoaAnalyzer.cc.

References CorrectOptAlignments(), ReadCalibrationDB(), ReadXMLFile(), RunCocoa(), ALIUtils::setDebugVerbosity(), and theCocoaDaqRootFileName.

Referenced by ~CocoaAnalyzer().

579 {
581 
582  ReadXMLFile( evts );
583 
584  std::vector<OpticalAlignInfo> oaListCalib = ReadCalibrationDB( evts );
585 
586  CorrectOptAlignments( oaListCalib );
587 
589 
590  /*-
591  int nEvents = daqReader->GetNEvents();
592  for( int ii = 0; ii < nEvents; ii++) {
593  if( ! daqReader->ReadEvent( ii ) ) break;
594  }
595  */
596 
597  RunCocoa();
598 
599  // std::cout << "!!!! NOT DumpCocoaResults() " << std::endl;
600 
601  // CocoaDBMgr::getInstance()->DumpCocoaResults();
602 
603  return;
604 
605 
606  // using namespace edm::eventsetup;
607  // std::cout <<" I AM IN RUN NUMBER "<<evt.id().run() <<std::endl;
608  // std::cout <<" ---EVENT NUMBER "<<evt.id().event() <<std::endl;
609 
610  // just a quick dump of the private OpticalAlignments object
611  // std::cout << oaList_ << std::endl;
612 
613  // STEP 2:
614  // Get calibrated OpticalAlignments. In this case I'm using
615  // some sqlite database examples that are generated using
616  // testOptAlignWriter.cc
617  // from CondFormats/OptAlignObjects/test/
618 
619 // edm::ESHandle<OpticalAlignments> oaESHandle;
620 // context.get<OpticalAlignmentsRcd>().get(oaESHandle);
621 
622 // // This assumes they ALL come in together. This may not be
623 // // the "real" case. One could envision different objects coming
624 // // in and we would get by label each one (type).
625 
626 // std::cout << "========== eventSetup data changes with IOV =========" << std::endl;
627 // std::cout << *oaESHandle << std::endl;
628 // //============== COCOA WORK!
629 // // calibrated values should be used to "correct" the ones read in during beginJob
630 // //==============
631 
632 // //
633 // // to see how to iterate over the OpticalAlignments, please
634 // // refer to the << operator of OpticalAlignments, OpticalAlignInfo
635 // // and OpticalAlignParam.
636 // // const OpticalAlignments* myoa=oa.product();
637 
638 // // STEP 3:
639 // // This retrieves the Measurements
640 // // for each event, a new set of measurements is available.
641 // edm::Handle<OpticalAlignMeasurements> measHandle;
642 // evt.getByLabel("OptAlignGeneratedSource", measHandle);
643 
644 
645 // std::cout << "========== event data product changes with every event =========" << std::endl;
646 // std::cout << *measHandle << std::endl;
647 
648  //============== COCOA WORK!
649  // Each set of optical alignment measurements can be used
650  // in whatever type of analysis COCOA does.
651  //==============
652 
653 } //end of ::analyze()
std::string theCocoaDaqRootFileName
Definition: CocoaAnalyzer.h:75
void ReadXMLFile(const edm::EventSetup &evts)
void CorrectOptAlignments(std::vector< OpticalAlignInfo > &oaListCalib)
static void setDebugVerbosity(ALIint val)
Definition: ALIUtils.h:42
std::vector< OpticalAlignInfo > ReadCalibrationDB(const edm::EventSetup &evts)
void CocoaAnalyzer::beginJob ( )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 40 of file CocoaAnalyzer.cc.

Referenced by ~CocoaAnalyzer().

41 {
42 }
bool CocoaAnalyzer::CorrectOaParam ( OpticalAlignParam oaParamXML,
const OpticalAlignParam oaParamDB 
)
private

Definition at line 548 of file CocoaAnalyzer.cc.

References MessageLogger_cfi::cerr, gather_cfg::cout, ALIUtils::debug, OpticalAlignParam::dimType(), cppFunctionSkipper::exception, AlCaHLTBitMon_QueryRunRegistry::string, and OpticalAlignParam::value_.

Referenced by CorrectOptAlignments(), and ~CocoaAnalyzer().

549 {
550  if(ALIUtils::debug >= 4) {
551  std::cout << "CocoaAnalyzer::CorrectOaParam old value= " << oaParamXML->value_ << " new value= " << oaParamDB.value_ << std::endl;
552  }
553  if( oaParamDB.value_ == -9.999E9 ) return false;
554 
555  double dimFactor = 1.;
556  //loop for an Entry with equal type to entries to know which is the
557  std::string type = oaParamDB.dimType();
558  if( type == "centre" || type == "length" ) {
559  dimFactor = 0.01; // in DB it is in cm
560  }else if ( type == "angles" || type == "angle" || type == "nodim" ){
561  dimFactor = 1.;
562  }else {
563  std::cerr << "!!! COCOA programming error: inform responsible: incorrect OpticalAlignParam type = " << type << std::endl;
564  std::exception();
565  }
566 
567  oaParamXML->value_ = oaParamDB.value_*dimFactor;
568 
569  return true;
570 
571 }
type
Definition: HCALResponse.h:21
static ALIint debug
Definition: ALIUtils.h:36
std::string dimType() const
void CocoaAnalyzer::CorrectOptAlignments ( std::vector< OpticalAlignInfo > &  oaListCalib)
private

Definition at line 466 of file CocoaAnalyzer.cc.

References OpticalAlignInfo::angx_, OpticalAlignInfo::angy_, OpticalAlignInfo::angz_, MessageLogger_cfi::cerr, CorrectOaParam(), gather_cfg::cout, ALIUtils::debug, OpticalAlignInfo::extraEntries_, FindOpticalAlignInfoXML(), oaList_, AlCaHLTBitMon_QueryRunRegistry::string, OpticalAlignInfo::x_, OpticalAlignInfo::y_, and OpticalAlignInfo::z_.

Referenced by analyze(), and ~CocoaAnalyzer().

467 {
468  if(ALIUtils::debug >= 3) {
469  std::cout<< std::endl<< "$$$ CocoaAnalyzer::CorrectOptAlignments: " << std::endl;
470  }
471 
472  std::vector<OpticalAlignInfo>::const_iterator it;
473  for( it=oaListCalib.begin();it!=oaListCalib.end(); ++it ){
474  OpticalAlignInfo oaInfoDB = *it;
475  OpticalAlignInfo* oaInfoXML = FindOpticalAlignInfoXML( oaInfoDB );
476  std::cerr << "error " << (*it).name_ << std::endl;
477  if( oaInfoXML == nullptr ) {
478  if(ALIUtils::debug >= 2) {
479  std::cerr << "@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: OpticalAlignInfo read from DB is not present in XML "<< *it << std::endl;
480  }
481  } else {
482  //------ Correct info
483  if(ALIUtils::debug >= 5) {
484  std::cout << "CocoaAnalyzer::CorrectOptAlignments: correcting data from DB info " << std::endl;
485  }
486  CorrectOaParam( &oaInfoXML->x_, oaInfoDB.x_ );
487  CorrectOaParam( &oaInfoXML->y_, oaInfoDB.y_ );
488  CorrectOaParam( &oaInfoXML->z_, oaInfoDB.z_ );
489  CorrectOaParam( &oaInfoXML->angx_, oaInfoDB.angx_ );
490  CorrectOaParam( &oaInfoXML->angy_, oaInfoDB.angy_ );
491  CorrectOaParam( &oaInfoXML->angz_, oaInfoDB.angz_ );
492  std::vector<OpticalAlignParam>::iterator itoap1, itoap2;
493  std::vector<OpticalAlignParam> extraEntDB = oaInfoDB.extraEntries_;
494  std::vector<OpticalAlignParam>* extraEntXML = &(oaInfoXML->extraEntries_);
495  for( itoap1 = extraEntDB.begin(); itoap1 != extraEntDB.end(); ++itoap1 ){
496  bool pFound = false;
497  //----- Look for the extra parameter in XML oaInfo that has the same name
498  std::string oaName = (*itoap1).name_.substr( 1, (*itoap1).name_.size()-2 );
499  for( itoap2 = extraEntXML->begin(); itoap2 != extraEntXML->end(); ++itoap2 ){
500  if( oaName == (*itoap2).name_ ) {
501  CorrectOaParam( &(*itoap2), *itoap1 );
502  pFound = true;
503  break;
504  }
505  }
506  if( !pFound && oaName != "None" ) {
507  if(ALIUtils::debug >= 2) {
508  std::cerr << "@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: extra entry read from DB is not present in XML "<< *itoap1 << " in object " << *it << std::endl;
509  }
510  }
511 
512  }
513  if(ALIUtils::debug >= 5) {
514  std::cout << "CocoaAnalyzer::CorrectOptAlignments: corrected OpticalAlingInfo " << oaList_ << std::endl;
515  }
516 
517  }
518  }
519 
520 }
OpticalAlignParam x_
static ALIint debug
Definition: ALIUtils.h:36
OpticalAlignParam angx_
OpticalAlignParam y_
OpticalAlignParam angz_
OpticalAlignParam z_
std::vector< OpticalAlignParam > extraEntries_
OpticalAlignParam angy_
OpticalAlignInfo * FindOpticalAlignInfoXML(const OpticalAlignInfo &oaInfo)
OpticalAlignments oaList_
Definition: CocoaAnalyzer.h:73
bool CorrectOaParam(OpticalAlignParam *oaParamXML, const OpticalAlignParam &oaParamDB)
OpticalAlignInfo * CocoaAnalyzer::FindOpticalAlignInfoXML ( const OpticalAlignInfo oaInfo)
private

Definition at line 524 of file CocoaAnalyzer.cc.

References gather_cfg::cout, ALIUtils::debug, OpticalAlignInfo::name_, oaList_, OpticalAlignments::opticalAlignments_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by CorrectOptAlignments(), and ~CocoaAnalyzer().

525 {
526  OpticalAlignInfo* oaInfoXML = nullptr;
527  std::vector<OpticalAlignInfo>::iterator it;
528  for( it=oaList_.opticalAlignments_.begin();it!=oaList_.opticalAlignments_.end(); ++it ){
529  std::string oaName = oaInfo.name_.substr( 1, oaInfo.name_.size()-2 );
530 
531  if(ALIUtils::debug >= 5) {
532  std::cout << "CocoaAnalyzer::FindOpticalAlignInfoXML: looking for OAI " << (*it).name_ << " =? " << oaName << std::endl;
533  }
534  if( (*it).name_ == oaName ) {
535  oaInfoXML = &(*it);
536  if(ALIUtils::debug >= 4) {
537  std::cout << "CocoaAnalyzer::FindOpticalAlignInfoXML: OAI found " << oaInfoXML->name_ << std::endl;
538  }
539  break;
540  }
541  }
542 
543  return oaInfoXML;
544 }
static ALIint debug
Definition: ALIUtils.h:36
std::vector< OpticalAlignInfo > opticalAlignments_
OpticalAlignments oaList_
Definition: CocoaAnalyzer.h:73
OpticalAlignInfo CocoaAnalyzer::GetOptAlignInfoFromOptO ( OpticalObject opto)
private

Referenced by ~CocoaAnalyzer().

double CocoaAnalyzer::myFetchDbl ( const DDsvalues_type dvst,
const std::string &  spName,
const size_t &  vecInd 
)
private

Definition at line 661 of file CocoaAnalyzer.cc.

References gather_cfg::cout, DDfetch(), DDValue::doubles(), and heppy_batch::val.

Referenced by ReadXMLFile(), and ~CocoaAnalyzer().

663  {
664  DDValue val(spName, 0.0);
665  if (DDfetch(&dvst,val)) {
666  if ( val.doubles().size() > vecInd ) {
667  // std::cout << "about to return: " << val.doubles()[vecInd] << std::endl;
668  return val.doubles()[vecInd];
669  } else {
670  std::cout << "WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd << " of SpecPar " << spName << std::endl;
671  }
672  }
673  return 0.0;
674 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
std::string CocoaAnalyzer::myFetchString ( const DDsvalues_type dvst,
const std::string &  spName,
const size_t &  vecInd 
)
private

Definition at line 677 of file CocoaAnalyzer.cc.

References gather_cfg::cout, DDfetch(), DDValue::strings(), and heppy_batch::val.

Referenced by ReadXMLFile(), and ~CocoaAnalyzer().

679  {
680  DDValue val(spName, 0.0);
681  if (DDfetch(&dvst,val)) {
682  if ( val.strings().size() > vecInd ) {
683  // std::cout << "about to return: " << val.doubles()[vecInd] << std::endl;
684  return val.strings()[vecInd];
685  } else {
686  std::cout << "WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd << " of SpecPar " << spName << std::endl;
687  }
688  }
689  return "";
690 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
std::vector< OpticalAlignInfo > CocoaAnalyzer::ReadCalibrationDB ( const edm::EventSetup evts)
private

Definition at line 439 of file CocoaAnalyzer.cc.

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

Referenced by analyze(), and ~CocoaAnalyzer().

440 {
441  if(ALIUtils::debug >= 3) {
442  std::cout<< std::endl <<"$$$ CocoaAnalyzer::ReadCalibrationDB: " << std::endl;
443  }
444 
445  using namespace edm::eventsetup;
447  evts.get<OpticalAlignmentsRcd>().get(pObjs);
448  const OpticalAlignments* dbObj = pObjs.product();
449 
450  if(ALIUtils::debug >= 5) {
451  std::vector<OpticalAlignInfo>::const_iterator it;
452  for( it=dbObj->opticalAlignments_.begin();it!=dbObj->opticalAlignments_.end(); ++it ){
453  std::cout<<"CocoaAnalyzer::ReadCalibrationDB: OpticalAlignInfo READ "<< *it << std::endl;
454  }
455  }
456 
457  if(ALIUtils::debug >= 4) {
458  std::cout<<"CocoaAnalyzer::ReadCalibrationDB: Number of OpticalAlignInfo READ "<< dbObj->opticalAlignments_.size() << std::endl;
459  }
460 
461  return dbObj->opticalAlignments_;
462 }
static ALIint debug
Definition: ALIUtils.h:36
std::vector< OpticalAlignInfo > opticalAlignments_
T get() const
Definition: EventSetup.h:63
T const * product() const
Definition: ESHandle.h:86
void CocoaAnalyzer::ReadXMLFile ( const edm::EventSetup evts)
private

Definition at line 83 of file CocoaAnalyzer.cc.

References DDExpandedNode::absRotation(), DDExpandedNode::absTranslation(), particleFlowDisplacedVertex_cfi::angles, OpticalAlignInfo::angx_, OpticalAlignInfo::angy_, OpticalAlignInfo::angz_, MessageLogger_cfi::cerr, OpticalAlignMeasurementInfo::clear(), OpticalAlignParam::clear(), OpticalAlignInfo::clear(), gather_cfg::cout, ALIUtils::debug, OpticalAlignParam::dim_type_, OpticalAlignParam::dimType(), OpticalAlignParam::error_, benchmark_cfg::errors, cppFunctionSkipper::exception, OpticalAlignInfo::extraEntries_, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), DDFilteredView::geoHistory(), edm::EventSetup::get(), ALIUtils::getRotationAnglesFromMatrix(), OpticalAlignMeasurementInfo::ID_, OpticalAlignInfo::ID_, cuy::ii, createfilelist::int, OpticalAlignMeasurementInfo::isSimulatedValue_, DDFilteredView::logicalPart(), measList_, OpticalAlignMeasurementInfo::measObjectNames_, DDFilteredView::mergedSpecifics(), myFetchDbl(), myFetchString(), DDName::name(), dataset::name, DDBase< N, C >::name(), OpticalAlignMeasurementInfo::name_, OpticalAlignParam::name_, OpticalAlignInfo::name_, names, DDFilteredView::next(), oaList_, OpticalAlignMeasurements::oaMeasurements_, OpticalAlignments::opticalAlignments_, class-composition::parent, OpticalAlignInfo::parentName_, jets_cff::quality, OpticalAlignParam::quality_, DDCompactView::root(), makeMuonMisalignmentScenario::rot, DDFilteredView::rotation(), DDFilteredView::specifics(), AlCaHLTBitMon_QueryRunRegistry::string, DDFilteredView::translation(), OpticalAlignMeasurementInfo::type_, OpticalAlignInfo::type_, OpticalAlignParam::value_, MuonErrorMatrixValues_cff::values, OpticalAlignMeasurementInfo::values_, OpticalAlignInfo::x_, geometryCSVtoXML::xx, geometryCSVtoXML::xy, geometryCSVtoXML::xz, OpticalAlignInfo::y_, geometryCSVtoXML::yy, geometryCSVtoXML::yz, OpticalAlignInfo::z_, and geometryCSVtoXML::zz.

Referenced by analyze(), and ~CocoaAnalyzer().

84 {
85 
86  // STEP ONE: Initial COCOA objects will be built from a DDL geometry
87  // description.
88 
90  evts.get<IdealGeometryRecord>().get(cpv);
91 
92  if(ALIUtils::debug >= 3) {
93  std::cout << std::endl << "$$$ CocoaAnalyzer::ReadXML: root object= " << cpv->root() << std::endl;
94  }
95 
96  //Build OpticalAlignInfo "system"
97  const DDLogicalPart lv = cpv->root();
98 
99  OpticalAlignInfo oaInfo;
100  oaInfo.ID_ = 0;
101  //--- substract file name to object name
102  oaInfo.name_ = lv.name().name();
103  oaInfo.parentName_ = "";
104  oaInfo.x_.quality_ = 0;
105  oaInfo.x_.value_ = 0.;
106  oaInfo.x_.error_ = 0.;
107  oaInfo.x_.quality_ = 0;
108  oaInfo.y_.value_ = 0.;
109  oaInfo.y_.error_ = 0.;
110  oaInfo.y_.quality_ = 0;
111  oaInfo.z_.value_ = 0.;
112  oaInfo.z_.error_ = 0.;
113  oaInfo.z_.quality_ = 0;
114  oaInfo.angx_.value_ = 0.;
115  oaInfo.angx_.error_ = 0.;
116  oaInfo.angx_.quality_ = 0;
117  oaInfo.angy_.value_ = 0.;
118  oaInfo.angy_.error_ = 0.;
119  oaInfo.angy_.quality_ = 0;
120  oaInfo.angz_.value_ = 0.;
121  oaInfo.angz_.error_ = 0.;
122  oaInfo.angz_.quality_ = 0;
123 
124  oaInfo.type_ = "system";
125 
126  oaList_.opticalAlignments_.push_back(oaInfo);
127  oaInfo.clear();
128 
129  // Example of traversing the whole optical alignment geometry.
130  // At each node we get specpars as variables and use them in
131  // constructing COCOA objects.
132  // It stores these objects in a private data member, opt
133  std::string attribute = "COCOA";
134  std::string value = "COCOA";
135 
136  // get all parts labelled with COCOA using a SpecPar
137  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
138  DDFilteredView fv(*cpv, filter);
139  bool doCOCOA = fv.firstChild();
140 
141  // Loop on parts
142  int nObjects=0;
143  OpticalAlignParam oaParam;
145 
146  while ( doCOCOA ){
147  ++nObjects;
148  // oaInfo.ID_ = nObjects;
149  const DDsvalues_type params(fv.mergedSpecifics());
150 
151  const DDLogicalPart lv = fv.logicalPart();
152  if(ALIUtils::debug >= 4) {
153  std::cout << " CocoaAnalyzer::ReadXML reading object " << lv.name() << std::endl;
154  }
155 
156  std::vector<DDExpandedNode> history = fv.geoHistory();
157  oaInfo.parentName_ = "";
158  size_t ii;
159  for(ii = 0; ii < history.size()-1;ii++ ) {
160  if( ii != 0 ) oaInfo.parentName_ += "/";
161  std::string name = history[ii].logicalPart().name().name();
162  oaInfo.parentName_ += name;
163  // oaInfo.parentName_ = (fv.geoHistory()[fv.geoHistory().size()-2]).logicalPart().name();
164 // icol = oaInfo.parentName_.find(":");
165  // oaInfo.parentName_ = oaInfo.parentName_.substr(icol+1,oaInfo.parentName_.length());
166  }
167 
168  //--- build object name (= parent name + object name)
169  std::string name = history[ii].logicalPart().name().name();
170  //--- substract file name to object name
171  oaInfo.name_ = oaInfo.parentName_ + "/" + name;
172  if(ALIUtils::debug >= 5) {
173  std::cout << " @@ Name built= " << oaInfo.name_ << " short_name= " << name << " parent= " << oaInfo.parentName_ << std::endl;
174  }
175  //----- Read centre and angles
176  oaInfo.x_.quality_ = int (myFetchDbl(params, "centre_X_quality", 0));
177  DDTranslation transl = (fv.translation());
178  DDRotationMatrix rot = (fv.rotation());
179  DDExpandedNode parent = fv.geoHistory()[ fv.geoHistory().size()-2 ];
180  const DDTranslation& parentTransl = parent.absTranslation();
181  const DDRotationMatrix& parentRot = parent.absRotation();
182  transl = parentRot.Inverse()*(transl - parentTransl );
183  rot = parentRot.Inverse()*rot;
184  rot = rot.Inverse(); //DDL uses opposite convention than COCOA
185  /* if(ALIUtils::debug >= 4) {
186  ALIUtils::dumprm( rot, "local rotation ");
187  ALIUtils::dump3v( transl, "local translation");
188  } */
189 
190  oaInfo.x_.name_ = "X";
191  oaInfo.x_.dim_type_ = "centre";
192  oaInfo.x_.value_ = transl.x()*0.001; // CLHEP units are mm, COCOA are m
193  oaInfo.x_.error_ = myFetchDbl(params, "centre_X_sigma", 0)*0.001; // CLHEP units are mm, COCOA are m
194  oaInfo.x_.quality_ = int (myFetchDbl(params, "centre_X_quality", 0));
195 
196  oaInfo.y_.name_ = "Y";
197  oaInfo.y_.dim_type_ = "centre";
198  oaInfo.y_.value_ = transl.y()*0.001; // CLHEP units are mm, COCOA are m
199  oaInfo.y_.error_ = myFetchDbl(params, "centre_Y_sigma", 0)*0.001; // CLHEP units are mm, COCOA are m
200  oaInfo.y_.quality_ = int (myFetchDbl(params, "centre_Y_quality", 0));
201 
202  oaInfo.z_.name_ = "Z";
203  oaInfo.z_.dim_type_ = "centre";
204  oaInfo.z_.value_ = transl.z()*0.001; // CLHEP units are mm, COCOA are m
205  oaInfo.z_.error_ = myFetchDbl(params, "centre_Z_sigma", 0)*0.001; // CLHEP units are mm, COCOA are m
206  oaInfo.z_.quality_ = int (myFetchDbl(params, "centre_Z_quality", 0));
207 
208  //---- DDD convention is to use the inverse matrix, COCOA is the direct one!!!
209  //---- convert it to CLHEP::Matrix
210  double xx,xy,xz,yx,yy,yz,zx,zy,zz;
211  rot.GetComponents (xx, xy, xz,
212  yx, yy, yz,
213  zx, zy, zz);
214  CLHEP::Hep3Vector colX(xx,xy,xz);
215  CLHEP::Hep3Vector colY(yx,yy,yz);
216  CLHEP::Hep3Vector colZ(zx,zy,zz);
217  CLHEP::HepRotation rotclhep( colX, colY, colZ );
218  std::vector<double> angles = ALIUtils::getRotationAnglesFromMatrix( rotclhep,0., 0., 0. );
219 
220  oaInfo.angx_.name_ = "X";
221  oaInfo.angx_.dim_type_ = "angles";
222  //- oaInfo.angx_.value_ = angles[0];
223  oaInfo.angx_.value_ = myFetchDbl(params, "angles_X_value", 0);
224  oaInfo.angx_.error_ = myFetchDbl(params, "angles_X_sigma", 0);
225  oaInfo.angx_.quality_ = int (myFetchDbl(params, "angles_X_quality", 0));
226 
227  oaInfo.angy_.name_ = "Y";
228  oaInfo.angy_.dim_type_ = "angles";
229  //- oaInfo.angy_.value_ = angles[1];
230  oaInfo.angy_.value_ = myFetchDbl(params, "angles_Y_value", 0);
231  oaInfo.angy_.error_ = myFetchDbl(params, "angles_Y_sigma", 0);
232  oaInfo.angy_.quality_ = int (myFetchDbl(params, "angles_Y_quality", 0));
233 
234  oaInfo.angz_.name_ = "Z";
235  oaInfo.angz_.dim_type_ = "angles";
236  // oaInfo.angz_.value_ = angles[2];
237  oaInfo.angz_.value_ = myFetchDbl(params, "angles_Z_value", 0);
238  oaInfo.angz_.error_ = myFetchDbl(params, "angles_Z_sigma", 0);
239  oaInfo.angz_.quality_ = int (myFetchDbl(params, "angles_Z_quality", 0));
240 
241  oaInfo.type_ = myFetchString(params, "cocoa_type", 0);
242 
243  oaInfo.ID_ = int(myFetchDbl(params, "cmssw_ID", 0));
244 
245  if(ALIUtils::debug >= 4) {
246  std::cout << "CocoaAnalyzer::ReadXML OBJECT " << oaInfo.name_ << " pos/angles read " << std::endl;
247  }
248 
249  if( fabs( oaInfo.angx_.value_ - angles[0] ) > 1.E-9 ||
250  fabs( oaInfo.angy_.value_ - angles[1] ) > 1.E-9 ||
251  fabs( oaInfo.angz_.value_ - angles[2] ) > 1.E-9 ) {
252  std::cerr << " WRONG ANGLE IN OBJECT " << oaInfo.name_<<
253  oaInfo.angx_.value_ << " =? " << angles[0] <<
254  oaInfo.angy_.value_ << " =? " << angles[1] <<
255  oaInfo.angz_.value_ << " =? " << angles[2] << std::endl;
256  }
257 
258  //----- Read extra entries and measurements
259  const std::vector<const DDsvalues_type *> params2(fv.specifics());
260  std::vector<const DDsvalues_type *>::const_iterator spit = params2.begin();
261  std::vector<const DDsvalues_type *>::const_iterator endspit = params2.end();
262  //--- extra entries variables
263  std::vector<std::string> names, dims;
264  std::vector<double> values, errors, quality;
265  //--- measurements variables
266  std::vector<std::string> measNames;
267  std::vector<std::string> measTypes;
268  std::map<std::string, std::vector<std::string> > measObjectNames;
269  std::map<std::string, std::vector<std::string> > measParamNames;
270  std::map<std::string, std::vector<double> > measParamValues;
271  std::map<std::string, std::vector<double> > measParamSigmas;
272  std::map<std::string, std::vector<double> > measIsSimulatedValue;
273 
274  for ( ; spit != endspit; ++spit ) {
275  DDsvalues_type::const_iterator sit = (**spit).begin();
276  DDsvalues_type::const_iterator endsit = (**spit).end();
277  for ( ; sit != endsit; ++sit ) {
278  if (sit->second.name() == "extra_entry") {
279  names = sit->second.strings();
280  } else if (sit->second.name() == "dimType") {
281  dims = sit->second.strings();
282  } else if (sit->second.name() == "value") {
283  values = sit->second.doubles();
284  } else if (sit->second.name() == "sigma") {
285  errors = sit->second.doubles();
286  } else if (sit->second.name() == "quality") {
287  quality = sit->second.doubles();
288 
289  } else if (sit->second.name() == "meas_name") {
290  //- std::cout << " meas_name found " << std::endl;
291  measNames = sit->second.strings();
292  } else if (sit->second.name() == "meas_type") {
293  //- std::cout << " meas_type found " << std::endl;
294  measTypes = sit->second.strings();
295  }
296 
297  }
298  }
299 
300  //---- loop again to look for the measurement object names, that have the meas name in the SpecPar title
301  // <Parameter name="meas_object_name_SENSOR2D:OCMS/sens2" value="OCMS/laser1" eval="false" />
302  // <Parameter name="meas_object_name_SENSOR2D:OCMS/sens2" value="OCMS/sens2" eval="false" />
303 
304  std::vector<std::string>::iterator vsite;
305  for ( spit = params2.begin(); spit != params2.end(); ++spit ) {
306  //- std::cout << "loop vector DDsvalues " << std::endl;
307  DDsvalues_type::const_iterator sit = (**spit).begin();
308  DDsvalues_type::const_iterator endsit = (**spit).end();
309  for ( ; sit != endsit; ++sit ) {
310  for( vsite = measNames.begin(); vsite != measNames.end(); ++vsite ){
311  //- std::cout << "looping measObjectNames " << *vsite << std::endl;
312  if (sit->second.name() == "meas_object_name_"+(*vsite)) {
313  measObjectNames[*vsite] = sit->second.strings();
314  }else if (sit->second.name() == "meas_value_name_"+(*vsite)) {
315  measParamNames[*vsite] = sit->second.strings();
316  }else if (sit->second.name() == "meas_value_"+(*vsite)) {
317  measParamValues[*vsite] = sit->second.doubles();
318  }else if (sit->second.name() == "meas_sigma_"+(*vsite)) {
319  measParamSigmas[*vsite] = sit->second.doubles();
320  }else if (sit->second.name() == "meas_is_simulated_value_"+(*vsite)) {
321  measIsSimulatedValue[*vsite] = sit->second.doubles(); // this is not in OptAlignParam info
322  if(ALIUtils::debug >= 5) {
323  std::cout << *vsite << " setting issimu " << measIsSimulatedValue[*vsite][0] << std::endl;
324  }
325  }
326  if(ALIUtils::debug >= 5) {
327  std::cout << "CocoaAnalyser: looped measObjectNames " << "meas_object_name_"+(*vsite) << " n obj " << measObjectNames[*vsite].size() << std::endl;
328  }
329 
330  }
331 
332  }
333  }
334 
335  if(ALIUtils::debug >= 4) {
336  std::cout << " CocoaAnalyzer::ReadXML: Fill extra entries with read parameters " << std::endl;
337  }
338  //--- Fill extra entries with read parameters
339  if ( names.size() == dims.size() && dims.size() == values.size()
340  && values.size() == errors.size() && errors.size() == quality.size() ) {
341  for ( size_t ind = 0; ind < names.size(); ++ind ) {
342  double dimFactor = 1.;
343  std::string type = oaParam.dimType();
344  if( type == "centre" || type == "length" ) {
345  dimFactor = 0.001; // in XML it is in mm
346  }else if ( type == "angles" || type == "angle" || type == "nodim" ){
347  dimFactor = 1.;
348  }
349  oaParam.value_ = values[ind]*dimFactor;
350  oaParam.error_ = errors[ind]*dimFactor;
351  oaParam.quality_ = int (quality[ind]);
352  oaParam.name_ = names[ind];
353  oaParam.dim_type_ = dims[ind];
354  oaInfo.extraEntries_.push_back (oaParam);
355  oaParam.clear();
356  }
357 
358  //t std::cout << names.size() << " OBJECT " << oaInfo.name_ << " extra entries read " << oaInfo << std::endl;
359 
360  oaList_.opticalAlignments_.push_back(oaInfo);
361  } else {
362  std::cout << "WARNING FOR NOW: sizes of extra parameters (names, dimType, value, quality) do"
363  << " not match! Did not add " << nObjects << " item to OpticalAlignments."
364  << std::endl;
365  }
366 
367  if(ALIUtils::debug >= 4) {
368  std::cout << " CocoaAnalyzer::ReadXML: Fill measurements with read parameters " << std::endl;
369  }
370  //--- Fill measurements with read parameters
371  if ( measNames.size() == measTypes.size() ) {
372  for ( size_t ind = 0; ind < measNames.size(); ++ind ) {
373  oaMeas.ID_ = ind;
374  oaMeas.name_ = measNames[ind];
375  oaMeas.type_ = measTypes[ind];
376  oaMeas.measObjectNames_ = measObjectNames[oaMeas.name_];
377  if( measParamNames.size() == measParamValues.size() && measParamValues.size() == measParamSigmas.size() ) {
378  for( size_t ind2 = 0; ind2 < measParamNames[oaMeas.name_].size(); ind2++ ){
379  oaParam.name_ = measParamNames[oaMeas.name_][ind2];
380  oaParam.value_ = measParamValues[oaMeas.name_][ind2];
381  oaParam.error_ = measParamSigmas[oaMeas.name_][ind2];
382  if( oaMeas.type_ == "SENSOR2D" || oaMeas.type_ == "COPS" || oaMeas.type_ == "DISTANCEMETER" || oaMeas.type_ == "DISTANCEMETER!DIM" || oaMeas.type_ == "DISTANCEMETER3DIM" ) {
383  oaParam.dim_type_ = "length";
384  } else if( oaMeas.type_ == "TILTMETER" ) {
385  oaParam.dim_type_ = "angle";
386  } else {
387  std::cerr << "CocoaAnalyzer::ReadXMLFile. Invalid measurement type: " << oaMeas.type_ << std::endl;
388  std::exception();
389  }
390 
391  oaMeas.values_.push_back( oaParam );
392  oaMeas.isSimulatedValue_.push_back( measIsSimulatedValue[oaMeas.name_][ind2] );
393  if(ALIUtils::debug >= 5) {
394  std::cout << oaMeas.name_ << " copying issimu " << oaMeas.isSimulatedValue_[oaMeas.isSimulatedValue_.size()-1] << " = " << measIsSimulatedValue[oaMeas.name_][ind2] << std::endl;
395  //- std::cout << ind2 << " adding meas value " << oaParam << std::endl;
396  }
397  oaParam.clear();
398  }
399  } else {
400  if(ALIUtils::debug >= 2) {
401  std::cout << "WARNING FOR NOW: sizes of measurement parameters (name, value, sigma) do"
402  << " not match! for measurement " << oaMeas.name_ << " !Did not fill parameters for this measurement " << std::endl;
403  }
404  }
405  measList_.oaMeasurements_.push_back (oaMeas);
406  if(ALIUtils::debug >= 5) {
407  std::cout << "CocoaAnalyser: MEASUREMENT " << oaMeas.name_ << " extra entries read " << oaMeas << std::endl;
408  }
409  oaMeas.clear();
410  }
411 
412  } else {
413  if(ALIUtils::debug >= 2) {
414  std::cout << "WARNING FOR NOW: sizes of measurements (names, types do"
415  << " not match! Did not add " << nObjects << " item to XXXMeasurements"
416  << std::endl;
417  }
418  }
419 
420 // std::cout << "sizes are values=" << values.size();
421 // std::cout << " sigma(errors)=" << errors.size();
422 // std::cout << " quality=" << quality.size();
423 // std::cout << " names=" << names.size();
424 // std::cout << " dimType=" << dims.size() << std::endl;
425  oaInfo.clear();
426  doCOCOA = fv.next(); // go to next part
427  } // while (doCOCOA)
428  if(ALIUtils::debug >= 3) {
429  std::cout << "CocoaAnalyzer::ReadXML: Finished building " << nObjects+1 << " OpticalAlignInfo objects" << " and " << measList_.oaMeasurements_.size() << " OpticalAlignMeasurementInfo objects " << std::endl;
430  }
431  if(ALIUtils::debug >= 5) {
432  std::cout << " @@@@@@ OpticalAlignments " << oaList_ << std::endl;
433  std::cout << " @@@@@@ OpticalMeasurements " << measList_ << std::endl;
434  }
435 
436 }
std::string myFetchString(const DDsvalues_type &dvst, const std::string &spName, const size_t &vecInd)
type
Definition: HCALResponse.h:21
const DDTranslation & absTranslation() const
absolute translation of this node
std::string parentName_
const N & name() const
Definition: DDBase.h:78
OpticalAlignParam x_
const DDRotationMatrix & absRotation() const
absolute rotation of this node
std::vector< std::string > measObjectNames_
static ALIint debug
Definition: ALIUtils.h:36
represents one node in the DDExpandedView
const std::string names[nVars_]
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
std::string dimType() const
OpticalAlignParam angx_
OpticalAlignParam y_
std::vector< OpticalAlignInfo > opticalAlignments_
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:20
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
Definition: value.py:1
std::vector< OpticalAlignMeasurementInfo > oaMeasurements_
OpticalAlignParam angz_
ii
Definition: cuy.py:589
double myFetchDbl(const DDsvalues_type &dvst, const std::string &spName, const size_t &vecInd)
OpticalAlignParam z_
std::vector< OpticalAlignParam > extraEntries_
OpticalAlignMeasurements measList_
Definition: CocoaAnalyzer.h:74
OpticalAlignParam angy_
T get() const
Definition: EventSetup.h:63
std::vector< OpticalAlignParam > values_
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
static std::vector< double > getRotationAnglesFromMatrix(CLHEP::HepRotation &rmLocal, double origAngleX, double origAngleY, double origAngleZ)
Definition: ALIUtils.cc:591
std::string dim_type_
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
OpticalAlignments oaList_
Definition: CocoaAnalyzer.h:73
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
unsigned int ID_
void CocoaAnalyzer::RunCocoa ( )
private

Definition at line 46 of file CocoaAnalyzer.cc.

References Model::BuildMeasurementsFromOA(), Model::BuildSystemDescriptionFromOA(), gather_cfg::cout, ALIUtils::debug, ALIFileOut::getInstance(), Fit::getInstance(), Model::getInstance(), measList_, oaList_, ALIUtils::report, Model::ReportFName(), and Fit::startFit().

Referenced by analyze(), and ~CocoaAnalyzer().

47 {
48  if(ALIUtils::debug >= 3) {
49  std::cout << std::endl << "$$$ CocoaAnalyzer::RunCocoa: " << std::endl;
50  }
51  //-ALIFileIn fin;
52  //- GlobalOptionMgr::getInstance()->setGlobalOption("debug_verbose",5, fin );
53 
54  //---------- Build the Model out of the system description text file
55  Model& model = Model::getInstance();
56 
58 
59  if(ALIUtils::debug >= 3) {
60  std::cout << "$$ CocoaAnalyzer::RunCocoa: geometry built " << std::endl;
61  }
62 
64 
65  if(ALIUtils::debug >= 3) {
66  std::cout << "$$ CocoaAnalyzer::RunCocoa: measurements built " << std::endl;
67  }
68 
70 
71  Fit::startFit();
72 
73  if(ALIUtils::debug >= 0) std::cout << "............ program ended OK" << std::endl;
74  if( ALIUtils::report >=1 ) {
76  fileout << "............ program ended OK" << std::endl;
77  }
78 
79 } // end of ::beginJob
void BuildMeasurementsFromOA(OpticalAlignMeasurements &measList)
Definition: Model.cc:1632
static ALIint debug
Definition: ALIUtils.h:36
static ALIstring & ReportFName()
the name of the report File
Definition: Model.h:96
static Fit & getInstance()
Definition: Fit.cc:71
static Model & getInstance()
-------— Gets the only instance of this class
Definition: Model.cc:83
void BuildSystemDescriptionFromOA(OpticalAlignments &optAlig)
Definition: Model.cc:1586
Definition: Model.h:38
static void startFit()
Definition: Fit.cc:105
static ALIint report
Definition: ALIUtils.h:35
OpticalAlignMeasurements measList_
Definition: CocoaAnalyzer.h:74
static ALIFileOut & getInstance(const ALIstring &filename)
Definition: ALIFileOut.cc:19
OpticalAlignments oaList_
Definition: CocoaAnalyzer.h:73

Member Data Documentation

OpticalAlignMeasurements CocoaAnalyzer::measList_
private

Definition at line 74 of file CocoaAnalyzer.h.

Referenced by ReadXMLFile(), and RunCocoa().

OpticalAlignments CocoaAnalyzer::oaList_
private
std::string CocoaAnalyzer::theCocoaDaqRootFileName
private

Definition at line 75 of file CocoaAnalyzer.h.

Referenced by analyze(), and CocoaAnalyzer().