ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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; }

◆ 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 }

◆ setAdjust()

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

Definition at line 41 of file DataTweaker.h.

41 { m_adjust = adjust; }

◆ setFitParams()

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

Definition at line 40 of file DataTweaker.h.

40 { m_fitParams = params; }

◆ setNSamplesTrunctation()

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

Definition at line 36 of file DataTweaker.h.

◆ 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

Definition at line 38 of file DataTweaker.h.

◆ 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();
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 }

◆ 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.

◆ m_fitParams

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

Definition at line 49 of file DataTweaker.h.

◆ m_nSamplesTruncation

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

Definition at line 46 of file DataTweaker.h.

◆ m_refit

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

Definition at line 47 of file DataTweaker.h.

◆ m_removeNoiseCorrelations

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

Definition at line 47 of file DataTweaker.h.

◆ m_removeRoIs

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

Definition at line 47 of file DataTweaker.h.

◆ 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:
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LArSamples::DataTweaker::m_fitParams
Chi2Params m_fitParams
Definition: DataTweaker.h:49
WriteBchToCool.adjust
adjust
Definition: WriteBchToCool.py:73
get_generator_info.result
result
Definition: get_generator_info.py:21
LArSamples::DataTweaker::m_removeNoiseCorrelations
bool m_removeNoiseCorrelations
Definition: DataTweaker.h:47
Data
@ Data
Definition: BaseObject.h:11
LArSamples::SimpleShape
Definition: SimpleShape.h:25
LArSamples::DataTweaker::m_refit
bool m_refit
Definition: DataTweaker.h:47
reference
Definition: hcg.cxx:437
LArSamples::ShapeFitter::fit
bool fit(const LArSamples::AbsShape &data, const AbsShape &reference, double &k, double &deltaT, double &chi2, const ScaledErrorData *sed=0) const
Definition: ShapeFitter.cxx:32
LArSamples::ScaledErrorData
Definition: ScaledErrorData.h:17
LArSamples::DataTweaker::m_removeRoIs
bool m_removeRoIs
Definition: DataTweaker.h:47
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
LArSamples::DataTweaker::findOption
bool findOption(TString &tweaks, const TString &option) const
Definition: DataTweaker.cxx:38
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
ITk::EventData
InDet::SiSpacePointsSeedMakerEventData EventData
Definition: ITkSiSpacePointsSeedMaker.h:63
LArSamples::OFC
Definition: OFC.h:27
LArSamples::Data
Definition: Data.h:72
LArSamples::DataTweaker::m_samples
std::map< unsigned int, bool > m_samples
Definition: DataTweaker.h:48
LArSamples::DataTweaker::m_adjust
bool m_adjust
Definition: DataTweaker.h:47
LArSamples::DataContainer
Definition: DataContainer.h:25
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
LArSamples::EventData::removeRoIs
void removeRoIs()
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:85
LArSamples::ShapeFitter
Definition: ShapeFitter.h:24
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
LArSamples::FitterData::sed
const ScaledErrorData * sed
Definition: ShapeFitter.cxx:26
ReadOfcFromCool.ofc
ofc
Definition: ReadOfcFromCool.py:110
LArSamples::EventData
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:29
LArSamples::DataTweaker::m_nSamplesTruncation
unsigned int m_nSamplesTruncation
Definition: DataTweaker.h:46
fitman.k
k
Definition: fitman.py:528