StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFtpcClusterMaker.cxx
1 // $Log: StFtpcClusterMaker.cxx,v $
2 // Revision 1.109 2017/04/26 19:47:29 perev
3 // Hide m_DataSet
4 //
5 // Revision 1.108 2013/03/26 15:56:00 genevb
6 // Replace agufld(x,b) with direct call to StarMagField::Instance()->BField(x,b)
7 //
8 // Revision 1.107 2013/02/18 16:30:42 fisyak
9 // gufld => agufld
10 //
11 // Revision 1.106 2011/08/31 16:39:37 jcs
12 // output ampSlope contents to LOG_INFO
13 //
14 // Revision 1.105 2010/12/17 14:54:56 jcs
15 // For embedding, read raw data from StFtpcMixerMaker tables
16 //
17 // Revision 1.104 2010/04/08 16:46:16 jcs
18 // swap data for RDO6,RDO7 FTPC East when Calibrations_ftpc/ftpcElectronics->swapRDO6RDO7East=1
19 //
20 // Revision 1.103 2009/11/25 19:50:16 jcs
21 // remove all references to StFtpcSoftwareMonitor
22 //
23 // Revision 1.102 2009/11/18 12:10:02 jcs
24 // add USE_LOCAL_DRIFTMAP instructions
25 //
26 // Revision 1.101 2009/10/14 15:52:43 jcs
27 // write out all gas temperature, air pressure info to Run branch of FTPC debug root file
28 //
29 // Revision 1.100 2009/08/04 08:37:28 jcs
30 // When the flaser option is included in the bfc, the 'perfect' gain table and
31 // adjustAverageWest = adjustAverageEast = 0.0, will be used for cluster finding
32 //
33 // Revision 1.99 2008/10/02 16:20:43 jcs
34 // standardize m_Mode LOG_INFO messages
35 //
36 // Revision 1.98 2008/07/30 14:47:29 jcs
37 // if microsecondsPerTimebin calculated from RHIC clock, write the new value for mMicrosecondsPerTimebin back into
38 // Calibrations_ftpc/ftpcElectronics table
39 //
40 // Revision 1.97 2008/07/17 18:43:14 jcs
41 // insure that the correct microsecondsPerTimebin is used for every event, not just for the first event
42 //
43 // Revision 1.96 2008/01/07 14:46:10 jcs
44 // create and fill the special set of Ftpc point histograms used to evaluate
45 // the Ftpc gain scan runs when bfc option fgain is in the chain
46 //
47 // Revision 1.95 2008/01/02 11:29:09 jcs
48 // bfc option fdbg selected if m_Mode==2
49 //
50 // Revision 1.94 2007/12/13 10:37:46 jcs
51 // standardize looger messages
52 //
53 // Revision 1.93 2007/12/12 13:24:45 jcs
54 // replace asserts with LOG_ERROR message and kStErr return code
55 //
56 // Revision 1.92 2007/04/28 17:56:09 perev
57 // Redundant StChain.h removed
58 //
59 // Revision 1.91 2007/04/26 11:06:11 jcs
60 // Use the bfc option "debug" to create and fill the FTPC cluster tuning histograms
61 //
62 // Revision 1.90 2007/02/01 11:57:04 jcs
63 // move unessential output from INFO to DEBUG
64 //
65 // Revision 1.89 2007/01/15 07:49:22 jcs
66 // replace printf, cout and gMesMgr with Logger
67 //
68 // Revision 1.88 2006/11/09 13:55:34 jcs
69 // bfc option fdbg selected if m_Mode>=2
70 //
71 // Revision 1.87 2006/08/23 09:25:36 jcs
72 // Return with kStWarn if error occurs accessing Calibrations_ftpc/ftpcVoltageStatus
73 // StDetectorState is set only for events with FTPC data
74 //
75 // Revision 1.86 2006/08/22 11:42:21 jcs
76 // Set StDetectorState for Ftpc West/East depending on ftpcVoltageStatus
77 //
78 // Revision 1.85 2006/03/19 19:29:45 jcs
79 // Move cluster struct definitions to StFtpcClustersStructures.hh
80 // Create DEBUGFILE with bfc option 'fdbg'
81 //
82 // Revision 1.84 2006/03/13 19:40:32 jcs
83 // save microsecondsPerTimebin and temperature/pressure corrections in DEBUGFILE run tree
84 //
85 // Revision 1.83 2006/03/01 17:24:47 jcs
86 // move all database initialization to InitRun
87 //
88 // Revision 1.82 2006/01/13 12:35:40 jcs
89 // Calculate mMicrosecondsPerTimebin from RHIC clock frequency for each event
90 //
91 // Revision 1.81 2005/12/12 13:42:32 jcs
92 // if StFtpcDbRead not constructed exit with kStWarn
93 //
94 // Revision 1.80 2005/10/26 14:01:09 jcs
95 // Set gas temperature to default values when running fss so that database
96 // values are printed out only once
97 //
98 // Revision 1.79 2005/10/14 07:29:01 jcs
99 // Calculate microsecondsPerTimebin from RHIC ClockFrequency
100 // If RHIC ClockFrequency = 0, use default value from database
101 //
102 // Revision 1.78 2005/03/23 14:32:28 jcs
103 // additional changes for using body + extra temperatures starting with y2005
104 //
105 // Revision 1.77 2005/03/14 22:56:12 jcs
106 // use the body + the extra ftpc temperature reading starting with y2005
107 //
108 // Revision 1.76 2004/11/16 11:35:34 jcs
109 // label the x-axis for the charge step plots
110 //
111 // Revision 1.75 2004/09/27 12:54:28 jcs
112 // pad vs. time histograms moved to St_QA_Maker
113 // set radial step histogram line color; red = FTPC East, blue=FTPC West
114 //
115 // Revision 1.74 2004/09/08 16:03:26 jcs
116 // correct binning error in fcl_flags histogram
117 //
118 // Revision 1.73 2004/09/07 14:09:07 jcs
119 // use the IAttr(".histos") to control histogrammingZ
120 //
121 // Revision 1.72 2004/09/03 20:35:03 perev
122 // Big LeakOff + mem optimisation
123 //
124 // Revision 1.71 2004/07/18 14:15:08 jcs
125 // include runNumber in call to StFtpcGasUtilities
126 //
127 // Revision 1.70 2004/06/18 12:06:18 jcs
128 // replace #ifdef...#elif...#endif conditional compiler directives with #ifdef...#endif #ifdef...#endif
129 //
130 // Revision 1.69 2004/06/18 09:04:40 jcs
131 // replace obsolete DEBUGFILE code with code to write out a root file for cluster/laser analysis
132 //
133 // Revision 1.68 2004/05/25 07:10:04 jcs
134 // initialize StFtpcSoftwareMonitor*ftpcMon
135 //
136 // Revision 1.67 2004/05/24 13:35:32 jcs
137 // create a new StFtpcSoftwareMonitor if none exists
138 //
139 // Revision 1.66 2004/05/19 17:44:46 oldi
140 // For simulated data the ftpcHitCollection inside StEvent doesn't exist yet.
141 // We have to create it on our own. Additional check for ftpcHitCollection
142 // introduced in StFtpcTrackMaker.
143 //
144 // Revision 1.65 2004/04/19 22:00:46 oldi
145 // Minor changes.
146 //
147 // Revision 1.64 2004/04/06 18:36:51 oldi
148 // New data mebers for pad and time position and pad and time sigma filled.
149 //
150 // Revision 1.63 2004/02/12 19:38:46 oldi
151 // Removal of intermediate tables.
152 //
153 // Revision 1.62 2004/01/28 02:04:43 jcs
154 // replace all instances of StFtpcReducedPoint and StFtpcPoint with StFtpcConfMapPoint
155 //
156 // Revision 1.61 2004/01/28 01:41:15 jeromel
157 // Change OST to OS everywhere since defaultoption is now not to print
158 // the date.
159 //
160 // Revision 1.60 2003/11/13 14:12:17 jcs
161 // move pressure and gas corrections from StFtpcClusterMaker.cxx to StFtpcGasUtilities
162 //
163 // Revision 1.59 2003/10/11 08:52:46 jcs
164 // protect against divide by zero while calculating average body temperatures
165 //
166 // Revision 1.58 2003/10/11 04:07:48 perev
167 // assert for number of east temperatures added
168 //
169 // Revision 1.57 2003/09/02 17:58:14 perev
170 // gcc 3.2 updates + WarnOff
171 //
172 // Revision 1.56 2003/08/21 14:27:24 jcs
173 // remove temporary fix to prevent segmentation violation which occurred when more than one run per job
174 //
175 // Revision 1.55 2003/07/18 18:31:47 perev
176 // test for nonexistance of XXXReader added
177 //
178 // Revision 1.54 2003/07/15 09:35:41 jcs
179 // do not re-flavor FTPC drift maps if already flavored to avoid creating
180 // memory leak.
181 // meomory leak will occur if flavor (i.e. magnetic field) changes within one
182 // *.fz file (only possible for MC data)
183 //
184 // Revision 1.53 2003/07/04 00:35:53 perev
185 // Defence against luch of DB info added
186 //
187 // Revision 1.52 2003/06/13 10:57:28 jcs
188 // remove debug statement
189 //
190 // Revision 1.51 2003/06/12 10:01:25 jcs
191 // renamed ftpcClusterGeometry database table to ftpcClusterGeom
192 // (name was too long)
193 //
194 // Revision 1.50 2003/06/11 12:06:03 jcs
195 // get inner cathode and cluster geometry parameters from database
196 //
197 // Revision 1.49 2003/06/10 13:10:05 jcs
198 // get min,max gas temperature and pressure limits from database instead of from
199 // parameters
200 //
201 // Revision 1.48 2003/05/07 15:08:56 putschke
202 // improvements for cathode offset corretions
203 //
204 // Revision 1.47 2003/04/15 11:34:41 putschke
205 // Include corrections for inner cathode offset and move some parameter to database
206 //
207 // Revision 1.46 2003/02/27 22:56:58 jcs
208 // use the ftpc body temperature readings to make temperature/pressure corrections
209 //
210 // Revision 1.44 2003/02/25 04:45:22 jcs
211 // comment out body4East temperature for AuAu central production
212 //
213 // Revision 1.43 2003/02/19 14:52:44 jcs
214 // calculate ftpc temperature from body temperatures
215 //
216 // Revision 1.42 2003/02/08 03:45:22 jcs
217 // for dAu production ONLY: hardcode gas temperatures
218 //
219 // Revision 1.41 2003/01/14 12:58:01 jcs
220 // use Geometry_ftpc/ftpcAsicMap to control corrections for error in Y2001-2002
221 // FTPC asic mapping
222 //
223 // Revision 1.40 2002/08/02 11:24:29 oldi
224 // Used database values are printed to screen, now.
225 //
226 // Revision 1.39 2002/07/15 13:31:09 jcs
227 // incorporate charge step histos into cluster finder and remove StFtpcChargeStep
228 //
229 // Revision 1.38 2002/03/22 08:52:52 jcs
230 // correct memory leaks found by Insure
231 //
232 // Revision 1.37 2002/03/20 11:44:35 jcs
233 // forgot to uncomment delete step when reactivating StFtpcChargeStep - caused
234 // memory leak
235 //
236 // Revision 1.36 2002/03/14 10:53:42 jcs
237 // turn ftpc timebin charge step histograms back on
238 //
239 // Revision 1.35 2002/03/01 14:22:20 jcs
240 // add additional histograms to monitor cluster finding
241 //
242 // Revision 1.34 2002/02/10 21:15:38 jcs
243 // create separate radial chargestep histograms for Ftpc west and east
244 //
245 // Revision 1.33 2002/01/22 02:53:09 jcs
246 // remove extra test from if statement
247 //
248 // Revision 1.32 2002/01/21 22:10:38 jcs
249 // calculate FTPC gas temperature adjusted air pressure using online db
250 //
251 // Revision 1.31 2001/12/12 16:05:28 jcs
252 // Move GetDataBase.. statements from Init to Make to ensure selection of
253 // correct flavor (Thank you Jeff)
254 //
255 // Revision 1.30 2001/11/21 12:44:44 jcs
256 // make ftpcGas database table available to FTPC cluster maker
257 //
258 // Revision 1.29 2001/10/29 12:53:23 jcs
259 // select FTPC drift maps according to flavor of magnetic field
260 //
261 // Revision 1.28 2001/10/19 09:41:22 jcs
262 // tZero now in data base in ftpcElectronics
263 //
264 // Revision 1.27 2001/10/12 14:33:08 jcs
265 // create and fill charge step histograms for FTPC East and West
266 //
267 // Revision 1.26 2001/07/26 13:53:19 oldi
268 // Check if FTPC data is available.
269 //
270 // Revision 1.25 2001/07/12 10:35:14 jcs
271 // create and fill FTPC cluster radial position histogram
272 //
273 // Revision 1.24 2001/06/16 12:59:47 jcs
274 // delete ftpcReader only if it is the FTPC slow simulator reader
275 //
276 // Revision 1.23 2001/06/13 14:37:54 jcs
277 // change StDaqReader to StDAQReader
278 //
279 // Revision 1.22 2001/04/23 19:57:51 oldi
280 // The chargestep histogram is only filled but the evaluated value of the
281 // normalized pressure is not used for a correction. This was done due to the
282 // fact that StFtpcChargeStep is not stable enough to determine the actual
283 // charge step.
284 // Output is sent to StMessMgr now.
285 //
286 // Revision 1.21 2001/04/04 17:08:42 jcs
287 // remove references to StFtpcParamReader from StFtpcDbReader
288 //
289 // Revision 1.20 2001/04/02 12:10:18 jcs
290 // get FTPC calibrations,geometry from MySQL database and code parameters
291 // from StarDb/ftpc
292 //
293 // Revision 1.19 2001/03/19 15:52:47 jcs
294 // use ftpcDimensions from database
295 //
296 // Revision 1.18 2001/03/06 23:33:51 jcs
297 // use database instead of params
298 //
299 // Revision 1.17 2001/01/25 15:25:35 oldi
300 // Fix of several bugs which caused memory leaks:
301 // - Some arrays were not allocated and/or deleted properly.
302 // - TClonesArray seems to have a problem (it could be that I used it in a
303 // wrong way in StFtpcTrackMaker form where Holm cut and pasted it).
304 // I changed all occurences to TObjArray which makes the program slightly
305 // slower but much more save (in terms of memory usage).
306 //
307 // Revision 1.16 2000/11/24 15:02:33 hummler
308 // commit changes omitted in last commit
309 //
310 // Revision 1.14 2000/11/20 11:39:12 jcs
311 // remove remaining traces of fspar table
312 //
313 // Revision 1.13 2000/11/14 13:08:16 hummler
314 // add charge step calculation, minor cleanup
315 //
316 // Revision 1.12 2000/09/18 14:26:46 hummler
317 // expand StFtpcParamReader to supply data for slow simulator as well
318 // introduce StFtpcGeantReader to separate g2t tables from simulator code
319 // implement StFtpcGeantReader in StFtpcFastSimu
320 //
321 // Revision 1.11 2000/08/03 14:39:00 hummler
322 // Create param reader to keep parameter tables away from cluster finder and
323 // fast simulator. StFtpcClusterFinder now knows nothing about tables anymore!
324 //
325 // Revision 1.8 2000/04/13 18:08:21 fine
326 // Adjusted for ROOT 2.24
327 //
328 // Revision 1.7 2000/02/24 15:18:42 jcs
329 // inactivate histograms for MDC3
330 //
331 // Revision 1.6 2000/02/04 13:49:36 hummler
332 // upgrade ffs:
333 // -remove unused fspar table
334 // -make hit smearing gaussian with decent parameters and static rand engine
335 // -separate hit smearing from cluster width calculation
336 //
337 // Revision 1.5 2000/02/02 15:20:33 hummler
338 // correct acceptance at sector boundaries,
339 // take values from fcl_det
340 //
341 // Revision 1.4 2000/01/27 09:47:18 hummler
342 // implement raw data reader, remove type ambiguities that bothered kcc
343 //
344 //
345 //
347 // //
348 // StFtpcClusterMaker class for Makers //
349 // //
351 
352 #include <Stiostream.h>
353 #include <stdlib.h>
354 #include <errno.h>
355 #include <sys/stat.h>
356 #include <sys/fcntl.h>
357 //VP#include "StDaqLib/GENERIC/EventReader.hh"
358 #include "StDAQMaker/StFTPCReader.h"
359 
360 #include "StMessMgr.h"
361 #include "StFtpcClusterMaker.h"
362 #include "StFtpcParamReader.hh"
363 #include "StFtpcDbReader.hh"
364 #include "StFtpcGeantReader.hh"
365 #include "StFtpcClusterFinder.hh"
366 #include "StFtpcGasUtilities.hh"
367 #include "StFtpcTrackMaker/StFtpcConfMapPoint.hh"
368 #include "StFtpcGeantPoint.hh"
369 #include "StFtpcFastSimu.hh"
370 #include "St_DataSetIter.h"
371 #include "TH1.h"
372 #include "TH2.h"
373 #include "TObjArray.h"
374 #include "TObjectSet.h"
375 #include "PhysicalConstants.h"
376 
377 #include "tables/St_fcl_ftpcsqndx_Table.h"
378 #include "tables/St_fcl_ftpcadc_Table.h"
379 
380 #include "tables/St_g2t_vertex_Table.h"
381 #include "tables/St_g2t_track_Table.h"
382 #include "tables/St_g2t_ftp_hit_Table.h"
383 #include "tables/St_ffs_gepoint_Table.h"
384 
385 #include "StDetectorDbMaker/StDetectorDbClock.h"
386 #include "StDetectorDbMaker/StDetectorDbFTPCGas.h"
387 #include "StDetectorDbMaker/StDetectorDbFTPCVoltageStatus.h"
388 
389 #include "St_db_Maker/St_db_Maker.h"
390 
391 #include "StEvent.h"
392 #include "StFtpcHitCollection.h"
393 #include "StDetectorState.h"
394 
395 ClassImp(StFtpcClusterMaker)
396 
397  //_____________________________________________________________________________
398 StFtpcClusterMaker::StFtpcClusterMaker(const char *name):
399 StMaker(name),
400  m_clusterpars(0),
401  m_fastsimgas(0),
402  m_fastsimpars(0),
403  m_dimensions(0),
404  m_padrow_z(0),
405  m_asicmap(0),
406  m_efield(0),
407  m_vdrift(0),
408  m_deflection(0),
409  m_dvdriftdp(0),
410  m_ddeflectiondp(0),
411  m_ampslope(0),
412  m_ampoffset(0),
413  m_timeoffset(0),
414  m_driftfield(0),
415  m_gas(0),
416  m_electronics(0),
417  m_cathode(0),
418  m_clustergeo(0),
419  m_temps(0)
420 {
421  mCurrentEvent=0;
422  mFtpcHitColl=0;
423  mHitArray=0;
424  memset(m_ThBeg,0,m_ThEnd-m_ThBeg+1);
425  drawinit=kFALSE;
426 }
427 //_____________________________________________________________________________
428 StFtpcClusterMaker::~StFtpcClusterMaker(){
429 }
430 //_____________________________________________________________________________
431 Int_t StFtpcClusterMaker::InitRun(int runnumber){
432  Float_t x[3] = {0,0,0};
433  Float_t b[3];
434  StarMagField::Instance()->BField(x,b);
435  Double_t gFactor = b[2]/4.980;
436 
437  mDbMaker = (St_db_Maker*)GetMaker("db");
438  Int_t dbDate = mDbMaker->GetDateTime().GetDate();
439  Int_t dbTime = mDbMaker->GetDateTime().GetTime();
440  LOG_INFO<<"dbDate = "<<dbDate<<" dbTime = "<<dbTime<<" Run Number = "<<GetRunNumber()<<" gFactor = "<<gFactor<<endm;
441 
442  // Load the correct FTPC drift maps depending on magnetic field
443 
444  // Full Field Positive ?
445  if ( gFactor > 0.8 ) {
446  SetFlavor("ffp10kv","ftpcVDrift");
447  SetFlavor("ffp10kv","ftpcdVDriftdP");
448  SetFlavor("ffp10kv","ftpcDeflection");
449  SetFlavor("ffp10kv","ftpcdDeflectiondP");
450  LOG_DEBUG << "Ftpc drift map flavor set to ffp10kv"<<endm;
451  }
452  else if ( gFactor > 0.2 ) {
453  SetFlavor("hfp10kv","ftpcVDrift");
454  SetFlavor("hfp10kv","ftpcdVDriftdP");
455  SetFlavor("hfp10kv","ftpcDeflection");
456  SetFlavor("hfp10kv","ftpcdDeflectiondP");
457  LOG_DEBUG << "Ftpc drift map flavor set to hfp10kv"<<endm;
458  }
459  else if ( gFactor > -0.2 ) {
460  SetFlavor("zf10kv","ftpcVDrift");
461  SetFlavor("zf10kv","ftpcdVDriftdP");
462  SetFlavor("zf10kv","ftpcDeflection");
463  SetFlavor("zf10kv","ftpcdDeflectiondP");
464  LOG_DEBUG << "Ftpc drift map flavor set to zf10kv"<<endm;
465  }
466  else if ( gFactor > -0.8 ) {
467  SetFlavor("hfn10kv","ftpcVDrift");
468  SetFlavor("hfn10kv","ftpcdVDriftdP");
469  SetFlavor("hfn10kv","ftpcDeflection");
470  SetFlavor("hfn10kv","ftpcdDeflectiondP");
471  LOG_DEBUG << "Ftpc drift map flavor set to hfn10kv"<<endm;
472  }
473  else {
474  SetFlavor("ffn10kv","ftpcVDrift");
475  SetFlavor("ffn10kv","ftpcdVDriftdP");
476  SetFlavor("ffn10kv","ftpcDeflection");
477  SetFlavor("ffn10kv","ftpcdDeflectiondP");
478  LOG_DEBUG << "Ftpc drift map flavor set to ffn10kv"<<endm;
479  }
480 
481  // calculate microsecondsPerTimebin from RHIC clock frequency for current run
482  // if not available, use default values from offline database
483 
484  StDetectorDbClock* dbclock = StDetectorDbClock::instance();
485  double freq = dbclock->getCurrentFrequency()/1000000.0;
486  if ( freq != 0)
487  microsecondsPerTimebin = 1./(freq/2.);
488  else
489  microsecondsPerTimebin = 0.;
490 
491  // Geometry/ftpc offline database tables
492 
493  St_DataSet *ftpc_geometry_db = GetDataBase("Geometry/ftpc");
494  if ( !ftpc_geometry_db ){
495  LOG_ERROR << "InitRun - error Getting FTPC offline database Geometry/ftpc"<<endm;
496  return kStErr;
497  }
498 
499  St_DataSetIter dblocal_geometry(ftpc_geometry_db);
500 
501  m_dimensions = (St_ftpcDimensions *)dblocal_geometry("ftpcDimensions");
502  m_padrow_z = (St_ftpcPadrowZ *)dblocal_geometry("ftpcPadrowZ");
503  m_asicmap = (St_ftpcAsicMap *)dblocal_geometry("ftpcAsicMap");
504  m_clustergeo = (St_ftpcClusterGeom *)dblocal_geometry("ftpcClusterGeom");
505  m_cathode = (St_ftpcInnerCathode *)dblocal_geometry("ftpcInnerCathode");
506 
507  // Calibrations/ftpc offline database tables
508 
509  St_DataSet *ftpc_calibrations_db = GetDataBase("Calibrations/ftpc");
510  if ( !ftpc_calibrations_db ){
511  LOG_ERROR <<"InitRun - error getting FTPC offline database Calibrations/ftpc"<<endm;
512  return kStErr;
513  }
514 
515  St_DataSetIter dblocal_calibrations(ftpc_calibrations_db);
516 
517  m_efield = (St_ftpcEField *)dblocal_calibrations("ftpcEField" );
518 
519  // USE_LOCAL_DRIFTMAP:
520  // To use the FTPC drift map tables in $PWD/StarDb instead of those
521  // in the MySQL offline database, comment out the following 4 lines of code
522  // Then go to USE_LOCAL_DRIFTMAP: in Int_t StFtpcClusterMaker::Init()
523  // and follow the instructions
524  m_vdrift = (St_ftpcVDrift *)dblocal_calibrations("ftpcVDrift" );
525  m_deflection = (St_ftpcDeflection *)dblocal_calibrations("ftpcDeflection" );
526  m_dvdriftdp = (St_ftpcdVDriftdP *)dblocal_calibrations("ftpcdVDriftdP" );
527  m_ddeflectiondp = (St_ftpcdDeflectiondP *)dblocal_calibrations("ftpcdDeflectiondP" );
528 
529  m_ampslope = (St_ftpcAmpSlope *)dblocal_calibrations("ftpcAmpSlope" );
530  m_ampoffset = (St_ftpcAmpOffset *)dblocal_calibrations("ftpcAmpOffset");
531  m_timeoffset = (St_ftpcTimeOffset *)dblocal_calibrations("ftpcTimeOffset");
532  m_driftfield = (St_ftpcDriftField *)dblocal_calibrations("ftpcDriftField");
533  m_gas = (St_ftpcGas *)dblocal_calibrations("ftpcGas");
534  m_electronics = (St_ftpcElectronics *)dblocal_calibrations("ftpcElectronics");
535  m_temps = (St_ftpcTemps *)dblocal_calibrations("ftpcTemps");
536 
537  return kStOK;
538 }
539 //_____________________________________________________________________________
540 Int_t StFtpcClusterMaker::Init(){
541 
542  // m_Mode is used to pass bfc option information to the Maker
543  // m_Mode bfc option Comments
544  // 0 normal setting for production runs
545  // 2 fdbg open special Ftpc root file and fill with cluster information
546  // for analysis in StFtpcCalibMaker
547  // 3 fdbg + flaser open special Ftpc root file for laser run and fill with cluster information
548  // for analysis in StFtpcCalibMaker
549  // 4 fgain initialize and fill the special set of Ftpc cluster histograms
550  // used to evaluate the Ftpc gain scan runs
551 
552  LOG_INFO << "StFtpcClusterMaker entered with m_Mode = "<< m_Mode <<endm;
553 
554  if (m_Mode == 2) {
555  LOG_INFO << "StFtpcClusterMaker running with fdbg option selected"<<endm;
556  }
557 
558  if (m_Mode == 3) {
559  LOG_INFO << "StFtpcClusterMaker writing to DEBUGFILE (fdbg option selected) for laser run (flaser option selected)"<<endm;
560  laserRun = kTRUE;
561  }
562  else {laserRun = kFALSE;}
563 
564  if (m_Mode == 4) {
565  LOG_INFO << "StFtpcClusterMaker running with fgain option selected"<<endm;
566  }
567 
568  St_DataSet *ftpc = GetDataBase("ftpc");
569  if (!ftpc) {
570  LOG_ERROR << "StFtpcClusterMaker exiting - run parameter database StarDb/ftpc not found"<<endm;
571  return kStErr;
572  }
573  St_DataSetIter local(ftpc);
574 
575  m_clusterpars = (St_ftpcClusterPars *)local("ftpcClusterPars");
576  m_fastsimgas = (St_ftpcFastSimGas *)local("ftpcFastSimGas");
577  m_fastsimpars = (St_ftpcFastSimPars *)local("ftpcFastSimPars");
578 
579 
580  // USE_LOCAL_DRIFTMAP:
581  // To use the FTPC drift map tables in $PWD/StarDb instead of those
582  // in the MySQL offline database, uncomment the following 4 lines of code
583  //m_vdrift = (St_ftpcVDrift *)local("ftpcVDrift" );
584  //m_deflection = (St_ftpcDeflection *)local("ftpcDeflection" );
585  //m_dvdriftdp = (St_ftpcdVDriftdP *)local("ftpcdVDriftdP" );
586  //m_ddeflectiondp = (St_ftpcdDeflectiondP *)local("ftpcdDeflectiondP" );
587 
588  // Create Histograms
589  m_chargestep_West = new TH1F("fcl_chargestepW","FTPC West chargestep",260, -0.5, 259.5);
590  m_chargestep_West->SetXTitle("timebin");
591  m_chargestep_East = new TH1F("fcl_chargestepE","FTPC East chargestep",260, -0.5, 259.5);
592  m_chargestep_East->SetXTitle("timebin");
593  m_cluster_radial_West = new TH1F("fcl_radialW","FTPCW cluster radial position",700,0.,35.);
594  m_cluster_radial_West->SetLineColor(kBlue);
595  m_cluster_radial_East = new TH1F("fcl_radialE","FTPCE cluster radial position",700,0.,35.);
596  m_cluster_radial_East->SetLineColor(kRed);
597 
598  m_csteps = NULL;
599  m_hitsvspad = NULL;
600  m_hitsvstime = NULL;
601 
602  if (IAttr(".histos")) {
603  if (m_Mode == 4) {
604  m_pnt_xyFW = new TH2F("PointXYFtpcW","point: x-y distribution of hits, ftpcW",70,-35,35,70,-35,35);
605  m_pnt_xyFE = new TH2F("PointXYFtpcE","point: x-y distribution of hits, ftpcE",70,-35,35,70,-35,35);
606  m_pnt_planeF = new TH1F("PointPlaneF","point: plane distribution of hits, ftpc",20,0.5,20.5);
607  m_pnt_padtimeFW = new TH2F("PointPadTimeFtpcW","point: #pads vs #timebins of hits, ftpcW",12,0.5,12.5,10,0.5,10.5);
608  m_pnt_padtimeFW->SetXTitle("#timebins");
609  m_pnt_padtimeFW->SetYTitle("#pads");
610  m_pnt_padtimeFE = new TH2F("PointPadTimeFtpcE","point: #pads vs #timebins of hits, ftpcE",12,0.5,12.5,10,0.5,10.5);
611  m_pnt_padtimeFE->SetXTitle("#timebins");
612  m_pnt_padtimeFE->SetYTitle("#pads");
613  }
614  m_maxadc_West = new TH1F("fcl_maxadcW","FTPCW MaxAdc",50,0.5,50.5);
615  m_maxadc_East = new TH1F("fcl_maxadcE","FTPCE MaxAdc",50,0.5,50.5);
616  m_charge_West = new TH1F("fcl_chargeW","FTPCW charge",50,0.5,500.5);
617  m_charge_East = new TH1F("fcl_chargeE","FTPCE charge",50,0.5,500.5);
618  if (Debug()){
619  m_flags = new TH1F("fcl_flags" ,"FTPC cluster finder flags" ,8,0.,8.);
620  m_row = new TH1F("fcl_row" ,"FTPC rows" ,20,1.,21.);
621  m_sector = new TH1F("fcl_sector" ,"FTPC sectors" ,6,1.,7.);
622  m_row_sector = new TH2F("fcl_row_sector","FTPC(fcl) row vs. sector" ,20,1.,21.,6,1.,7.);
623  //m_pads = new TH1F("fcl_pads" ,"FTPC pads" ,80,1.,161.);
624  //m_timebins = new TH1F("fcl_timebins","FTPC timebins" ,100,1.,257.);
625  //m_npad_nbin = new TH2F("fcl_pad_bin" ,"FTPC(fcl) pad vs. timebin" ,80,1.,161.,100,1.,257.);
626  //m_csteps = new TH2F("fcl_csteps" ,"FTPC charge steps by sector" ,60,-0.5,59.5, 260, -0.5, 259.5);
627  m_hitsvspad = new TH2F("fcl_hitsvspad","#hits vs. padlength",10,0.5,10.5,11,0.5,11.5);
628  m_hitsvstime = new TH2F("fcl_hitsvstime","#hits vs. timelength",12,0.5,12.5,11,0.5,11.5);
629  }
630  }
631 
632  return StMaker::Init();
633 }
634 //_____________________________________________________________________________
636 {
637 
638  int using_FTPC_slow_simulator = 0;
639 
640  mCurrentEvent = (StEvent*) GetInputDS("StEvent");
641  if (mCurrentEvent) {
642  if (!(mFtpcHitColl = mCurrentEvent->ftpcHitCollection())) {
643  mFtpcHitColl = new StFtpcHitCollection;
644  mCurrentEvent->setFtpcHitCollection(mFtpcHitColl);
645  }
646  } else mFtpcHitColl = 0;
647 
648  // create parameter reader
649  StFtpcParamReader paramReader(m_clusterpars,m_fastsimgas,m_fastsimpars);
650 
651  if ( paramReader.returnCode != kStOK ) {
652  LOG_ERROR << "Exiting - error constructing StFtpcParamReader (paramReader.returnCode = "<<paramReader.returnCode<<")"<<endm;
653  return kStERR;
654  }
655 
656  // create FTPC data base reader
657  StFtpcDbReader dbReader(m_dimensions,
658  m_padrow_z,
659  m_asicmap,
660  m_efield,
661  m_vdrift,
662  m_deflection,
663  m_dvdriftdp,
664  m_ddeflectiondp,
665  m_ampslope,
666  m_ampoffset,
667  m_timeoffset,
668  m_driftfield,
669  m_gas,
670  m_electronics,
671  m_cathode,
672  m_clustergeo);
673 
674  if ( dbReader.returnCode != kStOK ) {
675  LOG_ERROR << "Exiting - error constructing StFtpcDbReader (dbReader.returnCode = "<<dbReader.returnCode<<")"<<endm;
676  return kStERR;
677  }
678 
679  if ( paramReader.gasTemperatureWest() == 0 && paramReader.gasTemperatureEast() == 0) {
680  dbReader.setLaserRun(laserRun);
681  LOG_INFO<<"Using the following values from database:"<<endm;
682  if (microsecondsPerTimebin > 0.0 ) {
683  dbReader.setMicrosecondsPerTimebin(microsecondsPerTimebin);
684  LOG_INFO<<" microsecondsPerTimebin = "<<dbReader.microsecondsPerTimebin()<<" (calculated from RHIC Clock Frequency)"<<endm;
685  } else {
686  LOG_INFO<<" microsecondsPerTimebin = "<<dbReader.microsecondsPerTimebin()<<" (default value from database)"<<endm;
687  }
688  LOG_INFO<<" SwapRDO6RDO7East = "<<dbReader.SwapRDO6RDO7East()<<endm;
689  LOG_INFO<<" EastIsInverted = "<<dbReader.EastIsInverted()<<endm;
690  LOG_INFO<<" Asic2EastNotInverted = "<<dbReader.Asic2EastNotInverted()<<endm;
691  LOG_INFO<<" tzero = "<<dbReader.tZero()<<endm;
692  LOG_INFO<<" temperatureDifference = "<<dbReader.temperatureDifference()<<endm;
693  LOG_INFO<<" defaultTemperatureWest = "<<dbReader.defaultTemperatureWest()<<endm;
694  LOG_INFO<<" defaultTemperatureEast = "<<dbReader.defaultTemperatureEast()<<endm;
695  LOG_INFO<<" adjustAverageWest = "<<dbReader.adjustAverageWest()<<endm;
696  LOG_INFO<<" adjustAverageEast = "<<dbReader.adjustAverageEast()<<endm;
697  LOG_INFO<<" magboltzVDrift(0,0) = "<<dbReader.magboltzVDrift(0,0)<<endm;
698  LOG_INFO<<" magboltzDeflection(0,0) = "<<dbReader.magboltzDeflection(0,0)<<endm;
699  LOG_INFO<<" offsetCathodeWest = "<<dbReader.offsetCathodeWest()<<endm;
700  LOG_INFO<<" offsetCathodeEast = "<<dbReader.offsetCathodeEast()<<endm;
701  LOG_INFO<<" angleOffsetWest = "<<dbReader.angleOffsetWest()<<endm;
702  LOG_INFO<<" angleOffsetEast = "<<dbReader.angleOffsetEast()<<endm;
703  LOG_INFO<<" minChargeWindow = "<<dbReader.minChargeWindow()<<endm;
704  LOG_INFO << " using gain table: amplitudeSlope(1,0) = "<<dbReader.amplitudeSlope(1,0)<<", amplitudeSlope(1,1) = "<<dbReader.amplitudeSlope(1,1)<< endm;
705  }
706  LOG_DEBUG<<" Using microsecondsPerTimebin = "<<dbReader.microsecondsPerTimebin()<<" for this event"<<endm;
707 
708  // Test if input data is real data (DAQ)
709 
710  St_DataSet *daqDataset;
712  StFTPCReader *ftpcReader=NULL;
713  daqDataset=GetDataSet("StDAQReader");
714  if(daqDataset)
715  {
716  LOG_DEBUG << "Using StDAQReader to get StFTPCReader" << endm;
717  if (!daqDataset) {
718  LOG_ERROR << "Exiting - daqDataset not found" << endm;
719  return kStErr;
720  }
721  daqReader=(StDAQReader *)(daqDataset->GetObject());
722  if (!daqReader) {
723  LOG_ERROR << "Exiting - daqReader not found" << endm;
724  return kStErr;
725  }
726  ftpcReader=daqReader->getFTPCReader();
727 
728  if (!ftpcReader || !ftpcReader->checkForData()) {
729  LOG_WARN << "No FTPC data available!" << endm;
730  return kStWarn;
731  }
732 
733  // test if pressure and gas temperature available from offline DB
734 
735  StDetectorDbFTPCGas *gas = StDetectorDbFTPCGas::instance();
736  if ( !gas ){
737  LOG_ERROR << "Error getting FTPC Offline database: Calibrations_ftpc/ftpcGasOut"<<endm;
738  return kStErr;
739  }
740 
741  Int_t returnCode;
742 
743  // use available pressure and gas temperature from offline DB to adjust
744  // the barometric pressure depending on the FTPC gas temperature
745 
746  StFtpcGasUtilities gasUtils(&paramReader,
747  &dbReader,
748  gas,
749  m_temps);
750 
751  returnCode = gasUtils.barometricPressure();
752 
753  // Calculate FTPC gas temperature from body temperatures
754 
755  //mDbMaker = (St_db_Maker*)GetMaker("db");
756  Int_t dbDate = mDbMaker->GetDateTime().GetDate();
757 
758  // For FTPC West
759 
760  returnCode = gasUtils.averageTemperatureWest(dbDate,GetRunNumber());
761 
762  // test if averageBodyTemperature for FTPC West found for first event
763  if (paramReader.gasTemperatureWest() == 0) {
764  // no value found in Calibrations_ftpc/ftpcGasOut for first event
765  // initialize FTPC gas temperatures to default values
766  // default values change depending on SVT high voltage on/off
767  // currently using daqReader->SVTPresent() to test but may need
768  // access to Conditions_svt/svtInterLocks
769  LOG_DEBUG << "daqReader->SVTPresent() = " << daqReader->SVTPresent() << endm;
770  returnCode = gasUtils.defaultTemperatureWest(dbDate,daqReader->SVTPresent());
771  }
772 
773  // For FTPC East
774 
775  returnCode = gasUtils.averageTemperatureEast(dbDate,GetRunNumber());
776 
777  // test if averageBodyTemperature for FTPC East found for first event
778  if (paramReader.gasTemperatureEast() == 0 ) {
779  // no value found in Calibrations_ftpc/ftpcGasOut for first event
780  // initialize FTPC gas temperatures to default values
781  // default values change depending on SVT high voltage on/off
782  // currently using daqReader->SVTPresent() to test but may need
783  // access to Conditions_svt/svtInterLocks
784  LOG_DEBUG << "daqReader->SVTPresent() = " << daqReader->SVTPresent() << endm;
785  returnCode = gasUtils.defaultTemperatureEast(dbDate,daqReader->SVTPresent());
786  }
787 
788 
789 
790  // Calculate and set adjustedAirPressureWest
791 
792  paramReader.setAdjustedAirPressureWest(paramReader.normalizedNowPressure()*((dbReader.baseTemperature()+STP_Temperature)/(paramReader.gasTemperatureWest()+STP_Temperature)));
793 
794 
795  // Calculate and set adjustedAirPressureEast
796 
797  paramReader.setAdjustedAirPressureEast(paramReader.normalizedNowPressure()*((dbReader.baseTemperature()+STP_Temperature)/(paramReader.gasTemperatureEast()+STP_Temperature)));
798 
799  LOG_INFO << " Using normalizedNowPressure = "<<paramReader.normalizedNowPressure()<<" gasTemperatureWest = "<<paramReader.gasTemperatureWest()<<" gasTemperatureEast = "<<paramReader.gasTemperatureEast()<< " to calculate and set adjustedAirPressureWest = "<<paramReader.adjustedAirPressureWest()<<" and adjustedAirPressureEast = "<<paramReader.adjustedAirPressureEast()<<endm;
800 
801  }
802 
803  mHitArray = new TObjArray(10000);
804  mHitArray->SetOwner(kTRUE); // make sure that delete calls ->Delete() as well
805  AddData(new TObjectSet("ftpcClusters", mHitArray));
806 
807  // ghitarray will only be used if fast simulator is active
808  TObjArray ghitarray(10000);
809  ghitarray.SetOwner();
810 
811  // Test if input data is embedding data (StFtpcMixerMaker)
812 
813  St_DataSet *mix = NULL;
814  mix = GetDataSet("FtpcMixer");
815  if (mix) {
816  LOG_INFO <<" DataSet FtpcMixer found" << endm;
817  //mix->ls(0);
818 
819  // Create an iterator
820  St_DataSetIter ftpc_raw(mix);
821 
822  //Get the tables
823  St_fcl_ftpcadc *adc = (St_fcl_ftpcadc *) ftpc_raw.Find("fcl_ftpcadc");
824  St_fcl_ftpcsqndx *sqndx = (St_fcl_ftpcsqndx *) ftpc_raw.Find("fcl_ftpcsqndx");
825  if (adc && sqndx) {
826 
827  ftpcReader=new StFTPCReader((short unsigned int *) sqndx->GetTable(),
828  sqndx->GetNRows(),
829  (char *) adc->GetTable(),
830  adc->GetNRows());
831 
832  LOG_INFO << "Created StFTPCReader from StFtpcMixerMaker(Embedding) tables #fcl_ftpcsqndx rows = "<<sqndx->GetNRows()<<" #fcl_ftpcadc rows = "<<adc->GetNRows() << endm;
833  using_FTPC_slow_simulator = 1;
834 
835  // Set gas temperature to default values so that database values printed only once
836  paramReader.setGasTemperatureWest(dbReader.defaultTemperatureWest());
837  paramReader.setGasTemperatureEast(dbReader.defaultTemperatureEast());
838  LOG_INFO << "Found StFtpcMixerMaker sequences with #fcl_ftpcsqndx rows = "<<sqndx->GetNRows()<<" #fcl_ftpcadc rows = "<<adc->GetNRows() <<endm;
839  }
840  else {
841  LOG_WARN << "FTPC Embedding Tables are not found:"
842  << " fcl_ftpcsqndx = " << sqndx
843  << " fcl_ftpcadc = " << adc << endm;
844  return kStWarn;
845  }
846  }
847 
848  // Test if input data is simulated data (StFtpcSlowSimMaker)
849 
850  St_DataSet *raw = GetDataSet("ftpc_raw");
851  if (raw && !mix) {
852  // FCL
853  St_DataSetIter get(raw);
854 
855  St_fcl_ftpcsqndx *fcl_ftpcsqndx = (St_fcl_ftpcsqndx*)get("fcl_ftpcsqndx");
856  St_fcl_ftpcadc *fcl_ftpcadc = (St_fcl_ftpcadc* )get("fcl_ftpcadc");
857 
858  if (fcl_ftpcsqndx&&fcl_ftpcadc) {
859 
860  ftpcReader=new StFTPCReader((short unsigned int *) fcl_ftpcsqndx->GetTable(),
861  fcl_ftpcsqndx->GetNRows(),
862  (char *) fcl_ftpcadc->GetTable(),
863  fcl_ftpcadc->GetNRows());
864 
865  LOG_INFO << "Created StFTPCReader from FTPC Slow Simulator tables #fcl_ftpcsqndx rows = "<<fcl_ftpcsqndx->GetNRows()<<" #fcl_ftpcadc rows = "<<fcl_ftpcadc->GetNRows() << endm;
866  using_FTPC_slow_simulator = 1;
867 
868  // Set gas temperature to default values so that database values printed only once
869  paramReader.setGasTemperatureWest(dbReader.defaultTemperatureWest());
870  paramReader.setGasTemperatureEast(dbReader.defaultTemperatureEast());
871  }
872  else {
873  LOG_WARN << "FTPC Slow Simulator Tables are not found:"
874  << " fcl_ftpcsqndx = " << fcl_ftpcsqndx
875  << " fcl_ftpcadc = " << fcl_ftpcadc << endm;
876  return kStWarn;
877  }
878  }
879 
880  if(ftpcReader) {
881 
882  if(Debug()) {
883  LOG_DEBUG << "start running StFtpcClusterFinder" << endm;
884  }
885 
886  Int_t searchResult = kStOK;
887 
888  if (m_Mode == 2 || m_Mode==3) {
889  StFtpcClusterDebug cldebug((int) GetRunNumber(),(int) GetEventNumber());
890  cldebug.fillRun((int) GetRunNumber(), (int) mDbMaker->GetDateTime().GetDate(), (int) mDbMaker->GetDateTime().GetTime(), dbReader.microsecondsPerTimebin(), paramReader.normalizedNowPressure(), paramReader.standardPressure(),dbReader.baseTemperature(), paramReader.gasTemperatureWest(), paramReader.gasTemperatureEast(),paramReader.adjustedAirPressureWest()-paramReader.standardPressure(), paramReader.adjustedAirPressureEast()-paramReader.standardPressure());
891 
892  StFtpcClusterFinder fcl( ftpcReader,
893  &paramReader,
894  &dbReader,
895  mHitArray,
896  m_hitsvspad,
897  m_hitsvstime,
898  m_csteps,
901  &cldebug);
902  if (Debug()) fcl.DebugOn=kTRUE;
903  else fcl.DebugOn=kFALSE;
904  searchResult = fcl.search();
905  }
906 
907  else {
908  StFtpcClusterFinder fcl( ftpcReader,
909  &paramReader,
910  &dbReader,
911  mHitArray,
912  m_hitsvspad,
913  m_hitsvstime,
914  m_csteps,
917  if (Debug()) fcl.DebugOn=kTRUE;
918  else fcl.DebugOn=kFALSE;
919  searchResult = fcl.search();
920  }
921 
922  if (searchResult == kStERR) return kStERR;
923 
924  if (using_FTPC_slow_simulator) delete ftpcReader;
925  }
926  else {
927  // FFS
928  St_DataSet *gea = GetDataSet("geant");
929  St_DataSetIter geant(gea);
930  St_g2t_vertex *g2t_vertex = (St_g2t_vertex *) geant("g2t_vertex");
931  St_g2t_track *g2t_track = (St_g2t_track *) geant("g2t_track");
932  St_g2t_ftp_hit *g2t_ftp_hit = (St_g2t_ftp_hit *) geant("g2t_ftp_hit");
933  if (g2t_vertex && g2t_track && g2t_ftp_hit){
934  StFtpcGeantReader geantReader (g2t_vertex,
935  g2t_track,
936  g2t_ftp_hit);
937 
938  if(Debug()) {
939  LOG_DEBUG << "NO RAW DATA AVAILABLE - start running StFtpcFastSimu" << endm;
940  }
941 
942  StFtpcFastSimu ffs (&geantReader,
943  &paramReader,
944  &dbReader,
945  mHitArray,
946  &ghitarray);
947  if(Debug()) {
948  LOG_DEBUG << "finished running StFtpcFastSimu" << endm;
949  }
950  }
951  }
952 
953  Int_t num_points = mHitArray->GetEntriesFast();
954  if(num_points>0 && mFtpcHitColl) { // points found and hitCollection exists
955  // Write hits to StEvent
956  StFtpcPoint *point;
957 
958  for (Int_t i=0; i<num_points; i++) {
959  point = (StFtpcPoint *)mHitArray->At(i);
960  point->ToStEvent(mFtpcHitColl);
961  }
962  }
963 
964 
965  StDetectorDbFTPCVoltageStatus *voltageStatus = StDetectorDbFTPCVoltageStatus::instance();
966  if ( !voltageStatus) {
967  LOG_ERROR << "Error getting FTPC Offline database: Calibrations_ftpc/ftpcVoltageStatus"<<endm;
968  return kStErr;
969  }
970  // if mVoltageStatus and StEvent exists, set StDetectorState
971  // (StDetectorState only set for events with FTPC data)
972  if (voltageStatus && mCurrentEvent) {
973  mCurrentEvent->addDetectorState(new StDetectorState(kFtpcEastId,voltageStatus->getStatusFTPCEast()));
974  mCurrentEvent->addDetectorState(new StDetectorState(kFtpcWestId,voltageStatus->getStatusFTPCWest()));
975  }
976 
977 
978  Int_t num_gpoints = ghitarray.GetEntriesFast();
979  if(num_gpoints>0)
980  {
981  St_ffs_gepoint *ffs_gepoint = new St_ffs_gepoint("ffs_fgepoint",num_gpoints);
982  AddData(ffs_gepoint);
983 
984  ffs_gepoint_st *gpointTable= ffs_gepoint->GetTable();
985 
986  StFtpcGeantPoint *gpoint;
987 
988  for (Int_t i=0; i<num_gpoints; i++)
989  {
990  gpoint = (StFtpcGeantPoint *)ghitarray.At(i);
991  gpoint->ToTable(&(gpointTable[i]));
992  }
993 
994  ffs_gepoint->SetNRows(num_gpoints);
995  }
996 
997  // mHitArray and its contents will be deleted by StMaker::Clear() since it is sitting in a TDataSet
998 
999  // Fill FTPC cluster maker histograms
1000  MakeHistograms();
1001 
1002  return kStOK;
1003 }
1004 
1005 
1006 
1007 //_____________________________________________________________________________
1008 void StFtpcClusterMaker::MakeHistograms()
1009 {
1010  if (!mHitArray) return;
1011 
1012  //LOG_DEBUG<<"*** NOW MAKING HISTOGRAMS ***"<<endm;
1013 
1014  for (Int_t i=0; i<mHitArray->GetEntriesFast();i++) {
1015  StFtpcPoint *hit = (StFtpcPoint*)mHitArray->At(i);
1016 
1017  if (m_Mode == 4) m_pnt_planeF->Fill(hit->GetPadRow());
1018  // created here because x,y still in FTPC internal coordinate system
1019  Float_t rpos = ::sqrt(hit->GetX()*hit->GetX() + hit->GetY()*hit->GetY());
1020  if (hit->GetPadRow() <=10 ) {
1021  m_cluster_radial_West->Fill(rpos);
1022  if (IAttr(".histos")) {
1023  if (m_Mode == 4) {
1024  m_pnt_xyFW->Fill(hit->GetX(),hit->GetY());
1025  m_pnt_padtimeFW->Fill(hit->GetNumberBins(),hit->GetNumberPads());
1026  }
1027  m_maxadc_West->Fill(hit->GetMaxADC());
1028  m_charge_West->Fill(hit->GetCharge());
1029  }
1030  } //end if hit->GetPadRow() <=10
1031  else if (hit->GetPadRow() >=11 ) {
1032  m_cluster_radial_East->Fill(rpos);
1033  if (IAttr(".histos")) {
1034  if (m_Mode == 4) {
1035  m_pnt_xyFE->Fill(hit->GetX(),hit->GetY());
1036  m_pnt_padtimeFE->Fill(hit->GetNumberBins(),hit->GetNumberPads());
1037  }
1038  m_maxadc_East->Fill(hit->GetMaxADC());
1039  m_charge_East->Fill(hit->GetCharge());
1040  }
1041  } //end if hit->GetPadRow() >=11
1042 
1043  if (IAttr(".histos") && Debug()) {
1044  Int_t flag = hit->GetFlags();
1045  if (flag > 0) {
1046  Int_t bin = 7;
1047  for (Int_t twofac=128; twofac>0; twofac=twofac/2,bin--) {
1048  Int_t nbit = flag/twofac;
1049  if (nbit != 1) continue;
1050  m_flags->Fill((float)bin);
1051  flag = flag - nbit*twofac;
1052  } //end loop twofac
1053  } //endif flag
1054 
1055  Float_t nrow = hit->GetPadRow();
1056  m_row->Fill(nrow);
1057  Float_t nsec = hit->GetSector();
1058  m_sector->Fill(nsec);
1059  m_row_sector->Fill(nrow,nsec);
1060 
1061  // Float_t npad = r->n_pads;
1062  // m_pads->Fill(npad);
1063  // Float_t nbin = r->n_bins;
1064  // m_timebins->Fill(nbin);
1065  // m_npad_nbin->Fill(npad,nbin);
1066  } //end if IAttr
1067 
1068  } //end for mHitArray->GetEntriesFast()
1069 
1070 }
Int_t m_Mode
counters
Definition: StMaker.h:81
TH1F * m_flags
FTPC East charge step.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
TH1F * m_cluster_radial_East
radial position of clusters in FTPC West
TH2F * m_pnt_xyFE
xy dist. of hits, ftpcW
TH2F * m_hitsvspad
charge step by (6*row)+sector
TH1F * m_pnt_planeF
padlength vs timelength of hits, ftpcW
TH1F * m_chargestep_East
FTPC West charge step.
TH2F * m_csteps
row vs. sector
TH1F * m_row
quality control flags
TH2F * m_pnt_padtimeFW
xy dist. of hits, ftpcE
TH1F * m_maxadc_West
number of found hits over cluster timelength
TH2F * m_pnt_padtimeFE
plane dist. of hits, ftpc
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TDataSet.cxx:428
TH1F * m_chargestep_West
radial position of clusters in FTPC East
Definition: Stypes.h:42
Definition: Stypes.h:40
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
virtual TDataSet * Find(const Char_t *path, TDataSet *rootset=0, Bool_t mkdir=kFALSE, Bool_t titleFlag=kFALSE)
Definition: Stypes.h:44
TH2F * m_pnt_xyFW
sectors
TH2F * m_row_sector
padlength vs timelength of hits, ftpcE
TH2F * m_hitsvstime
number of found hits over cluster padlength
Definition: Stypes.h:45