NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
NcCalcluster.cxx
Go to the documentation of this file.
1
31
33
65
66#include "NcCalcluster.h"
67#include "Riostream.h"
68
69ClassImp(NcCalcluster); // Class implementation to enable ROOT I/O
70
73{
79
80 fRow=0;
81 fCol=0;
82 fNmods=0;
83 fRowdisp=0.;
84 fColdisp=0.;
85 fNvetos=0;
86 fVetos=0;
87 SetName("NcCalcluster [sig, sig11, sig33, sig55,...]");
88}
89
91{
97
98 if (fVetos)
99 {
100 delete fVetos;
101 fVetos=0;
102 }
103}
104
106{
112
113 fRow=c.fRow;
114 fCol=c.fCol;
115 fNmods=c.fNmods;
119
120 fVetos=new TObjArray();
121 fVetos->SetOwner();
122
123 for (Int_t i=1; i<=fNvetos; i++)
124 {
125 NcSignal* sx=c.GetVetoSignal(i);
126 fVetos->Add(new NcSignal(*sx));
127 }
128}
129
131{
144
145 Nc3Vector r;
146
147 Float_t sig=m.GetClusteredSignal();
148
149 if (sig>0. && m.GetDeadValue()==0)
150 {
151 fRow=m.GetRow();
152 fCol=m.GetColumn();
153 r=m.GetPosition();
154 SetPosition(r);
155 sig=m.GetSignal(1,1); // Use the gain etc... corrected module signal
156 SetSignal(sig);
157 fNmods=1;
158 fRowdisp=0.;
159 fColdisp=0.;
160 m.SetClusteredSignal(0.); // mark module as used in cluster
161 fNvetos=0;
162 fVetos=0;
163 }
164 else
165 {
166 fRow=0;
167 fCol=0;
168 SetPosition(r);
169 fNmods=0;
170 fRowdisp=0.;
171 fColdisp=0.;
172 fNvetos=0;
173 fVetos=0;
174 }
175 SetName("NcCalcluster [sig, sig11, sig33, sig55,...]");
176}
177
179{
185
186 return fRow;
187}
188
190{
196
197 return fCol;
198}
199
201{
207
208 return fNmods;
209}
210
212{
218
219 Float_t sig=GetSignal();
220 if (sig > 0.)
221 {
222 return fRowdisp/sig;
223 }
224 else
225 {
226 return 0.;
227 }
228}
229
231{
237
238 Float_t sig=GetSignal();
239 if (sig > 0.)
240 {
241 return fColdisp/sig;
242 }
243 else
244 {
245 return 0.;
246 }
247}
248
250{
263
265
266 Nc3Vector r;
267
268 if (m.GetClusteredSignal()>0. && m.GetDeadValue()==0)
269 {
270 fRow=m.GetRow();
271 fCol=m.GetColumn();
272 r=m.GetPosition();
273 SetPosition(r);
274 SetSignal(m.GetSignal(1,1)); // Use the gain etc... corrected module signal
275 fNmods=1;
276 fRowdisp=0.;
277 fColdisp=0.;
278 m.SetClusteredSignal(0.); // mark module as used in cluster
279 }
280 else
281 {
282 fRow=0;
283 fCol=0;
284 SetPosition(r);
285 fNmods=0;
286 fRowdisp=0.;
287 fColdisp=0.;
288 }
289}
290
292{
301
302 if (fNmods)
303 {
304 if (m.GetClusteredSignal()>0. && m.GetDeadValue()==0) // only add unused modules
305 {
306 Float_t sigm=m.GetSignal(1,1); // Use the gain etc... corrected module signal
307
308 Int_t drow=int(fabs(double(GetRow()-m.GetRow()))); // row distance to center
309 Int_t dcol=int(fabs(double(GetColumn()-m.GetColumn()))); // column distance to center
310
311 // Determine the ring index for this module around the cluster center
312 Int_t jring=drow;
313 if (dcol>drow) jring=dcol;
314
315 Int_t nvalues=GetNvalues();
316
317 if ((jring+2)<=nvalues) // Module within existing ring(s) ==> Add module signal to the enclosing ring(s)
318 {
319 for (Int_t i=(jring+2); i<=nvalues; i++)
320 {
321 AddSignal(sigm,i);
322 }
323 }
324 else // Module outside all existing rings ==> Init. new ring signals with existing enclosed signal(s)
325 {
326 for (Int_t j=(nvalues+1); j<=(jring+2); j++)
327 {
328 SetSignal(GetSignal(j-1),j);
329 }
330 // Add current module signal to the signal value for the corresponding ring
331 AddSignal(sigm,(jring+2));
332 }
333
334 // Update total cluster signal
335 AddSignal(sigm);
336
337 fNmods+=1;
338 fRowdisp+=sigm*float(drow*drow);
339 fColdisp+=sigm*float(dcol*dcol);
340 m.SetClusteredSignal(0.); // mark module as used in cluster
341 }
342 }
343 else
344 {
345 cout << " *NcCalcluster::Add* No action. Cluster should be started first."
346 << endl;
347 }
348}
349
351{
374
375 if (!fVetos)
376 {
377 fNvetos=0;
378 fVetos=new TObjArray();
379 fVetos->SetOwner();
380 }
381
382 Int_t nvalues=s.GetNvalues();
383 NcSignal* sx=new NcSignal(s); // Additional values will be added
384 TString name=s.GetName();
385 name.Append(" + additional chi2, ndf and CL values");
386 sx->SetName(name);
387
388 Double_t vecc[3],vecv[3];
389 if (extr)
390 {
391 // Extrapolate the veto hit position
392 Double_t scale=1;
393 GetPosition(vecc,"sph");
394 s.GetPosition(vecv,"sph");
395 if (vecv[0]) scale=vecc[0]/vecv[0];
396 Nc3Vector r=s*scale;
397 sx->SetPosition(r);
398 }
399
400 // Calculate the confidence level of association
401 GetPosition(vecc,"car");
402 sx->GetPosition(vecv,"car");
403 Double_t dx=vecc[0]-vecv[0];
404 Double_t dy=vecc[1]-vecv[1];
405 GetPositionErrors(vecc,"car");
406 sx->GetPositionErrors(vecv,"car");
407 Double_t sxc2=vecc[0]*vecc[0];
408 Double_t syc2=vecc[1]*vecc[1];
409 Double_t sxv2=vecv[0]*vecv[0];
410 Double_t syv2=vecv[1]*vecv[1];
411 Double_t sumx2=sxc2+sxv2;
412 Double_t sumy2=syc2+syv2;
413 Double_t chi2=0;
414 if (sumx2>0 && sumy2>0) chi2=(dx*dx/sumx2)+(dy*dy/sumy2);
415 Int_t ndf=2;
416 NcMath m;
417 Double_t prob=m.Prob(chi2,ndf);
418 if (chi2>0) sx->SetSignal(chi2,nvalues+1);
419 if (ndf>0) sx->SetSignal(ndf,nvalues+2);
420 if (prob>0) sx->SetSignal(prob,nvalues+3);
421
422 fVetos->Add(sx);
423 fNvetos++;
424}
425
427{
433
434 return fNvetos;
435}
436
438{
445
446 if (!fVetos)
447 {
448 cout << " *NcCalcluster::GetVetoSignal* No veto signals present." << endl;
449 return 0;
450 }
451 else
452 {
453 if (i>0 && i<=fNvetos)
454 {
455 return (NcSignal*)fVetos->At(i-1);
456 }
457 else
458 {
459 cout << " *NcCalcluster::GetVetoSignal* Signal number " << i << " out of range."
460 << " Nvetos = " << fNvetos << endl;
461 return 0;
462 }
463 }
464}
465
467{
473
474 Float_t cl=0;
475 Float_t clmax=0;
476 NcSignal* s=0;
477 Int_t nvalues=0;
478 if (fVetos)
479 {
480 for (Int_t i=0; i<fNvetos; i++)
481 {
482 s=((NcSignal*)fVetos->At(i));
483 if (s)
484 {
485 nvalues=s->GetNvalues();
486 cl=s->GetSignal(nvalues);
487 if (cl>clmax) clmax=cl;
488 }
489 }
490 }
491 return clmax;
492}
493
494Int_t NcCalcluster::HasVetoHit(Double_t cl) const
495{
503
504 NcSignal* s=0;
505 Int_t nvalues=0;
506 if (fVetos)
507 {
508 for (Int_t i=0; i<fNvetos; i++)
509 {
510 s=((NcSignal*)fVetos->At(i));
511 if (s)
512 {
513 nvalues=s->GetNvalues();
514 if (s->GetSignal(nvalues) > cl) return 1;
515 }
516 }
517 }
518 return 0;
519}
520
ClassImp(NcCalcluster)
Int_t GetDeadValue(Int_t j=1) const
Description of a cluster of calorimeter modules.
Int_t GetNvetos() const
Int_t HasVetoHit(Double_t cl) const
Int_t GetRow() const
Int_t GetNmodules() const
void Add(NcCalmodule &m)
Float_t GetColumnDispersion() const
Float_t GetVetoLevel() const
TObjArray * fVetos
NcSignal * GetVetoSignal(Int_t j) const
void Start(NcCalmodule &m)
Float_t fColdisp
virtual ~NcCalcluster()
Float_t GetRowDispersion() const
Float_t fRowdisp
Int_t GetColumn() const
void AddVetoSignal(NcSignal &s, Int_t extr=1)
Description of a module in a calorimeter system.
Definition NcCalmodule.h:11
Float_t GetClusteredSignal() const
Int_t GetRow() const
Int_t GetColumn() const
void SetClusteredSignal(Double_t val)
Various mathematical tools for scientific analysis.
Definition NcMath.h:26
Double_t Prob(Double_t chi2, Int_t ndf, Int_t mode=1) const
Definition NcMath.cxx:421
void GetPosition(Double_t *r, TString f, TString u="rad", Float_t s=-1) const
NcPosition & GetPosition()
void GetPositionErrors(Double_t *e, TString f, TString u="rad", Float_t s=-1) const
void SetPosition(Double_t *r, TString f, TString u="rad")
virtual void Reset(Int_t mode=0)
Definition NcSignal.cxx:334
virtual void SetSignal(Double_t sig, Int_t j=1)
Definition NcSignal.cxx:516
virtual Float_t GetSignal(Int_t j=1, Int_t mode=0) const
Definition NcSignal.cxx:651
NcSignal(const char *name="", const char *title="")
Definition NcSignal.cxx:155
virtual void AddSignal(Double_t sig, Int_t j=1)
Definition NcSignal.cxx:583
Int_t GetNvalues() const