musrfit 1.10.0
PMusrT0.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PMusrT0.h
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
30#ifndef _PMUSRT0_H_
31#define _PMUSRT0_H_
32
33#include <memory>
34
35#include <TObject.h>
36#include <TQObject.h>
37#include <TStyle.h>
38#include <TRootCanvas.h>
39#include <TGMenu.h>
40#include <TCanvas.h>
41#include <TH1.h>
42#include <TLine.h>
43#include <TLatex.h>
44#include <TTimer.h>
45
46#include "PMusr.h"
47#ifndef __MAKECLING__
48#include "PMsrHandler.h"
49#endif // __MAKECLING__
50
51//--------------------------------------------------------------------------
52// Detector tags
53//--------------------------------------------------------------------------
54#define PMUSRT0_FORWARD 0
55#define PMUSRT0_BACKWARD 1
56
57//--------------------------------------------------------------------------
58// Command/mode tags
59//--------------------------------------------------------------------------
60#define PMUSRT0_GET_T0 0
61#define PMUSRT0_GET_DATA_AND_BKG_RANGE 1
62#define PMUSRT0_GET_T0_DATA_AND_BKG_RANGE 2
63
64
65//--------------------------------------------------------------------------
83 public:
87 virtual ~PMusrT0Data();
88
90 virtual void InitData();
91
93 virtual Bool_t IsSingleHisto() { return fSingleHisto; }
95 virtual UInt_t GetRawRunDataSize() { return fRawRunData.size(); }
97 virtual PRawRunData* GetRawRunData(Int_t idx);
99 virtual Int_t GetRunNo() { return fRunNo; }
101 virtual Int_t GetAddRunIdx() { return fAddRunIdx; }
103 virtual Int_t GetHistoNoIdx() { return fHistoNoIdx; }
105 virtual UInt_t GetHistoNoSize() { return fHistoNo.size(); }
107 virtual Int_t GetHistoNo(UInt_t idx);
109 virtual Int_t GetDetectorTag() { return fDetectorTag; }
111 virtual Int_t GetCmdTag() { return fCmdTag; }
113 virtual UInt_t GetT0BinSize() { return fT0.size(); }
115 virtual Int_t GetT0Bin(UInt_t idx);
117 virtual UInt_t GetAddT0Entries() { return fAddT0.size(); }
119 virtual UInt_t GetAddT0BinSize(UInt_t idx);
121 virtual Int_t GetAddT0Bin(UInt_t addRunIdx, UInt_t idx);
123 virtual Int_t GetT0BinData() { return fT0Data; }
124
126 virtual void SetSingleHisto(const Bool_t flag) { fSingleHisto = flag; }
128 virtual void SetRawRunData(const std::vector<PRawRunData*> rawRunData) { fRawRunData = rawRunData; }
130 virtual void SetRunNo(const UInt_t runNo) { fRunNo = runNo; }
132 virtual void SetAddRunIdx(const UInt_t addRunIdx) { fAddRunIdx = addRunIdx; }
134 virtual void SetHistoNoIdx(const UInt_t histoNoIdx) { fHistoNoIdx = histoNoIdx; }
136 virtual void SetHistoNo(const PIntVector histoNo) { fHistoNo = histoNo; }
138 virtual void SetDetectorTag(const UInt_t detectorTag) { fDetectorTag = detectorTag; }
140 virtual void SetCmdTag(const UInt_t cmdTag) { fCmdTag = cmdTag; }
142 virtual void SetT0Bin(UInt_t val, UInt_t idx);
144 virtual void SetAddT0Bin(UInt_t val, UInt_t addRunIdx, UInt_t idx);
146 virtual void SetT0BinData(UInt_t val) { fT0Data = val; }
147
148 private:
150 std::vector<PRawRunData*> fRawRunData;
151 Int_t fRunNo;
156 Int_t fCmdTag;
158 std::vector<PIntVector> fAddT0;
159 Int_t fT0Data;
160};
161
162
163//--------------------------------------------------------------------------
197class PMusrT0 : public TObject, public TQObject
198{
199 public:
206 PMusrT0(PMusrT0Data &data);
207
212 virtual Bool_t IsValid() { return fValid; }
213
218 virtual void Done(Int_t status=0); // *SIGNAL*
219
230 virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected); // SLOT
231
233 virtual void Quit(); // SLOT
234
241 virtual void SetTimeout(Int_t timeout);
242
243#ifndef __MAKECLING__
248 virtual void SetMsrHandler(PMsrHandler *msrHandler);
249#endif // __MAKECLING__
250
252 virtual void InitT0();
253
255 virtual void InitDataAndBkg();
256
261 virtual Int_t GetStatus() { return fStatus; }
262
263 private:
264#ifndef __MAKECLING__
266#endif // __MAKECLING__
267 Int_t fTimeout;
268
269 Bool_t fValid;
270
271 Int_t fStatus;
272
274
276 Bool_t fT0Enabled;
279
280 std::unique_ptr<TTimer> fTimeoutTimer;
281
282 // Canvas related variables
283 std::unique_ptr<TCanvas> fMainCanvas;
284
285 std::unique_ptr<TH1F> fHisto;
286 std::unique_ptr<TH1F> fData;
287 std::unique_ptr<TH1F> fBkg;
288
289 std::unique_ptr<TLatex> fToDoInfo;
290
291 std::unique_ptr<TLine> fT0Line;
292 std::unique_ptr<TLine> fT0DataLine;
293 std::unique_ptr<TLine> fFirstBkgLine;
294 std::unique_ptr<TLine> fLastBkgLine;
295 std::unique_ptr<TLine> fFirstDataLine;
296 std::unique_ptr<TLine> fLastDataLine;
297
298 Int_t fPx;
299 Int_t fPy;
300
301 Int_t fDataRange[2];
302 Int_t fBkgRange[2];
303
304 void ShowDataFileT0Channel();
305 void HideDataFileT0Channel();
306 void SetT0Channel();
307 void SetEstimatedT0Channel();
308 void SetDataFirstChannel();
309 void SetDataLastChannel();
310 void SetBkgFirstChannel();
311 void SetBkgLastChannel();
312 void UnZoom();
313 void ZoomT0();
314
315 ClassDef(PMusrT0, 1)
316};
317
318#endif // _PMUSRT0_H_
std::vector< Int_t > PIntVector
Definition PMusr.h:367
return status
MSR file parser and manager for the musrfit framework.
Data container for musrt0 raw run data and histogram information.
Definition PMusrT0.h:82
virtual Int_t GetHistoNo(UInt_t idx)
Returns histogram number at given index.
Definition PMusrT0.cpp:127
PIntVector fT0
t0 bin values for main run histograms
Definition PMusrT0.h:157
virtual Int_t GetAddT0Bin(UInt_t addRunIdx, UInt_t idx)
Returns t0 bin for specific addrun and histogram.
Definition PMusrT0.cpp:179
virtual Int_t GetHistoNoIdx()
Returns current histogram number index.
Definition PMusrT0.h:103
Int_t fHistoNoIdx
Current histogram number index.
Definition PMusrT0.h:153
virtual void SetT0BinData(UInt_t val)
Sets t0 bin value found from data file.
Definition PMusrT0.h:146
PMusrT0Data()
Default constructor.
Definition PMusrT0.cpp:51
virtual void InitData()
Initializes data structures (currently empty implementation)
Definition PMusrT0.cpp:84
std::vector< PRawRunData * > fRawRunData
Raw data: index 0 = main run, index >0 = addruns.
Definition PMusrT0.h:150
virtual Int_t GetRunNo()
Returns MSR file run number.
Definition PMusrT0.h:99
virtual void SetSingleHisto(const Bool_t flag)
Sets single histogram fit mode flag.
Definition PMusrT0.h:126
virtual UInt_t GetHistoNoSize()
Returns number of histogram numbers.
Definition PMusrT0.h:105
virtual void SetHistoNo(const PIntVector histoNo)
Sets vector of histogram numbers.
Definition PMusrT0.h:136
virtual void SetRawRunData(const std::vector< PRawRunData * > rawRunData)
Sets vector of raw run data pointers.
Definition PMusrT0.h:128
virtual Int_t GetT0Bin(UInt_t idx)
Returns t0 bin value at given index.
Definition PMusrT0.cpp:144
virtual UInt_t GetRawRunDataSize()
Returns number of raw run data entries (1 + number of addruns)
Definition PMusrT0.h:95
virtual void SetAddT0Bin(UInt_t val, UInt_t addRunIdx, UInt_t idx)
Sets t0 bin value for specific addrun and index.
Definition PMusrT0.cpp:221
virtual Int_t GetT0BinData()
Returns t0 bin found from data file.
Definition PMusrT0.h:123
virtual void SetHistoNoIdx(const UInt_t histoNoIdx)
Sets current histogram number index.
Definition PMusrT0.h:134
virtual ~PMusrT0Data()
Destructor.
Definition PMusrT0.cpp:65
std::vector< PIntVector > fAddT0
t0 bin values for addrun histograms
Definition PMusrT0.h:158
PIntVector fHistoNo
Histogram numbers (with Red/Green offset applied)
Definition PMusrT0.h:154
virtual void SetCmdTag(const UInt_t cmdTag)
Sets command/mode tag.
Definition PMusrT0.h:140
virtual UInt_t GetAddT0Entries()
Returns number of addrun entries with t0 values.
Definition PMusrT0.h:117
virtual UInt_t GetAddT0BinSize(UInt_t idx)
Returns number of t0 bins for given addrun.
Definition PMusrT0.cpp:161
virtual PRawRunData * GetRawRunData(Int_t idx)
Returns raw run data for given index (0=main run, >0=addruns)
Definition PMusrT0.cpp:110
Int_t fT0Data
t0 bin found in current data file
Definition PMusrT0.h:159
Int_t fRunNo
MSR file run block number.
Definition PMusrT0.h:151
Int_t fCmdTag
Mode: 0=t0 only, 1=ranges only, 2=both t0 and ranges.
Definition PMusrT0.h:156
virtual Int_t GetCmdTag()
Returns command tag (mode for t0/range determination)
Definition PMusrT0.h:111
virtual UInt_t GetT0BinSize()
Returns number of t0 bins for main run.
Definition PMusrT0.h:113
virtual void SetDetectorTag(const UInt_t detectorTag)
Sets detector tag (forward/backward)
Definition PMusrT0.h:138
virtual Int_t GetAddRunIdx()
Returns current addrun index.
Definition PMusrT0.h:101
virtual void SetRunNo(const UInt_t runNo)
Sets MSR file run number.
Definition PMusrT0.h:130
Int_t fAddRunIdx
Current addrun index being processed.
Definition PMusrT0.h:152
virtual void SetT0Bin(UInt_t val, UInt_t idx)
Sets t0 bin value at given index.
Definition PMusrT0.cpp:201
virtual Bool_t IsSingleHisto()
Returns true if single histogram fit mode.
Definition PMusrT0.h:93
virtual void SetAddRunIdx(const UInt_t addRunIdx)
Sets current addrun index.
Definition PMusrT0.h:132
Bool_t fSingleHisto
True for single histogram fit, false for asymmetry fit.
Definition PMusrT0.h:149
Int_t fDetectorTag
Detector: PMUSRT0_FORWARD (0) or PMUSRT0_BACKWARD (1)
Definition PMusrT0.h:155
virtual Int_t GetDetectorTag()
Returns detector tag (PMUSRT0_FORWARD or PMUSRT0_BACKWARD)
Definition PMusrT0.h:109
Int_t fTimeout
Timeout in ms after which Done signal is emitted (≤0 disables timeout)
Definition PMusrT0.h:267
std::unique_ptr< TLine > fLastBkgLine
Vertical line marking background end bin.
Definition PMusrT0.h:294
std::unique_ptr< TLine > fFirstDataLine
Vertical line marking first good data bin.
Definition PMusrT0.h:295
std::unique_ptr< TTimer > fTimeoutTimer
Timer to emit Done signal if no user interaction occurs.
Definition PMusrT0.h:280
void SetDataLastChannel()
Sets last good data bin to cursor position.
Definition PMusrT0.cpp:1024
PMusrT0Data fMusrT0Data
Container for raw μSR run data and histogram information.
Definition PMusrT0.h:273
std::unique_ptr< TLine > fT0Line
Vertical line marking current t0 position.
Definition PMusrT0.h:291
std::unique_ptr< TLatex > fToDoInfo
Text display showing current instructions to user.
Definition PMusrT0.h:289
Bool_t fValid
True if raw data sets are available and GUI is functional.
Definition PMusrT0.h:269
void UnZoom()
Resets zoom to show full histogram range.
Definition PMusrT0.cpp:1173
PMusrT0()
Default constructor (creates invalid instance)
void HideDataFileT0Channel()
Hides vertical line showing t0 from data file.
Definition PMusrT0.cpp:864
virtual Bool_t IsValid()
Returns validity status of the PMusrT0 instance.
Definition PMusrT0.h:212
void SetBkgLastChannel()
Sets background end bin to cursor position.
Definition PMusrT0.cpp:1124
void SetEstimatedT0Channel()
Sets t0 to estimated value and updates display.
Definition PMusrT0.cpp:930
Bool_t fShowT0DataChannel
Flag to show/hide t0 value from data file.
Definition PMusrT0.h:278
virtual void SetMsrHandler(PMsrHandler *msrHandler)
Sets the MSR file handler for accessing run configuration.
Definition PMusrT0.cpp:675
std::unique_ptr< TLine > fLastDataLine
Vertical line marking last good data bin.
Definition PMusrT0.h:296
virtual void InitT0()
Initializes GUI for interactive t0 determination.
Definition PMusrT0.cpp:691
virtual void InitDataAndBkg()
Initializes GUI for interactive data and background range determination.
Definition PMusrT0.cpp:739
void SetT0Channel()
Sets t0 to cursor position and updates display.
Definition PMusrT0.cpp:882
virtual void Done(Int_t status=0)
Emits signal indicating completion of t0/range determination.
Definition PMusrT0.cpp:551
Bool_t fDataAndBkgEnabled
Enable/disable data and background range handling (required for grouping/addrun)
Definition PMusrT0.h:275
Int_t fDataRange[2]
Data range in bins: [0]=first good bin, [1]=last good bin.
Definition PMusrT0.h:301
Int_t fPx
Current cursor x-position in pixel coordinates.
Definition PMusrT0.h:298
void ShowDataFileT0Channel()
Displays vertical line showing t0 from data file.
Definition PMusrT0.cpp:838
Int_t fPy
Current cursor y-position in pixel coordinates.
Definition PMusrT0.h:299
std::unique_ptr< TH1F > fHisto
Full raw data histogram (all bins)
Definition PMusrT0.h:285
PMsrHandler * fMsrHandler
MSR file handler for accessing run configuration.
Definition PMusrT0.h:265
Int_t fBkgRange[2]
Background range in bins: [0]=first bkg bin, [1]=last bkg bin.
Definition PMusrT0.h:302
std::unique_ptr< TLine > fFirstBkgLine
Vertical line marking background start bin.
Definition PMusrT0.h:293
void SetBkgFirstChannel()
Sets background start bin to cursor position.
Definition PMusrT0.cpp:1074
Int_t fStatus
Exit status: 0=local quit (single canvas), 1=quit application.
Definition PMusrT0.h:271
std::unique_ptr< TLine > fT0DataLine
Vertical line marking t0 found in data file.
Definition PMusrT0.h:292
std::unique_ptr< TH1F > fBkg
Background region histogram (background start to end)
Definition PMusrT0.h:287
Bool_t fT0Enabled
Enable/disable t0 handling (required for grouping/addrun)
Definition PMusrT0.h:276
Int_t fT0Estimated
Estimated t0 value in bins (used as initial guess)
Definition PMusrT0.h:277
virtual Int_t GetStatus()
Returns current exit status.
Definition PMusrT0.h:261
std::unique_ptr< TH1F > fData
Data region histogram (first good bin to last good bin)
Definition PMusrT0.h:286
virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
Handles keyboard input for interactive t0 and range selection.
Definition PMusrT0.cpp:584
void SetDataFirstChannel()
Sets first good data bin to cursor position.
Definition PMusrT0.cpp:974
void ZoomT0()
Zooms to region around t0 for precise adjustment.
Definition PMusrT0.cpp:1192
virtual void SetTimeout(Int_t timeout)
Sets automatic timeout for the interactive session.
Definition PMusrT0.cpp:650
virtual void Quit()
Quit slot that emits Done signal to close the current canvas.
Definition PMusrT0.cpp:633
std::unique_ptr< TCanvas > fMainCanvas
Main ROOT canvas for the interactive GUI.
Definition PMusrT0.h:283
static int timeout
Definition musrfit.cpp:71