StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFtpcTrackMaker.cxx
1 // $Id: StFtpcTrackMaker.cxx,v 1.93 2012/11/07 23:30:18 fisyak Exp $
2 // $Log: StFtpcTrackMaker.cxx,v $
3 // Revision 1.93 2012/11/07 23:30:18 fisyak
4 // Supress warnings
5 //
6 // Revision 1.92 2009/11/25 19:50:21 jcs
7 // remove all references to StFtpcSoftwareMonitor
8 //
9 // Revision 1.91 2009/11/24 11:54:01 jcs
10 // Remove dst_vertex_st code commented out by Yuri
11 //
12 // Revision 1.90 2009/11/23 16:38:11 fisyak
13 // Remove dependence on dst_vertex_st
14 //
15 // Revision 1.89 2008/10/02 16:21:01 jcs
16 // standardize m_Mode LOG_INFO messages
17 //
18 // Revision 1.88 2008/05/13 12:20:58 jcs
19 // only write FTPC calibration vertices with successful fit to StEvent
20 //
21 // Revision 1.87 2008/01/07 14:45:06 jcs
22 // create and fill the special set of Ftpc track histograms used to evaluate
23 // the Ftpc gain scan runs when the bfc option fgain is in the chain
24 //
25 // Revision 1.86 2007/12/12 12:49:34 jcs
26 // remove assert() and replace LOG_WARN with LOG_ERROR messages
27 //
28 // Revision 1.85 2007/12/11 09:36:39 jcs
29 // Remove m_nrec_track histogram (never used)
30 //
31 // Revision 1.84 2007/11/30 09:19:54 jcs
32 // Use the first primary vertex if any primary vertex exists
33 // Multiple primary vertices have been ordered in StEvent
34 //
35 // Revision 1.83 2007/05/08 09:02:35 jcs
36 // move database initialization from Init to InitRun as requested by Victor and Yuri
37 // redefine m_nrec_track histogram and only fill if debug option on
38 //
39 // Revision 1.82 2007/04/27 17:04:27 jcs
40 // forgot to check if bfc option debug is on before filling vertex by sector histograms
41 //
42 // Revision 1.81 2007/04/27 15:39:28 jcs
43 // Removed obsolete histogram (fpt_theta)
44 // Only create and fill FTPC vertex by sector histograms if bfc debug option is on
45 //
46 // Revision 1.80 2007/02/28 13:31:27 jcs
47 // temporary fix: add explanation why accessing ftpcDimensions and ftpcPadRowZ
48 // in Init doesn't cause problems
49 //
50 // Revision 1.79 2007/01/15 08:23:02 jcs
51 // replace printf, cout and gMesMgr with Logger commands
52 //
53 // Revision 1.78 2006/11/09 13:58:37 jcs
54 // bfc option fdbg selected if m_Mode>=2
55 //
56 // Revision 1.77 2006/09/27 11:00:31 jcs
57 // comment out ftpc vs. tpc vertex histogram definitions, they are defined and filled in St_QA_Maker
58 //
59 // Revision 1.76 2006/08/25 07:57:33 jcs
60 // remove debug printout
61 //
62 // Revision 1.75 2006/03/19 19:25:06 jcs
63 // Select LASERTRACKING with bfc option 'flaser' (otherwise TWOCYCLETRACKING is used)
64 // Create DEBUGFILE with bfc option 'fdbg'
65 //
66 // Revision 1.74 2006/03/13 19:46:35 jcs
67 // make changes necessary fot DoT0Calib
68 //
69 // Revision 1.73 2005/06/30 09:21:48 jcs
70 // extend histogram limits to make gasGain determination easier
71 //
72 // Revision 1.72 2005/03/01 23:02:11 jcs
73 // Correct error: TWOCYCLETRACKING should be standard, not LASERTRACKING
74 //
75 // Revision 1.71 2004/12/10 23:07:37 jcs
76 // Only fill FTPC software monitor if it exists
77 //
78 // Revision 1.70 2004/11/23 19:18:16 jcs
79 // Store FTPC vertices (east and west) in StEvent/StCalibrationVertex
80 // Comment out (should eventually be removed) Ftpc vertex - Tpc vertex histograms,
81 // they are now filled in StEventQAMaker.cxx
82 //
83 // Revision 1.69 2004/09/27 14:17:03 jcs
84 // pad vs. time histograms moved to St_QA_Maker
85 //
86 // Revision 1.68 2004/09/07 14:06:19 jcs
87 // use the IAttr(".histos") to control histogramming
88 //
89 // Revision 1.67 2004/09/03 20:36:22 perev
90 // Big LeakOff + mem optimisation
91 //
92 // Revision 1.66 2004/08/10 12:42:10 jcs
93 // move DEBUGFILE and tracking method define statements from .h to .cxx
94 //
95 // Revision 1.65 2004/08/10 12:21:42 jcs
96 // remove histograms which are also created in St_QA_Maker
97 //
98 // Revision 1.64 2004/08/09 15:08:14 jcs
99 // remove unused histogram
100 //
101 // Revision 1.63 2004/06/18 12:07:41 jcs
102 // replace #ifdef...#elif...#endif conditional compiler directives with #ifdef...#endif #ifdef...#endif
103 //
104 // Revision 1.62 2004/06/18 09:07:03 jcs
105 // add code to write out a root file for calibration
106 //
107 // Revision 1.61 2004/06/04 11:04:15 jcs
108 // replaced StarDb/ftpc/fdepars/fdepar with StarDb/ftpc/ftpcdEdxPars
109 //
110 // Revision 1.60 2004/05/25 07:25:47 jcs
111 // initialize StFtpcSoftwareMonitor*ftpcMon
112 //
113 // Revision 1.59 2004/05/24 13:46:39 jcs
114 // fill StFtpcSoftwareMonitor not dst_mon_soft_ftpc
115 //
116 // Revision 1.58 2004/05/19 17:45:06 oldi
117 // *** empty log message ***
118 //
119 // Revision 1.57 2004/05/07 15:02:18 oldi
120 // Tracks are written to StEvent directly, now.
121 // Primary Vertex is read from StEvent.
122 // MonSoftDst table is filled here now (was filled in the now obsolete StFtpcGlobalMaker before).
123 //
124 // Revision 1.56 2004/04/26 09:53:45 jcs
125 // comment out delete StFtpcTrackingParams::Instance() in FinishRun as a temorary
126 // fix for Bug #372
127 //
128 // Revision 1.55 2004/03/22 16:02:03 oldi
129 // Moved destruction of the instance of StFtpcTrackingParams from Finish() to FinishRun().
130 //
131 // Revision 1.54 2004/02/13 21:12:19 oldi
132 // Protection against missing FTPC DAQ data added.
133 //
134 // Revision 1.53 2004/02/12 19:37:11 oldi
135 // *** empty log message ***
136 //
137 // Revision 1.52 2004/02/05 00:24:54 oldi
138 // Eliminating a bug concerning a test of the wrong pointer to a vertex.
139 //
140 // Revision 1.51 2004/01/28 01:41:32 jeromel
141 // *** empty log message ***
142 //
143 // Revision 1.50 2003/10/07 14:08:33 jcs
144 // remove previous fix for determining magnetic field
145 //
146 // Revision 1.49 2003/09/26 06:08:55 oldi
147 // Check if the magentic field was reversed 'by hand' with a chain option.
148 // If yes, multiply the scaleFactor of the field with -1.
149 //
150 // Revision 1.48 2003/09/02 17:58:16 perev
151 // gcc 3.2 updates + WarnOff
152 //
153 // Revision 1.47 2003/07/07 20:29:30 oldi
154 // Pointer to geant taken out (no actual code change).
155 //
156 // Revision 1.46 2003/07/04 14:09:31 fsimon
157 // SlowSimulator now rotates hits: Check for simulated hits before rotation
158 // commented out.
159 //
160 // Revision 1.45 2003/05/20 18:34:57 oldi
161 // Cuts for vertex estimation introduced (globDca < 1 cm, multiplicity >= 200).
162 //
163 // Revision 1.44 2003/02/21 01:14:03 oldi
164 // Unnecessary call of database "Geometry/tpc" removed.
165 //
166 // Revision 1.43 2003/01/20 13:11:56 oldi
167 // Floats converted to ints to avoid warnings on linux machines.
168 //
169 // Revision 1.42 2003/01/16 18:04:34 oldi
170 // Bugs eliminated. Now it compiles on Solaris again.
171 // Split residuals for global and primary fit.
172 //
173 // Revision 1.41 2002/11/06 13:46:46 oldi
174 // Vertex handling simplifed.
175 // Global/primary fit handling simplified.
176 // Vertex estimations only calculated if a vertex was used for tracking.
177 // Code clean ups.
178 //
179 // Revision 1.40 2002/10/31 13:40:52 oldi
180 // dE/dx parameters read from database.
181 // Calibration parameters read from database.
182 // Vertex estimation for different sectors added.
183 // Vertex estimation switched off for events with no tracks.
184 //
185 // Revision 1.39 2002/10/11 15:45:31 oldi
186 // Get FTPC geometry and dimensions from database.
187 // No field fit activated: Returns momentum = 0 but fits a helix.
188 // Bug in TrackMaker fixed (events with z_vertex > outer_ftpc_radius were cut).
189 // QA histograms corrected (0 was supressed).
190 // Code cleanup (several lines of code changed due to *params -> Instance()).
191 // cout -> gMessMgr.
192 //
193 // Revision 1.38 2002/10/03 10:34:01 oldi
194 // Usage of gufld removed.
195 // Magnetic field is read by StMagUtilities, now.
196 //
197 // Revision 1.37 2002/09/07 21:30:52 jeromel
198 // Syntax correct ")" or "(" at the begining of a line seems to make gcc crash
199 // in optimize flags.
200 //
201 // Revision 1.36 2002/08/02 11:15:21 oldi
202 // Tracking is performed even if no primary vertex is found. In this case
203 // (0., 0., 0.) is used as vertex position.
204 // Minor cosmetics.
205 //
206 // Revision 1.35 2002/06/06 15:59:18 oldi
207 // Local -> global transformation is only done if the event isn't simulated.
208 //
209 // Revision 1.34 2002/06/04 13:39:26 oldi
210 // After tracking local coordinates are transformed to global coordinates.
211 // Points are written to the table again. This causes a loss of symmetry which
212 // was used while the tracking was done. Due to the fact that the main vertex
213 // is measured in global coordinates, the subsequent momentum fit is done
214 // correctly.
215 //
216 // Revision 1.33 2002/04/29 15:50:10 oldi
217 // All tracking parameters moved to StFtpcTrackingParameters.cc/hh.
218 // In a future version the actual values should be moved to an .idl file (the
219 // interface should be kept as is in StFtpcTrackingParameters.cc/hh).
220 //
221 // Revision 1.32 2002/04/09 16:10:13 oldi
222 // Method to get the magentic field factor moved to StFormulary. It works for
223 // simulation as well, now.
224 //
225 // Revision 1.31 2002/04/08 15:38:04 oldi
226 // Switch for magnetic field factor installed.
227 // Minor corrections/improvements.
228 //
229 // Revision 1.30 2002/04/05 16:51:00 oldi
230 // Cleanup of MomentumFit (StFtpcMomentumFit is now part of StFtpcTrack).
231 // Each Track inherits from StHelix, now.
232 // Therefore it is possible to calculate, now:
233 // - residuals
234 // - vertex estimations obtained by back extrapolations of FTPC tracks
235 // Chi2 was fixed.
236 // Many additional minor (and major) changes.
237 //
238 // Revision 1.29 2002/03/25 12:50:56 oldi
239 // Customization of Warnings.
240 //
241 // Revision 1.28 2002/03/25 09:52:55 jcs
242 // exit with warning if primary vertex calculation returns nan
243 //
244 // Revision 1.27 2002/03/15 10:04:41 oldi
245 // Adjust eta segments not only to z-position of vertex but to x,y as well.
246 // Avoid tracking if vertex position is outside of the inner radius of the Ftpc.
247 //
248 // Revision 1.26 2002/03/01 14:21:21 jcs
249 // add additional histograms to monitor cluster finding
250 //
251 // Revision 1.25 2002/02/20 16:11:15 jcs
252 // change loop over vertex table to test if first row is primary vertex
253 //
254 // Revision 1.24 2002/02/10 21:04:49 jcs
255 // Use primary vertex for tracking if it is available. Otherwise use preVertex.
256 //
257 // Revision 1.23 2002/02/05 13:53:09 jcs
258 // remove code for ZDC and Holm's primary vertex calculation methods
259 // if no preVertex available, stop FTPC tracking
260 //
261 // Revision 1.22 2001/09/19 20:58:40 jcs
262 // Use TPC preVertex if it exists, if not use ZDC vertex(slew correction hardwired)
263 //
264 // Revision 1.21 2001/07/26 13:42:27 oldi
265 // Two messages added for the case of missing data.
266 //
267 // Revision 1.20 2001/07/13 17:58:18 oldi
268 // Small change related to new StFtpcDisplay (commented).
269 //
270 // Revision 1.19 2001/07/12 13:08:49 oldi
271 // Remove display !@#$%^&*(.
272 //
273 // Revision 1.18 2001/07/12 13:05:00 oldi
274 // QA histogram of FTPC vertex estimation is generated.
275 // FTPC vertex estimation is stored as pre vertex (id = 301) in any case, now.
276 //
277 // Revision 1.17 2001/07/12 08:42:28 oldi
278 // Minor update.
279 //
280 // Revision 1.16 2001/04/27 10:20:24 oldi
281 // Moved function calls of StFtpcTrackEvalulator to constructor of StFtpcTrackEvalulator.
282 //
283 // Revision 1.15 2001/01/30 13:31:41 oldi
284 // New variable mTime introduced to count total time consumption.
285 //
286 // Revision 1.14 2001/01/25 15:22:25 oldi
287 // Review of the complete code.
288 // Fix of several bugs which caused memory leaks:
289 // - Tracks were not allocated properly.
290 // - Tracks (especially split tracks) were not deleted properly.
291 // - TClonesArray seems to have a problem (it could be that I used it in a
292 // wrong way). I changed all occurences to TObjArray which makes the
293 // program slightly slower but much more save (in terms of memory usage).
294 // Speed up of HandleSplitTracks() which is now 12.5 times faster than before.
295 // Cleanup.
296 //
297 // Revision 1.13 2000/11/10 18:38:50 oldi
298 // Cleanup due to changes in other classes.
299 //
300 // Revision 1.12 2000/08/09 19:15:31 didenko
301 // remove unneeded include
302 //
303 // Revision 1.11 2000/08/07 00:20:03 jcs
304 // save prevertex information correctly
305 //
306 // Revision 1.10 2000/07/18 21:22:17 oldi
307 // Changes due to be able to find laser tracks.
308 // Cleanup: - new functions in StFtpcConfMapper, StFtpcTrack, and StFtpcPoint
309 // to bundle often called functions
310 // - short functions inlined
311 // - formulas of StFormulary made static
312 // - avoid streaming of objects of unknown size
313 // (removes the bunch of CINT warnings during compile time)
314 // - two or three minor bugs cured
315 //
316 // Revision 1.9 2000/07/03 12:45:23 jcs
317 // get (pre)Vertex coordinates directly from (pre)Vertex table instead of from
318 // fptpars
319 //
320 // Revision 1.8 2000/06/26 22:10:44 fisyak
321 // remove params
322 //
323 // Revision 1.7 2000/06/15 09:13:34 oldi
324 // No tracking is performed (return kStWarn instead) if the z-position of the
325 // main vertex is off by more than 100 cm from z = 0. Different error messages
326 // (depending on how far the vertex is off) are printed.
327 //
328 // Revision 1.6 2000/06/13 14:25:56 oldi
329 // Changed couts to gMessMgr->Message().
330 // Printed output changed (slightly).
331 //
332 // Revision 1.5 2000/06/07 11:16:29 oldi
333 // Changed 0 pointers to NULL pointers.
334 // Function HandleSplitTracks() called.
335 //
336 // Revision 1.4 2000/05/15 14:28:12 oldi
337 // problem of preVertex solved: if no main vertex is found (z = NaN) StFtpcTrackMaker stops with kStWarn,
338 // refitting procedure completed and included in StFtpcTrackMaker (commented),
339 // new constructor of StFtpcVertex due to refitting procedure,
340 // minor cosmetic changes
341 //
342 // Revision 1.3 2000/05/12 12:59:16 oldi
343 // removed delete operator for mSegment in StFtpcConfMapper (mSegment was deleted twice),
344 // add two new constructors for StFtpcTracker to be able to refit already existing tracks,
345 // minor cosmetics
346 //
347 // Revision 1.2 2000/05/11 15:14:52 oldi
348 // Changed class names *Hit.* due to already existing class StFtpcHit.cxx in StEvent
349 //
350 // Revision 1.1 2000/05/10 13:39:28 oldi
351 // Initial version of StFtpcTrackMaker
352 //
353 
354 //----------Author: Markus D. Oldenburg
355 //----------Last Modified: 10.11.2000
356 //----------Copyright: &copy MDO Production 1999
357 
358 #include "StFtpcTrackMaker.h"
359 #include "StFtpcVertex.hh"
360 #include "StFtpcConfMapper.hh"
361 #include "StFtpcDisplay.hh"
362 #include "StFtpcTrackEvaluator.hh"
363 #include "StFormulary.hh"
364 #include "StFtpcTrackingParams.hh"
365 #include "StFtpcTrackToStEvent.hh"
366 #include "StFtpcClusterMaker/StFtpcClusterDebug.hh"
367 
368 #include "TObjArray.h"
369 #include "TObjectSet.h"
370 #include "StEvent.h"
371 
372 #include <Stiostream.h>
373 #include <math.h>
374 
375 #include "TDataSet.h"
376 #include "TDataSetIter.h"
377 
378 #include "StVertexId.h"
379 #include "StFtpcHit.h"
380 #include "StPrimaryVertex.h"
381 #include "StCalibrationVertex.h"
382 #include "StMeasuredPoint.h"
383 #include "StMessMgr.h"
384 
385 #include "tables/St_ffs_gepoint_Table.h"
386 #include "tables/St_g2t_track_Table.h"
387 #include "TH1.h"
388 #include "TH2.h"
389 
391 // //
392 // StFtpcTrkMaker class for Makers //
393 // //
395 
396 ClassImp(StFtpcTrackMaker)
397 
398 //_____________________________________________________________________________
399 StFtpcTrackMaker::StFtpcTrackMaker(const char *name) : StMaker(name)
400 {
401  // Default constructor.
402 }
403 
404 //_____________________________________________________________________________
405 StFtpcTrackMaker::~StFtpcTrackMaker()
406 {
407  // Destructor.
408 }
409 
410 //_____________________________________________________________________________
411 Int_t StFtpcTrackMaker::InitRun(Int_t run) {
412 
413  // get ftpc parameters
414  TDataSet *ftpcParsDb = GetInputDB("ftpc");
415  if (!ftpcParsDb) {
416  LOG_ERROR << "StFtpcTrackMaker::Error Getting FTPC parameter database" << endm;
417  return kStErr;
418  }
419  TDataSetIter ftpcPars(ftpcParsDb);
420 
421  // get ftpc geometry
422  TDataSet *ftpcGeometryDb = GetDataBase("Geometry/ftpc");
423 
424  if (!ftpcGeometryDb){
425  LOG_ERROR << "StFtpcTrackMaker::Error Getting FTPC database: Geometry" << endm;
426  return kStErr;
427  }
428 
429  TDataSetIter ftpcGeometry(ftpcGeometryDb);
430 
431  // get tracking parameters from database
432 
433  // Explanation:
434  // dbDate not yet set in Init but Geometry_ftpc/ftpcPadrowZ never changes
435  // and only Geometry_ftpc/ftpcDimensions.sizeOfTimebin changed but it was
436  // never used in StFtpcTrackMaker
437 
438 
439  StFtpcTrackingParams::Instance(Debug(),
440  (St_ftpcTrackingPars *)ftpcPars("ftpcTrackingPars"),
441  (St_ftpcdEdxPars *)ftpcPars("ftpcdEdxPars"),
442  (St_ftpcDimensions *)ftpcGeometry("ftpcDimensions"),
443  (St_ftpcPadrowZ *)ftpcGeometry("ftpcPadrowZ"));
444 cout<<"InitRun StFtpcTrackingParams::Instance()->NumberOfPadRowsPerSide() = "<<StFtpcTrackingParams::Instance()->NumberOfPadRowsPerSide()<<endl;
445 
446  if (StFtpcTrackingParams::Instance()->GetReturnCode() > 0) {
447  LOG_ERROR << " FATAL error in StFtpcTrackingParams return code = "<< StFtpcTrackingParams::Instance()->GetReturnCode() <<endm;
448  return kStErr;
449  }
450 
451  // get ftpc calibration db
452  TDataSet *ftpcCalibrationsDb = GetDataBase("Calibrations/ftpc");
453 
454  if (!ftpcCalibrationsDb){
455  LOG_ERROR << "StFtpcTrackMaker::Error Getting FTPC database: Calibrations" << endm;
456  return kStErr;
457  }
458 
459  TDataSetIter ftpcCalibrations(ftpcCalibrationsDb);
460 
461  // get run dependent tracking parameters from database
462  StFtpcTrackingParams::Instance(kTRUE,
463  (St_ftpcCoordTrans *)ftpcCalibrations("ftpcCoordTrans"));
464 
465  if (StFtpcTrackingParams::Instance()->GetReturnCode() > 0) {
466  LOG_ERROR << " FATAL error in StFtpcTrackingParams return code = "<< StFtpcTrackingParams::Instance()->GetReturnCode() <<endm;
467  return kStErr;
468  }
469 
470  return kStOK;
471 }
472 
473 //_____________________________________________________________________________
474 Int_t StFtpcTrackMaker::Init()
475 {
476  // Initialisation.
477 
478  // m_Mode is used to pass bfc option information to the Maker
479  // m_Mode bfc option(s) Comments
480  // 0 use TwoCycle tracking
481  // 1 flaser use Laser Tracking - ALWAYS used in combination with the "fdbg" bfc option
482  // 2 fdbg add tracking information to the special Ftpc root file created in StFtpcClusterMaker
483  // for analysis in StFtpcCalibMaker
484  // 3 fdbg flaser both "fdbg" and "flaser" bfc options selected
485  // 4 fgain create and fill the special set of Ftpc track histograms used to evaluate
486  // the Ftpc gain scan runs
487 
488  LOG_INFO << "StFtpcTrackMaker entered with m_Mode = "<< m_Mode <<endm;
489 
490  // Create Histograms
491 
492 if (m_Mode == 2 || m_Mode == 3) {
493  LOG_INFO << "StFtpcTrackMaker running with fdbg option selected" << endm;
494  if (m_Mode == 3) LOG_INFO << "StFtpcTrackMaker running with flaser option selected" << endm;
495  m_vtx_pos = new TH1F("fpt_vtx_pos", "FTPC estimated vertex position", 800, -400.0, 400.0);
496 }
497 
498 // m_vertex_east_xy = new TH2F("fpt_vertex_east_xy",
499 // "FTPC east vertex xy estimation with resp. to TPC vertex",
500 // 80, -2., 2., 80, -2., 2.);
501 // m_vertex_east_z = new TH1F("fpt_vertex_east_z",
502 // "FTPC east vertex z estimation with resp. to TPC vertex",
503 // 100, -10., 10.);
504 // m_vertex_west_xy = new TH2F("fpt_vertex_west_xy",
505 // "FTPC west vertex xy estimation with resp. to TPC vertex",
506 // 80, -2., 2., 80, -2., 2.);
507 // m_vertex_west_z = new TH1F("fpt_vertex_west_z",
508 // "FTPC west vertex z estimation with resp. to TPC vertex",
509 // 100, -10., 10.);
510 
511  if (IAttr(".histos")) {
512  if (m_Mode == 4) {
513  LOG_INFO << "StFtpcTrackMaker running with fgain option selected" <<endm;
514  m_pointFW = new TH1F("NPntFW","N points on trk,ftpc west", 8, 4.,12.);
515  m_pointFE = new TH1F("NPntFE","N points on trk,ftpc east", 8, 4.,12.);
516  m_ratiomFW = new TH1F("RnmFW","ratio Nfit/max pnt, ftpc west", 55, 0., 1.1);
517  m_ratiomFE = new TH1F("RnmFE","ratio Nfit/max pnt, ftpc east", 55, 0., 1.1);
518  m_planefF = new TH1F("PlanefF","plane of first hit on trk, ftpc",20,0.5,20.5);
519  m_psiFW = new TH1F("PsiFW","psi, ftpc west", 90, 0.,360.);
520  m_psiFE = new TH1F("PsiFE","psi, ftpc east", 90, 0.,360.);
521  m_xf_yfFW = new TH2F("XfYfFW","Y vs X of first hit on trk, ftpcW", 70,-35.,35.,70,-35.,35.);
522  m_xf_yfFE = new TH2F("XfYfFE","Y vs X of first hit on trk, ftpcE", 70,-35.,35.,70,-35.,35.);
523  m_good_trk = new TH2F("NtrkGoodF","total number tracks found ftpcE vs. ftpcW",150,0.,1500.,150,0.,1500.);
524  m_good_trk->SetXTitle("FTPC East");
525  m_good_trk->SetYTitle("FTPC West");
526  m_pnt_padtimeFW = new TH2F("PointPadTimeFtpcW","point: #pads vs #timebins of hits, ftpcW",12,0.5,12.5,10,0.5,10.5);
527  m_pnt_padtimeFW->SetXTitle("#timebins");
528  m_pnt_padtimeFW->SetYTitle("#pads");
529  m_pnt_padtimeFE = new TH2F("PointPadTimeFtpcE","point: #pads vs #timebins of hits, ftpcE",12,0.5,12.5,10,0.5,10.5);
530  m_pnt_padtimeFE->SetXTitle("#timebins");
531  m_pnt_padtimeFE->SetYTitle("#pads");
532  }
533 // m_nrec_track = new TH2F("fpt_hits_mom", "FTPC: points found per track vs. momentum" , 10, 0.5, 10.5, 100, 0.0, 20.);
534 
535  m_maxadc_West = new TH1F("fpt_maxadcW", "FTPCW MaxAdc", 150, 0.5, 150.5);
536  m_maxadc_East = new TH1F("fpt_maxadcE", "FTPCE MaxAdc", 150, 0.5, 150.5);
537 
538  m_charge_West = new TH1F("fpt_chargeW", "FTPCW charge", 80, 0.5, 800.5);
539  m_charge_East = new TH1F("fpt_chargeE", "FTPCE charge", 80, 0.5, 800.5);
540 
541  m_xres = new TH1F("fpt_x_res", "FTPC x residuals", 100, -0.25, 0.25);
542  m_yres = new TH1F("fpt_y_res", "FTPC y residuals", 100, -0.25, 0.25);
543  m_rres = new TH1F("fpt_r_res", "FTPC r residuals", 100, -0.25, 0.25);
544  m_phires = new TH1F("fpt_phi_res", "FTPC phi residuals", 100, -0.01, 0.01);
545 
546  m_rres_vs_r_east = new TH2F("fpt_r_res_vs_r_east", "FTPC east r residuals vs. r",
547  100, -0.25, 0.25, 100, 6.5, 31.);
548  m_phires_vs_r_east = new TH2F("fpt_phi_res_vs_r_east", "FTPC east phi residuals vs. r",
549  100, -0.01, 0.01, 100, 6.5, 31.);
550  m_rres_vs_r_west = new TH2F("fpt_r_res_vs_r_west", "FTPC west r residuals vs. r",
551  100, -0.25, 0.25, 100, 6.5, 31.);
552  m_phires_vs_r_west = new TH2F("fpt_phi_res_vs_r_west", "FTPC west phi residuals vs. r",
553  100, -0.01, 0.01, 100, 6.5, 31.);
554 
555  if (Debug()) {
556  m_vertex_east_x_vs_sector = new TH2F("fpt_vertex_east_x_vs_sector",
557  "FTPC east vertex x estimation vs. sector with resp. to TPC vertex",
558  6, 0.5, 6.5, 80, -2., 2.);
559  m_vertex_east_y_vs_sector = new TH2F("fpt_vertex_east_y_vs_sector",
560  "FTPC east vertex y estimation vs. sector with resp. to TPC vertex",
561  6, 0.5, 6.5, 80, -2., 2.);
562  m_vertex_east_z_vs_sector = new TH2F("fpt_vertex_east_z_vs_sector",
563  "FTPC east vertex z estimation vs. sector with resp. to TPC vertex",
564  6, 0.5, 6.5, 100, -10., 10.);
565  m_vertex_west_x_vs_sector = new TH2F("fpt_vertex_west_x_vs_sector",
566  "FTPC west vertex x estimation vs. sector with resp. to TPC vertex",
567  6, 0.5, 6.5, 80, -2., 2.);
568  m_vertex_west_y_vs_sector = new TH2F("fpt_vertex_west_y_vs_sector",
569  "FTPC west vertex y estimation vs. sector with resp. to TPC vertex",
570  6, 0.5, 6.5, 80, -2., 2.);
571  m_vertex_west_z_vs_sector = new TH2F("fpt_vertex_west_z_vs_sector",
572  "FTPC west vertex z estimation vs. sector with resp. to TPC vertex",
573  6, 0.5, 6.5, 100, -10., 10.);
574  }
575  } //end if IAttr(".histos")
576 
577  return StMaker::Init();
578 }
579 //_____________________________________________________________________________
581 {
582  // Setup and tracking.
583 
584  LOG_INFO << "Tracking (FTPC) started..." << endm;
585 
586  TObjectSet* objSet = (TObjectSet*)GetDataSet("ftpcClusters");
587  if (!objSet) {
588  LOG_WARN << "StFtpcTrackMaker::Make(): TObjectSet of ftpc clusters is missing." << endm;
589  return kStWarn;
590  }
591  TObjArray *ftpcHits = (TObjArray*)objSet->GetObject();
592  if (!ftpcHits) {
593  LOG_WARN << "No FTPC clusters available!" << endm;
594  return kStWarn;
595  }
596  Int_t rc = StFtpcTrackingParams::Instance()->GetReturnCode();
597  if (rc > 0) {
598  LOG_ERROR << "FTPC Database not available. Return Code = " << rc << endm;
599  return kStErr;
600  }
601 
602  StEvent *event = dynamic_cast<StEvent*>( GetInputDS("StEvent") );
603 
604  StFtpcVertex vertex; // create vertex (all parameters set to 0)
605 
606  // Use the first primary vertex if any primary vertex exists
607  // Multiple vertices have been ordered in StEvent::addPrimaryVertex
608 
609  if (event->numberOfPrimaryVertices() > 0) {
610  vertex = StFtpcVertex(event->primaryVertex(0));
611  }
612  if (Int_t problem = vertex.CheckVertex()) {
613  return problem;
614  }
615 
616  StFtpcConfMapper tracker(ftpcHits, &vertex, kTRUE);
617 
618  // tracking
619  if (StFtpcTrackingParams::Instance()->MagFieldFactor() == 0.) {
620  tracker.NoFieldTracking();
621  }
622 
623  else if (m_Mode%2 == 0) {
624  tracker.TwoCycleTracking();
625  LOG_INFO << "StFtpcTrackMaker: Using TwoCycleTracking"<<endm;
626  }
627  else if (m_Mode%2 == 1) {
628  tracker.LaserTracking();
629  LOG_INFO << "StFtpcTrackMaker: Using LaserTracking"<<endm;
630  }
631 
632  // for the line above you have these possibilities
633  //tracker.MainVertexTracking();
634  //tracker.FreeTracking();
635  //tracker.TwoCycleTracking();
636  //tracker.NoFieldTracking();
637  //tracker.LaserTracking();
638 
639  // coordinate transformation due to rotation and shift of TPC with respect to the magnet
640  // (= global coordinate system).
641  // Since the simulator incorporates these transformations, the distinction between simulated
642  // and real events isn't necessary any more.
643 
644  TObjArray *clusters = tracker.GetClusters();
645  StFtpcPoint *point;
646 
647  // loop over all clusters
648  for (Int_t i = 0; i < clusters->GetEntriesFast(); i++) {
649  point = (StFtpcPoint *)clusters->At(i);
650  point->TransformFtpc2Global(); // errors are not transformed up to now (effect should be small) !!!
651  if (event->ftpcHitCollection()) point->GetStFtpcHit()->update(*point);
652  }
653 
654  // momentum fit, dE/dx calculation
655  tracker.GlobalFitAnddEdx();
656 
657  // calculate FTPC calibration vertices
658  if (tracker.GetNumberOfTracks() >= StFtpcTrackingParams::Instance()->MinNumTracks()) {
659  tracker.EstimateVertex(tracker.GetVertex(), 1);
660 
661  // write FTPC calibration vertices (east and west) to StEvent
662  if (tracker.GetVertexEast()->GetIFlag() == 0) {
663  const StThreeVectorF east(tracker.GetVertexEast()->GetX(), tracker.GetVertexEast()->GetY(), tracker.GetVertexEast()->GetZ());
664  StCalibrationVertex *ftpcEastVertex = new StCalibrationVertex();
665  ftpcEastVertex->setPosition(east);
666  ftpcEastVertex->setType(kFtpcEastCalVtxId);
667  event->addCalibrationVertex(ftpcEastVertex);
668  LOG_INFO << "Added FTPC East calibration vertex: x = "<<tracker.GetVertexEast()->GetX()<<" y = "<<tracker.GetVertexEast()->GetY()<<" z = "<<tracker.GetVertexEast()->GetZ() << endm;
669  }
670 
671  if (tracker.GetVertexWest()->GetIFlag() == 0) {
672  StThreeVectorF west(tracker.GetVertexWest()->GetX(), tracker.GetVertexWest()->GetY(), tracker.GetVertexWest()->GetZ());
673  StCalibrationVertex *ftpcWestVertex = new StCalibrationVertex();
674  ftpcWestVertex->setPosition(west);
675  ftpcWestVertex->setType(kFtpcWestCalVtxId);
676  event->addCalibrationVertex(ftpcWestVertex);
677  LOG_INFO << "Added FTPC West calibration vertex: x = "<<tracker.GetVertexWest()->GetX()<<" y = "<<tracker.GetVertexWest()->GetY()<<" z = "<<tracker.GetVertexWest()->GetZ() << endm;
678  }
679  }
680 
681  // write global tracks, do primary fit, write primary tracks
682  StFtpcTrackToStEvent trackToStEvent;
683  trackToStEvent.FillEvent(event, tracker.GetTracks());
684  tracker.PrimaryFit();
685  trackToStEvent.FillEventPrimaries(event, tracker.GetTracks());
686 
687  if (Debug()) {
688  LOG_INFO << "Total time consumption " << tracker.GetTime() << " s." << endm;
689  StFtpcTrackingParams::Instance()->PrintParams();
690  tracker.TrackingInfo();
691  }
692 
693  else {
694  //tracker.SettingInfo();
695  // Cuts only set for laser tracking
696  //tracker.CutInfo();
697  tracker.TrackingInfo();
698  }
699 
700 if (m_Mode == 2 || m_Mode == 3) {
701  Double_t vertexPos[3];
702  if (m_Mode == 2) {
703  vertexPos[0] = vertex.GetX();
704  vertexPos[1] = vertex.GetY();
705  vertexPos[2] = vertex.GetZ();
706  LOG_INFO<<"TWOCYCLETRACKING: vertexPos[0] = "<<vertexPos[0]<<" vertexPos[1] = "<<vertexPos[1]<<" vertexPos[2] = "<<vertexPos[2]<<endm;
707  }
708  if (m_Mode == 3) {
709  vertexPos[0] = 0.;
710  vertexPos[1] = 0.;
711  vertexPos[2] = 0.;
712  LOG_INFO<<"LASER : No FTPC to global transformation !!!"<<endm;
713  }
714  StFtpcClusterDebug cldebug((int) GetRunNumber(),(int) GetEventNumber());
715  //LOG_INFO<<"Debug fill tracktree"<<endm;
716  cldebug.filltracktree(tracker.GetTracks(),vertexPos);
717  //if (cldebug.drawvertexhisto!=0)
718  //cldebug.drawvertex(m_vertex_east,m_vertex_west,m_vtx_pos);
719 }
720 
721 
722 /*
723  // Track Display
724 
725  // Uncomment this block if you want to see (I mean see!) the found tracks.
726  {
727  StFtpcDisplay display(tracker.GetClusters(), tracker.GetTracks());
728  //display.TrackInfo();
729  //display.Info();
730  //display.ShowClusters();
731  //display.ShowTracks();
732  display.WriteData("ftpc_display.root");
733  }
734  */
735 
736  /*
737  // Track Evaluator
738 
739  // Uncomment this block to get information about the quality
740  // of the found tracks in comparison to the simulated input event.
741 
742  TDataSet *ftpc_data = GetDataSet("ftpc_hits");
743 
744  if (!ftpc_data) {
745  LOG_WARN << "No FTPC data available!" << endm;
746  return kStWarn;
747  }
748 
749  {StFtpcTrackEvaluator eval (geant,
750  ftpc_data,
751  tracker.GetVertex(),
752  tracker.GetClusters(),
753  tracker.GetTracks(),
754  "ftpc_evaluator.root",
755  "RECREATE");
756 
757  // Uncomment the following line if you want to 'see' the information (split tracks, unclean tracks, ...)
758  // evaluated by the TrackEvaluator.
759  //eval.ShowTracks();
760  }
761  */
762 
763  if (tracker.GetNumberOfTracks() > 0) { // only done when some tracks found
764  MakeHistograms(&tracker);
765  }
766 
767 
768  LOG_INFO << "Tracking (FTPC) completed." << endm;
769 
770  return kStOK;;
771 }
772 
773 
774 
775 //_____________________________________________________________________________
776 void StFtpcTrackMaker::MakeHistograms(StFtpcTracker *tracker)
777 {
778  // Fill histograms.
779  // This is done only if at least one track was found.
780  // With that a crash in EstimateVertex is prohibited.
781  // (Problem to fit empty histograms.)
782 
783  if (tracker->GetVertex()->GetIFlag()) { // only do vertex estimation if some found vertex was used for tracking
784 
785  // vertex estimation for different sectors
787 
788  if (tracker->GetNumberOfTracks() >= StFtpcTrackingParams::Instance()->MinNumTracks()) {
789 
790 // the following 4 histograms are now accumulated in StEventQAMaker.cxx
791 // J.Seyboth Nov 19,2004
792  // vertex estimation for both FTPCs (using all tracks)
793  //m_vertex_east_xy->Fill(tracker->GetVertexEast()->GetX()-tracker->GetVertex()->GetX(),
794  // tracker->GetVertexEast()->GetY()-tracker->GetVertex()->GetY());
795  //m_vertex_east_z->Fill(tracker->GetVertexEast()->GetZ()-tracker->GetVertex()->GetZ());
796  //m_vertex_west_xy->Fill(tracker->GetVertexWest()->GetX()-tracker->GetVertex()->GetX(),
797  // tracker->GetVertexWest()->GetY()-tracker->GetVertex()->GetY());
798  //m_vertex_west_z->Fill(tracker->GetVertexWest()->GetZ()-tracker->GetVertex()->GetZ());
799 
800  if (IAttr(".histos") && Debug()) {
801  for (Int_t i = 1; i <= 6; i++) { // east
802  vertex = tracker->EstimateVertex(tracker->GetVertex(), -1, i, 1);
803  m_vertex_east_x_vs_sector->Fill((Float_t)i, vertex.GetX()-tracker->GetVertex()->GetX());
804  m_vertex_east_y_vs_sector->Fill((Float_t)i, vertex.GetY()-tracker->GetVertex()->GetY());
805  m_vertex_east_z_vs_sector->Fill((Float_t)i, vertex.GetZ()-tracker->GetVertex()->GetZ());
806  }
807 
808  for (Int_t i = 1; i <= 6; i++) { // west
809  vertex = tracker->EstimateVertex(tracker->GetVertex(), +1, i, 1);
810  m_vertex_west_x_vs_sector->Fill((Float_t)i, vertex.GetX()-tracker->GetVertex()->GetX());
811  m_vertex_west_y_vs_sector->Fill((Float_t)i, vertex.GetY()-tracker->GetVertex()->GetY());
812  m_vertex_west_z_vs_sector->Fill((Float_t)i, vertex.GetZ()-tracker->GetVertex()->GetZ());
813  }
814  }
815  }
816  }
817 
818  if (IAttr(".histos")) {
819  Int_t nTrkW = 0;
820  Int_t nTrkE = 0;
821  for (Int_t t_counter = 0; t_counter < tracker->GetTracks()->GetEntriesFast(); t_counter++) {
822 
823  StFtpcTrack *track = (StFtpcTrack*) tracker->GetTracks()->At(t_counter);
824  TObjArray *fhits = (TObjArray*) track->GetHits();
825 
826  StFtpcPoint* firstPoint = (StFtpcPoint*)track->GetHits()->First();
827  StFtpcPoint* lastPoint = (StFtpcPoint*)track->GetHits()->Last();
828  Int_t iftpc = (firstPoint->GetDetectorId() == 5) ? 0 : 1; // 0 for detId == 5 and1 for detId == 4
829  // StFtpcTrack lastPoint => StEvent firstPoint !!!
830  if (m_Mode == 4) m_planefF->Fill(lastPoint->GetPadRow());
831 
832  // momentum angle at start
833  Float_t psi = TMath::ATan2(track->GetPy(), track->GetPx())/degree;
834  if (psi<0) psi+=360;
835 
836  if ( m_Mode == 4 ) {
837  if (iftpc==1) {
838  nTrkW++;
839  m_pointFW->Fill(track->GetNumberOfPoints());
840  m_ratiomFW->Fill(Float_t(track->GetNumberOfPoints())/Float_t(track->GetNMax()));
841  m_xf_yfFW->Fill(firstPoint->GetX(),firstPoint->GetY());
842  m_psiFW->Fill(psi);
843  }
844  if (iftpc==0) {
845  nTrkE++;
846  m_pointFE->Fill(track->GetNumberOfPoints());
847  m_ratiomFE->Fill(Float_t(track->GetNumberOfPoints())/Float_t(track->GetNMax()));
848  m_xf_yfFE->Fill(firstPoint->GetX(),firstPoint->GetY());
849  m_psiFE->Fill(psi);
850  }
851  }
852 
853 // m_nrec_track->Fill(track->GetNumberOfPoints(),track->GetP());
854 
855  for (Int_t h_counter = 0; h_counter < fhits->GetEntriesFast(); h_counter++) {
856 
857  StFtpcPoint *mhit = (StFtpcPoint *) fhits->At(h_counter);
858 
859  // Residuals (fill globals only, during tracking primary isn't filled anyway)
860  if (mhit->GetUsage()) {
861  m_xres->Fill(mhit->GetXGlobResidual());
862  m_yres->Fill(mhit->GetYGlobResidual());
863  m_rres->Fill(mhit->GetRGlobResidual());
864  m_phires->Fill(mhit->GetPhiGlobResidual());
865  }
866 
867  if (mhit->GetPadRow() <= StFtpcTrackingParams::Instance()->NumberOfPadRowsPerSide()) {
868  if ( m_Mode == 4) m_pnt_padtimeFW->Fill(mhit->GetNumberBins(),mhit->GetNumberPads());
869  m_maxadc_West->Fill(mhit->GetMaxADC());
870  m_charge_West->Fill(mhit->GetCharge());
871 
872  if (mhit->GetUsage()) {
873  m_rres_vs_r_west->Fill(mhit->GetRGlobResidual(), mhit->GetRadius());
874  m_phires_vs_r_west->Fill(mhit->GetPhiGlobResidual(), mhit->GetRadius());
875  }
876  }
877 
878  else if (mhit->GetPadRow() > StFtpcTrackingParams::Instance()->NumberOfPadRowsPerSide()) {
879  if ( m_Mode == 4) m_pnt_padtimeFE->Fill(mhit->GetNumberBins(),mhit->GetNumberPads());
880  m_maxadc_East->Fill(mhit->GetMaxADC());
881  m_charge_East->Fill(mhit->GetCharge());
882 
883  if (mhit->GetUsage()) {
884  m_rres_vs_r_east->Fill(mhit->GetRGlobResidual(), mhit->GetRadius());
885  m_phires_vs_r_east->Fill(mhit->GetPhiGlobResidual(), mhit->GetRadius());
886  }
887  }
888  } //end for h_counter
889  } //end for t_counter
890  if ( m_Mode == 4 ) m_good_trk->Fill(nTrkE,nTrkW);
891  } //end IAttr(".histos")
892 }
893 
894 
895 //_____________________________________________________________________________
897 {
898  // final cleanup
899  // nothing to do right now
900 
901  return StMaker::Finish();
902 }
903 
904 
905 //_____________________________________________________________________________
906 Int_t StFtpcTrackMaker::FinishRun(Int_t run)
907 {
908  // cleanup after every run
909 
910 // delete StFtpcTrackingParams::Instance();
911 
912  return StMaker::FinishRun(run);
913 }
914 
915 
916 //_____________________________________________________________________________
917 void StFtpcTrackMaker::PrintInfo()
918 {
919  // Prints information.
920 
921  LOG_INFO << "******************************************************************" << endm;
922  LOG_INFO << "* $Id: StFtpcTrackMaker.cxx,v 1.93 2012/11/07 23:30:18 fisyak Exp $ *" << endm;
923  LOG_INFO << "******************************************************************" << endm;
924 
925  if (Debug()) {
926  StMaker::PrintInfo();
927  }
928 }
929 
Int_t m_Mode
counters
Definition: StMaker.h:81
TH2F * m_vertex_west_x_vs_sector
vertex z estimation east vs sector
TH2F * m_phires_vs_r_west
r residuals vs. r west
StEvent * FillEvent(StEvent *, TObjArray *)
TH1F * m_psiFW
plane of first hit on trk, ftpc
TH1F * m_rres
y residuals
TH2F * m_vertex_west_z_vs_sector
vertex y estimation west vs sector
TH1F * m_ratiomFW
number of points on the track - ftpc east
TH2F * m_good_trk
padlength vs timelength of hits, ftpcE
TH2F * m_phires_vs_r_east
r residuals vs. r east
TH2F * m_vertex_east_y_vs_sector
vertex x estimation east vs sector
TH1F * m_pointFE
number of points on the track - ftpc west
TH2F * m_vertex_east_x_vs_sector
phi residuals vs. r west
TH2F * m_vertex_west_y_vs_sector
vertex x estimation west vs sector
TH2F * m_pnt_padtimeFE
padlength vs timelength of hits, ftpcW
TH1F * m_psiFE
psi reconstructed, ftpc west
TH1F * m_planefF
ratio of n fit pnts over max n pnts - ftpc east
virtual Int_t Finish()
TH1F * m_vtx_pos
tot # tracks ftpcW vs. ftpcE
TH2F * m_xf_yfFW
psi reconstructed, ftpc east
TH2F * m_vertex_east_z_vs_sector
vertex y estimation east vs sector
TH2F * m_rres_vs_r_east
phi residuals
Definition: Stypes.h:42
Definition: Stypes.h:40
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
TH2F * m_rres_vs_r_west
phi residuals vs. r east
TH1F * m_yres
x residuals
TH2F * m_xf_yfFE
Y vs X of first hit on trk, ftpc west.
TH1F * m_maxadc_West
vertex position
void EstimateVertex(StFtpcVertex *vertex, UChar_t iterations=1)
Vertex estimation with fit tracks for FTPC east and west.
virtual Int_t Finish()
Definition: StMaker.cxx:776
TH2F * m_pnt_padtimeFW
Y vs X of first hit on trk, ftpc east.
TH1F * m_ratiomFE
ratio of n fit pnts over max n pnts - ftpc west
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:56
Definition: Stypes.h:44
TH1F * m_phires
r residuals
virtual Int_t Make()