er  dev
ERNeuRadHitFinder.cxx
1 #include "ERNeuRadHitFinder.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 ERNeuRadHitFinder::fEvent = 0;
19 
20 // ----------------------------------------------------------------------------
22  : FairTask("ER muSi hit producing scheme")
23 {
24 }
25 // ----------------------------------------------------------------------------
26 
27 // ----------------------------------------------------------------------------
29  : FairTask("ER muSi hit producing scheme ", verbose)
30 {
31 }
32 // ----------------------------------------------------------------------------
33 
34 // ----------------------------------------------------------------------------
36 {
37 }
38 //----------------------------------------------------------------------------
39 
40 //----------------------------------------------------------------------------
41 void ERNeuRadHitFinder::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("ERNeuRadHit",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 ERNeuRadHitFinder::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 << "ERNeuRadHitFinder: "<< std::endl;
84  Reset();
85  Float_t fOnePEInteg = 4.8;
86  Int_t hitNumber=0;
87  ERNeuRadPixelSignal* targetHitSignal = NULL;
88  ERNeuRadSetup* setup = ERNeuRadSetup::Instance();
89 
90  for (Int_t iSignal=0; iSignal < fNeuRadPMTSignals->GetEntriesFast(); iSignal++){
92  std::cerr << "0" << std::endl;
93  if (signal->Side()==0){
94  //Ищем пару с другой стороны
95  std::cerr << "1" << std::endl;
96  Bool_t founded=kFALSE;
97  Int_t jBackSignal = -1;
98  for (Int_t jSignal=0; jSignal<fNeuRadPMTSignals->GetEntriesFast(); jSignal++){
99  ERNeuRadPixelSignal* signalBack = (ERNeuRadPixelSignal*)fNeuRadPMTSignals->At(jSignal);
100  if (signalBack->Side() == 1 && signalBack->ModuleNb()==signal->ModuleNb() && signalBack->PixelNb()==signal->PixelNb()){
101  founded=kTRUE;
102  jBackSignal = jSignal;
103  break;
104  }
105  }
106 
107  if (founded){
108  ERNeuRadPixelSignal* signalBack = (ERNeuRadPixelSignal*)fNeuRadPMTSignals->At(jBackSignal);
109  std::cerr << signal->FullInteg() << " " << fPixelThreshold*signal->OnePEIntegral()<< " " <<signalBack->FullInteg()<< std::endl;
110  if (signal->FullInteg() > fPixelThreshold*signal->OnePEIntegral() && signalBack->FullInteg() > fPixelThreshold*signal->OnePEIntegral()){
111  targetHitSignal = signal;
112  hitNumber++;
113  }
114  }
115  if (hitNumber > 1)
116  break;
117  }
118  }
119  if (hitNumber == 1){
120  TVector3 pos(setup->FiberX(targetHitSignal->ModuleNb(), targetHitSignal->PixelNb()),
121  setup->FiberY(targetHitSignal->ModuleNb(), targetHitSignal->PixelNb()),
122  setup->Z()-setup->FiberLength());
123  TVector3 dpos(0,0,0);
124  AddHit(kNEURAD,pos, dpos,targetHitSignal->ModuleNb(),targetHitSignal->PixelNb(),targetHitSignal->FullInteg());
125  }
126  std::cout << "Hits count: " << fNeuRadHits->GetEntriesFast() << std::endl;
127 }
128 //----------------------------------------------------------------------------
129 
130 //----------------------------------------------------------------------------
132 {
133  if (fNeuRadHits) {
134  fNeuRadHits->Delete();
135  }
136 }
137 // ----------------------------------------------------------------------------
138 
139 // ----------------------------------------------------------------------------
141 {
142 }
143 // ----------------------------------------------------------------------------
144 
145 // ----------------------------------------------------------------------------
146 ERNeuRadHit* ERNeuRadHitFinder::AddHit(Int_t detID, TVector3& pos, TVector3& dpos,
147  Int_t ModuleNb, Int_t PixelNb, Float_t time)
148 {
149  ERNeuRadHit *hit = new((*fNeuRadHits)[fNeuRadHits->GetEntriesFast()])
150  ERNeuRadHit(fNeuRadHits->GetEntriesFast(),detID, pos, dpos,-1, ModuleNb, PixelNb, time);
151  return hit;
152 }
153 // ----------------------------------------------------------------------------
154 
155 //-----------------------------------------------------------------------------
156 ClassImp(ERNeuRadHitFinder)
virtual void Exec(Option_t *opt)
TClonesArray * fNeuRadPMTSignals
virtual InitStatus Init()