Updates to AddTask macro from Chris
[u/mrichter/AliRoot.git] / MUON / AliMUONQADataMakerRec.cxx
CommitLineData
04236e67 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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
bf4d93eb 16// $Id$
17
b1341ab0 18// --- MUON header files ---
19#include "AliMUONQADataMakerRec.h"
04236e67 20
04236e67 21//-----------------------------------------------------------------------------
22/// \class AliMUONQADataMakerRec
23///
24/// MUON base class for quality assurance data (histo) maker
25///
ece56eb9 26/// It is now only a steering class for the two subclasses AliMUONTrackerQADataMakerRec
27/// and AliMUONTriggerQADataMakerRec
28///
29/// \author C. Finck, D. Stocco, L. Aphecetche, A. Blanc
30
1d1e08f6 31#include "AliDAQ.h"
ece56eb9 32#include "AliMUONTrackerQADataMakerRec.h"
33#include "AliMUONTriggerQADataMakerRec.h"
34#include "AliQAChecker.h"
35#include "AliRawReader.h"
36#include "AliRawEventHeaderBase.h"
04236e67 37
38/// \cond CLASSIMP
39ClassImp(AliMUONQADataMakerRec)
40/// \endcond
41
42//____________________________________________________________________________
ece56eb9 43AliMUONQADataMakerRec::AliMUONQADataMakerRec(Bool_t tracker, Bool_t trigger) :
4e25ac79 44AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kMUON), "MUON Quality Assurance Data Maker"),
ece56eb9 45fTracker(tracker ? new AliMUONTrackerQADataMakerRec(this) : 0x0),
46fTrigger(trigger ? new AliMUONTriggerQADataMakerRec(this) : 0x0)
04236e67 47{
ece56eb9 48 /// ctor
1d5cf0f2 49 AliInfo(Form("tracker=%d trigger=%d",tracker,trigger));
04236e67 50}
51
52//__________________________________________________________________
53AliMUONQADataMakerRec::~AliMUONQADataMakerRec()
54{
55 /// dtor
ece56eb9 56 delete fTracker;
57 delete fTrigger;
04236e67 58}
59
60//____________________________________________________________________________
b3d57767 61Int_t AliMUONQADataMakerRec::Add2List(TH1 * hist, const Int_t index, AliQAv1::TASKINDEX_t task, const Bool_t expert, const Bool_t image, const Bool_t saveForCorr)
62{
63 TObjArray** list = GetList(task);
64 if (list)
65 {
66 return Add2List(hist,index,list,expert,image,saveForCorr);
67 }
68 return -1;
69}
70
71//____________________________________________________________________________
4e25ac79 72void AliMUONQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
04236e67 73{
b9bd355c 74 /// Detector specific actions at end of cycle
92664bc8 75 //
76 ResetEventTrigClasses(); // RS
77 //
c455c5fb 78 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
79 {
b9bd355c 80 if (! IsValidEventSpecie(specie, list) ) continue;
81
b3d57767 82 SetEventSpecie(AliRecoParam::ConvertIndex(specie)); // needed by the GetXXXData methods
83
ece56eb9 84 if ( task == AliQAv1::kRAWS )
b9bd355c 85 {
b3d57767 86 if ( fTracker ) fTracker->EndOfDetectorCycleRaws(specie,list);
87 if ( fTrigger ) fTrigger->EndOfDetectorCycleRaws(specie,list);
88 }
89 else if ( task == AliQAv1::kRECPOINTS )
b9bd355c 90 {
91 // normalize recpoints histograms
b3d57767 92 if ( fTracker ) fTracker->EndOfDetectorCycleRecPoints(specie,list);
93 if ( fTrigger ) fTrigger->EndOfDetectorCycleRecPoints(specie,list);
b9bd355c 94 }
b3d57767 95 else if ( task == AliQAv1::kESDS )
b9bd355c 96 {
97 // normalize esds histograms
b3d57767 98 if ( fTracker ) fTracker->EndOfDetectorCycleESDs(specie,list);
99 if ( fTrigger ) fTrigger->EndOfDetectorCycleESDs(specie,list);
100 }
101 else if ( task == AliQAv1::kDIGITSR )
102 {
103 if ( fTracker ) fTracker->EndOfDetectorCycleDigits(specie,list);
104 if ( fTrigger ) fTrigger->EndOfDetectorCycleDigits(specie,list);
105 }
106 else
107 {
108 AliFatal(Form("Not implemented for task %s",AliQAv1::GetTaskName(task).Data()));
b9bd355c 109 }
b3d57767 110 } // loop on specie
b9bd355c 111
112 // do the QA checking
ece56eb9 113 AliQAChecker::Instance()->Run(AliQAv1::kMUON,task,list,const_cast<AliDetectorRecoParam*>(GetRecoParam()));
04236e67 114}
115
116//____________________________________________________________________________
b3d57767 117TObject* AliMUONQADataMakerRec::GetData(AliQAv1::TASKINDEX_t task, const Int_t index)
118{
119 TObjArray** list = GetList(task);
120 if (list) return GetData(list,index);
121 return 0x0;
122}
123
124//____________________________________________________________________________
125TObjArray** AliMUONQADataMakerRec::GetList(AliQAv1::TASKINDEX_t task)
126{
127 // enum TASKINDEX_t {
128 // kNULLTASKINDEX=-1, kRAWS, kHITS, kSDIGITS, kDIGITS, kDIGITSR, kRECPOINTS, kTRACKSEGMENTS, kRECPARTICLES, kESDS, kNTASKINDEX };
129 if ( task == AliQAv1::kRAWS )
130 {
131 return fRawsQAList;
132 }
133 else if ( task == AliQAv1::kDIGITS || task == AliQAv1::kDIGITSR )
134 {
135 return fDigitsQAList;
136 }
137 else if ( task == AliQAv1::kRECPOINTS )
138 {
139 return fRecPointsQAList;
140 }
141 else
142 {
143 AliFatal(Form("task %s not supported here yet",AliQAv1::GetTaskName(task).Data()));
144 }
145 return 0x0;
146}
147
148//____________________________________________________________________________
04236e67 149void AliMUONQADataMakerRec::InitRaws()
150{
ece56eb9 151 /// create Raws histograms in Raws subdir
df48c8a4 152
ece56eb9 153 if ( fTracker ) fTracker->InitRaws();
154 if ( fTrigger ) fTrigger->InitRaws();
92664bc8 155 //
156 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
f587a77d 157}
04236e67 158
44ed7a66 159//__________________________________________________________________
160void AliMUONQADataMakerRec::InitDigits()
161{
162 /// Initialized Digits spectra
ece56eb9 163 if ( fTracker ) fTracker->InitDigits();
164 if ( fTrigger ) fTrigger->InitDigits();
92664bc8 165 //
166 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
44ed7a66 167}
168
f587a77d 169//____________________________________________________________________________
170void AliMUONQADataMakerRec::InitRecPoints()
171{
172 /// create Reconstructed Points histograms in RecPoints subdir
ece56eb9 173 if ( fTracker ) fTracker->InitRecPoints();
174 if ( fTrigger ) fTrigger->InitRecPoints();
92664bc8 175 //
176 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
04236e67 177}
178
179
180//____________________________________________________________________________
181void AliMUONQADataMakerRec::InitESDs()
182{
c92a8c85 183 ///create ESDs histograms in ESDs subdir
ece56eb9 184 if ( fTracker ) fTracker->InitESDs();
185 if ( fTrigger ) fTrigger->InitESDs();
92664bc8 186 //
187 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
04236e67 188}
189
190//____________________________________________________________________________
191void AliMUONQADataMakerRec::MakeRaws(AliRawReader* rawReader)
192{
ece56eb9 193 /// make QA for rawdata
1d1e08f6 194 /// Note that we do not call the sub-datamaker MakeRaws method
195 /// for events where the MCH or MTR is not part of the readout...
196
197 if ( !rawReader || !rawReader->GetDetectorPattern() ) return;
198
199 UInt_t clmask = rawReader->GetDetectorPattern()[0];
200
ece56eb9 201 if ( fTracker && rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent )
f587a77d 202 {
1d1e08f6 203 UInt_t mchMask = AliDAQ::DetectorPattern(" MUONTRK ");
204 if ( clmask & mchMask )
205 {
206 rawReader->Reset();
207 fTracker->MakeRaws(rawReader);
208 }
f587a77d 209 }
04236e67 210
ece56eb9 211 if ( fTrigger && (rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ||
212 rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent ) )
719914e0 213 {
1d1e08f6 214 UInt_t mtrMask = AliDAQ::DetectorPattern(" MUONTRG ");
215 if ( clmask & mtrMask )
216 {
217 rawReader->Reset();
218 fTrigger->MakeRaws(rawReader);
219 }
719914e0 220 }
92664bc8 221 //
222 IncEvCountCycleRaws();
223 IncEvCountTotalRaws();
224 //
f587a77d 225}
2346e1ad 226
ece56eb9 227//__________________________________________________________________
228void AliMUONQADataMakerRec::MakeDigits()
f587a77d 229{
ece56eb9 230 /// makes data from Digits
bb22d2a6 231
b3d57767 232 AliFatal("Not implemented");
04236e67 233}
234
44ed7a66 235//__________________________________________________________________
236void AliMUONQADataMakerRec::MakeDigits(TTree* digitsTree)
237{
238 /// makes data from Digits
eca4fa66 239
77bd5fcf 240 // Do nothing in case of calibration event
b3d57767 241 if ( GetEventSpecie() == AliRecoParam::kCalib ) return;
77bd5fcf 242
ece56eb9 243 if ( fTracker ) fTracker->MakeDigits(digitsTree);
244 if ( fTrigger ) fTrigger->MakeDigits(digitsTree);
92664bc8 245 //
246 IncEvCountCycleDigits();
247 IncEvCountTotalDigits();
248 //
44ed7a66 249}
250
04236e67 251//____________________________________________________________________________
252void AliMUONQADataMakerRec::MakeRecPoints(TTree* clustersTree)
253{
f587a77d 254 /// Fill histograms from treeR
77bd5fcf 255
256 // Do nothing in case of calibration event
b3d57767 257 if ( GetEventSpecie() == AliRecoParam::kCalib ) return;
f587a77d 258
ece56eb9 259 if ( fTracker ) fTracker->MakeRecPoints(clustersTree);
260 if ( fTrigger ) fTrigger->MakeRecPoints(clustersTree);
92664bc8 261 //
262 IncEvCountCycleRecPoints();
263 IncEvCountTotalRecPoints();
264 //
04236e67 265}
266
267//____________________________________________________________________________
268void AliMUONQADataMakerRec::MakeESDs(AliESDEvent* esd)
269{
c92a8c85 270 /// make QA data from ESDs
77bd5fcf 271
272 // Do nothing in case of calibration event
b3d57767 273 if ( GetEventSpecie() == AliRecoParam::kCalib ) return;
c92a8c85 274
ece56eb9 275 if ( fTracker ) fTracker->MakeESDs(esd);
276 if ( fTrigger ) fTrigger->MakeESDs(esd);
92664bc8 277 //
278 IncEvCountCycleESDs();
279 IncEvCountTotalESDs();
280 //
ece56eb9 281 }
04236e67 282
283//____________________________________________________________________________
152fe71e 284void AliMUONQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
285{
286 /// Reset internals
287
288 for (int spec = 0; spec < AliRecoParam::kNSpecies; ++spec)
289 {
290 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec)))
291 continue;
292
293 if ( task == AliQAv1::kRAWS )
294 {
295 if (fTracker) fTracker->ResetDetectorRaws(fRawsQAList[spec]);
296 if (fTrigger) fTrigger->ResetDetectorRaws(fRawsQAList[spec]);
297 }
298 else if ( task == AliQAv1::kRECPOINTS )
299 {
300 if (fTracker) fTracker->ResetDetectorRecPoints(fRecPointsQAList[spec]);
301 if (fTrigger) fTrigger->ResetDetectorRecPoints(fRecPointsQAList[spec]);
302 }
303 else if ( task == AliQAv1::kESDS )
304 {
305 if (fTracker) fTracker->ResetDetectorESDs(fESDsQAList[spec]);
306 if (fTrigger) fTrigger->ResetDetectorESDs(fESDsQAList[spec]);
307 }
308 else if ( task == AliQAv1::kDIGITS )
309 {
310 if (fTracker) fTracker->ResetDetectorDigits(fDigitsQAList[spec]);
311 if (fTrigger) fTrigger->ResetDetectorDigits(fDigitsQAList[spec]);
312 }
313 else
314 {
b3d57767 315 AliFatal(Form("Not implemented for task %s",AliQAv1::GetTaskName(task).Data()));
152fe71e 316 }
317 }
318}
319
320//____________________________________________________________________________
04236e67 321void AliMUONQADataMakerRec::StartOfDetectorCycle()
322{
92664bc8 323 /// Detector specific actions at start of cycle
324
df48c8a4 325}