CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- 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::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 28 of file CocoaAnalyzer.cc.

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

29 {
30  theCocoaDaqRootFileName = pset.getParameter< std::string >("cocoaDaqRootFile");
31 
32  int maxEvents = pset.getParameter< int32_t >("maxEvents");
34  GlobalOptionMgr::getInstance()->setGlobalOption("maxEvents",maxEvents);
35  GlobalOptionMgr::getInstance()->setGlobalOption("writeDBAlign",1);
36  GlobalOptionMgr::getInstance()->setGlobalOption("writeDBOptAlign",1);
37  usesResource("CocoaAnalyzer");
38 }
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

Definition at line 47 of file CocoaAnalyzer.h.

47 { }

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 587 of file CocoaAnalyzer.cc.

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

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 41 of file CocoaAnalyzer.cc.

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

Definition at line 557 of file CocoaAnalyzer.cc.

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

Referenced by CorrectOptAlignments().

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

Definition at line 475 of file CocoaAnalyzer.cc.

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

Referenced by analyze().

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

Definition at line 533 of file CocoaAnalyzer.cc.

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

Referenced by CorrectOptAlignments().

534 {
535  OpticalAlignInfo* oaInfoXML = 0;
536  std::vector<OpticalAlignInfo>::iterator it;
537  for( it=oaList_.opticalAlignments_.begin();it!=oaList_.opticalAlignments_.end(); ++it ){
538  std::string oaName = oaInfo.name_.substr( 1, oaInfo.name_.size()-2 );
539 
540  if(ALIUtils::debug >= 5) {
541  std::cout << "CocoaAnalyzer::FindOpticalAlignInfoXML: looking for OAI " << (*it).name_ << " =? " << oaName << std::endl;
542  }
543  if( (*it).name_ == oaName ) {
544  oaInfoXML = &(*it);
545  if(ALIUtils::debug >= 4) {
546  std::cout << "CocoaAnalyzer::FindOpticalAlignInfoXML: OAI found " << oaInfoXML->name_ << std::endl;
547  }
548  break;
549  }
550  }
551 
552  return oaInfoXML;
553 }
static ALIint debug
Definition: ALIUtils.h:35
std::vector< OpticalAlignInfo > opticalAlignments_
tuple cout
Definition: gather_cfg.py:121
OpticalAlignments oaList_
Definition: CocoaAnalyzer.h:73
OpticalAlignInfo CocoaAnalyzer::GetOptAlignInfoFromOptO ( OpticalObject opto)
private
double CocoaAnalyzer::myFetchDbl ( const DDsvalues_type dvst,
const std::string &  spName,
const size_t &  vecInd 
)
private

Definition at line 670 of file CocoaAnalyzer.cc.

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

Referenced by ReadXMLFile().

