er  dev
ERNeuRadHitFinderWBT.cxx
1 #include "ERNeuRadHitFinderWBT.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 "ERNeuRadPixelSignal.h"
16 #include "ERNeuRadSetup.h"
17 
18 Int_t ERNeuRadHitFinderWBT::fEvent = 0;
19 
20 // ----------------------------------------------------------------------------
22  : FairTask("ER NeuRad hit producing scheme")
23 {
24 }
25 // ----------------------------------------------------------------------------
26 
27 // ----------------------------------------------------------------------------
29  : FairTask("ER NeuRad hit producing scheme ", verbose)
30 {
31 }
32 // ----------------------------------------------------------------------------
33 
34 // ----------------------------------------------------------------------------
36 {
37 }
38 //----------------------------------------------------------------------------
39 
40 //----------------------------------------------------------------------------
41 void ERNeuRadHitFinderWBT::SetParContainers()
42 {
43  // Get run and runtime database
44  FairRunAna* run = FairRunAna::Instance();
45  if ( ! run ) Fatal("SetParContainers", "No analysis run");
46 
47  FairRuntimeDb* rtdb = run->GetRuntimeDb();
48  if ( ! rtdb ) Fatal("SetParContainers", "No runtime database");
49 
50  fDigiPar = (ERNeuRadDigiPar*)
51  (rtdb->getContainer("ERNeuRadDigiPar"));
52 }
53 //----------------------------------------------------------------------------
54 
55 //----------------------------------------------------------------------------
57 {
58  // Get input array
59  FairRootManager* ioman = FairRootManager::Instance();
60  if ( ! ioman ) Fatal("Init", "No FairRootManager");
61 
62  fNeuRadPMTSignals = (TClonesArray*) ioman->GetObject("NeuRadPMTSignal");
63  //todo check
64 
65  // Register output array fmuSiHits
66  fNeuRadHits = new TClonesArray("ERNeuRadHitWBT",1000);
67 
68  ioman->Register("NeuRadHit", "NeuRad hits", fNeuRadHits, kTRUE);
69 
70  ERNeuRadSetup* NeuRadSetup = ERNeuRadSetup::Instance();
71  NeuRadSetup->Print();
72 
73  return kSUCCESS;
74 }
75 // -------------------------------------------------------------------------
76 
77 // ----- Public method Exec --------------------------------------------
78 void ERNeuRadHitFinderWBT::Exec(Option_t* opt)
79 {
80  std::cout << std::endl;
81  std::cout << "####### EVENT " << fEvent++ << " #####" << std::endl;
82  std::cout << std::endl;
83  std::cout << "ERNeuRadHitFinderWBT: "<< std::endl;
84  Reset();
85  Float_t fOnePEInteg = 4.8;
86  Int_t hitNumber=0;
87  ERNeuRadSetup* setup = ERNeuRadSetup::Instance();
88 
89  for (Int_t iSignal=0; iSignal < fNeuRadPMTSignals->GetEntriesFast(); iSignal++){
91  if (signal->Side() == 0){
92  //Float_t qInteg = signal->GetInteg(signal->GetStartTime(), signal->GetFinishTime());
93  Float_t qInteg = signal->AmplitudesSum();
94  TVector3 pos(setup->FiberX(signal->ModuleNb(), signal->PixelNb()),
95  setup->FiberY(signal->ModuleNb(), signal->PixelNb()),
96  setup->Z()-setup->FiberLength());
97  TVector3 dpos(0,0,0);
98  AddHit(kNEURAD,pos, dpos,signal->ModuleNb(),signal->PixelNb(), -1, qInteg);
99  }
100  }
101  std::cout << "Hits count: " << fNeuRadHits->GetEntriesFast() << std::endl;
102 }
103 //----------------------------------------------------------------------------
104 
105 //----------------------------------------------------------------------------
107 {
108  if (fNeuRadHits) {
109  fNeuRadHits->Delete();
110  }
111 }
112 // ----------------------------------------------------------------------------
113 
114 // ----------------------------------------------------------------------------
116 {
117 }
118 // ----------------------------------------------------------------------------
119 
120 // ----------------------------------------------------------------------------
121 ERNeuRadHitWBT* ERNeuRadHitFinderWBT::AddHit(Int_t detID, TVector3& pos, TVector3& dpos,
122  Int_t ModuleNb, Int_t PixelNb, Float_t time,
123  Float_t qInteg)
124 {
125  ERNeuRadHitWBT *hit = new((*fNeuRadHits)[fNeuRadHits->GetEntriesFast()])
126  ERNeuRadHitWBT(fNeuRadHits->GetEntriesFast(),detID, pos, dpos,-1, ModuleNb, PixelNb, time,
127  qInteg);
128  return hit;
129 }
130 // ----------------------------------------------------------------------------
131 
132 //-----------------------------------------------------------------------------
133 ClassImp(ERNeuRadHitFinderWBT)
virtual void Exec(Option_t *opt)
TClonesArray * fNeuRadPMTSignals
virtual InitStatus Init()