FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndGemMatchHits Class Reference

#include <PndGemMatchHits.h>

Inheritance diagram for PndGemMatchHits:

Public Member Functions

 PndGemMatchHits ()
 
 PndGemMatchHits (Int_t iVerbose)
 
 PndGemMatchHits (const char *name, Int_t iVerbose)
 
virtual ~PndGemMatchHits ()
 
virtual void Exec (Option_t *opt)
 
virtual void Finish ()
 

Private Member Functions

virtual void SetParContainers ()
 
virtual InitStatus Init ()
 
virtual InitStatus ReInit ()
 
void Reset ()
 
 ClassDef (PndGemMatchHits, 1)
 

Private Attributes

PndGemDigiParfDigiPar
 
TClonesArray * fPoints
 
TClonesArray * fHits
 
Int_t fNHits
 
Int_t fNMatchedHits
 
Int_t fNFakeHits
 
Int_t fNMultiHits
 

Detailed Description

Definition at line 32 of file PndGemMatchHits.h.

Constructor & Destructor Documentation

PndGemMatchHits::PndGemMatchHits ( )

Default constructor

Definition at line 46 of file PndGemMatchHits.cxx.

References fDigiPar, fHits, fPoints, and Reset().

46  : FairTask("GEM MatchHits", 1) {
47  fDigiPar = NULL;
48  fPoints = NULL;
49  fHits = NULL;
50  Reset();
51 }
PndGemDigiPar * fDigiPar
TClonesArray * fHits
TClonesArray * fPoints
PndGemMatchHits::PndGemMatchHits ( Int_t  iVerbose)

Standard constructor

Definition at line 57 of file PndGemMatchHits.cxx.

References fDigiPar, fHits, fPoints, and Reset().

58  : FairTask("GEM MatchHitsr", iVerbose) {
59  fDigiPar = NULL;
60  fPoints = NULL;
61  fHits = NULL;
62  Reset();
63 }
PndGemDigiPar * fDigiPar
Int_t iVerbose
TClonesArray * fHits
TClonesArray * fPoints
PndGemMatchHits::PndGemMatchHits ( const char *  name,
Int_t  iVerbose 
)

Constructor with name

Definition at line 69 of file PndGemMatchHits.cxx.

References fDigiPar, fHits, fPoints, and Reset().

70  : FairTask(name, iVerbose) {
71  fDigiPar = NULL;
72  fPoints = NULL;
73  fHits = NULL;
74  Reset();
75 }
PndGemDigiPar * fDigiPar
TString name
Int_t iVerbose
TClonesArray * fHits
TClonesArray * fPoints
PndGemMatchHits::~PndGemMatchHits ( )
virtual

Destructor

Definition at line 81 of file PndGemMatchHits.cxx.

References fDigiPar, and Reset().

81  {
82  if ( fDigiPar) delete fDigiPar;
83  Reset();
84 }
PndGemDigiPar * fDigiPar

Member Function Documentation

PndGemMatchHits::ClassDef ( PndGemMatchHits  ,
 
)
private
void PndGemMatchHits::Exec ( Option_t *  opt)
virtual

Execution

Definition at line 88 of file PndGemMatchHits.cxx.

References CAMath::Abs(), Bool_t, Double_t, fHits, fNFakeHits, fNHits, fNMatchedHits, fNMultiHits, fPoints, fVerbose, PndGemHit::GetDp(), PndGemHit::GetDr(), PndGemMCPoint::GetSensorId(), nHits, Pi, PndGemHit::SetBotIndex(), CAMath::Sqrt(), and CAMath::Tan().

