143 #include "StEventClusteringHints.h"
146 static const char rcsid[] =
"$Id: StEventClusteringHints.cxx,v 2.43 2021/01/11 20:27:40 ullrich Exp $";
152 StEventClusteringHints::StEventClusteringHints()
158 setBranch(
"StRunInfo",
"evt_header", 2);
159 setBranch(
"StEventInfo",
"evt_header", 2);
160 setBranch(
"StEventSummary",
"evt_header", 2);
161 setBranch(
"StSPtrVecDetectorState",
"evt_header", 2);
162 setBranch(
"StEventClusteringHints",
"evt_header", 2);
163 setBranch(
"StL0Trigger",
"evt_trigger", 3);
164 setBranch(
"StL1Trigger",
"evt_trigger", 3);
165 setBranch(
"StL3Trigger",
"evt_trigger", 3);
166 setBranch(
"StTriggerDetectorCollection",
"evt_trigger", 3);
167 setBranch(
"StTriggerIdCollection",
"evt_trigger", 3);
168 setBranch(
"StTriggerData",
"evt_trigger", 3);
169 setBranch(
"StTriggerData2003",
"evt_trigger", 3);
170 setBranch(
"StTriggerData2004",
"evt_trigger", 3);
171 setBranch(
"StTriggerData2005",
"evt_trigger", 3);
172 setBranch(
"StTriggerData2007",
"evt_trigger", 3);
173 setBranch(
"StTriggerData2008",
"evt_trigger", 3);
174 setBranch(
"StTriggerData2009",
"evt_trigger", 3);
175 setBranch(
"StTriggerData2012",
"evt_trigger", 3);
176 setBranch(
"StTriggerData2013",
"evt_trigger", 3);
177 setBranch(
"StTriggerData2016",
"evt_trigger", 3);
178 setBranch(
"StTriggerData2017",
"evt_trigger", 3);
179 setBranch(
"StTriggerData2018",
"evt_trigger", 3);
180 setBranch(
"StTriggerData2019",
"evt_trigger", 3);
181 setBranch(
"StTriggerData2022",
"evt_trigger", 3);
182 setBranch(
"StSPtrVecTrackDetectorInfo",
"evt_tracks", 4);
183 setBranch(
"StSPtrVecPrimaryVertex",
"evt_tracks", 4);
184 setBranch(
"StSPtrVecTrackNode",
"evt_tracks", 4);
185 setBranch(
"StFwdTrackCollection",
"evt_tracks", 4);
186 setBranch(
"StSPtrVecKinkVertex",
"evt_vertices", 5);
187 setBranch(
"StSPtrVecV0Vertex",
"evt_vertices", 5);
188 setBranch(
"StSPtrVecXiVertex",
"evt_vertices", 5);
189 setBranch(
"StSPtrVecCalibrationVertex",
"evt_vertices", 5);
190 setBranch(
"StEmcCollection",
"evt_emc", 6);
191 setBranch(
"StFmsCollection",
"evt_emc", 6);
192 setBranch(
"StFcsCollection",
"evt_emc", 6);
193 setBranch(
"StRHICfCollection",
"evt_emc", 6);
194 setBranch(
"StRichCollection",
"evt_aux", 7);
195 setBranch(
"StTofCollection",
"evt_aux", 7);
196 setBranch(
"StBTofCollection",
"evt_aux", 7);
197 setBranch(
"StETofCollection",
"evt_aux", 7);
198 setBranch(
"StEpdCollection",
"evt_aux", 7);
199 setBranch(
"StMtdCollection",
"evt_aux", 7);
200 setBranch(
"StFpdCollection",
"evt_aux", 7);
201 setBranch(
"StPhmdCollection",
"evt_aux", 7);
202 setBranch(
"StRpsCollection",
"evt_aux", 7);
203 setBranch(
"StFttCollection",
"evt_aux", 7);
204 setBranch(
"StFstEvtCollection",
"evt_aux", 7);
205 setBranch(
"StSsdHitCollection",
"evt_hits", 8);
206 setBranch(
"StSstHitCollection",
"evt_hits", 8);
207 setBranch(
"StSvtHitCollection",
"evt_hits", 8);
208 setBranch(
"StIstHitCollection",
"evt_hits", 8);
209 setBranch(
"StFstHitCollection",
"evt_hits", 8);
210 setBranch(
"StPxlHitCollection",
"evt_hits", 8);
211 setBranch(
"StTpcHitCollection",
"evt_hits", 8);
212 setBranch(
"StFtpcHitCollection",
"evt_hits", 8);
213 setBranch(
"StRnDHitCollection",
"evt_hits", 8);
214 setBranch(
"StHltEvent",
"evt_hlt", 9);
215 setBranch(
"StFgtCollection",
"evt_fgt", 9);
218 setBranch(
"StRunInfo",
"event", 1);
219 setBranch(
"StEventInfo",
"event", 1);
220 setBranch(
"StEventSummary",
"event", 1);
221 setBranch(
"StSPtrVecDetectorState",
"event", 1);
222 setBranch(
"StEventClusteringHints",
"event", 1);
223 setBranch(
"StEmcCollection",
"event", 1);
224 setBranch(
"StFmsCollection",
"event", 1);
225 setBranch(
"StFcsCollection",
"event", 1);
226 setBranch(
"StFttCollection",
"event", 1);
227 setBranch(
"StRHICfCollection",
"event", 1);
228 setBranch(
"StRichCollection",
"event", 1);
229 setBranch(
"StTofCollection",
"event", 1);
230 setBranch(
"StBTofCollection",
"event", 1);
231 setBranch(
"StETofCollection",
"event", 1);
232 setBranch(
"StEpdCollection",
"event", 1);
233 setBranch(
"StMtdCollection",
"event", 1);
234 setBranch(
"StFpdCollection",
"event", 1);
235 setBranch(
"StRpsCollection",
"event", 1);
236 setBranch(
"StSsdHitCollection",
"event", 1);
237 setBranch(
"StSstHitCollection",
"event", 1);
238 setBranch(
"StSvtHitCollection",
"event", 1);
239 setBranch(
"StIstHitCollection",
"event", 1);
240 setBranch(
"StFstEvtCollection",
"event", 1);
241 setBranch(
"StFstHitCollection",
"event", 1);
242 setBranch(
"StPxlHitCollection",
"event", 1);
243 setBranch(
"StTpcHitCollection",
"event", 1);
244 setBranch(
"StFtpcHitCollection",
"event", 1);
245 setBranch(
"StL0Trigger",
"event", 1);
246 setBranch(
"StL1Trigger",
"event", 1);
247 setBranch(
"StL3Trigger",
"event", 1);
248 setBranch(
"StTriggerDetectorCollection",
"event", 1);
249 setBranch(
"StTriggerIdCollection",
"event", 1);
250 setBranch(
"StTriggerData",
"event", 1);
251 setBranch(
"StTriggerData2003",
"event", 1);
252 setBranch(
"StTriggerData2004",
"event", 1);
253 setBranch(
"StTriggerData2005",
"event", 1);
254 setBranch(
"StTriggerData2007",
"event", 1);
255 setBranch(
"StTriggerData2008",
"event", 1);
256 setBranch(
"StTriggerData2009",
"event", 1);
257 setBranch(
"StTriggerData2012",
"event", 1);
258 setBranch(
"StTriggerData2013",
"event", 1);
259 setBranch(
"StTriggerData2016",
"event", 1);
260 setBranch(
"StTriggerData2017",
"event", 1);
261 setBranch(
"StTriggerData2018",
"event", 1);
262 setBranch(
"StTriggerData2019",
"event", 1);
263 setBranch(
"StTriggerData2022",
"event", 1);
264 setBranch(
"StSPtrVecKinkVertex",
"event", 1);
265 setBranch(
"StSPtrVecV0Vertex",
"event", 1);
266 setBranch(
"StSPtrVecXiVertex",
"event", 1);
267 setBranch(
"StSPtrVecTrackDetectorInfo",
"event", 1);
268 setBranch(
"StSPtrVecCalibrationVertex",
"event", 1);
269 setBranch(
"StSPtrVecPrimaryVertex",
"event", 1);
270 setBranch(
"StSPtrVecTrackNode",
"event", 1);
271 setBranch(
"StPhmdCollection",
"event", 1);
272 setBranch(
"StRnDHitCollection",
"event", 1);
273 setBranch(
"StHltEvent",
"event", 1);
274 setBranch(
"StFgtCollection",
"event", 1);
275 setBranch(
"StFwdTrackCollection",
"event", 1);
279 StEventClusteringHints::setDstMode()
281 if (mNameMap == &mDstMap)
return;
283 if (fParent) fParent->Notify();
287 StEventClusteringHints::setMiniDstMode()
289 if (mNameMap == &mMiniDstMap)
return;
290 mNameMap = &mMiniDstMap;
291 if (fParent) fParent->Notify();
294 StEventClusteringHints::branchName(
const char* classname)
const
296 if (strstr(classname,
"Hit"))
return "evt_hits";
297 map<string,string>::const_iterator i = mNameMap->find(
string(classname));
298 return i != mNameMap->end() ? i->second.c_str() :
"event";
302 StEventClusteringHints::setBranch(
const char* classname,
const char* branchname,
int id)
304 (*mNameMap)[string(classname)] = string(branchname);
305 mBranchIds[string(branchname)] = id;
306 if (fParent) fParent->Notify();
311 StEventClusteringHints::branchId(
const char* branchname)
const
313 map<string,int>::const_iterator i = mBranchIds.find(
string(branchname));
314 return i != mBranchIds.end() ? i->second : 1;
318 StEventClusteringHints::listOfBranches()
const
320 vector<string> result, tmp;
321 map<string,string>::iterator i;
322 for (i = mNameMap->begin(); i != mNameMap->end(); i++)
323 tmp.push_back(i->second);
324 sort(tmp.begin(), tmp.end());
325 insert_iterator<vector<string> > ins(result, result.begin());
326 unique_copy(tmp.begin(), tmp.end(), ins);
331 StEventClusteringHints::listOfClasses()
const
333 vector<string> result;
334 map<string,string>::iterator i;
335 for (i = mNameMap->begin(); i != mNameMap->end(); i++)
336 result.push_back(i->first);
337 sort(result.begin(), result.end());
342 StEventClusteringHints::listOfClasses(
const char* branchname)
const
344 vector<string> result;
345 map<string,string>::iterator i;
346 for (i = mNameMap->begin(); i != mNameMap->end(); i++)
347 if (
string(branchname) == i->second) result.push_back(i->first);
348 sort(result.begin(), result.end());
353 StEventClusteringHints::print(ostream& os)
355 vector<string> branches = listOfBranches();
356 for (
unsigned int j=0; j<branches.size(); j++) {
357 vector<string> classes = listOfClasses(branches[j].c_str());
358 cout << branches[j] <<
"[id=" << branchId(branches[j].c_str()) <<
"]" << endl;
359 for (
unsigned int k=0; k<classes.size(); k++)
360 cout <<
'\t' << classes[k] << endl;
364 static TBuffer& operator<<(TBuffer& buf, const map<string,string> &s)
367 map<string,string>::const_iterator i;
369 for (i = s.begin(); i != s.end(); i++){
370 ts1 = i->first. c_str(); ts1.Streamer(buf);
371 ts2 = i->second.c_str(); ts2.Streamer(buf);}
375 static TBuffer& operator>>(TBuffer& buf, map<string,string> & s)
377 TString ts1,ts2;
int i,size;
379 for (i = 0;i<size;i++){
380 ts1.Streamer(buf); ts2.Streamer(buf);
381 s[string(ts1.Data())] =
string(ts2.Data());}
385 static TBuffer& operator<<(TBuffer& buf, const map<string,int> &s)
388 map<string,int>::const_iterator i;
389 int size = s.size();buf << size;
390 for (i = s.begin(); i != s.end(); i++){
391 ts1 = i->first.c_str(); ts1.Streamer(buf);
396 static TBuffer& operator>>(TBuffer& buf, map<string,int> & s)
401 for (i = 0;i<size;i++){
402 ts1.Streamer(buf); buf>>ii;
403 s[string(ts1.Data())] = ii;}
409 void StEventClusteringHints::Streamer(TBuffer &R__b)
415 if (R__b.IsReading()) {
416 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v) { }
417 R__b >> mode; mNameMap=(mode)? &mMiniDstMap:&mDstMap;
421 R__b.CheckByteCount(R__s, R__c, Class());
424 R__c = R__b.WriteVersion(Class(), kTRUE);
425 mode = (mNameMap == &mMiniDstMap);
430 R__b.SetByteCount(R__c, kTRUE);