]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenFLUKAsource.cxx
ReadRaw(): TGraphs are created once per event (B.Polichtchouk)
[u/mrichter/AliRoot.git] / EVGEN / AliGenFLUKAsource.cxx
index 255ffb672760d78c64b6578377cc77cdae1b6619..d1565b97dcbd9234399b830dab6818bc59ff702a 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.10  2000/06/09 20:31:34  morsch
-All coding rule violations except RS3 corrected
+/* $Id$ */
 
-Revision 1.9  2000/03/07 13:52:54  morsch
-static Int_t irwn=0;
-
-Revision 1.8  2000/02/14 14:49:38  morsch
-Correct particle type for gamma and neutrons
-More consistent calculation of momentum from kin. energy and mass
-
-Revision 1.7  1999/11/03 17:43:20  fca
-New version from G.Martinez & A.Morsch
-
-Revision 1.6  1999/09/29 09:24:12  fca
-Introduction of the Copyright and cvs Log
-
-*/
+// Read background particles from a FLUKA boundary source file
+// This is a very special generator that works for background studies for the muon-spectrometer.
+// The input files come from FLUKA simulations.
+// Files can be chained. 
+// Author: andreas.morsch@cern.ch
 
 #include "AliGenFLUKAsource.h"
-#include "AliMC.h"
-#include "AliRun.h"
-#include "AliPDG.h"
-
+#include <stdlib.h>
 
+#include <TDatabasePDG.h>
+#include <TPDGCode.h>
+#include <RVersion.h>
+#include <TChain.h>
 #include <TFile.h>
 #include <TTree.h>
-#include <TChain.h>
-#include <stdlib.h>
- ClassImp(AliGenFLUKAsource)
-     AliGenFLUKAsource::AliGenFLUKAsource()
-        :AliGenerator(-1)
+#include <TVirtualMC.h>
+
+#include "AliRun.h"
+
+ClassImp(AliGenFLUKAsource)
+
+AliGenFLUKAsource::AliGenFLUKAsource()
+    :AliGenerator(-1), 
+     fIkine(6),
+     fAgeMax(1.e-5), 
+     fAddWeight(1.),
+     fZshift(0.),
+     fFrac(0.),
+     fSourceId(-1),
+     fFileName(0),
+     fTreeChain(0),
+     fTreeFluka(0),
+     fIp(0.),
+     fIpp(0.),
+     fXi(0.),
+     fYi(0.),
+     fZi(0.),
+     fPx(0.),
+     fPy(0.),
+     fPz(0.),
+     fEkin(0.),
+     fZv(0.),
+     fRv(0.),
+     fItra(0.),
+     fIgas(0.),
+     fWgt(0.),
+     fEtag(0.),
+     fPtg(0.),
+     fAge(0.)
 {
     // Constructor
     fName="FLUKA";
     fTitle="FLUKA Boundary Source";
     // Read in all particle types by default
-    fIkine=6;
     // Set maximum admitted age of particles to 1.e-05 by default 
-    fAgeMax=1.e-05;
     // Do not add weight
-    fAddWeight=1.;
     // Shift the z-coordinate of the impact point by 4.5 cm only if it reads 
     // from  specific boundary source to the chamber (fZshift=4.5;),else there 
     // is no need to shift as it reads boundary source for the whole volume of 
     // the Muon Arm; the default value corresponds to boundary source for the
     // whole volume of the MUON Arm 
-    fZshift=0;
     // Set the default file 
-    fFileName="flukasource.root";
-
-    fTreeFluka=0;
     fTreeChain = new TChain("h1");
 //
 //  Read all particles
     fNpart=-1;
-
-    
 }
 
 AliGenFLUKAsource::AliGenFLUKAsource(Int_t npart)
-    :AliGenerator(npart)
+    :AliGenerator(npart), 
+     fIkine(6),
+     fAgeMax(1.e-5), 
+     fAddWeight(1.),
+     fZshift(0.),
+     fFrac(0.),
+     fSourceId(-1),
+     fFileName(""),
+     fTreeChain(new TChain("h1")),
+     fTreeFluka(0),
+     fIp(0.),
+     fIpp(0.),
+     fXi(0.),
+     fYi(0.),
+     fZi(0.),
+     fPx(0.),
+     fPy(0.),
+     fPz(0.),
+     fEkin(0.),
+     fZv(0.),
+     fRv(0.),
+     fItra(0.),
+     fIgas(0.),
+     fWgt(0.),
+     fEtag(0.),
+     fPtg(0.),
+     fAge(0.)
 {
     // Constructor
-    fName="FLUKA";
-    fTitle="FLUKA Boundary Source";
-    // Read in all particle types by default
-    fIkine=6;
-    // Set maximum admitted age of particles to 1.e-05 by default 
-    fAgeMax=1.e-05;
-    // Do not add weight
-    fAddWeight=1.;
-    // Shift the z-coordinate of the impact point by 4.5 cm only if it reads 
-    // from  specific boundary source to the chamber (fZshift=4.5;),else there 
-    // is no need to shift as it reads boundary source for the whole volume of 
-    // the Muon Arm; the default value corresponds to boundary source for the
-    // whole volume of the MUON Arm 
-    fZshift=0;
-    // Set the default file 
-    fFileName="flukasource.root";
-
-    fTreeFluka=0;
-    fTreeChain = new TChain("h1"); 
-    fSourceId=-1;
+    fName  = "FLUKA";
+    fTitle = "FLUKA Boundary Source";
 }
 
