ATLAS Offline Software
Loading...
Searching...
No Matches
MdtVsTgcRawData_maptgchits.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 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
26
27#include <TH1F.h>
28#include <TH2F.h>
29#include <TH1.h>
30#include <TH2.h>
31#include <inttypes.h>
32
33#include <sstream>
34#include <algorithm>
35#include <fstream>
36
37void
39 const Muon::TgcPrepDataContainer *tgc_prepcontainer){//use new mdt segment
40 ATH_MSG_DEBUG("inside maptgchits" );
41
43 // loop over MDT Segment Collection
44 xAOD::MuonSegmentContainer::const_iterator mdtseg_itr = newsegment->begin();
45 xAOD::MuonSegmentContainer::const_iterator mdtseg_end = newsegment->end();
46 for(; mdtseg_itr!=mdtseg_end; ++mdtseg_itr){
47 if(!(*mdtseg_itr)->muonSegment().isValid())continue;
48 // Get segm
49 const Muon::MuonSegment* segm = dynamic_cast<const Muon::MuonSegment*>(*(*mdtseg_itr)->muonSegment());
50 if (segm == nullptr) {
51 ATH_MSG_ERROR( "no pointer to segm!!!" );
52 break;
53 }
54 // Initialize variables
55 int stationName=0;
56 int nMdtMeas[4] = {0,0,0,0};
57 bool isMdt=false, isEndcap=false;
58
59 // Loop through contained ROTs and count used MDT and TGC stations
60 for(unsigned int i=0;i<segm->numberOfContainedROTs();++i){
61 // Get station information
62 const Trk::RIO_OnTrack* rio = segm->rioOnTrack(i);
63 if(!rio) continue;
64 Identifier id = rio->identify();
65 stationName = int(m_idHelperSvc->mdtIdHelper().stationName(id));
66 // Flag Segments with ROTs in the MDT & Endcap
67 if(m_idHelperSvc->isMdt(id))isMdt=true;
68 if(m_idHelperSvc->isEndcap(id))isEndcap=true;
69 // If ROT is MDT
70 if((stationName==13)||(stationName==49)){nMdtMeas[0]++;}
71 if((stationName==14)||(stationName==15)){nMdtMeas[1]++;}
72 if((stationName==17)||(stationName==18)){nMdtMeas[2]++;}
73 if((stationName==20)||(stationName==21)){nMdtMeas[3]++;}
74 }
75 if(!isMdt)continue;
76 if(!isEndcap)continue;
77
78 // Establish which MDT stations the Segment is in
79 int nStations = 0;
80 for(int jMDT=0;jMDT<4;jMDT++){
81 if(nMdtMeas[jMDT]){
82 nStations++;
83 }
84 }
85 // Check that the Segment only occupies one Station
86 if(nStations!=1)continue;
87
88 // Get Position pointer and segmAC index
89 const Amg::Vector3D segmGlobalPos = segm->globalPosition();
90 int segmAC = (segmGlobalPos.z()<0);// a:0, c:1
91
92 // Fill MDT data
93 for(int jMDT=0;jMDT<4;jMDT++){// jMDT
94 if(nMdtMeas[jMDT]){// If hits in this Station
95 // Get position variables
96 float segmGlobalEta = std::abs(segmGlobalPos.eta());
97 float segmGlobalPhi = segmGlobalPos.phi();
98 if(segmGlobalPhi<0) segmGlobalPhi+=2*M_PI;
99 // Fill position histogram
100 m_mdt_segmmap[segmAC][jMDT]->Fill(segmGlobalPhi, segmGlobalEta);
101 }// If hits in Station
102 }// jMDT
103 }// MDT Segment Collection
104
106 //loop over TGC Prep Data container
107 Muon::TgcPrepDataContainer::const_iterator tgc_it_end=tgc_prepcontainer->end();
108 for( Muon::TgcPrepDataContainer::const_iterator tgc_it=tgc_prepcontainer->begin();
109 tgc_it!=tgc_it_end;
110 ++tgc_it){
111
112 //loop over TGC Prep Data collection
113 Muon::TgcPrepDataCollection::const_iterator tgc_itc_end=(*tgc_it)->end();
114 for( Muon::TgcPrepDataCollection::const_iterator tgc_itc=(*tgc_it)->begin();
115 tgc_itc!= tgc_itc_end;
116 ++tgc_itc){
117 const Muon::TgcPrepData* tpd=*tgc_itc;
118
119 // Get detector information
120 const MuonGM::TgcReadoutElement *tre = tpd->detectorElement();
121 const std::string tgcStationType = tre->getStationType();
122
123 // Get detector variables
124 Identifier tgcid=(*tgc_itc)->identify();
125 int tgcStationName = m_idHelperSvc->tgcIdHelper().stationName(tgcid);
126
127 // Get position variables
128 const Amg::Vector3D tgcGlobalPos = tpd->globalPosition();
129 float tgcGlobalPhi = tgcGlobalPos.phi();
130 if(tgcGlobalPhi<0)tgcGlobalPhi+=2*M_PI;
131
132 // Cut non-TGC-Endcap
133 if(tgcStationName<41 || tgcStationName>48)continue;
134 }// TGC PRD Collection
135 }// TGC PRD Container
136
137 return;
138}// End of function
139
140// Finalize histograms which need post processing
142
143}// End of function
#define M_PI
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const_iterator end() const
return const_iterator for end of container
const_iterator begin() const
return const_iterator for first entry
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
void maphists(const xAOD::MuonSegmentContainer *m_newsegment, const Muon::TgcPrepDataContainer *tgc_prepcontainer)
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
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
Eigen::Matrix< double, 3, 1 > Vector3D
MuonPrepDataContainerT< TgcPrepData > TgcPrepDataContainer
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".