Skip to content
Snippets Groups Projects
THcHodoscope.h 8.31 KiB
Newer Older
  • Learn to ignore specific revisions
  • #ifndef ROOT_THcHodoscope
    #define ROOT_THcHodoscope
    
    ///////////////////////////////////////////////////////////////////////////////
    //                                                                           //
    
    //                                                                           //
    ///////////////////////////////////////////////////////////////////////////////
    
    
    #include "TClonesArray.h"
    #include "THaNonTrackingDetector.h"
    #include "THcHitList.h"
    
    #include "THcRawHodoHit.h"
    
    #include "THcScintillatorPlane.h"
    
    Zafar's avatar
    Zafar committed
    #include "THcShower.h"
    
    #include "THaTrackingDetector.h"
    #include "THcHitList.h"
    #include "THcRawDCHit.h"
    #include "THcSpacePoint.h"
    #include "THcDriftChamberPlane.h"
    #include "THcDriftChamber.h"
    #include "TMath.h"
    
    #include "THaSubDetector.h"
    #include "TClonesArray.h"
    #include <iostream>
    #include <fstream>
    
    
    
    class THaScCalib;
    
    class THcHodoscope : public THaNonTrackingDetector, public THcHitList {
    
    public:
      THcHodoscope( const char* name, const char* description = "",
    		   THaApparatus* a = NULL );
      virtual ~THcHodoscope();
    
      virtual Int_t      Decode( const THaEvData& );
      virtual EStatus    Init( const TDatime& run_time );
    
      virtual Int_t      CoarseProcess( TClonesArray& tracks );
      virtual Int_t      FineProcess( TClonesArray& tracks );
      
      virtual Int_t      ApplyCorrections( void );
    
      Double_t GetStartTime() const { return fStartTime; }
    
    Gabriel Niculescu's avatar
    Gabriel Niculescu committed
      Bool_t IsStartTimeGood() const {return fGoodStartTime;};
    
      Int_t GetNfptimes() const {return fNfptimes;};
    
      Int_t GetScinIndex(Int_t nPlane, Int_t nPaddle);
      Int_t GetScinIndex(Int_t nSide, Int_t nPlane, Int_t nPaddle);
      Double_t GetPathLengthCentral();
    
      Int_t GetNTracks() const { return fTrackProj->GetLast()+1; }
    
      Double_t GetTdcMin() const {return fScinTdcMin;}
      Double_t GetTdcMax() const {return fScinTdcMax;}
      Double_t GetTofTolerance() const {return fTofTolerance;}
      Double_t GetTdcToTime() const {return fScinTdcToTime;}
      Double_t GetHodoPosPhcCoeff(Int_t iii) const {return fHodoPosPhcCoeff[iii];}
      Double_t GetHodoNegPhcCoeff(Int_t iii) const {return fHodoNegPhcCoeff[iii];}
      Double_t GetHodoPosMinPh(Int_t iii) const {return fHodoPosMinPh[iii];}
      Double_t GetHodoNegMinPh(Int_t iii) const {return fHodoNegMinPh[iii];}
      Double_t GetHodoPosTimeOffset(Int_t iii) const {return fHodoPosTimeOffset[iii];}
      Double_t GetHodoNegTimeOffset(Int_t iii) const {return fHodoNegTimeOffset[iii];}
      Double_t GetHodoVelLight(Int_t iii) const {return fHodoVelLight[iii];}
    
      Double_t GetStartTimeCenter() const {return fStartTimeCenter;}
      Double_t GetStartTimeSlop() const {return fStartTimeSlop;}
      Double_t GetBetaNotrk() const {return fBetaNotrk;}
    
      Int_t GetGoodRawPad(Int_t iii){return fTOFCalc[iii].good_raw_pad;}
    
    Zafar's avatar
    Zafar committed
      Double_t GetNScinHits(Int_t iii){return fNScinHits[iii];}
    
    
      Int_t GetNPaddles(Int_t iii) { return fNPaddle[iii];}
      Double_t GetPlaneCenter(Int_t iii) { return fPlaneCenter[iii];}
      Double_t GetPlaneSpacing(Int_t iii) { return fPlaneSpacing[iii];}
    
    Zafar's avatar
    Zafar committed
    
    
      //  Double_t GetBeta() const {return fBeta[];}
    
    
      // Not used
      //Double_t GetBeta(Int_t itrack) const {return fBeta[itrack];} // Ahmed
    
    Zafar's avatar
    Zafar committed
      //  Int_t GetEvent(){ return fCheckEvent;}
    
      Double_t GetHodoPosSigma(Int_t iii) const {return fHodoPosSigma[iii];}
    
      Double_t GetHodoNegSigma(Int_t iii) const {return fHodoNegSigma[iii];}
    
    Zafar's avatar
    Zafar committed
    
    
      const TClonesArray* GetTrackHits() const { return fTrackProj; }
    
      friend class THaScCalib;
    
      THcHodoscope();  // for ROOT I/O
    protected:
    
    
    Stephen A. Wood's avatar
    Stephen A. Wood committed
      Int_t fAnalyzePedestals;
    
    
      // Calibration
    
      // Per-event data
    
    Gabriel Niculescu's avatar
    Gabriel Niculescu committed
      Bool_t fGoodStartTime;
    
      Double_t fStartTime; 
      Int_t fNfptimes;
    
      Double_t fBetaNotrk;
    
      // Potential Hall C parameters.  Mostly here for demonstration
    
      Int_t fNPlanes,fMaxScinPerPlane,fMaxHodoScin; // number of planes; max number of scin/plane; product of the first two 
    
      Double_t fStartTimeCenter, fStartTimeSlop, fScinTdcToTime;
      Double_t fTofTolerance;
    
      Double_t fScinTdcMin, fScinTdcMax; // min and max TDC values
    
      char** fPlaneNames;
    
      Int_t* fNPaddle;		// Number of paddles per plane
    
    
      Double_t* fHodoVelLight;
      Double_t* fHodoPosSigma;
      Double_t* fHodoNegSigma;
    
      Double_t* fHodoPosMinPh;
      Double_t* fHodoNegMinPh;
      Double_t* fHodoPosPhcCoeff;
      Double_t* fHodoNegPhcCoeff;
      Double_t* fHodoPosTimeOffset;
      Double_t* fHodoNegTimeOffset;
      Int_t* fHodoPosPedLimit;
      Int_t* fHodoNegPedLimit;
      Int_t fTofUsingInvAdc;
      Double_t* fHodoPosInvAdcOffset;
      Double_t* fHodoNegInvAdcOffset;
      Double_t* fHodoPosInvAdcLinear;
      Double_t* fHodoNegInvAdcLinear;
      Double_t* fHodoPosInvAdcAdc;
      Double_t* fHodoNegInvAdcAdc;
    
      THcScintillatorPlane** fPlanes; // List of plane objects
    
    
      TClonesArray*  fTrackProj;  // projection of track onto scintillator plane
                                  // and estimated match to TOF paddle
    
    Zafar's avatar
    Zafar committed
      //--------------------------   Ahmed   -----------------------------
    
    Zafar's avatar
    Zafar committed
      THcShower* fShower;
    
    
    Zafar's avatar
    Zafar committed
    
      Int_t        fGoodTrack;
      Int_t        fSelNDegreesMin;
      Double_t     fSeldEdX1Min;
      Double_t     fSeldEdX1Max;
      Double_t     fSelBetaMin;
      Double_t     fSelBetaMax;
      Double_t     fSelEtMin;
      Double_t     fSelEtMax;
      Double_t     fScin2XZpos;
      Double_t     fScin2XdZpos;
      Double_t     fScin2YZpos;
      Double_t     fScin2YdZpos;
    
      Double_t     fChi2Min;
    
      Double_t*    fPlaneCenter;
      Double_t*    fPlaneSpacing;
    
    Zafar's avatar
    Zafar committed
    
      Double_t**   fScinHit;                // [fNPlanes] Array
    
    
      Double_t*    fFPTime;               // [fNPlanes] Array 
    
    
    Zafar's avatar
    Zafar committed
    
    
      Double_t* fSumPlaneTime; // [fNPlanes]
    
      Int_t* fNScinHits;  // [fNPlanes]
      Int_t fTimeHist[200];
      Int_t* fNPlaneTime; // [fNPlanes]
    
      Bool_t* fGoodPlaneTime;  // [fNPlanes]
    
    
      TClonesArray* scinPosADC;
      TClonesArray* scinNegADC;
      TClonesArray* scinPosTDC;
      TClonesArray* scinNegTDC;
    
      //----------------------------------------------------------------
    
    
      // Useful derived quantities
      // double tan_angle, sin_angle, cos_angle;
      
      //  static const char NDEST = 2;
      //  struct DataDest {
      //    Int_t*    nthit;
      //    Int_t*    nahit;
      //    Double_t*  tdc;
      //    Double_t*  tdc_c;
      //    Double_t*  adc;
      //    Double_t*  adc_p;
      //    Double_t*  adc_c;
      //    Double_t*  offset;
      //    Double_t*  ped;
      //    Double_t*  gain;
      //  } fDataDest[NDEST];     // Lookup table for decoder
    
    
      // Used in TOF calculation (FineProcess) to hold information about hits
      // within a given plane
      struct TOFPInfo {
        Double_t time_pos;
        Double_t time_neg;
        Bool_t keep_pos;
        Bool_t keep_neg;
        Double_t adcPh;
        Double_t path;
        Double_t time;
        Double_t scin_pos_time;
        Double_t scin_neg_time;
        TOFPInfo () : time_pos(-99.0), time_neg(-99.0), keep_pos(kFALSE),
    		  keep_neg(kFALSE), scin_pos_time(0.0), scin_neg_time(0.0) {}
      };
      std::vector<TOFPInfo> fTOFPInfo;
      
      // Used to hold information about all hits within the hodoscope for the TOF
      struct TOFCalc {
        Int_t hit_paddle;
        Int_t good_raw_pad;
        Bool_t good_scin_time;
        Bool_t good_tdc_pos;
        Bool_t good_tdc_neg;
        Double_t scin_time;
        Double_t scin_sigma;
        TOFCalc() : good_scin_time(kFALSE), good_tdc_pos(kFALSE),
    		good_tdc_neg(kFALSE) {}
      };
      std::vector<TOFCalc> fTOFCalc;
        // This doesn't work because we clear this structure each track
        // Do we need an vector of vectors of structures?
        // Start with a separate vector of vectors for now.
      std::vector<std::vector<Double_t> > fdEdX;	// Vector over track #
      std::vector<Int_t > fNScinHit;		// # scins hit for the track
      // Could combine the above into a structure
        
    
      void           ClearEvent();
      void           DeleteArrays();
      virtual Int_t  ReadDatabase( const TDatime& date );
      virtual Int_t  DefineVariables( EMode mode = kDefine );
    
      Double_t DefineDoubleVariable(const char* fName);
      Int_t    DefineIntVariable(const char* fName);
      void DefineArray(const char* fName, const Int_t index, Double_t *myArray);
      void DefineArray(const char* fName, char** Suffix, const Int_t index, Double_t *myArray);
      void DefineArray(const char* fName, char** Suffix, const Int_t index, Int_t *myArray);
    
      enum ESide { kLeft = 0, kRight = 1 };
      
      virtual  Double_t TimeWalkCorrection(const Int_t& paddle,
    					   const ESide side);
    
      void Setup(const char* name, const char* description);
    
    
      ClassDef(THcHodoscope,0)   // Hodoscope detector
    
    };
    
    ////////////////////////////////////////////////////////////////////////////////
    
    #endif