ATLAS Offline Software
Loading...
Searching...
No Matches
LArSamples::DataTweaker Class Reference

#include <DataTweaker.h>

Collaboration diagram for LArSamples::DataTweaker:

Public Member Functions

 DataTweaker ()=default
bool set (const TString &tweaks)
bool findOption (TString &tweaks, const TString &option) const
Datatweak (const Data &data, int evtIndex=-1) const
EventDatatweak (const EventData &eventData, int runIndex=-1) const
void setNSamplesTrunctation (unsigned int n)
void addSample (unsigned int n)
void setRemoveNoiseCorrelations (bool remove=true)
void setRefit (bool refit=true)
void setFitParams (Chi2Params params)
void setAdjust (bool adjust=true)
void setRemoveRoIs (bool removeRoIs=true)

Private Attributes

unsigned int m_nSamplesTruncation {0}
bool m_removeNoiseCorrelations {false}
bool m_refit {false}
bool m_adjust {false}
bool m_removeRoIs {false}
std::map< unsigned int, bool > m_samples
Chi2Params m_fitParams {DefaultChi2}

Detailed Description

Definition at line 24 of file DataTweaker.h.

Constructor & Destructor Documentation

◆ DataTweaker()

LArSamples::DataTweaker::DataTweaker ( )
default

Member Function Documentation

◆ addSample()

void LArSamples::DataTweaker::addSample ( unsigned int n)
inline

Definition at line 37 of file DataTweaker.h.

37{ m_samples[n] = true; }
std::map< unsigned int, bool > m_samples
Definition DataTweaker.h:48

◆ findOption()

bool DataTweaker::findOption ( TString & tweaks,
const TString & option ) const

Definition at line 38 of file DataTweaker.cxx.

39{
40 int i = tweaks.Index(option);
41 if (i < 0) return false;
42 tweaks = tweaks(0, i) + tweaks(i + option.Length(), tweaks.Length() - i - option.Length());
43 return true;
44}

◆ set()

bool DataTweaker::set ( const TString & tweaks)

Definition at line 23 of file DataTweaker.cxx.

24{
25 TString toMod = tweaks;
26
27 if (findOption(toMod, "removeNoiseCorrelations")) { m_removeNoiseCorrelations = true; cout << "--> removeNoiseCorrelations" << endl; }
28 if (findOption(toMod, "refit")) { m_refit = true; cout << "--> refit" << endl; }
29 if (findOption(toMod, "adjust")) { m_adjust = true; cout << "--> adjust" << endl; }
30 if (findOption(toMod, "removeRoIs")) { m_removeRoIs = true; cout << "--> removeRoIs" << endl; }
31
32 if (toMod == "") return true;
33 cout << "Invalid tweaker option(s) " << toMod << endl;
34 return false;
35}
bool findOption(TString &tweaks, const TString &option) const

◆ setAdjust()

void LArSamples::DataTweaker::setAdjust ( bool adjust = true)
inline

Definition at line 41 of file DataTweaker.h.

◆ setFitParams()

void LArSamples::DataTweaker::setFitParams ( Chi2Params params)
inline

◆ setNSamplesTrunctation()

void LArSamples::DataTweaker::setNSamplesTrunctation ( unsigned int n)
inline

Definition at line 36 of file DataTweaker.h.

unsigned int m_nSamplesTruncation
Definition DataTweaker.h:46

◆ setRefit()

void LArSamples::DataTweaker::setRefit ( bool refit = true)
inline

Definition at line 39 of file DataTweaker.h.

39{ m_refit = refit; }

◆ setRemoveNoiseCorrelations()

void LArSamples::DataTweaker::setRemoveNoiseCorrelations ( bool remove = true)
inline

◆ setRemoveRoIs()

void LArSamples::DataTweaker::setRemoveRoIs ( bool removeRoIs = true)
inline

Definition at line 42 of file DataTweaker.h.

42{ m_removeRoIs = removeRoIs; }

◆ tweak() [1/2]

Data * DataTweaker::tweak ( const Data & data,
int evtIndex = -1 ) const

Definition at line 47 of file DataTweaker.cxx.

