]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/AliHLTGlobalVertexerHistoComponent.cxx
update of histograms
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalVertexerHistoComponent.cxx
1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project        * 
3 //* ALICE Experiment at CERN, All rights reserved.                         *
4 //*                                                                        *
5 //* Primary Authors: Timur.Pocheptsov@cern.ch                              *
6 //*                  for The ALICE HLT Project.                            *
7 //*                                                                        *
8 //* Permission to use, copy, modify and distribute this software and its   *
9 //* documentation strictly for non-commercial purposes is hereby granted   *
10 //* without fee, provided that the above copyright notice appears in all   *
11 //* copies and that both the copyright notice and this permission notice   *
12 //* appear in the supporting documentation. The authors make no claims     *
13 //* about the suitability of this software for any purpose. It is          *
14 //* provided "as is" without express or implied warranty.                  *
15 //**************************************************************************
16
17 /** @file   AliHLTGlobalVertexerComponent.h
18     @author Timur Pocheptsov
19     @brief  Component for monitor primary vertex
20 */
21
22 #include "AliESDVertex.h"
23 #include "AliESDEvent.h"
24
25 #include "AliHLTGlobalVertexerHistoComponent.h"
26
27 ClassImp(AliHLTGlobalVertexerHistoComponent)
28
29 AliHLTGlobalVertexerHistoComponent::AliHLTGlobalVertexerHistoComponent()
30   : 
31   fPrimaryXY(),
32   fPrimaryX(),
33   fPrimaryY(),
34   fPrimaryZ(),
35   fSPDVertexXY(),
36   fSPDVertexX(),
37   fSPDVertexY(),
38   fSPDVertexZ()
39 {
40   //Default ctor.
41   fPrimaryXY.SetName("primVertexXY");
42   fPrimaryXY.SetTitle("HLT: Primary vertex distribution in XY");
43   fPrimaryXY.SetMarkerStyle(8);
44   fPrimaryXY.SetMarkerSize(0.4);
45   fPrimaryXY.SetYTitle("Y [cm]");
46   fPrimaryXY.SetXTitle("X [cm]");
47   //fPrimaryXY.SetStats(0);
48   //fPrimaryXY.SetBit(TH1::kCanRebin);
49
50   fPrimaryX.SetName("primVertexX");
51   fPrimaryX.SetTitle("HLT: Primary vertex distribution in X");
52   fPrimaryX.SetMarkerStyle(8);
53   fPrimaryX.SetMarkerSize(0.4);
54   fPrimaryX.SetXTitle("X [cm]");
55   //fPrimaryX.SetStats(0);
56   //fPrimaryX.SetBit(TH1::kCanRebin);
57
58   fPrimaryY.SetName("primVertexY");
59   fPrimaryY.SetTitle("HLT: Primary vertex distribution in Y");
60   fPrimaryY.SetMarkerStyle(8);
61   fPrimaryY.SetMarkerSize(0.4);
62   fPrimaryY.SetXTitle("Y [cm]");
63   //fPrimaryY.SetStats(0);
64   //fPrimaryX.SetBit(TH1::kCanRebin);
65
66   fPrimaryZ.SetName("primVertexZ");
67   fPrimaryZ.SetTitle("HLT: Primary vertex distribution in Z");
68   fPrimaryZ.SetMarkerStyle(8);
69   fPrimaryZ.SetMarkerSize(0.4);
70   fPrimaryZ.SetXTitle("Z [cm]");
71   //fPrimaryZ.SetStats(0);
72   //fPrimaryX.SetBit(TH1::kCanRebin);
73
74
75   fSPDVertexXY.SetName("spdVertexXY");
76   fSPDVertexXY.SetTitle("HLT: SPD vertex distribution in XY");
77   fSPDVertexXY.SetMarkerStyle(8);
78   fSPDVertexXY.SetMarkerSize(0.4);
79   fSPDVertexXY.SetYTitle("Y [cm]");
80   fSPDVertexXY.SetXTitle("X [cm]");
81   fSPDVertexXY.SetStats(0);
82   //fSPDVertexXY.SetBit(TH1::kCanRebin);
83
84   fSPDVertexX.SetName("spdVertexX");
85   fSPDVertexX.SetTitle("HLT: SPD vertex distribution in X");
86   fSPDVertexX.SetMarkerStyle(8);
87   fSPDVertexX.SetMarkerSize(0.4);
88   fSPDVertexX.SetXTitle("X [cm]");
89   //fSPDVertexX.SetStats(0);
90   //fSPDVertexX.SetBit(TH1::kCanRebin);
91
92   fSPDVertexY.SetName("spdVertexY");
93   fSPDVertexY.SetTitle("HLT: SPD vertex distribution in Y");
94   fSPDVertexY.SetMarkerStyle(8);
95   fSPDVertexY.SetMarkerSize(0.4);
96   fSPDVertexY.SetXTitle("Y [cm]");
97   //fSPDVertexY.SetStats(0);
98   //fSPDVertexY.SetBit(TH1::kCanRebin);
99  
100   fSPDVertexZ.SetName("spdVertexZ");
101   fSPDVertexZ.SetTitle("HLT: SPD vertex distribution in Z");
102   fSPDVertexZ.SetMarkerStyle(8);
103   fSPDVertexZ.SetMarkerSize(0.4);
104   fSPDVertexZ.SetXTitle("Z [cm]");
105   //fSPDVertexZ.SetStats(0);
106   //fSPDVertexZ.SetBit(TH1::kCanRebin);
107 }
108
109 const char* AliHLTGlobalVertexerHistoComponent::GetComponentID()
110 {
111   //Unique component id.
112   return "GlobalVertexerHisto";
113 }
114
115 void AliHLTGlobalVertexerHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
116 {
117   //
118   list.clear();
119   list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
120   list.push_back(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS );
121 }
122
123
124
125 AliHLTComponentDataType AliHLTGlobalVertexerHistoComponent::GetOutputDataType()
126 {
127   // see header file for class documentation
128   return kAliHLTMultipleDataType;
129 }
130
131 int AliHLTGlobalVertexerHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
132
133 {
134   // see header file for class documentation
135   tgtList.clear();
136   tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginOut);
137   tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginITSSPD);
138  return tgtList.size();
139 }
140
141
142 void AliHLTGlobalVertexerHistoComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
143 {
144   //8000 is a temporary number. Find the way to
145   //estimate 3 serialized TH2F. 
146   constBase = GetOutputDataSize();
147   inputMultiplier = 1.;
148 }
149
150 AliHLTComponent* AliHLTGlobalVertexerHistoComponent::Spawn()
151 {
152   //Should be const, I think, but it's not.
153   return new AliHLTGlobalVertexerHistoComponent;
154 }
155
156 int AliHLTGlobalVertexerHistoComponent::DoInit(int /*argc*/, const char** /*argv*/)
157 {
158   //Clear all bin contents and statistics.
159   fPrimaryXY.Reset();
160   fPrimaryX.Reset();
161   fPrimaryY.Reset();
162   fPrimaryZ.Reset();
163   fSPDVertexXY.Reset();
164   fSPDVertexX.Reset();
165   fSPDVertexY.Reset();
166   fSPDVertexZ.Reset();
167   //Set bin numbers and axis ranges.
168   fPrimaryXY.SetBins(1000,  -1.,  1., 1000, -1., 1.);
169   fPrimaryX.SetBins( 1000, -1., 1.);
170   fPrimaryY.SetBins( 1000, -1., 1.);
171   fPrimaryZ.SetBins( 1000, -30., 30.); 
172   fSPDVertexXY.SetBins(1000,  -1.,  1., 1000, -1., 1.);
173   fSPDVertexX.SetBins(1000,  -1.,  1.);
174   fSPDVertexY.SetBins(1000,  -1.,  1.);
175   fSPDVertexZ.SetBins(1000,  -30.,  30.);
176
177   return 0;
178 }
179
180 int AliHLTGlobalVertexerHistoComponent::DoDeinit()
181 {
182   //Nothing to delete or "do de init" yet.
183   return 0;
184 }
185
186 int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
187                                                 const AliHLTComponentBlockData* /*blocks*/,
188                                                 AliHLTComponentTriggerData& /*trigData*/,
189                                                 AliHLTUInt8_t* /*outputPtr*/,
190                                                 AliHLTUInt32_t& size,
191                                                 AliHLTComponentBlockDataList& /*outputBlocks*/)
192 {
193   //Fill histogramms.
194   if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR))
195     return 0;
196
197   if (GetOutputDataSize() > size) {
198     Logging(kHLTLogFatal, "HLT::AliHLTGlobalVertexerHistoComponent::DoEvent", "Too much data", 
199             "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
200             GetOutputDataSize(), size);
201     return -ENOSPC;
202   }
203
204   int iResult = 0;
205
206   bool wasITS = 0;
207   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
208     if( AliESDVertex *vertex = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ) ){
209       if( vertex && vertex->GetNContributors() >= 5 ){
210         fSPDVertexXY.Fill(vertex->GetX(), vertex->GetY());
211         fSPDVertexX.Fill(vertex->GetX() );
212         fSPDVertexY.Fill(vertex->GetY() );
213         fSPDVertexZ.Fill(vertex->GetZ() );
214         wasITS = 1;
215       }
216     } else {
217       HLTError("ITS SPD vertex object is corrupted");
218       iResult = -EINVAL;    
219     }
220   }
221
222   for (const TObject* iter = GetFirstInputObject(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut); iter; iter = GetNextInputObject() ) {
223     if (AliESDEvent* event = dynamic_cast<AliESDEvent*>((TObject*)iter)) {
224       event->GetStdContent();
225       const AliESDVertex* vertex = event->GetPrimaryVertexTracks();
226       if (vertex && vertex->GetNContributors() >= 5) {
227         fPrimaryXY.Fill(vertex->GetX(), vertex->GetY());
228         fPrimaryX.Fill(vertex->GetX());
229         fPrimaryY.Fill(vertex->GetY());
230         fPrimaryZ.Fill(vertex->GetZ());
231       }
232       if( !wasITS ){
233         vertex = event->GetPrimaryVertexSPD();
234         if( vertex && vertex->GetNContributors() >= 3 ){
235           fSPDVertexXY.Fill(vertex->GetX(), vertex->GetY());
236           fSPDVertexX.Fill(vertex->GetX() );
237           fSPDVertexY.Fill(vertex->GetY() );
238           fSPDVertexZ.Fill(vertex->GetZ() );      
239         }
240       }
241     } else {
242       HLTError("ESD event object is corrupted");
243       iResult = -EINVAL;    
244     }
245   }
246  
247   PushBack(&fPrimaryXY, kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
248   PushBack(&fPrimaryZ, kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
249   PushBack(&fPrimaryX, kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
250   PushBack(&fPrimaryY, kAliHLTDataTypeHistogram | kAliHLTDataOriginOut, 0);
251
252   PushBack(&fSPDVertexXY, kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
253   PushBack(&fSPDVertexZ, kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
254   PushBack(&fSPDVertexX, kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
255   PushBack(&fSPDVertexY, kAliHLTDataTypeHistogram | kAliHLTDataOriginITSSPD, 0);
256   
257   return iResult; 
258 }
259
260 int AliHLTGlobalVertexerHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
261 {
262   //Do nothing at the moment, but at least log (base class version).
263   return AliHLTComponent::Reconfigure(cdbEntry, chainId);
264 }
265
266 unsigned long AliHLTGlobalVertexerHistoComponent::GetOutputDataSize()const
267 {
268   //8000 is a temporary number. Find the way to
269   //estimate serialized TH2F. 
270   return 20000;
271 }