ROOTPWA
diffractivePhaseSpace.h
Go to the documentation of this file.
1 
2 //
3 // Copyright 2009 Sebastian Neubert
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 
22 
27 #ifndef TDIFFRACTIVEPHASESPACE_HH
28 #define TDIFFRACTIVEPHASESPACE_HH
29 
30 
31 #include <iostream>
32 #include <vector>
33 
34 
35 #include "nBodyPhaseSpaceGen.h"
36 #include "primaryVertexGen.h"
37 
38 
39 class TH1;
40 class TLorentzVector;
41 
42 namespace rpwa {
43 
46  class particleInfo {
47 
48  public:
49 
50  particleInfo(int gId,
51  int charge,
52  double mass)
53  : _gId (gId),
54  _charge(charge),
55  _mass (mass) { }
56 
57  int _gId; // GEANT ID
58  int _charge; // charge
59  double _mass; // mass [GeV/c^2]
60 
61  };
62 
63 
69 
70  public:
71 
72  // Constructors/Destructors ---------
75 
76  // Accessors -----------------------
77  const TLorentzVector* const GetDecay(unsigned int i) { return &_phaseSpace.daughter(i); }
78  TLorentzVector* GetBeam() { return &_beamLab; }
79  TVector3* GetVertex() { return &_vertex; }
80  double Gettprime() { return _tprime; }
81 
82  // Modifiers -----------------------
93  void SetBeam(double Mom=190, double MomSigma=1.2,
94  double DxDz=0, double DxDzSigma=0,
95  double DyDz=0, double DyDzSigma=0);
96 
105  void SetTarget(double zPos,
106  double length,
107  double r,
108  double mass)
109  {
110  _targetZPos=zPos;
111  _targetZLength=length;
112  _targetR=r;
115  }
116 
117  //void SetThetaDistribution(TH1* distr){thetaDistribution=distr;}
118 
119 
124  void SetTPrimeSlope(double slopePar) {
125  _invSlopePar = new double[1];
126  _invSlopePar[0] = 1. / slopePar;
127  } // inverse for simple usage with TRandom
128 
135  void SetTPrimeSlope(double* slopePar, double* inv_m = NULL, int nvalues = 1) {
136  // delete previous arrays if existing
137  if(_invSlopePar) {
138  delete [] _invSlopePar;
139  }
140  if(_invM) {
141  delete [] _invM;
142  }
143  _invSlopePar = new double [nvalues];
144  _invM = new double [nvalues];
145  _ninvSlopePar = nvalues;
146  for(int i = 0; i < _ninvSlopePar; i++) {
147  if(inv_m) {
148  _invM[i] = inv_m[i];
149  } else {
150  _invM[i] = 0;
151  }
152  _invSlopePar[i] = 1. / slopePar[i];
153  //cout << _invM[i] << " " << _invSlopePar[i] << endl;
154  }
155  } // inverse for simple usage with TRandom
156 
161  void SetMassRange(double min, double max) {
162  _xMassMin=min;
163  _xMassMax=max;
164  }
165 
166  void SetDecayProducts(const std::vector<particleInfo>& info);
167  void AddDecayProduct(const particleInfo& info);
168  void SetSeed(int seed);
169 
170  void setVerbose(bool flag) { _phaseSpace.setVerbose(flag); }
171 
172  void SetImportanceBW(double mass, double width) {
173  _phaseSpace.setProposalBW(mass, width);
175  }
176 
177  void SettMin(double tMin) {
178  _tMin = tMin;
179  if (tMin > 0) _tMin = -tMin;
180  };
181 
182  void SettprimeMin(double tprimeMin) {
183  _tprimeMin = tprimeMin;
184  if (tprimeMin > 0) _tprimeMin = -tprimeMin;
185  };
186 
187  void SettprimeMax(double tprimeMax) {
188  _tprimeMax = tprimeMax;
189  if (tprimeMax > 0) _tprimeMax = -tprimeMax;
190  };
191 
192  /*
193  * If you set the Primary Vertex Generator (create it first)
194  * Vertex position, Beam Energy and Direction will be
195  * created by the primary Vertex Generator
196  */
198 
204  unsigned int event();
205 
212  unsigned int event(ostream&);
213 
221  unsigned int event(ostream&, ostream&);
222 
223  double impWeight() const { return _phaseSpace.impWeight(); }
224 
225  private:
226 
227  // Private Data Members ------------
229 
231 
232 
233  // target position
234  double _targetZPos; // [cm]
235  double _targetZLength; // [cm]
236  double _targetR; // [cm]
237 
238  double _targetMass; // [GeV/c^2]
239  double _recoilMass; // [GeV/c^2]
240 
241  // beam parameters:
242  double _beamMomSigma; // [GeV/c]
243  double _beamMom; // [GeV/c]
244 
245  double _beamDxDz;
247  double _beamDyDz;
249 
250  TLorentzVector _beamLab; // cache for last generated beam (in lab frame)
251  TLorentzVector _recoilprotonLab; // cache for last generated recoil proton (in lab frame)
252  TVector3 _vertex; // cache for last generated vertex
253  double _tprime; // cache for last generated t' (recalculated)
254 
255  //TH1* thetaDistribution;
256 
257  double* _invSlopePar; // inverse slope parameter(s) 1 / b of t' distribution [(GeV/c)^{-2}]
258  double* _invM; // invariant masses corresponding to _invSlopePar
260 
261  // cut on t-distribution
262  double _tMin; // [(GeV/c)^2]
263  double _tprimeMin; // [(GeV/c)]
264  double _tprimeMax; // [(GeV/c)]
265 
266  double _xMassMin; // [GeV/c^2]
267  double _xMassMax; // [GeV/c^2]
268 
269  std::vector<particleInfo> _decayProducts;
270 
271  // Private Methods -----------------
272 
273  TLorentzVector makeBeam();
274 
275  bool writePwa2000Ascii(std::ostream& out,
276  const int beamGeantId,
277  const int beamCharge);
278 
279  // writes event to ascii file read by ComGeant fort.26 interface
280  // please don't use the binary file option yet since there seems
281  // to be a problem reading it in ComGeant
282  bool writeComGeantAscii(ostream& out,
283  bool formated = true); // true: text file ; false: binary file
284 
285  void BuildDaughterList();
286  // particle masses
287  double _protonMass;
288  double _pionMass;
289  double _pionMass2;
290 
291  // calculate the t' by using the information of the incoming and outgoing particle in the vertex
292  float Calc_t_prime(const TLorentzVector& particle_In, const TLorentzVector& particle_Out);
293 
294  // case invariant_M < 0. : first entry in _invSlopePar is taken (if any)
295  // case invariant_M >= 0.: extrapolation or interpolation of given points
296  // for t' over invariant Mass
297  double Get_inv_SlopePar(double invariant_M = -1.);
298 
299  };
300 
301 } // namespace rpwa
302 
303 #endif // TDIFFRACTIVEPHASESPACE_HH
304 /* @} **/