-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObsDifferential.cc
68 lines (58 loc) · 2.16 KB
/
ObsDifferential.cc
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
#include "ObsDifferential.hh"
#include "NtupleReader.hh"
#include "DataStructure.hh"
#include "DifferentialDataStructure.hh"
#include "MatrixDataStructure.hh"
#include "FilledObservable.hh"
#include "DifferentialCalculator.hh"
#include <iostream>
using std::cout;
using std::endl;
using std::string;
using std::vector;
ObsDifferential::ObsDifferential( const string& name,
const vector<Double_t>& bins,
const vector<Analysis>& variations,
const DifferentialCalculator* calc,
const bool lprint ) :
Observable( name ), binedges( bins ), calculator( calc ) {
addAnalyses( variations );
if( lprint ) {
cout << "ObsDifferential::ObsDifferential: ds/dy, ds/dy*y, ds/dy*y**2 for "
<< name << endl;
printVectorD( "Binedges:", bins );
}
return;
}
ObsDifferential::~ObsDifferential() {}
void ObsDifferential::addAnalysis( const Analysis& analysis ) {
string tag= analysis.getTag();
data[tag]= new DifferentialDataStructure( binedges );
weighted1[tag]= new DifferentialDataStructure( binedges );
weighted2[tag]= new DifferentialDataStructure( binedges );
if( analysis.getReco2() != "none" ) {
matrices[tag]= new MatrixDataStructure( binedges );
}
}
void ObsDifferential::fill( NtupleReader* ntr, const Analysis& variation ) {
string tag= variation.getTag();
Double_t value= calculator->getValue( ntr, variation.getReco() );
data.at( tag )->fill( value );
if( value >= 0.0 ) {
weighted1.at( tag )->fill( value, value );
weighted2.at( tag )->fill( value, TMath::Power( value, 2 ) );
}
if( variation.getReco2() != "none" and ntr->isMC() ) {
Double_t MCvalue= calculator->getValue( ntr, variation.getReco2() );
matrices.at( tag )->fill( value, MCvalue );
}
}
vector<FilledObservable*> ObsDifferential::getFilledObservables() const {
// cout << "ObsDifferential::getFilledObservables: "
// << "create FilledObservables " << name << " and " << name+"W1" << endl;
vector<FilledObservable*> vfobs;
vfobs.push_back( new FilledObservable( name, data, matrices ) );
vfobs.push_back( new FilledObservable( name+"W1", weighted1 ) );
vfobs.push_back( new FilledObservable( name+"W2", weighted2 ) );
return vfobs;
}