Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LiteCaloEval.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LiteCaloEval.cc
1 #include "LiteCaloEval.h"
2 
3 #include <calobase/RawTower.h>
4 #include <calobase/RawTowerContainer.h>
5 #include <calobase/RawTowerGeom.h>
6 #include <calobase/RawTowerGeomContainer.h>
7 #include <calobase/TowerInfo.h>
8 #include <calobase/TowerInfoContainer.h>
9 
12 
14 #include <fun4all/SubsysReco.h>
15 
16 #include <phool/PHCompositeNode.h>
17 #include <phool/getClass.h>
18 #include <phool/phool.h>
19 
20 #include <TF1.h>
21 #include <TFile.h>
22 #include <TGraph.h>
23 #include <TGraphErrors.h>
24 #include <TH1.h>
25 #include <TH2.h>
26 #include <TH3.h>
27 #include <TStyle.h>
28 #include <TSystem.h>
29 #include <TTree.h>
30 #include <TCanvas.h>
31 
32 #include <cmath> // for abs
33 #include <cstdlib>
34 #include <fstream>
35 #include <iostream>
36 #include <map> // for _Rb_tree_const_iterator
37 #include <memory>
38 #include <utility> // for pair
39 
40 /*
41 #include <centrality/CentralityInfo.h> // for CentralityInfo, CentralityI...
42 #include <centrality/CentralityInfov1.h>
43 */
44 
48 double LCE_fitf(Double_t *x, Double_t *par)
49 {
50  return par[0] * LCE_grff->Eval(x[0] * par[1], nullptr, "S");
51 }
52 
54 void LiteCaloEval::setFitMax(float fitMax)
55 {
56  fitmax = fitMax;
57 }
58 
59 void LiteCaloEval::setFitMin(float fitMin)
60 {
61  fitmin = fitMin;
62 }
63 
66 {
67  return fitmax;
68 }
69 
71 {
72  return fitmin;
73 }
74 
75 //____________________________________________________________________________..
77  : SubsysReco(name)
78  , _caloname(caloname)
79  , _filename(filename)
80  , _inputnodename("TOWERINFO")
81  , m_UseTowerInfo(1)
82 {
83 }
84 
85 //____________________________________________________________________________..
87 {
88  std::cout << "in init run " << std::endl;
89  // just quit if we forgot to set the calorimeter type
91  {
92  std::cout << Name() << ": No Calo Type set" << std::endl;
93  gSystem->Exit(1);
94  }
95 
96  /*
97  mygaus = new TF1("mygaus","gaus",-4,4);
98  mygaus->SetParameters(1e7,0.,1);
99  */
100 
101  _ievent = 0;
102 
103  cal_output = new TFile(_filename.c_str(), "RECREATE");
104 
106  {
107  hcalin_energy_eta = new TH2F("hcalin_energy_eta", "hcalin energy eta", 1000, 0, 100, 240, -1.1, 1.1);
108  hcalin_e_eta_phi = new TH3F("hcalin_e_eta_phi", "hcalin e eta phi", 50, 0, 14, 24, -1.1, 1.1, 64, -3.14159, 3.14159);
109 
111  for (int i = 0; i < 24; i++)
112  {
113  for (int j = 0; j < 64; j++)
114  {
115  std::string hist_name = "hcal_in_eta_" + std::to_string(i) + "_phi_" + std::to_string(j);
116 
117  hcal_in_eta_phi[i][j] = new TH1F(hist_name.c_str(), "Hcal_in_energy", 40000, 0, 4);
118  }
119  }
120 
121  for (int i = 0; i < 25; i++)
122  {
123  std::string hist_name = "hcalin_eta_" + std::to_string(i);
124  // hcalin_eta[i] = new TH1F(hist_name.c_str(), "hcalin eta's", 40000, 0, 4.);
125  // now fixed < 25 it should'v been // cppcheck flags this as always true (which it is in this loop
126  if (i < 24)
127  {
128  hcalin_eta[i] = new TH1F(hist_name.c_str(), "hcalin eta's", 40000, 0, 4.);
129  }
130  else
131  {
132  hcalin_eta[i] = new TH1F(hist_name.c_str(), "hcalin eta's", 2000000, 0, 4.);
133  }
134  }
135  }
136  else if (calotype == LiteCaloEval::HCALOUT)
137  {
138  hcalout_energy_eta = new TH2F("hcalout_energy_eta", "hcalout energy eta", 100, 0, 10, 240, -1.1, 1.1);
139  hcalout_e_eta_phi = new TH3F("hcalout_e_eta_phi", "hcalout e eta phi", 48, 0, 10, 24, -1.1, 1.1, 64, -3.14159, 3.14159);
140 
142  for (int i = 0; i < 24; i++)
143  {
144  for (int j = 0; j < 64; j++)
145  {
146  std::string hist_name = "hcal_out_eta_" + std::to_string(i) + "_phi_" + std::to_string(j);
147 
148  hcal_out_eta_phi[i][j] = new TH1F(hist_name.c_str(), "Hcal_out energy", 20000, 0, 10);
149  }
150  }
151 
153  for (int i = 0; i < 25; i++)
154  {
155  std::string hist_name = "hcalout_eta_" + std::to_string(i);
156  if (i < 24)
157  {
158  hcalout_eta[i] = new TH1F(hist_name.c_str(), "hcalout eta's", 20000, 0, 10);
159  }
160  else
161  {
162  hcalout_eta[i] = new TH1F(hist_name.c_str(), "hcalout eta's", 1000000, 0, 10);
163  }
164  }
165  }
166 
167  else if (calotype == LiteCaloEval::CEMC)
168  {
170  for (int i = 0; i < 96; i++)
171  {
172  for (int j = 0; j < 256; j++)
173  {
174  std::string hist_name = "emc_ieta" + std::to_string(i) + "_phi" + std::to_string(j);
175 
176  cemc_hist_eta_phi[i][j] = new TH1F(hist_name.c_str(), "Hist_ieta_phi_leaf(e)", 5000, 0, 10);
177  }
178  }
179 
180  // create eta slice histos
181  for (int i = 0; i < 97; i++)
182  {
183  gStyle->SetOptFit(1);
184  std::string b = "eta_" + std::to_string(i);
185 
186  if (i < 96)
187  {
188  eta_hist[i] = new TH1F(b.c_str(), "eta and all phi's", 5000, 0, 10);
189  }
190  else
191  {
192  eta_hist[i] = new TH1F(b.c_str(), "eta and all phi's", 1000000, 0, 10);
193  }
194  }
195 
196  // make 2d histo
197  energy_eta_hist = new TH2F("energy_eta_hist", "energy eta and all phi", 512, 0, 10, 960, -1.15, 1.15);
198 
199  // make 3d histo
200  e_eta_phi = new TH3F("e_eta_phi", "e v eta v phi", 50, 0, 10, 192, -1.1335, 1.13350, 256, -3.14159, 3.14159);
201  }
202 
203  /*
204  //centrality histo
205  if(calotype == LiteCaloEval::CEMC)
206  evtCentrality = new TH2F("centVsNtow","",100,0,100,24576,0,24576);
207  else
208  evtCentrality = new TH2F("centVsNtow","",100,0,100,1536,0,1536);
209  */
210 
212 }
213 
214 //____________________________________________________________________________..
216 {
217  if (_ievent % 100 == 0)
218  {
219  std::cout << "LiteCaloEval::process_event(PHCompositeNode *topNode) Processing Event " << _ievent << std::endl;
220  }
221 
222  // used to get centrality of collision
223  // we don't need centrality right now
224  // previous code for this was for tests
225  /*
226  CentralityInfo *cent = findNode::getClass<CentralityInfo>(topNode, "CentralityInfo");
227  if (!cent)
228  {
229  std::cout << " ERROR -- can't find CentralityInfo node after it should have been created" << std::endl;
230  exit(-1);
231 
232  }
233  */
234 
235  // raw tower container
236  std::string towernode = "TOWER_CALIB_" + _caloname;
237  RawTowerContainer *towers = nullptr;
238  RawTowerGeomContainer *towergeom = nullptr;
239 
240  // get tower energy for towerslope method only
243 
244  if (m_UseTowerInfo < 1)
245  {
246  towers = findNode::getClass<RawTowerContainer>(topNode, towernode);
247  if (!towers)
248  {
249  std::cout << PHWHERE << " ERROR: Can't find " << towernode << std::endl;
250  exit(-1);
251  }
252 
253  // raw tower geom container
254  std::string towergeomnode = "TOWERGEOM_" + _caloname;
255  towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnode);
256  if (!towergeom)
257  {
258  std::cout << PHWHERE << " ERROR: Can't find " << towergeomnode << std::endl;
259  exit(-1);
260  }
261 
262  begin_end = towers->getTowers();
263  rtiter = begin_end.first;
264  }
265 
266  if (mode && _ievent < 4)
267  {
268  std::cout << "mode is set " << std::endl;
269  // e*= 1.15;
270  }
271 
272  // int centval1 = cent->get_centile(CentralityInfo::PROP::mbd_NS);
273  TowerInfoContainer *towerinfos = nullptr;
274 
275  // if using towerinfo create a tower object
276  if (m_UseTowerInfo)
277  {
278 
279  // towernode = "TOWERINFO_CALIB_" + _caloname;
280  // towernode = "TOWERS_Calib_" + _caloname;
281  towernode = _inputnodename;
282 
283  towerinfos = findNode::getClass<TowerInfoContainer>(topNode, towernode.c_str());
284 
285  if (!towerinfos)
286  {
287  std::cout << PHWHERE << " ERROR: Can't find " << towernode << std::endl;
288  exit(-1);
289  }
290  }
291 
292  // getting size of node
293  unsigned int nchannels = -1;
294 
295  if (m_UseTowerInfo)
296  {
297  nchannels = towerinfos->size();
298  }
299  else
300  {
301  nchannels = towers->size();
302  }
303 
304  TowerInfo *tower_info;
305  RawTower *tower;
306  RawTowerGeom *tower_geom;
307 
308  // int towCnt = 0;
309 
310  /*
311  if (_ievent < 4)
312  {
313  std::cout << Name() << "towerinfo " << towerinfos << " towers "
314  << towers << " nchannels" << nchannels << std::endl;
315  }
316  */
317 
318  for (unsigned int channel = 0; channel < nchannels; channel++)
319  {
320  if (!m_UseTowerInfo && rtiter == begin_end.second)
321  {
322  std::cout << "ERROR: Recheck iteration process with rtiter variable" << std::endl;
323  }
324 
325  float e = -1.0; // tower energy
326  unsigned int ieta = 99999;
327  unsigned int iphi = 99999;
328  // int towerid =-1;
329 
330  if (m_UseTowerInfo)
331  {
332  tower_info = towerinfos->get_tower_at_channel(channel);
333  unsigned int towerkey = towerinfos->encode_key(channel);
334 
335  e = tower_info->get_energy();
336  ieta = towerinfos->getTowerEtaBin(towerkey);
337  iphi = towerinfos->getTowerPhiBin(towerkey);
338  if(!tower_info->get_isGood()) continue;
339  }
340 
341  else
342  {
343  tower = rtiter->second;
344 
345  /*
346  if (tower->get_energy() < 0.02)
347  {
348  continue;
349  }
350  */
351  tower_geom = towergeom->get_tower_geometry(tower->get_id());
352 
353  if (!tower_geom)
354  {
355  std::cout << PHWHERE << " ERROR: Can't find tower geometry for this tower hit: ";
356  tower->identify();
357  exit(-1);
358  }
359 
360  e = tower->get_energy();
361  ieta = tower->get_bineta();
362  iphi = tower->get_binphi();
363 
364  } // end else for rawtower mode
365 
366  if (ieta > 95 || iphi > 256)
367  {
368  // rough check for all calos uing the largest emcal
369  std::cout << "ieta or iphi not set correctly/ was less than 0 " << std::endl;
370  break;
371  }
372 
373  if (e <= 0)
374  {
375  continue;
376  }
377 
379  {
380  /*
381  if (e > 0)
382  towCnt++;
383 
384  if (_ievent > 2 && _ievent < 7 && (channel < 10 || nchannels-channel < 10 || (e > 0.2 && towCnt < nchannels/4.)))
385  {
386  std::cout << _ievent << " evtn,iphi,ieta, e" << iphi << " "
387  << ieta << " " << e << " " << Name() << std::endl;
388  }
389  */
390 
391  if (mode)
392  {
393  int ket = ieta / 8;
394  int llet = ket % 6;
395  int pket = iphi / 8;
396  int ppkket = pket % 3;
397 
398  e *= 0.88 + llet * 0.04 - 0.01 + 0.01 * ppkket;
399  }
400 
401  // fill the hist with energy data
402  cemc_hist_eta_phi[ieta][iphi]->Fill(e);
403 
404  // fill the 1d hist eta and all phi
405  eta_hist[96]->Fill(e);
406  eta_hist[ieta]->Fill(e);
407 
408  // fill the 2d histo eta, energy and all phi
409  energy_eta_hist->Fill(e, ieta);
410 
411  // fill 3d histo e_eta_phid
412  e_eta_phi->Fill(e, ieta, iphi);
413  }
414 
415  else if (calotype == LiteCaloEval::HCALOUT)
416  {
417  // fill the hist with energy data
418  // std::cout << ieta << " " << iphi << std::endl;
419 
420  if (mode)
421  {
422  int ket = ieta / 2;
423 
424  int llet = ket % 6;
425  e *= 0.945 + llet * 0.02;
426  int pket = iphi / 4;
427  if (pket % 2 == 0)
428  {
429  e *= 1.03;
430  }
431  }
432 
433  hcal_out_eta_phi[ieta][iphi]->Fill(e);
434 
435  hcalout_eta[24]->Fill(e);
436  hcalout_eta[ieta]->Fill(e);
437 
438  hcalout_energy_eta->Fill(e, ieta);
439 
440  hcalout_e_eta_phi->Fill(e, ieta, iphi);
441  }
442 
443  else if (calotype == LiteCaloEval::HCALIN)
444  {
445  // fill the hist with energy data
446 
447  if (mode)
448  {
449  int ket = ieta / 2;
450 
451  int llet = ket % 6;
452  e *= 0.945 + llet * 0.02;
453  int pket = iphi / 4;
454  if (pket % 2 == 0)
455  {
456  e *= 1.03;
457  }
458  }
459 
460  hcal_in_eta_phi[ieta][iphi]->Fill(e);
461 
462  hcalin_eta[24]->Fill(e);
463  hcalin_eta[ieta]->Fill(e);
464 
465  hcalin_energy_eta->Fill(e, ieta);
466 
467  hcalin_e_eta_phi->Fill(e, ieta, iphi);
468  }
469 
470  if (!m_UseTowerInfo)
471  {
472  ++rtiter;
473  }
474 
475  } // end of for loop
476 
477  _ievent++;
478 
480 }
481 
482 //____________________________________________________________________________..
484 {
485  cal_output->cd();
486  std::cout << " writing lite calo file" << std::endl;
487  cal_output->Write();
488  // cout <<" wrote lite calo file" << endl;
489 
491 
492  /*
493  // turn off fitting at end because
494  // it always needs merged first
495 
496  if (calotype == LiteCaloEval::HCALIN)
497  {
498  double par_value[24];
499  double eta_value[24];
500  double par_err[24];
501  double rel_err[24];
502 
503  //same as above but for the second fit performed below in code
504  double par_value2[24];
505  double par_err2[24];
506  double rel_err2[24];
507 
508  for (int i = 0; i < 24; i++)
509  {
510  //a,b,c,d hold the par value, error, par2 value, par2 error respectivley. The 2 refers to the second fit below
511  double a;
512  double b;
513  double c;
514  double d;
515 
516  //make functions to fit the eta histos
517  std::unique_ptr<TF1> f1(new TF1("f1", "expo", 0.02, 0.1));
518  std::unique_ptr<TF1> f2(new TF1("f2", "expo", 0.1, 1));
519  f2->SetLineColor(7);
520 
521  hcalin_eta[i]->Fit("f1", "R");
522  hcalin_eta[i]->Fit("f2", "R+");
523 
524  a = f1->GetParameter(1);
525  b = f1->GetParError(1);
526 
527  c = f2->GetParameter(1);
528  d = f2->GetParError(1);
529 
530  //assign retreived parameter values
531  par_value[i] = abs(a);
532  par_err[i] = b;
533  eta_value[i] = i;
534  rel_err[i] = par_err[i] / par_value[i];
535 
536  par_value2[i] = abs(c);
537  par_err2[i] = d;
538  rel_err2[i] = par_err2[i] / par_value2[i];
539  }
540 
541  //create graphs
542  TGraph g1(24, eta_value, par_value);
543  g1.SetTitle("HCal In (0.02-0.1 GeV); eta; p1");
544  g1.SetMarkerStyle(20);
545  g1.Draw("ap");
546  g1.SetName("Fit1_hcalin");
547  g1.Write();
548 
549  TGraph g2(24, eta_value, rel_err);
550  g2.SetTitle("HCal In Error (0.02-0.1 GeV); eta; p1 rel error");
551  g2.SetMarkerStyle(20);
552  g2.Draw("ap");
553  g2.SetName("Fit1_err_hcalin");
554  g2.Write();
555 
556  TGraph g3(24, eta_value, par_value2);
557  g3.SetTitle("HCal In (0.1-1 GeV); eta; p1");
558  g3.SetMarkerStyle(20);
559  g3.Draw("ap");
560  g3.SetName("Fit2_hcalin");
561  g3.Write();
562 
563  TGraph g4(24, eta_value, rel_err2);
564  g4.SetTitle("HCal In Error (0.1-1 GeV); eta; p1 rel error");
565  g4.SetMarkerStyle(20);
566  g4.Draw("ap");
567  g4.SetName("Fit2_err_hcalin");
568  g4.Write();
569  }
570  else if (calotype == LiteCaloEval::HCALOUT)
571  {
572  double par_value[24];
573  double eta_value[24];
574  double par_err[24];
575  double rel_err[24];
576 
577  //same as above but for the second/third fit performed below in code
578  double par_value2[24];
579  double par_err2[24];
580  double rel_err2[24];
581 
582  double par_value3[24];
583  double par_err3[24];
584  double rel_err3[24];
585 
586  for (int i = 0; i < 24; i++)
587  {
588  //a,b hold the p1 value, p1 error, and then repeats for the second fit (c,d) and third fit (e,f)
589  double a;
590  double b;
591  double c;
592  double d;
593  double e;
594  double f;
595 
596  //make functions to fit the eta histos
597  std::unique_ptr<TF1> f1(new TF1("f1", "expo", 0.05, 0.2));
598  std::unique_ptr<TF1> f2(new TF1("f2", "expo", 0.2, 1));
599  std::unique_ptr<TF1> f3(new TF1("f3", "expo", 1, 2));
600  f2->SetLineColor(7);
601  f3->SetLineColor(1);
602 
603  hcalout_eta[i]->Fit("f1", "R");
604  hcalout_eta[i]->Fit("f2", "R+");
605  hcalout_eta[i]->Fit("f3", "R+");
606 
607  a = f1->GetParameter(1);
608  b = f1->GetParError(1);
609 
610  c = f2->GetParameter(1);
611  d = f2->GetParError(1);
612 
613  e = f3->GetParameter(1);
614  f = f3->GetParError(1);
615 
616  //assign retreived parameter values
617  par_value[i] = abs(a);
618  par_err[i] = b;
619  eta_value[i] = i;
620  rel_err[i] = par_err[i] / par_value[i];
621 
622  par_value2[i] = abs(c);
623  par_err2[i] = d;
624  rel_err2[i] = par_err2[i] / par_value2[i];
625 
626  par_value3[i] = abs(e);
627  par_err3[i] = f;
628  rel_err3[i] = par_err3[i] / par_value3[i];
629  }
630 
631  //create graphs
632  TGraph g1(24, eta_value, par_value);
633  g1.SetTitle("HCal Out (0.05-0.2 GeV); eta; p1");
634  g1.SetMarkerStyle(20);
635  g1.Draw("ap");
636  g1.SetName("Fit1_hcalout");
637  g1.Write();
638 
639  TGraph g2(24, eta_value, rel_err);
640  g2.SetTitle("HCal Out Error (0.05-0.2 GeV); eta; p1 rel err");
641  g2.SetMarkerStyle(20);
642  g2.Draw("ap");
643  g2.SetName("Fit1_err_hcalout");
644  g2.Write();
645 
646  TGraph g3(24, eta_value, par_value2);
647  g3.SetTitle("HCal Out (0.2-1 GeV); eta; p1");
648  g3.SetMarkerStyle(20);
649  g3.Draw("ap");
650  g3.SetName("Fit2_hcalout");
651  g3.Write();
652 
653  TGraph g4(24, eta_value, rel_err2);
654  g4.SetTitle("HCal Out Error (0.2-1 GeV); eta; p1 rel err");
655  g4.SetMarkerStyle(20);
656  g4.Draw("ap");
657  g4.SetName("Fit2_err_hcalout");
658  g4.Write();
659 
660  TGraph g5(24, eta_value, par_value3);
661  g5.SetTitle("HCal Out (1-2 GeV); eta; p1");
662  g5.SetMarkerStyle(20);
663  g5.Draw("ap");
664  g5.SetName("Fit3_hcalout");
665  g5.Write();
666 
667  TGraph g6(24, eta_value, rel_err3);
668  g6.SetTitle("HCal Out Error (1-2 GeV); eta; p1 rel err");
669  g6.SetMarkerStyle(20);
670  g6.Draw("ap");
671  g6.SetName("Fit3_err_hcalout");
672  g6.Write();
673  }
674  else if (calotype == LiteCaloEval::CEMC && 0)
675  {
676  //create arrays that holds parameter (p1) value and error
677  double par_value[96];
678  double eta_value[96];
679  double par_err[96];
680  double rel_err[96];
681 
682  //same as above but for the second fit performed below in code
683  double par_value2[96];
684  double par_err2[96];
685  double rel_err2[96];
686 
687  double par_value3[96];
688  double par_err3[96];
689  double rel_err3[96];
690 
691  //create graphs for parameter (p1) vs eta
692  for (int i = 0; i < 96; i++)
693  {
694  //a,b,c,d hold the par value, error, par2 value, par2 error respectivley. The 2 refers to the second fit below
695  double a;
696  double b;
697  double c;
698  double d;
699  double e;
700  double f;
701 
702  //make functions to fit the eta histos
703  std::unique_ptr<TF1> f1(new TF1("f1", "expo", 0.04, 0.1));
704  std::unique_ptr<TF1> f2(new TF1("f2", "expo", 0.1, 0.4));
705  std::unique_ptr<TF1> f3(new TF1("f3", "expo", 0.4, 2));
706  f2->SetLineColor(7);
707  f3->SetLineColor(1);
708 
709  eta_hist[i]->Fit("f1", "R");
710  eta_hist[i]->Fit("f2", "R+");
711  eta_hist[i]->Fit("f3", "R+");
712 
713  a = f1->GetParameter(1);
714  b = f1->GetParError(1);
715 
716  c = f2->GetParameter(1);
717  d = f2->GetParError(1);
718 
719  e = f3->GetParameter(1);
720  f = f3->GetParError(1);
721 
722  //assign retreived parameter values
723  par_value[i] = abs(a);
724  par_err[i] = b;
725  eta_value[i] = i;
726  rel_err[i] = par_err[i] / par_value[i];
727 
728  par_value2[i] = abs(c);
729  par_err2[i] = d;
730  rel_err2[i] = par_err2[i] / par_value2[i];
731 
732  par_value3[i] = abs(e);
733  par_err3[i] = f;
734  rel_err3[i] = par_err3[i] / par_value3[i];
735  }
736 
737  //create graphs
738  TGraph g1(96, eta_value, par_value);
739  g1.SetTitle("EMCal (0.04-0.1 GeV); eta; p1");
740  g1.SetMarkerStyle(20);
741  g1.Draw("ap");
742  g1.SetName("Fit1_emc");
743  g1.Write();
744 
745  TGraph g2(96, eta_value, rel_err);
746  g2.SetTitle("EMCal Error (0.04-0.1 GeV); eta; p1 rel error");
747  g2.SetMarkerStyle(20);
748  g2.Draw("ap");
749  g2.SetName("Fit1_err_emc");
750  g2.Write();
751 
752  TGraph g3(96, eta_value, par_value2);
753  g3.SetTitle("EMCal (0.1-0.4 GeV); eta; p1");
754  g3.SetMarkerStyle(20);
755  g3.Draw("ap");
756  g3.SetName("Fit2_emc");
757  g3.Write();
758 
759  TGraph g4(96, eta_value, rel_err2);
760  g4.SetTitle("EMCal Error (0.1-0.4 GeV); eta; p1 rel error");
761  g4.SetMarkerStyle(20);
762  g4.Draw("ap");
763  g4.SetName("Fit2_err_emc");
764  g4.Write();
765 
766  TGraph g5(96, eta_value, par_value3);
767  g5.SetTitle("EMCal (0.4-2 GeV); eta; p1");
768  g5.SetMarkerStyle(20);
769  g5.Draw("ap");
770  g5.SetName("Fit3_emc");
771  g5.Write();
772 
773  TGraph g6(96, eta_value, rel_err3);
774  g6.SetTitle("EMCal Error (0.4-2 GeV); eta; p1 rel err");
775  g6.SetMarkerStyle(20);
776  g6.Draw("ap");
777  g6.SetName("Fit3_err_emc");
778  g6.Write();
779  }
780 
781  std::cout <<" writing lite calo file" << std::endl;
782  cal_output->Write();
783  //cout <<" wrote lite calo file" << endl;
784  return Fun4AllReturnCodes::EVENT_OK;
785  */
786 }
787 
789 void LiteCaloEval::Get_Histos(const char *infile, const char *outfile)
790 {
791  // std::cout << "*** IN GET_HISTOS ***" << std::endl;
792 
793  std::string outF = outfile;
794  std::string inF = infile;
795 
796  if ((inF == ""))
797  {
798  std::cout << "need infile to run LiteCaloEval::Get_Histos" << std::endl;
799  exit(0);
800  }
801 
802  if (!(outF == ""))
803  {
804  TString ts = "cp ";
805  ts += infile;
806  ts += " ";
807  ts += outfile;
808  gSystem->Exec(ts.Data());
809  f_temp = new TFile(outfile, "UPDATE"); // load the file from the fun4all 1st run
810  }
811 
812  else
813  {
814  f_temp = new TFile(infile);
815  }
816 
817  int max_ieta = 96;
819  {
820  max_ieta = 24;
821  }
822 
823  int max_iphi = 256;
825  {
826  max_iphi = 64;
827  }
828 
830  for (int i = 0; i < max_ieta+1; i++)
831  {
832  TString a;
833  a.Form("%d", i);
834  TString b = "eta_" + a;
835 
837  {
838  b = "hcalout_" + b;
839  }
840  else if (calotype == LiteCaloEval::HCALIN)
841  {
842  b = "hcalin_" + b;
843  }
844 
846  TH1F *heta_temp = (TH1F *) f_temp->Get(b.Data());
847 
848  if (!heta_temp && i == 0)
849  {
850  std::cout << " warning hist " << b.Data() << " not found" << std::endl;
851  }
852 
854  eta_hist[i] = heta_temp;
855 
857  {
858  hcalout_eta[i] = heta_temp;
859  }
860  else if (calotype == LiteCaloEval::HCALIN)
861  {
862  hcalin_eta[i] = heta_temp;
863  }
864 
865  if (! (i < max_ieta) )
866  continue;
867 
869  for (int j = 0; j < max_iphi; j++)
870  {
872  std::string hist_name_p = "emc_ieta" + std::to_string(i) + "_phi" + std::to_string(j);
873 
875  {
876  hist_name_p = "hcal_out_eta_" + std::to_string(i) + "_phi_" + std::to_string(j);
877  }
878  else if (calotype == LiteCaloEval::HCALIN)
879  {
880  hist_name_p = "hcal_in_eta_" + std::to_string(i) + "_phi_" + std::to_string(j);
881  }
882 
883  if (j < 2)
884  {
885  std::cout << "getting " << hist_name_p << std::endl;
886  }
887 
889  TH1F *heta_tempp = (TH1F *) f_temp->Get(hist_name_p.c_str());
890 
891  if (!heta_tempp && i == 0)
892  {
893  std::cout << " warning hist " << hist_name_p.c_str() << " not found" << std::endl;
894  }
895 
897  cemc_hist_eta_phi[i][j] = heta_tempp;
898 
900  {
901  hcal_out_eta_phi[i][j] = heta_tempp;
902  }
903  else if (calotype == LiteCaloEval::HCALIN)
904  {
905  hcal_in_eta_phi[i][j] = heta_tempp;
906  }
907  }
908  }
909 
910  // std::cout<< " *** LEAVING GET HISTOS *** "<< std::endl;
911 }
912 
913 void LiteCaloEval::FitRelativeShifts(LiteCaloEval *ref_lce, int modeFitShifts)
914 {
915  bool onlyEta = false;
916 
917  if (fitmin < 0.001)
918  {
919  fitmin = 0.15;
920  }
921  if (fitmax < 0.001)
922  {
923  fitmax = 1.3;
924  }
925 
926 
927  float par_value[96] = {0};
928  float par_err[96] = {0};
929  float eta_value[96] = {0};
930  float eta_err[96] = {0};
931  // float rel_err[96];
932 
933  if (f_temp)
934  {
935  f_temp->cd();
936  }
937 
939  TF1 *f1 = new TF1("myexpo", LCE_fitf, 0.1, 10, 2);
940  f1->SetParameters(1.0, 1.0);
941 
943  if (modeFitShifts % 10 == 1)
944  {
945  onlyEta = true;
946  }
947 
949  int nsmooth = 1;
950 
952  int addSmooth = modeFitShifts % 100 / 10;
953  if (addSmooth)
954  {
955  nsmooth += addSmooth;
956  }
957 
959  bool flag_fit_rings = false;
960 
963  if (modeFitShifts % 1000 / 100 == 1)
964  {
965  flag_fit_rings = true;
966  }
967 
968  int max_ieta = 96;
970  {
971  max_ieta = 24;
972  }
973 
974  int max_iphi = 256;
976  {
977  max_iphi = 64;
978  }
979 
981  TH2F *corrPat = new TH2F("corrPat", "", max_ieta, 0, max_ieta, max_iphi, 0, max_iphi);
982 
983  if (flag_fit_rings == true)
984  {
986  {
987  corrPat->SetMinimum(0.95);
988  corrPat->SetMaximum(1.03);
989  }
990  else
991  {
992  corrPat->SetMinimum(0.92);
993  corrPat->SetMaximum(1.05);
994  }
995  }
996  else
997  {
999  {
1000  corrPat->SetMinimum(0.87);
1001  corrPat->SetMaximum(1.09);
1002  }
1003  else
1004  {
1005  corrPat->SetMinimum(0.9450);
1006  corrPat->SetMaximum(1.0764);
1007  }
1008  }
1009 
1010  int minbin = 0;
1011  int maxbin = max_ieta;
1012 
1013  if (m_myminbin > -1)
1014  minbin = m_myminbin;
1015  if (m_mymaxbin > -1)
1016  maxbin = m_mymaxbin;
1017 
1018 
1020  TH1F *hnewf = nullptr;
1021 
1023  for (int i = minbin; i < maxbin; i++)
1024  {
1026  double a1f;
1027  double b1f;
1028 
1030  TString myClnm = "newhc_eta";
1031  myClnm = myClnm + i;
1032 
1033  TString myClnm2 = "gnewhc_eta";
1034  myClnm2 = myClnm2 + i;
1035 
1037  int iik = i;
1038 
1039  // /// assign hnewf the eta slice histos.
1040  // TH1F *hnewf = nullptr;
1041  hnewf = nullptr;
1042 
1044  TH1F *cleanEtaRef = nullptr;
1045  TString cleanEta = "cleanEtaRef_";
1046 
1048  {
1050  if (flag_fit_rings == true)
1051  {
1052  cleanEta += iik;
1053  cleanEtaRef = (TH1F *) eta_hist[iik]->Clone(cleanEta.Data());
1054 
1055  // 4/1/23
1056  /*
1057  if( (i >= 2 && i<=93) )
1058  {
1059  for(int b = 0; b< 256; b++)
1060  {
1061  if( (b >=32 && b <= 34) || (b >= 229 && b <= 231) )
1062  {
1063  cleanEtaRef->Add((TH1F *)cemc_hist_eta_phi[i][b],-1.0);
1064  }
1065  }
1066  }*/
1067 
1068  // rebin for run62 to match v9 binning
1069  cleanEtaRef->Rebin(5);
1070 
1071  }
1072 
1073  else
1074  {
1075  hnewf = (TH1F *) ref_lce->eta_hist[iik]->Clone(myClnm.Data());
1076  hnewf->Rebin(5);
1077  }
1078  }
1079 
1080  else if (calotype == LiteCaloEval::HCALOUT)
1081  {
1082  if (flag_fit_rings == true)
1083  {
1085  cleanEta += iik;
1086  cleanEtaRef = (TH1F *) hcalout_eta[iik]->Clone(cleanEta.Data());
1087 
1088  if (i < 4)
1089  {
1090  for (int b = 14; b <= 19; b++)
1091  {
1092  cleanEtaRef->Add((TH1F *) hcal_out_eta_phi[i][b], -1.0);
1093  }
1094  }
1095  // rebin for run62
1096  cleanEtaRef->Rebin(10);
1097  cleanEtaRef->Rebin(2);
1098 
1099  } // end flag
1100 
1101  else
1102  {
1103  hnewf = (TH1F *) ref_lce->hcalout_eta[iik]->Clone(myClnm.Data());
1104  hnewf->Rebin(10);
1105  hnewf->Rebin(2);
1106  }
1107  }
1108 
1109  else if (calotype == LiteCaloEval::HCALIN)
1110  {
1111  if (flag_fit_rings == true)
1112  {
1113  cleanEta += iik;
1114  cleanEtaRef = (TH1F *) hcalin_eta[iik]->Clone(cleanEta.Data());
1115 
1116  // rebin for run62
1117  cleanEtaRef->Rebin(10);
1118  cleanEtaRef->Rebin(10);
1119  }
1120  else
1121  {
1122  hnewf = (TH1F *) ref_lce->hcalin_eta[iik]->Clone(myClnm.Data());
1123  hnewf->Rebin(10);
1124  hnewf->Rebin(10);
1125  }
1126  }
1127 
1128  if (flag_fit_rings == true)
1129  {
1130  cleanEtaRef->Smooth(nsmooth);
1131  LCE_grff = new TGraph(cleanEtaRef);
1132  }
1133  else
1134  {
1136  hnewf->Smooth(nsmooth);
1137  LCE_grff = new TGraph(hnewf);
1138  }
1139 
1141  TF1 *f2f = nullptr;
1142 
1145  {
1146  eta_hist[i]->Rebin(5);
1147 
1148  if (nsmooth > 1)
1149  {
1150  eta_hist[i]->Smooth(nsmooth);
1151  }
1152 
1153  std::cout << "fitting " << i << std::endl;
1154  eta_hist[i]->Fit("myexpo", "L", "", fitmin, fitmax);
1155 
1156  f2f = (TF1 *) eta_hist[i]->GetFunction("myexpo");
1157  }
1158 
1159  else if (calotype == LiteCaloEval::HCALOUT)
1160  {
1161  // added 3/3/23 to get the same bin width as previous bin size. Was tested on command line to achieve same bin width as before.
1162  // old bin width was 0.01, new bin width is 0.0005. So rebin(10) and then rebin(2) worked to get 0.01
1163  hcalout_eta[i]->Rebin(10);
1164  hcalout_eta[i]->Rebin(2);
1165 
1166  if (nsmooth > 1)
1167  {
1168  hcalout_eta[i]->Smooth(nsmooth);
1169  }
1170 
1171  hcalout_eta[i]->Fit("myexpo", "L", "", fitmin, fitmax);
1172 
1173  f2f = (TF1 *) hcalout_eta[i]->GetFunction("myexpo");
1174  }
1175 
1176  else if (calotype == LiteCaloEval::HCALIN)
1177  {
1178  // rebinning for run62 only
1179  hcalin_eta[i]->Rebin(10);
1180  hcalin_eta[i]->Rebin(10);
1181 
1182  if (nsmooth > 1)
1183  {
1184  hcalin_eta[i]->Smooth(nsmooth);
1185  }
1186 
1187  hcalin_eta[i]->Fit("myexpo", "L", "", fitmin, fitmax);
1188 
1189  f2f = (TF1 *) hcalin_eta[i]->GetFunction("myexpo");
1190  }
1191 
1194  TGraph *grT = new TGraph(1000);
1195  grT->SetName(myClnm2.Data());
1196 
1197  for (int jjk = 0; jjk < 1000; jjk++)
1198  {
1199  float xjj = fitmin + jjk * (fitmax - fitmin) / 1000.0;
1200  grT->SetPoint(jjk, xjj, f2f->Eval(xjj));
1201  }
1202 
1203  grT->Write();
1204 
1206 
1208  a1f = f2f->GetParameter(1);
1209  b1f = f2f->GetParError(1);
1210 
1211  // assign retreived parameter values for graphing
1212  par_value[i] = a1f;
1213  par_err[i] = b1f;
1214  eta_value[i] = i;
1215  eta_err[i] = 0.01;
1216  // rel_err[i] = par_err[i] / par_value[i];
1217 
1219  if (onlyEta == true)
1220  {
1221  continue;
1222  }
1223 
1224  /****************************************************
1225  This is the nested forloop to start tower material
1226  ****************************************************/
1227 
1228  for (int j = 0; j < max_iphi; j++)
1229  {
1230  // 4/1/23
1231  /*
1233  if(flag_fit_rings == true)
1234  {
1235 
1236  if(calotype == LiteCaloEval::CEMC)
1237  {
1238 
1239  if(i >= 2 && i <= 93)
1240  {
1241  if( (j >=32 && j <= 34) || (j >=229 && j <= 231) )
1242  {
1243  continue;
1244  }
1245  }
1246 
1247  }
1248  else if(calotype == LiteCaloEval::HCALOUT)
1249  {
1251  if( (i >=0 && i <=3) && (j>=14 && j <= 19))
1252  {
1253  continue;
1254  }
1255  }
1256 
1257  }//end flag
1258  */
1259 
1261  TString myClnmp = "newhc_eta";
1262  myClnmp = myClnmp + 1000 * (i + 2) + j;
1263 
1264  TString myClnm2p = "gnewhc_eta";
1265  myClnm2p = myClnm2p + 1000 * (i + 2) + j;
1266 
1267  if (j == 0)
1268  {
1269  std::cout << " making fitting " << myClnmp.Data() << std::endl;
1270  }
1271 
1273  TH1F *hnewfp = nullptr;
1274 
1276  {
1277  cemc_hist_eta_phi[i][j]->Rebin(5);
1278 
1279  if (flag_fit_rings == true)
1280  {
1281  cleanEtaRef->Add((TH1F *) cemc_hist_eta_phi[i][j], -1.0);
1282  }
1283 
1284  else
1285  {
1286  hnewfp = (TH1F *) ref_lce->cemc_hist_eta_phi[i][j]->Clone(myClnmp.Data());
1287  hnewfp->Rebin(5);
1288  }
1289  }
1290 
1291  else if (calotype == LiteCaloEval::HCALOUT)
1292  {
1293  // for run62 added 3/3/23 to get the same bin width as previous bins. Was tested on command line to achieve same bin width as before.
1294  // old bin width was 0.01, new bin width is 0.0005. So rebin(10) and then rebin(2) worked to get 0.01
1295  hcal_out_eta_phi[i][j]->Rebin(10);
1296  hcal_out_eta_phi[i][j]->Rebin(2);
1297 
1298  if (flag_fit_rings == true)
1299  {
1300  cleanEtaRef->Add((TH1F *) hcal_out_eta_phi[i][j], -1.0);
1301  }
1302 
1303  else
1304  {
1305  hnewfp = (TH1F *) ref_lce->hcal_out_eta_phi[i][j]->Clone(myClnmp.Data());
1306  hnewfp->Rebin(10);
1307  hnewfp->Rebin(2);
1308  }
1309  }
1310 
1311  else if (calotype == LiteCaloEval::HCALIN)
1312  {
1313  // rebin tower for run62
1314  hcal_in_eta_phi[i][j]->Rebin(10);
1315  hcal_in_eta_phi[i][j]->Rebin(10);
1316 
1317  if (flag_fit_rings == true)
1318  {
1319  cleanEtaRef->Add((TH1F *) hcal_in_eta_phi[i][j], -1.0);
1320  }
1321  else
1322  {
1323  hnewfp = (TH1F *) ref_lce->hcal_in_eta_phi[i][j]->Clone(myClnmp.Data());
1324  hnewfp->Rebin(10);
1325  hnewfp->Rebin(10);
1326  }
1327  }
1328 
1329  if (j < 2)
1330  {
1331  std::cout << "got neweff phi eta ... fitting w/ fit min,max: " << fitmin
1332  << " " << fitmax << std::endl;
1333  }
1334 
1335  /*
1336  If false make tgraph out of tower and send to be fit with fit fuction.
1337  If true the towers are actually fit against the eta ring. This happends bc "myexpo" uses a tgraph
1338  to fit, and if we dont make LCE_grff for a tower, myexpo uses the latest version of LCE_grff, which is an eta slice tgraph
1339  */
1340  if (flag_fit_rings == false)
1341  {
1342  hnewfp->Smooth(nsmooth);
1343  LCE_grff = new TGraph(hnewfp);
1344  }
1345 
1346  if (flag_fit_rings == true)
1347  {
1348  // cleanEtaRef->Smooth(nsmooth);
1349  LCE_grff = new TGraph(cleanEtaRef);
1350  }
1351 
1353  TF1 *f2f2 = nullptr;
1354 
1356  {
1357  double scaleP0 = cemc_hist_eta_phi[i][j]->Integral(cemc_hist_eta_phi[i][j]->FindBin(fitmin), cemc_hist_eta_phi[i][j]->FindBin(fitmax));
1358 
1359  if (flag_fit_rings == 1)
1360  {
1361  scaleP0 /= cleanEtaRef->Integral(cleanEtaRef->FindBin(fitmin), cleanEtaRef->FindBin(fitmax));
1362  }
1363  else
1364  {
1365  scaleP0 /= hnewfp->Integral(hnewfp->FindBin(fitmin), hnewfp->FindBin(fitmax));
1366  }
1367 
1368  f1->SetParameters(scaleP0, 1.0);
1369 
1370  if (j < 2)
1371  {
1372  cemc_hist_eta_phi[i][j]->Fit("myexpo", "L", "", fitmin, fitmax);
1373  }
1374 
1375  else
1376  {
1377  cemc_hist_eta_phi[i][j]->Fit("myexpo", "LQ", "", fitmin, fitmax);
1378  }
1379 
1380  f2f2 = (TF1 *) cemc_hist_eta_phi[i][j]->GetFunction("myexpo");
1381 
1382  if (flag_fit_rings == true)
1383  {
1384  cleanEtaRef->Add((TH1F *) cemc_hist_eta_phi[i][j], 1.0);
1385  }
1386  }
1387 
1388  else if (calotype == LiteCaloEval::HCALOUT)
1389  {
1390  double scaleP0 = hcal_out_eta_phi[i][j]->Integral(hcal_out_eta_phi[i][j]->FindBin(fitmin), hcal_out_eta_phi[i][j]->FindBin(fitmax));
1391 
1392  if (flag_fit_rings == 1)
1393  {
1394  scaleP0 /= cleanEtaRef->Integral(cleanEtaRef->FindBin(fitmin), cleanEtaRef->FindBin(fitmax));
1395  }
1396  else
1397  {
1398  scaleP0 /= hnewfp->Integral(hnewfp->FindBin(fitmin), hnewfp->FindBin(fitmax));
1399  }
1400 
1402  f1->SetParameters(scaleP0, 1.0);
1403 
1404  if (j < 2)
1405  {
1406  hcal_out_eta_phi[i][j]->Fit("myexpo", "L", "", fitmin, fitmax);
1407  }
1408 
1409  else
1410  {
1411  hcal_out_eta_phi[i][j]->Fit("myexpo", "LQ", "", fitmin, fitmax);
1412  }
1413 
1414  f2f2 = (TF1 *) hcal_out_eta_phi[i][j]->GetFunction("myexpo");
1415 
1416  if (flag_fit_rings == true)
1417  {
1418  cleanEtaRef->Add((TH1F *) hcal_out_eta_phi[i][j], 1.0);
1419  }
1420  }
1421 
1422  else if (calotype == LiteCaloEval::HCALIN)
1423  {
1424  double scaleP0 = hcal_in_eta_phi[i][j]->Integral(hcal_in_eta_phi[i][j]->FindBin(fitmin), hcal_in_eta_phi[i][j]->FindBin(fitmax));
1425 
1426  if (flag_fit_rings == 1)
1427  {
1428  scaleP0 /= cleanEtaRef->Integral(cleanEtaRef->FindBin(fitmin), cleanEtaRef->FindBin(fitmax));
1429  }
1430 
1431  else
1432  {
1433  scaleP0 /= hnewfp->Integral(hnewfp->FindBin(fitmin), hnewfp->FindBin(fitmax));
1434  }
1435 
1436  f1->SetParameters(scaleP0, 1.0);
1437 
1438  if (j < 2)
1439  {
1440  hcal_in_eta_phi[i][j]->Fit("myexpo", "L", "", fitmin, fitmax);
1441  }
1442  else
1443  {
1444  hcal_in_eta_phi[i][j]->Fit("myexpo", "LQ", "", fitmin, fitmax);
1445  }
1446 
1447  f2f2 = (TF1 *) hcal_in_eta_phi[i][j]->GetFunction("myexpo");
1448 
1449  if (flag_fit_rings == true)
1450  {
1451  cleanEtaRef->Add((TH1F *) hcal_in_eta_phi[i][j], 1.0);
1452  }
1453  }
1454 
1456  TGraph *local_grT = new TGraph(1000);
1457  local_grT->SetName(myClnm2p.Data());
1458 
1459  for (int jjk = 0; jjk < 1000; jjk++)
1460  {
1461  float xjj = fitmin + jjk * (fitmax - fitmin) / 1000.0;
1462  // grT->SetPoint(jjk,xjj,f2f->Eval(xjj));
1463  local_grT->SetPoint(jjk, xjj, f2f2->Eval(xjj));
1464  }
1465 
1466  local_grT->Write();
1467 
1468  float a1fp = f2f2->GetParameter(1);
1469  float b1fp = f2f2->GetParError(1);
1470  // float b1fp = f2f->GetParError(1);
1471 
1475  corrPat->SetBinContent(i + 1, j + 1, 1 / a1fp);
1476  corrPat->SetBinError(i + 1, j + 1, 1 / b1fp);
1477 
1478  } // end of inner forloop (phi)
1479 
1480  } // end of outter forloop (eta)
1481 
1482  // create graph that plots eta slice par values
1483  TGraphErrors g1(max_ieta, eta_value, par_value, eta_err, par_err);
1484  g1.SetTitle("fitted shifts; eta; p1");
1485  g1.SetMarkerStyle(20);
1486  g1.Draw("ap");
1487  g1.SetName("Fit1_etaout");
1488  g1.Write();
1489 
1490  corrPat->Write();
1491 
1493  {
1494  std::cout << "TowerSlope module: writing emcal correction tree into output file"
1495  << std::endl;
1496  TTree *t1 = new TTree("emc_corr_tree", "a tree of simple emcal calib corrections");
1497  int towid;
1498  float corr;
1499  t1->Branch("corr", &corr, "corr/F");
1500  t1->Branch("towid", &towid, "towid/I");
1501 
1502  for (int mjl = 0; mjl < max_ieta; mjl++)
1503  {
1504  for (int mjk = 0; mjk < max_iphi; mjk++)
1505  {
1506  towid = mjl * 1000 + mjk;
1507  corr = corrPat->GetBinContent(mjl + 1, mjk + 1);
1508  if (!(corr > 0.0))
1509  {
1510  corr = 1.0;
1511  }
1512  else
1513  {
1514  corr = 1.0 / corr;
1515  }
1516  t1->Fill();
1517  }
1518  }
1519  t1->Write();
1520  }
1521 
1524  {
1525  std::string hcal_corr_file_name = "HCAL_CORR_TXTFILE";
1526  if (f_temp)
1527  {
1528  hcal_corr_file_name += f_temp->GetName();
1529  hcal_corr_file_name += ".txt";
1530  }
1531 
1532  std::cout << "TowerSlope module: writing hcal corrections into output file "
1533  << hcal_corr_file_name
1534  << std::endl;
1535 
1536  std::ofstream out_hcal_corrF(hcal_corr_file_name.c_str());
1537 
1538  for (int mjl = 0; mjl < max_ieta; mjl++)
1539  {
1540  for (int mjk = 0; mjk < max_iphi; mjk++)
1541  {
1542  float corr = corrPat->GetBinContent(mjl + 1, mjk + 1);
1543  if (!(corr > 0.))
1544  {
1545  corr = 1.0;
1546  }
1547  else
1548  {
1549  corr = 1.0 / corr;
1550  }
1551 
1552  out_hcal_corrF << mjl << " "
1553  << mjk << " "
1554  << corr << std::endl;
1555  }
1556  }
1557 
1558  out_hcal_corrF.close();
1559  }
1560 
1561  if (f_temp)
1562  {
1563  f_temp->Write();
1564  }
1565 
1566  f_temp->Close();
1567 
1568  // std::cout << "LEAVING REL SHIFTS" << std::endl;
1569 }