Belle II Software development
eclComputePulseTemplates_Step1.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <TF1.h>
9#include <ecl/digitization/OfflineFitFunction.h>
10#include <TTree.h>
11#include <TFile.h>
12#include <iostream>
13#include <assert.h>
14
15//
16/*
17 See eclComputePulseTemplates_Step0.cc for README instructions.
18 */
19//
20// cppcheck-suppress constParameter ; main() keeps its standard signature
21int main(int argc, char* argv[])
22{
23 //
24 TString OutputDirectory = "";
25 if (OutputDirectory == ".") {
26 std::cout << "Error set output directory" << std::endl;
27 return -1;
28 }
29 //
30 assert(argc == 3);
31 int LowIDLimit = atoi(argv[1]);
32 int HighIDLimit = atoi(argv[2]);
33 //
34 double PhotonWaveformPar[11];
35 TFile* PhotonParFile = new TFile(OutputDirectory + "PhotonWaveformParameters.root");
36 TTree* chain = static_cast<TTree*>(PhotonParFile->Get("ParTree"));
37 chain->SetBranchAddress("PhotonPar", &PhotonWaveformPar);
38 //
39 TFile* f = new TFile(OutputDirectory + Form("PhotonShapes_Low%d_High%d.root", LowIDLimit, HighIDLimit), "RECREATE");
40 f->cd();
41 TTree* mtree = new TTree("mtree", "");
42 std::vector<double> PhotonWaveformArray(100000);
43 mtree->Branch("PhotonArray", PhotonWaveformArray.data(), "PhotonWaveformArray[100000]/D");
44
45 //
46 for (Long64_t jentry = LowIDLimit; jentry < HighIDLimit; jentry++) {
47 chain->GetEntry(jentry);
48 TF1 PhotonShapeFunc = TF1(Form("photonShape_%lld", jentry), Belle2::ECL::WaveFuncTwoComponent, 0, 20, 26);;
49 PhotonShapeFunc.SetNpx(1000);
50 std::cout << PhotonWaveformPar[0] << std::endl;
51 PhotonShapeFunc.SetParameter(0, 0);
52 PhotonShapeFunc.SetParameter(1, 0);
53 PhotonShapeFunc.SetParameter(2, 1);
54 PhotonShapeFunc.SetParameter(3, 0);
55 for (int k = 0; k < 10; k++) {
56 PhotonShapeFunc.SetParameter(4 + k, PhotonWaveformPar[k + 1]);
57 PhotonShapeFunc.SetParameter(10 + 4 + k, PhotonWaveformPar[k + 1]);
58 }
59 PhotonShapeFunc.SetParameter(24, PhotonWaveformPar[0]);
60 PhotonShapeFunc.SetParameter(25, 1);
61 //
62 if (PhotonWaveformPar[0] > 0 && jentry <= 8737) {
63 for (unsigned int k = 0; k < PhotonWaveformArray.size();
64 k++) PhotonWaveformArray[k] = PhotonShapeFunc.Eval(((double)k) * (1. / 1000.)) ;
65 } else {
66 for (unsigned int k = 0; k < PhotonWaveformArray.size(); k++) PhotonWaveformArray[k] = -999;
67 }
68 mtree->Fill();
69 //
70 }
71 //
72 f->cd();
73 mtree->Write();
74 f->Write();
75 //
76 return 0;
77}