Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5840)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5841)
@@ -31,4 +31,5 @@
 
 
+
  2005/01/14 Thomas Bretz
  
@@ -69,4 +70,22 @@
    * msignal/MExtractTimeFastSpline.cc:
      - fixed delete --> delete[]
+
+   * mbadpixels/MBadPixelsCalc.cc:
+     - slight change to some output
+
+   * mbase/MTaskEnv.h:
+     - set name of default task when pointer is given
+
+   * mjobs/MJCalibrateSignal.cc:
+     - fixed handling of extraction range for various cases
+     - fixed handling in case no arrival times are calculated
+
+   * mjobs/MJCalibration.cc:
+     - write at least a default arrival time calibration container
+       to make further processing easier
+
+   * mjobs/MJPedestal.[h,cc]:
+     - fixed handling of extraction range for various cases
+
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 5840)
+++ trunk/MagicSoft/Mars/NEWS	(revision 5841)
@@ -37,9 +37,14 @@
      MTriggerPattern, MTriggerPatternDecode and MFTriggerPattern
 
-   - changed callisto to calculate two kinds of pedestals and pedestal rms:
+   - implemented filters to callisto to skip calibration events
+
+   - changed callisto to calculate three kinds of pedestals and pedestal rms:
      + fundamental pedestal (MPedPhotFundamental): extracted directly from
        the slices by statistics                              
      + pedestal from extractor (MPedPhotFromExtractor): extracted with the
        signal extractor without randomization
+     + random pedestal from extractor (MPedPhotFromExtractorRndm): extracted
+       with the signal extractor with randomization (extraction window is 
+       randomly fixed)
      The thir kind of pedestal is not yet implemented (for speed reasons) as
      long as nobody really needs it:
Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 5840)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 5841)
@@ -120,5 +120,5 @@
     }
 
-    *fLog << inf << "Name of MPedPhotCam to get 'pedestal rms' from used: " << fNamePedPhotCam << endl;
+    *fLog << inf << "Name of MPedPhotCam to get pedestal rms from: " << fNamePedPhotCam << endl;
     if (fPedestalLevel)
         *fLog << "Checking mean 'pedestal rms' against absolute value with level " << fPedestalLevel << endl;
Index: trunk/MagicSoft/Mars/mbase/MTaskEnv.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskEnv.h	(revision 5840)
+++ trunk/MagicSoft/Mars/mbase/MTaskEnv.h	(revision 5841)
@@ -32,5 +32,5 @@
     void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
 
-    void SetDefault(MTask *task) { fTask = task; if (!task) SetBit(kIsDummy); }
+    void SetDefault(MTask *task) { fTask = task; if (fTask) fTask->SetName(fName); else SetBit(kIsDummy); }
     void SetDefault(const char *def);
 
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5840)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5841)
@@ -177,5 +177,5 @@
 //
 // For more details see the class description and the corresponding Getters
-// 
+//
 Bool_t MJCalibrateSignal::CheckEnvLocal()
 {
@@ -282,7 +282,4 @@
     plist.AddToList(&calibcont);
 
-    pedcamab.SetName("MPedestalFundamental");
-    plist.AddToList(&pedcamab);
-
     // Setup Tasklist
     MTaskList tlist;
@@ -364,9 +361,5 @@
     if (extractor1)
     {
-        // FIXME: How to get the fixed value 15 automatically?
-        const Float_t win = extractor1->GetNumHiGainSamples();
-        pedlo1.SetExtractWindow(15, (UShort_t)TMath::Nint(win));
-        pedlo2.SetExtractWindow(15, (UShort_t)TMath::Nint(win));
-        pedlo3.SetExtractWindow(15, (UShort_t)TMath::Nint(win));
+        extractor1->SetPedestals(&pedcamab);
 
         if (extractor1->InheritsFrom("MExtractTimeAndCharge"))
@@ -374,7 +367,20 @@
             pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor1);
             pedlo3.SetExtractor((MExtractTimeAndCharge*)extractor1);
-            extractor1->SetPedestals(&pedcamab);
+            pedlo1.SetExtractWindow(15, 0/*obsolete*/);
+            pedlo2.SetExtractWindow(15, 0/*obsolete*/);
+            pedlo3.SetExtractWindow(15, 0/*obsolete*/);
         }
