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//
20int main(int argc, char* argv[])
21{
22 //
23 TString OutputDirectory = "";
24 if (OutputDirectory == ".") {
25 std::cout << "Error set ouput directory" << std::endl;
26 return -1;
27 }
28 //
29 assert(argc == 3);
30 int LowIDLimit = atoi(argv[1]);
31 int HighIDLimit = atoi(argv[2]);
32 //
33 double PhotonWaveformPar[11];
34 TFile* PhotonParFile = new TFile(OutputDirectory + "PhotonWaveformParameters.root");
35 TTree* chain = (TTree*) PhotonParFile->Get("ParTree");
36 chain->SetBranchAddress("PhotonPar", &PhotonWaveformPar);
37 //
38 TFile* f = new TFile(OutputDirectory + Form("PhotonShapes_Low%d_High%d.root", LowIDLimit, HighIDLimit), "RECREATE");
39 f->cd();
40 TTree* mtree = new TTree("mtree", "");
41 std::vector<double> PhotonWaveformArray(100000);
42 mtree->Branch("PhotonArray", PhotonWaveformArray.data(), "PhotonWaveformArray[100000]/D");
43
44 //
45 for (Long64_t jentry = LowIDLimit; jentry < HighIDLimit; jentry++) {
46 chain->GetEntry(jentry);
47 TF1 PhotonShapeFunc = TF1(Form("photonShape_%lld", jentry), Belle2::ECL::WaveFuncTwoComponent, 0, 20, 26);;
48 PhotonShapeFunc.SetNpx(1000);
49 std::cout << PhotonWaveformPar[0] << std::endl;
50 PhotonShapeFunc.SetParameter(0, 0);
51 PhotonShapeFunc.SetParameter(1, 0);
52 PhotonShapeFunc.SetParameter(2, 1);
53 PhotonShapeFunc.SetParameter(3, 0);
54 for (int k = 0; k < 10; k++) {
55 PhotonShapeFunc.SetParameter(4 + k, PhotonWaveformPar[k + 1]);
56 PhotonShapeFunc.SetParameter(10 + 4 + k, PhotonWaveformPar[k + 1]);
57 }
58 PhotonShapeFunc.SetParameter(24, PhotonWaveformPar[0]);
59 PhotonShapeFunc.SetParameter(25, 1);
60 //
61 if (PhotonWaveformPar[0] > 0 && jentry <= 8737) {
62 for (unsigned int k = 0; k < PhotonWaveformArray.size();
63 k++) PhotonWaveformArray[k] = PhotonShapeFunc.Eval(((double)k) * (1. / 1000.)) ;
64 } else {
65 for (unsigned int k = 0; k < PhotonWaveformArray.size(); k++) PhotonWaveformArray[k] = -999;
66 }
67 mtree->Fill();
68 //
69 }
70 //
71 f->cd();
72 mtree->Write();
73 f->Write();
74 //
75 return 0;
76}