ATLAS Offline Software
MdtVsTgcRawData_SegmSorting.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 
14 #include "../MdtVsTgcRawDataValAlg.h"
15 
20 #include "xAODMuon/MuonSegment.h"
21 
22 #include <inttypes.h>
23 #include <sstream>
24 #include <algorithm>
25 #include <fstream>
26 
27 // New Sort Segments in the MDT Endcap into Sides and MDT Stations
28 void
30  std::vector<const Muon::MuonSegment*> (&sortedSegments)[2][4]){
31 
32  // Loop over all segments in event
33  xAOD::MuonSegmentContainer::const_iterator mdtseg_itr = newsegment->begin();
34  xAOD::MuonSegmentContainer::const_iterator mdtseg_end = newsegment->end();
35  for(; mdtseg_itr!=mdtseg_end; ++mdtseg_itr){
36  if(!(*mdtseg_itr)->muonSegment().isValid())continue;
37  // Get segm
38  const Muon::MuonSegment* segm = dynamic_cast<const Muon::MuonSegment*>(*(*mdtseg_itr)->muonSegment());
39  if (segm == nullptr) {
40  ATH_MSG_ERROR( "no pointer to segm!!!" );
41  break;
42  }
43 
44  bool isMdt=false, isEndcap=false; // Flags for whether the Segment has hits from the MDT/Endcap
45  int nMdtMeas[4]={0,0,0,0}; // int array to count number of MDT hits in different stations
46 
47  // Loop through contained ROTs and identify used stations
48  for(unsigned int iROT=0; iROT<segm->numberOfContainedROTs(); ++iROT){
49  const Trk::RIO_OnTrack* rio = segm->rioOnTrack(iROT);
50  if(!rio){
51  ATH_MSG_DEBUG("No RIO");
52  continue;
53  }
54  Identifier id = rio->identify();
55 
56  // Identify MDT Endcap Segments
57  if(m_idHelperSvc->isMdt(id))isMdt=true;
58  if(m_idHelperSvc->isEndcap(id))isEndcap=true;
59 
60  int stationName = int(m_idHelperSvc->mdtIdHelper().stationName(id));
61  // Large (L) = odd, greater r, Small (S) = even, lower r
62  // 13=EIL 49=EIS 14=EEL 15=EES 17=EML 18=EMS 20=EOL 21=EOS
63  if((stationName==13)||(stationName==49))nMdtMeas[0]++;// MDT
64  if((stationName==14)||(stationName==15))nMdtMeas[1]++;// MDT
65  if((stationName==17)||(stationName==18))nMdtMeas[2]++;// MDT
66  if((stationName==20)||(stationName==21))nMdtMeas[3]++;// MDT
67  }
68 
69  // If not Endcap and does not contain MDT hits
70  if(!isMdt||!isEndcap)continue;
71 
72  // Get Side
73  int segmAC = (segm->globalPosition().eta()<0);// a:0, c:1
74 
75  // Check MDT Stations included in this Segment
76  int nMDTStations=0; int MDTStationj=-1;
77  for(int jMDT=0;jMDT<4;jMDT++){
78  if(nMdtMeas[jMDT]!=0){
79  nMDTStations++;
80  MDTStationj=jMDT;
81  }
82  }
83 
84  // MC data has an odd channel set always triggering segments, this cuts them
85  if((segmAC==0)&&(MDTStationj==0)&&
86  (segm->globalPosition().eta()>1.815)&&(segm->globalPosition().eta()<1.82)&&
87  (segm->globalPosition().phi()>2.857)&&(segm->globalPosition().phi()<2.862))continue;
88 
89  // If there is only one station pass the segment data on to the variables
90  if(nMDTStations==1){
91  //HasStationSegm[segmAC][MDTStationj]=true;
92  sortedSegments[segmAC][MDTStationj].push_back(segm);
93  }
94  }// Loop over segments
95 }// End of function
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MdtVsTgcRawDataValAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtVsTgcRawDataValAlg.h:69
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
Muon::MuonSegment::rioOnTrack
const Trk::RIO_OnTrack * rioOnTrack(unsigned int) const
returns the RIO_OnTrack (also known as ROT) objects depending on the integer
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:187
MuonSegment.h
MuonContainer.h
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
Muon::MuonSegment::numberOfContainedROTs
unsigned int numberOfContainedROTs() const
number of RIO_OnTracks
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:199
MuonSegmentContainer.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MdtVsTgcRawDataValAlg::SortMDTSegments
void SortMDTSegments(const xAOD::MuonSegmentContainer *m_newsegment, std::vector< const Muon::MuonSegment * >(&sortedSegments)[2][4])
Definition: MdtVsTgcRawData_SegmSorting.cxx:29
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrkEventPrimitivesDict.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
RIO_OnTrack.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
Muon::MuonSegment::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
global position
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:157
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Identifier
Definition: IdentifierFieldParser.cxx:14