SND@LHC Software
Loading...
Searching...
No Matches
ecalClusterFinder.cxx
Go to the documentation of this file.
1#include "ecalClusterFinder.h"
2
3#include "TClonesArray.h"
4
5#include "FairRootManager.h"
6#include "FairTrackParam.h"
7
8#include "ecalStructure.h"
9#include "ecalCell.h"
10#include "ecalInf.h"
11#include "ecalCluster.h"
12#include "ecalPreCluster.h"
13#include "ecalMaximum.h"
15
16#include <iostream>
17#include <list>
18
19using namespace std;
20
22void ecalClusterFinder::Exec(Option_t* option)
23{
24 fEv++;
25
29}
30
32{
33 FairRootManager* io=FairRootManager::Instance();
34 if (!io)
35 {
36 Fatal("Init", "Can't find IOManager.");
37 return kFATAL;
38 }
39 fStr=(ecalStructure*)io->GetObject("EcalStructure");
40 if (!fStr)
41 {
42 Fatal("Init()", "Can't find calorimeter structure in the system.");
43 return kFATAL;
44 }
46 fMaximums=(TClonesArray*)io->GetObject("EcalMaximums");
47 if (!fMaximums)
48 {
49 Fatal("Init", "Can't find array of calorimeter maximums in the system.");
50 return kFATAL;
51 }
52 fCalib=(ecalClusterCalibration*)io->GetObject("ecalClusterCalibration");
53 if (!fCalib)
54 {
55 Fatal("Init", "Can't find ecalClusterCalibration in the system.");
56 return kFATAL;
57 }
58
59 fClusters=new TClonesArray("ecalCluster", 2000);
60 io->Register("EcalClusters", "ECAL", fClusters, kTRUE);
61 fEv=0;
62 return kSUCCESS;
63}
64
65TClonesArray* ecalClusterFinder::InitPython(ecalStructure* structure, TClonesArray* maximums, ecalClusterCalibration* calib)
66{
67 fMaximums=maximums;
68 fStr=structure;
69 fCalib=calib;
70 fClusters=new TClonesArray("ecalCluster", 2000);
71 return fClusters;
72}
73
76{
77 ;
78}
79
82{
83 if (fClusters)
84 {
85 fClusters->Delete();
86 delete fClusters;
87 }
88}
89
94{
95 Int_t nm=fMaximums->GetEntriesFast();
96 Int_t i=0;
97 ecalMaximum* max;
98 list<ecalCell*> all;
99 list<ecalCell*>::const_iterator p;
100 list<ecalCell*>::const_iterator p2;
101 list<ecalCell*> cls;
102 list<ecalCell*> cls2;
103 ecalCell* cell;
104 ecalCell* min;
105 Double_t e;
106 Double_t ecls;
107 ecalPreCluster* precluster;
108
109
110 for(;i<nm;i++)
111 {
112 max=(ecalMaximum*)fMaximums->At(i);
113 if (max==NULL) continue;
115 if (max->Mark()!=0) continue;
116 cell=max->Cell();
117 ecls=cell->GetEnergy();
118// cout << ecls << endl;
120 if (ecls<fMinMaxE) continue;
121/*
122 cell->GetNeighborsList(all);
123 cls.clear();
124 for(p=all.begin();p!=all.end();++p)
125 {
126 (*p)->GetNeighborsList(cls2);
127 for(p2=cls2.begin();p2!=cls2.end();++p2)
128 if (find(cls.begin(), cls.end(), *p2)==cls.end()) cls.push_back(*p2);
129 }
130*/
131 cell->Get5x5Cluster(cls);
132 ecls=0.0;
133 for(p=cls.begin();p!=cls.end();++p)
134 ecls+=(*p)->GetEnergy();
135// cout << ":" << ecls << endl;
137 if (ecls<fMinClusterE) continue;
138 precluster=new ecalPreCluster(cls, max);
139 fPreClusters.push_back(precluster);
140 }
141}
142
145{
147 fClusters->Delete();
148 Int_t fN=0;
149 list<ecalPreCluster*>::const_iterator p1=fPreClusters.begin();
150 list<ecalPreCluster*>::const_iterator p2;
151 list<ecalCell*> cluster;
152 list<ecalMaximum*> maxs;
153 list<ecalCell*>::const_iterator pc;
154 list<ecalCell*>::const_iterator pc1;
155 UInt_t oldsize;
156 Int_t MaxSize=0;
157 Int_t Maximums=0;
158 Int_t max;
159 Int_t type;
160
161 if (fVerbose>9)
162 {
163 Info("FormClusters", "Total %d preclusters found.", (Int_t)fPreClusters.size());
164 }
165 for(;p1!=fPreClusters.end();++p1)
166 if ((*p1)->fMark==0)
167 {
168 cluster.clear(); oldsize=0; maxs.clear();
169 cluster=(*p1)->fCells; maxs.push_back((*p1)->fMax); type=(*p1)->fMaximum->GetType();
170 max=1;
171 while(cluster.size()!=oldsize)
172 {
173 oldsize=cluster.size();
174 p2=p1;
175 for(++p2;p2!=fPreClusters.end();++p2)
176 if ((*p2)->fMark==0)
177 {
178 pc=cluster.begin();
179 for(;pc!=cluster.end();++pc)
180 {
181 pc1=find((*p2)->fCells.begin(), (*p2)->fCells.end(), (*pc));
182 if (pc1==(*p2)->fCells.end()) continue;
183 break;
184 }
185 if (pc!=cluster.end())
186 {
187 (*p2)->fMark=1;
188 pc=(*p2)->fCells.begin();
189 for(;pc!=(*p2)->fCells.end();++pc)
190 if (find(cluster.begin(), cluster.end(), (*pc))==cluster.end())
191 cluster.push_back(*pc);
192 maxs.push_back((*p2)->fMax);
193 max++;
194 }
195 }
196 }
197 (*p1)->fMark=1;
198 if ((Int_t)cluster.size()>MaxSize)
199 MaxSize=cluster.size();
200 if (max>Maximums) Maximums=max;
201 ecalCluster* cls=new ((*fClusters)[fN]) ecalCluster(fN, cluster, maxs); fN++;
202 cls->fPreCalibrated=fCalib->Calibrate(type, cls->fEnergy);
203 }
204 if (fVerbose>0)
205 {
206 Info("FormClusters", "Total %d clusters formed.", fN);
207 Info("FormClusters", "Maximum size of cluster is %d cells.", MaxSize);
208 Info("FormClusters", "Maximum number of photons per cluster is %d.", Maximums);
209 }
210}
211
214{
215 list<ecalPreCluster*>::const_iterator p=fPreClusters.begin();
216 for(;p!=fPreClusters.end();++p)
217 delete (*p);
218 fPreClusters.clear();
219}
220
222ecalClusterFinder::ecalClusterFinder(const char* name, const Int_t verbose)
223 : FairTask(name, verbose),
224 fEv(0),
225 fMaximums(NULL),
226 fClusters(NULL),
227 fStr(NULL),
228 fInf(NULL),
229 fPreClusters(),
230 fMinClusterE(0.03),
231 fMinMaxE(0.015)
232{
233 ;
234}
235
236
239 : FairTask(),
240 fEv(0),
241 fMaximums(NULL),
242 fClusters(NULL),
243 fStr(NULL),
244 fInf(NULL),
245 fPreClusters(),
246 fMinClusterE(0.03),
247 fMinMaxE(0.015)
248{
249 ;
250}
251
void Get5x5Cluster(std::list< ecalCell * > &cls)
Definition ecalCell.h:58
Float_t GetEnergy() const
Definition ecalCell.h:42
Double_t Calibrate(Int_t celltype, Double_t energy)
TClonesArray * InitPython(ecalStructure *structure, TClonesArray *maximums, ecalClusterCalibration *calib)
std::list< ecalPreCluster * > fPreClusters
virtual void Exec(Option_t *option)
ecalStructure * fStr
TClonesArray * fClusters
virtual InitStatus Init()
ecalClusterCalibration * fCalib
TClonesArray * fMaximums
Double_t fEnergy
Definition ecalCluster.h:73
Double_t fPreCalibrated
Definition ecalCluster.h:75
ecalInf * GetEcalInf() const
ClassImp(ecalContFact) ecalContFact