StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St_sfs_Maker.cxx
1 /* $Id: St_sfs_Maker.cxx,v 1.1 2009/11/10 21:14:18 fisyak Exp $
2  $Log: St_sfs_Maker.cxx,v $
3  Revision 1.1 2009/11/10 21:14:18 fisyak
4  pams clean up
5 
6 */
7 #include "Stiostream.h"
8 #include "St_sfs_Maker.h"
9 #include "StHit.h"
10 #include "StEventTypes.h"
11 #include "tables/St_HitError_Table.h"
12 #include "StSvtHitCollection.h"
13 #include "StEvent.h"
14 #include "TMath.h"
15 #include "TRandom.h"
16 #include "StSvtDbMaker/StSvtDbMaker.h"
17 #include "tables/St_g2t_svt_hit_Table.h"
18 #include "TGeoMatrix.h"
19 ClassImp(St_sfs_Maker);
20 //____________________________________________________________
21 Int_t St_sfs_Maker::InitRun(Int_t RunNo)
22 {
23  // Define various SVT hit errors from database
24  St_HitError *tableSet = (St_HitError *) GetDataBase("Calibrations/tracker/svtHitError");
25  HitError_st* hitError = tableSet->GetTable();
26  mResXSvt = TMath::Sqrt(hitError->coeff[0]);
27  mResZSvt = TMath::Sqrt(hitError->coeff[3]);
28  LOG_DEBUG << "Smearing SVT hits by " << mResXSvt << " " << mResZSvt << " cm in the SVT " << endm;
29  return kStOk;
30 }
31 //____________________________________________________________
33 {
34  if (! gRandom) gRandom = new TRandom();
35  // Get the input data structures from StEvent
36  StEvent *rEvent = (StEvent*) GetInputDS("StEvent");
37  if (! rEvent) { LOG_WARN << "No StEvent on input, bye bye" << endm; return kStWarn; }
38  StSvtHitCollection *rCol = rEvent->svtHitCollection();
39  if (!rCol) {
40  rCol = new StSvtHitCollection;
41  rEvent->setSvtHitCollection(rCol);
42  }
43  TDataSetIter geant(GetInputDS("geant"));
44  St_g2t_svt_hit *g2t_svt_hit = (St_g2t_svt_hit *) geant("g2t_svt_hit");
45  if (! g2t_svt_hit) {
46  LOG_WARN << "No g2t_svt_hit on input, bye bye" << endm; return kStWarn;
47  return kStWarn;
48  }
49  g2t_svt_hit_st *g2t = g2t_svt_hit->GetTable();
50  Int_t Nhits = g2t_svt_hit->GetNRows();
51  if (Nhits <= 0) return kStWarn;
52  THashList *rotMHash = gStSvtDbMaker->GetRotations();
53  if (! rotMHash) {LOG_WARN << " No list of Rotation from StSvtDbMaker " << endm; return kStWarn;}
54 
55  for (Int_t i = 0; i < Nhits; i++) {
56  TGeoHMatrix *comb = (TGeoHMatrix *) rotMHash->FindObject(Form("R%04i",g2t[i].volume_id%10000));
57  if (! comb) { LOG_WARN << "No rotation matrix for wafer =" << g2t[i].volume_id << endm; continue;}
58  Double_t xyzG[3] = {g2t[i].x[0],g2t[i].x[1],g2t[i].x[2]};
59  Double_t xyzL[3];
60  comb->MasterToLocal(xyzG,xyzL);
61  if (Debug() && TMath::Abs(xyzL[2]) > 0.0100) {
62  cout << "Id: " << g2t[i].volume_id
63  << "\txyzL :" << xyzL[0] << "\t" << xyzL[1] << "\t" << xyzL[2] << endl;
64  comb->Print();
65  }
66  xyzL[0] += gRandom->Gaus(0, mResXSvt);
67  xyzL[1] += gRandom->Gaus(0, mResZSvt);
68  comb->LocalToMaster(xyzL,xyzG);
69  // Id = 1000*layer + 100*wafer + ladder;
70  Int_t ladderID = g2t[i].volume_id%100;
71  Int_t waferID = (g2t[i].volume_id/100)%10;
72  Int_t layerID = (g2t[i].volume_id%10000)/1000;
73  Int_t barrelID = (layerID-1)/2 + 1;
74  Int_t hybridID = 1;
75  if (xyzL[0] >= 0) hybridID = 2;
76  static const Int_t NumberOfHybrids = 2;
77  static const Int_t NumberOfWafers[3] = {4, 6, 7}; // Number of wafers per ladder
78  static const Int_t NumberOfLadders[3] = {8,12,16}; // Number of ladders per barrel
79  Int_t index = ((ladderID-1)*NumberOfWafers[barrelID-1] + (waferID-1))*NumberOfHybrids + (hybridID-1);
80  switch (barrelID) {
81  case 3: index += NumberOfLadders[barrelID-3]*NumberOfWafers[barrelID-3]*NumberOfHybrids;
82  case 2: index += NumberOfLadders[barrelID-2]*NumberOfWafers[barrelID-2]*NumberOfHybrids;
83  case 1: break;
84  default:
85  LOG_ERROR << "There is NO barrel number " << barrelID << " !!!" << endm;
86  // gMessMgr->Print();
87  index = -1;
88  break;
89  }
90  assert(index != -1);
91  Int_t hw = 2;
92  hw += (1L<<4)*(index);
93  StSvtHit *svtHit = new StSvtHit();
94  svtHit->setHardwarePosition(hw);
95  svtHit->setLocalPosition(xyzL[0],xyzL[1]);
96  svtHit->setCharge(g2t[i].de);
97  svtHit->setIdTruth(g2t[i].track_p,100);
98  svtHit->setFlag(0);
99  svtHit->setFitFlag(0);
100  StThreeVectorF pos(xyzG[0],xyzG[1],xyzG[2]);
101  svtHit->setPosition(pos);
102  rCol->addHit(svtHit);
103  }
104  return kStOK;
105 }
virtual Int_t Make()
Definition: Stypes.h:42
Definition: Stypes.h:40
Definition: Stypes.h:41