diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/TRT_Monitoring/TRT_Hits_Monitoring_Tool.h b/InnerDetector/InDetMonitoring/TRT_Monitoring/TRT_Monitoring/TRT_Hits_Monitoring_Tool.h new file mode 100644 index 0000000000000000000000000000000000000000..dce894717a0b36e8a5493aa71e988468ff3d2342 --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/TRT_Monitoring/TRT_Hits_Monitoring_Tool.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifdef ONLINE // This tool is only meant for special online monitoring at Point 1 + +#ifndef TRT_HITS_MONITORING_TOOL_H +#define TRT_HITS_MONITORING_TOOL_H + +#include "AthenaMonitoring/ManagedMonitorToolBase.h" +#include "InDetRawData/InDetRawDataCLASS_DEF.h" +#include "is/infodictionary.h" +#include "is/infoT.h" + +#include <string> + +class TRT_ID; + +class TRT_Hits_Monitoring_Tool: public ManagedMonitorToolBase +{ +public: + TRT_Hits_Monitoring_Tool(const std::string &type, const std::string &name, const IInterface *parent); + virtual ~TRT_Hits_Monitoring_Tool(); + + virtual StatusCode initialize(); + virtual StatusCode bookHistogramsRecurrent(); + virtual StatusCode fillHistograms(); + virtual StatusCode procHistograms(); + +private: + const TRT_ID *m_pTRTHelper; + + ISInfoDictionary m_dict; + + ISInfoFloat m_occ_longToT; + ISInfoFloat m_occBR_longToT; + ISInfoFloat m_occEA_longToT; + ISInfoFloat m_occEC_longToT; + + std::string m_name_longToT; + std::string m_nameBR_longToT; + std::string m_nameEA_longToT; + std::string m_nameEC_longToT; + + std::string m_rawDataObjectName; + std::string m_partition; + std::string m_server; + std::string m_name; + + float m_longToTCut; + unsigned int m_sleepTime; // milliseconds + boost::posix_time::ptime m_lastPublishTime; +}; + +#endif // TRT_HITS_MONITORING_TOOL_H +#endif // ONLINE diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/TRT_Monitoring/TRT_Monitoring_Tool.h b/InnerDetector/InDetMonitoring/TRT_Monitoring/TRT_Monitoring/TRT_Monitoring_Tool.h new file mode 100644 index 0000000000000000000000000000000000000000..5b439d954b7464f01e541ef08a325083d638037c --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/TRT_Monitoring/TRT_Monitoring_Tool.h @@ -0,0 +1,607 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRT_MONITORING_TOOL_H +#define TRT_MONITORING_TOOL_H + +#include "AthenaMonitoring/ManagedMonitorToolBase.h" +#include "InDetRawData/InDetRawDataCLASS_DEF.h" +#include "InDetRawData/InDetTimeCollection.h" +#include "GaudiKernel/StatusCode.h" + +#include <string> +#include <vector> +#include <set> + +class TH1F; +class TH2F; +class TProfile; +class TH1F_LW; +class TH2F_LW; +class TProfile_LW; + +namespace Trk +{ + class ITrackHoleSearchTool; + class Track; + class ITrackHoleSearchTool; + class TrackStateOnSurface; + class ITrackSummaryTool; + class IExtrapolator; + class IPropagator; +} + +namespace InDetDD +{ + class TRT_DetectorManager; +} + +class AtlasDetectorID; +class TRT_ID; +class Identifier; +class EventInfo; +class ComTime; +class IInDetConditionsSvc; +class ITRT_CalDbSvc; +class ITRT_StrawStatusSummarySvc; +class ITRT_DCS_ConditionsSvc; +class ITRT_DAQ_ConditionsSvc; +class ITRT_ByteStream_ConditionsSvc; +class ITRT_ConditionsSvc; +class ITRT_StrawNeighbourSvc; +class ITRT_DriftFunctionTool; + +class TRT_Monitoring_Tool : public ManagedMonitorToolBase +{ +public: + TRT_Monitoring_Tool(const std::string &type, const std::string &name, const IInterface *parent); + virtual ~TRT_Monitoring_Tool(); + virtual StatusCode initialize(); + virtual StatusCode bookHistogramsRecurrent(); + virtual StatusCode fillHistograms(); + virtual StatusCode procHistograms(); + +private: + int lastLumiBlock; + int nLumiBlock; + int evtLumiBlock; + int good_bcid; + float probScale; + int numberOfTracks; + int m_nTotalTracks; + int m_nTracksB[2]; + int m_nTracksEC[2]; + int m_nTracksEC_B[2]; + float nBSErrors[195]; + float nRobErrors[195]; + std::vector<unsigned int> m_rodMap; + bool passEventBurst; + bool m_ArgonXenonSplitter; + + const AtlasDetectorID * m_idHelper; + + /** Structure used in collection straw hits into a vector */ + struct strawHit{ + float xPos; + float yPos; + int stack; + int straw; + }; + struct chipHit{ + int stack; + int chip; + }; + + /** + * Data Structure containing the board to chip index map. + * The chip index is a number from 0-103, where the index corresponds to a unique chip number (hex number). + * The board is a string which is the name of the board type. + */ + struct strawIndexMap{ + std::string board; + int index; + }; + + /** + * The maps of chip to board maps. There is one per side. + */ + strawIndexMap chipToBoard_side[2][600]; + + StatusCode CheckEventBurst(); + StatusCode Book_TRT_RDOs(bool isNewLumiBlock, bool isNewRun); + StatusCode Retrieve_TRT_RDOs(); + StatusCode Fill_TRT_RDOs(); + StatusCode Book_TRT_Tracks(bool isNewLumiBlock, bool isNewRun); + StatusCode Book_TRT_Shift_Tracks(bool isNewLumiBlock, bool isNewRun); + StatusCode Retrieve_TRT_Tracks(); + StatusCode Fill_TRT_Tracks(); + + int strawLayerNumber(int strawLayerNumber, int LayerNumber); + + + // Returns the straw number (0-1641) given the layerNumber, strawlayerNumber, and strawNumber, all gotten from Athena IDHelper + int strawNumber(int strawNumber, int strawlayerNumber, int LayerNumber); + // Returns Barrel Board Number + int chipToBoard(int chip); + // Returns EndCap Board Number + int chipToBoard_EndCap(int chip); + + // Returns Degrees, converted from radians (Athena Standard units) + float radToDegrees(float radValue); + + + TH1F_LW* bookTH1F_LW(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int bins, double lowbin, double highbin, const std::string &xTitle, const std::string &yTitle, StatusCode &scode); + TH1F* bookTH1F(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int bins, double lowbin, double highbin, const std::string &xTitle, const std::string &yTitle, StatusCode &scode); + TH2F_LW* bookTH2F_LW(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int xbins, double lowxbins, double highxbins, int ybins, double lowybins, double highybins, const std::string &xTitle, const std::string &yTitle, StatusCode &scode); + TH2F* bookTH2F(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int xbins, double lowxbins, double highxbins, int ybins, double lowybins, double highybins, const std::string &xTitle, const std::string &yTitle, StatusCode &scode); + TProfile_LW* bookTProfile_LW(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int bins, double lowbin, double highbin, double ymin, double ymax, const std::string &xTitle, const std::string &yTitle, StatusCode &scode); + TProfile* bookTProfile(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int bins, double lowbin, double highbin, double ymin, double ymax, const std::string &xTitle, const std::string &yTitle, StatusCode &scode); + + template<typename T> StatusCode trtRegHist(T *hist, MonGroup &mongrp, const char *hName) + { + StatusCode scode = mongrp.regHist(hist); + if (scode == StatusCode::FAILURE) { + ATH_MSG_FATAL("Failed to register histogram " << hName); + } + return scode; + } + + StatusCode Check_TRT_Readout_Integrity(const EventInfo* eventInfo); + +private: + static const int s_numberOfBarrelStacks; + static const int s_numberOfEndCapStacks; + + static const int s_Straw_max[2]; + static const int s_iStack_max[2]; + static const int s_iChip_max[2]; + static const int s_numberOfStacks[2]; + static const int s_moduleNum[2]; + + ServiceHandle<IToolSvc> p_toolSvc; + ServiceHandle<ITRT_StrawStatusSummarySvc> m_sumSvc; + ServiceHandle<ITRT_DCS_ConditionsSvc> m_DCSSvc; + ServiceHandle<ITRT_DAQ_ConditionsSvc> m_DAQSvc; + ServiceHandle<ITRT_ByteStream_ConditionsSvc> m_BSSvc; + ServiceHandle<ITRT_ConditionsSvc> m_condSvc_BS; + //ServiceHandle<ITRT_ConditionsSvc> m_condSvc_DAQ; + ServiceHandle<ITRT_StrawNeighbourSvc> m_TRTStrawNeighbourSvc; + ServiceHandle<ITRT_CalDbSvc> m_trtcaldbSvc; + + + bool m_doDCS; + + + const TRT_ID* m_pTRTHelper; + const InDetDD::TRT_DetectorManager *mgr; + + ToolHandle<Trk::ITrackSummaryTool> m_TrackSummaryTool; + ToolHandle<ITRT_DriftFunctionTool> m_drifttool; + + const TRT_RDO_Container* m_rdoContainer; + std::string m_rawDataObjectName; + + const DataVector<Trk::Track> *m_trkCollection; + std::string m_tracksObjectName; + + const InDetTimeCollection *TRT_BCIDColl; + + const ComTime *theComTime; + const EventInfo* eventInfo; + + std::string m_comTimeObjectName; + std::string geo_summary_provider; + std::string mapPath; + + int rbins; + float rmin; + float rmax; + float tbins; + float tmin; + float tmax; + float fitmin; + float fitmax; + + TH1F_LW* m_hSummary; + TProfile* m_hChipBSErrorsVsLB[2][2]; + TProfile* m_hRobBSErrorsVsLB[2][2]; + + TProfile_LW* m_hAvgHLOcc_side[2][2]; + TProfile_LW* m_hAvgLLOcc_side[2][2]; + + TH1F_LW* m_hNumTrksDetPhi_B;//hNTrksvsPhi + TProfile_LW* m_hNumHoTDetPhi_B;//hNumHoTPhi + TProfile_LW* m_hAvgTroTDetPhi_B;//hAvgTrEdgeonTrack + TH1F_LW* m_hNumSwLLWoT_B;//hLLHitsonTrk + TH1F_LW* m_hHitWMap_B; + TH1F_LW* m_hHitWonTMap_B; + TH1F_LW* m_hResidual_B;//hHitToTrkDistance + TH1F_LW* m_hTimeResidual_B;//hHitToTrkDistance + TH1F_LW* m_hDriftTimeonTrkDist_B;//hDriftTimeonTrk + TH1F_LW* m_hTronTDist_B;//hTronT + TH2F_LW* m_hrtRelation_B;//hrt + TH1F_LW* m_hHLhitOnTrack_B; + TH1F_LW* m_hHtoLRatioOnTrack_B; + TH1F_LW* m_hWireToTrkPosition_B;//hWiretoTrkPosition + TH1F_LW* m_hResVsDetPhi_B; + TProfile* m_hNHitsperLB_B; + TProfile* m_hNTrksperLB_B; + TProfile* m_hNHLHitsperLB_B; + + TH1F_LW* m_hHitWMap_B_Ar; + TH1F_LW* m_hResidual_B_Ar; + TH1F_LW* m_hTimeResidual_B_Ar; + TH2F_LW* m_hrtRelation_B_Ar;//hrt + + TH1F_LW* m_hNumTrksDetPhi_E[2];//hNTrksvsPhi + TProfile_LW* m_hNumHoTDetPhi_E[2];//hNumHoTPhi + TProfile_LW* m_hAvgTroTDetPhi_E[2];//hAvgTrEdgeonTrack + TH1F_LW* m_hNumSwLLWoT_E[2];//hLLHitsonTrk + TH1F_LW* m_hHitWMap_E[2]; + TH1F_LW* m_hHitWonTMap_E[2]; + TH1F_LW* m_hResidual_E[2];//hHitToTrkDistance + TH1F_LW* m_hTimeResidual_E[2];//hHitToTrkDistance + TH1F_LW* m_hDriftTimeonTrkDist_E[2];//hDriftTimeonTrk + TH1F_LW* m_hTronTDist_E[2];//hTronT + TH2F_LW* m_hrtRelation_E[2];//hrt + TH1F_LW* m_hHLhitOnTrack_E[2]; + TH1F_LW* m_hHtoLRatioOnTrack_E[2]; + TH1F_LW* m_hWireToTrkPosition_E[2];//hWiretoTrkPosition + TH1F_LW* m_hResVsDetPhi_E[2]; + TProfile* m_hNHitsperLB_E[2]; + TProfile* m_hNTrksperLB_E[2]; + TProfile* m_hNHLHitsperLB_E[2]; + + TH1F_LW* m_hHitWMap_E_Ar[2]; + TH1F_LW* m_hResidual_E_Ar[2]; + TH1F_LW* m_hTimeResidual_E_Ar[2]; + TH2F_LW* m_hrtRelation_E_Ar[2];//hrt + + TProfile_LW* m_hStrawsEff[2][64]; + + TProfile_LW* m_hEvtPhaseDetPhi_B; + TProfile_LW* m_hEvtPhaseDetPhi_E[2]; + TH1F_LW* m_hEvtPhase; + TH2F_LW* m_hEvtPhaseVsTrig;// evt phase vs trig item + TProfile_LW* m_hChipsEff[2][64]; + + TH1F_LW* m_hHitOnTrackVsAllS[2][64]; + TH1F_LW* m_hHitOnTrackVsAllC[2][64]; + + /** Leading Edge in time Window: Straws. + * Any hit where the leading edge (driftTimeBin()) is less than 24. + * In Time window means ((driftTimeBin<24) && !lastBinHigh && !firstBinHigh) + * This is an RDO level histogram. + */ + TH1F_LW* m_hHitWMapS[2][64]; + + /** TE in Time Window: Straws. + * If hit trailing edge is in time window. + * In Time window means ((trailingEdge<23)&& !lastBinHigh && !firstBinHigh) + * m_hHitTrWMapS[m_phi_module]->Fill(m_strawNumber, ((m_trailingEdge+1)*3.125)); + */ + TProfile_LW* m_hHitTrWMapS[2][64]; + + /** Mean TE: Straws. + * Average of Trailing Edge bin where the trailing edge (trailingEdge()) is less than 23. + * This an RDO level histogram. + */ + TProfile_LW* m_hHitTrMapS[2][64]; + + /** Any LL bit on: Straws + * if any low threshold bit was set. + * if leading edge is > 0, or if trailing edge < 23, or if first bin is high, or if last bin is high + * This is an RDO level histogram. + */ + TH1F_LW* m_hHitAMapS[2][64]; + + /** LL in time window: Straws + * Any low level hit in time window by straw. + * ((m_driftTimeBin>0 || m_trailingEdge<23)&& !m_firstBinHigh && !m_lastBinHigh) + * This is an RDO level histogram. + */ + TH1F_LW* m_hHitAWMapS[2][64]; + + /** HL/LL: Straws + * The ratio of High Level hits to Low Level hits per straw. + * This is an RDO level histogram. + */ + TH1F_LW* m_hHtoLMapS[2][64]; // not filled + + /** Mean ToT (ns): Straws. + * Average Time over Threshold (ToT) in nano seconds per straw. + * m_hHitToTMapS[m_phi_module]->Fill(m_strawNumber, m_timeOverThreshold); + * m_timeOverThreshold = (p_lolum)->timeOverThreshold(); + * This is an RDO level histogram. + */ + TProfile_LW* m_hHitToTMapS[2][64]; + + /** Mean ToT (ns) for straws with ToT > LongToTCut: Straws. + * Average Time over Threshold (ToT) in nano seconds per straw for straws with ToT > LongToTCut. + * m_hHitToTLongMapS[m_phi_module]->Fill(m_strawNumber, m_timeOverThreshold); + * m_timeOverThreshold = (p_lolum)->timeOverThreshold(); + * This is an RDO level histogram. + */ + TProfile_LW* m_hHitToTLongMapS[2][64]; + + /** Mean Trailing Edge (ns) for straws with ToT > LongToTCut: Straws. + * Average Trailing Edge (Tr) in nano seconds per straw for straws with ToT > LongToTCut. + * m_hHitToTLongTrMapS[m_phi_module]->Fill(m_strawNumber, m_trailingEdge); + * m_trailingEdge = (p_lolum)->trailingEgde(); + * This is an RDO level histogram. + */ + TProfile_LW* m_hHitToTLongTrMapS[2][64]; + + /** High Level: Straws + * If a hit has any of the high threshold time bins up. + * m_hHitHMapS[m_phi_module]->Fill(m_strawNumber); + * This is an RDO level histogram + */ + TH1F_LW* m_hHitHMapS[2][64]; + + /** HL in time window: Straws + * If a hit has any of the high threshold time bins up, and is in the time window. ((m_driftTimeBin<24) && !m_firstBinHight && !m_lastBinHight) + * This is an RDO level histogram + */ + TH1F_LW* m_hHitHWMapS[2][64]; + + /** LE in time window on track: Straws. + * Leading Edge (LE) is within first 23 time bins of read out from a hit associated with a track. + * This is track level histogram. + */ + TH1F_LW* m_hHitWonTMapS[2][64]; + + /** Mean TE on track: Straws + * Average Trailing Edge(TE) from a hit associated with a track. + * This is a track level histogram. + */ + TProfile_LW* m_hHitTronTMapS[2][64]; + + /** Any LL bit on track: Straws + * Any low level bit is set from hit associated with a track. + * This is a track level hit + */ + TH1F_LW* m_hHitAonTMapS[2][64]; + + /** Any LL bit in time window on track: Straws + * Any low level (LL) bit set and is in time window from hits associated with tracks + * This is a track level histogram. + */ + TH1F_LW* m_hHitAWonTMapS[2][64]; + + /** Any HL hit on track: Straws + * Any straw with a High Threshold (HL) hit associated with a track. + * This is a track level histogram + */ + TH1F_LW* m_hHitHonTMapS[2][64]; + + /** HL in time window on track: Straws + * Straws with a High Threshold hit associated with a track and the hit is in the time window. + * This is a track level histogram. + */ + TH1F_LW* m_hHtoLonTMapS[2][64]; //not filled + + /** Mean ToT (ns) on Track: Straws + * Average Time over Threshold (ToT) from a straw hit associated with a track. + * This is a track level histogram. + */ + TProfile_LW* m_hHitToTonTMapS[2][64]; + + /** Mean TE on track (with Event Phase correction): Straws. + * Average trailing edge(TE) on track after correcting for event phase from a hit associated with a track. + * This is a track level histogram. + */ + TProfile_LW* m_hHitTronTwEPCMapS[2][64]; + + /** Valid Raw Drift Time on Track. + * Staws with hits that have valid drift times and are associated with a track. + * This is a track level histogram. + */ + TProfile_LW* m_hValidRawDriftTimeonTrk[2][64]; + TProfile_LW* m_hValidRawDriftTimeonTrkC[2][64]; + TH1F_LW* m_hHitWMapC[2][64]; + TProfile_LW* m_hHitTrMapC[2][64]; + TProfile_LW* m_hHitTrWMapC[2][64]; + TH1F_LW* m_hHitAMapC[2][64]; + TH1F_LW* m_hHitAWMapC[2][64]; + TH1F_LW* m_hHtoLMapC[2][64]; // not filled + + TH2F_LW* m_hHtoBCMapC[2][64]; + TH2F_LW* m_hHtoBCMapB[2][64]; + TProfile_LW* m_hHitToTMapC[2][64]; + TH1F_LW* m_hHitHMapC[2][64]; + TH1F_LW* m_hHitHWMapC[2][64]; + + /** LE in time window on track: Chips. + * Leading Edge (LE) from a hit associated with a track is within first 23 time bins. + * Plotted as a function of DTMROC. + * This is a track level histogram. + */ + TH1F_LW* m_hHitWonTMapC[2][64]; + TProfile_LW* m_hHitTronTMapC[2][64]; + TH1F_LW* m_hHitAonTMapC[2][64]; + TH1F_LW* m_hHitAWonTMapC[2][64]; + TH1F_LW* m_hHitHonTMapC[2][64]; + TH1F_LW* m_hHtoLonTMapC[2][64]; // not filled + TProfile_LW* m_hHitToTonTMapC[2][64]; + TProfile_LW* m_hHitTronTwEPCMapC[2][64]; + + TProfile_LW* m_hHitToTrkDistanceMapS_E[64]; + + /** Avg. Occupancy: Modules (Side A&C) + * Average Occupancy per Phi Module on Side A(&C). + * This is an RDO level Histogram. + */ + TProfile_LW* m_hAvgLLOccMod_side[2][2]; + TProfile_LW* m_hAvgHLOccMod_side[2][2]; + TProfile_LW* m_hBCIDvsOcc[2]; + + /** Avg. Occupancy: Modules (Side A and C) + * Average Occupancy per Phi Module on Side A and C. + * This is an RDO level Histogram. + */ + TH1F_LW* m_hChipOcc[2][64]; + TH1F_LW* m_hStrawOcc[2][64]; + + /** Anatoli's "Scatter histograms" ** + ** Monitor quantities as a function of lumi block. Fill per every stack + */ + TH2F_LW* m_hHitsOnTrack_Scatter[2]; + TH2F_LW* m_hLLOcc_Scatter[2]; + TH2F_LW* m_hHightoLowRatioOnTrack_Scatter[2]; + TH1F_LW* m_hOccAll; + + /* Helpers for the scatter histograms - 32 stacks (do same for both side for now) */ + float m_LLOcc[2][64]; // easy to keep occupancy separately for sides A&C, so let's do that + + + float m_HTfraconTrack_B[32]; + float m_LonTrack_B[32]; + int m_nTrack_B[32]; + int m_nTrackwithHL_B[32]; + + + + float m_HTfraconTrack_E[64]; + float m_LonTrack_E[64]; + int m_nTrack_E[64]; + int m_nTrackwithHL_E[64]; + + bool m_doRDOsMon; + bool m_doGeoMon; + bool m_doTracksMon; + int m_nEvents; + int nTRTHits[2]; + int nEvents; + + bool DoAside, DoCside, DoStraws, DoChips, DoShift, DoExpert, DoDiagnostic, DoMaskStraws; + bool m_useHoleFinder;//switch for hole finder + + int m_LE_timeWindow_MIN; + int m_LE_timeWindow_MAX; + + int m_LL_timeWindow_MIN; + int m_LL_timeWindow_MAX; + + int m_HL_timeWindow_MIN; + int m_HL_timeWindow_MAX; + + bool m_NoiseSuppressionLevel_30pc; + int m_MIN_N_LL_Hits; + int m_MIN_TOT_Hits; + bool m_NoiseSuppressionMap; + + float EventPhaseScale; + + + unsigned char mat_chip_B[64][1642]; + int m_nStrawHits_B[1642]; + + unsigned char mat_chip_E[64][3840]; + int m_nStrawHits_E[2][3840]; + + float DriftTimeonTrkDistScale_B; + float HLhitOnTrackScale_B; + float HtoLRatioOnTrackScale_B; + float NumSwLLWoTScale_B; + float WireToTrkPositionScale_B; + float TronTDistScale_B; + float ResidualScale_B; + float TimeResidualScale_B; + float ResidualScale_B_Ar; + float TimeResidualScale_B_Ar; + float nTrkvPhiScale_B; + int nTrksperLB_B; + int nHitsperLB_B; + int nHLHitsperLB_B; + + float DriftTimeonTrkDistScale_E[2]; + float HLhitOnTrackScale_E[2]; + float HtoLRatioOnTrackScale_E[2]; + float NumSwLLWoTScale_E[2]; + float WireToTrkPositionScale_E[2]; + float TronTDistScale_E[2]; + float ResidualScale_E[2]; + float TimeResidualScale_E[2]; + float ResidualScale_E_Ar[2]; + float TimeResidualScale_E_Ar[2]; + float nTrkvPhiScale_E[2]; + int nTrksperLB_E[2]; + int nHitsperLB_E[2]; + int nHLHitsperLB_E[2]; + + + ToolHandle<Trk::IPropagator> m_propagatorTool; + Trk::IPropagator *m_propagator; + ToolHandle<Trk::IExtrapolator> m_extrapolatorTool; + Trk::IExtrapolator *m_extrapolator; + + float m_maxDistToStraw; + float m_DistToStraw; + bool m_trt_only_trks; + bool m_zero_field; + bool DEBUG; + bool m_printEventInfo; + float m_longToTCut; + int m_nphi_bins; + int m_EventBurstCut; + int m_lumiBlocksToResetOcc; + bool m_isCosmics; + int m_minTRThits; + float m_minP; + void scale_LWHist(TH1F_LW* hist, float scale); + void divide_LWHist(TH1F_LW* result, TH1F_LW* a, TH1F_LW* b); + + ///// Additional stuff for efficiency measurements, online only for now + bool DoEfficiency; + ToolHandle<Trk::ITrackHoleSearchTool> m_trt_hole_finder; + std::string m_track_collection_hole_finder; + float m_max_abs_d0; + float m_max_abs_z0; + float m_min_pT; + float m_max_abs_eta; + + int m_min_si_hits; + int m_min_pixel_hits; + int m_min_sct_hits; + int m_min_trt_hits; + + float m_track_pt; + float m_track_eta; + float m_track_phi; + float m_track_d0; + float m_track_z0; + int m_min_tracks_straw; + + int m_every_xth_track; + std::string m_RODlistfile; + std::string m_datatype; + + StatusCode Book_TRT_Efficiency(bool isNewLumiBlock, bool isNewRun); + StatusCode Fill_TRT_Efficiency(); + + TProfile_LW* m_hefficiency_eta; + TProfile_LW* m_hefficiency_phi; + TProfile_LW* m_hefficiency_pt; + TProfile_LW* m_hefficiency_z0; + TProfile_LW* m_hefficiencyBarrel_locR; + TProfile_LW* m_hefficiencyEndCap_locR[2]; + + TProfile_LW* m_hefficiencyBarrel_locR_Off; + TProfile_LW* m_hefficiencyBarrel_locR_Off_Ar; + TProfile_LW* m_hefficiencyEndCap_locR_Off[2]; + TProfile_LW* m_hefficiencyEndCap_locR_Off_Ar[2]; + + TProfile_LW* m_hefficiencyMap[2]; // 0-barrel, 1-endcap + TProfile_LW* m_hefficiencyS[2][64]; // 0-barrel, 1-endcap + TProfile_LW* m_hefficiencyC[2][64]; // 0-barrel, 1-endcap + TH1F_LW* m_hefficiency[2][2]; + TH1F_LW* m_hefficiencyIntegral[2][2]; + + const DataVector<Trk::Track> *m_trkCollectionEff; + + int strawNumberEndCap(int strawNumber, int strawLayerNumber, int LayerNumber, int phi_stack, int side); +}; + +#endif diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/cmt/requirements b/InnerDetector/InDetMonitoring/TRT_Monitoring/cmt/requirements new file mode 100644 index 0000000000000000000000000000000000000000..f0f89f342446d72140a60ad93f98e42fc1211b73 --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/cmt/requirements @@ -0,0 +1,48 @@ +package TRT_Monitoring + +author James Degenhardt <James.Degenhardt@cern.ch> + +private + +use DataModel DataModel-* Control +use AtlasROOT AtlasROOT-* External +#use AtlasBoost AtlasBoost-* External +use LWHists LWHists-* Tools +use EventInfo EventInfo-* Event +use AtlasDetDescr AtlasDetDescr-* DetectorDescription +use Identifier Identifier-* DetectorDescription +use InDetRIO_OnTrack InDetRIO_OnTrack-* InnerDetector/InDetRecEvent +use InDetIdentifier InDetIdentifier-* InnerDetector/InDetDetDescr +use InDetReadoutGeometry InDetReadoutGeometry-* InnerDetector/InDetDetDescr +use TRT_DriftFunctionTool TRT_DriftFunctionTool-* InnerDetector/InDetRecTools +use TRT_TrackHoleSearch TRT_TrackHoleSearch-* InnerDetector/InDetRecTools +use InDetConditionsSummaryService InDetConditionsSummaryService-* InnerDetector/InDetConditions +use TRT_ConditionsServices TRT_ConditionsServices-* InnerDetector/InDetConditions +use TrkTrack TrkTrack-* Tracking/TrkEvent +#use TrkParameters TrkParameters-* Tracking/TrkEvent +use TrkTrackSummary TrkTrackSummary-* Tracking/TrkEvent +use TrkToolInterfaces TrkToolInterfaces-* Tracking/TrkTools +use TrkExInterfaces TrkExInterfaces-* Tracking/TrkExtrapolation +use CommissionEvent CommissionEvent-* Commission + +end_private + +public + +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External +use AthenaMonitoring AthenaMonitoring-* Control +use InDetRawData InDetRawData-* InnerDetector/InDetRawEvent + +# Online packages, needed for the TRT_Hits_Monitoring_Tool at Point 1 +macro online_use "" AtlasHLT_scripts "HLTtdaq HLTtdaq-* HLT/HLTExternal" +use $(online_use) + +library TRT_Monitoring *.cxx components/*.cxx +apply_pattern declare_joboptions files="*.py *.txt" +apply_pattern component_library + +# Online preprocessing, needed for the TRT_Hits_Monitoring_Tool at Point 1 +macro_append AtlasCxxPolicy_pp_cppflags "" AtlasHLT_scripts " -DONLINE" +# Online libraries, needed for the TRT_Hits_Monitoring_Tool at Point 1 +macro_append TRT_Monitoring_shlibflags "" AtlasHLT_scripts " -lipc -lis" diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/share/jobOptions_artest.py b/InnerDetector/InDetMonitoring/TRT_Monitoring/share/jobOptions_artest.py new file mode 100644 index 0000000000000000000000000000000000000000..f0e0b7afe080b36621a8dbadc696085a3c10af29 --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/share/jobOptions_artest.py @@ -0,0 +1,80 @@ +OutputLevel = INFO +doJiveXML = False +doVP1 = False +doWriteESD = False +doWriteAOD = False +doReadBS = True +doAuditors = True + +import os +if os.environ['CMTCONFIG'].endswith('-dbg'): + doEdmMonitor = True + doNameAuditor = True +else: + doEdmMonitor = False + doNameAuditor = False +DetDescrVersion = "ATLAS-GEO-18-01-01" +import AthenaCommon.SystemOfUnits as Units +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo = 'atlas' +globalflags.DataSource = 'data' +if 'doReadBS' in dir() and doReadBS: + globalflags.InputFormat = 'bytestream' + globalflags.ConditionsTag = 'COMCOND-BLKPST-005-01' +else: + globalflags.InputFormat = 'pool' +globalflags.DetDescrVersion = DetDescrVersion +globalflags.print_JobProperties() +if len(globalflags.ConditionsTag())!=0: + from IOVDbSvc.CondDB import conddb + conddb.setGlobalTag(globalflags.ConditionsTag()) + +from AthenaCommon.BeamFlags import jobproperties +jobproperties.Beam.energy = 7.*Units.TeV +jobproperties.Beam.beamType = 'collisions' +if 'doReadBS' in dir() and doReadBS: + jobproperties.Beam.bunchSpacing = 75 +from RecExConfig.RecFlags import rec +rec.Commissioning=False + +from AthenaCommon.DetFlags import DetFlags +DetFlags.ID_setOn() +DetFlags.Calo_setOff() +DetFlags.Muon_setOff() + +DetFlags.Print() +from InDetRecExample.InDetJobProperties import InDetFlags +InDetFlags.doTruth = (globalflags.DataSource == 'geant4' and globalflags.InputFormat() == 'pool') +InDetFlags.doxKalman = False +InDetFlags.doiPatRec = True +InDetFlags.doMonitoringGlobal = True +InDetFlags.doMonitoringPixel = False +InDetFlags.doMonitoringSCT = False +InDetFlags.doMonitoringTRT = True +InDetFlags.doMonitoringAlignment = False +InDetFlags.doTrkNtuple = True +InDetFlags.doPixelTrkNtuple = True +InDetFlags.doTrtTrkNtuple = True +InDetFlags.doPrintConfigurables = True + +from TrkDetDescrSvc.TrkDetDescrJobProperties import TrkDetFlags +TrkDetFlags.TRT_BuildStrawLayers = True + +include("InDetRecExample/InDetRec_all.py") +from TRT_Monitoring.TRT_MonitoringConf import TRT_Monitoring_Tool +#TRT_Monitoring_Tool.m_useConditionsHTStatus = True +#TRT_Monitoring_Tool.m_useArgonStraws = True +TRT_Monitoring_Tool.doArgonXenonSeperation = True +TRT_Monitoring_Tool.useHoleFinder = False +from IOVDbSvc.CondDB import conddb +conddb.addOverride("/TRT/Cond/StatusHT","TrtStrawStatusHT-ArTest-00-00") +theApp.EvtMax = 50 +if not doReadBS: + ServiceMgr.PoolSvc.AttemptCatalogPatch=True + ServiceMgr.EventSelector.InputCollections = ["/afs/cern.ch/atlas/maxidisk/d158/CSC.005200.T1_McAtNlo_Jimmy.RDO.pool.root" ] +if doReadBS: +# ServiceMgr.ByteStreamInputSvc.FullFileName = [ "/afs/cern.ch/user/e/eyazici/rawdata/data12_8TeV.00205010.physics_ZeroBiasOverlay.merge.RAW/data12_8TeV.00205010.physics_ZeroBiasOverlay.merge.RAW._lb0137._SFO-ALL._0001.1"] +#AB ServiceMgr.ByteStreamInputSvc.FullFileName = [ "/afs/cern.ch/user/e/eyazici/rawdata/data12_8TeV.00201113.physics_ZeroBiasOverlay.merge.RAW/data12_8TeV.00201113.physics_ZeroBiasOverlay.merge.RAW._lb0423._SFO-ALL._0001.1"] + ServiceMgr.ByteStreamInputSvc.FullFileName = [ "/afs/cern.ch/user/e/eyazici/public/data12_8TeV.00201113.physics_ZeroBiasOverlay.merge.RAW._lb0423._SFO-ALL._0001.1"] + +# ServiceMgr.ByteStreamInputSvc.FullFileName = [ "/tmp/rjungst/testinput"] diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/src/TRT_Hits_Monitoring_Tool.cxx b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/TRT_Hits_Monitoring_Tool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..acf3b7bee4d624c50998ffd11e0e0ac3dc48321c --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/TRT_Hits_Monitoring_Tool.cxx @@ -0,0 +1,131 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifdef ONLINE // This tool is only meant for special online monitoring at Point 1 + +#include "TRT_Monitoring/TRT_Hits_Monitoring_Tool.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" + +#include "boost/date_time/posix_time/posix_time_types.hpp" + +TRT_Hits_Monitoring_Tool::TRT_Hits_Monitoring_Tool(const std::string &type, const std::string &name, const IInterface *parent): + ManagedMonitorToolBase(type, name, parent), + m_pTRTHelper(0), + m_lastPublishTime(boost::posix_time::min_date_time) // never +{ + declareProperty("TRTRawDataObjectName", m_rawDataObjectName = "TRT_RDOs"); + declareProperty("Partition", m_partition = "initial"); + declareProperty("Server", m_server = "beamconditions"); + declareProperty("Name", m_name = "hitfractionTRT"); + declareProperty("LongToTCut", m_longToTCut = 9.375); + declareProperty("SleepTime", m_sleepTime = 500); // milliseconds +} + +TRT_Hits_Monitoring_Tool::~TRT_Hits_Monitoring_Tool() +{ +} + +StatusCode TRT_Hits_Monitoring_Tool::initialize () +{ + StatusCode sc; + + sc = ManagedMonitorToolBase::initialize(); + if (!sc.isSuccess()) return sc; + + sc = AlgTool::initialize(); + if (!sc.isSuccess()) return sc; + + sc = detStore()->retrieve(m_pTRTHelper, "TRT_ID"); + if (!sc.isSuccess()) return sc; + + IPCPartition partition(m_partition); + m_dict = ISInfoDictionary(partition); + + m_name_longToT = m_server + "." + m_name + "_longToT"; + m_nameBR_longToT = m_server + "." + m_name + "Barrel_longToT"; + m_nameEA_longToT = m_server + "." + m_name + "EndCapA_longToT"; + m_nameEC_longToT = m_server + "." + m_name + "EndCapC_longToT"; + + m_dict.checkin(m_name_longToT, m_occ_longToT); + m_dict.checkin(m_nameBR_longToT, m_occBR_longToT); + m_dict.checkin(m_nameEA_longToT, m_occEA_longToT); + m_dict.checkin(m_nameEC_longToT, m_occEC_longToT); + + return StatusCode::SUCCESS; +} + +StatusCode TRT_Hits_Monitoring_Tool::bookHistogramsRecurrent() +{ + return StatusCode::SUCCESS; +} + +StatusCode TRT_Hits_Monitoring_Tool::fillHistograms() +{ + const static boost::posix_time::time_duration sleepTime = boost::posix_time::milliseconds(m_sleepTime); + const boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time(); + if (now - m_lastPublishTime < sleepTime) return StatusCode::SUCCESS; // do not publish results too often + + if (!evtStore()->contains<TRT_RDO_Container>(m_rawDataObjectName)) { + ATH_MSG_ERROR("StoreGate contains no TRT_RDO_Container named " << m_rawDataObjectName); + return StatusCode::FAILURE; + } + TRT_RDO_Container *rdoContainer = 0; + StatusCode sc = evtStore()->retrieve(rdoContainer, m_rawDataObjectName); // get TRT Raw Data Objects (all TRT hits) + if (sc.isFailure() || !rdoContainer) { + ATH_MSG_ERROR("Could not retrieve TRT_RDO_Container named " << m_rawDataObjectName); + return StatusCode::FAILURE; + } + + unsigned int nHits_longToT = 0; + unsigned int nHitsBR_longToT = 0; + unsigned int nHitsEA_longToT = 0; + unsigned int nHitsEC_longToT = 0; + + const TRT_RDO_Container::const_iterator containerBeg = rdoContainer->begin(); + const TRT_RDO_Container::const_iterator containerEnd = rdoContainer->end(); + for (TRT_RDO_Container::const_iterator collection = containerBeg; collection != containerEnd; ++collection) { + const InDetRawDataCollection<TRT_RDORawData> *TRT_Collection(*collection); + if (!TRT_Collection) continue; // select only TRT RDOs + + const DataVector<TRT_RDORawData>::const_iterator collectionBeg = TRT_Collection->begin(); + const DataVector<TRT_RDORawData>::const_iterator collectionEnd = TRT_Collection->end(); + for (DataVector<TRT_RDORawData>::const_iterator rdo = collectionBeg; rdo != collectionEnd; ++rdo) { + const TRT_LoLumRawData *rawData = dynamic_cast<const TRT_LoLumRawData *>(*rdo); + if (!rawData) continue; // not the right data type + if (rawData->timeOverThreshold() <= m_longToTCut) continue; // omit hits with short ToT + + ++nHits_longToT; + switch (m_pTRTHelper->barrel_ec((*rdo)->identify())) { // which detector region? + case -1: // ... or ... + case +1: ++nHitsBR_longToT; break; + case +2: ++nHitsEA_longToT; break; + case -2: ++nHitsEC_longToT; break; + } + } + } + + const unsigned int nChannelsBarrel = 105088; // 52544 straws with two channels + const unsigned int nChannelsEndcap = 122880; // 122880 straws with one channel + const unsigned int nChannelsTotal = nChannelsBarrel + 2 * nChannelsEndcap; + + m_occ_longToT = (float)nHits_longToT / nChannelsTotal; + m_occBR_longToT = (float)nHitsBR_longToT / nChannelsBarrel; + m_occEA_longToT = (float)nHitsEA_longToT / nChannelsEndcap; + m_occEC_longToT = (float)nHitsEC_longToT / nChannelsEndcap; + + m_dict.update(m_name_longToT, m_occ_longToT); + m_dict.update(m_nameBR_longToT, m_occBR_longToT); + m_dict.update(m_nameEA_longToT, m_occEA_longToT); + m_dict.update(m_nameEC_longToT, m_occEC_longToT); + + m_lastPublishTime = now; + return StatusCode::SUCCESS; +} + +StatusCode TRT_Hits_Monitoring_Tool::procHistograms() +{ + return StatusCode::SUCCESS; +} + +#endif // ONLINE diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/src/TRT_Monitoring_Tool.cxx b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/TRT_Monitoring_Tool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fb9a93bcb088767438f0329acfe46f114015efb1 --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/TRT_Monitoring_Tool.cxx @@ -0,0 +1,3643 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TRT_Monitoring/TRT_Monitoring_Tool.h" + +#include "TRT_TrackHoleSearch/TRTStrawEfficiency.h" +#include "TRT_TrackHoleSearch/TRTTrackHoleSearchTool.h" +#include "DataModel/DataVector.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" +#include "InDetRIO_OnTrack/PixelClusterOnTrack.h" +#include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" +#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" +//#include "TrkParameters/MeasuredPerigee.h" +#include "TrkToolInterfaces/ITrackSummaryTool.h" +#include "TrkTrackSummary/TrackSummary.h" +#include "TrkExInterfaces/IPropagator.h" +#include "TrkExInterfaces/IExtrapolator.h" +#include "CommissionEvent/ComTime.h" +#include "AtlasDetDescr/AtlasDetectorID.h" +#include "Identifier/Identifier.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetRawData/InDetRawDataContainer.h" +#include "TrkTrack/Track.h" +#include "TrkTrack/TrackCollection.h" +#include "TRT_DriftFunctionTool/ITRT_DriftFunctionTool.h" +#include "TRT_ConditionsServices/ITRT_CalDbSvc.h" +#include "TRT_ConditionsServices/ITRT_ConditionsSvc.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" +#include "TRT_ConditionsServices/ITRT_DCS_ConditionsSvc.h" +#include "TRT_ConditionsServices/ITRT_DAQ_ConditionsSvc.h" +#include "TRT_ConditionsServices/ITRT_ByteStream_ConditionsSvc.h" +#include "TRT_ConditionsServices/ITRT_StrawNeighbourSvc.h" +#include "InDetConditionsSummaryService/IInDetConditionsSvc.h" +#include "EventInfo/EventInfo.h" +#include "EventInfo/TriggerInfo.h" +#include "EventInfo/EventID.h" + +#include "TH1.h" +#include "TH2.h" +#include "TProfile.h" +#include "LWHists/TH1F_LW.h" +#include "LWHists/TH2F_LW.h" +#include "LWHists/TProfile_LW.h" + +#include <sstream> +#include <iomanip> +#include <memory> + +using namespace std; + +const int TRT_Monitoring_Tool::s_numberOfBarrelStacks = 32; +const int TRT_Monitoring_Tool::s_numberOfEndCapStacks = 32; +const int TRT_Monitoring_Tool::s_Straw_max[2]={1642,3840}; +const int TRT_Monitoring_Tool::s_iStack_max[2]={32,64}; +const int TRT_Monitoring_Tool::s_iChip_max[2]={104,240}; +const int TRT_Monitoring_Tool::s_numberOfStacks[2]={32,32}; +const int TRT_Monitoring_Tool::s_moduleNum[2]={96,64}; + +//------------------------------------------------------------------------------------------------// +TRT_Monitoring_Tool::TRT_Monitoring_Tool(const std::string &type, const std::string &name, const IInterface *parent) : + ManagedMonitorToolBase(type, name, parent), + lastLumiBlock(-99), + nLumiBlock(0), + evtLumiBlock(0), + good_bcid(0), + probScale(1.0), + numberOfTracks(0), + m_nTotalTracks(0), + nBSErrors(), + nRobErrors(), + passEventBurst(), + m_idHelper(0), + p_toolSvc("IToolSvc",name), + m_sumSvc("TRT_StrawStatusSummarySvc",name), + m_DCSSvc("TRT_DCS_ConditionsSvc",name), + m_DAQSvc("TRT_DAQ_ConditionsSvc",name), + m_BSSvc("TRT_ByteStream_ConditionsSvc",name), + m_condSvc_BS("TRT_ByteStream_ConditionsSvc",name), + //m_condSvc_DAQ("TRT_DAQ_ConditionsSvc",name), + m_TRTStrawNeighbourSvc("TRT_StrawNeighbourSvc",name), + m_trtcaldbSvc("TRT_CalDbSvc",name), + m_doDCS(false), + m_pTRTHelper(0), + mgr(0), + m_TrackSummaryTool("Trk::TrackSummaryTool/InDetTrackSummaryTool"), + m_drifttool("TRT_DriftFunctionTool"), + m_rdoContainer(0), + m_trkCollection(0), + TRT_BCIDColl(0), + theComTime(0), + eventInfo(0), + m_comTimeObjectName("ComTime"), + geo_summary_provider("debug"), + rbins(40), + rmin(0.0), + rmax(2.0), + tbins(68), + tmin(-12.5), + tmax(75.0), + fitmin(-5.0), + fitmax(30.0), + m_HTfraconTrack_B(), + m_LonTrack_B(), + m_nTrack_B(), + m_nTrackwithHL_B(), + m_HTfraconTrack_E(), + m_LonTrack_E(), + m_nTrack_E(), + m_nTrackwithHL_E(), + nTRTHits(), + EventPhaseScale(1.0), + m_nStrawHits_B(), + m_nStrawHits_E(), + DriftTimeonTrkDistScale_B(), + HLhitOnTrackScale_B(), + HtoLRatioOnTrackScale_B(), + NumSwLLWoTScale_B(), + WireToTrkPositionScale_B(), + TronTDistScale_B(), + ResidualScale_B(), + TimeResidualScale_B(), + ResidualScale_B_Ar(), + TimeResidualScale_B_Ar(), + nTrkvPhiScale_B(), + DriftTimeonTrkDistScale_E(), + HLhitOnTrackScale_E(), + HtoLRatioOnTrackScale_E(), + NumSwLLWoTScale_E(), + WireToTrkPositionScale_E(), + TronTDistScale_E(), + ResidualScale_E(), + TimeResidualScale_E(), + ResidualScale_E_Ar(), + TimeResidualScale_E_Ar(), + nTrkvPhiScale_E(), + m_propagator(0), + m_extrapolator(0), + DEBUG(false), + m_printEventInfo(false), + m_longToTCut(9.375), + m_EventBurstCut(200), + m_lumiBlocksToResetOcc(20), + m_isCosmics(false), + m_minTRThits(10), + m_minP(0), + m_trt_hole_finder("TRTTrackHoleSearchTool"), + m_useHoleFinder(false), + m_track_pt(0), + m_track_eta(0), + m_track_phi(0), + m_track_d0(0), + m_track_z0(0), + m_min_tracks_straw(10), + m_trkCollectionEff(0) + + //-----------------------------------------------------------------------------------------------// +{ + declareProperty("ToolSvc", p_toolSvc); + declareProperty("InDetTRTStrawStatusSummarySvc",m_sumSvc); + declareProperty("InDetTRT_DAQ_ConditionsSvc", m_DAQSvc); + declareProperty("InDetTRT_DCS_ConditionsSvc", m_DCSSvc); + declareProperty("TRT_ByteStream_ConditionsSvc", m_BSSvc); + declareProperty("TRT_StrawNeighbourSvc", m_TRTStrawNeighbourSvc); + declareProperty("DriftFunctionTool", m_drifttool); + declareProperty("DoTRT_DCS", m_doDCS); + declareProperty("DoRDOsMon", m_doRDOsMon = true); + declareProperty("DoGeoMon", m_doGeoMon = false); + declareProperty("TRTRawDataObjectName", m_rawDataObjectName = "TRT_RDOs"); + declareProperty("NumberOfEvents", m_nEvents = -1); + declareProperty("DoTracksMon", m_doTracksMon = true); + declareProperty("TRTTracksObjectName", m_tracksObjectName = "Tracks"); + declareProperty("doAside", DoAside = true); + declareProperty("doCside", DoCside = true); + declareProperty("doStraws", DoStraws = true); + declareProperty("doChips", DoChips = false); + declareProperty("doExpert", DoExpert = false); + declareProperty("doEfficiency", DoEfficiency = true); + declareProperty("doMaskStraws", DoMaskStraws = true); + declareProperty("doShift", DoShift = true); + declareProperty("doDiagnostic", DoDiagnostic = false); + declareProperty("ComTimeObjectName", m_comTimeObjectName = "TRT_Phase"); + declareProperty("TrkSummaryTool", m_TrackSummaryTool); + declareProperty("Geo_Summary_Provider", geo_summary_provider); + declareProperty("Map_Path", mapPath); // obsolete + declareProperty("maxDistToStraw", m_maxDistToStraw = 2.0); + declareProperty("DistanceToStraw", m_DistToStraw = 0.4); + declareProperty("is_TRT_only_tracks", m_trt_only_trks = true); + declareProperty("is_zero_mag_field", m_zero_field = true); + // + // Tunable parameters for TRT monitoring histograms + // + declareProperty("LE_TimeWindow_MIN", m_LE_timeWindow_MIN = 0); + declareProperty("LE_TimeWindow_MAX", m_LE_timeWindow_MAX = 24); + declareProperty("LL_TimeWindow_MIN", m_LL_timeWindow_MIN = 0); + declareProperty("LL_TimeWindow_MAX", m_LL_timeWindow_MAX = 24); + declareProperty("HL_TimeWindow_MIN", m_HL_timeWindow_MIN = 0); + declareProperty("HL_TimeWindow_MAX", m_HL_timeWindow_MAX = 3); + declareProperty("MIN_N_LL_Hits", m_MIN_N_LL_Hits = 10); + declareProperty("MIN_TOT_Hits", m_MIN_TOT_Hits = 2); + declareProperty("NoiseSuppressionLevel_30pc", m_NoiseSuppressionLevel_30pc = false); + declareProperty("NoiseSuppressionMap", m_NoiseSuppressionMap = false); + declareProperty("Debug", DEBUG); + declareProperty("PrintEventInfo", m_printEventInfo); + declareProperty("ITRT_CalDbSvc", m_trtcaldbSvc); + declareProperty("LongToTCut", m_longToTCut); + declareProperty("NPhiBins", m_nphi_bins = 360); + declareProperty("EventBurstCut", m_EventBurstCut = 200); + declareProperty("LumiBlocksToResetOcc", m_lumiBlocksToResetOcc = 20); + declareProperty("IsCosmics", m_isCosmics = false); + declareProperty("MinTRTHitCut", m_minTRThits = 10); + declareProperty("trt_hole_finder", m_trt_hole_finder); + declareProperty("useHoleFinder", m_useHoleFinder); + declareProperty("track_collection_hole_finder", m_track_collection_hole_finder = "CombinedInDetTracks"); + declareProperty("max_abs_d0", m_max_abs_d0 = 10 * CLHEP::mm); + declareProperty("max_abs_z0", m_max_abs_z0 = 300 * CLHEP::mm); + declareProperty("max_abs_eta", m_max_abs_eta = 2.5); + declareProperty("MinTrackP", m_minP = 0.0 * CLHEP::GeV); + declareProperty("min_pT", m_min_pT = 0.5 * CLHEP::GeV); + declareProperty("min_si_hits", m_min_si_hits = 1); + declareProperty("min_pixel_hits", m_min_pixel_hits = 0); + declareProperty("min_sct_hits", m_min_sct_hits = 0); + declareProperty("min_trt_hits", m_min_trt_hits = 10); + declareProperty("min_tracks_straw", m_min_tracks_straw = 10); + declareProperty("every_xth_track", m_every_xth_track = 25); + declareProperty("whatdatatype", m_datatype); + declareProperty("doArgonXenonSeparation", m_ArgonXenonSplitter = true); // Argon Histograms won't be created if this is set to false. + + nEvents=0; + m_hSummary = 0; + m_hEvtPhaseDetPhi_B = 0; + m_hEvtPhase = 0; + m_hEvtPhaseVsTrig = 0; + m_hOccAll = 0; + m_hefficiency_eta = 0; + m_hefficiency_phi = 0; + m_hefficiency_pt = 0; + m_hefficiency_z0 = 0; + + for (int iside=0; iside<2; iside++) { // A-side(iside=0), C-side(iside=1) + m_nTracksB[iside]=0; + m_nTracksEC[iside]=0; + m_nTracksEC_B[iside]=0; + } + + for (int ibe=0; ibe<2; ibe++) { + m_hBCIDvsOcc[ibe] = 0; + m_hHitsOnTrack_Scatter[ibe] = 0; + m_hLLOcc_Scatter[ibe] = 0; + m_hHightoLowRatioOnTrack_Scatter[ibe] = 0; + m_hefficiencyMap[ibe]=0; + + for (int iside=0; iside<2; iside++) { + m_hChipBSErrorsVsLB[ibe][iside] = 0; + m_hRobBSErrorsVsLB[ibe][iside] = 0; + m_hAvgHLOcc_side[ibe][iside] = 0; + m_hAvgLLOcc_side[ibe][iside] = 0; + m_hAvgLLOccMod_side[ibe][iside] = 0; + m_hAvgHLOccMod_side[ibe][iside] = 0; + m_hefficiency[ibe][iside] = 0; + m_hefficiencyIntegral[ibe][iside] = 0; + }// for (int iside=0; iside<2; iside++) + + for (int i = 0; i < 64; i++) { + m_hChipOcc[ibe][i] = 0; + m_hStrawOcc[ibe][i] = 0; + m_hStrawsEff[ibe][i] = 0; + m_hChipsEff[ibe][i] = 0; + m_hHitOnTrackVsAllS[ibe][i] = 0; + m_hHitOnTrackVsAllC[ibe][i] = 0; + m_hHitWMapS[ibe][i] = 0; + m_hHitTrWMapS[ibe][i] = 0; + m_hHitTrMapS[ibe][i] = 0; + m_hHitAMapS[ibe][i] = 0; + m_hHitAWMapS[ibe][i] = 0; + m_hHtoLMapS[ibe][i] = 0; + m_hHitToTMapS[ibe][i] = 0; + m_hHitToTLongMapS[ibe][i] = 0; + m_hHitToTLongTrMapS[ibe][i] = 0; + m_hHitHMapS[ibe][i] = 0; + m_hHitHWMapS[ibe][i] = 0; + m_hHitWonTMapS[ibe][i] = 0; + m_hHitTronTMapS[ibe][i] = 0; + m_hHitAonTMapS[ibe][i] = 0; + m_hHitAWonTMapS[ibe][i] = 0; + m_hHitHonTMapS[ibe][i] = 0; + m_hHtoLonTMapS[ibe][i] = 0; + m_hHtoLonTMapS[ibe][i] = 0; + m_hHitToTonTMapS[ibe][i] = 0; + m_hHitTronTwEPCMapS[ibe][i] = 0; + m_hValidRawDriftTimeonTrk[ibe][i] = 0; + m_hValidRawDriftTimeonTrkC[ibe][i] = 0; + m_hHitWMapC[ibe][i] = 0; + m_hHitTrMapC[ibe][i] = 0; + m_hHitTrWMapC[ibe][i] = 0; + m_hHitAMapC[ibe][i] = 0; + m_hHitAWMapC[ibe][i] = 0; + m_hHtoLMapC[ibe][i] = 0; + m_hHtoBCMapC[ibe][i] = 0; + m_hHtoBCMapB[ibe][i] = 0; + m_hHitToTMapC[ibe][i] = 0; + m_hHitHMapC[ibe][i] = 0; + m_hHitHWMapC[ibe][i] = 0; + m_hHitWonTMapC[ibe][i] = 0; + m_hHitTronTMapC[ibe][i] = 0; + m_hHitAonTMapC[ibe][i] = 0; + m_hHitAWonTMapC[ibe][i] = 0; + m_hHitHonTMapC[ibe][i] = 0; + m_hHtoLonTMapC[ibe][i] = 0; + m_hHitToTonTMapC[ibe][i] = 0; + m_hHitTronTwEPCMapC[ibe][i] = 0; + m_hefficiencyS[ibe][i] = 0; + m_hefficiencyC[ibe][i] = 0; + + if (ibe==1) m_hHitToTrkDistanceMapS_E[i]=0; + + } //for (int i = 0; i < 64; i++) + } // for (int ibe=0; ibe<2; ibe++) + + nTrksperLB_B=0; + nHitsperLB_B=0; + nHLHitsperLB_B=0; + m_hNumTrksDetPhi_B = 0; + m_hNumHoTDetPhi_B = 0; + m_hAvgTroTDetPhi_B = 0; + m_hNumSwLLWoT_B = 0; + m_hHitWMap_B = 0; + m_hHitWonTMap_B = 0; + m_hResidual_B = 0; + m_hTimeResidual_B = 0; + m_hDriftTimeonTrkDist_B = 0; + m_hTronTDist_B = 0; + m_hrtRelation_B = 0; + m_hHLhitOnTrack_B = 0; + m_hHtoLRatioOnTrack_B = 0; + m_hWireToTrkPosition_B = 0; + m_hResVsDetPhi_B = 0; + m_hNHitsperLB_B = 0; + m_hNTrksperLB_B = 0; + m_hNHLHitsperLB_B = 0; + m_hefficiencyBarrel_locR = 0; + m_hefficiencyBarrel_locR_Off = 0; + m_hefficiencyBarrel_locR_Off_Ar = 0; + m_hHitWMap_B_Ar=0; + m_hResidual_B_Ar=0; + m_hTimeResidual_B_Ar=0; + m_hrtRelation_B_Ar = 0; + + for (int iside=0; iside<2; iside++) { + nTrksperLB_E[iside]=0; + nHitsperLB_E[iside]=0; + nHLHitsperLB_E[iside]=0; + m_hNumTrksDetPhi_E[iside] = 0; + m_hNumHoTDetPhi_E[iside] = 0; + m_hAvgTroTDetPhi_E[iside] = 0; + m_hNumSwLLWoT_E[iside] = 0; + m_hEvtPhaseDetPhi_E[iside] = 0; + m_hHitWMap_E[iside] = 0; + m_hHitWonTMap_E[iside] = 0; + m_hResidual_E[iside] = 0; + m_hTimeResidual_E[iside] = 0; + m_hDriftTimeonTrkDist_E[iside] = 0; + m_hTronTDist_E[iside] = 0; + m_hrtRelation_E[iside] = 0; + m_hHLhitOnTrack_E[iside] = 0; + m_hHtoLRatioOnTrack_E[iside] = 0; + m_hWireToTrkPosition_E[iside] = 0; + m_hResVsDetPhi_E[iside] = 0; + m_hNHitsperLB_E[iside] = 0; + m_hNTrksperLB_E[iside] = 0; + m_hNHLHitsperLB_E[iside] = 0; + m_hefficiencyEndCap_locR[iside] = 0; + m_hefficiencyEndCap_locR_Off[iside] = 0; + m_hefficiencyEndCap_locR_Off_Ar[iside] = 0; + m_hHitWMap_E_Ar[iside] = 0; + m_hResidual_E_Ar[iside] = 0; + m_hTimeResidual_E_Ar[iside] = 0; + m_hrtRelation_E_Ar[iside] = 0; + } +} + +//-------------------------------------------------------------------------// +TRT_Monitoring_Tool::~TRT_Monitoring_Tool() +//-------------------------------------------------------------------------// +{ +} + +//------------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::initialize() +//------------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Initializing TRT Monitoring"); + + StatusCode sc = ManagedMonitorToolBase::initialize(); + if (!sc.isSuccess()) return sc; + + sc = AlgTool::initialize(); + if (!sc.isSuccess()) + return StatusCode::FAILURE; + + IToolSvc* p_toolSvc; + sc = service("ToolSvc",p_toolSvc); + if (sc.isFailure()) { + ATH_MSG_FATAL("Tool Service not found"); + return StatusCode::FAILURE; + } + // Retrieve detector manager. + sc = detStore()->retrieve(mgr, "TRT"); + if (sc.isFailure()) { + ATH_MSG_ERROR("Unable to retrieve pointer to TRT DetectorManager"); + return sc; + } + + // Get ID helper for TRT to access various detector components like straw, straw_layer, layer_or_wheel, phi_module, etc... + sc = detStore()->retrieve(m_pTRTHelper,"TRT_ID"); + if (sc.isFailure()) { + ATH_MSG_ERROR("Unable to retrieve pointer to TRT Helper"); + return sc; + } + if (detStore()->retrieve(m_idHelper, "AtlasID").isFailure()) { + ATH_MSG_FATAL("Could not get AtlasDetectorID helper"); + return StatusCode::FAILURE; + } + + if (DoExpert) { + // Retrieve the TRT_Straw Status Service. + if (m_sumSvc.name().empty()) { + ATH_MSG_WARNING("TRT_StrawStatusSvc not given."); + } else { + sc = m_sumSvc.retrieve(); + if (sc.isFailure()) { + ATH_MSG_FATAL("I couldn't retrieve " << m_sumSvc); + return sc; + } + } + if (m_doDCS) { + // Retrieve the TRT_DCS Conditions Service. + if (m_DCSSvc.name().empty()) { + ATH_MSG_WARNING("TRT_DCSConditionsSvc not given."); + } else { + sc = m_DCSSvc.retrieve(); + if (sc.isFailure()) { + ATH_MSG_FATAL("I couldn't retrieve " << m_DCSSvc); + return sc; + } + } + }// if do dcs + + // Retrieve the TRT_Conditions Service. + if (m_condSvc_BS.name().empty()) { + ATH_MSG_WARNING("TRT_ConditionsSvc not given."); + } else { + sc = m_condSvc_BS.retrieve(); + if (sc.isFailure()) { + ATH_MSG_FATAL("I couldn't retrieve " << m_condSvc_BS ); + return sc; + } + } + // Retrieve the TRT TRTTrackHoleSearchTool. + if ( m_trt_hole_finder.retrieve().isFailure() ){ + ATH_MSG_FATAL( "Failed to retrieve the TRTTrackHoleSearchTool." ); + return StatusCode::FAILURE; + + } else { + msg(MSG::INFO) << "retrieved TRTTrackHoleSearchTool " << m_trt_hole_finder << endreq; + } + /** + if (m_condSvc_DAQ.name().empty()) { + ATH_MSG_WARNING("TRT_ConditionsSvc not given."); + } else { + sc = m_condSvc_DAQ.retrieve(); + if (sc.isFailure()) { + ATH_MSG_FATAL("I couldn't retrieve " << m_condSvc_DAQ ); + return sc; + } + } + */ + + // Retrieve the TRT_DAQConditions Service. + if (m_DAQSvc.name().empty()) { + ATH_MSG_WARNING("TRT_DAQConditionsSvc not given."); + } else { + sc = m_DAQSvc.retrieve(); + if (sc.isFailure()) { + ATH_MSG_FATAL("I couldn't retrieve " << m_DAQSvc); + return sc; + } + } + + // Retrieve the TRT_ByteStreamService. + if (m_BSSvc.name().empty()) { + ATH_MSG_WARNING("TRT_ByteStreamSvc not given."); + } else { + sc = m_BSSvc.retrieve(); + if (sc.isFailure()) { + ATH_MSG_FATAL("I couldn't retrieve " << m_BSSvc); + return sc; + } + } + // Test out the TRT_ConditionsSummaryTool. + //Identifier ident = m_trtid->straw_id(1,1,1,1,1); + Identifier ident; + if (m_sumSvc.name()!= "") { + ATH_MSG_VERBOSE("Trying " <<m_sumSvc << " isGood"); + ATH_MSG_VERBOSE("TRT_StrawStatusSvc reports status = " << m_sumSvc->getStatus(ident)); + } + }//If do expert + + //Retrieve TRT_StrawNeighbourService. + if (m_TRTStrawNeighbourSvc.name().empty()) { + ATH_MSG_WARNING("TRT_StrawNeighbourSvc not given."); + } else { + sc = m_TRTStrawNeighbourSvc.retrieve(); + if (sc.isFailure()) { + ATH_MSG_FATAL("Could not get StrawNeighbourSvc."); + } + } + // Get Track summary tool + sc= m_TrackSummaryTool.retrieve(); + if (sc.isFailure()) + ATH_MSG_ERROR("Cannot get TrackSummaryTool"); + else + ATH_MSG_DEBUG("Retrieved succesfully the track summary tool" << m_TrackSummaryTool); + //Get TRTCalDbTool + if (m_trtcaldbSvc.name().empty()) { + ATH_MSG_WARNING("TRT_CalDbSvc not given."); + } else { + if (m_trtcaldbSvc.retrieve().isFailure()) { + ATH_MSG_ERROR("Cannot get TRTCalDBSvc."); + //return StatusCode::FAILURE; + } + } + // retrieve TRTTrackHoleSearchTool + if (DoEfficiency) { + if (m_trt_hole_finder.retrieve().isFailure()) { + ATH_MSG_FATAL("Failed to retrieve the TRTTrackHoleSearchTool."); + return StatusCode::FAILURE; + } + } + + // Initialize arrays + // These arrays store information about each entry to the HitMap histograms + + // if (m_environment==AthenaMonManager::online) + if (true) { + //loop over straw hash index to create straw number mapping for TRTViewer + unsigned int maxHash = m_pTRTHelper->straw_layer_hash_max(); + + for (int ibe=0; ibe<2; ibe++) { // ibe=0(barrel), ibe=1(endcap) + + for (unsigned int index = 0; index < maxHash; index++) { + IdentifierHash idHash = index; + Identifier id = m_pTRTHelper->layer_id(idHash); + + int idBarrelEndcap = m_pTRTHelper->barrel_ec(id); + int idLayerWheel = m_pTRTHelper->layer_or_wheel(id); + int idPhiModule = m_pTRTHelper->phi_module(id); + int idStrawLayer = m_pTRTHelper->straw_layer(id); + + int idSide; int sectorflag=0; + const InDetDD::TRT_BaseElement * element= NULL; + if (ibe==0) { // barrel + idSide = idBarrelEndcap ? 1 : -1; + if ((m_pTRTHelper->is_barrel(id))&&(m_pTRTHelper->barrel_ec(id)==-1)) { + sectorflag=1; + element = mgr->getBarrelElement(idSide, idLayerWheel, idPhiModule, idStrawLayer); + } + } else if (ibe==1) { // endcap + idSide = idBarrelEndcap ? 1 : 0; + if ((!m_pTRTHelper->is_barrel(id)) + && ((m_pTRTHelper->barrel_ec(id)==-2) || (m_pTRTHelper->barrel_ec(id)==2))) { + sectorflag=1; + element = mgr->getEndcapElement(idSide, idLayerWheel, idStrawLayer, idPhiModule);//, idStrawLayer_ec); + } + } + + if (sectorflag==1) { + if (element ==NULL) continue; + + for (unsigned int istraw = 0; istraw < element->nStraws(); istraw++) { + if (istraw>element->nStraws()) continue; + + std::vector<Identifier> neighbourIDs; + Identifier strawID = m_pTRTHelper->straw_id(id, int(istraw)); + int i_chip, i_pad; + + m_TRTStrawNeighbourSvc->getChip(strawID,i_chip); + m_TRTStrawNeighbourSvc->getPad(id,i_pad); + + if (ibe==0) { //barrel + if (idLayerWheel == 1) i_chip += 21; + if (idLayerWheel == 2) i_chip += 54; + + int tempStrawNumber = strawNumber(istraw, idStrawLayer, idLayerWheel); + if (tempStrawNumber < 0 || tempStrawNumber > (s_Straw_max[ibe]-1)) { + ATH_MSG_WARNING("Found tempStrawNumber = " << tempStrawNumber << " out of range."); + } else { + mat_chip_B[idPhiModule][tempStrawNumber] = i_chip; + mat_chip_B[idPhiModule+32][tempStrawNumber] = i_chip; + } + + } else if (ibe==1) { //endcap + // i_chip -= 104; + ++i_chip -= 104; + + int tempStrawNumber = strawNumberEndCap(istraw, idStrawLayer, idLayerWheel, idPhiModule, idSide); + if (tempStrawNumber < 0 || tempStrawNumber > (s_Straw_max[ibe]-1)) { + ATH_MSG_WARNING("Found tempStrawNumber = " << tempStrawNumber << " out of range."); + } else { + mat_chip_E[idPhiModule][tempStrawNumber] = i_chip; + mat_chip_E[idPhiModule+32][tempStrawNumber] = i_chip; + } + } + + } + } + }//for (unsigned int index = 0; index < maxHash; index++) + } //for (int ibe=0; ibe<2; ibe++) + } + + if (DoShift) { // ugly way of doing this, so we probably want to clean it up a bit. + // Barrel + int ibe=0; + for (int iStack = 0; iStack < s_iStack_max[ibe]; iStack++) { + m_LLOcc[ibe][iStack] = 0; m_LLOcc[ibe][iStack+32]=0; + m_HTfraconTrack_B[iStack] = 0; + m_LonTrack_B[iStack] = 0; + m_nTrack_B[iStack] = 0; + } + for (int i=0; i<s_Straw_max[ibe]; i++) { + m_nStrawHits_B[i]=0; + } + // Endcap + ibe=1; + for (int iStack = 0; iStack < s_iStack_max[ibe]; iStack++) { + m_LLOcc[ibe][iStack] = 0; + m_HTfraconTrack_E[iStack] = 0; + m_LonTrack_E[iStack] = 0; + m_nTrack_E[iStack] = 0; + } + for (int i=0; i<s_Straw_max[ibe]; i++) { + m_nStrawHits_E[0][i]=0; // A-side + m_nStrawHits_E[1][i]=0; // C-side + } + } // doshift for phi bin init + + ATH_MSG_INFO("My TRT_DAQ_ConditionsSvc is " << m_DAQSvc); + return sc; +} + + +//------------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::bookHistogramsRecurrent() +//------------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Booking TRT histograms"); + + if (newLumiBlock) ATH_MSG_VERBOSE("newLumiBlock"); + if (newRun) ATH_MSG_VERBOSE("newRun"); + + StatusCode sc; + if (newRun) { + if (!evtStore()->contains<TRT_RDO_Container>(m_rawDataObjectName)) { + ATH_MSG_WARNING("No TRT_RDO_Container by the name of " << m_rawDataObjectName << " in StoreGate. Skipping TRT RDO Monitoring."); + m_doRDOsMon = false; + } + if (!evtStore()->contains<TrackCollection>(m_tracksObjectName)) { + ATH_MSG_WARNING("No TrackCollection by the name of " << m_tracksObjectName << " in StoreGate. Skipping TRT Track Monitoring."); + m_doTracksMon = false; + } + }// is new run? + + //Book_TRT_RDOs registers all raw data histograms + if (m_doRDOsMon) { + sc = Book_TRT_RDOs(newLumiBlock, newRun); + if (sc == StatusCode::FAILURE) { + ATH_MSG_ERROR("Unable to register RDO histograms"); + return sc; + }//if sc == failure + }// if do rdos mon + + //Book_TRT_Tracks registers all tracking histograms + if (m_doTracksMon) { + sc = Book_TRT_Tracks(newLumiBlock, newRun); + if (DoShift) { + sc = Book_TRT_Shift_Tracks(newLumiBlock, newRun); + if (sc == StatusCode::FAILURE) { + ATH_MSG_ERROR("Unable to book trt shift tracks histograms"); + }//if sc== failure + }//if DoShift + }//if do tracks mon + + if (DoEfficiency) { + sc = Book_TRT_Efficiency (newLumiBlock, newRun); + if (sc == StatusCode::FAILURE) { + ATH_MSG_ERROR("Unable to book trt efficiency"); + }//if sc== failure + } + if (newRun) { + ATH_MSG_DEBUG("Begin of run"); + } + + if (sc == StatusCode::FAILURE){ + ATH_MSG_ERROR("No histograms booked"); + } + return StatusCode::SUCCESS; +} + +//Book TRT Raw Data Object info (all TRT Hits). +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Book_TRT_RDOs(bool newLumiBlock, bool newRun) +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Booking TRT RDO Histograms"); + if (newLumiBlock) ATH_MSG_VERBOSE("newLumiBlock"); + if (newRun) ATH_MSG_VERBOSE("newRun"); + + StatusCode scode = StatusCode::SUCCESS; + std::string hName, hTitle; + + const std::string barrel_or_endcap[2] = { "Barrel", "EndCap" }; + const std::string be_id[2] = { "B", "E" }; + const std::string side_id[2] = { "A", "C" }; + + for (int ibe=0; ibe<2; ibe++) { + for (int i=0; i<s_numberOfStacks[ibe]*2; i++) { + std::ostringstream oss; + if (ibe == 0) { // barrel + if (i < s_numberOfStacks[ibe]) { oss << "TRT/Barrel/Stack" << i + 1 << "A"; } + else if (i >= s_numberOfStacks[ibe]) { oss << "TRT/Barrel/Stack" << i + 1 - 32 << "C"; } + } else if (ibe == 1) { // endcap + if (i < s_numberOfStacks[ibe]) { oss << "TRT/EndcapA/Sector" << i + 1; } + else if (i >= s_numberOfStacks[ibe]) { oss << "TRT/EndcapC/Sector" << i + 1 - 32; } + } + const std::string hPath = oss.str(); + + // MonGroup rdoStackWeighted(this, hPath, expert, run, "","weightedEff"); + MonGroup rdoStackWeighted(this, hPath, run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED, "","weightedEff"); + if (newRun) { + if (DoExpert) { + if (DoStraws) { + m_hHitWMapS[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitWMapS", "Leading Edge in Time Window: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability per Event", scode); + m_hHitTrWMapS[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitTrWMapS", "Mean Trailing Edge in Time Window: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hHitTrMapS[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitTrMapS", "Mean Trailing Edge: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hHitAWMapS[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitAWMapS", "LL in Time Window: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHitAMapS[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitAMapS", "Any LL Bit: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hStrawOcc[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hOccupancyS", "Straw Occupancy Distribution: Straws", 201, 0, 1.005, "Occupancy", "Number of Straws", scode); + m_hHitToTMapS[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitToTMapS", "Mean ToT: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hHitToTLongMapS[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitToTLongMapS", "Mean ToT for Straws with ToT > LongToTCut: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hHitToTLongTrMapS[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitToTLongTrMapS", "Mean Trailing Edge for Straws with ToT > LongToTCut: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hHitHMapS[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitHMapS", "Any HL Bit: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHitHWMapS[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitHWMapS", "HL in Time Window: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHtoLMapS[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHtoLMapS", "HL/LL Ratio: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + } + + if (DoChips) { + m_hHitWMapC[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitWMapC", "Leading Edge in Time Window: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHitTrMapC[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitTrMapC", "Mean Trailing Edge: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], 0, 75, "Chip Number in Stack", "Time (ns)", scode); + m_hHitTrWMapC[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitTrWMapC", "Mean Trailing Edge in Time Window: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], 0, 75, "Chip Number in Stack", "Time (ns)", scode); + m_hHitAWMapC[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitAWMapC", "LL in Time Window: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHitAMapC[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitAMapC", "Any LL Bit: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hChipOcc[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hOccupancyC", "Chip Occupancy Distribution", 201, 0, 1.005, "Occupancy", "Number of Chips", scode); + m_hHitToTMapC[ibe][i] = bookTProfile_LW(rdoStackWeighted, "hHitToTMapC", "Mean ToT: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], 0, 75, "Chip Number in Stack", "Time (ns)", scode); + m_hHitHMapC[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitHMapC", "Any HL Bit: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHitHWMapC[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHitHWMapC", "HL in Time Window: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHtoLMapC[ibe][i] = bookTH1F_LW(rdoStackWeighted, "hHtoLMapC", "HL/LL Ratio: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHtoBCMapC[ibe][i] = bookTH2F_LW(rdoStackWeighted, "hHtoBCMapC", "HL in BC: Chips", 3, 0, 3, s_iChip_max[ibe], 0, s_iChip_max[ibe], "Bunch Crossing ID", "Chip Number in Stack", scode); + + if (ibe == 0) { + m_hHtoBCMapB[ibe][i] = bookTH2F_LW(rdoStackWeighted, "hHtoBCMapB", "HL in BC: Boards", 3, 0, 3, 9, 0, 9, "Bunch Crossing ID", "Board Number in Stack", scode); + } else if (ibe == 1) { + m_hHtoBCMapB[ibe][i] = bookTH2F_LW(rdoStackWeighted, "hHtoBCMapB", "HL in BC: Boards", 3, 0, 3, 20, -0.5, 19.5, "Bunch Crossing ID", "Board Number in Stack", scode); + } + } + }//end if (DoExpert) + }//end if (newRun) + }//end loop over stacks + } //for (int ibe=0; ibe<2; ibe++) { + + //Registering Collisions Histograms + if (DoShift) { + //MonGroup rdoShiftSmry (this, "TRT/Shift/Summary", shift, run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + MonGroup rdoShiftSmry (this, "TRT/Shift/Summary", run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + //MonGroup rdoShiftSmryRebinned (this, "TRT/Shift/Summary", shift, run,"","mergeRebinned"); + MonGroup rdoShiftSmryRebinned (this, "TRT/Shift/Summary", run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED,"","mergeRebinned"); + + if (newRun) { + m_hSummary = bookTH1F_LW(rdoShiftSmry, "hSummary", "Run Summary", 8, 0, 8, "", "Entries", scode); + m_hSummary->GetXaxis()->SetBinLabel(1,"Events"); + m_hSummary->GetXaxis()->SetBinLabel(2,"Tracks Total"); + m_hSummary->GetXaxis()->SetBinLabel(3,"Tracks BA"); + m_hSummary->GetXaxis()->SetBinLabel(4,"Tracks BC"); + m_hSummary->GetXaxis()->SetBinLabel(5,"Tracks EA"); + m_hSummary->GetXaxis()->SetBinLabel(6,"Tracks EC"); + m_hSummary->GetXaxis()->SetBinLabel(7,"Transition Side A"); + m_hSummary->GetXaxis()->SetBinLabel(8,"Transition Side C"); + + const unsigned int maxLumiBlock = 200; + + for (int ibe=0; ibe<2; ibe++) { // ibe=0(barrel), ibe=1(endcap) + for (int iside=0; iside<2; iside++) { // iside=0(A-side), iside=1(C-side) + const std::string regionTag = " (" + be_id[ibe] + side_id[iside] + ")"; + m_hChipBSErrorsVsLB[ibe][iside] = bookTProfile(rdoShiftSmryRebinned, "hChipBSErrorsVsLB_" + be_id[ibe] + side_id[iside], "Chip Bytestream Errors vs LB" + regionTag, maxLumiBlock + 1, -0.5, maxLumiBlock + 0.5, 0, 150.0, "Luminosity Block", "Fraction of Chips with Errors", scode); + m_hChipBSErrorsVsLB[ibe][iside]->SetBit(TH1::kCanRebin); + m_hRobBSErrorsVsLB[ibe][iside] = bookTProfile(rdoShiftSmryRebinned, "hRobBSErrorsVsLB_" + be_id[ibe] + side_id[iside], "Rob Bytestream Errors vs LB" + regionTag, maxLumiBlock + 1, -0.5, maxLumiBlock + 0.5, 0, 150.0, "Luminosity Block", "Fraction of RODs with Errors", scode); + m_hRobBSErrorsVsLB[ibe][iside]->SetBit(TH1::kCanRebin); + } + } + + // Barrel/Endcap Histograms + const std::string module_or_wheel[2] = { "Module", "Wheel" }; + const std::string stack_or_sector[2] = { "Barrel Stack", "Endcap Sector" }; + const std::string modulenum_assign2[2] = { "Modules Type 1 (1-32), Type 2 (33-64), Type 3 (65-96)", "Wheels A (1-32), B (33-64)" }; + + for (int ibe=0; ibe<2; ibe++) { + const std::string regionTag = " (" + barrel_or_endcap[ibe] + ")"; + // MonGroup rdo(this, "TRT/"+barrel_or_endcap[ibe]+"/Expert", expert, run); + // MonGroup rdoShift (this, "TRT/Shift/"+barrel_or_endcap[ibe], shift, run); + // MonGroup rdoShiftTH1(this, "TRT/Shift/"+barrel_or_endcap[ibe],shift,run,"","weightedEff"); + MonGroup rdo(this, "TRT/"+barrel_or_endcap[ibe]+"/Expert", run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + MonGroup rdoShift (this, "TRT/Shift/"+barrel_or_endcap[ibe], run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + MonGroup rdoShiftTH1(this, "TRT/Shift/"+barrel_or_endcap[ibe], run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED,"","weightedEff"); + + if (ibe == 0) { + m_hHitWMap_B = bookTH1F_LW(rdoShiftTH1, "hHitWMap", "Leading Edge in Time Window: Straws" " (Barrel)", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + + if (m_ArgonXenonSplitter) { + m_hHitWMap_B_Ar = bookTH1F_LW(rdoShiftTH1, "hHitWMap_Ar", "Leading Edge in Time Window: Argon Straws (Barrel)", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + } + + m_hOccAll = bookTH1F_LW(rdoShift, "hOccAll", "Occupancy per Event", 400, 0.0, 1.0, "Occupancy", "Events", scode); + } else if (ibe == 1) { + m_hHitWMap_E[0] = bookTH1F_LW(rdoShiftTH1, "hHitWMap_A", "Leading Edge in Time Window: Straws" " (EA)", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHitWMap_E[1] = bookTH1F_LW(rdoShiftTH1, "hHitWMap_C", "Leading Edge in Time Window: Straws" " (EC)", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + + if (m_ArgonXenonSplitter) { + m_hHitWMap_E_Ar[0] = bookTH1F_LW(rdoShiftTH1, "hHitWMap_Ar_A", "Leading Edge in Time Window: Argon Straws" " (EA)", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHitWMap_E_Ar[1] = bookTH1F_LW(rdoShiftTH1, "hHitWMap_Ar_C", "Leading Edge in Time Window: Argon Straws" " (EC)", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + } + } + + m_hBCIDvsOcc[ibe] = bookTProfile_LW(rdo, "hBCIDvsOcc", "Avg. Occupancy vs BCID" + regionTag, 3565, 0, 3564, 0, 1, "Bunch Crossing ID", "Occupancy", scode); + + for (int iside = 0; iside < 2; iside++) { + const std::string regionTag = " (" + be_id[ibe] + side_id[iside] + ")"; // hides variable in outer scope + const std::string regionMarker = (m_environment == AthenaMonManager::online) ? (be_id[ibe] + side_id[iside]) : (side_id[iside]); // for historical reasons ... + + m_hAvgHLOcc_side[ibe][iside] = bookTProfile_LW(rdoShift, "hAvgHLOcc_" + regionMarker, "Avg. HL Occupancy" + regionTag, 32, 1, 33, 0, 1, stack_or_sector[ibe], "Occupancy", scode); + m_hAvgLLOcc_side[ibe][iside] = bookTProfile_LW(rdoShift, "hAvgLLOcc_" + regionMarker, "Avg. LL Occupancy" + regionTag, 32, 1, 33, 0, 1, stack_or_sector[ibe], "Occupancy", scode); + m_hAvgLLOccMod_side[ibe][iside] = bookTProfile_LW(rdo, "hAvgLLOccMod_" + regionMarker, "Avg. LL Occupancy: " + module_or_wheel[ibe] + "s" + regionTag, s_moduleNum[ibe], 0, s_moduleNum[ibe], 0, 1, modulenum_assign2[ibe], "Occupancy", scode); + m_hAvgHLOccMod_side[ibe][iside] = bookTProfile_LW(rdo, "hAvgHLOccMod_" + regionMarker, "Avg. HL Occupancy: " + module_or_wheel[ibe] + "s" + regionTag, s_moduleNum[ibe], 0, s_moduleNum[ibe], 0, 1, modulenum_assign2[ibe], "Occupancy", scode); + } + }//for (int ibe=0; ibe<2; ibe++) + + }//if is new run + }//if DoShift + + ATH_MSG_VERBOSE("Finished Booking TRT RDO Histograms"); + + return scode;//StatusCode::SUCCESS; +}//Book_TRT_RDOs() + + +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Book_TRT_Tracks(bool newLumiBlock, bool newRun) +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Booking TRT Track Histograms"); + if (newLumiBlock) ATH_MSG_VERBOSE("newLumiBlock"); + if (newRun) ATH_MSG_VERBOSE("newRun"); + + StatusCode scode = StatusCode::SUCCESS; + std::string hName, hTitle; + const std::string barrel_or_endcap[2] = { "Barrel", "EndCap" }; + + for (int ibe=0; ibe<2; ibe++) { + std::ostringstream oss_distance; + oss_distance << std::setprecision(3) << std::fixed << m_DistToStraw; + const std::string distance = oss_distance.str(); + const std::string hPathGen = "TRT/"+barrel_or_endcap[ibe]+"/Expert"; + const std::string regionTag = " (" + barrel_or_endcap[ibe] + ")"; + + for (int i=0; i<s_numberOfStacks[ibe]*2; i++) { + std::ostringstream oss; + if (ibe == 0) { + if (i < s_numberOfStacks[ibe]) { oss << "TRT/Barrel/Stack" << i + 1 << "A"; } + else if (i >= s_numberOfStacks[ibe]) { oss << "TRT/Barrel/Stack" << i + 1 - 32 << "C"; } + } else if (ibe == 1) { + if (i < s_numberOfStacks[ibe]) { oss << "TRT/EndcapA/Sector" << i + 1; } + else if (i >= s_numberOfStacks[ibe]) { oss << "TRT/EndcapC/Sector" << i + 1 - 32; } + } + const std::string hPath = oss.str(); + + //MonGroup trackStackWeighted(this, hPath, expert, run, "", "weightedEff"); + MonGroup trackStackWeighted(this, hPath, run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED,"", "weightedEff"); + if (DoExpert) { + if (newRun) { + if (DoStraws) { + m_hHitWonTMapS[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitWonTMapS", "Leading Edge on Track in Time Window: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHitTronTMapS[ibe][i] = bookTProfile_LW(trackStackWeighted, "hHitTronTMapS", "Mean Trailing Edge on Track: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75.0, "Straw Number in Stack", "Time (ns)", scode); + + m_hHitAonTMapS[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitAonTMapS", "Any LL Bit on Track: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hStrawsEff[ibe][i] = bookTProfile_LW(trackStackWeighted, "hEfficiencyS", "Straw Efficiency with " + distance + " mm Cut", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0.0, 1.0, "Straw Number in Stack", "Efficiency", scode); + + m_hHitAWonTMapS[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitAWonTMapS", "Any LL Bit on Track in Time Window: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHitHonTMapS[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitHonTMapS", "HL Hit on Track: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + + m_hHitToTonTMapS[ibe][i] = bookTProfile_LW(trackStackWeighted, "hHitToTonTMapS", "Mean ToT on Track: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hValidRawDriftTimeonTrk[ibe][i] = bookTProfile_LW(trackStackWeighted, "hValidRawDriftTimeonTrkS", "Valid Raw Drift Time on Track: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], 0, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hHtoLonTMapS[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHtoLonTMapS", "HL/LL Ratio on Track: Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Probability", scode); + m_hHitTronTwEPCMapS[ibe][i] = bookTProfile_LW(trackStackWeighted, "hHitTronTwEPCMapS", "Mean Trailing Edge on Track (with Event Phase Correction): Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], -50, 75, "Straw Number in Stack", "Time (ns)", scode); + m_hHitOnTrackVsAllS[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitonTrackVAllS", "(Hit on Track) / (Any LL Bit): Straws", s_Straw_max[ibe], 0, s_Straw_max[ibe], "Straw Number in Stack", "Ratio", scode); + }//if DoStraws + + if (DoChips) { + m_hHitWonTMapC[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitWonTMapC", "Leading Edge on Track in Time Window: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHitTronTMapC[ibe][i] = bookTProfile_LW(trackStackWeighted, "hHitTronTMapC", "Mean Trailing Edge on Track: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], 0, 75, "Chip Number in Stack", "Time (ns)", scode); + + m_hHitAonTMapC[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitAonTMapC", "Any LL Bit on Track: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hChipsEff[ibe][i] = bookTProfile_LW(trackStackWeighted, "hEfficiencyC", "Chip Efficiency with " + distance + " mm Cut", s_iChip_max[ibe], 0, s_iChip_max[ibe], 0.0, 1.0, "Chip Number in Stack", "Efficiency", scode); + + m_hHitAWonTMapC[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitAWonTMapC", "Any LL Bit on Track in Time Window: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHitHonTMapC[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitHonTMapC", "HL Hit on Track: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHitToTonTMapC[ibe][i] = bookTProfile_LW(trackStackWeighted, "hHitToTonTMapC", "Mean ToT on Track: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], 0, 75, "Chip Number in Stack", "Time (ns)", scode); + m_hValidRawDriftTimeonTrkC[ibe][i] = bookTProfile_LW(trackStackWeighted, "hValidRawDriftTimeonTrkC", "Valid Raw Drift Time on Track: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], 0, 75, "Chip Number in Stack", "Time (ns)", scode); + m_hHtoLonTMapC[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHtoLonTMapC", "HL/LL Ratio on Track: Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Probability", scode); + m_hHitTronTwEPCMapC[ibe][i] = bookTProfile_LW(trackStackWeighted, "hHitTronTwEPCMapC", "Mean Trailing Edge on Track (with Event Phase Correction): Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], -50, 75, "Chip Number in Stack", "Time (ns)", scode); + m_hHitOnTrackVsAllC[ibe][i] = bookTH1F_LW(trackStackWeighted, "hHitonTrackVAllC", "(Hit on Track) / (Any LL Bit): Chips", s_iChip_max[ibe], 0, s_iChip_max[ibe], "Chip Number in Stack", "Ratio", scode); + }//DoChips + }// if (newRun) + }//DoExpert + }// for (int i=0; i<s_numberOfStacks[ibe]*2; i++) + }// for (int ibe=0; ibe<2; ibe++) + + ATH_MSG_VERBOSE("Booked TRT Track Histograms successfully"); + return scode; + +}//Book_TRT_Tracks() + + +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Book_TRT_Efficiency(bool newLumiBlock, bool newRun) +//----------------------------------------------------------------------------------// +{ + StatusCode scode = StatusCode::SUCCESS; + if (newLumiBlock) {} + if (newRun) { + std::string hName, hTitle; + + const std::string barrel_or_endcap[2] = { "Barrel", "EndCap" }; + const std::string be_id[2] = { "B", "E" }; + const std::string side_id[2] = { "A", "C" }; + + //MonGroup trackShiftEff(this, "TRT/Efficiency", expert, run); + MonGroup trackShiftEff(this, "TRT/Efficiency", run,ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + m_hefficiency_eta = bookTProfile_LW(trackShiftEff, "hEfficiency_eta", "Efficiency vs #eta", 50, -2.8, 2.8, 0, 1, "#eta", "Efficiency", scode); + m_hefficiency_phi = bookTProfile_LW(trackShiftEff, "hEfficiency_phi", "Efficiency vs #phi", 50, -3.2, 3.2, 0, 1, "#phi (deg)", "Efficiency", scode); + m_hefficiency_pt = bookTProfile_LW(trackShiftEff, "hEfficiency_pt", "Efficiency vs pT", 50, 0, 10, 0, 1, "pT (GeV)", "Efficiency", scode); + m_hefficiency_z0 = bookTProfile_LW(trackShiftEff, "hEfficiency_z0", "Efficiency vs z0", 50, -200, 200, 0, 1, "z0", "Efficiency", scode); + m_hefficiencyBarrel_locR = bookTProfile_LW(trackShiftEff, "hEfficiencyBarrel_locR", "Efficiency vs Track-to-Wire Distance" " (Barrel)", 50, -2.5, 2.5, 0, 1, "Track-to-Wire Distance (mm)", "Efficiency", scode); + + m_hefficiencyMap[0] = bookTProfile_LW(trackShiftEff, "hEfficiencyBarrelMap", "Straw Efficiency Map" " (Barrel)", s_Straw_max[0], 0, s_Straw_max[0], 0, 1, "Straw Number", "Efficiency", scode); + m_hefficiencyMap[1] = bookTProfile_LW(trackShiftEff, "hEfficiencyEndCapMap", "Straw Efficiency Map" " (Endcap)", s_Straw_max[1], 0, s_Straw_max[1], 0, 1, "Straw Number", "Efficiency", scode); + + for (int iside=0; iside<2; iside++) { + const std::string regionTag = " (" + be_id[1] + side_id[iside] + ")"; + m_hefficiencyEndCap_locR[iside] = bookTProfile_LW(trackShiftEff, "hEfficiencyEndCap"+side_id[iside]+"_locR", "Efficiency vs Track-to-Wire Distance" + regionTag, 50, -2.5, 2.5, 0, 1, "Track-to-Wire Distance (mm)", "Efficiency", scode); + } + + for (int ibe=0; ibe<2; ibe++) { + for (int iside=0; iside<2; iside++) { + const std::string regionTag = " (" + be_id[ibe] + side_id[iside] + ")"; + //MonGroup trackShiftEffWeighted(this, "TRT/Efficiency", expert, run, "", "weightedEff"); + MonGroup trackShiftEffWeighted(this, "TRT/Efficiency", run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED,"", "weightedEff"); + m_hefficiency[ibe][iside] = bookTH1F_LW(trackShiftEffWeighted, "hEfficiency"+barrel_or_endcap[ibe]+side_id[iside], "Straw Efficiency" + regionTag, 500, -0.01, 1.01, "Efficiency", "Number of Straws", scode); + m_hefficiencyIntegral[ibe][iside] = bookTH1F_LW(trackShiftEffWeighted, "hEfficiencyIntegral"+barrel_or_endcap[ibe]+side_id[iside], "Straw Efficiency Integral" + regionTag, 500, -0.01, 1.01, "Efficiency", "Fraction of Straws", scode); + + if (DoExpert) { + int imintmp=s_numberOfBarrelStacks*iside; + int imaxtmp=s_numberOfBarrelStacks*(iside+1); + for (int i=imintmp; i<imaxtmp; i++) { + std::ostringstream oss; + if (ibe == 0) oss << "TRT/Barrel/Stack" << (i + 1 - 32 * iside) << side_id[iside]; + else if (ibe == 1) oss << "TRT/Endcap" << side_id[iside] << "/Sector" << (i + 1 - 32 * iside); + const std::string hPath = oss.str(); + + //MonGroup trackStack(this, hPath, expert, run); + MonGroup trackStack(this, hPath, run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + m_hefficiencyS[ibe][i] = bookTProfile_LW(trackStack, "hHitEfficiencyS", "Straw Efficiency Map", s_Straw_max[ibe], 0.5, s_Straw_max[ibe] + 0.5, 0, 1, "Straw Number", "Efficiency", scode); + m_hefficiencyC[ibe][i] = bookTProfile_LW(trackStack, "hHitEfficiencyC", "Chip Efficiency Map", s_iChip_max[ibe], 0.5, s_iChip_max[ibe] + 0.5, 0, 1, "Chip Number", "Efficiency", scode); + } + } //DoExpert + } //for (int iside=0; iside<2; iside++) + } //for (int ibe=0; ibe<2; ibe++) + } + return scode; +} //book_trt_efficiency + +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Book_TRT_Shift_Tracks(bool newLumiBlock, bool newRun) +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Booking TRT Track Histograms"); + + if (newLumiBlock) ATH_MSG_VERBOSE("newLumiBlock"); + if (newRun) ATH_MSG_VERBOSE("newRun"); + + std::string hName, hTitle; + + std::ostringstream oss_distance; + oss_distance << std::setprecision(3) << std::fixed << m_DistToStraw; + const std::string distance = oss_distance.str(); + StatusCode scode = StatusCode::SUCCESS; + //create several histogram directories. + // MonGroup trackBarrelShiftTProf(this, "TRT/Shift/Barrel",shift,run); + // MonGroup trackBarrelDiag(this, "TRT/Barrel/Diagnostics", debug, run); + MonGroup trackBarrelShiftTProf( this, "TRT/Shift/Barrel", run,ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + MonGroup trackBarrelDiag( this, "TRT/Barrel/Diagnostics", run,ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + const std::string barrel_or_endcap[2] = { "Barrel", "EndCap" }; + const std::string be_id[2] = { "B", "E" }; + const std::string side_id[2] = { "A", "C" }; + const int maxLumiblock = 720; + + for (int ibe=0; ibe<2; ibe++) { + const std::string regionTag = " (" + barrel_or_endcap[ibe] + ")"; + // MonGroup trackShift(this, "TRT/Shift/"+barrel_or_endcap[ibe], shift, run); + // MonGroup trackShiftRebinned(this, "TRT/Shift/"+barrel_or_endcap[ibe], shift, run,"","mergeRebinned"); + // MonGroup trackShiftTH1(this, "TRT/Shift/"+barrel_or_endcap[ibe], shift, run,"","weightedEff"); + MonGroup trackShift(this, "TRT/Shift/"+barrel_or_endcap[ibe], run); + MonGroup trackShiftRebinned(this, "TRT/Shift/"+barrel_or_endcap[ibe], run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED,"","mergeRebinned"); + MonGroup trackShiftTH1(this, "TRT/Shift/"+barrel_or_endcap[ibe], run, ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED,"","weightedEff"); + + if (newRun && DoShift) { + if (ibe==0) { + m_hEvtPhase = bookTH1F_LW(trackShift, "hEvtPhase", "Event Phase Correction Factor", 30, -50, 100, "Event Phase (ns)", "Entries", scode); + m_hEvtPhaseVsTrig = bookTH2F_LW(trackShift, "hEvtPhaseVsTrig", "Event Phase vs L1 Trigger Item", 300, -200, 100, 256, -0.5, 255.5,"Event Phase (ns)","L1 Trigger Item", scode); + + m_hEvtPhaseDetPhi_B = bookTProfile_LW(trackShift, "hEvtPhaseDetPhi", "Event Phase vs #phi (2D)" + regionTag, m_nphi_bins, 0, 360, -50, 100., "#phi (deg)", "Event Phase from Tracks per Event", scode); + m_hrtRelation_B = bookTH2F_LW(trackShift, "hrtRelation", "R(t) Relation" + regionTag, 30, -12.5, 81.25, 50, 0, 2.5, "Measured Leading Edge (ns)", "Track-to-Wire Distance (mm)", scode); + m_hNumHoTDetPhi_B = bookTProfile_LW(trackShift, "hNumHoTDetPhi", "Number of Hits per Track with " + distance + " mm Cut vs #phi" + regionTag, m_nphi_bins, 0., 360, 0, 150, "#phi (deg)", Form("Hits per Track, TRT Hits >= %d", m_minTRThits), scode); + m_hTronTDist_B = bookTH1F_LW(trackShiftTH1, "hTronTDist", "Trailing Edge Distribution on Track" + regionTag, 26, -0.5, 80.75, "Trailing Edge (ns)", "Norm. Entries", scode); + m_hDriftTimeonTrkDist_B = bookTH1F_LW(trackShiftTH1, "hDriftTimeonTrkDist", "Drift Time Distribution on Track" + regionTag, 32, 0, 100., "Drift Time (ns)", "Norm. Entries", scode); + m_hNumTrksDetPhi_B = bookTH1F_LW(trackShift, "hNumTrksDetPhi", "Number of Reconstructed Tracks vs #phi (2D)" + regionTag, 60, 0, 360, "#phi (deg)", "Number of Tracks", scode); + + if (m_ArgonXenonSplitter) { + m_hrtRelation_B_Ar = bookTH2F_LW(trackShift, "hrtRelation_Ar", "R(t) Relation for Argon Straws" + regionTag, 30, -12.5, 81.25, 50, 0, 2.5, "Measured Leading Edge (ns)", "Track-to-Wire Distance (mm)", scode); + m_hResidual_B_Ar = bookTH1F_LW(trackShiftTH1, "hResidual_Ar", "Residuals for Argon Straws" + regionTag, 100, -2.5, 2.5, "Hit-to-Track Distance (mm)", "Norm. Entries", scode); + m_hTimeResidual_B_Ar = bookTH1F_LW(trackShiftTH1, "hTimeResidual_Ar", "Time Residuals for Argon Straws" + regionTag, 200, -20, 20, "Time Residual (ns)", "Norm. Entries", scode); + } + + m_hResidual_B = bookTH1F_LW(trackShiftTH1, "hResidual", "Residuals for All Straws" + regionTag, 100, -2.5, 2.5, "Hit-to-Track Distance (mm)", "Norm. Entries", scode); + m_hTimeResidual_B = bookTH1F_LW(trackShiftTH1, "hTimeResidual", "Time Residuals for All Straws" + regionTag, 200, -20, 20, "Time Residual (ns)", "Norm. Entries", scode); + m_hWireToTrkPosition_B = bookTH1F_LW(trackShiftTH1, "hWireToTrkPosition", "Track-to-Wire Distance" + regionTag, 100, -5., 5, "Track-to-Wire Distance (mm)", "Norm. Entries", scode); + m_hNumSwLLWoT_B = bookTH1F_LW(trackShiftTH1, "hNumSwLLWoT", "Number of Straws with Hits on Track in Time Window" + regionTag, 150, 0, 150, "Number of LL Hits per Track", "Norm. Entries", scode); + m_hAvgTroTDetPhi_B = bookTProfile_LW(trackShift, "hAvgTroTDetPhi", "Avg. Trailing Edge on Track vs #phi (2D)" + regionTag, m_nphi_bins, 0, 360, 0, 75., "#phi (deg)", "Trailing Edge (ns)", scode); + + m_hNTrksperLB_B = bookTProfile(trackShiftRebinned, "hNTrksperLB", "Avg. Number of Reconstructed Tracks per Event" + regionTag, maxLumiblock, -0.5, maxLumiblock - 0.5, 0, 150.0, "Luminosity Block", "Number of Tracks", scode); + m_hNTrksperLB_B->SetBit(TH1::kCanRebin); + m_hNHitsperLB_B = bookTProfile(trackShiftRebinned, "hNHitsperLB", "Avg. Occupancy" + regionTag, maxLumiblock, -0.5, maxLumiblock - 0.5, 0, 150.0, "Luminosity Block", "Occupancy", scode); + m_hNHitsperLB_B->SetBit(TH1::kCanRebin); + m_hNHLHitsperLB_B = bookTProfile(trackShiftRebinned, "hNHLHitsperLB", "Avg. HL Occupancy" + regionTag, maxLumiblock, -0.5, maxLumiblock - 0.5, 0, 150.0, "Luminosity Block", "Occupancy", scode); + m_hNHLHitsperLB_B->SetBit(TH1::kCanRebin); + + + m_hHLhitOnTrack_B = bookTH1F_LW(trackShiftTH1, "hHLhitOnTrack", "Number of HL Hits per Reconstructed Track" + regionTag, 50, 0, 50, "Number of HL Hits per Track", "Norm. Entries", scode); + m_hHtoLRatioOnTrack_B = bookTH1F_LW(trackShiftTH1, "hHtoLRatioOnTrack", "HL/LL Ratio per Reconstructed Track" + regionTag, 50, 0, 1, "HL/LL Ratio", "Norm. Entries", scode); + m_hHitWonTMap_B = bookTH1F_LW(trackShiftTH1, "hHitWonTMap", "Leading Edge in Time Window per Reconstructed Track" + regionTag, 1642, 0, 1642, "Straw Number", "Norm. Entries", scode); + + } else if (ibe==1) { + for (int iside=0; iside<2; iside++) { + const std::string regionTag = " (" + be_id[ibe] + side_id[iside] + ")"; // hides variable in outer scope + m_hEvtPhaseDetPhi_E[iside] = bookTProfile_LW(trackShift, "hEvtPhaseDetPhi_"+side_id[iside], "Event Phase vs #phi (2D)" + regionTag, m_nphi_bins, 0, 360, -50, 100, "#phi (deg)", "Event Phase from Tracks per Event", scode); + m_hrtRelation_E[iside] = bookTH2F_LW(trackShift, "hrtRelation_"+side_id[iside], "R(t) Relation" + regionTag, 30, -12.5, 81.25, 50, 0, 2.5, "Measured Leading Edge (ns)", "Track-to-Wire Distance (mm)", scode); + m_hNumHoTDetPhi_E[iside] = bookTProfile_LW(trackShift, "hNumHoTDetPhi_"+side_id[iside], "Number of Hits per Track with " + distance + " mm Cut vs #phi" + regionTag, m_nphi_bins,0.,360,0,150, "#phi (deg)", Form("Hits per Track, TRT Hits> = %d", m_minTRThits),scode); + m_hTronTDist_E[iside] = bookTH1F_LW(trackShiftTH1, "hTronTDist_"+side_id[iside], "Trailing Edge Distribution on Track" + regionTag, 26, -0.5, 80.75, "Trailing Edge (ns)", "Norm. Entries", scode); + m_hDriftTimeonTrkDist_E[iside] = bookTH1F_LW(trackShiftTH1, "hDriftTimeonTrkDist_"+side_id[iside], "Drift Time Distribution on Track" + regionTag, 32, 0, 100, "Drift Time (ns)", "Norm. Entries", scode); + m_hNumTrksDetPhi_E[iside] = bookTH1F_LW(trackShift, "hNumTrksDetPhi_"+side_id[iside], "Number of Reconstructed Tracks vs #phi (2D)" + regionTag, 60, 0, 360, "#phi (deg)", "Number of Tracks", scode); + m_hResidual_E[iside] = bookTH1F_LW(trackShiftTH1, "hResidual_"+side_id[iside], "Residuals for All Straws" + regionTag, 100, -2.5, 2.5, "Hit-to-Track Distance (mm)", "Norm. Entries", scode); + m_hTimeResidual_E[iside] = bookTH1F_LW(trackShiftTH1, "hTimeResidual_"+side_id[iside], "Time Residuals for All Straws" + regionTag, 200, -20, 20, "Time Residual (ns)", "Norm. Entries", scode); + + if (m_ArgonXenonSplitter) { + m_hrtRelation_E_Ar[iside] = bookTH2F_LW(trackShift, "hrtRelation_Ar_" + side_id[iside], "R(t) Relation for Argon Straws" + regionTag, 30, -12.5, 81.25, 50, 0, 2.5, "Measured Leading Edge (ns)", "Track-to-Wire Distance (mm)", scode); + m_hResidual_E_Ar[iside] = bookTH1F_LW(trackShiftTH1, "hResidual_Ar_" + side_id[iside], "Residuals for Argon Straws" + regionTag, 100, -2.5, 2.5, "Hit-to-Track Distance (mm)", "Norm. Entries", scode); + m_hTimeResidual_E_Ar[iside] = bookTH1F_LW(trackShiftTH1, "hTimeResidual_Ar_" + side_id[iside], "Time Residuals for Argon Straws" + regionTag, 200, -20, 20, "Time Residual (ns)", "Norm. Entries", scode); + } + + m_hWireToTrkPosition_E[iside] = bookTH1F_LW(trackShiftTH1, "hWireToTrkPosition_"+side_id[iside], "Track-to-Wire Distance" + regionTag, 100, -5., 5, "Track-to-Wire Distance (mm)", "Norm. Entries", scode); + m_hNumSwLLWoT_E[iside] = bookTH1F_LW(trackShiftTH1, "hNumSwLLWoT_"+side_id[iside], "Number of Straws with Hits on Track in Time Window" + regionTag, 150, 0, 150, "Number of LL Hits per Track", "Norm. Entries", scode); + m_hAvgTroTDetPhi_E[iside] = bookTProfile_LW(trackShift, "hAvgTroTDetPhi_"+side_id[iside], "Avg. Trailing Edge on Track vs #phi (2D)" + regionTag, m_nphi_bins, 0, 360, 0, 75., "#phi (deg)", "Trailing Edge (ns)", scode); + + m_hNTrksperLB_E[iside] = bookTProfile(trackShiftRebinned, "hNTrksperLB_"+side_id[iside], "Avg. Number of Reconstructed Tracks per Event" + regionTag, maxLumiblock, -0.5, maxLumiblock - 0.5, 0, 150.0, "Luminosity Block", "Number of Tracks", scode); + m_hNTrksperLB_E[iside]->SetBit(TH1::kCanRebin); + m_hNHitsperLB_E[iside] = bookTProfile(trackShiftRebinned, "hNHitsperLB_"+side_id[iside], "Avg. Occupancy" + regionTag, maxLumiblock, -0.5, maxLumiblock - 0.5, 0, 150.0, "Luminosity Block", "Occupancy", scode); + m_hNHitsperLB_E[iside]->SetBit(TH1::kCanRebin); + m_hNHLHitsperLB_E[iside] = bookTProfile(trackShiftRebinned, "hNHLHitsperLB_"+side_id[iside], "Avg. HL Occupancy" + regionTag, maxLumiblock, -0.5, maxLumiblock - 0.5, 0, 150.0, "Luminosity Block", "Occupancy", scode); + m_hNHLHitsperLB_E[iside]->SetBit(TH1::kCanRebin); + + m_hHLhitOnTrack_E[iside] = bookTH1F_LW(trackShiftTH1, "hHLhitOnTrack_"+side_id[iside], "Number of HL Hits per Reconstructed Track" + regionTag, 50, 0, 50, "Number of HL Hits per Track", "Norm. Entries", scode); + m_hHtoLRatioOnTrack_E[iside] = bookTH1F_LW(trackShiftTH1, "hHtoLRatioOnTrack_"+side_id[iside], "HL/LL Ratio per Reconstructed Track" + regionTag, 50, 0, 1.0, "HL/LL Ratio", "Norm. Entries", scode); + m_hHitWonTMap_E[iside] = bookTH1F_LW(trackShiftTH1, "hHitWonTMap_"+side_id[iside], "Leading Edge in Time Window per Reconstructed Track" + regionTag, 3840, 0, 3840, "Straw Number", "Norm. Entries", scode); + } //for (int iside=0; iside<2; iside++) + } //else if (ibe==1) + + if (DoShift) { + m_hHitsOnTrack_Scatter[ibe] = bookTH2F_LW(trackShift, "m_hHitsOnTrack_Scatter", "Hits per Track in Time Window in Stacks" + regionTag, 720, -0.5, 720 - 0.5, 80, 0, 80, "Luminosity Block (mod 720)", "Number of Hits per Track in Stacks", scode); + m_hLLOcc_Scatter[ibe] = bookTH2F_LW(trackShift, "m_hLLOcc_Scatter", "LL Occupancy in Stacks" + regionTag, 720, -0.5, 720 - 0.5, 400, 0.0, 1.0, "Luminosity Block (mod 720)", "LL Occupancy in Stacks", scode); + m_hHightoLowRatioOnTrack_Scatter[ibe] = bookTH2F_LW(trackShift, "m_hHightoLowRatioOnTrack_Scatter", "HL/LL Ratio on Track in Stacks" + regionTag, 720, -0.5, 720 - 0.5, 40, 0.0, 0.5, "Luminosity Block (mod 720)", "HL/LL Ratio in Stacks", scode); + } + + //Here begins the booking of offline efficiency histograms. + // MonGroup trackEffBarrel(this, "TRT/Shift/Barrel",shift,run); + // MonGroup trackEffEndCap(this, "TRT/Shift/EndCap",shift,run); + MonGroup trackEffBarrel(this, "TRT/Shift/Barrel",run,ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + MonGroup trackEffEndCap(this, "TRT/Shift/EndCap",run,ManagedMonitorToolBase::MgmtAttr_t::ATTRIB_UNMANAGED); + m_hefficiencyBarrel_locR_Off = bookTProfile_LW(trackEffBarrel, "hEfficiencyBarrel_locR_Off", "Efficiency vs Track-to-Wire Distance" " (Barrel)", 50, -2.5, 2.5, 0, 1, "Track-to-Wire Distance (mm)", "Efficiency", scode); + m_hefficiencyBarrel_locR_Off_Ar = bookTProfile_LW(trackEffBarrel, "hEfficiencyBarrel_locR_Off_Ar", "Efficiency vs Track-to-Wire Distance Argon Straws" " (Barrel)", 50, -2.5, 2.5, 0, 1, "Track-to-Wire Distance (mm)", "Efficiency", scode); + + for (int iside=0; iside<2; iside++) { + const std::string regionTag = " (" + be_id[1] + side_id[iside] + ")"; + m_hefficiencyEndCap_locR_Off[iside] = bookTProfile_LW(trackEffEndCap, "hEfficiencyEndCap"+side_id[iside]+"_locR_Off", "Efficiency vs Track-to-Wire Distance" + regionTag, 50, -2.5, 2.5, 0, 1, "Track-to-Wire Distance (mm)", "Efficiency", scode); + m_hefficiencyEndCap_locR_Off_Ar[iside] = bookTProfile_LW(trackEffEndCap, "hEfficiencyEndCap"+side_id[iside]+"_locR_Off_Ar", "Efficiency vs Track-to-Wire Distance for Argon Straws" + regionTag, 50, -2.5, 2.5, 0, 1, "Track-to-Wire Distance (mm)", "Efficiency", scode); + //End of offline efficiency histograms. + } + + }//if (newRun && DoShift) + }//for (int ibe=0; ibe<2; ibe++) + + return scode; +} + +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::fillHistograms() +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Monitoring Histograms being filled"); + StatusCode sc; + + const EventInfo* eventInfo0; + sc = evtStore()->retrieve(eventInfo0); + + if (m_doRDOsMon) { + sc = Retrieve_TRT_RDOs(); + if (sc == StatusCode::FAILURE) return sc; + + sc = CheckEventBurst(); + if (sc == StatusCode::FAILURE) return sc; + if (passEventBurst) { + nEvents++; + evtLumiBlock++; + sc = Fill_TRT_RDOs(); + if (sc == StatusCode::FAILURE) return sc; + } + } else { + nEvents++; + passEventBurst = true; + evtLumiBlock++; + } + + if (m_doTracksMon) { + sc = Retrieve_TRT_Tracks(); + if (sc == StatusCode::FAILURE) return sc; + if (passEventBurst) sc = Fill_TRT_Tracks(); + if (sc == StatusCode::FAILURE) return sc; + } + + if (DoEfficiency) { + sc = Fill_TRT_Efficiency(); + if (sc == StatusCode::FAILURE) return sc; + } + + return StatusCode::SUCCESS; +}//fillHistograms() + +// Process all of the Histrograms. ie divide, multiply, or whate ver and write them to file. +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::procHistograms() +//----------------------------------------------------------------------------------// +{ + double n_BorE[2][2], total_BorE[2][2]; + double nfill[2]={3.0, 2.0}; // [0]:barrel, [1]:endcap + + if (m_environment != AthenaMonManager::online) { + if (DoShift) { + if (m_doRDOsMon) { + m_hSummary->SetBinContent(1,nEvents); + if (m_doTracksMon) { + m_hSummary->SetBinContent(2,m_nTotalTracks); + m_hSummary->SetBinContent(3,m_nTracksB[0]); + m_hSummary->SetBinContent(4,m_nTracksB[1]); + m_hSummary->SetBinContent(5,m_nTracksEC[0]); + m_hSummary->SetBinContent(6,m_nTracksEC[1]); + m_hSummary->SetBinContent(7,m_nTracksEC_B[0]); + m_hSummary->SetBinContent(8,m_nTracksEC_B[1]); + }//dotracks + }//do rdos + }//DoShift + + if (nEvents<m_nEvents || m_nEvents<0) + m_nEvents = nEvents; + + for (int ibe=0; ibe<2; ibe++) { //ibe=0(barrel), ibe=1(endcap) + //Loop over stack histograms and normalize to number of events processed. + if (DoChips && DoExpert && endOfRun) { + for (int i=0; i<64; i++) { + if (m_doTracksMon && DoExpert) { + divide_LWHist(m_hHitOnTrackVsAllC[ibe][i], m_hHitAonTMapC[ibe][i], m_hHitAMapC[ibe][i]); + } + if (m_doRDOsMon) { + float scale = (float)m_nEvents*16; + if (scale > 0) { + scale = 1./scale; + scale_LWHist(m_hHitHWMapC[ibe][i], scale); + scale_LWHist(m_hHitWMapC[ibe][i], scale); + scale_LWHist(m_hHitAMapC[ibe][i], scale); + scale_LWHist(m_hHitAWMapC[ibe][i], scale); + scale_LWHist(m_hHitHMapC[ibe][i], scale); + } + }//doRDOsMon + + for (int j=0; j<s_iChip_max[ibe]; j++) { + if (m_doRDOsMon) m_hChipOcc[ibe][i]->Fill(m_hHitAMapC[ibe][i]->GetBinContent(j+1)); + if (m_doTracksMon) { + float scale = m_hChipsEff[ibe][i]->GetBinEntries(j+1); + if (scale > 0) { + m_hHitAonTMapC[ibe][i]->SetBinContent(j+1, m_hHitAonTMapC[ibe][i]->GetBinContent(j+1)/scale); + m_hHitWonTMapC[ibe][i]->SetBinContent(j+1, m_hHitWonTMapC[ibe][i]->GetBinContent(j+1)/scale); + m_hHitAWonTMapC[ibe][i]->SetBinContent(j+1, m_hHitAWonTMapC[ibe][i]->GetBinContent(j+1)/scale); + m_hHitHonTMapC[ibe][i]->SetBinContent(j+1, m_hHitHonTMapC[ibe][i]->GetBinContent(j+1)/scale); + } else { + m_hHitAonTMapC[ibe][i]->SetBinContent(j+1, 0); + m_hHitWonTMapC[ibe][i]->SetBinContent(j+1, 0); + m_hHitAWonTMapC[ibe][i]->SetBinContent(j+1, 0); + m_hHitHonTMapC[ibe][i]->SetBinContent(j+1, 0); + } + }//doTracksMon + }// for (int j=0; j<s_iChip_max[ibe]; j++) + + if (m_doRDOsMon && DoExpert) { + divide_LWHist(m_hHtoLMapC[ibe][i], m_hHitHMapC[ibe][i], m_hHitAMapC[ibe][i]); + } + if (m_doTracksMon && DoExpert) { + divide_LWHist(m_hHtoLonTMapC[ibe][i],m_hHitHonTMapC[ibe][i], m_hHitAonTMapC[ibe][i]); + } + }//Loop over A side and C side Stacks: for (int i=0; i<64; i++) + }//if DoChips && DoExpert && endOfRun + + if (DoStraws && endOfRun) { + if (m_doRDOsMon && m_nEvents > 0) { + if (ibe==0) { + scale_LWHist(m_hHitWMap_B, 1. / (m_nEvents*64)); + if (m_ArgonXenonSplitter) { + scale_LWHist(m_hHitWMap_B_Ar, 1. / (m_nEvents * 64)); + } + } else if (ibe==1) { + scale_LWHist(m_hHitWMap_E[0], 1. / (m_nEvents * 32)); + scale_LWHist(m_hHitWMap_E[1], 1. / (m_nEvents * 32)); + if (m_ArgonXenonSplitter) { + scale_LWHist(m_hHitWMap_E_Ar[0], 1. / (m_nEvents * 32)); + scale_LWHist(m_hHitWMap_E_Ar[1], 1. / (m_nEvents * 32)); + } + } + }// doRDOsMon and m_nevents > 0 + for (int i=0; i<64; i++) { + if (m_doTracksMon && DoExpert) { + divide_LWHist(m_hHitOnTrackVsAllS[ibe][i], m_hHitAonTMapS[ibe][i], m_hHitAMapS[ibe][i]); + } + if (m_doRDOsMon && DoExpert && m_nEvents > 0) { + float scale = 1./m_nEvents; + scale_LWHist(m_hHitHWMapS[ibe][i], scale); + scale_LWHist(m_hHitWMapS[ibe][i], scale); + scale_LWHist(m_hHitAMapS[ibe][i], scale); + scale_LWHist(m_hHitAWMapS[ibe][i], scale); + scale_LWHist(m_hHitHMapS[ibe][i], scale); + }// doRDOsMon && doExpert && m_nEvents > 0 + + for (int j=0; j<s_Straw_max[ibe]; j++) { + if (m_doRDOsMon) { + if (DoExpert) { + //No normalization done (just fill occupancy distribution) + m_hStrawOcc[ibe][i]->Fill(m_hHitAMapS[ibe][i]->GetBinContent(j+1)); + }//do expert + }//doRDOsMon + if (m_doTracksMon) { + if (i==0) { + if (ibe==0) { + if (m_nStrawHits_B[j]>0) m_hHitWonTMap_B->SetBinContent(j+1, m_hHitWonTMap_B->GetBinContent(j+1)/((Float_t)m_nStrawHits_B[j])); + } else if (ibe==1) { + if (m_nStrawHits_E[0][j]>0) m_hHitWonTMap_E[0]->SetBinContent(j+1,(float)m_hHitWonTMap_E[0]->GetBinContent(j+1)/(m_nStrawHits_E[0][j])); + if (m_nStrawHits_E[1][j]>0) m_hHitWonTMap_E[1]->SetBinContent(j+1,(float)m_hHitWonTMap_E[1]->GetBinContent(j+1)/(m_nStrawHits_E[1][j])); + } + } + if (DoExpert) { + float scale = m_hStrawsEff[ibe][i]->GetBinEntries(j+1); + if (scale > 0 && m_hStrawsEff[ibe][i]->GetBinEntries(j+1) > 0) { + scale = 1./scale; + m_hHitAWonTMapS[ibe][i]->SetBinContent(j+1, m_hHitAWonTMapS[ibe][i]->GetBinContent(j+1)*scale); + m_hHitAonTMapS[ibe][i]->SetBinContent(j+1, m_hHitAonTMapS[ibe][i]->GetBinContent(j+1)*scale); + m_hHitHonTMapS[ibe][i]->SetBinContent(j+1, m_hHitHonTMapS[ibe][i]->GetBinContent(j+1)*scale); + m_hHitWonTMapS[ibe][i]->SetBinContent(j+1, m_hHitWonTMapS[ibe][i]->GetBinContent(j+1)*scale); + } else { + m_hHitAWonTMapS[ibe][i]->SetBinContent(j+1, 0); + m_hHitAonTMapS[ibe][i]->SetBinContent(j+1, 0); + m_hHitHonTMapS[ibe][i]->SetBinContent(j+1, 0); + m_hHitWonTMapS[ibe][i]->SetBinContent(j+1, 0); + } + } //DoExpert + }//doTracksMon + } //for (int j=0; j<s_Straw_max[ibe]; j++) + + if (m_doRDOsMon && DoExpert) divide_LWHist(m_hHtoLMapS[ibe][i],m_hHitHMapS[ibe][i], m_hHitAMapS[ibe][i]); + if (m_doTracksMon && DoExpert) divide_LWHist(m_hHtoLonTMapS[ibe][i],m_hHitHonTMapS[ibe][i], m_hHitAonTMapS[ibe][i]); + + }//Loop over A side and C side Stacks: for (int i=0; i<64; i++) + }//if DoStraws && endOfRun + + if (DoShift && endOfRun) { + if (m_doTracksMon) { + if (ibe==0) { //barrel + EventPhaseScale = m_hEvtPhase->GetEntries()*3.125; + if (EventPhaseScale > 0) { + scale_LWHist(m_hEvtPhase, 1./EventPhaseScale); + } + DriftTimeonTrkDistScale_B = m_hDriftTimeonTrkDist_B->GetEntries()*3.125; + if (DriftTimeonTrkDistScale_B > 0) + scale_LWHist(m_hDriftTimeonTrkDist_B, 1./DriftTimeonTrkDistScale_B); + + HLhitOnTrackScale_B = m_hHLhitOnTrack_B->GetEntries(); + if (HLhitOnTrackScale_B > 0) { + scale_LWHist(m_hHLhitOnTrack_B,1./HLhitOnTrackScale_B); + } + HtoLRatioOnTrackScale_B = m_hHtoLRatioOnTrack_B->GetEntries()*0.02; + if (HtoLRatioOnTrackScale_B > 0) { + scale_LWHist(m_hHtoLRatioOnTrack_B, 1./HtoLRatioOnTrackScale_B); + } + NumSwLLWoTScale_B=m_hNumSwLLWoT_B->GetEntries(); + if (NumSwLLWoTScale_B > 0) { + scale_LWHist(m_hNumSwLLWoT_B, 1./NumSwLLWoTScale_B); + } + WireToTrkPositionScale_B=m_hWireToTrkPosition_B->GetEntries()*0.1; + if (WireToTrkPositionScale_B > 0) { + scale_LWHist(m_hWireToTrkPosition_B, 1./WireToTrkPositionScale_B); + } + TronTDistScale_B=m_hTronTDist_B->GetEntries()*3.125; + if (TronTDistScale_B > 0) { + scale_LWHist(m_hTronTDist_B ,1./TronTDistScale_B); + } + ResidualScale_B = m_hResidual_B->GetEntries()*0.05; + if (ResidualScale_B > 0) { + scale_LWHist(m_hResidual_B, 1./ResidualScale_B); + } + TimeResidualScale_B = m_hTimeResidual_B->GetEntries()*0.2; + if (TimeResidualScale_B > 0) { + scale_LWHist(m_hTimeResidual_B, 1./TimeResidualScale_B); + } + if (m_ArgonXenonSplitter) { + ResidualScale_B_Ar = m_hResidual_B_Ar->GetEntries() * 0.05; + if (ResidualScale_B_Ar > 0) { + scale_LWHist(m_hResidual_B_Ar, 1. / ResidualScale_B_Ar); + } + TimeResidualScale_B_Ar = m_hTimeResidual_B_Ar->GetEntries() * 0.2; + if (TimeResidualScale_B_Ar > 0) { + scale_LWHist(m_hTimeResidual_B_Ar, 1. / TimeResidualScale_B_Ar); + } + } + } else if (ibe==1) { //endcap + for (int iside=0; iside<2; iside++) { + DriftTimeonTrkDistScale_E[iside] = m_hDriftTimeonTrkDist_E[iside]->GetEntries()*3.125; + if (DriftTimeonTrkDistScale_E[iside] > 0) { + scale_LWHist(m_hDriftTimeonTrkDist_E[iside], 1./DriftTimeonTrkDistScale_E[iside]); + } + HLhitOnTrackScale_E[iside] = m_hHLhitOnTrack_E[iside]->GetEntries(); + if (HLhitOnTrackScale_E[iside] > 0) { + scale_LWHist(m_hHLhitOnTrack_E[iside], 1./HLhitOnTrackScale_E[iside]); + } + HtoLRatioOnTrackScale_E[iside] = m_hHtoLRatioOnTrack_E[iside]->GetEntries()*0.02; + if (HtoLRatioOnTrackScale_E[iside] > 0) { + scale_LWHist(m_hHtoLRatioOnTrack_E[iside], 1./HtoLRatioOnTrackScale_E[iside]); + } + NumSwLLWoTScale_E[iside] = m_hNumSwLLWoT_E[iside]->GetEntries(); + if (NumSwLLWoTScale_E[iside] > 0) { + scale_LWHist(m_hNumSwLLWoT_E[iside], 1./NumSwLLWoTScale_E[iside]); + } + WireToTrkPositionScale_E[iside] = m_hWireToTrkPosition_E[iside]->GetEntries()*0.1; + if (WireToTrkPositionScale_E[iside] > 0) { + scale_LWHist(m_hWireToTrkPosition_E[iside], 1./WireToTrkPositionScale_E[iside]); + } + TronTDistScale_E[iside] = m_hTronTDist_E[iside]->GetEntries()*3.125; + if (TronTDistScale_E[iside] > 0) { + scale_LWHist(m_hTronTDist_E[iside], 1./TronTDistScale_E[iside]); + } + ResidualScale_E[iside] = m_hResidual_E[iside]->GetEntries()*0.05; + if (ResidualScale_E[iside] > 0) { + scale_LWHist(m_hResidual_E[iside], 1./ResidualScale_E[iside]); + } + TimeResidualScale_E[iside] = m_hTimeResidual_E[iside]->GetEntries()*0.2; + if (TimeResidualScale_E[iside] > 0) { + scale_LWHist(m_hTimeResidual_E[iside], 1./TimeResidualScale_E[iside]); + } + if (m_ArgonXenonSplitter) { + ResidualScale_E_Ar[iside] = m_hResidual_E_Ar[iside]->GetEntries() * 0.05; + if (ResidualScale_E_Ar[iside] > 0) { + scale_LWHist(m_hResidual_E_Ar[iside], 1. / ResidualScale_E_Ar[iside]); + } + TimeResidualScale_E_Ar[iside] = m_hTimeResidual_E_Ar[iside]->GetEntries() * 0.2; + if (TimeResidualScale_E_Ar[iside] > 0) { + scale_LWHist(m_hTimeResidual_E_Ar[iside], 1. / TimeResidualScale_E_Ar[iside]); + } + } + } //for (int iside=0; iside<2; iside++) + }// else if (ibe==1) + + }//doTracksMon + }//if DoShift && isendofrun + + if (DoEfficiency && endOfRun) { + for (int iside=0; iside<2; iside++) { + for (int i = 0; i < 32; i++) { + for (int ibin = 0; ibin <= s_Straw_max[ibe]; ibin++) { + + if (DoExpert) { + if (m_hefficiencyS[ibe][i+(32*iside)]->GetBinEntries(ibin) > m_min_tracks_straw) { + m_hefficiency[ibe][iside]->Fill(m_hefficiencyS[ibe][i+(32*iside)]->GetBinContent(ibin)); + } + } + + } //loop ibin + }// loop phi sectors + n_BorE[ibe][iside] = m_hefficiency[ibe][iside]->GetEntries(); + + total_BorE[ibe][iside] = 0.0; + for (unsigned int ibin = 0; ibin <= m_hefficiency[ibe][iside]->GetXaxis()->GetNbins(); ibin++) { + total_BorE[ibe][iside] += m_hefficiency[ibe][iside]->GetBinContent(ibin); + m_hefficiencyIntegral[ibe][iside]->SetBinContent(ibin, n_BorE[ibe][iside]!=0.0 ? total_BorE[ibe][iside]/n_BorE[ibe][iside] : 0); + }// loop over ibin + }//for (int iside=0; iside<2; iside++) + }// if DoEfficiency && EndOfRun + + } // for (int ibe=0; ibe<2; ibe++) + }//if is not online + + if (endOfLumiBlock || endOfRun) { + if (DoShift) { + Int_t lumiblock720 = lastLumiBlock % 720; + + if (m_doTracksMon) { + + if (evtLumiBlock > 0) { + m_hNHitsperLB_B->Fill(lastLumiBlock, (float)nHitsperLB_B / (evtLumiBlock * 105088.)); + m_hNTrksperLB_B->Fill(lastLumiBlock, (float)nTrksperLB_B / evtLumiBlock); + m_hNHLHitsperLB_B->Fill(lastLumiBlock, (float)nHLHitsperLB_B/ (evtLumiBlock * 105088.)); + for (int iside=0; iside<2; iside++) { + m_hNHitsperLB_E[iside]->Fill(lastLumiBlock, (float)nHitsperLB_E[iside] / (evtLumiBlock * 122880.)); + m_hNTrksperLB_E[iside]->Fill(lastLumiBlock, (float)nTrksperLB_E[iside] / evtLumiBlock); + m_hNHLHitsperLB_E[iside]->Fill(lastLumiBlock, (float)nHLHitsperLB_E[iside] / (evtLumiBlock * 122880.)); + } + } + + + nTrksperLB_B=0; + nHitsperLB_B=0; + nHLHitsperLB_B=0; + for (int iside=0; iside<2; iside++) { + nTrksperLB_E[iside]=0; + nHitsperLB_E[iside]=0; + nHLHitsperLB_E[iside]=0; + } + + for (int ibe=0; ibe<2; ibe++) { //ibe=0(barrel), ibe=1(endcap) + for (int i = 0; i < s_iStack_max[ibe]; i++) { + if (ibe==0) { // barrel + if (evtLumiBlock > 0) { + float occ = (m_LLOcc[ibe][i]/evtLumiBlock)/nfill[ibe]; + m_hLLOcc_Scatter[ibe]->Fill(lumiblock720,occ); + occ = (m_LLOcc[ibe][i+32]/evtLumiBlock)/nfill[ibe]; + m_hLLOcc_Scatter[ibe]->Fill(lumiblock720,occ); + } + m_LLOcc[ibe][i]=0; m_LLOcc[ibe][i+32]=0; + + if (m_nTrack_B[i]) { + float ratio=m_HTfraconTrack_B[i]/m_nTrack_B[i]; + m_hHightoLowRatioOnTrack_Scatter[ibe]->Fill(lumiblock720,ratio); + m_hHitsOnTrack_Scatter[ibe]->Fill(lumiblock720,m_LonTrack_B[i]/m_nTrack_B[i]); + } + m_LonTrack_B[i] = 0; + m_HTfraconTrack_B[i] = 0; + m_nTrack_B[i] = 0; + + } else if (ibe==1) { // endcap + if (evtLumiBlock > 0) { + float occ = (m_LLOcc[ibe][i]/evtLumiBlock)/nfill[ibe]; + m_hLLOcc_Scatter[ibe]->Fill(lumiblock720,occ); + } + m_LLOcc[ibe][i]=0; + if (m_nTrack_E[i]) { + float ratio=m_HTfraconTrack_E[i]/m_nTrack_E[i]; + m_hHightoLowRatioOnTrack_Scatter[ibe]->Fill(lumiblock720,ratio); + m_hHitsOnTrack_Scatter[ibe]->Fill(lumiblock720,m_LonTrack_E[i]/m_nTrack_E[i]); + } + m_LonTrack_E[i] = 0; + m_HTfraconTrack_E[i] = 0; + m_nTrack_E[i] = 0; + } + }// for (int i = 0; i < s_iStack_max[ibe]; i++) + } //for (int ibe=0; ibe<2; ibe++) + } //if (m_doTracksMon) + }//Doshift + + if (DoShift && m_environment == AthenaMonManager::online && (lastLumiBlock % m_lumiBlocksToResetOcc) == 0) { + for (int ibe=0; ibe<2; ibe++) { + for (int iside=0; iside<2; iside++) { + m_hAvgHLOcc_side[ibe][iside]->Reset(); + m_hAvgLLOcc_side[ibe][iside]->Reset(); + m_hAvgHLOccMod_side[ibe][iside]->Reset(); + m_hAvgLLOccMod_side[ibe][iside]->Reset(); + } + } + } + + ATH_MSG_DEBUG("end of event and lumi block"); + evtLumiBlock = 0; + } // end lumi block + + if (endOfRun) { + ATH_MSG_DEBUG("end of run"); + } + + return StatusCode::SUCCESS; +}//procHistograms + +//Get TRT Raw Data Objects (all TRT Hits) +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Retrieve_TRT_RDOs() +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Retrieving RDO Container from StoreGate"); + + StatusCode sc = StatusCode::SUCCESS; + if (evtStore()->contains<TRT_RDO_Container>(m_rawDataObjectName)) { + sc = evtStore()->retrieve(m_rdoContainer, m_rawDataObjectName); + if (sc.isFailure() || !m_rdoContainer) { + ATH_MSG_FATAL("Could not find the data object"); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG("Data Object " << m_rawDataObjectName << " found"); + } + } + else { + ATH_MSG_WARNING("No TRT_RDO_Container by the name of "<<m_rawDataObjectName <<" in storegate"); + return StatusCode::FAILURE; + } + ATH_MSG_VERBOSE("Leaving Retrieve_TRT_RDOs()"); + return sc; +}//Retrieve_TRT_RDOs() + + +//Check for EventBurst +StatusCode TRT_Monitoring_Tool::CheckEventBurst() +{ + passEventBurst = true; + if (m_EventBurstCut <= 0) return StatusCode::SUCCESS; + + int nHLHits = 0; + TRT_RDO_Container::const_iterator RDO_CollectionBegin = m_rdoContainer->begin(); + TRT_RDO_Container::const_iterator RDO_CollectionEnd = m_rdoContainer->end(); + for (;RDO_CollectionBegin!=RDO_CollectionEnd; ++RDO_CollectionBegin) { + //Get pointer to TRT_Collection + const InDetRawDataCollection<TRT_RDORawData>* TRT_Collection(*RDO_CollectionBegin); + // select only TRT RDOs + if (!TRT_Collection) continue; + else { + DataVector<TRT_RDORawData>::const_iterator p_rdo;//pointer to trt rdo data vector + // Loop over TRT RDOs + for (p_rdo=TRT_Collection->begin(); p_rdo!=TRT_Collection->end(); ++p_rdo) { + const TRT_LoLumRawData* p_lolum=dynamic_cast<const TRT_LoLumRawData*>(*p_rdo); + if (!p_lolum) continue; + if (p_lolum->highLevel()) nHLHits++; + } //loop over TRT RDOs + } // if TRT_Collection + } // loop over RDOs + if (nHLHits > m_EventBurstCut) passEventBurst = false; + return StatusCode::SUCCESS; +}//CheckEventBurst + +//Now Fill the TRT RDO Histograms +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Fill_TRT_RDOs() +//----------------------------------------------------------------------------------// +{ + ATH_MSG_DEBUG("Filling TRT RDO Histograms"); + + TRT_RDO_Container::const_iterator RDO_CollectionBegin = m_rdoContainer->begin(); + TRT_RDO_Container::const_iterator RDO_CollectionEnd = m_rdoContainer->end(); + InDetTimeCollection *TRT_BCIDColl = 0; + + if (evtStore()->contains<InDetTimeCollection>("TRT_BCID")) { + if (evtStore()->retrieve(TRT_BCIDColl, "TRT_BCID").isFailure()) { + ATH_MSG_INFO("Could not get InDetTimeCollection from Store Gate"); + } else { + ATH_MSG_DEBUG("Got BCID Collection from Store Gate"); + } + } + + const EventInfo* eventInfo; + if (evtStore()->retrieve(eventInfo).isFailure()) { + ATH_MSG_ERROR("Could not retrieve the EventInfo from Store Gate"); + return StatusCode::FAILURE; + } + if (Check_TRT_Readout_Integrity(eventInfo).isFailure()) { + ATH_MSG_ERROR("Failure when checking the TRT readout integrity"); + return StatusCode::FAILURE; + } + + int numberOfStacks_b[2]; + numberOfStacks_b[0]= s_numberOfBarrelStacks*3; + numberOfStacks_b[1]= s_numberOfEndCapStacks*2; + + Identifier TRT_Identifier; + int numberOfStrawsMod[3]; // For barrel + numberOfStrawsMod[0]=329; + numberOfStrawsMod[1]=520; + numberOfStrawsMod[2]=793; + + int numberOfStrawsWheel[2]; // For endcap + numberOfStrawsWheel[0]=2304; //6 layers (6*16=96) 96*24=2304 straws in wheel A + numberOfStrawsWheel[1]=1536; //8 layers (8*8=64) 64*24=1536 straws in wheel B + + int moduleHits_B[192], moduleHits_E[128]; + int HLmoduleHits_B[192], HLmoduleHits_E[128]; + for (int i = 0; i < 192; i++) { moduleHits_B[i]=0; HLmoduleHits_B[i]=0; } + for (int i = 0; i < 128; i++) { moduleHits_E[i]=0; HLmoduleHits_E[i]=0; } + + int goodid_status = 0; + int prev_bcid = 0; + + if (TRT_BCIDColl) { + InDetTimeCollection::const_iterator itrt_bcid = TRT_BCIDColl->begin(); + while (goodid_status == 0 && itrt_bcid != TRT_BCIDColl->end()) { + if (!(*itrt_bcid)) continue; + const unsigned int trt_bcid = (*itrt_bcid)->second; + if (itrt_bcid > TRT_BCIDColl->begin() && prev_bcid-trt_bcid == 0) { + goodid_status = 1; + } + else if (itrt_bcid > TRT_BCIDColl->begin() && prev_bcid-trt_bcid != 0) { + ATH_MSG_WARNING("TRT BCID is not consistent. TRT RODID is " << std::hex << (*itrt_bcid)->first << " trt bcid from ROD is " << std::hex << trt_bcid); + } + prev_bcid = trt_bcid; + ++itrt_bcid; + } + }//if trt_bcidcoll is valid + + // Test out the TRT_StrawStatusSummarySvc. + if (!m_sumSvc.name().empty() && DoExpert) { + ATH_MSG_VERBOSE("Trying " << m_sumSvc << " isGood"); + ATH_MSG_VERBOSE("TRT_StrawStatusSvc reports status = " << m_sumSvc->getStatus(TRT_Identifier)); + } + + for (int ibe = 0; ibe < 2; ibe++) { //ibe=0(barrel), ibe=1(endcap) + nTRTHits[ibe] = 0; + + //Take out normalization from previous event for online environment + if (m_environment == AthenaMonManager::online && nEvents >0) { + //Loop over stack histograms and normalize to number of events processed. + + if (DoChips && DoExpert) { + for (int i = 0; i < 64; i++) { + float scale = (nEvents-1) * 16; + scale_LWHist(m_hHitHWMapC[ibe][i], scale); + scale_LWHist(m_hHitWMapC[ibe][i], scale); + scale_LWHist(m_hHitAMapC[ibe][i], scale); + scale_LWHist(m_hHitAWMapC[ibe][i], scale); + scale_LWHist(m_hHitHMapC[ibe][i], scale); + }//Loop over A side and C side Stacks: for (int i=0; i<64; i++) + }//if DoChips && DoExpert + + if (DoStraws) { + if (ibe == 0) { + scale_LWHist(m_hHitWMap_B, (nEvents-1) * 64); + if (m_ArgonXenonSplitter) { + scale_LWHist(m_hHitWMap_B_Ar, (nEvents-1) * 64); + } + } else if (ibe==1) { + scale_LWHist(m_hHitWMap_E[0], (nEvents-1) * 32); + scale_LWHist(m_hHitWMap_E[1], (nEvents-1) * 32); + if (m_ArgonXenonSplitter) { + scale_LWHist(m_hHitWMap_E_Ar[0], (nEvents-1) * 32); + scale_LWHist(m_hHitWMap_E_Ar[1], (nEvents-1) * 32); + } + } + + if (DoExpert) { + for (int i = 0; i < 64; i++) { + // m_hStrawOcc[ibe][i]->Reset(); + scale_LWHist(m_hHitHWMapS[ibe][i], nEvents-1); + scale_LWHist(m_hHitWMapS[ibe][i], nEvents-1); + scale_LWHist(m_hHitAMapS[ibe][i], nEvents-1); + scale_LWHist(m_hHitAWMapS[ibe][i], nEvents-1); + scale_LWHist(m_hHitHMapS[ibe][i], nEvents-1); + }//Loop over A side and B side Stacks: for (int i=0; i<64; i++) + } // if doExpert + }//if DoStraws && DoExpert + }//If online environment + //finish taking out normalization + + }// for (int ibe=0; ibe<2; ibe++) + + int nhitsall = 0; + for (; RDO_CollectionBegin != RDO_CollectionEnd; ++RDO_CollectionBegin) { + //Get pointer to TRT_Collection + const InDetRawDataCollection<TRT_RDORawData>* TRT_Collection(*RDO_CollectionBegin); + + // select only TRT RDOs + if (!TRT_Collection) continue; + DataVector<TRT_RDORawData>::const_iterator p_rdo;//pointer to trt rdo data vector + // Loop over TRT RDOs + for (p_rdo=TRT_Collection->begin(); p_rdo!=TRT_Collection->end(); ++p_rdo) { + TRT_Identifier = (*p_rdo)->identify(); + if (DoMaskStraws && m_sumSvc->get_status(TRT_Identifier)) continue; + int m_barrel_ec = m_pTRTHelper->barrel_ec(TRT_Identifier); + const TRT_LoLumRawData* p_lolum=dynamic_cast<const TRT_LoLumRawData*>(*p_rdo); + if (!p_lolum) continue; + nhitsall++; + int barrelendcap_sectorflag[2][2]; + barrelendcap_sectorflag[0][0]=1; // barrel-A + barrelendcap_sectorflag[0][1]=-1; // barrel-C + barrelendcap_sectorflag[1][0]=2; // endcap-A + barrelendcap_sectorflag[1][1]=-2; + + int moduleNumber_barrel1[2]; + int moduleNumber_barrel2[2]; + int moduleNumber_barrel3[2]; + + int moduleNumber_endcapA[2]; + int moduleNumber_endcapB[2]; + + for (int ibe=0; ibe<2; ibe++) { // ibe=0(barrel) ,ibe=1(endcap) + //Get TRT Identifier (need to know phi module, module layer, straw layer, and straw # with in the layer, to get proper straw numbering. + TRT_Identifier = p_lolum->identify(); + + // assume always Xe if m_ArgonXenonSplitter is not enabled, otherwise check the straw status (good is Xe, non-good is Ar) + const bool isArgonStraw = m_ArgonXenonSplitter && (m_sumSvc->getStatusHT(TRT_Identifier) != TRTCond::StrawStatus::Good); + + int m_phi_module = m_pTRTHelper->phi_module(TRT_Identifier); + int m_layer_or_wheel = m_pTRTHelper->layer_or_wheel(TRT_Identifier); + int m_straw_layer = m_pTRTHelper->straw_layer(TRT_Identifier); + int m_straw = m_pTRTHelper->straw(TRT_Identifier); + + int m_strawNumber, m_chip=0, m_board=-1; + + int ibe_tmp=-1; + if ((m_pTRTHelper->is_barrel(TRT_Identifier)) + && (m_pTRTHelper->barrel_ec(TRT_Identifier)==-1 + || m_pTRTHelper->barrel_ec(TRT_Identifier)==1)) { // barrel + ibe_tmp=0; + m_strawNumber=strawNumber(m_straw, m_straw_layer, m_layer_or_wheel); + if (m_strawNumber >= 0 && m_strawNumber < s_Straw_max[ibe_tmp]) { + m_chip = mat_chip_B[m_phi_module][m_strawNumber]; + } + m_board = chipToBoard(m_chip); + + if (m_strawNumber < 0 || m_strawNumber >= s_Straw_max[ibe_tmp]) { + ATH_MSG_WARNING("Found m_strawNumber = " << m_strawNumber << " out of range."); + } + + } else if ((!(m_pTRTHelper->is_barrel(TRT_Identifier))) + && (m_pTRTHelper->barrel_ec(TRT_Identifier)==-2 + || m_pTRTHelper->barrel_ec(TRT_Identifier)==2)) { // endcap + ibe_tmp=1; + m_strawNumber = strawNumberEndCap(m_straw, m_straw_layer, m_layer_or_wheel, m_phi_module, m_barrel_ec); + if (m_strawNumber >= 0 && m_strawNumber < s_Straw_max[ibe_tmp]) { + m_chip = mat_chip_E[m_phi_module][m_strawNumber]; + } + m_board = chipToBoard_EndCap(m_chip); + + if (m_strawNumber < 0 || m_strawNumber >= s_Straw_max[ibe_tmp]) { + ATH_MSG_WARNING("Found m_strawNumber= " << m_strawNumber << " out of range."); + } + } else { + m_strawNumber=-1; + } + + if (ibe_tmp==-1) continue; + if (m_strawNumber<0 || m_strawNumber >= s_Straw_max[ibe_tmp]) continue; + + const int m_driftTimeBin = p_lolum->driftTimeBin(); + const int m_trailingEdge = p_lolum->trailingEdge(); + + const bool m_highlevel = p_lolum->highLevel(); + const bool m_firstBinHigh = p_lolum->firstBinHigh(); // if the first time bin is up then the hit is out of time window + const bool m_lastBinHigh = p_lolum->lastBinHigh(); // if the last bin is up then the hit is out of time window. + + const float m_timeOverThreshold = p_lolum->timeOverThreshold(); + + moduleNumber_barrel1[0]=m_phi_module; + moduleNumber_barrel1[1]=m_phi_module+96; + + moduleNumber_barrel2[0]=m_phi_module+s_numberOfBarrelStacks; + moduleNumber_barrel2[1]=m_phi_module+s_numberOfBarrelStacks+96; + + moduleNumber_barrel3[0]=m_phi_module+2*s_numberOfBarrelStacks; + moduleNumber_barrel3[1]=m_phi_module+2*s_numberOfBarrelStacks+96; + + moduleNumber_endcapA[0]=m_phi_module; + moduleNumber_endcapA[1]=m_phi_module+64; + + moduleNumber_endcapB[0]=m_phi_module+s_numberOfEndCapStacks; + moduleNumber_endcapB[1]=m_phi_module+s_numberOfEndCapStacks+64; + + for (int iside=0; iside<2; iside++) { // iside=0(A-side), iside=1(C-side) + if (m_barrel_ec==barrelendcap_sectorflag[ibe][iside]) { + + int iphi_module=-999; + if (iside==0) { //A-side + iphi_module=m_phi_module; + } else if (iside==1) { //C-side + iphi_module=m_phi_module+32; + } + + if (ibe==0) { // Barrel + nTRTHits[ibe]++; + if (DoStraws) { + if (isArgonStraw) { + m_hHitWMap_B_Ar->Fill(m_strawNumber); // Fill leading edge in time window histograms for Argon straws. + } else { + m_hHitWMap_B->Fill(m_strawNumber); // Fill leading edge in time window histograms. + } + } + if (DoShift) { + nHitsperLB_B++; + if (m_highlevel) { nHLHitsperLB_B++; } + } + } else if (ibe==1) { // Endcap + nTRTHits[ibe]++; + if (DoStraws) { + if (isArgonStraw) { + m_hHitWMap_E_Ar[iside]->Fill(m_strawNumber); // Fill leading edge in time window histograms for Argon straws. + } else { + m_hHitWMap_E[iside]->Fill(m_strawNumber);// Fill leading edge in time window histograms. + } + }//DoStraws + if (DoShift) { + nHitsperLB_E[iside]++; + if (m_highlevel) { nHLHitsperLB_E[iside]++; } + } + } + + + if (DoExpert) { + if ((m_driftTimeBin<24) && !m_lastBinHigh && !m_firstBinHigh) { //Fill Leading Edge Histos. + if (DoStraws) m_hHitWMapS[ibe][iphi_module]->Fill(m_strawNumber); //Leading Edge in time Window: Straws + if (DoChips) m_hHitWMapC[ibe][iphi_module]->Fill(m_chip-1); //Leading Edge in time Window: Chips + } + if ((m_trailingEdge<23)&& !m_lastBinHigh && !m_firstBinHigh) { //Fill Trailing Edge Histos + if (DoStraws) m_hHitTrWMapS[ibe][iphi_module]->Fill(m_strawNumber, ((m_trailingEdge+1)*3.125)); //Mean TE in time window: Straws + if (DoChips) m_hHitTrWMapC[ibe][iphi_module]->Fill((m_chip-1), ((m_trailingEdge+1)*3.125)); //Mean TE in time window: Chips + } + if (DoStraws) m_hHitTrMapS[ibe][iphi_module]->Fill(m_strawNumber, ((m_trailingEdge+1)*3.125)); //Mean TE: Straws + if (DoChips) m_hHitTrMapC[ibe][iphi_module]->Fill((m_chip-1), ((m_trailingEdge+1)*3.125)); //Mean TE: Chips + + //Look at high threshold (HL) hit distributions (was there a HL hit? was the HL hit in the time window?) + if (m_highlevel) { // If ANY highLevel bit is up. + if (DoStraws) m_hHitHMapS[ibe][iphi_module]->Fill(m_strawNumber); //High Level: Straws + if (DoChips) m_hHitHMapC[ibe][iphi_module]->Fill(m_chip-1); //High Level: Chips + + if ((m_driftTimeBin<24) && !m_firstBinHigh && !m_lastBinHigh) { + //m_hHitHWMapS[ibe][iphi_module]->Fill(strawNumber(m_straw,m_straw_layer,m_layer_or_wheel)); //HL in time window: Straws + if (DoStraws) m_hHitHWMapS[ibe][iphi_module]->Fill(m_strawNumber); //HL in time window: Straws + if (DoChips) m_hHitHWMapC[ibe][iphi_module]->Fill(m_chip-1); //HL in time window: Chip + } + } + + if (m_firstBinHigh || m_lastBinHigh || m_driftTimeBin>0 || m_trailingEdge<23) { + if (DoStraws) m_hHitAMapS[ibe][iphi_module]->Fill(m_strawNumber); //Any LL bit on: Straws + if (DoChips) m_hHitAMapC[ibe][iphi_module]->Fill(m_chip-1); //Any LL bit on: Chips + } + + if ((m_driftTimeBin>0 || m_trailingEdge<23)&& !m_firstBinHigh && !m_lastBinHigh) { + if (DoStraws) m_hHitAWMapS[ibe][iphi_module]->Fill(m_strawNumber); // LL in time window: Straws + if (DoChips) m_hHitAWMapC[ibe][iphi_module]->Fill(m_chip-1); // LL in time window: Chips + }//if (m_driftTimeBin>0 && m_trailingEdge<23) + + if (DoStraws) { + m_hHitToTMapS[ibe][iphi_module]->Fill(m_strawNumber, m_timeOverThreshold); //Mean ToT (ns): Straws + if (m_timeOverThreshold>m_longToTCut) { + m_hHitToTLongMapS[ibe][iphi_module]->Fill(m_strawNumber, m_timeOverThreshold); //Mean ToT (ns) for Straws with ToT > LongToTCut: Straws + m_hHitToTLongTrMapS[ibe][iphi_module]->Fill(m_strawNumber, (m_trailingEdge+1)*3.125);// Mean Tr (ns) for Straws with ToT > LongToTCut: Straws + } + } + if (DoChips) m_hHitToTMapC[ibe][iphi_module]->Fill((m_chip-1), m_timeOverThreshold); //Mean ToT (ns): Chips + if (DoChips) { + if (p_lolum->highLevel(1)) { + m_hHtoBCMapC[ibe][iphi_module]->Fill(0.,(m_chip-1)); + m_hHtoBCMapB[ibe][iphi_module]->Fill(0.,(m_board-1)); + } + if (p_lolum->highLevel(2)) { + m_hHtoBCMapC[ibe][iphi_module]->Fill(1.,(m_chip-1)); + m_hHtoBCMapB[ibe][iphi_module]->Fill(1.,(m_board-1)); + } + if (p_lolum->highLevel(3)) { + m_hHtoBCMapC[ibe][iphi_module]->Fill(2.,(m_chip-1)); + m_hHtoBCMapB[ibe][iphi_module]->Fill(2.,(m_board-1)); + } + } + }//if DoExpert + + //Set Module Numbers. + int moduleNumber=-1; + if (ibe==0) {// barrel + if (m_layer_or_wheel==0) { + moduleNumber=moduleNumber_barrel1[iside]; + moduleHits_B[moduleNumber]++; + } else if (m_layer_or_wheel==1) { + moduleNumber=moduleNumber_barrel2[iside]; + moduleHits_B[moduleNumber]++; + } else if (m_layer_or_wheel==2) { + moduleNumber=moduleNumber_barrel3[iside]; + moduleHits_B[moduleNumber]++; + } + if (m_highlevel) { + if (m_layer_or_wheel==0) { + moduleNumber=moduleNumber_barrel1[iside]; + HLmoduleHits_B[moduleNumber]++; + } else if (m_layer_or_wheel==1) { + moduleNumber=moduleNumber_barrel2[iside]; + HLmoduleHits_B[moduleNumber]++; + } else if (m_layer_or_wheel==2) { + moduleNumber=moduleNumber_barrel3[iside]; + HLmoduleHits_B[moduleNumber]++; + } + }//if HL hit + + } else if (ibe==1) { //endcap + if (m_layer_or_wheel<6) { //WheelA (0-5) + moduleNumber=moduleNumber_endcapA[iside]; + moduleHits_E[moduleNumber]++; + } else if (m_layer_or_wheel>5) { //WheelB (6-13) + moduleNumber=moduleNumber_endcapB[iside]; + moduleHits_E[moduleNumber]++; + } + if (m_highlevel) { + if (m_layer_or_wheel<6) { //WheelA (0-5) + moduleNumber=moduleNumber_endcapA[iside]; + HLmoduleHits_E[moduleNumber]++; + } else if (m_layer_or_wheel>5) { //WheelB (6-13) + moduleNumber=moduleNumber_endcapB[iside]; + HLmoduleHits_E[moduleNumber]++; + } + }//if HL hit + } // else if (ibe==1) + + } //if (m_barrel_ec==barrelendcap_sectorflag[ibe][iside]) + } // for (int iside=0; iside<2; iside++) + } // for (int ibe=0; ibe<2; ibe++) + + } //Loop over rdo trt collection + + }//Loop over RDO Collection + + m_hOccAll->Fill(nhitsall/350848.); + + for (int ibe=0; ibe<2; ibe++) { + if (DoShift) { + if (ibe==0) { + m_hBCIDvsOcc[ibe]->Fill(good_bcid,(nTRTHits[ibe]/105088.0)); + } else if (ibe==1) { + m_hBCIDvsOcc[ibe]->Fill(good_bcid,(nTRTHits[ibe]/245760.0)); + } + + for (int iside=0; iside<2; iside++) { + for (int i=1; i<=numberOfStacks_b[ibe]; i++) { + int index_tmp, modulenum_tmp; + if (iside==0) { + index_tmp=i-1; + modulenum_tmp=i-1; + } else if (iside==1) { + index_tmp=i+31; + if (ibe==0) modulenum_tmp=(i-1)+96; + else if (ibe==1) modulenum_tmp=(i-1)+64; + } + int nclass=-1; + if (i<=s_numberOfBarrelStacks) { + nclass=0; + } else if (i<=2*s_numberOfBarrelStacks && i>s_numberOfBarrelStacks) { + nclass=1; + } else if (i>2*s_numberOfBarrelStacks) { + nclass=2; + } + + if (nclass>=0) { + if (ibe==0) { + m_LLOcc[ibe][(index_tmp-32*nclass)] += float(moduleHits_B[modulenum_tmp])/float(numberOfStrawsMod[nclass]); + m_hAvgLLOcc_side[ibe][iside]->Fill(i-(32*nclass), (float(moduleHits_B[modulenum_tmp])/float(numberOfStrawsMod[nclass]))); //Avg. Occupancy + m_hAvgHLOcc_side[ibe][iside]->Fill(i-(32*nclass), (float(HLmoduleHits_B[modulenum_tmp])/float(numberOfStrawsMod[nclass]))); //Avg. Occupancy + m_hAvgLLOccMod_side[ibe][iside]->Fill(i, (float(moduleHits_B[modulenum_tmp])/float(numberOfStrawsMod[nclass]))); //Avg. Occupancy + m_hAvgHLOccMod_side[ibe][iside]->Fill(i, (float(HLmoduleHits_B[modulenum_tmp])/float(numberOfStrawsMod[nclass]))); //Avg. Occupancy + } else if (ibe==1) { + m_LLOcc[ibe][(index_tmp-32*nclass)] += float(moduleHits_E[modulenum_tmp])/float(numberOfStrawsWheel[nclass]); + m_hAvgLLOcc_side[ibe][iside]->Fill(i-(32*nclass), (float(moduleHits_E[modulenum_tmp])/float(numberOfStrawsWheel[nclass]))); //Avg. Occupancy + m_hAvgHLOcc_side[ibe][iside]->Fill(i-(32*nclass), (float(HLmoduleHits_E[modulenum_tmp])/float(numberOfStrawsWheel[nclass]))); //Avg. Occupancy + m_hAvgLLOccMod_side[ibe][iside]->Fill(i, (float(moduleHits_E[modulenum_tmp])/float(numberOfStrawsWheel[nclass]))); //Avg. Occupancy + m_hAvgHLOccMod_side[ibe][iside]->Fill(i, (float(HLmoduleHits_E[modulenum_tmp])/float(numberOfStrawsWheel[nclass]))); //Avg. Occupancy + } + } //if (nclass>=0) + } //for (int i=1; i<=numberOfStacks_b[ibe]; i++) + } //for (int iside=0; iside<2; iside++) + } //if DoShift + + if (m_environment == AthenaMonManager::online) { + //Loop over stack histograms and normalize to number of events processed. + if (DoChips && DoExpert) { + for (int i=0; i<64; i++) { + for (int j=0; j<s_iChip_max[ibe]; j++) m_hChipOcc[ibe][i]->Fill(m_hHitAMapC[ibe][i]->GetBinContent(j+1)); + if (nEvents > 0) { + const float scale = 1./(16*nEvents); + scale_LWHist(m_hHitHWMapC[ibe][i], scale); + scale_LWHist(m_hHitWMapC[ibe][i], scale); + scale_LWHist(m_hHitAMapC[ibe][i], scale); + scale_LWHist(m_hHitAWMapC[ibe][i], scale); + scale_LWHist(m_hHitHMapC[ibe][i], scale); + } + }//Loop over A side and C side Stacks + }//if DoChips && DoExpert + + if (DoStraws) { + if (DoShift && nEvents > 0) { + if (ibe==0) { + scale_LWHist(m_hHitWMap_B, 1./(64*nEvents)); + if (m_ArgonXenonSplitter) { + scale_LWHist(m_hHitWMap_B_Ar, 1. / (64 * nEvents)); + } + } else if (ibe==1) { + scale_LWHist(m_hHitWMap_E[0], 1./(32*nEvents)); + scale_LWHist(m_hHitWMap_E[1], 1./(32*nEvents)); + if (m_ArgonXenonSplitter) { + scale_LWHist(m_hHitWMap_E_Ar[0], 1. / (32 * nEvents)); + scale_LWHist(m_hHitWMap_E_Ar[1], 1. / (32 * nEvents)); + } + } + } // DoShift && nEvents > 0 + + for (int i=0; i<64; i++) { + if (DoExpert && nEvents > 0) { + const float scale = 1./nEvents; + scale_LWHist(m_hHitHWMapS[ibe][i], scale); + scale_LWHist(m_hHitWMapS[ibe][i], scale); + scale_LWHist(m_hHitAMapS[ibe][i], scale); + scale_LWHist(m_hHitAWMapS[ibe][i], scale); + scale_LWHist(m_hHitHMapS[ibe][i], scale); + } // DoExpert && nEvents > 0 + for (int j=0; j<s_iChip_max[ibe]; j++) { + if (DoExpert) m_hStrawOcc[ibe][i]->Fill(m_hHitAMapS[ibe][i]->GetBinContent(j+1)); + } + } //Loop over A side and B side Stacks: for (int i=0; i<64; i++) + } // DoStraws + }//If online environment + + }// for (int ibe=0; ibe<2; ibe++) + + + if (m_environment == AthenaMonManager::online) { + if (DoShift) m_hSummary->SetBinContent(1, nEvents); + } + + ATH_MSG_VERBOSE("Leaving Fill TRT RDO Histograms"); + return StatusCode::SUCCESS; +}//Fill_TRT_RDOs() + + +//Get the TRT Track Collections from store gate +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Retrieve_TRT_Tracks() +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Retrieving TRT Tracks Container from StoreGate"); + if (evtStore()->contains<TrackCollection>(m_tracksObjectName)) { + if (evtStore()->retrieve(m_trkCollection, m_tracksObjectName).isFailure()) { + ATH_MSG_ERROR("Could not find Tracks Collection"); + return StatusCode::FAILURE; + } else { + ATH_MSG_VERBOSE("Tracks retrieved from StoreGate"); + } + } else { + ATH_MSG_WARNING("No TrackCollection by the name of "<<m_tracksObjectName<<" in storegate"); + return StatusCode::FAILURE; + } + + if (evtStore()->contains<ComTime>(m_comTimeObjectName)) { + if (evtStore()->retrieve(theComTime, m_comTimeObjectName).isFailure()) { + ATH_MSG_DEBUG("ComTime object not found with name " << m_comTimeObjectName << "."); + theComTime = 0; // protection for later on + } else { + ATH_MSG_DEBUG("ComTime object found successfully"); + } + } else { + ATH_MSG_DEBUG("No ComTime object found in storegate."); + theComTime = 0; + } + return StatusCode::SUCCESS; +}//Retrieve_TRT_Tracks() + +//Fill the TRT Track level histograms +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Fill_TRT_Tracks() +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Filling TRT Tracks Histos"); + + //Initialize a bunch of stuff before looping over the track collection. Fill some basic histograms. + const float timeCor = theComTime ? theComTime->getTime() : 0; + + DataVector<Trk::Track>::const_iterator p_trk; + + //const Trk::MeasuredPerigee* m_mPer = NULL; + const Trk::Perigee* m_mPer = NULL; + const DataVector<const Trk::TrackParameters>* AllTrkPar(0); + DataVector<const Trk::TrackParameters>::const_iterator p_trkpariter; + + const int sectorflag[2][2] = { + { +1, -1 }, // Barrel A, Barrel C + { +2, -2 } // Endcap A, Endcap C + }; + + //Take out normalization of previous event for online environment + if (m_environment == AthenaMonManager::online) { + for (int ibe=0; ibe<2; ibe++) { //ibe=0(barrel), ibe=1(endcap) + if (DoChips && DoExpert) { + for (int i=0; i<64; i++) { + for (int j=0; j<s_iChip_max[ibe]; j++) { + if (m_hChipsEff[ibe][i]->GetBinEntries(j+1) > 0) { + m_hHitAonTMapC[ibe][i]->SetBinContent(j+1, m_hHitAonTMapC[ibe][i]->GetBinContent(j+1)*m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitWonTMapC[ibe][i]->SetBinContent(j+1, m_hHitWonTMapC[ibe][i]->GetBinContent(j+1)*m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitAWonTMapC[ibe][i]->SetBinContent(j+1, m_hHitAWonTMapC[ibe][i]->GetBinContent(j+1)*m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitHonTMapC[ibe][i]->SetBinContent(j+1, m_hHitHonTMapC[ibe][i]->GetBinContent(j+1)*m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + } + }//for (int j=0; j<s_iChip_max[ibe]; j++) + }//Loop over A side and C side Stacks: for (int i=0; i<64; i++) + }//if DoChips && DoExpert + if (DoStraws) { + for (int i=0; i<64; i++) { + for (int j=0; j<s_Straw_max[ibe]; j++) { + + if (ibe==0) { // barrel + if (i==0 && m_nStrawHits_B[j]>0) { + m_hHitWonTMap_B->SetBinContent(j+1, m_hHitWonTMap_B->GetBinContent(j+1)*(m_nStrawHits_B[j])); + } + } else if (ibe==1) { // endcap + for (int iside=0; iside<2; iside++) { + if (i==0 && m_nStrawHits_E[iside][j]>0) { + m_hHitWonTMap_E[iside]->SetBinContent(j+1,m_hHitWonTMap_E[iside]->GetBinContent(j+1)*(m_nStrawHits_E[iside][j])); + } + } + } + + if (DoExpert) { + if (m_hStrawsEff[ibe][i]->GetBinEntries(j+1)>0) { + m_hHitAWonTMapS[ibe][i]->SetBinContent(j+1, m_hHitAWonTMapS[ibe][i]->GetBinContent(j+1)*m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitAonTMapS[ibe][i]->SetBinContent(j+1, m_hHitAonTMapS[ibe][i]->GetBinContent(j+1)*m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitHonTMapS[ibe][i]->SetBinContent(j+1, m_hHitHonTMapS[ibe][i]->GetBinContent(j+1)*m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitWonTMapS[ibe][i]->SetBinContent(j+1, m_hHitWonTMapS[ibe][i]->GetBinContent(j+1)*m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + } + }//DoExpert + }//for (int j=0; j<s_Straw_max[ibe]; j++) + }//Loop over A side and C side Stacks: for (int i=0; i<64; i++) + }//DoStraws + }//for (int ibe=0; ibe<2; ibe++) + + if (DoShift) { + scale_LWHist(m_hEvtPhase,EventPhaseScale); + scale_LWHist(m_hDriftTimeonTrkDist_B, DriftTimeonTrkDistScale_B); + scale_LWHist(m_hHLhitOnTrack_B, HLhitOnTrackScale_B); + scale_LWHist(m_hHtoLRatioOnTrack_B, HtoLRatioOnTrackScale_B); + scale_LWHist(m_hNumSwLLWoT_B, NumSwLLWoTScale_B); + scale_LWHist(m_hWireToTrkPosition_B, WireToTrkPositionScale_B); + scale_LWHist(m_hTronTDist_B, TronTDistScale_B); + scale_LWHist(m_hResidual_B, ResidualScale_B); + scale_LWHist(m_hTimeResidual_B, TimeResidualScale_B); + if (m_ArgonXenonSplitter) { + scale_LWHist(m_hResidual_B_Ar, ResidualScale_B_Ar); + scale_LWHist(m_hTimeResidual_B_Ar, TimeResidualScale_B_Ar); + } + for (int iside=0; iside<2; iside++) { + scale_LWHist(m_hDriftTimeonTrkDist_E[iside], DriftTimeonTrkDistScale_E[iside]); + scale_LWHist(m_hHLhitOnTrack_E[iside], HLhitOnTrackScale_E[iside]); + scale_LWHist(m_hHtoLRatioOnTrack_E[iside], HtoLRatioOnTrackScale_E[iside]); + scale_LWHist(m_hNumSwLLWoT_E[iside], NumSwLLWoTScale_E[iside]); + scale_LWHist(m_hWireToTrkPosition_E[iside], WireToTrkPositionScale_E[iside]); + scale_LWHist(m_hTronTDist_E[iside], TronTDistScale_E[iside]); + scale_LWHist(m_hResidual_E[iside], ResidualScale_E[iside]); + scale_LWHist(m_hTimeResidual_E[iside], TimeResidualScale_E[iside]); + scale_LWHist(m_hResidual_E_Ar[iside], ResidualScale_E_Ar[iside]); + scale_LWHist(m_hTimeResidual_E_Ar[iside], TimeResidualScale_E_Ar[iside]); + } + } //DoShift + }//if online environment + + int ntrackstack[2][64]; + for (int ibe=0; ibe<2; ibe++) { + std::fill(ntrackstack[ibe], ntrackstack[ibe] + 64, 0); + } + + for (p_trk = m_trkCollection->begin(); p_trk != m_trkCollection->end(); ++p_trk) { + + const std::auto_ptr<const Trk::TrackSummary> summary(m_TrackSummaryTool->createSummary(*(*p_trk))); + int m_nTRTHits = summary->get(Trk::numberOfTRTHits); + if (m_nTRTHits < m_minTRThits) continue; + + AllTrkPar = (*p_trk)->trackParameters(); + + // Search of MeasuredPerigee in TrackParameters + // The following algorithm only finds the First perigee measurement. + // As there should be one and only one perigee measurement then this assumption should be valid. + // But no check is done to see if there is more than one perigee measurement. + for (p_trkpariter = AllTrkPar->begin(); p_trkpariter != AllTrkPar->end(); ++p_trkpariter) { + //if track parameter does have a measured perigee then the track parameter is a keeper and break out of the loop + //if ((m_mPer = dynamic_cast<const Trk::MeasuredPerigee*>(*p_trkpariter))) break; + if ((m_mPer = dynamic_cast<const Trk::Perigee*>(*p_trkpariter))) break; + } + + //if you went through all of the track parameters and found no perigee mearsurement + //then something is wrong with the track and so don't use the track. + //i.e. continue to the next track. + if (!m_mPer) continue; + + // DEPRECATED!! CLHEP::HepVector VectPerig = m_mPer->parameters(); + //AmgVector(5) VectPerig = m_mPer->parameters(); + float m_theta = m_mPer->parameters()[Trk::theta]; + float m_p = (m_mPer->parameters()[Trk::qOverP] != 0.) ? fabs(1./(m_mPer->parameters()[Trk::qOverP])) : 10e7; + float m_pT = (m_p * sin(m_theta)); + m_pT = m_pT/1000.; // GeV + + if (m_p < m_minP) continue; + + const DataVector<const Trk::TrackStateOnSurface>* trackStates = (**p_trk).trackStateOnSurfaces(); + if (trackStates == 0) continue; + + DataVector<const Trk::TrackStateOnSurface>::const_iterator TSOSItBegin0 = trackStates->begin(); + DataVector<const Trk::TrackStateOnSurface>::const_iterator TSOSItBegin = trackStates->begin(); + DataVector<const Trk::TrackStateOnSurface>::const_iterator TSOSItBeginTemp = trackStates->begin(); + DataVector<const Trk::TrackStateOnSurface>::const_iterator TSOSItEnd = trackStates->end(); + + int n_pixel_hits = 0; + int n_sct_hits = 0; + int n_trt_hits = 0; + for (DataVector<const Trk::TrackStateOnSurface>::const_iterator it = trackStates->begin(); it != trackStates->end(); ++it) { + if ((*it)->type(Trk::TrackStateOnSurface::Measurement)) { + if (dynamic_cast<const InDet::TRT_DriftCircleOnTrack*> ((*it)->measurementOnTrack())) n_trt_hits++; + else if (dynamic_cast<const InDet::SCT_ClusterOnTrack*> ((*it)->measurementOnTrack())) n_sct_hits++; + else if (dynamic_cast<const InDet::PixelClusterOnTrack*> ((*it)->measurementOnTrack())) n_pixel_hits++; + } + } + const int n_si_hits = n_pixel_hits + n_sct_hits; + + const bool passed_track_preselection = + (m_mPer->pT() > m_min_pT)&& + (m_p > m_minP) && + (n_si_hits >= m_min_si_hits) && + (n_pixel_hits >= m_min_pixel_hits)&& + (n_sct_hits >= m_min_sct_hits)&& + (n_trt_hits >= m_min_trt_hits); + + if (!passed_track_preselection) continue; + + // Here we fill track efficiency histograms for the offline monitoring. Every other efficiency related histograms should come here. + ATH_MSG_VERBOSE("Filling TRT Eff Histos"); + + const DataVector<const Trk::TrackStateOnSurface>* track_states = (*p_trk)->trackStateOnSurfaces(); + if (track_states) { + ATH_MSG_DEBUG("This track has " << track_states->size() << " track states on surface."); + } else { + ATH_MSG_DEBUG("This track has null track states on surface."); + continue; + } + for (DataVector<const Trk::TrackStateOnSurface>::const_iterator it = track_states->begin(); it != track_states->end(); it++) { + if ((*it)->type(Trk::TrackStateOnSurface::Measurement)) { + const Trk::TrackParameters* track_parameters = (*it)->trackParameters(); + if (track_parameters) { + Identifier id = track_parameters->associatedSurface().associatedDetectorElementIdentifier(); + if (m_pTRTHelper->is_trt(id)) { + // assume always Xe if m_ArgonXenonSplitter is not enabled, otherwise check the straw status (good is Xe, non-good is Ar) + const bool isArgonStraw = m_ArgonXenonSplitter && (m_sumSvc->getStatusHT(id) != TRTCond::StrawStatus::Good); + float locR = track_parameters->parameters()[Trk::driftRadius]; + int m_barrel_ec = m_pTRTHelper->barrel_ec(id); + for (int ibe=0; ibe<2; ibe++) { + if (abs(m_barrel_ec) == sectorflag[ibe][0]) { + if (ibe==0) { + if (isArgonStraw) { + m_hefficiencyBarrel_locR_Off_Ar->Fill(locR, 1.0); // Fill Efficiency cs Track to Wire Distance + } else { + m_hefficiencyBarrel_locR_Off->Fill(locR, 1.0); // Fill Efficiency cs Track to Wire Distance + } + } else if (ibe==1) { + if (m_barrel_ec==sectorflag[ibe][0]) { + if (isArgonStraw) { + m_hefficiencyEndCap_locR_Off_Ar[0]->Fill(locR, 1.0); // Fill Efficiency cs Track to Wire Distance + } else { + m_hefficiencyEndCap_locR_Off[0]->Fill(locR, 1.0); // Fill Efficiency cs Track to Wire Distance + } + }else { + if (isArgonStraw) { + m_hefficiencyEndCap_locR_Off_Ar[1]->Fill(locR, 1.0); // Fill Efficiency cs Track to Wire Distance + } else { + m_hefficiencyEndCap_locR_Off[1]->Fill(locR, 1.0); // Fill Efficiency cs Track to Wire Distance + } + } + } + } // is barrel(or endcap) + } // for (int ibe=0; ibe<2; ibe++) + }// if is trt + }// if track_parameters + }// if measurement + }// loop over track states + + if(m_useHoleFinder){ + const DataVector<const Trk::TrackStateOnSurface>* holes = m_trt_hole_finder->getHolesOnTrack(**p_trk); + if (!holes) { + ATH_MSG_WARNING("TRTTrackHoleSearchTool returned null results."); + continue; + } else { + for (DataVector<const Trk::TrackStateOnSurface>::const_iterator it = holes->begin(); it != holes->end(); ++it) { + if ((*it)->type(Trk::TrackStateOnSurface::Hole)) { + const Trk::TrackParameters* track_parameters = (*it)->trackParameters(); + if (track_parameters) { + Identifier id = track_parameters->associatedSurface().associatedDetectorElementIdentifier(); + if (m_pTRTHelper->is_trt(id)) { + // assume always Xe if m_ArgonXenonSplitter is not enabled, otherwise check the straw status (good is Xe, non-good is Ar) + const bool isArgonStraw = m_ArgonXenonSplitter && (m_sumSvc->getStatusHT(id) != TRTCond::StrawStatus::Good); + float locR = track_parameters->parameters()[Trk::driftRadius]; + int m_barrel_ec = m_pTRTHelper->barrel_ec(id); + for (int ibe=0; ibe<2; ibe++) { + if (abs(m_barrel_ec) == sectorflag[ibe][0]) { + if (ibe==0) { + if (isArgonStraw) { + m_hefficiencyBarrel_locR_Off_Ar->Fill(locR, 0.0); // Fill Efficiency cs Track to Wire Distance + } else { + m_hefficiencyBarrel_locR_Off->Fill(locR, 0.0); // Fill Efficiency cs Track to Wire Distance + } + } else if (ibe==1) { + if (m_barrel_ec==sectorflag[ibe][0]) { + if (isArgonStraw) { + m_hefficiencyEndCap_locR_Off_Ar[0]->Fill(locR, 0.0); // Fill Efficiency cs Track to Wire Distance + } else { + m_hefficiencyEndCap_locR_Off[0]->Fill(locR, 0.0); // Fill Efficiency cs Track to Wire Distance + } + }else { + if (isArgonStraw) { + m_hefficiencyEndCap_locR_Off_Ar[1]->Fill(locR, 0.0); // Fill Efficiency cs Track to Wire Distance + } else { + m_hefficiencyEndCap_locR_Off[1]->Fill(locR, 0.0); // Fill Efficiency cs Track to Wire Distance + } + } + } + } // Barrel (or Endcap) + } // for (int ibe=0; ibe<2; ibe++) + } // if is trt + } // if (track_parameters) + } + } // loop over holes + delete holes; + } // found holes + }//m_useHoleFinder + //Here ends offline efficiency histograms + + m_nTotalTracks++; + + int checkB[2],checkEC[2],checkEC_B[2]; + for (int iside=0; iside<2; iside++) { + checkB[iside]=0; + checkEC[iside]=0; + checkEC_B[iside]=0; + } + + int m_nTRTHitsW[2][2], m_nTRTHLHitsW[2][2], m_nTRTHits_side[2][2]; + //int m_nTRTHitsW_permodule[2][3], m_nTRTHLHitsW_permodule[2][3]; //barrel + int m_nTRTHitsW_perwheel[2][18] ; // endcap + int hitontrack[2]; + int hitontrack_E_side[2]; + + for (int ibe=0; ibe<2; ibe++) { + hitontrack[ibe]=0; + for (int iside=0; iside<2; iside++) { + m_nTRTHits_side[ibe][iside]=-1; + m_nTRTHitsW[ibe][iside]=0; + m_nTRTHLHitsW[ibe][iside]=0; + hitontrack_E_side[iside]=0; + + std::fill(m_nTRTHitsW_perwheel[iside], m_nTRTHitsW_perwheel[iside] + 18, 0); + } + } + + for (int ibe=0; ibe<2; ibe++) { + bool isBarrelOnly = true; + bool ECAhit = false, ECChit = false, Bhit = false; + + int m_barrel_ec = 0; + int m_layer_or_wheel = 0; + int m_phi_module = 0; + int m_straw_layer = 0; + int m_straw = 0; + int m_nearest_straw_layer = 100; + int m_nearest_straw =0; + int testLayer = 100; + float m_phi2D = -100; + int innerstack = -999; + + //find det, phi of track: + // Means loop over all measurements on track to find phi of inner most hit + for (TSOSItBeginTemp = TSOSItBegin0; TSOSItBeginTemp != TSOSItEnd; ++TSOSItBeginTemp) { + if ((*TSOSItBeginTemp) == 0) { + continue; + } else if ((*TSOSItBeginTemp)->type(Trk::TrackStateOnSurface::Measurement)) { + + const InDet::TRT_DriftCircleOnTrack *trtCircle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>((*TSOSItBeginTemp)->measurementOnTrack()); + const Trk::TrackParameters *aTrackParam = dynamic_cast<const Trk::TrackParameters*>((*TSOSItBeginTemp)->trackParameters()); + + if (!trtCircle) continue; + if (!aTrackParam) continue; + + Identifier DCoTId = trtCircle->identify(); + m_barrel_ec = m_pTRTHelper->barrel_ec(DCoTId); + m_layer_or_wheel = m_pTRTHelper->layer_or_wheel(DCoTId); + m_straw_layer = m_pTRTHelper->straw_layer(DCoTId); + m_straw = m_pTRTHelper->straw(DCoTId); + + //restrict ourselves to the inner most TRT layers To get detector phi. + if ((m_layer_or_wheel < testLayer)&&(abs(m_barrel_ec)==sectorflag[ibe][0])) { + testLayer = m_layer_or_wheel; + if (m_straw_layer<m_nearest_straw_layer) { + m_nearest_straw_layer = m_straw_layer; + m_nearest_straw = m_straw; + const InDetDD::TRT_BaseElement* circleElement = NULL; + circleElement = trtCircle->detectorElement(); + m_phi2D = radToDegrees(circleElement->strawCenter(m_nearest_straw).phi()); + circleElement = NULL; + innerstack = m_pTRTHelper->phi_module(DCoTId); + } + } + }//tsos is a measurement + }//loop over tsos + + if (m_phi2D == -999 && (abs(m_barrel_ec)==sectorflag[ibe][0])) { + ATH_MSG_DEBUG("Track did not go through inner layer."); + } else if (abs(m_barrel_ec) == sectorflag[ibe][0]) { + ATH_MSG_VERBOSE("Track's closest approach is m_layer_or_wheel: "<<testLayer<<" m_straw_layer: "<<m_nearest_straw_layer<<"."); + } + + bool trackfound[64]; + std::fill(trackfound, trackfound + 64, false); + + for (int iside=0; iside<2; iside++) { // iside=0(A-side), iside=1(C-side) + for (TSOSItBegin=TSOSItBegin0; TSOSItBegin!=TSOSItEnd; ++TSOSItBegin) { + if ((*TSOSItBegin) == 0) continue; + if ((*TSOSItBegin)->type(Trk::TrackStateOnSurface::Measurement)) { + const InDet::TRT_DriftCircleOnTrack *trtCircle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>((*TSOSItBegin)->measurementOnTrack()); + const Trk::TrackParameters *aTrackParam = dynamic_cast<const Trk::TrackParameters*>((*TSOSItBegin)->trackParameters()); + + if (!trtCircle) continue; + if (!aTrackParam) continue; + + Identifier DCoTId = trtCircle->identify(); + m_barrel_ec = m_pTRTHelper->barrel_ec(DCoTId); + m_layer_or_wheel = m_pTRTHelper->layer_or_wheel(DCoTId); + m_phi_module = m_pTRTHelper->phi_module(DCoTId); + m_straw_layer = m_pTRTHelper->straw_layer(DCoTId); + m_straw = m_pTRTHelper->straw(DCoTId); + + int m_strawNumber; + int m_chip=0; + + int ibe_tmp=-1; + if ((m_pTRTHelper->is_barrel(DCoTId)) + && (m_pTRTHelper->barrel_ec(DCoTId)==-1 + ||m_pTRTHelper->barrel_ec(DCoTId)==1)) { + ibe_tmp=0; + m_strawNumber = strawNumber(m_straw, m_straw_layer, m_layer_or_wheel); + if (m_strawNumber>=0 && m_strawNumber<s_Straw_max[ibe_tmp]) { + m_chip = mat_chip_B[m_phi_module][m_strawNumber]; + } + + } else if ((!(m_pTRTHelper->is_barrel(DCoTId))) + && (m_pTRTHelper->barrel_ec(DCoTId)==-2 + || m_pTRTHelper->barrel_ec(DCoTId)==2)) { + ibe_tmp=1; + m_strawNumber = strawNumberEndCap(m_straw, m_straw_layer, m_layer_or_wheel, m_phi_module, m_barrel_ec); + if (m_strawNumber>=0 && m_strawNumber<s_Straw_max[ibe_tmp]) { + m_chip = mat_chip_E[m_phi_module][m_strawNumber]; + } + + } else { + m_strawNumber = -1; + } + if (ibe_tmp==-1) continue; + if (m_strawNumber<0 || m_strawNumber >= s_Straw_max[ibe_tmp]) continue; + + if (checkB[iside] == 0 && m_barrel_ec == sectorflag[0][iside]) { m_nTracksB[iside]++; checkB[iside] = 1;} + if (checkEC[iside] == 0 && m_barrel_ec == sectorflag[1][iside]) { m_nTracksEC[iside]++; checkEC[iside] = 1;} + if (checkEC_B[iside] == 0 && checkB[iside]==1 && m_barrel_ec == sectorflag[1][iside]) { + m_nTracksEC_B[iside]++; + checkEC_B[iside] = 1; + } + if (ibe==0) { + if (abs(m_pTRTHelper->barrel_ec(DCoTId))!=1) isBarrelOnly = false; + } + if (m_pTRTHelper->barrel_ec(DCoTId) == 2) ECAhit = true; + else if (m_pTRTHelper->barrel_ec(DCoTId) == -2) ECChit = true; + else if (abs(m_pTRTHelper->barrel_ec(DCoTId)) == 1) Bhit = true; + + if ((m_pTRTHelper->barrel_ec(DCoTId)==sectorflag[ibe][iside])) { + Identifier surfaceID; + const Trk::MeasurementBase* mesb=(*TSOSItBegin)->measurementOnTrack(); + + surfaceID = trtCircle->identify(); + + // assume always Xe if m_ArgonXenonSplitter is not enabled, otherwise check the straw status (good is Xe, non-good is Ar) + const bool isArgonStraw = m_ArgonXenonSplitter && (m_sumSvc->getStatusHT(surfaceID) != TRTCond::StrawStatus::Good); + + float temp_locr = aTrackParam->parameters()[Trk::driftRadius]; + TRTCond::RtRelation const *rtr = m_trtcaldbSvc->getRtRelation(surfaceID); + + int iphi_module=-9999; + if (iside==0) iphi_module=m_phi_module; + else if (iside==1) iphi_module=m_phi_module+32; + + trackfound[iphi_module] = true; + + if ((ibe==0&&temp_locr < m_DistToStraw) || (ibe==1&&((*TSOSItBegin)->type(Trk::TrackStateOnSurface::Measurement)||(*TSOSItBegin)->type(Trk::TrackStateOnSurface::Outlier)||(*TSOSItBegin)->type(Trk::TrackStateOnSurface::Hole))&&temp_locr < m_DistToStraw)) { + if (m_idHelper->is_trt(DCoTId)) { + if (m_pTRTHelper->barrel_ec(DCoTId) == sectorflag[ibe][iside]) { + + if (ibe==0) {// barrel + hitontrack[ibe]++; + if (DoStraws && DoShift) m_nStrawHits_B[m_strawNumber]++; + } else if (ibe==1) { //endcap + hitontrack[ibe]++; hitontrack_E_side[iside]++; + if (DoStraws && DoShift) m_nStrawHits_E[iside][m_strawNumber]++; + } + + if (DoStraws && DoExpert) m_hStrawsEff[ibe][iphi_module]->Fill(m_strawNumber,1.0); + if (DoChips && DoExpert) m_hChipsEff[ibe][iphi_module]->Fill((m_chip-1),1.0); + + } + }//if surface is trt + } else { + if (m_idHelper->is_trt(DCoTId)) { + if (m_pTRTHelper->barrel_ec(DCoTId) == sectorflag[ibe][iside]) { + + if (ibe==0) { //barrel + if (DoStraws && DoShift) m_nStrawHits_B[m_strawNumber]++; + } else if (ibe==1) { //endcap + if (DoStraws && DoShift) m_nStrawHits_E[iside][m_strawNumber]++; + } + + if (DoStraws && DoExpert) m_hStrawsEff[ibe][iphi_module]->Fill(m_strawNumber,0.0); + if (DoChips && DoExpert) m_hChipsEff[ibe][iphi_module]->Fill((m_chip-1),0.0); + } + }//is trt surface + }//is not measurement + + const InDet::TRT_DriftCircle *RawDriftCircle = dynamic_cast<const InDet::TRT_DriftCircle*>(trtCircle->prepRawData()); + //const Trk::MeasurementBase* mesb = (*TSOSItBegin)->measurementOnTrack(); + //bool isTubeHit = (mesb->localErrorMatrix().covValue(Trk::locX) > 1.0) ? 1 : 0; + bool isTubeHit = (mesb->localCovariance()(Trk::locX,Trk::locX) > 1.0) ? 1 : 0; + + if (RawDriftCircle) { + if (m_barrel_ec == sectorflag[ibe][iside]) { + m_nTRTHits_side[ibe][iside]++; + } + + float m_timeOverThreshold = RawDriftCircle->timeOverThreshold(); + double t0 = m_trtcaldbSvc->getT0(DCoTId, TRTCond::ExpandedIdentifier::STRAW); + if (DoExpert && DoStraws) m_hHitToTonTMapS[ibe][iphi_module]->Fill(m_strawNumber, m_timeOverThreshold);//Mean ToT (ns) on Track: Straws + if (DoExpert && DoChips) m_hHitToTonTMapC[ibe][iphi_module]->Fill((m_chip-1), m_timeOverThreshold);//Mean ToT (ns) on Track: Chips + + if (RawDriftCircle->highLevel()) { + TRT_LoLumRawData lolum(surfaceID,RawDriftCircle->getWord()); + if (DoExpert && DoStraws) m_hHitHonTMapS[ibe][iphi_module]->Fill(m_strawNumber,1.0);// Any HL hit on track: Straws + if (DoExpert && DoChips) m_hHitHonTMapC[ibe][iphi_module]->Fill(m_chip-1);// Any HL hit on track: Chips + if ((RawDriftCircle->driftTimeBin()<24) && !(RawDriftCircle->lastBinHigh()) && !(RawDriftCircle->firstBinHigh())) { + // if (DoExpert && DoStraws) m_hHitHWonTMapS[iphi_module]->Fill(m_strawNumber, 1.0);// HL in time window on track: Straws + } + + }//is high level hit + + const bool m_driftTimeValid = RawDriftCircle->driftTimeValid(); + if (m_driftTimeValid) { + const float m_validRawDriftTime = RawDriftCircle->rawDriftTime(); + if (DoExpert && DoStraws) m_hValidRawDriftTimeonTrk[ibe][iphi_module]->Fill(m_strawNumber, m_validRawDriftTime); //Valid Raw Drift Time on Track: Straws + if (DoExpert && DoChips) m_hValidRawDriftTimeonTrkC[ibe][iphi_module]->Fill((m_chip-1), m_validRawDriftTime); //Valid Raw Drift Time on Track: Chips + } + + if (DoShift && DoStraws) { + if (ibe==0) m_hDriftTimeonTrkDist_B->Fill(RawDriftCircle->rawDriftTime()); + else if (ibe==1) m_hDriftTimeonTrkDist_E[iside]->Fill(RawDriftCircle->rawDriftTime()); + } + + float locR = aTrackParam->parameters()[Trk::driftRadius]; + float loc = trtCircle->localParameters()[Trk::driftRadius]; + if (isTubeHit) { + bool isOK = false; + loc = m_drifttool->driftRadius(RawDriftCircle->rawDriftTime(), DCoTId, t0, isOK); + if ((loc * locR) < 0) loc = -loc; + } + // Calculate Residuals for hit + if (DoShift && DoStraws) { + const double thist0 = m_trtcaldbSvc->getT0(surfaceID); + const double trkdrifttime = rtr->drifttime(fabs(locR)); + const double timeresidual = RawDriftCircle->rawDriftTime() - thist0 - trkdrifttime; + if (ibe==0) { + if (isArgonStraw) { + m_hResidual_B_Ar->Fill(loc-locR); // Fill residuals for Argon Straws + m_hTimeResidual_B_Ar->Fill(timeresidual); // Fill time residuals for Argon Straws + } else { + m_hResidual_B->Fill(loc-locR); // Fill residuals + m_hTimeResidual_B->Fill(timeresidual); // Fill time residuals + } + } else if (ibe==1) { + if (isArgonStraw) { + m_hResidual_E_Ar[iside]->Fill(loc - locR); // Fill residuals + m_hTimeResidual_E_Ar[iside]->Fill(timeresidual); // Fill time residuals for Argon Straws + } else { + m_hResidual_E[iside]->Fill(loc - locR); // Fill residuals + m_hTimeResidual_E[iside]->Fill(timeresidual); // Fill time residuals for Argon Straws + } + }// ibe==1 + }//DoShift && DoStraws + if (DoShift) { + if (ibe==0) { + m_hWireToTrkPosition_B->Fill(locR); + } else if (ibe==1) { + m_hWireToTrkPosition_E[iside]->Fill(locR); + } + } + + const float LE = (RawDriftCircle->driftTimeBin())*3.125; + const float EP = timeCor; + if (DoShift && DoStraws) { + if (ibe==0) { + if (isArgonStraw) { + if (m_isCosmics) m_hrtRelation_B_Ar->Fill(LE - EP - t0, fabs(locR)); // Fill R(t) Relation for Argon Straws. + else m_hrtRelation_B_Ar->Fill(LE - t0, fabs(locR)); // Fill R(t) Relation for Argon Straws. + } else { + if (m_isCosmics) m_hrtRelation_B->Fill(LE - EP - t0, fabs(locR)); // Fill R(t) Relation. + else m_hrtRelation_B->Fill(LE - t0, fabs(locR)); // Fill R(t) Relation. + } + } else if (ibe==1) { + if (isArgonStraw) { + if (m_isCosmics) m_hrtRelation_E_Ar[iside]->Fill(LE - EP - t0, fabs(locR)); // Fill R(t) Relation for Argon Straws. + else m_hrtRelation_E_Ar[iside]->Fill(LE - t0, fabs(locR)); // Fill R(t) Relation for Argon Straws. + } else { + if (m_isCosmics) m_hrtRelation_E[iside]->Fill(LE - EP - t0, fabs(locR)); // Fill R(t) Relation. + else m_hrtRelation_E[iside]->Fill(LE - t0, fabs(locR)); // Fill R(t) Relation. + } + }//ibe==1 + } + const int m_driftTimeBin = RawDriftCircle->driftTimeBin(); + if ((m_driftTimeBin<24)&& !(RawDriftCircle->lastBinHigh()) && !(RawDriftCircle->firstBinHigh())) { + if (DoStraws) { + if (ibe==0) m_hHitWonTMap_B->Fill(m_strawNumber); + else if (ibe==1) m_hHitWonTMap_E[iside]->Fill(m_strawNumber); + } + if (DoExpert && DoStraws) m_hHitWonTMapS[ibe][iphi_module]->Fill(m_strawNumber,1.0);//LE in time window on track: Straws + if (DoExpert && DoChips) m_hHitWonTMapC[ibe][iphi_module]->Fill(m_chip-1,1.0);//LE in time window on track: Chips + } + const int m_trailingEdge = RawDriftCircle->trailingEdge(); + if ((m_trailingEdge<23) && !(RawDriftCircle->lastBinHigh()) && !(RawDriftCircle->firstBinHigh())) { + if (DoExpert && DoStraws) m_hHitTronTMapS[ibe][iphi_module]->Fill(m_strawNumber, ((m_trailingEdge+1)*3.125));// Mean TE on track: Straws + if (DoExpert && DoChips) m_hHitTronTMapC[ibe][iphi_module]->Fill(m_chip-1,((m_trailingEdge+1)*3.125));// Mean TE on track: Chips + if (DoExpert && DoStraws) m_hHitTronTwEPCMapS[ibe][iphi_module]->Fill(m_strawNumber, (((m_trailingEdge+1)*3.125) - timeCor));// Mean TE on Track (with Event Phase correction): Straws + if (DoExpert && DoChips) m_hHitTronTwEPCMapC[ibe][iphi_module]->Fill((m_chip-1), (((m_trailingEdge+1)*3.125) - timeCor));// Mean TE on Track (with Event Phase correction): Chips + if (DoShift && DoStraws) { + if (RawDriftCircle->driftTimeValid()) { + if (ibe==0) { + m_hTronTDist_B->Fill(((m_trailingEdge+1)*3.125)); + m_hAvgTroTDetPhi_B->Fill(m_phi2D, ((m_trailingEdge+1)*3.125)); + } else if (ibe==1) { + m_hTronTDist_E[iside]->Fill(((m_trailingEdge+1)*3.125)); + m_hAvgTroTDetPhi_E[iside]->Fill(m_phi2D, ((m_trailingEdge+1)*3.125)); + } + } + } + } + + const bool m_firstBinHigh = RawDriftCircle->firstBinHigh(); + const bool m_lastBinHigh = RawDriftCircle->lastBinHigh(); + if (m_firstBinHigh || m_lastBinHigh || m_driftTimeBin>0 || m_trailingEdge<23) { + if (DoExpert && DoStraws) m_hHitAonTMapS[ibe][iphi_module]->Fill(m_strawNumber);// Any LL bit on track: Straws + if (DoExpert && DoChips) m_hHitAonTMapC[ibe][iphi_module]->Fill(m_chip-1);// Any LL bit on track: Chips + m_nTRTHitsW[ibe][iside]++; + //m_nTRTHitsW_permodule[iside][m_layer_or_wheel]++; + m_nTRTHitsW_perwheel[iside][m_layer_or_wheel]++; + if (RawDriftCircle->highLevel()) { + m_nTRTHLHitsW[ibe][iside]++; + //m_nTRTHLHitsW_permodule[iside][m_layer_or_wheel]++; + } + } + + if ((m_driftTimeBin > 0) || (m_trailingEdge < 23)) { + if (DoExpert && DoStraws) m_hHitAWonTMapS[ibe][iphi_module]->Fill(m_strawNumber);//Any LL bit in time window on track: Straws + if (DoExpert && DoChips) m_hHitAWonTMapC[ibe][iphi_module]->Fill(m_chip-1);//Any LL bit in time window on track: Chips + } + + }// if raw drift circle + }// if ((m_pTRTHelper->barrel_ec(DCoTId)==sectorflag[ibe][iside])) + } // else if ((*TSOSItBegin)->type(Trk::TrackStateOnSurface::Measurement)) + } //for (;TSOSItBegin!=TSOSItEnd; ++TSOSItBegin) + }// for (int iside=0;iside<=1;iside++) + + + for (int i = 0; i < 64; i++) if (trackfound[i]) ntrackstack[ibe][i]++; + if (DoShift) { + if (ibe==0) { + if (hitontrack[ibe]>=m_minTRThits) m_hNumHoTDetPhi_B->Fill(m_phi2D, hitontrack[ibe]); + } + if (ibe==1) { + if (hitontrack_E_side[0]>=m_minTRThits) m_hNumHoTDetPhi_E[0]->Fill(m_phi2D,hitontrack_E_side[0]); + if (hitontrack_E_side[1]>=m_minTRThits) m_hNumHoTDetPhi_E[1]->Fill(m_phi2D,hitontrack_E_side[1]); + } + } + if (m_phi2D<0) continue; + + if (DoShift) { + if (ibe==0) { + if (m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]>0) m_hNumTrksDetPhi_B->Fill(m_phi2D); + } else if (ibe==1) { + if (m_nTRTHitsW[ibe][0]>0) m_hNumTrksDetPhi_E[0]->Fill(m_phi2D); + if (m_nTRTHitsW[ibe][1]>0) m_hNumTrksDetPhi_E[1]->Fill(m_phi2D); + } + } + + if (DoShift) { + if (innerstack >= 0 && innerstack < s_iStack_max[ibe]) { + if (ibe==0) { + m_LonTrack_B[innerstack] += (m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]); + if ((m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]) > 0) { + m_HTfraconTrack_B[innerstack] += (float)(m_nTRTHLHitsW[ibe][0]+m_nTRTHLHitsW[ibe][1]) / (m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]); + m_nTrack_B[innerstack] = (m_nTrack_B[innerstack])+1; + } + } else if (ibe==1) { + m_LonTrack_E[innerstack] += (m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]); + if ((m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]) > 0) { + m_HTfraconTrack_E[innerstack] += (float)(m_nTRTHLHitsW[ibe][0]+m_nTRTHLHitsW[ibe][1]) / (m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]); + m_nTrack_E[innerstack] = (m_nTrack_E[innerstack])+1; + } + } + }// if (innerstack >= 0 && innerstack < s_iStack_max[ibe]) + } + + if (DoShift) { + if (ibe==0) { + if (isBarrelOnly) { + if (m_nTRTHitsW[ibe][0]>0) { + if (m_nTRTHitsW[ibe][1]>0) m_hNumSwLLWoT_B->Fill(m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]); + else m_hNumSwLLWoT_B->Fill(m_nTRTHitsW[ibe][0]); + } else if (m_nTRTHitsW[ibe][1]>0) { + m_hNumSwLLWoT_B->Fill(m_nTRTHitsW[ibe][1]); + } + } + if (m_nTRTHLHitsW[ibe][0] > 0) { + if (m_nTRTHLHitsW[ibe][1] > 0) { + m_hHLhitOnTrack_B->Fill(m_nTRTHLHitsW[ibe][0] + m_nTRTHLHitsW[ibe][1]); + } else { + m_hHLhitOnTrack_B->Fill(m_nTRTHLHitsW[ibe][0]); + } + } else if (m_nTRTHLHitsW[ibe][1] > 0) { + m_hHLhitOnTrack_B->Fill(m_nTRTHLHitsW[ibe][1]); + } + + if ((m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]) > 0) { + m_hHtoLRatioOnTrack_B->Fill((float)(m_nTRTHLHitsW[ibe][0]+m_nTRTHLHitsW[ibe][1]) / (m_nTRTHitsW[ibe][0] + m_nTRTHitsW[ibe][1])); + } + + } else if (ibe==1) { + if (m_nTRTHitsW[ibe][0]>0) { + if (m_nTRTHitsW[ibe][1]>0) { + if (ECAhit && !ECChit && !Bhit) m_hNumSwLLWoT_E[0]->Fill(m_nTRTHitsW[ibe][0]); + if (ECChit && !ECAhit && !Bhit) m_hNumSwLLWoT_E[1]->Fill(m_nTRTHitsW[ibe][1]); + }//Number of Straws with LL hits on track + else if (m_nTRTHitsW[ibe][0]>0) { + if (ECAhit && !ECChit && !Bhit) m_hNumSwLLWoT_E[0]->Fill(m_nTRTHitsW[ibe][0]); + }//Number of Straws with LL hits on track + } + else if (m_nTRTHitsW[ibe][1]>0) { + if (ECChit && !ECAhit && !Bhit) m_hNumSwLLWoT_E[1]->Fill(m_nTRTHitsW[ibe][1]); + }//Number of straws with LL hits on track + for (int iside=0; iside<2; iside++) { + if (m_nTRTHLHitsW[ibe][iside]>0) { + m_hHLhitOnTrack_E[iside]->Fill(m_nTRTHLHitsW[ibe][iside]); + } + if ((m_nTRTHitsW[ibe][iside]) > 0) { + m_hHtoLRatioOnTrack_E[iside]->Fill((float)(m_nTRTHLHitsW[ibe][iside])/((m_nTRTHitsW[ibe][iside]))); + } + } + } + }// DoShift + + if (ibe==0) { + if ((m_nTRTHitsW[ibe][0]+m_nTRTHitsW[ibe][1]) > 0) nTrksperLB_B++; + if (theComTime) { + if (DoShift && (m_phi2D > 0) && (std::fabs(timeCor) > 1e-8)) + m_hEvtPhaseDetPhi_B->Fill(m_phi2D, timeCor); + } //the comtime + } else if (ibe==1) { + for (int iside=0; iside<2; iside++) { + if (m_nTRTHitsW[ibe][iside] > 0) nTrksperLB_E[iside]++; + if (theComTime) { + if (m_nTRTHits_side[ibe][iside]>5 && (std::fabs(timeCor) + > 1e-8)) { + if (DoShift) m_hEvtPhaseDetPhi_E[iside]->Fill(m_phi2D, timeCor); + } + } + } + } // else if (ibe==1) + } // for (int ibe=0; ibe<2; ibe++) + }//for (p_trk=m_trkCollection->begin(); p_trk!=m_trkCollection->end(); ++p_trk) + + if (theComTime) { + if (std::fabs(timeCor) > 1e-8) { + if (DoShift) m_hEvtPhase->Fill(timeCor);// Event Phase Correction factor + if (DoShift) { + std::vector<int> trigid; trigid.clear(); // Trigger ID + const DataHandle<EventInfo> evtInfo; + + StatusCode sc = evtStore()->retrieve(evtInfo); + if (sc.isFailure() || !evtInfo) { + ATH_MSG_WARNING("No event info container found in TDS"); + } else { + std::vector<unsigned int> level1TriggerInfo_t = evtInfo->trigger_info()->level1TriggerInfo(); + for (unsigned int j = 16; j < 24 && j < level1TriggerInfo_t.size(); ++j) { + for (unsigned int i = 0; i < 32; ++i) { + if ((level1TriggerInfo_t[j] >> i) & 0x1) trigid.push_back(i + (j % 8) * 32); // Found the ID + } // Loop over bits in the last word + } // Loop from 16-24 bits + + for (unsigned int j = 0; j < trigid.size(); ++j) { + m_hEvtPhaseVsTrig->Fill(timeCor, trigid[j]);// Event Phase vs. Trigger Item + } + } // Got the container out of SG + } // if DoShift + } + } //the comtime + + + for (int ibe=0; ibe<2; ibe++) { + if (m_environment == AthenaMonManager::online && nEvents>0) { + //Loop over stack histograms and normalize to number of events processed. + if (DoChips && DoExpert) { + for (int i=0; i<64; i++) { + divide_LWHist(m_hHitOnTrackVsAllC[ibe][i], m_hHitAonTMapC[ibe][i], m_hHitAMapC[ibe][i]); + + for (int j=0; j<s_iChip_max[ibe]; j++) { + if (m_hChipsEff[ibe][i]->GetBinEntries(j+1) > 0) { + m_hHitAonTMapC[ibe][i]->SetBinContent(j+1, m_hHitAonTMapC[ibe][i]->GetBinContent(j+1)/m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitWonTMapC[ibe][i]->SetBinContent(j+1, m_hHitWonTMapC[ibe][i]->GetBinContent(j+1)/m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitAWonTMapC[ibe][i]->SetBinContent(j+1, m_hHitAWonTMapC[ibe][i]->GetBinContent(j+1)/m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitHonTMapC[ibe][i]->SetBinContent(j+1, m_hHitHonTMapC[ibe][i]->GetBinContent(j+1)/m_hChipsEff[ibe][i]->GetBinEntries(j+1)); + } else { + m_hHitAonTMapC[ibe][i]->SetBinContent(j+1, 0); + m_hHitHonTMapC[ibe][i]->SetBinContent(j+1,0); + m_hHitWonTMapC[ibe][i]->SetBinContent(j+1, 0); + m_hHitAWonTMapC[ibe][i]->SetBinContent(j+1, 0); + } + }// for (int j=0; j<s_iChip_max[ibe]; j++) + divide_LWHist(m_hHtoLMapC[ibe][i], m_hHitHMapC[ibe][i], m_hHitAMapC[ibe][i]); + divide_LWHist(m_hHtoLonTMapC[ibe][i], m_hHitHonTMapC[ibe][i], m_hHitAonTMapC[ibe][i]); + }//Loop over A side and C side Stacks: for (int i=0; i<64; i++) + }//if DoChips && DoExpert + if (DoStraws) { + for (int i=0; i<64; i++) { + if (DoExpert) divide_LWHist(m_hHitOnTrackVsAllS[ibe][i], m_hHitAonTMapS[ibe][i], m_hHitAMapS[ibe][i]); + for (int j=0; j<s_Straw_max[ibe]; j++) { + if (i==0) { + if (ibe==0) { + if (m_nStrawHits_B[j]>0) { + m_hHitWonTMap_B->SetBinContent(j+1, m_hHitWonTMap_B->GetBinContent(j+1) / (m_nStrawHits_B[j])); + } + } else if (ibe==1) { + if (m_nStrawHits_E[0][j]>0) + m_hHitWonTMap_E[0]->SetBinContent(j+1,m_hHitWonTMap_E[0]->GetBinContent(j+1)/m_nStrawHits_E[0][j]); + if (m_nStrawHits_E[1][j]>0) + m_hHitWonTMap_E[1]->SetBinContent(j+1,m_hHitWonTMap_E[1]->GetBinContent(j+1)/m_nStrawHits_E[1][j]); + } + } + + if (DoExpert) { + if (m_hStrawsEff[ibe][i]->GetBinEntries(j+1)>0) { + m_hHitAWonTMapS[ibe][i]->SetBinContent(j+1, m_hHitAWonTMapS[ibe][i]->GetBinContent(j+1)/m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitAonTMapS[ibe][i]->SetBinContent(j+1, m_hHitAonTMapS[ibe][i]->GetBinContent(j+1)/m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitHonTMapS[ibe][i]->SetBinContent(j+1, m_hHitHonTMapS[ibe][i]->GetBinContent(j+1)/m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + m_hHitWonTMapS[ibe][i]->SetBinContent(j+1, m_hHitWonTMapS[ibe][i]->GetBinContent(j+1)/m_hStrawsEff[ibe][i]->GetBinEntries(j+1)); + } else { + m_hHitAWonTMapS[ibe][i]->SetBinContent(j+1, 0); + m_hHitAonTMapS[ibe][i]->SetBinContent(j+1, 0); + m_hHitHonTMapS[ibe][i]->SetBinContent(j+1, 0); + m_hHitWonTMapS[ibe][i]->SetBinContent(j+1, 0); + } + }//do expert + }//for (int j=0; j<s_Straw_max[ibe]; j++) + if (DoExpert) { + divide_LWHist(m_hHtoLMapS[ibe][i], m_hHitHMapS[ibe][i], m_hHitAMapS[ibe][i]); + divide_LWHist(m_hHtoLonTMapS[ibe][i], m_hHitHonTMapS[ibe][i], m_hHitAonTMapS[ibe][i]); + }//Do Expert + }//Loop over A side and B side Stacks: for (int i=0; i<64; i++) + }//if DoStraws && DoExpert + //Loops over degrees (probably will get eliminated). + + if (DoShift) { + if (ibe==0) { //barrel + m_hSummary->SetBinContent(2, m_nTotalTracks); + m_hSummary->SetBinContent(3, m_nTracksB[0]); + m_hSummary->SetBinContent(4, m_nTracksB[1]); + m_hSummary->SetBinContent(5, m_nTracksEC[0]); + m_hSummary->SetBinContent(6, m_nTracksEC[1]); + m_hSummary->SetBinContent(7, m_nTracksEC_B[0]); + m_hSummary->SetBinContent(8, m_nTracksEC_B[1]); + + EventPhaseScale = m_hEvtPhase->GetEntries()*3.125; + if (EventPhaseScale > 0) { + scale_LWHist(m_hEvtPhase, 1./EventPhaseScale); + } + DriftTimeonTrkDistScale_B = m_hDriftTimeonTrkDist_B->GetEntries()*3.125; + if (DriftTimeonTrkDistScale_B > 0) { + scale_LWHist(m_hDriftTimeonTrkDist_B, 1./DriftTimeonTrkDistScale_B); + } + HLhitOnTrackScale_B = m_hHLhitOnTrack_B->GetEntries(); + if (HLhitOnTrackScale_B > 0) { + scale_LWHist(m_hHLhitOnTrack_B,1./HLhitOnTrackScale_B); + } + HtoLRatioOnTrackScale_B = m_hHtoLRatioOnTrack_B->GetEntries()*0.02; + if (HtoLRatioOnTrackScale_B > 0) { + scale_LWHist(m_hHtoLRatioOnTrack_B, 1./HtoLRatioOnTrackScale_B); + } + NumSwLLWoTScale_B=m_hNumSwLLWoT_B->GetEntries(); + if (NumSwLLWoTScale_B > 0) { + scale_LWHist(m_hNumSwLLWoT_B, 1./NumSwLLWoTScale_B); + } + WireToTrkPositionScale_B=m_hWireToTrkPosition_B->GetEntries()*0.1; + if (WireToTrkPositionScale_B > 0) { + scale_LWHist(m_hWireToTrkPosition_B,1./WireToTrkPositionScale_B); + } + TronTDistScale_B=m_hTronTDist_B->GetEntries()*3.125; + if (TronTDistScale_B > 0) { + scale_LWHist(m_hTronTDist_B,1./TronTDistScale_B); + } + ResidualScale_B = m_hResidual_B->GetEntries()*0.05; + if (ResidualScale_B > 0) { + scale_LWHist(m_hResidual_B,1./ResidualScale_B); + } + TimeResidualScale_B = m_hTimeResidual_B->GetEntries()*0.2; + if (TimeResidualScale_B > 0) { + scale_LWHist(m_hTimeResidual_B,1./TimeResidualScale_B); + } + + } else if (ibe==1) { //endcap + for (int iside=0; iside<2; iside++) { + DriftTimeonTrkDistScale_E[iside] = m_hDriftTimeonTrkDist_E[iside]->GetEntries()*3.125; + if (DriftTimeonTrkDistScale_E[iside] > 0) { + scale_LWHist(m_hDriftTimeonTrkDist_E[iside], 1./DriftTimeonTrkDistScale_E[iside]); + } + HLhitOnTrackScale_E[iside] = m_hHLhitOnTrack_E[iside]->GetEntries(); + if (HLhitOnTrackScale_E[iside] > 0) { + scale_LWHist(m_hHLhitOnTrack_E[iside],1./HLhitOnTrackScale_E[iside]); + } + HtoLRatioOnTrackScale_E[iside] = m_hHtoLRatioOnTrack_E[iside]->GetEntries()*0.02; + if (HtoLRatioOnTrackScale_E[iside] > 0) { + scale_LWHist(m_hHtoLRatioOnTrack_E[iside], 1./HtoLRatioOnTrackScale_E[iside]); + } + NumSwLLWoTScale_E[iside]=m_hNumSwLLWoT_E[iside]->GetEntries(); + if (NumSwLLWoTScale_E[iside] > 0) { + scale_LWHist(m_hNumSwLLWoT_E[iside], 1./NumSwLLWoTScale_E[iside]); + } + WireToTrkPositionScale_E[iside]=m_hWireToTrkPosition_E[iside]->GetEntries()*0.1; + if (WireToTrkPositionScale_E[iside] > 0) { + scale_LWHist(m_hWireToTrkPosition_E[iside],1./WireToTrkPositionScale_E[iside]); + } + TronTDistScale_E[iside]=m_hTronTDist_E[iside]->GetEntries()*3.125; + if (TronTDistScale_E[iside] > 0) { + scale_LWHist(m_hTronTDist_E[iside],1./TronTDistScale_E[iside]); + } + ResidualScale_E[iside] = m_hResidual_E[iside]->GetEntries()*0.05; + if (ResidualScale_E[iside] > 0) { + scale_LWHist(m_hResidual_E[iside],1./ResidualScale_E[iside]); + } + TimeResidualScale_E[iside] = m_hTimeResidual_E[iside]->GetEntries()*0.2; + if (TimeResidualScale_E[iside] > 0) { + scale_LWHist(m_hTimeResidual_E[iside],1./TimeResidualScale_E[iside]); + } + if (m_ArgonXenonSplitter) { + ResidualScale_E_Ar[iside] = m_hResidual_E_Ar[iside]->GetEntries() * 0.05; + if (ResidualScale_E_Ar[iside] > 0) { + scale_LWHist(m_hResidual_E_Ar[iside], 1. / ResidualScale_E_Ar[iside]); + } + TimeResidualScale_E_Ar[iside] = m_hTimeResidual_E_Ar[iside]->GetEntries() * 0.2; + if (TimeResidualScale_E_Ar[iside] > 0) { + scale_LWHist(m_hTimeResidual_E_Ar[iside],1./TimeResidualScale_E_Ar[iside]); + } + } + } + } + } // DoShift + }//if online environment + }// for (int ibe=0; ibe<2; ibe++) + return StatusCode::SUCCESS; +}//Fill_TRT_Tracks() + +//Fill the TRT Eff histograms +//----------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Fill_TRT_Efficiency() +//----------------------------------------------------------------------------------// +{ + ATH_MSG_VERBOSE("Filling TRT Eff Histos"); + + // retrive tracks + StatusCode sc; + if (evtStore()->contains<TrackCollection>(m_track_collection_hole_finder)) { + sc = evtStore()->retrieve(m_trkCollectionEff, m_track_collection_hole_finder); + if (sc.isFailure()) { + ATH_MSG_ERROR("Could not find Tracks Collection"); + return StatusCode::FAILURE; + } else { + ATH_MSG_VERBOSE("Tracks retrieved from StoreGate"); + } + }//if contains trackCollection + else { + ATH_MSG_ERROR("Could not find Tracks Collection for eff"); + return StatusCode::FAILURE; + } + + const int sectorflag[2][2] = { + { +1, -1 }, + { +2, -2 } + }; + + int itrack = 0; + for (TrackCollection::const_iterator track = m_trkCollectionEff->begin(); track != m_trkCollectionEff->end(); ++track) { + // online: use all tracks, offline: use only every xth track, skip the rest + if (m_environment != AthenaMonManager::online && (itrack % m_every_xth_track) != 0) continue; + ++itrack; + + // get perigee + const Trk::Perigee* perigee = (*track)->perigeeParameters(); + if (perigee) { + m_track_pt = perigee->pT(); + m_track_eta = perigee->eta(); + m_track_phi = perigee->parameters()[Trk::phi0]; + m_track_d0 = perigee->parameters()[Trk::d0]; + m_track_z0 = perigee->parameters()[Trk::z0]; + + ATH_MSG_DEBUG("This track has perigee parameters:\n" + << " pT = " << m_track_pt / CLHEP::GeV << " GeV" << "\n" + << " eta = " << m_track_eta << "\n" + << " phi0 = " << m_track_phi << "\n" + << " d0 = " << m_track_d0 / CLHEP::mm << "\n" + << " z0 = " << m_track_z0 / CLHEP::mm << "\n" + << " theta = " << perigee->parameters()[Trk::theta] << "\n" + << " qOverP = " << perigee->parameters()[Trk::qOverP]); + } else { + ATH_MSG_DEBUG("This track has null perigeeParameters."); + continue; + } + + const DataVector<const Trk::TrackStateOnSurface>* track_states = (*track)->trackStateOnSurfaces(); + if (track_states) { + ATH_MSG_DEBUG("This track has " << track_states->size() << " track states on surface."); + } else { + ATH_MSG_DEBUG("This track has null track states on surface."); + continue; + } + // count hits + int n_pixel_hits = 0; + int n_sct_hits = 0; + int n_trt_hits = 0; + for (DataVector<const Trk::TrackStateOnSurface>::const_iterator it = track_states->begin(); it != track_states->end(); ++it) { + if ((*it)->type(Trk::TrackStateOnSurface::Measurement)) { + if (dynamic_cast<const InDet::TRT_DriftCircleOnTrack*> ((*it)->measurementOnTrack())) n_trt_hits++; + else if (dynamic_cast<const InDet::SCT_ClusterOnTrack*> ((*it)->measurementOnTrack())) n_sct_hits++; + else if (dynamic_cast<const InDet::PixelClusterOnTrack*> ((*it)->measurementOnTrack())) n_pixel_hits++; + } + } + + // preselect tracks + + float m_p = 1.0e+08; + if (perigee) { + m_p = (perigee->parameters()[Trk::qOverP]!=0.)? + fabs(1./(perigee->parameters()[Trk::qOverP])) : 1.0e+08; + } + + const bool passed_track_preselection = + (fabs(perigee->parameters()[Trk::d0]) < m_max_abs_d0)&& + (fabs(perigee->parameters()[Trk::z0]) < m_max_abs_z0)&& + (perigee->pT() > m_min_pT)&& + (m_p > m_minP) && + (fabs(perigee->eta()) < m_max_abs_eta)&& + (n_pixel_hits >= m_min_pixel_hits)&& + (n_sct_hits >= m_min_sct_hits)&& + (n_trt_hits >= m_min_trt_hits); + + ATH_MSG_DEBUG("track has ntrt = " << n_trt_hits << " and nsct = " << n_sct_hits << " and npix = " << n_pixel_hits); + if (!passed_track_preselection) { + ATH_MSG_DEBUG("This track failed preselection."); + continue; + } + ATH_MSG_DEBUG("This track passed preselection."); + for (DataVector<const Trk::TrackStateOnSurface>::const_iterator it = track_states->begin(); it != track_states->end(); it++) { + if ((*it)->type(Trk::TrackStateOnSurface::Measurement)) { + const Trk::TrackParameters* track_parameters = (*it)->trackParameters(); + if (track_parameters) { + Identifier id = track_parameters->associatedSurface().associatedDetectorElementIdentifier(); + if (m_pTRTHelper->is_trt(id)) { + float locR = track_parameters->parameters()[Trk::driftRadius]; + int m_barrel_ec = m_pTRTHelper->barrel_ec(id); + int m_layer_or_wheel = m_pTRTHelper->layer_or_wheel(id); + int m_phi_module = m_pTRTHelper->phi_module(id); + int m_straw_layer = m_pTRTHelper->straw_layer(id); + int m_straw = m_pTRTHelper->straw(id); + + for (int ibe=0; ibe<2; ibe++) { + if (abs(m_barrel_ec) == sectorflag[ibe][0]) { + if (ibe==0) { + m_hefficiencyBarrel_locR->Fill(locR, 1.0); + } else if (ibe==1) { + if (m_barrel_ec==sectorflag[ibe][0]) m_hefficiencyEndCap_locR[0]->Fill(locR, 1.0); + else m_hefficiencyEndCap_locR[1]->Fill(locR, 1.0); + } + if (fabs(locR) < 1.3) { + int m_strawNumber = 0, m_chip = 0; + if (ibe==0) { + m_strawNumber = strawNumber(m_straw, m_straw_layer, m_layer_or_wheel); + if (m_strawNumber>=0 && m_strawNumber<s_Straw_max[ibe]) m_chip = mat_chip_B[m_phi_module][m_strawNumber]; + } else if (ibe==1) { + m_strawNumber = strawNumberEndCap(m_straw, m_straw_layer, m_layer_or_wheel, m_phi_module, m_barrel_ec); + if (m_strawNumber>=0 && m_strawNumber<s_Straw_max[ibe]) m_chip = mat_chip_E[m_phi_module][m_strawNumber]; + } + + m_hefficiencyMap[ibe]->Fill(m_strawNumber, 1.0); + + if (DoExpert) { + if (m_barrel_ec == sectorflag[ibe][0]) { + m_hefficiencyS[ibe][m_phi_module]->Fill(m_strawNumber, 1.0); + m_hefficiencyC[ibe][m_phi_module]->Fill(m_chip, 1.0); + } else { + m_hefficiencyS[ibe][m_phi_module+32]->Fill(m_strawNumber, 1.0); + m_hefficiencyC[ibe][m_phi_module+32]->Fill(m_chip, 1.0); + } + } // Do Expert + m_hefficiency_eta->Fill(m_track_eta, 1.0); + m_hefficiency_phi->Fill(m_track_phi, 1.0); + m_hefficiency_pt->Fill(m_track_pt / CLHEP::GeV, 1.0); + m_hefficiency_z0->Fill(m_track_z0, 1.0); + } //locR < 1.3 + } // is barrel(or endcap) + } // for (int ibe=0; ibe<2; ibe++) + }// if is trt + }// if track_parameters + }// if measurement + }// loop over track states + if(m_useHoleFinder){ + const DataVector<const Trk::TrackStateOnSurface>* holes = m_trt_hole_finder->getHolesOnTrack(**track); + + if (!holes) { + ATH_MSG_WARNING("TRTTrackHoleSearchTool returned null results."); + continue; + } else { + for (DataVector<const Trk::TrackStateOnSurface>::const_iterator it = holes->begin(); it != holes->end(); ++it) { + if ((*it)->type(Trk::TrackStateOnSurface::Hole)) { + const Trk::TrackParameters* track_parameters = (*it)->trackParameters(); + if (track_parameters) { + Identifier id = track_parameters->associatedSurface().associatedDetectorElementIdentifier(); + if (m_pTRTHelper->is_trt(id)) { + float locR = track_parameters->parameters()[Trk::driftRadius]; + int m_barrel_ec = m_pTRTHelper->barrel_ec(id); + int m_layer_or_wheel = m_pTRTHelper->layer_or_wheel(id); + int m_phi_module = m_pTRTHelper->phi_module(id); + int m_straw_layer = m_pTRTHelper->straw_layer(id); + int m_straw = m_pTRTHelper->straw(id); + + for (int ibe=0; ibe<2; ibe++) { + if (abs(m_barrel_ec) == sectorflag[ibe][0]) { + if (ibe==0) { + m_hefficiencyBarrel_locR->Fill(locR, 0.0); + } else if (ibe==1) { + if (m_barrel_ec == sectorflag[ibe][0]) m_hefficiencyEndCap_locR[0]->Fill(locR, 0.0); + else m_hefficiencyEndCap_locR[1]->Fill(locR, 0.0); + } + if (fabs(locR) < 1.3) { + int m_strawNumber = 0, m_chip = 0; + if (ibe==0) { + m_strawNumber = strawNumber(m_straw, m_straw_layer, m_layer_or_wheel); + if (m_strawNumber>=0 && m_strawNumber<s_Straw_max[ibe]) m_chip = mat_chip_B[m_phi_module][m_strawNumber]; + } else if (ibe==1) { + m_strawNumber = strawNumberEndCap(m_straw, m_straw_layer, m_layer_or_wheel, m_phi_module, m_barrel_ec); + if (m_strawNumber>=0 && m_strawNumber<s_Straw_max[ibe]) m_chip = mat_chip_E[m_phi_module][m_strawNumber]; + } + + m_hefficiencyMap[ibe]->Fill(m_strawNumber, 0.0); + + if (DoExpert) { + if (m_barrel_ec == sectorflag[ibe][0]) { + m_hefficiencyS[ibe][m_phi_module]->Fill(m_strawNumber, 0.0); + m_hefficiencyC[ibe][m_phi_module]->Fill(m_chip, 0.0); + } else { + m_hefficiencyS[ibe][m_phi_module+32]->Fill(m_strawNumber, 0.0); + m_hefficiencyC[ibe][m_phi_module+32]->Fill(m_chip, 0.0); + } + } // do expert + m_hefficiency_eta->Fill(m_track_eta, 0.0); + m_hefficiency_phi->Fill(m_track_phi, 0.0); + m_hefficiency_pt->Fill(m_track_pt / CLHEP::GeV, 0.0); + m_hefficiency_z0->Fill(m_track_z0, 0.0); + } // loc R < 1.3 + } // Barrel (or Endcap) + } // for (int ibe=0; ibe<2; ibe++) + } // if is trt + } // if (track_parameters) + } + } // loop over holes + delete holes; + } // found holes + }//m_useHoleFinder + } // end loop over tracks + + double n_BorE[2][2]; + double total_BorE[2][2]; + for (int ibe=0; ibe<2; ibe++) { + for (int iside=0; iside<2; iside++) { + + m_hefficiency[ibe][iside]->Reset(); + m_hefficiencyIntegral[ibe][iside]->Reset(); + + for (int i = 0; i < 32; i++) { + for (int ibin = 0; ibin <= s_Straw_max[ibe]; ibin++) { + if (DoExpert) { + if (m_hefficiencyS[ibe][i+(32*iside)]->GetBinEntries(ibin) > m_min_tracks_straw) + m_hefficiency[ibe][iside]->Fill(m_hefficiencyS[ibe][i+(32*iside)]->GetBinContent(ibin)); + } + } // loop ibin barrel + } // loop sectors + + n_BorE[ibe][iside] = m_hefficiency[ibe][iside]->GetEntries(); + total_BorE[ibe][iside] = 0.0; + + for (UInt_t ibin = 0; ibin <= m_hefficiency[ibe][iside]->GetXaxis()->GetNbins(); ibin++) { + total_BorE[ibe][iside] += m_hefficiency[ibe][iside]->GetBinContent(ibin); + m_hefficiencyIntegral[ibe][iside]->SetBinContent(ibin, n_BorE[ibe][iside]!= 0.0 ? total_BorE[ibe][iside]/n_BorE[ibe][iside] : 0.0); + } // loop over ibin + }//for (int iside=0; iside<2; iside++) + }//for (int ibe=0; ibe<2; ibe++) + + return sc; +} + +//-------------------------------------------------------------------------------------------------// +StatusCode TRT_Monitoring_Tool::Check_TRT_Readout_Integrity(const EventInfo* eventInfo) +//-------------------------------------------------------------------------------------------------// +{ + StatusCode sc = StatusCode::SUCCESS; + if (eventInfo) { + ATH_MSG_VERBOSE("Got the event info"); + + EventID* TRTEventID = eventInfo->event_ID(); + if (TRTEventID) { + const unsigned int m_lumiBlock = TRTEventID->lumi_block(); + ATH_MSG_VERBOSE("This is lumiblock : "<<m_lumiBlock); + + good_bcid = TRTEventID->bunch_crossing_id(); + if ((int)m_lumiBlock != lastLumiBlock) { + nLumiBlock++; + lastLumiBlock = m_lumiBlock; + } + + //Get BSConversion Errors from BSConditionsServices: + std::set<std::pair<uint32_t, uint32_t> > *L1IDErrorSet = m_BSSvc->getIdErrorSet(TRTByteStreamErrors::L1IDError); + std::set<std::pair<uint32_t, uint32_t> > *BCIDErrorSet = m_BSSvc->getIdErrorSet(TRTByteStreamErrors::BCIDError); + std::set<uint32_t> *MissingErrorSet = m_BSSvc->getErrorSet(TRTByteStreamErrors::MISSINGError); + std::set<uint32_t> *SidErrorSet = m_BSSvc->getErrorSet(TRTByteStreamErrors::SIDError); + std::set<std::pair<uint32_t, uint32_t> > *RobStatusErrorSet = m_BSSvc->getRodRobErrorSet(TRTByteStreamErrors::RobStatusError); + + const unsigned int rod_id_base[2][2] = { { 0x310000, 0x320000 }, { 0x330000, 0x340000 } }; + const unsigned int nChipsTotal[2][2] = { { 3328, 3328 }, { 7680, 7680 } }; + const unsigned int nRobsTotal[2][2] = { { 32, 32 }, { 64, 64 } }; + + float nBSErrors[2][2] = { { 0, 0 }, { 0, 0 } }; + float nRobErrors[2][2] = { { 0, 0 }, { 0, 0 } }; + + const std::set<std::pair<uint32_t, uint32_t> > *errorset1[2] = { BCIDErrorSet, L1IDErrorSet }; + for (int iset = 0; iset < 2; ++iset) { + for (std::set<std::pair<uint32_t, uint32_t> >::iterator setIt = errorset1[iset]->begin(); setIt != errorset1[iset]->end(); ++setIt) { + for (int ibe = 0; ibe < 2; ++ibe) { + for (int iside = 0; iside < 2; ++iside) { + if (((setIt->first >> 8) & 0xFF0000) == rod_id_base[ibe][iside]) { + nBSErrors[ibe][iside] += 1. / nChipsTotal[ibe][iside]; + } + } + } + } + } + + const std::set<uint32_t> *errorset2[2] = { MissingErrorSet, SidErrorSet }; + for (int iset = 0; iset < 2; ++iset) { + for (std::set<uint32_t>::iterator setIt = errorset2[iset]->begin(); setIt != errorset2[iset]->end(); ++setIt) { + for (int ibe = 0; ibe < 2; ++ibe) { + for (int iside = 0; iside < 2; ++iside) { + if (((*setIt >> 8) & 0xFF0000) == rod_id_base[ibe][iside]) { + nBSErrors[ibe][iside] += 1. / nChipsTotal[ibe][iside]; + } + } + } + } + } + + for (int ibe = 0; ibe < 2; ++ibe) { + for (int iside = 0; iside < 2; ++iside) { + m_hChipBSErrorsVsLB[ibe][iside]->Fill(m_lumiBlock, nBSErrors[ibe][iside]); + m_hChipBSErrorsVsLB[ibe][iside]->SetEntries(m_lumiBlock); // we need this so the LastBinThreshold algorithm can find the last bin + } + } + + for (std::set<std::pair<uint32_t, uint32_t> >::iterator setIt = RobStatusErrorSet->begin(); setIt != RobStatusErrorSet->end(); ++setIt) { + for (int ibe = 0; ibe < 2; ++ibe) { + for (int iside = 0; iside < 2; ++iside) { + if (setIt->first % rod_id_base[ibe][iside] < 0xffff) { + nRobErrors[ibe][iside] += 1. / nRobsTotal[ibe][iside]; + } + } + } + } + + for (int ibe = 0; ibe < 2; ++ibe) { + for (int iside = 0; iside < 2; ++iside) { + m_hRobBSErrorsVsLB[ibe][iside]->Fill(m_lumiBlock, nRobErrors[ibe][iside]); + m_hRobBSErrorsVsLB[ibe][iside]->SetEntries(m_lumiBlock); // we need this so the LastBinThreshold algorithm can find the last bin + } + } + } // TRTEventID + } // eventInfo + + return sc; +}//Check_TRT_Readout_Integrity + +//----------------------------------------------------------------// +int TRT_Monitoring_Tool::strawNumber(int strawNumber, int strawlayerNumber, int LayerNumber) +//-----------------------------------------------------------------// +{ + int addToStrawNumber=0; + int addToStrawNumberNext=0; + int i=0; + const int numberOfStraws[75] = { + 0, + 15, + 16,16,16,16, + 17,17,17,17,17, + 18,18,18,18,18, + 19,19,19, + 18, + 19, + 20,20,20,20,20, + 21,21,21,21,21, + 22,22,22,22,22, + 23,23,23,23,23, + 24,24, + 23,23, + 24,24,24,24, + 25,25,25,25,25, + 26,26,26,26,26, + 27,27,27,27,27, + 28,28,28,28,28, + 29,29,29,29, + 28, + 0 + }; + do { + i++; + addToStrawNumber+=numberOfStraws[i-1]; + addToStrawNumberNext = addToStrawNumber+numberOfStraws[i]; + } while (strawLayerNumber(strawlayerNumber,LayerNumber)!=i-1); + + if (strawLayerNumber(strawlayerNumber,LayerNumber) % 2==-10) { + strawNumber += addToStrawNumber; + } else { + strawNumber = addToStrawNumberNext - strawNumber-1; + } + + if (strawNumber < 0 || strawNumber > 1641) { + ATH_MSG_WARNING("strawNumber = " << strawNumber << " out of range. Will set to 0."); + strawNumber = 0; + } + return strawNumber; + +}//strawNumber() + +//----------------------------------------------------------------// +int TRT_Monitoring_Tool::strawNumberEndCap(int strawNumber, int strawLayerNumber, int LayerNumber, int phi_stack, int side) +//-----------------------------------------------------------------// +{ + + // Before perfoming map, corrections need to be perfomed. + // apply special rotations for endcap mappings + + // for eca, rotate triplets by 180 for stacks 9-16, and 25-32. + static const int TripletOrientation[2][32] = { + {1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0}, + {1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0} + }; + int phi1=-1; + if (side==2) phi1=phi_stack, side=1; + else if (side==-2) phi1=31-phi_stack, side=0; + if (phi1>-1) { + //if (side==1 && TripletOrientation[side][phi1]) { + if (TripletOrientation[side][phi1]) { + + //Change straw number from 0-23 in straw layer to 0-192 + if (strawLayerNumber < 8)strawNumber = strawNumber + 24*strawLayerNumber; + if (strawLayerNumber > 7)strawNumber = strawNumber + 24*(strawLayerNumber -8); + strawNumber = (192-1)*TripletOrientation[side][phi1]+strawNumber*(1-2*TripletOrientation[side][phi1]);//actual rotation + + //take strawNumber back to 0-23 + if (strawLayerNumber<8) strawLayerNumber = int(strawNumber/24); + if (strawLayerNumber>7) strawLayerNumber = int(strawNumber/24) + 8; + strawNumber = strawNumber % 24; + } + //Finish rotation + //Flip straw in layer. + + if (side==0) strawNumber = 23 - strawNumber; + //Finish Flipping + } + + // Done with corrections + //Start mapping from athena identifiers to TRTViewer maps + int strawNumberNew=0; + if (LayerNumber<6 && strawLayerNumber>7) { + strawNumberNew=strawNumberNew+(384*LayerNumber); + strawNumberNew=strawNumberNew+192+(strawLayerNumber % 8)+(strawNumber * 8); + } else if (LayerNumber<6 && strawLayerNumber<8) { + strawNumberNew=strawNumberNew+(384*LayerNumber); + strawNumberNew=strawNumberNew + (strawLayerNumber % 8) + (strawNumber * 8); + } else if (LayerNumber>5 && strawLayerNumber>7) { + strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber - 6); + strawNumberNew = strawNumberNew + 192 + (strawLayerNumber % 8) + (8 * strawNumber); + } else if (LayerNumber>5 && strawLayerNumber<8) { + strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber-6); + strawNumberNew = strawNumberNew + (strawLayerNumber % 8) + (8 * strawNumber); + } + + strawNumber=strawNumberNew; + + if (strawNumber < 0 || strawNumber > 3839) { + ATH_MSG_WARNING("strawNumber = " << strawNumber << " out of range. Will set to 0."); + strawNumber = 0; + } + + return strawNumber; +} + +//----------------------------------------------------------------------// +int TRT_Monitoring_Tool::strawLayerNumber(int strawLayerNumber, int LayerNumber) +//----------------------------------------------------------------------// +{ + switch (LayerNumber) { + case 0: return strawLayerNumber; + case 1: return strawLayerNumber + 19; + case 2: return strawLayerNumber + 43; + default: return strawLayerNumber; + } +} + +//---------------------------------------------------------------- +float TRT_Monitoring_Tool::radToDegrees(float radValue) +//---------------------------------------------------------------- +{ + float degreeValue = radValue / M_PI * 180; + if (degreeValue < 0) degreeValue += 360; + return degreeValue; +} + +//---------------------------------------------------------------- +int TRT_Monitoring_Tool::chipToBoard(int chip) +//---------------------------------------------------------------- +// return logical board index: +// 0 for Board 1S (has 10 chips) 0 - 9 +// 1 for 1L (11) 10 - 20 +// 2 for 2S (15) 21 - 35 +// 3 for 2L, first 9 chips 36 - 44 +// 4 for 2L, second 9 chips 45 - 53 +// 5 for 3S, first 11 54 - 64 +// 6 for 3S, second 12 65 - 76 +// 7 for 3L, first 13 77 - 89 +// 8 for 3L, second 14 90 - 103 + +{ + const int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14}; + int count = 0; + chip--; + + for (int i = 0; i < 9; i++) { + count += list[i]; + if (chip < count) return i + 1; + else if (chip == 104) return 9; + } + assert(count == 104); + assert(false); // should never come this far + return -1; +} + +//---------------------------------------------------------------- +int TRT_Monitoring_Tool::chipToBoard_EndCap(int chip) +//---------------------------------------------------------------- +{ + const int remainder = (chip-1) % 12; + const int Board = int(((chip -1) - remainder) / 12); + return Board+1; +} + +// Code to normalize a LW histogram. For now does it only of TH1F_LW. +// Return whether we could do it (ie integral was non-zero) +void TRT_Monitoring_Tool::scale_LWHist(TH1F_LW* hist, float scale) +{ + if (!hist) return; + const unsigned int entries = hist->GetEntries(); + unsigned int index; + double content, error; + hist->resetActiveBinLoop(); + while (hist->getNextActiveBin(index, content, error)) { + hist->SetBinContentAndError(index, scale * content, scale * error); + } + hist->SetEntries(entries); +} + +// code to divide one histogram by another and save result +// we could add coefficients to this, but we're not going to +// we might also want to check that the bin ranges are the same, but for now +// all we check is that we have the same number of bins! +// Also, for now we don't care (I don't think) about the errors, so don't bother with them... + +void TRT_Monitoring_Tool::divide_LWHist(TH1F_LW* result, TH1F_LW* a, TH1F_LW* b) +{ + if (!result || !a || !b) return; + if (result->GetXaxis()->GetNbins() != a->GetXaxis()->GetNbins() || b->GetXaxis()->GetNbins() != a->GetXaxis()->GetNbins()) return; + + result->Reset(); + + unsigned index; + double contentA, errorA; + double contentB, errorB; + a->resetActiveBinLoop(); + while (a->getNextActiveBin(index, contentA, errorA)) { + b->GetBinContentAndError(index, contentB, errorB); + if (contentB == 0) + result->SetBinContentAndError(index, 0, 0); + else + result->SetBinContentAndError(index, contentA / contentB, 0); + } + result->SetEntries(a->GetEntries()); +} + +//------------------------------------------------------------------------------------- +TH1F_LW *TRT_Monitoring_Tool::bookTH1F_LW(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int nbins, double firstbin, double lastbin, const std::string &xTitle, const std::string &yTitle, StatusCode &scode) +{ + TH1F_LW *hist = TH1F_LW::create(hName.c_str(), hTitle.c_str(), nbins, firstbin, lastbin); + scode = trtRegHist<TH1F_LW>(hist, mongroup, hName.c_str()); + + hist->GetXaxis()->SetLabelSize(0.03); + hist->GetYaxis()->SetLabelSize(0.03); + hist->SetXTitle(xTitle.c_str()); + hist->SetYTitle(yTitle.c_str()); + + return hist; +} + +TH1F *TRT_Monitoring_Tool::bookTH1F(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int nbins, double firstbin, double lastbin, const std::string &xTitle, const std::string &yTitle, StatusCode &scode) +{ + TH1F *hist = new TH1F(hName.c_str(), hTitle.c_str(), nbins, firstbin, lastbin); + scode = trtRegHist<TH1F>(hist, mongroup, hName.c_str()); + + hist->GetXaxis()->SetLabelSize(0.03); + hist->GetYaxis()->SetLabelSize(0.03); + hist->GetXaxis()->SetTitle(xTitle.c_str()); + hist->GetYaxis()->SetTitle(yTitle.c_str()); + + return hist; +} + +TH2F *TRT_Monitoring_Tool::bookTH2F(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int xnbins, double xfirstbin, double xlastbin, int ynbins, double yfirstbin, double ylastbin, const std::string &xTitle, const std::string &yTitle, StatusCode &scode) +{ + TH2F *hist = new TH2F(hName.c_str(), hTitle.c_str(), xnbins, xfirstbin, xlastbin, ynbins, yfirstbin, ylastbin); + scode = trtRegHist<TH2F>(hist, mongroup, hName.c_str()); + + hist->GetXaxis()->SetLabelSize(0.03); + hist->GetYaxis()->SetLabelSize(0.03); + hist->SetXTitle(xTitle.c_str()); + hist->SetYTitle(yTitle.c_str()); + + return hist; +} + +TProfile *TRT_Monitoring_Tool::bookTProfile(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int nbins, double firstbin, double lastbin, double ymin, double ymax, const std::string &xTitle, const std::string &yTitle, StatusCode &scode) +{ + TProfile *hist = new TProfile(hName.c_str(), hTitle.c_str(), nbins, firstbin, lastbin, ymin, ymax); + scode = trtRegHist<TProfile>(hist, mongroup, hName.c_str()); + + hist->SetMarkerSize(0.5); + hist->SetMarkerStyle(2); + hist->SetMarkerColor(2); + hist->GetXaxis()->SetLabelSize(0.03); + hist->GetYaxis()->SetLabelSize(0.03); + hist->GetXaxis()->SetTitle(xTitle.c_str()); + hist->GetYaxis()->SetTitle(yTitle.c_str()); + + return hist; +} + +TProfile_LW *TRT_Monitoring_Tool::bookTProfile_LW(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int nbins, double firstbin, double lastbin, double ymin, double ymax, const std::string &xTitle, const std::string &yTitle, StatusCode &scode) +{ + TProfile_LW *hist = TProfile_LW::create(hName.c_str(), hTitle.c_str(), nbins, firstbin, lastbin, ymin, ymax); + scode = trtRegHist<TProfile_LW>(hist, mongroup, hName.c_str()); + + hist->SetMarkerSize(0.5); + hist->SetMarkerStyle(2); + hist->SetMarkerColor(2); + hist->GetXaxis()->SetLabelSize(0.03); + hist->GetYaxis()->SetLabelSize(0.03); + hist->GetXaxis()->SetTitle(xTitle.c_str()); + hist->GetYaxis()->SetTitle(yTitle.c_str()); + + return hist; +} + +TH2F_LW *TRT_Monitoring_Tool::bookTH2F_LW(MonGroup& mongroup, const std::string &hName, const std::string &hTitle, int xnbins, double xfirstbin, double xlastbin, int ynbins, double yfirstbin, double ylastbin, const std::string &xTitle, const std::string &yTitle, StatusCode &scode) +{ + TH2F_LW *hist = TH2F_LW::create(hName.c_str(), hTitle.c_str(), xnbins, xfirstbin, xlastbin, ynbins, yfirstbin, ylastbin); + scode = trtRegHist<TH2F_LW>(hist, mongroup, hName.c_str()); + + hist->GetXaxis()->SetLabelSize(0.03); + hist->GetYaxis()->SetLabelSize(0.03); + hist->SetXTitle(xTitle.c_str()); + hist->SetYTitle(yTitle.c_str()); + + return hist; +} diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/src/components/TRT_Monitoring_entries.cxx b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/components/TRT_Monitoring_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1ed477874d7af14c2677f194462d7624e668a404 --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/components/TRT_Monitoring_entries.cxx @@ -0,0 +1,16 @@ +#include "TRT_Monitoring/TRT_Monitoring_Tool.h" +#include "TRT_Monitoring/TRT_Hits_Monitoring_Tool.h" +#include "GaudiKernel/DeclareFactoryEntries.h" + +DECLARE_TOOL_FACTORY(TRT_Monitoring_Tool) +#ifdef ONLINE +DECLARE_TOOL_FACTORY(TRT_Hits_Monitoring_Tool) +#endif + +DECLARE_FACTORY_ENTRIES(TRT_Monitoring) +{ + DECLARE_ALGTOOL(TRT_Monitoring_Tool); +#ifdef ONLINE + DECLARE_ALGTOOL(TRT_Hits_Monitoring_Tool); +#endif +} diff --git a/InnerDetector/InDetMonitoring/TRT_Monitoring/src/components/TRT_Monitoring_load.cxx b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/components/TRT_Monitoring_load.cxx new file mode 100644 index 0000000000000000000000000000000000000000..436160ed9a9e8187d3171102692097c5bdbc448d --- /dev/null +++ b/InnerDetector/InDetMonitoring/TRT_Monitoring/src/components/TRT_Monitoring_load.cxx @@ -0,0 +1,3 @@ +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES(TRT_Monitoring)