StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtHitMaker.cxx
1 /***************************************************************************
2  *
3  * $Id: StSvtHitMaker.cxx,v 1.44 2018/06/08 16:38:23 genevb Exp $
4  *
5  * Author:
6  ***************************************************************************
7  *
8  * Description: Cluster Hit Maker class
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtHitMaker.cxx,v $
13  * Revision 1.44 2018/06/08 16:38:23 genevb
14  * Needs explicit include of TROOT.h
15  *
16  * Revision 1.43 2009/11/23 16:44:55 fisyak
17  * Remove references to tables
18  *
19  * Revision 1.42 2007/12/17 14:15:15 fisyak
20  * Add reject for hits for invalid drift regions
21  *
22  * Revision 1.41 2007/09/21 00:08:17 caines
23  * Save out number of pixels and hits into StEvent hits
24  *
25  * Revision 1.40 2007/07/12 20:06:50 fisyak
26  * Move initialization to IntRun from Init, empty GetSvtDriftCurve, clean up
27  *
28  * Revision 1.39 2007/04/28 17:57:06 perev
29  * Redundant StChain.h removed
30  *
31  * Revision 1.38 2007/03/21 17:22:58 fisyak
32  * Ivan Kotov's drift velocities, use TGeoHMatrix for coordinate transformation
33  *
34  * Revision 1.37 2006/05/08 13:52:11 fisyak
35  * Fill StSvtHits directly into StEvent (if it exists), add local coordinate, add handle for drift velocity hack correction
36  *
37  * Revision 1.36 2005/07/23 03:37:33 perev
38  * IdTruth + Cleanup
39  *
40  * Revision 1.35 2004/11/03 21:36:04 caines
41  * Remove calls that need database and event time information to correct place in InitRun not Init
42  *
43  * Revision 1.34 2004/07/29 01:36:59 caines
44  * Changes for using the drift curves
45  *
46  * Revision 1.33 2004/07/07 18:09:24 caines
47  * Save out fraction drfi5 velocity scaler to StEvent
48  *
49  * Revision 1.32 2004/06/21 20:18:34 caines
50  * Add number of anodes count to res[0] variable for use in dedx calc
51  *
52  * Revision 1.31 2004/06/14 21:27:46 caines
53  * Fine tuning of drift velocity using laser spots from Jana Bielcikova
54  *
55  * Revision 1.30 2004/05/05 21:27:54 caines
56  * Fix bug that causes default drift vel. to be used instead of value from database...
57  *
58  * Revision 1.29 2004/03/18 04:02:56 caines
59  * Remove from global scope variables used in debug mode as they shouldnt be there and caused erratic behaviour
60  *
61  * Revision 1.28 2004/01/27 02:34:11 perev
62  * LeakOff
63  *
64  * Revision 1.27 2003/09/18 18:16:38 caines
65  * Initialise stuff for new compiler
66  *
67  * Revision 1.26 2003/09/02 17:59:07 perev
68  * gcc 3.2 updates + WarnOff
69  *
70  * Revision 1.25 2003/04/14 18:33:45 munhoz
71  * reading t0 from DB
72  *
73  * Revision 1.24 2003/01/28 20:28:51 munhoz
74  * new filters for clusters
75  *
76  * Revision 1.22 2002/02/22 18:43:39 caines
77  * Add SetFileNames function
78  *
79  * Revision 1.21 2002/02/16 22:05:06 jeromel
80  * Marcelo's recen changes to StSvtClusterMaker (needed to be in sync with
81  * StDbUtilities changes)
82  *
83  * Revision 1.20 2002/02/03 00:34:50 caines
84  * Still fill scs_spt table even if database missing so global doesnt crash
85  *
86  * Revision 1.19 2002/01/31 23:53:25 caines
87  * Return kStOK even if init fails so chain doesnt crash
88  *
89  * Revision 1.18 2002/01/31 22:56:39 caines
90  * Make code cope with database failing, now just sends error messages and quits but doesnt make chain end
91  *
92  * Revision 1.17 2002/01/28 23:42:10 caines
93  * Move to SVT database with StSvtDbMaker
94  *
95  * Revision 1.16 2001/09/22 01:07:09 caines
96  * Fixes now that AddData() is cleared everyevent
97  *
98  * Revision 1.15 2001/08/07 20:52:15 caines
99  * Implement better packing of svt hardware and charge values
100  *
101  * Revision 1.14 2001/07/24 23:43:08 caines
102  * Better flagging of hits out of drift range
103  *
104  * Revision 1.13 2001/05/09 02:23:06 caines
105  * Fix axis limits
106  *
107  * Revision 1.12 2001/05/04 14:20:05 caines
108  * Improved historgramming
109  *
110  * Revision 1.11 2001/03/22 20:46:54 caines
111  * Comment out some of the QA histograms
112  *
113  * Revision 1.10 2001/02/19 23:55:34 caines
114  * Even get id correct (start from 1 not 0)
115  *
116  * Revision 1.9 2001/02/19 23:37:59 caines
117  * Ensure hits have a unique id for ALL svt, remover print statement
118  *
119  * Revision 1.8 2001/02/18 00:10:48 caines
120  * Improve and use StSvtConfig
121  *
122  * Revision 1.7 2001/02/07 19:15:54 caines
123  * Change evaluation flag when running with GEANT
124  *
125  * Revision 1.6 2000/11/30 20:42:08 caines
126  * Some more evaluation and use dataase
127  *
128  * Revision 1.5 2000/10/02 13:47:03 caines
129  * Fixed some array bound problems. Better flagging of hits
130  *
131  * Revision 1.4 2000/08/29 22:46:26 caines
132  * Fixed some memory leaks
133  *
134  * Revision 1.3 2000/08/26 20:36:28 caines
135  * Adjustments for StSvtCoordinateTransform calls
136  *
137  * Revision 1.2 2000/08/24 04:26:56 caines
138  * Printout for debugging
139  *
140  * Revision 1.1 2000/08/21 13:03:40 caines
141  * First version of cluster->STAR hit maker
142  *
143  **************************************************************************/
144 
145 #include <stdlib.h>
146 #include <string.h>
147 #include "Stiostream.h"
148 
149 #include "StSvtHitMaker.h"
150 
151 #include "TDataSetIter.h"
152 #include "TObjectSet.h"
153 #include "StMessMgr.h"
154 #include "StMCTruth.h"
155 
156 #include "TROOT.h"
157 #include "TFile.h"
158 #include "TNtuple.h"
159 
160 #include "StDbUtilities/StSvtCoordinateTransform.hh"
161 #include "StDbUtilities/StCoordinates.hh"
162 //#include "StTpcDb/StTpcDb.h"
163 #include "StSvtClassLibrary/StSvtHybridCollection.hh"
164 #include "StSvtClassLibrary/StSvtData.hh"
165 #include "StSvtClassLibrary/StSvtGeometry.hh"
166 #include "StSvtClassLibrary/StSvtWaferGeometry.hh"
167 #include "StSvtClassLibrary/StSvtT0.hh"
168 #include "StSvtAnalysedHybridClusters.hh"
169 #include "StSvtSimulationMaker/StSvtGeantHits.hh"
170 #include "StEvent.h"
171 #include "StEventTypes.h"
172 #include "StDbUtilities/St_svtCorrectionC.h"
173 #include "StDbUtilities/St_svtHybridDriftVelocityC.h"
174 
175 ClassImp(StSvtHitMaker)
176 //___________________________________________________________________________
177 StSvtHitMaker::StSvtHitMaker(const char *name) : StMaker(name)
178 {
179  int n = (char*)&filenameC - (char*)&iWrite + sizeof(filenameC);
180  memset(&iWrite,0,n);
181 }
182 
183 //_____________________________________________________________________________
185 {
186  delete m_x_vs_y;
187  for (int i=0;i<mNwaf_no;i++) {delete m_waf_no[i];}
188  delete [] m_waf_no; m_waf_no=0;
189 
190  delete m_ClusTuple;
191  delete m_hfile;
192 
193  // delete Evaluation histos
194  delete mTimeHitResolution;
195  delete mAnodeHitResolution;
196  delete mXHitResolution;
197  delete mYHitResolution;
198  delete mZHitResolution;
199  delete mHitResolution;
200 
201 }
202 
203 //_____________________________________________________________________________
204 Int_t StSvtHitMaker::Init()
205 {
206 
207  if (Debug()) gMessMgr->Debug() << "In StSvtHitMaker::Init() ..." << endm;
208 
209  return StMaker::Init();
210 
211 }
212 
213 //_____________________________________________________________________________
214 Int_t StSvtHitMaker::InitRun(int runumber)
215 {
216 
217  if (Debug()) gMessMgr->Debug() << "In StSvtHitMaker::InitRun() ..." << endm;
218  // Get pointer to StSvtAnalysis
219 
220  if( GetSvtRawData()){
221  gMessMgr->Warning() << " No SVT raw data "<< endm;
222  return kStWarn;
223  }
224 
225  // get geant hits if running MC data
226  mSvtGeantHitColl = 0;
227  St_DataSet *dataSet2 = GetDataSet("StSvtGeantHits");
228  if (dataSet2)
229  mSvtGeantHitColl = (StSvtHybridCollection*)(dataSet2->GetObject());
230 
231  if( GetSvtGeometry() != kStOK) return kStWarn;
232 
233  // drift velocity
234  if( GetSvtDriftVelocity() != kStOK) return kStWarn;
235 
236  // drift curves from Robert
237  if( GetSvtDriftCurve() != kStOK) return kStWarn;
238 
239  // t0
240  if( GetSvtT0() != kStOK) return kStWarn;
241 
242  // iWrite=1;
243 
244 
245  // Create tables
246  // St_DataSetIter local(GetInputDB("svt"));
247 
248 
249  // geometry parameters
250 
251  //if( GetSvtGeometry() != kStOK) return kStWarn;
252 
253  // drift velocity
254  // if( GetSvtDriftVelocity() != kStOK) return kStWarn;
255 
256  // drift curves from Robert
257  //if( GetSvtDriftCurve() != kStOK) return kStWarn;
258 
259  m_x_vs_y = new TH2F("si_x_vs_y","X vs Y of Si space points",
260  300,-30,30,300,-30,30);
261 
262  m_x_vs_y->SetYTitle("y cm");
263  m_x_vs_y->SetXTitle("x cm");
264 
265  mNwaf_no = 2*mSvtData->getNumberOfBarrels();
266  m_waf_no = new TH2F*[mNwaf_no];
267 
268  char title1[20];
269  char* title3;
270  char title2[4];
271 
272  int barrel=0;
273 
274  for( int idbarrel=1; idbarrel<=mSvtData->getNumberOfBarrels();
275  idbarrel++, barrel++){
276 
277 
278  float n_ladders = float(mSvtData->getNumberOfLadders(idbarrel))+0.5;
279 
280  sprintf(title1,"SvtLayer");
281  sprintf(title2,"%d", barrel+1);
282  title3 = strcat(title1,title2);
283 
284 
285  m_waf_no[barrel] = new TH2F(title3," Si z vs ladder no.",
286  100,-25.,25.,100,0.5,n_ladders);
287  m_waf_no[barrel]->SetYTitle("ladder no");
288  m_waf_no[barrel]->SetXTitle("Z cm");
289  barrel++;
290 
291  sprintf(title1,"SvtLayer");
292  sprintf(title2,"%d", barrel+1);
293  title3 = strcat(title1,title2);
294  m_waf_no[barrel] = new TH2F(title3," Si z vs ladder no.",
295  100,-25.,25.,100,0.5,n_ladders);
296  m_waf_no[barrel]->SetYTitle("ladder no");
297  m_waf_no[barrel]->SetXTitle("Z cm");
298  }
299 
300  if( iWrite >0){
301  m_hfile = new TFile(filenameN,"RECREATE","Clusters");
302 
303  m_ClusTuple = new TNtuple("Clusters","Clusters","flag:xl:yl:x:y:z:charge:mom2x:mom2y:numAnodes:numPixels:peak:hybrid:evt");
304 
305  // if( iWrite > 1){
306 // //cluInfo.open(filenameC,ios::out);
307 // }
308  }
309 
310  if (mSvtGeantHitColl){
311 
312  mTimeHitResolution = new TH1F("hitTRes","Delta X for Hits",1000,-2.0,2.0);
313  mAnodeHitResolution = new TH1F("hitARes","Delta Z for Hits",1000,-2.0,2.0);
314  mXHitResolution = new TH1F("hitXRes","Delta X for Hits",1000,-0.1,0.1);
315  mYHitResolution = new TH1F("hitYRes","Delta Y for Hits",1000,-0.1,0.1);
316  mZHitResolution = new TH1F("hitZRes","Delta Z for Hits",1000,-0.1,0.1);
317  mHitResolution = new TH2F("hitRes","Delta Z Vs Delta X for Hits",1000,-2.0,2.0,1000,-2.0,2.0);
318 
319  mTimeHitResolution->SetXTitle("delta X (timebucket)");
320  mAnodeHitResolution->SetXTitle("delta Z (anode)");
321  mXHitResolution->SetXTitle("delta X (cm)");
322  mYHitResolution->SetXTitle("delta Y (cm)");
323  mZHitResolution->SetXTitle("delta Z (cm)");
324  mHitResolution->SetXTitle("delta X (timebucket)");
325  mHitResolution->SetYTitle("delta Z (anode)");
326  }
327 
328  // Add the Maker histograms in the Maker histograms list
329  // and remove it from the ROOT system directory
330  TObject *objLast,*objHist;
331  gROOT->cd();
332  objLast = gDirectory->GetList()->Last();
333  TIter nextHist(gDirectory->GetList());
334  int ready = !objLast;
335  while((objHist=nextHist())) {// loop over gDirectory
336  if (!ready && objHist!=objLast) continue;
337  ready = 1999;
338  if (objHist==objLast) continue;
339  if (!objHist->InheritsFrom("TH1")) continue;
340 
341  // Move the histogram from the ROOT list into the "maker's" list
342  ((TH1*)objHist)->SetDirectory(0);
343  AddHist((TH1*)objHist);
344  }
345  return kStOK;
346 
347 }
348 
349 
350 //___________________________________________________________________________
351 
352 Int_t StSvtHitMaker::GetSvtRawData()
353 {
354 
355  mSvtData = 0;
356  St_DataSet *dataSet2 = GetDataSet("StSvtData");
357  if( dataSet2) mSvtData = (StSvtData*)(dataSet2->GetObject());
358 
359  if( !mSvtData) return kStWarn;
360  return kStOk;
361 }
362 //___________________________________________________________________________
363 
364 Int_t StSvtHitMaker::GetSvtClusterData()
365 {
366 
367  mSvtCluColl = 0;
368  St_DataSet *dataSet2 = GetDataSet("StSvtAnalResults");
369  if( !dataSet2) return kStWarn;
370  mSvtCluColl = (StSvtHybridCollection*)(dataSet2->GetObject());
371 
372  if( !mSvtCluColl) return kStWarn;
373  return kStOK;
374 
375 }
376 //___________________________________________________________________________
377 Int_t StSvtHitMaker::GetSvtGeometry()
378 {
379  m_geom = 0;
380  St_DataSet* dataSet;
381  dataSet = GetDataSet("StSvtGeometry");
382  if(!dataSet) {
383  gMessMgr->Error("Failure to get SVT geometry - THINGS HAVE GONE SERIOUSLY WRONG!!!!! \n");
384 
385  return kStOK;
386  }
387 
388  m_geom = (StSvtGeometry*)dataSet->GetObject();
389 
390  return kStOK;
391 
392 }
393 //___________________________________________________________________________
394 Int_t StSvtHitMaker::GetSvtDriftVelocity()
395 {
396  m_driftVeloc = 0;
397  St_DataSet* dataSet;
398  dataSet = GetDataSet("StSvtDriftVelocity");
399  if(!dataSet) {
400  gMessMgr->Error("Failure to get SVT drift velocity - THINGS HAVE GONE SERIOUSLY WRONG!!!!! \n");
401 
402  return kStOK;
403  }
404 
405  m_driftVeloc = (StSvtHybridCollection*)dataSet->GetObject();
406 
407  return kStOK;
408 
409 }
410 //___________________________________________________________________________
411 Int_t StSvtHitMaker::GetSvtDriftCurve()
412 {
413  m_driftCurve = 0;
414  return kStOK;
415 
416 }
417 //___________________________________________________________________________
418 Int_t StSvtHitMaker::GetSvtT0()
419 {
420 
421  St_DataSet* dataSet;
422  dataSet = GetDataSet("StSvtT0");
423  if(!dataSet) {
424  gMessMgr->Error("Failure to get SVT t0 - THINGS HAVE GONE SERIOUSLY WRONG!!!!! \n");
425 
426  return kStOK;
427  }
428 
429  m_t0 = (StSvtT0*)dataSet->GetObject();
430 
431  return kStOK;
432 
433 }
434 //___________________________________________________________________________
436 {
437  if (Debug()) gMessMgr->Debug() << "In StSvtHitMaker::Make() ..." << endm;
438 // Get pointer to StSvtData
439 
440  if( GetSvtRawData()){
441  gMessMgr->Warning() <<" No SVT raw data" << endm;
442  return kStWarn;
443  }
444 
445  if( GetSvtClusterData()){
446  gMessMgr->Warning() <<" No SVT Cluster data" << endm;
447  return kStWarn;
448  }
449 
450  if( !m_geom){
451  gMessMgr->Warning() <<" Things are wrong with the SVT database!!!!!!!!!" << endm;
452  }
453 
454  TransformIntoSpacePoint();
455  FillHistograms();
456 
457 // if (mSvtGeantHitColl)
458 // Eval();
459 
460  return kStOK;
461 }
462 
463 //____________________________________________________________________________
464 
465 void StSvtHitMaker::TransformIntoSpacePoint(){
466 
467  int index, TotHits=0, GoodHit=0;
468 
469 
470  StSvtCoordinateTransform SvtGeomTrans;
471  //SvtGeomTrans.setParamPointers(&srs_par[0], &geom[0], &shape[0], mSvtData->getSvtConfig());
472  // if(m_geom) SvtGeomTrans.setParamPointers(m_geom, mSvtData->getSvtConfig(), m_driftVeloc, m_t0);
473  St_svtCorrectionC *driftVelocityCor = 0;
474  if(m_geom) SvtGeomTrans.setParamPointers(m_geom, mSvtData->getSvtConfig(), m_driftVeloc, m_driftCurve, m_t0,driftVelocityCor );
475  StSvtLocalCoordinate localCoord(0,0,0);
476  StSvtWaferCoordinate waferCoord(0,0,0,0,0,0);
477  StGlobalCoordinate globalCoord(0,0,0);
478  StThreeVectorF mPos(0,0,0);
479  StEvent *pEvent = (StEvent*) GetInputDS("StEvent");
480 
481  //here is applied laser correction for temperature variations;
482  St_svtHybridDriftVelocityC *driftVel = St_svtHybridDriftVelocityC::instance();
483  assert(driftVel);
484  Int_t index2 = -1;
485  for(int barrel = 1;barrel <= mSvtData->getNumberOfBarrels();barrel++) {
486 
487  for (int ladder = 1;ladder <= mSvtData->getNumberOfLadders(barrel);ladder++) {
488 
489  for (int wafer = 1;wafer <= mSvtData->getNumberOfWafers(barrel);wafer++) {
490 
491  for (int hybrid = 1;hybrid <=mSvtData->getNumberOfHybrids();hybrid++){
492  index2++;
493 
494  index = mSvtData->getHybridIndex(barrel,ladder,wafer,hybrid);
495  if(index < 0) continue;
496  if (! driftVel->p(barrel,ladder,wafer,hybrid)) continue;
497  mSvtBigHit = (StSvtAnalysedHybridClusters*)mSvtCluColl->at(index);
498  if( !mSvtBigHit) continue;
499 
500  for( int clu=0; clu<mSvtBigHit->numOfHits(); clu++){
501  if (! driftVel->IsValidDriftRegion(barrel,ladder,wafer,hybrid, mSvtBigHit->WaferPosition()[clu].x())) continue;
502  TotHits++;
503  mSvtBigHit->svtHitData()[clu].id = TotHits;
504  waferCoord.setTimeBucket(mSvtBigHit->WaferPosition()[clu].x());
505  waferCoord.setAnode(mSvtBigHit->WaferPosition()[clu].y());
506  waferCoord.setLayer(mSvtBigHit->getLayerID());
507  waferCoord.setLadder(ladder);
508  waferCoord.setWafer(wafer);
509  waferCoord.setHybrid(hybrid);
510 
511  if( m_geom) {
512  SvtGeomTrans(waferCoord,localCoord);
513  SvtGeomTrans(localCoord,globalCoord);
514  }
515  // cout << " Timebucket=" << waferCoord.timebucket() <<
516  // " x=" << localCoord.position().x() <<
517  // " hybrid=" << localCoord.hybrid() <<
518  // " flag =" <<mSvtBigHit->svtHit()[clu].flag() << endl;
519 
520  mPos.setX(globalCoord.position().x());
521  mPos.setY(globalCoord.position().y());
522  mPos.setZ(globalCoord.position().z());
523  mSvtBigHit->svtHit()[clu].setPosition(mPos);
524  mSvtBigHit->svtHitData()[clu].uv[0] = localCoord.position().x();
525  mSvtBigHit->svtHitData()[clu].uv[1] = localCoord.position().y();
526  mSvtBigHit->svtHitData()[clu].anode = waferCoord.anode();
527  mSvtBigHit->svtHitData()[clu].timeb = waferCoord.timebucket();
528  // cout << "local x = " << localCoord.position().x() << ", local y = " << localCoord.position().y() << ", local z = " << localCoord.position().z() << endl;
529  //cout << "global x = " << globalCoord.position().x() << ", global y = " << globalCoord.position().y() << ", global z = " << globalCoord.position().z() << endl;
530 
531  if (pEvent) {
532 
533  Int_t hw_position, svtx, svty;
534  StSvtHit *svtHit = 0;
535  StSvtHitCollection *svtHitColl = pEvent->svtHitCollection();
536  if (! svtHitColl) {
537  svtHitColl = new StSvtHitCollection;
538  pEvent->setSvtHitCollection(svtHitColl);
539  }
540  svtHit = new StSvtHit();
541  StSvtHitData *dat = mSvtBigHit->svtHitData() +clu;
542  StThreeVector<double> *waf = mSvtBigHit->WaferPosition()+clu;
543  StSvtHit *hit= mSvtBigHit->svtHit() +clu;
544 
545  hw_position = 2;
546  hw_position += (1L<<4)*(index2);
547  svtx = int(waf->x()*4);
548  hw_position += (1L<<13)*(svtx);
549  svty = int(waf->y()*4);
550  hw_position += (1L<<22)*svty;
551  svtHit->setHardwarePosition(hw_position);
552  svtHit->setIdTruth(hit->idTruth(),hit->qaTruth());
553 
554  svtHit->setPeak(dat->peakAdc);
555  svtHit->setCharge(hit->charge());
556  svtHit->setFlag(hit->flag());
557  if (driftVelocityCor) {
558  if (! driftVelocityCor->pCorrection(svtHit->layer(), svtHit->ladder(), svtHit->wafer(), svtHit->hybrid()))
559  svtHit->setFlag(hit->flag()+100);
560  }
561  svtHit->setFitFlag(0);
562  svtHit->setPosition(mSvtBigHit->svtHit()[clu].position());
563  svtHit->setId(dat->id);
564  svtHit->setLocalPosition(dat->uv[0],dat->uv[1]);
565  svtHit->setAnode(dat->anode);
566  svtHit->setTimebucket(dat->timeb);
567  svtHit->setNumberOfAnodes(dat->numOfAnodesInClu);
568  svtHit->setNumberOfPixels(dat->numOfPixelsInClu);
569 
570  svtHitColl->addHit(svtHit);
571  }
572 
573  if(mSvtBigHit->svtHit()[clu].flag() < 4) GoodHit++;
574 
575  if( iWrite > 0){
576  SaveIntoNtuple(mSvtBigHit->numOfHits(),index);
577  }
578  }
579  }
580  }
581  }
582 
583  }
584 
585  SafeDelete(driftVelocityCor);
586  gMessMgr->Info() << "Found " << GoodHit << " good hits " << endm;
587 }
588 
589 //_____________________________________________________________________________
590 Int_t StSvtHitMaker::FillHistograms(){
591 
592 
593  int index;
594 
595  for(int barrel = 1;barrel <= mSvtData->getNumberOfBarrels();barrel++) {
596 
597  for (int ladder = 1;ladder <= mSvtData->getNumberOfLadders(barrel);ladder++) {
598 
599  for (int wafer = 1;wafer <= mSvtData->getNumberOfWafers(barrel);wafer++) {
600 
601  for (int hybrid = 1;hybrid <=mSvtData->getNumberOfHybrids();hybrid++){
602 
603 
604  index = mSvtData->getHybridIndex(barrel,ladder,wafer,hybrid);
605  if(index < 0) continue;
606 
607  mSvtBigHit = (StSvtAnalysedHybridClusters*)mSvtCluColl->at(index);
608  if( !mSvtBigHit) continue;
609 
610  for( int clu=0; clu<mSvtBigHit->numOfHits(); clu++){
611 
612  if( mSvtBigHit->svtHit()[clu].flag() < 4){
613  int layer = mSvtBigHit->getLayerID()-1;
614  int ladder = (int)(mSvtBigHit->svtHit()[clu].ladder());
615 
616  m_x_vs_y->Fill(mSvtBigHit->svtHit()[clu].position().x(),mSvtBigHit->svtHit()[clu].position().y());
617  m_waf_no[layer]->Fill(mSvtBigHit->svtHit()[clu].position().z(),ladder,1);
618  }
619  }
620  }
621  }
622  }
623  }
624  return kStOK;
625 }
626 //_____________________________________________________________________________
627 
628 
629  void StSvtHitMaker::SaveIntoNtuple(int numOfClusters, int index)
630 {
631 
632  for( int i=0; i<numOfClusters; i++){
633  if( mSvtBigHit->svtHit()[i].flag() < 255)
634  m_ClusTuple->Fill(mSvtBigHit->svtHit()[i].flag(),
635  mSvtBigHit->WaferPosition()[i].x(),
636  mSvtBigHit->WaferPosition()[i].y(),
637  mSvtBigHit->svtHit()[i].position().x(),
638  mSvtBigHit->svtHit()[i].position().y(),
639  mSvtBigHit->svtHit()[i].position().z(),
640  mSvtBigHit->svtHit()[i].charge(),
641  mSvtBigHit->svtHitData()[i].mom2[0],
642  mSvtBigHit->svtHitData()[i].mom2[1],
643  mSvtBigHit->svtHitData()[i].numOfAnodesInClu,
644  mSvtBigHit->svtHitData()[i].numOfPixelsInClu,
645  mSvtBigHit->svtHitData()[i].peakAdc,
646  index,
647  mSvtData->getEventNumber());
648  // if( iWrite > 1){
649 // cluInfo<<mSvtData->getEventNumber()
650 // <<setw(13)<< index
651 // <<setw(13)<< mSvtBigHit->svtHit()[i].flag()
652 // <<setw(13)<< mSvtBigHit->WaferPosition()[i].x()
653 // <<setw(13)<< mSvtBigHit->WaferPosition()[i].y()
654 // <<setw(13)<< mSvtBigHit->svtHit()[i].position().x()
655 // <<setw(13)<< mSvtBigHit->svtHit()[i].position().y()
656 // <<setw(13)<< mSvtBigHit->svtHit()[i].position().z()
657 // <<setw(13)<< mSvtBigHit->svtHit()[i].charge()
658 // <<setw(13)<< mSvtBigHit->svtHitData()[i].mom2[0]
659 // <<setw(13)<< mSvtBigHit->svtHitData()[i].mom2[1]
660 // <<setw(13)<< mSvtBigHit->svtHitData()[i].numOfAnodesInClu
661 // <<setw(13)<< mSvtBigHit->svtHitData()[i].numOfPixelsInClu
662 // <<setw(13)<< mSvtBigHit->svtHitData()[i].peakAdc<<endl;
663 // }
664  }
665 }
666 
667 //_____________________________________________________________________________
668 
669 Int_t StSvtHitMaker::Eval()
670 {
671  for(int barrel = 1;barrel <= mSvtData->getNumberOfBarrels();barrel++) {
672  for (int ladder = 1;ladder <= mSvtData->getNumberOfLadders(barrel);ladder++) {
673  for (int wafer = 1;wafer <= mSvtData->getNumberOfWafers(barrel);wafer++) {
674  for (int hybrid = 1;hybrid <=mSvtData->getNumberOfHybrids();hybrid++){
675 
676  int index = mSvtData->getHybridIndex(barrel,ladder,wafer,hybrid);
677  if(index < 0) continue;
678 
679  mSvtBigHit = (StSvtAnalysedHybridClusters*)mSvtCluColl->at(index);
680  if( !mSvtBigHit) continue;
681 
682  mSvtGeantHit = (StSvtGeantHits*)mSvtGeantHitColl->at(index);
683  if( !mSvtGeantHit) continue;
684 
685  for( int clu=0; clu<mSvtBigHit->numOfHits(); clu++){
686 
687  float tim = mSvtBigHit->WaferPosition()[clu].x();
688  float anod = mSvtBigHit->WaferPosition()[clu].y();
689 
690  float diffTime = 0,diffAnode = 0, diffX = 0, diffY = 0, diffZ = 0;
691 
692  for( int gHit = 0; gHit < mSvtGeantHit->numberOfHits(); gHit++){
693  if(gHit == 0)
694  {
695  diffTime = tim - mSvtGeantHit->waferCoordinate()[gHit].timebucket();
696  diffAnode = anod - mSvtGeantHit->waferCoordinate()[gHit].anode();
697  diffX = mSvtBigHit->svtHit()[clu].position().x() - mSvtGeantHit->globalCoordinate()[gHit].position().x();
698  diffY = mSvtBigHit->svtHit()[clu].position().y() - mSvtGeantHit->globalCoordinate()[gHit].position().y();
699  diffZ = mSvtBigHit->svtHit()[clu].position().z() - mSvtGeantHit->globalCoordinate()[gHit].position().z();
700  }
701  if ((fabs(tim - mSvtGeantHit->waferCoordinate()[gHit].timebucket()) < fabs(diffTime)) &&
702  (fabs(anod - mSvtGeantHit->waferCoordinate()[gHit].anode()) < fabs(diffAnode))) {
703  //Pick closest match
704  diffTime = tim - mSvtGeantHit->waferCoordinate()[gHit].timebucket();
705  diffAnode = anod - mSvtGeantHit->waferCoordinate()[gHit].anode();
706  diffX = mSvtBigHit->svtHit()[clu].position().x() - mSvtGeantHit->globalCoordinate()[gHit].position().x();
707  diffY = mSvtBigHit->svtHit()[clu].position().y() - mSvtGeantHit->globalCoordinate()[gHit].position().y();
708  diffZ = mSvtBigHit->svtHit()[clu].position().z() - mSvtGeantHit->globalCoordinate()[gHit].position().z();
709  }
710  }
711 
712  //cout << " diffZ= " << diffZ << endl;
713  mTimeHitResolution->Fill(diffTime);
714  mAnodeHitResolution->Fill(diffAnode);
715  mXHitResolution->Fill(diffX);
716  mYHitResolution->Fill(diffY);
717  mZHitResolution->Fill(diffZ);
718  mHitResolution->Fill(diffTime,diffAnode);
719  }
720  }
721  }
722  }
723  }
724 
725  return kStOK;
726 }
727 
728 //_____________________________________________________________________________
730 
731  if (Debug()) gMessMgr->Debug() << "In StSvtHitMaker::Finish() ..."
732  << GetName() << endm;
733 
734  if( iWrite == 1){
735  iWrite = 0;
736  m_hfile->Write();
737  m_hfile->Close();
738  delete m_hfile; m_hfile=0;
739  //cluInfo.close();
740  }
741  return kStOK;
742 }
743 
744 //________________________________________________________________________
745 void StSvtHitMaker::SetFileNames(const char* filen, const char* filec){
746  filenameN = filen;
747  filenameC = filec;
748 }
749 
750 //________________________________________________________________________
751 double StSvtHitMaker::LaserTemperatureCorrection() {
752  // This function returns a percentage change of the drift velocity
753  // obtained from the laser spot positions. It is actually a ratio of the
754  // average distance between the laser spots over the current distance (both in timebuckets).
755 
756 
757  double driftVelocityChange;
758  int barrel,ladder,wafer,hybrid;
759  double anode,tbin; //anode, timebucket position of a given hit
760 
761  int index; //index of laser spot 1/2 located at B3L15W7 (it is the same one for both of the spots)
762  double tbin1,tbin2; //timebucket positions of laser spot 1/2 located at B3L15W7
763 
764  driftVelocityChange=1.0;
765  barrel=3;
766  ladder=15;
767  wafer=7;
768  hybrid=1;
769 
770  index= mSvtData->getHybridIndex(barrel,ladder,wafer,hybrid);
771  mSvtBigHit = (StSvtAnalysedHybridClusters*)mSvtCluColl->at(index);
772  if(!mSvtBigHit) {
773  // cout << "No data on B3L15W7" << endl;
774  return driftVelocityChange;
775  }
776 
777  tbin1=-1;
778  tbin2=-1;
779  for( int clu=0; clu<mSvtBigHit->numOfHits(); clu++){
780  // we have to find laser spots:
781  // spot1: 195<anode<197, 123<tbin<125
782  // spot2: 198<anode<201, 95<tbin<98
783  // x: timebucket, y: anode
784  tbin=mSvtBigHit->WaferPosition()[clu].x();
785  anode=mSvtBigHit->WaferPosition()[clu].y();
786  if((tbin>123)&&(tbin<125)&&(anode>195)&&( anode<197)) tbin1=tbin;
787  if((tbin>95)&&(tbin<98)&&(anode>198)&&(anode<201)) tbin2=tbin;
788  }
789 
790  if((tbin1>0)&&(tbin2>0)&&(tbin1!=tbin2)) driftVelocityChange=27.03/(tbin1-tbin2);
791  else {
792  // Print out in the case laser spot(s) was(were) not found.
793  // Spot which was not found has tbin=-1.
794  cout << "Missing laser spot(s):" << endl;
795  cout << "spot 1 status " << tbin1 << endl;
796  cout << "spot 2 status " << tbin2 << endl;
797  return driftVelocityChange;
798  }
799 
800  return driftVelocityChange;
801 }
virtual Int_t Make()
virtual Int_t Finish()
TNtuple * m_ClusTuple
ladder no vs z of Si hit
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TDataSet.cxx:428
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
Definition: Stypes.h:42
Definition: Stypes.h:40
int mNwaf_no
x vs y of Si points
TH2F ** m_waf_no
size of following array
Definition: Stypes.h:41