er  dev
ERNeuRadHitFinderMF.cxx
1 #include "ERNeuRadHitFinderMF.h"
2 
3 #include <iostream>
4 #include <vector>
5 #include <map>
6 
7 #include "TVector3.h"
8 #include "TGeoMatrix.h"
9 
10 #include "FairRootManager.h"
11 #include "FairRunAna.h"
12 #include "FairRuntimeDb.h"
13 
14 #include "ERDetectorList.h"
15 #include "ERNeuRadDigi.h"
16 #include "ERNeuRadSetup.h"
17 
18 Int_t ERNeuRadHitFinderMF::fEvent = 0;
19 
20 // ----------------------------------------------------------------------------
22  : fPixelThreshold(2.),
23  fModuleThreshold(4.),
24  fNeuRadDigis(NULL),
25  fNeuRadHits(NULL),
26  fDigiPar(NULL),
27  FairTask("ER muSi hit producing scheme")
28 {
29 }
30 // ----------------------------------------------------------------------------
31 
32 // ----------------------------------------------------------------------------
34  : fPixelThreshold(2.),
35  fModuleThreshold(4.),
36  fNeuRadDigis(NULL),
37  fNeuRadHits(NULL),
38  fDigiPar(NULL),
39  FairTask("ER muSi hit producing scheme ", verbose)
40 {
41 }
42 // ----------------------------------------------------------------------------
43 
44 // ----------------------------------------------------------------------------
46 {
47 }
48 //----------------------------------------------------------------------------
49 
50 //----------------------------------------------------------------------------
51 void ERNeuRadHitFinderMF::SetParContainers()
52 {
53  // Get run and runtime database
54  FairRunAna* run = FairRunAna::Instance();
55  if ( ! run ) Fatal("SetParContainers", "No analysis run");
56 
57  FairRuntimeDb* rtdb = run->GetRuntimeDb();
58  if ( ! rtdb ) Fatal("SetParContainers", "No runtime database");
59 
60  fDigiPar = (ERNeuRadDigiPar*)
61  (rtdb->getContainer("ERNeuRadDigiPar"));
62 }
63 //----------------------------------------------------------------------------
64 
65 //----------------------------------------------------------------------------
67 {
68  // Get input array
69  FairRootManager* ioman = FairRootManager::Instance();
70  if ( ! ioman ) Fatal("Init", "No FairRootManager");
71 
72  fNeuRadDigis = (TClonesArray*) ioman->GetObject("NeuRadDigi");
73  //todo check
74 
75  // Register output array fmuSiHits
76  fNeuRadHits = new TClonesArray("ERNeuRadHit",1000);
77 
78  ioman->Register("NeuRadHit", "NeuRad hits", fNeuRadHits, kTRUE);
79 
80  ERNeuRadSetup* NeuRadSetup = ERNeuRadSetup::Instance();
81  NeuRadSetup->Print();
82 
83  return kSUCCESS;
84 }
85 // -------------------------------------------------------------------------
86 
87 // ----- Public method Exec --------------------------------------------
88 void ERNeuRadHitFinderMF::Exec(Option_t* opt)
89 {
90  std::cout << std::endl;
91  std::cout << "####### EVENT " << fEvent++ << " #####" << std::endl;
92  std::cout << std::endl;
93  std::cout << "ERNeuRadHitFinderMF: "<< std::endl;
94  Reset();
95  Float_t fOnePEInteg = 4.8;
96 
97  Int_t hitNumber=0;
98  ERNeuRadSetup* setup = ERNeuRadSetup::Instance();
99  //Суммируем сигналы по модулям
100  Float_t* SumModuleSignals = new Float_t[setup->NofModules()];
101  for (Int_t iModule=0; iModule < setup->NofModules(); iModule++)
102  SumModuleSignals[iModule] =0.;
103  for (Int_t iDigi=0; iDigi < fNeuRadDigis->GetEntriesFast(); iDigi++){
104  ERNeuRadDigi* digi = (ERNeuRadDigi*)fNeuRadDigis->At(iDigi);
105  SumModuleSignals[digi->ModuleIndex()]+=digi->QDC();
106  }
107 
108  Int_t nofModules = 0;
109  for (Int_t iModule=0; iModule < setup->NofModules(); iModule++){
110  if (SumModuleSignals[iModule] > fModuleThreshold*fOnePEInteg)
111  nofModules++;
112  }
113 
114  //if (nofModules == 1){
115  for (Int_t iDigi=0; iDigi < fNeuRadDigis->GetEntriesFast(); iDigi++){
116  ERNeuRadDigi* digi = (ERNeuRadDigi*)fNeuRadDigis->At(iDigi);
117  if (digi->Side()==0 && digi->QDC() > fPixelThreshold*fOnePEInteg && SumModuleSignals[digi->ModuleIndex()] > fModuleThreshold*fOnePEInteg){
118  TVector3 pos(setup->FiberX(digi->ModuleIndex(), digi->FiberIndex()),
119  setup->FiberY(digi->ModuleIndex(), digi->FiberIndex()),
120  setup->Z()-setup->FiberLength());
121  TVector3 dpos(0,0,0);
122  AddHit(kNEURAD,pos, dpos,digi->ModuleIndex(),digi->FiberIndex(),digi->FrontTDC());
123  }
124  }
125  //}
126  delete [] SumModuleSignals;
127  std::cout << "Hits count: " << fNeuRadHits->GetEntriesFast() << std::endl;
128 }
129 //----------------------------------------------------------------------------
130 
131 //----------------------------------------------------------------------------
133 {
134  if (fNeuRadHits) {
135  fNeuRadHits->Delete();
136  }
137 }
138 // ----------------------------------------------------------------------------
139 
140 // ----------------------------------------------------------------------------
142 {
143 }
144 // ----------------------------------------------------------------------------
145 
146 // ----------------------------------------------------------------------------
147 ERNeuRadHit* ERNeuRadHitFinderMF::AddHit(Int_t detID, TVector3& pos, TVector3& dpos,
148  Int_t ModuleIndex, Int_t FiberIndex, Float_t time)
149 {
150  ERNeuRadHit *hit = new((*fNeuRadHits)[fNeuRadHits->GetEntriesFast()])
151  ERNeuRadHit(fNeuRadHits->GetEntriesFast(),detID, pos, dpos,-1, ModuleIndex, FiberIndex, time);
152  return hit;
153 }
154 // ----------------------------------------------------------------------------
155 
156 //-----------------------------------------------------------------------------
157 ClassImp(ERNeuRadHitFinderMF)
TClonesArray * fNeuRadDigis
virtual void Exec(Option_t *opt)
virtual InitStatus Init()