672  {
673  DDValue val(spName, 0.0);
674  if (DDfetch(&dvst,val)) {
675  if ( val.doubles().size() > vecInd ) {
676  // std::cout << "about to return: " << val.doubles()[vecInd] << std::endl;
677  return val.doubles()[vecInd];
678  } else {
679  std::cout << "WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd << " of SpecPar " << spName << std::endl;
680  }
681  }
682  return 0.0;
683 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple cout
Definition: gather_cfg.py:121
std::string CocoaAnalyzer::myFetchString ( const DDsvalues_type dvst,
const std::string &  spName,
const size_t &  vecInd 
)
private

Definition at line 686 of file CocoaAnalyzer.cc.

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

Referenced by ReadXMLFile().

688  {
689  DDValue val(spName, 0.0);
690  if (DDfetch(&dvst,val)) {
691  if ( val.strings().size() > vecInd ) {
692  // std::cout << "about to return: " << val.doubles()[vecInd] << std::endl;
693  return val.strings()[vecInd];
694  } else {
695  std::cout << "WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd << " of SpecPar " << spName << std::endl;
696  }
697  }
698  return "";
699 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple cout
Definition: gather_cfg.py:121
std::vector< OpticalAlignInfo > CocoaAnalyzer::ReadCalibrationDB ( const edm::EventSetup evts)
private

Definition at line 448 of file CocoaAnalyzer.cc.

References gather_cfg::cout, ALIUtils::debug, and edm::EventSetup::get().

Referenced by analyze().

449 {
450  if(ALIUtils::debug >= 3) {
451  std::cout<< std::endl <<"$$$ CocoaAnalyzer::ReadCalibrationDB: " << std::endl;
452  }
453 
454  using namespace edm::eventsetup;
456  evts.get<OpticalAlignmentsRcd>().get(pObjs);
457  const OpticalAlignments* dbObj = pObjs.product();
458 
459  if(ALIUtils::debug >= 5) {
460  std::vector<OpticalAlignInfo>::const_iterator it;
461  for( it=dbObj->opticalAlignments_.begin();it!=dbObj->opticalAlignments_.end(); ++it ){
462  std::cout<<"CocoaAnalyzer::ReadCalibrationDB: OpticalAlignInfo READ "<< *it << std::endl;
463  }
464  }
465 
466  if(ALIUtils::debug >= 4) {
467  std::cout<<"CocoaAnalyzer::ReadCalibrationDB: Number of OpticalAlignInfo READ "<< dbObj->opticalAlignments_.size() << std::endl;
468  }
469 
470  return dbObj->opticalAlignments_;
471 }
static ALIint debug
Definition: ALIUtils.h:35
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:121
void CocoaAnalyzer::ReadXMLFile ( const edm::EventSetup evts)
private

Definition at line 84 of file CocoaAnalyzer.cc.

References DDExpandedNode::absRotation(), DDExpandedNode::absTranslation(), DDFilteredView::addFilter(), DDSpecificsFilter::AND, OpticalAlignInfo::angx_, OpticalAlignInfo::angy_, OpticalAlignInfo::angz_, dtNoiseDBValidation_cfg::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_, alcazmumu_cfi::filter, DDFilteredView::firstChild(), DDFilteredView::geoHistory(), edm::EventSetup::get(), ALIUtils::getRotationAnglesFromMatrix(), OpticalAlignMeasurementInfo::ID_, OpticalAlignInfo::ID_, cuy::ii, OpticalAlignMeasurementInfo::isSimulatedValue_, DDFilteredView::logicalPart(), DDSpecificsFilter::matches, measList_, OpticalAlignMeasurementInfo::measObjectNames_, DDFilteredView::mergedSpecifics(), myFetchDbl(), myFetchString(), DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), OpticalAlignMeasurementInfo::name_, OpticalAlignParam::name_, OpticalAlignInfo::name_, cscdqm::h::names, DDFilteredView::next(), oaList_, OpticalAlignMeasurements::oaMeasurements_, OpticalAlignments::opticalAlignments_, dbtoconf::parent, OpticalAlignInfo::parentName_, OpticalAlignParam::quality_, makeMuonMisalignmentScenario::rot, DDFilteredView::rotation(), DDSpecificsFilter::setCriteria(), DDFilteredView::specifics(), AlCaHLTBitMon_QueryRunRegistry::string, DDFilteredView::translation(), OpticalAlignMeasurementInfo::type_, OpticalAlignInfo::type_, relativeConstraints::value, OpticalAlignParam::value_, makeHLTPrescaleTable::values, OpticalAlignMeasurementInfo::values_, OpticalAlignInfo::x_, create_public_lumi_plots::xy, OpticalAlignInfo::y_, and OpticalAlignInfo::z_.

Referenced by analyze().

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

Definition at line 47 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().

48 {
49  if(ALIUtils::debug >= 3) {
50  std::cout << std::endl << "$$$ CocoaAnalyzer::RunCocoa: " << std::endl;
51  }
52  //-ALIFileIn fin;
53  //- GlobalOptionMgr::getInstance()->setGlobalOption("debug_verbose",5, fin );
54 
55  //---------- Build the Model out of the system description text file
56  Model& model = Model::getInstance();
57 
59 
60  if(ALIUtils::debug >= 3) {
61  std::cout << "$$ CocoaAnalyzer::RunCocoa: geometry built " << std::endl;
62  }
63 
65 
66  if(ALIUtils::debug >= 3) {
67  std::cout << "$$ CocoaAnalyzer::RunCocoa: measurements built " << std::endl;
68  }
69 
71 
72  Fit::startFit();
73 
74  if(ALIUtils::debug >= 0) std::cout << "............ program ended OK" << std::endl;
75  if( ALIUtils::report >=1 ) {
77  fileout << "............ program ended OK" << std::endl;
78  }
79 
80 } // end of ::beginJob
void BuildMeasurementsFromOA(OpticalAlignMeasurements &measList)
Definition: Model.cc:1626
static ALIint debug
Definition: ALIUtils.h:35
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:81
void BuildSystemDescriptionFromOA(OpticalAlignments &optAlig)
Definition: Model.cc:1580
Definition: Model.h:38
static void startFit()
Definition: Fit.cc:105
static ALIint report
Definition: ALIUtils.h:34
OpticalAlignMeasurements measList_
Definition: CocoaAnalyzer.h:74
tuple cout
Definition: gather_cfg.py:121
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().