ATLAS Offline Software
Loading...
Searching...
No Matches
DisambiguationInvmIncl2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4/*********************************
5 * DisambiguationInvmIncl2.cpp
6 * Created by Davide Gerbaudo on 2016-10-10.
7 *
8 * @brief compute the INVMASS**2 between distinct objects from two lists and applies invmass criteria
9 *
10 * The 'distinct object' criterion is based on the disambiguation
11 * as implemented in DisambiguationDRIncl2, where deltaR is > 0.
12 *
13**********************************/
14
15#include <cmath>
16
21
22REGISTER_ALG_TCS(DisambiguationInvmIncl2)
23
24
25// not the best solution but we will move to athena where this comes for free
26#define LOG std::cout << "TCS::DisambiguationInvmIncl2: "
27
28
30{
31 defineParameter("InputWidth1", 9);
32 defineParameter("InputWidth2", 9);
33 defineParameter("MaxTob1", 0);
34 defineParameter("MaxTob2", 0);
35 defineParameter("NumResultBits", 2);
36 defineParameter("MinET1", 1, 0);
37 defineParameter("MinET2", 1, 0);
38 defineParameter("MinMSqr", 0, 0);
39 defineParameter("MaxMSqr", 0, 0);
40 defineParameter("MinET1", 1, 1);
41 defineParameter("MinET2", 1, 1);
42 defineParameter("MinMSqr", 0, 1);
43 defineParameter("MaxMSqr", 0, 1);
44
46}
47
49
52 p_NumberLeading1 = parameter("InputWidth1").value();
53 p_NumberLeading2 = parameter("InputWidth2").value();
54 if(parameter("MaxTob1").value() > 0) p_NumberLeading1 = parameter("MaxTob1").value();
55 if(parameter("MaxTob2").value() > 0) p_NumberLeading2 = parameter("MaxTob2").value();
56
57 for(unsigned int i=0; i<numberOutputBits(); ++i) {
58 p_MinET1[i] = parameter("MinET1",i).value();
59 p_MinET2[i] = parameter("MinET2",i).value();
60 p_InvMassMin[i] = parameter("MinMSqr", i).value();
61 p_InvMassMax[i] = parameter("MaxMSqr", i).value();
62 TRG_MSG_INFO("MinET1 : " << i << " : "<< p_MinET1[i]);
63 TRG_MSG_INFO("MinET2 : " << i << " : "<< p_MinET2[i]);
64 TRG_MSG_INFO("MinMSqr : " << i << " : "<< p_InvMassMin[i]);
65 TRG_MSG_INFO("MaxMSqr : " << i << " : "<< p_InvMassMin[i]);
66 }
67 TRG_MSG_INFO("number output : " << numberOutputBits());
69}
70
72TCS::DisambiguationInvmIncl2::processBitCorrect(const std::vector<TCS::TOBArray const *> & input,
73 const std::vector<TCS::TOBArray *> & output,
74 Decision & decision)
75{
76 if(input.size() == 2) {
77 for(TOBArray::const_iterator tob1 = input[0]->begin();
78 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
79 ++tob1) {
80 for(TCS::TOBArray::const_iterator tob2 = input[1]->begin();
81 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
82 ++tob2) {
83 unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
84 unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
85 for(unsigned int i=0; i<numberOutputBits(); ++i) {
86 bool accept = false;
87 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
88 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue; // ET cut
89 accept = (deltaR2 > 0 &&
90 invmass2 >= p_InvMassMin[i] &&
91 invmass2 <= p_InvMassMax[i] );
92 if( accept ) {
93 decision.setBit(i, true);
94 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
95 }
96 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail")
97 << " deltaR = " << deltaR2
98 << " invmass2 = " << invmass2);
99 } // for(i)
100 } // for(tob2)
101 } // for(tob1)
102 for (unsigned int i=0; i < numberOutputBits(); ++i) {
103 bool hasAmbiguousInputs = TSU::isAmbiguousTruncation(input[0], p_NumberLeading1, p_MinET1[i])
105 output[i]->setAmbiguityFlag(hasAmbiguousInputs);
106 }
107 } else {
108 TCS_EXCEPTION("DisambiguationInvmIncl2 alg must have 2 inputs, but got " << input.size());
109 }
111}
112
114TCS::DisambiguationInvmIncl2::process(const std::vector<TCS::TOBArray const *> & input,
115 const std::vector<TCS::TOBArray *> & output,
116 Decision & decision)
117{
118 if( input.size() == 2) {
119 for( TOBArray::const_iterator tob1 = input[0]->begin();
120 tob1 != input[0]->end() && distance(input[0]->begin(), tob1) < p_NumberLeading1;
121 ++tob1) {
122 for(TCS::TOBArray::const_iterator tob2 = input[1]->begin();
123 tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
124 ++tob2) {
125 unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
126 unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
127 for(unsigned int i=0; i<numberOutputBits(); ++i) {
128 bool accept = false;
129 if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue;
130 if( parType_t((*tob2)->Et()) <= p_MinET2[i]) continue;
131 accept = (deltaR2 > 0 &&
132 invmass2 >= p_InvMassMin[i] &&
133 invmass2 <= p_InvMassMax[i] );
134 if( accept ) {
135 decision.setBit(i, true);
136 output[i]->push_back(TCS::CompositeTOB(*tob1, *tob2));
137 }
138 TRG_MSG_DEBUG("Decision " << i << ": " << (accept?"pass":"fail") << " deltaR = " << deltaR2 );
139 } // for(i)
140 } // for(tob2)
141 } // for(tob1)
142 } else {
143 TCS_EXCEPTION("DisambiguationInvmIncl2 alg must have 2 inputs, but got " << input.size());
144 }
146}
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
const Parameter & parameter(const std::string &parameterName) const
const std::string & name() const
unsigned int calcDeltaR2BW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcInvMassBW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
void defineParameter(const std::string &name, TCS::parType_t value)
unsigned int calcDeltaR2(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
unsigned int calcInvMass(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
data_t::const_iterator const_iterator
void setNumberOutputBits(unsigned int numberOutputBits)
Definition DecisionAlg.h:40
DecisionAlg(const std::string &name)
Definition DecisionAlg.h:25
unsigned int numberOutputBits() const
Definition DecisionAlg.h:39
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
DisambiguationInvmIncl2(const std::string &name)
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
uint32_t parType_t
Definition Parameter.h:22
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)