ATLAS Offline Software
Loading...
Searching...
No Matches
MdtVsTgcRawData_SegmDQ.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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// Checks that segments have sufficient DQ
31// Segments with insuffient DQ are added to disqualifiedSegments and subsequently ignored by the other functions
32void
33MdtVsTgcRawDataValAlg::DQCheckMDTSegments(std::vector<const Muon::MuonSegment*> (&sortedSegments)[2][4],
34 std::vector<const Muon::MuonSegment*> (&disqualifiedSegments)[2][4]){
35 // Define Cuts:
36 // Cut for miniumum number of measurements necessary to use Segments
37 const int nMeasCutMdt[4] = { 4, 2, 4, 5}; //[MDTStation]
38 const int nMeasCutTgcStrip[4] = { 0, 0, 1, 0}; //[MDTStation]
39 // Cut for differences between direction and position vectors
40 const float dPhiCutPosDir[4] = {0.05,0.05,0.08,0.1 };
41 const float dTheCutPosDir[4] = { 0.2, 0.4, 0.6,0.5 };
42
43 // Loop over sides
44 for(int i=0;i<2;i++){// AC
45 bool skipSegm;int nDisqualifiedSegm; // used when checking the disqualified list for a segment
46 bool segmDisqual; // used to flag a segment which has been found DQ insufficient
47 //bool HasStationDQSegm[4] = {false, false, false, false};// flags for whether the there are segments in each MDT station with sufficienct DQ
48
49 for(int jMDT=0;jMDT<4;jMDT++){// MDT Stations
50 // Get number of segments
51 int nSegm=sortedSegments[i][jMDT].size();
52
53 // Loop over segments in this MDT Station
54 for(int n=0; n<nSegm;n++){
55 segmDisqual = false;// set disqualified flag to false
56 // Get segment
57 const Muon::MuonSegment *segm=sortedSegments[i][jMDT].at(n);
58 if(segm==nullptr)continue;// Cut empty entries
59
60 // Check disqualifiedSegments for current segment
61 skipSegm=false;
62 nDisqualifiedSegm=disqualifiedSegments[i][jMDT].size();
63 for(int ndis=0;ndis<nDisqualifiedSegm;ndis++)if(segm==disqualifiedSegments[i][jMDT].at(ndis))skipSegm=true;
64 if(skipSegm)continue;
65
67 // Apply nHits cuts to segments
69 int stationName=0;
70 int nMdtMeas = 0; // nMDTHits in this Segment
71 int nTgcMeas[2] = {0,0};// [WireStrip] nTGCHits in this Segment
72
73 // Loop through contained ROTs and identify used stations
74 for(unsigned int iROT=0; iROT<segm->numberOfContainedROTs(); ++iROT) {
75 const Trk::RIO_OnTrack* rio = segm->rioOnTrack(iROT);
76 if(!rio){
77 ATH_MSG_DEBUG("no RIO");
78 continue;
79 }
80 Identifier id = rio->identify();
81 stationName = int(m_idHelperSvc->mdtIdHelper().stationName(id));
82 int isStrip = m_idHelperSvc->tgcIdHelper().isStrip(id);
83
84 if((stationName==41)||(stationName==42))nTgcMeas[isStrip]++;// TGC
85 if((stationName==43)||(stationName==44))nTgcMeas[isStrip]++;// TGC
86 if((stationName==45)||(stationName==46))nTgcMeas[isStrip]++;// TGC
87 if((stationName==47)||(stationName==48))nTgcMeas[isStrip]++;// TGC
88
89 if((stationName==13)||(stationName==49))nMdtMeas++;// MDT
90 if((stationName==14)||(stationName==15))nMdtMeas++;// MDT
91 if((stationName==17)||(stationName==18))nMdtMeas++;// MDT
92 if((stationName==20)||(stationName==21))nMdtMeas++;// MDT
93 }
94
95 // Cut Segments with insufficient numbers of hits in the stations
96 if(nMdtMeas<nMeasCutMdt[jMDT]||nTgcMeas[1]<nMeasCutTgcStrip[jMDT]){
97 segmDisqual = true;
98 }
99
101 // Apply Direction-Position cuts to segments
103 // Get Position and Direction Variables
104 // const Trk::GlobalPosition segmGlobalPos = segm->globalPosition();
105 const Amg::Vector3D segmGlobalPos = segm->globalPosition();
106
107 float segmPosPhi = segmGlobalPos.phi();
108 float segmPosThe = segmGlobalPos.theta();
109 if(segmPosPhi<0) segmPosPhi+=2*M_PI;
110 if(segmPosThe>M_PI/2) segmPosThe=M_PI-segmPosThe;
111 //const Trk::GlobalDirection segmGlobalDir = segm->globalDirection();
112 const Amg::Vector3D segmGlobalDir = segm->globalDirection();
113
114 float segmDirPhi = segmGlobalDir.phi();
115 float segmDirThe = segmGlobalDir.theta();
116 if(segmDirPhi<0) segmDirPhi+=2*M_PI;
117 if(segmDirThe>M_PI/2) segmDirThe=M_PI-segmDirThe;
118
119 // Get Differences between Position and Direction vectors
120 float dPhi_Pos_Dir = segmPosPhi-segmDirPhi;
121 float dThe_Pos_Dir = segmPosThe-segmDirThe;
122 if(dPhi_Pos_Dir<-M_PI)dPhi_Pos_Dir+=2*M_PI;
123 if(dPhi_Pos_Dir> M_PI)dPhi_Pos_Dir-=2*M_PI;
124
125 if(!segmDisqual){
126 if(m_mdt_segmposdirsag[i][jMDT][2]) m_mdt_segmposdirsag[i][jMDT][2]->Fill(dPhi_Pos_Dir);
127 if(m_mdt_segmposdirsag[i][jMDT][3]) m_mdt_segmposdirsag[i][jMDT][3]->Fill(dThe_Pos_Dir);
128 }
129
130 // Cut Segments with too great a difference between position and direction vectors
131 if(std::abs(dPhi_Pos_Dir)>dPhiCutPosDir[jMDT]||std::abs(dThe_Pos_Dir)>dTheCutPosDir[jMDT]){
132 segmDisqual = true;
133 }
134
136 // Add disqualified segments to the disqualified list
138 if(segmDisqual){
139 disqualifiedSegments[i][jMDT].push_back(segm);
140 }
141 else{
142 //HasStationDQSegm[jMDT]=true;// Flag event as having a DQ sufficient segment in the current station
143 }
144 }// Segments in station
145 }// MDT Stations
146 }// AC
147
148 return;
149}// End of function
#define M_PI
#define ATH_MSG_DEBUG(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
void DQCheckMDTSegments(std::vector< const Muon::MuonSegment * >(&sortedSegments)[2][4], std::vector< const Muon::MuonSegment * >(&disqualifiedSegments)[2][4])
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 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
Eigen::Matrix< double, 3, 1 > Vector3D