-    }
+        else
+        {
+            // FIXME: How to get the fixed value 15 automatically?
+            const Int_t f = (Int_t)(15.5+extractor1->GetHiGainFirst());
+            const Int_t n = (Int_t)(15.5+extractor1->GetNumHiGainSamples());
+            pedlo1.SetExtractWindow(f, n);
+            pedlo2.SetExtractWindow(f, n);
+            pedlo3.SetExtractWindow(f, n);
+        }
+    }
+    if (extractor2)
+        extractor2->SetPedestals(&pedcamab);
 
     MFCosmics fcosmics;
@@ -414,4 +420,6 @@
     treat.AddNamePedPhotCam("MPedPhotFromExtractor");
     treat.AddNamePedPhotCam("MPedPhotFromExtractorRndm");
+    if (!extractor2 && !extractor1->InheritsFrom("MExtractTimeAndCharge"))
+        treat.SetProcessTimes(kFALSE);
 
 
@@ -461,5 +469,5 @@
     write.AddContainer("MTime",                     "Events",     kFALSE);
     write.AddContainer("MRawEvtHeader",             "Events");
-    write.AddContainer("MArrivalTime",              "Events");
+    write.AddContainer("MArrivalTime",              "Events",     kFALSE);
     // Slow-Control: Current
     write.AddContainer("MTimeCurrents",             "Currents",   kFALSE);
@@ -509,5 +517,6 @@
     tlist2.AddToList(&fill2);
     tlist2.AddToList(&calib);
-    tlist2.AddToList(&caltm);
+    if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
+        tlist2.AddToList(&caltm);
     tlist2.AddToList(&bpcal);
     tlist2.AddToList(&treat);
@@ -516,5 +525,6 @@
     tlist2.AddToList(&fill4);
     tlist2.AddToList(&fill5);
-    tlist2.AddToList(&fill7);
+    if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
+        tlist2.AddToList(&fill7);
 
     // Setup List for Drive-tree
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 5840)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 5841)
@@ -1711,5 +1711,5 @@
     {
         taskenv2.SetDefault(fTimeExtractor);
-    
+   
         if (IsRelTimes())
             tlist.AddToList(&taskenv2);
@@ -1760,5 +1760,5 @@
     }
 
-    if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
+    if (!WriteTasks(taskenv.GetTask(), IsRelTimes() ? taskenv2.GetTask() : 0))
         return kFALSE;
 
@@ -1995,6 +1995,6 @@
     cont.Add(&fCalibrationPINDiode);
 
-    if (IsRelTimes())
-        cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
+    //if (IsRelTimes())
+    cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
 
     if (!geom)
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 5840)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 5841)
@@ -783,19 +783,4 @@
 }
 
-Bool_t MJPedestal::SetupExtractor(MParList &plist, MExtractPedestal &extped)
-{
-    if (!fExtractor)
-        return kTRUE;
-
-    if (fExtractionType==kFundamental || !fExtractor->InheritsFrom("MExtractTimeAndCharge"))
-        return kFALSE;
-
-    extped.SetPedestalsIn(&fPedestalCamIn);
-    extped.SetExtractor((MExtractTimeAndCharge*)fExtractor);
-    extped.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
-
-    return kTRUE;
-}
-
 Bool_t MJPedestal::ProcessFile()
 {
@@ -908,21 +893,22 @@
     }
 
