GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OFTAdapter.C
Go to the documentation of this file.
1 
2 #ifndef GW_GAMMATRACKER_H
3 #include <GammaTracker.h>
4 #endif
5 
6 using namespace Gw;
7 
21 class OFT : public GammaTracker
22 {
23 public:
24  OFT(const char *name = "OFT", const char *title = "Orsay's forward tracking program");
25  virtual ~OFT() ;
26 
27  virtual Int_t DoTracking();
28 
30  ClassDef(OFT,0); // Orsay Forward Tracker
31 };
32 
33 // real implementation
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 #include <tracking_define.h>
39 #include <tracking_data.h>
40 #include <tracking_data_manip.h>
41 #include <tracking_utilitaires.h>
42 #include <tracking_cluster.h>
43 #include <tracking_events.h>
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 
49 namespace {
50 
51 Double_t r[intmax][intmax], r_ge[intmax][intmax], erfcu[1000], etot[intmax], probtot[intmax], angn[intmax];
52 Int_t sn[intmax][kmax], numn[intmax], order[intmax], nombre[intmax], flagu[intmax], nbtot[intmax];
53 Double_t angtheta[intmax], angphi[intmax];
54 Double_t et[intmax];
55 Int_t numinter[intmax], numintern[intmax], interaction[intmax][kmax];
56 
57 Double_t ddu; Int_t nintu;
58 
59 } // anonymous namespace to protect globals
60 
61 
62 OFT::OFT(const char *name,const char *title) : GammaTracker(name,title)
63 {
64 
65  // Init some constants
66  Init_Tracking_Lib();
67 
68  /**********************************************************/
69  /* mapping random number vs uncertainty in units of sigma */
70  /**********************************************************/
71 
72  // TODO - should be set through a member function?
73 
74 
75  nintu = 1000; /* initialisation for random number vs uncertainty procedure */
76  ddu = 0.005; /* step in random number vs uncertainty procedure */
77 
78  maprandom(erfcu, ddu, nintu);
79 
80  SetDistFactor(10.0); SetEnerFactor(1000.0); // units are centimeters and MeV
81 }
82 
83 OFT::~OFT() {;}
84 
85 
87 {
88  Int_t n, i, j, itot, itotcurr, mult;
89 
90  // symbolic link between local notation and global notation
91  Double_t *e = InputE; Double_t *x = InputX, *y = InputY, *z = InputZ;
92  Double_t *thetafirst = OutputTheta1, *phifirst = OutputPhi1, *thetasecond = OutputTheta2, *phisecond = OutputPhi2;
93 
94  if ( InputN == 0 ) { OutputN = 0; return OutputN; }
95 
96  Int_t nb_int = InputN;
97 
98  mult = 0;
99  /****************************************************/
100  /******* pack points with r < d_res ****************/
101  /****************************************************/
102  if ( gDebug ) printf("pack points\n");
103  nb_int = packpoints(nb_int, x, y, z, e, numinter, order);
104 
105 /*
106  Double_t packenergy, totenergy = 1.0;
107 
108  packenergy = 0;
109  for (j = 0; j < nb_int; j++)
110  packenergy = packenergy + e[j];
111  if (fabs(packenergy - totenergy) > 1e-4)
112  printf("pb with energy after packing %f %f %d %d \n", packenergy, totenergy, nb_int,InputN);
113  else
114  printf("NO pb with energy after packing %f %f %d %d \n", packenergy, totenergy, nb_int,InputN); */
115 
116  /*******************************************************/
117  /********* smear positions *****************************/
118  /*******************************************************/
119  if ( gDebug ) printf("smear positions\n");
120  smearpoints(nb_int, x, y, z, erfcu, ddu, nintu);
121 
122 
123  /*****************************************************/
124  /*********** Apply Energy threshold ******************/
125  /*****************************************************/
126  if ( gDebug ) printf("Apply Energy threshold\n");
127  nb_int = energy_thresh(nb_int, x, y, z, e, numinter, order);
128 
129  /*
130  totenergy = 0;
131  for (i = 0; i < InputN; i++) {
132  totenergy = totenergy + e[i];
133  }
134  if (InputN == 1 && totenergy >= emini)
135  nsingint++;
136  nbinttot = nbinttot + InputN;
137  if (totenergy > emini) {
138  nbinter = nbinter + InputN;
139  } */
140 
141  /*****************************************************/
142  /******** compute distance source-int and ************/
143  /*************theta and phi for each int *************/
144  /*****************************************************/
145  for (i = 0; i < nb_int; i++) {
146  r[i][i] = sqrt(SQ(x[i] - xsource) + SQ(y[i] - ysource) + SQ(z[i] - zsource));
147  angtheta[i] = acos((z[i] - zsource) / r[i][i]);
148  angphi[i] = atan2((y[i] - ysource), (x[i] - xsource));
149  if (angphi[i] < 0)
150  angphi[i] = 2 * PI + angphi[i];
151  }
152 
153  /*****************************************************/
154  /********* sort according to increasing theta*********/
155  /*****************************************************/
156  if ( gDebug ) printf("sort according to increasing theta\n");
157  for (i = 0; i < nb_int; i++) {
158  for (j = i + 1; j < nb_int; j++) {
159  if (angtheta[j] < angtheta[i]) {
160  swap(e, i, j);
161  swap(x, i, j);
162  swap(y, i, j);
163  swap(z, i, j);
164  swapi(numinter, i, j);
165  swapi(order, i, j);
166  swap(angtheta, i, j);
167  swap(angphi, i, j);
168  }
169  }
170  }
171 
172  /*****************************************************************/
173  /******** computing all distances between interactions *********/
174  /*****************************************************************/
175  if ( gDebug ) printf("computing all distances between interactions\n");
176  distances(r, r_ge, nb_int, x, y, z);
177 
178  /* computes r and r_ge (real distances and effective distances in Ge)
179  // given position vectors x,y and z and the number of interaction points InputN
180  // NB: distances in Ge are calculated assuming a 4pi ge sphere */
181 
182  /****************************************************/
183  /*************** find clusters ***********************/
184  /****************************************************/
185  if ( gDebug ) printf("find clusters\n");
186  n = cluster_search(numn, angn, et, sn, nb_int, e, angtheta, angphi);
187 
188  /* numn = number of interactions in cluster
189  // angn = angle of cluster
190  // et = total energy of cluster
191  // sn[1][2] = identity of 2nd point of cluster 1
192  // e = energy vector of interaction points
193  // angtheta and angphi = theta and phi vector of interaction points
194  // routine returns number of clusters found */
195 
196  /*******************************************************/
197  /******** compute figure of merit of clusters **********/
198  /*******************************************************/
199  if ( gDebug ) printf("compute figure of merit of clusters\n");
200  cluster_evaluation(n, et, numn, sn, probtot, interaction, e, x, y, z, r, r_ge, flagu);
201 
202  /* n = number of clusters
203  // probtot = figure of merit of cluster
204  // interaction = ordering of interactions in cluster which gives best
205  // figure of merit (set to minprobtrack for singles temporarily)
206  // x,y,z,r and e vectors of x,y,z and energy of interaction points
207  // r and r_ge = real and effective distances in Ge
208  // flagu - is set to 0 for all clusters */
209 
210  /***********************************************************************/
211  /************ sort clusters according to figure of merit ****************/
212  /************* flag worst clusters with same interactions **************/
213  /***********************************************************************/
214  if ( gDebug ) printf("sort clusters\n");
215  cluster_sort_flag(n, et, numn, sn, angn, probtot, interaction, flagu);
216 
217  /* flagu is set to 1 if a cluster with a worst figure of merit than another one shares at least one common interaction point */
218 
219  /**********************************/
220  /* test of direct photopic events */
221  /**********************************/
222  if ( gDebug ) printf("test of direct photopic events\n");
223 // if (nodirect == 0) { /* treat single interaction points */
224  single_interaction(nb_int, r, r_ge, n, et, numn, sn, probtot, flagu);
225 // }
226 
227  /* routines computes figure of merit for single interaction points */
228 
229  /**************************************************************/
230  /*********************** cluster validation ******************/
231  /*************************************************************/
232  if ( gDebug ) printf("cluster validation\n");
233  itotcurr = itot;
234  mult = cluster_validation(etot, nbtot, n, probtot, numn, interaction, et, flagu, /*e, */ x, y, z, r, thetafirst, phifirst, thetasecond, phisecond);
235 
236  /*routine returns number of tracked gamma rays
237  // etot - energy of tracked gamma rays
238  // nbtot - number of interaction points making up the gamma
239  // thetafirst and phifirst are the incident angle direction
240  // thetasecond and phisecond are he scattered direction (wrt the incident direction) */
241 
242  // set output
243  OutputN = mult; ::memcpy(OutputE,etot,sizeof(Double_t)*OutputN); return OutputN;
244 }
245 
246 
247 
248 
UInt_t OutputN
DZ positions.
Definition: GammaTracker.h:49
virtual void SetEnerFactor(Double_t f)
Definition: GammaTracker.h:87
printf("******************************************************************** \n")
Base class to build tracker families.
Definition: GammaTracker.h:29
Double_t * InputZ
Y positions.
Definition: GammaTracker.h:44
OFT(const char *name="OFT", const char *title="Orsay's forward tracking program")
Definition: OFTAdapter.C:62
Adapter to plug the Orsay's forward tracking code.
Definition: OFTAdapter.C:21
Double_t * OutputPhi2
direction (theta) of the first scattered gamma-ray for polarisation
Definition: GammaTracker.h:54
Double_t * OutputPhi1
incoming direction (theta) of the reconstructed gamma-rays
Definition: GammaTracker.h:52
virtual void SetDistFactor(Double_t f)
Definition: GammaTracker.h:86
UInt_t InputN
Units for energies.
Definition: GammaTracker.h:38
Double_t * OutputTheta1
energies of the reconstructed gamma-rays
Definition: GammaTracker.h:51
Double_t * InputY
X positions.
Definition: GammaTracker.h:43
virtual ~OFT()
Definition: OFTAdapter.C:83
Double_t * OutputE
of reconstructed gamma-rays
Definition: GammaTracker.h:50
Double_t * InputE
of impacts
Definition: GammaTracker.h:39
virtual Int_t DoTracking()
to track the gamma-rays
Definition: OFTAdapter.C:86
Double_t * InputX
errors on energies
Definition: GammaTracker.h:42
Double_t * OutputTheta2
incoming direction (phi) of the reconstructed gamma-rays
Definition: GammaTracker.h:53