@@ -23,12 +23,15 @@ def main(reader_name,
2323 leg_pos = [0.74 , 0.2 , 0.90 , 0.4 ],
2424 particles = None ,
2525 eta = 0 ,
26+ dnch_deta = 100 ,
2627 rmin = None ,
2728 add_eta_label = True ,
2829 add_alice3_label = True ,
2930 save = None ,
3031 background = False ,
31- aod = None ):
32+ use_p_over_z = True ,
33+ aod = None ,
34+ study_label = "ALICE 3 study" ):
3235 gROOT .LoadMacro (reader_name )
3336 gROOT .LoadMacro ("style.C" )
3437 reader_name = reader_name .split ("." )[- 2 ]
@@ -39,10 +42,15 @@ def main(reader_name,
3942
4043 style ()
4144
42- p = {"el" : "e" , "pi" : "#pi" , "ka" : "K" , "pr" : "p" , "de" : "d" , "he3" : "^{3}He" }
45+ p = {"el" : "e" , "pi" : "#pi" , "ka" : "K" , "pr" : "p" ,
46+ "de" : "d" , "tr" : "t" , "he3" : "^{3}He" }
47+ charge = {"el" : 1 , "pi" : 1 , "ka" : 1 , "pr" : 1 ,
48+ "de" : 1 , "tr" : 1 , "he3" : 2 }
4349 p_colors = {"el" : "#e41a1c" , "pi" : "#377eb8" ,
4450 "ka" : "#4daf4a" , "pr" : "#984ea3" ,
45- "de" : "#ff7f00" , "he3" : "#a65628" }
51+ "de" : "#ff7f00" , "tr" : "#999999" ,
52+ "he3" : "#a65628" }
53+
4654 if particles is not None :
4755 to_remove = []
4856 for i in p :
@@ -87,6 +95,8 @@ def adjust_pad():
8795 leg = TLegend (* leg_pos )
8896 if add_eta_label :
8997 label = f"#eta = { int (eta )} "
98+ label += " dN_{Ch}/d#eta ="
99+ label += f" { int (dnch_deta )} "
90100 if rmin is not None :
91101 label += " R_{min} = " + rmin
92102 else :
@@ -95,10 +105,10 @@ def adjust_pad():
95105 leg .SetLineColor (0 )
96106 drawn .append (leg )
97107
98- def draw_alice3_label (x = 0.5 , y = 0.9 ):
108+ def draw_study_label (x = 0.5 , y = 0.9 ):
99109 latex = TLatex ()
100110 latex .SetTextAlign (13 )
101- drawn .append (latex .DrawLatexNDC (x , y , "ALICE 3 study" ))
111+ drawn .append (latex .DrawLatexNDC (x , y , " " . join ( study_label ) ))
102112 for i in p :
103113 c = f"{ canvas .GetName ()} _{ i } "
104114 c = TCanvas (c , c , 800 , 800 )
@@ -115,32 +125,53 @@ def draw_alice3_label(x=0.5, y=0.9):
115125 '#984ea3' , '#ff7f00' , '#ffff33' ]
116126 for k , j in enumerate (tags ):
117127 lut = f"{ lut_path } /lutCovm.{ i } .{ j } .dat"
128+ if j == "" :
129+ lut = f"{ lut_path } /lutCovm.{ i } .dat"
118130 if not path .isfile (lut ):
119131 print ("LUT file" , lut , "does not exist" )
120132 return
121- g = reader (lut , eta )
133+ g = reader (lut , eta , dnch_deta )
122134 if g .GetN () <= 0 :
123135 print ("Skipping" , g .GetName (), "because empty graph" )
124136 continue
125137 if len (g_list ) == 0 :
126138 frame .GetXaxis ().SetTitle (g .GetXaxis ().GetTitle ())
127139 frame .GetYaxis ().SetTitle (g .GetYaxis ().GetTitle ())
140+ if use_p_over_z :
141+ for j in range (g .GetN ()):
142+ if "_pt" in reader_name :
143+ g .SetPoint (j ,
144+ g .GetPointX (j )/ charge [i ],
145+ g .GetPointY (j )/ charge [i ])
146+ else :
147+ g .SetPoint (j ,
148+ g .GetPointX (j )/ charge [i ], g .GetPointY (j ))
149+ frame .GetXaxis ().SetTitle ("#it{p}_{T}/z (GeV/#it{c})" )
128150 col = TColor .GetColor (cols [len (g_list )])
129151 g .SetLineColor (col )
130152 g .SetLineStyle (1 )
131153 g .SetLineWidth (3 )
132154 g .Draw ("samel" )
133155 if aod is not None :
156+ f_aod = TFile (aod , "READ" )
134157 if "_eff" in reader_name :
135- f_aod = TFile (aod , "READ" )
136158 extra [g .GetName ()] = f_aod .Get (
137159 "qa-tracking-efficiency-kaon/pt/num" )
138160 extra [g .GetName ()].Divide (f_aod .Get ("qa-tracking-efficiency-kaon/pt/num" ),
139161 f_aod .Get ("qa-tracking-efficiency-kaon/pt/den" ), 1 , 1 , "B" )
140162 extra [g .GetName ()].Scale (100 )
141163 extra [g .GetName ()].Draw ("SAME" )
142164 extra [g .GetName ()].SetDirectory (0 )
143- f_aod .Close ()
165+ elif "_pt" in reader_name :
166+ extra [g .GetName ()] = f_aod .Get (
167+ "qa-tracking-efficiency-kaon/pt/num" )
168+ extra [g .GetName ()].Divide (f_aod .Get ("qa-tracking-efficiency-kaon/pt/num" ),
169+ f_aod .Get ("qa-tracking-efficiency-kaon/pt/den" ), 1 , 1 , "B" )
170+ extra [g .GetName ()].Scale (100 )
171+ extra [g .GetName ()].Draw ("SAME" )
172+ extra [g .GetName ()].SetDirectory (0 )
173+ f_aod .Close ()
174+
144175 print ("Drawing" , g .GetName ())
145176 if tag_name is not None and counter == 1 :
146177 leg .AddEntry (g , tag_name [k ], "l" )
@@ -152,7 +183,7 @@ def draw_alice3_label(x=0.5, y=0.9):
152183 drawn .append (latex .DrawLatexNDC (0.9 , 0.9 , p [i ]))
153184 if leg is not None :
154185 leg .Draw ()
155- draw_alice3_label (.4 , .91 )
186+ draw_study_label (.4 , .91 )
156187 gPad .Update ()
157188 canvas .cd (counter )
158189 clone = c .DrawClonePad ()
@@ -169,15 +200,7 @@ def draw_alice3_label(x=0.5, y=0.9):
169200 c .SaveAs (f"/tmp/{ c .GetName ()} .png" )
170201 gPad .Update ()
171202 counter += 1
172- if save is None :
173- canvas .SaveAs (f"/tmp/lut_{ canvas .GetName ()} .root" )
174- else :
175- fo = TFile (save , "RECREATE" )
176- fo .cd ()
177- canvas .Write ()
178- for i in drawn_graphs :
179- for j in drawn_graphs [i ]:
180- j .Write ()
203+ canvas_all_species = None
181204 if len (tags ) == 1 :
182205 canvas_all_species = TCanvas ("all_spec_" + canvas .GetName (),
183206 "all_spec_" + canvas .GetName (), 800 , 800 )
@@ -194,24 +217,40 @@ def draw_alice3_label(x=0.5, y=0.9):
194217 g_list = []
195218 for j in drawn_graphs [i ]:
196219 g_list .append (j .Clone ())
220+ g_list [- 1 ].SetName (g_list [- 1 ].GetName ()+ "_color" )
197221 g_list [- 1 ].SetLineColor (TColor .GetColor (p_colors [i ]))
198222 g_list [- 1 ].Draw ("same" )
199223 leg_all_spec .AddEntry (g_list [- 1 ], p [i ], "L" )
200224 drawn_graphs_all_spec [i ] = g_list
225+ for i in drawn_graphs_all_spec :
226+ drawn_graphs [i + "_allspec" ] = drawn_graphs_all_spec [i ]
201227 leg_all_spec .Draw ()
202228 if add_alice3_label :
203- draw_alice3_label ()
229+ draw_study_label ()
204230 latex = TLatex ()
205231 latex .SetTextAlign (13 )
206232 latex .SetTextSize (0.04 )
207233 if tag_name is not None :
208234 drawn .append (latex .DrawLatexNDC (0.5 , 0.80 , tag_name [0 ]))
209- drawn .append (latex .DrawLatexNDC (0.5 , 0.75 , f"#eta = { int (eta )} " +
210- (" R_{min} = " + rmin if rmin is not None else "" ) ))
235+ drawn .append (latex .DrawLatexNDC (0.4 , 0.82 , f"#eta = { int (eta )} "
236+ + "\n dN_{Ch}/d#eta ="
237+ + f" { int (dnch_deta )} "
238+ + ("\n R_{min} = " + rmin if rmin is not None else "" )))
211239
212240 adjust_pad ()
213241 canvas_all_species .Update ()
214242 canvas_all_species .SaveAs (f"/tmp/{ canvas_all_species .GetName ()} .png" )
243+ if save is None :
244+ canvas .SaveAs (f"/tmp/lut_{ canvas .GetName ()} .root" )
245+ else :
246+ fo = TFile (save , "RECREATE" )
247+ fo .cd ()
248+ canvas .Write ()
249+ if canvas_all_species is not None :
250+ canvas_all_species .Write ()
251+ for i in drawn_graphs :
252+ for j in drawn_graphs [i ]:
253+ j .Write ()
215254 if not background :
216255 input ("Done, press enter to continue" )
217256
@@ -249,6 +288,10 @@ def draw_alice3_label(x=0.5, y=0.9):
249288 type = float ,
250289 default = 0 ,
251290 help = "Eta position" )
291+ parser .add_argument ("--nch" , "--dndeta" ,
292+ type = float ,
293+ default = 100 ,
294+ help = "Value of the charged particle multiplicity" )
252295 parser .add_argument ("--ymin" ,
253296 type = float ,
254297 default = None ,
@@ -273,10 +316,16 @@ def draw_alice3_label(x=0.5, y=0.9):
273316 type = float , nargs = "+" ,
274317 default = [0.74 , 0.2 , 0.90 , 0.4 ],
275318 help = "Position of the legend in NDC coordinates" )
319+ parser .add_argument ("--label" , "-L" ,
320+ type = str , nargs = "+" ,
321+ default = ["ALICE 3 study" ],
322+ help = "Label to write into the label box" )
276323 parser .add_argument ("--logx" , action = "store_true" ,
277324 help = "Log x" )
278325 parser .add_argument ("--logy" , action = "store_true" ,
279326 help = "Log y" )
327+ parser .add_argument ("--pt_over_z" , action = "store_true" ,
328+ help = "Plot pt over z" )
280329 parser .add_argument ("-b" , action = "store_true" ,
281330 help = "Background mode" )
282331 args = parser .parse_args ()
@@ -296,4 +345,7 @@ def draw_alice3_label(x=0.5, y=0.9):
296345 eta = args .eta ,
297346 save = args .save ,
298347 background = args .b ,
299- aod = args .aod )
348+ aod = args .aod ,
349+ dnch_deta = args .nch ,
350+ use_p_over_z = args .pt_over_z ,
351+ study_label = args .label )
0 commit comments