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
24 #include "AliHLTEveHistoMerger.h"
25 #include "AliCDBEntry.h"
26 #include "AliCDBManager.h"
28 #include "TObjArray.h"
29 #include "TObjString.h"
31 #include "TTimeStamp.h"
37 AliHLTEveHistoMerger::AliHLTEveHistoMerger()
43 AliHLTEveHistoMerger::~AliHLTEveHistoMerger() {
44 // see header file for class documentation
50 void AliHLTEveHistoMerger::Clear()
54 for ( unsigned int i=0; i<fStore.size(); i++ ) {
55 for ( unsigned int j=0; j<fStore[i].fInstances.size(); j++ ) {
56 delete fStore[i].fInstances[j].fObject;
58 delete fStore[i].fMergedObject;
66 TObject* AliHLTEveHistoMerger::Process(const TObject * evtData, AliHLTUInt32_t spec)
68 // see header file for class documentation
69 //cout<<"\n\nDoEvent called"<<endl;
72 if ( !evtData ) return 0;
74 if ( !evtData->InheritsFrom(TH1::Class())
75 && !evtData->InheritsFrom(TSeqCollection::Class()) ) return 0;
77 std::cout<<"received object "<<evtData->GetName()<<" with id="<< spec << std::endl;
79 //search for the base entry, if not exist then create a new entry
82 for ( unsigned int i=0; i<fStore.size(); i++ ) {
83 if ( fStore[i].fInstances.size()<1 ) continue;
84 TObject * obj = fStore[i].fInstances[0].fObject;
86 if ( TString(obj->GetName()).CompareTo(evtData->GetName())==0) {
91 cout<<"Collection found: "<<iColl<<endl;
93 AliHLTGlobalHCCollection c;
97 iColl = fStore.size()-1;
99 fStore[iColl].fNeedToMerge = 1;
102 // search for the specific entry, if not exist then create a new one
104 AliHLTGlobalHCCollection &c = fStore[iColl];
107 for ( unsigned int i=0; i<c.fInstances.size(); i++ ) {
108 AliHLTGlobalHCInstance &inst = c.fInstances[i];
109 if ( inst.fHLTSpecification == spec ) {
114 cout<<"Instance found:"<<iSpec<<endl;
116 AliHLTGlobalHCInstance inst;
117 inst.fHLTSpecification = spec;
119 c.fInstances.push_back(inst);
120 iSpec = c.fInstances.size()-1;
122 delete c.fInstances[iSpec].fObject;
125 c.fInstances[iSpec].fObject = evtData->Clone();
127 cout<<"index = "<<iColl<<","<<iSpec<<endl;
132 for ( unsigned int jColl = 0; jColl<fStore.size(); jColl++) {
133 AliHLTGlobalHCCollection &c = fStore[jColl];
134 if ( !c.fNeedToMerge && c.fMergedObject ) continue;
135 if ( c.fInstances.size() <1 ) continue;
136 delete c.fMergedObject;
137 c.fMergedObject = c.fInstances[0].fObject->Clone();
139 for ( unsigned int i=1; i<c.fInstances.size(); i++ ) {
140 l.Add(c.fInstances[i].fObject);
143 if ( c.fMergedObject->InheritsFrom(TH1::Class()) ) {
144 TH1 *histo = dynamic_cast<TH1*>(c.fMergedObject);
145 if ( histo ) histo->Merge(&l);
147 else if ( c.fMergedObject->InheritsFrom(TSeqCollection::Class()) ) {
148 TSeqCollection *list = dynamic_cast<TSeqCollection*>(c.fMergedObject);
149 if ( list ) list->Merge(&l);
155 return fStore[iColl].fMergedObject;