//
// Clusters containing a bad cell can be rejected, use SetBadCells().
//
+// The output can be directly saved into a file (see the class second
+// constructor). Saving through AliAnalysisManager is always happen with
+// TObject::kSingleKey option. In such case an output from different runs
+// cannot be merged later, because here we have histograms which are
+// run-dependent, i.e. not the same between every analysis instance.
+//
+// If you forget to initialize EMCAL/PHOS geometry, the class will do it
+// for you.
+//
// See AddTaskCaloCellsQA.C for usage example.
//
//----
// --- AliRoot header files ---
#include <AliAnalysisTaskCaloCellsQA.h>
+#include "AliAnalysisManager.h"
#include <AliVEvent.h>
#include <AliVCaloCells.h>
#include <AliVCluster.h>
#include <AliVVertex.h>
+#include <AliEMCALGeometry.h>
+#include <AliPHOSGeometry.h>
+#include <AliLog.h>
ClassImp(AliAnalysisTaskCaloCellsQA)
AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA() : AliAnalysisTaskSE(),
fkAvoidPileup(kTRUE),
fCellsQA(0),
- fOutfile(new TString),
- fBadCells(0),
- fNBad(0)
+ fOutfile(""),
+ fNBad(0),
+ fBadCells(0)
{
+ // Constructor for root I/O, do not use it
}
//________________________________________________________________
-AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA(const char *name) : AliAnalysisTaskSE(name),
+AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA(const char *name, Int_t nmods, Int_t det, char *outfile) :
+ AliAnalysisTaskSE(name),
fkAvoidPileup(kTRUE),
fCellsQA(0),
- fOutfile(new TString),
- fBadCells(0),
- fNBad(0)
-{
-}
-
-//________________________________________________________________
-AliAnalysisTaskCaloCellsQA::~AliAnalysisTaskCaloCellsQA()
+ fOutfile(""),
+ fNBad(0),
+ fBadCells(0)
{
- if (fCellsQA) delete fCellsQA;
- delete fOutfile;
- if (fBadCells) delete [] fBadCells;
-}
-
-//________________________________________________________________
-void AliAnalysisTaskCaloCellsQA::InitCaloCellsQA(char* fname, Int_t nmods, Int_t det)
-{
- // Must be called at the very beginning.
+ // Main constructor.
//
- // fname -- output file name;
// nmods -- number of supermodules + 1;
// det -- detector;
+ // outfile -- file name to write to; if NULL, write into output container;
+ // allows to avoid limitation of AliAnalysisManager, which always
+ // writes with TObject::kSingleKey option.
+
if (det == kEMCAL)
fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kEMCAL);
else if (det == kPHOS)
fCellsQA = new AliCaloCellsQA(nmods, AliCaloCellsQA::kPHOS);
else
- Fatal("AliAnalysisTaskCaloCellsQA::InitCellsQA", "Wrong detector provided");
+ AliFatal("Wrong detector provided");
- *fOutfile = fname;
+ if (outfile) fOutfile = outfile;
+ else
+ DefineOutput(1, TObjArray::Class());
+}
+
+//________________________________________________________________
+AliAnalysisTaskCaloCellsQA::~AliAnalysisTaskCaloCellsQA()
+{
+ if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fCellsQA;
+ if (fBadCells) delete [] fBadCells;
}
//________________________________________________________________
// Per run histograms cannot be initialized here
fCellsQA->InitSummaryHistograms();
+
+ if (fOutfile.Length() == 0)
+ PostData(1, fCellsQA->GetListOfHistos());
}
//________________________________________________________________
// event
AliVEvent *event = InputEvent();
if (!event) {
- Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get event");
+ AliWarning("Could not get event");
return;
}
+ fCellsQA->InitTransientFindCurrentRun(event->GetRunNumber());
+
+ // check geometry
+ if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL) {
+ if (!AliEMCALGeometry::GetInstance()) {
+ AliInfo("EMCAL geometry not initialized, initializing it for you");
+ AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
+ }
+ } else {
+ if (!AliPHOSGeometry::GetInstance()) {
+ AliInfo("PHOS geometry not initialized, initializing it for you");
+ AliPHOSGeometry::GetInstance("IHEP");
+ }
+ }
+
// pileup; FIXME: why AliVEvent does not allow a version without arguments?
if (fkAvoidPileup && event->IsPileupFromSPD(3,0.8,3.,2.,5.))
return;
cells = event->GetPHOSCells();
if (!cells) {
- Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get cells");
+ AliWarning("Could not get cells");
return;
}
// primary vertex
AliVVertex *vertex = (AliVVertex*) event->GetPrimaryVertex();
if (!vertex) {
- Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get primary vertex");
+ AliWarning("Could not get primary vertex");
return;
}
for (Int_t i = 0; i < event->GetNumberOfCaloClusters(); i++) {
AliVCluster *clus = event->GetCaloCluster(i);
if (!clus) {
- Warning("AliAnalysisTaskCaloCellsQA::UserExec", "Could not get cluster");
+ AliWarning("Could not get cluster");
return;
}
Double_t vertexXYZ[3];
vertex->GetXYZ(vertexXYZ);
fCellsQA->Fill(event->GetRunNumber(), &clusArray, cells, vertexXYZ);
+
+ if (fOutfile.Length() == 0)
+ PostData(1, fCellsQA->GetListOfHistos());
}
//________________________________________________________________
void AliAnalysisTaskCaloCellsQA::Terminate(Option_t*)
{
- // The AliCaloCellsQA analysis output should not be saved through
- // AliAnalysisManager, because it will write with TObject::kSingleKey
- // option. Such an output cannot be merged later: we have histograms
- // which are run-dependent, i.e. not the same between every analysis
- // instance.
-
- TFile f(fOutfile->Data(), "RECREATE");
- fCellsQA->GetListOfHistos()->Write();
+ // Handle direct saving of the histograms into a file
+
+ if (fOutfile.Length() > 0) {
+ TFile f(fOutfile.Data(), "RECREATE");
+ fCellsQA->GetListOfHistos()->Write();
+ }
}
//____________________________________________________________