More code clean up.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDCorrDoubleHit.cxx
1 #include "AliFMDCorrDoubleHit.h"
2 #include <TBrowser.h>
3 #include <TH1D.h>
4 #include <AliLog.h>
5 #include <iostream>
6
7 //____________________________________________________________________
8 AliFMDCorrDoubleHit::AliFMDCorrDoubleHit()
9   : fCorrections()
10 {
11   fCorrections.SetOwner(kTRUE);
12   fCorrections.SetName("doubleHit");
13 }
14 //____________________________________________________________________
15 AliFMDCorrDoubleHit::AliFMDCorrDoubleHit(const AliFMDCorrDoubleHit& o)
16   : TObject(o), 
17     fCorrections(o.fCorrections)
18 {
19 }
20 //____________________________________________________________________
21 AliFMDCorrDoubleHit::~AliFMDCorrDoubleHit()
22 {
23   fCorrections.Clear();
24 }
25 //____________________________________________________________________
26 AliFMDCorrDoubleHit&
27 AliFMDCorrDoubleHit::operator=(const AliFMDCorrDoubleHit& o)
28 {
29   fCorrections   = o.fCorrections;
30
31   return *this;
32 }
33 //____________________________________________________________________
34 TH1D*
35 AliFMDCorrDoubleHit::GetCorrection(UShort_t d, Char_t r) const
36 {
37   Int_t idx = GetRingIndex(d, r);
38   if (idx < 0) return 0;
39
40   TObject* o = fCorrections.At(idx);
41   if (!o) { 
42     AliWarning(Form("No double hit correction found for FMD%d%c", d, r));
43     return 0;
44   }
45   return static_cast<TH1D*>(o);
46 }
47 //____________________________________________________________________
48 Int_t
49 AliFMDCorrDoubleHit::GetRingIndex(UShort_t d, Char_t r) const
50 {
51   switch (d) {
52   case 1:  return 0;
53   case 2:  return (r == 'I' || r == 'i' ? 1 : 2); break;  
54   case 3:  return (r == 'I' || r == 'i' ? 3 : 4); break;  
55   }
56   AliWarning(Form("Index for FMD%d%c not found", d, r));
57   return -1;
58 }
59 //____________________________________________________________________
60 Bool_t
61 AliFMDCorrDoubleHit::SetCorrection(UShort_t d, Char_t r, TH1D* h) 
62 {
63   Int_t idx = GetRingIndex(d, r);
64   if (idx < 0) return kFALSE;
65
66   h->SetName(Form("FMD%d%c", d, r));
67   h->SetTitle(Form("Double hit correction for FMD%d%c", d,r));
68   h->SetXTitle("#eta");
69   h->SetYTitle("#sum_{i} N_{i,strips hit}(#eta)/"
70                "#sum_{i} N_{i,total hits}(#eta)");
71   // h->SetFillColor(Color(d,r));
72   h->SetFillStyle(3001);
73   h->SetDirectory(0);
74   h->SetStats(0);
75   
76   fCorrections.AddAtAndExpand(h, idx);
77   return kTRUE;
78 }
79 //____________________________________________________________________
80 void
81 AliFMDCorrDoubleHit::Browse(TBrowser* b)
82 {
83   b->Add(&fCorrections);
84 }
85 //____________________________________________________________________
86 void
87 AliFMDCorrDoubleHit::Print(Option_t* option) const
88 {
89   std::cout << "Double hit correction" << std::endl;
90   fCorrections.Print(option);
91 }
92     
93 //____________________________________________________________________
94 //
95 // EOF
96 //