CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MeasurementCOPS.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 // Id: Measurement.C
3 // CAT: Model
4 // ---------------------------------------------------------------------------
5 // History: v1.0
6 // Authors:
7 // Pedro Arce
8 
12 #ifdef COCOA_VIS
13 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
14 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
15 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
16 #endif
17 
18 #include <iostream>
19 #include <iomanip>
20 #include <cstdlib>
21 
22 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
23 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
24 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
26 {
27 
28  if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this ); // important for Examples/FakeMeas
29 
30  //---------- Create light ray
31  LightRay* lightray = new LightRay;
32 
33  //---------- Define types of OptO that may take part in the Measurement
34  ALIuint isec = 0; //security variable to check OptOList().size()
35 
36  //---------- Loop list of OptO that take part in measurement
37  std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
38  if( ALIUtils::debug >= 5) std::cout << "OptOList size" <<OptOList().size() << std::endl;
39 
40  //----- Check that first object is 'Xlaser'
41  if( (*vocite)->type() != "Xlaser" ) {
42  std::cerr << "!!ERROR MeasurementCOPS: first Optical object should be 'Xlaser'" << std::endl;
44  exit(1);
45  }
46 
47  //---------- Check that last object is a COPS Sensor (that makes measuremnt and kill the lightray)
48  if( ( *(OptOList().end() -1) )->type() != "COPS" ) {
49  std::cerr << "!!ERROR MeasurementCOPS: last Optical object should be 'COPS'" << std::endl;
51  exit(1);
52  }
53 
54 #ifdef COCOA_VIS
55  ALIVisLightPath* vispath = 0;
56  if( ALIUtils::getFirstTime() ) {
58  if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
59  vispath = IgCocoaFileMgr::getInstance().newLightPath( name() );
60  }
61  }
62 #endif
63  std::cout << (vocite == OptOList().end()) << " vocite " << (*vocite)->name() << std::endl;
64  while( vocite != OptOList().end() ) {
65  if( ALIUtils::debug >= -2) std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;
66  isec ++;
67 
68  //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
69  ALIstring behav = getMeasuringBehaviour(vocite);
70 
71  if( lightray ) {
72  (*vocite)->participateInMeasurement( *lightray, *this, behav );
73 #ifdef COCOA_VIS
74  if( ALIUtils::getFirstTime() ) {
76  if(gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
77  ALIVRMLMgr::getInstance().addLightPoint( lightray->point());
78  // std::cout << "ALIVRMLMg addLightPoint " << lightray->point() << (*vocite)->name() << std::endl;
79  }
80  if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
81  vispath->addLightPoint( lightray->point(), *vocite );
82  }
83  }
84 #endif
85  } else {
86  std::cerr << "!! Last object is not Sensor 2D in measurement " << name() << std::endl;
88  exit(1);
89  }
90 
91  vocite++;
92  if ( isec > OptOList().size() ) {
93  std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
94  exit(5);
95  }
96  }
97 
98 
99  if(ALIUtils::debug >= 9) std::cout << "end calculateSimulatedValue" <<std::endl;
100 
101  delete lightray;
102 }
103 
104 
105 
106 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
107 //@@ You input 8 numbers after 'TILMETER':
108 //@@
109 //@@ set the conversion factor from mV to mrad and the pedestal
110 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
111 void MeasurementCOPS::setConversionFactor( const std::vector<ALIstring>& wordlist )
112 {
113  //--------- Set it to 0
114  ALIuint ii;
115  for( ii = 0; ii < dim(); ii++) {
116  theDisplace[ii] = 0.;
117  }
118 
119  //--------- Check that the format is OK
120  if(wordlist.size() == 1) return;
121  if( wordlist.size() != 3
122  || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[2])
123  || !ALIUtils::IsNumber(wordlist[3]) || !ALIUtils::IsNumber(wordlist[4]) ) {
124  std::cerr << "!! SensorCOPS Measurement setConversionFactor: WRONG FORMAT "<< std::endl
125  << "It should be: SENSOR2D displace_U displace_D displace_L displace_R " << std::endl
126  << "It is: ";
127  ALIUtils::dumpVS( wordlist, " ", std::cerr );
128  exit(1);
129  }
130 
131  for( ii = 0; ii < dim(); ii++) {
132  theDisplace[ii] = atof(wordlist[ii+1].c_str())* valueDimensionFactor();
133  }
134 
135 }
136 
137 
138 
140 {
141  //---------- Make displacement
142  ALIuint ii;
143  for( ii = 0; ii < dim(); ii++) {
144  ALIdouble val = value()[ii];
145  val += theDisplace[ii];
146  if(ALIUtils::debug >= 9) std::cout << "MeasurementCOPS::correctValueAndSigma: old value X " << value()[ii] << " new " << val << " +- " << std::endl;
147  setValue( ii, val );
148  }
149 
150 }
151 
long double ALIdouble
Definition: CocoaGlobals.h:11
virtual const ALIdouble valueDimensionFactor() const
Definition: Measurement.h:144
const ALIuint dim() const
Definition: Measurement.h:82
virtual void calculateSimulatedValue(ALIbool firstTime)
std::vector< OpticalObject * > & OptOList()
Definition: Measurement.h:109
void setValue(ALIint coor, ALIdouble val)
Definition: Measurement.h:167
static ALIint debug
Definition: ALIUtils.h:35
static GlobalOptionMgr * getInstance()
ALIstring getMeasuringBehaviour(const std::vector< OpticalObject * >::const_iterator vocite)
Definition: Measurement.cc:591
void DumpBadOrderOptOs()
Definition: Measurement.cc:487
bool ALIbool
Definition: CocoaGlobals.h:19
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:34
bool firstTime
Definition: QTestHandle.cc:18
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:52
#define end
Definition: vmac.h:38
virtual void setConversionFactor(const std::vector< ALIstring > &wordlist)
virtual void correctValueAndSigma()
static ALIbool getFirstTime()
Definition: ALIUtils.h:100
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
Definition: ALIUtils.cc:501
ALIdouble theDisplace[4]
const ALIdouble * value() const
Definition: Measurement.h:125
const ALIstring & type() const
Definition: Measurement.h:86
std::string ALIstring
Definition: CocoaGlobals.h:9
void printStartCalculateSimulatedValue(const Measurement *meas)
Definition: Measurement.cc:444
const ALIstring & name() const
Definition: Measurement.h:90
tuple cout
Definition: gather_cfg.py:121
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
tuple size
Write out results.
unsigned int ALIuint
Definition: CocoaGlobals.h:17