Removed pointers alltogether from the class members
[u/mrichter/AliRoot.git] / FMD / AliFMDQADataMakerSim.cxx
1 /**************************************************************************
2  * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved.      *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 // --- ROOT system ---
16 #include <iostream>
17 #include <TClonesArray.h>
18 #include <TFile.h> 
19 #include <TH1F.h> 
20 #include <TH1I.h> 
21
22 // --- AliRoot header files ---
23 #include "AliESDEvent.h"
24 #include "AliLog.h"
25 #include "AliFMDQADataMakerSim.h"
26 #include "AliFMDDigit.h"
27 #include "AliFMDHit.h"
28 #include "AliQAChecker.h"
29 #include "AliFMDParameters.h"
30
31 //_____________________________________________________________________
32 // This is the class that collects the QA data for the FMD during simulation.
33 // The following data types are picked up:
34 // - hits
35 // - digits
36 // The following data types are not supported (yet):
37 // - raws
38 // - sdigits
39 // Author : Hans Hjersing Dalsgaard, Niels Bohr Institute, hans.dalsgaard@cern.ch
40 //_____________________________________________________________________
41
42 ClassImp(AliFMDQADataMakerSim)
43 #if 0
44 ; // This line is for Emacs - do not delete!
45 #endif
46 //_____________________________________________________________________
47 AliFMDQADataMakerSim::AliFMDQADataMakerSim() 
48   :  AliQADataMakerSim(AliQA::GetDetName(AliQA::kFMD),
49                        "FMD Quality Assurance Data Maker"),
50      fDigitsArray("AliFMDDigit", 1000),
51      fHitsArray("AliFMDHit", 10)
52 {
53   // ctor
54
55 }
56
57 //_____________________________________________________________________
58 AliFMDQADataMakerSim::AliFMDQADataMakerSim(const AliFMDQADataMakerSim& qadm) 
59   : AliQADataMakerSim(),
60     fDigitsArray(qadm.fDigitsArray),
61     fHitsArray(qadm.fHitsArray)
62 {
63   //copy ctor 
64   
65   // Parameters: 
66   //    qadm    Object to copy from
67   
68 }
69 //_____________________________________________________________________
70 AliFMDQADataMakerSim& AliFMDQADataMakerSim::operator = (const AliFMDQADataMakerSim& qadm ) 
71 {
72   fDigitsArray = qadm.fDigitsArray;
73   fHitsArray = qadm.fHitsArray;
74   
75   return *this;
76 }
77 //_____________________________________________________________________
78 AliFMDQADataMakerSim::~AliFMDQADataMakerSim()
79 {
80
81 }
82
83 //_____________________________________________________________________
84 void AliFMDQADataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t task, 
85                                               TObjArray * list)
86 {
87   //Detector specific actions at end of cycle
88   // do the QA checking
89   AliLog::Message(5,"FMD: end of detector cycle",
90                   "AliFMDQADataMakerSim","AliFMDQADataMakerSim",
91                   "AliFMDQADataMakerSim::EndOfDetectorCycle",
92                   "AliFMDQADataMakerSim.cxx",83);
93   AliQAChecker::Instance()->Run(AliQA::kFMD, task, list) ;  
94   
95 }
96
97 //____________________________________________________________________ 
98 void AliFMDQADataMakerSim::InitHits()
99 {
100   // create Digits histograms in Digits subdir
101   TH1F* hEnergyOfHits = new TH1F("hEnergyOfHits","Energy distribution",100,0,3);
102   hEnergyOfHits->SetXTitle("Edep");
103   hEnergyOfHits->SetYTitle("Counts");
104   Add2HitsList(hEnergyOfHits, 0);
105 }
106
107 //_____________________________________________________________________
108 void AliFMDQADataMakerSim::InitDigits()
109 {
110   // create Digits histograms in Digits subdir
111   TH1I* hADCCounts = new TH1I("hADCCounts","Dist of ADC counts",1024,0,1024);
112   hADCCounts->SetXTitle("ADC counts");
113   Add2DigitsList(hADCCounts, 0);
114 }
115
116 //_____________________________________________________________________
117 void AliFMDQADataMakerSim::MakeHits(TClonesArray * hits)
118 {
119   TIter next(hits);
120   AliFMDHit * hit;
121   while ((hit = static_cast<AliFMDHit *>(next()))) 
122     GetHitsData(0)->Fill(hit->Edep()/hit->Length()*0.032);
123 }
124
125 //_____________________________________________________________________
126 void AliFMDQADataMakerSim::MakeHits(TTree * hitTree)
127 {
128   // make QA data from Hit Tree
129   
130   fHitsArray.Clear();
131   
132   TBranch * branch = hitTree->GetBranch("FMD") ;
133   if (!branch) {
134     AliWarning("FMD branch in Hit Tree not found") ; 
135     return;
136   }
137   
138   TClonesArray* hitsAddress = &fHitsArray;
139   
140   branch->SetAddress(&hitsAddress) ;
141   
142   for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
143     branch->GetEntry(ientry);
144     MakeHits(hitsAddress);   //tmp); 
145   }     
146   
147 }
148
149 //_____________________________________________________________________
150 void AliFMDQADataMakerSim::MakeDigits(TClonesArray * digits)
151 {
152   // makes data from Digits
153   if(!digits) return;
154
155   for(Int_t i = 0 ; i < digits->GetEntriesFast() ; i++) {
156     //Raw ADC counts
157     AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
158     GetDigitsData(0)->Fill(digit->Counts());
159   }
160 }
161
162 //_____________________________________________________________________
163 void AliFMDQADataMakerSim::MakeDigits(TTree * digitTree)
164 {
165   
166   fDigitsArray.Clear();
167   TBranch * branch = digitTree->GetBranch("FMD") ;
168   if (!branch)    {
169       AliWarning("FMD branch in Digit Tree not found") ; 
170       return;
171   } 
172   TClonesArray* digitAddress = &fDigitsArray;
173   branch->SetAddress(&digitAddress) ;
174   branch->GetEntry(0) ; 
175   MakeDigits(digitAddress) ; 
176 }
177
178 //_____________________________________________________________________ 
179 void AliFMDQADataMakerSim::StartOfDetectorCycle()
180 {
181    
182 }
183 //_____________________________________________________________________ 
184 //
185 // EOF
186 //