5 #include "GaudiKernel/ConcurrencyFlags.h"
15 declareInterface<NSWL1::IStripSegmentTool>(
this);
22 const INamedInterface* pnamed =
dynamic_cast<const INamedInterface*
>(
parent);
23 const std::string& algo_name = pnamed->name();
25 if (Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1) {
26 ATH_MSG_ERROR(
"DoNtuple is not possible in multi-threaded mode");
27 return StatusCode::FAILURE;
33 if ( algo_name==
"NSWL1Simulation" ) {
34 SmartIF<ITHistSvc> tHistSvc{service(
"THistSvc")};
36 std::string ntuple_name = algo_name+
"Tree";
45 return StatusCode::SUCCESS;
49 if( inc.type()==IncidentType::BeginEvent ) {
63 moduleList.push_back(regSelector->Module(moduleHashId));
71 std::sort(
moduleList.begin(),
moduleList.end(),[](
const auto& M1,
const auto& M2){ return std::abs(M1->_etaMin()) < std::abs(M2->_etaMin());} );
73 std::sort(
moduleList.begin(),
moduleList.end(),[](
const auto& M1,
const auto& M2){ return std::abs(M1->_etaMax()) > std::abs(M2->_etaMax());} );
75 std::sort(
moduleList.begin(),
moduleList.end(),[](
const auto& M1,
const auto& M2){ return std::abs(M1->rMin()) < std::abs(M2->rMin());} );
77 std::sort(
moduleList.begin(),
moduleList.end(),[](
const auto& M1,
const auto& M2){ return std::abs(M1->rMax()) > std::abs(M2->rMax());} );
79 std::sort(
moduleList.begin(),
moduleList.end(),[](
const auto& M1,
const auto& M2){ return std::abs(M1->zMin()) < std::abs(M2->zMin());} );
81 std::sort(
moduleList.begin(),
moduleList.end(),[](
const auto& M1,
const auto& M2){ return std::abs(M1->zMax()) > std::abs(M2->zMax());} );
84 if(rmin<=0 || rmax<=0)
ATH_MSG_WARNING(
"Unable to fetch NSW r/z boundaries");
88 env.upper_eta = etamax;
91 ATH_MSG_DEBUG(
"rmin=" << rmin <<
" rmax=" << rmax <<
" zmin=" <<
zmin <<
" zmax=" <<
zmax <<
" etamin=" <<
etamin <<
" etamax=" << etamax);
92 return StatusCode::SUCCESS;
97 std::pair<float,float>
range;
103 range=std::make_pair(
env.lower_eta,
env.upper_eta);
128 const std::unique_ptr<Muon::NSW_TrigRawDataContainer>& trgContainer)
const {
134 return StatusCode::SUCCESS;
137 std::map<uint32_t, std::vector<std::unique_ptr<StripClusterData>>[2] > cluster_map;
149 sectorid=
cl->sectorId();
150 if(
cl->isSmall()) sectorNumber=2*sectorid;
151 else sectorNumber=2*sectorid-1;
152 hash=16*sideid+sectorNumber;
162 auto item =cluster_map.find(hash_bandid);
163 if (
item != cluster_map.end()){
164 item->second[
cl->wedge()-1].push_back(std::move(
cl));
167 cluster_map[hash_bandid][
cl->wedge()-1].push_back(std::move(
cl));
173 for(
const auto& band : cluster_map){
174 int bandId=band.first;
175 if (band.second[0].size() == 0){
176 ATH_MSG_WARNING(
"Cluster size is zero for inner wedge trg with bandId "<<bandId<<
"...skipping");
179 if(band.second[1].size() == 0){
180 ATH_MSG_WARNING(
"Cluster size is zero for outer wedge trg with bandId "<<bandId<<
"...skipping");
202 char sectorSide =
'-';
203 for(
const auto&
cl : band.second[0] ){
204 z1+=
cl->globZ()*
cl->charge();
205 glx1+=
cl->globX()*
cl->charge();
206 gly1+=
cl->globY()*
cl->charge();
207 charge1+=
cl->charge();
208 sectorID = (
cl->isSmall()) ? 2*
cl->sectorId()-1 : 2*(
cl->sectorId()-1);
209 sectorSide = (
cl->sideId() == 0) ?
'C' :
'A';
212 auto trgRawData=std::make_unique< Muon::NSW_TrigRawData>(sectorID, sectorSide, bcID);
216 for(
const auto&
cl : band.second[1] ){
217 z2+=
cl->globZ()*
cl->charge();
218 glx2+=
cl->globX()*
cl->charge();
219 gly2+=
cl->globY()*
cl->charge();
220 charge2+=
cl->charge();
221 sectorID = (
cl->isSmall()) ? 2*
cl->sectorId()-1 : 2*(
cl->sectorId()-1);
222 sectorSide = (
cl->sideId() == 0) ?
'C' :
'A';
224 if (( sectorID != trgRawData->sectorId() ) ||
225 ( sectorSide != trgRawData->sectorSide() ) ||
226 ( bcID != trgRawData->bcId() ))
ATH_MSG_WARNING(
"Possible mismatch between inner and outer wedge RDO parameters");
242 float avg_z=(z1+z2)/2.;
245 ROOT::Math::XYZVector v3_centr1(glx1,gly1,z1), v3_centr2(glx2,gly2,z2);
246 ROOT::Math::XYZVector v3_segment = v3_centr2 - v3_centr1;
247 phi=v3_segment.Phi();
248 theta=v3_segment.Theta();
249 eta=v3_segment.Eta();
252 theta_inf=v3_centr1.Theta();
253 eta_inf=v3_centr1.Eta();
254 dtheta=(theta-theta_inf)*1000;
256 ATH_MSG_DEBUG(
"StripSegmentTool: phi:" <<
phi <<
" theta:" << theta <<
" eta: " <<
eta <<
" theta_inf: " << theta_inf <<
" eta_inf: " << eta_inf <<
" dtheta: " << dtheta);
259 int phiId=band.second[0].at(0)->phiId();
265 return StatusCode::SUCCESS;
274 rIndex=
findRIdx(std::abs(eta_inf), envelope);
285 m_seg_wedge1_size->push_back(band.second[0].size());
286 m_seg_wedge2_size->push_back(band.second[1].size());
287 m_seg_bandId->push_back(bandId);
288 m_seg_phiId->push_back(phiId);
289 m_seg_rIdx->push_back(rIndex);
290 m_seg_theta->push_back(theta);
291 m_seg_dtheta->push_back(dtheta);
292 m_seg_dtheta_int->push_back(dtheta_int);
293 m_seg_eta->push_back(
eta);
294 m_seg_eta_inf->push_back(eta_inf);
295 m_seg_phi->push_back(
phi);
296 m_seg_global_x->push_back(glx);
297 m_seg_global_y->push_back(gly);
298 m_seg_global_z->push_back(avg_z);
302 if(std::abs(dtheta)>15)
continue;
303 auto rdo_segment= std::make_unique<Muon::NSW_TrigRawDataSegment>( dtheta_int, (
uint8_t)phiId, (rIndex), lowRes, phiRes);
304 trgRawData->push_back(std::move(rdo_segment));
305 trgContainer->
push_back(std::move(trgRawData));
308 return StatusCode::SUCCESS;
313 m_seg_theta =
new std::vector< float >();
314 m_seg_dtheta =
new std::vector< float >();
315 m_seg_dtheta_int =
new std::vector< uint8_t >();
316 m_seg_eta =
new std::vector< float >();
317 m_seg_eta_inf=
new std::vector< float >();
318 m_seg_phi =
new std::vector< float >();
319 m_seg_global_x =
new std::vector< float >();
320 m_seg_global_y =
new std::vector< float >();
321 m_seg_global_z =
new std::vector< float >();
322 m_seg_bandId =
new std::vector< int >();
323 m_seg_phiId =
new std::vector< int >();
324 m_seg_rIdx=
new std::vector< int >();
325 m_seg_wedge1_size =
new std::vector< int >();
326 m_seg_wedge2_size =
new std::vector< int >();
329 std::string ToolName =
name().substr(
name().
find(
"::")+2,std::string::npos );
330 const char*
n = ToolName.c_str();
346 return StatusCode::SUCCESS;
350 if(
m_tree==
nullptr)
return;
352 m_seg_theta->clear();
353 m_seg_dtheta->clear();
354 m_seg_dtheta_int->clear();
356 m_seg_eta_inf->clear();
358 m_seg_global_x->clear();
359 m_seg_global_y->clear();
360 m_seg_global_z->clear();
361 m_seg_bandId->clear();
362 m_seg_phiId->clear();
364 m_seg_wedge2_size->clear();
365 m_seg_wedge1_size->clear();