Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 6341)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 6385)
@@ -150,4 +150,5 @@
 #include <TLegend.h>
 #include <TGraph.h>
+#include <TEnv.h>
 
 ClassImp(MHCalibrationChargeCam);
@@ -174,9 +175,5 @@
 const Float_t MHCalibrationChargeCam::fgTimeLowerLimit           = 1.;
 const Float_t MHCalibrationChargeCam::fgTimeUpperLimit           = 3.;
-// 1Led Green, 1 LED blue, 5 LEDs blue, 10 LEDs blue, 10 LEDs UV, CT1, 5Leds Green
-const Float_t MHCalibrationChargeCam::gkHiGainInnerRefLines[7]   = { 245., 323. , 1065., 1467., 258., 211. , 533.5};   
-const Float_t MHCalibrationChargeCam::gkHiGainOuterRefLines[7]   = { 217., 307.5, 932. , 1405., 262.5, 183.5, 405.5};
-const Float_t MHCalibrationChargeCam::gkLoGainInnerRefLines[7]   = { 20.8, 28.0 , 121. , 200.2, 16.5, 13.5 , 41.7 };
-const Float_t MHCalibrationChargeCam::gkLoGainOuterRefLines[7]   = { 18.9, 26.0 , 108.3, 198. , 14.0, 11.  , 42.  };
+const TString MHCalibrationChargeCam::fgReferenceFile = "mjobs/calibrationref.rc";
 // --------------------------------------------------------------------------
 //
@@ -242,4 +239,9 @@
   SetAbsHistXTitle(gsAbsHistXTitle.Data());
   SetAbsHistYTitle(gsAbsHistYTitle.Data());
+
+  SetReferenceFile();
+
+  fInnerRefCharge = 278.;
+  fOuterRefCharge = 282.;
 }
 
@@ -270,4 +272,5 @@
   cam->fLoGainFirst            = fLoGainFirst;
   cam->fLoGainLast             = fLoGainLast;
+  cam->fReferenceFile          = fReferenceFile;
 
   //
@@ -1201,8 +1204,8 @@
          {
            MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
-           DrawDataCheckPixel(lopix,i ? gkLoGainOuterRefLines : gkLoGainInnerRefLines);
+           DrawDataCheckPixel(lopix,i ? fOuterRefCharge : fInnerRefCharge);
          }
        else
-         DrawDataCheckPixel(hipix,i ? gkHiGainOuterRefLines : gkHiGainInnerRefLines);
+         DrawDataCheckPixel(hipix,i ? fOuterRefCharge : fInnerRefCharge);
 
     }      
@@ -1217,5 +1220,5 @@
 // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
 //
