FairRoot/PandaRoot
PndSdsHitProducerIdeal.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndSdsHitProducerIdeal source file -----
3 // -------------------------------------------------------------------------
4 
5 
6 #include "TClonesArray.h"
7 
8 #include "FairRootManager.h"
10 #include "PndSdsHit.h"
11 #include "PndSdsMCPoint.h"
12 #include "FairRun.h"
13 #include "FairRuntimeDb.h"
14 
15 
16 // ----- Default constructor -------------------------------------------
18 PndSdsTask("Ideal SDS Hit Producer"),
19 fPointArray(NULL),
20 fHitArray(NULL)
21 {
22  SetPersistency(kTRUE);
23 }
24 // -------------------------------------------------------------------------
25 
26 // ----- Named constructor -------------------------------------------
28 PndSdsTask(name),
29 fPointArray(),
30 fHitArray()
31 {
32  SetPersistency(kTRUE);
33 }
34 // -------------------------------------------------------------------------
35 
36 
37 
38 // ----- Destructor ----------------------------------------------------
40 {
41 }
42 
43 // ----- Public method Init --------------------------------------------
45 {
46  // Get RootManager
47  FairRootManager* ioman = FairRootManager::Instance();
48 
50 
51  if ( ! ioman )
52  {
53  std::cout << "-E- PndSdsHitProducerIdeal::Init: "
54  << "RootManager not instantiated!" << std::endl;
55  return kFATAL;
56  }
57 
58  // Get input array
59  fPointArray = (TClonesArray*) ioman->GetObject(fInBranchName);
60 
61  if ( ! fPointArray )
62  {
63  std::cout << "-W- PndSdsHitProducerIdeal::Init: "
64  << "No SDSPoint array!" << std::endl;
65  return kERROR;
66  }
67 
68 
69  // Create and register output array
70  fHitArray = new TClonesArray("PndSdsHit");
71  ioman->Register(fOutBranchName, fFolderName, fHitArray, GetPersistency());
72 
73  std::cout << "-I- PndSdsHitProducerIdeal: Intialisation successfull" << std::endl;
74  return kSUCCESS;
75 }
76 // -------------------------------------------------------------------------
78 {
79  // Get Base Container
80  //FairRun* ana = FairRun::Instance();
81  //FairRuntimeDb* rtdb=ana->GetRuntimeDb();
82  // fGeoPar = (PndSdsGeoPar*)(rtdb->getContainer("PndSdsGeoPar"));
83 
84 }
85 
86 
87 // ----- Public method Exec --------------------------------------------
89 {
90  // Reset output array
91  if ( ! fHitArray )
92  Fatal("Exec", "No HitArray");
93 
94  fHitArray->Delete();
95 
96  // Declare some variables
97  PndSdsMCPoint *point = 0;
98 
99  Int_t
100  detID = 0; // Detector ID
101  //trackID = 0; // Track index //[R.K. 01/2017] unused variable
102 
103  TVector3
104  pos, dpos; // Position and error vectors
105 
106  // Loop over PndSdsMCPoints
107  Int_t
108  nPoints = fPointArray->GetEntriesFast();
109 
110  for (Int_t iPoint = 0; iPoint < nPoints; iPoint++)
111  {
112  point = (PndSdsMCPoint*) fPointArray->At(iPoint);
113 // std::cout << " Ideal Hit Producer -Point-: " << point << std::endl;
114  if ( ! point)
115  continue;
116 
117  // Detector ID
118  detID = point->GetDetectorID();
119 
120  // MCTrack ID
121  //trackID = point->GetTrackID(); //[R.K. 01/2017] unused variable
122 
123  TVector3
124  position(point->GetX(), point->GetY(), point->GetZ());
125  dpos.SetXYZ(0.005,0.005,0.005);
126 
127 
128  // Create new hit
129  PndSdsHit* myHit = new ((*fHitArray)[iPoint]) PndSdsHit(detID, point->GetSensorID(), position, dpos, -1, point->GetEnergyLoss(),1, iPoint);
130  myHit->SetClusterIndex(fInBranchId, iPoint);
131  // std::cout << "Hit created for module: " << point->GetDetName() << std::endl;
132 
133 
134 
135  } // Loop over MCPoints
136 
137  // Event summary
138 // std::cout << "-I- PndSdsHitProducerIdeal: " << nPoints << " PndSdsMCPoints, "
139  // << nPoints << " Hits created." << std::endl;
140 
141 }
142 // -------------------------------------------------------------------------
143 
144 
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
TString fInBranchName
Definition: PndSdsTask.h:39
TString fFolderName
Definition: PndSdsTask.h:41
TString name
virtual void SetBranchNames()=0
ClassImp(PndAnaContFact)
virtual void Exec(Option_t *opt)
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72