]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/sim/Simulate.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / sim / Simulate.C
1 /**
2  * @file   Simulate.C
3  * @author Christian Holm Christensen <cholm@nbi.dk>
4  * @date   Wed Oct 15 13:28:09 2014
5  * 
6  * @brief  Steering script for the simulation 
7  */
8 Bool_t RunLego(AliSimulation& steer)
9 {
10   TString runType = gSystem->Getenv("CONFIG_RUN_TYPE");
11   runType.ToUpper();
12   if (!runType.BeginsWith("LEGO")) return false;
13
14   TString v(runType);
15   v.ToUpper();
16   v.ReplaceAll("LEGO", "");
17   Info("Setup", "Making Lego event generator (variant: %s)", v.Data());
18
19   AliLegoGenerator* gener = 0;
20   if (v.BeginsWith("X") || v.BeginsWith("Y") || v.BeginsWith("Z")) {
21       const char* c[] = { v(0), '\0' };
22       gener = new AliLegoGeneratorXYZ(c);
23   }
24   else if (v.BeginsWith("PHIZ")) {
25     gener = new AliLegoGeneratorPhiZ();
26   }
27   else if (v.BeginsWith("ETA")) {
28     gener = new AliLegoGeneratorEta();
29   }
30   else {
31     gener = new AliLegoGenerator();
32   }
33   
34   // XYZ varies origin of the particles in two dimensions:
35   //  X:  o=(0,t1,t2), p=(1,0,0)
36   //  Y:  o=(t1,0,t2), p=(0,1,0)
37   //  Z:  o=(t1,t2,0), p=(0,0,1)
38   // PhiZ varies the momentum in two dimensions
39   //  o=(0,0,t1) p=(cos(t2),sin(t2),0)
40   // Eta varies momentum in two dimensions
41   //  phi=t1
42   //  theta=2*atan(exp(-t2))
43   //  o=(0,0,0) p=(cos(phi)*sin(theta),sin(phi)*cos(theta),cos(theta))
44   // Base varies in two dimensions
45   //  phi=t1
46   //  theta=t2
47   //  o=(0,0,0) p=(cos(phi)*sin(theta),sin(phi)*cos(theta),cos(theta))
48   const char* cfg = "Config.C";
49   Bool_t ret = false;
50   Double_t rMin = 0;
51   Double_t rMax = 32; // 430;
52   Double_t zMax = 400; // 10000;
53   if (v.BeginsWith("X") || v.BeginsWith("Y"))
54     ret = steer.RunLego(cfg,
55                          10,-2,2,      // Y, X
56                          10,-10,10,    // Z
57                          rMin, rMax, zMax, gener);
58   else if (v.BeginsWith("Z"))
59     ret = steer.RunLego(cfg,
60                          10,-2,2,      // X
61                          10,-2,2,      // Y
62                          rMin, rMax, zMax, gener);
63   else if (v.BeginsWith("PHIZ"))
64     ret = steer.RunLego(cfg,
65                          10,-10,10, // Z
66                          360,0,360, // phi
67                          rMin, rMax, zMax, gener);
68   else if (v.BeginsWith("ETA")) {
69     Double_t aEta = 6;
70     Double_t dEta = (6.--4.)/200;
71     ret = steer.RunLego(cfg,
72                         360,0,360, // phi
73                         2*aEta/dEta,-aEta,+aEta, // Eta
74                         rMin, rMax, zMax, gener);
75   }
76   else 
77     ret = steer.RunLego(cfg);
78   if (!ret)
79     Warning("RunLego", "Failed to do lego run");
80   return true;
81 }
82
83 /** 
84  * Run the simulation 
85  * 
86  * @param nev Number of events per job
87  * @param run Run number to simulate 
88  */
89 void Simulate(Int_t nev=1, UInt_t run=0) 
90 {
91   // -----------------------------------------------------------------
92   // 
93   // - Get GRP parameters.  Defines global "grp" as a pointer to GRPData
94   // - Load base class definitions in BaseConfig.C
95   // - Get which detectors are turned on in "detCfg". 
96   // - Create the OCDB configuration object "ocdbCfg"
97   // 
98   gROOT->Macro(Form("GRP.C(%d)", run));
99   gROOT->Macro("BaseConfig.C");
100   gROOT->Macro("DetConfig.C"); 
101   gROOT->Macro("OCDBConfig.C"); 
102
103   // --- Get GRP to deduce collision system --------------------------
104   Bool_t         isAA  = grp->IsAA();
105   Bool_t         isPP  = grp->IsPP();
106   Bool_t         is10h = grp->period.EqualTo("LHC10h");
107
108   // -----------------------------------------------------------------
109   // 
110   // Basic setup 
111   //
112   AliSimulation steer; 
113   TString sDigits, fromHits;
114   detCfg->GetSDigitString(sDigits);
115   detCfg->GetHits2DigitsString(fromHits);
116   steer.SetMakeSDigits(sDigits);
117   steer.SetMakeDigitsFromHits(fromHits);
118
119   // -----------------------------------------------------------------
120   // 
121   // Vertex, Mag.field, and trigger from OCDB
122   //
123   steer.SetTriggerConfig(!isAA ? "p-p" : "Pb-Pb");//Replace with "ocdb"
124   steer.UseMagFieldFromGRP();
125   steer.UseVertexFromCDB();
126
127   // -----------------------------------------------------------------
128   //
129   // OCDB and specific storages 
130   // 
131   AliCDBManager* cdb = AliCDBManager::Instance();
132   cdb->SetRun(grp->run);
133   cdb->SetDefaultStorageFromRun(grp->run);
134   cdb->SetRun(-1);
135   ocdbCfg->Init(true);
136   steer.SetRunNumber(grp->run);
137   
138   // -----------------------------------------------------------------
139   // 
140   // The rest - disable QA and HLT (memory heavy) for PbPb
141   //
142   if (isAA) steer.SetRunQA(":");
143   if (is10h) steer.SetRunHLT("");
144   
145   TStopwatch timer;
146   timer.Start();
147   // Check first if we're doing a Lego run, and if not,
148   // do a normal run
149   if (!RunLego(steer)) steer.Run(nev);
150   timer.Stop();
151   timer.Print();
152 }
153 // 
154 // EOF
155 //