]>
Commit | Line | Data |
---|---|---|
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 | // | |
f4dd0897 | 20 | // Clusters containing a bad cell can be rejected, use SetBadCells(). |
21 | // | |
4dfe4df7 | 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. | |
27 | // | |
28 | // If you forget to initialize EMCAL/PHOS geometry, the class will do it | |
29 | // for you. | |
30 | // | |
045862db | 31 | // See AddTaskCaloCellsQA.C for usage example. |
32 | // | |
33 | //---- | |
34 | // Author: Olga Driga (SUBATECH) | |
35 | ||
36 | // --- ROOT system --- | |
37 | #include <TFile.h> | |
0d81af58 | 38 | #include <TObjArray.h> |
045862db | 39 | |
40 | // --- AliRoot header files --- | |
41 | #include <AliAnalysisTaskCaloCellsQA.h> | |
42 | #include <AliVEvent.h> | |
43 | #include <AliVCaloCells.h> | |
44 | #include <AliVCluster.h> | |
45 | #include <AliVVertex.h> | |
4dfe4df7 | 46 | #include <AliEMCALGeometry.h> |
47 | #include <AliPHOSGeometry.h> | |
db05d873 | 48 | #include <AliLog.h> |
045862db | 49 | |
50 | ClassImp(AliAnalysisTaskCaloCellsQA) | |
51 | ||
60a1d411 | 52 | //________________________________________________________________ |
53 | AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA() : AliAnalysisTaskSE(), | |
54 | fkAvoidPileup(kTRUE), | |
55 | fCellsQA(0), | |
d30ac678 | 56 | fOutfile(""), |
4dfe4df7 | 57 | fNBad(0), |
58 | fBadCells(0) | |
60a1d411 | 59 | { |
d30ac678 | 60 | // Constructor for root I/O, do not use it |
60a1d411 | 61 | } |
62 | ||
045862db | 63 | //________________________________________________________________ |
d30ac678 | 64 | AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA(const char *name, Int_t nmods, Int_t det, char *outfile) : |
65 | AliAnalysisTaskSE(name), | |
0d81af58 | 66 | fkAvoidPileup(kTRUE), |
045862db | 67 | fCellsQA(0), |
d30ac678 | 68 | fOutfile(""), |
4dfe4df7 | 69 | fNBad(0), |
70 | fBadCells(0) | |
045862db | 71 | { |
d30ac678 | 72 | // Main constructor. |
73 | // | |
74 | // nmods -- number of supermodules + 1; | |
75 | // det -- detector; | |
4dfe4df7 | 76 | // outfile -- file name to write to; if NULL, write into output container; |
77 | // allows to avoid limitation of AliAnalysisManager, which always | |
78 | // writes with TObject::kSingleKey option. | |
79 | ||
d30ac678 | 80 | |
81 | if (det == kEMCAL) | |
82 | fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kEMCAL); | |
83 | else if (det == kPHOS) | |
84 | fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kPHOS); | |
85 | else | |
db05d873 | 86 | AliFatal("Wrong detector provided"); |
d30ac678 | 87 | |
88 | if (outfile) fOutfile = outfile; | |
4dfe4df7 | 89 | else |
90 | DefineOutput(1, TObjArray::Class()); | |
045862db | 91 | } |
92 | ||
93 | //________________________________________________________________ | |
94 | AliAnalysisTaskCaloCellsQA::~AliAnalysisTaskCaloCellsQA() | |
95 | { | |
d30ac678 | 96 | delete fCellsQA; |
f4dd0897 | 97 | if (fBadCells) delete [] fBadCells; |
045862db | 98 | } |
99 | ||
045862db | 100 | //________________________________________________________________ |
101 | void AliAnalysisTaskCaloCellsQA::UserCreateOutputObjects() | |
102 | { | |
103 | // Per run histograms cannot be initialized here | |
104 | ||
105 | fCellsQA->InitSummaryHistograms(); | |
4dfe4df7 | 106 | |
d30ac678 | 107 | if (fOutfile.Length() == 0) |
4dfe4df7 | 108 | PostData(1, fCellsQA->GetListOfHistos()); |
045862db | 109 | } |
110 | ||
111 | //________________________________________________________________ | |
112 | void AliAnalysisTaskCaloCellsQA::UserExec(Option_t *) | |
113 | { | |
114 | // Does the job for one event | |
115 | ||
db05d873 | 116 | // event |
117 | AliVEvent *event = InputEvent(); | |
118 | if (!event) { | |
119 | AliWarning("Could not get event"); | |
120 | return; | |
121 | } | |
122 | ||
123 | fCellsQA->InitTransientFindCurrentRun(event->GetRunNumber()); | |
124 | ||
4dfe4df7 | 125 | // check geometry |
d30ac678 | 126 | if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL) { |
4dfe4df7 | 127 | if (!AliEMCALGeometry::GetInstance()) { |
db05d873 | 128 | AliInfo("EMCAL geometry not initialized, initializing it for you"); |
4dfe4df7 | 129 | AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1"); |
130 | } | |
131 | } else { | |
132 | if (!AliPHOSGeometry::GetInstance()) { | |
db05d873 | 133 | AliInfo("PHOS geometry not initialized, initializing it for you"); |
4dfe4df7 | 134 | AliPHOSGeometry::GetInstance("IHEP"); |
135 | } | |
136 | } | |
137 | ||
0d81af58 | 138 | // pileup; FIXME: why AliVEvent does not allow a version without arguments? |
139 | if (fkAvoidPileup && event->IsPileupFromSPD(3,0.8,3.,2.,5.)) | |
140 | return; | |
141 | ||
045862db | 142 | // cells |
143 | AliVCaloCells *cells; | |
144 | if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL) | |
145 | cells = event->GetEMCALCells(); | |
146 | else | |
147 | cells = event->GetPHOSCells(); | |
148 | ||
149 | if (!cells) { | |
db05d873 | 150 | AliWarning("Could not get cells"); |
045862db | 151 | return; |
152 | } | |
153 | ||
154 | // primary vertex | |
155 | AliVVertex *vertex = (AliVVertex*) event->GetPrimaryVertex(); | |
156 | if (!vertex) { | |
db05d873 | 157 | AliWarning("Could not get primary vertex"); |
045862db | 158 | return; |
159 | } | |
160 | ||
161 | // collect clusters | |
0d81af58 | 162 | TObjArray clusArray; |
045862db | 163 | for (Int_t i = 0; i < event->GetNumberOfCaloClusters(); i++) { |
164 | AliVCluster *clus = event->GetCaloCluster(i); | |
165 | if (!clus) { | |
db05d873 | 166 | AliWarning("Could not get cluster"); |
045862db | 167 | return; |
168 | } | |
169 | ||
f4dd0897 | 170 | // basic filtering |
171 | if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL && !clus->IsEMCAL()) continue; | |
172 | if (fCellsQA->GetDetector() == AliCaloCellsQA::kPHOS && !clus->IsPHOS()) continue; | |
173 | if (IsClusterBad(clus)) continue; | |
174 | ||
0d81af58 | 175 | clusArray.Add(clus); |
045862db | 176 | } |
177 | ||
178 | Double_t vertexXYZ[3]; | |
179 | vertex->GetXYZ(vertexXYZ); | |
0d81af58 | 180 | fCellsQA->Fill(event->GetRunNumber(), &clusArray, cells, vertexXYZ); |
4dfe4df7 | 181 | |
d30ac678 | 182 | if (fOutfile.Length() == 0) |
4dfe4df7 | 183 | PostData(1, fCellsQA->GetListOfHistos()); |
045862db | 184 | } |
185 | ||
186 | //________________________________________________________________ | |
187 | void AliAnalysisTaskCaloCellsQA::Terminate(Option_t*) | |
188 | { | |
4dfe4df7 | 189 | // Handle direct saving of the histograms into a file |
190 | ||
d30ac678 | 191 | if (fOutfile.Length() > 0) { |
192 | TFile f(fOutfile.Data(), "RECREATE"); | |
4dfe4df7 | 193 | fCellsQA->GetListOfHistos()->Write(); |
194 | } | |
045862db | 195 | } |
f4dd0897 | 196 | |
197 | //____________________________________________________________ | |
198 | void AliAnalysisTaskCaloCellsQA::SetBadCells(Int_t badcells[], Int_t nbad) | |
199 | { | |
200 | // Set absId numbers for bad cells; | |
201 | // clusters which contain a bad cell will be rejected. | |
202 | ||
ef7b092d | 203 | if (fBadCells) delete [] fBadCells; |
204 | ||
f4dd0897 | 205 | // switch off bad cells, if asked |
206 | if (nbad <= 0) { | |
f4dd0897 | 207 | fNBad = 0; |
208 | return; | |
209 | } | |
210 | ||
211 | fNBad = nbad; | |
212 | fBadCells = new Int_t[nbad]; | |
213 | ||
214 | for (Int_t i = 0; i < nbad; i++) | |
215 | fBadCells[i] = badcells[i]; | |
216 | } | |
217 | ||
218 | //________________________________________________________________ | |
219 | Bool_t AliAnalysisTaskCaloCellsQA::IsClusterBad(AliVCluster *clus) | |
220 | { | |
221 | // Returns true if cluster contains a bad cell | |
222 | ||
223 | for (Int_t b = 0; b < fNBad; b++) | |
224 | for (Int_t c = 0; c < clus->GetNCells(); c++) | |
225 | if (clus->GetCellAbsId(c) == fBadCells[b]) | |
226 | return kTRUE; | |
227 | ||
228 | return kFALSE; | |
229 | } |