]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/AliHLTGlobalVertexerHistoComponent.cxx
VertexerHistoComponent added.
[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   fPrimaryZX(),
33   fPrimaryZY(),
34   fSPDVertexXY(),
35   fSPDVertexX(),
36   fSPDVertexY(),
37   fSPDVertexZ()
38 {
39   //Default ctor.
40   fPrimaryXY.SetName("primVertexXY");
41   fPrimaryXY.SetTitle("HLT: Primary vertex distribution in XY");
42   fPrimaryXY.SetMarkerStyle(8);
43   fPrimaryXY.SetMarkerSize(0.4);
44   fPrimaryXY.SetYTitle("Y [cm]");
45   fPrimaryXY.SetXTitle("X [cm]");
46   fPrimaryXY.SetStats(0);
47   fPrimaryXY.SetBit(TH1::kCanRebin);
48
49   fPrimaryZX.SetName("primVertexZX");
50   fPrimaryZX.SetTitle("HLT: Primary vertex distribution in ZX");
51   fPrimaryZX.SetMarkerStyle(8);
52   fPrimaryZX.SetMarkerSize(0.4);
53   fPrimaryZX.SetYTitle("X [cm]");
54   fPrimaryZX.SetXTitle("Z [cm]");
55   fPrimaryZX.SetStats(0);
56   fPrimaryZX.SetBit(TH1::kCanRebin);
57
58   fPrimaryZY.SetName("primVertexZY");
59   fPrimaryZY.SetTitle("HLT: Primary vertex distribution in ZY");
60   fPrimaryZY.SetMarkerStyle(8);
61   fPrimaryZY.SetMarkerSize(0.4);
62   fPrimaryZY.SetYTitle("Y [cm]");
63   fPrimaryZY.SetXTitle("Z [cm]");
64   fPrimaryZY.SetStats(0);
65   fPrimaryZY.SetBit(TH1::kCanRebin);
66
67
68   fSPDVertexXY.SetName("spdVertexXY");
69   fSPDVertexXY.SetTitle("HLT: SPDVertex vertex distribution in XY");
70   fSPDVertexXY.SetMarkerStyle(8);
71   fSPDVertexXY.SetMarkerSize(0.4);
72   fSPDVertexXY.SetYTitle("Y [cm]");
73   fSPDVertexXY.SetXTitle("X [cm]");
74   fSPDVertexXY.SetStats(0);
75   fSPDVertexXY.SetBit(TH1::kCanRebin);
76
77   fSPDVertexX.SetName("spdVertexX");
78   fSPDVertexX.SetTitle("HLT: SPDVertex vertex distribution in X");
79   fSPDVertexX.SetMarkerStyle(8);
80   fSPDVertexX.SetMarkerSize(0.4);
81   fSPDVertexX.SetXTitle("X [cm]");
82   fSPDVertexX.SetStats(0);
83   fSPDVertexX.SetBit(TH1::kCanRebin);
84
85   fSPDVertexY.SetName("spdVertexY");
86   fSPDVertexY.SetTitle("HLT: SPDVertex vertex distribution in Y");
87   fSPDVertexY.SetMarkerStyle(8);
88   fSPDVertexY.SetMarkerSize(0.4);
89   fSPDVertexY.SetXTitle("Y [cm]");
90   fSPDVertexY.SetStats(0);
91   fSPDVertexY.SetBit(TH1::kCanRebin);
92  
93   fSPDVertexZ.SetName("spdVertexZ");
94   fSPDVertexZ.SetTitle("HLT: SPDVertex vertex distribution in Z");
95   fSPDVertexZ.SetMarkerStyle(8);
96   fSPDVertexZ.SetMarkerSize(0.4);
97   fSPDVertexZ.SetXTitle("Z [cm]");
98   fSPDVertexZ.SetStats(0);
99   fSPDVertexZ.SetBit(TH1::kCanRebin);
100 }
101
102 const char* AliHLTGlobalVertexerHistoComponent::GetComponentID()
103 {
104   //Unique component id.
105   return "GlobalVertexerHisto";
106 }
107
108 void AliHLTGlobalVertexerHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
109 {
110   //
111   list.clear();
112   list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
113   list.push_back(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS );
114 }
115
116
117 AliHLTComponentDataType AliHLTGlobalVertexerHistoComponent::GetOutputDataType()
118 {
119   //Output are histogramms.
120   return kAliHLTDataTypeHistogram /*| kAliHLTDataOriginOut*/;
121 }
122
123 void AliHLTGlobalVertexerHistoComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
124 {
125   //8000 is a temporary number. Find the way to
126   //estimate 3 serialized TH2F. 
127   constBase = GetOutputDataSize();
128   inputMultiplier = 1.;
129 }
130
131 AliHLTComponent* AliHLTGlobalVertexerHistoComponent::Spawn()
132 {
133   //Should be const, I think, but it's not.
134   return new AliHLTGlobalVertexerHistoComponent;
135 }
136
137 int AliHLTGlobalVertexerHistoComponent::DoInit(int /*argc*/, const char** /*argv*/)
138 {
139   //Clear all bin contents and statistics.
140   fPrimaryXY.Reset();
141   fPrimaryZX.Reset();
142   fPrimaryZY.Reset();
143   fSPDVertexXY.Reset();
144   fSPDVertexX.Reset();
145   fSPDVertexY.Reset();
146   fSPDVertexZ.Reset();
147   //Set bin numbers and axis ranges.
148   fPrimaryXY.SetBins(60,  -2.,  2., 60, -2., 2.);
149   fPrimaryZX.SetBins(60, -15., 15., 60, -2., 2.);
150   fPrimaryZY.SetBins(60, -10., 10., 60, -2., 2.);
151   fSPDVertexXY.SetBins(100,  -2.,  2., 100, -2., 2.);
152   fSPDVertexX.SetBins(100,  -2.,  2.);
153   fSPDVertexY.SetBins(100,  -2.,  2.);
154   fSPDVertexZ.SetBins(100,  -15.,  15.);
155
156   return 0;
157 }
158
159 int AliHLTGlobalVertexerHistoComponent::DoDeinit()
160 {
161   //Nothing to delete or "do de init" yet.
162   return 0;
163 }
164
165 int AliHLTGlobalVertexerHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
166                                                 const AliHLTComponentBlockData* /*blocks*/,
167                                                 AliHLTComponentTriggerData& /*trigData*/,
168                                                 AliHLTUInt8_t* /*outputPtr*/,
169                                                 AliHLTUInt32_t& size,
170                                                 AliHLTComponentBlockDataList& /*outputBlocks*/)
171 {
172   //Fill histogramms.
173   if (GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR))
174     return 0;
175
176   if (GetOutputDataSize() > size) {
177     Logging(kHLTLogFatal, "HLT::AliHLTGlobalVertexerHistoComponent::DoEvent", "Too much data", 
178             "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
179             GetOutputDataSize(), size);
180     return -ENOSPC;
181   }
182
183   int iResult = 0;
184
185   bool wasITS = 0;
186   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
187     if( AliESDVertex *vertex = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ) ){
188       if( vertex && vertex->GetNContributors() >= 3 ){
189         fSPDVertexXY.Fill(vertex->GetX(), vertex->GetY());
190         fSPDVertexX.Fill(vertex->GetX() );
191         fSPDVertexY.Fill(vertex->GetY() );
192         fSPDVertexZ.Fill(vertex->GetZ() );
193         wasITS = 1;
194       }
195     } else {
196       HLTError("ITS SPD vertex object is corrupted");
197       iResult = -EINVAL;    
198     }
199   }
200
201   for (const TObject* iter = GetFirstInputObject(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut); iter; iter = GetNextInputObject() ) {
202     if (AliESDEvent* event = dynamic_cast<AliESDEvent*>((TObject*)iter)) {
203       event->GetStdContent();
204       const AliESDVertex* vertex = event->GetPrimaryVertexTracks();
205       if (vertex && vertex->GetNContributors() >= 3) {
206         fPrimaryXY.Fill(vertex->GetX(), vertex->GetY());
207         fPrimaryZX.Fill(vertex->GetZ(), vertex->GetX());
208         fPrimaryZY.Fill(vertex->GetZ(), vertex->GetY());
209       }
210       if( !wasITS ){
211         vertex = event->GetPrimaryVertexSPD();
212         if( vertex && vertex->GetNContributors() >= 3 ){
213           fSPDVertexXY.Fill(vertex->GetX(), vertex->GetY());
214           fSPDVertexX.Fill(vertex->GetX() );
215           fSPDVertexY.Fill(vertex->GetY() );
216           fSPDVertexZ.Fill(vertex->GetZ() );      
217         }
218       }
219     } else {
220       HLTError("ESD event object is corrupted");
221       iResult = -EINVAL;    
222     }
223   }
224  
225   PushBack(&fPrimaryXY, kAliHLTDataTypeHistogram, 0);
226   PushBack(&fPrimaryZX, kAliHLTDataTypeHistogram, 0);
227   PushBack(&fPrimaryZY, kAliHLTDataTypeHistogram, 0);
228
229   PushBack(&fSPDVertexXY, kAliHLTDataTypeHistogram, 0);
230   PushBack(&fSPDVertexX, kAliHLTDataTypeHistogram, 0);
231   PushBack(&fSPDVertexY, kAliHLTDataTypeHistogram, 0);
232   PushBack(&fSPDVertexZ, kAliHLTDataTypeHistogram, 0);
233   
234   return iResult; 
235 }
236
237 int AliHLTGlobalVertexerHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
238 {
239   //Do nothing at the moment, but at least log (base class version).
240   return AliHLTComponent::Reconfigure(cdbEntry, chainId);
241 }
242
243 unsigned long AliHLTGlobalVertexerHistoComponent::GetOutputDataSize()const
244 {
245   //8000 is a temporary number. Find the way to
246   //estimate serialized TH2F. 
247   return 20000;
248 }