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