+++ /dev/null
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * *
- * Author: The ALICE Off-line Project. *
- * Contributors are mentioned in the code where appropriate. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
-
-/* $Id$ */
-
-// 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 <stdlib.h>
-
-#include <TDatabasePDG.h>
-#include <TPDGCode.h>
-#include <RVersion.h>
-#include <TChain.h>
-#include <TFile.h>
-#include <TTree.h>
-#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
- // Set maximum admitted age of particles to 1.e-05 by default
- // Do not add weight
- // 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
- // Set the default file
- fTreeChain = new TChain("h1");
-//
-// Read all particles
- fNpart=-1;
-}
-
-AliGenFLUKAsource::AliGenFLUKAsource(Int_t 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";
-}
-
-//____________________________________________________________
-AliGenFLUKAsource::~AliGenFLUKAsource()
-{
-// Destructor
- if (fTreeFluka) delete fTreeFluka;
- if (fTreeChain) delete fTreeChain;
-}
-
-void AliGenFLUKAsource::AddFile(const Text_t *filename)
-{
-// Add a file to the chain
- fTreeChain->Add(filename);
-
-}
-
-
-//____________________________________________________________
-void AliGenFLUKAsource::FlukaInit()
-{
-// Set branch addresses of data entries
- TChain *h2=fTreeChain;
-//Set branch addresses
- h2->SetBranchAddress("Ip",&fIp);
- h2->SetBranchAddress("Ipp",&fIpp);
- h2->SetBranchAddress("Xi",&fXi);
- h2->SetBranchAddress("Yi",&fYi);
- h2->SetBranchAddress("Zi",&fZi);
- h2->SetBranchAddress("Px",&fPx);
- h2->SetBranchAddress("Py",&fPy);
- h2->SetBranchAddress("Pz",&fPz);
- h2->SetBranchAddress("Ekin",&fEkin);
- h2->SetBranchAddress("Zv",&fZv);
- h2->SetBranchAddress("Rv",&fRv);
- h2->SetBranchAddress("Itra",&fItra);
- h2->SetBranchAddress("Igas",&fIgas);
- h2->SetBranchAddress("Wgt",&fWgt);
- h2->SetBranchAddress("Etag",&fEtag);
- h2->SetBranchAddress("Ptg",&fPtg);
- h2->SetBranchAddress("Age",&fAge);
-}
-
-//____________________________________________________________
-void AliGenFLUKAsource::Generate()
-{
-// Generate one event
-
- const Int_t kIfluge[28]={kProton, kProtonBar, kElectron, kPositron,
- kNuE, kNuEBar, kGamma, kNeutron, kNeutronBar,
- kMuonPlus, kMuonMinus, kK0Long , kPiPlus, kPiMinus,
- kKPlus, kKMinus, kLambda0, kLambda0Bar, kK0Short,
- kSigmaMinus, kSigmaPlus, kSigma0, kPi0, kK0, kK0Bar,
- 0,kNuMu,kNuMuBar};
- Float_t polar[3]= {0,0,0};
- //
- Float_t origin[3];
- Float_t p[3];
- Float_t prwn;
- Float_t wgt, fwgt;
- Float_t phi;
- Float_t amass;
- Int_t iwgt;
- Int_t i, j, part, nt;
- static Int_t irwn=0;
- //
- Float_t random[2];
- //
- FlukaInit();
- 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();
- for (i=0; i<fNpart;i++) {
- Int_t entry=fNpart*(ev-1)+i;
- nb = (Int_t)h2->GetEvent(entry);
- if (irwn > nentries) {
- printf("No more entries in the FLUKA boundary source file\n");
- TFile *pFile=0;
- // Get AliRun object or create it
- if (!gAlice) {
- gAlice = (AliRun*)pFile->Get("gAlice");
- if (gAlice) printf("AliRun object found on file\n");
- if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
- }
- TTree *fAli=AliRunLoader::Instance()->TreeK();
- if (fAli) pFile =fAli->GetCurrentFile();
- pFile->cd();
- printf("Generate - I'm out \n");
- return;
- }
-
- Int_t ifip = Int_t(fIp);
-
-
- if (fSourceId != -1 && fIgas !=fSourceId) {
- irwn++;
- continue;
- }
-
- if (ifip > 28 || ifip < 0) {
- irwn++;
- continue;
- }
-
- if ((ifip != fIkine && fIkine != kAll && fIkine != kCharged
- && fIkine != 10) || fAge > fAgeMax){
- irwn++;
- continue;
- } else if (fIkine == kCharged) {
- if (ifip == 7 || ifip == 8 || fAge > fAgeMax) {
- irwn++;
- continue;
- }
- } else if (fIkine == kNoNeutron) {
- if (ifip == 8 || fAge > fAgeMax) {
- irwn++;
- continue;
- }
- }
-
-
- irwn++;
-//
-// PDG code from FLUKA particle type (ifip)
- part=kIfluge[int(ifip)-1];
-//
-// Calculate momentum from kinetic energy and mass of the particle
-#if ROOT_VERSION_CODE > 197895
- amass = gMC->ParticleMass(part);
-#else
- amass = (TDatabasePDG::Instance())->GetParticle(part)->Mass();
-#endif
- prwn=fEkin*sqrt(1. + 2.*amass/fEkin);
-
-
- origin[0]=fYi;
- origin[1]=fXi;
- origin[2]=fZi;
-
- p[0]=fPy*prwn;
- p[1]=fPx*prwn;
- p[2]=fPz*prwn;
-
- //handle particle weight correctly
- wgt = (part == 13) ? fWgt*fAddWeight : fWgt;
- iwgt=Int_t(wgt);
- fwgt=wgt-Float_t(iwgt);
- 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++) {
- 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);
- p[0]=pn1;
- p[1]=pn2;
- Float_t on1=origin[0]*TMath::Sin(phi)-origin[1]*TMath::Cos(phi);
- Float_t on2=origin[0]*TMath::Cos(phi)+origin[1]*TMath::Sin(phi);
- origin[0]=on1;
- origin[1]=on2;
- nstack++;
- }
- if (nstack == 0) continue;
- }
-
- TFile *pFile=0;
-// Get AliRun object or create it
- if (!gAlice) {
- gAlice = (AliRun*)pFile->Get("gAlice");
- if (gAlice) printf("AliRun object found on file\n");
- if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
- }
- TTree *fAli=AliRunLoader::Instance()->TreeK();
- if (fAli) pFile =fAli->GetCurrentFile();
- pFile->cd();
-}
-
-
-
-
-
-
+++ /dev/null
-#ifndef ALIGENFLUKASOURCE_H
-#define ALIGENFLUKASOURCE_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice */
-
-/* $Id$ */
-
-
-// Read background particles from a FLUKA boundary source file
-// This is a very special generator that works for background studies for the muon-spectrometer
-// Ask: andreas.morsch@cern.ch
-
-#include "AliGenerator.h"
-class TChain;
-class TTree;
-class AliGenFLUKAsource : public AliGenerator
-
-{
-public:
- enum constants {kAll = 6, kGammas = 7, kNeutrons = 8, kCharged = 9, kNoNeutron = 10};
-
- AliGenFLUKAsource();
- AliGenFLUKAsource(Int_t npart);
- virtual ~AliGenFLUKAsource();
- // Initialise
- virtual void Init() {}
- // Initialise fluka data
- virtual void FlukaInit();
- // choose particle type
- virtual void SetPartFlag(Int_t ikine) {fIkine=ikine;}
- // set time cut
- virtual void SetAgeMax(Float_t agemax) {fAgeMax=agemax;}
- // use additional weight on neutrals
- virtual void SetAddWeight(Float_t addwgt) {fAddWeight=addwgt;}
- // z-shift of vertex
- virtual void SetZshift(Float_t zshift) {fZshift=zshift;}
- // set file name of data file
- virtual void SetFileName(const Text_t *filname) {fFileName=filname;}
- // set source
- virtual void SetSourceId(Int_t id=-1){fSourceId=id;}
- // add a new source file
- virtual void AddFile(const Text_t *filname) ;
- // read only fraction of data
- virtual void SetFraction(Float_t frac=1.){fFrac=frac;}
- // generate event
- virtual void Generate();
-
- protected:
-
- Int_t fIkine; // Flag to choose type of particles to be read
- Float_t fAgeMax; // Maximum age of particle
- Float_t fAddWeight; // Add weight for neutrons
- Float_t fZshift; // Shift the Z of impact point by this quantity
- Float_t fFrac; // Fraction of file that corresponds to one event
- Int_t fSourceId; // Source identifier (-1: all sources)
-
-
- const Text_t *fFileName; //!Choose the file
- TChain *fTreeChain; //file chaining
- TTree *fTreeFluka; //pointer to the TTree
-//Declaration of variables read from the file -- TTree type
- Float_t fIp; // Particle type
- Float_t fIpp; // Primary particle type
- Float_t fXi; // x-Impact
- Float_t fYi; // y-Impact
- Float_t fZi; // z-Impact
- Float_t fPx; // Direction cosine x
- Float_t fPy; // Direction cosine y
- Float_t fPz; // Direction cosine z
- Float_t fEkin; // Kinetic energy
- Float_t fZv; // z-Position of particle vertex
- Float_t fRv; // r-Position of particle vertex
- Float_t fItra; // Primary track number
- Float_t fIgas; // Volume identifier
- Float_t fWgt; // Particle weight
- Float_t fEtag; // Pseudorapidity of primary particle
- Float_t fPtg; // Pt of primary particle
- Float_t fAge; // Time of flight
-
- private:
- AliGenFLUKAsource(const AliGenFLUKAsource &FLUKAsource);
- AliGenFLUKAsource & operator=(const AliGenFLUKAsource & rhs);
-
- ClassDef(AliGenFLUKAsource,1) //Boundary source
-};
-#endif
-
-
-
-
-
-