LCOV - code coverage report
Current view: top level - EVGEN - AliGenBox.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 55 92 59.8 %
Date: 2016-06-14 17:26:59 Functions: 7 8 87.5 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : 
      19             : // Generator for particles in a preset
      20             : // kinematic range (flat distribution)
      21             : // Note that for a given theta pt and p are not independent 
      22             : // Range for only one variable (pt or p) should be given.
      23             : // Comments and suggestions: andreas.morsch@cern.ch
      24             : 
      25             : 
      26             : #include "TPDGCode.h"
      27             : 
      28             : #include "AliConst.h"
      29             : #include "AliGenBox.h"
      30             : #include "AliRun.h"
      31             : #include "AliGenEventHeader.h"
      32             : #include "TDatabasePDG.h"
      33             : #include "AliPDG.h"
      34             : 
      35           6 : ClassImp(AliGenBox)
      36             : 
      37             : //_____________________________________________________________________________
      38             : AliGenBox::AliGenBox()
      39          48 :     :AliGenerator(), 
      40          48 :      fIpart(0),
      41          48 :      fEtaMin(0),
      42          48 :      fEtaMax(0)
      43         240 : {
      44             :   //
      45             :   // Default constructor
      46             :   //
      47          96 : }
      48             : 
      49             : //_____________________________________________________________________________
      50             : AliGenBox::AliGenBox(Int_t npart)
      51           4 :     :AliGenerator(npart),
      52           4 :      fIpart(kProton),
      53           4 :      fEtaMin(0),
      54           4 :      fEtaMax(0)
      55          20 : {
      56             :   //
      57             :   // Standard constructor
      58             :   //
      59           4 :   fName  = "Box";
      60           4 :   fTitle = "Box particle generator";
      61           8 : }
      62             : 
      63             : //_____________________________________________________________________________
      64             : 
      65             : void AliGenBox::Generate() {
      66             :   //
      67             :   // Generate one trigger (fNpart particles)
      68             :   //
      69           0 :   GenerateN(1);
      70           0 : }
      71             :  
      72             : //_____________________________________________________________________________
      73             : void AliGenBox::GenerateN(Int_t ntimes)
      74             : {
      75             :   //
      76             :   // Generate ntimes triggers
      77             :   //   total ntimes*fNpart particles
      78             :   //
      79             :   
      80          32 :     Float_t polar[3]= {0,0,0};
      81             :   //
      82          16 :     Float_t origin[3];
      83             :     Float_t time;
      84          16 :     Float_t p[3];
      85          16 :     Int_t i, j, nt;
      86             :     Double_t pmom, theta, phi, pt;
      87             :     Double_t y, mt;
      88             :     //
      89          16 :     Float_t random[6];
      90             :   //
      91         128 :     for (j=0;j<3;j++) origin[j]=fOrigin[j];
      92          16 :     time = fTimeOrigin;
      93          16 :     if(fVertexSmear==kPerEvent) {
      94           0 :         Vertex();
      95           0 :         for (j=0;j<3;j++) origin[j]=fVertex[j];
      96           0 :         time = fTime;
      97           0 :     }
      98             : 
      99          16 :     Double_t m = TDatabasePDG::Instance()->GetParticle(fIpart)->Mass();
     100             : 
     101          16 :     Int_t mult = fNpart*ntimes;
     102          64 :     for(i=0;i<mult;i++) {
     103          16 :         Rndm(random,3);
     104             :         
     105          16 :         if (TestBit(kYRange)) {
     106           0 :             y = fYMin+random[0]*(fYMax-fYMin);
     107             :         
     108           0 :             if(TestBit(kMomentumRange)) {
     109           0 :                 pmom=fPMin+random[1]*(fPMax-fPMin);
     110           0 :                 mt = TMath::Sqrt(pmom*pmom+m*m)/TMath::CosH(y);
     111           0 :                 pt = TMath::Sqrt(mt*mt - m*m);
     112           0 :             } else {
     113           0 :                 pt=fPtMin+random[1]*(fPtMax-fPtMin);
     114           0 :                 mt=TMath::Sqrt(pt*pt+m*m);
     115             :             }
     116             : 
     117           0 :             phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
     118           0 :             p[0] = pt*TMath::Cos(phi);
     119           0 :             p[1] = pt*TMath::Sin(phi);
     120           0 :             p[2] = mt*TMath::SinH(y);
     121           0 :         } else {
     122          16 :             if (TestBit(kThetaRange)) {
     123          16 :                 theta = fThetaMin+random[0]*(fThetaMax-fThetaMin);
     124          16 :             } else {
     125           0 :                 Float_t eta = fEtaMin+random[0]*(fEtaMax-fEtaMin);
     126           0 :                 theta = 2. * TMath::ATan(TMath::Exp(-eta));
     127             :             }
     128             :         
     129          16 :             if(TestBit(kMomentumRange)) {
     130          16 :                 pmom=fPMin+random[1]*(fPMax-fPMin);
     131          16 :                 pt=pmom*TMath::Sin(theta);
     132          16 :             } else {
     133             : 
     134           0 :                 pt=fPtMin+random[1]*(fPtMax-fPtMin);
     135           0 :                 pmom=pt/TMath::Sin(theta);
     136             :             }
     137             : 
     138          16 :             phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
     139          16 :             p[0] = pt*TMath::Cos(phi);
     140          16 :             p[1] = pt*TMath::Sin(phi);
     141          16 :             p[2] = pmom*TMath::Cos(theta);
     142             :         }
     143             : 
     144          16 :         if(fVertexSmear==kPerTrack) {
     145           0 :             Rndm(random,6);
     146           0 :             for (j=0;j<3;j++) {
     147           0 :                 origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
     148           0 :                     TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
     149             :             }
     150             : 
     151           0 :             Rndm(random,2);
     152           0 :             time = fTimeOrigin + fOsigma[2]/TMath::Ccgs()*
     153           0 :               TMath::Cos(2*random[0]*TMath::Pi())*
     154           0 :               TMath::Sqrt(-2*TMath::Log(random[1]));
     155           0 :         }
     156          16 :         PushTrack(fTrackIt,-1,fIpart,p,origin,polar,time,kPPrimary,nt, 1., 1);
     157             :     }
     158             : 
     159          16 :     AliGenEventHeader* header = new AliGenEventHeader("BOX");
     160          16 :     header->SetPrimaryVertex(fVertex);
     161          16 :     header->SetNProduced(mult);
     162          16 :     header->SetInteractionTime(fTime);
     163             :     
     164             :  // Passes header either to the container or to gAlice
     165          16 :     if (fContainer) {
     166          16 :         header->SetName(fName);
     167          16 :         fContainer->AddHeader(header);
     168          16 :     } else {
     169           0 :         gAlice->SetGenEventHeader(header);   
     170             :     }
     171          16 : }
     172             : 
     173             : //_____________________________________________________________________________
     174             : 
     175             : void AliGenBox::Init()
     176             : {
     177             : // Initialisation, check consistency of selected ranges
     178           8 :   if(TestBit(kPtRange)&&TestBit(kMomentumRange)) 
     179           0 :     Fatal("Init","You should not set the momentum range and the pt range!\n");
     180           8 :   if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange))) 
     181           0 :     Fatal("Init","You should set either the momentum or the pt range!\n");
     182          12 :   if((TestBit(kYRange)&&TestBit(kThetaRange)) || (TestBit(kYRange)&&TestBit(kEtaRange)) || (TestBit(kEtaRange)&&TestBit(kThetaRange)) )
     183           0 :     Fatal("Init","You should only set the range of one of these variables: y, eta or theta\n");
     184          12 :   if((!TestBit(kYRange)) && (!TestBit(kEtaRange)) && (!TestBit(kThetaRange)) )
     185           0 :     Fatal("Init","You should set the range of one of these variables: y, eta or theta\n");
     186           4 : }
     187             : 

Generated by: LCOV version 1.11