//////////////////////////////////////////////////////////// // Chimera Event UnPacker // CsI Identification // partially based on KaliVeda classes KVIDGridManager/KVIDGCsI // KVIDLine, KVIDGrid, KVIDZAGrid and others // // data structures for lines and cuts are different from the // KaliVeda ones. // // E. De Filippo v 1.1 2011 defilippo@ct.infn.it // TCHILNS / Exochim / AsyEos collaboration // credits: J.D. Frankland, KaliVeda object library /////////////////////////////////////////////////////////// #ifndef TCHIGRIDCSI_H #define TCHIGRIDCSI_H #include #include #include #include #include #include #include #include "TList.h" #include "TGraph.h" #include "TMath.h" #include "TVector2.h" #include "TCHIResult.h" using namespace std; enum ECut {kgamma, kIMF}; enum EDirection {kabove, kbelow}; class TCHIGraphCsI { private: int fNtel; //telescope number TList *fgrid; //the points grid for the telescope TGraph *fgamma; //the gamma line (above direction cut) TGraph *fIMF; //the IMF line (below direction cut bool fHasValidGrid; // the telescope [has|not has] a valid grid bool fHasValidCuts; // the telescope [has|not has] valid cuts Int_t finfi, finf, fsup, fsups; Double_t fdinf, fdsup, fdinfi, fdsups; Double_t fwinf, fwsup, fwinfi, fwsups; Int_t fZinfi, fZinf, fZsup, fZsups; Int_t fAinfi, fAinf, fAsup, fAsups; Int_t fZint, fAint; // Z and mass of line used to identify particle ECode fICode; // Return code Int_t fZMax; // largest Z of lines in grid TGraph *fZMaxLine; // line with biggest Z and A TGraph *fClosest; // closest line to last-identified point TGraph *fLsups; TGraph *fLsup; TGraph *fLinf; TGraph *fLinfi; Double_t fDistanceClosest; // distance from point to closest line Int_t fIdxClosest; // index of closest line in main list fIdentifiers Bool_t fIMFlineadded; // IMF line is added to the grid list public: TCHIGraphCsI(int tel) : fNtel(tel), fHasValidGrid(false) { fgrid = new TList; fgamma = new TGraph; fIMF = new TGraph; Init(); } ~TCHIGraphCsI() { fgrid->Delete(); delete fgrid; fgrid = 0; delete fgamma; delete fIMF; //cloned fIMF objects deleted inside fgrid->Delete() } void Init(); void Initialize(); TList *GetGrid() {return fgrid;} TGraph *GetGammaL() {return fgamma;} TGraph *GetIMFL() {return fIMF;} int GetNTel() {return fNtel;} Bool_t IsIMFlineadded() {return fIMFlineadded;} void SetIMFLineAdded(Bool_t val) {fIMFlineadded = val;} bool SetValidGrid(bool val) {fHasValidGrid = val;} bool SetValidCuts(bool val) {fHasValidCuts = val;} bool HasValidGrid() {return (fHasValidGrid && fHasValidCuts);} TGraph *GetZALine(int, int, int &); //Return a pointer to the [Z A] grid and its index int GetZ(TGraph *); //Get grid Z value int GetA(TGraph *); //Get grid A value Int_t GetZint() {return fZint;} Int_t GetAint() {return fAint;} Int_t GetZmax() const {return fZMax;} ECode GetICode() {return fICode;} Int_t GetNumberOfIdentifiers() const {return fgrid->GetSize();} TGraph *GetIdentifierAt(Int_t index) const {return (TGraph *)fgrid->At(index);} Double_t DistanceToLine(TGraph *, Double_t , Double_t , Int_t &); Double_t DistanceToLine(Double_t, Double_t, Double_t, Double_t, Double_t, Double_t, Int_t &); Bool_t PosRelToLine(Option_t *, Double_t, Double_t, Double_t, Double_t, Double_t, Double_t); Bool_t WhereAmI(TGraph *, Double_t , Double_t , Option_t *); Bool_t IsBetweenEndPoints(TGraph *gr, Double_t x, Double_t y, const Char_t *axis); void GetStartPoint(TGraph *gr, Double_t &x, Double_t &y); void GetEndPoint(TGraph *, Double_t &x, Double_t &y); Bool_t IsIdentifiable(Double_t x, Double_t y); Bool_t FindFourEmbracingLines(Double_t x, Double_t y, const Char_t* position); Int_t GetIDLinesEmbracingPoint(const Char_t *direction, Double_t x, Double_t y, TList& tmp); TGraph* FindNearestEmbracingIDLine(Double_t x, Double_t y, const Char_t * position, const Char_t* axis, Int_t &idx, Int_t & idx_min, Int_t & idx_max, Double_t &dist, Double_t &dist_min, Double_t &dist_max); TGraph* FindNextEmbracingLine(Int_t &index, Int_t inc_index, Double_t x, Double_t y, const Char_t* axis); void IdentZA(Double_t x, Double_t y, Int_t& Z, Double_t& A); // Main identification routine ClassDef(TCHIGraphCsI,1); }; class TCHIGridCsI { private: string fgridfilename; //the file's name containing the grids bool fgridOK; //a valid grid is defined TCHIGraphCsI *fgraph[MAXTEL]; //All telescopes grids pointers map felem; // a map of nuclei with key Z*100 + A int fring[MAXTEL],fmod[MAXTEL]; //ring and module in chimera format int frmin[MAXTEL],frmax[MAXTEL]; //run min/max public: TCHIGridCsI(string ); //Constructor ~TCHIGridCsI(); //Destructor void InitChimera(); void SetGridFileName(string gfilename) {fgridfilename = gfilename;} string GetGridFileName() {return fgridfilename;} bool ReadAsciiFile(); //Read file containing grid void Initialize(); //Initializes and prepares grids for identification int AddLine(ifstream &, int *, int); //Add a grid line to a given telescope int AddCut(ifstream &, int *, int, ECut); //Add a grid cut to a given telescope void PrintLine(int ntel, int opt=0); //Print grid info for a given telescope (opt=1 print points) void Export2Isospin(string ); //Write an ascii file compatible with Chimera isospin program void Identify(int ntel, Double_t x, Double_t y, TCHIResult *idr); ClassDef(TCHIGridCsI, 1); }; #endif