FairRoot/PandaRoot
PndLmdPixelHitProducerFast.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndLmdPixelHitProducerFast source file -----
3 // -------------------------------------------------------------------------
4 
5 
6 #include "TClonesArray.h"
7 #include "TMath.h"
8 
9 #include "FairRootManager.h"
11 #include "PndSdsHit.h"
12 #include "PndSdsMCPoint.h"
13 #include "FairRun.h"
14 #include "FairRuntimeDb.h"
15 
16 
17 // ----- Default constructor -------------------------------------------
19 PndSdsTask("Fast LMD Hit Producer")
20 {
21  fPixelSizeX=0.005; //to round MC-Hit x-position
22  fPixelSizeY=0.005; //to round MC-Hit y-position
23  SetPersistency(kTRUE);
24 }
25 
27 PndSdsTask("Fast LMD Hit Producer"), fPixelSizeX(pixelx), fPixelSizeY(pixely)
28 {
29  SetPersistency(kTRUE);
30 }
31 // -------------------------------------------------------------------------
32 
33 // ----- Named constructor -------------------------------------------
35 PndSdsTask(name)
36 {
37  fPixelSizeX=0.005; //to round MC-Hit x-position
38  fPixelSizeY=0.005; //to round MC-Hit y-position
39  SetPersistency(kTRUE);
40 }
41 // -------------------------------------------------------------------------
42 
43 
44 
45 // ----- Destructor ----------------------------------------------------
47 {
48 }
49 
50 // ----- Public method Init --------------------------------------------
52 {
53  // Get RootManager
54  FairRootManager* ioman = FairRootManager::Instance();
55 
57 
58  if ( ! ioman )
59  {
60  std::cout << "-E- PndLmdPixelHitProducerFast::Init: "
61  << "RootManager not instantiated!" << std::endl;
62  return kFATAL;
63  }
64 
65  // Get input array
66  fPointArray = (TClonesArray*) ioman->GetObject(fInBranchName);
67 
68  if ( ! fPointArray )
69  {
70  std::cout << "-W- PndLmdPixelHitProducerFast::Init: "
71  << "No SDSPoint array!" << std::endl;
72  return kERROR;
73  }
74 
75 
76  // Create and register output array
77  fHitArray = new TClonesArray("PndSdsHit");
78  ioman->Register(fOutBranchName, fFolderName, fHitArray, GetPersistency());
79 
80  std::cout << "-I- PndLmdPixelHitProducerFast: Intialisation successfull" << std::endl;
81  return kSUCCESS;
82 }
83 // -------------------------------------------------------------------------
85 {
86  // Get Base Container
87  //FairRun* ana = FairRun::Instance();
88  //FairRuntimeDb* rtdb=ana->GetRuntimeDb();
89  // fGeoPar = (PndSdsGeoPar*)(rtdb->getContainer("PndSdsGeoPar"));
90 
91 }
92 
93 void PndLmdPixelHitProducerFast::SetBranchNames(TString inBranchname, TString outBranchname, TString folderName)
94 {
95  fInBranchName = inBranchname;
96  fOutBranchName = outBranchname;
97  fFolderName = folderName;
98 }
99 
100 
102 {
103  fInBranchName = "LMDPoint";
104  fOutBranchName = "LMDHit";
105  fFolderName = "PndLmd";
106 }
107 
108 
109 // ----- Public method Exec --------------------------------------------
111 {
112  // Reset output array
113  if ( ! fHitArray )
114  Fatal("Exec", "No HitArray");
115 
116  fHitArray->Delete();
117 
118  // Declare some variables
119  PndSdsMCPoint *point = 0;
120 
121  Int_t
122  detID = 0; // Detector ID
123  //trackID = 0; // Track index //[R.K.03/2017] unused variable
124 
125  TVector3
126  pos, dpos; // Position and error vectors
127 
128  // Loop over PndSdsMCPoints
129  Int_t
130  nPoints = fPointArray->GetEntriesFast();
131 
132  for (Int_t iPoint = 0; iPoint < nPoints; iPoint++)
133  {
134  point = (PndSdsMCPoint*) fPointArray->At(iPoint);
135  //std::cout << " Fast Hit Producer -Point-: " << point << std::endl;
136  if ( ! point)
137  continue;
138 
139  // Detector ID
140  detID = point->GetDetectorID();
141 
142  // MCTrack ID
143  //trackID = point->GetTrackID(); //[R.K.03/2017] unused variable
144 
145  TVector3
146  position(fPixelSizeX*TMath::Nint(point->GetX()/fPixelSizeX), fPixelSizeY*TMath::Nint(point->GetY()/fPixelSizeY), point->GetZ());
147  dpos.SetXYZ(0.005,0.005,0.005);
148 
149 
150  // Create new hit
151  PndSdsHit* myHit = new ((*fHitArray)[iPoint]) PndSdsHit(detID, point->GetSensorID(), position, dpos, -1, point->GetEnergyLoss(),1, iPoint);
152  myHit->SetClusterIndex(fInBranchId, iPoint);
153  // std::cout << "Hit created for module: " << point->GetDetName() << std::endl;
154 
155 
156 
157  } // Loop over MCPoints
158 
159  // Event summary
160  //std::cout << "-I- PndLmdPixelHitProducerFast: " << nPoints << " PndSdsMCPoints, "
161  // << nPoints << " Hits created." << std::endl;
162 
163 }
164 // -------------------------------------------------------------------------
165 
166 
TVector3 pos
Int_t fInBranchId
Definition: PndSdsTask.h:43
TString fOutBranchName
Definition: PndSdsTask.h:40
void SetClusterIndex(Int_t datasource, Int_t id, Int_t fileId=-1, Int_t evtId=-1)
Definition: PndSdsHit.h:82
void SetPersistency(Bool_t val=kTRUE)
Int_t GetSensorID() const
Definition: PndSdsMCPoint.h:89
Double_t
virtual void Exec(Option_t *opt)
TString fInBranchName
Definition: PndSdsTask.h:39
TClonesArray * point
Definition: anaLmdDigi.C:29
TString fFolderName
Definition: PndSdsTask.h:41
TString name
ClassImp(PndAnaContFact)
int Nint(float x)
Definition: PndCAMath.h:117