]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDDisplay.cxx
fix requested by Laurent Aphecetche to clean up the memory properly during simulation...
[u/mrichter/AliRoot.git] / FMD / AliFMDDisplay.cxx
index 3832b9e7d064544435536b2c0fc7aff37c4c476d..2122e77fe57404992f0213d4153d5b5f8ccb3a49 100644 (file)
@@ -131,7 +131,10 @@ AliFMDDisplay::AliFMDDisplay(Bool_t onlyFMD, const char* gAliceFile)
     fAux(0), 
     fReturn(kFALSE), 
     fContinous(kFALSE),
-    fTimeout("gApplication->StopIdleing()", 10)
+    fTimeout("gApplication->StopIdleing()", 10), 
+    fInitialMin(0), 
+    fInitialMax(1), 
+    fInitialFactor(3/10.)
 {
   // Constructor of an FMD display object. 
   // Must be called 
@@ -175,13 +178,15 @@ AliFMDDisplay::MakeCanvas(const char** which)
   Double_t xb = 1;
   fCanvas->cd();
   if (TESTBIT(fTreeMask, kDigits) || 
+      TESTBIT(fTreeMask, kRawCalib) || 
       TESTBIT(fTreeMask, kRaw)) { 
     yb = .05;
     xb = .66;
     fFactor = new TSlider("pedFactor", "Pedestal Factor", xb+.01, 0, 1, yb);
     fFactor->SetMethod("AliFMDDisplay::Instance()->ChangeFactor()");
-    fFactor->SetRange(3./10, 1);
+    fFactor->SetRange(fInitialFactor, 1);
     fFactor->Draw();
+    fFactor->SetMinimum(fInitialFactor);
     TSliderBox *sbox = 
       static_cast<TSliderBox*>(fFactor->GetListOfPrimitives()->
                               FindObject("TSliderBox"));
@@ -194,11 +199,12 @@ AliFMDDisplay::MakeCanvas(const char** which)
       TESTBIT(fTreeMask, kESD)     || 
       TESTBIT(fTreeMask, kDigits)  || 
       TESTBIT(fTreeMask, kSDigits) || 
-      TESTBIT(fTreeMask, kRaw)) {
+      TESTBIT(fTreeMask, kRaw)     ||
+      TESTBIT(fTreeMask, kRawCalib)) {
     yb = .05;
     fSlider = new TSlider("genCut", "Multiplicity cut", 0, 0, xb, yb);
     fSlider->SetMethod("AliFMDDisplay::Instance()->ChangeCut()");
-    fSlider->SetRange(0,1);
+    fSlider->SetRange(fInitialMin,fInitialMax);
     fSlider->Draw();
     TSliderBox *sbox = 
       static_cast<TSliderBox*>(fSlider->GetListOfPrimitives()->
@@ -207,6 +213,9 @@ AliFMDDisplay::MakeCanvas(const char** which)
       sbox->SetToolTipText("Adjust lower and upper limit on data signal");
     }
   }
+  // fCanvas->Modified();
+  // fCanvas->Update();
+  // fCanvas->cd();
   Float_t      x0 = 0;
   Float_t      dx = 1. / n;
   p               = which;
@@ -384,6 +393,7 @@ AliFMDDisplay::MakeAux()
   // etc, 
   const Range_t* range = 0;
   if      (TESTBIT(fTreeMask, kESD))      range = &fgkMultRange;
+  else if (TESTBIT(fTreeMask, kRawCalib)) range = &fgkMultRange;
   else if (TESTBIT(fTreeMask, kDigits))   range = &fgkAdcRange;
   else if (TESTBIT(fTreeMask, kSDigits))  range = &fgkAdcRange;
   else if (TESTBIT(fTreeMask, kRaw))      range = &fgkAdcRange;
@@ -391,7 +401,8 @@ AliFMDDisplay::MakeAux()
   if (!range) return;
   
   if (!fAux) {
-    fAux = new TCanvas("aux", "Aux");
+    fAux = new TCanvas(Form("aux_%s", GetName()), 
+                      Form("Aux - %s", GetTitle()));
     fAux->SetLogy();
     fAux->SetFillColor(kWhite);
     fAux->SetBorderMode(0);
@@ -400,11 +411,17 @@ AliFMDDisplay::MakeAux()
     fSpec = new TH1D("spec", "Spectra", range->fNbins, 
                     range->fLow-dBin/2, range->fHigh+dBin/2);
     fSpecCut = static_cast<TH1*>(fSpec->Clone("specCut"));
-    fSpec->SetXTitle("signal");
+    TString xTitle((TESTBIT(fTreeMask, kRawCalib) || 
+                   TESTBIT(fTreeMask, kESD)) ? "#Delta E/#Delta E_{mip}" :
+                  (TESTBIT(fTreeMask, kDigits) ||
+                   TESTBIT(fTreeMask, kSDigits) || 
+                   TESTBIT(fTreeMask, kRaw)) ? "ADC [counts]" :
+                  TESTBIT(fTreeMask, kHits) ? "Hits" : "signal");
+    fSpec->SetXTitle(xTitle.Data());
     fSpec->SetYTitle("events");
     fSpec->SetFillColor(2);
     fSpec->SetFillStyle(3001);
-    fSpecCut->SetXTitle("signal");
+    fSpecCut->SetXTitle(xTitle.Data());
     fSpecCut->SetYTitle("events");
     fSpecCut->SetFillColor(4);
     fSpecCut->SetFillStyle(3001);
@@ -504,10 +521,10 @@ AliFMDDisplay::Idle()
     gApplication->StopIdleing();
     if (fContinous) break;
   }
-  AliFMDDebug(1, ("After idle loop"));
+  AliFMDDebug(3, ("After idle loop"));
   if (fMarkers) fMarkers->Delete();
   if (fHits)    fHits->Clear();
-  AliFMDDebug(1, ("After clearing caches"));
+  AliFMDDebug(3, ("After clearing caches"));
 }
 
 //____________________________________________________________________
