// By default, pileup events are not processed, use SetAvoidPileup()
// to change this.
//
+// Clusters containing a bad cell can be rejected, use SetBadCells().
+//
// See AddTaskCaloCellsQA.C for usage example.
//
//----
AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA(const char *name) : AliAnalysisTaskSE(name),
fkAvoidPileup(kTRUE),
fCellsQA(0),
- fOutfile(new TString)
+ fOutfile(new TString),
+ fBadCells(0),
+ fNBad(0)
{
}
{
if (fCellsQA) delete fCellsQA;
delete fOutfile;
+ if (fBadCells) delete [] fBadCells;
}
//________________________________________________________________
return;
}
+ // basic filtering
+ if (fCellsQA->GetDetector() == AliCaloCellsQA::kEMCAL && !clus->IsEMCAL()) continue;
+ if (fCellsQA->GetDetector() == AliCaloCellsQA::kPHOS && !clus->IsPHOS()) continue;
+ if (IsClusterBad(clus)) continue;
+
clusArray.Add(clus);
}
TFile f(fOutfile->Data(), "RECREATE");
fCellsQA->GetListOfHistos()->Write();
}
+
+//____________________________________________________________
+void AliAnalysisTaskCaloCellsQA::SetBadCells(Int_t badcells[], Int_t nbad)
+{
+ // Set absId numbers for bad cells;
+ // clusters which contain a bad cell will be rejected.
+
+ // switch off bad cells, if asked
+ if (nbad <= 0) {
+ if (fBadCells) delete [] fBadCells;
+ fNBad = 0;
+ return;
+ }
+
+ fNBad = nbad;
+ fBadCells = new Int_t[nbad];
+
+ for (Int_t i = 0; i < nbad; i++)
+ fBadCells[i] = badcells[i];
+}
+
+//________________________________________________________________
+Bool_t AliAnalysisTaskCaloCellsQA::IsClusterBad(AliVCluster *clus)
+{
+ // Returns true if cluster contains a bad cell
+
+ for (Int_t b = 0; b < fNBad; b++)
+ for (Int_t c = 0; c < clus->GetNCells(); c++)
+ if (clus->GetCellAbsId(c) == fBadCells[b])
+ return kTRUE;
+
+ return kFALSE;
+}
void UserExec(Option_t *);\r
void Terminate(Option_t *);\r
\r
+ void SetBadCells(Int_t badcells[], Int_t nbad);\r
+\r
// getters and setters\r
AliCaloCellsQA* GetCaloCellsQA() { return fCellsQA; }\r
Bool_t GetAvoidPileup() { return fkAvoidPileup; }\r
void SetAvoidPileup(Bool_t flag) { fkAvoidPileup = flag; }\r
void SetOutputFileName(char* fname) { *fOutfile = fname; }\r
\r
+protected:\r
+ Bool_t IsClusterBad(AliVCluster *clus);\r
+\r
private:\r
AliAnalysisTaskCaloCellsQA(const AliAnalysisTaskCaloCellsQA &);\r
AliAnalysisTaskCaloCellsQA & operator = (const AliAnalysisTaskCaloCellsQA &);\r
Bool_t fkAvoidPileup; // flag not to process pileup events\r
AliCaloCellsQA* fCellsQA; // analysis instance\r
TString* fOutfile; // output file name\r
+ Int_t* fBadCells; // bad cells array\r
+ Int_t fNBad; // number of entries in fBadCells\r
\r
ClassDef(AliAnalysisTaskCaloCellsQA, 1);\r
};\r
// vertex->GetXYZ(vertexXYZ);
//
// // clusters
-// static TObjArray *clusArray = new TObjArray;
-// clusArray->Clear();
+// TObjArray clusArray;
// for (Int_t i = 0; i < event->GetNumberOfCaloClusters(); i++) {
// AliVCluster *clus = event->GetCaloCluster(i);
//
// // filter clusters here, if necessary
// // if (clus->E() < 0.3) continue;
+// // if (clus->GetNCells() < 2) continue;
//
-// clusArray->Add(clus);
+// clusArray.Add(clus);
// }
//
// // apply afterburners, etc.
// // ...
//
-// cellsQA->Fill(event->GetRunNumber(), clusArray, cells, vertexXYZ);
+// cellsQA->Fill(event->GetRunNumber(), &clusArray, cells, vertexXYZ);
//
// d) Do not forget to post data, where necessary:
// PostData(1,cellsQA->GetListOfHistos());
fXMaxECells(0),
fXMaxPi0Mass(0),
fXMaxNCellsInCluster(0),
+ fRunNumbers(),
+ fNRuns(0),
+ fRI(-1),
fAbsIdMin(0),
fAbsIdMax(0),
fListOfHistos(0),
fXMaxECells(0),
fXMaxPi0Mass(0),
fXMaxNCellsInCluster(0),
+ fRunNumbers(),
+ fNRuns(0),
+ fRI(-1),
fAbsIdMin(0),
fAbsIdMax(0),
fListOfHistos(0),
{
// Return current run index; add a new run if necessary.
- static Int_t ri = -1; // run index
- static Int_t runNumbers[1000]; // already encountered runs ...
- static Int_t nruns = 0; // ... and their number
-
// try previous value ...
- if (ri >= 0 && runNumbers[ri] == runNumber) return ri;
+ if (fRI >= 0 && fRunNumbers[fRI] == runNumber) return fRI;
// ... or find current run index ...
- for (ri = 0; ri < nruns; ri++)
- if (runNumbers[ri] == runNumber) return ri;
+ for (fRI = 0; fRI < fNRuns; fRI++)
+ if (fRunNumbers[fRI] == runNumber) return fRI;
// ... or add a new run
- if (nruns >= 1000)
+ if (fNRuns >= 1000)
Fatal("AliCaloCellsQA::FindCurrentRunIndex", "Too many runs, how is this possible?");
- // ri = nruns
- runNumbers[ri] = runNumber;
- InitHistosForRun(runNumber, ri);
- nruns++;
+ // fRI = fNRuns
+ fRunNumbers[fRI] = runNumber;
+ InitHistosForRun(runNumber, fRI);
+ fNRuns++;
- return ri;
+ return fRI;
}
//_________________________________________________________________________
// EMCAL
if (fDetector == kEMCAL) {
- static AliEMCALGeometry *geomEMCAL = AliEMCALGeometry::GetInstance();
+ AliEMCALGeometry *geomEMCAL = AliEMCALGeometry::GetInstance();
if (!geomEMCAL)
Fatal("AliCaloCellsQA::AbsIdToSMEtaPhi", "EMCAL geometry is not initialized");
// PHOS
if (fDetector == kPHOS) {
- static AliPHOSGeometry *geomPHOS = AliPHOSGeometry::GetInstance();
+ AliPHOSGeometry *geomPHOS = AliPHOSGeometry::GetInstance();
if (!geomPHOS)
Fatal("AliCaloCellsQA::AbsIdToSMEtaPhi", "PHOS geometry is not initialized");
Double_t fXMaxPi0Mass; // X axis maximum in hPi0Mass
Double_t fXMaxNCellsInCluster; // X axis maximum in hNCellsInCluster
+ // internal parameters
+ Int_t fRunNumbers[1000]; // already encountered runs
+ Int_t fNRuns; // number of encountered runs
+ Int_t fRI; // current (cached) run index
+
// internal parameters, used for coding convenience
- Int_t fAbsIdMin; // minimum absId number (0/EMCAL, 1/PHOS)
- Int_t fAbsIdMax; // maximum absId number + 1
+ Int_t fAbsIdMin; // minimum absId number (0/EMCAL, 1/PHOS)
+ Int_t fAbsIdMax; // maximum absId number + 1
- TObjArray *fListOfHistos; //! array with all the histograms
- TH1D *fhNEventsProcessedPerRun; //! number of processed events per run
+ TObjArray *fListOfHistos; //! array with all the histograms
+ TH1D *fhNEventsProcessedPerRun; //! number of processed events per run
// per run histograms, X axis -- cell absId number;
// NOTE: the maximum number of runs to handle per analysis instance is set to 1000;
// AliAnalysisTaskCaloCellsQA *taskQA = AddTaskCaloCellsQA(10); // 10 supermodules
// taskQA->SelectCollisionCandidates(AliVEvent::kMB); // if necessary
// // taskQA->SetAvoidPileup(kFALSE); // some customization
+ // // Int_t badcells[] = {74,103,917};
+ // // taskQA->SetBadCells(badcells, 3); // reject clusters containing any of these cells
//
// Usage example for PHOS:
//