Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 5067)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 5111)
@@ -214,4 +214,8 @@
   SetDebug             ( kFALSE );
   SetIntensity         ( kFALSE );
+
+  SetNoStorage         ( kFALSE );
+  SetHistsStorage      ( kFALSE );
+
 }
 
@@ -983,6 +987,4 @@
           
         }
-      
-      
       return;
     }
@@ -1306,14 +1308,4 @@
 
     return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
-}
-
-Bool_t MJCalibration::IsUseBlindPixel() const 
-{
-    return TESTBIT(fDevices,kUseBlindPixel);
-}
-
-Bool_t MJCalibration::IsUsePINDiode() const 
-{
-    return TESTBIT(fDevices,kUsePINDiode);
 }
 
@@ -1490,5 +1482,5 @@
 
     // --------------------------------------------------------------------------------
-
+    
     // Setup Tasklist
     MParList plist;
@@ -1546,9 +1538,11 @@
     // Initialize two histogram containers which could be modified in this class
     //
+    MHCalibrationRelTimeCam     reltimecam;
     MHCalibrationChargeCam      chargecam;
     MHCalibrationChargeBlindCam blindcam;
     plist.AddToList(&chargecam);
     plist.AddToList(&blindcam);
-
+    if (IsRelTimes())
+      plist.AddToList(&reltimecam);
     //
     // Data Reading tasks
@@ -1614,5 +1608,5 @@
         drawoption += "datacheck";
     if (fDisplayType == kFullDisplay)
-        drawoption += " all";
+        drawoption += "all";
 
     fillcam.SetDrawOption(drawoption.Data());
@@ -1742,7 +1736,16 @@
     DisplayResult(plist);
 
-    if (!WriteResult(plist.FindObject("MGeomCam")))
-        return kFALSE;
-
+    if (!IsNoStorage())
+      {
+        if (!WriteResult(plist.FindObject("MGeomCam")))
+          return kFALSE;
+      }
+
+    if (IsHistsStorage())
+      {
+        if (!WriteHists(plist))
+          return kFALSE;
+      }
+    
     *fLog << all << GetDescriptor() << ": Done." << endl;
 
@@ -1759,4 +1762,8 @@
 Bool_t MJCalibration::ReadCalibrationCam()
 {
+  
+  if (IsNoStorage())
+    return kFALSE;
+
   const TString fname = GetOutputFile();
   
@@ -1887,8 +1894,11 @@
 // The following containers are written:
 // - MStatusDisplay
-// - MCalibrationChargeCam or MCalibrationIntensityChargeCam 
-// - MCalibrationBlindCam  or MCalibrationIntensityBlindCam
-// - MCalibrationQECam     or MCalibrationIntensityQECam     
+// - MCalibrationChargeCam  or MCalibrationIntensityChargeCam 
+// - MCalibrationBlindCam   or MCalibrationIntensityBlindCam
+// - MCalibrationQECam      or MCalibrationIntensityQECam     
+// - MCalibrationChargePINDiode
 // - MBadPixelsCam
+// If the flag kRelTimes is set, then also:
+// - MCalibrationRelTimeCam or MCalibrationIntensityRelTimeCam     
 //
 Bool_t MJCalibration::WriteResult(TObject *geom)
@@ -1926,4 +1936,5 @@
     else
     {
+        cont.Add(&fBadPixels);
         cont.Add(&fCalibrationCam);
         cont.Add(&fQECam);
@@ -1931,16 +1942,51 @@
     }
     cont.Add(&fCalibrationPINDiode);
-    cont.Add(&fBadPixels);
     if (IsRelTimes())
-          cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
+      cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
 
     if (!geom)
         *fLog << warn << " - WARNING - MGeomCam... not found!" << endl;
     else
-        cont.Add(geom);
+      cont.Add(geom);
 
     return WriteContainer(cont);
-
-    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the calibration histograms into the output file GetOutputFile(), 
+// if fOutputPath exists.
+// 
+// The following containers are written:
+// - MHCalibrationChargeCam
+// - MHCalibrationChargeBlindCam
+// - MHCalibrationChargePINDiode
+// If the flag kRelTimes is set, then also:
+// - MHCalibrationRelTimeBlindCam
+//
+Bool_t MJCalibration::WriteHists(MParList &plist)
+{
+    if (fPathOut.IsNull())
+        return kTRUE;
+
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
+    if (!file.IsOpen())
+    {
+        *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
+        return kFALSE;
+    }
+
+    TObjArray cont;
+    cont.Add(plist.FindObject("MHCalibrationChargeCam"));
+    cont.Add(plist.FindObject("MHCalibrationChargeBlindCam"));
+    cont.Add(plist.FindObject("MHCalibrationChargePINDiode"));
+    if (IsRelTimes())
+      cont.Add(plist.FindObject("MHCalibrationRelTimeCam"));
+
+    return WriteContainer(cont);
 }
 
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 5067)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 5111)
@@ -116,4 +116,12 @@
   Byte_t fDevices;                                     // Bit-field for used devices for calibration
 