-AliGenFLUKAsource::AliGenFLUKAsource(const AliGenFLUKAsource & FLUKAsource)
+AliGenFLUKAsource::AliGenFLUKAsource(const AliGenFLUKAsource & FLUKAsource):
+    AliGenerator(FLUKAsource), 
+    fIkine(6),
+    fAgeMax(1.e-5), 
+    fAddWeight(1.),
+    fZshift(0.),
+    fFrac(0.),
+    fSourceId(-1),
+    fFileName(0),
+    fTreeChain(0),
+    fTreeFluka(0),
+    fIp(0.),
+    fIpp(0.),
+    fXi(0.),
+    fYi(0.),
+    fZi(0.),
+    fPx(0.),
+    fPy(0.),
+    fPz(0.),
+    fEkin(0.),
+    fZv(0.),
+    fRv(0.),
+    fItra(0.),
+    fIgas(0.),
+    fWgt(0.),
+    fEtag(0.),
+    fPtg(0.),
+    fAge(0.)
 {
-// copy constructor
+// Copy constructor
+    FLUKAsource.Copy(*this);
 }
 
 
@@ -151,7 +196,6 @@ void AliGenFLUKAsource::FlukaInit()
 void AliGenFLUKAsource::Generate()
 {
 // Generate one event 
-    AliMC* gMC = AliMC::GetMC();
 
     const Int_t kIfluge[28]={kProton, kProtonBar, kElectron, kPositron,
                          kNuE, kNuEBar, kGamma, kNeutron, kNeutronBar,
@@ -166,9 +210,7 @@ void AliGenFLUKAsource::Generate()
     Float_t prwn;
     Float_t wgt, fwgt;
     Float_t phi;
-    char name[100];
-    Float_t amass, charge, tlife;
-    Int_t itrtyp;
+    Float_t amass;
     Int_t iwgt;
     Int_t i, j, part, nt;
     static Int_t irwn=0;
@@ -179,7 +221,8 @@ void AliGenFLUKAsource::Generate()
     TChain *h2=fTreeChain;
     Int_t nentries = (Int_t) h2->GetEntries();
     if (fNpart == -1) fNpart=Int_t(nentries*fFrac);
-  
+    
+
   // loop over number of particles
     Int_t nb=0;
     Int_t ev=gMC->CurrentEvent();
@@ -201,27 +244,31 @@ void AliGenFLUKAsource::Generate()
            printf("Generate - I'm out \n");
            return;
        }   
+       
+       Int_t ifip = Int_t(fIp);
+       
 
        if (fSourceId != -1 && fIgas !=fSourceId) {
            irwn++;
            continue;
        }
        
-       if (fIp > 28 || fIp < 0) {
+       if (ifip > 28 || ifip < 0) {
            irwn++;
            continue;
        }
        
-       if ((fIp != fIkine && fIkine != 6 && fIkine != 9 && fIkine != 10) || fAge > fAgeMax){
+       if ((ifip != fIkine && fIkine != kAll && fIkine != kCharged 
+            && fIkine != 10) || fAge > fAgeMax){
            irwn++;
            continue;
-       } else if (fIkine == 9) {
-           if (fIp == 7 || fIp == 8 || fAge > fAgeMax) { 
+       } else if (fIkine == kCharged) {
+           if (ifip == 7 || ifip == 8 || fAge > fAgeMax) { 
                irwn++;
                continue;
            }
-       } else if (fIkine == 10) {
-           if (fIp == 8 || fAge > fAgeMax) { 
+       } else if (fIkine == kNoNeutron) {
+           if (ifip == 8 || fAge > fAgeMax) { 
                irwn++;
                continue;
            }
@@ -230,12 +277,15 @@ void AliGenFLUKAsource::Generate()
 
        irwn++;
 //
-// PDG code from FLUKA particle type (fIp)
-       part=kIfluge[int(fIp)-1];       
+// PDG code from FLUKA particle type (ifip)
+       part=kIfluge[int(ifip)-1];      
 //
 // Calculate momentum from kinetic energy and mass of the particle
-       gMC->Gfpart(part, name, itrtyp,  
-                   amass, charge, tlife); 
+#if ROOT_VERSION_CODE > 197895
+        amass = gMC->ParticleMass(part);
+#else
+       amass = (TDatabasePDG::Instance())->GetParticle(part)->Mass();
+#endif
        prwn=fEkin*sqrt(1. + 2.*amass/fEkin);
 
 
@@ -251,13 +301,13 @@ void AliGenFLUKAsource::Generate()
        wgt = (part == 13) ? fWgt*fAddWeight : fWgt;
        iwgt=Int_t(wgt);
        fwgt=wgt-Float_t(iwgt);
-       gMC->Rndm(random,2);
+       Rndm(random,2);
        if (random[0] < fwgt) iwgt++;
        if (part==1 && iwgt>100) iwgt=100;
        Int_t nstack=0;
        for (j=0; j<iwgt; j++) {
-           gAlice->SetTrack(fTrackIt,-1,part,p,origin,polar,fAge,"Primary",nt);
-           gMC->Rndm(random,2);
+           PushTrack(fTrackIt,-1,part,p,origin,polar,fAge,kPPrimary,nt);
+           Rndm(random,2);
            phi=2*random[1]*TMath::Pi();
            Float_t pn1=p[0]*TMath::Sin(phi) - p[1]*TMath::Cos(phi);
            Float_t pn2=p[0]*TMath::Cos(phi) + p[1]*TMath::Sin(phi);
@@ -288,10 +338,16 @@ void AliGenFLUKAsource::Generate()
 AliGenFLUKAsource& AliGenFLUKAsource::operator=(const  AliGenFLUKAsource& rhs)
 {
 // Assignment operator
-    return *this;
+    rhs.Copy(*this);
+    return (*this);
 }
 
 
+void AliGenFLUKAsource::Copy(TObject &) const
+{
+    Fatal("Copy","Not implemented!\n");
+}
+