FairRoot/PandaRoot
PndSdsRecoTask.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndSdsRecoTask source file -----
3 // ----- Created 20/03/07 by R.Kliemt -----
4 // -------------------------------------------------------------------------
5 // libc includes
6 #include <iostream>
7 #include <vector>
8 
9 // Root includes
10 #include "TROOT.h"
11 #include "TClonesArray.h"
12 #include "TParticlePDG.h"
13 #include "TRandom.h"
14 #include "TGeoManager.h"
15 #include "TGeoMatrix.h"
16 
17 // framework includes
18 #include "FairRootManager.h"
19 #include "PndSdsRecoTask.h"
20 #include "FairRun.h"
21 #include "FairRuntimeDb.h"
22 #include "../pnddata/PndMCTrack.h"
23 #include "FairHit.h"
24 // PndSds includes
25 #include "PndSdsMCPoint.h"
26 #include "PndSdsDigiPixel.h"
27 #include "PndSdsDigiStrip.h"
28 #include "PndSdsHit.h"
29 
30 // #include "PndSdsHitMaker.h"
31 // #include "PndSdsHitMakerFactory.h"
32 // #include "PndSdsDetectorDescr.h"
33 
34 
35 // ----- Default constructor -------------------------------------------
37  fHitCovMatrix(3,3),
38  PndSdsTask("Reconstruction task for PANDA PndSds")
39 {
40 /* fSigmaX=0.;
41  fSigmaY=0.;
42  fSigmaZ=0.;*/
43 }
44 // -------------------------------------------------------------------------
45 /*
46 // ----- Constructor ---------------------------------------------------
47 PndSdsRecoTask::PndSdsRecoTask(Double_t sx, Double_t sy, Double_t sz) :
48  fHitCovMatrix(3,3),
49  SdsTask("Ideal reconstruction task for PANDA PndSds")
50 {
51  fSigmaX=sx;
52  fSigmaY=sy;
53  fSigmaZ=sz;
54 }
55 // -------------------------------------------------------------------------
56 
57 */
58 // ----- Constructor ---------------------------------------------------
59 PndSdsRecoTask::PndSdsRecoTask(std::string type) :
60  PndSdsTask("Reconstruction task for PANDA PndSds")
61 {
62  fMakerType = type;
63  if(fVerbose>0)
64  std::cout<<type<<" Reconstruction task for PANDA PndSds"<<std::endl;
65 }
66 // -------------------------------------------------------------------------
67 
68 
69 
70 // ----- Destructor ----------------------------------------------------
72 {
73 }
74 
75 // ----- Public method Init --------------------------------------------
77 {
79  SetInBranchId();
80 
81  if(fVerbose>1)
82  std::cout<<"PndSdsRecoTask::Init() called."<<std::endl;
83 
84  // Get RootManager
85  FairRootManager* ioman = FairRootManager::Instance();
86  if ( ! ioman ) {
87  std::cout << "-E- PndSdsRecoTask::Init: "
88  << "RootManager not instantiated!" << std::endl;
89  return kFATAL; }
90 
91 
92  // Get MCTruth collection
93 // fMctruthArray=(TClonesArray*) ioman->GetObject("MCTrack");
94 // if(fMctruthArray==0) {
95 // std::cout << "-W- PndSdsRecoTask::Init: No McTruth array!" << std::endl;
96 // return kERROR; }
97 
98 
99  // Get input array
100  fDigiPixelArray=(TClonesArray*) ioman->GetObject(fPixelBranchName);
101  if(fDigiPixelArray==0) {
102  std::cout << "-W- PndSdsRecoTask::Init: No fDigiPixelArray!" << std::endl;
103  return kERROR; }
104 
105  // Get input array
106  fDigiStripArray=(TClonesArray*) ioman->GetObject(fStripBranchName);
107  if(fDigiStripArray==0) {
108  std::cout << "-W- PndSdsRecoTask::Init: No fDigiStripArray!" << std::endl;
109  return kERROR; }
110 
111  // Create and register output array
112  fHitOutputArray = new TClonesArray("PndSdsHit");
113  ioman->Register(fOutBranchName, fFolderName, fHitOutputArray, kTRUE);
114 
115 /*
116  PndSdsDetectorDescr(
117  Double_t pixelCellX, Double_t pixelCellXLong, Double_t pixelCellY,
118  Double_t stripX, Double_t stripY, Double_t feY, Double_t feX,
119  Double_t rpStripPitch, Double_t zstripPitch,
120  unsigned int numOfRows, unsigned int numOfColumns,
121  unsigned int numNormalColumns, Double_t rowOffsetEdge,
122  unsigned int zFE, unsigned int rphiFE, unsigned int channelsFE);
123 */
124  // TODO remove hardcoded numbers & improve detector description class
125  Double_t pixelCellX = 0.01;
126  Double_t pixelCellXLong = 0.03;
127  Double_t pixelCellY = 0.01;
128  Double_t stripX = 0.004921;//pitch in sensor coordinates
129  Double_t stripY = 0.0042969;//
130  Double_t feY = 0.82;
131  Double_t feX = 0.76;
132  Double_t rpStripPitch = 0.;//0.00859375;
133  Double_t zstripPitch = 0.;//0.00984375;
134  unsigned int numOfRows = 0;
135  unsigned int numOfColumns = 0;
136  unsigned int numNormalColumns = 0;
137  Double_t rowOffsetEdge = 0.;
138  unsigned int zFE = 0;
139  unsigned int rphiFE = 0;
140  unsigned int channelsFE = 128;
141  if(fVerbose>=1)
142  std::cout<<"PndSdsRecoTask::Init(): Making PndSdsDetectorDescr "<<std::endl;
143 
144 // PndSdsDetectorDescr* detDescr = new PndSdsDetectorDescr(pixelCellX,pixelCellXLong,
145 // pixelCellY,stripX,stripY,feY,feX,rpStripPitch,zstripPitch,numOfRows,
146 // numOfColumns,numNormalColumns,rowOffsetEdge,zFE,rphiFE,channelsFE);
147 // fHitMaker = PndSdsHitMakerFactory::theFactory().maker(fMakerType,detDescr);
148 
149 // if (fHitMaker == 0) return kERROR;
150 
151  fevent=0;
152 
153  if(fVerbose>1)
154  std::cout<<"PndSdsRecoTask::Init() done."<<std::endl;
155  return kSUCCESS;
156 }
157 // -------------------------------------------------------------------------
159 {
160  // Get Base Container
161  FairRun* ana = FairRun::Instance();
162  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
163 
164 }
165 
166 
167 // ----- Public method Exec --------------------------------------------
168 void PndSdsRecoTask::Exec(Option_t*)
169 {
170  // Fills PndSdsHits with the MC Truth
171  // TODO filling of RecoHits, together with the sensor plane
172  fevent++;
173  if (fVerbose > 0) {
174  std::cout<<"PndSdsRecoTask::Exec() started event no. "<<fevent<<std::endl;
175  }
176  if ( ! fHitOutputArray ) Fatal("Exec", "No fHitOutputArray");
177  fHitOutputArray->Clear();
178 
179  if ( ! fDigiPixelArray ) Fatal("Exec", "No fDigiPixelArray");
180  if ( ! fDigiStripArray ) Fatal("Exec", "No fDigiStripArray");
181 
182  // preparing arrays
183  std::vector<PndSdsDigiPixel*> mvdPixelDigis;
184  std::vector<PndSdsDigiStrip*> mvdStripDigis;
185  std::vector<PndSdsHit*> mvdHits;
186 
187  //converting TClonesarrays of Digis to std::vector
188  PndSdsDigiPixel* aDigiPixel = 0;
189  for (Int_t k = 0; k < fDigiPixelArray->GetEntriesFast(); k++)
190  {
191  aDigiPixel = (PndSdsDigiPixel*)fDigiPixelArray->At(k);
192  if (aDigiPixel != 0) {
193  mvdPixelDigis.push_back(aDigiPixel);
194  }
195  }
196  PndSdsDigiStrip* aDigiStrip = 0;
197  for (Int_t h = 0; h < fDigiStripArray->GetEntriesFast(); h++)
198  {
199  aDigiStrip = (PndSdsDigiStrip*)fDigiStripArray->At(h);
200  if (aDigiStrip != 0) {
201  mvdStripDigis.push_back(aDigiStrip);
202  }
203  }
204  if (fVerbose > 2) {
205  std::cout<<" mvdStripDigis[0] = "<<mvdStripDigis[0]<<std::endl;
206  std::cout<<"PndSdsRecoTask::Exec() conversion done, start hitmaking."<<std::endl;
207  }
208 
209  // ---
210 // bool success = fHitMaker->makeHits(mvdPixelDigis,mvdStripDigis,mvdHits);
211  // ---
212 
213 /* if (!success){
214  std::cerr << "making PndSds hits was not successfull" << std::endl;
215  }*/
216  if (fVerbose > 2) {
217  std::cout<<"PndSdsRecoTask::Exec() hitmaking done, reconvert now."<<std::endl;
218  }
219 
220  //converting of std::vector Hits to TClonesarray
221 // Int_t size = fHitOutputArray->GetEntriesFast();
222 // Int_t s=0;
223 // for (std::vector<PndSdsHit*>::iterator it = mvdHits.begin();
224 // it != mvdHits.end(); it++)
225 // { // size++ returns size and increases it then; ++size gives the increased one
226 // s++;
227 // if (*it==0){
228 // std::cout<<"PndSdsRecoTask::Exec(): mvdHits["<<s
229 // <<"] does not exist!"<<std::endl;
230 // continue;
231 // }
232 // new ((*fHitOutputArray)[size++]) PndSdsHit(**it);
233 // delete *it;
234 // }
235 //
236 // if (fVerbose > 0) {
237 // std::cout<<fHitOutputArray->GetEntriesFast() <<" Hits created out of "
238 // <<fDigiPixelArray->GetEntriesFast() <<" Pixel Digis and "
239 // <<fDigiStripArray->GetEntriesFast() <<" Strip Digis."<<std::endl;
240 // }
241 
242 }
243 
244 
245 
246 
247 
248 // -------------------------------------------------------------------------
250 {
251  gGeoManager->cd(fCurrentPndSdsMCPoint->GetDetName());
252  fCurrentTransMat = gGeoManager->GetCurrentMatrix();
253  if (fVerbose > 1) {
254  fCurrentTransMat->Print("");
255  }
256 }
257 
258 void PndSdsRecoTask::CalcDetPlane(TVector3& oVect, TVector3& uVect,TVector3& vVect)
259 {
260  Double_t O[3], U[3], V[3], o[3], u[3], v[3];
261  O[0]=oVect.x(); O[1]=oVect.y(); O[2]=oVect.z();
262  U[0]=uVect.x(); U[1]=uVect.y(); U[2]=uVect.z();
263  V[0]=vVect.x(); V[1]=vVect.y(); V[2]=vVect.z();
264 
265  if (fVerbose > 1) {
266  std::cout<<"PndSdsRecoTask::CalcDetPlane from Detector "
267  <<fCurrentPndSdsMCPoint->GetDetName()<<std::endl;
268  }
269  //make transformation
270  fCurrentTransMat->LocalToMaster(O,o);
271  fCurrentTransMat->LocalToMaster(U,u);
272  fCurrentTransMat->LocalToMaster(V,v);
273  oVect.SetXYZ(o[0],o[1],o[2]);
274  uVect.SetXYZ(u[0],u[1],u[2]);
275  vVect.SetXYZ(v[0],v[1],v[2]);
276 }
277 
278 
int fVerbose
Definition: poormantracks.C:24
TString fStripBranchName
virtual ~PndSdsRecoTask()
TString fOutBranchName
Definition: PndSdsTask.h:40
Class for digitised strip hits.
TString fPixelBranchName
TClonesArray * fHitOutputArray
TClonesArray * fDigiStripArray
TGeoManager * gGeoManager
__m128 v
Definition: P4_F32vec4.h:4
virtual InitStatus Init()
Double_t
void CalcDetPlane(TVector3 &o, TVector3 &u, TVector3 &v)
virtual void SetBranchNames()=0
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
TString fFolderName
Definition: PndSdsTask.h:41
ClassImp(PndAnaContFact)
TClonesArray * fDigiPixelArray
virtual void SetParContainers()
Data class to store the digi output of a pixel module.
virtual void Exec(Option_t *opt)
TGeoHMatrix * fCurrentTransMat
std::string fMakerType
PndSdsMCPoint * fCurrentPndSdsMCPoint
virtual void SetInBranchId()
Definition: PndSdsTask.h:30