26 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h" 27 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h" 45 : theDim(measdim), theType(
type), theName(
name) {
63 std::vector<ALIstring> wordlist;
70 std::cout <<
"@@@@ Reading Measurement " <<
name() <<
" TYPE= " <<
type() << std::endl <<
" MEASURED OPTO NAMES: ";
71 std::ostream_iterator<ALIstring> outs(
std::cout,
" ");
72 copy(wordlist.begin(), wordlist.end(), outs);
77 for (
unsigned int ii = 0;
ii <
dim();
ii++) {
92 std::vector<std::string>::const_iterator
site;
93 std::vector<ALIstring> wordlist;
95 for (
site = objNames.begin();
site != objNames.end(); ++
site) {
96 if (
site != objNames.begin())
97 wordlist.push_back(
"&");
98 wordlist.push_back(*
site);
103 std::cout <<
"@@@@ Reading Measurement " <<
name() <<
" TYPE= " <<
type() <<
" " << measInfo << std::endl
104 <<
" MEASURED OPTO NAMES: ";
112 for (
unsigned int ii = 0;
ii <
dim();
ii++) {
114 wordlist.push_back((measInfo.
values_)[
ii].name_);
118 std::cout <<
"Measurement::constructFromOA: meas value " <<
ii <<
" " <<
dim() <<
" = simulated_value" 121 wordlist.push_back(
"simulated_value");
124 std::cout <<
"Measurement::constructFromOA: meas value " <<
ii <<
" " <<
dim() <<
" = " 125 << measInfo.
values_.size() << std::endl;
131 wordlist.push_back(ctmp);
137 wordlist.push_back(ctmp);
175 int NPairs = (
wl.size() + 1) / 2;
178 for (
int ii = 0;
ii < NPairs;
ii++) {
183 std::cerr <<
"!!! Measured Optical Objects should be separated by '&', not by" <<
wl[2 *
ii + 1] << std::endl;
194 std::cout <<
"@@ Filling coordinate " << coor << std::endl;
202 if (wordlist.size() != 3) {
204 std::cerr <<
" Incorrect format for Measurement value:" << std::endl;
205 std::ostream_iterator<ALIstring> outs(
std::cout,
" ");
206 copy(wordlist.begin(), wordlist.end(), outs);
207 std::cout << std::endl <<
"There should be three words: name value sigma " << std::endl;
214 std::cerr <<
"Trying to fill Measurement coordinate No " << coor <<
" but the dimension is " <<
theDim << std::endl;
227 if (wordlist[1] ==
ALIstring(
"simulated_value")) {
231 std::cerr <<
"!!! parameter for value not found: " << wordlist[1].c_str() << std::endl;
238 val = atof(wordlist[1].c_str());
249 std::cerr <<
"!!! parameter for sigma not found: " << wordlist[2].c_str() << std::endl;
255 sig = atof(wordlist[2].c_str());
269 std::cout <<
"@@ Filling coordinate " << coor << std::endl;
276 std::cerr <<
"Trying to fill Measurement coordinate No " << coor <<
" but the dimension is " <<
theDim << std::endl;
294 sig = oaParam->
sigma();
310 std::vector<ALIstring>::iterator vsite;
317 int i2p = (*vsite).find_first_of(twopoints, 3 *
ii);
321 std::cerr << i2p <<
"!!! Bad position of '..' in reference ALIstring: " << (*vsite).c_str() << std::endl;
331 if (Ntwopoints != 0) {
337 ALIint colon = referenceOptO.find(
':');
340 std::cout <<
"colon in reference OptO name " << colon << referenceOptO.c_str() << std::endl;
342 referenceOptO = referenceOptO.substr(0, colon);
346 std::cout <<
"Measurement::buildOptOList: OptO in Measurement: " << OptOitem->
name() << std::endl;
350 std::cerr <<
"!!! Error in Measurement: can't find Optical Object " << (*vsite).c_str() << std::endl;
362 std::vector<OpticalObject*>::const_iterator vocite;
374 std::cout <<
"Measurement::addAffectingEntriesFromOptO: OptO taking part in Measurement: " << optoP->
name()
377 std::vector<Entry*>::const_iterator vecite;
378 std::vector<Entry*>::const_iterator fvecite;
387 std::cout <<
"Entry that may affect Measurement: " << (*vecite)->name() << std::endl;
395 std::cout <<
"Entry that may affect Measurement: " << (*vecite)->name() << std::endl;
398 if (optoP->
parent() !=
nullptr) {
410 int pos1st = firstref.length();
412 for (
int ii = 0;
ii < Ntwopoints;
ii++) {
413 pos1st = firstref.find_last_of(
slash, pos1st - 1);
419 std::cout <<
"before change ref: " << ref <<
" 1ref " << firstref << std::endl;
421 ref.replace(0, (Ntwopoints * 3) - 1, firstref, 0, pos1st);
423 std::cout <<
"after change ref: " << ref <<
" 1ref " << firstref << std::endl;
429 <<
"@@@ Start calculation of simulated value of " << meas->
type() <<
" Measurement " << meas->
name()
444 ALIVRMLMgr::getInstance().newLightRay();
470 std::cerr <<
" Detector can not make measurement with these optical objects " << std::endl;
477 std::vector<ALIstring>::const_iterator vsite;
491 std::vector<ALIdouble> deriv;
500 <<
"%%% Derivative w.r.t. entry " <<
entry->name() <<
": displacement = " << displacement << std::endl;
507 entry->displace(displacement);
510 std::cout <<
"Get simulated value for displacement " << displacement << std::endl;
518 std::cout <<
"iteration " << count_itera <<
" COOR " <<
ii <<
" difference =" 522 << displacement <<
" sum derivatives = " << sumderiv << std::endl;
529 if (count_itera >= 100) {
530 std::cerr <<
"EXITING: too many iterations in derivative, displacement is " << displacement
531 <<
" sum of derivatives is " << sumderiv << std::endl;
546 <<
"### DERIVATIVE: " << deriv[
ii] << std::endl;
551 entry->OptOCurrent()->resetGlobalCoordinates();
569 std::vector<ALIstring>::const_iterator vscite =
571 ALIint colon = (*vscite).find(
':');
574 behav = (*vscite).substr(colon + 1, (*vscite).size());
586 std::vector<OpticalObject*>::const_iterator vocite;
588 if (*vocite == Popto) {
590 std::cerr <<
" ERROR in getPreviousOptO of measurement " <<
name() << std::endl;
591 std::cerr <<
" OptO " << Popto->
name() <<
" is the first one " << std::endl;
594 return *(vocite - 1);
599 std::cerr <<
" ERROR in getPreviousOptO of measurement " <<
name() << std::endl;
600 std::cerr <<
" OptO " << Popto->
name() <<
" not found " << std::endl;
606 if (
wl.size() != 3) {
607 std::cerr <<
"!!!EXITING: reading DATE of measurements set: it must have three words, it is though " << std::endl;
610 }
else if (
wl[0] !=
"DATE:") {
611 std::cerr <<
"!!!EXITING: reading DATE of measurements set: first word must be 'DATE:', it is though " << std::endl;
642 std::vector<std::string> wordlist;
644 ALIuint nOptos = optolist.size();
648 if (
ii != nOptos - 1)
649 wordlist.push_back(
"&");
655 std::cout <<
"@@@@ Reading Measurement " <<
name() <<
" TYPE= " <<
type() << std::endl <<
" MEASURED OPTO NAMES: ";
656 std::ostream_iterator<ALIstring> outs(
std::cout,
" ");
657 copy(wordlist.begin(), wordlist.end(), outs);
671 <<
" !!! Error in your code, you cannot ask for the name of the Measurement before the OptONameList is build " 675 std::vector<ALIstring>::iterator vsite = (
_OptONameList.end() - 1);
static ALIstring theCurrentTime
ALIdouble * theValueSimulated
const ALIdouble valueSimulated_orig(ALIuint ii) const
std::vector< ALIdouble > DerivativeRespectEntry(Entry *entry)
static ALIFileIn & getInstance(const ALIstring &name)
bool valueIsSimulated(ALIint coor)
std::vector< ALIstring > _OptONameList
const ALIdouble * value() const
const OpticalObject * getPreviousOptO(const OpticalObject *Popto) const
std::vector< OpticalObject * > _OptOList
const ALIuint dim() const
void Substitute2p(ALIstring &ref, const ALIstring &firstref, int NtwoPoints)
const std::vector< ALIstring > & OptONameList() const
void setValue(ALIint coor, ALIdouble val)
static ALIdouble getMaximumDeviationDerivative()
static ParameterMgr * getInstance()
std::vector< std::string > measObjectNames_
void buildAffectingEntryList()
static OpticalObject * getOptOByName(const ALIstring &opto_name)
--— Find an OptO name in theOptOList and return a pointer to it
ALIstring getMeasuringBehaviour(const std::vector< OpticalObject *>::const_iterator vocite)
static ALIstring & SDFName()
the name of the System Description File
const ALIstring & name() const
static ALIstring only1Time
static GlobalOptionMgr * getInstance()
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual void calculateSimulatedValue(ALIbool firstTime)
const std::vector< Entry * > & ExtraEntryList() const
virtual const ALIdouble valueDimensionFactor() const
ALIint getParameterValue(const ALIstring &name, ALIdouble &val)
void fillData(ALIuint coor, const std::vector< ALIstring > &wl)
static void addMeasurementToList(Measurement *measadd)
static int IsNumber(const ALIstring &str)
static ALIstring theCurrentDate
const ALIdouble valueSimulated(ALIuint ii) const
Abs< T >::type abs(const T &t)
void addAffectingEntriesFromOptO(const OpticalObject *optoP)
const std::vector< Entry * > & CoordinateEntryList() const
static ALIstring theMeasurementsFileName
ALIint getWordsInLine(std::vector< ALIstring > &wl)
std::vector< Entry * > theAffectingEntryList
static ALIdouble cameraScaleFactor
static std::string changeName(const std::string &oldName, const std::string &subsstr1, const std::string &subsstr2)
static ALIbool getFirstTime()
const ALIdouble * sigma() const
void calculateOriginalSimulatedValue()
const ALIstring & type() const
static void dumpVS(const std::vector< ALIstring > &wl, const std::string &msg, std::ostream &outs=std::cout)
dumps a vector of strings with a message to outs
ALIdouble * theValueSimulated_orig
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
void setValueSimulated_orig(ALIint coor, ALIdouble value)
void printStartCalculateSimulatedValue(const Measurement *meas)
std::vector< OpticalAlignParam > values_
const OpticalObject * parent() const
void constructFromOA(OpticalAlignMeasurementInfo &measInfo)
virtual void correctValueAndSigma()
virtual void buildOptONamesList(const std::vector< ALIstring > &wl)
static std::vector< Measurement * > & MeasurementList()
const std::vector< OpticalObject * > & OptOList() const
std::vector< bool > isSimulatedValue_
static ALIstring only1Date
ALIbool * theValueIsSimulated
void copyMeas(Measurement *meas, const std::string &subsstr1, const std::string &subsstr2)
static void setCurrentDate(const std::vector< ALIstring > &wl)
set the date of the current measurement
const ALIstring & name() const
virtual const ALIdouble sigmaDimensionFactor() const