@@ -544,11 +561,25 @@ void
 AliFMDDisplay::SetCut(Float_t l, Float_t h) 
 {
   // Change the cut on the slider. 
-  fSlider->SetMinimum(l);
-  fSlider->SetMaximum(h);
+  fInitialMin = l;
+  fInitialMax = h;
+  if (!fSlider) return;
+  fSlider->SetMinimum(fInitialMin);
+  fSlider->SetMaximum(fInitialMax);
   ChangeCut();
 }
 
+//____________________________________________________________________
+void
+AliFMDDisplay::SetFactor(Float_t f) 
+{
+  // Change the cut on the slider. 
+  fInitialFactor = f / 10;
+  if (!fFactor) return;
+  fFactor->SetMinimum(fInitialFactor);
+  ChangeFactor();
+}
+
 //____________________________________________________________________
 void
 AliFMDDisplay::ChangeCut() 
@@ -558,10 +589,11 @@ AliFMDDisplay::ChangeCut()
   // drawn in the AUX canvas
   AliInfo(Form("Range is now %7.5f - %7.5f", fSlider->GetMinimum(), 
               fSlider->GetMaximum()));
-  if ((TESTBIT(fTreeMask, kESD) || 
-       TESTBIT(fTreeMask, kDigits) || 
+  if ((TESTBIT(fTreeMask, kESD)     || 
+       TESTBIT(fTreeMask, kDigits)  || 
        TESTBIT(fTreeMask, kSDigits) || 
-       TESTBIT(fTreeMask, kRaw))) {
+       TESTBIT(fTreeMask, kRaw)     ||
+       TESTBIT(fTreeMask, kRawCalib))) {
     Float_t l = fSlider->GetMinimum();
     Float_t h = fSlider->GetMaximum();
     l         = 1024 * l + 0;
@@ -577,9 +609,7 @@ AliFMDDisplay::ChangeFactor()
   // Change the cut on the slider. 
   // The factor depends on what is 
   // drawn in the AUX canvas
-  AliInfo(Form("Noise factor is now %4.1f, pedestal factor %3.1f", 
-              10 * fFactor->GetMinimum(),
-              (fFactor->GetMaximum()-fFactor->GetMaximum())));
+  AliInfo(Form("Noise factor is now %4.1f", 10 * fFactor->GetMinimum()));
   Redisplay();
 }
 
@@ -676,7 +706,11 @@ AliFMDDisplay::InsideCut(Float_t val, const Float_t& min,
   Float_t l = fSlider->GetMinimum();
   Float_t h = fSlider->GetMaximum();
   if (l == h) { l = 0; h = 1; }
-  if (val < r * l + min || val > r * h + min) return kFALSE;
+  if (val < r * l + min || val > r * h + min) { 
+    AliFMDDebug(2, ("Value %f is outside cut %f - %f (range %f - %f)", 
+                   val, min+r*l, min+r*h, min, max));
+    return kFALSE;
+  }
   return kTRUE;
 }
 
@@ -716,21 +750,13 @@ AliFMDDisplay::ProcessDigit(AliFMDDigit* digit)
 
   if (!digit) { AliError("No digit");   return kFALSE; }
 
-  AliFMDParameters* parm = AliFMDParameters::Instance();
   UShort_t det           =  digit->Detector();
   Char_t   ring          =  digit->Ring();
   UShort_t sec           =  digit->Sector();
   UShort_t str           =  digit->Strip();
-  Double_t ped           =  parm->GetPedestal(det,ring, sec, str);
-  Double_t pedW          =  parm->GetPedestalWidth(det,ring, sec, str);
-  Double_t threshold     =  ((fFMDReader && fFMDReader->IsZeroSuppressed(det-1)
-                             ? 0 : (ped * (fFactor->GetMaximum()
-                                           -fFactor->GetMinimum())))
-                            + pedW * 10 * fFactor->GetMinimum());
-  if (threshold > fgkAdcRange.fHigh) threshold = fgkAdcRange.fHigh;
+  Double_t threshold     =  GetADCThreshold(det, ring, sec, str);
   Float_t  counts        =  digit->Counts();
-  if (fFMDReader && fFMDReader->IsZeroSuppressed(det-1) && counts > 0)
-    counts += fFMDReader->NoiseFactor(det-1) * pedW;
+  if (threshold < 0) { counts += -threshold; threshold = 0; }
 
   AliFMDDebug(10, ("FMD%d%c[%02d,%03d] counts %4d threshold %4d", 
                   det, ring, sec, str, Int_t(counts), Int_t(threshold)));
@@ -785,6 +811,51 @@ AliFMDDisplay::ProcessRawDigit(AliFMDDigit* digit)
   return ProcessDigit(digit);
 }
 
