5 #include "GaudiKernel/ConcurrencyFlags.h"
23 using STRIP_MAP=std::map < Identifier,std::vector<StripHits> >;
29 m_incidentSvc(
"IncidentSvc",
name),
30 m_detManager(nullptr),
33 declareInterface<NSWL1::IStripTdsTool>(
this);
41 << std::setfill(
' ') << std::setiosflags(std::ios::right) );
47 const INamedInterface* pnamed =
dynamic_cast<const INamedInterface*
>(
parent);
48 const std::string& algo_name = pnamed->name();
51 if (Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1) {
52 ATH_MSG_ERROR(
"DoNtuple is not possible in multi-threaded mode");
53 return StatusCode::FAILURE;
59 if ( algo_name==
"NSWL1Simulation" ) {
60 SmartIF<ITHistSvc> tHistSvc{service(
"THistSvc")};
63 std::string ntuple_name = algo_name+
"Tree";
64 ATH_CHECK(tHistSvc->getTree(ntuple_name,m_tree));
70 return StatusCode::SUCCESS;
74 if( inc.type()==IncidentType::BeginEvent ) {
82 m_stripCharge=
new std::vector< float >();
83 m_stripCharge_6bit=
new std::vector< float >();
84 m_stripCharge_10bit=
new std::vector< float >();
85 m_strip_global_X=
new std::vector< float >();
86 m_strip_global_Y=
new std::vector< float >();
87 m_strip_global_Z=
new std::vector< float >();
88 m_strip_local_X=
new std::vector< float >();
89 m_strip_local_Y=
new std::vector< float >();
90 m_strip_layer=
new std::vector< float >();
91 m_strip_isSmall=
new std::vector< bool >();
92 m_strip_eta=
new std::vector< float >();
93 m_strip_phi=
new std::vector< float >();
94 m_strip_readStrip =
new std::vector<bool >();
95 m_strip_channel=
new std::vector< int >();
96 m_strip_BCID=
new std::vector< int >();
97 m_strip_wedge=
new std::vector< int >();
98 m_strip_time=
new std::vector< float >();
101 std::string ToolName =
name().substr(
name().
find(
"::")+2,std::string::npos );
102 const char*
n = ToolName.c_str();
122 return StatusCode::SUCCESS;
127 if(m_tree==0)
return;
129 m_stripCharge->clear();
130 m_stripCharge_6bit->clear();
131 m_stripCharge_10bit->clear();
132 m_stripCharge->clear();
133 m_stripCharge_6bit->clear();
134 m_stripCharge_10bit->clear();
135 m_strip_global_X->clear();
136 m_strip_global_Y->clear();
137 m_strip_global_Z->clear();
138 m_strip_local_X->clear();
139 m_strip_local_Y->clear();
140 m_strip_layer->clear();
141 m_strip_isSmall->clear();
142 m_strip_eta->clear();
143 m_strip_phi->clear();
144 m_strip_readStrip->clear();
145 m_strip_channel->clear();
146 m_strip_BCID->clear();
147 m_strip_time->clear();
148 m_strip_wedge->clear();
152 for (
const auto &hit : strip_cache) {
154 ATH_MSG_DEBUG(
"Hits :" << m_nStripHits <<
" Cache strip " << hit.get() <<
" " << strip_cache.size() );
156 m_stripCharge->push_back(hit->strip_charge());
157 m_stripCharge_6bit->push_back(hit->strip_charge_6bit());
158 m_stripCharge_10bit->push_back(hit->strip_charge_10bit());
159 m_strip_readStrip->push_back(hit->readStrip());
160 m_strip_channel->push_back(hit->channelId());
161 m_strip_BCID->push_back(hit->trig_BCID());
162 m_strip_time->push_back(hit->time());
163 m_strip_wedge->push_back(hit->wedge());
169 ATH_MSG_DEBUG(
"gather_strip_data: start gathering all strip htis");
171 std::vector<std::unique_ptr<StripData>> strip_cache;
175 for (
unsigned int i=0;
i< strip_cache.size();
i++) {
177 strips.push_back(std::move(strip_cache.at(
i)));
180 ATH_MSG_DEBUG(
"Delivered n. " << strips.size() <<
" STRIP hits." );
181 return StatusCode::SUCCESS;
186 ATH_MSG_DEBUG(
"fill_strip_cache: start filling the cache for STRIP hits" );
191 ATH_MSG_WARNING(
"could not retrieve the sTGC SDO container: it will not be possible to associate the MC truth");
196 if(!digit_container.
isValid()){
197 ATH_MSG_ERROR(
"could not retrieve the sTGC Digit container: cannot return the STRIP hits");
204 int strip_hit_number = 0;
205 for(;
it!=it_e; ++
it) {
221 const auto& stripSurface=rdoEl->
surface(Id);
222 stripSurface.
localToGlobal(strip_lpos, strip_gpos, strip_gpos);
225 int stationEta =
m_idHelperSvc->stgcIdHelper().stationEta(Id);
226 int stationPhi =
m_idHelperSvc->stgcIdHelper().stationPhi(Id);
230 int bctag =
digit->bcTag();
236 ATH_MSG_DEBUG(
"sTGC Strip hit " << strip_hit_number <<
": Station Name [" << stName <<
"]"
237 <<
" Station Eta [" << stationEta <<
"]"
238 <<
" Station Phi [" << stationPhi <<
"]"
239 <<
" Wedge [" << wedge <<
"]"
240 <<
" Layer [" <<
layer <<
"]"
243 <<
" Strip Eta [" << strip_eta <<
"]"
244 <<
" Strip Phi [" << strip_phi <<
"]"
245 <<
" Strip bcTAg [" << bctag <<
"]");
248 int trigger_sector = (isSmall)? stationPhi*2 : stationPhi*2-1;
249 int cache_index = (stationEta>0)? trigger_sector + 16 : trigger_sector;
250 ATH_MSG_DEBUG(
"sTGC Strip hit " << strip_hit_number <<
": Trigger Sector [" << trigger_sector <<
"]" <<
" Cache Index [" << cache_index <<
"]" );
255 m_strip_global_X->push_back(strip_gpos.x());
256 m_strip_global_Y->push_back(strip_gpos.y());
257 m_strip_global_Z->push_back(strip_gpos.z());
258 m_strip_local_X->push_back(strip_lpos.x());
259 m_strip_local_Y->push_back(strip_lpos.y());
260 m_strip_layer->push_back(
layer);
261 m_strip_isSmall->push_back(isSmall);
262 m_strip_eta->push_back(stationEta);
263 m_strip_phi->push_back(stationPhi);
265 auto strip=std::make_unique<StripOfflineData>(Id,&
m_idHelperSvc->stgcIdHelper(),
digit);
266 strip->set_locX(strip_lpos.x());
267 strip->set_locY(strip_lpos.y());
268 int sideid= (stationEta>0) ? 1 : 0;
269 int sectortype= (isSmall==1) ? 0 : 1;
270 int sectorid=stationPhi;
271 int moduleid=std::abs(stationEta);
274 strip->setSideId(sideid);
275 strip->setSectorType(sectortype);
276 strip->setSectorId(sectorid);
277 strip->setModuleId(moduleid);
278 strip->setWedgeId(wedgeid);
279 strip->setLayerId(layerid);
280 strip->set_globX(strip_gpos.x());
281 strip->set_globY(strip_gpos.y());
282 strip->set_globZ(strip_gpos.z());
285 bool read_strip=
readStrip(strip.get(),padTriggers);
286 if (read_strip && (strip->bandId() ==-1 || strip->phiId()==-1 ) ) {
288 <<
"wedge:" << strip->wedge() <<
"\n"
289 <<
"layer:"<< strip->layer() <<
"\n"
290 <<
"loc_x:"<< strip->locX()<<
"\n");
294 strip->set_readStrip(read_strip);
295 strip_cache.push_back(std::move(strip));
300 return StatusCode::SUCCESS;
306 if (strip->bandId() !=-1) {
307 ATH_MSG_DEBUG(
"StripTdsOfflineTool:ReadStrip: BandId already set\n" <<
"moduleID:" << strip->moduleId() +1 <<
"\n"
308 <<
"sectiorID:" << strip->sectorId() + 1 <<
"\n" <<
"layer:" << strip->wedge() <<
"\n");
310 if (strip->phiId() !=-1) {
311 ATH_MSG_DEBUG(
"StripTdsOfflineTool:ReadStrip: PhiId already set\n" <<
"moduleID:"<< strip->moduleId() +1 <<
"\n"
312 <<
"sectiorID:" << strip->sectorId() + 1 <<
"\n" <<
"layer:" << strip->wedge() <<
"\n");
314 for(
const std::unique_ptr<PadTrigger>& trig :padTriggers){
316 for(
const std::shared_ptr<PadData>& pad : trig->m_pads){
317 if (strip->sideId()!=pad->sideId() ||
318 strip->isSmall()==pad->sectorType() ||
319 strip->sectorId()!=pad->sectorId() ||
320 std::abs(strip->etaCenter() )> trig->etaMax() ||
321 std::abs(strip->etaCenter() ) < trig->etaMin() ||
322 strip->layer()!=pad->gasGapId()
325 strip->setBandId(trig->bandId());
326 strip->setPhiId(trig->phiId());