25 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
26 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
45 : theDim(measdim), theType(type), theName( name )
68 std::vector<ALIstring> wordlist;
75 std::cout <<
"@@@@ Reading Measurement " <<
name() <<
" TYPE= " <<
type() << std::endl
76 <<
" MEASURED OPTO NAMES: ";
77 std::ostream_iterator<ALIstring> outs(
std::cout,
" ");
78 copy(wordlist.begin(), wordlist.end(), outs);
99 std::vector<std::string>::const_iterator site;
100 std::vector<ALIstring> wordlist;
102 for( site = objNames.begin(); site != objNames.end(); ++site) {
103 if( site != objNames.begin() ) wordlist.push_back(
"&");
104 wordlist.push_back(*site);
109 std::cout <<
"@@@@ Reading Measurement " <<
name() <<
" TYPE= " <<
type() <<
" " << measInfo << std::endl
110 <<
" MEASURED OPTO NAMES: ";
118 for (
unsigned int ii=0;
ii<
dim();
ii++){
120 wordlist.push_back( (measInfo.
values_)[
ii].name_ );
124 std::cout <<
"Measurement::constructFromOA: meas value " <<
ii <<
" " <<
dim() <<
" = simulated_value" << std::endl;
126 wordlist.push_back(
"simulated_value");
129 std::cout <<
"Measurement::constructFromOA: meas value " <<
ii <<
" " <<
dim() <<
" = " << measInfo.
values_.size() << std::endl;
132 gcvt( val, 10, ctmp );
133 wordlist.push_back( ctmp );
136 gcvt( err, 10, ctmp );
137 wordlist.push_back( ctmp );
138 std::cout <<
" sigma " << err <<
" = " << ctmp <<
" " << (measInfo.
values_)[
ii].error_ << std::endl;
180 int NPairs = (wl.size()+1)/2;
183 for (
int ii=0;
ii<NPairs;
ii++ ) {
186 if (ii != NPairs-1 && wl[2*ii+1] !=
ALIstring(
"&") ) {
188 std::cerr <<
"!!! Measured Optical Objects should be separated by '&', not by"
189 << wl[2*ii+1] << std::endl;
203 std::cout <<
"@@ Filling coordinate " << coor << std::endl ;
211 if( wordlist.size() != 3 ) {
213 std::cerr <<
" Incorrect format for Measurement value:" << std::endl;
214 std::ostream_iterator<ALIstring> outs(
std::cout,
" ");
215 copy(wordlist.begin(), wordlist.end(), outs);
216 std::cout << std::endl <<
"There should be three words: name value sigma " << std::endl;
223 std::cerr <<
"Trying to fill Measurement coordinate No "
224 << coor <<
" but the dimension is " <<
theDim << std::endl;
237 if( wordlist[1] ==
ALIstring(
"simulated_value") ) {
241 std::cerr <<
"!!! parameter for value not found: " << wordlist[1].c_str() << std::endl;
248 val = atof( wordlist[1].c_str() );
258 std::cerr <<
"!!! parameter for sigma not found: " << wordlist[2].c_str() << std::endl;
264 sig = atof( wordlist[2].c_str() );
280 std::cout <<
"@@ Filling coordinate " << coor << std::endl ;
287 std::cerr <<
"Trying to fill Measurement coordinate No "
288 << coor <<
" but the dimension is " <<
theDim << std::endl;
296 val = oaParam->
value();
305 sig = oaParam->
sigma();
322 std::vector<ALIstring>::iterator vsite;
330 int i2p = (*vsite).find_first_of( twopoints, 3*ii );
331 if ( i2p < 0 )
break;
332 if ( i2p !=
ALIint(3*ii)) {
333 std::cerr << i2p <<
"!!! Bad position of '..' in reference ALIstring: "
334 << (*vsite).c_str() << std::endl;
343 if (Ntwopoints != 0) {
349 ALIint colon = referenceOptO.find(
':');
352 std::cout <<
"colon in reference OptO name " << colon <<
353 referenceOptO.c_str() << std::endl;
355 referenceOptO = referenceOptO.substr( 0, colon );
362 std::cerr <<
"!!! Error in Measurement: can't find Optical Object " <<
363 (*vsite).c_str() << std::endl;
377 std::vector< OpticalObject* >::const_iterator vocite;
391 if(
ALIUtils::debug >= 3)
std::cout <<
"Measurement::addAffectingEntriesFromOptO: OptO taking part in Measurement: " << optoP->
name() << std::endl;
393 std::vector< Entry* >::const_iterator vecite;
394 std::vector< Entry* >::const_iterator fvecite;
414 if(optoP->
parent() != 0) {
428 int pos1st = firstref.length();
430 for (
int ii=0;
ii < Ntwopoints;
ii++) {
431 pos1st = firstref.find_last_of( slash, pos1st-1);
437 ref.replace( 0, (Ntwopoints*3)-1, firstref, 0, pos1st);
446 std::cout << std::endl <<
"@@@ Start calculation of simulated value of " << meas->
type() <<
" Measurement " << meas->
name() << std::endl;
461 ALIVRMLMgr::getInstance().newLightRay();
489 std::cerr <<
" Detector can not make measurement with these optical objects " << std::endl;
496 std::vector<ALIstring>::const_iterator vsite;
514 std::vector<ALIdouble> deriv;
521 if(
ALIUtils::debug >= 3)
std::cout << std::endl <<
"%%% Derivative w.r.t. entry " << entry->
name() <<
": displacement = " << displacement << std::endl;
538 std::cout <<
"iteration " << count_itera <<
" COOR " << ii
542 <<
" sum derivatives = " << sumderiv << std::endl;
548 if (count_itera >= 100) {
549 std::cerr <<
"EXITING: too many iterations in derivative, displacement is " <<
550 displacement <<
" sum of derivatives is " << sumderiv << std::endl;
592 std::vector<ALIstring>::const_iterator vscite =
_OptONameList.begin() +
594 ALIint colon = (*vscite).find(
':');
597 behav = (*vscite).substr(colon+1,(*vscite).size());
611 std::vector<OpticalObject*>::const_iterator vocite;
613 if( *vocite == Popto ) {
615 std::cerr <<
" ERROR in getPreviousOptO of measurement " <<
name() << std::endl;
616 std::cerr <<
" OptO " << Popto->
name() <<
" is the first one " << std::endl;
624 std::cerr <<
" ERROR in getPreviousOptO of measurement " <<
name() << std::endl;
625 std::cerr <<
" OptO " << Popto->
name() <<
" not found " << std::endl;
634 if( wl.size() != 3 ){
635 std::cerr <<
"!!!EXITING: reading DATE of measurements set: it must have three words, it is though " << std::endl;
638 }
else if(wl[0] !=
"DATE:" ){
639 std::cerr <<
"!!!EXITING: reading DATE of measurements set: first word must be 'DATE:', it is though " << std::endl;
663 for(ii = 0; ii <
theDim; ii++) {
671 std::vector<std::string> wordlist;
673 ALIuint nOptos = optolist.size();
674 for (
ALIuint ii = 0; ii < nOptos; ii++ ) {
677 if( ii != nOptos -1 ) wordlist.push_back(
"&");
683 std::cout <<
"@@@@ Reading Measurement " <<
name() <<
" TYPE= " <<
type() << std::endl
684 <<
" MEASURED OPTO NAMES: ";
685 std::ostream_iterator<ALIstring> outs(
std::cout,
" ");
686 copy(wordlist.begin(), wordlist.end(), outs);
702 std::cerr <<
" !!! Error in your code, you cannot ask for the name of the Measurement before the OptONameList is build " << std::endl;
705 std::vector<ALIstring>::iterator vsite = (
_OptONameList.end()-1);
static ALIstring theCurrentTime
virtual const ALIdouble sigmaDimensionFactor() const
ALIdouble * theValueSimulated
void resetGlobalCoordinates()
std::vector< ALIdouble > DerivativeRespectEntry(Entry *entry)
virtual const ALIdouble valueDimensionFactor() const
static ALIFileIn & getInstance(const ALIstring &name)
bool valueIsSimulated(ALIint coor)
std::vector< ALIstring > _OptONameList
const ALIuint dim() const
std::vector< OpticalObject * > _OptOList
const std::vector< Entry * > & ExtraEntryList() const
void Substitute2p(ALIstring &ref, const ALIstring &firstref, int NtwoPoints)
void setValue(ALIint coor, ALIdouble val)
static ALIdouble getMaximumDeviationDerivative()
static ParameterMgr * getInstance()
const std::vector< Entry * > & CoordinateEntryList() const
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
static ALIstring & SDFName()
the name of the System Description File
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)
ALIstring getMeasuringBehaviour(const std::vector< OpticalObject * >::const_iterator vocite)
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 * sigma() const
const OpticalObject * parent() const
const std::vector< ALIstring > & OptONameList() const
const ALIdouble valueSimulated_orig(ALIuint ii) const
void addAffectingEntriesFromOptO(const OpticalObject *optoP)
const ALIstring & name() const
const std::vector< OpticalObject * > & OptOList() const
static ALIstring theMeasurementsFileName
ALIint getWordsInLine(std::vector< ALIstring > &wl)
std::vector< Entry * > theAffectingEntryList
const OpticalObject * getPreviousOptO(const OpticalObject *Popto) const
static ALIdouble cameraScaleFactor
static std::string changeName(const std::string &oldName, const std::string &subsstr1, const std::string &subsstr2)
static ALIbool getFirstTime()
void calculateOriginalSimulatedValue()
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
const ALIdouble * value() const
const ALIstring & type() const
void setValueSimulated_orig(ALIint coor, ALIdouble value)
virtual ALIdouble startingDisplacement()
void printStartCalculateSimulatedValue(const Measurement *meas)
std::vector< OpticalAlignParam > values_
const ALIstring & name() const
const ALIdouble valueSimulated(ALIuint ii) const
const ALIstring & name() const
void constructFromOA(OpticalAlignMeasurementInfo &measInfo)
virtual void correctValueAndSigma()
virtual void buildOptONamesList(const std::vector< ALIstring > &wl)
OpticalObject * OptOCurrent() const
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
std::vector< bool > isSimulatedValue_
static ALIstring only1Date
ALIbool * theValueIsSimulated
void copyMeas(Measurement *meas, const std::string &subsstr1, const std::string &subsstr2)
static std::vector< Measurement * > & MeasurementList()
virtual void displace(ALIdouble disp)
static void setCurrentDate(const std::vector< ALIstring > &wl)
set the date of the current measurement