]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/UserTasks/CaloCellQA/AliAnalysisTaskCaloCellsQA.cxx
Fix for uploading packages in proof mode (D.Stocco)
[u/mrichter/AliRoot.git] / PWG4 / UserTasks / CaloCellQA / AliAnalysisTaskCaloCellsQA.cxx
CommitLineData
045862db 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// Container class for bad channels & bad runs identification
16//
0d81af58 17// By default, pileup events are not processed, use SetAvoidPileup()
18// to change this.
19//
045862db 20// See AddTaskCaloCellsQA.C for usage example.
21//
22//----
23// Author: Olga Driga (SUBATECH)
24
25// --- ROOT system ---
26#include <TFile.h>
0d81af58 27#include <TObjArray.h>
045862db 28
29// --- AliRoot header files ---
30#include <AliAnalysisTaskCaloCellsQA.h>
31#include <AliVEvent.h>
32#include <AliVCaloCells.h>
33#include <AliVCluster.h>
34#include <AliVVertex.h>
35
36ClassImp(AliAnalysisTaskCaloCellsQA)
37
38//________________________________________________________________
39AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA(const char *name) : AliAnalysisTaskSE(name),
0d81af58 40 fkAvoidPileup(kTRUE),
045862db 41 fCellsQA(0),
0d81af58 42 fOutfile(new TString)
045862db 43{
045862db 44}
45
46//________________________________________________________________
47AliAnalysisTaskCaloCellsQA::~AliAnalysisTaskCaloCellsQA()
48{
045862db 49 if (fCellsQA) delete fCellsQA;
0d81af58 50 delete fOutfile;
045862db 51}
52
53//________________________________________________________________
54void AliAnalysisTaskCaloCellsQA::InitCaloCellsQA(char* fname, Int_t nmods, Int_t det)
55{
56 // Must be called at the very beginning.
57 //
58 // fname -- output file name;
59 // nmods -- number of supermodules + 1;
60 // det -- detector;
045862db 61
62 if (det == kEMCAL)
63 fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kEMCAL);
64 else if (det == kPHOS)
65 fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kPHOS);
66 else
67 Fatal("AliAnalysisTaskCaloCellsQA::InitCellsQA", "Wrong detector provided");
68
0d81af58 69 *fOutfile = fname;
045862db 70}
71
72//________________________________________________________________
73void AliAnalysisTaskCaloCellsQA::UserCreateOutputObjects()
74{
75 // Per run histograms cannot be initialized here
76
77 fCellsQA->InitSummaryHistograms();
78}
79
80//________________________________________________________________
81void AliAnalysisTaskCaloCellsQA::UserExec(Option_t *)
82{
83 // Does the job for one event
84
85 // event
86 AliVEvent *event = InputEvent();
87 if (!event) {
88 Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get event");
89 return;
90 }
91
0d81af58 92 // pileup; FIXME: why AliVEvent does not allow a version without arguments?
93 if (fkAvoidPileup && event->IsPileupFromSPD(3,0.8,3.,2.,5.))
94 return;
95
045862db 96 // cells
97 AliVCaloCells *cells;
98 if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL)
99 cells = event->GetEMCALCells();
100 else
101 cells = event->GetPHOSCells();
102
103 if (!cells) {
104 Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get cells");
105 return;
106 }
107
108 // primary vertex
109 AliVVertex *vertex = (AliVVertex*) event->GetPrimaryVertex();
110 if (!vertex) {
111 Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get primary vertex");
112 return;
113 }
114
115 // collect clusters
0d81af58 116 TObjArray clusArray;
045862db 117 for (Int_t i = 0; i < event->GetNumberOfCaloClusters(); i++) {
118 AliVCluster *clus = event->GetCaloCluster(i);
119 if (!clus) {
120 Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get cluster");
121 return;
122 }
123
0d81af58 124 clusArray.Add(clus);
045862db 125 }
126
127 Double_t vertexXYZ[3];
128 vertex->GetXYZ(vertexXYZ);
0d81af58 129 fCellsQA->Fill(event->GetRunNumber(), &clusArray, cells, vertexXYZ);
045862db 130}
131
132//________________________________________________________________
133void AliAnalysisTaskCaloCellsQA::Terminate(Option_t*)
134{
135 // The AliCaloCellsQA analysis output should not be saved through
136 // AliAnalysisManager, because it will write with TObject::kSingleKey
137 // option. Such an output cannot be merged later: we have histograms
138 // which are run-dependent, i.e. not the same between every analysis
139 // instance.
140
141 TFile f(fOutfile->Data(), "RECREATE");
142 fCellsQA->GetListOfHistos()->Write();
143}