Macro and default object for the new Pb-Pb entry.
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTrending.cxx
CommitLineData
4c68b44f 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15\r
16// \r
17// Class AliVZEROTrending\r
18// ---------------------------\r
19// \r
20// class used in QA to publish variables evolution versus time in AMORE. \r
21// These histo are the one which will be looked at by QA Shifter\r
22// \r
23#include "TGraph.h"\r
3dc953e2 24#include "TMultiGraph.h"\r
25#include "TLegend.h"\r
26#include "TString.h"\r
4c68b44f 27\r
28#include "AliLog.h"\r
29#include "AliVZEROTrending.h"\r
30\r
31ClassImp(AliVZEROTrending)\r
32\r
33//_____________________________________________________________________________\r
3dc953e2 34AliVZEROTrending::AliVZEROTrending() : TH1(), fNEntries(0), fMultiGraphs(NULL)\r
4c68b44f 35{\r
36 // Default constructor\r
3dc953e2 37 for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
127e0d90 38 for (int i = 0; i < kDataSize; i++) {\r
39 fTime[i] = 0;\r
40 for (int j = 0; j < 8; j++) {\r
41 fData[j][i] = 0;\r
42 }\r
43 }\r
4c68b44f 44}\r
45//_____________________________________________________________________________\r
3dc953e2 46AliVZEROTrending::AliVZEROTrending(const char* name, const char* title) : TH1(), fNEntries(0), fMultiGraphs(NULL)\r
4c68b44f 47{\r
48 SetName(name);\r
49 SetTitle(title);\r
3dc953e2 50 for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
127e0d90 51 for (int i = 0; i < kDataSize; i++) {\r
52 fTime[i] = 0;\r
53 for (int j = 0; j < 8; j++) {\r
54 fData[j][i] = 0;\r
55 }\r
56 }\r
4c68b44f 57}\r
58//_____________________________________________________________________________\r
59AliVZEROTrending::AliVZEROTrending(const AliVZEROTrending &trend) : \r
3dc953e2 60 TH1(), fNEntries(trend.fNEntries), fMultiGraphs(NULL)\r
4c68b44f 61{\r
62 // Copy constructor\r
3dc953e2 63 for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
4c68b44f 64 SetName(trend.GetName());\r
65 SetTitle(trend.GetTitle());\r
66 for (int i = 0; i < kDataSize; i++) {\r
67 fTime[i] = trend.fTime[i];\r
68 for (int j = 0; j < 8; j++) {\r
69 fData[j][i] = trend.fData[j][i];\r
70 }\r
71 }\r
72}\r
73\r
74//_____________________________________________________________________________\r
75AliVZEROTrending::~AliVZEROTrending(){\r
9e8cc154 76 for (Int_t i=0; i<8; ++i) delete fGraphs[i];\r
36017f8b 77 delete fMultiGraphs;\r
4c68b44f 78}\r
79// ----------------------------------------------------------------- \r
80void AliVZEROTrending::AddEntry(Double_t * data, UInt_t time)\r
81{\r
82\r
83 if(fNEntries<kDataSize){\r
84 for (int i = 0; i < 8; i++)\r
85 {\r
86 fData[i][fNEntries] = data[i];\r
87 fTime[fNEntries] = (double) time;\r
88 }\r
89 fNEntries++; \r
90 }else{\r
91\r
92 for (int i = 0; i < kDataSize-1; i++){\r
93 fTime[i] = fTime[i+1];\r
94 for (int ich = 0; ich < 8; ich++){ \r
95 fData[ich][i] = fData[ich][i+1];\r
96 } \r
97 }\r
98 for (int i = 0; i < 8; i++)\r
99 {\r
100 fData[i][fNEntries-1] = data[i];\r
101 fTime[fNEntries-1] = (double) time;\r
102 }\r
103 \r
104 }\r
3dc953e2 105// printf("sizeof UInt_t Double_t %d %d\n",sizeof(UInt_t),sizeof(Double_t));\r
106// printf("Add Entry %d @ %f : %f %f %f %f %f %f %f %f \n",fNEntries,fTime[fNEntries-1], \r
107// data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);\r
4c68b44f 108} \r
109// ----------------------------------------------------------------- \r
110void AliVZEROTrending::PrintEntry(UInt_t entry)\r
111{\r
112\r
113 if(entry>=fNEntries){\r
114 AliError(Form("maximum entry is %d\n",fNEntries-1));\r
115 }else{\r
116 AliInfo(Form("Entry %d @ %f : %f %f %f %f %f %f %f %f \n",entry, fTime[entry],\r
117 fData[0][entry],fData[1][entry],fData[2][entry],fData[3][entry],fData[4][entry],fData[5][entry],fData[6][entry],fData[7][entry]));\r
118\r
119 }\r
120} \r
3dc953e2 121\r
122// ----------------------------------------------------------------- \r
123void AliVZEROTrending::Draw(Option_t *option){\r
124 TString opt = option; \r
125 fMultiGraphs = new TMultiGraph();\r
126 fMultiGraphs->SetTitle(GetTitle());\r
127 \r
128 for(int i=0;i<8;i++) {\r
129 fGraphs[i] = new TGraph(GetNEntries(), GetTime(), GetChannel(i));\r
130 fGraphs[i]->SetLineWidth(2);\r
131 fGraphs[i]->SetLineColor(i<4 ? i+1 : i -3);\r
132 fGraphs[i]->SetLineStyle(i<4 ? 1 : 2);\r
133 fMultiGraphs->Add(fGraphs[i]);\r
134 }\r
135\r
136 fMultiGraphs->Draw("AL");\r
137 fMultiGraphs->GetXaxis()->SetTimeDisplay(1);\r
138 fMultiGraphs->GetXaxis()->SetNdivisions(505,kFALSE);\r
139 fMultiGraphs->Draw("AL");\r
140 TLegend * legend = new TLegend(0.7,0.65,0.86,0.88);\r
141 legend->AddEntry(fGraphs[4],"V0A - Ring0","l");\r
142 legend->AddEntry(fGraphs[5],"V0A - Ring1","l");\r
143 legend->AddEntry(fGraphs[6],"V0A - Ring2","l");\r
144 legend->AddEntry(fGraphs[7],"V0A - Ring3","l");\r
145 legend->AddEntry(fGraphs[0],"V0C - Ring0","l");\r
146 legend->AddEntry(fGraphs[1],"V0C - Ring1","l");\r
147 legend->AddEntry(fGraphs[2],"V0C - Ring2","l");\r
148 legend->AddEntry(fGraphs[3],"V0C - Ring3","l");\r
149 legend->Draw();\r
150}\r