StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEtrFastSimMaker.cxx
1 /* $Id: StEtrFastSimMaker.cxx,v 1.3 2012/07/21 18:43:53 perev Exp $
2  $Log: StEtrFastSimMaker.cxx,v $
3  Revision 1.3 2012/07/21 18:43:53 perev
4  IdTruth added
5 
6  Revision 1.2 2012/04/10 22:38:18 perev
7  Errors increased to 300 microns
8 
9  Revision 1.1 2012/03/22 01:19:12 perev
10  *** empty log message ***
11 
12 
13 */
14 #include "Stiostream.h"
15 #include "StEtrFastSimMaker.h"
16 #include "StEtrHit.h"
17 #include "StEventTypes.h"
18 #include "StEtrHitCollection.h"
19 #include "StEvent.h"
20 #include "TMath.h"
21 #include "TRandom.h"
22 #include "tables/St_g2t_etr_hit_Table.h"
23 #include "StEventHitIter.h"
24 #include "StuDraw3DEvent.h"
25 static TRandom *myRandom = 0;
26 
27 ClassImp(StEtrFastSimMaker);
28 //____________________________________________________________
29 StEtrFastSimMaker::StEtrFastSimMaker(const char *name):StMaker(name)
30 {
31  myRandom = new TRandom();
32  mErr[0] = 3e-2; mErr[1] = 3e-2; mErr[2] = 0;
33 }
34 
35 
36 //____________________________________________________________
37 int StEtrFastSimMaker::InitRun(int RunNo)
38 {
39  // Define various SVT hit errors from database
40  LOG_DEBUG << "Smearing SVT hits by " << mErr[0] << " " << mErr[2] << " cm in the ETR " << endm;
41  return kStOk;
42 }
43 //____________________________________________________________
45 {
46  // Get the input data structures from StEvent
47  StEvent *stEvent = (StEvent*) GetInputDS("StEvent");
48  if (! stEvent) { LOG_WARN << "No StEvent on input, bye bye" << endm; return kStWarn; }
49  StEtrHitCollection *etrCol = stEvent->etrHitCollection();
50  if (!etrCol) {
51  etrCol = new StEtrHitCollection;
52  stEvent->setEtrHitCollection(etrCol);
53  }
54  TDataSetIter geant(GetInputDS("geant"));
55  St_g2t_etr_hit *g2t_etr_hit = (St_g2t_etr_hit *) geant("g2t_etr_hit");
56  if (! g2t_etr_hit) {
57  LOG_WARN << "No g2t_etr_hit on input, bye bye" << endm; return kStWarn;
58  return kStWarn;
59  }
60  g2t_etr_hit_st *g2t = g2t_etr_hit->GetTable();
61  int Nhits = g2t_etr_hit->GetNRows();
62  if (Nhits <= 0) return kStWarn;
63  for (int i = 0; i < Nhits; i++) {
64  double xyzG[3];
65  g2t_etr_hit_st *tb = g2t+i;
66  for (int j=0;j<3;j++) {xyzG[j] = tb->x[j];}
67 // Smearing only x,y, not Z
68  for (int j=0;j<2;j++) {xyzG[j]+= gRandom->Gaus(0, mErr[j]);}
69 
70 // volume_id = section + 100*layer + 10000*sector
71  int section =(tb->volume_id )%100;
72  int layer = (tb->volume_id/100 )%100; // 3 disk in TRD, iLayer=0, 1, 2
73  int sector = (tb->volume_id/10000)%100; // 12 sector in TRD layer, 0 - 11
74 
75  StEtrHit *etrHit = new StEtrHit(StThreeVectorF(xyzG),sector,layer,section,tb->de);
76  etrHit->setIdTruth(tb->track_p,100);
77  etrCol->addHit(etrHit);
78  }
79  Info("Make","%d EtrHits was pushed into StEvent",Nhits);
80 
81 static int etrDraw = 0;
82  if (etrDraw) {
83 static StuDraw3DEvent *stu=0;
84  if (!stu) stu = new StuDraw3DEvent;
85  stu->Clear();
86  StEventHitIter iter(stEvent);
87  iter.AddDetector(kEtrId);
88  stu->Hits(iter);
89  stu->Wait();
90  }
91 
92  return kStOK;
93 }
StEventHitIter is the top level hook, providing hits to the Stv tracking code.
Class StuDraw3DEvent - to draw the 3D StEvent primitives like StTrack, StHit, StVertex decorated with...
Definition: Stypes.h:42
Definition: Stypes.h:40
virtual void Clear(Option_t *opt="update")
Remove all objects from the list and update the screen if opt is &quot;update&quot;.
Definition: StDraw3D.cxx:398
Definition: Stypes.h:41