+    // ----------------------------------------------------------------------
+    //   Now we make sure, that in all cases the ranges are setup correctly
+    // ----------------------------------------------------------------------
     MTaskEnv taskenv("ExtractPedestal");
     switch (fExtractType)
     {
+    case kUsePedRun:
+        // In case  other than 'fundamental' second argument is obsolete
+        pedcalc.SetExtractWindow(0, 13);  // kUsePedRun
+        taskenv.SetDefault(&pedcalc);
+        tlist.AddToList(&taskenv);
+        break;
+
     case kUseData:
+        // In case  other than 'fundamental' second argument is obsolete
+        pedlogain.SetExtractWindow(15, 28); // kUseData
         taskenv.SetDefault(&pedlogain);
         tlist.AddToList(&taskenv);
-
-        if (!SetupExtractor(plist, pedlogain))
-            pedlogain.SetExtractWindow(15, (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
-        break;
-
-    case kUsePedRun:
-        taskenv.SetDefault(&pedcalc);
-        tlist.AddToList(&taskenv);
-
-        if (!SetupExtractor(plist, pedcalc))
-            pedcalc.SetExtractWindow(fExtractor->GetHiGainFirst(), TMath::Nint(fExtractor->GetNumHiGainSamples()));
         break;
 
@@ -940,4 +926,76 @@
     }
 
+    pedcalc.SetPedestalsIn(&fPedestalCamIn);
+    pedlogain.SetPedestalsIn(&fPedestalCamIn);
+
+     // kFundamental
+    if (fExtractor)
+    {
+        if (!fExtractor->InheritsFrom("MExtractTimeAndCharge"))
+        {
+            const Float_t f = 0.5+fExtractor->GetHiGainFirst();
+            const Float_t n = 0.5+fExtractor->GetNumHiGainSamples();
+            pedcalc.SetExtractWindow((Int_t)f, (Int_t)n);
+            pedlogain.SetExtractWindow((Int_t)(15+f), (Int_t)(15+n));
+
+            if (fExtractionType!=kFundamental)
+            {
+                *fLog << inf;
+                *fLog << "Signal extractor doesn't inherit from MExtractTimeAndCharge..." << endl;
+                *fLog << " --> falling back to fundamental pedestal extraction." << endl;
+                fExtractionType=kFundamental;
+            }
+        }
+        else
+        {
+            pedcalc.SetExtractor((MExtractTimeAndCharge*)fExtractor);
+            pedlogain.SetExtractor((MExtractTimeAndCharge*)fExtractor);
+        }
+
+        if (fExtractionType!=kFundamental)
+        {
+            pedcalc.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
+            pedlogain.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
+        }
+    }
+
+    /*
+    switch (fExtractType)
+    {
+    case kUseData:
+        *fLog << all << "TYPE: USEDATA " << fExtractor << endl;
+        taskenv.SetDefault(&pedlogain);
+        tlist.AddToList(&taskenv);
+
+        if (!SetupExtractor(plist, pedlogain))
+        {
+            *fLog << all <<  "SETTING TO: " << fExtractor << " " << fExtractor->GetNumHiGainSamples() << endl;
+            fExtractor->Print();
+            pedlogain.SetExtractWindow(15, (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
+        }
+        break;
+
+    case kUsePedRun:
+        *fLog << all <<  "TYPE: USEPEDRUN " << fExtractor << endl;
+        taskenv.SetDefault(&pedcalc);
+        tlist.AddToList(&taskenv);
+
+        if (!SetupExtractor(plist, pedcalc))
+            pedcalc.SetExtractWindow(fExtractor->GetHiGainFirst(), TMath::Nint(fExtractor->GetNumHiGainSamples()));
+        break;
+
+    case kUseHists:
+        if (!fExtractor)
+        {
+            *fLog << err << GetDescriptor() << " - ERROR: ";
+            *fLog << "Extraction Type is kUseHists, but no extractor was set" << endl;
+            return kFALSE;
+        }
+
+        tlist.AddToList(fExtractor);
+        tlist.AddToList(&fillped);
+        break;
+    } */
+
     /*
     if (!fPathIn.IsNull())
