AliRoot Core  ee782a0 (ee782a0)
fastMUONGen.C
Go to the documentation of this file.
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 
30 
31 #if !defined(__CINT__) || defined(__MAKECINT__)
32 #include "AliGenerator.h"
33 #include "AliRunLoader.h"
34 #include "AliRun.h"
35 #include "AliHeader.h"
36 #include "AliStack.h"
37 #include "AliGenCocktail.h"
38 #include "AliDecayerPythia.h"
39 #include "AliPDG.h"
40 #include "AliGenMUONCocktailpp.h"
41 
42 #include "TParticle.h"
43 #endif
44 
45 AliGenerator* CreateGeneratorMC(Int_t mult);
46 Int_t SetupOutputDirectory();
47 
55 void fastMUONGen(Int_t nev = 1, char* filename = "galice.root", Int_t mult = 2)
56 {
58  gAlice->SetRunNumber(runNumber);
59  printf("\n\n\n\nsetting run number to %d\n\n\n\n", runNumber);
60 
61  // Update data base
63  //
64  AliRunLoader* rl = AliRunLoader::Open(filename,"FASTRUN","recreate");
65  rl->SetCompressionLevel(2);
66  rl->SetNumberOfEventsPerFile(10000);
67  rl->LoadKinematics("RECREATE");
68  rl->MakeTree("E");
69  gAlice->SetRunLoader(rl);
70  //
71  rl->MakeStack();
72  AliStack* stack = rl->Stack();
73  AliHeader* header = rl->GetHeader();
74  //
75  // Create and Initialize Generator
76  AliGenerator *gener = CreateGeneratorMC(mult);
77  gener->SetStack(stack);
78  gener->Init();
79  //
80  for (int iev = 0; iev < nev; iev++) {
81 
82  if(iev%1000 == 0) printf("Event %d\n", iev);
83  // Initialize event
84  header->Reset(0,iev);
85  rl->SetEventNumber(iev);
86  stack->Reset();
87  rl->MakeTree("K");
88 
89  gener->Generate();
90 /*
91  // Printing
92  Int_t npart = stack->GetNprimary();
93  for (Int_t part=0; part<npart; part++) {
94  TParticle *MPart = stack->Particle(part);
95  Int_t mpart = MPart->GetPdgCode();
96  printf("Particle %5d %5d %5d\n", part, mpart, MPart->GetFirstMother());
97  }
98 */
99 
100  // Finish event
101  header->SetNprimary(stack->GetNprimary());
102  header->SetNtrack(stack->GetNtrack());
103  // I/O
104  //
105  stack->FinishEvent();
106  header->SetStack(stack);
107  rl->TreeE()->Fill();
108  rl->WriteKinematics("OVERWRITE");
109  } // event loop
110 
111  gener->FinishRun();
112  rl->WriteHeader("OVERWRITE");
113  gener->Write();
114  rl->Write();
115 }
116 //===============================================
118 {
119  AliGenMUONCocktailpp* gener = new AliGenMUONCocktailpp();
120  gener->SetPtRange(0.,100.);
121  gener->SetYRange(-4.,-2.4);
122  gener->SetPhiRange(0., 360.);
123  gener->SetMuonMultiplicity(mult);
124  gener->SetMuonPtCut(0.5);
125  gener->SetMuonThetaRange(171.,178.);
126  gener->SetOrigin(0.,0.,0.);
127  gener->SetSigma(0.,0.,5.);
128  gener->SetVertexSmear(kPerEvent);
129  //for resonances: "kAll" all decay modes are openend
130  gener->SetDecayModeResonance(kAll);
131  //for MC Pythia events: all decays, including muonic decays from pion and Kaons are opened
132  gener->SetDecayModePythia(kAllMuonic);
133  gener->SetMuonOriginCut(-130.); //prevent the trigger muon(s) from decaying after 130 cm
134  AliDecayerPythia* decayer = new AliDecayerPythia();
135  gener->SetDecayer(decayer);
136  return gener;
137 }
138 //===============================================
140 
141  //Setting up the name for the output directory:
142  static Int_t sseed = 0; // Set 0 to use the current time
143  gRandom->SetSeed(sseed);
144  UInt_t theSeed = gRandom->GetSeed();
145  Int_t labIndex = 5; //1 subatech, 2 clermont, 3 Torino, 4 Orsay
146  // 5 Cagliari, etc...
147  Int_t runNumber = (theSeed%100000000 + 100000000*labIndex);
148 
149  Char_t name[100];
150  sprintf(name, "touch run_%d", runNumber);
151  gSystem->Exec(name);
152 
153  return runNumber;
154 }
void SetStack(AliStack *stack)
Definition: AliGenerator.h:93
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
void SetRunLoader(AliRunLoader *rloader)
Definition: AliRun.cxx:392
virtual void FinishRun()
void fastMUONGen(Int_t nev=1, char *filename="galice.root", Int_t mult=2)
Definition: fastMUONGen.C:55
Int_t SetupOutputDirectory()
Definition: fastMUONGen.C:139
Int_t WriteKinematics(Option_t *opt="")
static void AddParticlesToPdgDataBase()
Definition: AliPDG.cxx:31
static AliRunLoader * Open(const char *filename="galice.root", const char *eventfoldername=AliConfig::GetDefaultEventFolderName(), Option_t *option="READ")
Int_t SetEventNumber(Int_t evno)
virtual void SetStack(AliStack *stack)
Definition: AliHeader.cxx:187
Int_t GetNprimary() const
Definition: AliStack.h:137
virtual Int_t GetNtrack() const
Definition: AliStack.h:134
void MakeTree(Option_t *option)
virtual void SetNprimary(Int_t nprimary)
Definition: AliHeader.h:37
AliHeader * GetHeader() const
void SetCompressionLevel(Int_t cl)
Int_t WriteHeader(Option_t *opt="")
AliRun * gAlice
Definition: AliRun.cxx:62
virtual void Reset(Int_t run, Int_t event)
Definition: AliHeader.cxx:130
TTree * TreeE() const
virtual void Generate()=0
virtual void SetNtrack(Int_t ntrack)
Definition: AliHeader.h:44
void Reset(Int_t size=0)
Definition: AliStack.cxx:654
void SetNumberOfEventsPerFile(Int_t nevpf)
Definition: AliRunLoader.h:153
static Int_t runNumber
Definition: pdc06_config.C:126
void FinishEvent()
Definition: AliStack.cxx:556
virtual void Init()
AliGenerator * CreateGeneratorMC(Int_t mult)
Definition: fastMUONGen.C:117
static Int_t sseed
Definition: ConfigCosmic.C:127
Int_t LoadKinematics(Option_t *option="READ")
AliStack * Stack() const
Definition: AliRunLoader.h:95