]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalHistoComponent.cxx
- implementation of tree with UPC related variables
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalHistoComponent.cxx
CommitLineData
a4c1f5dd 1// $Id$
2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
19/// @file AliHLTGlobalHistoComponent.cxx
20/// @author Matthias Richter
21/// @date 2010-09-16
22/// @brief A histogramming component for global ESD properties based
23/// on the AliHLTTTreeProcessor
24
25#include "AliHLTGlobalHistoComponent.h"
26#include "AliESDEvent.h"
7a37a034 27#include "AliESDv0.h"
28#include "AliKFParticle.h"
29#include "AliKFVertex.h"
30
a4c1f5dd 31#include "TTree.h"
32#include "TString.h"
a4c1f5dd 33#include <cassert>
34
35/** ROOT macro for the implementation of ROOT specific class methods */
36ClassImp(AliHLTGlobalHistoComponent)
37
38AliHLTGlobalHistoComponent::AliHLTGlobalHistoComponent()
39 : AliHLTTTreeProcessor()
40 , fEvent(0)
41 , fNofTracks(0)
1b89b93a 42 , fNofV0s(0)
1c1af02a 43 , fNofUPCpairs(0)
1b89b93a 44 , fNofContributors(0)
54da0d34 45 , fVertexX(-99)
46 , fVertexY(-99)
47 , fVertexZ(-99)
1b89b93a 48 , fVertexStatus(kFALSE)
a4c1f5dd 49 , fTrackVariables()
e7f3baeb 50 , fTrackVariablesInt()
7a37a034 51 , fV0Variables()
1c1af02a 52 , fUPCVariables()
7a37a034 53 , fNEvents(0)
54 , fNGammas(0)
55 , fNKShorts(0)
56 , fNLambdas(0)
57 , fNPi0s(0)
a4c1f5dd 58{
59 // see header file for class documentation
60 // or
61 // refer to README to build package
62 // or
63 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
64
65}
66
67AliHLTGlobalHistoComponent::~AliHLTGlobalHistoComponent()
68{
69 // see header file for class documentation
70 fTrackVariables.Reset();
e7f3baeb 71 fTrackVariablesInt.Reset();
7a37a034 72 fV0Variables.Reset();
1c1af02a 73 fUPCVariables.Reset();
a4c1f5dd 74}
75
7a37a034 76void AliHLTGlobalHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
a4c1f5dd 77 // see header file for class documentation
78 list.push_back(kAliHLTAllDataTypes);
79}
80
7a37a034 81AliHLTComponentDataType AliHLTGlobalHistoComponent::GetOutputDataType(){
af747e4b 82 // see header file for class documentation
83 return kAliHLTDataTypeHistogram|kAliHLTDataOriginOut;
84}
85
7a37a034 86TTree* AliHLTGlobalHistoComponent::CreateTree(int /*argc*/, const char** /*argv*/){
a4c1f5dd 87 // create the tree and branches
88 int iResult=0;
89 TTree* pTree=new TTree("ESDproperties", "HLT ESD properties");
90 if (!pTree) return NULL;
91
92 const char* trackVariableNames = {
e7f3baeb 93 // Note the black at the end of each name!
a4c1f5dd 94 "Track_pt "
95 "Track_phi "
96 "Track_eta "
54da0d34 97 "Track_p "
98 "Track_theta "
99 "Track_Nclusters "
97491309 100 "Track_status "
54da0d34 101 "Track_charge "
97491309 102 "Track_DCAr "
103 "Track_DCAz "
104 "Track_dEdx "
a4c1f5dd 105 };
54da0d34 106
e7f3baeb 107 const char* trackIntVariableNames = {
108 // Note the black at the end of each name!
109 "Track_status "
110 };
111
7a37a034 112 const char* V0VariableNames = {
113 // Note the black at the end of each name!
114 "V0_AP "
115 "V0_pt "
116 "clust1 "
117 "clust2 "
118 "dev1 "
119 "dev2 "
120 "devPrim "
121 "length "
122 "sigmaLength "
123 "r "
1c1af02a 124 };
125
126 const char* UPCVariableNames = {
127 // Note the black at the end of each name!
128 "nClusters_1 "
129 "nClusters_2 "
130 "polarity_1 "
131 "polarity_2 "
132 "pt_1 "
133 "pt_2 "
134 };
7a37a034 135
af747e4b 136 int maxTrackCount = 20000; // FIXME: make configurable
7a37a034 137 int maxV0Count = 100000;
1c1af02a 138 int maxUPCCount = 1;
af747e4b 139
a4c1f5dd 140 if ((iResult=fTrackVariables.Init(maxTrackCount, trackVariableNames))<0) {
e7f3baeb 141 HLTError("failed to initialize internal structure for track properties (float)");
142 }
143 if ((iResult=fTrackVariablesInt.Init(maxTrackCount, trackIntVariableNames))<0) {
144 HLTError("failed to initialize internal structure for track properties (int)");
a4c1f5dd 145 }
7a37a034 146 if ((iResult=fV0Variables.Init(maxV0Count, V0VariableNames))<0) {
147 HLTError("failed to initialize internal structure for V0 properties (float)");
148 }
1c1af02a 149 if ((iResult=fUPCVariables.Init(maxUPCCount, UPCVariableNames))<0) {
150 HLTError("failed to initialize internal structure for UPC properties (float)");
151 }
a4c1f5dd 152
153 if (iResult>=0) {
1b89b93a 154 pTree->Branch("event", &fEvent, "event/I");
155 pTree->Branch("trackcount", &fNofTracks, "trackcount/I");
156 pTree->Branch("vertexX", &fVertexX, "vertexX/F");
157 pTree->Branch("vertexY", &fVertexY, "vertexY/F");
158 pTree->Branch("vertexZ", &fVertexZ, "vertexZ/F");
7a37a034 159 pTree->Branch("V0", &fNofV0s, "V0/I");
1c1af02a 160 pTree->Branch("UPC", &fNofUPCpairs, "UPC/I");
1b89b93a 161 pTree->Branch("nContributors",&fNofContributors, "nContributors/I");
162 pTree->Branch("vertexStatus", &fVertexStatus, "vertexStatus/I");
e7f3baeb 163
164 int i=0;
165 // FIXME: this is a bit ugly since type 'f' and 'i' are specified
166 // explicitely. Would be better to use a function like
167 // AliHLTGlobalHistoVariables::GetType but could not get this working
168 for (i=0; i<fTrackVariables.Variables(); i++) {
a4c1f5dd 169 TString specifier=fTrackVariables.GetKey(i);
170 float* pArray=fTrackVariables.GetArray(specifier);
171 specifier+="[trackcount]/f";
172 pTree->Branch(fTrackVariables.GetKey(i), pArray, specifier.Data());
173 }
e7f3baeb 174 for (i=0; i<fTrackVariablesInt.Variables(); i++) {
175 TString specifier=fTrackVariablesInt.GetKey(i);
176 int* pArray=fTrackVariablesInt.GetArray(specifier);
177 specifier+="[trackcount]/i";
178 pTree->Branch(fTrackVariablesInt.GetKey(i), pArray, specifier.Data());
7a37a034 179 }
180 for (i=0; i<fV0Variables.Variables(); i++) {
181 TString specifier=fV0Variables.GetKey(i);
182 float* pArray=fV0Variables.GetArray(specifier);
183 specifier+="[V0]/f";
184 pTree->Branch(fV0Variables.GetKey(i), pArray, specifier.Data());
e7f3baeb 185 }
1c1af02a 186 for (i=0; i<fUPCVariables.Variables(); i++) {
187 TString specifier=fUPCVariables.GetKey(i);
188 float* pArray=fUPCVariables.GetArray(specifier);
189 specifier+="[UPC]/f";
190 pTree->Branch(fUPCVariables.GetKey(i), pArray, specifier.Data());
191 }
a4c1f5dd 192 } else {
193 delete pTree;
194 pTree=NULL;
195 }
7a37a034 196
a4c1f5dd 197 return pTree;
198}
199
7a37a034 200void AliHLTGlobalHistoComponent::FillHistogramDefinitions(){
a4c1f5dd 201 /// default histogram definitions
202}
203
7a37a034 204int AliHLTGlobalHistoComponent::FillTree(TTree* pTree, const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ){
205
a4c1f5dd 206 /// fill the tree from the ESD
207 int iResult=0;
208 if (!IsDataEvent()) return 0;
209
210 ResetVariables();
211
212 // fetch ESD from input stream
213 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
214 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
215 esd->GetStdContent();
216
217 // fill track variables
1b89b93a 218 fNofTracks = esd->GetNumberOfTracks();
219 fVertexX = esd->GetPrimaryVertexTracks()->GetX();
220 fVertexY = esd->GetPrimaryVertexTracks()->GetY();
221 fVertexZ = esd->GetPrimaryVertexTracks()->GetZ();
222 fNofV0s = esd->GetNumberOfV0s();
223 fNofContributors = esd->GetPrimaryVertexTracks()->GetNContributors();
224 fVertexStatus = esd->GetPrimaryVertexTracks()->GetStatus();
1c1af02a 225 fNofUPCpairs = 1;
54da0d34 226
a4c1f5dd 227 for (int i=0; i<fNofTracks; i++) {
228 AliESDtrack *esdTrack = esd->GetTrack(i);
229 if (!esdTrack) continue;
230
97491309 231 Float_t DCAr, DCAz = -99;
232 esdTrack->GetImpactParametersTPC(DCAr, DCAz);
233
54da0d34 234 fTrackVariables.Fill("Track_pt" , esdTrack->Pt() );
235 fTrackVariables.Fill("Track_phi" , esdTrack->Phi()*TMath::RadToDeg() );
236 fTrackVariables.Fill("Track_eta" , esdTrack->Theta() );
237 fTrackVariables.Fill("Track_p" , esdTrack->P() );
238 fTrackVariables.Fill("Track_theta" , esdTrack->Theta()*TMath::RadToDeg() );
239 fTrackVariables.Fill("Track_Nclusters" , esdTrack->GetTPCNcls() );
97491309 240 fTrackVariables.Fill("Track_status" , esdTrack->GetStatus() );
54da0d34 241 fTrackVariables.Fill("Track_charge" , esdTrack->Charge() );
97491309 242 fTrackVariables.Fill("Track_DCAr" , DCAr );
243 fTrackVariables.Fill("Track_DCAz" , DCAz );
244 fTrackVariables.Fill("Track_dEdx" , esdTrack->GetTPCsignal() );
1c1af02a 245 fTrackVariablesInt.Fill("Track_status" , esdTrack->GetStatus() );
7a37a034 246 }
1b89b93a 247 //HLTInfo("added parameters for %d tracks", fNofTracks);
1c1af02a 248
249 if(fNofTracks==2){
250 AliESDtrack *esdTrack1 = esd->GetTrack(0);
251 if(!esdTrack1) return 0;
252 AliESDtrack *esdTrack2 = esd->GetTrack(1);
253 if(!esdTrack2) return 0;
254
255 if(esdTrack1->Charge()*esdTrack2->Charge()<0){
256
257 fUPCVariables.Fill("nClusters_1", esdTrack1->GetTPCNcls() );
258 fUPCVariables.Fill("nClusters_2", esdTrack2->GetTPCNcls() );
259 fUPCVariables.Fill("polarity_1", esdTrack1->Charge() );
260 fUPCVariables.Fill("polarity_2", esdTrack2->Charge() );
261 fUPCVariables.Fill("pt_1", esdTrack1->Pt() );
262 fUPCVariables.Fill("pt_2", esdTrack2->Pt() );
263 }
264 }
265
7a37a034 266 AliKFParticle::SetField( esd->GetMagneticField() );
267
8dabf5a9 268 //const double kKsMass = 0.49767;
269 //const double kLambdaMass = 1.11568;
7a37a034 270 //const double kPi0Mass = 0.13498;
271
1c1af02a 272 //std::vector<AliKFParticle> vGammas;
7a37a034 273
274
275 for (int i=0; i<fNofV0s; i++) {
276 AliESDv0 *esdV0 = esd->GetV0(i);
277 if (!esdV0) continue;
278
279 AliESDtrack *t1 = esd->GetTrack( esd->GetV0(i)->GetNindex());
280 AliESDtrack *t2 = esd->GetTrack( esd->GetV0(i)->GetPindex());
281
282 AliKFParticle kf1( *t1, 11 );
283 AliKFParticle kf2( *t2, 11 );
284
285 AliKFVertex primVtx( *esd->GetPrimaryVertexTracks() );
286 double dev1 = kf1.GetDeviationFromVertex( primVtx );
287 double dev2 = kf2.GetDeviationFromVertex( primVtx );
288
289 AliKFParticle v0( kf1, kf2 );
290 double devPrim = v0.GetDeviationFromVertex( primVtx );
291 primVtx+=v0;
292 v0.SetProductionVertex( primVtx );
293
294 Double_t length, sigmaLength;
295 if( v0.GetDecayLength( length, sigmaLength ) ) continue;
296
297 double dx = v0.GetX()-primVtx.GetX();
298 double dy = v0.GetY()-primVtx.GetY();
299 double r = sqrt(dx*dx + dy*dy);
300
301
302 // Armenteros-Podolanski plot
303
304 double pt=0, ap=0;
305 //{
306 AliKFParticle kf01 = kf1, kf02 = kf2;
307 kf01.SetProductionVertex(v0);
308 kf02.SetProductionVertex(v0);
309 kf01.TransportToProductionVertex();
310 kf02.TransportToProductionVertex();
311 double px1=kf01.GetPx(), py1=kf01.GetPy(), pz1=kf01.GetPz();
312 double px2=kf02.GetPx(), py2=kf02.GetPy(), pz2=kf02.GetPz();
313 double px = px1+px2, py = py1+py2, pz = pz1+pz2;
314 double p = sqrt(px*px+py*py+pz*pz);
315 double l1 = (px*px1 + py*py1 + pz*pz1)/p;
316 double l2 = (px*px2 + py*py2 + pz*pz2)/p;
317 pt = sqrt(px1*px1+py1*py1+pz1*pz1 - l1*l1);
318 ap = (l2-l1)/(l1+l2);
319 //}
320
321// if(
322// t1->GetTPCNcls()>=fAPCuts[0]
323// && t2->GetTPCNcls()>=fAPCuts[0]
324// && dev1>=fAPCuts[1]
325// && dev2>=fAPCuts[1]
326// && devPrim <= fAPCuts[2]
327// && length >= fAPCuts[3]*sigmaLength
328// && length >= fAPCuts[4]
329// && r <= fAPCuts[5]
330// )
331// //{
332// //if( fAP ) fAP->Fill( ap, pt );
333// //}
334//
335// // Gamma finder
336//
337// bool isGamma = 0;
338//
339// if(
340// t1->GetTPCNcls()>=fGammaCuts[0]
341// && t2->GetTPCNcls()>=fGammaCuts[0]
342// && dev1>=fGammaCuts[1]
343// && dev2>=fGammaCuts[1]
344// && devPrim <= fGammaCuts[2]
345// && length >= fGammaCuts[3]*sigmaLength
346// && length >= fGammaCuts[4]
347// && r <= fGammaCuts[5]
348// ){
349// double mass, error;
350// v0.GetMass(mass,error);
351// //if( fGamma ) fGamma->Fill( mass );
352//
353// if( TMath::Abs(mass)<=fGammaCuts[6]*error || TMath::Abs(mass)<=fGammaCuts[7] ){
354// AliKFParticle gamma = v0;
355// gamma.SetMassConstraint(0);
356// // if( fGammaXY
357// // && t1->GetTPCNcls()>=60
358// // && t2->GetTPCNcls()>=60
359// // ) fGammaXY->Fill(gamma.GetX(), gamma.GetY());
360// isGamma = 1;
361// fNGammas++;
362// vGammas.push_back( gamma );
363// }
364// }
365//
366// if( isGamma ) continue;
367//
368//
369// // KShort finder
370//
371// bool isKs = 0;
372//
373// if(
374// t1->GetTPCNcls()>=fKsCuts[0]
375// && t2->GetTPCNcls()>=fKsCuts[0]
376// && dev1>=fKsCuts[1]
377// && dev2>=fKsCuts[1]
378// && devPrim <= fKsCuts[2]
379// && length >= fKsCuts[3]*sigmaLength
380// && length >= fKsCuts[4]
381// && r <= fKsCuts[5]
382// ){
383//
384// AliKFParticle piN( *t1, 211 );
385// AliKFParticle piP( *t2, 211 );
386//
387// AliKFParticle Ks( piN, piP );
388// Ks.SetProductionVertex( primVtx );
389//
390// double mass, error;
391// Ks.GetMass( mass, error);
392// //if( fKShort ) fKShort->Fill( mass );
393// if( TMath::Abs( mass - kKsMass )<=fKsCuts[6]*error || TMath::Abs( mass - kKsMass )<=fKsCuts[7] ){
394// isKs = 1;
395// fNKShorts++;
396// }
397// }
398//
399// if( isKs ) continue;
400//
401// // Lambda finder
402// //printf("QQQQQQQQQQQQQQQQq :%f\n",fLambdaCuts[0]);
403// if(
404// t1->GetTPCNcls()>=fLambdaCuts[0]
405// && t2->GetTPCNcls()>=fLambdaCuts[0]
406// && dev1>=fLambdaCuts[1]
407// && dev2>=fLambdaCuts[1]
408// && devPrim <= fLambdaCuts[2]
409// && length >= fLambdaCuts[3]*sigmaLength
410// && length >= fLambdaCuts[4]
411// && r <= fLambdaCuts[5]
412// && TMath::Abs( ap )>.4
413// ){
414//
415// AliKFParticle kP, kpi;
416// if( ap<0 ){
417// kP = AliKFParticle( *t2, 2212 );
418// kpi = AliKFParticle( *t1, 211 );
419// } else {
420// kP = AliKFParticle( *t1, 2212 );
421// kpi = AliKFParticle( *t2, 211 );
422// }
423//
424// AliKFParticle lambda = AliKFParticle( kP, kpi );
425// lambda.SetProductionVertex( primVtx );
426// //double mass, error;
427// lambda.GetMass( Lmass, Lerror);
428// //if( fLambda ) fLambda->Fill( mass );
429// if( TMath::Abs( Lmass - kLambdaMass )<=fLambdaCuts[6]*Lerror || TMath::Abs( Lmass - kLambdaMass )<=fLambdaCuts[7] ){
430// fNLambdas++;
431// }
432// }
433
434
435 fV0Variables.Fill("V0_AP", ap);
436 fV0Variables.Fill("V0_pt", pt);
437 fV0Variables.Fill("clust1", t1->GetTPCNcls());
438 fV0Variables.Fill("clust2", t2->GetTPCNcls());
439 fV0Variables.Fill("dev1", dev1);
440 fV0Variables.Fill("dev2", dev2);
441 fV0Variables.Fill("devPrim", devPrim);
442 fV0Variables.Fill("length", length);
443 fV0Variables.Fill("sigmaLength", sigmaLength);
444 fV0Variables.Fill("r", r);
445
446 } // end of loop over V0s
447
a4c1f5dd 448 if (iResult<0) {
449 // fill an empty event
450 ResetVariables();
451 }
452 fEvent++;
453
454 pTree->Fill();
455 return iResult;
456}
457
458int AliHLTGlobalHistoComponent::ResetVariables()
459{
460 /// reset all filling variables
461 fNofTracks=0;
4868ab3f 462 fNofV0s=0;
a4c1f5dd 463 fTrackVariables.ResetCount();
e7f3baeb 464 fTrackVariablesInt.ResetCount();
c3176951 465 fV0Variables.ResetCount();
1c1af02a 466 fUPCVariables.ResetCount();
a4c1f5dd 467 return 0;
468}
469
470AliHLTComponentDataType AliHLTGlobalHistoComponent::GetOriginDataType() const
471{
472 // get the origin of the output data
473 return kAliHLTVoidDataType;
474}
475
476// AliHLTUInt32_t AliHLTGlobalHistoComponent::GetDataSpec() const;
477// {
478// // get specifications of the output data
479// return 0;
480// }