-
Notifications
You must be signed in to change notification settings - Fork 0
/
EBChannel.cpp
70 lines (59 loc) · 1.53 KB
/
EBChannel.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
#include "EBChannel.h"
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TGraphAsymmErrors.h"
#include "TRandom3.h"
#include "Riostream.h"
#include <algorithm>
EBChannel::EBChannel(double eta)
{
char hname[120];
int indx;
indx = int(fabs(eta-0.05) * 10.0);
if(indx > 13) indx = 13;
if(indx < 0) indx = 0;
sprintf(hname,"pupdf_%d",indx);
TFile *fin1 = new TFile("pileupPDFs.root");
hpdf_signal_ = (TH1D*)fin1->Get(hname);
hpdf_signal_->SetDirectory(0);
fin1->Close();
TFile *fin2 = new TFile("pdf_apd_1M.root");
TProfile *hp = (TProfile*)fin2->Get("h01");
indx = int(fabs(eta)/1.5 * 85.) + 1;
if(indx < 1) indx = 1;
if(indx > 85) indx = 85;
apd_probability_ = hp->GetBinContent(indx);
hpdf_spike_ = (TH2D*)fin2->Get("h03");
hpdf_spike_->SetDirectory(0);
fin2->Close();
energySignal_ = 0;
energySpike_ = 0;
timeSpike_ = 0;
}
EBChannel::~EBChannel()
{
delete hpdf_signal_;
delete hpdf_spike_;
}
void EBChannel::GenerateBX(int NPU)
{
energySignal_ = 0;
energySpike_ = 0;
timeSpike_ = 0;
for(int i=0; i<NPU; ++i){
rnd1 = hpdf_signal_->GetRandom();
if(rnd1 > -10.9){
energySignal_ += pow(10, rnd1);
}
}
if( r1.Rndm() < (NPU * apd_probability_) ){
hpdf_spike_->GetRandom2(rnd1,rnd2);
energySpike_ += pow(10, rnd1) * 1.476; // factor 1.476 accounts for pulse shaping by CATIA vs legacy FE
if(rnd2 < 0) rnd2 += 25.;
if(rnd2 > 25.) rnd2 -= 25.;
timeSpike_ = rnd2;
timeSpike_ -= 9.3; // offset wrt prompt signal
}
}