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";
153 std::cout <<
" CocoaAnalyzer::ReadXML reading object " << lv.name() << std::endl;
156 std::vector<DDExpandedNode> history = fv.
geoHistory();
159 for(ii = 0; ii < history.size()-1;ii++ ) {
173 std::cout <<
" @@ Name built= " << oaInfo.
name_ <<
" short_name= " << name <<
" parent= " << oaInfo.
parentName_ << std::endl;
182 transl = parentRot.Inverse()*(transl - parentTransl );
183 rot = parentRot.Inverse()*
rot;
192 oaInfo.
x_.
value_ = transl.x()*0.001;
198 oaInfo.
y_.
value_ = transl.y()*0.001;
204 oaInfo.
z_.
value_ = transl.z()*0.001;
211 rot.GetComponents (xx, xy, xz,
214 CLHEP::Hep3Vector colX(xx,xy,xz);
215 CLHEP::Hep3Vector colY(yx,yy,yz);
216 CLHEP::Hep3Vector colZ(zx,zy,zz);
217 CLHEP::HepRotation rotclhep( colX, colY, colZ );
246 std::cout <<
"CocoaAnalyzer::ReadXML OBJECT " << oaInfo.
name_ <<
" pos/angles read " << std::endl;
249 if( fabs( oaInfo.
angx_.
value_ - angles[0] ) > 1.E-9 ||
251 fabs( oaInfo.
angz_.
value_ - angles[2] ) > 1.E-9 ) {
255 oaInfo.
angz_.
value_ <<
" =? " << angles[2] << std::endl;
259 const std::vector<const DDsvalues_type *> params2(fv.
specifics());
260 std::vector<const DDsvalues_type *>::const_iterator spit = params2.begin();
261 std::vector<const DDsvalues_type *>::const_iterator endspit = params2.end();
263 std::vector<std::string>
names, dims;
266 std::vector<std::string> measNames;
267 std::vector<std::string> measTypes;
268 std::map<std::string, std::vector<std::string> > measObjectNames;
269 std::map<std::string, std::vector<std::string> > measParamNames;
270 std::map<std::string, std::vector<double> > measParamValues;
271 std::map<std::string, std::vector<double> > measParamSigmas;
272 std::map<std::string, std::vector<double> > measIsSimulatedValue;
274 for ( ; spit != endspit; ++spit ) {
275 DDsvalues_type::const_iterator sit = (**spit).begin();
276 DDsvalues_type::const_iterator endsit = (**spit).end();
277 for ( ; sit != endsit; ++sit ) {
278 if (sit->second.name() ==
"extra_entry") {
279 names = sit->second.strings();
280 }
else if (sit->second.name() ==
"dimType") {
281 dims = sit->second.strings();
282 }
else if (sit->second.name() ==
"value") {
283 values = sit->second.doubles();
284 }
else if (sit->second.name() ==
"sigma") {
285 errors = sit->second.doubles();
286 }
else if (sit->second.name() ==
"quality") {
287 quality = sit->second.doubles();
289 }
else if (sit->second.name() ==
"meas_name") {
291 measNames = sit->second.strings();
292 }
else if (sit->second.name() ==
"meas_type") {
294 measTypes = sit->second.strings();
304 std::vector<std::string>::iterator vsite;
305 for ( spit = params2.begin(); spit != params2.end(); ++spit ) {
307 DDsvalues_type::const_iterator sit = (**spit).begin();
308 DDsvalues_type::const_iterator endsit = (**spit).end();
309 for ( ; sit != endsit; ++sit ) {
310 for( vsite = measNames.begin(); vsite != measNames.end(); ++vsite ){
312 if (sit->second.name() ==
"meas_object_name_"+(*vsite)) {
313 measObjectNames[*vsite] = sit->second.strings();
314 }
else if (sit->second.name() ==
"meas_value_name_"+(*vsite)) {
315 measParamNames[*vsite] = sit->second.strings();
316 }
else if (sit->second.name() ==
"meas_value_"+(*vsite)) {
317 measParamValues[*vsite] = sit->second.doubles();
318 }
else if (sit->second.name() ==
"meas_sigma_"+(*vsite)) {
319 measParamSigmas[*vsite] = sit->second.doubles();
320 }
else if (sit->second.name() ==
"meas_is_simulated_value_"+(*vsite)) {
321 measIsSimulatedValue[*vsite] = sit->second.doubles();
323 std::cout << *vsite <<
" setting issimu " << measIsSimulatedValue[*vsite][0] << std::endl;
327 std::cout <<
"CocoaAnalyser: looped measObjectNames " <<
"meas_object_name_"+(*vsite) <<
" n obj " << measObjectNames[*vsite].size() << std::endl;
336 std::cout <<
" CocoaAnalyzer::ReadXML: Fill extra entries with read parameters " << std::endl;
339 if ( names.size() == dims.size() && dims.size() == values.size()
340 && values.size() == errors.size() && errors.size() == quality.size() ) {
341 for (
size_t ind = 0; ind < names.size(); ++ind ) {
342 double dimFactor = 1.;
344 if( type ==
"centre" || type ==
"length" ) {
346 }
else if ( type ==
"angles" || type ==
"angle" || type ==
"nodim" ){
349 oaParam.
value_ = values[ind]*dimFactor;
350 oaParam.
error_ = errors[ind]*dimFactor;
352 oaParam.
name_ = names[ind];
362 std::cout <<
"WARNING FOR NOW: sizes of extra parameters (names, dimType, value, quality) do" 363 <<
" not match! Did not add " << nObjects <<
" item to OpticalAlignments." 368 std::cout <<
" CocoaAnalyzer::ReadXML: Fill measurements with read parameters " << std::endl;
371 if ( measNames.size() == measTypes.size() ) {
372 for (
size_t ind = 0; ind < measNames.size(); ++ind ) {
374 oaMeas.
name_ = measNames[ind];
375 oaMeas.
type_ = measTypes[ind];
377 if( measParamNames.size() == measParamValues.size() && measParamValues.size() == measParamSigmas.size() ) {
378 for(
size_t ind2 = 0; ind2 < measParamNames[oaMeas.
name_].size(); ind2++ ){
379 oaParam.
name_ = measParamNames[oaMeas.
name_][ind2];
380 oaParam.
value_ = measParamValues[oaMeas.
name_][ind2];
381 oaParam.
error_ = measParamSigmas[oaMeas.
name_][ind2];
382 if( oaMeas.
type_ ==
"SENSOR2D" || oaMeas.
type_ ==
"COPS" || oaMeas.
type_ ==
"DISTANCEMETER" || oaMeas.
type_ ==
"DISTANCEMETER!DIM" || oaMeas.
type_ ==
"DISTANCEMETER3DIM" ) {
384 }
else if( oaMeas.
type_ ==
"TILTMETER" ) {
387 std::cerr <<
"CocoaAnalyzer::ReadXMLFile. Invalid measurement type: " << oaMeas.
type_ << std::endl;
391 oaMeas.
values_.push_back( oaParam );
401 std::cout <<
"WARNING FOR NOW: sizes of measurement parameters (name, value, sigma) do" 402 <<
" not match! for measurement " << oaMeas.
name_ <<
" !Did not fill parameters for this measurement " << std::endl;
407 std::cout <<
"CocoaAnalyser: MEASUREMENT " << oaMeas.
name_ <<
" extra entries read " << oaMeas << std::endl;
414 std::cout <<
"WARNING FOR NOW: sizes of measurements (names, types do" 415 <<
" not match! Did not add " << nObjects <<
" item to XXXMeasurements" 429 std::cout <<
"CocoaAnalyzer::ReadXML: Finished building " << nObjects+1 <<
" OpticalAlignInfo objects" <<
" and " <<
measList_.
oaMeasurements_.size() <<
" OpticalAlignMeasurementInfo objects " << std::endl;
442 std::cout<< std::endl <<
"$$$ CocoaAnalyzer::ReadCalibrationDB: " << std::endl;
451 std::vector<OpticalAlignInfo>::const_iterator it;
453 std::cout<<
"CocoaAnalyzer::ReadCalibrationDB: OpticalAlignInfo READ "<< *it << std::endl;
469 std::cout<< std::endl<<
"$$$ CocoaAnalyzer::CorrectOptAlignments: " << std::endl;
472 std::vector<OpticalAlignInfo>::const_iterator it;
473 for( it=oaListCalib.begin();it!=oaListCalib.end(); ++it ){
476 std::cerr <<
"error " << (*it).name_ << std::endl;
477 if( oaInfoXML == 0 ) {
479 std::cerr <<
"@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: OpticalAlignInfo read from DB is not present in XML "<< *it << std::endl;
484 std::cout <<
"CocoaAnalyzer::CorrectOptAlignments: correcting data from DB info " << std::endl;
492 std::vector<OpticalAlignParam>::iterator itoap1, itoap2;
493 std::vector<OpticalAlignParam> extraEntDB = oaInfoDB.
extraEntries_;
494 std::vector<OpticalAlignParam>* extraEntXML = &(oaInfoXML->
extraEntries_);
495 for( itoap1 = extraEntDB.begin(); itoap1 != extraEntDB.end(); ++itoap1 ){
498 std::string oaName = (*itoap1).name_.substr( 1, (*itoap1).name_.size()-2 );
499 for( itoap2 = extraEntXML->begin(); itoap2 != extraEntXML->end(); ++itoap2 ){
500 if( oaName == (*itoap2).name_ ) {
506 if( !pFound && oaName !=
"None" ) {
508 std::cerr <<
"@@@@@ WARNING CocoaAnalyzer::CorrectOptAlignments: extra entry read from DB is not present in XML "<< *itoap1 <<
" in object " << *it << std::endl;
514 std::cout <<
"CocoaAnalyzer::CorrectOptAlignments: corrected OpticalAlingInfo " <<
oaList_ << std::endl;
527 std::vector<OpticalAlignInfo>::iterator it;
532 std::cout <<
"CocoaAnalyzer::FindOpticalAlignInfoXML: looking for OAI " << (*it).name_ <<
" =? " << oaName << std::endl;
534 if( (*it).name_ == oaName ) {
537 std::cout <<
"CocoaAnalyzer::FindOpticalAlignInfoXML: OAI found " << oaInfoXML->
name_ << std::endl;
551 std::cout <<
"CocoaAnalyzer::CorrectOaParam old value= " << oaParamXML->
value_ <<
" new value= " << oaParamDB.
value_ << std::endl;
553 if( oaParamDB.
value_ == -9.999E9 )
return false;
555 double dimFactor = 1.;
558 if( type ==
"centre" || type ==
"length" ) {
560 }
else if ( type ==
"angles" || type ==
"angle" || type ==
"nodim" ){
563 std::cerr <<
"!!! COCOA programming error: inform responsible: incorrect OpticalAlignParam type = " << type << std::endl;
663 const size_t& vecInd ) {
666 if ( val.
doubles().size() > vecInd ) {
670 std::cout <<
"WARNING: OUT OF BOUNDS RETURNING 0 for index " << vecInd <<
" of SpecPar " << spName << std::endl;
679 const size_t& vecInd ) {
682 if ( val.
strings().size() > vecInd ) {
686 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
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_
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
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.
T const * product() const
std::vector< OpticalAlignInfo > ReadCalibrationDB(const edm::EventSetup &evts)
OpticalAlignments oaList_
const std::string & name() const
Returns the name.
bool CorrectOaParam(OpticalAlignParam *oaParamXML, const OpticalAlignParam &oaParamDB)