]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQADataMaker.cxx
protect QA agains non TH objects
[u/mrichter/AliRoot.git] / STEER / AliQADataMaker.cxx
CommitLineData
421ab0fb 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
16
17/* $Id$ */
18
202374b1 19//
20// Base Class
21// Produces the data needed to calculate the quality assurance.
22// All data must be mergeable objects.
23// Y. Schutz CERN July 2007
24//
421ab0fb 25
26// --- ROOT system ---
27#include <TSystem.h>
28#include <TFile.h>
6c18591a 29#include <TList.h>
d76c31f4 30#include <TTree.h>
d5cf81bd 31#include <TClonesArray.h>
421ab0fb 32
33// --- Standard library ---
34
35// --- AliRoot header files ---
36#include "AliLog.h"
2e42b4d4 37#include "AliQADataMaker.h"
38#include "AliQAChecker.h"
d76c31f4 39#include "AliESDEvent.h"
d5cf81bd 40#include "AliRawReader.h"
421ab0fb 41
2e42b4d4 42ClassImp(AliQADataMaker)
312e6f8d 43
421ab0fb 44//____________________________________________________________________________
2e42b4d4 45AliQADataMaker::AliQADataMaker(const char * name, const char * title) :
421ab0fb 46 TNamed(name, title),
47 fOutput(0x0),
6c18591a 48 fDetectorDir(0x0),
312e6f8d 49 fDetectorDirName(""),
5b188f2f 50 fCurrentCycle(-1),
51 fCycle(9999999),
52 fCycleCounter(0),
53 fRun(0)
421ab0fb 54{
55 // ctor
421ab0fb 56 fDetectorDirName = GetName() ;
57}
58
59//____________________________________________________________________________
2e42b4d4 60AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
421ab0fb 61 TNamed(qadm.GetName(), qadm.GetTitle()),
62 fOutput(qadm.fOutput),
6c18591a 63 fDetectorDir(qadm.fDetectorDir),
312e6f8d 64 fDetectorDirName(qadm.fDetectorDirName),
5b188f2f 65 fCurrentCycle(qadm.fCurrentCycle),
66 fCycle(qadm.fCycle),
67 fCycleCounter(qadm.fCycleCounter),
a4976ef3 68 fRun(qadm.fRun)
421ab0fb 69{
70 //copy ctor
71 fDetectorDirName = GetName() ;
72}
73
ba7aca7d 74//____________________________________________________________________________
4edbc5bc 75Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray * list)
ba7aca7d 76{
04236e67 77 // Set histograms memory resident and add to the list
ab4351aa 78 // Maximm allowed is 10000
cb905b0f 79 TString className(hist->ClassName()) ;
80 if( ! className.BeginsWith("TH") ) {
81 AliError(Form("QA data Object must be a generic TH1 ROOT object and not %s", className.Data())) ;
82 return -1 ;
83 }
ab4351aa 84 if ( index > 10000 ) {
85 AliError("Max number of authorized QA objects is 10000") ;
04236e67 86 return -1 ;
87 } else {
88 hist->SetDirectory(0) ;
89 list->AddAtAndExpand(hist, index) ;
90 return list->GetLast() ;
91 }
421ab0fb 92}
93
96d67a8d 94//____________________________________________________________________________
95void AliQADataMaker::DefaultEndOfDetectorCycle(AliQA::TASKINDEX_t task)
96{
97 // this method must be oveloaded by detectors
98 // sets the QA result to Fatal
7c002d48 99 AliQA::Instance(AliQA::GetDetIndex(GetName())) ;
96d67a8d 100 AliQA * qa = AliQA::Instance(task) ;
101 qa->Set(AliQA::kFATAL) ;
102 AliQA::GetQAResultFile()->cd() ;
103 qa->Write(AliQA::GetQAName(), kWriteDelete) ;
104 AliQA::GetQAResultFile()->Close() ;
105}
106
421ab0fb 107//____________________________________________________________________________
c65c502a 108void AliQADataMaker::Finish() const
421ab0fb 109{
96d67a8d 110 // write to the output File
d9cbd8fd 111 if (fOutput)
112 fOutput->Close() ;
421ab0fb 113}
114
115//____________________________________________________________________________
04236e67 116TObject * AliQADataMaker::GetData(TObjArray * list, const Int_t index)
117{
118 // Returns the QA object at index. Limit is 100.
27773260 119 if (list) {
120 if ( index > 10000 ) {
121 AliError("Max number of authorized QA objects is 10000") ;
122 return NULL ;
123 } else {
124 return list->At(index) ;
125 }
04236e67 126 } else {
27773260 127 AliError("Data list is NULL !!") ;
128 return NULL ;
04236e67 129 }
27773260 130}
312e6f8d 131
5b188f2f 132//____________________________________________________________________________
609d9712 133void AliQADataMaker::Reset(const Bool_t sameCycle)
c65c502a 134{
135 // Resets defaut value of data members
609d9712 136 if (!sameCycle) {
137 fCycleCounter = 0 ;
138 }
fe6925e9 139}