CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
DeviationsFromFileSensor2D Class Reference

#include <DeviationsFromFileSensor2D.h>

Public Member Functions

 DeviationsFromFileSensor2D ()
 
std::pair< ALIdouble, ALIdoublegetDevis (ALIdouble intersX, ALIdouble intersY)
 
void readFile (ALIFileIn &ifdevi)
 
void setOffset (ALIdouble offX, ALIdouble offY)
 
 ~DeviationsFromFileSensor2D ()
 

Static Public Member Functions

static const ALIbool apply ()
 
static void setApply (ALIbool val)
 

Private Attributes

bool firstScanDir
 
vvd theDeviations
 
ALIuint theNPoints
 
ALIdouble theOffsetX
 
ALIdouble theOffsetY
 
int theScanSenseX
 
int theScanSenseY
 
ALIint verbose
 

Static Private Attributes

static ALIbool theApply = true
 

Detailed Description

Definition at line 24 of file DeviationsFromFileSensor2D.h.

Constructor & Destructor Documentation

DeviationsFromFileSensor2D::DeviationsFromFileSensor2D ( )
inline

Definition at line 29 of file DeviationsFromFileSensor2D.h.

References theOffsetX, and theOffsetY.

29  {
30  theOffsetX = 0.;
31  theOffsetY = 0.;
32  };
DeviationsFromFileSensor2D::~DeviationsFromFileSensor2D ( )
inline

Definition at line 33 of file DeviationsFromFileSensor2D.h.

33 { };

Member Function Documentation

static const ALIbool DeviationsFromFileSensor2D::apply ( )
inlinestatic

Definition at line 48 of file DeviationsFromFileSensor2D.h.

References theApply.

Referenced by heavyIonTools.ConfigureHeavyIons::__call__(), editorTools.UserCodeTool::__call__(), HiCoreTools.RestrictInputToAOD::__call__(), coreTools.RunOnData::__call__(), trackTools.MakeAODTrackCandidates::__call__(), metTools.AddMETCollection::__call__(), heavyIonTools.ProductionDefaults::__call__(), editorTools.ChangeSource::__call__(), jetTools.AddJetCollection::__call__(), HiCoreTools.RemoveMCMatching::__call__(), cmsswVersionTools.PickRelValInputFiles::__call__(), coreTools.RemoveMCMatching::__call__(), trackTools.MakePATTrackCandidates::__call__(), trigTools.SwitchOnTrigger::__call__(), heavyIonTools.SelectionDefaults::__call__(), HiCoreTools.RemoveAllPATObjectsBut::__call__(), heavyIonTools.DisbaleMonteCarloDeps::__call__(), HiCoreTools.RemoveSpecificPATObjects::__call__(), trigTools.SwitchOnTriggerStandAlone::__call__(), trackTools.MakeTrackCandidates::__call__(), tauTools.AddTauCollection::__call__(), trigTools.SwitchOnTriggerMatching::__call__(), HiCoreTools.RemoveCleaning::__call__(), HiCoreTools.AddCleaning::__call__(), trigTools.SwitchOnTriggerMatchingStandAlone::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.AddJetID::__call__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.SetTagInfos::__call__(), metUncertaintyTools.RunMEtUncertainties::__call__(), OptOSensor2D::detailedTraversesLightRay(), and OptOSensor2D::fastTraversesLightRay().

48  {
49  return theApply;
50  }
std::pair< ALIdouble, ALIdouble > DeviationsFromFileSensor2D::getDevis ( ALIdouble  intersX,
ALIdouble  intersY 
)

Definition at line 138 of file DeviationsFromFileSensor2D.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, alignCSCRings::e, cmsRelvalreport::exit, cuy::ii, DeviationSensor2D::posX(), funct::pow(), mathSSE::sqrt(), theDeviations, theNPoints, theOffsetX, theOffsetY, theScanSenseX, and theScanSenseY.

