FairRoot/PandaRoot
PndMvdAllDataEventAna.cxx
Go to the documentation of this file.
2 #include "PndSdsMCPoint.h"
3 #include "PndSdsPixel.h"
4 #include "GFTrackCand.h"
5 #include "TVector3.h"
6 #include "TGeoManager.h"
7 #include "TGeoBBox.h"
8 #include "TLegend.h"
9 #include "TGeoMatrix.h"
10 #include "PndFileNameCreator.h"
11 
12 #include "TGeoTrack.h"
13 #include <sstream>
14 
16 
18 {
19  Init(fileName);
21 
22 
24 
25  fRecoVolume = gGeoManager->MakeSphere("RecoHit",gGeoManager->GetMedium("vacuum"),0,0.1);
26  fRecoVolume->SetLineColor(kRed);
27 
28  TGeoVolume* mcHit = gGeoManager->MakeSphere("MCHit",gGeoManager->GetMedium("vacuum"),0,0.1);
29  mcHit->SetLineColor(kGreen);
30 
31  TGeoShape* stripShape = gGeoManager->GetVolume("StripSensor")->GetShape();
32  TGeoVolume* stripVol = new TGeoVolume("StripSensorRed",stripShape, gGeoManager->GetMedium("vacuum"));
33  stripVol->SetLineColor(kRed);
34  gGeoManager->AddVolume(stripVol);
35  stripVol = gGeoManager->GetVolume("StripSensorRed");
36 
37  TGeoShape* pixShape1 = gGeoManager->GetVolume("SensorActiveAreao[NrFE=8ooE]")->GetShape();
38  TGeoVolume* pixVol1 = new TGeoVolume("PixelSensor8",pixShape1, gGeoManager->GetMedium("vacuum"));
39  pixVol1->SetLineColor(kRed);
40  gGeoManager->AddVolume(pixVol1);
41  pixVol1 = gGeoManager->GetVolume("PixelSensor8");
42 
43  TGeoShape* pixShape2 = gGeoManager->GetVolume("SensorActiveAreao[NrFE=4]")->GetShape();
44  TGeoVolume* pixVol2 = new TGeoVolume("PixelSensor4",pixShape2, gGeoManager->GetMedium("vacuum"));
45  pixVol2->SetLineColor(kRed);
46  gGeoManager->AddVolume(pixVol2);
47  pixVol2 = gGeoManager->GetVolume("PixelSensor4");
48 
49  TGeoShape* pixShape3 = gGeoManager->GetVolume("SensorActiveAreao[NrFE=5]")->GetShape();
50  TGeoVolume* pixVol3 = new TGeoVolume("PixelSensor5",pixShape3, gGeoManager->GetMedium("vacuum"));
51  pixVol3->SetLineColor(kRed);
52  gGeoManager->AddVolume(pixVol3);
53  pixVol3 = gGeoManager->GetVolume("PixelSensor5");
54 
55  TGeoVolume* stripVolG = new TGeoVolume("StripSensorGreen",stripShape, gGeoManager->GetMedium("vacuum"));
56  stripVolG->SetLineColor(kGreen);
57  gGeoManager->AddVolume(stripVolG);
58  stripVolG = gGeoManager->GetVolume("StripSensorGreen");
59 
60  TGeoVolume* pixVolG1 = new TGeoVolume("PixelSensor8Green",pixShape1, gGeoManager->GetMedium("vacuum"));
61  pixVolG1->SetLineColor(kGreen);
62  gGeoManager->AddVolume(pixVolG1);
63  pixVolG1 = gGeoManager->GetVolume("PixelSensor8Green");
64 
65  TGeoVolume* pixVolG2 = new TGeoVolume("PixelSensor4Green",pixShape2, gGeoManager->GetMedium("vacuum"));
66  pixVolG2->SetLineColor(kGreen);
67  gGeoManager->AddVolume(pixVolG2);
68  pixVolG2 = gGeoManager->GetVolume("PixelSensor4Green");
69 
70  TGeoVolume* pixVolG3 = new TGeoVolume("PixelSensor5Green",pixShape3, gGeoManager->GetMedium("vacuum"));
71  pixVolG3->SetLineColor(kGreen);
72  gGeoManager->AddVolume(pixVolG3);
73  pixVolG3 = gGeoManager->GetVolume("PixelSensor5Green");
74 
75  fMvdTopVolume = gGeoManager->GetVolume("MVDoOption1");
76  fGeoList = new PndEventDisplay();
77 
78  fGeoList->AddNewGroup("RecoHits",new PndGeoHitList("RecoHits","MVDoOption1", fRecoVolume));
79  fGeoList->AddNewGroup("MCHits",new PndGeoHitList("MCHits","MVDoOption1", mcHit));
80  fGeoList->AddNewGroup("StripHits", new PndGeoHitList("StripHits","MVDoOption1",stripVol));
81  fGeoList->AddNewGroup("PixHits8", new PndGeoHitList("PixHits8","MVDoOption1",pixVol1));
82  fGeoList->AddNewGroup("PixHits4", new PndGeoHitList("PixHits4","MVDoOption1",pixVol2));
83  fGeoList->AddNewGroup("PixHits5", new PndGeoHitList("PixHits5","MVDoOption1",pixVol3));
84  fGeoList->AddNewGroup("StripHitsGreen", new PndGeoHitList("StripHitsGreen","MVDoOption1",stripVolG));
85  fGeoList->AddNewGroup("PixHits8Green", new PndGeoHitList("PixHits8Green","MVDoOption1",pixVolG1));
86  fGeoList->AddNewGroup("PixHits4Green", new PndGeoHitList("PixHits4Green","MVDoOption1",pixVolG2));
87  fGeoList->AddNewGroup("PixHits5Green", new PndGeoHitList("PixHits5Green","MVDoOption1",pixVolG3));
88 
89  fPixelCon = new PndSdsCalcFePixel(76,84,10);
90 }
91 
93 {
94  PndFileNameCreator nameCreator(fileName.Data());
95  fFile = new TFile(fileName.Data());
96  fTree = (TTree*)fFile->Get("pndsim");
97 
98  fTree->AddFriend("digi=pndsim",nameCreator.GetDigiFileName().c_str());
99  fTree->AddFriend("reco=pndsim",nameCreator.GetRecoFileName().c_str());
100  fTree->AddFriend("trackF=pndsim",nameCreator.GetTrackFindingFileName().c_str());
101 
102  fHitArray=new TClonesArray("PndSdsMCPoint");
103  fDigiArray = new TClonesArray("PndSdsDigiPixel");
104  fClusterArray = new TClonesArray("PndSdsCluster");
105  fRecoArray = new TClonesArray("PndSdsHit");
106  fGeoTrackArray = new TClonesArray("TGeoTrack");
107  fTrackFArray = new TClonesArray("GFTrackCand");
108 
109  fTree->SetBranchAddress("MVDPoint",&fHitArray);
110  fTree->SetBranchAddress("MVDPixelDigis",&fDigiArray);
111  fTree->SetBranchAddress("MVDClusterCand",&fClusterArray);
112  fTree->SetBranchAddress("MVDClusterHit",&fRecoArray);
113  fTree->SetBranchAddress("MVDTrackCand",&fTrackFArray);
114  if (fTree->FindBranch("GeoTracks") != 0)
115  fTree->SetBranchAddress("GeoTracks", &fGeoTrackArray);
116 
117  fAllHitPerClusterHistos = new TH1I("hitPerCluster","hitPerCluster",21,0,20);
118  fAllHitResolutionHistos = new TH1D("AllHitResolution","AllHitResolution", 1000,0,0.1);
119  f3DMCHisto = new TH3D("h3D","h3D", 50,-15,15, 50, -15,15, 50, -30,30);
120  f3DRecoHisto = new TH3D("h3D","h3D", 50,-15,15, 50, -15,15, 50, -30,30);
121 
122 }
123 
125 {
126 }
127 
129 {
130 }
131 
133 {
134  ClearAllHMaps();
135  ClearAllVectors();
136 
137  fGeoList->ClearHits("RecoHits");
138  fGeoList->ClearHits("MCHits");
139  fGeoList->ClearHits("StripHits");
140  fGeoList->ClearHits("PixHits4");
141  fGeoList->ClearHits("PixHits5");
142  fGeoList->ClearHits("PixHits8");
143  fGeoList->ClearHits("StripHitsGreen");
144  fGeoList->ClearHits("PixHits4Green");
145  fGeoList->ClearHits("PixHits5Green");
146  fGeoList->ClearHits("PixHits8Green");
147 }
148 
150 {
151  fHitArray->Delete();
152  fDigiArray->Delete();
153  fClusterArray->Delete();
154  fRecoArray->Delete();
155 
156  fTree->GetEntry(fActiveEvent);
157 
158  std::cout << "hitArray: " << fHitArray->GetEntries() << std::endl;
159  std::cout << "digiArray: " << fDigiArray->GetEntries() << std::endl;
160  std::cout << "clusterArray: " << fClusterArray->GetEntries() << std::endl;
161  std::cout << "recoArray: " << fRecoArray->GetEntries() << std::endl;
162 
163  PrintHitArray();
164  PrintDigiArray();
166  PrintRecoArray();
167 
168  FillHitHistos();
169  FillDigiHistos();
171  FillRecoHistos();
174  Fill3DHisto();
176 
177  Create3DGeoHits();
178 }
179 
181 {
182  for (Int_t i = 0; i < fHitArray->GetEntries(); i++){
183  std::cout << i << ": ";
184  PndSdsMCPoint* myPoint = (PndSdsMCPoint*)fHitArray->At(i);
185  std::cout << *myPoint;
186  }
187 }
189 {
190  for (Int_t i = 0; i < fDigiArray->GetEntries(); i++){
191  PndSdsDigiPixel* myDigi = (PndSdsDigiPixel*)fDigiArray->At(i);
192  std::cout << i << ": ";
193  //myDigi->Print();
194  std::cout << *myDigi;
195  }
196 }
198 {
199  for (Int_t i = 0; i < fClusterArray->GetEntries(); i++){
200  std::cout << "Cluster " << i << ": " << std::endl;
201  PndSdsCluster* myCluster = (PndSdsCluster*)fClusterArray->At(i);
202  //myCluster->Print();
203  std::vector<Int_t> myClusterList = myCluster->GetClusterList();
204  for (UInt_t j = 0; j < myClusterList.size(); j++){
205  PndSdsDigiPixel* myDigi = (PndSdsDigiPixel*)fDigiArray->At(myClusterList[j]);
206  std::cout << myClusterList[j] << ": ";
207  std::cout << *myDigi;
208  }
209  }
210 
211 }
213 {
214  for (Int_t i = 0; i < fRecoArray->GetEntries(); i++){
215  std::cout << i << ": ";
216  PndSdsHit* myHit = (PndSdsHit*)fRecoArray->At(i);
217  std::cout << *myHit;
218  }
219 }
220 
221 
222 TVector3 PndMvdAllDataEventAna::GetLocalHitPoints(TString detName, TVector3 input)
223 {
224  TVector3 result;
225  Double_t in[3];
226  Double_t local[3];
227 
228  in[0] = input.X();
229  in[1] = input.Y();
230  in[2] = input.Z();
231 
232  gGeoManager->cd(fGeoH->GetPath(detName.Data()));
233  TGeoHMatrix* transMat = gGeoManager->GetCurrentMatrix();
234 
235  transMat->MasterToLocal(in, local);
236 
237  TGeoVolume* actVolume = gGeoManager->GetCurrentVolume();
238  TGeoBBox* actBox = (TGeoBBox*)(actVolume->GetShape());
239 
240  result.SetX(local[0] + actBox->GetDX());
241  result.SetY(local[1] + actBox->GetDY());
242  result.SetZ(local[2] + actBox->GetDZ());
243 
244  return result;
245 }
246 
248 {
249  for (Int_t i = 0; i < fHitArray->GetEntries(); i++){
250  PndSdsMCPoint *myPoint = (PndSdsMCPoint*)fHitArray->At(i);
251  TString detName = myPoint->GetDetName();
252  //if (hit->GetDetName().Contains("119_2")){
253  if (fHistos[detName] == 0){
254  fHistos[detName] = new TH2I("MCHisto",detName.Data(), 1000,0,1000,201,0,200);
255  //fDrawOption[hit->GetDetName()] = "colz";
256  }
257  //TH2* tempHisto = (TH2*)(fHistos[detName]);
258  gGeoManager->cd(fGeoH->GetPath(detName.Data()));
259  // TGeoHMatrix* transMat = gGeoManager->GetCurrentMatrix();
260 
261  TVector3 in(myPoint->GetX(), myPoint->GetY(), myPoint->GetZ());
262  TVector3 out(myPoint->GetXOut(), myPoint->GetYOut(), myPoint->GetZOut());
263  TVector3 inLocal, outLocal;
264  inLocal = GetLocalHitPoints(detName, in);
265  outLocal = GetLocalHitPoints(detName, out);
266 
267  fHistos[detName]->Fill(inLocal.X()*100, inLocal.Y()*100);
268  fHistos[detName]->Fill(outLocal.X()*100, outLocal.Y()*100);
269 
270 // std::cout << i << ": " << std::endl;
271 // for (Int_t i = 0; i < 3; i++){
272 // std::cout << "posInLocal "<< i << ": " << inLocal(i) << std::endl;
273 // std::cout << "posOutLocal "<< i << ": " << outLocal(i) << std::endl;
274 // }
275  }
276 }
278 {
279  for (Int_t i = 0; i < fDigiArray->GetEntries(); i++){
281  //if (hit->GetDetName().Contains("119_2")){
282  if (fDigiHistos[hit->GetDetName()] == 0){
283  fDigiHistos[hit->GetDetName()] = new TH2I("digiHisto",hit->GetDetName().Data(), 1000,0,1000,201,0,200);
284  //fDrawOption[hit->GetDetName()] = "colz";
285  }
286  TH2* tempHisto = (TH2*)(fDigiHistos[hit->GetDetName()]);
287  PndSdsPixel myFePixel(hit->GetSensorID(), hit->GetFE(), hit->GetPixelColumn(), hit->GetPixelRow(), hit->GetCharge());
288  PndSdsPixel mySensorPixel = fPixelCon->CalcSensorHit(myFePixel);
289  tempHisto->Fill(mySensorPixel.GetCol(), mySensorPixel.GetRow(),mySensorPixel.GetCharge());//, (Double_t)(hit->GetCharge()));
290  }
291 }
293 {
294  for (Int_t i = 0; i < fClusterArray->GetEntries(); i++){
295  PndSdsCluster *cluster = (PndSdsCluster*)fClusterArray->At(i);
296  //if (hit->GetDetName().Contains("119_2")){
297  std::vector<Int_t> clusterList = cluster->GetClusterList();
298  PndSdsDigiPixel* hit = (PndSdsDigiPixel*)fDigiArray->At(clusterList[0]);
299  Int_t sensorID = hit->GetSensorID();
300  if (fClusterHistos[sensorID] == 0){
301  fClusterHistos[sensorID] = new TH2I("clusterHisto",detName.Data(), 1000,0,1000,201,0,200);
302  //fDrawOption[hit->GetDetName()] = "colz";
303  }
304  TH2* tempHisto = (TH2*)(fClusterHistos[detName]);
305  for (Int_t j = 0; j < clusterList.size(); j++){
306  hit = (PndSdsDigiPixel*)fDigiArray->At(clusterList[j]);
307  PndSdsPixel myFePixel(sensorID, hit->GetFE(), hit->GetPixelColumn(), hit->GetPixelRow(), hit->GetCharge());
308  PndSdsPixel mySensorPixel = fPixelCon->CalcSensorHit(myFePixel);
309  tempHisto->Fill(mySensorPixel.GetCol(), mySensorPixel.GetRow());
310  }
311  }
312 }
313 
315 {
316  for (Int_t i = 0; i < fRecoArray->GetEntries(); i++){
317  PndSdsHit *myHit = (PndSdsHit*)fRecoArray->At(i);
318  TString detName = myHit->GetDetName();
319  //if (hit->GetDetName().Contains("119_2")){
320  if (fRecoHistos[detName] == 0){
321  fRecoHistos[detName] = new TH2I("RecoHisto",detName.Data(), 1000,0,1000,201,0,200);
322  //fDrawOption[hit->GetDetName()] = "colz";
323  }
324  //TH2* tempHisto = (TH2*)(fRecoHistos[detName]);
325 
326  TVector3 in(myHit->GetX(), myHit->GetY(), myHit->GetZ());
327  TVector3 inLocal;
328  inLocal = GetLocalHitPoints(detName, in);
329 
330  fRecoHistos[detName]->Fill(inLocal.X()*100, inLocal.Y()*100);
331 
332 // std::cout << i << ": " << std::endl;
333 // for (Int_t i = 0; i < 3; i++){
334 // std::cout << "posInLocal "<< i << ": " << inLocal(i) << std::endl;
335 // }
336  }
337 }
338 
340 {
341  for (Int_t i = 0; i < fClusterArray->GetEntries(); i++){
343  std::vector<Int_t> hits = GetHitPerCluster(cand);
344  PndSdsMCPoint* point = (PndSdsMCPoint*)(fHitArray->At(hits[0]));
345  TString detName = point->GetDetName();
346  if (fHitPerClusterHistos[detName] == 0){
347  fHitPerClusterHistos[detName] = new TH1I("HitPerCluster",detName.Data(), 21,0,20);
348  //fDrawOption[hit->GetDetName()] = "colz";
349  }
350  fHitPerClusterHistos[detName]->Fill(hits.size());
351  fAllHitPerClusterHistos->Fill(hits.size());
352  std::cout << "Hits in Cluster: " << hits.size() << " for Det: " << detName.Data() << std::endl;
353  }
354 }
355 
357 {
358  for (Int_t i = 0; i < fRecoArray->GetEntries(); i++){
359  PndSdsHit *myHit = (PndSdsHit*)fRecoArray->At(i);
360  TString detName = myHit->GetDetName();
361  std::cout << "HitResolution for: " << detName << std::endl;
362  TVector3 recoPos = myHit->GetPosition();
363  std::cout << "RecoPos: " << recoPos.X() << " " << recoPos.Y() << " " << recoPos.Z() << std::endl;
364  std::cout << "MC point RefIndex: " << myHit->GetRefIndex() << std::endl;
365  std::cout << "Cluster Index: " << myHit->GetClusterIndex() << std::endl;
366  PndSdsCluster *myCand = (PndSdsCluster*)(fClusterArray->At(myHit->GetClusterIndex()));
367  std::vector<Int_t> points = GetHitPerCluster(myCand);
368  for (UInt_t k = 0; k < points.size(); i++)
369  std::cout << "ClusterPoints: " << points[k] << std::endl;
370  TVector3 hitPos = CalcMeanHitPos(points);
371  std::cout << "HitPos: " << hitPos.X() << " " << hitPos.Y() << " " << hitPos.Z() << std::endl;
372  if (fHitResolutionHistos[detName] == 0){
373  fHitResolutionHistos[detName] = new TH1D("HitRes",detName.Data(), 1000,0,0.01);
374  //fDrawOption[hit->GetDetName()] = "colz";
375  }
376  TVector3 resPos = recoPos - hitPos;
377  fHitResolutionHistos[detName]->Fill(resPos.Mag());
378  fAllHitResolutionHistos->Fill(resPos.Mag());
379  std::cout << "HitRes: " << resPos.Mag() << std::endl;
380  }
381 }
382 
384 {
385  for (Int_t i = 0; i < fRecoArray->GetEntries(); i++){
386  PndSdsHit* myHit = (PndSdsHit*)fRecoArray->At(i);
387  f3DRecoHisto->Fill(myHit->GetX(), myHit->GetY(), myHit->GetZ());
388  }
389  for (Int_t j = 0; j < fHitArray->GetEntries(); j++){
390  PndSdsMCPoint* myPoint = (PndSdsMCPoint*)fHitArray->At(j);
391  f3DMCHisto->Fill(myPoint->GetX(), myPoint->GetY(), myPoint->GetZ());
392  }
393 
394 }
395 
397 {
400  unsigned int detID, hitID;
401  TVector3 vec;
402 
403  for (Int_t i = 0; i < fTrackFArray->GetEntries(); i++){
404  GFTrackCand* trackC = (GFTrackCand*)fTrackFArray->At(i);
405  TH2D* myHistoXY = new TH2D("recohisxy","MVD Reco Points, xy view",400,-15.,15.,400,-15.,15.);
406  myHistoXY->SetMarkerStyle(7);
407  myHistoXY->SetMarkerColor(i+1);
408 
409  TH2D* myHistoRZ = new TH2D("recohisrz","MVD Reco Points, rz view",400,-20.,20.,400,-20.,20.);
410  myHistoRZ->SetMarkerStyle(7);
411  myHistoRZ->SetMarkerColor(i+1);
412 
413  fRecoHisxy.push_back(myHistoXY);
414  fRecoHisrz.push_back(myHistoRZ);
415  for (UInt_t j = 0; j < trackC->getNHits(); j++){
416  trackC->getHit(j, detID, hitID);
417  PndSdsHit* myHit = (PndSdsHit*)fRecoArray->At(hitID);
418  vec.SetXYZ(myHit->GetX(), myHit->GetY(), myHit->GetZ());
419  myHistoXY->Fill(vec.x(), vec.y());
420  myHistoRZ->Fill(vec.z(), vec.Perp());
421  }
422  }
423 }
424 
425 
426 TVector3 PndMvdAllDataEventAna::CalcMeanHitPos(std::vector<Int_t> points)
427 {
428  TVector3 result;
429  Double_t energy = 0;
430  for (UInt_t i = 0; i < points.size(); i++){
431  PndSdsMCPoint *myPoint = (PndSdsMCPoint*)fHitArray->At(points[i]);
432  TVector3 posIn = myPoint->GetPosition();
433  std::cout << "posIn: " << posIn.X() << " " << posIn.Y() << " " << posIn.Z() << std::endl;
434  TVector3 posOut = myPoint->GetPositionOut();
435  std::cout << "posOut: " << posOut.X() << " " << posOut.Y() << " " << posOut.Z() << std::endl;
436 
437  TVector3 posHit = posIn + posOut;
438  posHit *= 0.5;
439 
440  std::cout << "posHit: " << posHit.X() << " " << posHit.Y() << " " << posHit.Z() << std::endl;
441  //posHit *= myPoint->GetEnergyLoss();
442  energy += myPoint->GetEnergyLoss();
443  result += posHit;
444  }
445  //Double_t div = 1/energy;
446  Double_t div = 1/(Double_t)points.size();
447  result *= div;
448  return result;
449 }
450 
451 void PndMvdAllDataEventAna::DrawHitHisto(TString detName, TCanvas* extCan, Int_t pad)
452 {
453  if (extCan)
454  extCan->cd(pad);
455 
456  if (fHistos[detName] != 0)
457  fHistos[detName]->Draw();
458 }
459 
460 void PndMvdAllDataEventAna::DrawDigiHisto(TString detName, TCanvas* extCan, Int_t pad)
461 {
462  if (extCan)
463  extCan->cd(pad);
464 
465  if(fDigiHistos[detName] != 0)
466  fDigiHistos[detName]->Draw("colz");
467 }
468 void PndMvdAllDataEventAna::DrawClusterHisto(TString detName, TCanvas* extCan, Int_t pad)
469 {
470  if (extCan)
471  extCan->cd(pad);
472 
473  if(fClusterHistos[detName] != 0)
474  fClusterHistos[detName]->Draw("colz");
475 }
476 void PndMvdAllDataEventAna::DrawRecoHisto(TString detName, TCanvas* extCan, Int_t pad)
477 {
478  if (extCan)
479  extCan->cd(pad);
480 
481  if (fRecoHistos[detName] != 0)
482  fRecoHistos[detName]->Draw();
483 }
484 
485 void PndMvdAllDataEventAna::DrawAllHistos(TString detName, TCanvas* extCan)
486 {
487  if (extCan)
488  fCan1 = extCan;
489  if (fCan1 == 0)
490  fCan1 = new TCanvas();
491  DrawHitHisto(detName, fCan1, 1);
492  DrawDigiHisto(detName, fCan1, 2);
493  DrawClusterHisto(detName, fCan1, 3);
494  DrawRecoHisto(detName, fCan1, 4);
495  fCan1->cd(5);
496  fHitPerClusterHistos[detName]->Draw();
497  fCan1->cd(6);
498  fHitResolutionHistos[detName]->Draw();
499  fCan1->Modified(kTRUE);
500  fCan1->Update();
501 }
502 
503 void PndMvdAllDataEventAna::DrawAllHistos(Int_t index, TCanvas* extCan)
504 {
505  std::map<TString,TH1*>::const_iterator ki;
506  Int_t histoSize = fHistos.size();
507 
508  if (index >= histoSize) return;
509  ki = fHistos.begin();
510  for (Int_t i = 0; i < index; i++)
511  ki++;
512  TString detName = ki->first;
513  std::cout << "DetName: " << detName.Data() << std::endl;
514  DrawAllHistos(detName, extCan);
515 }
516 
517 void PndMvdAllDataEventAna::Draw3D(TString opt, TCanvas* extCan, Int_t pad)
518 {
519  if (extCan == 0)
520  extCan = new TCanvas();
521  extCan->cd(pad);
522  f3DMCHisto->SetMarkerStyle(8);
523  f3DMCHisto->SetMarkerSize(0.5);
524  f3DMCHisto->SetMarkerColor(2);
525  f3DMCHisto->Draw(opt.Data());
526  f3DRecoHisto->SetMarkerStyle(8);
527  f3DRecoHisto->SetMarkerSize(0.5);
528  f3DRecoHisto->SetMarkerColor(1);
529  f3DRecoHisto->Draw("same");
530 
531 }
532 
533 void PndMvdAllDataEventAna::DrawAllTracks(TCanvas* extCan, Int_t pad)
534 {
535  if (extCan == 0)
536  extCan = new TCanvas();
537  extCan->cd(pad);
538 
539  for (Int_t i = 0; i < fGeoTrackArray->GetEntries(); i++){
540  TGeoTrack* myTrack = (TGeoTrack*) fGeoTrackArray->At(i);
541  myTrack->Print();
542  myTrack->Draw();
543  }
544 }
545 
546 void PndMvdAllDataEventAna::DrawHitTracks(TCanvas* extCan, Int_t pad)
547 {
548  if (extCan == 0)
549  extCan = new TCanvas();
550  extCan->cd(pad);
551 
552  std::map<Int_t, Int_t> trackUsed;
553  for (Int_t i = 0; i < fHitArray->GetEntries(); i++){
554  PndSdsMCPoint* myPoint = (PndSdsMCPoint*)fHitArray->At(i);
555  std::cout << "Hit " << i << " TrackID " << myPoint->GetTrackID() << std::endl;
556  if (trackUsed[myPoint->GetTrackID()] == 0){
557  for (Int_t j = 0; j < fGeoTrackArray->GetEntries(); j++){
558  TGeoTrack* myTrack = (TGeoTrack*)fGeoTrackArray->At(j);
559  if (myPoint->GetTrackID() == myTrack->GetId()){
560  myTrack->Draw();
561  myTrack->Print();
562  }
563  }
564  trackUsed[myPoint->GetTrackID()] = 1;
565  }
566  }
567 }
568 
569 void PndMvdAllDataEventAna::DrawTopVolume(TCanvas* extCan, Int_t pad, const char* opt)
570 {
571  if (extCan)
572  extCan->cd(pad);
573 // fMvdTopVolume->Draw(""); //ogl for OpenGL Viewer
574  fMvdTopVolume->Draw(opt);
575 }
576 
577 void PndMvdAllDataEventAna::DrawHisrz(TCanvas* extCan, Int_t pad)
578 {
579  DrawHistoVec(&fRecoHisxy, extCan, pad);
580 }
581 
582 void PndMvdAllDataEventAna::DrawHisxy(TCanvas* extCan, Int_t pad)
583 {
584  DrawHistoVec(&fRecoHisrz, extCan, pad);
585 }
586 
587 void PndMvdAllDataEventAna::DrawHistoVec(std::vector<TH1*> *vec, TCanvas* extCan, Int_t pad) const
588 {
589  if (extCan)
590  extCan->cd(pad);
591  if (vec->size() > 0)
592  (*vec)[0]->Draw();
593  for (UInt_t i = 1; i < vec->size(); i++)
594  (*vec)[i]->Draw("same");
595 }
596 
597 void PndMvdAllDataEventAna::DrawHisto(TH1* histo, TCanvas* extCan, Int_t pad) const
598 {
599  if (extCan)
600  extCan->cd(pad);
601  histo->Draw();
602 }
603 
604 void PndMvdAllDataEventAna::DrawEvent(bool tracks, TCanvas* extCan)
605 {
606  if (extCan)
607  fCan2 = extCan;
608  if (fCan2 == 0)
609  fCan2 = new TCanvas();
610 
611  fCan2->Divide(2,2);
612 
613  fCan2->cd(1);
614  DrawTopVolume();
615 
616  if (tracks)
617  DrawHitTracks();
618 
619  fCan2->cd(2);
620  fAllHitResolutionHistos->Draw();
621 
622  fCan2->cd(3);
624 
625  fCan2->cd(4);
627 }
628 
630 {
631  std::vector<Int_t> result;
632  std::vector<Int_t> digiPos = clusterCand->GetClusterList();
633  bool isInResult = false;
634  for (UInt_t i = 0; i < digiPos.size(); i++){
635  PndSdsDigiPixel* digiHit = (PndSdsDigiPixel*)(fDigiArray->At(digiPos[i]));
636  Int_t mcID = digiHit->GetIndex(0);
637  std::cout << " -I- GetHitPerCluster: mcID: " << mcID << std::endl;
638  for (UInt_t j = 0; j < result.size() && isInResult == false; j++){
639  //std::cout << "Result: " << result[j] << std::endl;
640  if (mcID == result[j])
641  isInResult = true;
642  }
643  if (isInResult == false)
644  result.push_back(mcID);
645  isInResult = false;
646  }
647  for (UInt_t k = 0; k < result.size(); k++)
648  std::cout << " Result: " << k << ": " << result[k] << std::endl;
649  return result;
650 }
651 
653 {
654  fGeoList->SetHits("RecoHits",fRecoArray);
655 
656  for (Int_t i = 0; i < fHitArray->GetEntriesFast(); i++){
657  PndSdsMCPoint* myPoint = (PndSdsMCPoint*)fHitArray->At(i);
658  fGeoList->AddHit("MCHits", myPoint->GetX(), myPoint->GetY(), myPoint->GetZ());
659  std::cout << "gGeoManager cd: " << myPoint->GetDetName() << " " << gGeoManager->cd(fGeoH->GetPath(myPoint->GetDetName())) << std::endl;
660  TGeoHMatrix* mat = gGeoManager->GetCurrentMatrix();
661  mat->Print();
662  if (myPoint->GetDetName().Contains("71")){
663  std::cout << "StripHits added!" << std::endl;
664  fGeoList->AddHit("StripHits", mat);
665  fGeoList->AddHit("StripHitsGreen", mat, kFALSE);
666  }
667  else if (myPoint->GetDetName().Contains("89")){
668  std::cout << "PixHits4 added!" << std::endl;
669  fGeoList->AddHit("PixHits4", mat);
670  fGeoList->AddHit("PixHits4Green", mat, kFALSE);
671  }
672  else if (myPoint->GetDetName().Contains("56")){
673  std::cout << "PixHits8 added!" << std::endl;
674  fGeoList->AddHit("PixHits8", mat);
675  fGeoList->AddHit("PixHits8Green", mat, kFALSE);
676  }
677  }
678 }
679 
680 
681 void PndMvdAllDataEventAna::ClearHistoMaps(std::map<TString, TH1*>* myMaps) const
682 {
683  for (std::map<TString,TH1*>::const_iterator ki = myMaps->begin(); ki != myMaps->end(); ki++){
684  ki->second->Delete();
685  (*myMaps)[ki->first] = 0;
686  }
687  myMaps->clear();
688  std::cout << " Maps.size: " << myMaps->size() << std::endl;
689 }
690 
692 {
699 }
700 
702 {
707 }
708 void PndMvdAllDataEventAna::ClearHistoVector(std::vector<TH1*>* myVectors) const
709 {
710  for (UInt_t i = 0; i < myVectors->size(); i++)
711  {
712  delete ((*myVectors)[i]);
713  }
714  myVectors->clear();
715 }
716 
718 {
719  std::vector<TString> result;
720  for(std::map<TString, TH1*>::const_iterator ki= fRecoHistos.begin(); ki != fRecoHistos.end(); ++ki){
721  std::cout << "First: " << ki->first << std::endl;
722  std::cout << "Path: " << fGeoH->GetPath(ki->first) << std::endl;
723  result.push_back(fGeoH->GetPath(ki->first));
724  }
725  return result;
726 }
void DrawRecoHisto(TString detName, TCanvas *extCan=0, Int_t pad=0)
Int_t GetPixelRow() const
std::vector< Int_t > GetHitPerCluster(PndSdsCluster *clusterCand)
std::map< TString, TH1 * > fRecoHistos
Double_t GetXOut() const
Definition: PndSdsMCPoint.h:81
std::vector< Int_t > GetClusterList() const
Definition: PndSdsCluster.h:38
void ClearHits(TString groupName)
TVector3 CalcMeanHitPos(std::vector< Int_t > points)
std::vector< TH1 * > fDigiHistoVec
void DrawHisxy(TCanvas *extCan=0, Int_t pad=0)
void AddHit(TString groupName, FairHit *hit, Bool_t vis=kTRUE)
Int_t GetSensorID() const
Definition: PndSdsDigi.h:59
PndSdsCalcFePixel * fPixelCon
std::vector< TString > GetModulesHit()
Int_t i
Definition: run_full.C:25
TVector3 GetPosition() const
Definition: PndSdsHit.h:93
Class to store the Digis which belong to one cluster This class holds the information which Digi belo...
Definition: PndSdsCluster.h:19
Double_t GetZOut() const
Definition: PndSdsMCPoint.h:83
Int_t GetIndex(int i=0) const
Definition: PndSdsDigi.h:63
Int_t GetPixelColumn() const
void DrawHitHisto(TString detName, TCanvas *extCan=0, Int_t pad=0)
void DrawDigiHisto(TString detName, TCanvas *extCan=0, Int_t pad=0)
unsigned int getNHits() const
Definition: GFTrackCand.h:113
void SetCanvasColumns(Int_t col)
Double_t GetCharge() const
Definition: PndSdsDigi.h:60
TVector3 GetPositionOut() const
Definition: PndSdsMCPoint.h:91
display of hits inside the gGeoManager
virtual void Init(TString filename)
Int_t GetFE() const
Definition: PndSdsDigi.h:57
TGeoManager * gGeoManager
std::map< TString, TH1 * > fClusterHistos
TString GetPath(Int_t shortID)
for a given shortID the path is returned
PndGeoHandling * fGeoH
std::map< TString, TH1 * > fHistos
void Draw3D(TString opt="", TCanvas *extCan=0, Int_t pad=0)
TVector3 GetLocalHitPoints(TString detName, TVector3 input)
void DrawHitTracks(TCanvas *extCan=0, Int_t pad=0)
std::map< TString, TH1 * > fHitPerClusterHistos
void DrawHistoVec(std::vector< TH1 * > *vec, TCanvas *extCan=0, Int_t pad=0) const
void DrawClusterHisto(TString detName, TCanvas *extCan=0, Int_t pad=0)
A simple class which adds the corresponding file extensions to a given base class.
void AddNewGroup(TString groupName, PndGeoHitList *newList)
Double_t
void DrawAllHistos(TString detName, TCanvas *extCan=0)
void getHit(unsigned int i, unsigned int &detId, unsigned int &hitId) const
Get detector ID and cluster index (hitId) for hit number i.
Definition: GFTrackCand.h:84
void ClearHistoVector(std::vector< TH1 * > *myVectors) const
std::vector< TH1 * > fClusterHistoVec
std::vector< TH1 * > fRecoHistoVec
void DrawAllTracks(TCanvas *extCan=0, Int_t pad=0)
Track candidate – a list of cluster indices.
Definition: GFTrackCand.h:55
TClonesArray * fHitArray
TFile * out
Definition: reco_muo.C:20
static PndGeoHandling * Instance()
std::vector< TH1 * > fRecoHisrz
std::vector< TH1 * > fRecoHisxy
TVector3 GetPosition() const
Definition: PndSdsMCPoint.h:90
Double_t GetYOut() const
Definition: PndSdsMCPoint.h:82
void DrawHisto(TH1 *histo, TCanvas *extCan=0, Int_t pad=0) const
void DrawEvent(bool tracks=false, TCanvas *extCan=0)
void DrawTopVolume(TCanvas *extCan=0, Int_t pad=0, const char *opt="")
std::map< TString, TH1 * > fHitResolutionHistos
ClassImp(PndAnaContFact)
std::map< TString, TH1 * > fDigiHistos
void DrawHisrz(TCanvas *extCan=0, Int_t pad=0)
Data class to store the digi output of a pixel module.
Int_t GetClusterIndex() const
Definition: PndSdsHit.h:94
PndSdsMCPoint * hit
Definition: anasim.C:70
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
void SetHits(TString groupName, TClonesArray *hits, Bool_t vis=kTRUE)
Class to calculate the position of digis on a front-end from the digis on a sensor.
dble_vec_t vec[12]
Definition: ranlxd.cxx:380
std::vector< TH1 * > fHitHistoVec
void ClearHistoMaps(std::map< TString, TH1 * > *myHistos) const
Double_t energy
Definition: plot_dirc.C:15
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72