- fixing warnings/coverity
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTESDCaloClusterMaker.cxx
CommitLineData
d0bb5541 1//-*- Mode: C++ -*-
2// $Id$
7fc04b67 3
4/**************************************************************************
5 * This file is property of and copyright by the ALICE HLT Project *
6 * All rights reserved. *
7 * *
8 * Primary Authors: Oystein Djuvsland *
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
20/**
21 * @file AliHLTESDCaloClusterMaker.cxx
22 * @author Oystein Djuvsland
23 * @date
24 * @brief ESD Calo Cluster maker for HLT
25 */
26
27// see header file for class documentation
28// or
29// refer to README to build package
30// or
31// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32
33#include "AliESDEvent.h"
34#include "AliHLTESDCaloClusterMaker.h"
35#include "AliHLTCaloClusterDataStruct.h"
36#include "AliHLTCaloClusterReader.h"
37#include "AliESDCaloCluster.h"
38#include <iostream>
39
40ClassImp(AliHLTESDCaloClusterMaker);
41
42AliHLTESDCaloClusterMaker::AliHLTESDCaloClusterMaker() :
43 fClusterReaderPtr(0)
44{
45 //See header file for documentation
46 fClusterReaderPtr = new AliHLTCaloClusterReader();
47
48}
49
50AliHLTESDCaloClusterMaker::~AliHLTESDCaloClusterMaker()
51{
52 //See header file for documentation
9eb97e6e 53 delete fClusterReaderPtr;
7fc04b67 54}
55
56Int_t
57AliHLTESDCaloClusterMaker::FillESD(AliESDEvent *esdPtr, const AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr)
58{
59 // See header file for documentation
60
61 AliHLTCaloClusterDataStruct* caloClusterStructPtr = 0;
62
63 fClusterReaderPtr->SetMemory(caloClusterHeaderPtr);
64
65 Int_t nClusters = 0;
66
67 while((caloClusterStructPtr = fClusterReaderPtr->NextCluster()) != 0)
68 {
69 AliESDCaloCluster esdCluster;
70
71 esdCluster.SetID(caloClusterStructPtr->fID);
05b4444e 72#ifndef HAVE_NOT_ALIVCLUSTER // backward compatibility for r42844
c8fe2783 73 esdCluster.SetType(caloClusterStructPtr->fClusterType);
05b4444e 74#else
75 esdCluster.SetClusterType(caloClusterStructPtr->fClusterType);
76#endif
7fc04b67 77 esdCluster.SetPosition((Float_t*)(caloClusterStructPtr->fGlobalPos));
78 esdCluster.SetE(caloClusterStructPtr->fEnergy);
79 esdCluster.SetTOF(caloClusterStructPtr->fTOF);
05b4444e 80#ifndef HAVE_NOT_ALIVCLUSTER // backward compatibility for r42844
c8fe2783 81 esdCluster.SetDispersion(caloClusterStructPtr->fDispersion);
82 esdCluster.SetChi2(caloClusterStructPtr->fFitQuality);
05b4444e 83#else
84 esdCluster.SetClusterDisp(caloClusterStructPtr->fDispersion);
85 esdCluster.SetClusterChi2(caloClusterStructPtr->fFitQuality);
86#endif
ba340030 87 const Float_t *pid = caloClusterStructPtr->fPID;
05b4444e 88#ifndef HAVE_NOT_ALIVCLUSTER // backward compatibility for r42844
c8fe2783 89 esdCluster.SetPID(pid);
05b4444e 90#else
91 esdCluster.SetPid(pid);
92#endif
7fc04b67 93 esdCluster.SetM20(caloClusterStructPtr->fM20);
94 esdCluster.SetM02(caloClusterStructPtr->fM02);
95 esdCluster.SetNExMax(caloClusterStructPtr->fNExMax);
96 esdCluster.SetEmcCpvDistance(caloClusterStructPtr->fEmcCpvDistance);
97 esdCluster.SetDistanceToBadChannel(caloClusterStructPtr->fDistToBadChannel);
34eb3256 98 esdCluster.SetNCells(caloClusterStructPtr->fNCells);
99 //esdCluster.SetNCells(0);
2a114625 100 if(caloClusterStructPtr->GetNTracksMatched())
101 {
102 TArrayI tracksMatched(caloClusterStructPtr->GetNTracksMatched(), caloClusterStructPtr->fTracksMatched);
103 esdCluster.AddTracksMatched(tracksMatched);
104 }
34eb3256 105 UShort_t *idArrayPtr = new UShort_t[caloClusterStructPtr->fNCells];
106 Double32_t *ampFracArrayPtr = new Double32_t[caloClusterStructPtr->fNCells];
2a114625 107
7fc04b67 108 for(UInt_t index = 0; index < caloClusterStructPtr->fNCells; index++)
109 {
2a1edad1 110 fClusterReaderPtr->GetCell(caloClusterStructPtr, idArrayPtr[index], ampFracArrayPtr[index], index);
34eb3256 111 //printf("EM: cellId: %d\n", idArrayPtr[index]);;
7fc04b67 112 }
2a1edad1 113 esdCluster.SetCellsAbsId(idArrayPtr);
114 esdCluster.SetCellsAmplitudeFraction(ampFracArrayPtr);
d0bb5541 115#ifndef HAVE_NOT_ALIESDCALOCLUSTER_r38477
116 // this is to ensure compilation with the v4-18-Release branch for the moment
117 // until the changes of AliESDCaloCluster have been ported
3469a4b7 118 esdCluster.SetTrackDistance(caloClusterStructPtr->fTrackDx, caloClusterStructPtr->fTrackDz);
d0bb5541 119#endif //HAVE_NOT_ALIESDCALOCLUSTER_r38477
2a114625 120
121 delete [] idArrayPtr;
34eb3256 122 delete [] ampFracArrayPtr;
9a0cbaba 123// idArrayPtr = 0;
124 //ampFracArrayPtr = 0;
2a114625 125
7fc04b67 126 esdPtr->AddCaloCluster(&esdCluster);
2a1edad1 127 //printf("EM: Energy: %f\n", esdCluster.E());
7fc04b67 128 nClusters++;
129 }
130 return nClusters;
131}