]>
Commit | Line | Data |
---|---|---|
34b10fb1 | 1 | |
2 | //************************************************************************** | |
3 | //* This file is property of and copyright by the ALICE HLT Project * | |
4 | //* ALICE Experiment at CERN, All rights reserved. * | |
5 | //* * | |
6 | //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> * | |
7 | //* for The ALICE HLT Project. * | |
8 | //* * | |
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 | //************************************************************************** | |
17 | ||
18 | /** @file AliHLTEveHistoMerger.cxx | |
19 | @author Kalliopi Kanaki | |
20 | @date | |
21 | @brief The Histogram Handler component | |
22 | */ | |
23 | ||
34b10fb1 | 24 | #include "AliHLTEveHistoMerger.h" |
25 | #include "AliCDBEntry.h" | |
26 | #include "AliCDBManager.h" | |
27 | #include "TString.h" | |
28 | #include "TObjArray.h" | |
29 | #include "TObjString.h" | |
30 | #include "TH1.h" | |
31 | #include "TTimeStamp.h" | |
32 | #include "TSystem.h" | |
33 | #include <iostream> | |
34 | ||
a7f38894 | 35 | using namespace std; |
36 | ||
34b10fb1 | 37 | AliHLTEveHistoMerger::AliHLTEveHistoMerger() |
38 | : | |
39 | fStore() | |
40 | { | |
41 | } | |
42 | ||
43 | AliHLTEveHistoMerger::~AliHLTEveHistoMerger() { | |
44 | // see header file for class documentation | |
45 | Clear(); | |
46 | } | |
47 | ||
48 | ||
49 | ||
50 | void AliHLTEveHistoMerger::Clear() | |
51 | { | |
52 | // reset the store | |
53 | ||
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; | |
57 | } | |
58 | delete fStore[i].fMergedObject; | |
59 | } | |
60 | fStore.clear(); | |
61 | } | |
62 | ||
63 | ||
64 | ||
65 | ||
66 | TObject* AliHLTEveHistoMerger::Process(const TObject * evtData, AliHLTUInt32_t spec) | |
67 | { | |
68 | // see header file for class documentation | |
69 | //cout<<"\n\nDoEvent called"<<endl; | |
70 | ||
71 | ||
72 | if ( !evtData ) return 0; | |
73 | ||
74 | if ( !evtData->InheritsFrom(TH1::Class()) | |
75 | && !evtData->InheritsFrom(TSeqCollection::Class()) ) return 0; | |
76 | ||
77 | std::cout<<"received object "<<evtData->GetName()<<" with id="<< spec << std::endl; | |
78 | ||
79 | //search for the base entry, if not exist then create a new entry | |
80 | ||
81 | int iColl = -1; | |
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; | |
85 | if ( !obj ) continue; | |
86 | if ( TString(obj->GetName()).CompareTo(evtData->GetName())==0) { | |
87 | iColl = i; | |
88 | break; | |
89 | } | |
90 | } | |
91 | cout<<"Collection found: "<<iColl<<endl; | |
92 | if ( iColl<0 ) { | |
93 | AliHLTGlobalHCCollection c; | |
94 | c.fMergedObject = 0; | |
95 | c.fNeedToMerge = 1; | |
96 | fStore.push_back(c); | |
97 | iColl = fStore.size()-1; | |
98 | } else { | |
99 | fStore[iColl].fNeedToMerge = 1; | |
100 | } | |
101 | ||
102 | // search for the specific entry, if not exist then create a new one | |
103 | { | |
104 | AliHLTGlobalHCCollection &c = fStore[iColl]; | |
105 | ||
106 | int iSpec=-1; | |
107 | for ( unsigned int i=0; i<c.fInstances.size(); i++ ) { | |
108 | AliHLTGlobalHCInstance &inst = c.fInstances[i]; | |
109 | if ( inst.fHLTSpecification == spec ) { | |
110 | iSpec = i; | |
111 | break; | |
112 | } | |
113 | } | |
114 | cout<<"Instance found:"<<iSpec<<endl; | |
115 | if ( iSpec<0 ) { | |
116 | AliHLTGlobalHCInstance inst; | |
117 | inst.fHLTSpecification = spec; | |
118 | inst.fObject = 0; | |
119 | c.fInstances.push_back(inst); | |
120 | iSpec = c.fInstances.size()-1; | |
121 | } else { | |
122 | delete c.fInstances[iSpec].fObject; | |
123 | } | |
124 | ||
125 | c.fInstances[iSpec].fObject = evtData->Clone(); | |
126 | ||
127 | cout<<"index = "<<iColl<<","<<iSpec<<endl; | |
128 | } | |
129 | ||
130 | // merge histos | |
131 | ||
123f3721 | 132 | for ( unsigned int jColl = 0; jColl<fStore.size(); jColl++) { |
133 | AliHLTGlobalHCCollection &c = fStore[jColl]; | |
34b10fb1 | 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(); | |
138 | TList l; | |
139 | for ( unsigned int i=1; i<c.fInstances.size(); i++ ) { | |
140 | l.Add(c.fInstances[i].fObject); | |
141 | } | |
142 | ||
143 | if ( c.fMergedObject->InheritsFrom(TH1::Class()) ) { | |
144 | TH1 *histo = dynamic_cast<TH1*>(c.fMergedObject); | |
145 | if ( histo ) histo->Merge(&l); | |
146 | } | |
147 | else if ( c.fMergedObject->InheritsFrom(TSeqCollection::Class()) ) { | |
148 | TSeqCollection *list = dynamic_cast<TSeqCollection*>(c.fMergedObject); | |
149 | if ( list ) list->Merge(&l); | |
150 | } | |
151 | c.fNeedToMerge = 0; | |
152 | ||
153 | } | |
154 | ||
155 | return fStore[iColl].fMergedObject; | |
156 | ||
157 | } | |
158 |