scripts/DrawHits.C

Go to the documentation of this file.
00001 //____________________________________________________________________
00002 //
00003 // $Id: DrawHits.C,v 1.5 2006/03/17 11:42:24 cholm Exp $
00004 //
00005 // Script that contains a class to draw hits, using the
00006 // 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 <AliFMDInput.h>
00017 #include <iostream>
00018 #include <TStyle.h>
00019 #include <TArrayF.h>
00020 #include <TParticle.h>
00021 
00032 class DrawHits : public AliFMDInputHits
00033 {
00034 private:
00035   TH2D* fElossVsPMQ; // Histogram 
00036   Int_t fPdg;
00037 public:
00038   //__________________________________________________________________
00039   TArrayF MakeLogScale(Int_t n, Double_t min, Double_t max) 
00040   {
00041     TArrayF bins(n+1);
00042     bins[0]      = min;
00043     if (n <= 20) {
00044       for (Int_t i = 1; i < n+1; i++) bins[i] = bins[i-1] + (max-min)/n;
00045       return bins;
00046     }
00047     Float_t dp   = n / TMath::Log10(max / min);
00048     Float_t pmin = TMath::Log10(min);
00049     for (Int_t i = 1; i < n+1; i++) {
00050       Float_t p = pmin + i / dp;
00051       bins[i]   = TMath::Power(10, p);
00052     }
00053     return bins;
00054   }
00055   //__________________________________________________________________
00056   DrawHits(Int_t m=1000, Double_t emin=1, Double_t emax=1000, 
00057            Int_t n=900, Double_t tmin=1e-2, Double_t tmax=1e3, 
00058            Int_t pdg=211) 
00059     : fPdg(pdg)
00060   { 
00061     AddLoad(kKinematics);
00062     TArrayF tkine(MakeLogScale(n, tmin, tmax));
00063     TArrayF eloss(MakeLogScale(m, emin, emax));
00064     TString name(Form("elossVsP%s", (fPdg == 0 ? "MQ" : "")));
00065     TString title(Form("#Delta E/#Delta x vs. p%s", 
00066                        (fPdg == 0 ? "/(mq^{2})" : "")));
00067     fElossVsPMQ = new TH2D(name.Data(), title.Data(), 
00068                            tkine.fN-1, tkine.fArray, 
00069                            eloss.fN-1, eloss.fArray);
00070     fElossVsPMQ->SetXTitle(Form("p%s", (fPdg == 0 ? "/(mq^{2})" : " [GeV]")));
00071     fElossVsPMQ->SetYTitle("#Delta E/#Delta x [MeV/cm]");
00072   }
00073   //__________________________________________________________________
00074   Bool_t ProcessHit(AliFMDHit* hit, TParticle* p) 
00075   {
00076     if (!hit) {
00077       std::cout << "No hit" << std::endl;
00078       return kFALSE;
00079     }
00080 
00081     if (!p) {
00082       std::cout << "No track" << std::endl;
00083       return kFALSE;
00084     }
00085     if (!p->IsPrimary()) return kTRUE;
00086     if (hit->IsStop()) return kTRUE;
00087     Float_t x = hit->P();
00088     Float_t y = hit->Edep()/hit->Length();
00089     if (fPdg != 0) {
00090       if (TMath::Abs(hit->Pdg()) != fPdg) return kTRUE;
00091     }
00092     else {
00093       Float_t q = hit->Q() / 3.;
00094       if (hit->M() == 0 || q == 0) return kTRUE;
00095       x /= hit->M();
00096       y /= q * q;
00097     }
00098     fElossVsPMQ->Fill(x, y);
00099     return kTRUE;
00100   }
00101   //__________________________________________________________________
00102   Bool_t Finish()
00103   {
00104     gStyle->SetPalette(1);
00105     gStyle->SetOptTitle(0);
00106     gStyle->SetCanvasColor(0);
00107     gStyle->SetCanvasBorderSize(0);
00108     gStyle->SetPadColor(0);
00109     gStyle->SetPadBorderSize(0);
00110     fElossVsPMQ->SetStats(kFALSE);
00111     fElossVsPMQ->Draw("COLZ box");
00112     return kTRUE;
00113   }
00114   ClassDef(DrawHits,0);
00115 };
00116 
00117 //____________________________________________________________________
00118 //
00119 // EOF
00120 //

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