SND@LHC Software
Loading...
Searching...
No Matches
ecalMaximumLocator.cxx
Go to the documentation of this file.
2
3#include "ecalStructure.h"
4#include "ecalInf.h"
5#include "ecalMaximum.h"
6#include "ecalCell.h"
7
8#include "FairRootManager.h"
9
10#include "TClonesArray.h"
11
12#include <list>
13#include <iostream>
14
15using namespace std;
16
18 : FairTask(),
19 fMaximums(NULL),
20 fStr(NULL),
21 fECut(0.015),
22 fEvent(-1)
23{
24}
25
26ecalMaximumLocator::ecalMaximumLocator(const char* name, Int_t verbose)
27 : FairTask(name, verbose),
28 fMaximums(NULL),
29 fStr(NULL),
30 fECut(0.015),
31 fEvent(-1)
32{
33}
34
40
42{
43 FairRootManager* fManager=FairRootManager::Instance();
44 if (!fManager)
45 {
46 Fatal("Init", "Can't find a Root Manager.");
47 return kFATAL;
48 }
49 fStr=(ecalStructure*)fManager->GetObject("EcalStructure");
50 if (!fStr)
51 {
52 Fatal("Init()", "Can't find calorimeter structure in the system.");
53 return kFATAL;
54 }
55 fMaximums=new TClonesArray("ecalMaximum", 3000);
56 fManager->Register("EcalMaximums", "ECAL", fMaximums, kFALSE);
57 fEvent=0;
58 return kSUCCESS;
59}
60
62{
63 fStr=structure;
64 fMaximums=new TClonesArray("ecalMaximum", 3000);
65 return fMaximums;
66}
67
69{
70 fMaximums->Clear();
71}
72
73void ecalMaximumLocator::Exec(const Option_t* opt)
74{
75 list<ecalCell*> all;
76 list<ecalCell*> cells;
77 list<ecalCell*>::const_iterator p;
78 list<ecalCell*>::const_iterator r;
79 Double_t e;
80 Double_t z=fStr->GetEcalInf()->GetZPos();
81 Double_t r1;
82 Double_t r2;
83 Double_t t;
84 Int_t n=0;
85
86 fEvent++;
87 fMaximums->Clear();
88 fStr->GetCells(all);
89 for(p=all.begin();p!=all.end();++p)
90 {
91 e=(*p)->GetEnergy();
92 r1=(*p)->GetCenterX(); r1*=r1;
93 t=(*p)->GetCenterY(); t*=t;
94 r1=TMath::Sqrt(r1*r1+t*t);
95 if (e<fECut)
96 continue;
97 (*p)->GetNeighborsList(cells);
98 for(r=cells.begin();r!=cells.end();++r)
99 {
100 if ((*r)->GetEnergy()<e) continue;
101 if ((*r)->GetEnergy()==e)
102 {
103 r2=(*r)->GetCenterX(); r2*=r2;
104 t=(*r)->GetCenterY(); t*=t;
105 r2=TMath::Sqrt(r2*r2+t*t);
106 if (r1>=r2) continue;
107 }
108 break;
109 }
110 if (r!=cells.end())
111 continue;
112// cout << e << " : " << (*p)->GetCenterX() << ", " << (*p)->GetCenterY() << endl;
113 new ((*fMaximums)[n++]) ecalMaximum(*p, z);
114 }
115 if (fVerbose>9)
116 Info("Exec", "%d maximums found", n);
117}
118
Double_t GetZPos() const
Definition ecalInf.h:34
TClonesArray * fMaximums
virtual InitStatus Init()
virtual void Exec(const Option_t *option)
TClonesArray * InitPython(ecalStructure *structure)
void GetCells(std::list< ecalCell * > &cells) const
ecalInf * GetEcalInf() const
ClassImp(ecalContFact) ecalContFact