LCOV - code coverage report
Current view: top level - EVGEN - AliGenBeamGas.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 43 2.3 %
Date: 2016-06-14 17:26:59 Functions: 1 10 10.0 %

          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 to simulate beam gas interactions.
      20             : // At present single interactions are read from an external file. 
      21             : // Several interactions are combined in one event.
      22             : // By default the vertex is smeared between +/- 20 m
      23             : // Author: andreas.morsch@cern.ch
      24             : 
      25             : #include "AliGenBeamGas.h"
      26             : #include "AliGenReader.h"
      27             : 
      28             : #include <TParticle.h>
      29             : 
      30             : 
      31           6 : ClassImp(AliGenBeamGas)
      32             : 
      33             : AliGenBeamGas::AliGenBeamGas()
      34           0 :     :AliGenExtFile(), 
      35           0 :      fInteractions(1)
      36           0 : {
      37             : //  Constructor
      38             : //
      39           0 :     fOsigma[0] =    0.;
      40           0 :     fOsigma[1] =    0.;
      41           0 :     fOsigma[2] = 2000.;
      42           0 : }
      43             : 
      44             : //____________________________________________________________
      45             : 
      46           0 : AliGenBeamGas::~AliGenBeamGas()
      47           0 : {
      48             : // Destructor
      49           0 :     delete fReader;
      50           0 : }
      51             : 
      52             : //___________________________________________________________
      53             : void AliGenBeamGas::Init()
      54             : {
      55             : // Initialize
      56           0 :     AliGenExtFile::Init();
      57           0 : }
      58             : 
      59             :     
      60             : void AliGenBeamGas::Generate()
      61             : {
      62             : // Generate particles
      63             : 
      64           0 :   Float_t polar[3]  = {0,0,0};
      65           0 :   Float_t origin[3] = {0,0,0};
      66           0 :   Float_t p[3];
      67           0 :   Float_t random[2];
      68           0 :   Int_t i, nt;
      69             :   Int_t nInt = 0;
      70             :   
      71           0 :   while(nInt < fInteractions) {
      72             : //
      73           0 :       Rndm(random,2);
      74             : //
      75             : //  Interaction vertex
      76             : //
      77           0 :       origin[2] = 2. * fOsigma[2] * random[0] - fOsigma[2];
      78             : //
      79             : //    beam 1 or 2
      80             : //      
      81           0 :       Float_t ibeam = (random[1] < 0.5) ? -1. : 1.;
      82             : 
      83             :       // Interaction time
      84           0 :       Float_t time = origin[2]/TMath::Ccgs()*ibeam;
      85             : //
      86             : //    Read next event
      87             : //      
      88           0 :       Int_t nTracks = fReader->NextEvent();  
      89           0 :       if (nTracks == 0) {
      90             :           // printf("\n No more events !!! !\n");
      91           0 :           Warning("AliGenBeamGas::Generate",
      92             :                   "\nNo more events in external file!!!\n Last event may be empty or incomplete.\n");
      93           0 :           return;
      94             :       }
      95             :       
      96             :       //
      97             :       // Stack filling loop
      98             :       //
      99           0 :       for (i = 0; i < nTracks; i++) {
     100           0 :           TParticle* iparticle = fReader->NextParticle();
     101           0 :           p[0] = iparticle->Px();
     102           0 :           p[1] = iparticle->Py();
     103           0 :           p[2] = iparticle->Pz() * ibeam;
     104             :         
     105           0 :           Int_t idpart     = iparticle->GetPdgCode();
     106           0 :           Int_t decayed    = iparticle->GetFirstDaughter();
     107           0 :           Int_t doTracking = fTrackIt && (decayed < 0) && (TMath::Abs(idpart) > 10);
     108           0 :           PushTrack(doTracking,-1,idpart,p,origin,polar,time,kPPrimary,nt);
     109           0 :           KeepTrack(nt);
     110             :       } // track loop
     111           0 :       nInt++;
     112           0 :   } // event loop
     113             : //
     114           0 :   SetHighWaterMark(nt);
     115             : //
     116           0 :   CdEventFile();
     117           0 : }
     118             : 
     119             : 
     120             : 
     121             : 
     122             : 

Generated by: LCOV version 1.11