]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROTrending.cxx
Typo
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTrending.cxx
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
24 #include "TMultiGraph.h"\r
25 #include "TLegend.h"\r
26 #include "TString.h"\r
27 \r
28 #include "AliLog.h"\r
29 #include "AliVZEROTrending.h"\r
30 \r
31 ClassImp(AliVZEROTrending)\r
32 \r
33 //_____________________________________________________________________________\r
34 AliVZEROTrending::AliVZEROTrending() : TH1(), fNEntries(0), fMultiGraphs(NULL)\r
35 {\r
36         // Default constructor\r
37         for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
38 }\r
39 //_____________________________________________________________________________\r
40 AliVZEROTrending::AliVZEROTrending(const char* name, const char* title) : TH1(), fNEntries(0), fMultiGraphs(NULL)\r
41 {\r
42         SetName(name);\r
43         SetTitle(title);\r
44         for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
45 }\r
46 //_____________________________________________________________________________\r
47 AliVZEROTrending::AliVZEROTrending(const AliVZEROTrending &trend) : \r
48         TH1(), fNEntries(trend.fNEntries), fMultiGraphs(NULL)\r
49 {\r
50         // Copy constructor\r
51         for(int i=0; i<8;i++) fGraphs[i] = NULL;\r
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
63 AliVZEROTrending::~AliVZEROTrending(){\r
64   if (fGraphs) {\r
65     for (Int_t i=0; i<8; ++i) delete fGraphs[i];\r
66     delete [] fGraphs;\r
67   }\r
68   delete fMultiGraphs;\r
69 }\r
70 // -----------------------------------------------------------------                    \r
71 void AliVZEROTrending::AddEntry(Double_t * data, UInt_t time)\r
72 {\r
73 \r
74         if(fNEntries<kDataSize){\r
75                 for (int i = 0; i < 8; i++)\r
76                 {\r
77                         fData[i][fNEntries] = data[i];\r
78                         fTime[fNEntries] = (double) time;\r
79                 }\r
80                 fNEntries++;    \r
81         }else{\r
82 \r
83                 for (int i = 0; i < kDataSize-1; i++){\r
84                         fTime[i] = fTime[i+1];\r
85                         for (int ich = 0; ich < 8; ich++){              \r
86                                 fData[ich][i] = fData[ich][i+1];\r
87                         }       \r
88                 }\r
89                 for (int i = 0; i < 8; i++)\r
90                 {\r
91                         fData[i][fNEntries-1] = data[i];\r
92                         fTime[fNEntries-1] = (double) time;\r
93                 }\r
94                 \r
95         }\r
96 //      printf("sizeof UInt_t Double_t %d %d\n",sizeof(UInt_t),sizeof(Double_t));\r
97 //      printf("Add Entry %d @ %f : %f %f %f %f %f %f %f %f \n",fNEntries,fTime[fNEntries-1], \r
98 //              data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);\r
99 }                       \r
100 // -----------------------------------------------------------------                    \r
101 void AliVZEROTrending::PrintEntry(UInt_t entry)\r
102 {\r
103 \r
104         if(entry>=fNEntries){\r
105                 AliError(Form("maximum entry is %d\n",fNEntries-1));\r
106         }else{\r
107                 AliInfo(Form("Entry %d @ %f : %f %f %f %f %f %f %f %f \n",entry, fTime[entry],\r
108                         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
109 \r
110         }\r
111 }                       \r
112 \r
113 // -----------------------------------------------------------------                    \r
114 void AliVZEROTrending::Draw(Option_t *option){\r
115     TString opt = option;       \r
116         fMultiGraphs = new TMultiGraph();\r
117         fMultiGraphs->SetTitle(GetTitle());\r
118         \r
119         for(int i=0;i<8;i++) {\r
120                 fGraphs[i] = new TGraph(GetNEntries(), GetTime(), GetChannel(i));\r
121                 fGraphs[i]->SetLineWidth(2);\r
122                 fGraphs[i]->SetLineColor(i<4 ? i+1 : i -3);\r
123                 fGraphs[i]->SetLineStyle(i<4 ? 1 : 2);\r
124                 fMultiGraphs->Add(fGraphs[i]);\r
125         }\r
126 \r
127         fMultiGraphs->Draw("AL");\r
128         fMultiGraphs->GetXaxis()->SetTimeDisplay(1);\r
129         fMultiGraphs->GetXaxis()->SetNdivisions(505,kFALSE);\r
130         fMultiGraphs->Draw("AL");\r
131         TLegend * legend = new TLegend(0.7,0.65,0.86,0.88);\r
132         legend->AddEntry(fGraphs[4],"V0A - Ring0","l");\r
133         legend->AddEntry(fGraphs[5],"V0A - Ring1","l");\r
134         legend->AddEntry(fGraphs[6],"V0A - Ring2","l");\r
135         legend->AddEntry(fGraphs[7],"V0A - Ring3","l");\r
136         legend->AddEntry(fGraphs[0],"V0C - Ring0","l");\r
137         legend->AddEntry(fGraphs[1],"V0C - Ring1","l");\r
138         legend->AddEntry(fGraphs[2],"V0C - Ring2","l");\r
139         legend->AddEntry(fGraphs[3],"V0C - Ring3","l");\r
140         legend->Draw();\r
141 }\r