StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RunSimulator.C
1 /*
2  So, you've downloaded the StRoot/StPicoEvent and StRoot/StEpdUtil packages onto your laptop, eh? Great!!
3  Now you've got to do a few more things, to make the code useable
4 
5  1. one quick edit on StRoot/StPicoEvent/StPicoEpdHit.cxx, right at the bottom:
6  replace LOG_INFO << "EPD hit id: " << mId << " QT data: " << mQTdata << " nMIP: " << mnMIP << endm;
7  with std::cout << "EPD hit id: " << mId << " QT data: " << mQTdata << " nMIP: " << mnMIP << std::endl;
8 
9  and at the top:
10  replace #include "StPicoMessMgr.h
11  with #include <iostream>
12 
13  2. a quick edit to StRoot/StEpdUtil/StEpdFastSim/StEpdFastSim.cxx at the very top.
14  You will see an //#include statement to un-comment. Basically, you need to point directly to StPicoEpdHit.h file
15 
16  3. Make a similar edit to StRoot/StEpdUtil/StEpdEpFinder.cxx
17 
18  4. go to StRoot/StPicoEvent
19  root
20  > .L StPicoEpdHit.cxx++
21  > .q
22 
23  5. go to StRoot/StEpdUtil
24  root
25  > .L StEpdGeom.cxx++
26  > .L StEpdEpInfo.cxx++
27  > .L StEpdEpFinder.cxx++ <-- this one will give you lots of warnings about possibly-undefined variables. Ignore them.
28  > .q
29 
30  6. go to StRoot/StEpdUtil/StEpdFastSim
31  root
32  > .L ../StEpdGeom_cxx.so
33  > .L StEpdTrivialEventGenerator.cxx++
34  > .L StEpdFastSim.cxx++
35 
36  Now, steps 4-6 above make the .so files. These files are loaded (see below) with R__LOAD_LIBRARY commands.
37  That's how Root 6 does it. In Root 5, they use the gSystem->Load() commands, and you'll just have to figure
38  it out. (Or, get with the times and install root6.)
39 
40  And, if you want to run it on RCF rather than at home, that's fine, too. You'll just need to remove the
41  R__LOAD_LIBRARY statements and maybe screw around a bit, but it shouldn't be too hard.
42 
43  - Mike Lisa lisa.1@osu.edu - 15feb2020 / updated 20march2020
44 */
45 
46 R__LOAD_LIBRARY(./StEpdTrivialEventGenerator_cxx.so)
47 R__LOAD_LIBRARY(../StEpdGeom_cxx.so)
48 R__LOAD_LIBRARY(../../StPicoEvent/StPicoEpdHit_cxx.so)
49 R__LOAD_LIBRARY(./StEpdFastSim_cxx.so)
50 
51 void RunSimulator(){
52 
53  StEpdGeom* eGeom = new StEpdGeom(); // handy later
54 
55 
56  // ================================ Step 1 ==============================
57  /* =================================================================
58  first, generate the particles using the "Trivial Event Generator"
59  feel free to replace this with something using UrQMD or AMPT!!!
60  ================================================================= */
61  // The Trivial Event Generator takes as input some histograms that
62  // define the dNdeta, v1 and v2 which the program samples
63  double etaMin(2.0),etaMax(5.2);
64  int nbins(100);
65  double dNdetaValue(500.0),v1Value(0.3),v2Value(0.1);
66  TH1D* dNdeta = new TH1D("dNdeta","dNdeta",nbins,-etaMax,etaMax);
67  TH1D* v1 = new TH1D("v1","v1",nbins,-etaMax,etaMax);
68  TH1D* v2 = new TH1D("v2","v2",nbins,-etaMax,etaMax);
69  for (int i=1; i<=nbins; i++){
70  double eta = dNdeta->GetXaxis()->GetBinCenter(i);
71  if (fabs(eta)>etaMin){
72  dNdeta->SetBinContent(i,dNdetaValue);
73  double v1Here = (eta<0.0)?-v1Value:v1Value;
74  v1->SetBinContent(i,v1Here);
75  v2->SetBinContent(i,v2Value);
76  }
77  }
78  // Having now defined the event characteristics, make the generator
80 
81  // ================================ Step 2 ===============================
82  /* Loop over events
83  In this process, the parts are:
84  a. Generate an event with an event generator (Trivial, UrQMD, whatever). Format is a TClonesArray of momentum TVector3 objects
85  b. If you want the events randomly rotated, or whatever, do it yourself. That way you control stuff and you have the event plane angle.
86  c. Hand this TClonesArray(TVector3) to the StEpdFastSimulator, which will produce a TClonesArray of StPicoEpdHit objects, just like the real data.
87  In this step, you have to tell the simulator where is the primary vertex. You, the user, control this. Again, this way you know, and you can do analysis or whatever.
88  d. Now do your regular EPD analysis! You can hand this TClonesArray(StPicoHit) to the StEpdEpFinder or whatever you want
89 
90  As usual, the code below is longer than strictly necessary, since I put in comments and fill histograms, etc.
91  Right here is what the code looks like, pared down:
92 -----
93  TRandom3* ran = new TRandom3;
94  int Nevents=500;
95  StEpdFastSim* efs = new StEpdFastSim(0.2);
96  for (int iev=0; iev<Nevents; iev++){
97  TClonesArray* momenta = eg->Momenta();
98  double RPangle = ran->Uniform(2.0*TMath::Pi());
99  for (int trk=0; trk<momenta->GetEntries(); trk++){
100  TVector3* mom = (TVector3*)momenta->At(trk);
101  mom->RotateZ(RPangle);}
102  TVector3 PrimaryVertex(0.0,0.0,0.0);
103  TClonesArray* picoHits = efs->GetPicoHits(momenta,PrimaryVertex);
104  // now you do something with this data
105  }
106 -----
107  */
108 
109 
110  // the following histograms are just standard for looking at stuff. In principle they are optional
111  TH2D* EtaPhi = new TH2D("EtaPhi","Eta-Phi from generator",50,-5.5,5.5,50,-4.0,4.0);
112  TH1D* nmip = new TH1D("Nmip","Nmip of all tiles",50,0.0,10.0);
113  TH2D* EastWheel = new TH2D("East","East EPD",100,-100.0,100.0,100,-100.0,100.0);
114  TH2D* WestWheel = new TH2D("West","West EPD",100,-100.0,100.0,100,-100.0,100.0);
115  TH2D* EastWheelADC = new TH2D("EastADC","East EPD - ADC weighted",100,-100.0,100.0,100,-100.0,100.0);
116  TH2D* WestWheelADC = new TH2D("WestADC","West EPD - ADC weighted",100,-100.0,100.0,100,-100.0,100.0);
117  // end of optional histograms
118 
119  TRandom3* ran = new TRandom3;
120  int Nevents=500;
121  StEpdFastSim* efs = new StEpdFastSim(0.2); // the argument is WID/MPV for the Landau energy loss. Use 0.2 for the EPD
122  for (int iev=0; iev<Nevents; iev++){
123  // a. Generate event
124  TClonesArray* momenta = eg->Momenta();
125  if (momenta==0) cout << "No event!!\n";
126  for (int itrk=0; itrk<momenta->GetEntries(); itrk++){TVector3* mom = (TVector3*)momenta->At(itrk); EtaPhi->Fill(mom->Eta(),mom->Phi());} // just a histogram
127  // b. Randomly rotate (optional)
128  /*
129  double RPangle = ran->Uniform(2.0*TMath::Pi());
130  for (int trk=0; trk<momenta->GetEntries(); trk++){
131  TVector3* mom = (TVector3*)momenta->At(trk);
132  mom->RotateZ(RPangle);
133  }
134  */
135  // c. Run EPD Fast simulator
136  TVector3 PrimaryVertex(0.0,0.0,0.0);
137  TClonesArray* picoHits = efs->GetPicoHits(momenta,PrimaryVertex); // and that's it! you've got the TClonesArray of StPicoHit objects
138 
139  /* fill some diagnostic plots */
140  for (int i=0; i<picoHits->GetEntries(); i++){ // quick plots
141  StPicoEpdHit* ph = (StPicoEpdHit*)picoHits->At(i);
142  nmip->Fill(ph->nMIP());
143  TVector3 point = eGeom->RandomPointOnTile(ph->id());
144  if (ph->id()<0){ // East
145  EastWheel->Fill(point.X(),point.Y());
146  EastWheelADC->Fill(point.X(),point.Y(),ph->nMIP());
147  }
148  else{ // West
149  WestWheel->Fill(point.X(),point.Y());
150  WestWheelADC->Fill(point.X(),point.Y(),ph->nMIP());
151  }
152  }
153  cout << "Event " << iev << " has " << momenta->GetEntries() << " particles,"
154  << " and the StPicoEpdHit list has " << picoHits->GetEntries() << "entries\n";
155 
156  // d. Now do your analysis. What, you want me to do THAT for you, too?
157 
158  }
159 
160  TCanvas* tc = new TCanvas("diagnostics","diag",700,1200);
161  tc->Divide(2,3);
162  tc->cd(1); EtaPhi->Draw("colz");
163  tc->cd(2); nmip->Draw();
164  tc->cd(3)->SetLogz(); EastWheel->Draw("colz");
165  tc->cd(4)->SetLogz(); WestWheel->Draw("colz");
166  tc->cd(5)->SetLogz(); EastWheelADC->Draw("colz");
167  tc->cd(6)->SetLogz(); WestWheelADC->Draw("colz");
168 }
169 
170 
Short_t id() const
Definition: StPicoEpdHit.h:90
Stores global information about the event.
Definition: StPicoEvent.h:24
Float_t nMIP() const
Definition: StPicoEpdHit.h:104