+//____________________________________________________________________
+Bool_t 
+AliFMDDisplay::ProcessRawCalibDigit(AliFMDDigit* digit)
+{
+  // Process a digit 
+  // Parameters: 
+  //   digit Digit information 
+  static const Float_t rMin  = fgkMultRange.fLow;
+  static const Float_t rMax  = fgkMultRange.fHigh;
+  static const Float_t aMin  = fgkAdcRange.fLow;
+  static const Float_t aMax  = fgkAdcRange.fHigh;
+
+  if (!digit) { AliError("No digit");   return kFALSE; }
+
+  AliFMDParameters* parm = AliFMDParameters::Instance();
+  UShort_t det           =  digit->Detector();
+  Char_t   ring          =  digit->Ring();
+  UShort_t sec           =  digit->Sector();
+  UShort_t str           =  digit->Strip();
+  Double_t gain          =  parm->GetPulseGain(det, ring, sec, str);
+  Double_t ped           =  parm->GetPedestal(det, ring, sec, str);
+  Double_t threshold     =  GetADCThreshold(det, ring, sec, str);
+  Float_t  counts        =  digit->Counts();
+  if (threshold < 0) { counts += -threshold; threshold = 0; ped = 0; }
+
+  //   Double_t edep = ((counts * parm->GetEdepMip() / 
+  //               (gain * parm->GetDACPerMIP()));
+  Double_t mult = (counts-ped) / (gain * parm->GetDACPerMIP());
+  if (gain < 0.1 || gain > 10) mult = 0;
+  
+
+  AliFMDDebug(10, ("FMD%d%c[%02d,%03d] adc %4d "
+                  "(threshold %4d, gain %6.3f) -> mult %7.4f", 
+                  det, ring, sec, str, int(counts), int(threshold), 
+                  gain, mult));
+  if (fHits)                                    fHits->Add(digit);
+  if (fSpec)                                    fSpec->Fill(mult);
+  if (!InsideCut(counts-threshold, aMin, aMax)) return kTRUE;
+  if (fSpecCut)                                 fSpecCut->Fill(mult);
+  
+  if (mult >= 0) 
+    AddMarker(det, ring, sec, str, digit, mult, rMin, rMax);
+  return kTRUE;
+}
+
 //____________________________________________________________________
 Bool_t 
 AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint)
@@ -830,7 +901,27 @@ AliFMDDisplay::ProcessESD(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
   return kTRUE;
 }
 
+Double_t
+AliFMDDisplay::GetADCThreshold(UShort_t d, Char_t r, 
+                              UShort_t s, UShort_t t) const
+{
+  AliFMDParameters* parm = AliFMDParameters::Instance();
+  Double_t ped           =  parm->GetPedestal(d,r, s, t);
+  Double_t pedW          =  parm->GetPedestalWidth(d,r, s, t);
+  Double_t threshold     = 0;
+  if (fFMDReader && fFMDReader->IsZeroSuppressed(d-1))
+    threshold = - fFMDReader->NoiseFactor(d-1) * pedW;
+  else 
+    threshold = ped + pedW * 10 * fFactor->GetMinimum();
+  AliFMDDebug(10, ("FMD%d%c[%2d,%3d] ped: %f +/- %f [factor: %f-%f]", 
+                  d, r, s, t, ped, pedW, 
+                  fFactor->GetMinimum(), fFactor->GetMaximum()));
+  if (threshold > fgkAdcRange.fHigh) threshold = fgkAdcRange.fHigh;
+  return threshold;
+}
+
 //____________________________________________________________________
 //
 // EOF
 //
+