1212 ******************************************************************************/
1313
1414#include " R3BCALIFATestGenerator.h"
15+ #include " R3BLogger.h"
1516
16- #include " FairLogger.h"
17- #include " FairPrimaryGenerator.h"
17+ #include < FairPrimaryGenerator.h>
1818
19- #include " TDatabasePDG.h"
20- #include " TMath.h"
21- #include " TParticlePDG.h"
22- #include " TRandom.h"
19+ #include < TDatabasePDG.h>
20+ #include < TMath.h>
21+ #include < TParticlePDG.h>
22+ #include < TRandom.h>
23+ #include < iomanip>
24+ #include < iostream>
25+ #include < sstream>
2326
2427R3BCALIFATestGenerator::R3BCALIFATestGenerator ()
25- : fPDGType(0 )
26- , fMult(0 )
27- , fPDGMass(0 )
28- , fPtMin(0 )
29- , fPtMax(0 )
30- , fPhiMin(0 )
31- , fPhiMax(0 )
32- , fEtaMin(0 )
33- , fEtaMax(0 )
34- , fYMin(0 )
35- , fYMax(0 )
36- , fPMin(0 )
37- , fPMax(0 )
38- , fThetaMin(0 )
39- , fThetaMax(0 )
40- , fX(0 )
41- , fY(0 )
42- , fZ(0 )
43- , fX1(0 )
44- , fY1(0 )
45- , fZ1(0 )
46- , fX2(0 )
47- , fY2(0 )
48- , fZ2(0 )
49- , fEtaRangeIsSet(0 )
50- , fYRangeIsSet(0 )
51- , fThetaRangeIsSet(0 )
52- , fCosThetaIsSet(0 )
53- , fPtRangeIsSet(0 )
54- , fPRangeIsSet(0 )
55- , fPointVtxIsSet(0 )
56- , fBoxVtxIsSet(0 )
57- , fDebug(0 )
58- , fGammasDefinedInNuclearDecay(0 )
59- , fBetaOfEmittingFragment(0 )
60- , fGammaFactor(1 )
61- , fLorentzBoostIsSet(0 )
62- , fNuclearDecayChainIsSet(0 )
28+ : R3BCALIFATestGenerator(22 , 1 )
6329{
6430 // Default constructor
6531}
@@ -111,38 +77,33 @@ R3BCALIFATestGenerator::R3BCALIFATestGenerator(Int_t pdgid, Int_t mult)
11177Bool_t R3BCALIFATestGenerator::Init ()
11278{
11379 // Initialize generator
114-
115- if (fPhiMax - fPhiMin > 360 )
116- LOG (fatal) << " Init(): R3BCALIFATestGenerator: phi range is too wide: " << fPhiMin << " <phi<" << fPhiMax ;
117- if (fPRangeIsSet && fPtRangeIsSet )
118- LOG (fatal) << " Init(): R3BCALIFATestGenerator: Cannot set P and Pt ranges simultaneously" ;
119- if (fPRangeIsSet && fYRangeIsSet )
120- LOG (fatal) << " Init(): R3BCALIFATestGenerator: Cannot set P and Y ranges simultaneously" ;
80+ R3BLOG_IF (fatal, fPhiMax - fPhiMin > 360 , " phi range is too wide: " << fPhiMin << " <phi<" << fPhiMax );
81+ R3BLOG_IF (fatal, fPRangeIsSet && fPtRangeIsSet , " Cannot set P and Pt ranges simultaneously" );
82+ R3BLOG_IF (fatal, fPRangeIsSet && fYRangeIsSet , " Cannot set P and Y ranges simultaneously" );
12183 if ((fThetaRangeIsSet && fYRangeIsSet ) || (fThetaRangeIsSet && fEtaRangeIsSet ) || (fYRangeIsSet && fEtaRangeIsSet ))
122- LOG (fatal) << " Init(): R3BCALIFATestGenerator: Cannot set Y, Theta or Eta ranges simultaneously" ;
123- if (fPointVtxIsSet && fBoxVtxIsSet )
124- LOG (fatal) << " Init(): R3BCALIFATestGenerator: Cannot set point and box vertices simultaneously" ;
84+ {
85+ R3BLOG (fatal, " Cannot set Y, Theta or Eta ranges simultaneously" );
86+ }
87+ R3BLOG_IF (fatal, fPointVtxIsSet && fBoxVtxIsSet , " Cannot set point and box vertices simultaneously" );
12588
12689 // CALIFA specifics
127- if (fBetaOfEmittingFragment > 1 )
128- LOG (fatal) << " Init(): R3BCALIFATestGenerator: beta of fragment larger than 1!" ;
90+ R3BLOG_IF (fatal, fBetaOfEmittingFragment > 1 , " beta of fragment larger than 1!" );
12991
13092 Double32_t sumBranchingRatios = 0 ;
13193 for (Int_t i = 0 ; i < fGammasDefinedInNuclearDecay ; i++)
13294 {
13395 if (fGammaBranchingRatios [i] > 1 )
134- LOG (fatal) << " Init(): R3BCALIFATestGenerator: gamma branching ratio in position " << i
135- << " larger than 1!" ;
96+ {
97+ R3BLOG (fatal, " gamma branching ratio in position " << i << " larger than 1!" );
98+ }
13699 sumBranchingRatios += fGammaBranchingRatios [i];
137100 }
138- if (sumBranchingRatios > 1 )
139- LOG (fatal) << " Init(): R3BCALIFATestGenerator: gamma branching ratio sum larger than 1!" ;
101+ R3BLOG_IF (fatal, sumBranchingRatios > 1 , " gamma branching ratio sum larger than 1!" );
140102
141103 // Check for particle type
142104 TDatabasePDG* pdgBase = TDatabasePDG::Instance ();
143105 TParticlePDG* particle = pdgBase->GetParticle (fPDGType );
144- if (!particle)
145- LOG (fatal) << " R3BCALIFATestGenerator: PDG code " << fPDGType << " not defined." ;
106+ R3BLOG_IF (fatal, !particle, " PDG code " << fPDGType << " not defined." );
146107 fPDGMass = particle->Mass ();
147108 return kTRUE ;
148109}
@@ -157,7 +118,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
157118
158119 Double32_t pabs = 0 , phi, pt = 0 , theta = 0 , eta, y, mt, px, py, pz = 0 ;
159120 Double32_t br = 0 ;
160- Bool_t doNotBoost = 0 ;
121+ bool doNotBoost = false ;
161122
162123 // Generate particles
163124 for (Int_t k = 0 ; k < fMult ; k++)
@@ -211,8 +172,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
211172
212173 if (fNuclearDecayChainIsSet )
213174 {
214- if (fPDGType != 22 )
215- LOG (fatal) << " R3BCALIFATestGenerator: PDG code " << fPDGType << " is not a gamma!" ;
175+ LOG_IF (fatal, fPDGType != 22 ) << " PDG code " << fPDGType << " is not a gamma!" ;
216176 br = gRandom ->Uniform ();
217177 for (Int_t i = 0 ; i < fGammasDefinedInNuclearDecay ; i++)
218178 {
@@ -226,7 +186,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
226186 }
227187 }
228188 // if Sum(branchingRatios)<1, the leftover probability (up to 1) is defined as environmental noise
229- doNotBoost = 1 ;
189+ doNotBoost = true ;
230190 }
231191 /*
232192 if (fLorentzBoostIsSet && !doNotBoost){
@@ -256,24 +216,24 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
256216 }
257217
258218 if (fDebug )
259- printf (" CALIFATestGen: kf=%d, p=(%.2f, %.2f, %.2f) GeV, x=(%.1f, %.1f, %.1f) cm\n " ,
260- fPDGType ,
261- px,
262- py,
263- pz,
264- fX ,
265- fY ,
266- fZ );
219+ {
220+ std::ostringstream oss;
221+ oss << " CALIFATestGen: kf=" << fPDGType << " , p=(" << std::fixed << std::setprecision (2 ) << px << " , " << py
222+ << " , " << pz << " ) GeV"
223+ << " , x=(" << std::setprecision (1 ) << fX << " , " << fY << " , " << fZ << " ) cm" ;
267224
225+ std::cout << oss.str () << std::endl;
226+ }
268227 primGen->AddTrack (fPDGType , px, py, pz, fX , fY , fZ );
269228 }
270229 return kTRUE ;
271230}
272231
273- void R3BCALIFATestGenerator::SetFragmentVelocity (Double32_t beta)
232+ void R3BCALIFATestGenerator::SetFragmentVelocity (double beta, double dispersion )
274233{
275234 // Sets the velocity and gamma factor of the fragment emitting the gammas
276- fBetaOfEmittingFragment = beta;
235+ R3BLOG (info, " Set a beta of " << beta << " with a sigma dispersion of " << dispersion);
236+ fBetaOfEmittingFragment = gRandom ->Gaus (beta, dispersion);
277237 fGammaFactor = TMath::Sqrt (1 - fBetaOfEmittingFragment * fBetaOfEmittingFragment );
278238}
279239
@@ -283,13 +243,14 @@ void R3BCALIFATestGenerator::SetDecayChainPoint(Double32_t gammaEnergy, Double32
283243 //
284244 //
285245 if (fGammasDefinedInNuclearDecay > 7 )
286- printf (" CALIFATestGen: Maximum number (8) of gammas defined in the chain\n " );
246+ {
247+ R3BLOG (error, " Maximum number (8) of gammas defined in the chain\n " );
248+ }
287249 else
288250 {
289251 fGammaEnergies [fGammasDefinedInNuclearDecay ] = gammaEnergy;
290252 fGammaBranchingRatios [fGammasDefinedInNuclearDecay ] = branchingRatio;
291253 fGammasDefinedInNuclearDecay ++;
292254 }
293255}
294-
295256ClassImp (R3BCALIFATestGenerator)
0 commit comments