00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 #include <TH2D.h>
00015 #include <AliFMDHit.h>
00016 #include <AliFMDDigit.h>
00017 #include <AliFMDInput.h>
00018 #include <AliFMDEdepMap.h>
00019 #include <iostream>
00020 #include <TStyle.h>
00021 #include <TArrayF.h>
00022 
00033 class DrawHitsDigits : public AliFMDInputHits
00034 {
00035 private:
00036   TH2D* fElossVsAdc; 
00037   AliFMDEdepMap fMap;
00038 public:
00039   
00040   TArrayF MakeLogScale(Int_t n, Double_t min, Double_t max) 
00041   {
00042     TArrayF bins(n+1);
00043     Float_t dp   = n / TMath::Log10(max / min);
00044     Float_t pmin = TMath::Log10(min);
00045     bins[0]      = min;
00046     for (Int_t i = 1; i < n+1; i++) {
00047       Float_t p = pmin + i / dp;
00048       bins[i]   = TMath::Power(10, p);
00049     }
00050     return bins;
00051   }
00052   
00053   DrawHitsDigits(Int_t n=900, Double_t emin=1e-3, Double_t emax=10, 
00054                  Int_t m=1100, Double_t amin=-0.5, Double_t amax=1099.5) 
00055   { 
00056     AddLoad(kDigits);
00057     TArrayF eloss(MakeLogScale(n, emin, emax));
00058     TArrayF adcs(m+1);
00059     adcs[0] = amin;
00060     for (Int_t i = 1; i < m+1; i++) adcs[i] = adcs[i-1] + (amax-amin)/m;
00061     fElossVsAdc = new TH2D("bad", "#Delta E vs. ADC", 
00062                            eloss.fN-1, eloss.fArray, adcs.fN-1, adcs.fArray);
00063     fElossVsAdc->SetXTitle("#Delta E/#Delta x [MeV/cm]");
00064     fElossVsAdc->SetYTitle("ADC value");
00065   }
00066   
00070   Bool_t Begin(Int_t ev) 
00071   {
00072     fMap.Reset();
00073     return AliFMDInputHits::Begin(ev);
00074   }
00075   
00076   Bool_t ProcessHit(AliFMDHit* hit, TParticle*) 
00077   {
00078     
00079     if (!hit) return kFALSE;
00080     UShort_t det = hit->Detector();
00081     Char_t   rng = hit->Ring();
00082     UShort_t sec = hit->Sector();
00083     UShort_t str = hit->Strip();
00084     if (str > 511) {
00085       AliWarning(Form("Bad strip number %d in hit", str));
00086       return kTRUE;
00087     }
00088     fMap(det, rng, sec, str).fEdep += hit->Edep();
00089     fMap(det, rng, sec, str).fN++;
00090     return kTRUE;
00091   }
00092   
00093   Bool_t ProcessDigit(AliFMDDigit* digit)
00094   {
00095     if (!digit) continue;
00096     UShort_t det = digit->Detector();
00097     Char_t   rng = digit->Ring();
00098     UShort_t sec = digit->Sector();
00099     UShort_t str = digit->Strip();
00100     if (str > 511) {
00101       AliWarning(Form("Bad strip number %d in digit", str));
00102       continue;
00103     }
00104     fElossVsAdc->Fill(fMap(det, rng, sec, str).fEdep, digit->Counts());
00105     return kTRUE;
00106   }
00107   
00108   Bool_t Finish()
00109   {
00110     gStyle->SetPalette(1);
00111     gStyle->SetOptTitle(0);
00112     gStyle->SetCanvasColor(0);
00113     gStyle->SetCanvasBorderSize(0);
00114     gStyle->SetPadColor(0);
00115     gStyle->SetPadBorderSize(0);
00116     fElossVsAdc->SetStats(kFALSE);
00117     fElossVsAdc->Draw("COLZ");
00118     return kTRUE;
00119   }
00120 
00121   ClassDef(DrawHitsDigits,0);
00122 };
00123 
00124 
00125 
00126 
00127