scripts/DrawHitsRecs.C

Go to the documentation of this file.
00001 //____________________________________________________________________
00002 //
00003 // $Id: DrawHitsRecs.C,v 1.2 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 <AliFMDMultStrip.h>
00017 #include <AliFMDMultRegion.h>
00018 #include <AliFMDDigit.h>
00019 #include <AliFMDInput.h>
00020 #include <AliFMDEdepMap.h>
00021 #include <AliFMDFloatMap.h>
00022 #include <iostream>
00023 #include <TStyle.h>
00024 #include <TArrayF.h>
00025 #include <TCanvas.h>
00026 #include <TParticle.h>
00027 #include <TClonesArray.h>
00028 #include <TTree.h>
00029 #include <AliStack.h>
00030 #include <AliLog.h>
00031 
00032 //____________________________________________________________________
00043 class DrawHitsRecs : public AliFMDInputHits
00044 {
00045 private:
00046   TH2D* fElossVsMult; // Histogram 
00047   TH2D* fHitsVsStrip;  // Histogram 
00048   TH2D* fHitsVsRegion;  // Histogram 
00049   AliFMDEdepMap fMap;
00050   AliFMDFloatMap fEta;
00051   AliFMDFloatMap fPhi;
00052   AliFMDFloatMap fMult;
00053   Bool_t fPrimary;
00054 public:
00055   //__________________________________________________________________
00056   TArrayF MakeLogScale(Int_t n, Double_t min, Double_t max) 
00057   {
00058     TArrayF bins(n+1);
00059     Float_t dp   = n / TMath::Log10(max / min);
00060     Float_t pmin = TMath::Log10(min);
00061     bins[0]      = min;
00062     for (Int_t i = 1; i < n+1; i++) {
00063       Float_t p = pmin + i / dp;
00064       bins[i]   = TMath::Power(10, p);
00065     }
00066     return bins;
00067   }
00068   //__________________________________________________________________
00069   DrawHitsRecs(Bool_t primary=kFALSE,
00070                Int_t n=900, Double_t emin=1e-3, Double_t emax=10, 
00071                Int_t m=21, Double_t mmin=-0.5, Double_t mmax=20.5) 
00072   { 
00073     fPrimary = primary;
00074     AddLoad(kRecPoints);
00075     if (fPrimary) AddLoad(kKinematics);
00076     TArrayF eloss(MakeLogScale(n, emin, emax));
00077     TArrayF mults(m+1);
00078     mults[0] = mmin;
00079     for (Int_t i = 1; i < m+1; i++) mults[i] = mults[i-1] + (mmax-mmin)/m;
00080     fElossVsMult = new TH2D("elossVsMult", 
00081                             "#Delta E vs. Multiplicity (single)", 
00082                            eloss.fN-1, eloss.fArray, mults.fN-1, mults.fArray);
00083     fElossVsMult->SetXTitle("#Delta E/#Delta x [MeV/cm]");
00084     fElossVsMult->SetYTitle("Strip Multiplicity");
00085 
00086     Double_t omin = -.5;
00087     Double_t omax = 7.5;
00088     Int_t    o    = 8;
00089     fHitsVsStrip = new TH2D("hitsVsStrip", 
00090                             "# of Hits vs. Multiplicity (strip)",
00091                            o, omin, omax, m, mmin, mmax);
00092     fHitsVsStrip->SetXTitle("# of Hits");
00093     fHitsVsStrip->SetYTitle("Strip Multiplicity");
00094   }
00095   //__________________________________________________________________
00099   Bool_t Begin(Int_t ev) 
00100   {
00101     fMap.Reset();
00102     return AliFMDInputHits::Begin(ev);
00103   }
00104   //__________________________________________________________________
00105   Bool_t ProcessHit(AliFMDHit* hit, TParticle*) 
00106   {
00107     // Cache the energy loss 
00108     if (!hit) return kFALSE;
00109     UShort_t det = hit->Detector();
00110     Char_t   rng = hit->Ring();
00111     UShort_t sec = hit->Sector();
00112     UShort_t str = hit->Strip();
00113     if (str > 511) {
00114       AliWarning(Form("Bad strip number %d in hit", str));
00115       return kTRUE;
00116     }
00117     if (fPrimary) {
00118       TParticle* kine = fStack->Particle(hit->Track());
00119       if (!kine) return kTRUE;
00120       if (!kine->IsPrimary()) return kTRUE;
00121     }
00122     
00123     fMap(det, rng, sec, str).fEdep += hit->Edep();
00124     fMap(det, rng, sec, str).fN++;
00125     return kTRUE;
00126   }
00127   //__________________________________________________________________
00128   Bool_t ProcessRecPoint(AliFMDRecPoint* single) 
00129   {
00130     if (!single) continue;
00131     UShort_t det = single->Detector();
00132     Char_t   rng = single->Ring();
00133     UShort_t sec = single->Sector();
00134     UShort_t str = single->Strip();
00135     if (str > 511) {
00136       AliWarning(Form("Bad strip number %d in single", str));
00137       continue;
00138     }
00139     if (fMap(det, rng, sec, str).fEdep > 0) 
00140       fElossVsMult->Fill(fMap(det, rng, sec, str).fEdep, 
00141                          single->Particles());
00142     if (fMap(det, rng, sec, str).fN > 0) 
00143       fHitsVsStrip->Fill(fMap(det, rng, sec, str).fN, 
00144                          single->Particles());
00145     return kTRUE;
00146   }
00147   //__________________________________________________________________
00148   Bool_t Finish()
00149   {
00150     gStyle->SetPalette(1);
00151     gStyle->SetOptTitle(0);
00152     gStyle->SetCanvasColor(0);
00153     gStyle->SetCanvasBorderSize(0);
00154     gStyle->SetPadColor(0);
00155     gStyle->SetPadBorderSize(0);
00156 
00157     new TCanvas("c1", "Energy loss vs. Strip Multiplicity");
00158     fElossVsMult->SetStats(kFALSE);
00159     fElossVsMult->Draw("COLZ");
00160 
00161     new TCanvas("c2", "# of Hits vs. Strip Multiplicity");
00162     fHitsVsStrip->SetStats(kFALSE);
00163     fHitsVsStrip->Draw("COLZ");
00164 
00165     return kTRUE;
00166   }
00167 
00168   ClassDef(DrawHitsRecs,0);
00169 };
00170 
00171 //____________________________________________________________________
00172 //
00173 // EOF
00174 //

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