Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 07:56:42

0001 #ifndef TILETREND_H
0002 #define TILETREND_H
0003 
0004 #include "TObject.h"
0005 #include "TString.h"
0006 #include "TH1D.h"
0007 #include "TH2D.h"
0008 #include "TProfile.h"
0009 #include "TGraphErrors.h"
0010 #include "TF1.h"
0011 #include "TPad.h" 
0012 #include "TCanvas.h"
0013 #include "TLegend.h"
0014 #include "TFile.h"
0015 #include "Calib.h"
0016 
0017 class TileTrend: public TObject{
0018 
0019  public:
0020  TileTrend():TObject(){}
0021  TileTrend(int id, int deb=0, int ext=0):TObject()
0022     {
0023     CellID         = id;
0024     debug          = deb;
0025     extended       = ext;
0026     
0027     gTrendLGped    = TGraphErrors();
0028     gTrendLGped    .SetName(Form("TrendLGpedCellID%d",CellID));
0029     gTrendLGped    .GetYaxis()->SetTitle("#mu_{PED, LG} (arb. units)");
0030     gTrendLGped    .SetLineColor(kRed);
0031     gTrendLGped    .SetMarkerColor(kRed);
0032     gTrendLGped    .SetMarkerStyle(kFullCircle);
0033     
0034     gTrendHGped    = TGraphErrors();
0035     gTrendHGped    .SetName(Form("TrendHGpedCellID%d",CellID));
0036     gTrendHGped    .GetYaxis()->SetTitle("#mu_{PED, HG} (arb. units)");
0037     gTrendHGped    .SetLineColor(kRed);
0038     gTrendHGped    .SetMarkerColor(kRed);
0039     gTrendHGped    .SetMarkerStyle(kFullCircle);
0040     
0041     gTrendLGpedwidth  = TGraphErrors();
0042     gTrendLGpedwidth  .SetName(Form("TrendLGpedwidthCellID%d",CellID));
0043     gTrendLGpedwidth  .GetYaxis()->SetTitle("#sigma_{PED, LG} (arb. units)");
0044     gTrendLGpedwidth  .SetLineColor(kRed);
0045     gTrendLGpedwidth  .SetMarkerColor(kRed);
0046 
0047     gTrendHGpedwidth  = TGraphErrors();
0048     gTrendHGpedwidth  .SetName(Form("TrendHGpedwidthCellID%d",CellID));
0049     gTrendHGpedwidth  .GetYaxis()->SetTitle("#sigma_{PED, HG} (arb. units)");
0050     gTrendHGpedwidth  .SetLineColor(kRed);
0051     gTrendHGpedwidth  .SetMarkerColor(kRed);
0052 
0053     gTrendLGscale  = TGraphErrors();
0054     gTrendLGscale  .SetName(Form("TrendLGscaleCellID%d",CellID));
0055     gTrendLGscale  .GetYaxis()->SetTitle("Max_{LG} (arb. units)");
0056     gTrendLGscale  .SetLineColor(kRed);
0057     gTrendLGscale  .SetMarkerColor(kRed);
0058     gTrendLGscale  .SetMarkerStyle(kFullCircle);
0059 
0060     gTrendHGscale  = TGraphErrors();
0061     gTrendHGscale  .SetName(Form("TrendHGscaleCellID%d",CellID));
0062     gTrendHGscale  .GetYaxis()->SetTitle("Max_{HG} (arb. units)");
0063     gTrendHGscale  .SetLineColor(kRed);
0064     gTrendHGscale  .SetMarkerColor(kRed);
0065     gTrendHGscale  .SetMarkerStyle(kFullCircle);
0066 
0067     gTrendHGLGcorr = TGraphErrors();
0068     gTrendHGLGcorr .SetName(Form("TrendHGLGcorrCellID%d",CellID));
0069     gTrendHGLGcorr .GetYaxis()->SetTitle("a_{HG-LG} (arb. units)");
0070     gTrendHGLGcorr .SetLineColor(kRed);
0071     gTrendHGLGcorr .SetMarkerColor(kRed);
0072     gTrendHGLGcorr .SetMarkerStyle(kFullCircle);
0073 
0074     gTrendLGHGcorr = TGraphErrors();    
0075     gTrendLGHGcorr .SetName(Form("TrendLGHGcorrCellID%d",CellID));
0076     gTrendLGHGcorr .GetYaxis()->SetTitle("a_{LG-HG} (arb. units)");
0077     gTrendLGHGcorr .SetLineColor(kRed);
0078     gTrendLGHGcorr .SetMarkerColor(kRed);
0079     gTrendLGHGcorr .SetMarkerStyle(kFullCircle);    
0080 
0081     gTrendHGLGOffset = TGraphErrors();
0082     gTrendHGLGOffset .SetName(Form("TrendHGLGOffsetCellID%d",CellID));
0083     gTrendHGLGOffset .GetYaxis()->SetTitle("b_{HG,LG} (arb. units)");
0084     gTrendHGLGOffset .SetLineColor(kRed);
0085     gTrendHGLGOffset .SetMarkerColor(kRed);
0086     gTrendHGLGOffset .SetMarkerStyle(kFullCircle);
0087 
0088     gTrendLGHGOffset = TGraphErrors();
0089     gTrendLGHGOffset .SetName(Form("TrendLGHGOffsetCellID%d",CellID));
0090     gTrendLGHGOffset .GetYaxis()->SetTitle("b_{LG,HG} (arb. units)");
0091     gTrendLGHGOffset .SetLineColor(kRed);
0092     gTrendLGHGOffset .SetMarkerColor(kRed);
0093     gTrendLGHGOffset .SetMarkerStyle(kFullCircle);
0094     
0095     if (ext == 1 || ext == 2){
0096       // std::cout << "entering expanded option" << std::endl;
0097       gTrendTrigger = TGraphErrors();
0098       gTrendTrigger .SetName(Form("TrendTriggerCellID%d",CellID));
0099       gTrendTrigger .GetYaxis()->SetTitle("#mu triggers");
0100       gTrendTrigger .SetLineColor(kRed);
0101       gTrendTrigger .SetMarkerColor(kRed);
0102       gTrendTrigger .SetMarkerStyle(kFullCircle);
0103       
0104       gTrendSBNoise = TGraphErrors();
0105       gTrendSBNoise .SetName(Form("TrendSBNoiseCellID%d",CellID));
0106       gTrendSBNoise .GetYaxis()->SetTitle("S/B noise region");
0107       gTrendSBNoise .SetLineColor(kRed);
0108       gTrendSBNoise .SetMarkerColor(kRed);
0109       gTrendSBNoise .SetMarkerStyle(kFullCircle);
0110       
0111       gTrendSBSignal = TGraphErrors();
0112       gTrendSBSignal .SetName(Form("TrendSBSignalCellID%d",CellID));
0113       gTrendSBSignal .GetYaxis()->SetTitle("S/B signal region");
0114       gTrendSBSignal .SetLineColor(kRed);
0115       gTrendSBSignal .SetMarkerColor(kRed);
0116       gTrendSBSignal .SetMarkerStyle(kFullCircle);
0117     } 
0118     if (ext == 1){
0119       gTrendHGLMPV = TGraphErrors();
0120       gTrendHGLMPV .SetName(Form("TrendHGLMPVCellID%d",CellID));
0121       gTrendHGLMPV .GetYaxis()->SetTitle("MPV_{HG} (arb. units)");
0122       gTrendHGLMPV .SetLineColor(kRed);
0123       gTrendHGLMPV .SetMarkerColor(kRed);
0124       gTrendHGLMPV .SetMarkerStyle(kFullCircle);
0125 
0126       gTrendHGLSigma = TGraphErrors();
0127       gTrendHGLSigma .SetName(Form("TrendHGLSigmaCellID%d",CellID));
0128       gTrendHGLSigma .GetYaxis()->SetTitle("#sigma_{L,HG} (arb. units)");
0129       gTrendHGLSigma .SetLineColor(kRed);
0130       gTrendHGLSigma .SetMarkerColor(kRed);
0131       gTrendHGLSigma .SetMarkerStyle(kFullCircle);
0132 
0133       gTrendHGGSigma = TGraphErrors();
0134       gTrendHGGSigma .SetName(Form("TrendHGGSigmaCellID%d",CellID));
0135       gTrendHGGSigma .GetYaxis()->SetTitle("#sigma_{G,HG} (arb. units)");
0136       gTrendHGGSigma .SetLineColor(kRed);
0137       gTrendHGGSigma .SetMarkerColor(kRed);
0138       gTrendHGGSigma .SetMarkerStyle(kFullCircle);
0139       
0140       gTrendLGLMPV = TGraphErrors();
0141       gTrendLGLMPV .SetName(Form("TrendLGLMPVCellID%d",CellID));
0142       gTrendLGLMPV .GetYaxis()->SetTitle("MPV_{LG} (arb. units)");
0143       gTrendLGLMPV .SetLineColor(kRed);
0144       gTrendLGLMPV .SetMarkerColor(kRed);
0145       gTrendLGLMPV .SetMarkerStyle(kFullCircle);
0146       
0147       gTrendLGLSigma = TGraphErrors();
0148       gTrendLGLSigma .SetName(Form("TrendLGLSigmaCellID%d",CellID));
0149       gTrendLGLSigma .GetYaxis()->SetTitle("#sigma_{L,LG} (arb. units)");
0150       gTrendLGLSigma .SetLineColor(kRed);
0151       gTrendLGLSigma .SetMarkerColor(kRed);
0152       gTrendLGLSigma .SetMarkerStyle(kFullCircle);
0153       
0154       gTrendLGGSigma = TGraphErrors();
0155       gTrendLGGSigma .SetName(Form("TrendLGGSigmaCellID%d",CellID));
0156       gTrendLGGSigma .GetYaxis()->SetTitle("#sigma_{G,LG} (arb. units)");
0157       gTrendLGGSigma .SetLineColor(kRed);
0158       gTrendLGGSigma .SetMarkerColor(kRed);
0159       gTrendLGGSigma .SetMarkerStyle(kFullCircle);
0160     } 
0161   }
0162   ~TileTrend(){}
0163 
0164   // Fill objects 
0165   bool Fill           (double, const TileCalib&, int, double);
0166   bool FillExtended   (double, int, int, TH1D*, TH1D*, TProfile*);
0167   void FillMPV        (double, double, double, double, double);
0168   void FillLSigma     (double, double, double, double, double);
0169   void FillGSigma     (double, double, double, double, double);
0170   void FillSB         (double, double, double);
0171   void FillCorrOffset (double, double, double, double, double);
0172   
0173   // Drawing functions for graphs
0174   bool DrawLGped      (TString);
0175   bool DrawHGped      (TString);
0176   bool DrawLGpedwidth (TString);
0177   bool DrawHGpedwidth (TString);
0178   bool DrawLGscale    (TString);
0179   bool DrawHGscale    (TString);
0180   bool DrawHGLGcorr   (TString);
0181   bool DrawLGHGcorr   (TString);
0182   bool DrawTrigger    (TString);
0183   bool DrawSBNoise    (TString);
0184   bool DrawSBSignal   (TString);
0185   bool DrawHGLMPV     (TString);
0186   bool DrawLGLMPV     (TString);
0187   bool DrawHGLSigma   (TString);
0188   bool DrawLGLSigma   (TString);
0189   bool DrawHGGSigma   (TString);
0190   bool DrawLGGSigma   (TString);
0191   bool DrawHGLGOffset (TString);
0192   bool DrawLGHGOffset (TString);
0193   
0194   // Set default drawing options for all graphs
0195   bool SetLineColor   (uint);
0196   bool SetMarkerColor (uint);
0197   bool SetMarkerStyle (uint);
0198   bool SetXAxisTitle  (TString);
0199   
0200   // Sort graph according to voltage or run number
0201   void Sort          ();
0202   // Write graphs to file
0203   bool Write          (TFile*);
0204 
0205   inline double GetExtOpt()       {return extended;};
0206 
0207   // Get minima and maxima for different graphs
0208   inline double GetMinLGped()     {return MinLGped;};
0209   inline double GetMaxLGped()     {return MaxLGped;};
0210   inline double GetMinHGped()     {return MinHGped;};
0211   inline double GetMaxHGped()     {return MaxHGped;};
0212   inline double GetMinLGpedwidth(){return MinLGpedwidth;};
0213   inline double GetMaxLGpedwidth(){return MaxLGpedwidth;};
0214   inline double GetMinHGpedwidth(){return MinHGpedwidth;};
0215   inline double GetMaxHGpedwidth(){return MaxHGpedwidth;};
0216   inline double GetMinLGscale()   {return MinLGscale;};
0217   inline double GetMaxLGscale()   {return MaxLGscale;};
0218   inline double GetMinHGscale()   {return MinHGscale;};
0219   inline double GetMaxHGscale()   {return MaxHGscale;};
0220   inline double GetMinHGLGcorr()  {return MinHGLGcorr;};
0221   inline double GetMaxHGLGcorr()  {return MaxHGLGcorr;};
0222   inline double GetMinLGHGcorr()  {return MinLGHGcorr;};
0223   inline double GetMaxLGHGcorr()  {return MaxLGHGcorr;};
0224   
0225   // Get minima and maxima for different graphs extended graphs
0226   inline double GetMinTrigg()     {return MinTrigg;};
0227   inline double GetMaxTrigg()     {return MaxTrigg;};
0228   inline double GetMinHGSpec()    {return MinHGSpec;};
0229   inline double GetMaxHGSpec()    {return MaxHGSpec;};
0230   inline double GetMinLGSpec()    {return MinLGSpec;};
0231   inline double GetMaxLGSpec()    {return MaxLGSpec;};
0232   inline double GetMinLGMPV()     {return MinLGMPV;};
0233   inline double GetMaxLGMPV()     {return MaxLGMPV;};
0234   inline double GetMinHGMPV()     {return MinHGMPV;};
0235   inline double GetMaxHGMPV()     {return MaxHGMPV;};
0236   inline double GetMinHGLSigma()  {return MinHGLSigma;};
0237   inline double GetMaxHGLSigma()  {return MaxHGLSigma;};
0238   inline double GetMinLGLSigma()  {return MinLGLSigma;};
0239   inline double GetMaxLGLSigma()  {return MaxLGLSigma;};
0240   inline double GetMinHGGSigma()  {return MinHGGSigma;};
0241   inline double GetMaxHGGSigma()  {return MaxHGGSigma;};
0242   inline double GetMinLGGSigma()  {return MinLGGSigma;};
0243   inline double GetMaxLGGSigma()  {return MaxLGGSigma;};
0244   inline double GetMinSBSignal()  {return MinSBSignal;};
0245   inline double GetMaxSBSignal()  {return MaxSBSignal;};
0246   inline double GetMinSBNoise()   {return MinSBNoise;};
0247   inline double GetMaxSBNoise()   {return MaxSBNoise;};
0248   inline double GetMinLGHGOffset(){return MinLGHGOff;};
0249   inline double GetMaxLGHGOffset(){return MaxLGHGOff;};
0250   inline double GetMinHGLGOffset(){return MinHGLGOff;};
0251   inline double GetMaxHGLGOffset(){return MaxHGLGOff;};
0252   
0253   inline int GetNRuns()           {return (int)runNrs.size();};
0254   inline int GetFirstRun()        {if (runNrs.size()> 0) return runNrs[0]; else return -1;};
0255   inline int GetLastRun()         {if (runNrs.size()> 0) return runNrs[runNrs.size()-1]; else return -1;};
0256   inline int GetRunNr(int i)      {if (runNrs.size()> 0 && i < (int)runNrs.size()) return runNrs[i]; else return -1;}
0257   inline int GetVoltage(int i)    {if (voltages.size()> 0 && i < (int)voltages.size()) return voltages[i]; else return -1;}
0258   
0259   // Getters for graphs
0260   inline TGraphErrors* GetHGped()     {return &gTrendHGped;};
0261   inline TGraphErrors* GetLGped()     {return &gTrendLGped;};
0262   inline TGraphErrors* GetHGpedwidth(){return &gTrendHGpedwidth;};
0263   inline TGraphErrors* GetLGpedwidth(){return &gTrendLGpedwidth;};
0264   inline TGraphErrors* GetHGScale()   {return &gTrendHGscale;};
0265   inline TGraphErrors* GetLGScale()   {return &gTrendLGscale;};
0266   inline TGraphErrors* GetLGHGcorr()  {return &gTrendLGHGcorr;};
0267   inline TGraphErrors* GetHGLGcorr()  {return &gTrendHGLGcorr;};
0268   // Getters for extended graphs
0269   inline TGraphErrors* GetTrigger()   {return &gTrendTrigger;};
0270   inline TGraphErrors* GetSBNoise()   {return &gTrendSBNoise;};
0271   inline TGraphErrors* GetSBSignal()  {return &gTrendSBSignal;};
0272   inline TGraphErrors* GetHGLMPV()    {return &gTrendHGLMPV;};
0273   inline TGraphErrors* GetLGLMPV()    {return &gTrendLGLMPV;};
0274   inline TGraphErrors* GetHGLSigma()  {return &gTrendHGLSigma;};
0275   inline TGraphErrors* GetLGLSigma()  {return &gTrendLGLSigma;};
0276   inline TGraphErrors* GetHGGSigma()  {return &gTrendHGGSigma;};
0277   inline TGraphErrors* GetLGGSigma()  {return &gTrendLGGSigma;};
0278   inline TGraphErrors* GetLGHGOff()   {return &gTrendLGHGOffset;};
0279   inline TGraphErrors* GetHGLGOff()   {return &gTrendHGLGOffset;};
0280   // Getters for individual graph histgrams
0281   TH1D* GetHGTriggRun(int);
0282   TH1D* GetLGTriggRun(int);
0283   TProfile* GetLGHGTriggRun(int);
0284   
0285  protected:
0286   int CellID;
0287   int debug;
0288   int extended;
0289   TGraphErrors gTrendLGped    ;
0290   TGraphErrors gTrendHGped    ;
0291   TGraphErrors gTrendLGpedwidth ;
0292   TGraphErrors gTrendHGpedwidth ;
0293   TGraphErrors gTrendLGscale  ;
0294   TGraphErrors gTrendHGscale  ;
0295   TGraphErrors gTrendHGLGcorr ;
0296   TGraphErrors gTrendLGHGcorr ;
0297   TGraphErrors gTrendTrigger  ;
0298 
0299   TGraphErrors gTrendSBNoise  ;
0300   TGraphErrors gTrendSBSignal ;
0301   TGraphErrors gTrendHGLMPV   ;
0302   TGraphErrors gTrendHGLSigma ;
0303   TGraphErrors gTrendHGGSigma ;
0304   TGraphErrors gTrendLGLMPV   ;
0305   TGraphErrors gTrendLGLSigma ;
0306   TGraphErrors gTrendLGGSigma ;
0307   
0308   TGraphErrors gTrendLGHGOffset ;
0309   TGraphErrors gTrendHGLGOffset ;
0310   
0311   double MaxLGped    =0.;
0312   double MaxHGped    =0.;
0313   double MaxLGpedwidth =0.;
0314   double MaxHGpedwidth =0.;
0315   double MaxLGscale  =0.;
0316   double MaxHGscale  =0.;
0317   double MaxHGLGcorr =0.;
0318   double MaxLGHGcorr =0.;
0319   double MaxTrigg    =0.;
0320   double MaxHGSpec   =0.;
0321   double MaxLGSpec   =0.;
0322   double MaxHGMPV    =0.;
0323   double MaxLGMPV    =0.;
0324   double MaxHGLSigma =0.;
0325   double MaxLGLSigma =0.;
0326   double MaxHGGSigma =0.;
0327   double MaxLGGSigma =0.;
0328   double MaxSBNoise  =0.;
0329   double MaxSBSignal =0.;
0330   double MaxLGHGOff  =-10000.;
0331   double MaxHGLGOff  =-10000.;
0332   
0333   double MinLGped    =9999.;
0334   double MinHGped    =9999.;
0335   double MinLGpedwidth =9999.;
0336   double MinHGpedwidth =9999.;
0337   double MinLGscale  =9999.;
0338   double MinHGscale  =9999.;
0339   double MinHGLGcorr =9999.;
0340   double MinLGHGcorr =9999.;
0341   double MinTrigg    =9999.;
0342   double MinHGSpec   =9999.;
0343   double MinLGSpec   =9999.;
0344   double MinHGMPV    =9999.;
0345   double MinLGMPV    =9999.;
0346   double MinHGLSigma =9999.;
0347   double MinLGLSigma =9999.;
0348   double MinHGGSigma =9999.;
0349   double MinLGGSigma =9999.;
0350   double MinSBNoise  =9999.;
0351   double MinSBSignal =9999.;
0352   double MinLGHGOff  =9999.;
0353   double MinHGLGOff  =9999.;
0354   
0355   std::vector<int> runNrs;
0356   std::vector<double> voltages;
0357   std::map<int, TH1D> HGTriggRuns;
0358   std::map<int, TH1D> LGTriggRuns;
0359   std::map<int, TProfile> LGHGTriggRuns;
0360   
0361   ClassDef(TileTrend,4);
0362 };
0363 
0364 #endif