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