88  {
89  Int_t nofPoints = fPoints->GetEntriesFast();
90  Int_t nofHits = fHits->GetEntriesFast();
91 
92  if ( fVerbose )
93  cout << "PndGemMatchHits::Exec() with " << nofPoints << " points and " << nofHits << " hits." << endl;
94 
95  Int_t nHits = 0;
96  Int_t nMatchedHits = 0;
97  Int_t nFakeHits = 0;
98  Int_t nMultiHits = 0;
99 
100  vector<Double_t> pointZ;
101  vector<Double_t> pointR;
102  vector<Double_t> pointP;
103  for ( Int_t iPoint = 0 ; iPoint < nofPoints ; iPoint++ ) {
104  PndGemMCPoint* currentPndGemMCPoint = (PndGemMCPoint*)fPoints->At(iPoint);
105 
106  Double_t pointX = currentPndGemMCPoint->GetX();
107  Double_t pointY = currentPndGemMCPoint->GetY();
108 
109  if ( fVerbose > 1 )
110  cout << " .... " << pointX << " " << pointY << " " << currentPndGemMCPoint->GetZ() << endl;
111 
112  Double_t phiAValue = TMath::ATan(pointX/pointY);
113  if ( pointY < 0 ) phiAValue += TMath::Pi();
114  else if ( pointX < 0 ) phiAValue += 2.*TMath::Pi();
115 
116  pointZ.push_back(currentPndGemMCPoint->GetZ());
117  pointR.push_back(TMath::Sqrt(pointX*pointX+pointY*pointY));
118  pointP.push_back(phiAValue);
119 
120  if ( fVerbose > 1 )
121  cout << "point " << iPoint << ", sensor Id = " << currentPndGemMCPoint->GetSensorId() << " (" << pointZ[pointZ.size()-1] << "," << pointR[pointR.size()-1] << "," << pointP[pointP.size()-1] << ")" << endl;
122  }
123 
124  for ( Int_t iHit = 0 ; iHit < nofHits ; iHit++ ) {
125  PndGemHit* currentPndGemHit = (PndGemHit*)fHits->At(iHit);
126 
127  Double_t hitX = currentPndGemHit->GetX();
128  Double_t hitY = currentPndGemHit->GetY();
129  Double_t hitZ = currentPndGemHit->GetZ();
130 
131  if ( fVerbose > 1 )
132  cout << " .... " << hitX << " " << hitY << " " << currentPndGemHit->GetZ() << endl;
133 
134  Double_t hitP = TMath::ATan(hitX/hitY);
135  if ( hitY < 0 ) hitP += TMath::Pi();
136  else if ( hitX < 0 ) hitP += 2.*TMath::Pi();
137  Double_t hitR = TMath::Sqrt(hitX*hitX+hitY*hitY);
138 
139  if ( fVerbose > 1 ) {
140  cout << "-------------------------------------------" << endl;
141  cout << "hit " << iHit << " (" << hitZ << "," << hitR << "," << hitP << ")" << endl;
142  }
143 
144  Int_t matchPoint = -1;
145  Double_t closestDistance = 1000.;
146  Bool_t multiHit = kFALSE;
147  for ( size_t iPoint = 0 ; iPoint < pointZ.size() ; iPoint++ ) {
148  // if ( fVerbose > 1 )
149  if ( TMath::Abs(pointZ[iPoint]-hitZ) > currentPndGemHit->GetDz() ) { /*cout << "FAILED Z" << endl;*/ continue; }
150  if ( TMath::Abs(pointR[iPoint]-hitR) > currentPndGemHit->GetDr()*TMath::Sqrt(3.) ) { /*cout << "FAILED R" << endl;*/ continue; }
151 
152  if ( hitP < 1.0 && pointP[iPoint] > 5.5 ) hitP += 2.*TMath::Pi();
153  if ( hitP > 5.5 && pointP[iPoint] < 1.0 ) hitP -= 2.*TMath::Pi();
154 
155  if ( TMath::Abs(TMath::Tan(pointP[iPoint]-hitP)) > currentPndGemHit->GetDp()*TMath::Sqrt(3.)/hitR ) { /*cout << "FAILED PHI" << endl;*/ continue; }
156  if ( fVerbose > 1 ) {
157  cout << "matched with " << " (" << pointZ[iPoint] << "," << pointR[iPoint] << "," << pointP[iPoint] << ") " << endl;
158  cout << "DP = " << currentPndGemHit->GetDp() << " after transf. = " << currentPndGemHit->GetDp()*TMath::Sqrt(3.)/hitR << " while p_p = " << pointP[iPoint] << " " << " h_p = " << hitP << endl;
159  cout << "PASSED WITH POINT " << iPoint << endl;
160  }
161  Double_t distance = TMath::Sqrt((pointR[iPoint]-hitR)*(pointR[iPoint]-hitR)/currentPndGemHit->GetDr()/currentPndGemHit->GetDr()+
162  (pointP[iPoint]-hitP)*(pointP[iPoint]-hitP)/currentPndGemHit->GetDp()/currentPndGemHit->GetDp());
163  if ( matchPoint != -1 ) multiHit = kTRUE;
164  if ( distance > closestDistance ) continue;
165  closestDistance = distance;
166  matchPoint = iPoint;
167  }
168  currentPndGemHit->SetRefIndex(matchPoint);
169  if ( matchPoint != -1 ) {
170  PndGemMCPoint* matchp = (PndGemMCPoint*)fPoints->At(matchPoint);
171  currentPndGemHit->SetBotIndex(matchp->GetTrackID());
172  }
173  else {
174  currentPndGemHit->SetBotIndex(-1);
175  }
176 
177  nHits++;
178  if ( matchPoint != -1 ) nMatchedHits++;
179  else nFakeHits++;
180  if ( multiHit ) nMultiHits++;
181  }
182 
183  fNHits += nHits;
184  fNMatchedHits += nMatchedHits;
185  fNFakeHits += nFakeHits;
186  fNMultiHits += nMultiHits;
187 
188  if ( fVerbose ) {
189  cout << "************PndGemMatchHits**************" << endl;
190  cout << " Number of all hits " << nHits << endl;
191  cout << " Number of matched hits " << nMatchedHits << " -> " << 100.*(Double_t)nMatchedHits/(Double_t)nHits << endl;
192  cout << " Number of fake hits " << nFakeHits << " -> " << 100.*(Double_t)nFakeHits/(Double_t)nHits << endl;
193  cout << " Number of multi hits " << nMultiHits << " -> " << 100.*(Double_t)nMultiHits/(Double_t)nHits << endl;
194  cout << "*****************************************" << endl;
195  }
196 
197 }
int fVerbose
Definition: poormantracks.C:24
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
float Tan(float x)
Definition: PndCAMath.h:165
void SetBotIndex(Int_t id)
Definition: PndGemHit.h:65
static T Abs(const T &x)
Definition: PndCAMath.h:39
Int_t GetSensorId() const
Definition: PndGemMCPoint.h:90
int nHits
Definition: RiemannTest.C:16
Double_t
Double_t GetDp() const
Definition: PndGemHit.h:76
Double_t GetDr() const
Definition: PndGemHit.h:75
Double_t Pi
TClonesArray * fHits
TClonesArray * fPoints
void PndGemMatchHits::Finish ( )
virtual

