8 #include "../interface/CocoaAnalyzer.h"
37 usesResource(
"CocoaAnalyzer");
50 std::cout << std::endl <<
"$$$ CocoaAnalyzer::RunCocoa: " << std::endl;
61 std::cout <<
"$$ CocoaAnalyzer::RunCocoa: geometry built " << std::endl;
67 std::cout <<
"$$ CocoaAnalyzer::RunCocoa: measurements built " << std::endl;
77 fileout <<
"............ program ended OK" << std::endl;
94 std::cout << std::endl <<
"$$$ CocoaAnalyzer::ReadXML: root object= " << cpv->root() << std::endl;
125 oaInfo.
type_ =
"system";
136 DDValue val(attribute, value, 0.0);
162 std::cout <<
" CocoaAnalyzer::ReadXML reading object " << lv.name() << std::endl;
165 std::vector<DDExpandedNode> history = fv.
geoHistory();
168 for(ii = 0; ii < history.size()-1;ii++ ) {
182 std::cout <<
" @@ Name built= " << oaInfo.
name_ <<
" short_name= " << name <<
" parent= " << oaInfo.
parentName_ << std::endl;
191 transl = parentRot.Inverse()*(transl - parentTransl );
192 rot = parentRot.Inverse()*
rot;
201 oaInfo.
x_.
value_ = transl.x()*0.001;
207 oaInfo.
y_.
value_ = transl.y()*0.001;
213 oaInfo.
z_.
value_ = transl.z()*0.001;
219 double xx,
xy,xz,yx,yy,yz,zx,zy,zz;
220 rot.GetComponents (xx, xy, xz,
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 );
255 std::cout <<
"CocoaAnalyzer::ReadXML OBJECT " << oaInfo.
name_ <<
" pos/angles read " << std::endl;
258 if( fabs( oaInfo.
angx_.
value_ - angles[0] ) > 1.E-9 ||
260 fabs( oaInfo.
angz_.
value_ - angles[2] ) > 1.E-9 ) {
264 oaInfo.
angz_.
value_ <<
" =? " << angles[2] << std::endl;
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();
272 std::vector<std::string>
names, dims;
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;
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();
298 }
else if (sit->second.name() ==
"meas_name") {
300 measNames = sit->second.strings();
301 }
else if (sit->second.name() ==
"meas_type") {
303 measTypes = sit->second.strings();
313 std::vector<std::string>::iterator vsite;
314 for ( spit = params2.begin(); spit != params2.end(); ++spit ) {
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++ ){
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();
332 std::cout << *vsite <<
" setting issimu " << measIsSimulatedValue[*vsite][0] << std::endl;
336 std::cout <<
"CocoaAnalyser: looped measObjectNames " <<
"meas_object_name_"+(*vsite) <<
" n obj " << measObjectNames[*vsite].size() << std::endl;
345 std::cout <<
" CocoaAnalyzer::ReadXML: Fill extra entries with read parameters " << std::endl;
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.;
353 if( type ==
"centre" || type ==
"length" ) {
355 }
else if ( type ==
"angles" || type ==
"angle" || type ==
"nodim" ){
358 oaParam.
value_ = values[ind]*dimFactor;
359 oaParam.
error_ = errors[ind]*dimFactor;
360 oaParam.
quality_ = int (quality[ind]);
361 oaParam.
name_ = names[ind];
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."
377 std::cout <<
" CocoaAnalyzer::ReadXML: Fill measurements with read parameters " << std::endl;
380 if ( measNames.size() == measTypes.size() ) {
381 for (
size_t ind = 0; ind < measNames.size(); ++ind ) {
383 oaMeas.
name_ = measNames[ind];
384 oaMeas.
type_ = measTypes[ind];
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" ) {
393 }
else if( oaMeas.
type_ ==
"TILTMETER" ) {
396 std::cerr <<
"CocoaAnalyzer::ReadXMLFile. Invalid measurement type: " << oaMeas.
type_ << std::endl;
400 oaMeas.
values_.push_back( oaParam );
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;
416 std::cout <<
"CocoaAnalyser: MEASUREMENT " << oaMeas.
name_ <<
" extra entries read " << oaMeas << std::endl;
423 std::cout <<
"WARNING FOR NOW: sizes of measurements (names, types do"
424 <<
" not match! Did not add " << nObjects <<
" item to XXXMeasurements"
438 std::cout <<
"CocoaAnalyzer::ReadXML: Finished building " << nObjects+1 <<
" OpticalAlignInfo objects" <<
" and " <<
measList_.
oaMeasurements_.size() <<
" OpticalAlignMeasurementInfo objects " << std::endl;
451 std::cout<< std::endl <<
"$$$ CocoaAnalyzer::ReadCalibrationDB: " << std::endl;
454 using namespace edm::eventsetup;
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;
467 std::cout<<
"CocoaAnalyzer::ReadCalibrationDB: Number of OpticalAlignInfo READ "<< dbObj->opticalAlignments_.size() << std::endl;
470 return dbObj->opticalAlignments_;
478 std::cout<< std::endl<<
"$$$ CocoaAnalyzer::CorrectOptAlignments: " << std::endl;
481 std::vector<OpticalAlignInfo>::const_iterator it;
482 for( it=oaListCalib.begin();it!=oaListCalib.end(); ++it ){
485 std::cerr <<
"error " << (*it).name_ << std::endl;
486 if( oaInfoXML == 0 ) {
488 std::cerr <<
"@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: OpticalAlignInfo read from DB is not present in XML "<< *it << std::endl;
493 std::cout <<
"CocoaAnalyzer::CorrectOptAlignments: correcting data from DB info " << std::endl;
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++ ){
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_ ) {
515 if( !pFound && oaName !=
"None" ) {
517 std::cerr <<
"@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: extra entry read from DB is not present in XML "<< *itoap1 <<
" in object " << *it << std::endl;
523 std::cout <<
"CocoaAnalyzer::CorrectOptAlignments: corrected OpticalAlingInfo " <<
oaList_ << std::endl;
536 std::vector<OpticalAlignInfo>::iterator it;
541 std::cout <<
"CocoaAnalyzer::FindOpticalAlignInfoXML: looking for OAI " << (*it).name_ <<
" =? " << oaName << std::endl;
543 if( (*it).name_ == oaName ) {
546 std::cout <<
"CocoaAnalyzer::FindOpticalAlignInfoXML: OAI found " << oaInfoXML->
name_ << std::endl;
560 std::cout <<
"CocoaAnalyzer::CorrectOaParam old value= " << oaParamXML->
value_ <<
" new value= " << oaParamDB.
value_ << std::endl;
562 if( oaParamDB.
value_ == -9.999E9 )
return false;
564 double dimFactor = 1.;
567 if( type ==
"centre" || type ==
"length" ) {
569 }
else if ( type ==
"angles" || type ==
"angle" || type ==
"nodim" ){
572 std::cerr <<
"!!! COCOA programming error: inform responsible: incorrect OpticalAlignParam type = " << type << std::endl;
672 const size_t& vecInd ) {
675 if ( val.
doubles().size() > vecInd ) {
679 std::cout <<
"WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd <<
" of SpecPar " << spName << std::endl;
688 const size_t& vecInd ) {
691 if ( val.
strings().size() > vecInd ) {
695 std::cout <<
"WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd <<
" of SpecPar " << spName << std::endl;
std::string myFetchString(const DDsvalues_type &dvst, const std::string &spName, const size_t &vecInd)
void BuildMeasurementsFromOA(OpticalAlignMeasurements &measList)
T getParameter(std::string const &) const
std::string theCocoaDaqRootFileName
CocoaAnalyzer(edm::ParameterSet const &p)
virtual void beginJob() override
const DDTranslation & absTranslation() const
absolute translation of this node
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
static const HistoName names[]
const DDRotationMatrix & absRotation() const
absolute rotation of this node
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
void ReadXMLFile(const edm::EventSetup &evts)
std::vector< std::string > measObjectNames_
static ALIstring & ReportFName()
the name of the report File
represents one node in the DDExpandedView
static Fit & getInstance()
void CorrectOptAlignments(std::vector< OpticalAlignInfo > &oaListCalib)
static GlobalOptionMgr * getInstance()
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
std::string dimType() const
bool next()
set current node to the next node in the filtered tree
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::...
static Model & getInstance()
-------— Gets the only instance of this class
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
std::vector< OpticalAlignMeasurementInfo > oaMeasurements_
void BuildSystemDescriptionFromOA(OpticalAlignments &optAlig)
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
void setGlobalOption(const ALIstring go, const ALIdouble val, ALIFileIn &filein)
virtual void analyze(const edm::Event &e, const edm::EventSetup &c) override
double myFetchDbl(const DDsvalues_type &dvst, const std::string &spName, const size_t &vecInd)
void setDefaultGlobalOptions()
Set the list of default global options.
std::vector< OpticalAlignParam > extraEntries_
DDsvalues_type mergedSpecifics() const
OpticalAlignMeasurements measList_
static void setDebugVerbosity(ALIint val)
bool firstChild()
set the current node to the first child ...
std::vector< OpticalAlignParam > values_
OpticalAlignInfo * FindOpticalAlignInfoXML(const OpticalAlignInfo &oaInfo)
static std::vector< double > getRotationAnglesFromMatrix(CLHEP::HepRotation &rmLocal, double origAngleX, double origAngleY, double origAngleZ)
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< const DDsvalues_type * > specifics() const
static ALIFileOut & getInstance(const ALIstring &filename)
std::vector< bool > isSimulatedValue_
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
std::vector< OpticalAlignInfo > ReadCalibrationDB(const edm::EventSetup &evts)
OpticalAlignments oaList_
const std::string & name() const
Returns the name.
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
bool CorrectOaParam(OpticalAlignParam *oaParamXML, const OpticalAlignParam &oaParamDB)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.