Belle II Software  release-05-01-25
eclComputePulseTemplates_Step1.cc
1 #include <TF1.h>
2 #include <ecl/digitization/OfflineFitFunction.h>
3 #include <TTree.h>
4 #include <TFile.h>
5 #include <iostream>
6 #include <assert.h>
7 
8 //
9 /*
10  See eclComputePulseTemplates_Step0.cc for README instructions.
11  */
12 //
13 int main(int argc, char* argv[])
14 {
15  //
16  TString OutputDirectory = "";
17  if (OutputDirectory == "") {
18  std::cout << "Error set ouput directory" << std::endl;
19  return -1;
20  }
21  //
22  assert(argc == 3);
23  int LowIDLimit = atoi(argv[1]);
24  int HighIDLimit = atoi(argv[2]);
25  //
26  double PhotonWaveformPar[11];
27  TFile* PhotonParFile = new TFile(OutputDirectory + "PhotonWaveformParameters.root");
28  TTree* chain = (TTree*) PhotonParFile->Get("ParTree");
29  chain->SetBranchAddress("PhotonPar", &PhotonWaveformPar);
30  //
31  TFile* f = new TFile(OutputDirectory + Form("PhotonShapes_Low%d_High%d.root", LowIDLimit, HighIDLimit), "RECREATE");
32  f->cd();
33  TTree* mtree = new TTree("mtree", "");
34  std::vector<double> PhotonWaveformArray(100000);
35  mtree->Branch("PhotonArray", PhotonWaveformArray.data(), "PhotonWaveformArray[100000]/D");
36 
37  //
38  for (Long64_t jentry = LowIDLimit; jentry < HighIDLimit; jentry++) {
39  chain->GetEntry(jentry);
40  TF1 PhotonShapeFunc = TF1(Form("photonShape_%lld", jentry), Belle2::ECL::WaveFuncTwoComponent, 0, 20, 26);;
41  PhotonShapeFunc.SetNpx(1000);
42  std::cout << PhotonWaveformPar[0] << std::endl;
43  PhotonShapeFunc.SetParameter(0, 0);
44  PhotonShapeFunc.SetParameter(1, 0);
45  PhotonShapeFunc.SetParameter(2, 1);
46  PhotonShapeFunc.SetParameter(3, 0);
47  for (int k = 0; k < 10; k++) {
48  PhotonShapeFunc.SetParameter(4 + k, PhotonWaveformPar[k + 1]);
49  PhotonShapeFunc.SetParameter(10 + 4 + k, PhotonWaveformPar[k + 1]);
50  }
51  PhotonShapeFunc.SetParameter(24, PhotonWaveformPar[0]);
52  PhotonShapeFunc.SetParameter(25, 1);
53  //
54  if (PhotonWaveformPar[0] > 0 && jentry <= 8737) {
55  for (unsigned int k = 0; k < PhotonWaveformArray.size();
56  k++) PhotonWaveformArray[k] = PhotonShapeFunc.Eval(((double)k) * (1. / 1000.)) ;
57  } else {
58  for (unsigned int k = 0; k < PhotonWaveformArray.size(); k++) PhotonWaveformArray[k] = -999;
59  }
60  mtree->Fill();
61  //
62  }
63  //
64  f->cd();
65  mtree->Write();
66  f->Write();
67  //
68  return 0;
69 }
main
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:77