-void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[])
+void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline)
 {
   
@@ -1331,55 +1334,10 @@
 
 
-void  MHCalibrationChargeCam::DisplayRefLines(const TH1F *hist, const Float_t refline[]) const
+void  MHCalibrationChargeCam::DisplayRefLines(const TH1F *hist, const Float_t refline) const
 {
 
-  TGraph *green1 = new TGraph(2);
-  green1->SetPoint(0,refline[0],0.1);
-  green1->SetPoint(1,refline[0],hist->GetMaximum());
-  green1->SetBit(kCanDelete);
-  green1->SetLineColor(kGreen);
-  green1->SetLineStyle(2);
-  green1->SetLineWidth(3);
-  green1->Draw("L");
-
-  TGraph *green5 = new TGraph(2);
-  green5->SetPoint(0,refline[6],0.1);
-  green5->SetPoint(1,refline[6],hist->GetMaximum());
-  green5->SetBit(kCanDelete);
-  green5->SetLineColor(8);
-  green5->SetLineStyle(2);
-  green5->SetLineWidth(3);
-  green5->Draw("L");
-
-  TGraph *blue1   = new TGraph(2);
-  blue1->SetPoint(0,refline[1],0.1);
-  blue1->SetPoint(1,refline[1],hist->GetMaximum());
-  blue1->SetBit(kCanDelete);
-  blue1->SetLineColor(227);
-  blue1->SetLineStyle(2);
-  blue1->SetLineWidth(3);
-  blue1->Draw("L");
-
-  TGraph *blue5   = new TGraph(2);
-  blue5->SetPoint(0,refline[2],0.1);
-  blue5->SetPoint(1,refline[2],hist->GetMaximum());
-  blue5->SetBit(kCanDelete);
-  blue5->SetLineColor(68);
-  blue5->SetLineStyle(2);
-  blue5->SetLineWidth(3);
-  blue5->Draw("L");
-
-  TGraph *blue10   = new TGraph(2);
-  blue10->SetPoint(0,refline[3],0.1);
-  blue10->SetPoint(1,refline[3],hist->GetMaximum());
-  blue10->SetBit(kCanDelete);
-  blue10->SetLineColor(4);
-  blue10->SetLineStyle(2);
-  blue10->SetLineWidth(3);
-  blue10->Draw("L");
-
   TGraph *uv10    = new TGraph(2);
-  uv10->SetPoint(0,refline[4],0.1);
-  uv10->SetPoint(1,refline[4],hist->GetMaximum());
+  uv10->SetPoint(0,refline,0.1);
+  uv10->SetPoint(1,refline,hist->GetMaximum());
   uv10->SetBit(kCanDelete);
   uv10->SetLineColor(106);
@@ -1388,22 +1346,7 @@
   uv10->Draw("L");
 
-  TGraph *ct1    = new TGraph(2);
-  ct1->SetPoint(0,refline[5],0.1);
-  ct1->SetPoint(1,refline[5],hist->GetMaximum());
-  ct1->SetBit(kCanDelete);
-  ct1->SetLineColor(6);
-  ct1->SetLineStyle(2);
-  ct1->SetLineWidth(3);
-  ct1->Draw("L");
-
   TLegend *leg = new TLegend(0.8,0.35,0.99,0.99);
   leg->SetBit(kCanDelete);
-  leg->AddEntry(green1,"1 Led GREEN","l");
-  leg->AddEntry(green5,"5 Leds GREEN","l");
-  leg->AddEntry(blue1,"1 Led BLUE","l");
-  leg->AddEntry(blue5,"5 Leds BLUE","l");
-  leg->AddEntry(blue10,"10 Leds BLUE","l");
   leg->AddEntry(uv10,"10 Leds UV","l");
-  leg->AddEntry(ct1,"CT1-Pulser","l");
 
   leg->Draw();
@@ -1466,5 +1409,15 @@
     }
    
- 
+  if (IsEnvDefined(env, prefix, "ReferenceFile", print))
+    {
+      SetReferenceFile(GetEnvValue(env,prefix,"ReferenceFile",fReferenceFile.Data()));
+      rc = kTRUE;
+    }
+
+  TEnv refenv(fReferenceFile);
+
+  fInnerRefCharge = refenv.GetValue("InnerRefCharge",fInnerRefCharge);
+  fOuterRefCharge = refenv.GetValue("OuterRefCharge",fOuterRefCharge);
+
   return rc;
 }
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 6341)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 6385)
@@ -32,4 +32,6 @@
   static const Float_t fgProbLimit;                  //! The default for fProbLimit    (now set to: 0.00001)
   
+  static const TString fgReferenceFile;              //! default for fReferenceFile ("mjobs/calibrationref.rc")
+
   static const TString gsHistName;                   //! Default Histogram names
   static const TString gsHistTitle;                  //! Default Histogram titles
@@ -37,8 +39,8 @@
   static const TString gsHistYTitle;                 //! Default Histogram y-axis titles
   
-  static const TString gsAbsHistName;               //! Default Histogram names abs.times
-  static const TString gsAbsHistTitle;              //! Default Histogram titles abs.times
-  static const TString gsAbsHistXTitle;             //! Default Histogram x-axis titles abs.times
-  static const TString gsAbsHistYTitle;             //! Default Histogram y-axis titles abs.times
+  static const TString gsAbsHistName;                //! Default Histogram names abs.times
+  static const TString gsAbsHistTitle;               //! Default Histogram titles abs.times
+  static const TString gsAbsHistXTitle;              //! Default Histogram x-axis titles abs.times
+  static const TString gsAbsHistYTitle;              //! Default Histogram y-axis titles abs.times
   
   static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit (now at: 0.01)
@@ -48,9 +50,4 @@
   static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit    (now set to: 2.)
   
-  static const Float_t gkHiGainInnerRefLines[7];     //!
-  static const Float_t gkHiGainOuterRefLines[7];     //!
-  static const Float_t gkLoGainInnerRefLines[7];     //!
-  static const Float_t gkLoGainOuterRefLines[7];     //!
-
   Int_t   fLoGainNbins;                              // Number of LoGain bins        
   Axis_t  fLoGainFirst;                              // Lower histogram limit low gain
@@ -62,4 +59,9 @@
   TString fAbsHistYTitle;                            // Histogram y-axis titles abs. times
   
