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::EDAnalyzer 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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
 
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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 }
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::EDAnalyzer.

Definition at line 586 of file CocoaAnalyzer.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 40 of file CocoaAnalyzer.cc.

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

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

557 {
558  if(ALIUtils::debug >= 4) {
559  std::cout << "CocoaAnalyzer::CorrectOaParam old value= " << oaParamXML->value_ << " new value= " << oaParamDB.value_ << std::endl;
560  }
561  if( oaParamDB.value_ == -9.999E9 ) return false;
562 
563  double dimFactor = 1.;
564  //loop for an Entry with equal type to entries to know which is the
565  std::string type = oaParamDB.dimType();
566  if( type == "centre" || type == "length" ) {
567  dimFactor = 0.01; // in DB it is in cm
568  }else if ( type == "angles" || type == "angle" || type == "nodim" ){
569  dimFactor = 1.;
570  }else {
571  std::cerr << "!!! COCOA programming error: inform responsible: incorrect OpticalAlignParam type = " << type << std::endl;
572  std::exception();
573  }
574 
575  oaParamXML->value_ = oaParamDB.value_*dimFactor;
576 
577  return true;
578 
579 }
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 474 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().

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

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

Referenced by CorrectOptAlignments().

533 {
534  OpticalAlignInfo* oaInfoXML = 0;
535  std::vector<OpticalAlignInfo>::iterator it;
536  for( it=oaList_.opticalAlignments_.begin();it!=oaList_.opticalAlignments_.end(); ++it ){
537  std::string oaName = oaInfo.name_.substr( 1, oaInfo.name_.size()-2 );
538 
539  if(ALIUtils::debug >= 5) {
540  std::cout << "CocoaAnalyzer::FindOpticalAlignInfoXML: looking for OAI " << (*it).name_ << " =? " << oaName << std::endl;
541  }
542  if( (*it).name_ == oaName ) {
543  oaInfoXML = &(*it);
544  if(ALIUtils::debug >= 4) {
545  std::cout << "CocoaAnalyzer::FindOpticalAlignInfoXML: OAI found " << oaInfoXML->name_ << std::endl;
546  }
547  break;
548  }
549  }
550 
551  return oaInfoXML;
552 }
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 669 of file CocoaAnalyzer.cc.

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

Referenced by ReadXMLFile().

671  {
672  DDValue val(spName, 0.0);
673  if (DDfetch(&dvst,val)) {
674  if ( val.doubles().size() > vecInd ) {
675  // std::cout << "about to return: " << val.doubles()[vecInd] << std::endl;
676  return val.doubles()[vecInd];
677  } else {
678  std::cout << "WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd << " of SpecPar " << spName << std::endl;
679  }
680  }
681  return 0.0;
682 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:102
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 685 of file CocoaAnalyzer.cc.

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

Referenced by ReadXMLFile().

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

Definition at line 447 of file CocoaAnalyzer.cc.

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

Referenced by analyze().

448 {
449  if(ALIUtils::debug >= 3) {
450  std::cout<< std::endl <<"$$$ CocoaAnalyzer::ReadCalibrationDB: " << std::endl;
451  }
452 
453  using namespace edm::eventsetup;
455  evts.get<OpticalAlignmentsRcd>().get(pObjs);
456  const OpticalAlignments* dbObj = pObjs.product();
457 
458  if(ALIUtils::debug >= 5) {
459  std::vector<OpticalAlignInfo>::const_iterator it;
460  for( it=dbObj->opticalAlignments_.begin();it!=dbObj->opticalAlignments_.end(); ++it ){
461  std::cout<<"CocoaAnalyzer::ReadCalibrationDB: OpticalAlignInfo READ "<< *it << std::endl;
462  }
463  }
464 
465  if(ALIUtils::debug >= 4) {
466  std::cout<<"CocoaAnalyzer::ReadCalibrationDB: Number of OpticalAlignInfo READ "<< dbObj->opticalAlignments_.size() << std::endl;
467  }
468 
469  return dbObj->opticalAlignments_;
470 }
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 83 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().

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

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: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().