Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 6767)
+++ trunk/MagicSoft/Mars/Changelog	(revision 6768)
@@ -21,4 +21,10 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/03/07 Markus Gaug
+
+   * mjobs/MJPedestal.[h,cc]
+     - modified range setting according Thomas S. suggestions
+
+
  2005/03/05 Markus Gaug
   
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6767)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6768)
@@ -92,6 +92,8 @@
 using namespace std;
 
-const TString  MJPedestal::fgReferenceFile = "mjobs/pedestalref.rc";
-const TString  MJPedestal::fgBadPixelsFile = "mjobs/badpixels_0_559.rc";
+const TString  MJPedestal::fgReferenceFile   = "mjobs/pedestalref.rc";
+const TString  MJPedestal::fgBadPixelsFile   = "mjobs/badpixels_0_559.rc";
+const Float_t  MJPedestal::fgExtractWinLeft  = 2.5;
+const Float_t  MJPedestal::fgExtractWinRight = 6.0;
 // --------------------------------------------------------------------------
 //
@@ -116,4 +118,6 @@
     SetBadPixelsFile();
 
+    SetExtractWinLeft();
+    SetExtractWinRight();
     //
     // Default references for case that no value references file is there
@@ -301,4 +305,5 @@
     disp1.SetCamError  (fPedestalCamOut, 3);
 
+    /*
     if (fIsUseHists)
       {
@@ -340,4 +345,5 @@
           }
       }
+    */
     
     if (fExtractionType!=kFundamental/*fExtractorResolution*/)
@@ -381,5 +387,5 @@
     // Display data
     //
-    if (fDisplayType != kDisplayDataCheck &&  !fIsUseHists && fExtractionType==kFundamental/*fExtractorResolution*/)
+    if (fDisplayType != kDisplayDataCheck &&  fExtractionType==kFundamental/*fExtractorResolution*/)
       {
         TCanvas &c3 = fDisplay->AddTab("Pedestals");
@@ -391,4 +397,5 @@
       }
     
+#if 0
     if (fIsUseHists)
       {
@@ -406,5 +413,5 @@
         disp5.CamDraw(c4, 2, 2, 5);
 
-
+        /*
         TCanvas &c5 = fDisplay->AddTab("Difference Hist.");
         c5.Divide(2,3);
@@ -412,4 +419,5 @@
         disp6.CamDraw(c5, 1, 2, 1);
         disp7.CamDraw(c5, 2, 2, 5);
+        */
 
         TCanvas &c6 = fDisplay->AddTab("Difference Calc.");
@@ -420,5 +428,5 @@
         return;
       }
-
+#endif
     if (fDisplayType == kDisplayDataCheck)
       {
@@ -812,4 +820,8 @@
     }
 
+
+    SetExtractWinLeft (GetEnv("ExtractWinLeft",  fExtractWinLeft ));
+    SetExtractWinRight(GetEnv("ExtractWinRight", fExtractWinRight));
+
     if (!MJCalib::CheckEnvLocal())
         return kFALSE;
@@ -996,4 +1008,5 @@
     MHPedestalCam hpedcam;
     //    fPedestalHist.SetRenorm(kTRUE);
+    //    fPedestalHist.SetPedestalsOut(&fPedestalCamOut);
 
     MPedestalCam pedinter;
@@ -1001,6 +1014,6 @@
 
     MFillH fillped(&hpedcam, "MPedestalCamIntermediate", "FillPedCam");
+    //    MFillH fillped(&fPedestalHist, "MPedestalCamIntermediate", "FillPedCam");
     MFillH fillpul("MHCalibrationPulseTimeCam", "MRawEvtData", "FillPulseTime");
-    //    MFillH fillped(&fPedestalHist, "MPedestalCamIntermediate", "FillPedCam");
     fillped.SetBit(MFillH::kDoNotDisplay);
     fillpul.SetBit(MFillH::kDoNotDisplay);
@@ -1012,5 +1025,5 @@
     sel.SetNumSelectEvts(0);
      
