#include <TreeShapeErrorGetter.h>
|
| | TreeShapeErrorGetter (const TString &fileName, bool recreate=false) |
| virtual | ~TreeShapeErrorGetter () |
| ShapeErrorData * | shapeErrorData (unsigned int hash, CaloGain::CaloGain gain, const Residual *toExclude=0) const |
| ShapeErrorData * | phiSymShapeErrorData (short ring, CaloGain::CaloGain gain, const Residual *toExclude=0) const |
| int | addCell (const ResidualCalculator &calc, CaloGain::CaloGain gain) |
| int | addRing (const ResidualCalculator &calc, CaloGain::CaloGain gain) |
| void | dump (CaloGain::CaloGain gain) const |
| TH2D * | correlate (const TreeShapeErrorGetter &other, CaloGain::CaloGain gain, unsigned short sample, bool xip, unsigned int nBins, double xMin, double xMax) const |
| bool | compare (const TreeShapeErrorGetter &other, const TString &fileName, const Interface *tmpl=0) const |
| const ResidualCalculator * | cellCalc () const |
| const ResidualCalculator * | ringCalc () const |
| TTree * | cellTree (CaloGain::CaloGain gain) const |
| TTree * | ringTree (CaloGain::CaloGain gain) const |
| TFile * | file () const |
|
| static bool | merge (const TString &listFile, const TString &outputFile) |
| static bool | merge (const std::vector< const TreeShapeErrorGetter * > &getters, const TString &outputFile) |
Definition at line 30 of file TreeShapeErrorGetter.h.
◆ TreeShapeErrorGetter()
| TreeShapeErrorGetter::TreeShapeErrorGetter |
( |
const TString & | fileName, |
|
|
bool | recreate = false ) |
Definition at line 25 of file TreeShapeErrorGetter.cxx.
27{
28 m_file = TFile::Open(fileName, (recreate ?
"RECREATE" :
"READ"));
30 cout <<
"File " <<
fileName <<
" is not accessible" << endl;
31 return;
32 }
33 if (recreate) {
40 for (
unsigned int i = 0;
i < 3;
i++ ) {
43 }
44 }
45 else {
50 cout <<
"Trees with cell shape error data not found in " <<
fileName << endl;
51 return;
52 }
57 cout <<
"Trees with phi symmetric shape error data not found in " <<
fileName << endl;
58 return;
59 }
60 for (
unsigned int i = 0;
i < 3;
i++ ) {
63 }
64 }
65}
std::vector< TTree * > m_cellTrees
ResidualCalculator * m_cellCalc
ResidualCalculator * m_ringCalc
std::vector< TTree * > m_ringTrees
◆ ~TreeShapeErrorGetter()
| TreeShapeErrorGetter::~TreeShapeErrorGetter |
( |
| ) |
|
|
virtual |
Definition at line 68 of file TreeShapeErrorGetter.cxx.
69{
70 if (
m_file->GetOption() == TString(
"CREATE")) {
72 for (
unsigned int g = 0;
g < 3;
g++ ) {
74 cout << "Missing trees, error writing data to TreeShapeErrorGetter" << endl;
75 return;
76 }
79 }
80 }
82}
◆ addCell()
◆ addRing()
◆ cellCalc()
◆ cellTree()
◆ compare()
Definition at line 259 of file TreeShapeErrorGetter.cxx.
260{
261 std::unique_ptr<TFile>
f(TFile::Open(fileName,
"RECREATE"));
262 auto tree = std::make_unique<TTree>(
"tree",
"");
263
265 double xi1[99], xi2[99], xip1[99], xip2[99];
266 int calo;
269
270 tree->Branch(
"hash", &hash);
271
272 if (tmpl) {
273 tree->Branch(
"calo", &calo);
274 tree->Branch(
"layer", &layer);
275 tree->Branch(
"ft", &ft);
276 tree->Branch(
"slot", &slot);
277 tree->Branch(
"channel", &channel);
280 }
281 tree->Branch(
"gain", &gain);
282 tree->Branch(
"lwb1", &lwb1);
283 tree->Branch(
"lwb2", &lwb2);
284 tree->Branch(
"nSamples", &nSamples);
285 tree->Branch(
"xi1", xi1,
"xi1[nSamples]/D");
286 tree->Branch(
"xi2", xi2,
"xi2[nSamples]/D");
287 tree->Branch(
"xip1", xip1,
"xip1[nSamples]/D");
288 tree->Branch(
"xip2", xip2,
"xip2[nSamples]/D");
289
291 if (k % 10000 == 0) cout <<
"Processing entry " <<
k << endl;
293 if (tmpl) {
294 const CellInfo* cellInfo = tmpl->
cellInfo(k);
295 calo = (cellInfo ? cellInfo->
calo() : -999 );
296 layer = (cellInfo ? cellInfo->
layer() : -999 );
298 slot = (cellInfo ? cellInfo->
slot() : -999 );
300 eta = (cellInfo ? cellInfo->
eta() : -999 );
301 phi = (cellInfo ? cellInfo->
phi() : -999 );
302 }
303 for (
unsigned int g = 0;
g < 3;
g++) {
307
311 int lwb = (lwb1 >= 0 ? lwb1 : lwb2);
312 if (lwb<0) throw std::runtime_error("TreeShapeErrorGetter::compare() attempt to access arrays with negative index");
313 for (
int j = lwb; j < lwb +
nSamples; j++) {
318 }
320 }
321 }
324 return true;
325}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
virtual const CellInfo * cellInfo(unsigned int i) const
short feedThrough() const
ShapeErrorData * shapeErrorData(unsigned int hash, CaloGain::CaloGain gain, const Residual *toExclude=0) const
static const unsigned int nChannels
◆ correlate()
Definition at line 164 of file TreeShapeErrorGetter.cxx.
166{
167 TH2D*
h =
new TH2D(Form(
"%s_%d", xip ?
"xip" :
"xi", sample),
"", nBins, xMin, xMax, nBins, xMin, xMax);
170 if (!data1) continue;
171 ShapeErrorData*
data2 =
other.shapeErrorData(i, gain);
172 if (!data2) {
delete data1;
continue; }
174 unsigned int sample1 =
sample +
data1->xip().GetLwb();
175 unsigned int sample2 =
sample +
data2->xip().GetLwb();
176 if (
data1->isInRange(sample1) &&
data2->isInRange(sample2))
177 h->Fill(xip ?
data1->xip()(sample1) :
data1->xi()(sample1),
178 xip ?
data2->xip()(sample2) :
data2->xi()(sample2));
181 }
183}
◆ dump()
Definition at line 151 of file TreeShapeErrorGetter.cxx.
152{
154 for (
long long i = 0;
i <
cellTree(gain)->GetEntries();
i++) {
156 if (!sed) continue;
157 cout <<
"-> " <<
i << endl;
161 }
162}
const TVectorD & xi() const
const TVectorD & xip() const
const ScaledErrorData * sed
◆ file()
| TFile * LArSamples::TreeShapeErrorGetter::file |
( |
| ) |
const |
|
inline |
◆ merge() [1/2]
| bool TreeShapeErrorGetter::merge |
( |
const std::vector< const TreeShapeErrorGetter * > & | getters, |
|
|
const TString & | outputFile ) |
|
static |
Definition at line 217 of file TreeShapeErrorGetter.cxx.
218{
219 auto output = std::make_unique<TreeShapeErrorGetter>(outputFile,
true);
221 for (
unsigned int g = 0;
g < 3;
g++) {
222 bool gotResult = false;
225 if (gotResult) {
226 cout <<
"TreeShapeErrorGetter::merge : input getters have non-zero overlap for cell " <<
i <<
" -- not supported, exiting." << endl;
227 return false;
228 }
229 gotResult = true;
230 cout <<
"Adding " <<
i <<
" " <<
g <<
" " << getter->cellCalc()->size() << endl;
232 }
233 }
235 }
236 }
237
239 for (
unsigned int g = 0;
g < 3;
g++) {
240 bool gotResult = false;
243 if (gotResult) {
244 cout <<
"TreeShapeErrorGetter::merge : input getters have non-zero overlap for ring " <<
i <<
" -- not supported, exiting." << endl;
245 return false;
246 }
247 gotResult = true;
248 cout <<
"Adding ring " <<
i <<
" " <<
g << endl;
250 }
251 }
253 }
254 }
255 return true;
256}
TreeShapeErrorGetter(const TString &fileName, bool recreate=false)
◆ merge() [2/2]
| bool TreeShapeErrorGetter::merge |
( |
const TString & | listFile, |
|
|
const TString & | outputFile ) |
|
static |
Definition at line 186 of file TreeShapeErrorGetter.cxx.
187{
188 std::ifstream
f(listFile);
189 if (!f) {
190 cout << "file " << listFile << " not accessible" << endl;
191 return 0;
192 }
193
196 std::vector<const TreeShapeErrorGetter*> getters;
197
198 while (f >> fileName) {
199
201 if (!getter) {
202 cout <<
"Skipping invalid file " <<
fileName << endl;
203 continue;
204 }
205 cout << std::setw(2) << ++
i <<
" - " <<
fileName << endl;
206 getters.push_back(getter);
207 }
209
211 delete getter;
212
214}
static bool merge(const TString &listFile, const TString &outputFile)
◆ phiSymShapeErrorData()
◆ ringCalc()
◆ ringTree()
◆ shapeErrorData()
◆ m_cellCalc
◆ m_cellTrees
| std::vector<TTree*> LArSamples::TreeShapeErrorGetter::m_cellTrees |
|
private |
◆ m_file
| TFile* LArSamples::TreeShapeErrorGetter::m_file |
|
private |
◆ m_ringCalc
◆ m_ringTrees
| std::vector<TTree*> LArSamples::TreeShapeErrorGetter::m_ringTrees |
|
private |
The documentation for this class was generated from the following files: