1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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
17 // By default, pileup events are not processed, use SetAvoidPileup()
20 // Clusters containing a bad cell can be rejected, use SetBadCells().
22 // The output can be directly saved into a file (see the class second
23 // constructor). Saving through AliAnalysisManager is always happen with
24 // TObject::kSingleKey option. In such case an output from different runs
25 // cannot be merged later, because here we have histograms which are
26 // run-dependent, i.e. not the same between every analysis instance.
28 // If you forget to initialize EMCAL/PHOS geometry, the class will do it
31 // See AddTaskCaloCellsQA.C for usage example.
34 // Author: Olga Driga (SUBATECH)
36 // --- ROOT system ---
38 #include <TObjArray.h>
40 // --- AliRoot header files ---
41 #include <AliAnalysisTaskCaloCellsQA.h>
42 #include "AliAnalysisManager.h"
43 #include <AliVEvent.h>
44 #include <AliVCaloCells.h>
45 #include <AliVCluster.h>
46 #include <AliVVertex.h>
47 #include <AliEMCALGeometry.h>
48 #include <AliPHOSGeometry.h>
51 ClassImp(AliAnalysisTaskCaloCellsQA)
53 //________________________________________________________________
54 AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA() : AliAnalysisTaskSE(),
61 // Constructor for root I/O, do not use it
64 //________________________________________________________________
65 AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA(const char *name, Int_t nmods, Int_t det, char *outfile) :
66 AliAnalysisTaskSE(name),
75 // nmods -- number of supermodules + 1;
77 // outfile -- file name to write to; if NULL, write into output container;
78 // allows to avoid limitation of AliAnalysisManager, which always
79 // writes with TObject::kSingleKey option.
83 fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kEMCAL);
84 else if (det == kPHOS)
85 fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kPHOS);
87 AliFatal("Wrong detector provided");
89 if (outfile) fOutfile = outfile;
91 DefineOutput(1, TObjArray::Class());
94 //________________________________________________________________
95 AliAnalysisTaskCaloCellsQA::~AliAnalysisTaskCaloCellsQA()
97 if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fCellsQA;
98 if (fBadCells) delete [] fBadCells;
101 //________________________________________________________________
102 void AliAnalysisTaskCaloCellsQA::UserCreateOutputObjects()
104 // Per run histograms cannot be initialized here
106 fCellsQA->InitSummaryHistograms();
108 if (fOutfile.Length() == 0)
109 PostData(1, fCellsQA->GetListOfHistos());
112 //________________________________________________________________
113 void AliAnalysisTaskCaloCellsQA::UserExec(Option_t *)
115 // Does the job for one event
118 AliVEvent *event = InputEvent();
120 AliWarning("Could not get event");
124 fCellsQA->InitTransientFindCurrentRun(event->GetRunNumber());
127 if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL) {
128 if (!AliEMCALGeometry::GetInstance()) {
129 AliInfo("EMCAL geometry not initialized, initializing it for you");
130 AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
133 if (!AliPHOSGeometry::GetInstance()) {
134 AliInfo("PHOS geometry not initialized, initializing it for you");
135 AliPHOSGeometry::GetInstance("IHEP");
139 // pileup; FIXME: why AliVEvent does not allow a version without arguments?
140 if (fkAvoidPileup && event->IsPileupFromSPD(3,0.8,3.,2.,5.))
144 AliVCaloCells *cells;
145 if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL)
146 cells = event->GetEMCALCells();
148 cells = event->GetPHOSCells();
151 AliWarning("Could not get cells");
156 AliVVertex *vertex = (AliVVertex*) event->GetPrimaryVertex();
158 AliWarning("Could not get primary vertex");
164 for (Int_t i = 0; i < event->GetNumberOfCaloClusters(); i++) {
165 AliVCluster *clus = event->GetCaloCluster(i);
167 AliWarning("Could not get cluster");
172 if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL && !clus->IsEMCAL()) continue;
173 if (fCellsQA->GetDetector() == AliCaloCellsQA::kPHOS && !clus->IsPHOS()) continue;
174 if (IsClusterBad(clus)) continue;
179 Double_t vertexXYZ[3];
180 vertex->GetXYZ(vertexXYZ);
181 fCellsQA->Fill(event->GetRunNumber(), &clusArray, cells, vertexXYZ);
183 if (fOutfile.Length() == 0)
184 PostData(1, fCellsQA->GetListOfHistos());
187 //________________________________________________________________
188 void AliAnalysisTaskCaloCellsQA::Terminate(Option_t*)
190 // Handle direct saving of the histograms into a file
192 if (fOutfile.Length() > 0) {
193 TFile f(fOutfile.Data(), "RECREATE");
194 fCellsQA->GetListOfHistos()->Write();
198 //____________________________________________________________
199 void AliAnalysisTaskCaloCellsQA::SetBadCells(Int_t badcells[], Int_t nbad)
201 // Set absId numbers for bad cells;
202 // clusters which contain a bad cell will be rejected.
204 if (fBadCells) delete [] fBadCells;
206 // switch off bad cells, if asked
213 fBadCells = new Int_t[nbad];
215 for (Int_t i = 0; i < nbad; i++)
216 fBadCells[i] = badcells[i];
219 //________________________________________________________________
220 Bool_t AliAnalysisTaskCaloCellsQA::IsClusterBad(AliVCluster *clus)
222 // Returns true if cluster contains a bad cell
224 for (Int_t b = 0; b < fNBad; b++)
225 for (Int_t c = 0; c < clus->GetNCells(); c++)
226 if (clus->GetCellAbsId(c) == fBadCells[b])