2 /**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * All rights reserved. *
6 * Primary Authors: Svein Lindal, Oeystein Djuvsland *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 * @file AliHLTCaloHistoComponent.cxx
18 * @author Svein Lindal
20 * @brief A physics histogram producer component for Calo HLT
28 #include "AliHLTCaloHistoComponent.h"
29 #include "AliHLTCaloHistoCellEnergy.h"
30 #include "AliHLTCaloHistoClusterEnergy.h"
31 #include "AliHLTCaloHistoInvMass.h"
32 #include "AliHLTCaloHistoMatchedTracks.h"
33 #include "AliESDEvent.h"
34 #include "TRefArray.h"
35 #include "AliHLTCaloClusterDataStruct.h"
36 #include "AliHLTCaloClusterReader.h"
37 #include "TObjArray.h"
39 // see below for class documentation
41 // refer to README to build package
43 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 AliHLTCaloHistoComponent gAliHLTCaloHistoComponent;
48 ClassImp(AliHLTCaloHistoComponent);
50 AliHLTCaloHistoComponent::AliHLTCaloHistoComponent() :
53 fEmcalClustersArray(NULL),
54 fPhosClustersArray(NULL),
55 fPhosHistogramArray(NULL),
56 fEmcalHistogramArray(NULL),
60 //see header file for documentation
63 AliHLTCaloHistoComponent::~AliHLTCaloHistoComponent()
65 //see header file for documentation
69 Int_t AliHLTCaloHistoComponent::DoInit(int argc, const char** argv ) {
70 //see header file for documentation
73 fEmcalHistogramArray = new TObjArray();
74 fEmcalHistogramArray->SetOwner(kTRUE);
75 fPhosHistogramArray = new TObjArray();
76 fPhosHistogramArray->SetOwner(kTRUE);
82 for(int i = 0; i < argc; i++) {
84 if(!strcmp("-phos", argv[i])) {
89 if(!strcmp("-emcal", argv[i])) {
94 if(!strcmp("-both", argv[i])) {
101 if(!strcmp("-clusterenergy", argv[i])){
103 AliHLTCaloHistoClusterEnergy * histo = new AliHLTCaloHistoClusterEnergy("EMCAL");
104 fEmcalHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
105 HLTInfo("Adding EMCAL cluster energy histogram");
108 AliHLTCaloHistoClusterEnergy * histo = new AliHLTCaloHistoClusterEnergy("PHOS");
109 fPhosHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
110 HLTInfo("Adding PHOS cluster energy histogram");
114 if(!strcmp("-invariantmass", argv[i])){
116 AliHLTCaloHistoInvMass * histo = new AliHLTCaloHistoInvMass("EMCAL");
117 fEmcalHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
118 HLTInfo("Adding EMCAL invariant mass histogram");
121 AliHLTCaloHistoInvMass * histo = new AliHLTCaloHistoInvMass("PHOS");
122 fPhosHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
123 HLTInfo("Adding PHOS invariant mass histogram");
127 if(!strcmp("-matchedtracks", argv[i])) {
129 AliHLTCaloHistoMatchedTracks * histo = new AliHLTCaloHistoMatchedTracks("EMCAL");
130 fEmcalHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
131 HLTInfo("Adding EMCAL track-matching histograms");
134 AliHLTCaloHistoMatchedTracks * histo = new AliHLTCaloHistoMatchedTracks("PHOS");
135 fPhosHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
136 HLTInfo("Adding PHOS track-matching histograms");
142 fPhosClustersArray = new TRefArray();
144 fEmcalClustersArray = new TRefArray();
146 fClusterReader = new AliHLTCaloClusterReader();
152 Int_t AliHLTCaloHistoComponent::DoDeinit()
154 //see header file for documentation
156 if(fEmcalClustersArray)
157 delete fEmcalClustersArray;
158 fEmcalClustersArray = NULL;
160 if(fPhosClustersArray)
161 delete fPhosClustersArray;
162 fPhosClustersArray = NULL;
164 //Deleting these should also destroy histograms!!?
165 if(fEmcalHistogramArray)
166 delete fEmcalHistogramArray;
167 fEmcalHistogramArray = NULL;
169 if(fPhosHistogramArray)
170 delete fPhosHistogramArray;
171 fPhosHistogramArray = NULL;
176 const char* AliHLTCaloHistoComponent::GetComponentID()
178 //see header file for documentation
179 return "CaloPhysicsHistos";
184 AliHLTCaloHistoComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
186 //see header file for documentation
188 list.push_back( kAliHLTDataTypeESDObject | kAliHLTDataOriginOut );
189 list.push_back( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL );
190 list.push_back( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS );
192 // list.push_back(AliHLTPHOSDefinitions::fgkClusterDataType);
193 // list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
194 // list.push_back(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);
198 AliHLTComponentDataType AliHLTCaloHistoComponent::GetOutputDataType()
200 //see header file for documentation
201 return kAliHLTDataTypeHistogram | kAliHLTDataOriginAny ;
205 void AliHLTCaloHistoComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
207 //see header file for documentation
212 AliHLTComponent* AliHLTCaloHistoComponent::Spawn() {
213 //see header file for documentation
214 return new AliHLTCaloHistoComponent();
217 Int_t AliHLTCaloHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) {
219 //see header file for documentation
223 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
228 // HLTInfo("Processing EMCAL blocks");
229 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL ); pBlock!=NULL; pBlock=GetNextInputBlock()) {
230 ProcessBlocks(pBlock, fEmcalHistogramArray);
235 //HLTInfo("Processing PHOS blocks");
236 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS ); pBlock!=NULL; pBlock=GetNextInputBlock()) {
237 ProcessBlocks(pBlock, fPhosHistogramArray);
242 for(int ih = 0; ih < fPhosHistogramArray->GetEntriesFast(); ih++) {
243 //HLTInfo("Pushing PHOS histograms");
244 PushBack(static_cast<AliHLTCaloHistoProducer*>(fPhosHistogramArray->At(ih))->GetHistograms(), kAliHLTDataTypeHistogram | kAliHLTDataOriginPHOS );
246 for(int ih = 0; ih < fEmcalHistogramArray->GetEntriesFast(); ih++) {
247 //HLTInfo("Pushing EMCAL histograms");
248 PushBack(static_cast<AliHLTCaloHistoProducer*>(fEmcalHistogramArray->At(ih))->GetHistograms(), kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL );
256 Int_t AliHLTCaloHistoComponent::ProcessBlocks(const AliHLTComponentBlockData * pBlock, TObjArray * histoArray) {
260 AliHLTCaloClusterDataStruct * clusterStruct;
261 vector<AliHLTCaloClusterDataStruct*> clustersVector;
263 AliHLTCaloClusterHeaderStruct *clusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
264 fClusterReader->SetMemory(clusterHeader);
266 if ( (clusterHeader->fNClusters) < 0) {
267 HLTError("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (clusterHeader->fNClusters));
271 clustersVector.resize((int) (clusterHeader->fNClusters));
274 while( (clusterStruct = fClusterReader->NextCluster()) != 0) {
275 clustersVector[nClusters++] = clusterStruct;
278 nClusters = clusterHeader->fNClusters;
280 for(int ih = 0; ih < histoArray->GetEntriesFast(); ih++) {
281 iResult = static_cast<AliHLTCaloHistoProducer*>(histoArray->At(ih))->FillHistograms(nClusters, clustersVector);