StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEventClusteringHints.cxx
1 /***************************************************************************
2  *
3  * $Id: StEventClusteringHints.cxx,v 2.43 2021/01/11 20:27:40 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Apr 2001
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StEventClusteringHints.cxx,v $
13  * Revision 2.43 2021/01/11 20:27:40 ullrich
14  * Updated to add FCS elements (Akio).
15  *
16  * Revision 2.42 2019/01/07 15:50:12 ullrich
17  * Added StTriggerData2019.
18  *
19  * Revision 2.41 2018/12/11 19:53:10 ullrich
20  * Added RICHf.
21  *
22  * Revision 2.40 2018/07/09 14:54:37 ullrich
23  * Changed to add ETof.
24  *
25  * Revision 2.39 2018/02/08 17:36:26 ullrich
26  * Changed for new EPD classes.
27  *
28  * Revision 2.38 2017/10/13 20:11:17 ullrich
29  * Changes to handle new StTriggerData2018.
30  *
31  * Revision 2.37 2016/12/08 18:59:31 ullrich
32  * Added hooks for StTriggerData2017.
33  *
34  * Revision 2.36 2015/12/02 08:20:25 ullrich
35  * Added fields for StTriggerData2016.
36  *
37  * Revision 2.35 2015/05/13 17:06:13 ullrich
38  * Added hooks and interfaces to Sst detector (part of HFT).
39  *
40  * Revision 2.34 2014/04/10 16:00:13 jeromel
41  * Changes to inlcude Ist structure (Thomas OK-ed / may revisit some comments)
42  *
43  * Revision 2.33 2013/03/05 14:42:45 ullrich
44  * Added StPxl hits and Containers.
45  *
46  * Revision 2.32 2012/12/10 16:00:49 ullrich
47  * Added 2013 trigger data hints.
48  *
49  * Revision 2.31 2012/04/16 20:28:37 ullrich
50  * Added StFgtCollection.
51  *
52  * Revision 2.30 2012/01/24 03:03:13 perev
53  * Open for new detectors
54  *
55  * Revision 2.29 2011/11/04 19:19:33 ullrich
56  * Added StTriggerData2012.
57  *
58  * Revision 2.28 2011/10/13 17:52:52 perev
59  * Fgt added
60  *
61  * Revision 2.27 2011/04/27 22:28:46 ullrich
62  * Add MTD.
63  *
64  * Revision 2.26 2011/02/01 19:47:36 ullrich
65  * Added HLT branch and hooks.
66  *
67  * Revision 2.25 2010/08/31 19:55:38 fisyak
68  * Remove SoftwareMonitors
69  *
70  * Revision 2.24 2010/04/07 14:40:27 ullrich
71  * Added StTriggerData2009.
72  *
73  * Revision 2.23 2010/01/08 22:43:44 ullrich
74  * Updates needed to add StFmsCollection and related classes.
75  *
76  * Revision 2.22 2009/11/23 22:22:25 ullrich
77  * Minor cleanup performed and hooks for RPS added.
78  *
79  * Revision 2.21 2008/12/22 20:36:54 ullrich
80  * Added hooks for new ToF (BTof)
81  *
82  * Revision 2.20 2007/11/19 19:31:42 ullrich
83  * Added class StTriggerData2008.
84  *
85  * Revision 2.19 2007/02/24 03:03:02 ullrich
86  * Added StTriggerData2007.
87  *
88  * Revision 2.18 2006/01/19 21:51:51 ullrich
89  * Added RnD collection.
90  *
91  * Revision 2.17 2004/11/02 21:19:25 ullrich
92  * Added StTriggerData2005 class.
93  *
94  * Revision 2.16 2003/12/23 21:58:28 ullrich
95  * Modifications to handle StTruggerData2004.
96  *
97  * Revision 2.15 2003/10/02 16:39:25 jeromel
98  * Unitialized data member mNameMap
99  *
100  * Revision 2.14 2003/07/25 19:47:37 ullrich
101  * Added StSPtrVecCalibrationVertex to I/O list.
102  *
103  * Revision 2.13 2003/04/16 17:48:32 ullrich
104  * Added StTriggerData and inherited classe(s).
105  *
106  * Revision 2.12 2003/01/30 18:37:55 ullrich
107  * Added Phmd and TriggerId stuff.
108  *
109  * Revision 2.11 2002/12/20 22:41:30 ullrich
110  * Added PMD.
111  *
112  * Revision 2.10 2002/02/19 16:42:05 ullrich
113  * Fixed bug: StDetectorState now StSPtrVecDetectorState.
114  *
115  * Revision 2.9 2002/01/03 20:59:33 ullrich
116  * Added BBC and FPD.
117  *
118  * Revision 2.8 2001/12/01 15:41:55 ullrich
119  * Added StDetectorState container hints.
120  *
121  * Revision 2.7 2001/11/07 21:19:43 ullrich
122  * Added L1 trigger.
123  *
124  * Revision 2.6 2001/10/15 23:15:50 ullrich
125  * Added StRunInfo.
126  *
127  * Revision 2.5 2001/05/30 17:45:54 perev
128  * StEvent branching
129  *
130  * Revision 2.4 2001/05/01 03:48:28 ullrich
131  * Added branch IDs.
132  *
133  * Revision 2.3 2001/04/23 19:28:53 ullrich
134  * Inherit from StObject. Not a singleton anymore.
135  *
136  * Revision 2.2 2001/04/20 00:50:48 ullrich
137  * Added new query methods.
138  *
139  * Revision 2.1 2001/04/06 17:47:20 ullrich
140  * Initial Revision
141  *
142  **************************************************************************/
143 #include "StEventClusteringHints.h"
144 #include <algorithm>
145 
146 static const char rcsid[] = "$Id: StEventClusteringHints.cxx,v 2.43 2021/01/11 20:27:40 ullrich Exp $";
147 
148 ClassImp(StEventClusteringHints)
149 
151 
152 StEventClusteringHints::StEventClusteringHints()
153 {
154  fParent = 0;
155  mNameMap= 0;
156 
157  setMiniDstMode();
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);
216 
217  setDstMode();
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);
276 }
277 
278 void
279 StEventClusteringHints::setDstMode()
280 {
281  if (mNameMap == &mDstMap) return;
282  mNameMap = &mDstMap;
283  if (fParent) fParent->Notify();
284 }
285 
286 void
287 StEventClusteringHints::setMiniDstMode()
288 {
289  if (mNameMap == &mMiniDstMap) return;
290  mNameMap = &mMiniDstMap;
291  if (fParent) fParent->Notify();
292 }
293 const char*
294 StEventClusteringHints::branchName(const char* classname) const
295 {
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";
299 }
300 
301 void
302 StEventClusteringHints::setBranch(const char* classname, const char* branchname, int id)
303 {
304  (*mNameMap)[string(classname)] = string(branchname);
305  mBranchIds[string(branchname)] = id;
306  if (fParent) fParent->Notify();
307 
308 }
309 
310 int
311 StEventClusteringHints::branchId(const char* branchname) const
312 {
313  map<string,int>::const_iterator i = mBranchIds.find(string(branchname));
314  return i != mBranchIds.end() ? i->second : 1;
315 }
316 
317 vector<string>
318 StEventClusteringHints::listOfBranches() const
319 {
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);
327  return result;
328 }
329 
330 vector<string>
331 StEventClusteringHints::listOfClasses() const
332 {
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());
338  return result;
339 }
340 
341 vector<string>
342 StEventClusteringHints::listOfClasses(const char* branchname) const
343 {
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());
349  return result;
350 }
351 
352 void
353 StEventClusteringHints::print(ostream& os)
354 {
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;
361  }
362 }
363 
364 static TBuffer& operator<<(TBuffer& buf, const map<string,string> &s)
365 {
366  TString ts1,ts2;
367  map<string,string>::const_iterator i;
368  buf << s.size();
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);}
372  return buf;
373 }
374 
375 static TBuffer& operator>>(TBuffer& buf, map<string,string> & s)
376 {
377  TString ts1,ts2; int i,size;
378  buf >> size;
379  for (i = 0;i<size;i++){
380  ts1.Streamer(buf); ts2.Streamer(buf);
381  s[string(ts1.Data())] = string(ts2.Data());}
382  return buf;
383 }
384 
385 static TBuffer& operator<<(TBuffer& buf, const map<string,int> &s)
386 {
387  TString ts1;
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);
392  buf << i->second;}
393  return buf;
394 }
395 
396 static TBuffer& operator>>(TBuffer& buf, map<string,int> & s)
397 {
398  TString ts1;
399  int i,size,ii;
400  buf >> size;
401  for (i = 0;i<size;i++){
402  ts1.Streamer(buf); buf>>ii;
403  s[string(ts1.Data())] = ii;}
404  return buf;
405 }
406 
407 
408 
409 void StEventClusteringHints::Streamer(TBuffer &R__b)
410 {
411 // Stream an object of class StEventClusteringHints
412 
413  UChar_t mode;
414  UInt_t R__s, R__c;
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;
418  R__b >> mDstMap;
419  R__b >> mMiniDstMap;
420  R__b >> mBranchIds;
421  R__b.CheckByteCount(R__s, R__c, Class());
422 
423  } else { /*writing*/
424  R__c = R__b.WriteVersion(Class(), kTRUE);
425  mode = (mNameMap == &mMiniDstMap);
426  R__b << mode;
427  R__b << mDstMap;
428  R__b << mMiniDstMap;
429  R__b << mBranchIds;
430  R__b.SetByteCount(R__c, kTRUE);
431  }
432 }