-    if (fExtractionType!=kFundamental)
+    if (fExtractionType!=kFundamental && fExtractor)
       {
         fExtractor->SetFilter(&sel);
@@ -1235,5 +1248,5 @@
             const Float_t rmspulsetime = cam->GetAverageArea(0).GetHiGainRms();
             *fLog << inf << "Mean pulse time (cosmics): " << meanpulsetime << "+-" << rmspulsetime << endl;
-            const Int_t newfirst = (Int_t)(meanpulsetime-2.5);
+            const Int_t newfirst = (Int_t)(meanpulsetime-fExtractWinLeft);
             Int_t wshigain = fExtractor->InheritsFrom("MExtractTimeAndCharge") 
               ?  ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain()
@@ -1244,6 +1257,7 @@
               ? ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeLoGain()
               : 6;
-            const Int_t newlast  = (Int_t)(meanpulsetime+6.);
-            *fLog << inf << "Try to set new range limits: ("<<newfirst<<","<<newlast+wshigain<<")"<<endl;
+            const Int_t newlast  = (Int_t)(meanpulsetime+fExtractWinRight);
+            *fLog << inf << "Try to set new range limits: ("<<newfirst<<","<<newlast<<"+"<<wshigain
+                  <<","<<newfirst<<","<<newlast<<"+"<<wslogain<<")"<<endl;
             if (newfirst < 0)
               {
@@ -1251,8 +1265,8 @@
                 return kFALSE;
               }
-            if (newlast+wshigain > data->GetNumHiGainSamples())
+            if (newlast+wshigain > data->GetNumHiGainSamples()+data->GetNumLoGainSamples()-1)
               {
-                *fLog << err << "Pulse is too much to the right, cannot go beyond higain limits! " 
-                      << " Try to use a different extractor ... " << endl;
+                *fLog << err << "Pulse is too much to the right, cannot go beyond limits! " 
+                      << " Cannot extract at all! ... " << endl;
                 return kFALSE;
               }
@@ -1263,5 +1277,5 @@
                 return kFALSE;
               }
-            fExtractor->SetRange(newfirst,newlast+wshigain,newfirst,data->GetNumLoGainSamples());
+            fExtractor->SetRange(newfirst,newlast+wshigain,newfirst,data->GetNumLoGainSamples()-1);
             if (!WriteExtractor())
               {
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 6767)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 6768)
@@ -27,6 +27,9 @@
 private:
 
-    static const TString  fgReferenceFile;   //! default for fReferenceFile ("pedestalref.rc")
-    static const TString  fgBadPixelsFile;   //! default for fBadPixelsFile ("badpixels_0_559.rc")
+    static const TString  fgReferenceFile;    //! default for fReferenceFile ("pedestalref.rc")
+    static const TString  fgBadPixelsFile;    //! default for fBadPixelsFile ("badpixels_0_559.rc")
+
+    static const Float_t  fgExtractWinLeft;   //! default for fExtractWinLeft  (now set to: 2.5)
+    static const Float_t  fgExtractWinRight;  //! default for fExtractWinRight (now set to: 6.0)
 
     Axis_t fPedestalMin;                     //! Minimum Axis value for pedestal datacheck display
@@ -47,4 +50,7 @@
     Float_t fRefPedRmsGalacticOuter;         //! Ref. line ped. RMS for galactic source - outer pixels
 
+    Float_t fExtractWinLeft;                 //  Number of FADC slices to extract leftward from mean pulse pos.  
+    Float_t fExtractWinRight;                //  Number of FADC slices to extract rightward from mean pulse pos.
+    
     TString fReferenceFile;                  // File name containing the reference values
     TString fBadPixelsFile;                  // File name containing the bad pixels excluded beforehand 
@@ -119,4 +125,7 @@
     void SetBadPixelsFile( const TString ref=fgBadPixelsFile ) { fBadPixelsFile = ref; }
 
+    void SetExtractWinLeft ( const Float_t f=fgExtractWinLeft  ) { fExtractWinLeft  = f; }
+    void SetExtractWinRight( const Float_t f=fgExtractWinRight ) { fExtractWinRight = f; }    
+
     MExtractor *GetExtractor() const { return fExtractor; }
 
