HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TpcSimGeometry.cxx
Go to the documentation of this file.
1 
2 #include "TCanvas.h"
3 #include "TGraph2D.h"
4 #include "TH3F.h"
5 #include "TRandom.h"
6 
7 #include "TpcSimGeometry.h"
8 
9 ClassImp(TpcSimGeometry)
10 
12 {
13  fX = 0;
14  fY = 0;
15  fZ = 0;
16 
17  fGasSizeX = 300;
18  fGasSizeY = 300;
19  fGasSizeZ = 300;
20 
21  fBoxThickness = 10;
22 
23 
24  for(Int_t i = 0; i<fkNScinti; i++){
25  fScintiX[i] = 0;
26  fScintiY[i] = 0;
27  fScintiZ[i] = 0;
28  fScintiSizeX[i] = 0;
29  fScintiSizeY[i] = 0;
30  fScintiSizeZ[i] = 0;
31  }
32 
33 }
34 
35 
36 Int_t TpcSimGeometry::GetVolume(Double_t x, Double_t y, Double_t z)
37 {
38 
39  if(TMath::Abs(x-fX)<fGasSizeX/2 &&
40  TMath::Abs(y-fY)<fGasSizeY/2 &&
41  TMath::Abs(z-fZ-fGasSizeZ/2)<fGasSizeZ/2)
42  return 1; // Gas Volume
43 
44  if(TMath::Abs(x-fX)<fGasSizeX/2 + fBoxThickness &&
45  TMath::Abs(y-fY)<fGasSizeY/2 + fBoxThickness &&
46  TMath::Abs(z-fZ-fGasSizeZ/2)<fGasSizeZ/2 + fBoxThickness)
47  return 2; // Box/Field cage
48 
49 
50  return 0;
51 
52 }
53 
54 
56 {
57 
58  TGraph2D* g[fkNScinti+3];
59  for(Int_t i = 0; i<fkNScinti+3; i++)
60  g[i] = new TGraph2D();
61 
62  for(Int_t i = 0; i<100000; i++){
63  Double_t x = 400*gRandom->Rndm() - 200;
64  Double_t y = 400*gRandom->Rndm() - 200;
65  Double_t z = 400*gRandom->Rndm() - 50;
66 
67  Int_t vol = GetVolume(x,y,z);
68  g[vol]->SetPoint(g[vol]->GetN(),x,y,z);
69  }
70 
71  g[0]->SetMarkerColor(kCyan);
72  g[1]->SetMarkerColor(kBlue);
73  g[2]->SetMarkerColor(kRed);
74 
75  TH3F* h = new TH3F("h",";x;y;z;",100,0,200,100,0,200,100,-50,350);
76  TCanvas* c = new TCanvas();
77  h->Draw();
78  for(Int_t i = 0; i<fkNScinti+3; i++)
79  g[i]->Draw("Psame");
80 
81 
82  return c;
83 }
static const Int_t fkNScinti
Int_t GetVolume(Double_t x, Double_t y, Double_t z)
TCanvas * DrawDetector()
Double_t fGasSizeY
Double_t fBoxThickness
Double_t fGasSizeX
Double_t fGasSizeZ