]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALClusterizerv2.cxx
AliCaloPID: Correct matching rejection in case of recalculation in the analysis,...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALClusterizerv2.cxx
CommitLineData
8c0c0f09 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
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.)
26//
27
28// --- ROOT system ---
29
30#include <TFile.h>
31#include <TMath.h>
32#include <TMinuit.h>
33#include <TTree.h>
34#include <TBenchmark.h>
35#include <TBrowser.h>
36#include <TROOT.h>
37#include <TList.h>
38#include <TClonesArray.h>
39
40// --- Standard library ---
41#include <cassert>
42
43// --- AliRoot header files ---
44#include "AliLog.h"
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"
53
54ClassImp(AliEMCALClusterizerv2)
55
56//____________________________________________________________________________
57AliEMCALClusterizerv2::AliEMCALClusterizerv2()
58 : AliEMCALClusterizerv1(), fDoEnGradCut(1)
59{
60 // ctor with the indication of the file where header Tree and digits Tree are stored
61}
62
63//____________________________________________________________________________
64AliEMCALClusterizerv2::AliEMCALClusterizerv2(AliEMCALGeometry* geometry)
65 : AliEMCALClusterizerv1(geometry), fDoEnGradCut(1)
66{
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
70}
71
72//____________________________________________________________________________
73AliEMCALClusterizerv2::AliEMCALClusterizerv2(AliEMCALGeometry* geometry, AliEMCALCalibData* calib, AliCaloCalibPedestal* caloped)
74 : AliEMCALClusterizerv1(geometry, calib, caloped), fDoEnGradCut(1)
75{
76 // ctor, geometry and calibration are initialized elsewhere.
77}
78
79//____________________________________________________________________________
80AliEMCALClusterizerv2::~AliEMCALClusterizerv2()
81{
82 // dtor
83}
84
85//____________________________________________________________________________
86Int_t AliEMCALClusterizerv2::AreNeighbours(AliEMCALDigit* d1, AliEMCALDigit* d2, Bool_t& shared) const
87{
88 // Gives the neighbourness of two digits = 0 are not neighbour; continue searching
89 // = 1 are neighbour
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
95
96 if (fDoEnGradCut) {
97 if (d2->GetCalibAmp()>d1->GetCalibAmp())
98 return 3; // energy of neighboring cell should be smaller in order to become a neighbor
99 }
100 return AliEMCALClusterizerv1::AreNeighbours(d1,d2,shared);
101}
102
103//____________________________________________________________________________
104void AliEMCALClusterizerv2::MakeClusters()
105{
106 // Make list of clusters. Start from highest energy cell.
107
108 if (fGeom==0)
109 AliFatal("Did not get geometry from EMCALLoader");
110
111 fRecPoints->Delete();
112
113 // set up TObjArray with pointers to digits to work on
114 TObjArray digitsC;
fd555bfe 115 Double_t ehs = 0.0;
8c0c0f09 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)
122 continue;
123 if (!fGeom->CheckAbsCellId(digit->GetId()))
124 continue;
125 ehs += dEnergyCalibrated;
126 digitsC.AddLast(digit);
127 }
128
129 AliDebug(1,Form("MakeClusters: Number of digits %d -> ehs %f (minE %f)\n",
130 fDigitsArr->GetEntries(),ehs,fMinECut));
131
132 TIter nextdigitC(&digitsC);
133 while (1) {
134 Int_t iMaxEnergyDigit = -1;
135 Float_t dMaxEnergyDigit = -1;
136 AliEMCALDigit *pMaxEnergyDigit = 0;
137 nextdigitC.Reset();
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;
144 }
145 }
146 if (iMaxEnergyDigit<0 || digitsC.GetEntries() <= 0) {
147 break;
148 }
149
150 if (fNumberOfECAClusters>=fRecPoints->GetSize())
151 fRecPoints->Expand(2*fNumberOfECAClusters+1);
152
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();
162
163 AliDebug(1,Form("MakeClusters: Max digit found id = %d, ene = %f , clus.th. = %f \n",
164 iMaxEnergyDigit, dMaxEnergyDigit, fECAClusteringThreshold));
165
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 )
172 continue;
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);
178 }
179 }
180 }
181 AliDebug(2,Form("MakeClusters: %d digitd, energy %f \n", clusterDigits.GetEntries(), recPoint->GetEnergy()));
182 }
183 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,fDigitsArr->GetEntriesFast()));
184}
185