]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGGA/EMCALTasks/AliAnalysisTaskEMCALClusterizeFast.cxx
New base class
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliAnalysisTaskEMCALClusterizeFast.cxx
index 24b9fbd40f7bdd762a21245126c4cc76796f8f43..170c285513344e81ead9af623737a27324775628 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+//_________________________________________________________________________
+// This analysis provides a new list of clusters to be used in other analysis
+//
+// Author: Constantin Loizides, Salvatore Aiola
+//         Adapted from analysis class from Deepa Thomas
+//
+// $Id$
+//_________________________________________________________________________
 
 // --- Root ---
 #include <TClonesArray.h>
@@ -81,7 +88,8 @@ AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast()
     fShiftEta(2),
     fTRUShift(0),
     fClusterizeFastORs(0),
-    fTrackName()
+    fTrackName(),
+    fCutL0Times(kTRUE)
 { 
   // Constructor
 
@@ -122,7 +130,8 @@ AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast(const cha
     fShiftEta(2),
     fTRUShift(0),
     fClusterizeFastORs(0),
-    fTrackName()
+    fTrackName(),
+    fCutL0Times(kTRUE)
 { 
   // Constructor
 
@@ -136,7 +145,6 @@ AliAnalysisTaskEMCALClusterizeFast::~AliAnalysisTaskEMCALClusterizeFast()
 {
   // Destructor.
 
-  //delete fDigitsArr; 
   delete fClusterizer;
   delete fUnfolder;   
   delete fRecoUtils;
@@ -270,14 +278,8 @@ void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
   } else if (fClusterizeFastORs) { // Fill digits from FastORs
     
     AliEMCALGeometry *fGeom = AliEMCALGeometry::GetInstance(fGeomName);
-  
-    AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
-    if (!esd){
-      AliError("Cannot get the ESD event");
-      return;
-    } 
     
-    AliESDCaloTrigger *triggers = esd->GetCaloTrigger("EMCAL");
+    AliVCaloTrigger *triggers = InputEvent()->GetCaloTrigger("EMCAL");
     
     if (!triggers || !(triggers->GetEntries() > 0))
       return;
@@ -294,12 +296,13 @@ void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
       Int_t triggerTime = 0;
       Int_t ntimes = 0;
       triggers->GetNL0Times(ntimes);
-      if (ntimes > 0) {
-        Int_t trgtimes[25];
-        triggers->GetL0Times(trgtimes);
-        triggerTime = trgtimes[0];
-      }
-      
+      if (!(ntimes > 0) && fCutL0Times)
+       continue;
+
+      Int_t trgtimes[25];
+      triggers->GetL0Times(trgtimes);
+      triggerTime = trgtimes[0];
+     
       Int_t triggerCol = 0, triggerRow = 0;
       triggers->GetPosition(triggerCol, triggerRow);
       
@@ -334,9 +337,9 @@ void AliAnalysisTaskEMCALClusterizeFast::FillDigitsArray()
     Double_t avgE        = 0; // for background subtraction
     const Int_t ncells   = cells->GetNumberOfCells();
     for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
-      Double_t cellAmplitude=0, cellTime=0;
-      Short_t cellNumber=0;
-      if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime) != kTRUE)
+      Double_t cellAmplitude=0, cellTime=0, cellEFrac = 0;
+      Short_t  cellNumber=0, cellMCLabel=-1;
+      if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
         break;
       AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
       digit->SetId(cellNumber);
@@ -385,18 +388,22 @@ void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
 
   AliVCaloCells *cells = InputEvent()->GetEMCALCells();
   AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(fGeomName);
-  AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
+  AliVEvent *event = InputEvent();
+  if (!event) {
+    AliError("Cannot get the event");
+    return;
+  } 
 
   // tracks array for track/cluster matching
   TClonesArray *tarr = 0;
   if (!fTrackName.IsNull()) {
-    tarr = dynamic_cast<TClonesArray*>(esdevent->FindListObject(fTrackName));
+    tarr = dynamic_cast<TClonesArray*>(event->FindListObject(fTrackName));
     if (!tarr) {
       AliError(Form("Cannot get tracks named %s", fTrackName.Data()));
     }
   }
   
-  const Int_t Ncls = fClusterArr->GetEntriesFast();
+  const Int_t Ncls = fClusterArr->GetEntries();
   AliDebug(1, Form("total no of clusters %d", Ncls)); 
   for(Int_t i=0, nout=clus->GetEntries(); i < Ncls; ++i) {
     AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i));
@@ -431,6 +438,16 @@ void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
     c->SetE(recpoint->GetEnergy());
     c->SetPosition(g);
     c->SetNCells(ncells_true);
+    if (esdobjects) {
+      AliESDCaloCluster *cesd = static_cast<AliESDCaloCluster*>(c);
+      cesd->SetCellsAbsId(absIds);
+      cesd->SetCellsAmplitudeFraction(ratios);
+      cesd->SetID(recpoint->GetUniqueID());
+    } else {
+      AliAODCaloCluster *caod = static_cast<AliAODCaloCluster*>(c);
+      caod->SetCellsAbsId(absIds);
+      caod->SetCellsAmplitudeFraction(ratios);
+    }
     c->SetDispersion(recpoint->GetDispersion());
     c->SetEmcCpvDistance(-1);
     c->SetChi2(-1);
@@ -442,8 +459,7 @@ void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
     c->SetM20(elipAxis[1]*elipAxis[1]);
     if (fPedestalData) {
       c->SetDistanceToBadChannel(recpoint->GetDistanceToBadTower()); 
-    } 
-    else {
+    } else {
       if (fRecoUtils && fRecoUtils->IsBadChannelsRemovalSwitchedOn()) {
         fRecoUtils->RecalculateClusterDistanceToBadChannel(geom, cells, c);
       } 
@@ -492,21 +508,8 @@ void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
           imin = t;
         }
       }
-  
-      if (esdobjects) {
-        AliESDCaloCluster *cesd = static_cast<AliESDCaloCluster*>(c);
-        cesd->SetCellsAbsId(absIds);
-        cesd->SetCellsAmplitudeFraction(ratios);
-        cesd->SetID(recpoint->GetUniqueID());
-        cesd->SetEmcCpvDistance(imin);
-        cesd->SetTrackDistance(dPhiMin, dEtaMin);
-      } else {
-        AliAODCaloCluster *caod = static_cast<AliAODCaloCluster*>(c);
-        caod->SetCellsAbsId(absIds);
-        caod->SetCellsAmplitudeFraction(ratios);
-        caod->SetEmcCpvDistance(imin);
-        caod->SetTrackDistance(dPhiMin, dEtaMin);
-      }
+      c->SetEmcCpvDistance(imin);
+      c->SetTrackDistance(dPhiMin, dEtaMin);
     }
   }
 }