Added QA code from Hans Hjersing Dalsgaard <canute@nbi.dk>
[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            
44 //_____________________________________________________________________
45 AliFMDQADataMakerSim::AliFMDQADataMakerSim() : 
46 AliQADataMakerSim(AliQA::GetDetName(AliQA::kFMD),
47                   "FMD Quality Assurance Data Maker")
48 {
49   // ctor
50   
51 }
52
53 //_____________________________________________________________________
54 AliFMDQADataMakerSim::AliFMDQADataMakerSim(const AliFMDQADataMakerSim& qadm) :
55   AliQADataMakerSim()
56 {
57   //copy ctor 
58   // Parameters: 
59   //    qadm    Object to copy from
60   
61 }
62
63 //_____________________________________________________________________
64 void AliFMDQADataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
65 {
66   //Detector specific actions at end of cycle
67   // do the QA checking
68   AliLog::Message(5,"FMD: end of detector cycle","AliFMDQADataMakerSim","AliFMDQADataMakerSim","AliFMDQADataMakerSim::EndOfDetectorCycle","AliFMDQADataMakerSim.cxx",83);
69   AliQAChecker::Instance()->Run(AliQA::kFMD, task, list) ;  
70   
71 }
72
73 //____________________________________________________________________ 
74 void AliFMDQADataMakerSim::InitHits()
75 {
76   // create Digits histograms in Digits subdir
77   TH1F* hEnergyOfHits    = new TH1F("hEnergyOfHits","Energy distribution",100,0,3);
78   hEnergyOfHits->SetXTitle("Edep");
79   hEnergyOfHits->SetYTitle("Counts");
80   Add2HitsList(hEnergyOfHits, 0);
81 }
82
83 //_____________________________________________________________________
84 void AliFMDQADataMakerSim::InitDigits()
85 {
86   // create Digits histograms in Digits subdir
87   TH1I* hADCCounts = new TH1I("hADCCounts","Dist of ADC counts",1024,0,1024);
88   //TH1F* hEnergyOfDigits    = new TH1F("hEnergyOfDigits","Energy distribution",100,0,3);
89   hADCCounts->SetXTitle("ADC counts");
90   //hADCCounts->SetYTitle("Counts");
91   //hEnergyOfDigits->SetXTitle("Edep/Emip");
92   //hEnergyOfDigits->SetYTitle("Counts");
93   Add2DigitsList(hADCCounts, 0);
94   //Add2DigitsList(hEnergyOfDigits, 1);
95   
96 }
97
98 //_____________________________________________________________________
99 void AliFMDQADataMakerSim::MakeHits(TClonesArray * hits)
100 {
101   TIter next(hits);
102   AliFMDHit * hit;
103   while ((hit = static_cast<AliFMDHit *>(next()))) 
104     GetHitsData(0)->Fill(hit->Edep()/hit->Length()*0.032);
105 }
106
107 //_____________________________________________________________________
108 void AliFMDQADataMakerSim::MakeHits(TTree * hitTree)
109 {
110   // make QA data from Hit Tree
111   
112   TBranch * branch = hitTree->GetBranch("FMD") ;
113   if (!branch) {
114     AliWarning("FMD branch in Hit Tree not found") ; 
115     return;
116   }
117
118   TClonesArray * tmp =  new TClonesArray("AliFMDHit", 10) ;
119   branch->SetAddress(&tmp) ;
120   
121   for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
122     branch->GetEntry(ientry);
123     MakeHits(tmp); 
124   }     
125   tmp->Delete() ; 
126   delete tmp ; 
127 }
128
129 //_____________________________________________________________________
130 void AliFMDQADataMakerSim::MakeDigits(TClonesArray * digits)
131 {
132   // makes data from Digits
133   if(!digits) return;
134
135   for(Int_t i = 0 ; i < digits->GetEntries() ; i++) {
136     //Raw ADC counts
137     AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
138     GetDigitsData(0)->Fill(digit->Counts());
139   }
140 }
141
142 //_____________________________________________________________________
143 void AliFMDQADataMakerSim::MakeDigits(TTree * digitTree)
144 {
145   
146   TClonesArray * digits = new TClonesArray("AliFMDDigit", 1000) ; 
147   
148   TBranch * branch = digitTree->GetBranch("FMD") ;
149   if (!branch)    {
150       AliWarning("FMD branch in Digit Tree not found") ; 
151       return;
152   } 
153   branch->SetAddress(&digits) ;
154   branch->GetEntry(0) ; 
155   MakeDigits(digits) ; 
156 }
157
158 //_____________________________________________________________________ 
159 void AliFMDQADataMakerSim::StartOfDetectorCycle()
160 {
161    
162 }
163 //_____________________________________________________________________ 
164 //
165 // EOF
166 //