Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LITuning.h

Go to the documentation of this file.
00001 
00002 
00003 // Program name: LITuning.h                        
00004 //                                                                     
00005 // Package: LISummary                                         
00006 //                                                                    
00007 // Coded by Jeff Hartnell Feb-Aug/2003          
00008 //                                                                    
00009 // Purpose: To provide algorithms for the tuning of the LI system
00010 //                                                                    
00011 // Contact: jeffrey.hartnell@physics.ox.ac.uk                         
00013 
00014 #ifndef LITUNING_H
00015 #define LITUNING_H
00016 
00017 #include <vector>
00018 
00019 #include "TH2F.h"
00020 #include "TObject.h"
00021 
00022 #include "LIRun.h"
00023 
00024 class LITuning : public LILookup
00025 {
00026   
00027  public:  
00028 
00029   typedef enum EGcTuningType {
00030     kGcUnknown        = 0,
00031     kGcLinearInPmtAdc = 1,
00032     kGcLinearInPinAdc = 2
00033   } EGcTuningType_t;  
00034 
00035   LITuning();
00036   ~LITuning();
00037 
00039   //methods that do modify the object's state
00041   void CalculateDriftPoints();
00042   void CalculateGainCurve(EGcTuningType tuningType=kGcLinearInPinAdc);
00043   void InputDataGc(std::vector<LIRun>& gainCurve);
00044   //the setters
00045   void SetAdcAtStartOfSaturation(Double_t i){fAdcAtStartOfSaturation=i;}
00046   void SetdADCdPHAtSat(Double_t i) {fdADCdPHAtSat=i;}
00047   void SetFirstGcPointAdc(Double_t i) {fFirstGcPointAdc=i;}
00048   void SetIdealAdc(Int_t i) {fIdealAdc=i;}
00049   void SetLastGcPointAdc(Double_t i) {fLastGcPointAdc=i;}
00050   void SetPinHighestMaxHG(Double_t i) {fPinHighestMaxHG=i;}
00051   void SetPinHighestMaxLG(Double_t i) {fPinHighestMaxLG=i;}
00052   void SetPinLowestMaxHG(Double_t i) {fPinLowestMaxHG=i;}
00053   void SetPinLowestMaxLG(Double_t i) {fPinLowestMaxLG=i;}
00054   void SetPinLowestMinHG(Double_t i) {fPinLowestMinHG=i;}
00055   void SetPinLowestMinLG(Double_t i) {fPinLowestMinLG=i;}
00056   void SetMaxPossAdc(Double_t i) {fMaxPossAdc=i;}
00057   void SetMaxPossPh(Double_t i) {fMaxPossPh=i;}
00058   void SetMaxPossPin(Double_t i) {fMaxPossPin=i;}
00059   void SetMinHGdPINdPH(Double_t i) {fMinHGdPINdPH=i;}
00060   void SetMinLGdPINdPH(Double_t i) {fMinLGdPINdPH=i;}
00061   void SetMinPossAdc(Double_t i) {fMinPossAdc=i;}
00062   void SetMinPossPh(Double_t i) {fMinPossPh=i;}
00063   void SetMinPossPin(Double_t i) {fMinPossPin=i;}
00064   void SetNumCalibPoints(Int_t i); 
00065   void SetNumGainPoints(Int_t i);
00066 
00068   //methods that don't modify the objects state
00070   Float_t FindLowerFraction(std::map<Float_t,Int_t>& inputMap,
00071                             Float_t fraction,Int_t totalNumHits);
00072   Float_t FindMidFractionAv(std::map<Float_t,Int_t>& inputMap,
00073                             Float_t lowerFraction,Float_t upperFraction,
00074                             Int_t totalNumHits);
00075   Float_t FindUpperFraction(std::map<Float_t,Int_t>& inputMap,
00076                             Float_t fraction,Int_t totalNumHits);
00077   Bool_t GetDataGcGraphs(std::vector<TGraph*>& gGcAdc,
00078                          std::vector<TGraph*>& gAdcFVsPh,
00079                          std::vector<TGraph*>& gPinVsPh,
00080                          std::vector<TGraph*>& gPin2VsPh,
00081                          std::vector<TGraphAsymmErrors*>& gAdcErrVsPh,
00082                          std::vector<TGraphAsymmErrors*>& gAdcFErrVsPh);
00083   Bool_t GetTunedDpGraphs(TGraph*& gAdcVsLed,TGraph*& gPhVsLed,
00084                           TGraph*& gPinVsLed,Int_t numLedsPerPb);
00085   Bool_t GetTunedGcPlots(std::vector<TH2F*>& hGcAdc,
00086                          std::vector<TH2F*>& hGcPin,
00087                          std::vector<TH2F*>& hGcPh,
00088                          Int_t firstLed,Int_t lastLed);
00089   void PrintAll();
00090   void PrintConfig();
00091   void PrintLedCheckGrid(LIRun::ELIRunType LIRunType,
00092                          Int_t firstPb,Int_t lastPb,
00093                          Int_t firstLed,Int_t lastLed);
00094   Int_t PrintLIConfig(LIRun::ELIRunType LIRunType);
00095 
00096  private:
00097 
00099   //methods that do modify the object's state
00101   void CorrectInterpValues(std::vector<Double_t>::iterator adc,
00102                            std::vector<Double_t>::iterator ph,
00103                            std::vector<Double_t>::iterator pin,
00104                            Int_t led,Int_t pb,Double_t requiredPointAdc,
00105                            Double_t& interpPh,Double_t& interpPin);
00106   void GcLinearInPinAdc(std::vector<LIRun>::iterator gcData,
00107                         Int_t goodPin,
00108                         std::vector<LIRun>::iterator& gcTuned,
00109                         Double_t firstPh,Double_t lastPh,
00110                         Double_t firstPin,Double_t lastPin);
00111   void GcLinearInPmtAdc(std::vector<LIRun>::iterator gcData,
00112                         Int_t goodPin,
00113                         std::vector<LIRun>::iterator& gcTuned,
00114                         Double_t firstPh,Double_t lastPh,
00115                         Double_t firstPin,Double_t lastPin);
00116   void InitialiseDataMembers(Detector::Detector_t det);
00117     
00119   //methods that don't modify the objects state
00121   Double_t CalcAv_dPINdPH(std::vector<LIRun>::iterator gcData,
00122                           Int_t pinNumber);
00123   void CalcFirstGcPoint(std::vector<LIRun>::iterator gcData,
00124                         Int_t goodPin,Double_t& firstPh,
00125                         Double_t& firstPin);
00126   void CalcLastGcPoint(std::vector<LIRun>::iterator gcData,
00127                        Int_t goodPin,Double_t& lastPh,
00128                        Double_t& lastPin);
00129   Double_t CalcLastGcPointAdc(std::vector<LIRun>::iterator gcData);
00130   Bool_t DataIsOk(std::vector<LIRun>::iterator GainCurveData,
00131                   Int_t minNumPoints=4,Int_t maxAllowedAdc=15000);
00132   Int_t GoodPin(std::vector<LIRun>::iterator currentGc);
00133   Double_t Interpolate(Double_t y,Double_t y2,Double_t m,Double_t x2);
00134   void InterpolateAboveOrBelow(EGcTuningType tuningType,
00135                                std::vector<Double_t>::iterator adc,
00136                                std::vector<Double_t>::iterator ph,
00137                                std::vector<Double_t>::iterator pin,
00138                                Int_t led,Int_t pb,
00139                                Double_t& interpAdc,
00140                                Double_t& interpPh,Double_t& interpPin);
00141   void PrintFirstLastMsg(Double_t firstPh,Double_t lastPh,
00142                          Double_t firstPin,Double_t lastPin);
00143   void PrintPhPinMsg(std::vector<Double_t>::iterator adc,
00144                      std::vector<Double_t>::iterator ph,
00145                      std::vector<Double_t>::iterator pin,
00146                      Double_t interpPh,
00147                      Double_t interpPin);
00148   void PrintPhMsg(std::vector<Double_t>::iterator adc,
00149                   std::vector<Double_t>::iterator ph,
00150                   Double_t interpPh);
00151   void PrintPinMsg(std::vector<Double_t>::iterator pin,
00152                    std::vector<Double_t>::iterator ph,
00153                    Double_t interpAdc,Double_t interpPh);
00154 
00156   //data members
00158   Double_t fAdcAtStartOfSaturation;//the adc where saturation starts
00159   std::vector<LIRun> fBestDp;//to hold the calculated DPs
00160   std::vector<LIRun> fBestGc;//to hold the calculated GCs
00161   Double_t fdADCdPHAtSat;
00162   Detector::Detector_t fDetector;
00163   Double_t fFirstGcPointAdc;//lowest adc GC point
00164   std::vector<LIRun>* fGainCurve;//to hold the input GC (real data)
00165   Int_t fIdealAdc;//the adc to aim for in DP tuning
00166   Double_t fLastGcPointAdc;//highest adc GC point
00167   Int_t fNumCalibPoints;//the number of point in the input data GC
00168   Int_t fNumGainPoints;//the number of points required in the tuned GC
00169   Double_t fPinHighestMaxHG;//the max acceptable pin to calc gain curve
00170   Double_t fPinHighestMaxLG;
00171   Double_t fPinLowestMaxHG;//the lowest acceptable max 
00172   Double_t fPinLowestMaxLG;
00173   Double_t fPinLowestMinHG;//the min acceptable pin to calc gain curve
00174   Double_t fPinLowestMinLG;
00175   Double_t fMaxPossAdc;//the maximum adc possible in FD
00176   Double_t fMaxPossPh;//the maximum PH possible in minos
00177   Double_t fMaxPossPin;//the maximum adc possible in FD
00178   Double_t fMinHGdPINdPH;//min pin/ph gradient for high gain pin
00179   Double_t fMinLGdPINdPH;
00180   Double_t fMinPossAdc;
00181   Double_t fMinPossPh;
00182   Double_t fMinPossPin;
00183   std::string fS;//general purpose string
00184 
00185   ClassDef(LITuning,0)
00186 };
00187 
00188 #endif // LITUNING_H

Generated on Mon Feb 15 11:06:53 2010 for loon by  doxygen 1.3.9.1