CMS 3D CMS Logo

DeviationsFromFileSensor2D Class Reference

#include <Alignment/CocoaModel/interface/DeviationsFromFileSensor2D.h>

List of all members.

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.

00029                               { 
00030     theOffsetX = 0.;
00031     theOffsetY = 0.;
00032   };

DeviationsFromFileSensor2D::~DeviationsFromFileSensor2D (  )  [inline]

Definition at line 33 of file DeviationsFromFileSensor2D.h.

00033 { };


Member Function Documentation

static const ALIbool DeviationsFromFileSensor2D::apply (  )  [inline, static]

Definition at line 48 of file DeviationsFromFileSensor2D.h.

References theApply.

Referenced by OptOSensor2D::detailedTraversesLightRay(), and OptOSensor2D::fastTraversesLightRay().

00048                               {
00049     return theApply;
00050   }

std::pair< ALIdouble, ALIdouble > DeviationsFromFileSensor2D::getDevis ( ALIdouble  intersX,
ALIdouble  intersY 
)

Definition at line 137 of file DeviationsFromFileSensor2D.cc.

References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, dist(), e, lat::endl(), cmsRelvalreport::exit, DeviationSensor2D::posX(), funct::pow(), funct::sqrt(), theDeviations, theNPoints, theOffsetX, theOffsetY, theScanSenseX, and theScanSenseY.

Referenced by OptOSensor2D::fastTraversesLightRay().

00138 { 
00139   //intersX += 10000;
00140   //intersY += 10000;
00141   if(verbose >= 4) std::cout << " entering getdevis " << intersX << " " <<intersY << " " << this << std::endl;
00142   vvd::iterator vvdite;
00143   vd::iterator vdite; 
00144   
00145   // assume scan is in Y first, else revers intersection coordinates
00146 /*  if( !firstScanDirY ) {
00147     ALIdouble tt = intersY;
00148     intersY = intersX;
00149     intersX = tt;
00150   }
00151 */
00152 
00153   //---------- look which point in the deviation matrices correspond to intersX,Y
00154   //----- Look for each column, between which rows intersY is
00155   //assume first dir is Y
00156   uint* yrows = new uint[ theNPoints ];
00157 
00158   uint ii = 0;
00159   ALIbool insideMatrix = 0;
00160   for( vvdite = theDeviations.begin(); vvdite != (theDeviations.end()-1); vvdite++ ){
00161     for( vdite = (*vvdite).begin(); vdite != ((*vvdite).end()-1); vdite++ ){
00162      if( verbose >= 5 ) std::cout << " check posy " << (*(vdite))->posY()  << " " <<  (*(vdite+1))->posY()  << " " <<  (*(vdite)) << std::endl;
00163       // if posy is between this point and previous one
00164 
00165      //-     std::cout << "intersy" << intersY << " " <<  (*(vdite))->posY() << std::endl;
00166 
00167       if( (intersY - (*(vdite))->posY() )*theScanSenseY > 0 
00168           && (intersY - (*(vdite+1))->posY() )*theScanSenseY < 0 ) {
00169         //-std::cout << " ii " << ii << std::endl;
00170         yrows[ii] = vdite - (*vvdite).begin();  
00171         if( verbose >= 3 ) std::cout << intersY << " DeviationsFromFileSensor2D yrows " << ii << " " << yrows[ii] << " : " << (*(vdite))->posY() << std::endl;
00172         insideMatrix = 1;
00173         break;
00174       } 
00175     }
00176     ii++;
00177   }
00178   if(insideMatrix == 0) {
00179     std::cerr << "!!EXITING intersection in Y outside matrix of deviations from file " << intersY << std::endl;
00180     exit(1);
00181   }
00182   insideMatrix = 0;
00183 
00184   vd thePoints;
00185   thePoints.clear();
00186   //----- For each row in 'yrows' look between which columns intersX is
00187   uint rn;
00188   DeviationSensor2D *dev1,*dev2;
00189   for( ii = 0; ii < theNPoints-1; ii++) {
00190     rn = yrows[ii];
00191     //-    std::cout << ii << " rn " << rn << std::endl;
00192     dev1 = (*(theDeviations.begin()+ii))[ rn ]; // column ii, row yrows[ii]
00193     rn = yrows[ii+1];
00194     dev2 = (*(theDeviations.begin()+ii+1))[ rn ]; // column ii+1, row yrows[ii+1]
00195     if( (intersX - dev1->posX() )*theScanSenseX > 0 
00196         && (intersX - dev2->posX() )*theScanSenseX < 0) {
00197       thePoints.push_back( dev1 ); 
00198       thePoints.push_back( dev2 ); 
00199       insideMatrix = 1;
00200       if( verbose >= 3 ) std::cout << " column up " << ii << " " << dev1->posX()  << " " << dev2->posX() << " : " << intersX << std::endl;
00201     }
00202     
00203     rn = yrows[ii] + 1;
00204     if(rn == theNPoints) rn = theNPoints-1;
00205     dev1 = (*(theDeviations.begin()+ii))[ rn ]; // column ii, row yrows[ii]+1
00206     rn = yrows[ii+1] + 1;
00207     if(rn == theNPoints) rn = theNPoints-1;
00208     dev2 = (*(theDeviations.begin()+ii+1))[ rn ]; // column ii+1, row yrows[ii+1]+1
00209     if( (intersX - dev1->posX() )*theScanSenseX > 0 
00210         && (intersX - dev2->posX() )*theScanSenseX < 0) {
00211       thePoints.push_back( dev1 ); 
00212       thePoints.push_back( dev2 ); 
00213       if( verbose >= 3 ) std::cout << " column down " << ii << " " <<  dev1->posX()  << " " << dev2->posX() << " : " << intersX << std::endl;
00214     }
00215     
00216     if( thePoints.size() == 4 ) break;
00217     
00218   }
00219  
00220   if(insideMatrix == 0) {
00221     std::cerr << "!!EXITING intersection in X outside matrix of deviations from file " << intersX << std::endl;
00222     exit(1);
00223   }
00224  
00225   //----------- If loop finished and not 4 points, point is outside scan bounds
00226  
00227   //----- calculate deviation in x and y interpolating between four points
00228   ALIdouble dist, disttot=0, deviX=0, deviY=0;
00229   
00230    if( verbose >= 4) std::cout << " thepoints size " << thePoints.size() << std::endl;
00231 
00232   for( ii = 0; ii < 4; ii++) {
00233     dist = sqrt( pow(thePoints[ii]->posX() - intersX, 2 ) +  pow(thePoints[ii]->posY() - intersY, 2 ) ); 
00234     disttot += 1./dist;
00235     deviX += thePoints[ii]->devX()/dist;
00236     deviY += thePoints[ii]->devY()/dist;
00237     if( verbose >= 4 ) { 
00238       //t      std::cout << ii << " point " << *thePoints[ii] << std::endl;
00239       std::cout << ii << " distances: " << dist << " " << deviX << " " << deviY << " devX " << thePoints[ii]->devX() << " devY " << thePoints[ii]->devY() << std::endl;
00240     }
00241   }
00242   deviX /= disttot;
00243   deviY /= disttot;
00244 
00245   // add offset
00246   deviX += theOffsetX; 
00247   deviY += theOffsetY; 
00248   if( verbose >= 4 ) { 
00249     std::cout << " devisX/Y: " << deviX << " " << deviY 
00250          << " intersX/Y " << intersX  << " " << intersY << std::endl;
00251   }
00252 
00253   //change sign!!!!!?!?!?!?!?!
00254    deviX *= -1;
00255    deviY *= -1;
00256   return std::pair< ALIdouble, ALIdouble>( deviX*1.e-6, deviY*1e-6 );  // matrix is in microrad
00257 
00258 }