+  enum  Storage_t                                       // Possible devices for calibration
+    {
+      kNoStorage,
+      kHistsStorage
+    }; 
+  
+  Byte_t fStorage;                                     // Bit-field for chosen storage type
+
   enum { kRelTimes, kDataCheck, kDebug, kIntensity };  // Possible flags
 
@@ -121,4 +129,15 @@
   
   TString fGeometry;                                   // Class name geometry
+  
+  Bool_t IsUseBlindPixel() const { return TESTBIT(fDevices,kUseBlindPixel); }
+  Bool_t IsUsePINDiode  () const { return TESTBIT(fDevices,kUsePINDiode);   }
+
+  Bool_t IsRelTimes     () const { return TESTBIT(fFlags,kRelTimes);  }
+  Bool_t IsDataCheck    () const { return TESTBIT(fFlags,kDataCheck); }
+  Bool_t IsDebug        () const { return TESTBIT(fFlags,kDebug);     }
+  Bool_t IsIntensity    () const { return TESTBIT(fFlags,kIntensity); }
+
+  Bool_t IsNoStorage    () const { return TESTBIT(fStorage,kNoStorage);    }
+  Bool_t IsHistsStorage () const { return TESTBIT(fStorage,kHistsStorage); }
   
   void   DisplayResult        ( MParList &plist );
@@ -130,4 +149,5 @@
   
   Bool_t WriteResult   ( TObject *geom );
+  Bool_t WriteHists    ( MParList &plist );
   Bool_t WriteEventloop( MEvtLoop &evtloop   ) const;
   Bool_t WriteTasks    ( MTask *t1, MTask *t2) const;
@@ -152,12 +172,4 @@
   MCalibrationQECam               &GetQECam()                { return fQECam;            }
   MBadPixelsCam                   &GetBadPixels()            { return fBadPixels;        }
-  
-  Bool_t IsUseBlindPixel() const;
-  Bool_t IsUsePINDiode  () const;
-
-  Bool_t IsRelTimes     () const { return TESTBIT(fFlags,kRelTimes);  }
-  Bool_t IsDataCheck    () const { return TESTBIT(fFlags,kDataCheck); }
-  Bool_t IsDebug        () const { return TESTBIT(fFlags,kDebug);     }
-  Bool_t IsIntensity    () const { return TESTBIT(fFlags,kIntensity); }
   
   void SetBadPixels(const MBadPixelsCam &bad)               { bad.Copy(fBadPixels); }
@@ -187,4 +199,8 @@
   void SetUsePINDiode(const Bool_t b=kTRUE);
 
+  // Storage
+  void SetNoStorage    ( const Bool_t b=kTRUE ) { b ? SETBIT(fStorage,kNoStorage)    : CLRBIT(fStorage,kNoStorage); }
+  void SetHistsStorage ( const Bool_t b=kTRUE ) { b ? SETBIT(fStorage,kHistsStorage) : CLRBIT(fStorage,kHistsStorage); }
+  
   // Precessing
   Bool_t ReadCalibrationCam();
