ATLAS Offline Software
Loading...
Searching...
No Matches
MdtVsTgcRawData_MidstationMatching.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Package : MdtVsTgcRawDataValAlg
7// Author: M.King(Kobe)
8// Feb. 2011
9//
10// DESCRIPTION:
11// Subject: TGC Efficiency -->TGC Efficiency plots including EIFI by comparing with MDT Segments
13
15
21
23
24#include <inttypes.h>
25
26#include <sstream>
27#include <algorithm>
28#include <fstream>
29
30// Use Midstation Segments to look for additional Midstation Segments
31// Only the Midstation covers some trajectories so normal SegmTracks cannot be constructed
32void
33MdtVsTgcRawDataValAlg::MidstationOnlyCheck(std::vector<const Muon::MuonSegment*> (&sortedSegments)[2][4],
34 std::vector<const Muon::MuonSegment*> (&disqualifiedSegments)[2][4],
35 const Muon::TgcPrepDataContainer *tgc_prepcontainer){
36 // Define Cuts:
37 // Cut for matching Segments
38 const float dRhoCutSegmentMatching = 1000;
39 const float dPhiCutSegmentMatching = M_PI/8;
40
41 // Cuts for number of Mdt Measurements required for Midstation only track
42 const int nMeasCutMdtMidstation = 5;
43 const int nMeasCutTGCMidPRD[2] = {2,2};
44
45 // Loose cut for PRD and Extrapolated
46 const float dPhiCut_Loose = M_PI/8;
47 // Cut for Global Position Efficiencies
48 const float dPhiCutGlobal[2] = {static_cast<float>(M_PI/24),static_cast<float>(M_PI/12)};//[WireStrip]
49 const float dRhoCutGlobal[2] = { 0.08, 0.5};//[WireStrip]
50 // Cut for Sector Efficiencies
51 const float dPhiCutSector[2] = { 0.2, 0.1};//[WireStrip]
52 const float dRhoCutSector[2] = { 300, 3000};//[WireStrip]
53 // Cut for TgcPrepData comparison
54 const float dPhiCutTPD[2] = { 0.15, 0.02};//[WireStrip]
55 const float dRhoCutTPD[2] = { 150, 3000};//[WireStrip]
56
57 // Loop over sides
58 for(int i=0;i<2;i++){// AC
59 // Number of Segments found which passed all cuts
60 int nValidatedSegm = 0;
61
62 // Following "Fill" variables are only used if one segment passed all cuts
63 // Flags for whether different stations can be checked by the segment
64 //bool canCheckGlobalFill[4] = {0, 0, 0, 0};
65 bool canCheckSectorFill[4] = {0, 0, 0, 0};
66 // Segment Global Position variables
67 // float posThetaFill = 0;
68 // float posPhiFill = 0;
69 // Segment Sector Position
70 int TGCstation_StationFEFill[4] = {-1,-1,-1,-1};// [TGCStation]
71 int TGCstation_StationEtaFill[4] = { 0, 0, 0, 0};// [TGCStation]
72 int TGCstation_StationPhiFill[4] = { 0, 0, 0, 0};// [TGCStation]
73 // Hit registered arrays
74 // bool hitregisteredFill[9][2] = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
75 bool sectorhitregisteredFill[9][2] = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
76
77 bool skipSegm;int nDisqualifiedSegm; // used when checking the disqualified list for a segment
78
79 // Make copy of disqualifiedSegment vector array
80 std::vector<const Muon::MuonSegment*> copyDisqualifiedSegments;
81 nDisqualifiedSegm=disqualifiedSegments[i][2].size();
82 copyDisqualifiedSegments.reserve(nDisqualifiedSegm);
83for(int ndis=0;ndis<nDisqualifiedSegm;ndis++)copyDisqualifiedSegments.push_back(disqualifiedSegments[i][2].at(ndis));
84
86 // Apply preliminary nMdtMeas Cut
87 int nSegm = sortedSegments[i][2].size();
88 for(int n0=0; n0<nSegm;n0++){
89 // Get segment
90 const Muon::MuonSegment *segm0 = sortedSegments[i][2].at(n0);
91
92 // Check copyDisqualifiedSegments for current segment
93 skipSegm=false;
94 nDisqualifiedSegm=copyDisqualifiedSegments.size();
95 for(int ndis=0;ndis<nDisqualifiedSegm;ndis++)if(segm0==copyDisqualifiedSegments.at(ndis))skipSegm=true;
96 if(skipSegm)continue;
97
98 // Apply nMDTMeasurements Cut to Segment Collection
99 int stationName = 0;
100 int nMdtMeas = 0;
101 // Loop through contained ROTs and identify used stations
102 for(unsigned int iROT=0; iROT<segm0->numberOfContainedROTs(); ++iROT) {
103 const Trk::RIO_OnTrack* rio = segm0->rioOnTrack(iROT);
104 if(!rio) continue;
105 Identifier id = rio->identify();
106 stationName = int(m_idHelperSvc->mdtIdHelper().stationName(id));
107
108 if((stationName==17)||(stationName==18))nMdtMeas++;// MDT
109 }
110 // Cut Segments with insufficient numbers of hits in the stations
111 if(nMdtMeas<nMeasCutMdtMidstation){
112 copyDisqualifiedSegments.push_back(segm0);
113 }
114 }
115
116 // Loop over Segments in MidStation
117 for(int n1=0; n1<nSegm;n1++){
119 // Start operation on Segment
120 // Get segment
121 const Muon::MuonSegment *segm1 = sortedSegments[i][2].at(n1);
122
123 // Check copyDisqualifiedSegments for current segment
124 skipSegm=false;
125 nDisqualifiedSegm=copyDisqualifiedSegments.size();
126 for(int ndis=0;ndis<nDisqualifiedSegm;ndis++)if(segm1==copyDisqualifiedSegments.at(ndis))skipSegm=true;
127 if(skipSegm)continue;
128
129 // Flag for Grouping cut
130 bool failedGroupingCut = false;
131 // Flags for whether different stations can be checked by the segment
132 bool canCheckGlobal[4] = {true, true, true, false};
133 bool canCheckSector[4] = {true, true, true, false};
134
135 // Get position variables
136 //const Trk::GlobalPosition segm1Pos = segm1->globalPosition();
137 const Amg::Vector3D segm1Pos = segm1->globalPosition();
138
139 float segm1PosPhi = segm1Pos.phi();
140 float segm1PosThe = segm1Pos.theta();
141 float segm1PosZ = segm1Pos.z();
142 if(segm1PosPhi<0)segm1PosPhi+=2*M_PI;
143 if(segm1PosThe>M_PI/2) segm1PosThe=M_PI-segm1PosThe;
144 Amg::Vector3D segm1PosZunit(segm1Pos/std::abs(segm1PosZ));
145
146
148 // Apply nTGCStripMeasurements Cut to canCheck arrays
149 int stationName = 0;
150 int nTGCStrips[4] = { 0, 0, 0, 0};
151 // Loop through contained ROTs and identify used stations
152 for(unsigned int iROT=0; iROT<segm1->numberOfContainedROTs(); ++iROT){
153 const Trk::RIO_OnTrack* rio = segm1->rioOnTrack(iROT);
154 if(!rio) continue;
155 Identifier id = rio->identify();
156 stationName = int(m_idHelperSvc->mdtIdHelper().stationName(id));
157 bool isStrip = m_idHelperSvc->tgcIdHelper().isStrip(id);
158
159 if(((stationName==41)||(stationName==42))&&isStrip)nTGCStrips[0]++;// TGC
160 if(((stationName==43)||(stationName==44))&&isStrip)nTGCStrips[1]++;// TGC
161 if(((stationName==45)||(stationName==46))&&isStrip)nTGCStrips[2]++;// TGC
162 if(((stationName==47)||(stationName==48))&&isStrip)nTGCStrips[3]++;// TGC
163 }
164
165 // Don't check mid-stations when there are no strips in other mid-stations
166 if((nTGCStrips[1]==0)&&(nTGCStrips[2]==0)){canCheckSector[0]=false;canCheckGlobal[0]=false;}
167 if((nTGCStrips[0]==0)&&(nTGCStrips[2]==0)){canCheckSector[1]=false;canCheckGlobal[1]=false;}
168 if((nTGCStrips[0]==0)&&(nTGCStrips[1]==0)){canCheckSector[2]=false;canCheckGlobal[2]=false;}
169
170
172 // Do Grouping Cut
173 // Ignore any segments which are too close to any other segments not in the original disqualified list
174 for(int n2=0; n2<nSegm;n2++){
175 if(n1==n2)continue; // don't compare segment to itself
176 // Get segment
177 const Muon::MuonSegment *segm2 = sortedSegments[i][2].at(n2);
178
179 // Check disqualifiedSegments for current segment
180 skipSegm=false;
181 nDisqualifiedSegm=disqualifiedSegments[i][2].size();
182 for(int ndis=0;ndis<nDisqualifiedSegm;ndis++)if(segm1==disqualifiedSegments[i][2].at(ndis))skipSegm=true;
183 if(skipSegm)continue;
184
185 // Get position variables
186 const Amg::Vector3D segm2Pos = segm2->globalPosition();
187 float segm2PosRho = std::abs(segm2Pos.perp());
188 float segm2PosPhi = segm2Pos.phi();
189 float segm2PosZ = segm2Pos.z();
190 if(segm2PosPhi<0)segm2PosPhi+=2*M_PI;
191 Amg::Vector3D segm2PosZunit(segm2Pos/std::abs(segm2PosZ));
192
193 // Apply preliminary phi cut between segm1 and segm2 positions
194 float dPhi_Segm1_Segm2 = segm1PosPhi-segm2PosPhi;
195 if(dPhi_Segm1_Segm2<-M_PI)dPhi_Segm1_Segm2+=2*M_PI;
196 if(dPhi_Segm1_Segm2> M_PI)dPhi_Segm1_Segm2-=2*M_PI;
197 if(std::abs(dPhi_Segm1_Segm2)<dPhiCutSegmentMatching){
198 failedGroupingCut=true;
199 break;
200 }
201
202 // Extrapolate segm1 position to segm2's Z position
203 float dZ = std::abs(segm2PosZ)-std::abs(segm1PosZ);
204 Amg::Vector3D extrPos(segm1Pos+(segm1PosZunit*dZ));
205 float extrPosRho = std::abs(extrPos.perp());
206 float extrPosThe = extrPos.theta();
207 float extrPosPhi = extrPos.phi();
208 if(extrPosThe>M_PI/2) extrPosThe=M_PI-extrPosThe;
209 if(extrPosPhi<0)extrPosPhi+=2*M_PI;
210
211 // Get differences between extrapolated and segm2 positions
212 float dRho_Extr_Segm2 = extrPosRho-segm2PosRho;
213 float dPhi_Extr_Segm2 = extrPosPhi-segm2PosPhi;
214 if(dPhi_Extr_Segm2<-M_PI)dPhi_Extr_Segm2+=2*M_PI;
215 if(dPhi_Extr_Segm2> M_PI)dPhi_Extr_Segm2-=2*M_PI;
216
217 // Cut segments (segm1) which are inside difference cuts
218 if((std::abs(dPhi_Extr_Segm2)<dPhiCutSegmentMatching)||
219 (std::abs(dRho_Extr_Segm2)<dRhoCutSegmentMatching)){
220 failedGroupingCut=true;
221 break;
222 }
223 }// nSegm2
224 if(failedGroupingCut)continue;
225
227 // Check track against TGC Sectors to find which it passes
228 // Initialize variables for TRE array search
229 int TGCStationNames[8] ={41, 42, 43, 44, 45, 46, 47, 48};
230 int TGCstation_StationFE[4] ={-1,-1,-1,-1};// [TGCStation]
231 int TGCstation_StationEta[4]={ 0, 0, 0, 0};// [TGCStation]
232 int TGCstation_StationPhi[4]={ 0, 0, 0, 0};// [TGCStation]
233 int nStationMatch[4] ={ 0, 0, 0, 0};// [TGCStation]
234
235 // Loop through TRE array, finding sectors which match the track in each layer
236 for(int stationnameindex=0; stationnameindex<6; stationnameindex++){// Station {T1F,T1E,T2F,T2E,T3F,T3E}
237 // Skip stations which don't have sufficient Segments to run efficiency check
238 int stationName = TGCStationNames[stationnameindex];
239 int stationIndex= TGCstationname2stationindex(stationName);
240
241 // Loop over StationEta&StationPhi
242 for(int stationeta=1; stationeta<=8; stationeta++){// AbsStationEta
243 for(int stationphi=1; stationphi<=48; stationphi++){// StationPhi
244 // Cut Station EtaPhi combinations with no TGC element
245 if(m_TREarray[stationnameindex][i][stationeta][stationphi]==nullptr)continue;
246 const MuonGM::TgcReadoutElement *tre=m_TREarray[stationnameindex][i][stationeta][stationphi];
247
248 // Extrapolate position from nearest Station's Segment to Sector's Z
249 float sectorZ=tre->globalPosition().z();
250 float dZ_sector=std::abs(sectorZ)-std::abs(segm1PosZ);
251 //Trk::GlobalPosition sectorExtrapolatedPos = segm1Pos+(segm1PosZunit*dZ_sector);
252 Amg::Vector3D sectorExtrapolatedPos = segm1Pos+(segm1PosZunit*dZ_sector);
253
254 // Convert extrapolated position to local position on the Sector
255 Identifier sector_id=tre->identify();
256 //const HepGeom::Point3D<double> sectorLocalPos3D=tre->globalToLocalCoords(sectorExtrapolatedPos, sector_id);
257 const Amg::Vector3D sectorLocalPos3D=tre->globalToLocalTransf(sector_id) * sectorExtrapolatedPos;
258 //Trk::LocalPosition sectorLocalPos2D(sectorLocalPos3D.y(),sectorLocalPos3D.z());
259 Amg::Vector2D sectorLocalPos2D(sectorLocalPos3D.y(),sectorLocalPos3D.z());
260
261 double avWidth = (tre->getLongSsize()+tre->getSsize())/2;
262 //double dWidth = (tre->longWidth()-tre->shortWidth());
263 double length = tre->length();
264
265 // Cut sectors which the track does not go through the central 80% of (avoids double counts)
266 double tol1=-0.1*(avWidth/2);
267 double tol2=-0.1*(length/2);
268
269 bool insideSectorBounds=tre->bounds().inside(sectorLocalPos2D,tol1,tol2);
270 if(!insideSectorBounds)continue;
271 // Assign values to matching station variables
272 if(stationIndex<0) continue;
273 TGCstation_StationFE[stationIndex]= (tre->isForward()==false);
274 TGCstation_StationEta[stationIndex]=stationeta;
275 TGCstation_StationPhi[stationIndex]=stationphi;
276 nStationMatch[stationIndex]++;
277 }// StationPhi
278 }// StationEta
279 }// StationName
280
281 // Don't check stations that don't have exactly 1 match for this track
282 for(int jTGC=0;jTGC<4;jTGC++){// TGC Station
283 if(nStationMatch[jTGC]==0){
284 canCheckSector[jTGC]=false;
285 }
286 else if(nStationMatch[jTGC]>1){
287 canCheckSector[jTGC]=false;
288 // Should be impossible, but happens due a problem with the bounds().inside function
289 // commenting out until this bug is resolved
290 //m_log << MSG::WARNING << "MidstationOnly: Number of matches for TGC" << jTGC+1 << " is " << nStationMatch[jTGC] << endl;
291 }
292 }// TGC Station
293
294 // Cut Segment if no stations can be checked
295 if((!canCheckGlobal[0])&&(!canCheckGlobal[1])&&(!canCheckGlobal[2])&&(!canCheckGlobal[3]))continue;
297 // Check which PRD matches Segm1
298 // Initialise hit registered arrays
299 bool sectorhitregistered[9][2] = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
300 std::vector<const Muon::TgcPrepData*> tpdVector[2];
301
302 // Loop over TGC Prep Data container
303 Muon::TgcPrepDataContainer::const_iterator prepit_end=tgc_prepcontainer->end();
304 for( Muon::TgcPrepDataContainer::const_iterator prepit=tgc_prepcontainer->begin();
305 prepit!=prepit_end;
306 ++prepit){
307
308 //loop over TGC Prep Data collection
309 Muon::TgcPrepDataCollection::const_iterator prepitc_end=(*prepit)->end();
310 for( Muon::TgcPrepDataCollection::const_iterator prepitc=(*prepit)->begin();
311 prepitc!= prepitc_end;
312 ++prepitc){
313 // Get PRD and variables
314 const Muon::TgcPrepData* tpd=*prepitc;
315 const MuonGM::TgcReadoutElement *tre = tpd->detectorElement();
316 const std::string stationType = tre->getStationType();
317
318 // Get id values
319 Identifier tgcid=(*prepitc)->identify();
320 int tgcAC=(tre->sideA()==false);//isNotAside a:0, c:1
321 int tgcFE=(tre->isForward()==false);//isNotForward f:0, e:1
322 int tgcWS=(m_idHelperSvc->tgcIdHelper().isStrip(tgcid));//isStrip w=0, s=1
323 int stationName = m_idHelperSvc->tgcIdHelper().stationName(tgcid);
324 int stationEta = std::abs(tre->getStationEta());
325 int stationPhi = tre->getStationPhi();
326 int gasGap = m_idHelperSvc->tgcIdHelper().gasGap(tgcid);
327
328 // Cut hits except those from same side Midstation
329 if(tgcAC!=i) continue;
330 if(stationName>46 || stationName<41) continue;
331
332 // Get layer number and stationIndex
333 int layer = TGCgetlayer(stationName,gasGap);
334 int stationIndex = TGCstationname2stationindex(stationName);
335 if(stationIndex==3)continue;
336
337 // Get position variables
338 const Amg::Vector3D prdPos = tpd->globalPosition();
339 float tgcRho = std::abs(prdPos.perp());
340 float tgcPhi = prdPos.phi();
341 float tgcZ = prdPos.z();
342 if(tgcPhi<0)tgcPhi+=2*M_PI;
343
344 // Extrapolate Segm1 to PRD Z position
345 float dZ = std::abs(tgcZ) - std::abs(segm1PosZ);
346 Amg::Vector3D tgcExtrapolatedPos = ((segm1Pos)+((segm1PosZunit)*dZ));
347
348 // Get extrapolated variables
349 float tgcExtrRho = std::abs(tgcExtrapolatedPos.perp());
350 float tgcExtrPhi = tgcExtrapolatedPos.phi();
351 if(tgcExtrPhi<0)tgcExtrPhi+=2*M_PI;
352
353 // Get differences between extrapolated and segm2 positions
354 float dRho = tgcRho-tgcExtrRho;
355 float dPhi = tgcPhi-tgcExtrPhi;
356 if(dPhi<-M_PI)dPhi+=2*M_PI;
357 if(dPhi> M_PI)dPhi-=2*M_PI;
358
359 // Pass through loose phi cut to eliminate some noise
360 if(std::abs(dPhi)<dPhiCut_Loose){
361 // Fill PRD sagitta histograms
362 if(m_mvt_extrprdsag2[i][stationIndex][tgcFE][tgcWS][0]) m_mvt_extrprdsag2[i][stationIndex][tgcFE][tgcWS][0]->Fill(dRho);
363 if(m_mvt_extrprdsag2[i][stationIndex][tgcFE][tgcWS][2]) m_mvt_extrprdsag2[i][stationIndex][tgcFE][tgcWS][2]->Fill(dPhi);
364
365 // Do Global check
366 if(canCheckGlobal[stationIndex]){
367 float dRhoCut = dRhoCutGlobal[tgcWS]*tgcExtrRho;
368 if(std::abs(dPhi)<dPhiCutGlobal[tgcWS] && std::abs(dRho)<dRhoCut){
369 }
370 }// global
371
372 // Add PRD which matches Segm1 position to vector for further analysis
373 if(std::abs(dPhi)<dPhiCutSector[tgcWS] && std::abs(dRho)<dRhoCutSector[tgcWS]){
374 tpdVector[tgcWS].push_back(tpd);
375 }
376 // Do Sector Efficiency Check
377 if(canCheckSector[stationIndex]){
378 // Do check against PRD from matching Sectors
379 if((stationEta==TGCstation_StationEta[stationIndex])&&
380 (stationPhi==TGCstation_StationPhi[stationIndex])&&
381 (tgcFE==TGCstation_StationFE[stationIndex])){
382 // Do check
383 if(std::abs(dPhi)<dPhiCutSector[tgcWS] && std::abs(dRho)<dRhoCutSector[tgcWS]){
384 if(layer>=0)sectorhitregistered[layer][tgcWS]=true;// Sector hit
385 }
386 }
387 }// sector
388
389 }// dPhi Loose Cut
390 }// TGC PRD Collection
391 }// TGC PRD Container
392
393 // Cut Segment if no stations can be checked
394 if((!canCheckGlobal[0])&&(!canCheckGlobal[1])&&(!canCheckGlobal[2])&&(!canCheckGlobal[3]))continue;
396 // Do PRD checks
397 // Find vector of PRD which forms a coherent line in the vicinity of Segm1
398
399 // Variables to hold best PRD matching results
400 std::vector<const Muon::TgcPrepData*> *bestTPDmatches[2];
401 bestTPDmatches[0] = nullptr;
402 bestTPDmatches[1] = nullptr;
403 if(bestTPDmatches[0]->size()>0) bestTPDmatches[0]->clear();
404 if(bestTPDmatches[1]->size()>0) bestTPDmatches[1]->clear();
405 int bestTPDlayerMatches[2][9] = {{0,0,0,0,0,0,0,0,0},
406 {0,0,0,0,0,0,0,0,0}};
407
408 for(int k=0;k<2;k++){// WireStrip
409 // Variables to record quality of best match found
410 int nPRDMax = 0;
411 int nlayerMax = 0;
412
413 // Loop over PRD vector
414 int nTPD = tpdVector[k].size();
415 for(int iTPD1=0;iTPD1<nTPD;iTPD1++){
416 // Variables to hold matches found for this PRD
417 std::vector<const Muon::TgcPrepData*> thisTPDmatches;
418 int thisTPDlayerMatches[9] = {0,0,0,0,0,0,0,0,0};
419
420 // Get position variables
421 const Amg::Vector3D prdPos1 = tpdVector[k].at(iTPD1)->globalPosition();
422
423 float prd1Phi = prdPos1.phi();
424 float prd1Z = prdPos1.z();
425 if(prd1Phi<0)prd1Phi+=2*M_PI;
426 Amg::Vector3D prd1PosZunit(prdPos1/std::abs(prd1Z));
427
428 // Get id values
429 Identifier tgcid1=(tpdVector[k].at(iTPD1))->identify();
430 int stationName1 = m_idHelperSvc->tgcIdHelper().stationName(tgcid1);
431 int gasGap1 = m_idHelperSvc->tgcIdHelper().gasGap(tgcid1);
432 int layer1 = TGCgetlayer(stationName1,gasGap1);
433 if(layer1>=0)thisTPDlayerMatches[layer1]++;
434
435 // Loop over PRD
436 for(int iTPD2=0;iTPD2<nTPD;iTPD2++){
437 if(iTPD2==iTPD1)continue;// do not check PRD against itself
438
439 // Get position variables
440 const Amg::Vector3D prdPos2 = tpdVector[k].at(iTPD2)->globalPosition();
441 float prd2Rho = std::abs(prdPos2.perp());
442 float prd2Phi = prdPos2.phi();
443 float prd2Z = prdPos2.z();
444 if(prd2Phi<0)prd2Phi+=2*M_PI;
445
446 // Extrapolate PRD1 to PRD2 Z position
447 float dZ = std::abs(prd2Z)- std::abs(prd1Z);
448 Amg::Vector3D prdExtrPos = ((prdPos1)+((prd1PosZunit)*dZ));
449
450 // Get extrapolated variables
451 float prdExtrRho = std::abs(prdExtrPos.perp());
452 float prdExtrPhi = prdExtrPos.phi();
453 if(prdExtrPhi<0)prdExtrPhi+=2*M_PI;
454
455 // Get differences between extrapolated and PRD2 positions
456 float dRho = prd2Rho-prdExtrRho;
457 float dPhi = prd2Phi-prdExtrPhi;
458 if(dPhi<-M_PI)dPhi+=2*M_PI;
459 if(dPhi> M_PI)dPhi-=2*M_PI;
460
461 // Fill PRD comparison sagitta histograms
462 if(m_tgc_prdcompsag[i][k][0]) m_tgc_prdcompsag[i][k][0]->Fill(dRho);
463 if(m_tgc_prdcompsag[i][k][2]) m_tgc_prdcompsag[i][k][2]->Fill(dPhi);
464
465 // Do check
466 if(std::abs(dPhi)<dPhiCutTPD[k] && std::abs(dRho)<dRhoCutTPD[k]){
467 // Get id values
468 Identifier tgcid2=(tpdVector[k].at(iTPD2))->identify();
469 int stationName2 = m_idHelperSvc->tgcIdHelper().stationName(tgcid2);
470 int gasGap2 = m_idHelperSvc->tgcIdHelper().gasGap(tgcid2);
471 int layer2 = TGCgetlayer(stationName2,gasGap2);
472
473 // Add PRD2 to matches for PRD1
474 if(layer2>=0)thisTPDlayerMatches[layer2]++;
475 thisTPDmatches.push_back(tpdVector[k].at(iTPD2));
476 }
477 }// nTPD2
478
479 // Get quality of matching array produced
480 int nPRDCurrent = 0;
481 int nlayerCurrent = 0;
482 for(int l=0;l<9;l++){
483 if(thisTPDlayerMatches[l]>0)nlayerCurrent++;
484 nPRDCurrent+=thisTPDlayerMatches[l];
485 }
486
487 // Check quality variables against maximum found
488 if(nlayerMax <= nlayerCurrent){
489 if(nPRDMax < nPRDCurrent){
490 // Set maximum values to current segment's values
491 nlayerMax = nlayerCurrent;
492 nPRDMax = nPRDCurrent;
493 bestTPDmatches[k] = &thisTPDmatches;
494 for(int l=0;l<9;l++){
495 bestTPDlayerMatches[k][l] = thisTPDlayerMatches[l];
496 }
497 }
498 }
499 }// nTPD1
500
501 // If matching array was somehow empty (should be impossible)
502 if(nlayerMax==0)continue;
503 if(bestTPDmatches[k]->size()==0){
504 ATH_MSG_WARNING( "MidstationOnly: empty bestTPDmatches["<<k<<"] passed" );
505 continue;
506 }
507
508 // Set canCheck variables based on contents of matched PRD array
509 for(int jTGC1=0;jTGC1<3;jTGC1++){// TGC Stations
510 // Number of matched PRD found in other Stations
511 int nMatchOther = 0;
512 for(int l=0;l<9;l++){
513 int jTGC2 = TGClayer2stationindex(l);
514 if(jTGC1==jTGC2)continue;
515 nMatchOther+=bestTPDlayerMatches[k][l];
516 }
517
518 // Check against cut
519 if(nMatchOther<nMeasCutTGCMidPRD[k]){
520 canCheckGlobal[jTGC1]=false;
521 canCheckSector[jTGC1]=false;
522 }
523 }// TGC Stations
524 }// WireStrip
525
526 // Cut Segment if no stations can be checked
527 if((!canCheckGlobal[0])&&(!canCheckGlobal[1])&&(!canCheckGlobal[2])&&(!canCheckGlobal[3]))continue;
529 // Segment has passed all global cuts, fill histogram variables
530 // If no segments have already passed all cuts
531 if(nValidatedSegm==0){
532 for(int jTGC=0;jTGC<4;jTGC++){// TGC Stations
533 // Assign values of variables to fill histograms
534 // posThetaFill = segm1PosThe;
535 // posPhiFill = segm1PosPhi;
536
537 //canCheckGlobalFill[jTGC] = canCheckGlobal[jTGC];
538 canCheckSectorFill[jTGC] = canCheckSector[jTGC];
539
540 TGCstation_StationFEFill[jTGC] = TGCstation_StationFE[jTGC];
541 TGCstation_StationEtaFill[jTGC] = TGCstation_StationEta[jTGC];
542 TGCstation_StationPhiFill[jTGC] = TGCstation_StationPhi[jTGC];
543 }
544 for(int l=0;l<9;l++){
545 for(int k=0;k<2;k++){
546 sectorhitregisteredFill[l][k] = sectorhitregistered[l][k];
547 // hitregisteredFill[l][k] = hitregistered[l][k];
548 }
549 }
550 }// TGC Stations
551 nValidatedSegm++;
552 }// nSegm1
553
554 // If only one Segment was validated on this side
555 if(nValidatedSegm==1){
556 for(int l=0;l<9;l++){//Layer
557 int stationIndex = TGClayer2stationindex(l);
558 for(int k=0;k<2;k++){// WireStrip
559 // If this station can be checked
560 if(canCheckSectorFill[stationIndex]){
561 if((TGCstation_StationFEFill[stationIndex]<0)||(TGCstation_StationEtaFill[stationIndex]==0)||(TGCstation_StationPhiFill[stationIndex]==0)){
562 ATH_MSG_WARNING( "MidstationOnly: canCheckSector passed for jTGC=" << stationIndex
563 << " but, FE="<<TGCstation_StationFEFill[stationIndex]
564 << " Eta="<<TGCstation_StationEtaFill[stationIndex]
565 << " Phi=" << TGCstation_StationPhiFill[stationIndex] );
566 continue;
567 }
568 // Get Sector histogram indexes
569 int stationMap_EtaIndex=getStationMapIndex(1, l, TGCstation_StationFEFill[stationIndex], TGCstation_StationEtaFill[stationIndex], TGCstation_StationPhiFill[stationIndex]);
570 int stationMap_PhiIndex=getStationMapIndex(2, l, TGCstation_StationFEFill[stationIndex], TGCstation_StationEtaFill[stationIndex], TGCstation_StationPhiFill[stationIndex]);
571
572 // Fill Sector efficiency histograms
573 if(sectorhitregisteredFill[l][k]){// Hit in Sector matches extrapolated track
574 m_eff_stationmapmid[i][k][1]->Fill(stationMap_EtaIndex, stationMap_PhiIndex);
575 }
576 m_eff_stationmapmid[i][k][2]->Fill(stationMap_EtaIndex, stationMap_PhiIndex);
577 }
578 }// WireStrip
579 }// layer
580 }
581
582 }// AC
583
584}// End of Function
#define M_PI
#define ATH_MSG_WARNING(x)
double length(const pvec &v)
size_t size() const
Number of registered mappings.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const
return const_iterator for end of container
const_iterator begin() const
return const_iterator for first entry
int TGCgetlayer(int stationName, int g)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
TH1 * m_mvt_extrprdsag2[2][4][2][2][4]
void MidstationOnlyCheck(std::vector< const Muon::MuonSegment * >(&sortedSegments)[2][4], std::vector< const Muon::MuonSegment * >(&disqualifiedSegments)[2][4], const Muon::TgcPrepDataContainer *tgc_prepcontainer)
int getStationMapIndex(int x, int l, int stationFE, int stationEta, int stationPhi)
const MuonGM::TgcReadoutElement * m_TREarray[8][2][9][49]
int TGCstationname2stationindex(int stationName)
virtual const Trk::SurfaceBounds & bounds() const override
Return the boundaries of the element.
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Amg::Transform3D globalToLocalTransf(const Identifier &id) const
Returns the global -> local transformation.
bool isForward() const
Returns true if the chamber is mounted on the most inner ring, i.e. a TxF chamber.
This is the common class for 3D segments used in the muon spectrometer.
const Trk::RIO_OnTrack * rioOnTrack(unsigned int) const
returns the RIO_OnTrack (also known as ROT) objects depending on the integer
virtual const Amg::Vector3D & globalPosition() const override final
global position
Class to represent TGC measurements.
Definition TgcPrepData.h:32
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global position.
virtual const MuonGM::TgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD The pointer will be zero if the det el is not ...
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Identifier identify() const
return the identifier -extends MeasurementBase
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const =0
Each Bounds has a method inside, which checks if a LocalPosition is inside the bounds.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
MuonPrepDataContainerT< TgcPrepData > TgcPrepDataContainer