diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelChargeInterpolationParameters.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelChargeInterpolationParameters.cxx index acc6d4634fdbeb8b382336d78bb94076f8070e5a..4b15331c85dcdd1f54352346f42dffa46f4b0e6d 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelChargeInterpolationParameters.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelChargeInterpolationParameters.cxx @@ -11,87 +11,88 @@ #include <fstream> #include <cmath> +const int nmax(200); // set protection of variables read from file, not too big + namespace PixelCalib{ // constructor. Setting defaults for everything. Hopefully constants // will be read from database, or possibly from text file -PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ - + PixelChargeInterpolationParameters::PixelChargeInterpolationParameters() { m_version = 0; - - // define bins of parametrization - - // eta bins: [-2.5, -2.0, .... 2.5] - int netabins = 10; - for(int i=0; i<netabins+1; i++){ - m_etabins.push_back(-2.5+0.5*i); - } - // alfa (Rphi incidence angle) bins: [-6., -4., ... ,14] - int nphibins = 10; - for(int i=0; i<nphibins+1; i++){ - m_phibins.push_back(-6+2*i); - } - // cluster size bins - int ncs=3; - for(int i=0; i<ncs+1; i++){ - m_csx.push_back(1.5+i); - m_csy.push_back(1.5+i); - } - m_nlayerbins = 6; - - // Initialize default values for parametrization - // Should reading from database fail, these values would be used - int nxbin=nphibins*m_nlayerbins*ncs; - int nybin=netabins*m_nlayerbins*ncs; - // std::cout << "TOMTOM Setting defaults" << std::endl; - for(int i=0; i<nxbin; i++){ - m_deltax.push_back(0.); - m_errdeltax.push_back(0.); - } - for(int i=0; i<nybin; i++){ - m_deltay.push_back(0.); - m_errdeltay.push_back(0.); - } - // IBL - // eta bins: [0., 2.7] - m_etaibl = 0; - m_alphaibl = 0; - m_csxbinsibl = 0; - m_csybinsibl = 0; - - /* IBL initial from DB - int netaibl = 6; - m_ibletabins.reserve(netaibl+1); - m_ibletabins.push_back(0.00); - m_ibletabins.push_back(0.55); - m_ibletabins.push_back(1.275); - m_ibletabins.push_back(1.725); - m_ibletabins.push_back(2.025); - m_ibletabins.push_back(2.25); - m_ibletabins.push_back(2.70); - - // alfa (Rphi incidence angle) bins: [-15.47, 15.47] - float phimin = -15.47; - float phimax = 15.47; - int nalphaibl = 9; - m_ibletabins.reserve(nalphaibl+1); - for(int i=0; i<nalphaibl+1; i++){ - m_iblphibins.push_back(phimin +i*(phimax-phimin)/(nalphaibl)); - } - */ -} + + // define bins of parametrization + + // eta bins: [-2.5, -2.0, .... 2.5] + int netabins = 10; + for(int i=0; i<netabins+1; i++){ + m_etabins.push_back(-2.5+0.5*i); + } + // alfa (Rphi incidence angle) bins: [-6., -4., ... ,14] + int nphibins = 10; + for(int i=0; i<nphibins+1; i++){ + m_phibins.push_back(-6+2*i); + } + // cluster size bins + int ncs=3; + for(int i=0; i<ncs+1; i++){ + m_csx.push_back(1.5+i); + m_csy.push_back(1.5+i); + } + m_nlayerbins = 6; + + // Initialize default values for parametrization + // Should reading from database fail, these values would be used + int nxbin=nphibins*m_nlayerbins*ncs; + int nybin=netabins*m_nlayerbins*ncs; + // std::cout << "TOMTOM Setting defaults" << std::endl; + for(int i=0; i<nxbin; i++){ + m_deltax.push_back(0.); + m_errdeltax.push_back(0.); + } + for(int i=0; i<nybin; i++){ + m_deltay.push_back(0.); + m_errdeltay.push_back(0.); + } + // IBL + // eta bins: [0., 2.7] + m_etaibl = 0; + m_alphaibl = 0; + m_csxbinsibl = 0; + m_csybinsibl = 0; + + /* IBL initial from DB + int netaibl = 6; + m_ibletabins.reserve(netaibl+1); + m_ibletabins.push_back(0.00); + m_ibletabins.push_back(0.55); + m_ibletabins.push_back(1.275); + m_ibletabins.push_back(1.725); + m_ibletabins.push_back(2.025); + m_ibletabins.push_back(2.25); + m_ibletabins.push_back(2.70); + + // alfa (Rphi incidence angle) bins: [-15.47, 15.47] + float phimin = -15.47; + float phimax = 15.47; + int nalphaibl = 9; + m_ibletabins.reserve(nalphaibl+1); + for(int i=0; i<nalphaibl+1; i++){ + m_iblphibins.push_back(phimin +i*(phimax-phimin)/(nalphaibl)); + } + */ + } void PixelChargeInterpolationParameters::setVersion(int version){ m_version = version; } int PixelChargeInterpolationParameters::getVersion() const{ return m_version; } void PixelChargeInterpolationParameters::setParameters(const int n1, // number of cluster size bins (x-direction) - const int n2, // number of cluster size bins (y-direction) - const int n3, // number of eta bins - const int n4, // number of incidence angle bins - int offset, // start from c[offset] - const float* c){ // vector with bin values + const int n2, // number of cluster size bins (y-direction) + const int n3, // number of eta bins + const int n4, // number of incidence angle bins + int offset, // start from c[offset] + const float* c){ // vector with bin values m_csx.clear(); m_csy.clear(); m_etabins.clear(); @@ -112,14 +113,14 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ if(m_etaibl>0){ // IBL eta m_ibletabins.reserve(m_etaibl+1); for(int i = 0; i<m_etaibl+1; i++){ - m_ibletabins.push_back(c[i+offset]); + m_ibletabins.push_back(c[i+offset]); } offset +=m_etaibl+1; } if(m_alphaibl>0){ // IBL phi m_iblphibins.reserve(m_alphaibl+1); for(int i = 0; i<m_alphaibl+1; i++){ - m_iblphibins.push_back(c[i+offset]); + m_iblphibins.push_back(c[i+offset]); } offset +=m_alphaibl+1; } @@ -130,9 +131,9 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ for(int i=0; i<n4+1; i++){ m_phibins.push_back(c[i+offset]); } - + offset +=n4+1; - + m_deltax.clear(); m_deltay.clear(); m_errdeltax.clear(); @@ -152,10 +153,10 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ m_deltay.push_back(0.); m_errdeltay.push_back(0.); } - + return; } - + int PixelChargeInterpolationParameters::getNumberOfXbins() const{ return m_deltax.size(); } @@ -194,7 +195,7 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ return 1; } - + // just return 0 (no correction) outside parametrized range float PixelChargeInterpolationParameters::getErrDeltaX(int i) const{ if(i<0) return 0; @@ -226,90 +227,90 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ } - float PixelChargeInterpolationParameters::getDeltaXbarrel(int nrows, - float ang, - int ilayer) const - { - int ibin = getBarrelBinX(nrows, ang, ilayer); - float delta2 = getDeltaX(ibin); - return delta2; - } + float PixelChargeInterpolationParameters::getDeltaXbarrel(int nrows, + float ang, + int ilayer) const + { + int ibin = getBarrelBinX(nrows, ang, ilayer); + float delta2 = getDeltaX(ibin); + return delta2; + } + - float PixelChargeInterpolationParameters::getDeltaYbarrel(int ncol, - float eta, - int ilayer) const{ + float eta, + int ilayer) const{ // double delta = 0; - // if(ncol == 2 && eta<2) delta = 0.25*CLHEP::mm+0.13*CLHEP::mm*eta; - // if(ncol == 2 && eta>2) delta = 0.5*CLHEP::mm; - // if(ncol == 3 && eta>0.8) delta = 0.25*CLHEP::mm; + // if(ncol == 2 && eta<2) delta = 0.25*CLHEP::mm+0.13*CLHEP::mm*eta; + // if(ncol == 2 && eta>2) delta = 0.5*CLHEP::mm; + // if(ncol == 3 && eta>0.8) delta = 0.25*CLHEP::mm; - int ibin = getBarrelBinY(ncol, eta, ilayer); - float delta2 = getDeltaY(ibin); - return delta2; - } + int ibin = getBarrelBinY(ncol, eta, ilayer); + float delta2 = getDeltaY(ibin); + return delta2; + } /** methods to get/set the calibration data as a function of - the bin index for the various variables separately */ + the bin index for the various variables separately */ float PixelChargeInterpolationParameters::getDeltaX(int iangle, - int iclustersize, int ilayer) const{ + int iclustersize, int ilayer) const{ int ibin = getBarrelBinX(iclustersize, iangle, ilayer); if(ibin < 0) return 0; return getDeltaX(ibin); } float PixelChargeInterpolationParameters::getDeltaY(int ieta, - int iclustersize, int ilayer) const{ + int iclustersize, int ilayer) const{ int ibin = getBarrelBinY(iclustersize, ieta, ilayer); if(ibin < 0) return 0; return getDeltaY(ibin); } int PixelChargeInterpolationParameters::setDeltaX(int iangle, - int iclustersize, int ilayer, - float value){ + int iclustersize, int ilayer, + float value){ int ibin = getBarrelBinX(iclustersize, iangle, ilayer); if(ibin < 0) return 0; // error code return setDeltaX(ibin, value); } int PixelChargeInterpolationParameters::setDeltaY(int ieta, - int iclustersize, int ilayer, - float value){ + int iclustersize, int ilayer, + float value){ int ibin = getBarrelBinY(iclustersize, ieta, ilayer); if(ibin < 0) return 0; // error code return setDeltaY(ibin, value); } /** methods to get/set the calibration data errors as a function of - the bin index for the various variables separately */ + the bin index for the various variables separately */ float PixelChargeInterpolationParameters::getErrDeltaX(int iangle, - int iclustersize, int ilayer) const{ + int iclustersize, int ilayer) const{ int ibin = getBarrelBinX(iclustersize, iangle, ilayer); if(ibin < 0) return 0; return getErrDeltaX(ibin); } float PixelChargeInterpolationParameters::getErrDeltaY(int ieta, - int iclustersize, int ilayer) const{ + int iclustersize, int ilayer) const{ int ibin = getBarrelBinY(iclustersize, ieta, ilayer); if(ibin < 0) return 0; return getErrDeltaY(ibin); } int PixelChargeInterpolationParameters::setErrDeltaX(int iangle, - int iclustersize, int ilayer, - float value){ + int iclustersize, int ilayer, + float value){ int ibin = getBarrelBinX(iclustersize, iangle, ilayer); if(ibin < 0) return 0; // error code return setErrDeltaX(ibin, value); } int PixelChargeInterpolationParameters::setErrDeltaY(int ieta, - int iclustersize, int ilayer, - float value){ + int iclustersize, int ilayer, + float value){ int ibin = getBarrelBinY(iclustersize, ieta, ilayer); if(ibin < 0) return 0; // error code return setErrDeltaY(ibin, value); @@ -318,14 +319,14 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ float PixelChargeInterpolationParameters::getDeltaXendcap() const{ return 10*CLHEP::micrometer; } - + float PixelChargeInterpolationParameters::getDeltaYendcap() const{ return 10*CLHEP::micrometer; } int PixelChargeInterpolationParameters::getBarrelBinX(int nrows, - float ang, - int ilayer) const{ + float ang, + int ilayer) const{ // look for the phi bin int iphi = 0; int icsx=0; @@ -336,10 +337,10 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ if(ang > m_iblphibins[nphi-1]) return -1; if (nrows>=2 && nrows<=m_csxbinsibl+1) icsx=nrows-2; else{ - return -1; + return -1; } for(int i=0; i<nphi; i++){ - if(ang > m_iblphibins[i]) iphi=i; // 8 + if(ang > m_iblphibins[i]) iphi=i; // 8 } } else{ @@ -348,13 +349,13 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ if(ang < m_phibins[0]) return -1; if(ang > m_phibins[nphi-1]) return -1; for(int i=0; i<nphi; i++){ - if(ang > m_phibins[i]) iphi=i; // 8 + if(ang > m_phibins[i]) iphi=i; // 8 } int ncsx = m_csx.size(); // 4? if(nrows>m_csx[ncsx-1]) return -1; if(nrows<m_csx[0]) return -1; for(int i=0; i<ncsx; i++){ - if(nrows>(m_csx[i])) icsx=i; //0 + if(nrows>(m_csx[i])) icsx=i; //0 } } return getBarrelBinX(icsx, iphi, ilayer); @@ -364,8 +365,8 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ } int PixelChargeInterpolationParameters::getBarrelBinY(int ncol, - float eta, - int ilayer) const{ + float eta, + int ilayer) const{ // int nxbin=nphibins*m_nlayerbins*ncs; // int nybin=netabins*m_nlayerbins*ncs; int ieta=0; @@ -375,11 +376,11 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ if(eta < m_ibletabins[0]) return -1; if(eta > m_ibletabins[neta-1]) return -1; for(int i=0; i<neta; i++){ - if(eta > m_ibletabins[i]) ieta=i; // 10 + if(eta > m_ibletabins[i]) ieta=i; // 10 } if (ncol>=2 && ncol<=m_csybinsibl+1) icsy=ncol-2; else{ - return -1; + return -1; } } else{ @@ -387,13 +388,13 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ if(eta < m_etabins[0]) return -1; if(eta > m_etabins[neta-1]) return -1; for(int i=0; i<neta; i++){ - if(eta > m_etabins[i]) ieta=i; // 10 + if(eta > m_etabins[i]) ieta=i; // 10 } int ncsy = m_csy.size(); if(ncol < m_csy[0]) return -1; if(ncol > m_csy[ncsy-1]) return -1; for(int i=0; i<ncsy; i++){ - if(ncol>m_csy[i]) icsy=i; + if(ncol>m_csy[i]) icsy=i; } } return getBarrelBinY(icsy, ieta,ilayer); @@ -401,18 +402,18 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ // return ibin; } - - /** Get global bin index as a function of the separate bin index - for each variable of the parametrization */ - int PixelChargeInterpolationParameters::getBarrelBinX(int nrows, - int iangle, - int ilayer) const{ + + /** Get global bin index as a function of the separate bin index + for each variable of the parametrization */ + int PixelChargeInterpolationParameters::getBarrelBinX(int nrows, + int iangle, + int ilayer) const{ // check wether we are inside parametrized range - int dl = (ilayer>0) ? 1 : 0; - if(nrows > int(m_csx.size()-1) || nrows < 0 || - iangle > int(m_phibins.size()-1) || iangle < 0 || - ilayer <0 || ilayer > (m_nlayerbins+dl)) return -1; + int dl = (ilayer>0) ? 1 : 0; + if(nrows > int(m_csx.size()-1) || nrows < 0 || + iangle > int(m_phibins.size()-1) || iangle < 0 || + ilayer <0 || ilayer > (m_nlayerbins+dl)) return -1; int ncsx = m_csx.size(); int ibin = (m_version<-1&&ilayer==0) ? iangle*m_csxbinsibl+nrows: m_csxbinsibl*m_alphaibl+iangle*m_nlayerbins*(ncsx-1)+(ilayer-dl)*(ncsx-1)+nrows; @@ -420,21 +421,21 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ } /** Get global bin index as a function of the separate bin index - for each variable of the parametrization */ - int PixelChargeInterpolationParameters::getBarrelBinY(int ncol, - int ieta, - int ilayer) const{ + for each variable of the parametrization */ + int PixelChargeInterpolationParameters::getBarrelBinY(int ncol, + int ieta, + int ilayer) const{ // check wether we are inside parametrized range - int dl = (ilayer>0) ? 1 : 0; - if(ncol > int(m_csy.size()-1) || ncol < 0 || - ieta > int(m_etabins.size()-1) || ieta < 0 || - ilayer <0 || ilayer > (m_nlayerbins+dl)) return -1; - int ncsy = m_csy.size(); - int ibin = (m_version<-1&&ilayer==0) ? ieta*m_csybinsibl+ncol: - m_csybinsibl*m_etaibl+ieta*m_nlayerbins*(ncsy-1)+(ilayer-dl)*(ncsy-1)+ncol; - return ibin; - } + int dl = (ilayer>0) ? 1 : 0; + if(ncol > int(m_csy.size()-1) || ncol < 0 || + ieta > int(m_etabins.size()-1) || ieta < 0 || + ilayer <0 || ilayer > (m_nlayerbins+dl)) return -1; + int ncsy = m_csy.size(); + int ibin = (m_version<-1&&ilayer==0) ? ieta*m_csybinsibl+ncol: + m_csybinsibl*m_etaibl+ieta*m_nlayerbins*(ncsy-1)+(ilayer-dl)*(ncsy-1)+ncol; + return ibin; + } // @@ -443,7 +444,7 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ std::ofstream* outfile = new std::ofstream(file.c_str()); // std::cout << "TOMTOM printing constants" << std::endl; - + if(m_version < 0) *outfile << m_version << std::endl; // The number of bins is the number of bin extremes minus 1. int ncsx = m_csx.size()-1; @@ -456,38 +457,38 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ // std::cout << "TOMTOM new format" << std::endl; if(m_version<-1){ - *outfile <<ncsx<<" "<<ncsy<<" "<<neta<<" "<<nalpha<<" "<<m_csxbinsibl<< - " "<<m_csybinsibl<<" "<<m_etaibl<<" "<<m_alphaibl<<std::endl; + *outfile <<ncsx<<" "<<ncsy<<" "<<neta<<" "<<nalpha<<" "<<m_csxbinsibl<< + " "<<m_csybinsibl<<" "<<m_etaibl<<" "<<m_alphaibl<<std::endl; } else{ - *outfile <<ncsx<<" "<<ncsy<<" "<<neta<<" "<<nalpha<<std::endl; + *outfile <<ncsx<<" "<<ncsy<<" "<<neta<<" "<<nalpha<<std::endl; } // Then write bin extremes for(unsigned int i=0; i<m_csx.size(); i++){ - *outfile << m_csx[i] << " "; + *outfile << m_csx[i] << " "; } *outfile << std::endl; for(unsigned int i=0; i<m_csy.size(); i++){ - *outfile << m_csy[i] << " "; + *outfile << m_csy[i] << " "; } *outfile << std::endl; if(m_etaibl>0 && m_alphaibl >0 ){ // IBL - for(unsigned int i=0; i<m_ibletabins.size(); i++){ - *outfile << m_ibletabins[i] << " "; - } - *outfile << std::endl; - for(unsigned int i=0; i<m_iblphibins.size(); i++){ - *outfile << m_iblphibins[i] << " "; - } - *outfile << std::endl; + for(unsigned int i=0; i<m_ibletabins.size(); i++){ + *outfile << m_ibletabins[i] << " "; + } + *outfile << std::endl; + for(unsigned int i=0; i<m_iblphibins.size(); i++){ + *outfile << m_iblphibins[i] << " "; + } + *outfile << std::endl; } for(unsigned int i=0; i<m_etabins.size(); i++){ - *outfile << m_etabins[i] << " "; + *outfile << m_etabins[i] << " "; } *outfile << std::endl; for(unsigned int i=0; i<m_phibins.size(); i++){ - *outfile << m_phibins[i] << " "; + *outfile << m_phibins[i] << " "; } *outfile << std::endl; } @@ -505,151 +506,144 @@ PixelChargeInterpolationParameters::PixelChargeInterpolationParameters(){ *outfile << m_deltay[ie] << " " << m_errdeltay[ie] << std::endl; } outfile->close(); - + delete outfile; } // Load costants from file void PixelChargeInterpolationParameters::Load(std::string file){ - int nmax(200); // set protection of variables read from file, not too big - std::ifstream infile(file.c_str()); - int version; - int nxbins; - int nybins; - int ncsx; - int ncsy; - int neta; - int nalpha; - m_csxbinsibl = 0; - m_csybinsibl = 0; - m_etaibl = 0; - m_alphaibl = 0; - int nxbinsibl(0); - int nybinsibl(0); - - float value, error; - infile >> version; - if(version > 0){ // old format (without version number) - - m_version = 0; - nxbins = version; - infile >> nybins; - if(nxbins<0)nxbins = 0; - nxbins = std::min(nxbins, nmax); - if(nybins<0)nybins = 0; - nybins = std::min(nybins, nmax); - m_deltax.clear(); - m_deltay.clear(); - m_deltax.reserve(nxbins); - m_deltay.reserve(nybins); - - for(int ib=0; ib<nxbins; ib++){ - infile >> value; - m_deltax.push_back(value); - } - for(int ib=0; ib<nybins; ib++){ - infile >> value; - m_deltay.push_back(value); - } - - return; - - } - - else { - m_version = version; - if(version<-1){ // IBL version - // read the number of bins - infile >> ncsx >> ncsy >> neta >> nalpha>>m_csxbinsibl>>m_csybinsibl>>m_etaibl>>m_alphaibl; - nxbinsibl = m_csxbinsibl*m_alphaibl; - nybinsibl = m_csybinsibl*m_etaibl; - } - else{ // current pixel detector - infile >> ncsx >> ncsy >> neta >> nalpha; - } - - // read bins of parametrization - // Note: n bins = n+1 bin extremes - - float value; - m_csx.clear(); - if(ncsx<0)ncsx = 0; - ncsx = std::min(ncsx,nmax); - m_csx.reserve(ncsx+1); - for(int i=0; i<ncsx+1; i++){ - infile >> value; - m_csx.push_back(value); - } - m_csy.clear(); - if(ncsy<0)ncsy = 0; - ncsy = std::min(ncsy, nmax); - m_csy.reserve(ncsy+1); - for(int i=0; i<ncsy+1; i++){ - infile >> value; - m_csy.push_back(value); - } - if(m_etaibl>0 && m_alphaibl >0 ){ // IBL - m_ibletabins.clear(); - m_etaibl = std::min(m_etaibl, nmax); - m_ibletabins.reserve(m_etaibl+1); - for(int i=0; i<m_etaibl+1; i++){ - infile >> value; - m_ibletabins.push_back(value); - } - m_iblphibins.clear(); - m_alphaibl = std::min(m_alphaibl, nmax); - m_iblphibins.reserve(m_alphaibl+1); - for(int i=0; i<m_alphaibl+1; i++){ - infile >> value; - m_iblphibins.push_back(value); - } - } - // - m_etabins.clear(); - if(neta<0)neta = 0; - neta = std::min(neta, nmax); - m_etabins.reserve(neta+1); - for(int i=0; i<neta+1; i++){ - infile >> value; - m_etabins.push_back(value); - } - m_phibins.clear(); - if(nalpha<0)nalpha = 0; - nalpha = std::min(nalpha, nmax); - m_phibins.reserve(nalpha+1); - for(int i=0; i<nalpha+1; i++){ - infile >> value; - m_phibins.push_back(value); - } - - // Read contents of parametrization - - int nxbins = 6*ncsx*nalpha + nxbinsibl; - int nybins = 6*ncsy*neta + nybinsibl; - m_deltax.clear(); - m_deltay.clear(); - m_errdeltax.clear(); - m_errdeltay.clear(); - if(nxbins<0)nxbins = 0; - nxbins = std::min(nxbins, nmax); - if(nybins<0)nybins = 0; - nybins =std::min(nybins, nmax); - m_deltax.reserve(nxbins); - m_deltay.reserve(nybins); - m_errdeltax.reserve(nxbins); - m_errdeltay.reserve(nybins); - for(int ib=0; ib<nxbins; ib++){ - infile >> value >> error; - m_deltax.push_back(value); - m_errdeltax.push_back(error); - } - for(int ib=0; ib<nybins; ib++){ - infile >> value >> error; - m_deltay.push_back(value); - m_errdeltay.push_back(error); - } - return; - } // and of check if version number is the first thing on file + std::ifstream infile(file.c_str()); + int version; + int nxbins; + int nybins; + int ncsx; + int ncsy; + int neta; + int nalpha; + m_csxbinsibl = 0; + m_csybinsibl = 0; + m_etaibl = 0; + m_alphaibl = 0; + int nxbinsibl(0); + int nybinsibl(0); + + float value, error; + infile >> version; + if(version > 0){ // old format (without version number) + + m_version = 0; + nxbins = version; + infile >> nybins; + nxbins = std::min(nxbins, nmax); + if(nybins<0)nybins = 0; + nybins = std::min(nybins, nmax); + m_deltax.clear(); + m_deltay.clear(); + m_deltax.reserve(nxbins); + m_deltay.reserve(nybins); + + for(int ib=0; ib<nxbins; ib++){ + infile >> value; + m_deltax.push_back(value); + } + for(int ib=0; ib<nybins; ib++){ + infile >> value; + m_deltay.push_back(value); + } + } + else { + m_version = version; + if(version<-1){ // IBL version + // read the number of bins + infile >> ncsx >> ncsy >> neta >> nalpha>>m_csxbinsibl>>m_csybinsibl>>m_etaibl>>m_alphaibl; + nxbinsibl = m_csxbinsibl*m_alphaibl; + nybinsibl = m_csybinsibl*m_etaibl; + } + else{ // current pixel detector + infile >> ncsx >> ncsy >> neta >> nalpha; + } + + // read bins of parametrization + // Note: n bins = n+1 bin extremes + + float value; + m_csx.clear(); + if(ncsx<0)ncsx = 0; + ncsx = std::min(ncsx,nmax); + m_csx.reserve(ncsx+1); + for(int i=0; i<ncsx+1; i++){ + infile >> value; + m_csx.push_back(value); + } + m_csy.clear(); + if(ncsy<0)ncsy = 0; + ncsy = std::min(ncsy, nmax); + m_csy.reserve(ncsy+1); + for(int i=0; i<ncsy+1; i++){ + infile >> value; + m_csy.push_back(value); + } + if(m_etaibl>0 && m_alphaibl >0 ){ // IBL + m_ibletabins.clear(); + m_etaibl = std::min(m_etaibl, nmax); + m_ibletabins.reserve(m_etaibl+1); + for(int i=0; i<m_etaibl+1; i++){ + infile >> value; + m_ibletabins.push_back(value); + } + m_iblphibins.clear(); + m_alphaibl = std::min(m_alphaibl, nmax); + m_iblphibins.reserve(m_alphaibl+1); + for(int i=0; i<m_alphaibl+1; i++){ + infile >> value; + m_iblphibins.push_back(value); + } + } + // + m_etabins.clear(); + if(neta<0)neta = 0; + neta = std::min(neta, nmax); + m_etabins.reserve(neta+1); + for(int i=0; i<neta+1; i++){ + infile >> value; + m_etabins.push_back(value); + } + m_phibins.clear(); + if(nalpha<0)nalpha = 0; + nalpha = std::min(nalpha, nmax); + m_phibins.reserve(nalpha+1); + for(int i=0; i<nalpha+1; i++){ + infile >> value; + m_phibins.push_back(value); + } + + // Read contents of parametrization + + int nxbins = 6*ncsx*nalpha + nxbinsibl; + int nybins = 6*ncsy*neta + nybinsibl; + m_deltax.clear(); + m_deltay.clear(); + m_errdeltax.clear(); + m_errdeltay.clear(); + if(nxbins<0)nxbins = 0; + nxbins = std::min(nxbins, nmax); + if(nybins<0)nybins = 0; + nybins =std::min(nybins, nmax); + m_deltax.reserve(nxbins); + m_deltay.reserve(nybins); + m_errdeltax.reserve(nxbins); + m_errdeltay.reserve(nybins); + for(int ib=0; ib<nxbins; ib++){ + infile >> value >> error; + m_deltax.push_back(value); + m_errdeltax.push_back(error); + } + for(int ib=0; ib<nybins; ib++){ + infile >> value >> error; + m_deltay.push_back(value); + m_errdeltay.push_back(error); + } + } // and of check if version number is the first thing on file } // end of Load method } // end of namespace diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterErrorData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterErrorData.cxx index 901de105697490de8ef4a1a873908a5bca898d59..b267ae23d8806e1aeb6bfe797df759f85d8c0087 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterErrorData.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterErrorData.cxx @@ -7,6 +7,8 @@ #include <fstream> #include <string> +const int nmax(200);// protection for loop bound + // use namespace PixelOfflineCalib; namespace PixelCalib{ @@ -210,7 +212,6 @@ void PixelClusterErrorData::Print(std::string file) const { // Load costants from file void PixelClusterErrorData::Load(std::string file){ - int nmax(100); // protection for loop bound std::ifstream infile(file.c_str()); // number of bins for barrel and endcap @@ -236,7 +237,7 @@ void PixelClusterErrorData::Load(std::string file){ float value; nb = std::min(nb, nmax); - ne = std::min(ne,nmax); + ne = std::min(ne, nmax); for(int ib=0; ib<nb; ib++){ infile >> value; m_barrelphierror.push_back(value); diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterOnTrackErrorData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterOnTrackErrorData.cxx index 22e7fe2206be8e91a8248a20851f0c3f645f61b9..f9a984179e8e787e83f12438c532c46403451253 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterOnTrackErrorData.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelClusterOnTrackErrorData.cxx @@ -8,8 +8,10 @@ #include <fstream> #include <string> +const int nmax(200); // protection for loop bound // use namespace PixelOfflineCalib; + namespace PixelCalib{ PixelClusterOnTrackErrorData::PixelClusterOnTrackErrorData(){ @@ -416,7 +418,6 @@ void PixelClusterOnTrackErrorData::Print(std::string file) const { // Load costants from file void PixelClusterOnTrackErrorData::Load(std::string file){ - int nmax(100); // protection for loop bound std::ifstream infile(file.c_str()); // number of bins of parametrization diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx index 67b6e064ac3ec8dd1b1fa01a11b8e388d1835053..e9c1d88b0590a03afd1ec2a11cd33309934dc7ac 100755 --- a/InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx @@ -126,14 +126,14 @@ void ModuleSpecialPixelMap::print(int component, //print header - log << MSG::INFO << " " << endreq; - if(moduleID>-1)log << MSG::INFO << "ModuleSpecialPixelMap for module " << moduleID << ":" << endreq; + log << MSG::INFO << " " << endmsg; + if(moduleID>-1)log << MSG::INFO << "ModuleSpecialPixelMap for module " << moduleID << ":" << endmsg; log << MSG::INFO << "Offline ID [system,subsystem,endcap/barrel,layer/disk,phi,eta] : [" - << system << ',' << subSystem << ',' << component << ',' << layer << ',' << phi << ',' << eta << ']' << endreq; + << system << ',' << subSystem << ',' << component << ',' << layer << ',' << phi << ',' << eta << ']' << endmsg; log << MSG::INFO << "Module status: "; log.width(10); - log << m_module_status << endreq; - log << MSG::INFO << " " << endreq; + log << m_module_status << endmsg; + log << MSG::INFO << " " << endmsg; bool print_chip_status = false; bool print_column_pair_status = false; @@ -154,7 +154,7 @@ void ModuleSpecialPixelMap::print(int component, if(print_chip_status){ log <<MSG::INFO << "Chip number: "; for(int i = mch-1; i>mch/2-1; i--)log<<i<<" "; - log<< endreq; + log<< endmsg; log << MSG::INFO << "Chip status: "; for(int i = mch-1; i > mch/2-1; i--){ @@ -166,8 +166,8 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; - log << MSG::INFO << " " << endreq; + log << endmsg; + log << MSG::INFO << " " << endmsg; if(print_column_pair_status){ log << MSG::INFO << "Column pairs: "; @@ -180,7 +180,7 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; log << MSG::INFO << "pairs 0 to "<<mch/2<<" "; for(int i = mch-1; i > mch/2-1; i--){ log.width(10); @@ -191,7 +191,7 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; for(int j = 2; j < mcolumns/2; j++){ log << MSG::INFO << " "; for(int i = mch-1; i > mch/2-1; i--){ @@ -203,9 +203,9 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; } - log << MSG::INFO << " " << endreq; + log << MSG::INFO << " " << endmsg; log << MSG::INFO << "Column pairs: "; @@ -218,7 +218,7 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; log << MSG::INFO << "pairs 0 to "<<mch/2<<" "; for(int i = 0; i < mch/2; i++){ log.width(10); @@ -229,7 +229,7 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; for(int j = 2; j < mcolumns/2; j++){ log << MSG::INFO << " "; for(int i = 0; i < mch/2; i++){ @@ -241,13 +241,13 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; } - log << MSG::INFO << " " << endreq; + log << MSG::INFO << " " << endmsg; } else{ - log << MSG::INFO << "No special column pairs on this module" << endreq; - log << MSG::INFO << " " << endreq; + log << MSG::INFO << "No special column pairs on this module" << endmsg; + log << MSG::INFO << " " << endmsg; } log << MSG::INFO << "Chip status: "; @@ -260,16 +260,16 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; log << MSG::INFO << "Chip number: "; for(int i = 0; i<mch/2; ++i)log<<i<<" "; - log<< endreq; - log << MSG::INFO << " " << endreq; - log << MSG::INFO << " " << endreq; + log<< endmsg; + log << MSG::INFO << " " << endmsg; + log << MSG::INFO << " " << endmsg; } else{ - log << MSG::INFO << "No special chips and/or column pairs on this module" << endreq; - log << MSG::INFO << " " << endreq; + log << MSG::INFO << "No special chips and/or column pairs on this module" << endmsg; + log << MSG::INFO << " " << endmsg; } //print map @@ -301,10 +301,10 @@ void ModuleSpecialPixelMap::print(int component, log << statusBit; if(!(i%4)) log << ' '; } - log << endreq; + log << endmsg; } else{ - log << " status: " << pixel->second << endreq; + log << " status: " << pixel->second << endmsg; } } } @@ -313,7 +313,7 @@ void ModuleSpecialPixelMap::print(int component, if(print_chip_status){ log<<MSG::INFO << "Chip number: "; for(int i =0; i<mch; ++i)log<<i<<" "; - log<<endreq; + log<<endmsg; log <<MSG::INFO << "Chip status: "; for(int i = 0; i < (int)mch; i++){ log.width(10); @@ -324,12 +324,12 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; - log <<MSG::INFO << " " << endreq; + log << endmsg; + log <<MSG::INFO << " " << endmsg; if(print_column_pair_status){ log <<MSG::INFO <<"Column pairs 0 to "<<mcolumns/2<<" "; - log << endreq; + log << endmsg; for(int j = 0; j<mcolumns/2; ++j){ for(int i = 0; i < (int)mch; i++){ log.width(10); @@ -340,20 +340,20 @@ void ModuleSpecialPixelMap::print(int component, log << 0 << " "; } } - log << endreq; + log << endmsg; } - log << " " << endreq; + log << " " << endmsg; } else{ - log << "No special column pairs on this module" << endreq; - log << " " << endreq; + log << "No special column pairs on this module" << endmsg; + log << " " << endmsg; } } else{ - log << "No special chips and/or column pairs on this module" << endreq; - log << " " << endreq; + log << "No special chips and/or column pairs on this module" << endmsg; + log << " " << endmsg; } //print map @@ -383,10 +383,10 @@ void ModuleSpecialPixelMap::print(int component, log << statusBit; if(!(i%4)) log << ' '; } - log << endreq; + log << endmsg; } else{ - log << " status: " << pixel->second << endreq; + log << " status: " << pixel->second << endmsg; } } //