4 // Script that contains a class to draw hits, using the
5 // AliFMDInputHits class in the util library.
7 // It draws the energy loss versus the p/(mq^2). It can be overlayed
8 // with the Bethe-Bloc curve to show how the simulation behaves
9 // relative to the expected.
11 // Use the script `Compile.C' to compile this class using ACLic.
14 #include <AliFMDHit.h>
15 #include <AliFMDInput.h>
19 #include <TMarker3DBox.h>
20 #include <TGeoManager.h>
22 #include <TApplication.h>
24 #include <TParticle.h>
27 #include <TVirtualX.h>
29 class DrawHitPatterns : public AliFMDInputHits
44 static DrawHitPatterns* fgInstance;
45 DrawHitPatterns(Bool_t primary=kTRUE, Int_t pdg=211)
46 : fPrimary(primary), fPdg(pdg),
47 fCanvas(0), fPad(0), fButton(0)
51 fMarkers = new TObjArray;
52 fHits = new TObjArray;
53 fMarkers->SetOwner(kTRUE);
54 fHits->SetOwner(kFALSE);
57 void Continue() { fWait = kFALSE; }
58 void Zoom() { fZoomMode = kTRUE; }
59 void Pick() { fZoomMode = kFALSE; }
60 void ExecuteEvent(Int_t event, Int_t px, Int_t py)
62 Info("ExecuteEvent", "Event %d, at (%d,%d)", px, py);
63 static Float_t x0, y0, x1, y1;
64 static Int_t px0, py0, pxOld,pyOld;
65 static Bool_t lineDraw;
66 if (px == 0 && py == 0) return;
67 if (!fZoomMode && fPad->GetView()) {
68 fPad->GetView()->ExecuteRotateView(event, px, py);
71 gPad->SetCursor(kCross);
74 gPad->TAttLine::Modify();
75 x0 = fPad->AbsPixeltoX(px);
76 y0 = fPad->AbsPixeltoY(py);
83 gVirtualX->DrawBox(px0, py0, pxOld, pyOld, TVirtualX::kHollow);
87 gVirtualX->DrawBox(px0, py0, pxOld, pyOld, TVirtualX::kHollow);
90 fPad->GetCanvas()->FeedbackMode(kFALSE);
91 if (px == px0 || py == py0) return;
92 x1 = gPad->AbsPixeltoX(px);
93 y1 = gPad->AbsPixeltoY(py);
94 if (x1 < x0) std::swap(x0, x1);
95 if (y1 < y0) std::swap(y0, y1);
96 gPad->Range(x0, y0, x1, y1);
101 Int_t DistanceToPrimitive(Int_t px, Int_t py)
103 Info("DistanceToPrimitive", "@ (%d,%d)", px, py);
104 gPad->SetCursor(kCross);
105 Float_t xmin = gPad->GetX1();
106 Float_t xmax = gPad->GetX2();
107 Float_t dx = .02 * (xmax - xmin);
108 Float_t x = gPad->AbsPixeltoX(px);
109 if (x < xmin + dx || x > xmax - dx) return 9999;
110 return (fZoomMode ? 0 : 7);
112 Bool_t Begin(Int_t event)
115 fCanvas = new TCanvas("display", "Display", 700, 700);
116 fCanvas->SetFillColor(1);
117 fCanvas->ToggleEventStatus();
118 fPad = new TPad("view3D", "3DView", 0.0, 0.1, 1.0, 1.0, 1, 0, 0);
124 fButton = new TButton("Continue",
125 "DrawHitPatterns::fgInstance->Continue()",
128 fZoom = new TButton("Zoom",
129 "DrawHitPatterns::fgInstance->Zoom()",
132 fPick = new TButton("Pick",
133 "DrawHitPatterns::fgInstance->Pick()",
137 Info("Begin", "Clearing canvas");
140 Warning("End", "No geometry manager");
143 Info("Begin", "Drawing geometry");
145 fGeoManager->GetTopVolume()->Draw();
146 Info("Begin", "Adjusting view");
148 if (fPad->GetView()) {
149 fPad->GetView()->SetView(-200, -40, 80, irep);
150 fPad->GetView()->Zoom();
154 Info("Begin", "Drawing button");
156 return AliFMDInputHits::Begin(event);
159 Bool_t ProcessHit(AliFMDHit* hit, TParticle* p)
162 std::cout << "No hit" << std::endl;
167 std::cout << "No track" << std::endl;
170 if (fPrimary && !p->IsPrimary()) return kTRUE;
171 if (hit->IsStop()) return kTRUE;
173 if (TMath::Abs(hit->Pdg()) != fPdg) return kTRUE;
176 Float_t size = TMath::Min(TMath::Max(hit->Edep() * .1, .1), 1.);
177 Float_t pt = TMath::Sqrt(hit->Py()*hit->Py()+hit->Px()*hit->Px());
178 Float_t theta = TMath::ATan2(pt, hit->Pz());
179 Float_t phi = TMath::ATan2(hit->Py(), hit->Px());
180 TMarker3DBox* marker = new TMarker3DBox(hit->X(), hit->Y(), hit->Z(),
183 marker->SetLineColor((p->IsPrimary() ? 3 : 4));
184 marker->SetRefObject(hit);
185 fMarkers->Add(marker);
190 // fGeoManager->GetTopVolume()->Draw();
194 fPad->Modified(kTRUE);
197 fCanvas->Modified(kTRUE);
203 gApplication->StartIdleing();
204 gSystem->InnerLoop();
205 gApplication->StopIdleing();
207 Info("End", "After idle loop");
210 Info("End", "After clearing caches");
211 return AliFMDInputHits::End();
213 ClassDef(DrawHitPatterns,0);
216 DrawHitPatterns* DrawHitPatterns::fgInstance = 0;
218 //____________________________________________________________________