165 unsigned int nBins,
double xMin,
double xMax)
const
167 auto h = std::make_unique<TH2D>(Form(
"%s_%d", xip ?
"xip" :
"xi", sample),
"", nBins, xMin, xMax, nBins, xMin, xMax);
170 if (!data1)
continue;
171 std::unique_ptr<ShapeErrorData> data2 = other.shapeErrorData(i, gain);
172 if (!data2) {
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));
186 std::ifstream f(listFile);
188 cout <<
"file " << listFile <<
" not accessible" << endl;
192 std::string fileName;
194 std::vector<std::unique_ptr<const TreeShapeErrorGetter> > getters;
196 while (f >> fileName) {
198 auto getter = std::make_unique<TreeShapeErrorGetter>(fileName.c_str());
200 cout << std::setw(2) << ++i <<
" - " << fileName << endl;
201 getters.push_back(std::move(getter));
203 return merge(std::move(getters), outputFile);
209 auto output = std::make_unique<TreeShapeErrorGetter>(outputFile,
true);
211 for (
unsigned int g = 0; g < 3; g++) {
212 bool gotResult =
false;
213 for (std::unique_ptr<const TreeShapeErrorGetter>& getter : getters) {
216 cout <<
"TreeShapeErrorGetter::merge : input getters have non-zero overlap for cell " << i <<
" -- not supported, exiting." << endl;
220 cout <<
"Adding " << i <<
" " << g <<
" " << getter->cellCalc()->size() << endl;
229 for (
unsigned int g = 0; g < 3; g++) {
230 bool gotResult =
false;
231 for (std::unique_ptr<const TreeShapeErrorGetter>& getter : getters) {
234 cout <<
"TreeShapeErrorGetter::merge : input getters have non-zero overlap for ring " << i <<
" -- not supported, exiting." << endl;
238 cout <<
"Adding ring " << i <<
" " << g << endl;
251 std::unique_ptr<TFile> f(TFile::Open(fileName,
"RECREATE"));
252 TTree
tree (
"tree",
"");
254 int hash, gain, lwb1, lwb2, nSamples;
255 double xi1[99], xi2[99], xip1[99], xip2[99];
257 int layer, ft, slot, channel;
260 tree.Branch(
"hash", &hash);
263 tree.Branch(
"calo", &calo);
264 tree.Branch(
"layer", &layer);
265 tree.Branch(
"ft", &ft);
266 tree.Branch(
"slot", &slot);
267 tree.Branch(
"channel", &channel);
271 tree.Branch(
"gain", &gain);
272 tree.Branch(
"lwb1", &lwb1);
273 tree.Branch(
"lwb2", &lwb2);
274 tree.Branch(
"nSamples", &nSamples);
275 tree.Branch(
"xi1", xi1,
"xi1[nSamples]/D");
276 tree.Branch(
"xi2", xi2,
"xi2[nSamples]/D");
277 tree.Branch(
"xip1", xip1,
"xip1[nSamples]/D");
278 tree.Branch(
"xip2", xip2,
"xip2[nSamples]/D");
281 if (k % 10000 == 0) cout <<
"Processing entry " << k << endl;
284 std::unique_ptr<const CellInfo> cellInfo = tmpl->
cellInfo(k);
285 calo = (cellInfo ? cellInfo->calo() : -999 );
286 layer = (cellInfo ? cellInfo->layer() : -999 );
287 ft = (cellInfo ? cellInfo->feedThrough() : -999 );
288 slot = (cellInfo ? cellInfo->slot() : -999 );
289 channel = (cellInfo ? cellInfo->channel() : -999 );
290 eta = (cellInfo ? cellInfo->eta() : -999 );
291 phi = (cellInfo ? cellInfo->phi() : -999 );
293 for (
unsigned int g = 0; g < 3; g++) {
296 std::unique_ptr<ShapeErrorData> data2 = other.shapeErrorData(k, (
CaloGain::CaloGain)g);
298 lwb1 = (data1 ? data1->lwb() : -1);
299 lwb2 = (data2 ? data2->lwb() : -1);
300 nSamples = (data1 ? data1->nSamples() : data2 ? data2->nSamples() : 0);
301 int lwb = (lwb1 >= 0 ? lwb1 : lwb2);
302 if (lwb<0)
throw std::runtime_error(
"TreeShapeErrorGetter::compare() attempt to access arrays with negative index");
303 for (
int j = lwb; j < lwb + nSamples; j++) {
304 xi1[j] = (data1 ? data1->xi()(j) : -999);
305 xip1[j] = (data1 ? data1->xip()(j) : -999);
306 xi2[j] = (data2 && data2->isInRange(j) ? data2->xi()(j) : -999);
307 xip2[j] = (data2 && data2->isInRange(j) ? data2->xip()(j) : -999);
std::unique_ptr< TH2D > correlate(const TreeShapeErrorGetter &other, CaloGain::CaloGain gain, unsigned short sample, bool xip, unsigned int nBins, double xMin, double xMax) const