1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //H. Woehri, A. De Falco, INFN Cagliari, April 2007
19 //an example how to use the AliGenMUONCocktailpp generator
20 //without GEANT simulation of the detector
21 //The macro switches on all decay modes for the resonances,
22 //while for the minimum bias Pythia event we additionally
23 //switch on the muonic decays of pions and Kaons
24 //Its outcome can be further processed by the macro
27 #if !defined(__CINT__) || defined(__MAKECINT__)
28 #include "AliGenerator.h"
29 #include "AliRunLoader.h"
31 #include "AliHeader.h"
33 #include "AliGenCocktail.h"
34 #include "AliDecayerPythia.h"
36 #include "AliGenMUONCocktailpp.h"
38 #include "TParticle.h"
41 AliGenerator* CreateGeneratorMC(Int_t mult);
42 Int_t SetupOutputDirectory();
44 //the third argument "mult" allows to select at a "pre-trigger" level
45 //events with "mult" muons in the MUON detector's phase space
46 //window, which is defined in the method "CreateGeneratorMC(Int_t mult)"
47 //note that in this routine also a cut on the muon's origin
48 //should be placed in order not to trigger on muons from pi/K decays
49 //that were decayed by Pythia way inside the absorber or in the muon
51 void fastMUONGen(Int_t nev = 1, char* filename = "galice.root", Int_t mult = 2)
53 Int_t runNumber = SetupOutputDirectory();
54 gAlice->SetRunNumber(runNumber);
55 printf("\n\n\n\nsetting run number to %d\n\n\n\n", runNumber);
58 AliPDG::AddParticlesToPdgDataBase();
60 AliRunLoader* rl = AliRunLoader::Open(filename,"FASTRUN","recreate");
61 rl->SetCompressionLevel(2);
62 rl->SetNumberOfEventsPerFile(10000);
63 rl->LoadKinematics("RECREATE");
65 gAlice->SetRunLoader(rl);
68 AliStack* stack = rl->Stack();
69 AliHeader* header = rl->GetHeader();
71 // Create and Initialize Generator
72 AliGenerator *gener = CreateGeneratorMC(mult);
73 gener->SetStack(stack);
76 for (int iev = 0; iev < nev; iev++) {
78 if(iev%1000 == 0) printf("Event %d\n", iev);
81 rl->SetEventNumber(iev);
88 Int_t npart = stack->GetNprimary();
89 for (Int_t part=0; part<npart; part++) {
90 TParticle *MPart = stack->Particle(part);
91 Int_t mpart = MPart->GetPdgCode();
92 printf("Particle %5d %5d %5d\n", part, mpart, MPart->GetFirstMother());
97 header->SetNprimary(stack->GetNprimary());
98 header->SetNtrack(stack->GetNtrack());
101 stack->FinishEvent();
102 header->SetStack(stack);
104 rl->WriteKinematics("OVERWRITE");
108 rl->WriteHeader("OVERWRITE");
112 //===============================================
113 AliGenerator* CreateGeneratorMC(Int_t mult)
115 AliGenMUONCocktailpp* gener = new AliGenMUONCocktailpp();
116 gener->SetPtRange(0.,100.);
117 gener->SetYRange(-4.,-2.4);
118 gener->SetPhiRange(0., 360.);
119 gener->SetMuonMultiplicity(mult);
120 gener->SetMuonPtCut(0.5);
121 gener->SetMuonThetaRange(171.,178.);
122 gener->SetOrigin(0.,0.,0.);
123 gener->SetSigma(0.,0.,5.);
124 gener->SetVertexSmear(kPerEvent);
125 //for resonances: "kAll" all decay modes are openend
126 gener->SetDecayModeResonance(kAll);
127 //for MC Pythia events: all decays, including muonic decays from pion and Kaons are opened
128 gener->SetDecayModePythia(kAllMuonic);
129 gener->SetMuonOriginCut(-130.); //prevent the trigger muon(s) from decaying after 130 cm
130 AliDecayerPythia* decayer = new AliDecayerPythia();
131 gener->SetDecayer(decayer);
134 //===============================================
135 Int_t SetupOutputDirectory(){
137 //Setting up the name for the output directory:
138 static Int_t sseed = 0; // Set 0 to use the current time
139 gRandom->SetSeed(sseed);
140 UInt_t theSeed = gRandom->GetSeed();
141 Int_t labIndex = 5; //1 subatech, 2 clermont, 3 Torino, 4 Orsay
142 // 5 Cagliari, etc...
143 Int_t runNumber = (theSeed%100000000 + 100000000*labIndex);
146 sprintf(name, "touch run_%d", runNumber);