+//____________________________________________________________________________
+void AliGenCRT::GenerateOneSingleMuon(Bool_t withFlatMomentum)
+{
+ //
+ // Generate One Single Muon
+ // This method will generate only one muon.
+ // The momentum will be randomly flat distributed if
+ // the paremeter "withFlatMomentum" is set to kTRUE,
+ // otherwise the momentum will generate acordingly the parametrization
+ // given by
+ // and adpted from Bruno Alessandro's implementation with the
+ // CERNLIB to AliRoot.
+ // The "withFlatMomentum" parameter also will be used to generate
+ // the muons with a flat Zenithal angle distribution.
+ // Do the smearing here, so that means per track.
+
+ Float_t polar[3]= {0,0,0}; // Polarization parameters
+ Float_t origin[3];
+ Int_t nt;
+ Float_t p[3];
+ Float_t pmom, pt;
+ Float_t random[6];
+
+ // Take the azimuth random.
+ Rndm(random, 2);
+ Float_t azimuth = fAzimuthMin + (fAzimuthMax-fAzimuthMin)*random[0];
+ Float_t zenith = fZenithMin + (fZenithMax - fZenithMin)*random[1];
+
+ if ( withFlatMomentum ) {
+ Rndm(random,3);
+ if(TestBit(kMomentumRange)) {
+ pmom = -( fPMin + random[0]*(fPMax - fPMin) ); // always downwards.
+ pt = pmom*TMath::Sin(zenith*kDegrad);
+ } else {
+ pt = -( fPtMin + random[1]*(fPtMax - fPtMin)); // always downwards.
+ pmom = pt/TMath::Sin(zenith*kDegrad);
+ }
+
+ } else {
+ if ( fMomentumDist ) {
+ pmom = -this->GetMomentum(); // Always downwards.
+ } else {
+ pmom = -fPMin;
+ }
+ zenith = this->GetZenithAngle(pmom); // In degrees
+ pt = pmom*TMath::Sin(zenith*kDegrad);
+ }
+
+ p[0] = pt*TMath::Sin(azimuth*kDegrad);
+ p[1] = pmom*TMath::Cos(zenith*kDegrad);
+ p[2] = pt*TMath::Cos(azimuth*kDegrad);
+
+ // Finaly the origin, with the smearing
+ Rndm(random,6);
+ origin[0] = AliCRTConstants::Instance()->Depth()*TMath::Tan(zenith*kDegrad)*
+ TMath::Sin(azimuth*kDegrad);
+ // + fOsigma[0]* TMath::Cos(2*random[0]*TMath::Pi())*TMath::Sqrt(-2*TMath::Log(random[1]));
+
+ origin[1] = AliCRTConstants::Instance()->Depth();
+
+ origin[2] = AliCRTConstants::Instance()->Depth()*TMath::Tan(zenith*kDegrad)*
+ TMath::Cos(azimuth*kDegrad);
+ // + fOsigma[2]* TMath::Cos(2*random[2]*TMath::Pi())*TMath::Sqrt(-2*TMath::Log(random[3]));;
+
+ // Put the track on the stack.
+ PushTrack(fTrackIt,-1,fIpart,p,origin,polar,0,kPPrimary,nt);
+
+}
+
+//____________________________________________________________________________
+void AliGenCRT::GenerateOneMuonBundle()
+{
+ //
+ // Generate One Muon Bundle method
+ // This method will generate a bunch of muons following the
+ // procedure of the AliGenScan class.
+ // These muons will be generated with flat momentum.
+
+ Float_t polar[3]= {0,0,0}; // Polarization parameters
+ Float_t origin[3];
+ Float_t p[3];
+ Int_t nt;
+ Float_t pmom;
+ Float_t random[6];
+
+ Rndm(random, 3);
+ //Float_t zenith = fZenithMin + (fZenithMax - fZenithMin)*random[1];
+ //Float_t azimuth = fAzimuthMin + (fAzimuthMax-fAzimuthMin)*random[2];
+ Float_t zenith = 10;
+ Float_t azimuth = 30;
+
+ // Generate the kinematics a la AliGenScan (Andreas Morchs)
+ Float_t dx, dz;
+ if ( fNx > 0 ) {
+ dx = fXwidth/fNx;
+ } else {
+ dx = 1e10;
+ //dx = 100.;
+ }
+
+ if ( fNz > 0 ) {
+ dz = fZwidth/fNz;
+ } else {
+ dz = 1e10;
+ //dz = 100.;
+ }
+
+ //origin[0] = AliCRTConstants::fgDepth*TMath::Tan(zenith*kDegrad)*
+ origin[0] = 0.;
+ //TMath::Sin(azimuth*kDegrad);
+ //origin[1] = AliCRTConstants::fgDepth;
+ origin[1] = 900;
+ //origin[2] = AliCRTConstants::fgDepth*TMath::Tan(zenith*kDegrad)*
+ origin[2] = 0.;
+ //TMath::Cos(azimuth*kDegrad);
+
+ for (Int_t ix = 0; ix < fNx; ix++ ) {
+ for (Int_t iz = 0; iz < fNz; iz++ ) {
+ Rndm(random,6);
+ origin[0]+=ix*dx+2*(random[1]-0.5)*fOsigma[0];
+ origin[2]+=iz*dz+2*(random[2]-0.5)*fOsigma[2];
+ if ( random[4] < 0.5 ) {
+ origin[0] = -1*origin[0];
+ }
+ if ( random[5] < 0.5 ) {
+ origin[2] = -1*origin[2];
+ }
+
+ pmom = -(fPMin + random[3] *(fPMax - fPMax) ); // Always downwards
+ p[0] = TMath::Sin(zenith*kDegrad)*TMath::Sin(azimuth*kDegrad)*pmom;
+ p[1] = TMath::Cos(zenith*kDegrad)*pmom;
+ p[2] = TMath::Sin(zenith*kDegrad)*TMath::Cos(azimuth*kDegrad)*pmom;
+
+ PushTrack(fTrackIt, -1, fIpart, p, origin, polar, 0, kPPrimary, nt);
+ }
+
+ }
+
+}
+