]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
1) static variable were replaced by local variables and data members
authorkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Apr 2011 09:52:24 +0000 (09:52 +0000)
committerkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Apr 2011 09:52:24 +0000 (09:52 +0000)
2) setter for bad channel array is added

PWG4/UserTasks/CaloCellQA/AliAnalysisTaskCaloCellsQA.cxx
PWG4/UserTasks/CaloCellQA/AliAnalysisTaskCaloCellsQA.h
PWG4/UserTasks/CaloCellQA/AliCaloCellsQA.cxx
PWG4/UserTasks/CaloCellQA/AliCaloCellsQA.h
PWG4/UserTasks/CaloCellQA/macros/AddTaskCaloCellsQA.C

index 7655f368480dd6bc42252e12c57539e85edd4d03..525285d7104c88232777501516e0baada448306b 100644 (file)
@@ -17,6 +17,8 @@
 // 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.
 //
 //----
@@ -39,7 +41,9 @@ ClassImp(AliAnalysisTaskCaloCellsQA)
 AliAnalysisTaskCaloCellsQA::AliAnalysisTaskCaloCellsQA(const char *name) : AliAnalysisTaskSE(name),
   fkAvoidPileup(kTRUE),
   fCellsQA(0),
-  fOutfile(new TString)
+  fOutfile(new TString),
+  fBadCells(0),
+  fNBad(0)
 {
 }
 
@@ -48,6 +52,7 @@ AliAnalysisTaskCaloCellsQA::~AliAnalysisTaskCaloCellsQA()
 {
   if (fCellsQA) delete fCellsQA;
   delete fOutfile;
+  if (fBadCells) delete [] fBadCells;
 }
 
 //________________________________________________________________
@@ -121,6 +126,11 @@ void AliAnalysisTaskCaloCellsQA::UserExec(Option_t *)
       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);
   }
 
@@ -141,3 +151,36 @@ void AliAnalysisTaskCaloCellsQA::Terminate(Option_t*)
   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;
+}
index be2f999ec7836246e09b58b8f9407129d5d18c1b..c034ac0e032774c7d458dbe15a40a421492d551f 100644 (file)
@@ -34,6 +34,8 @@ public:
   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
@@ -41,6 +43,9 @@ public:
   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
@@ -49,6 +54,8 @@ private:
   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
index 61f333c796f1d4f86ac2551c6d5ec8f4e1b11737..d144beea7b414e597c13d5f89e6f88f9de2289c8 100644 (file)
 //    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());
@@ -101,6 +101,9 @@ AliCaloCellsQA::AliCaloCellsQA() :
   fXMaxECells(0),
   fXMaxPi0Mass(0),
   fXMaxNCellsInCluster(0),
+  fRunNumbers(),
+  fNRuns(0),
+  fRI(-1),
   fAbsIdMin(0),
   fAbsIdMax(0),
   fListOfHistos(0),
@@ -144,6 +147,9 @@ AliCaloCellsQA::AliCaloCellsQA(Int_t nmods, Int_t det, Int_t startRunNumber, Int
   fXMaxECells(0),
   fXMaxPi0Mass(0),
   fXMaxNCellsInCluster(0),
+  fRunNumbers(),
+  fNRuns(0),
+  fRI(-1),
   fAbsIdMin(0),
   fAbsIdMax(0),
   fListOfHistos(0),
@@ -367,27 +373,23 @@ Int_t AliCaloCellsQA::FindCurrentRunIndex(Int_t runNumber)
 {
   // 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;
 }
 
 //_________________________________________________________________________
@@ -715,7 +717,7 @@ void AliCaloCellsQA::AbsIdToSMEtaPhi(Int_t absId, Int_t &sm, Int_t &eta, Int_t &
 
   // EMCAL
   if (fDetector == kEMCAL) {
-    static AliEMCALGeometry *geomEMCAL = AliEMCALGeometry::GetInstance();
+    AliEMCALGeometry *geomEMCAL = AliEMCALGeometry::GetInstance();
     if (!geomEMCAL)
       Fatal("AliCaloCellsQA::AbsIdToSMEtaPhi", "EMCAL geometry is not initialized");
 
@@ -727,7 +729,7 @@ void AliCaloCellsQA::AbsIdToSMEtaPhi(Int_t absId, Int_t &sm, Int_t &eta, Int_t &
 
   // PHOS
   if (fDetector == kPHOS) {
-    static AliPHOSGeometry *geomPHOS = AliPHOSGeometry::GetInstance();
+    AliPHOSGeometry *geomPHOS = AliPHOSGeometry::GetInstance();
     if (!geomPHOS)
       Fatal("AliCaloCellsQA::AbsIdToSMEtaPhi", "PHOS geometry is not initialized");
 
index 842c44b7a769e2e9b1a89787735e36f5c1c8a89a..84b24014cead7c8b36b525f8c5881f6fe846f965 100644 (file)
@@ -95,12 +95,17 @@ private:
   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;
index 914d3a093450b92be976f371004cf133208f4624..9ed0bacca08768900bf1396c40238134bb35c24c 100644 (file)
@@ -10,6 +10,8 @@ AliAnalysisTaskCaloCellsQA* AddTaskCaloCellsQA(Int_t nmods = 10, Int_t det = 0,
   //   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:
   //