6 #include "CLHEP/Random/RandomEngine.h"
16 m_eventse(0), m_eventsmu(0), m_eventshad(0),
17 m_eventseacc(0), m_eventsmuacc(0), m_eventshadacc(0)
61 for(
int i=0;
i<6;
i++) {
67 return StatusCode::SUCCESS;
85 return StatusCode::SUCCESS;
91 CLHEP::HepRandomEngine* rndm{};
93 const EventContext& ctx = Gaudi::Hive::currentContext();
96 ATH_MSG_ERROR(
"Failed to retrieve random number engine for xAODTauFilter");
97 setFilterPassed(
false);
98 return StatusCode::SUCCESS;
102 CLHEP::HepLorentzVector mom_tauprod;
103 CLHEP::HepLorentzVector tauvis;
104 CLHEP::HepLorentzVector nutau;
107 double ptlep_max = 0;
108 double pthad_max = 0;
111 int ntaulep_tight = 0;
112 int ntauhad_tight = 0;
120 setFilterPassed(
false);
124 setFilterPassed(
false);
125 return StatusCode::SUCCESS;
128 setFilterPassed(
false);
129 return StatusCode::SUCCESS;
132 auto wgtsC = genEvt->weights();
133 weight = wgtsC.size() > 0 ? wgtsC[0] : 1;
137 for (
const auto * truthtau : *vtruth) {
145 tau->
phi() <<
"\t" <<
146 tau->
pdgId() <<
"\t");
155 int tauType = tauTypeAcc (*tau);
163 nutau = nuVectorAcc (*tau);
165 ATH_MSG_DEBUG(nutau.perp() <<
" nutau \t" << nutau.eta() <<
"\t" << nutau.phi() <<
"\t" << tauType);
167 tauvis.setPx(tau->
px()-nutau.px());
168 tauvis.setPy(tau->
py()-nutau.py());
169 tauvis.setPz(tau->
pz()-nutau.pz());
170 tauvis.setE(tau->
e()-nutau.e());
172 ATH_MSG_DEBUG(tauvis.perp() <<
" tauvis \t" << tauvis.eta() <<
"\t" << tauvis.phi() <<
"\t" << tauType);
173 if ( tauType == 1 ) {
176 if ( tauvis.perp() <
m_pTmine )
continue;
177 if ( std::abs( tauvis.eta() ) >
m_etaMaxe )
continue;
183 if ( std::abs( tauvis.eta() ) >
m_etaMaxlep )
continue;
185 if ( tauvis.perp() >= ptlep_max ) ptlep_max = tauvis.perp();
190 else if ( tauType == 2 ) {
193 if ( tauvis.perp() <
m_pTminmu )
continue;
194 if ( std::abs( tauvis.eta() ) >
m_etaMaxmu )
continue;
200 if ( std::abs( tauvis.eta() ) >
m_etaMaxlep )
continue;
202 if ( tauvis.perp() >= ptlep_max ) ptlep_max = tauvis.perp();
207 else if ( tauType == 0 ) {
210 if ( std::abs( tauvis.eta() ) >
m_etaMaxhad )
continue;
214 if ( tauvis.perp() >= pthad_max ) pthad_max = tauvis.perp();
219 ATH_MSG_DEBUG(
"Could not find a tauType! Something went wrong.");
220 std::cout << std::endl << std::endl <<
"************ COULD NOT FIND A TAU TYPE *****************" << std::endl << std::endl;
231 bool pass2 = ( ntaulep_tight + ntauhad_tight >=
m_Ntau
238 bool pass3 = (ntaulep + ntauhad >=
m_Ntau
252 double extra_weight = 1;
260 double rnd = rndm->flat();
294 if (
evtStore()->retrieve( mecc ).isFailure() || !mecc ){
295 setFilterPassed(
false);
296 ATH_MSG_ERROR(
"Could not retrieve MC Event Collection - weight might not work");
297 return StatusCode::SUCCESS;
302 for (
unsigned int i = 0;
i < mec->
size(); ++
i) {
303 if (!(*mec)[
i])
continue;
304 double existingWeight = (*mec)[
i]->weights().
size()>0 ? (*mec)[
i]->weights()[0] : 1.;
305 if ((*mec)[
i]->weights().size()>0) {
306 for (
unsigned int iw = 0; iw < (*mec)[
i]->weights().size(); ++iw) {
307 double existWeight = (*mec)[
i]->weights()[iw];
308 (*mec)[
i]->weights()[iw] = existWeight*extra_weight;
313 (*mec)[
i]->weights().push_back( existingWeight*extra_weight );
317 (*mec)[
i]->add_attribute(
"filterWeight", std::make_shared<HepMC3::DoubleAttribute>(extra_weight));
327 setFilterPassed(pass);
329 return StatusCode::SUCCESS;
334 const EventContext& ctx)
const
338 rngWrapper->
setSeed( rngName, ctx );