REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestTrackViewerProcess.cxx
1 /*************************************************************************
2  * This file is part of the REST software framework. *
3  * *
4  * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5  * For more information see http://gifna.unizar.es/trex *
6  * *
7  * REST is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * REST is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have a copy of the GNU General Public License along with *
18  * REST in $REST_PATH/LICENSE. *
19  * If not, see http://www.gnu.org/licenses/. *
20  * For the list of contributors see $REST_PATH/CREDITS. *
21  *************************************************************************/
22 
52 #include "TRestTrackViewerProcess.h"
53 
54 #include "TRestTrackLineAnalysisProcess.h"
55 
56 ClassImp(TRestTrackViewerProcess);
57 
62 
67 
73  SetSectionName(this->ClassName());
74  SetLibraryVersion(LIBRARY_VERSION);
75 
76  fTrackEvent = nullptr;
77  fSingleThreadOnly = true;
78 }
79 
85  CreateCanvas();
86  if (!hCanvas && fDrawHits)
87  hCanvas = new TCanvas("hitsCanvas", "hitsCanvas", fCanvasSize.X(), fCanvasSize.Y());
88 }
89 
94  // no need for verbose copy now
95  fTrackEvent = (TRestTrackEvent*)inputEvent;
96 
97  fCanvas->cd();
98  TPad* pad = fTrackEvent->DrawEvent();
99  if (fDrawOriginEnd) {
100  fTrackEvent->GetOriginEnd(originGr, endGr, legOrEnd);
101  fTrackEvent->DrawOriginEnd(pad, originGr, endGr, legOrEnd);
102  }
103 
104  fCanvas->cd();
105  pad->Draw();
106  fCanvas->Update();
107 
108  if (!fDrawHits) return fTrackEvent;
109 
110  hCanvas->cd();
111  TPad* hPad = fTrackEvent->DrawHits();
112  if (fDrawOriginEnd) {
113  fTrackEvent->DrawOriginEnd(hPad, originGr, endGr, legOrEnd);
114  }
115 
116  hCanvas->cd();
117  hPad->Draw();
118  hCanvas->Update();
119 
120  return fTrackEvent;
121 }
122 
TVector2 fCanvasSize
Canvas size.
TCanvas * fCanvas
< Canvas for some viewer event
void CreateCanvas()
Create the canvas.
A base class for any REST event.
Definition: TRestEvent.h:38
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
void SetSectionName(std::string sName)
set the section name, clear the section content
void GetOriginEnd(std::vector< TGraph * > &originGr, std::vector< TGraph * > &endGr, std::vector< TLegend * > &leg)
Retreive origin and end of the track and store in a TGraph and legend.
TPad * DrawEvent(const TString &option="")
Draw the event.
void DrawOriginEnd(TPad *pad, std::vector< TGraph * > &originGr, std::vector< TGraph * > &endGr, std::vector< TLegend * > &leg)
Draw origin and end of the track in a pad passed to the function Note that GetOriginEnd has to be iss...
A generic viewer REST process to visualize track events.
~TRestTrackViewerProcess()
Default destructor.
void Initialize() override
Function to initialize input/output event members and define the section name.
void InitProcess() override
Process initialization. It creates the canvas available in TRestEventProcess.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void EndProcess() override
Function to include required actions after all events have been processed.
TRestTrackViewerProcess()
Default constructor.