1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (SUBATECH & Kurchatov Institute)
19 //-- Gustavo Conesa (LPSC-Grenoble), move common clusterizer functionalities to mother class
20 //////////////////////////////////////////////////////////////////////////////
21 // Clusterization class. Performs clusterization (collects neighbouring active cells) and
22 // unfolds the clusters having several local maxima.
23 // Results are stored in TreeR#, branches EMCALTowerRP (EMC recPoints),
24 // EMCALPreShoRP (CPV RecPoints) and AliEMCALClusterizer (Clusterizer with all
25 // parameters including input digits branch title, thresholds etc.)
28 // --- ROOT system ---
34 #include <TBenchmark.h>
38 #include <TClonesArray.h>
40 // --- Standard library ---
43 // --- AliRoot header files ---
45 #include "AliEMCALClusterizerv2.h"
46 #include "AliEMCALRecPoint.h"
47 #include "AliEMCALDigit.h"
48 #include "AliEMCALGeometry.h"
49 #include "AliCaloCalibPedestal.h"
50 #include "AliEMCALCalibData.h"
51 #include "AliESDCaloCluster.h"
52 #include "AliEMCALUnfolding.h"
54 ClassImp(AliEMCALClusterizerv2)
56 //____________________________________________________________________________
57 AliEMCALClusterizerv2::AliEMCALClusterizerv2()
58 : AliEMCALClusterizerv1(), fDoEnGradCut(1)
60 // ctor with the indication of the file where header Tree and digits Tree are stored
63 //____________________________________________________________________________
64 AliEMCALClusterizerv2::AliEMCALClusterizerv2(AliEMCALGeometry* geometry)
65 : AliEMCALClusterizerv1(geometry), fDoEnGradCut(1)
67 // ctor with the indication of the file where header Tree and digits Tree are stored
68 // use this contructor to avoid usage of Init() which uses runloader
69 // change needed by HLT - MP
72 //____________________________________________________________________________
73 AliEMCALClusterizerv2::AliEMCALClusterizerv2(AliEMCALGeometry* geometry, AliEMCALCalibData* calib, AliCaloCalibPedestal* caloped)
74 : AliEMCALClusterizerv1(geometry, calib, caloped), fDoEnGradCut(1)
76 // ctor, geometry and calibration are initialized elsewhere.
79 //____________________________________________________________________________
80 AliEMCALClusterizerv2::~AliEMCALClusterizerv2()
85 //____________________________________________________________________________
86 Int_t AliEMCALClusterizerv2::AreNeighbours(AliEMCALDigit* d1, AliEMCALDigit* d2, Bool_t& shared) const
88 // Gives the neighbourness of two digits = 0 are not neighbour; continue searching
90 // = 2 is in different SM; continue searching
91 // In case it is in different SM, but same phi rack, check if neigbours at eta=0
92 // neighbours are defined as digits having at least a common side
93 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
94 // which is compared to a digit (d2) not yet in a cluster
97 if (d2->GetCalibAmp()>d1->GetCalibAmp())
98 return 3; // energy of neighboring cell should be smaller in order to become a neighbor
100 return AliEMCALClusterizerv1::AreNeighbours(d1,d2,shared);
103 //____________________________________________________________________________
104 void AliEMCALClusterizerv2::MakeClusters()
106 // Make list of clusters. Start from highest energy cell.
109 AliFatal("Did not get geometry from EMCALLoader");
111 fRecPoints->Delete();
113 // set up TObjArray with pointers to digits to work on
116 AliEMCALDigit *digit = 0;
117 TIter nextdigit(fDigitsArr);
118 while ( (digit = static_cast<AliEMCALDigit*>(nextdigit())) ) {
119 Float_t dEnergyCalibrated = Calibrate(digit->GetAmplitude(), digit->GetTime(),digit->GetId());
120 digit->SetCalibAmp(dEnergyCalibrated);
121 if (dEnergyCalibrated < fMinECut)
123 if (!fGeom->CheckAbsCellId(digit->GetId()))
125 ehs += dEnergyCalibrated;
126 digitsC.AddLast(digit);
129 AliDebug(1,Form("MakeClusters: Number of digits %d -> ehs %f (minE %f)\n",
130 fDigitsArr->GetEntries(),ehs,fMinECut));
132 TIter nextdigitC(&digitsC);
134 Int_t iMaxEnergyDigit = -1;
135 Float_t dMaxEnergyDigit = -1;
136 AliEMCALDigit *pMaxEnergyDigit = 0;
138 while ( (digit = static_cast<AliEMCALDigit *>(nextdigitC())) ) {
139 Float_t dEnergyCalibrated = digit->GetCalibAmp();
140 if (dEnergyCalibrated>fECAClusteringThreshold && dEnergyCalibrated>dMaxEnergyDigit) {
141 dMaxEnergyDigit = dEnergyCalibrated;
142 iMaxEnergyDigit = digit->GetId();
143 pMaxEnergyDigit = digit;
146 if (iMaxEnergyDigit<0 || digitsC.GetEntries() <= 0) {
150 if (fNumberOfECAClusters>=fRecPoints->GetSize())
151 fRecPoints->Expand(2*fNumberOfECAClusters+1);
153 AliEMCALRecPoint *recPoint = new AliEMCALRecPoint("");
154 recPoint->SetClusterType(AliVCluster::kEMCALClusterv1);
155 recPoint->AddDigit(*pMaxEnergyDigit, dMaxEnergyDigit, kFALSE);
156 fRecPoints->AddAt(recPoint, fNumberOfECAClusters++);
157 digitsC.Remove(pMaxEnergyDigit);
158 TObjArray clusterDigits;
159 clusterDigits.AddLast(pMaxEnergyDigit);
160 TIter nextClusterDigit(&clusterDigits);
161 Float_t time = pMaxEnergyDigit->GetTime();
163 AliDebug(1,Form("MakeClusters: Max digit found id = %d, ene = %f , clus.th. = %f \n",
164 iMaxEnergyDigit, dMaxEnergyDigit, fECAClusteringThreshold));
166 while ( (digit = static_cast<AliEMCALDigit*>(nextClusterDigit())) ) { // scan over digits in cluster
167 TIter nextdigitN(&digitsC);
168 AliEMCALDigit *digitN = 0; // digi neighbor
169 while ( (digitN = static_cast<AliEMCALDigit*>(nextdigitN())) ) { // scan over all digits to look for neighbours
170 //Do not add digits with too different time
171 if (TMath::Abs(time - digitN->GetTime()) > fTimeCut )
173 Bool_t shared = kFALSE; //cluster shared by 2 SuperModules?
174 if (AreNeighbours(digit, digitN, shared)==1) {
175 recPoint->AddDigit(*digitN, digitN->GetCalibAmp(), shared);
176 clusterDigits.AddLast(digitN);
177 digitsC.Remove(digitN);
181 AliDebug(2,Form("MakeClusters: %d digitd, energy %f \n", clusterDigits.GetEntries(), recPoint->GetEnergy()));
183 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,fDigitsArr->GetEntriesFast()));