Added PostData in UserCreateOutputObjects
[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
4c68b44f 38}\r
39//_____________________________________________________________________________\r
3dc953e2 40AliVZEROTrending::AliVZEROTrending(const char* name, const char* title) : TH1(), fNEntries(0), fMultiGraphs(NULL)\r
4c68b44f 41{\r
42 SetName(name);\r
43 SetTitle(title);\r
3dc953e2 44 for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
4c68b44f 45}\r
46//_____________________________________________________________________________\r
47AliVZEROTrending::AliVZEROTrending(const AliVZEROTrending &trend) : \r
3dc953e2 48 TH1(), fNEntries(trend.fNEntries), fMultiGraphs(NULL)\r
4c68b44f 49{\r
50 // Copy constructor\r
3dc953e2 51 for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
4c68b44f 52 SetName(trend.GetName());\r
53 SetTitle(trend.GetTitle());\r
54 for (int i = 0; i < kDataSize; i++) {\r
55 fTime[i] = trend.fTime[i];\r
56 for (int j = 0; j < 8; j++) {\r
57 fData[j][i] = trend.fData[j][i];\r
58 }\r
59 }\r
60}\r
61\r
62//_____________________________________________________________________________\r
63AliVZEROTrending::~AliVZEROTrending(){\r
9e8cc154 64 for (Int_t i=0; i<8; ++i) delete fGraphs[i];\r
36017f8b 65 delete fMultiGraphs;\r
4c68b44f 66}\r
67// ----------------------------------------------------------------- \r
68void AliVZEROTrending::AddEntry(Double_t * data, UInt_t time)\r
69{\r
70\r
71 if(fNEntries<kDataSize){\r
72 for (int i = 0; i < 8; i++)\r
73 {\r
74 fData[i][fNEntries] = data[i];\r
75 fTime[fNEntries] = (double) time;\r
76 }\r
77 fNEntries++; \r
78 }else{\r
79\r
80 for (int i = 0; i < kDataSize-1; i++){\r
81 fTime[i] = fTime[i+1];\r
82 for (int ich = 0; ich < 8; ich++){ \r
83 fData[ich][i] = fData[ich][i+1];\r
84 } \r
85 }\r
86 for (int i = 0; i < 8; i++)\r
87 {\r
88 fData[i][fNEntries-1] = data[i];\r
89 fTime[fNEntries-1] = (double) time;\r
90 }\r
91 \r
92 }\r
3dc953e2 93// printf("sizeof UInt_t Double_t %d %d\n",sizeof(UInt_t),sizeof(Double_t));\r
94// printf("Add Entry %d @ %f : %f %f %f %f %f %f %f %f \n",fNEntries,fTime[fNEntries-1], \r
95// data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);\r
4c68b44f 96} \r
97// ----------------------------------------------------------------- \r
98void AliVZEROTrending::PrintEntry(UInt_t entry)\r
99{\r
100\r
101 if(entry>=fNEntries){\r
102 AliError(Form("maximum entry is %d\n",fNEntries-1));\r
103 }else{\r
104 AliInfo(Form("Entry %d @ %f : %f %f %f %f %f %f %f %f \n",entry, fTime[entry],\r
105 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
106\r
107 }\r
108} \r
3dc953e2 109\r
110// ----------------------------------------------------------------- \r
111void AliVZEROTrending::Draw(Option_t *option){\r
112 TString opt = option; \r
113 fMultiGraphs = new TMultiGraph();\r
114 fMultiGraphs->SetTitle(GetTitle());\r
115 \r
116 for(int i=0;i<8;i++) {\r
117 fGraphs[i] = new TGraph(GetNEntries(), GetTime(), GetChannel(i));\r
118 fGraphs[i]->SetLineWidth(2);\r
119 fGraphs[i]->SetLineColor(i<4 ? i+1 : i -3);\r
120 fGraphs[i]->SetLineStyle(i<4 ? 1 : 2);\r
121 fMultiGraphs->Add(fGraphs[i]);\r
122 }\r
123\r
124 fMultiGraphs->Draw("AL");\r
125 fMultiGraphs->GetXaxis()->SetTimeDisplay(1);\r
126 fMultiGraphs->GetXaxis()->SetNdivisions(505,kFALSE);\r
127 fMultiGraphs->Draw("AL");\r
128 TLegend * legend = new TLegend(0.7,0.65,0.86,0.88);\r
129 legend->AddEntry(fGraphs[4],"V0A - Ring0","l");\r
130 legend->AddEntry(fGraphs[5],"V0A - Ring1","l");\r
131 legend->AddEntry(fGraphs[6],"V0A - Ring2","l");\r
132 legend->AddEntry(fGraphs[7],"V0A - Ring3","l");\r
133 legend->AddEntry(fGraphs[0],"V0C - Ring0","l");\r
134 legend->AddEntry(fGraphs[1],"V0C - Ring1","l");\r
135 legend->AddEntry(fGraphs[2],"V0C - Ring2","l");\r
136 legend->AddEntry(fGraphs[3],"V0C - Ring3","l");\r
137 legend->Draw();\r
138}\r