139 {
140  //intersX += 10000;
141  //intersY += 10000;
142  if(verbose >= 4) std::cout << " entering getdevis " << intersX << " " <<intersY << " " << this << std::endl;
143  vvd::iterator vvdite;
144  vd::iterator vdite;
145 
146  // assume scan is in Y first, else revers intersection coordinates
147 /* if( !firstScanDirY ) {
148  ALIdouble tt = intersY;
149  intersY = intersX;
150  intersX = tt;
151  }
152 */
153 
154  //---------- look which point in the deviation matrices correspond to intersX,Y
155  //----- Look for each column, between which rows intersY is
156  //assume first dir is Y
157  unsigned int* yrows = new unsigned int[ theNPoints ];
158 
159  unsigned int ii = 0;
160  ALIbool insideMatrix = 0;
161  for( vvdite = theDeviations.begin(); vvdite != (theDeviations.end()-1); vvdite++ ){
162  for( vdite = (*vvdite).begin(); vdite != ((*vvdite).end()-1); vdite++ ){
163  if( verbose >= 5 ) std::cout << " check posy " << (*(vdite))->posY() << " " << (*(vdite+1))->posY() << " " << (*(vdite)) << std::endl;
164  // if posy is between this point and previous one
165 
166  //- std::cout << "intersy" << intersY << " " << (*(vdite))->posY() << std::endl;
167 
168  if( (intersY - (*(vdite))->posY() )*theScanSenseY > 0
169  && (intersY - (*(vdite+1))->posY() )*theScanSenseY < 0 ) {
170  //-std::cout << " ii " << ii << std::endl;
171  yrows[ii] = vdite - (*vvdite).begin();
172  if( verbose >= 3 ) std::cout << intersY << " DeviationsFromFileSensor2D yrows " << ii << " " << yrows[ii] << " : " << (*(vdite))->posY() << std::endl;
173  insideMatrix = 1;
174  break;
175  }
176  }
177  ii++;
178  }
179  if(insideMatrix == 0) {
180  std::cerr << "!!EXITING intersection in Y outside matrix of deviations from file " << intersY << std::endl;
181  exit(1);
182  }
183  insideMatrix = 0;
184 
185  vd thePoints;
186  thePoints.clear();
187  //----- For each row in 'yrows' look between which columns intersX is
188  unsigned int rn;
189  DeviationSensor2D *dev1,*dev2;
190  for( ii = 0; ii < theNPoints-1; ii++) {
191  rn = yrows[ii];
192  //- std::cout << ii << " rn " << rn << std::endl;
193  dev1 = (*(theDeviations.begin()+ii))[ rn ]; // column ii, row yrows[ii]
194  rn = yrows[ii+1];
195  dev2 = (*(theDeviations.begin()+ii+1))[ rn ]; // column ii+1, row yrows[ii+1]
196  if( (intersX - dev1->posX() )*theScanSenseX > 0
197  && (intersX - dev2->posX() )*theScanSenseX < 0) {
198  thePoints.push_back( dev1 );
199  thePoints.push_back( dev2 );
200  insideMatrix = 1;
201  if( verbose >= 3 ) std::cout << " column up " << ii << " " << dev1->posX() << " " << dev2->posX() << " : " << intersX << std::endl;
202  }
203 
204  rn = yrows[ii] + 1;
205  if(rn == theNPoints) rn = theNPoints-1;
206  dev1 = (*(theDeviations.begin()+ii))[ rn ]; // column ii, row yrows[ii]+1
207  rn = yrows[ii+1] + 1;
208  if(rn == theNPoints) rn = theNPoints-1;
209  dev2 = (*(theDeviations.begin()+ii+1))[ rn ]; // column ii+1, row yrows[ii+1]+1
210  if( (intersX - dev1->posX() )*theScanSenseX > 0
211  && (intersX - dev2->posX() )*theScanSenseX < 0) {
212  thePoints.push_back( dev1 );
213  thePoints.push_back( dev2 );
214  if( verbose >= 3 ) std::cout << " column down " << ii << " " << dev1->posX() << " " << dev2->posX() << " : " << intersX << std::endl;
215  }
216 
217  if( thePoints.size() == 4 ) break;
218 
219  }
220 
221  if(insideMatrix == 0) {
222  std::cerr << "!!EXITING intersection in X outside matrix of deviations from file " << intersX << std::endl;
223  exit(1);
224  }
225 
226  //----------- If loop finished and not 4 points, point is outside scan bounds
227 
228  //----- calculate deviation in x and y interpolating between four points
229  ALIdouble dist, disttot=0, deviX=0, deviY=0;
230 
231  if( verbose >= 4) std::cout << " thepoints size " << thePoints.size() << std::endl;
232 
233  for( ii = 0; ii < 4; ii++) {
234  dist = sqrt( pow(thePoints[ii]->posX() - intersX, 2 ) + pow(thePoints[ii]->posY() - intersY, 2 ) );
235  disttot += 1./dist;
236  deviX += thePoints[ii]->devX()/dist;
237  deviY += thePoints[ii]->devY()/dist;
238  if( verbose >= 4 ) {
239  //t std::cout << ii << " point " << *thePoints[ii] << std::endl;
240  std::cout << ii << " distances: " << dist << " " << deviX << " " << deviY << " devX " << thePoints[ii]->devX() << " devY " << thePoints[ii]->devY() << std::endl;
241  }
242  }
243  deviX /= disttot;
244  deviY /= disttot;
245 
246  // add offset
247  deviX += theOffsetX;
248  deviY += theOffsetY;
249  if( verbose >= 4 ) {
250  std::cout << " devisX/Y: " << deviX << " " << deviY
251  << " intersX/Y " << intersX << " " << intersY << std::endl;
252  }
253 
254  //change sign!!!!!?!?!?!?!?!
255  deviX *= -1;
256  deviY *= -1;
257  return std::pair< ALIdouble, ALIdouble>( deviX*1.e-6, deviY*1e-6 ); // matrix is in microrad
258 
259 }
long double ALIdouble
Definition: CocoaGlobals.h:11
int ii
Definition: cuy.py:588
bool ALIbool
Definition: CocoaGlobals.h:19
std::vector< DeviationSensor2D * > vd
T sqrt(T t)
Definition: SSEVec.h:48
const ALIdouble & posX()
tuple cout
Definition: gather_cfg.py:121
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void DeviationsFromFileSensor2D::readFile ( ALIFileIn ifdevi)

