Newer
Older
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// AbsHist class definition file. -*- C++ -*-
// Copyright 2012 Bertram Kopf
#include <getopt.h>
#include <fstream>
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include "PwaUtils/AbsHist.hh"
#include "qft++/relativistic-quantum-mechanics/Utils.hh"
#include "ErrLogger/ErrLogger.hh"
#include "Particle/Particle.hh"
#include "Particle/ParticleTable.hh"
#include "Utils/PawianCollectionUtils.hh"
#include "PwaUtils/KinUtils.hh"
#include "PwaUtils/AbsLh.hh"
#include "PwaUtils/EvtDataBaseList.hh"
#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TNtuple.h"
AbsHist::AbsHist()
{
}
AbsHist::~AbsHist(){
_theTFile->Write();
_theTFile->Close();
}
void AbsHist::fillIt(boost::shared_ptr<AbsLh> theLh, fitParams& theFitParams){
if(0==theLh){
Alert <<"AbsLh* is a 0 pointer !!!!" ; // << endmsg;
exit(1);
}
boost::shared_ptr<const EvtDataBaseList> theEvtList=theLh->getEventList();
const std::vector<EvtData*> dataList=theEvtList->getDataVecs();
std::vector<EvtData*>::const_iterator it=dataList.begin();
while(it!=dataList.end())
{
double weight = (*it)->evtWeight;
fillMassHists((*it), weight, _massDataHistMap);
fillAngleHists((*it), weight, _angleDataHistMap);
++it;
}
const std::vector<EvtData*> mcList=theEvtList->getMcVecs();
it=mcList.begin();
while(it!=mcList.end())
{
double evtWeight = (*it)->evtWeight;
fillMassHists((*it), evtWeight, _massMcHistMap);
fillAngleHists((*it), evtWeight, _angleMcHistMap);
double fitWeight= theLh->calcEvtIntensity( (*it), theFitParams );
fillMassHists((*it), evtWeight*fitWeight, _massFitHistMap);
fillAngleHists((*it), evtWeight*fitWeight, _angleFitHistMap);
++it;
}
double integralDataWoWeight=(double) theEvtList->getDataVecs().size();
Info <<"No of data events without weight " << integralDataWoWeight ; // << endmsg;
double integralDataWWeight=(double) theEvtList->NoOfWeightedDataEvts();
Info <<"No of data events with weight " << integralDataWWeight ; // << endmsg;
double integralMC=(double) theEvtList->NoOfWeightedMcEvts();
Info <<"No of MC events " << integralMC ; // << endmsg;
Info <<"scaling factor " << integralDataWWeight/integralMC ; // << endmsg;
double scaleFactor = integralDataWWeight/integralMC;
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess >::iterator itMassMap;
for(itMassMap= _massFitHistMap.begin(); itMassMap!= _massFitHistMap.end(); ++itMassMap){
itMassMap->second->Scale(scaleFactor);
}
std::map<boost::shared_ptr<angleHistData>, std::pair<TH1F*, TH1F*>, pawian::Collection::SharedPtrLess >::iterator itAngleMap;
for(itAngleMap= _angleFitHistMap.begin(); itAngleMap!=_angleFitHistMap.end(); ++itAngleMap){
itAngleMap->second.first->Scale(scaleFactor);
itAngleMap->second.second->Scale(scaleFactor);
}
}
void AbsHist::fillMassHists(EvtData* theData, double weight, std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess >& toFill){
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess >::iterator it;
for(it= toFill.begin(); it!= toFill.end(); ++it){
//get relevant 4 vecs
Vector4<double> combined4Vec(0.,0.,0.,0.);
std::vector<std::string> fspNames=it->first->_fspNames;
std::vector<std::string>::iterator itStr;
for(itStr=fspNames.begin(); itStr!=fspNames.end(); ++itStr){
Vector4<double> tmp4vec=theData->FourVecsString[*itStr];
combined4Vec+=tmp4vec;
}
it->second->Fill(combined4Vec.M(), weight);
}
}
void AbsHist::fillAngleHists(EvtData* theData, double weight, std::map<boost::shared_ptr<angleHistData>, std::pair<TH1F*, TH1F*>, pawian::Collection::SharedPtrLess >& toFill){
std::map<boost::shared_ptr<angleHistData>, std::pair<TH1F*, TH1F*>, pawian::Collection::SharedPtrLess >::iterator it;
for(it= toFill.begin(); it!= toFill.end(); ++it){
short nBodyDecay = it->first->_nBodyDecay;
Vector4<double> combinedDec4Vec(0.,0.,0.,0.);
Vector4<double> combinedDec4Vec2(0.,0.,0.,0.);
Vector4<double> combinedMother4Vec(0.,0.,0.,0.);
Vector4<double> all4Vec=theData->FourVecsString["all"];
std::vector<std::string> decNames=it->first->_decPNames;
std::vector<std::string> decNames2=it->first->_decPNames2;
std::vector<std::string>::iterator itStr;
for(itStr=decNames.begin(); itStr!=decNames.end(); ++itStr){
Vector4<double> tmp4vec=theData->FourVecsString[*itStr];
combinedDec4Vec+=tmp4vec;
}
for(itStr=decNames2.begin(); itStr!=decNames2.end(); ++itStr){
Vector4<double> tmp4vec=theData->FourVecsString[*itStr];
combinedDec4Vec2+=tmp4vec;
}
std::vector<std::string> motherNames=it->first->_motherPNames;
for(itStr=motherNames.begin(); itStr!=motherNames.end(); ++itStr){
Vector4<double> tmp4vec=theData->FourVecsString[*itStr];
combinedMother4Vec+=tmp4vec;
}
Vector4<double> result4Vec(0.,0.,0.,0.);
Vector4<double> result4Vec2(0.,0.,0.,0.);
if( fabs(all4Vec.E()-combinedMother4Vec.E()) < 1e-5
&& fabs(all4Vec.Px()-combinedMother4Vec.Px()) < 1e-5
&& fabs(all4Vec.Py()-combinedMother4Vec.Py()) < 1e-5
&& fabs(all4Vec.Pz()-combinedMother4Vec.Pz()) < 1e-5 ){
result4Vec=combinedDec4Vec;
result4Vec.Boost(all4Vec);
}
else{
result4Vec=helicityVec(all4Vec, combinedMother4Vec, combinedDec4Vec);
if(nBodyDecay==3)
result4Vec2=helicityVec(all4Vec, combinedMother4Vec, combinedDec4Vec2);
}
if(nBodyDecay == 2){
it->second.first->Fill( result4Vec.CosTheta(), weight);
it->second.second->Fill( result4Vec.Phi(), weight);
}
else if(nBodyDecay == 3){
Vector4<double> result4VecPart1 = result4Vec;
Vector4<double> result4VecPart2 = result4Vec2;
Vector4<float> normVec(0,
result4VecPart1.Y()*result4VecPart2.Z()-result4VecPart1.Z()*result4VecPart2.Y(),
result4VecPart1.Z()*result4VecPart2.X()-result4VecPart1.X()*result4VecPart2.Z(),
result4VecPart1.X()*result4VecPart2.Y()-result4VecPart1.Y()*result4VecPart2.X());
it->second.first->Fill( normVec.CosTheta(), weight);
it->second.second->Fill( normVec.Phi(), weight);
}
}
}