er  dev
ERNeuRadMatcher.cxx
1 #include "ERNeuRadMatcher.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 "ERNeuRadHit.h"
15 #include "ERNeuRadStep.h"
16 
17 // ----------------------------------------------------------------------------
19  : fNeuRadHits(NULL),
20  fNeuRadFirstSteps(NULL),
21  fHdxy(NULL),
22  fHdxyLess6(NULL),
23  fHdxyOF(NULL),
24  fHdxyLess6OF(NULL),
25  fHdxyTF(NULL),
26  fHdxyLess6TF(NULL),
27  FairTask("ER muSi hit producing scheme") //TODO muSi ???
28 {
29 }
30 // ----------------------------------------------------------------------------
31 
32 // ----------------------------------------------------------------------------
34  : fNeuRadHits(NULL),
35  fNeuRadFirstSteps(NULL),
36  fHdxy(NULL),
37  fHdxyLess6(NULL),
38  fHdxyOF(NULL),
39  fHdxyLess6OF(NULL),
40  fHdxyTF(NULL),
41  fHdxyLess6TF(NULL),
42  FairTask("ER muSi hit producing scheme ", verbose) //TODO muSi ???
43 {
44 }
45 // ----------------------------------------------------------------------------
46 
47 // ----------------------------------------------------------------------------
49 {
50 }
51 //----------------------------------------------------------------------------
52 
53 //----------------------------------------------------------------------------
54 void ERNeuRadMatcher::SetParContainers()
55 {
56  // Get run and runtime database
57  FairRunAna* run = FairRunAna::Instance();
58  if ( ! run ) Fatal("SetParContainers", "No analysis run");
59 
60  FairRuntimeDb* rtdb = run->GetRuntimeDb();
61  if ( ! rtdb ) Fatal("SetParContainers", "No runtime database");
62 }
63 //----------------------------------------------------------------------------
64 
65 //----------------------------------------------------------------------------
67 {
68  // Get input array
69  FairRootManager* ioman = FairRootManager::Instance();
70  if ( ! ioman ) Fatal("Init", "No FairRootManager");
71 
72  fNeuRadHits = (TClonesArray*) ioman->GetObject("NeuRadHit");
73  fNeuRadFirstSteps = (TClonesArray*) ioman->GetObject("NeuRadFirstStep");
74  //todo check
75 
76  fHdxy = new TH1F("fHdxy", "XY distance",4000,0.,4.);
77  fHdxy->GetXaxis()->SetTitle("XY disance [cm]");
78 
79  fHdxyLess6 = new TH1F("fHdxyLess6", "XY distance less 6mm",100.,0.,1.);
80  fHdxyLess6->GetXaxis()->SetTitle("XY disance [cm]");
81 
82  fHdxyOF = new TH1F("fHdxyOF", "XY distance, One fiber mode",4000,0.,4.);
83  fHdxyOF->GetXaxis()->SetTitle("XY disance [cm]");
84 
85  fHdxyLess6OF = new TH1F("fHdxyLess6OF", "XY distance less 6mm, One fibre mode",100.,0.,1.);
86  fHdxyLess6OF->GetXaxis()->SetTitle("XY disance [cm]");
87 
88  fHdxyTF = new TH1F("fHdxyTF", "XY distance, Two fiber mode",4000,0.,4.);
89  fHdxyTF->GetXaxis()->SetTitle("XY disance [cm]");
90 
91  fHdxyLess6TF = new TH1F("fHdxyLess6TF", "XY distance less 6mm, Two fibre mode",100.,0.,1.);
92  fHdxyLess6TF->GetXaxis()->SetTitle("XY disance [cm]");
93 
94  return kSUCCESS;
95 }
96 // -------------------------------------------------------------------------
97 
98 // ----- Public method Exec --------------------------------------------
99 void ERNeuRadMatcher::Exec(Option_t* opt)
100 {
101  ERNeuRadStep* step = (ERNeuRadStep*)fNeuRadFirstSteps->At(0);
102 
103  // Однофайберная мода
104  if (fNeuRadHits->GetEntriesFast() == 1){
105  ERNeuRadHit* hit = (ERNeuRadHit*)fNeuRadHits->At(0);
106  Double_t dist = TMath::Sqrt((hit->GetX()-step->GetX())*(hit->GetX()-step->GetX()) +
107  (hit->GetY()-step->GetY())*(hit->GetY()-step->GetY()));
108  std::cerr << dist << std::endl;
109  fHdxyOF->Fill(dist);
110  if (dist < 0.6) {
111  fHdxyLess6OF->Fill(dist);
112  }
113  }
114 
115  // Двухфайберная мода
116  if (fNeuRadHits->GetEntriesFast() == 2 || fNeuRadHits->GetEntriesFast() == 1){
117  ERNeuRadHit* hit1 = (ERNeuRadHit*)fNeuRadHits->At(0);
118  ERNeuRadHit* hit2 = (ERNeuRadHit*)fNeuRadHits->At(0);
119  Double_t dist = 0.;
120  if (hit1->Time() < hit2->Time()) {
121  dist = TMath::Sqrt((hit1->GetX()-step->GetX())*(hit1->GetX()-step->GetX()) +
122  (hit1->GetY()-step->GetY())*(hit1->GetY()-step->GetY()));
123  } else {
124  dist = TMath::Sqrt((hit2->GetX()-step->GetX())*(hit2->GetX()-step->GetX()) +
125  (hit2->GetY()-step->GetY())*(hit2->GetY()-step->GetY()));
126  }
127 
128  fHdxyTF->Fill(dist);
129  if(dist < 0.6) {
130  fHdxyLess6TF->Fill(dist);
131  }
132  }
133 
134  // Многофайберная мода
135  if (fNeuRadHits->GetEntriesFast() > 0) {
136  // Находим самый первый хит
137  ERNeuRadHit* firstHit;
138  Float_t minTime = 999999999.;
139  for(Int_t iHit = 0; iHit < fNeuRadHits->GetEntriesFast(); iHit++) {
140  ERNeuRadHit* hit = (ERNeuRadHit*)fNeuRadHits->At(iHit);
141  if (hit->Time() < minTime){
142  minTime = hit->Time();
143  firstHit = hit;
144  }
145  }
146  Double_t dist = TMath::Sqrt((firstHit->GetX()-step->GetX())*(firstHit->GetX()-step->GetX()) +
147  (firstHit->GetY()-step->GetY())*(firstHit->GetY()-step->GetY()));
148  fHdxy->Fill(dist);
149  if(dist < 0.6)
150  fHdxyLess6->Fill(dist);
151  }
152 }
153 //----------------------------------------------------------------------------
154 
155 //----------------------------------------------------------------------------
157 {
158 }
159 // ----------------------------------------------------------------------------
160 
161 // ----------------------------------------------------------------------------
163 {
164  fHdxy->Write();
165  fHdxyLess6->Write();
166  fHdxyOF->Write();
167  fHdxyLess6OF->Write();
168  fHdxyTF->Write();
169  fHdxyLess6TF->Write();
170 }
171 // ----------------------------------------------------------------------------
172 
173 //-----------------------------------------------------------------------------
174 ClassImp(ERNeuRadMatcher)
virtual InitStatus Init()
virtual void Finish()
virtual void Reset()
TClonesArray * fNeuRadHits
virtual void Exec(Option_t *opt)