Definition at line 19 of file DeviationsFromFileSensor2D.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, ALIUtils::dumpVS(), ALIFileIn::eof(), cmsRelvalreport::exit, DeviationSensor2D::fillData(), firstScanDir, ALIFileIn::getWordsInLine(), ALIFileIn::name(), DeviationSensor2D::posX(), DeviationSensor2D::posY(), mathSSE::sqrt(), theDeviations, theNPoints, theScanSenseX, theScanSenseY, xdir, and ydir.

Referenced by Vispa.Plugins.EventBrowser.EventBrowserTabController.EventBrowserTabController::navigate(), Vispa.Main.TabController.TabController::open(), and Vispa.Main.TabController.TabController::refresh().

20 {
22  // verbose = 4;
23  if( verbose >= 3) std::cout << "DeviationsFromFileSensor2D::readFile " << this << ifdevi.name() << std::endl;
24 
25  theScanSenseX = 0;
26  theScanSenseY = 0;
27 
28  ALIuint nl = 1;
29 
30  ALIdouble oldposX=0, oldposY=0;
31  vd vcol;
32  std::vector<ALIstring> wl;
33  /* //------ first line with dimension factors //now with global option
34  ifdevi.getWordsInLine( wl );
35  if( wl[0] != "DIMFACTOR:" || wl.size() != 3) {
36  std::cerr << "Error reading sensor2D deviation file " << ifdevi.name() << std::endl
37  << " first line has to be DIMFACTOR: 'posDimFactor' 'angDimFactor' " << std::endl;
38  ALIUtils::dumpVS( wl, " ");
39  exit(1);
40  }
41  ALIdouble posDimFactor = atof(wl[1].c_str());
42  ALIdouble angDimFactor = atof(wl[2].c_str());
43  */
44 
45  for(;;) {
46  ifdevi.getWordsInLine( wl );
47  if(ifdevi.eof() ) break;
48 
50  dev->fillData( wl );
51 
52  if(verbose >= 5) {
53  ALIUtils::dumpVS( wl, "deviation sensor2D", std::cout );
54  }
55 
56  //--- line 2 of data
57  if(nl == 2) {
58  //--------- get if scan is first in Y or X
60  if(verbose >= 3) std::cout << "firstScanDir " << firstScanDir << " " << dev->posX() << " " << oldposX << " " << dev->posY() << " " << oldposY << std::endl;
61  if( fabs( dev->posX() - oldposX ) > fabs( dev->posY() - oldposY ) ) {
62  std::cerr << "!!!EXITING first scan direction has to be Y for the moment " << ifdevi.name() << std::endl;
64  exit(1);
65  }
66  //-------- get sense of first scan direction
67  if(firstScanDir == ydir ){
68  if( dev->posY() > oldposY ) {
69  theScanSenseY = +1;
70  } else {
71  theScanSenseY = -1;
72  }
73  if( verbose >= 3 ) std::cout << " theScanSenseY " << theScanSenseY << std::endl;
74  }else {
75  if( dev->posX() > oldposX ) {
76  theScanSenseX = +1;
77  } else {
78  theScanSenseX = -1;
79  }
80  if( verbose >= 3 ) std::cout << " theScanSenseX " << theScanSenseX << std::endl;
81  }
82  }
83 
84  //- std::cout << "firstScanDir " << firstScanDir << " " << dev->posX() << " " << oldposX << " " << dev->posY() << " " << oldposY << std::endl;
85 
86  //------- check if change of row: clear current std::vector of column values
87  if( ( firstScanDir == ydir && ( dev->posY() - oldposY)*theScanSenseY < 0 )
88  || ( firstScanDir == xdir && ( dev->posX() - oldposX)*theScanSenseX < 0 )) {
89  theDeviations.push_back( vcol );
90  vcol.clear();
91 
92  //- std::cout << " theDevi size " << theDeviations.size() << " " << ifdevi.name() << std::endl;
93  //-------- get sense of second scan direction
94  if( theScanSenseY == 0 ) {
95  if( dev->posY() > oldposY ) {
96  theScanSenseY = +1;
97  } else {
98  theScanSenseY = -1;
99  }
100  }
101  if( theScanSenseX == 0 ) {
102  if( dev->posX() > oldposX ) {
103  theScanSenseX = +1;
104  } else {
105  theScanSenseX = -1;
106  }
107  }
108  if( verbose >= 3 ) std::cout << " theScanSenseX " << theScanSenseX << " theScanSenseY " << theScanSenseY << std::endl;
109  }
110 
111  oldposX = dev->posX();
112  oldposY = dev->posY();
113 
114  //--- fill deviation std::vectors
115  vcol.push_back( dev );
116  nl++;
117  }
118  theDeviations.push_back( vcol );
119 
120  //----- Calculate std::vector size
121  ALIdouble dvsiz = ( sqrt( ALIdouble(nl-1) ) );
122  //----- Check that it is a square of points (<=> vsiz is integer)
123  ALIuint vsiz = ALIuint(dvsiz);
124  if( vsiz != dvsiz ) {
125  if( ALIUtils::debug >= 0) std::cerr << "!!WARNING: error reading deviation file: number of X points <> number of Y points : Number of points in X " << dvsiz << " nl " << nl-1 << " file " << ifdevi.name() << std::endl;
126  // exit(1);
127  }
128  theNPoints = vsiz;
129 
130  if(verbose >= 4 ) {
131  std::cout << " Filling deviation from file: " << ifdevi.name() << " theNPoints " << theNPoints << std::endl;
132  }
133 
134 }
long double ALIdouble
Definition: CocoaGlobals.h:11
ALIbool eof()
Definition: ALIFileIn.cc:211
const ALIstring & name()
Definition: ALIFileIn.h:44
static ALIint debug
Definition: ALIUtils.h:35
std::vector< DeviationSensor2D * > vd
T sqrt(T t)
Definition: SSEVec.h:48
const ALIdouble & posY()
ALIint getWordsInLine(std::vector< ALIstring > &wl)
Definition: ALIFileIn.cc:83
const ALIdouble & posX()
void fillData(const std::vector< ALIstring > &wl)
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
tuple cout
Definition: gather_cfg.py:121
unsigned int ALIuint
Definition: CocoaGlobals.h:17
static void DeviationsFromFileSensor2D::setApply ( ALIbool  val)
inlinestatic
void DeviationsFromFileSensor2D::setOffset ( ALIdouble  offX,
ALIdouble  offY 
)
inline

