1 #ifndef BackgroundHandler_cc
2 #define BackgroundHandler_cc
12 const std::vector<double>& leftWindowBorders,
13 const std::vector<double>& rightWindowBorders,
14 const double* ResMass,
15 const double* massWindowHalfWidth) {
37 for (
unsigned int i = 0;
i < 6; ++
i) {
38 double mass = ResMass[
i];
39 double lowerLimit =
mass - massWindowHalfWidth[
i];
40 double upperLimit =
mass + massWindowHalfWidth[
i];
45 std::vector<unsigned int>(1,
i),
52 double resMassForRegion[3];
53 resMassForRegion[0] = ResMass[0];
54 resMassForRegion[1] = (ResMass[1] + ResMass[2] + ResMass[3]) / 3;
55 resMassForRegion[2] = (ResMass[4] + ResMass[5]) / 2;
58 std::vector<std::vector<unsigned int> > indexes;
59 indexes.push_back(std::vector<unsigned int>(1, 0));
60 indexes.push_back(std::vector<unsigned int>());
61 for (
int i = 1;
i <= 3; ++
i) {
62 indexes[1].push_back(
i);
64 indexes.push_back(std::vector<unsigned int>());
65 for (
int i = 4;
i <= 5; ++
i) {
66 indexes[2].push_back(
i);
70 typedef std::vector<unsigned int> indexVec;
71 for (
auto const&
index : indexes) {
79 rightWindowBorders[
i],
108 const std::vector<double>& parBgr,
109 const std::vector<int>& parBgrOrder,
110 const int muonType) {
111 std::vector<double>::const_iterator parBgrIt = parBgr.begin();
112 std::vector<int>::const_iterator parBgrOrderIt = parBgrOrder.begin();
114 for (
int iReg = 0; iReg < 3; ++iReg) {
123 parBgrOrderIt +
shift,
126 for (
int iRes = 0; iRes < 6; ++iRes) {
136 parBgrOrderIt +
shift,
171 if (doBackgroundFit) {
183 if (doBackgroundFit) {
193 std::vector<double>& parBgr,
194 const double* ResMass,
195 const double* massWindowHalfWidth,
196 const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& muonPairs,
202 unsigned int iRegion = 0;
205 std::vector<double>::const_iterator parBgrIt = (parBgr.begin() +
parNumsRegions_[iRegion]);
206 TF1* backgroundFunctionForIntegral = backgroundWindow.backgroundFunction()->functionForIntegral(parBgrIt);
208 double kOld = *parBgrIt;
209 double Nbw = backgroundWindow.events();
210 double Ibw = backgroundFunctionForIntegral->Integral(backgroundWindow.lowerBound(), backgroundWindow.upperBound());
213 for (
unsigned int index : *(backgroundWindow.indexes())) {
235 std::cout <<
"backgroundWindow.lowerBound = " << backgroundWindow.lowerBound() << std::endl;
236 std::cout <<
"backgroundWindow.upperBound = " << backgroundWindow.upperBound() << std::endl;
238 std::cout <<
"Nbw = " << Nbw <<
", Ibw = " << Ibw << std::endl;
239 std::cout <<
"Nrw = " << Nrw <<
", Irw = " << Irw << std::endl;
241 std::cout <<
"background fraction in background window = Nbw*k = " << Nbw * kOld << std::endl;
242 std::cout <<
"background fraction in resonance window = Nrw*k' = " << Nrw * kNew << std::endl;
245 delete backgroundFunctionForIntegral;
250 const double* parval,
253 const bool* resConsidered,
254 const double* ResMass,
255 const double ResHalfWidth[],
259 const double&
eta2) {
260 if (doBackgroundFit) {
264 return std::make_pair(
274 return std::make_pair(
281 const std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >& muonPairs,
285 resonanceWindow.resetCounter();
289 backgroundWindow.resetCounter();
293 std::pair<lorentzVector, lorentzVector> muonPair;
294 for (
auto const& muonPair : muonPairs) {
297 resonanceWindow.count((muonPair.first + muonPair.second).mass(),
weight);
301 backgroundWindow.count((muonPair.first + muonPair.second).mass(),
weight);
307 const std::vector<double>& leftWindowBorders,
308 const std::vector<double>& rightWindowBorders)
const noexcept(
false) {
309 if (leftWindowBorders.size() != rightWindowBorders.size()) {
311 <<
"BackgroundHandler::BackgroundHandler: leftWindowBorders.size() = " << leftWindowBorders.size()
312 <<
" != rightWindowBorders.size() = " << rightWindowBorders.size() << std::endl;
314 if (leftWindowBorders.size() != 3) {
316 <<
"BackgroundHandler::BackgroundHandler: leftWindowBorders.size() = rightWindowBorders.size() = "
317 << leftWindowBorders.size() <<
" != 3" << std::endl;
319 if (identifiers.size() != 3) {
321 <<
"BackgroundHandler::BackgroundHandler: identifiers must match the number of regions = 3" << std::endl;
325 #endif // BackgroundHandler_cc