HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoSimChamber.cxx
Go to the documentation of this file.
1 #include "HarpoSimChamber.h"
2 #include "HarpoDebug.h"
3 #include "TpcSimIonisationTrack.h"
4 
5 #include "TRandom3.h"
6 #include "TMath.h"
7 
8 ClassImp(HarpoSimChamber)
9 
10 
11 HarpoSimChamber::HarpoSimChamber() : TObject()
12 {
13  fReadout = (HarpoSimReadout*)NULL;
14  fDriftChamber = (TpcSimDriftChamber*)NULL;
15  fDigi = (HarpoSimElectronics*)NULL;
16 }
17 
19 {
20 }
21 
23 {
24 
25  HarpoSimEvent *event = new HarpoSimEvent();
26 
27  // StartEvent();
28  // Int_t nTr = mcev->GetNtracks();
29  // //cout << nTr << endl;
30 
31  // event->SetMCEvent(mcev);
32 
33  // //event->SetMCEvent(ev);
34  // for(Int_t iTr = 0; iTr<nTr; iTr++){
35 
36  // //cout << " Generate Track " << iTr << endl;
37  // TpcSimIonisationTrack* tr = fIonisationChamber->GenerateTrack(mcev->GetTrack(iTr));
38  // //cout << " Add Track in Event" << endl;
39  // event->AddIonisationTrack(iTr,tr);
40 
41  // fHarpoReadout->Reset();
42  // fHarpoChamber->ProcessTrack(tr);
43 
44  // HarpoSimStrips* strips = fHarpoReadout->GetStrips();
45  // strips->SetTrackId(iTr);
46  // event->AddStrips(iTr,strips);
47 
48  // fHarpoElectronics->ProcessStrips(strips);
49  // }
50  // //cout << "Finish Event" << endl;
51  // FinishEvent();
52  // //cout << "GetDccMapX" << endl;
53  // HarpoDccMap* mapX = fHarpoElectronics->GetDccMapX();
54  // event->SetDccMapX(mapX);
55  // // cout << "GetDccMapY" << endl;
56  // HarpoDccMap* mapY = fHarpoElectronics->GetDccMapX();
57  // event->SetDccMapY(mapY);
58 
59  return event;
60 
61 }
62 
63 
64 
66 {
67 
68  if(!fDriftChamber){
69  return -1;
70  }
71  if(!fReadout){
72  return -1;
73  }
74 
75  const Int_t npoints = tr->GetNpoints();
76  Double_t xinit= 0, yinit =0 , zinit = 0;
77  Double_t xfin = 0, yfin = 0, zfin = 0;
78  Int_t nTot = 0;
79  Double_t mean = 0;
80  for(Int_t i = 0; i<npoints; i++){
81  if(gHarpoDebug>2) Info("ProcessTrack","Point %d",i);
82  TpcSimIonisationPoint* point = tr->GetPoint(i);
83 
84  Double_t x0 = point->GetX();
85  Double_t y0 = point->GetY();
86  Double_t z0 = point->GetZ();
87  Double_t t0 = point->GetT();
88  if(i==0){
89  xinit = x0;
90  yinit = y0;
91  zinit = z0;
92  }
93  Double_t length = TMath::Sqrt((x0-xfin)*(x0-xfin) + (y0-yfin)*(y0-yfin) + (z0-zfin)*(z0-zfin));
94  xfin = x0;
95  yfin = y0;
96  zfin = z0;
97  Int_t nElectrons = point->GetNe();
98  nTot += nElectrons;
99 
100  mean += nElectrons*1./length;
101 
102  for(Int_t j = 0; j<nElectrons; j++){
103  Double_t x, y, z, t;
104  Int_t test = fDriftChamber->DriftElectron(x0,y0,z0,t0,x,y,z,t);
105  if(test<1) continue;
106 
108  if(z0-z<4) region = hSimReadoutRegionTransfer2;
109  if(z0-z<2) region = hSimReadoutRegionTransfer1;
110  fReadout->ProcessElectron(x,y,t,region);
111  }
112  }
113 
114  Double_t length2 = TMath::Sqrt((xinit-xfin)*(xinit-xfin) + (yinit-yfin)*(yinit-yfin) + (zinit-zfin)*(zinit-zfin));
115  // if(length)
116  // Info("ProcessTrack","%d electrons / %.3g mm = %.3g e/cm",nTot,length,10*nTot/length);
117  if(npoints && length2){
118  mean /= npoints;
119  if(gHarpoDebug>1)
120  Info("ProcessTrack","%d electrons / %.3g mm = %.3g e/cm %.3g e/cm",nTot,length2,10*nTot/length2, 10*mean);
121  }
122 
123  return 1;
124 
125 }
126 
127 
129 {
130 
131  if(gHarpoDebug>1) Info("StartEvent","Reset readout");
132 
133  if(fReadout)
134  fReadout->Reset();
135  if(gHarpoDebug>1) Info("StartEvent","Reset electronics");
136  if(fDigi)
137  fDigi->Reset();
138 
139  return 1;
140 }
141 
142 
144 {
145  fDigi->Noise();
147  // fDigi->AGETmultiplicity();
148  return 1;
149 }
virtual ~HarpoSimChamber()
Int_t ProcessTrack(TpcSimIonisationTrack *tr)
HarpoSimElectronics * fDigi
enum hSimReadoutRegion_ hSimReadoutRegion
Harpo Reader Type.
Int_t DriftElectron(Double_t x0, Double_t y0, Double_t z0, Double_t t0, Double_t &xEnd, Double_t &yEnd, Double_t &zEnd, Double_t &tEnd)
HarpoSimReadout * fReadout
TpcSimIonisationPoint * GetPoint(Int_t i)
A class store HARPO row DCC event data and header. End provide access metods to the row data...
Definition: HarpoSimEvent.h:24
Long64_t gHarpoDebug
Definition: HarpoDebug.cxx:9
TpcSimDriftChamber * fDriftChamber
Transfer region 2 (between top and bottom GEM)
HarpoSimEvent * ProcessEvent(TpcSimMCEvent *ev)
HarpoSimStrips * ProcessElectron(Double_t x, Double_t y, Double_t t, hSimReadoutRegion region)