Resolution Map (resolution as a function of eta and E) More...
#include <PFResolutionMap.h>
Public Member Functions | |
int | FindBin (double eta, double e) |
extrapolation requires overloading of this function | |
const char * | GetMapFile () const |
double | getRes (double eta, double phi, double e, int MapEta=-1) |
PFResolutionMap (const char *name, unsigned nbinseta, double mineta, double maxeta, unsigned nbinse, double mine, double maxe, double value=-1) | |
create an empty map and initialize it | |
PFResolutionMap (const TH2D &h) | |
create a map from a 2d histogram | |
PFResolutionMap (const char *name, const char *mapfile) | |
create a map from text file mapfile | |
PFResolutionMap () | |
default constructor | |
bool | ReadMapFile (const char *mapfile) |
read text file | |
bool | WriteMapFile (const char *mapfile) |
Private Member Functions | |
double | dCrackPhi (double phi, double eta) |
bool | IsInAPhiCrack (double phi, double eta) |
double | minimum (double a, double b) |
Private Attributes | |
std::string | mapFile_ |
Static Private Attributes | |
static const unsigned | lineSize_ = 10000 |
Friends | |
std::ostream & | operator<< (std::ostream &out, const PFResolutionMap &rm) |
print this map |
Resolution Map (resolution as a function of eta and E)
Basically just a TH2D with text I/O
Definition at line 18 of file PFResolutionMap.h.
PFResolutionMap::PFResolutionMap | ( | ) | [inline] |
PFResolutionMap::PFResolutionMap | ( | const char * | name, |
const char * | mapfile | ||
) |
create a map from text file mapfile
Definition at line 72 of file PFResolutionMap.cc.
References ReadMapFile().
{ SetTitle(name); GetXaxis()->SetTitle("#eta"); GetYaxis()->SetTitle("E"); if( ! ReadMapFile(mapfile) ) { string err = "PFResolutionMap::PFResolutionMap : cannot read file "; err += mapfile; throw invalid_argument(err); } }
PFResolutionMap::PFResolutionMap | ( | const char * | name, |
unsigned | nbinseta, | ||
double | mineta, | ||
double | maxeta, | ||
unsigned | nbinse, | ||
double | mine, | ||
double | maxe, | ||
double | value = -1 |
||
) |
create an empty map and initialize it
Definition at line 16 of file PFResolutionMap.cc.
: TH2D(name, name, nbinseta, mineta, maxeta, nbinse, mine, maxe) { // fNbinsEta(nbinseta), fMinEta(mineta), fMaxEta(maxeta), // fNbinsE(nbinse), fMinE(mine), fMaxE(maxe) { GetXaxis()->SetTitle("#eta"); GetYaxis()->SetTitle("E"); if(value>0) { for(int ie=1; ie<=GetNbinsY(); ie++) { for(int ieta=1; ieta<=GetNbinsX(); ieta++) { SetBinContent(ieta,ie, value); } } } // cout<<"creating resolution map "<<endl; // Print("all"); }
PFResolutionMap::PFResolutionMap | ( | const TH2D & | h | ) | [inline] |
double PFResolutionMap::dCrackPhi | ( | double | phi, |
double | eta | ||
) | [private] |
Definition at line 307 of file PFResolutionMap.cc.
References gather_cfg::cout, i, m, M_PI, minimum(), and pi.
Referenced by IsInAPhiCrack().
{ static double pi= M_PI;// 3.14159265358979323846; //Location of the 18 phi-cracks static std::vector<double> cPhi; cPhi.resize(18,0); cPhi[0]=2.97025; for(unsigned i=1;i<=17;i++) cPhi[i]=cPhi[0]-2*i*pi/18; //Shift of this location if eta<0 static double delta_cPhi=0.00638; double m; //the result //the location is shifted if(eta<0){ phi +=delta_cPhi; if(phi>pi) phi-=2*pi; } if (phi>=-pi && phi<=pi){ //the problem of the extrema if (phi<cPhi[17] || phi>=cPhi[0]){ if (phi<0) phi+= 2*pi; m = minimum(phi -cPhi[0],phi-cPhi[17]-2*pi); } //between these extrema... else{ bool OK = false; unsigned i=16; while(!OK){ if (phi<cPhi[i]){ m=minimum(phi-cPhi[i+1],phi-cPhi[i]); OK=true; } else i-=1; } } } else{ m=0.; //if there is a problem, we assum that we are in a crack std::cout<<"Problem in dminphi"<<std::endl; } if(eta<0) m=-m; //because of the disymetry return m; }
int PFResolutionMap::FindBin | ( | double | eta, |
double | e | ||
) |
extrapolation requires overloading of this function
Definition at line 257 of file PFResolutionMap.cc.
Referenced by getRes(), and GoodSeedProducer::produce().
{ if(e >= GetYaxis()->GetXmax() ) e = GetYaxis()->GetXmax() - 0.001; return TH2D::FindBin(eta,e); }
const char* PFResolutionMap::GetMapFile | ( | ) | const [inline] |
double PFResolutionMap::getRes | ( | double | eta, |
double | phi, | ||
double | e, | ||
int | MapEta = -1 |
||
) |
Definition at line 231 of file PFResolutionMap.cc.
References newFWLiteAna::bin, FindBin(), and IsInAPhiCrack().
{ static double fMinEta = -2.95; static double fMaxEta = 2.95; static double fMinE=0; static double fMaxE=100; if( eta<fMinEta ) eta = fMinEta+0.001; if( eta>fMaxEta ) eta = fMaxEta-0.001; if( e<fMinE ) e = fMinE+0.001; if( e>fMaxE ) e = fMaxE-0.001; unsigned bin = FindBin(TMath::Abs(eta),e); double res= GetBinContent(bin); if(MapEta>-1){ if((eta<1.48) && IsInAPhiCrack(phi,eta)) { if(MapEta==1) res *= 1.88; else res *= 1.65; } } return res; }
bool PFResolutionMap::IsInAPhiCrack | ( | double | phi, |
double | eta | ||
) | [private] |
double PFResolutionMap::minimum | ( | double | a, |
double | b | ||
) | [private] |
Definition at line 296 of file PFResolutionMap.cc.
Referenced by dCrackPhi().
bool PFResolutionMap::ReadMapFile | ( | const char * | mapfile | ) |
read text file
Definition at line 110 of file PFResolutionMap.cc.
References relativeConstraints::empty, i, EcalCondDB::inf, j, lineSize_, mapFile_, pos, and alignCSCRings::s.
Referenced by PFResolutionMap().
{ // open the file ifstream inf(mapfile); if( !inf.good() ) { // cout<<"PFResolutionMap::Read : cannot open file "<<mapfile<<endl; return false; } // first data describes the map int nbinseta=0; double mineta=0; double maxeta=0; int nbinse=0; double mine=0; double maxe=0; inf>>nbinseta; inf>>mineta; inf>>maxeta; inf>>nbinse; inf>>mine; inf>>maxe; SetBins(nbinseta, mineta, maxeta, nbinse, mine, maxe); // Init(fNbinsEta,fMinEta,fMaxEta,fNbinsE,fMinE,fMaxE); // char data[lineSize_]; char s[lineSize_]; int pos=inf.tellg(); // parse map data int i=1; do { inf.seekg(pos); inf.getline(s,lineSize_); pos = inf.tellg(); if(string(s).empty()) { continue; // remove empty lines } istringstream lin(s); double dataw; int j=1; do { lin>>dataw; SetBinContent(j, i, dataw); j++; } while (lin.good() ); i++; } while(inf.good()); if(inf.eof()) { mapFile_ = mapfile; return true; } else { // cout<<"error"<<endl; return false; } mapFile_ = mapfile; return true; }
bool PFResolutionMap::WriteMapFile | ( | const char * | mapfile | ) |
write text file is not const because mapFile_ will be updated
Definition at line 84 of file PFResolutionMap.cc.
References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, and mapFile_.
{ // assert(fData.size() == fNbinsEta*fNbinsE); // open the file ofstream outf(mapfile); if( !outf.good() ) { cout<<"PFResolutionMap::Write : cannot open file "<<mapfile<<endl; return false; } outf<<(*this)<<endl; if(!outf.good() ) { cerr<<"PFResolutionMap::Write : corrupted file "<<mapfile<<endl; return false; } else { mapFile_ = mapfile; return true; } }
std::ostream& operator<< | ( | std::ostream & | out, |
const PFResolutionMap & | rm | ||
) | [friend] |
print this map
const unsigned PFResolutionMap::lineSize_ = 10000 [static, private] |
Definition at line 58 of file PFResolutionMap.h.
Referenced by ReadMapFile().
std::string PFResolutionMap::mapFile_ [private] |
Definition at line 59 of file PFResolutionMap.h.
Referenced by GetMapFile(), ReadMapFile(), and WriteMapFile().