7 #include "../interface/CocoaAnalyzer.h"
36 usesResource(
"CocoaAnalyzer");
49 std::cout << std::endl <<
"$$$ CocoaAnalyzer::RunCocoa: " << std::endl;
60 std::cout <<
"$$ CocoaAnalyzer::RunCocoa: geometry built " << std::endl;
66 std::cout <<
"$$ CocoaAnalyzer::RunCocoa: measurements built " << std::endl;
76 fileout <<
"............ program ended OK" << std::endl;
93 std::cout << std::endl <<
"$$$ CocoaAnalyzer::ReadXML: root object= " << cpv->root() << std::endl;
124 oaInfo.
type_ =
"system";
135 DDValue val(attribute, value, 0.0);
161 std::cout <<
" CocoaAnalyzer::ReadXML reading object " << lv.name() << std::endl;
164 std::vector<DDExpandedNode> history = fv.
geoHistory();
167 for(ii = 0; ii < history.size()-1;ii++ ) {
181 std::cout <<
" @@ Name built= " << oaInfo.
name_ <<
" short_name= " << name <<
" parent= " << oaInfo.
parentName_ << std::endl;
190 transl = parentRot.Inverse()*(transl - parentTransl );
191 rot = parentRot.Inverse()*
rot;
200 oaInfo.
x_.
value_ = transl.x()*0.001;
206 oaInfo.
y_.
value_ = transl.y()*0.001;
212 oaInfo.
z_.
value_ = transl.z()*0.001;
218 double xx,
xy,xz,yx,yy,yz,zx,zy,zz;
219 rot.GetComponents (xx, xy, xz,
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 );
254 std::cout <<
"CocoaAnalyzer::ReadXML OBJECT " << oaInfo.
name_ <<
" pos/angles read " << std::endl;
257 if( fabs( oaInfo.
angx_.
value_ - angles[0] ) > 1.E-9 ||
259 fabs( oaInfo.
angz_.
value_ - angles[2] ) > 1.E-9 ) {
263 oaInfo.
angz_.
value_ <<
" =? " << angles[2] << std::endl;
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();
271 std::vector<std::string>
names, dims;
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;
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();
297 }
else if (sit->second.name() ==
"meas_name") {
299 measNames = sit->second.strings();
300 }
else if (sit->second.name() ==
"meas_type") {
302 measTypes = sit->second.strings();
312 std::vector<std::string>::iterator vsite;
313 for ( spit = params2.begin(); spit != params2.end(); ++spit ) {
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 ){
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();
331 std::cout << *vsite <<
" setting issimu " << measIsSimulatedValue[*vsite][0] << std::endl;
335 std::cout <<
"CocoaAnalyser: looped measObjectNames " <<
"meas_object_name_"+(*vsite) <<
" n obj " << measObjectNames[*vsite].size() << std::endl;
344 std::cout <<
" CocoaAnalyzer::ReadXML: Fill extra entries with read parameters " << std::endl;
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.;
352 if( type ==
"centre" || type ==
"length" ) {
354 }
else if ( type ==
"angles" || type ==
"angle" || type ==
"nodim" ){
357 oaParam.
value_ = values[ind]*dimFactor;
358 oaParam.
error_ = errors[ind]*dimFactor;
359 oaParam.
quality_ = int (quality[ind]);
360 oaParam.
name_ = names[ind];
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."
376 std::cout <<
" CocoaAnalyzer::ReadXML: Fill measurements with read parameters " << std::endl;
379 if ( measNames.size() == measTypes.size() ) {
380 for (
size_t ind = 0; ind < measNames.size(); ++ind ) {
382 oaMeas.
name_ = measNames[ind];
383 oaMeas.
type_ = measTypes[ind];
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" ) {
392 }
else if( oaMeas.
type_ ==
"TILTMETER" ) {
395 std::cerr <<
"CocoaAnalyzer::ReadXMLFile. Invalid measurement type: " << oaMeas.
type_ << std::endl;
399 oaMeas.
values_.push_back( oaParam );
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;
415 std::cout <<
"CocoaAnalyser: MEASUREMENT " << oaMeas.
name_ <<
" extra entries read " << oaMeas << std::endl;
422 std::cout <<
"WARNING FOR NOW: sizes of measurements (names, types do"
423 <<
" not match! Did not add " << nObjects <<
" item to XXXMeasurements"
437 std::cout <<
"CocoaAnalyzer::ReadXML: Finished building " << nObjects+1 <<
" OpticalAlignInfo objects" <<
" and " <<
measList_.
oaMeasurements_.size() <<
" OpticalAlignMeasurementInfo objects " << std::endl;
450 std::cout<< std::endl <<
"$$$ CocoaAnalyzer::ReadCalibrationDB: " << std::endl;
453 using namespace edm::eventsetup;
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;
466 std::cout<<
"CocoaAnalyzer::ReadCalibrationDB: Number of OpticalAlignInfo READ "<< dbObj->opticalAlignments_.size() << std::endl;
469 return dbObj->opticalAlignments_;
477 std::cout<< std::endl<<
"$$$ CocoaAnalyzer::CorrectOptAlignments: " << std::endl;
480 std::vector<OpticalAlignInfo>::const_iterator it;
481 for( it=oaListCalib.begin();it!=oaListCalib.end(); ++it ){
484 std::cerr <<
"error " << (*it).name_ << std::endl;
485 if( oaInfoXML == 0 ) {
487 std::cerr <<
"@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: OpticalAlignInfo read from DB is not present in XML "<< *it << std::endl;
492 std::cout <<
"CocoaAnalyzer::CorrectOptAlignments: correcting data from DB info " << std::endl;
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 ){
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_ ) {
514 if( !pFound && oaName !=
"None" ) {
516 std::cerr <<
"@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: extra entry read from DB is not present in XML "<< *itoap1 <<
" in object " << *it << std::endl;
522 std::cout <<
"CocoaAnalyzer::CorrectOptAlignments: corrected OpticalAlingInfo " <<
oaList_ << std::endl;
535 std::vector<OpticalAlignInfo>::iterator it;
540 std::cout <<
"CocoaAnalyzer::FindOpticalAlignInfoXML: looking for OAI " << (*it).name_ <<
" =? " << oaName << std::endl;
542 if( (*it).name_ == oaName ) {
545 std::cout <<
"CocoaAnalyzer::FindOpticalAlignInfoXML: OAI found " << oaInfoXML->
name_ << std::endl;
559 std::cout <<
"CocoaAnalyzer::CorrectOaParam old value= " << oaParamXML->
value_ <<
" new value= " << oaParamDB.
value_ << std::endl;
561 if( oaParamDB.
value_ == -9.999E9 )
return false;
563 double dimFactor = 1.;
566 if( type ==
"centre" || type ==
"length" ) {
568 }
else if ( type ==
"angles" || type ==
"angle" || type ==
"nodim" ){
571 std::cerr <<
"!!! COCOA programming error: inform responsible: incorrect OpticalAlignParam type = " << type << std::endl;
671 const size_t& vecInd ) {
674 if ( val.
doubles().size() > vecInd ) {
678 std::cout <<
"WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd <<
" of SpecPar " << spName << std::endl;
687 const size_t& vecInd ) {
690 if ( val.
strings().size() > vecInd ) {
694 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.