StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFttFastSimMaker.cxx
1 
2 #include "StFttFastSimMaker.h"
3 
4 #include "StEvent/StEvent.h"
5 #include "St_base/StMessMgr.h"
6 
7 #include "StThreeVectorF.hh"
8 
9 #include "tables/St_g2t_fts_hit_Table.h"
10 #include "StEvent/StFttCollection.h"
11 #include "StEvent/StFttPoint.h"
12 
13 #include "StarGenerator/UTIL/StarRandom.h"
14 
15 
16 StFttFastSimMaker::StFttFastSimMaker(const Char_t *name)
17  : StMaker{name} {}
18 
19 int StFttFastSimMaker::Init() {
20  return StMaker::Init();
21 }
22 
24  LOG_DEBUG << "StFttFastSimMaker::Make" << endm;
25 
26  // Get the existing StEvent, or add one if it doesn't exist.
27  StEvent *event = static_cast<StEvent *>(GetDataSet("StEvent"));
28  if (!event) {
29  event = new StEvent;
30  AddData(event);
31  LOG_DEBUG << "Creating StEvent" << endm;
32  }
33 
34  if ( event->fttCollection() == nullptr ){
35  LOG_INFO << "Creating FttCollection" << endm;
36  StFttCollection *fttcollection = new StFttCollection();
37  event->setFttCollection(fttcollection);
38  }
39 
40  St_g2t_fts_hit *g2t_stg_hits = (St_g2t_fts_hit *)GetDataSet("geant/g2t_stg_hit");
41  // size_t numFwdHitsPrior = mFwdHitsFtt.size();
42  if (!g2t_stg_hits){
43  LOG_WARN << "geant/g2t_stg_hit is empty" << endm;
44  return kStOk;
45  }
46 
47  const double sigXY = 0.01;
48  int nstg = g2t_stg_hits->GetNRows();
49  LOG_DEBUG << "This event has " << nstg << " stg hits in geant/g2t_stg_hit " << endm;
50  for (int i = 0; i < nstg; i++) {
51  g2t_fts_hit_st *git = (g2t_fts_hit_st *)g2t_stg_hits->At(i);
52  if (0 == git)
53  continue; // geant hit
54  int track_id = git->track_p;
55  int volume_id = git->volume_id;
56  int plane_id = (volume_id - 1) / 100; // from 1 - 16. four chambers per station
57 
58  // only use the hits on the front modules
59  if ( volume_id % 2 ==0 )
60  continue;
61 
62  float x = git->x[0] + gRandom->Gaus(0, sigXY); // 100 micron blur according to approx sTGC reso
63  float y = git->x[1] + gRandom->Gaus(0, sigXY); // 100 micron blur according to approx sTGC reso
64  float z = git->x[2];
65 
66  StFttPoint *point = new StFttPoint();
67  point->setPlane(plane_id);
68  point->setQuadrant(0); // TODO this could be improved, but it is not used in the current implementation
69  StThreeVectorD xyz;
70  xyz.set(x, y, z);
71  point->setXYZ( xyz );
72  point->setIdTruth( track_id );
73  event->fttCollection()->addPoint(point);
74  } // loop on hits
75  return kStOk;
76 }
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
Definition: Stypes.h:41