00001 /*************************************************************************** 00002 * 00003 * $Id: StuCounter.hh,v 1.1 1999/12/15 15:05:20 ullrich Exp $ 00004 * 00005 * Author: Thomas Ullrich, Dec 1999 00006 *************************************************************************** 00007 * 00008 * Description: 00009 * Set of functions which perform simple counting 00010 * tasks. All functions are inline function and one 00011 * only needs to include the header file to use them. 00012 * No need to link with any library. 00013 * 00014 * Syntax: 00015 * unsigned int numberOfTracks(StEvent& evt, StTrackType ttyp, 00016 * unsigned int minHits = 0); 00017 * Returns number of tracks in event 'evt' of type 'ttyp' (global/primary) 00018 * with greater or equal 'minHits' hits. 'minHits' default to 0. 00019 * 00020 * There are two related specialised functions for the two track types: 00021 * unsigned int numberOfGlobalTracks(StEvent& evt, unsigned int minHits = 0); 00022 * unsigned int numberOfTracks(StEvent& evt, unsigned int minHits = 0); 00023 * Examples: 00024 * int n = numberOfTracks(evt, global); 00025 * int m = numberOfGlobalTracks(evt); // same as above 00026 * int k = numberOfPrimaryTracks(evt, 10); // primary tracks with >= 10 hits 00027 * int k = numberOfTracks(evt,primary, 10); // same as above 00028 * 00029 *************************************************************************** 00030 * 00031 * $Log: StuCounter.hh,v $ 00032 * Revision 1.1 1999/12/15 15:05:20 ullrich 00033 * Initial Revision 00034 * 00035 **************************************************************************/ 00036 #ifndef StStuCounter_hh 00037 #define StStuCounter_hh 00038 00039 #include "StEventTypes.h" 00040 00041 inline unsigned int 00042 numberOfTracks(StEvent& evt, StTrackType ttyp, unsigned int minHits = 0) 00043 { 00044 StSPtrVecTrackNode& nodes = evt.trackNodes(); 00045 unsigned int sum = 0; 00046 unsigned int i, j, n; 00047 00048 if (minHits) { 00049 for (i=0; i<nodes.size(); i++) { 00050 n = nodes[i]->entries(ttyp); 00051 for (j=0; j<n; j++) 00052 if (nodes[i]->track(ttyp, j)->detectorInfo()->numberOfPoints() >= minHits) 00053 sum++; 00054 } 00055 } 00056 else { 00057 for (i=0; i<nodes.size(); i++) 00058 sum += nodes[i]->entries(ttyp); 00059 } 00060 return sum; 00061 } 00062 00063 inline unsigned int 00064 numberOfGlobalTracks(StEvent& evt, unsigned int minHits = 0) 00065 { 00066 return numberOfTracks(evt, global, minHits); 00067 } 00068 00069 inline unsigned int 00070 numberOfPrimaryTracks(StEvent& evt, unsigned int minHits = 0) 00071 { 00072 return numberOfTracks(evt, primary, minHits); 00073 } 00074 00075 #endif
1.5.9