FairRoot/PandaRoot
PndMvdDigiPixelDraw.cxx
Go to the documentation of this file.
1 /*
2  * PndMvdDigiPixelDraw.cpp
3  *
4  * Created on: Apr 20, 2009
5  * Author: stockman
6  */
7 
8 #include "PndMvdDigiPixelDraw.h"
9 
10 #include "PndSdsCalcFePixel.h"
11 #include "PndSdsPixelDigiPar.h"
12 #include "PndSdsHit.h"
13 #include "PndSdsCluster.h"
14 
15 #include "FairRootManager.h"
16 
17 #include "TGeoMatrix.h"
18 #include "TClonesArray.h"
19 #include "TEveTrans.h"
20 #include "TEveManager.h"
21 #include "TEveBoxSet.h"
22 
23 PndMvdDigiPixelDraw::PndMvdDigiPixelDraw() : fPixelSize(0.01), fBoxSize(1)
24 {}
25 
26 PndMvdDigiPixelDraw::PndMvdDigiPixelDraw(const char* name, Int_t iVerbose) : FairBoxSetDraw(name, iVerbose), fPixelSize(0.01), fBoxSize(1)
27 {}
28 
30 {
31  delete(fGeoH);
32 }
33 
35 {
38  fClusterCands = (TClonesArray *)fManager->GetObject("MVDPixelClusterCand");
39  fRecoHits = (TClonesArray *)fManager->GetObject("MVDHitsPixel");
40 
41  if(fClusterCands != 0 && fRecoHits != 0) fUseCluster = kTRUE;
42  return kSUCCESS;
43 }
44 
46 {
47  PndSdsPixelDigiPar digipar;
48  digipar.SetFECols(104);
49  digipar.SetFERows(104);
50  digipar.SetMaxFEperCol(10);
51  digipar.SetMaxFEperRow(10);
52  PndSdsCalcFePixel calc(digipar);
53  Int_t col, row, fe;
54  Reset();
55  if (fUseCluster == kTRUE){
56  for (int hitNr = 0; hitNr < fRecoHits->GetEntriesFast(); hitNr++){
57  PndSdsHit* myRecoHit = (PndSdsHit*)fRecoHits->At(hitNr);
58  TVector3 recoVector;
59  myRecoHit->Position(recoVector);
60  TVector3 recoLocal = fGeoH->MasterToLocalShortId(recoVector, myRecoHit->GetSensorID());
61  TVector3 SensDim = fGeoH->GetSensorDimensionsShortId(myRecoHit->GetSensorID());
62  TString detName = fGeoH->GetPath(myRecoHit->GetSensorID());
63  Int_t sensorId = myRecoHit->GetSensorID();
64  if (fModules[sensorId] == 0)
65  fModules[sensorId] = CreateNewBoxSet(detName);
66 
67  PndSdsCluster* myCluster = (PndSdsCluster*)fClusterCands->At(myRecoHit->GetRefIndex());
68  for (int clusterNr = 0; clusterNr < myCluster->GetClusterSize(); clusterNr++){
69  PndSdsDigiPixel* p = (PndSdsDigiPixel*)fList->At(myCluster->GetDigiIndex(clusterNr));
70  col = p->GetPixelColumn();
71  row = p->GetPixelRow();
72  fe = p->GetFE();
73  std::cout << "Fe, Col, Row: " << fe << " " << col << "/" << row << std::endl;
74  calc.CalcSensorColRow(col, row, p->GetFE());
75  std::cout << "Col, Row " << p->GetSensorID() << " : " << col << "/" << row << std::endl;
76  TVector3 digiLocal(((col+0.5) - (SensDim.X()*100))*fPixelSize, ((row+0.5)-(SensDim.Y()*100))*fPixelSize, 0);
77  std::cout << "DigiLocal: " << digiLocal.X() << " " << digiLocal.Y() << " " << digiLocal.Z() << std::endl;
78  std::cout << "RecoLocal: " << recoLocal.X() << " " << recoLocal.Y() << " " << recoLocal.Z() << std::endl;
79  TVector3 diff = digiLocal - recoLocal;
80  std::cout << "Diff: " << diff.X() << " " << diff.Y() << " " << diff.Z() << std::endl;
81  TVector3 final = diff * (fBoxSize/fPixelSize);
82  final += recoLocal;
83  std::cout << "Final: " << final.X() << " " << final.Y() << " " << final.Z() << std::endl;
84 
85  fModules[p->GetSensorID()]->AddBox(final.X(), final.Y(), final.Z());
86  fModules[p->GetSensorID()]->DigitValue(p->GetCharge());
87  }
88  }
89  }
90  else {
91  for (Int_t i=0; i<fList->GetEntriesFast(); ++i) {
92  PndSdsDigiPixel* p = (PndSdsDigiPixel*)fList->At(i);
93  TString detName = fGeoH->GetPath(p->GetSensorID());
94  Int_t sensorId = p->GetSensorID();
95 
96  if (fModules[sensorId] == 0)
97  fModules[sensorId] = CreateNewBoxSet(detName);
98 
99  col = p->GetPixelColumn();
100  row = p->GetPixelRow();
101  fe = p->GetFE();
102  std::cout << "Fe, Col, Row: " << fe << " " << col << "/" << row << std::endl;
103  calc.CalcSensorColRow(col, row, p->GetFE());
104  std::cout << "Col, Row " << p->GetSensorID() << " : " << col << "/" << row << std::endl;
105  TVector3 SensDim = fGeoH->GetSensorDimensionsShortId(p->GetSensorID());
106  std::cout << "SensDim: " << SensDim.X() << " " << SensDim.Y() << " " << SensDim.Z() << std::endl;
107  fModules[p->GetSensorID()]->AddBox(((col+0.5) - (SensDim.X()*100))*0.01, ((row+0.5)-(SensDim.Y()*100))*0.01, 0.01);
108  fModules[p->GetSensorID()]->DigitValue(p->GetCharge());
109  }
110  }
111 
112  for (boxSetMapIter it = fModules.begin(); it != fModules.end(); it++){
113  TGeoHMatrix testMatrix = *(fGeoH->GetMatrixShortId(it->first));
114  //TGeoHMatrix invMatrix = testMatrix.Inverse();
115  //Double_t scale[] = {0.01,0.01,0.01}; //Dim is 0.1 mm //[R.K. 01/2017] unused variable
116  //testMatrix.SetScale(scale);
117  TEveTrans& t = it->second->RefMainTrans();
118  t.SetFrom(testMatrix);
119  //TEveElement* el = (TEveElement*)it->second; //[R.K. 01/2017] unused variable
120  TEveElement* man = (TEveElement*)fEventManager;
121 // gEve->AddElement(it->second, fEventManager);
122  gEve->AddElement(it->second, man);
123  }
124 
125  gEve->Redraw3D(kFALSE);
126 }
127 
129 {
130  TEveBoxSet* bs = new TEveBoxSet(name);
131  bs->Reset(TEveBoxSet::kBT_AABoxFixedDim, kFALSE, 32);
132  bs->SetDefWidth(fBoxSize);
133  bs->SetDefHeight(fBoxSize);
134  bs->SetDefDepth(fBoxSize);
135 
136  return bs;
137 }
138 
140 {
141  for (boxSetMapIter it = fModules.begin(); it != fModules.end(); it++){
142  //TEveElement* el = (TEveElement*)it->second; //[R.K. 01/2017] unused variable
143  TEveElement* man = (TEveElement*)fEventManager;
144 // gEve->AddElement(it->second, fEventManager);
145  gEve->AddElement(it->second, man);
146  }
147  fModules.clear();
148 }
149 
151 
int row
Definition: anaLmdDigi.C:67
Int_t GetPixelRow() const
TClonesArray * fRecoHits
Int_t GetClusterSize() const
Definition: PndSdsCluster.h:39
Int_t GetSensorID() const
Definition: PndSdsDigi.h:59
std::map< Int_t, TEveBoxSet * >::iterator boxSetMapIter
Int_t i
Definition: run_full.C:25
Class to store the Digis which belong to one cluster This class holds the information which Digi belo...
Definition: PndSdsCluster.h:19
Int_t GetPixelColumn() const
TEveBoxSet * CreateNewBoxSet(TString &name)
int col
Definition: anaLmdDigi.C:67
Double_t GetCharge() const
Definition: PndSdsDigi.h:60
std::map< Int_t, TEveBoxSet * > fModules
void Exec(Option_t *option)
Int_t GetFE() const
Definition: PndSdsDigi.h:57
double Y
Definition: anaLmdDigi.C:68
void CalcSensorColRow(Int_t &col, Int_t &row, const Int_t fe) const
Main function to calculate sensor hits.
ClassImp(PndMvdDigiPixelDraw)
TString GetPath(Int_t shortID)
for a given shortID the path is returned
Double_t p
Definition: anasim.C:58
TVector3 GetSensorDimensionsShortId(Int_t shortId)
TGeoHMatrix * GetMatrixShortId(Int_t shortId)
Int_t GetDigiIndex(Int_t i) const
Definition: PndSdsCluster.h:40
static PndGeoHandling * Instance()
TString name
TVector3 MasterToLocalShortId(const TVector3 &master, const Int_t &shortId)
TClonesArray * fClusterCands
PndGeoHandling * fGeoH
double X
Definition: anaLmdDigi.C:68
fRun Init()
Definition: NHitsPerEvent.C:20
int fe
Definition: anaLmdDigi.C:67
double Z
Definition: anaLmdDigi.C:68
Int_t iVerbose
TTree * t
Definition: bump_analys.C:13
Data class to store the digi output of a pixel module.
void SetMaxFEperRow(Int_t x)
void SetMaxFEperCol(Int_t x)
Int_t GetSensorID() const
Definition: PndSdsHit.h:90
Class to calculate the position of digis on a front-end from the digis on a sensor.
void SetFECols(Int_t x)
void SetFERows(Int_t x)
Digitization Parameter Class for SDS-Pixel part.