48{
49 std::vector<short> samples = data.container().samples();
50 std::vector<float> corrs = data.container().corrs();
51 float time = data.container().ofcTime();
52 double k = 1, deltaT = 0;
53
55 for (unsigned int i = 1; i < corrs.size(); i++) corrs[i] = 0;
56
57 if (m_nSamplesTruncation > 0) {
58 unsigned int maxIndex = data.maxPosition();
59
60 int i1 = maxIndex - (m_nSamplesTruncation - 1)/2;
61 if (i1 < 0) i1 = 0;
62
63 int i2 = maxIndex + m_nSamplesTruncation/2 + 1;
64 if (i2 > (int)data.nSamples()) i2 = (int)data.nSamples();
65 samples.clear();
66 for (int i = i1; i < i2; i++) samples.push_back(data.sample(i));
67 corrs.resize(i2 - i1);
68 time = time - data.time(i1);
69 }
70
71 if (!m_samples.empty()) {
72 std::vector<short> oldSamples = samples;
73 samples.clear();
74 for (std::map<unsigned int, bool>::const_iterator i = m_samples.begin();
75 i != m_samples.end(); ++i)
76 {
77 samples.push_back(oldSamples[i->first]);
78 if (i == m_samples.begin()) time = time - data.time(i->first);
79 }
80 }
81
82 if (m_refit) {
83 SimpleShape* reference = data.referenceShape();
84 const ScaledErrorData* sed = data.scaledErrorData();
85 ShapeFitter fitter(m_fitParams);
86 double chi2{};
87 if (!reference){
88 delete sed;
89 return nullptr;
90 }
91 bool result = fitter.fit(data, *reference, k, deltaT, chi2, sed);
92 delete sed;
93 if (!result) return nullptr;
94 }
95
96 if (m_adjust) {
97 if (!data.history() || data.adcMax() == 0) return nullptr;
98 OFC* ofc = data.history()->ofc(data.index());
99 if (!ofc) return nullptr;
100 k = ofc->A(data)/data.adcMax();
101 deltaT = ofc->time(data);
102 }
103
104 if (evtIndex < 0) evtIndex = data.container().eventIndex();
105
106 DataContainer* newContainer = new DataContainer(data.container().gain(), samples, corrs,
107 evtIndex,
108 data.container().energy(), time + deltaT, data.container().quality(),
109 data.container().pedestal(), data.container().pedestalRMS(),
110 data.container().status(), k*data.container().adcMax());
111 Data* newData = new Data(*newContainer, *data.eventData(), data.history(), data.index(), true);
112 return newData;
113}
@ Data
Definition BaseObject.h:11
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
bool fit(const LArSamples::AbsShape &data, const AbsShape &reference, double &k, double &deltaT, double &chi2, const ScaledErrorData *sed=0) const
double chi2(TH1 *h0, TH1 *h1)
time(flags, cells_name, *args, **kw)
const ShapeFitter * fitter
const ScaledErrorData * sed

◆ tweak() [2/2]

EventData * DataTweaker::tweak ( const EventData & eventData,
int runIndex = -1 ) const

Definition at line 116 of file DataTweaker.cxx.

117{
118 EventData* newEventData = new EventData(eventData, runIndex);
119 if (m_removeRoIs) newEventData->removeRoIs();
120 return newEventData;
121}

Member Data Documentation

◆ m_adjust

bool LArSamples::DataTweaker::m_adjust {false}
private

Definition at line 47 of file DataTweaker.h.

47{false}, m_refit{false}, m_adjust{false}, m_removeRoIs{false};

◆ m_fitParams

Chi2Params LArSamples::DataTweaker::m_fitParams {DefaultChi2}
private

Definition at line 49 of file DataTweaker.h.

@ DefaultChi2
Definition Chi2Calc.h:24

◆ m_nSamplesTruncation

unsigned int LArSamples::DataTweaker::m_nSamplesTruncation {0}
private

Definition at line 46 of file DataTweaker.h.

46{0};

◆ m_refit

bool LArSamples::DataTweaker::m_refit {false}
private

Definition at line 47 of file DataTweaker.h.

47{false}, m_refit{false}, m_adjust{false}, m_removeRoIs{false};

◆ m_removeNoiseCorrelations

bool LArSamples::DataTweaker::m_removeNoiseCorrelations {false}
private

Definition at line 47 of file DataTweaker.h.

47{false}, m_refit{false}, m_adjust{false}, m_removeRoIs{false};

◆ m_removeRoIs

bool LArSamples::DataTweaker::m_removeRoIs {false}
private

Definition at line 47 of file DataTweaker.h.

47{false}, m_refit{false}, m_adjust{false}, m_removeRoIs{false};

◆ m_samples

std::map<unsigned int, bool> LArSamples::DataTweaker::m_samples
private

Definition at line 48 of file DataTweaker.h.


The documentation for this class was generated from the following files: