Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions apps/TrappingCorrection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ using namespace ROOT::Minuit2;
#include "MModuleEventFilter.h"
#include "MModuleStripPairingChiSquare.h"
#include "MModuleStripPairingMultiRoundChiSquare.h"
#include "MModuleTACcut.h"
#include "MModuleTACCalibration.h"
#include "MAssembly.h"


Expand Down Expand Up @@ -153,7 +153,6 @@ class TrappingCorrection
MString m_FileName;
MString m_EcalFile;
MString m_TACCalFile;
MString m_TACCutFile;
MString m_StripMapFile;
//! output file names
MString m_OutFile;
Expand Down Expand Up @@ -277,7 +276,6 @@ bool TrappingCorrection::ParseCommandLine(int argc, char** argv)
Usage<<" --emax: maximum Event energy (default 5000 kev)"<<endl;
Usage<<" -e: energy calibration file (.ecal)"<<endl;
Usage<<" --tcal: TAC calibration file"<<endl;
Usage<<" --tcut: TAC cut file"<<endl;
Usage<<" -p: do pixel-by-pixel correction"<<endl;
Usage<<" -m: strip map file name (.map)"<<endl;
Usage<<" -mr: multi-round chi sqaure strip pairing (default is chi-square)"<<endl;
Expand Down Expand Up @@ -319,7 +317,7 @@ bool TrappingCorrection::ParseCommandLine(int argc, char** argv)

