5 #include "CLHEP/Vector/LorentzVector.h"
7 #include "CLHEP/Random/RandomEngine.h"
12 m_eventse(0), m_eventsmu(0), m_eventshad(0),
13 m_eventseacc(0), m_eventsmuacc(0), m_eventshadacc(0)
57 for(
int i=0;
i<6;
i++) {
63 return StatusCode::SUCCESS;
81 return StatusCode::SUCCESS;
86 CLHEP::HepLorentzVector nu( 0, 0, 0, 0);
87 if ( ( (std::abs(
part->pdg_id() ) == 12 ) || ( std::abs(
part->pdg_id() ) == 14 ) || ( std::abs(
part->pdg_id() ) == 16 ))
89 nu.setPx(
part->momentum().px());
90 nu.setPy(
part->momentum().py());
91 nu.setPz(
part->momentum().pz());
92 nu.setE(
part->momentum().e());
95 if (
part->end_vertex() == 0)
return nu;
106 CLHEP::HepRandomEngine* rndm{};
108 const EventContext& ctx = Gaudi::Hive::currentContext();
111 ATH_MSG_ERROR(
"Failed to retrieve random number engine for TauFilter");
112 setFilterPassed(
false);
113 return StatusCode::SUCCESS;
118 CLHEP::HepLorentzVector mom_tauprod;
119 CLHEP::HepLorentzVector tauvis;
120 CLHEP::HepLorentzVector nutau;
124 double ptlep_max = 0;
125 double pthad_max = 0;
128 int ntaulep_tight = 0;
129 int ntauhad_tight = 0;
136 setFilterPassed(
false);
137 return StatusCode::SUCCESS;
140 setFilterPassed(
false);
141 return StatusCode::SUCCESS;
144 auto wgtsC = genEvt->weights();
145 weight = wgtsC.size() > 0 ? wgtsC[0] : 1;
147 for (
const auto& pitr: *genEvt) {
154 tau->momentum().eta() <<
"\t" <<
155 tau->momentum().phi() <<
"\t" <<
156 tau->pdg_id() <<
"\t");
161 if(!tau->end_vertex())
continue;
162 for (
const auto&
beg: *(tau->end_vertex()) ) {
163 if ( (
beg)->production_vertex() != tau->end_vertex() )
continue;
165 else if ( std::abs( (
beg)->pdg_id() ) == 12 ) tauType = 1;
167 else if ( std::abs( (
beg)->pdg_id() ) == 14 ) tauType = 2;
169 else if ( std::abs( (
beg)->pdg_id() ) == 15 ) tauType = 11;
180 ATH_MSG_DEBUG(nutau.perp() <<
"\t" << nutau.eta() <<
"\t" << nutau.phi() <<
"\t" << tauType);
182 tauvis.setPx(tau->momentum().px()-nutau.px());
183 tauvis.setPy(tau->momentum().py()-nutau.py());
184 tauvis.setPz(tau->momentum().pz()-nutau.pz());
185 tauvis.setE(tau->momentum().e()-nutau.e());
187 ATH_MSG_DEBUG(tauvis.perp() <<
"\t" << tauvis.eta() <<
"\t" << tauvis.phi() <<
"\t" << tauType);
189 if ( tauType == 1 ) {
192 if ( tauvis.perp() <
m_pTmine )
continue;
193 if ( std::abs( tauvis.eta() ) >
m_etaMaxe )
continue;
199 if ( std::abs( tauvis.eta() ) >
m_etaMaxlep )
continue;
201 if ( tauvis.perp() >= ptlep_max ) ptlep_max = tauvis.perp();
206 else if ( tauType == 2 ) {
209 if ( tauvis.perp() <
m_pTminmu )
continue;
210 if ( std::abs( tauvis.eta() ) >
m_etaMaxmu )
continue;
216 if ( std::abs( tauvis.eta() ) >
m_etaMaxlep )
continue;
218 if ( tauvis.perp() >= ptlep_max ) ptlep_max = tauvis.perp();
223 else if ( tauType == 0 ) {
226 if ( std::abs( tauvis.eta() ) >
m_etaMaxhad )
continue;
230 if ( tauvis.perp() >= pthad_max ) pthad_max = tauvis.perp();
235 ATH_MSG_DEBUG(
"Could not find a tauType! Something went wrong.");
236 std::cout << std::endl << std::endl <<
"************ COULD NOT FIND A TAU TYPE *****************" << std::endl << std::endl;
248 bool pass2 = ( ntaulep_tight + ntauhad_tight >=
m_Ntau
255 bool pass3 = (ntaulep + ntauhad >=
m_Ntau
268 double extra_weight = 1;
276 double rnd = rndm->flat();
310 if (
evtStore()->retrieve( mecc ).isFailure() || !mecc ){
311 setFilterPassed(
false);
312 ATH_MSG_ERROR(
"Could not retrieve MC Event Collection - weight might not work");
313 return StatusCode::SUCCESS;
318 for (
unsigned int i = 0;
i < mec->
size(); ++
i) {
319 if (!(*mec)[
i])
continue;
320 double existingWeight = (*mec)[
i]->weights().
size()>0 ? (*mec)[
i]->weights()[0] : 1.;
321 if ((*mec)[
i]->weights().size()>0) {
322 (*mec)[
i]->weights()[0] = existingWeight*extra_weight;
324 (*mec)[
i]->weights().push_back( existingWeight*extra_weight );
333 setFilterPassed(pass);
335 return StatusCode::SUCCESS;
340 const EventContext& ctx)
const
344 rngWrapper->
setSeed( rngName, ctx );