Finish

Definition at line 254 of file PndGemMatchHits.cxx.

References Double_t, fNFakeHits, fNHits, fNMatchedHits, and fNMultiHits.

254  {
255  cout << "************PndGemMatchHits summary**************" << endl;
256  cout << " Number of all hits " << fNHits << endl;
257  cout << " Number of matched hits " << fNMatchedHits << " -> " << 100.*(Double_t)fNMatchedHits/(Double_t)fNHits << endl;
258  cout << " Number of fake hits " << fNFakeHits << " -> " << 100.*(Double_t)fNFakeHits/(Double_t)fNHits << endl;
259  cout << " Number of multi hits " << fNMultiHits << " -> " << 100.*(Double_t)fNMultiHits/(Double_t)fNHits << endl;
260  cout << "*************************************************" << endl;
261 }
Double_t
InitStatus PndGemMatchHits::Init ( )
privatevirtual

Intialisation

Definition at line 221 of file PndGemMatchHits.cxx.

References fHits, and fPoints.

221  {
222 
223  // Get input array
224  FairRootManager* ioman = FairRootManager::Instance();
225  if ( ! ioman ) Fatal("Init", "No FairRootManager");
226  fPoints = (TClonesArray*) ioman->GetObject("GEMPoint");
227 
228  fHits = (TClonesArray*) ioman->GetObject("GEMHit");
229 
230  return kSUCCESS;
231 
232 }
TClonesArray * fHits
TClonesArray * fPoints
InitStatus PndGemMatchHits::ReInit ( )
privatevirtual

Reinitialisation

Definition at line 238 of file PndGemMatchHits.cxx.

238  {
239 
240  return kSUCCESS;
241 
242 }
void PndGemMatchHits::Reset ( )
private

Reset eventwise counters

Definition at line 248 of file PndGemMatchHits.cxx.

References fNFakeHits, fNHits, fNMatchedHits, and fNMultiHits.

Referenced by PndGemMatchHits(), and ~PndGemMatchHits().

248  {
250 }
void PndGemMatchHits::SetParContainers ( )
privatevirtual

Get parameter containers

Definition at line 203 of file PndGemMatchHits.cxx.

References fDigiPar, and run.

203  {
204 
205  // Get run and runtime database
206  FairRunAna* run = FairRunAna::Instance();
207  if ( ! run ) Fatal("SetParContainers", "No analysis run");
208 
209  FairRuntimeDb* db = run->GetRuntimeDb();
210  if ( ! db ) Fatal("SetParContainers", "No runtime database");
211 
212  // Get GEM digitisation parameter container
213  fDigiPar = (PndGemDigiPar*)(db->getContainer("PndGemDetectors"));
214 
215 }
Int_t run
Definition: autocutx.C:47
Digitization Parameter Class for GEM part.
Definition: PndGemDigiPar.h:31
PndGemDigiPar * fDigiPar

Member Data Documentation

PndGemDigiPar* PndGemMatchHits::fDigiPar
private

Definition at line 56 of file PndGemMatchHits.h.

Referenced by PndGemMatchHits(), SetParContainers(), and ~PndGemMatchHits().

TClonesArray* PndGemMatchHits::fHits
private

Input array of PndGemPoint

Definition at line 58 of file PndGemMatchHits.h.

Referenced by Exec(), Init(), and PndGemMatchHits().

Int_t PndGemMatchHits::fNFakeHits
private

Definition at line 62 of file PndGemMatchHits.h.

Referenced by Exec(), Finish(), and Reset().

Int_t PndGemMatchHits::fNHits
private

Input array of PndGemHit

Definition at line 60 of file PndGemMatchHits.h.

Referenced by Exec(), Finish(), and Reset().

Int_t PndGemMatchHits::fNMatchedHits
private

Definition at line 61 of file PndGemMatchHits.h.

Referenced by Exec(), Finish(), and Reset().

Int_t PndGemMatchHits::fNMultiHits
private

Definition at line 63 of file PndGemMatchHits.h.

Referenced by Exec(), Finish(), and Reset().

TClonesArray* PndGemMatchHits::fPoints
private

Definition at line 57 of file PndGemMatchHits.h.

Referenced by Exec(), Init(), and PndGemMatchHits().


The documentation for this class was generated from the following files: