ATLAS Offline Software
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 
14 #include "MdtVsTgcRawDataValAlg.h"
15 
21 
25 #include "xAODMuon/MuonSegment.h"
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 
37 void
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
TH2::Fill
int Fill(double, double)
Definition: rootspy.cxx:382
Muon::MuonPrepDataContainer
Template for Muon PRD containers (which are basically collections of MuonPrepDataCollections).
Definition: MuonPrepDataContainer.h:42
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
MdtVsTgcRawDataValAlg::maphists
void maphists(const xAOD::MuonSegmentContainer *m_newsegment, const Muon::TgcPrepDataContainer *tgc_prepcontainer)
Definition: MdtVsTgcRawData_maptgchits.cxx:38
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
EventPrimitivesHelpers.h
MuonSegment.h
MuonContainer.h
MdtVsTgcRawDataValAlg.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Muon::TgcPrepData::detectorElement
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 ...
Definition: TgcPrepData.h:120
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
GeoPrimitives.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonGM::TgcReadoutElement
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/TgcReadoutElement.h:42
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
TrkEventPrimitivesDict.h
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
EventPrimitives.h
RIO_OnTrack.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MdtVsTgcRawDataValAlg::m_mdt_segmmap
TH2 * m_mdt_segmmap[2][4]
Definition: MdtVsTgcRawDataValAlg.h:111
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
MdtVsTgcRawDataValAlg::maphistsfinalize
void maphistsfinalize()
Definition: MdtVsTgcRawData_maptgchits.cxx:141
GeoPrimitivesHelpers.h
MuonGM::MuonReadoutElement::getStationType
std::string getStationType() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:189
Muon::TgcPrepData
Class to represent TGC measurements.
Definition: TgcPrepData.h:32
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
Muon::TgcPrepData::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global position.
Definition: TgcPrepData.h:125
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.