void DeviationsFromFileSensor2D::readFile ( ALIFileIn ifdevi  ) 

Definition at line 18 of file DeviationsFromFileSensor2D.cc.

References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, ALIUtils::dumpVS(), lat::endl(), ALIFileIn::eof(), cmsRelvalreport::exit, DeviationSensor2D::fillData(), firstScanDir, ALIFileIn::getWordsInLine(), ALIFileIn::name(), DeviationSensor2D::posX(), DeviationSensor2D::posY(), funct::sqrt(), theDeviations, theNPoints, theScanSenseX, theScanSenseY, xdir, and ydir.

Referenced by OptOSensor2D::fillExtraEntry().

00019 {
00020   verbose = ALIUtils::debug;
00021   //  verbose = 4;
00022   if( verbose >= 3) std::cout << "DeviationsFromFileSensor2D::readFile " << this << ifdevi.name() << std::endl;
00023 
00024   theScanSenseX = 0;
00025   theScanSenseY = 0;
00026 
00027   ALIuint nl = 1;
00028 
00029   ALIdouble oldposX=0, oldposY=0;
00030   vd vcol;
00031   std::vector<ALIstring> wl;
00032   /*  //------ first line with dimension factors //now with global option
00033   ifdevi.getWordsInLine( wl );
00034   if( wl[0] != "DIMFACTOR:" || wl.size() != 3) {
00035     std::cerr << "Error reading sensor2D deviation file " << ifdevi.name() << std::endl 
00036          << " first line has to be DIMFACTOR: 'posDimFactor' 'angDimFactor' " << std::endl;
00037     ALIUtils::dumpVS( wl, " ");
00038     exit(1);
00039   }
00040   ALIdouble posDimFactor = atof(wl[1].c_str());
00041   ALIdouble angDimFactor = atof(wl[2].c_str());
00042   */
00043 
00044   for(;;) {
00045     ifdevi.getWordsInLine( wl );
00046     if(ifdevi.eof() ) break;
00047      
00048     DeviationSensor2D* dev = new DeviationSensor2D();
00049     dev->fillData( wl );
00050     
00051     if(verbose >= 5) {
00052       ALIUtils::dumpVS( wl, "deviation sensor2D", std::cout );
00053     }
00054     
00055     //--- line 2 of data
00056     if(nl == 2) {
00057       //--------- get if scan is first in Y or X
00058       firstScanDir = ydir;
00059       if(verbose >= 3) std::cout << "firstScanDir " << firstScanDir << " " <<  dev->posX() <<  " " << oldposX << " " <<  dev->posY() <<  " " << oldposY << std::endl; 
00060       if( fabs( dev->posX() - oldposX ) >  fabs( dev->posY() - oldposY ) ) {
00061         std::cerr << "!!!EXITING first scan direction has to be Y for the moment " << ifdevi.name() << std::endl;
00062         firstScanDir = xdir;
00063         exit(1);
00064       }
00065       //-------- get sense of first scan direction 
00066       if(firstScanDir == ydir ){
00067         if( dev->posY() > oldposY ) {
00068           theScanSenseY = +1;
00069         } else {
00070           theScanSenseY = -1;
00071         }
00072         if( verbose >= 3 ) std::cout << " theScanSenseY " << theScanSenseY << std::endl;
00073       }else {
00074         if( dev->posX() > oldposX ) {
00075           theScanSenseX = +1;
00076         } else {
00077           theScanSenseX = -1;
00078         }
00079         if( verbose >= 3 ) std::cout << " theScanSenseX " << theScanSenseX << std::endl;
00080       }
00081     }
00082     
00083     //-      std::cout << "firstScanDir " << firstScanDir << " " <<  dev->posX() <<  " " << oldposX << " " <<  dev->posY() <<  " " << oldposY << std::endl; 
00084 
00085     //------- check if change of row: clear current std::vector of column values
00086     if( ( firstScanDir == ydir && ( dev->posY() - oldposY)*theScanSenseY < 0 )
00087         || ( firstScanDir == xdir && ( dev->posX() - oldposX)*theScanSenseX < 0 )) {
00088       theDeviations.push_back( vcol );
00089       vcol.clear(); 
00090       
00091       //-      std::cout << " theDevi size " << theDeviations.size() << " " << ifdevi.name()  << std::endl;
00092       //-------- get sense of second scan direction 
00093       if( theScanSenseY == 0 ) {
00094         if( dev->posY() > oldposY ) {
00095           theScanSenseY = +1;
00096         } else {
00097           theScanSenseY = -1;
00098         }
00099       }
00100       if( theScanSenseX == 0 ) {
00101         if( dev->posX() > oldposX ) {
00102           theScanSenseX = +1;
00103         } else {
00104           theScanSenseX = -1;
00105         }
00106       }
00107       if( verbose >= 3 ) std::cout << " theScanSenseX " << theScanSenseX << " theScanSenseY " << theScanSenseY << std::endl;
00108     }
00109     
00110     oldposX = dev->posX();
00111     oldposY = dev->posY();
00112     
00113     //--- fill deviation std::vectors
00114     vcol.push_back( dev );
00115     nl++;
00116   }
00117   theDeviations.push_back( vcol );
00118 
00119   //----- Calculate std::vector size
00120   ALIdouble dvsiz = ( sqrt( ALIdouble(nl-1) ) );
00121   //----- Check that it is a square of points (<=> vsiz is integer)
00122   ALIuint vsiz = ALIuint(dvsiz);
00123   if( vsiz != dvsiz ) {
00124     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; 
00125     //    exit(1);
00126   }
00127   theNPoints = vsiz;
00128   
00129   if(verbose >= 4 ) {
00130     std::cout << " Filling deviation from file: " << ifdevi.name() << " theNPoints " <<  theNPoints << std::endl;
00131   }
00132     
00133 }

static void DeviationsFromFileSensor2D::setApply ( ALIbool  val  )  [inline, static]

Definition at line 53 of file DeviationsFromFileSensor2D.h.

References theApply.

Referenced by Fit::calculateSimulatedMeasurementsWithOriginalValues(), and OptOSensor2D::detailedTraversesLightRay().

00053                                      {
00054     theApply = val;
00055   }

void DeviationsFromFileSensor2D::setOffset ( ALIdouble  offX,
ALIdouble  offY 
) [inline]

Definition at line 42 of file DeviationsFromFileSensor2D.h.

References theOffsetX, and theOffsetY.

Referenced by OptOSensor2D::fillExtraEntry().

00042                                                   {
00043     theOffsetX = offX; 
00044     theOffsetY = offY; 
00045   }


Member Data Documentation

bool DeviationsFromFileSensor2D::firstScanDir [private]

Definition at line 59 of file DeviationsFromFileSensor2D.h.

Referenced by readFile().

ALIbool DeviationsFromFileSensor2D::theApply = true [static, private]

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]

Definition at line 66 of file DeviationsFromFileSensor2D.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:18:24 2009 for CMSSW by  doxygen 1.5.4