-
Notifications
You must be signed in to change notification settings - Fork 24
Implementation of the algorithm to find the experimental Bragg curves from the AtTracks. #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2106ab5
b5bf1f3
64b3662
eb3fc7d
0321fed
df82291
bf01ba7
d0e07b8
491c91e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,16 @@ class TMemberInspector; | |
|
|
||
| class AtTrack : public TObject { | ||
|
|
||
| public: | ||
| struct BraggCurve { | ||
| std::vector<Double_t> IntegratedELossValues; | ||
| std::vector<Double_t> RangeValues; | ||
| std::vector<Double_t> ELossErrors; | ||
| Int_t nBins{0}; | ||
| Double_t binSize{0}; | ||
| Int_t smoothingSteps{0}; | ||
| }; | ||
|
|
||
| protected: | ||
| using XYZPoint = ROOT::Math::XYZPoint; | ||
| using HitPtr = std::unique_ptr<AtHit>; | ||
|
|
@@ -44,6 +54,12 @@ class AtTrack : public TObject { | |
| std::pair<Double_t, Double_t> fGeoCenter; //< Center of the spiral track | ||
| std::vector<AtHitCluster> fHitClusterArray; //< Clusterized hits container. Can also be stored in fHitArray | ||
|
|
||
| // Obtained in AtPatternModification | ||
| // Vector of pair of values for the Bragg curve of the track (archLength[mm], eLoss[a.u.]). | ||
| std::vector<std::pair<Double_t, Double_t>> fBraggCurveValues; | ||
| // Container for the Bragg curve integrated over the binning. | ||
| BraggCurve fBraggCurve; | ||
|
Comment on lines
+57
to
+61
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then these exist only in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, maybe makes sense. AtPatternEvent should still work with these I guess.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same response as above comment. |
||
|
|
||
| public: | ||
| AtTrack() = default; | ||
| AtTrack(const AtTrack &obj); | ||
|
|
@@ -72,6 +88,9 @@ class AtTrack : public TObject { | |
| swap(a.fGeoPhiAngle, b.fGeoPhiAngle); | ||
| swap(a.fGeoRadius, b.fGeoRadius); | ||
| swap(a.fGeoCenter, b.fGeoCenter); | ||
|
|
||
| swap(a.fBraggCurveValues, b.fBraggCurveValues); | ||
| swap(a.fBraggCurve, b.fBraggCurve); | ||
| }; | ||
|
|
||
| // Getters | ||
|
|
@@ -89,6 +108,9 @@ class AtTrack : public TObject { | |
| std::pair<Double_t, Double_t> GetGeoCenter() const { return fGeoCenter; } | ||
| std::vector<AtHitCluster> *GetHitClusterArray() { return &fHitClusterArray; } | ||
|
|
||
| std::vector<std::pair<Double_t, Double_t>> GetBraggCurveValues() const { return fBraggCurveValues; } | ||
| BraggCurve GetBraggCurve() const { return fBraggCurve; } | ||
|
|
||
| Bool_t GetIsMerged() const { return fIsMerged; } | ||
| Double_t GetVertexToZDist() const { return fVertexToZDist; } | ||
|
|
||
|
|
@@ -104,6 +126,9 @@ class AtTrack : public TObject { | |
| void SetGeoCenter(std::pair<Double_t, Double_t> center) { fGeoCenter = center; } | ||
| void AddClusterHit(std::shared_ptr<AtHitCluster> hitCluster); | ||
|
|
||
| void AddBraggCurvePair(Double_t range, Double_t eLoss) { fBraggCurveValues.push_back(std::make_pair(range, eLoss)); } | ||
| void SetBraggCurve(BraggCurve braggCurve) { fBraggCurve = braggCurve; } | ||
|
|
||
| void SetIsMerged(bool val) { fIsMerged = val; } | ||
| void SetVertexToZDist(Double_t val) { fVertexToZDist = val; } | ||
|
|
||
|
|
@@ -139,7 +164,7 @@ class AtTrack : public TObject { | |
| return o; | ||
| } | ||
|
|
||
| ClassDef(AtTrack, 3); | ||
| ClassDef(AtTrack, 4); | ||
| }; | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| #include "AtTabBraggCurve.h" | ||
|
|
||
| #include "AtPattern.h" // for AtPattern | ||
| #include "AtPatternEvent.h" | ||
| #include "AtTabInfo.h" // for AtTabInfoFairRoot, AtTabInfo | ||
| #include "AtTrack.h" // for AtTrack | ||
|
|
||
| #include <FairLogger.h> // for LOG | ||
|
|
||
| #include <TAttMarker.h> // for TAttMarker | ||
| #include <TCanvas.h> | ||
| #include <TEveBrowser.h> | ||
| #include <TEveElement.h> // for TEveElement | ||
| #include <TEveEventManager.h> // for TEveEventManager | ||
| #include <TEveGeoNode.h> | ||
| #include <TEveManager.h> // for TEveManager, gEve | ||
| #include <TEvePointSet.h> // for TEvePointSet | ||
| #include <TEveViewer.h> | ||
| #include <TEveWindow.h> | ||
| #include <TGLViewer.h> | ||
| #include <TGTab.h> | ||
| #include <TGeoManager.h> | ||
| #include <TRootEmbeddedCanvas.h> | ||
|
|
||
| #include <array> // for array | ||
| #include <utility> // for move | ||
| namespace DataHandling { | ||
| class AtSubject; | ||
| } | ||
|
|
||
| ClassImp(AtTabBraggCurve); | ||
|
|
||
| AtTabBraggCurve::AtTabBraggCurve() : AtTabMain() {} | ||
|
|
||
| AtTabBraggCurve::~AtTabBraggCurve() | ||
| { | ||
|
RealAurio marked this conversation as resolved.
|
||
| delete fHistELossVRange; | ||
| delete fCvsELossVRange; | ||
| } | ||
|
|
||
| void AtTabBraggCurve::Update(DataHandling::AtSubject *sub) | ||
| { | ||
| // If we should update the stuff that depends on the AtEvent | ||
| if (sub == fEventBranch || sub == fEntry) { | ||
| UpdateEventElements(); | ||
| } | ||
| if (sub == fPatternEventBranch || sub == fEntry) { | ||
| UpdatePatternEventElements(); | ||
| } | ||
|
|
||
| // If we should update the 3D display | ||
| if (sub == fEventBranch || sub == fPatternEventBranch || sub == fEntry) { | ||
| gEve->Redraw3D(false); // false -> don't reset camera | ||
| } | ||
| } | ||
|
|
||
| void AtTabBraggCurve::MakeTab(TEveWindowSlot *slot) | ||
| { | ||
| TEveWindowPack *pack = nullptr; | ||
|
|
||
| // 3D | ||
| pack = slot->MakePack(); | ||
| pack->SetElementName("BraggCurve"); | ||
| pack->SetHorizontal(); | ||
| pack->SetShowTitleBar(kFALSE); | ||
|
|
||
| pack->NewSlot()->MakeCurrent(); | ||
| TEveViewer *view3D = gEve->SpawnNewViewer("3D View", ""); | ||
| view3D->AddScene(gEve->GetGlobalScene()); | ||
| view3D->AddScene(gEve->GetEventScene()); | ||
|
|
||
| slot = pack->NewSlot(); | ||
| TEveWindowPack *pack2 = slot->MakePack(); | ||
| pack2->SetShowTitleBar(kFALSE); | ||
| pack2->SetVertical(); | ||
| slot = pack2->NewSlot(); | ||
| slot->StartEmbedding(); | ||
| // fCvsDeDx = new TCanvas("dEdx Bragg curve Canvas"); | ||
| // fCvsDeDx->ToggleEditor(); | ||
| slot->StopEmbedding(); | ||
|
|
||
| slot = pack2->NewSlotWithWeight(1.5); | ||
| auto *ecvs = new TRootEmbeddedCanvas(); | ||
| TEveWindowFrame *frame = slot->MakeFrame(ecvs); | ||
| frame->SetElementName("Bragg curve Canvas"); | ||
| pack->GetEveFrame()->SetShowTitleBar(kFALSE); | ||
| fCvsELossVRange = ecvs->GetCanvas(); | ||
| // fCvsELossVRange->AddExec("ex", "AtTab3DBraggCurve::NextTrack()"); | ||
|
|
||
| fCvsELossVRange->ToggleEventStatus(); | ||
| DrawHistELossVRange(); | ||
|
|
||
| if (gGeoManager) { | ||
| TGeoNode *geoNode = gGeoManager->GetTopNode(); | ||
| Int_t option = 1; | ||
| Int_t level = 3; | ||
| Int_t nNodes = 10000; | ||
| auto *topNode = new TEveGeoTopNode(gGeoManager, geoNode, option, level, nNodes); | ||
| gEve->AddGlobalElement(topNode); | ||
|
|
||
| Int_t transparency = 80; | ||
| gGeoManager->GetVolume("drift_volume")->SetTransparency(transparency); | ||
| gEve->FullRedraw3D(kTRUE); | ||
| } | ||
|
|
||
| gEve->GetBrowser()->GetTabRight()->SetTab(1); | ||
|
|
||
| gEve->Redraw3D(true, true); | ||
|
|
||
| TGLViewer *dfViewer = gEve->GetDefaultGLViewer(); // Is this doing anything? | ||
| dfViewer->CurrentCamera().RotateRad(-.7, 0.5); | ||
| dfViewer->DoDraw(); | ||
| UpdateRenderState(); | ||
| } | ||
|
|
||
| void AtTabBraggCurve::DrawHistELossVRange() | ||
| { | ||
| AtTrack::BraggCurve braggCurve; | ||
| braggCurve.nBins = 1000; | ||
| braggCurve.binSize = 1; | ||
| DrawHistELossVRange(braggCurve); | ||
| } | ||
|
|
||
| void AtTabBraggCurve::DrawHistELossVRange(AtTrack::BraggCurve braggCurve) | ||
| { | ||
| if (fHistELossVRange != nullptr) | ||
| fCvsELossVRange->GetListOfPrimitives()->Remove(fHistELossVRange); | ||
|
|
||
| int nBins = braggCurve.nBins; | ||
| double binSize = braggCurve.binSize; | ||
|
|
||
| fHistELossVRange = new TH1F("Charge vs Range", "Charge vs Range", nBins, 0, nBins * binSize); | ||
| fHistELossVRange->SetDirectory(0); | ||
| fCvsELossVRange->cd(); | ||
| fHistELossVRange->Draw(); | ||
| fHistELossVRange->GetXaxis()->SetTitle("Range [mm]"); | ||
| fHistELossVRange->GetYaxis()->SetTitle("Charge [ADC]"); | ||
|
|
||
| for (int i = 0; i < braggCurve.IntegratedELossValues.size(); i++) { | ||
| fHistELossVRange->SetBinContent(i + 1, braggCurve.IntegratedELossValues[i]); | ||
| fHistELossVRange->SetBinError(i + 1, braggCurve.ELossErrors[i]); | ||
| } | ||
|
|
||
| fCvsELossVRange->Modified(); | ||
| fCvsELossVRange->Update(); | ||
| } | ||
|
|
||
| void AtTabBraggCurve::UpdatePatternEventElements() | ||
| { | ||
| AtTabMain::UpdatePatternEventElements(); | ||
|
|
||
| auto fPatternEvent = GetFairRootInfo<AtPatternEvent>(); | ||
| if (fPatternEvent == nullptr) { | ||
| LOG(debug) << "Cannot update AtPatternEvent elements: no event available"; | ||
| return; | ||
| } | ||
|
|
||
| auto &tracks = fPatternEvent->GetTrackCand(); | ||
| if (tracks.size()) { | ||
| fTrackIdx = 0; | ||
| DrawHistELossVRange(tracks[fTrackIdx].GetBraggCurve()); | ||
| } else { | ||
| fTrackIdx = -1; | ||
| DrawHistELossVRange(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #ifndef ATTABBRAGGCURVE_H | ||
| #define ATTABBRAGGCURVE_H | ||
|
|
||
| #include "AtTabMain.h" // for AtTabMain::TEvePointSetPtr, AtTa... | ||
| #include "AtTrack.h" | ||
| #include "AtViewerManagerSubject.h" // for AtBranch | ||
|
|
||
| #include <Rtypes.h> // for THashConsistencyHolder, ClassDef... | ||
| #include <TEveEventManager.h> // for TEveEventManager | ||
| #include <TEvePointSet.h> // for TEvePointSet | ||
| #include <TH1F.h> | ||
|
|
||
| #include <array> // for array | ||
| #include <memory> // for make_unique | ||
| class TBuffer; // lines 21-21 | ||
| class TClass; // lines 23-23 | ||
| class TMemberInspector; // lines 27-27 | ||
| namespace DataHandling { | ||
| class AtSubject; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Tab for visualizing the Bragg curves of an AtTrack | ||
| */ | ||
| class AtTabBraggCurve : public AtTabMain { | ||
| protected: | ||
| TCanvas *fCvsELossVRange{nullptr}; | ||
| TH1F *fHistELossVRange{nullptr}; | ||
|
|
||
| int fTrackIdx{-1}; | ||
|
|
||
| public: | ||
| AtTabBraggCurve(); | ||
| virtual ~AtTabBraggCurve(); | ||
|
|
||
| virtual void Update(DataHandling::AtSubject *sub) override; | ||
|
|
||
| protected: | ||
| virtual void MakeTab(TEveWindowSlot *slot) override; | ||
|
|
||
| void DrawHistELossVRange(); | ||
| void DrawHistELossVRange(AtTrack::BraggCurve braggCurve); | ||
|
|
||
| virtual void UpdatePatternEventElements() override; | ||
|
|
||
| private: | ||
| ClassDefOverride(AtTabBraggCurve, 1); | ||
| }; | ||
| #endif |
Uh oh!
There was an error while loading. Please reload this page.