+  TString fReferenceFile;                            // File name containing the reference values
+
+  Float_t fInnerRefCharge;                           // The reference mean arrival time inner pixels
+  Float_t fOuterRefCharge;                           // The reference mean arrival time outer pixels
+
   MArrayD fSumhiarea  ;                              //!
   MArrayD fSumloarea  ;                              //!
@@ -76,12 +78,12 @@
   MArrayI fSatlosector;                              //!
 
-  Float_t fTimeLowerLimit;            // Limit dist. to first signal slice (in units of FADC slices) 
-  Float_t fTimeUpperLimit;            // Limit dist. to last signal slice  (in units of FADC slices) 
-  Byte_t  fFirstHiGain;               // First used slice High Gain 
-  Byte_t  fLastHiGain;                // Last used slice High Gain
-  Byte_t  fFirstLoGain;               // First used slice Low Gain
-  Byte_t  fLastLoGain;                // Last used slice Low Gain
+  Float_t fTimeLowerLimit;                           // Limit dist. to first signal slice (in units of FADC slices) 
+  Float_t fTimeUpperLimit;                           // Limit dist. to last signal slice  (in units of FADC slices) 
+  Byte_t  fFirstHiGain;                              // First used slice High Gain 
+  Byte_t  fLastHiGain;                               // Last used slice High Gain
+  Byte_t  fFirstLoGain;                              // First used slice Low Gain
+  Byte_t  fLastLoGain;                               // Last used slice Low Gain
   
-  MRawEvtData         *fRawEvt;       //!  Raw event data 
+  MRawEvtData         *fRawEvt;                      //!  Raw event data 
 
   Bool_t SetupHists(const MParList *pList);
@@ -97,6 +99,6 @@
   void   FinalizeBadPixels();
 
-  void   DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[]);
-  void   DisplayRefLines   ( const TH1F *hist,           const Float_t refline[]) const;
+  void   DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline);
+  void   DisplayRefLines   ( const TH1F *hist,           const Float_t refline) const;
 
   Int_t ReadEnv        ( const TEnv &env, TString prefix, Bool_t print);
@@ -110,21 +112,23 @@
   TObject *Clone(const char *name="") const;
 
-  void SetLoGainNbins       ( const Int_t  i )       { fLoGainNbins   = i; }
-  void SetLoGainFirst       ( const Axis_t f )       { fLoGainFirst   = f; }
-  void SetLoGainLast        ( const Axis_t f )       { fLoGainLast    = f; }  
+  // Draw
+  void   Draw(const Option_t *opt);
 
-  void SetTimeLowerLimit    ( const Float_t f=fgTimeLowerLimit ) { fTimeLowerLimit = f; }
-  void SetTimeUpperLimit    ( const Float_t f=fgTimeUpperLimit ) { fTimeUpperLimit = f; }
+  void SetAbsHistName   ( const char *name )  { fAbsHistName   = name; }
+  void SetAbsHistTitle  ( const char *name )  { fAbsHistTitle  = name; }
+  void SetAbsHistXTitle ( const char *name )  { fAbsHistXTitle = name; }
+  void SetAbsHistYTitle ( const char *name )  { fAbsHistYTitle = name; }
+   
+  void SetLoGainNbins   ( const Int_t  i )    { fLoGainNbins   = i; }
+  void SetLoGainFirst   ( const Axis_t f )    { fLoGainFirst   = f; }
+  void SetLoGainLast    ( const Axis_t f )    { fLoGainLast    = f; }  
+
+  void SetReferenceFile ( const TString ref=fgReferenceFile ) { fReferenceFile  = ref; }
+
+  void SetTimeLowerLimit( const Float_t f=fgTimeLowerLimit )  { fTimeLowerLimit = f; }
+  void SetTimeUpperLimit( const Float_t f=fgTimeUpperLimit )  { fTimeUpperLimit = f; }
   
-  void SetAbsHistName  ( const char *name )  { fAbsHistName  = name;  }
-  void SetAbsHistTitle ( const char *name )  { fAbsHistTitle = name;  }
-  void SetAbsHistXTitle( const char *name )  { fAbsHistXTitle = name; }
-  void SetAbsHistYTitle( const char *name )  { fAbsHistYTitle = name; }
-   
   Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const { return kTRUE; }
   void   DrawPixelContent( Int_t num )  const;    
-
-  // Draw
-  void   Draw(const Option_t *opt);
 
   ClassDef(MHCalibrationChargeCam, 1)	// Histogram class for Charge Camera Calibration 
