#ifndef HRICH700DIGIPAR_H_
#define HRICH700DIGIPAR_H_
#include "hparcond.h"
#include "hrich700data.h"
#include "TObject.h"
#include "TArrayD.h"
#include "TH2F.h"
#include <vector>
#include <utility>
#include <map>
using namespace std;
class HParamList;
#define NPARPMT 9
class HRich700DigiPar : public HParCond {
private:
map<Int_t,HRich700PmtData> fPmtDataMapPmtId;
map<pair<Int_t,Int_t>, HRich700PmtData> fPmtDataMapXY;
Int_t fNofPixelsInRow;
Double_t fPmtSize;
Double_t fPmtSensSize;
Double_t fCollectionEfficiency;
Double_t fCrossTalkProbability;
Int_t fNofNoiseHits;
Double_t fPmtGap;
TArrayD fArrayPmt;
vector<TArrayD> fArrayThetaMean ;
TArrayD fArrayZVertices ;
TArrayD fArrayThetaTransParamsPoly;
TArrayD fArrayThetaTransParamsGeo;
vector<TH2F*> fhxyThetaMean;
TArrayD fArrayPhiAlign;
TArrayD fArrayThetaAlign;
TH2D* fhPhiAlign;
TH2D* fhThetaAlign;
TArrayD fArrayInvPhiAlign;
TArrayD fArrayInvThetaAlign;
TH2D* fhInvPhiAlign;
TH2D* fhInvThetaAlign;
Float_t fMaxX;
Float_t fMaxY;
void fillMaps();
public:
HRich700DigiPar(const Char_t* name ="Rich700DigiPar",
const Char_t* title ="Digitizer parameters for RICH",
const Char_t* context="Rich700DigiParProduction");
virtual ~HRich700DigiPar();
void getLocation(Int_t pmtId, Float_t x, Float_t y, Int_t *loc,Bool_t silent=kTRUE);
void pmtIdPixelToColRowSec(Int_t pmtId,Int_t pixel,Int_t& sec,Int_t& col,Int_t& row, Bool_t silent=kTRUE);
pair<Double_t, Double_t> getXY(Int_t* loc,Bool_t silent=kTRUE);
pair<Double_t, Double_t> getPmtCenter(Int_t pmtId);
vector<pair<Double_t, Double_t> > getPmtCenters();
Double_t getPmtSize(){ return fPmtSize; }
Double_t getPmtSensSize(){ return fPmtSensSize; }
Double_t getCollectionEfficiency(){ return fCollectionEfficiency; }
Double_t getCrossTalkProbability(){ return fCrossTalkProbability; }
Int_t getNofNoiseHits(){ return fNofNoiseHits; }
Double_t getPmtGap (){ return fPmtGap; }
Int_t getNPmts() { return fArrayPmt.GetSize()/NPARPMT; }
Int_t getNPixelInRow() { return fNofPixelsInRow; }
vector<pair<Int_t, Int_t> > getDirectNeighbourPixels (Int_t col, Int_t row);
vector<pair<Int_t, Int_t> > getDiagonalNeighbourPixels(Int_t col, Int_t row);
vector<pair<Int_t, Int_t> > getNoisePixels (UInt_t nofNoisePixels);
map<Int_t,HRich700PmtData> getPmtDataMapPmtId() {return fPmtDataMapPmtId;}
Int_t getPMTId (Float_t x, Float_t y);
Int_t getPMTId (Int_t col, Int_t row);
HRich700PmtData* getPMTData(Int_t pmtid);
Int_t getInterpolatedSectorThetaPhi(Float_t x, Float_t y, Float_t& theta,Float_t& phi);
Int_t getInterpolatedSectorThetaPhi(Float_t x, Float_t y, Float_t zv, Float_t& theta,Float_t& phi);
Int_t getInterpolatedSectorThetaPhiAnalytical(Float_t x, Float_t y, Float_t zv, Float_t& theta,Float_t& phi);
void getRingCenterXY(Float_t theta, Float_t phi, Float_t zv, Float_t& x,Float_t& y);
Bool_t getInterpolatedThetaPhiPMT(Float_t x, Float_t y, Float_t& theta,Float_t& phi);
Int_t getSector(Float_t x, Float_t y);
Int_t getSectorPixels(Int_t col,Int_t row);
Int_t getSectorPMTInd(Int_t xind,Int_t yInd);
Int_t getSectorPMTId (Int_t pmtid);
Int_t getSectorPhiThetaDegPixels(Int_t col,Int_t row, Float_t& phiDeg,Float_t& thetaDeg);
Int_t getSectorPhiThetaDegPMTInd(Int_t xind,Int_t yInd, Float_t& phiDeg,Float_t& thetaDeg);
Int_t getSectorPhiThetaDegPMTId (Int_t pmtid, Float_t& phiDeg,Float_t& thetaDeg);
void getAlignedThetaPhi(const Float_t theta, const Float_t phi, Float_t & thetaCor, Float_t & phiCor);
void getAlignedThetaPhiInv(const Float_t theta, const Float_t phi, Float_t & thetaCor, Float_t & phiCor);
Bool_t init(HParIo* inp,Int_t* set);
void putParams(HParamList*);
Bool_t getParams(HParamList*);
void clear();
void printParam(void);
string getStringForParTxtFile();
ClassDef(HRich700DigiPar, 1)
};
#endif