Definition at line 42 of file DeviationsFromFileSensor2D.h.

References theOffsetX, and theOffsetY.

42  {
43  theOffsetX = offX;
44  theOffsetY = offY;
45  }

Member Data Documentation

bool DeviationsFromFileSensor2D::firstScanDir
private

Definition at line 59 of file DeviationsFromFileSensor2D.h.

Referenced by readFile().

ALIbool DeviationsFromFileSensor2D::theApply = true
staticprivate

Definition at line 64 of file DeviationsFromFileSensor2D.h.

Referenced by apply(), and setApply().

vvd DeviationsFromFileSensor2D::theDeviations
private

Definition at line 63 of file DeviationsFromFileSensor2D.h.

Referenced by getDevis(), and readFile().

ALIuint DeviationsFromFileSensor2D::theNPoints
private

Definition at line 62 of file DeviationsFromFileSensor2D.h.

Referenced by getDevis(), and readFile().

ALIdouble DeviationsFromFileSensor2D::theOffsetX
private

Definition at line 68 of file DeviationsFromFileSensor2D.h.

Referenced by DeviationsFromFileSensor2D(), getDevis(), and setOffset().

ALIdouble DeviationsFromFileSensor2D::theOffsetY
private

Definition at line 68 of file DeviationsFromFileSensor2D.h.

Referenced by DeviationsFromFileSensor2D(), getDevis(), and setOffset().

int DeviationsFromFileSensor2D::theScanSenseX
private

Definition at line 60 of file DeviationsFromFileSensor2D.h.

Referenced by getDevis(), and readFile().

int DeviationsFromFileSensor2D::theScanSenseY
private

Definition at line 60 of file DeviationsFromFileSensor2D.h.

Referenced by getDevis(), and readFile().

ALIint DeviationsFromFileSensor2D::verbose
private