2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
7 //* for The ALICE HLT Project. *
9 //* Permission to use, copy, modify and distribute this software and its *
10 //* documentation strictly for non-commercial purposes is hereby granted *
11 //* without fee, provided that the above copyright notice appears in all *
12 //* copies and that both the copyright notice and this permission notice *
13 //* appear in the supporting documentation. The authors make no claims *
14 //* about the suitability of this software for any purpose. It is *
15 //* provided "as is" without express or implied warranty. *
16 //**************************************************************************
18 /** @file AliHLTEveHistoMerger.cxx
19 @author Kalliopi Kanaki
21 @brief The Histogram Handler component
27 #include "AliHLTEveHistoMerger.h"
28 #include "AliCDBEntry.h"
29 #include "AliCDBManager.h"
31 #include "TObjArray.h"
32 #include "TObjString.h"
34 #include "TTimeStamp.h"
38 AliHLTEveHistoMerger::AliHLTEveHistoMerger()
44 AliHLTEveHistoMerger::~AliHLTEveHistoMerger() {
45 // see header file for class documentation
51 void AliHLTEveHistoMerger::Clear()
55 for ( unsigned int i=0; i<fStore.size(); i++ ) {
56 for ( unsigned int j=0; j<fStore[i].fInstances.size(); j++ ) {
57 delete fStore[i].fInstances[j].fObject;
59 delete fStore[i].fMergedObject;
67 TObject* AliHLTEveHistoMerger::Process(const TObject * evtData, AliHLTUInt32_t spec)
69 // see header file for class documentation
70 //cout<<"\n\nDoEvent called"<<endl;
73 if ( !evtData ) return 0;
75 if ( !evtData->InheritsFrom(TH1::Class())
76 && !evtData->InheritsFrom(TSeqCollection::Class()) ) return 0;
78 std::cout<<"received object "<<evtData->GetName()<<" with id="<< spec << std::endl;
80 //search for the base entry, if not exist then create a new entry
83 for ( unsigned int i=0; i<fStore.size(); i++ ) {
84 if ( fStore[i].fInstances.size()<1 ) continue;
85 TObject * obj = fStore[i].fInstances[0].fObject;
87 if ( TString(obj->GetName()).CompareTo(evtData->GetName())==0) {
92 cout<<"Collection found: "<<iColl<<endl;
94 AliHLTGlobalHCCollection c;
98 iColl = fStore.size()-1;
100 fStore[iColl].fNeedToMerge = 1;
103 // search for the specific entry, if not exist then create a new one
105 AliHLTGlobalHCCollection &c = fStore[iColl];
108 for ( unsigned int i=0; i<c.fInstances.size(); i++ ) {
109 AliHLTGlobalHCInstance &inst = c.fInstances[i];
110 if ( inst.fHLTSpecification == spec ) {
115 cout<<"Instance found:"<<iSpec<<endl;
117 AliHLTGlobalHCInstance inst;
118 inst.fHLTSpecification = spec;
120 c.fInstances.push_back(inst);
121 iSpec = c.fInstances.size()-1;
123 delete c.fInstances[iSpec].fObject;
126 c.fInstances[iSpec].fObject = evtData->Clone();
128 cout<<"index = "<<iColl<<","<<iSpec<<endl;
133 for ( unsigned int jColl = 0; jColl<fStore.size(); jColl++) {
134 AliHLTGlobalHCCollection &c = fStore[jColl];
135 if ( !c.fNeedToMerge && c.fMergedObject ) continue;
136 if ( c.fInstances.size() <1 ) continue;
137 delete c.fMergedObject;
138 c.fMergedObject = c.fInstances[0].fObject->Clone();
140 for ( unsigned int i=1; i<c.fInstances.size(); i++ ) {
141 l.Add(c.fInstances[i].fObject);
144 if ( c.fMergedObject->InheritsFrom(TH1::Class()) ) {
145 TH1 *histo = dynamic_cast<TH1*>(c.fMergedObject);
146 if ( histo ) histo->Merge(&l);
148 else if ( c.fMergedObject->InheritsFrom(TSeqCollection::Class()) ) {
149 TSeqCollection *list = dynamic_cast<TSeqCollection*>(c.fMergedObject);
150 if ( list ) list->Merge(&l);
156 return fStore[iColl].fMergedObject;