/
lowintmc.cpp
128 lines (105 loc) · 3.61 KB
/
lowintmc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
Copyright 2011 Julian Schutsch
This file is part of TRTGarf
TRTGarf is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TRTGarf is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TRTGarf. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <stdio.h>
#include <float.h>
#include "Signals/Signal.hpp"
#include "Signals/SignalPairSet.hpp"
#include "Signals/HighPass.hpp"
#include "tools.hpp"
#include <TApplication.h>
#include <TH2D.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TMultiGraph.h>
#include <TRandom.h>
#include <TRandom3.h>
// #include "boost/filesystem.hpp"
const std::string TopDir="/home/cluster/kn2a1/lu32cud/";
std::vector<std::string> DestVar;
std::vector<std::string> SourceVar;
const double SignalBins = 64;
const double SignalBinDiv = 256;
Signals::SignalPairSet signalpairs;
void LoadSignals(std::string ASignalIncPath,std::string ASignalLis,std::vector<unsigned int> ASections)
{
for(unsigned int i=0;i<ASections.size();++i)
{
Signals::Signal signal(3.125/SignalBinDiv);
Signals::Signal dest(3.125/SignalBinDiv);
signal.ReadSignalFromHSpicelis(ASignalLis,SourceVar,ASections[i]);
signal.Shift(-signal.GetSignalBin(0));
dest.ReadSignalFromHSpicelis(ASignalLis,DestVar,ASections[i]);
dest.Flatten(SignalBinDiv);
dest.Shift(-dest.GetSignalBin(0));
signalpairs.AddSignalPair(signal,dest);
}
}
int main(int argc,char * argv[])
{
try
{
TApplication application("app",&argc,argv);
InitRoot();
TRandom3 * random=new TRandom3();
SourceVar.push_back("blr_out");
DestVar.push_back("trkdisc");
std::vector<unsigned int> sections;
sections.push_back(0);
sections.push_back(1);
sections.push_back(2);
LoadSignals(TopDir+"sigs/ScaledSig/",
TopDir+"sigs/ASDSigScaled.lis",
sections);
double Bestd=1e30; TCanvas * canvas=new TCanvas();
std::cout<<"RUN"<<std::endl;
Signals::HighPass DiscIntegratorLow(3.125/SignalBinDiv);
DiscIntegratorLow.FDeltaCoefficients.resize(2);
DiscIntegratorLow.FDecayCoefficients.resize(2);
DiscIntegratorLow.FDeltaCoefficients[0] = 0;
DiscIntegratorLow.FDecayCoefficients[0] = 0;
signalpairs.SetPlotScales(1,5,5);
signalpairs.SetPlotColors(kBlack,kCyan,kBlue);
for(unsigned int mc=-1;mc<10000000;++mc)
{
DiscIntegratorLow.FDeltaCoefficients[1] = 5E-3*random->Rndm();
DiscIntegratorLow.FDecayCoefficients[1] = 5E-3*random->Rndm();
DiscIntegratorLow.FDelay = random->Rndm()*2;
if(signalpairs.IterReset())
{
do
{
signalpairs.SetCurrentResult(signalpairs.GetCurrentInput()>>DiscIntegratorLow);
} while(signalpairs.IterNext());
double d=signalpairs.CompareAll();
if(d<Bestd)
{
Bestd=d;
std::cout<<"*** "<<Bestd<<" ***"<<std::endl;
DiscIntegratorLow.Debug();
DiscIntegratorLow.SaveCoefficientsToFile("LowInt"+IntToStr(mc)+".dat");
signalpairs.PlotAll(canvas);
}
}
}
application.Run(kTRUE);
}
catch(const char * e)
{
std::cout<<e<<std::endl;
throw;
}
return 0;
}