scripts/DrawHitsDigits.C

Go to the documentation of this file.
00001 //____________________________________________________________________
00002 //
00003 // $Id: DrawHitsDigits.C,v 1.3 2006/03/17 11:42:24 cholm Exp $
00004 //
00005 // Script that contains a class to draw eloss from hits, versus ADC
00006 // counts from digits, using the AliFMDInputHits class in the util library. 
00007 //
00008 // It draws the energy loss versus the p/(mq^2).  It can be overlayed
00009 // with the Bethe-Bloc curve to show how the simulation behaves
00010 // relative to the expected. 
00011 //
00012 // Use the script `Compile.C' to compile this class using ACLic. 
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; // Histogram 
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     // Cache the energy loss 
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 // EOF
00127 //

Generated on Fri Mar 24 17:11:21 2006 for ALICE FMD Off-line by  doxygen 1.4.6