]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/scripts/DrawHitsDigits.C
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / FMD / scripts / DrawHitsDigits.C
index cf8471e5ee40340c6bd642a385bfd11e50a9a862..e5bd31b88065563e88ff83d50be6140faeca6129 100644 (file)
@@ -1,3 +1,4 @@
+//____________________________________________________________________
 //
 // $Id$
 //
 #include <iostream>
 #include <TStyle.h>
 #include <TArrayF.h>
+#include <AliLog.h>
+#include <TMath.h>
 
-class DrawHitsDigits : public AliFMDInputHits
+/** @class DrawHitsDigits
+    @brief Draw hit energy loss versus digit ADC
+    @code 
+    Root> .L Compile.C
+    Root> Compile("DrawHitsDigits.C")
+    Root> DrawHitsDigits c
+    Root> c.Run();
+    @endcode
+    @ingroup FMD_script
+ */
+class DrawHitsDigits : public AliFMDInput
 {
 private:
   TH2D* fElossVsAdc; // Histogram 
   AliFMDEdepMap fMap;
 public:
-  TArrayF MakeLogScale(Int_t n, Double_t min, Double_t max) 
-  {
-    TArrayF bins(n+1);
-    Float_t dp   = n / TMath::Log10(max / min);
-    Float_t pmin = TMath::Log10(min);
-    bins[0]      = min;
-    for (Int_t i = 1; i < n+1; i++) {
-      Float_t p = pmin + i / dp;
-      bins[i]   = TMath::Power(10, p);
-    }
-    return bins;
-  }
+  //__________________________________________________________________
   DrawHitsDigits(Int_t n=900, Double_t emin=1e-3, Double_t emax=10, 
                 Int_t m=1100, Double_t amin=-0.5, Double_t amax=1099.5) 
   { 
     AddLoad(kDigits);
+    AddLoad(kHits);
     TArrayF eloss(MakeLogScale(n, emin, emax));
     TArrayF adcs(m+1);
     adcs[0] = amin;
@@ -50,13 +53,19 @@ public:
     fElossVsAdc->SetXTitle("#Delta E/#Delta x [MeV/cm]");
     fElossVsAdc->SetYTitle("ADC value");
   }
+  //__________________________________________________________________
+  /** Begining of event
+      @param ev Event number
+      @return @c false on error */
   Bool_t Begin(Int_t ev) 
   {
     fMap.Reset();
-    return AliFMDInputHits::Begin(ev);
+    return AliFMDInput::Begin(ev);
   }
+  //__________________________________________________________________
   Bool_t ProcessHit(AliFMDHit* hit, TParticle*) 
   {
+    // Info("ProcessHit", "Processing hit %p", hit);
     // Cache the energy loss 
     if (!hit) return kFALSE;
     UShort_t det = hit->Detector();
@@ -69,33 +78,30 @@ public:
     }
     fMap(det, rng, sec, str).fEdep += hit->Edep();
     fMap(det, rng, sec, str).fN++;
+    // hit->Print();
     return kTRUE;
   }
-  Bool_t Event() 
+  //__________________________________________________________________
+  Bool_t ProcessDigit(AliFMDDigit* digit)
   {
-    if (!AliFMDInputHits::Event()) return kFALSE;
-    Int_t nEv = fTreeD->GetEntries();
-    for (Int_t i = 0; i < nEv; i++) {
-      Int_t digitRead  = fTreeD->GetEntry(i);
-      if (digitRead <= 0) continue;
-      Int_t nDigit = fArrayD->GetEntries();
-      if (nDigit <= 0) continue;
-      for (Int_t j = 0; j < nDigit; j++) {
-       AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayD->At(j));
-       if (!digit) continue;
-       UShort_t det = digit->Detector();
-       Char_t   rng = digit->Ring();
-       UShort_t sec = digit->Sector();
-       UShort_t str = digit->Strip();
-       if (str > 511) {
-         AliWarning(Form("Bad strip number %d in digit", str));
-         continue;
-       }
-       fElossVsAdc->Fill(fMap(det, rng, sec, str).fEdep, digit->Counts());
-      }    
+    // Info("ProcessDigit", "Processing digit %p", digit);
+    if (!digit) return kFALSE;
+    UShort_t det = digit->Detector();
+    Char_t   rng = digit->Ring();
+    UShort_t sec = digit->Sector();
+    UShort_t str = digit->Strip();
+    if (str > 511) {
+      AliWarning(Form("Bad strip number %d in digit", str));
+      return kFALSE;
     }
+    fElossVsAdc->Fill(fMap(det, rng, sec, str).fEdep, digit->Counts());
+    if (fMap(det, rng, sec, str).fEdep > 0) 
+      Info("ProcessDigit", "FMD%d%c[%2d,%3d] Edep=%8.5f -> ADC=0x%03x",
+          det, rng, sec, str, 
+          fMap(det, rng, sec, str).fEdep, digit->Counts());
     return kTRUE;
   }
+  //__________________________________________________________________
   Bool_t Finish()
   {
     gStyle->SetPalette(1);