FairRoot/PandaRoot
PndDrcAccuDigiPixelDraw.cxx
Go to the documentation of this file.
1 // -----------------------------------------
2 // PndDrcAccuDigiPixelDraw.cpp
3 //
4 // Created on: 03.06.2013
5 // Author: R.Dzhygadlo
6 // ------------------------------------------
7 
9 
10 #include "FairRootManager.h"
11 #include "PndDrcPDHit.h"
12 
13 #include "TGeoMatrix.h"
14 #include "TClonesArray.h"
15 #include "TEveTrans.h"
16 #include "TEveManager.h"
17 #include "TEveBoxSet.h"
18 #include "TGLViewer.h"
19 #include "TGLSAViewer.h"
20 #include "TRandom.h"
21 #include "TStyle.h"
22 
23 using std::cout;
24 using std::endl;
25 
26 PndDrcAccuDigiPixelDraw::PndDrcAccuDigiPixelDraw() : fPixelSize(0.01), fBoxSize(1)
27 {
28  fGeo = new PndGeoDrc();
29 }
30 
31 PndDrcAccuDigiPixelDraw::PndDrcAccuDigiPixelDraw(const char* name,TString digifile, Double_t height, Int_t ndigievents, Int_t iVerbose) : FairBoxSetDraw(name, iVerbose), fPixelSize(0.01), fBoxSize(1)
32 {
33  fDigiFile = digifile;
34  fBoxHeight = height;
35  fNdigiEvents = ndigievents;
36  fFirstEvent=true;
37  fGeo = new PndGeoDrc();
38 }
39 
41 {
42  fHitsArr.clear();
43  fHitsN.clear();
44  if (fGeo) delete fGeo;
45  delete(fGeoH);
46 }
47 
49 {
52 
53  TIter next((TObjArray*)gGeoManager->GetListOfVolumes());
54  TGeoVolume *vol;
55  while((vol=(TGeoVolume*)next())){
56  TString volumename = vol->GetName();
57  if(!volumename.Contains("Drc")) vol->SetVisibility(kFALSE);
58  if(volumename.Contains("DrcBarSupport")) vol->SetVisibility(kFALSE);
59  if(volumename.Contains("DrcAirBox")) vol->SetTransparency(80);
60  if(volumename.Contains("DrcEV")) vol->SetTransparency(80);
61  if(volumename.Contains("DrcBarSensor")) vol->SetTransparency(80);
62  if(volumename.Contains("DrcLENS")) vol->SetTransparency(95);
63  if(volumename.Contains("DrcMirr")) vol->SetTransparency(50);
64  if(volumename.Contains("DrcEVgrease")) vol->SetTransparency(60);
65 
66  //vol->SetTransparency(80);
67  // vol->SetLineColor(17);
68  }
69 
70  gGeoManager->SetNsegments(400);
71 
72  TGLViewer *v = gEve->GetDefaultGLViewer();
73  //v->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
74  TGLSAViewer *sav = (TGLSAViewer *)v;
75  sav->SetDrawCameraCenter(true);
76  TGLCamera & cam=(TGLOrthoCamera &)v->CurrentCamera();
77  cam.SetExternalCenter(true);
78  cam.SetCenterVec(46.8, 8.9, -120.);
79 
80  //Double_t c[] = {46.8, 8.9, -120.};
81  //cam.Configure(1.3,1,c,-0.4,2.);
82  //v->DoDraw();
83 
84  fFirstEvent=true;
85  return kSUCCESS;
86 }
87 
89  TFile* f = new TFile(fDigiFile);
90  TTree *t=(TTree *) f->Get("pndsim") ;
91  TClonesArray* hit_array=new TClonesArray("PndDrcPDHit");
93  TVector3 recoVector,recoLocal;
94  TEveBoxSet* bs;
95  TGeoHMatrix testMatrix;
96  t->SetBranchAddress("DrcPDHit",&hit_array);
97  for (Int_t j=0; (j<fNdigiEvents || fNdigiEvents==0) && j<t->GetEntriesFast(); j++){
98  t->GetEntry(j);
99  if(j%1==0) cout<<"Event No "<<j<<" #entries "<<hit_array->GetEntriesFast()<<endl;
100  for (Int_t i=0; i<hit_array->GetEntriesFast(); i++)
101  {
102  hit=(PndDrcPDHit*)hit_array->At(i);
103  hit->Position(recoVector);
104  Int_t detId = hit->GetDetectorID();
105  Int_t sensorId = detId/100;
106 
107  recoLocal = fGeoH->MasterToLocalShortId(recoVector, sensorId);
108 
109  TString detName = Form("pix %d", detId);
110  bs = CreateNewBoxSet(detName);
111  Float_t pixSize=fGeo->PixelSize();
112  bs->SetDefWidth(pixSize);
113  bs->SetDefHeight(pixSize);
114  bs->AddBox(recoLocal.X()-pixSize/2., recoLocal.Y()-pixSize/2., -0.01);
115  testMatrix = *(fGeoH->GetMatrixShortId(sensorId));
116  TEveTrans& et = bs->RefMainTrans();
117  et.SetFrom(testMatrix);
118  fHitsArr[detId] = bs;
119  fHitsN[detId] ++;
120  }
121  }
122 }
123 
125 {
126  if(fFirstEvent) ReadAllHits();
127 
128  gStyle->SetPalette(1);
129  Int_t colnums = 256;
130  TEveRGBAPalette* pal = new TEveRGBAPalette(0, colnums);
131  TEveElement* man = (TEveElement*)fEventManager;
132  if(fFirstEvent){
133  Double_t max = 0;
134  for (IntIter it = fHitsN.begin(); it != fHitsN.end(); it++){
135  if(it->second > max) max = it->second;
136  }
137  max -= 0.2*max;
138  Double_t hstep = fBoxHeight/max;
139  TEveBoxSet* topbs = new TEveBoxSet("DrcAccuDigiPixel");
140  for (boxSetMapIter it = fHitsArr.begin(); it != fHitsArr.end(); it++){
141  //if(hstep*fHitsN[it->first]<0.3) continue;
142  it->second->SetPalette(pal);
143  Int_t color = fHitsN[it->first]*colnums/max;
144  if(color<1) color =1;
145  it->second->DigitValue(color);
146  Double_t s = 0.01+hstep*fHitsN[it->first];
147  it->second->SetDefDepth(s); //-0.005
148  TEveTrans& et = it->second->RefMainTrans();
149  TVector3 pos = et.GetPos();
150  et.SetPos(pos.X(),pos.Y(),pos.Z()-s);
151  topbs->AddElement(it->second);
152  }
153  gEve->AddElement(topbs, man);
154  }
155  gEve->Redraw3D(kFALSE);
156 
157  fFirstEvent = false;
158 }
159 
161 {
162  TEveBoxSet* bs = new TEveBoxSet(name);
163  bs->Reset(TEveBoxSet::kBT_AABoxFixedDim, kFALSE, 64);
164  return bs;
165 }
166 
168 
TVector3 pos
std::map< Int_t, TEveBoxSet * >::iterator boxSetMapIter
Int_t i
Definition: run_full.C:25
ClassImp(PndDrcAccuDigiPixelDraw)
TLorentzVector s
Definition: Pnd2DStar.C:50
cout<< "POINTs for new FwEndCap == "<< tsim-> GetEntriesFast()
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
TGeoManager * gGeoManager
__m128 v
Definition: P4_F32vec4.h:4
TClonesArray * hit_array
TGeoHMatrix * GetMatrixShortId(Int_t shortId)
std::map< Int_t, TEveBoxSet * > fHitsArr
Double_t
TEveBoxSet * CreateNewBoxSet(TString &name)
TFile * f
Definition: bump_analys.C:12
static PndGeoHandling * Instance()
TString name
TVector3 MasterToLocalShortId(const TVector3 &master, const Int_t &shortId)
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
Definition: hit.C:1
fRun Init()
Definition: NHitsPerEvent.C:20
std::map< Int_t, Int_t > fHitsN
Int_t iVerbose
TTree * t
Definition: bump_analys.C:13
std::map< Int_t, Int_t >::iterator IntIter
static int next[96]
Definition: ranlxd.cxx:374
Double_t PixelSize()
Definition: PndGeoDrc.h:175