// First check if each option has sufficient arguments:
// Single argument
if ((Option == "-i") || (Option == "-o") || (Option == "--emin") || (Option == "--emax") || (Option == "--tcal") || (Option == "--tcut") || (Option == "-m")) {
if ((Option == "-i") || (Option == "-o") || (Option == "--emin") || (Option == "--emax") || (Option == "--tcal") || (Option == "-m")) {
if (!((argc > i+1) && (argv[i+1][0] != '-' || isalpha(argv[i+1][1]) == 0))){
cout<<"Error: Option "<<argv[i][1]<<" needs a second argument!"<<endl;
cout<<Usage.str()<<endl;
Expand Down Expand Up @@ -351,11 +349,6 @@ bool TrappingCorrection::ParseCommandLine(int argc, char** argv)
cout<<"Accepting file name: "<<m_TACCalFile<<endl;
}

if (Option == "--tcut") {
m_TACCutFile = argv[++i];
cout<<"Accepting file name: "<<m_TACCutFile<<endl;
}

if (Option == "-o"){
m_OutFile = argv[++i];
cout<<"Accepting file name: "<<m_OutFile<<endl;
Expand Down Expand Up @@ -426,7 +419,7 @@ bool TrappingCorrection::Analyze()
MSupervisor* S = MSupervisor::GetSupervisor();

MModuleLoaderMeasurementsHDF* Loader;
MModuleTACcut* TACCalibrator;
MModuleTACCalibration* TACCalibrator;
MModuleEnergyCalibration* EnergyCalibrator;
MModuleEventFilter* EventFilter;

Expand All @@ -445,9 +438,8 @@ bool TrappingCorrection::Analyze()
++MNumber;

cout<<"Creating TAC calibrator"<<endl;
TACCalibrator = new MModuleTACcut();
TACCalibrator = new MModuleTACCalibration();
TACCalibrator->SetTACCalFileName(m_TACCalFile);
TACCalibrator->SetTACCutFileName(m_TACCutFile);
S->SetModule(TACCalibrator, MNumber);
++MNumber;

Expand Down
14 changes: 4 additions & 10 deletions apps/TrappingCorrectionAm241.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ using namespace std;
#include "MModuleEventFilter.h"
#include "MModuleStripPairingChiSquare.h"
#include "MModuleStripPairingMultiRoundChiSquare.h"
#include "MModuleTACcut.h"
#include "MModuleTACCalibration.h"
#include "MAssembly.h"


Expand Down Expand Up @@ -106,7 +106,6 @@ class TrappingCorrectionAm241
MString m_LVFileName;
MString m_EcalFile;
MString m_TACCalFile;
MString m_TACCutFile;
MString m_StripMapFile;
//! output file names
MString m_OutFile;
Expand Down Expand Up @@ -159,7 +158,6 @@ bool TrappingCorrectionAm241::ParseCommandLine(int argc, char** argv)
Usage<<" --emax: maximum Event energy (default 70 kev)"<<endl;
Usage<<" -e: energy calibration file (.ecal)"<<endl;
Usage<<" --tcal: TAC calibration file"<<endl;
Usage<<" --tcut: TAC cut file"<<endl;
Usage<<" -p: do pixel-by-pixel correction"<<endl;
Usage<<" -m: strip map file name (.map)"<<endl;
Usage<<" -mr: multi-round chi square strip pairing (default is chi-square)"<<endl;
Expand Down Expand Up @@ -227,9 +225,6 @@ bool TrappingCorrectionAm241::ParseCommandLine(int argc, char** argv)
} else if (Option == "--tcal") {
m_TACCalFile = argv[++i];
cout<<"Accepting file name: "<<m_TACCalFile<<endl;
} else if (Option == "--tcut") {
m_TACCutFile = argv[++i];
cout<<"Accepting file name: "<<m_TACCutFile<<endl;
} else if (Option == "-m") {
m_StripMapFile = argv[++i];
cout<<"Accepting file name: "<<m_StripMapFile<<endl;
Expand Down Expand Up @@ -350,7 +345,7 @@ bool TrappingCorrectionAm241::Analyze()
MSupervisor* S = MSupervisor::GetSupervisor();

MModuleLoaderMeasurementsHDF* Loader;
MModuleTACcut* TACCalibrator;
MModuleTACCalibration* TACCalibrator;
MModuleEnergyCalibration* EnergyCalibrator;
MModuleEventFilter* EventFilter;

Expand All @@ -364,12 +359,11 @@ bool TrappingCorrectionAm241::Analyze()
++MNumber;

cout<<"Creating TAC calibrator"<<endl;
TACCalibrator = new MModuleTACcut();
TACCalibrator = new MModuleTACCalibration();
TACCalibrator->SetTACCalFileName(m_TACCalFile);
TACCalibrator->SetTACCutFileName(m_TACCutFile);
S->SetModule(TACCalibrator, MNumber);
++MNumber;

cout<<"Creating energy calibrator"<<endl;
EnergyCalibrator = new MModuleEnergyCalibration();
EnergyCalibrator->SetFileName(m_EcalFile);
Expand Down
4 changes: 2 additions & 2 deletions include/MAssembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class MAssembly
static const uint64_t c_EventLoaderMeasurement = (1 << 2); // = 4
static const uint64_t c_EventOrdering = (1 << 3); // = 8
static const uint64_t c_Coincidence = (1 << 4); // = 16
static const uint64_t c_TACcut = (1 << 5); // = 32
static const uint64_t c_NearestNeighbor = (1 << 6); // = 32
static const uint64_t c_TACCalibration = (1 << 5); // = 32
static const uint64_t c_NearestNeighbor = (1 << 6); // = 64
static const uint64_t c_DetectorEffectsEngine = (1 << 7);
static const uint64_t c_EventFilter = (1 << 8);
static const uint64_t c_EnergyCalibration = (1 << 9);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* MGUIOptionsTACcut.h
* MGUIOptionsTACCalibration.h
*
* Copyright (C) 2008-2010 by Jau-Shian Liang.
* All rights reserved.
Expand All @@ -9,8 +9,8 @@
*/


#ifndef __MGUIOptionsTACcut__
#define __MGUIOptionsTACcut__
#ifndef __MGUIOptionsTACCalibration__
#define __MGUIOptionsTACCalibration__


////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -43,28 +43,37 @@ class MGUIEEntry;
////////////////////////////////////////////////////////////////////////////////


class MGUIOptionsTACcut : public MGUIOptions
class MGUIOptionsTACCalibration : public MGUIOptions
{
// public Session:
public:
//! Default constructor
MGUIOptionsTACcut(MModule* Module);
MGUIOptionsTACCalibration(MModule* Module);
//! Default destructor
virtual ~MGUIOptionsTACcut();
virtual ~MGUIOptionsTACCalibration();

//! Process all button, etc. messages
virtual bool ProcessMessage(long Message, long Parameter1, long Parameter2);

//! The creation part which gets overwritten
virtual void Create();


// protected methods:
protected:

//! Actions after the Apply or OK button has been pressed
virtual bool OnApply();

//! Toggle TAC cut radio buttons and coincidence window entry
void ToggleRadioButtons(int WidgetID);

//! Widget IDs
enum {
c_TACCutIgnore = 120,
c_TACCutApply = 121
};

// protected members:
protected:
//! The detector IDs as a string
Expand All @@ -73,17 +82,22 @@ class MGUIOptionsTACcut : public MGUIOptions
//! Select TAC Calibration file to load, converts readout timing to nanoseconds
MGUIEFileSelector* m_TACCalFileSelector;

//! Select TAC Cut file to load, which specifies the parameters for removing strip hits
MGUIEFileSelector* m_TACCutFileSelector;
//! Do not apply TAC cuts
TGRadioButton* m_TACCutRBIgnore;

//! Apply TAC cuts
TGRadioButton* m_TACCutRBApply;

//! TAC coincidence window in ns
MGUIEEntry* m_CoincidenceWindow;

// private members:
private:


#ifdef ___CLING___
public:
ClassDef(MGUIOptionsTACcut, 1) // basic class for dialog windows
ClassDef(MGUIOptionsTACCalibration, 1) // basic class for dialog windows
#endif

};
Expand Down
82 changes: 43 additions & 39 deletions include/MModuleTACcut.h → include/MModuleTACCalibration.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* MModuleTACcut.h
* MModuleTACCalibration.h
*
* Copyright (C) by Andreas Zoglauer.
* All rights reserved.
Expand All @@ -9,90 +9,88 @@
*/


#ifndef __MModuleTACcut__
#define __MModuleTACcut__
#ifndef __MModuleTACCalibration__
#define __MModuleTACCalibration__


////////////////////////////////////////////////////////////////////////////////


// Standard libs:
#include <algorithm>

// ROOT libs:
#include "TGClient.h"
#include "TH1.h"

// MEGAlib libs:
#include "MGlobal.h"
#include "MModule.h"
#include "MGUIExpoTACcut.h"
#include "MGUIExpoPlotSpectrum.h"


// Forward declarations:
class MGUIExpoTACcut;
class MGUIExpoPlotSpectrum;


////////////////////////////////////////////////////////////////////////////////


class MModuleTACcut : public MModule
class MModuleTACCalibration : public MModule
{
// public interface:
public:
//! Default constructor
MModuleTACcut();
MModuleTACCalibration();
//! Default destructor
virtual ~MModuleTACcut();
virtual ~MModuleTACCalibration();

//! Create a new object of this class
virtual MModuleTACcut* Clone() { return new MModuleTACcut(); }
virtual MModuleTACCalibration* Clone() { return new MModuleTACCalibration(); }

//! Initialize the module
virtual bool Initialize();

//! Create expos
virtual void CreateExpos();

//! Finalize the module
virtual void Finalize();

//! Main data analysis routine, which updates the event to a new level
virtual bool AnalyzeEvent(MReadOutAssembly* Event);
//! Create Expos
virtual void CreateExpos();

//! Show the options GUI
virtual void ShowOptionsGUI();

//! Main data analysis routine, which updates the event to a new level
virtual bool AnalyzeEvent(MReadOutAssembly* Event);

//! Read the configuration data from an XML node
virtual bool ReadXmlConfiguration(MXmlNode* Node);

//! Create an XML node tree from the configuration
virtual MXmlNode* CreateXmlConfiguration();

///////////// Creating functions that will update and get the min/max TAC values //////////////////////////

//! Set filename for TAC calibration
void SetTACCalFileName( const MString& FileName) {m_TACCalFile = FileName;}
void SetTACCalFileName( const MString& FileName) { m_TACCalFile = FileName; }

//! Get filename for TAC calibration
MString GetTACCalFileName() const {return m_TACCalFile;}

//! Set filename for TAC cut
void SetTACCutFileName( const MString& FileName) {m_TACCutFile = FileName;}
//! Get filename for TAC cut
MString GetTACCutFileName() const {return m_TACCutFile;}

//! Load the TAC calibration file
bool LoadTACCalFile(MString FName);

//! Load the TAC cut file
bool LoadTACCutFile(MString FName);

//! Set the TAC calibration parameters
void SetTACCalParameters(unordered_map<int, vector<unordered_map<int, vector<double>>>> TACCal) { m_TACCal = TACCal; }

//! Get the TAC calibration parameters
unordered_map<int, vector<unordered_map<int, vector<double>>>> GetTACCalParameters() { return m_TACCal; }

//! Enable or disable TAC cuts
void SetApplyTACCuts(bool ApplyTACCuts) { m_ApplyTACCuts = ApplyTACCuts; }

//! Return whether TAC cuts are enabled
bool GetApplyTACCuts() const { return m_ApplyTACCuts; }

//! Set TAC coincidence window in ns
void SetCoincidenceWindow(double CoincidenceWindow) { m_CoincidenceWindow = CoincidenceWindow; }

//! Get TAC coincidence window in ns
double GetCoincidenceWindow() const { return m_CoincidenceWindow; }

Comment thread
NicoleRodriguezCavero marked this conversation as resolved.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Expand All @@ -104,6 +102,12 @@ class MModuleTACcut : public MModule
// private methods:
private:

//! Apply TAC calibration to strip hits
bool ApplyTACCal(MReadOutAssembly* Event);

//! Apply TAC cuts to calibrated strip hits
//! Assumes ApplyTACCal() has already been called for this event
bool ApplyTACCuts(MReadOutAssembly* Event);


// protected members:
Expand All @@ -115,29 +119,29 @@ class MModuleTACcut : public MModule
//! TAC calibration parameter file name
MString m_TACCalFile;

//! TAC cut parameter files
MString m_TACCutFile;

//! Map DetID -> Side (LV=0, HV=1) -> Strip ID -> TAC calibration parameters
unordered_map<int, vector<unordered_map<int, vector<double>>>> m_TACCal;

//! Map DetID -> Side (LV=0, HV=1) -> Strip ID -> TAC cut parameters
unordered_map<int, vector<unordered_map<int, vector<double>>>> m_TACCut;

//! Map characters representing sides of the detectors indices to avoid mistakes
//! Map characters representing detector sides to LV/HV indices
unordered_map<char, int> m_SideToIndex;

//! Vector of Detector IDs
vector<unsigned int> m_DetectorIDs;

MGUIExpoTACcut* m_ExpoTACcut;
//! TAC coincidence window in ns
double m_CoincidenceWindow;

//! Option to apply TAC cuts after TAC calibration
bool m_ApplyTACCuts;

//! TAC distribution and energy spectra
MGUIExpoTACcut* m_ExpoTACcut;
MGUIExpoPlotSpectrum* m_ExpoEnergySpectrum;


#ifdef ___CLING___
public:
ClassDef(MModuleTACcut, 0) // no description
ClassDef(MModuleTACCalibration, 0) // no description
#endif

};
Expand Down
Loading
Loading