StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StuCounter.hh
1 /***************************************************************************
2  *
3  * $Id: StuCounter.hh,v 1.1 1999/12/15 15:05:20 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Dec 1999
6  ***************************************************************************
7  *
8  * Description:
9  * Set of functions which perform simple counting
10  * tasks. All functions are inline function and one
11  * only needs to include the header file to use them.
12  * No need to link with any library.
13  *
14  * Syntax:
15  * unsigned int numberOfTracks(StEvent& evt, StTrackType ttyp,
16  * unsigned int minHits = 0);
17  * Returns number of tracks in event 'evt' of type 'ttyp' (global/primary)
18  * with greater or equal 'minHits' hits. 'minHits' default to 0.
19  *
20  * There are two related specialised functions for the two track types:
21  * unsigned int numberOfGlobalTracks(StEvent& evt, unsigned int minHits = 0);
22  * unsigned int numberOfTracks(StEvent& evt, unsigned int minHits = 0);
23  * Examples:
24  * int n = numberOfTracks(evt, global);
25  * int m = numberOfGlobalTracks(evt); // same as above
26  * int k = numberOfPrimaryTracks(evt, 10); // primary tracks with >= 10 hits
27  * int k = numberOfTracks(evt,primary, 10); // same as above
28  *
29  ***************************************************************************
30  *
31  * $Log: StuCounter.hh,v $
32  * Revision 1.1 1999/12/15 15:05:20 ullrich
33  * Initial Revision
34  *
35  **************************************************************************/
36 #ifndef StStuCounter_hh
37 #define StStuCounter_hh
38 
39 #include "StEventTypes.h"
40 
41 inline unsigned int
42 numberOfTracks(StEvent& evt, StTrackType ttyp, unsigned int minHits = 0)
43 {
44  StSPtrVecTrackNode& nodes = evt.trackNodes();
45  unsigned int sum = 0;
46  unsigned int i, j, n;
47 
48  if (minHits) {
49  for (i=0; i<nodes.size(); i++) {
50  n = nodes[i]->entries(ttyp);
51  for (j=0; j<n; j++)
52  if (nodes[i]->track(ttyp, j)->detectorInfo()->numberOfPoints() >= minHits)
53  sum++;
54  }
55  }
56  else {
57  for (i=0; i<nodes.size(); i++)
58  sum += nodes[i]->entries(ttyp);
59  }
60  return sum;
61 }
62 
63 inline unsigned int
64 numberOfGlobalTracks(StEvent& evt, unsigned int minHits = 0)
65 {
66  return numberOfTracks(evt, global, minHits);
67 }
68 
69 inline unsigned int
70 numberOfPrimaryTracks(StEvent& evt, unsigned int minHits = 0)
71 {
72  return numberOfTracks(evt, primary, minHits);
73 }
74 
75 #endif