]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/fastMUONGen.C
Adding FindPCBIndexByMotifPositionID method (Laurent)
[u/mrichter/AliRoot.git] / MUON / fastMUONGen.C
CommitLineData
9c090011 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//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
25//"fastMUONSim.C
26
27#if !defined(__CINT__) || defined(__MAKECINT__)
28#include "AliGenerator.h"
29#include "AliRunLoader.h"
30#include "AliRun.h"
31#include "AliHeader.h"
32#include "AliStack.h"
33#include "AliGenCocktail.h"
34#include "AliDecayerPythia.h"
35#include "AliPDG.h"
36#include "AliGenMUONCocktailpp.h"
37
38#include "TParticle.h"
39#endif
40
41AliGenerator* CreateGeneratorMC(Int_t mult);
42Int_t SetupOutputDirectory();
43
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
50//spectrometer itself
51void fastMUONGen(Int_t nev = 1, char* filename = "galice.root", Int_t mult = 2)
52{
53 Int_t runNumber = SetupOutputDirectory();
54 gAlice->SetRunNumber(runNumber);
55 printf("\n\n\n\nsetting run number to %d\n\n\n\n", runNumber);
56
57 // Update data base
58 AliPDG::AddParticlesToPdgDataBase();
59 //
60 AliRunLoader* rl = AliRunLoader::Open(filename,"FASTRUN","recreate");
61 rl->SetCompressionLevel(2);
62 rl->SetNumberOfEventsPerFile(10000);
63 rl->LoadKinematics("RECREATE");
64 rl->MakeTree("E");
65 gAlice->SetRunLoader(rl);
66 //
67 rl->MakeStack();
68 AliStack* stack = rl->Stack();
69 AliHeader* header = rl->GetHeader();
70 //
71 // Create and Initialize Generator
72 AliGenerator *gener = CreateGeneratorMC(mult);
73 gener->SetStack(stack);
74 gener->Init();
75 //
76 for (int iev = 0; iev < nev; iev++) {
77
78 if(iev%1000 == 0) printf("Event %d\n", iev);
79 // Initialize event
80 header->Reset(0,iev);
81 rl->SetEventNumber(iev);
82 stack->Reset();
83 rl->MakeTree("K");
84
85 gener->Generate();
86/*
87 // Printing
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());
93 }
94*/
95
96 // Finish event
97 header->SetNprimary(stack->GetNprimary());
98 header->SetNtrack(stack->GetNtrack());
99 // I/O
100 //
101 stack->FinishEvent();
102 header->SetStack(stack);
103 rl->TreeE()->Fill();
104 rl->WriteKinematics("OVERWRITE");
105 } // event loop
106
107 gener->FinishRun();
9c090011 108 rl->WriteHeader("OVERWRITE");
109 gener->Write();
110 rl->Write();
111}
112//===============================================
113AliGenerator* CreateGeneratorMC(Int_t mult)
114{
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);
132 return gener;
133}
134//===============================================
135Int_t SetupOutputDirectory(){
136
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);
144
145 Char_t name[100];
146 sprintf(name, "touch run_%d", runNumber);
147 gSystem->Exec(name);
148
149 return runNumber;
150}