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__(), runJetUncertainties.RunJetUncertainties::__call__(), metTools.AddMETCollection::__call__(), heavyIonTools.ProductionDefaults::__call__(), editorTools.ChangeSource::__call__(), HiCoreTools.RemoveMCMatching::__call__(), cmsswVersionTools.PickRelValInputFiles::__call__(), coreTools.RemoveMCMatching::__call__(), trackTools.MakePATTrackCandidates::__call__(), trigTools.SwitchOnTrigger::__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__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.AddJetCollection::__call__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.UpdateJetCollection::__call__(), jetTools.AddJetID::__call__(), jetTools.SetTagInfos::__call__(), OptOSensor2D::detailedTraversesLightRay(), and OptOSensor2D::fastTraversesLightRay().

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

Definition at line 139 of file DeviationsFromFileSensor2D.cc.

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

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

Definition at line 20 of file DeviationsFromFileSensor2D.cc.

References funct::abs(), ecal_dqm_sourceclient-live_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().

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