StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtCosmicTrackMaker.cxx
1 /***************************************************************************
2  *
3  * $Id: StFgtCosmicTrackMaker.cxx,v 1.1 2012/01/31 23:25:35 avossen Exp $
4  * Author: C. K. Riley (ckriley@bnl.gov), Oct. 10 2011
5  *
6  ***************************************************************************
7  *
8  * Description: CosmicTrackMaker for the cosmic stand
9  *
10  ***************************************************************************
11  *
12  * $Log: StFgtCosmicTrackMaker.cxx,v $
13  * Revision 1.1 2012/01/31 23:25:35 avossen
14  * moved StFgtCosmicTrackMaker to StFgtPool
15  *
16  * Revision 1.12 2011/11/25 20:24:59 ckriley
17  * now will look at all possible point combinations for tracks and pick the best one
18  *
19  * Revision 1.11 2011/11/16 22:15:07 ckriley
20  * now looks at all points on quadrants and gets best track
21  *
22  * Revision 1.10 2011/11/09 20:56:58 ckriley
23  * working version for new containers
24  *
25  * Revision 1.9 2011/11/01 18:50:13 sgliske
26  * Updated to correspond with StEvent containers, take 2.
27  *
28  * Revision 1.8 2011/10/28 18:30:09 ckriley
29  * make things up-to-date
30  *
31  * Revision 1.7 2011/10/28 14:54:11 sgliske
32  * Changed to get StFgtEvent from StEvent rather than another maker.
33  * Added some sanity checks to ensure the algo has been set.
34  * Also pClusterAlgo changed to mClusterAlgoPtr to conform with STAR guidelines.
35  *
36  * Revision 1.5 2011/10/20 17:13:44 ckriley
37  * major update -> headers, tracks stored in StFgtEvent instead of StFgtDisc, changes to trackmaker and algorithms
38  *
39  *
40  **************************************************************************/
41 
42 #include "StFgtCosmicTrackMaker.h"
43 #include "StRoot/StEvent/StEvent.h"
44 #include "StRoot/StEvent/StFgtCollection.h"
45 #include "StRoot/StEvent/StFgtPoint.h"
46 
47 #include "StFgtICosmicTrackAlgo.h"
48 
49 // constructors
50 StFgtCosmicTrackMaker::StFgtCosmicTrackMaker(const Char_t* name ):
51  StMaker( name ), eventCounter(0) {
52  /* */
53 };
54 
55 // deconstructor
56 StFgtCosmicTrackMaker::~StFgtCosmicTrackMaker(){
57  // check if pointers were created, then make sure to delete them
58 };
59 
60 // set algorithm
61 Int_t StFgtCosmicTrackMaker::setCosmicTrackAlgo(StFgtICosmicTrackAlgo* algo) {
62  mCosmicTrackAlgoPtr=algo;
63  return kStOk;
64 }
65 
66 // initialize pointers to data
67 Int_t StFgtCosmicTrackMaker::Init(){
68  Int_t ierr = kStOk;
69 
70  if( !mCosmicTrackAlgoPtr ){
71  LOG_ERROR << "No algorithm yet set for StFgtCosmicTrackMaker" << endm;
72  ierr = kStErr;
73  };
74 
75  if( !ierr )
76  mCosmicTrackAlgoPtr->Init();
77 
78  return ierr;
79 };
80 
81 // extract points, calculate ODR line and calculate chi^2 for an event
83  Int_t ierr = kStOk;
84 
85  LOG_DEBUG <<"StFgtCosmicTrackMaker::Make()******************************************************************"<<endm;
86 
87  if( !mCosmicTrackAlgoPtr ){
88  LOG_ERROR << "No algorithm set for StFgtCosmicTrackMaker" << endm;
89  ierr = kStErr;
90  };
91 
92  StEvent* eventPtr = 0;
93  eventPtr = (StEvent*)GetInputDS("StEvent");
94 
95  if( !eventPtr ) {
96  LOG_ERROR << "Error getting pointer to StEvent from '" << ClassName() << "'" << endm;
97  ierr = kStErr;
98  };
99 
100  StFgtCollection* fgtCollectionPtr = 0;
101 
102  if( eventPtr ) {
103  fgtCollectionPtr=eventPtr->fgtCollection();
104  };
105 
106  if( !fgtCollectionPtr) {
107  LOG_ERROR << "Error getting pointer to StFgtCollection from '" << ClassName() << "'" << endm;
108  ierr = kStErr;
109  };
110 
111  StFgtPointCollection *pointCollectionPtr = 0;
112 
113  if( fgtCollectionPtr )
114  pointCollectionPtr = fgtCollectionPtr->getPointCollection();
115 
116  if( !pointCollectionPtr && !ierr ){
117  LOG_ERROR << "Error getting pointer to StFgtPointCollection from StFgtCollection" << endm;
118  ierr = kStErr;
119  };
120 
121  if( !ierr ){
122  // heart of cosmic trackmaker
123  //Int_t filledQuads = 0;
124 
125  StSPtrVecFgtPoint &pointVec = pointCollectionPtr->getPointVec();
126  StSPtrVecFgtPointIterator iter;
127 
128 /* with simple cluster algo, you would expect there to be more than 3pts
129  if( pointVec.size() > 3 ) {
130  LOG_WARN << "too many points! " << endl;
131  ierr=kStWarn;
132  }
133 */
134  // check to see if at least one point on each disc
135  Bool_t haveDisc[3];
136  Int_t count[3];
137  for(Int_t j=0; j<3; j++) {
138  haveDisc[j]=false;
139  count[j]=0;
140  }
141  for( iter = pointVec.begin(); iter != pointVec.end(); ++iter ){
142  StFgtPoint *hit = *iter;
143  Int_t discId = hit->getDisc();
144  if(discId<3) {haveDisc[discId]=true; count[discId]++;}
145  }
146  if(!haveDisc[0] || !haveDisc[1] || !haveDisc[2]) return ierr;
147 
148 /* ONLY 3 QUADS OF 6 HAVE POINTS, SO NOT ALL WILL HAVE POINTS
149  if( filledQuads != 0x07 ){
150  LOG_ERROR << "not every quadrant has one point." << endl;
151  ierr = kStErr;
152  }
153 */
154  if( ierr < kStErr )
155  mCosmicTrackAlgoPtr->makeCosmicTracks(*pointCollectionPtr, mTrackVec, eventCounter);
156  };
157 
158  ++eventCounter;
159 
160  return ierr;
161 };
162 
163 // finish
165  cout << "StFgtCosmicTrackMaker::Finish()" << endl;
166  return kStOk;
167 };
168 
169 // clear function
170 void StFgtCosmicTrackMaker::Clear( Option_t *opt ){
171  mTrackVec.clear();
172 };
173 
174 
175 ClassImp(StFgtCosmicTrackMaker);
176 
void Clear(Option_t *opt="")
User defined functions.
Definition: Stypes.h:44
Definition: Stypes.h:41
Represents a point in the FGT.
Definition: StFgtPoint.h:49