From 7ccc9b646f7b05b7c80e2a55ce795540fef9c481 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Diaz <alejandro.alonso@cern.ch> Date: Fri, 17 Jan 2014 14:27:10 +0100 Subject: [PATCH] EDM and EIGEN migration for rel 19 (TRT_DetectorPerformance-00-02-00) --- .../TRT_DetectorPerformance/ITRT_StrawMap.h | 80 + .../TRT_DetectorPerformance/TRT_ClockNoise.h | 134 ++ .../TRT_DTMROC_HeaderCheck.h | 117 ++ .../TRT_DetectorPlots.h | 265 +++ .../TRT_DetectorTiming.h | 144 ++ .../TRT_EventPhaseAnalysis.h | 177 ++ .../TRT_DetectorPerformance/TRT_StrawMap.h | 147 ++ .../TRT_DetectorPerformance/cmt/requirements | 65 + .../share/TRT_ClockNoise.py | 20 + .../share/TRT_ClockNoiseResidualPlots.C | 612 ++++++ .../share/TRT_ClockNoiseResidualPlots.h | 222 ++ .../share/TRT_DTMROC_HeaderCheck.py | 19 + .../share/TRT_DetectorPlots.py | 19 + .../share/TRT_DetectorTiming.py | 20 + .../share/TRT_calculateTimingConstants.h | 640 ++++++ .../share/finedelays-avg0-chips.txt | 208 ++ .../share/shortStrawChips.txt | 12 + .../TRT_DetectorPerformance/share/swIndex.txt | 1649 +++++++++++++++ .../src/TRT_ClockNoise.cxx | 653 ++++++ .../src/TRT_DTMROC_HeaderCheck.cxx | 348 +++ .../src/TRT_DetectorPlots.cxx | 1863 +++++++++++++++++ .../src/TRT_DetectorTiming.cxx | 515 +++++ .../src/TRT_EventPhaseAnalysis.cxx | 545 +++++ .../src/TRT_StrawMap.cxx | 352 ++++ .../TRT_DetectorPerformance_entries.cxx | 25 + .../TRT_DetectorPerformance_load.cxx | 2 + .../TRT_DetectorPerformance/src/mapping.txt | 120 ++ 27 files changed, 8973 insertions(+) create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/ITRT_StrawMap.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_ClockNoise.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DTMROC_HeaderCheck.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorPlots.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorTiming.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_EventPhaseAnalysis.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_StrawMap.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/cmt/requirements create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoise.py create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.C create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DTMROC_HeaderCheck.py create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorPlots.py create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorTiming.py create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_calculateTimingConstants.h create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/finedelays-avg0-chips.txt create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/shortStrawChips.txt create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/swIndex.txt create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_ClockNoise.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DTMROC_HeaderCheck.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorPlots.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorTiming.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_EventPhaseAnalysis.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_StrawMap.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_entries.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_load.cxx create mode 100644 InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/mapping.txt diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/ITRT_StrawMap.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/ITRT_StrawMap.h new file mode 100644 index 000000000000..15bfa3b47c20 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/ITRT_StrawMap.h @@ -0,0 +1,80 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// ITRT_StrawMap.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +#ifndef IINDETTRT_STRAWMAP_H +#define IINDETTRT_STRAWMAP_H + +#include "GaudiKernel/IAlgTool.h" + +//#include "Identifier/Identifier.h" +//class Identifier; + + +namespace InDet +{ + + + static const InterfaceID IID_ITRT_StrawMap("InDet::ITRT_StrawMap", 1, 0); + + class ITRT_StrawMap : virtual public IAlgTool { + public: + static const InterfaceID& interfaceID( ) ; + + // enter declaration of your interface-defining member functions here + +// need these??? +// ITRT_StrawMap(const std::string&,const std::string&,const IInterface*); +// virtual ~ITRT_StrawMap (); + +// virtual StatusCode initialize(); +// virtual StatusCode finalize (); + + + + + /** return board number in range 0-28; + 0-8 for barrel (1S, 1L, 2S, 2L1, 2L2, 3S1, 3S2, 3L1, 3L2) + 9-28 for endcap (from smaller |z| to larger |z|) */ +// virtual int board(Identifier id); + /** will return the board number of the last identifier that was set */ +// virtual int board(); + /** return board number based on a straw number */ + // virtual int strawToBoard(int straw); + /** takes as an input chip number that follows 0-343 convention described below */ + // virtual int chipToBoard(int chip); + + /** return chip number in range 0-343; + 0-103 for barrel (same order as in hardware) + 103-343 for endcap (from smaller |z| to larger |z|, always 12 per board, 0-11 order same as in hardware) */ +// virtual int chip(Identifier id); + /** will return the chip number of the last identifier set */ +// virtual int chip(); + /** need side and phi information due to reversed numbering in some endcap phi stacks */ + // virtual int strawToChip(int straw, int side, int phi); + + /** return straw number in range 0-5481; + 0-1641 for barrel (same order as in hardware) + 1642-5481 for endcap (from smaller |z| to larger |z|, same order as in hardware) */ +// virtual int straw(Identifier id); + // virtual int straw(); + + /** set private members appropriately: m_id, m_straw (index), m_reverse */ + // virtual void setNewIdentifier(Identifier id, int *index = 0); + + /** prints out comparison with TRTStrawNeighbour tool (to debug the later) - very long output file! */ +// virtual void compareWithTRTStrawNeighbour(); + + }; + + inline const InterfaceID& InDet::ITRT_StrawMap::interfaceID() + { + return IID_ITRT_StrawMap; + } + +} // end of namespace + +#endif diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_ClockNoise.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_ClockNoise.h new file mode 100644 index 000000000000..820783cf7835 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_ClockNoise.h @@ -0,0 +1,134 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRT_DetectorPerformance_TRT_ClockNoise_H +#define TRT_DetectorPerformance_TRT_ClockNoise_H + +#include <stdlib.h> +#include <string.h> +#include <string> +#include <vector> +#include <fstream> +#include <map> +#include <utility> + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/ServiceHandle.h" + +//#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/DataHandle.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" + +//#include "DataModel/DataVector.h" + + + +namespace InDetDD { + class TRT_DetectorManager; +} +class ITRT_StrawNeighbourSvc; +namespace InDet { + class TRT_StrawMap; +} + +class ITHistSvc; +class TTree; + + + + +// constants for numbers of detector elements, time bins +#define nPhi 32 +#define nSide 2 +#define nStrawB 1642 // number of straws in a barrel stack +#define nStraw 5482 // number of straws in a barrel + endcap stack +#define nBin 24 + +// noise periods +#define PERIOD_40MHZ 8 +#define PERIOD_80MHZ 4 + + +///////////////////////////////////////////////////////////////////////////// + +namespace InDet +{ + + class TRT_ClockNoise : public AthAlgorithm { + + public: + + TRT_ClockNoise (const std::string& name, ISvcLocator* pSvcLocator); + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + + private: + +// const InDetDD::TRT_DetectorManager *m_trtDetMgr; + + ServiceHandle<ITRT_StrawNeighbourSvc> m_trtStrawNeighbourTool; + ToolHandle<InDet::TRT_StrawMap> m_trtStrawMap; + ServiceHandle<ITRT_StrawStatusSummarySvc> m_TRTStrawStatusSummarySvc; + + // flag to write ntuple + bool m_print_ntuple; + + // output text file + std::string m_textfile; + + // ---------------------------------- + // for clock noise cut: + // ---------------------------------- + // minimum number of noise hits + int m_min_noise_hits; + // minimum asymmetry value + float m_min_asym; + // ---------------------------------- + + // methods to look for clock noise + int classify_noise(); + float find_max_asymmetry(int occ[24], int period, int* phase, float* occ_above_thermal); + float find_asymmetry(int occ[24], int period, int phase, float* occ_above_thermal); + + // implement definition of clock noise in this method + int clock_noise_cut(int totalocc, float asym); + + // discrete fourier transform, to pick out the frequency of noise components + int DFT(int occ[24], float* comp0mhz, float* comp40mhz, int* phase40mhz, float* comp80mhz, int* phase80mhz); + + // find the phase of a noise component, from DFT output + int find_dft_phase(float re, float im, int period, int offset); + + // convert (0,1) for (C,A) side back to standard (-2,-1,1,2) + int recover_side(int AorC, int straw); + + // array for storing the occupancy for each straw, by LEbin + // indices are: phi, side (0 for C, 1 for A), straw#, LEbin + int m_straw_bin_occ[nPhi][nSide][nStraw][nBin]; + + // ---- for output tree --------------- + ServiceHandle<ITHistSvc> m_histSvc; + TTree* m_ntuple; + + int m_leadingEdgeBin; + int m_board; + int m_chip; + int m_pad; + int m_side; + int m_phi; + int m_straw; + int m_strawLayer; + int m_layer; + int m_evtNum; + + }; + + +} // end namespace + + +#endif // MY_TRT_TEMPLATE_MY_ALG_H diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DTMROC_HeaderCheck.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DTMROC_HeaderCheck.h new file mode 100644 index 000000000000..b915be69264c --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DTMROC_HeaderCheck.h @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TRT_DTMROC_HeaderCheck.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef INDETTRT_DTMROC_HEADERCHECK_H +#define INDETTRT_DTMROC_HEADERCHECK_H + + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ITHistSvc.h" +#include "TRT_ConditionsServices/ITRT_ByteStream_ConditionsSvc.h" +#include "StoreGate/StoreGateSvc.h" +#include "InDetRawData/InDetTimeCollection.h" +#include "EventInfo/EventInfo.h" +#include "EventInfo/EventID.h" + +#include <string> +#include <map> + +//#include "InDetByteStreamErrors/TRT_BSErrContainer.h" +//#include "InDetByteStreamErrors/TRT_BSIdErrContainer.h" + +#include "TTree.h" +#include "TH2.h" + +class AtlasDetectorID; +class Identifier; +class StoreGateSvc; + + +namespace InDet +{ + + /** @class TRT_DTMROC_HeaderCheck + + Algorithm to pull DTMROC Headers from events for analysis + + @author Jonathan Stahlman <stahlman@cern.ch> + */ + + class TRT_DTMROC_HeaderCheck : public AthAlgorithm + { + public: + + /** Standard Athena-Algorithm Constructor */ + TRT_DTMROC_HeaderCheck(const std::string& name, ISvcLocator* pSvcLocator); + /** Default Destructor */ + ~TRT_DTMROC_HeaderCheck(); + + /** standard Athena-Algorithm method */ + StatusCode initialize(); + /** standard Athena-Algorithm method */ + StatusCode execute(); + /** standard Athena-Algorithm method */ + StatusCode finalize(); + + private: + + bool BCID_Comparison(int rod_bcid, int dtmroc_bcid); + + ServiceHandle<StoreGateSvc> m_sgSvc; + ServiceHandle<ITHistSvc> m_histSvc; + ServiceHandle<ITRT_ByteStream_ConditionsSvc> m_bytestream_conditionsSvc; + const InDetTimeCollection* TRT_BCIDColl; + const InDetTimeCollection* TRT_L1IDColl; + std::map<uint32_t,uint32_t>* dtmroc_map; + + TTree* m_tree; + + int eventCount; + + unsigned int m_event_number; + unsigned int m_time_stamp; + unsigned int m_time_stamp_ns_offset; + + unsigned int m_total_num_l1id; + unsigned int m_total_num_bcid; + unsigned int m_total_num_missing; + unsigned int m_total_num_general; + unsigned int m_total_num_sendid; + + int m_bcid_returned_by_ROD; + int m_l1id_returned_by_ROD; + + std::vector<uint32_t>* m_l1id_dtmroc_index; + std::vector<uint32_t>* m_l1id_dtmroc_index_remap; + std::vector<uint32_t>* m_l1id_rod_index; + std::vector<uint32_t>* m_l1id_returned_l1id; + + std::vector<uint32_t>* m_bcid_dtmroc_index; + std::vector<uint32_t>* m_bcid_dtmroc_index_remap; + std::vector<uint32_t>* m_bcid_rod_index; + std::vector<uint32_t>* m_bcid_returned_bcid; + + std::vector<uint32_t>* m_missing_dtmroc_index; + std::vector<uint32_t>* m_missing_dtmroc_index_remap; + std::vector<uint32_t>* m_missing_rod_index; + + std::vector<uint32_t>* m_general_dtmroc_index; + std::vector<uint32_t>* m_general_dtmroc_index_remap; + std::vector<uint32_t>* m_general_rod_index; + + std::vector<uint32_t>* m_sendid_dtmroc_index; + std::vector<uint32_t>* m_sendid_dtmroc_index_remap; + std::vector<uint32_t>* m_sendid_rod_index; + + }; + + +} // end of namespace + +#endif diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorPlots.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorPlots.h new file mode 100644 index 000000000000..b688c28b1ae2 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorPlots.h @@ -0,0 +1,265 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRT_DetectorPerformance_TRT_DetectorPlots_H +#define TRT_DetectorPerformance_TRT_DetectorPlots_H + +#include <stdlib.h> +#include <string.h> +#include <string> +#include <vector> + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/ServiceHandle.h" + +#include "StoreGate/DataHandle.h" + +#include "DataModel/DataVector.h" + +#include "EventInfo/EventInfo.h" + +#include "Identifier/Identifier.h" +#include "InDetPrepRawData/TRT_DriftCircleContainer.h" +#include "InDetRawData/TRT_RDO_Container.h" + + +namespace InDetDD { + class TRT_DetectorManager; + class SCT_DetectorManager; + class PixelDetectorManager; +} +class TRT_ID; +class SCT_ID; +class PixelID; +class ITRT_CalDbSvc; +class ITRT_StrawNeighbourSvc; +namespace InDet { + class TRT_StrawMap; +} + +namespace Trk { + class Segment; + class Track; +} +class PRD_MultiTruthCollection; + +class ITHistSvc; +class TTree; + + +///////////////////////////////////////////////////////////////////////////// + +namespace InDet +{ + /** + * TRT_DetectorPlots: Algorithm to produce an ntuple containing track, track segment, + * and hit information used in viewing the detector performance + */ + class TRT_DetectorPlots : public AthAlgorithm { + + public: + + TRT_DetectorPlots (const std::string& name, ISvcLocator* pSvcLocator); + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + + protected: + + int m_doMC; + int m_doRDO; + int m_numNoise; + + int m_doSegments; + std::string m_barrelSegmentsName; + std::string m_endcapSegmentsName; + + std::string m_tracksName; + std::string m_fileName; + + private: + + StatusCode load(); // load private members from StoreGate + + + void fillEventAndTrackTrees(const EventInfo *eventInfo); + void fillSegmentTree(); + void fillHitsTree(); + + /* print 8BC time information form pixel hits */ + void pixelRDOhits(int runNumber); + void RDOhits(); + void DriftCircleHits(); + + void makeSegments(); + void MC(); + + ServiceHandle<ITHistSvc> m_histSvc; + TTree* m_treeEvent; + TTree* m_treeTrack; + TTree* m_treeSegment; + TTree* m_treeHits; + TTree* m_treePixel; + + /////////////////////// + /// Track Parameters + /////////////////////// + + int m_eventNumberOfTracks; + int m_eventNumberOfHitsOnTracks[7]; + int m_eventL1Type; + int m_eventL1TagName; + double m_eventTrackInfo[5]; + double m_eventPixelTimeBin; + std::vector<double>* m_eventPixelX; + std::vector<double>* m_eventPixelY; + std::vector<double>* m_eventPixelZ; + std::vector<int>* m_eventPixelHitTimeBin; + std::vector<double>* m_eventSCTX; + std::vector<double>* m_eventSCTY; + std::vector<double>* m_eventSCTZ; + std::vector<int>* m_eventSCTHitTimeBin; + std::vector<double>* m_eventTRTX; + std::vector<double>* m_eventTRTY; + std::vector<double>* m_eventTRTZ; + int m_eventL2Alg[3]; // 1: SiTrack, 2: IdScan, 3: TRTSegFinder + int m_siSP[2]; // N si upper, + + int m_trackRunNumber; + int m_trackEventNumber; + int m_trackTrigL1Type; + int m_trackTrigStreamSize; // number of trigger streams + int m_trackTrig1MU1; // TGC trigger + int m_trackTrig1MU2; // RPC trigger - non-pointing + int m_trackTrig1MU3; // RPC trigger - pointing + int m_trackTrigL1Calo; // Calo trigger + int m_trackTrigNIM0; // Tile trigger + int m_trackTrigNIM4; // ID scintillator trigger + int m_trackTrigMBTS; // min bias trigger + int m_trackTrigEML1Calo; + int m_trackTrigHLTerror; + int m_trackTrigAllTeIDSelected; // LVL 2 trigger + int m_trackTrigAllTePixel; // L2 pixel volume + int m_trackNumTracks; + int m_trackNumTrtTracks; + int m_trackNumSctHits; + int m_trackNumTrtHits; + int m_trackNumTrtHitsBarrelA; + int m_trackNumTrtHitsBarrelC; + int m_trackNumTrtHitsEcA; + int m_trackNumTrtHitsEcC; + int m_trackNdf; + double m_trackChi2; + double m_trackTheta; + double m_trackD0; + double m_trackZ0; + double m_trackPhi0; + double m_trackEventPhase; + + /////////////////////////////////////// + /// Hit parameters for hits on track + /////////////////////////////////////// + std::vector<int>* m_trackSide; + std::vector<int>* m_trackLayerOrWheel; + std::vector<int>* m_trackPhi; // phi module or stack number + std::vector<int>* m_trackStrawLayer; + std::vector<int>* m_trackStraw; + std::vector<int>* m_trackStrawNum; + std::vector<int>* m_trackChip; + std::vector<int>* m_trackBoard; + std::vector<int>* m_trackDriftTimeBin; + std::vector<int>* m_trackTrailingEdge; + std::vector<int>* m_trackHighThreshold; + std::vector<int>* m_trackDriftCircleWord; + std::vector<double>* m_trackX; + std::vector<double>* m_trackY; + std::vector<double>* m_trackZ; + std::vector<double>* m_trackT0; + + std::vector<double>* m_trackTrackR; + std::vector<double>* m_trackLocR; + std::vector<double>* m_trackErrR; + + ////////////////////////////////// + /// Hit parameters for all hits + ////////////////////////////////// + std::vector<int>* m_segmentSide; + std::vector<int>* m_segmentLayerOrWheel; + std::vector<int>* m_segmentPhi; // phi module or stack number + std::vector<int>* m_segmentStrawLayer; + std::vector<int>* m_segmentStraw; + std::vector<int>* m_segmentStrawNum; + std::vector<int>* m_segmentChip; + std::vector<int>* m_segmentBoard; + std::vector<int>* m_segmentDriftTimeBin; + std::vector<int>* m_segmentTrailingEdge; + std::vector<int>* m_segmentDriftCircleWord; + std::vector<int>* m_segmentHitOnTrack; + std::vector<double>* m_segmentX; + std::vector<double>* m_segmentY; + std::vector<double>* m_segmentZ; + std::vector<double>* m_segmentT0; + + ////////////////////////////////// + /// Hit parameters for all hits + ////////////////////////////////// + int m_hitsSide; + int m_hitsLayerOrWheel; + int m_hitsPhi; // phi module or stack number + int m_hitsStrawLayer; + int m_hitsStraw; + int m_hitsStrawNum; + int m_hitsChip; + int m_hitsBoard; + int m_hitsDriftTimeBin; + int m_hitsTrailingEdge; + int m_hitsDriftCircleWord; + int m_hitsHitOnTrack; + double m_hitsX; + double m_hitsY; + double m_hitsZ; + double m_hitsT0; + + ////////////////////////////////// + /// Pixel related + ////////////////////////////////// + + int m_pixelNumberOfPixelHits; + int m_pixelMaxNumberOfTRTBarrelHitsOnTrack; + double m_pixelTRTtrackD0; + double m_pixelTRTtrackPhi0; + double m_pixelTRTtrackEP; + double m_pixelComTime; + std::vector<int>* m_pixelL1TimeBin; + + std::vector<Identifier>* m_onTrackIdentifiers; // used in selecting hits on track + + const InDetDD::TRT_DetectorManager *m_trtDetMgr; + const TRT_ID *m_trtHelper; + const InDetDD::SCT_DetectorManager *m_SCTDetMgr; + const SCT_ID *m_SCTHelper; + const InDetDD::PixelDetectorManager *m_PixelDetMgr; + const PixelID *m_PixelHelper; + + ServiceHandle<ITRT_CalDbSvc> m_trtCondDbTool; + ServiceHandle<ITRT_StrawNeighbourSvc> m_trtStrawNeighbourTool; + ToolHandle<InDet::TRT_StrawMap> m_trtStrawMap; + + const TRT_RDO_Container* m_rdoContainer; + const InDet::TRT_DriftCircleContainer* m_trtDriftCircleContainer; + + const DataVector<Trk::Segment>* m_segmentCollectionBarrel; + const DataVector<Trk::Segment>* m_segmentCollectionEc; + const DataVector<Trk::Track>* m_trkCollection; + const PRD_MultiTruthCollection* m_truthTrt; + + int m_runNumber; + + }; + +} // end namespace + +#endif diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorTiming.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorTiming.h new file mode 100644 index 000000000000..1265b2148c38 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_DetectorTiming.h @@ -0,0 +1,144 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRT_DetectorPerformance_TRT_DetectorTiming_H +#define TRT_DetectorPerformance_TRT_DetectorTiming_H + +#include <stdlib.h> +#include <string.h> +#include <string> +#include <vector> +#include <fstream> +#include <map> +#include <utility> + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/ServiceHandle.h" + +//#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/DataHandle.h" + +//#include "DataModel/DataVector.h" + +#include "Identifier/Identifier.h" +#include "InDetPrepRawData/TRT_DriftCircleContainer.h" +#include "InDetRawData/TRT_RDO_Container.h" + + +namespace InDetDD { + class TRT_DetectorManager; +} +class ITRT_CalDbSvc; +class ITRT_StrawNeighbourSvc; +namespace InDet { + class TRT_StrawMap; +} + + +class ITHistSvc; +class TTree; + + + +///////////////////////////////////////////////////////////////////////////// + +class TRTCalDbTool ; + +namespace InDet +{ + + class TRT_DetectorTiming : public AthAlgorithm { + + public: + + TRT_DetectorTiming (const std::string& name, ISvcLocator* pSvcLocator); + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + + class hitParams; + + private: + +// const InDetDD::TRT_DetectorManager *m_trtDetMgr; + + int m_numTrtOnlyTracks; + int m_numTrtSctTracks; + + ServiceHandle<ITRT_CalDbSvc> m_trtCondDbTool ;//!< TRT Calibration DB tool + ServiceHandle<ITRT_StrawNeighbourSvc> m_trtStrawNeighbourTool; + ToolHandle<InDet::TRT_StrawMap> m_trtStrawMap; + + ServiceHandle<ITHistSvc> m_histSvc; + TTree* m_ntuple; + + double m_correctedLeadingEdge; + double m_timeCor; + double m_timeOverThreshold; + int m_trailingEdgeBin; + int m_leadingEdgeBin; + int m_wrongSide; + int m_board; + double m_locR; + double m_timeCorChip; + int m_chip; + int m_side; + double m_t0; + int m_phi; + int m_straw; + int m_strawLayer; + int m_layer; + int m_nTrtBarHits; + int m_nTrtEcHits; + int m_nTrtHitsBarrelA; + int m_nTrtHitsBarrelC; + int m_nTrtHitsEcA; + int m_nTrtHitsEcC; + int m_nSctHits; + int m_nPixHits; + double m_theta; + double m_eta; + double m_chi2Ndf; + double m_phi0; + double m_z0; + double m_d0; + int m_tubeHit; + double m_locRPat; + + + }; + + // struct to hold all relevant params for a given hit + // -- don't need eventPhase since that is constant for an event + class TRT_DetectorTiming::hitParams { + public: + double x; + double y; + int leadingEdgeBin; + int trailingEdgeBin; + double leadingEdge; + double correctedLeadingEdge; + int side; + int wrongSide; + double timeOverThreshold; + int board; + double locR; + double localPos; + double timeCorChip; + int chip; + double t0; + int phi; + int straw; + int strawLayer; + int layer; + int tubeHit; + double locRPat; + }; + +} // end namespace + + +#endif // MY_TRT_TEMPLATE_MY_ALG_H diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_EventPhaseAnalysis.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_EventPhaseAnalysis.h new file mode 100644 index 000000000000..c61cd3587353 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_EventPhaseAnalysis.h @@ -0,0 +1,177 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TRT_EventPhaseAnalysis.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef INDETTRT_EVENTPHASEANALYSIS_H +#define INDETTRT_EVENTPHASEANALYSIS_H + +// Gaudi includes +//#include "GaudiKernel/Algorithm.h" +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ITHistSvc.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetCosmicsEventPhase/InDetCosmicsEventPhaseTool.h" //~~~brett~~~ +#include "TRT_ConditionsServices/ITRT_CalDbSvc.h" + +#include "InDetTrackSplitterTool/IInDetTrackSplitterTool.h" + +#include <string> + +#include "TTree.h" + +class AtlasDetectorID; +class Identifier; + +namespace InDet +{ + + /** @class TRT_EventPhaseAnalysis + + This is for the Doxygen-Documentation. + Please delete these lines and fill in information about + the Algorithm! + Please precede every member function declaration with a + short Doxygen comment stating the purpose of this function. + + @author Brett Jackson <brett.david.jackson@cern.ch> + */ + + class TRT_EventPhaseAnalysis : public AthAlgorithm + { + public: + + /** Standard Athena-Algorithm Constructor */ + TRT_EventPhaseAnalysis(const std::string& name, ISvcLocator* pSvcLocator); + /** Default Destructor */ + ~TRT_EventPhaseAnalysis(); + + /** standard Athena-Algorithm method */ + StatusCode initialize(); + /** standard Athena-Algorithm method */ + StatusCode beginRun(); + /** standard Athena-Algorithm method */ + StatusCode execute(); + /** standard Athena-Algorithm method */ + StatusCode finalize(); + + private: + + struct trackData + { + Trk::Track* track; + int& nTRTBarrelHits; + int& nTRTEndcapHits; + int& nSCTHits; + int& nPixelHits; + double& EP; + double& EPFromTE; + float& tofFitPar0; + float& tofFitPar1; + float& tofChi2OverNdf; + std::vector<float>* timeDiff; + std::vector<float>* x; + std::vector<float>* y; + std::vector<float>* z; + std::vector<float>* dbT0; + }; + + + StatusCode load(); + + bool analyzeTrack(Trk::Track* track, int& nTRTBarrelHits, int& nTRTEndcapHits, int& nSCTHits, int& nPixelHits, double& EP, double& EPFromTE, + float& tofFitPar0, float& tofFitPar1, float& tofChi2OverNdf, std::vector<float>* timeDiff, + std::vector<float>* x, std::vector<float>* y, std::vector<float>* z, std::vector<float>* dbT0); + + /////////////////////////////////////////// + /// Helpers, tools, and date vectors + /////////////////////////////////////////// + ServiceHandle<ITHistSvc> m_histSvc; + ServiceHandle<ITRT_CalDbSvc> m_trtCondDbTool; + + ToolHandle<IInDetTrackSplitterTool> m_tracksplitter; + ToolHandle<InDet::IInDetCosmicsEventPhaseTool> m_eventPhaseTool; + + const DataVector<Trk::Track>* m_tracksCollection; + const TRT_ID *m_trtHelper; + + TTree* m_tree; + std::string m_tracksName; + + int eventCount; + + ///////////////////////////////////// + /// Variables to be stored in tree + ///////////////////////////////////// + int m_nTrtBarrelHits_trk; + int m_nTrtBarrelHits_top; + int m_nTrtBarrelHits_bot; + + int m_nTrtEndcapHits_trk; + int m_nTrtEndcapHits_top; + int m_nTrtEndcapHits_bot; + + int m_nSctHits_trk; + int m_nSctHits_top; + int m_nSctHits_bot; + + int m_nPixelHits_trk; + int m_nPixelHits_top; + int m_nPixelHits_bot; + + double m_EP_trk; + double m_EP_top; + double m_EP_bot; + + double m_EPFromTE_trk; + double m_EPFromTE_top; + double m_EPFromTE_bot; + + float m_tofFitPar0_trk; + float m_tofFitPar0_top; + float m_tofFitPar0_bot; + + float m_tofFitPar1_trk; + float m_tofFitPar1_top; + float m_tofFitPar1_bot; + + float m_tofChi2OverNdf_trk; + float m_tofChi2OverNdf_top; + float m_tofChi2OverNdf_bot; + + double m_trtPhase; + double m_d0; + double m_z0; + double m_phi; + double m_theta; + + std::vector<float>* m_x_trk; + std::vector<float>* m_x_top; + std::vector<float>* m_x_bot; + + std::vector<float>* m_y_trk; + std::vector<float>* m_y_top; + std::vector<float>* m_y_bot; + + std::vector<float>* m_z_trk; + std::vector<float>* m_z_top; + std::vector<float>* m_z_bot; + + std::vector<float>* m_timeDiff_trk; + std::vector<float>* m_timeDiff_top; + std::vector<float>* m_timeDiff_bot; + + std::vector<float>* m_dbT0_trk; + std::vector<float>* m_dbT0_top; + std::vector<float>* m_dbT0_bot; + + + }; +} // end of namespace + +#endif diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_StrawMap.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_StrawMap.h new file mode 100644 index 000000000000..1fe44e23f373 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/TRT_DetectorPerformance/TRT_StrawMap.h @@ -0,0 +1,147 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TRT_StrawMap.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef INDETTRT_STRAWMAP_H +#define INDETTRT_STRAWMAP_H + +#include "TRT_DetectorPerformance/ITRT_StrawMap.h" +#include "AthenaBaseComps/AthAlgTool.h" + +//#include "GaudiKernel/MsgStream.h" +//#include "GaudiKernel/ToolHandle.h" + +#include "GaudiKernel/ServiceHandle.h" + +/* + +#include "StoreGate/StoreGateSvc.h" + +#include "DataModel/DataVector.h" +#include "Identifier/Identifier.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" + +#include "TRT_ConditionsTools/TRTStrawNeighbourTool.h" +*/ + +#include "Identifier/Identifier.h" + +class TRT_ID; +namespace InDetDD { class TRT_DetectorManager; } +class ITRT_StrawNeighbourSvc; + + +namespace InDet +{ + + /** @class TRT_StrawMap + + This tool provides a numbering scheme that is common to all algorithms + in TRT_DetectorPerformance package. + For any other user, TRTStrawNeighbourTool is a recommended and default option. + Once TRTStrawNeighbour tool is fully debugged and available for the endcap, + this tool can only serve as an interface. + + @author Sasa Fratina <sasa.fratina@cern.ch> + */ + + class TRT_StrawMap : virtual public ITRT_StrawMap, public AthAlgTool + { + public: + + TRT_StrawMap(const std::string&,const std::string&,const IInterface*); + virtual ~TRT_StrawMap (); + + virtual StatusCode initialize(); + virtual StatusCode finalize (); + + /** return board number in range 0-28; + 0-8 for barrel (1S, 1L, 2S, 2L1, 2L2, 3S1, 3S2, 3L1, 3L2) + 9-28 for endcap (from smaller |z| to larger |z|) */ + int board(Identifier id); + /** will return the board number of the last identifier that was set */ + int board(); + /** return board number based on a straw number */ + int strawToBoard(int straw); + /** takes as an input chip number that follows 0-343 convention described below */ + int chipToBoard(int chip); + + /** return chip number in range 0-343; + 0-103 for barrel (same order as in hardware) + 103-343 for endcap (from smaller |z| to larger |z|, always 12 per board, 0-11 order same as in hardware) */ + int chip(Identifier id); + /** will return the chip number of the last identifier set */ + int chip(); + /** need side and phi information due to reversed numbering in some endcap phi stacks */ + int strawToChip(int straw, int side, int phi); + + private: + + int strawToChip(int straw, int reversed); + + public: + /** return straw number in range 0-5481; + 0-1641 for barrel (same order as in hardware) + 1642-5481 for endcap (from smaller |z| to larger |z|, same order as in hardware) */ + int straw(Identifier id); + int straw(); + + /** set private members appropriately: m_id, m_straw (index), m_reverse */ + void setNewIdentifier(Identifier id, int *index = 0); + + inline int nBarrelStraws() { return m_nBarrelStraws; } + inline int nAllStraws() { return m_nAllStraws; } + inline int nBarrelChips() { return m_nBarrelChips; } + + /** prints out comparison with TRTStrawNeighbour tool (to debug the later) - very long output file! */ + void compareWithTRTStrawNeighbour(); + + static const InterfaceID& interfaceID(){ + static const InterfaceID id("TRT_StrawMap",1,0); + return id; + } + + virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvIf ){ + if ( riid == interfaceID() ) { + *ppvIf = this; + addRef(); + return StatusCode::SUCCESS; + } + return AthAlgTool::queryInterface( riid, ppvIf ); + } + + + private: + + const InDetDD::TRT_DetectorManager *m_TRTDetMgr; + const TRT_ID *m_TRTHelper; + + Identifier m_id; + int m_straw; + int m_reverse; // needed for phi sectors 0-7 and 16-23 that have reversed chip order in the endcap + + int m_strawToPadMap[5482]; // 5482: number of all straws in one phi stack, one side + + int m_nBarrelStraws;// = 1642; + int m_nAllStraws;// = 5482; + int m_nBarrelChips;// = 104; + + /** member variables for algorithm properties: */ + // int/double/bool m_propertyName; + + ServiceHandle<ITRT_StrawNeighbourSvc> m_TRTStrawNeighbourTool; + + }; + + // int TRT_StrawMap::s_nBarrelStraws = 1642; + // int TRT_StrawMap::s_nAllStraws = 5482; + // int TRT_StrawMap::s_nBarrelChips = 104; + +} // end of namespace + +#endif diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/cmt/requirements b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/cmt/requirements new file mode 100644 index 000000000000..1703f4d6c59e --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/cmt/requirements @@ -0,0 +1,65 @@ +package TRT_DetectorPerformance + +author Sasa Fratina <Sasa.Fratina@cern.ch> +author Brett Jackson <Brett.Jackson@cern.ch> +author Dominick Olivito <Dominick.Olivito@cern.ch> + +public + +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External +use AtlasROOT AtlasROOT-* External + +use Identifier Identifier-* DetectorDescription + +use AthenaBaseComps AthenaBaseComps-* Control +use StoreGate StoreGate-* Control +use DataModel DataModel-* Control + +use InDetPrepRawData InDetPrepRawData-* InnerDetector/InDetRecEvent +use InDetRawData InDetRawData-* InnerDetector/InDetRawEvent +use TRT_ConditionsServices TRT_ConditionsServices-* InnerDetector/InDetConditions + +use EventInfo EventInfo-* Event +use InDetCosmicsEventPhase InDetCosmicsEventPhase-* InnerDetector/InDetCosmics +use InDetIdentifier InDetIdentifier-* InnerDetector/InDetDetDescr +use InDetTrackSplitterTool InDetTrackSplitterTool-* InnerDetector/InDetValidation + +private + + +use AtlasHepMC AtlasHepMC-* External + +use PathResolver PathResolver-* Tools + +use InDetReadoutGeometry InDetReadoutGeometry-* InnerDetector/InDetDetDescr + +use InDetRIO_OnTrack InDetRIO_OnTrack-* InnerDetector/InDetRecEvent +use InDetSimData InDetSimData-* InnerDetector/InDetRawEvent +use TRT_ConditionsData TRT_ConditionsData-* InnerDetector/InDetConditions +use InDetRecToolInterfaces InDetRecToolInterfaces-* InnerDetector/InDetRecTools +use TRT_TrackSegmentsFinder TRT_TrackSegmentsFinder-* InnerDetector/InDetRecAlgs + + +use TrkParameters TrkParameters-* Tracking/TrkEvent +use TrkTrackSummary TrkTrackSummary-* Tracking/TrkEvent +use TrkTrack TrkTrack-* Tracking/TrkEvent +use TrkTruthData TrkTruthData-* Tracking/TrkEvent +use TrkEventPrimitives TrkEventPrimitives-* Tracking/TrkEvent +use TrkSegment TrkSegment-* Tracking/TrkEvent + +use CommissionEvent CommissionEvent-* Commission + +use TrigConfL1Data TrigConfL1Data-* Trigger/TrigConfiguration +use TrigConfHLTData TrigConfHLTData-* Trigger/TrigConfiguration +use TrigInterfaces TrigInterfaces-* Trigger/TrigSteer +use TrigSteering TrigSteering-* Trigger/TrigSteer +use TrigSteeringEvent TrigSteeringEvent-* Trigger/TrigEvent +use TrigInDetEvent TrigInDetEvent-* Trigger/TrigEvent + + +public + +apply_pattern component_library +library TRT_DetectorPerformance *.cxx components/*.cxx +apply_pattern declare_joboptions files="*.py" diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoise.py b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoise.py new file mode 100644 index 000000000000..301c8aee013b --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoise.py @@ -0,0 +1,20 @@ +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +# Full job is a list of algorithms +from AthenaCommon.AlgSequence import AlgSequence +job = AlgSequence() +print job +# Add top algorithms to be run +from TRT_DetectorPerformance.TRT_DetectorPerformanceConf import InDet__TRT_ClockNoise +job += InDet__TRT_ClockNoise( "TRT_ClockNoise" ) # 1 alg +#-------------------------------------------------------------- +# Set output level threshold (DEBUG, INFO, WARNING, ERROR, FATAL) +#-------------------------------------------------------------- +job.TRT_ClockNoise.OutputLevel = INFO +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +# Number of events to be processed (default is 10) +#theApp.EvtMax = 10 +#============================================================== diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.C b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.C new file mode 100644 index 000000000000..9c6698cfabab --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.C @@ -0,0 +1,612 @@ +#define TRT_ClockNoiseResidualPlots_cxx +#include "TRT_ClockNoiseResidualPlots.h" + +// ------------------------------------------------------------------------------------------------------------------ +// ------------------------------- TRT_ClockNoiseResidualPlots.C ---------------------------------------------------- +// ------------------------------------------------------------------------------------------------------------------ +// - this is a macro for making plots of clock noise effect on residual distributions +// - it takes a list of clock noisy straws, and groups them based on the phase of the noise +// - then it makes the residual distributions for all hits on these straws, binned by Leading Edge bin +// - it compares the mean and sigma of these to the average overall residual distribution mean and sigma +// +// - the inputs to the macro are: +// - an ntuple with hit timing information for hits on track, output from the athena alg TRT_DetectorTiming +// - a text file with noisy straw info (one of two formats) +// - the simpler format is the output of the athena alg TRT_ClockNoise and contains a list of noisy straws +// - the more advanced version contains several noise parameters for all straws, and is the output of private code +// - these can be specified by hardcoding them into the .h file (s_noisetextfile and s_default), or when running in root +// +// - Usage: Compile in a ROOT session and run: +// Root > .L TRT_ClockNoiseResidualPlots.C+ +// Root > TRT_ClockNoiseResidualPlots t("ntuple.root","noisystrawlist.dat") +// Root > t.Loop(); // Loop on all entries +// +// - based on a ROOT MakeClass() macro +// - author: Dominick Olivito <olivito@cern.ch> +// ------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------ + + +// ******************************************************************** +TRT_ClockNoiseResidualPlots::TRT_ClockNoiseResidualPlots(TString s_file,TString s_textfile) +{ + s_noisetextfile = s_textfile; + + TTree* tree = 0; +// if parameter tree is not specified (or zero), connect the file +// used to generate this class and read the Tree. + if (tree == 0) { + TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(s_file); + if (!f) { + f = new TFile(s_file); + } + tree = (TTree*)gDirectory->Get("ntuple"); + + } + Init(tree); +} + +// ******************************************************************** +TRT_ClockNoiseResidualPlots::~TRT_ClockNoiseResidualPlots() +{ + if (!fChain) return; + delete fChain->GetCurrentFile(); +} + +Int_t TRT_ClockNoiseResidualPlots::GetEntry(Long64_t entry) +{ +// Read contents of entry. + if (!fChain) return 0; + return fChain->GetEntry(entry); +} + +// ******************************************************************** +Long64_t TRT_ClockNoiseResidualPlots::LoadTree(Long64_t entry) +{ +// Set the environment to read one entry + if (!fChain) return -5; + Long64_t centry = fChain->LoadTree(entry); + if (centry < 0) return centry; + if (!fChain->InheritsFrom(TChain::Class())) return centry; + TChain *chain = (TChain*)fChain; + if (chain->GetTreeNumber() != fCurrent) { + fCurrent = chain->GetTreeNumber(); + Notify(); + } + return centry; +} + +// ******************************************************************** +void TRT_ClockNoiseResidualPlots::Init(TTree *tree) +{ + // The Init() function is called when the selector needs to initialize + // a new tree or chain. Typically here the branch addresses and branch + // pointers of the tree will be set. + // It is normally not necessary to make changes to the generated + // code, but the routine can be extended by the user if needed. + // Init() will be called many times when running on PROOF + // (once per file to be processed). + + // Set branch addresses and branch pointers + if (!tree) return; + fChain = tree; + fCurrent = -1; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("corLE", &corLE, &b_corLE); + fChain->SetBranchAddress("EP", &EP, &b_EP); + fChain->SetBranchAddress("TOT", &TOT, &b_TOT); + fChain->SetBranchAddress("TEbin", &TEbin, &b_TEbin); + fChain->SetBranchAddress("LEbin", &LEbin, &b_LEbin); + fChain->SetBranchAddress("wrongSide", &wrongSide, &b_wrongSide); + fChain->SetBranchAddress("board", &board, &b_board); + fChain->SetBranchAddress("locR", &locR, &b_locR); + fChain->SetBranchAddress("timeCorChip", &timeCorChip, &b_timeCorChip); + fChain->SetBranchAddress("chip", &chip, &b_chip); + fChain->SetBranchAddress("side", &side, &b_side); + fChain->SetBranchAddress("t0", &t0, &b_t0); + fChain->SetBranchAddress("phi", &phi, &b_phi); + fChain->SetBranchAddress("straw", &straw, &b_straw); + fChain->SetBranchAddress("strawLayer", &strawLayer, &b_strawLayer); + fChain->SetBranchAddress("layer", &layer, &b_layer); + fChain->SetBranchAddress("nBarHits", &nBarHits, &b_nBarHits); + fChain->SetBranchAddress("nEcHits", &nEcHits, &b_nEcHits); + fChain->SetBranchAddress("nTRThits_barrelA", &nTRThits_barrelA, &b_nTRThits_barrelA); + fChain->SetBranchAddress("nTRThits_barrelC", &nTRThits_barrelC, &b_nTRThits_barrelC); + fChain->SetBranchAddress("nTRThits_ecA", &nTRThits_ecA, &b_nTRThits_ecA); + fChain->SetBranchAddress("nTRThits_ecC", &nTRThits_ecC, &b_nTRThits_ecC); + fChain->SetBranchAddress("nSCThits", &nSCThits, &b_nSCThits); + fChain->SetBranchAddress("nPixHits", &nPixHits, &b_nPixHits); + fChain->SetBranchAddress("theta", &theta, &b_theta); + fChain->SetBranchAddress("eta", &eta, &b_eta); + fChain->SetBranchAddress("chi2ndf", &chi2ndf, &b_chi2ndf); + fChain->SetBranchAddress("phi0", &phi0, &b_phi0); + fChain->SetBranchAddress("z0", &z0, &b_z0); + fChain->SetBranchAddress("d0", &d0, &b_d0); + fChain->SetBranchAddress("tubeHit", &tubeHit, &b_tubeHit); + fChain->SetBranchAddress("locRpat", &locRpat, &b_locRpat); + Notify(); +} + +// ******************************************************************** +Bool_t TRT_ClockNoiseResidualPlots::Notify() +{ + // The Notify() function is called when a new file is opened. This + // can be either for a new TTree in a TChain or when when a new TTree + // is started when using PROOF. It is normally not necessary to make changes + // to the generated code, but the routine can be extended by the + // user if needed. The return value is currently not used. + + return kTRUE; +} + +// ******************************************************************** +void TRT_ClockNoiseResidualPlots::Show(Long64_t entry) +{ +// Print contents of entry. +// If entry is not specified, print current entry + if (!fChain) return; + fChain->Show(entry); +} + +// ******************************************************************** +int TRT_ClockNoiseResidualPlots::initialize() { + fout = new TFile(s_outfile,"RECREATE"); + + fill_noise_map(); + book_histograms(); + + cout << "-- initialize(): complete" << endl; + + return 0; +} + +// ******************************************************************** +int TRT_ClockNoiseResidualPlots::book_histograms() { + + ctemp = new TCanvas("c_temp","temp"); + + //style settings for all histograms + gStyle->SetOptStat(1110); // no name + gStyle->SetOptFit(111); // only display fit param values and chi2 + + // ------------------------------------------------------- + // plots for all hits on track + + hres = new TH1F("hres","residuals for all hits on track",rbins,-rmax,rmax); + hres->GetXaxis()->SetTitle("residual [mm]"); + + for (int ibin=0; ibin<24; ibin++) { + hresLEbin[ibin] = new TH1F(Form("hresLEbin[%d]",ibin),Form("residuals for all hits on track with LEbin == %d",ibin),rbins,-rmax,rmax); + hresLEbin[ibin]->GetXaxis()->SetTitle("residual [mm]"); + } + + gresMean = new TGraphErrors(24); + gresMean->SetTitle("residuals mean by time bin, all hits on track"); + gresMean->SetName("gresMean"); + + gresSigma = new TGraphErrors(24); + gresSigma->SetTitle("residuals sigma by time bin, all hits on track"); + gresSigma->SetName("gresSigma"); + + // ------------------------------------------------------- + // plots for hits on straws with 40MHz noise + + for (int iphase=0;iphase<PERIOD_40MHZ;iphase++) { + + hres40mhz[iphase] = new TH1F(Form("hres40mhz[%d]",iphase),Form("residuals for hits on straws with 40MHz noise, phase == %d",iphase),rbins,-rmax,rmax); + hres40mhz[iphase]->GetXaxis()->SetTitle("residual [mm]"); + + for (int ibin=0; ibin<24; ibin++) { + hresLEbin40mhz[iphase][ibin] = new TH1F(Form("hresLEbin40mhz[%d][%d]",iphase,ibin),Form("residuals for hits on straws with 40MHz noise, phase == %d, with LEbin == %d",iphase,ibin),rbins,-rmax,rmax); + hresLEbin40mhz[iphase][ibin]->GetXaxis()->SetTitle("residual [mm]"); + } + + gresMean40mhz[iphase] = new TGraphErrors(24); + gresMean40mhz[iphase]->SetTitle(Form("residuals mean by time bin, hits on straws with 40MHz noise, phase == %d",iphase)); + gresMean40mhz[iphase]->SetName(Form("gresMean40mhz[%d]",iphase)); + + gresSigma40mhz[iphase] = new TGraphErrors(24); + gresSigma40mhz[iphase]->SetTitle(Form("residuals sigma by time bin, hits on straws with 40MHz noise, phase == %d",iphase)); + gresSigma40mhz[iphase]->SetName(Form("gresSigma40mhz[%d]",iphase)); + + // these diff graphs get replaced later, so we need to title them in finalize() + + gdiffMean40mhz[iphase] = new TGraphErrors(24); + gdiffSigma40mhz[iphase] = new TGraphErrors(24); + + gdiffMeanColor40mhz[iphase] = new TMultiGraph(); + gdiffSigmaColor40mhz[iphase] = new TMultiGraph(); + + + } // end 40mhz phase loop + + return 0; +} + +// ******************************************************************** +// do gaussian fits, etc for all relevant histograms here +int TRT_ClockNoiseResidualPlots::fit_all_histos() { + + gaus_fit(hres); + gaus_fit(hresLEbin); + for (int iphase=0;iphase<PERIOD_40MHZ;iphase++) { + gaus_fit(hres40mhz[iphase]); + gaus_fit(hresLEbin40mhz[iphase]); + } + + return 0; +} + +// ******************************************************************** +// be sure to write graphs to the TFile here! +// also need to set labels for graphs here (after they have points in them), for some asinine reason... +int TRT_ClockNoiseResidualPlots::finalize() { + + // ------------------------------------------------------- + // plots for all hits on track + + gresMean->GetXaxis()->SetTitle("LEbin"); + gresMean->GetYaxis()->SetTitle("residual mean [mm]"); + gresMean->Write(); + + gresSigma->GetXaxis()->SetTitle("LEbin"); + gresSigma->GetYaxis()->SetTitle("residual sigma [mm]"); + gresSigma->Write(); + + // ------------------------------------------------------- + // plots for hits on straws with 40MHz noise + + for (int iphase=0;iphase<PERIOD_40MHZ;iphase++) { + gresMean40mhz[iphase]->GetXaxis()->SetTitle("LEbin"); + gresMean40mhz[iphase]->GetYaxis()->SetTitle("residual mean [mm]"); + gresMean40mhz[iphase]->Write(); + + gresSigma40mhz[iphase]->GetXaxis()->SetTitle("LEbin"); + gresSigma40mhz[iphase]->GetYaxis()->SetTitle("residual sigma [mm]"); + gresSigma40mhz[iphase]->Write(); + + // these diff plots were created outside of book_histograms(), + // so give them titles and names here as well + + gdiffMean40mhz[iphase]->SetTitle(Form("residuals mean diff by time bin, hits on straws with 40MHz noise, phase == %d",iphase)); + gdiffMean40mhz[iphase]->SetName(Form("gdiffMean40mhz[%d]",iphase)); + gdiffMean40mhz[iphase]->GetXaxis()->SetTitle("LEbin"); + gdiffMean40mhz[iphase]->GetYaxis()->SetTitle("diff in residual mean [mm]"); + gdiffMean40mhz[iphase]->Write(); + + gdiffSigma40mhz[iphase]->SetTitle(Form("residuals sigma diff by time bin, hits on straws with 40MHz noise, phase == %d",iphase)); + gdiffSigma40mhz[iphase]->SetName(Form("gdiffSigma40mhz[%d]",iphase)); + gdiffSigma40mhz[iphase]->GetXaxis()->SetTitle("LEbin"); + gdiffSigma40mhz[iphase]->GetYaxis()->SetTitle("diff in residual sigma [mm]"); + gdiffSigma40mhz[iphase]->Write(); + + + // for the TMultiGraphs, record the canvas to file instead of the graphs themselves + // not sure if this is necessary or optimal, but it might be. + + cdiffMeanColor40mhz[iphase] = new TCanvas(Form("cdiffMeanColor40mhz[%d]",iphase),Form("colored diff mean for 40MHz, phase %d",iphase)); + cdiffMeanColor40mhz[iphase]->cd(); + gdiffMeanColor40mhz[iphase]->SetTitle(Form("residuals mean diff by time bin, hits on straws with 40MHz noise, phase == %d",iphase)); + gdiffMeanColor40mhz[iphase]->SetName(Form("gdiffMeanColor40mhz[%d]",iphase)); + // need to draw before we can access the axes on a TMultiGraph -- otherwise we segfault!! + gdiffMeanColor40mhz[iphase]->Draw("AP"); + gdiffMeanColor40mhz[iphase]->GetXaxis()->SetTitle("LEbin"); + gdiffMeanColor40mhz[iphase]->GetYaxis()->SetTitle("diff in residual mean [mm]"); + gdiffMeanColor40mhz[iphase]->Draw("AP"); + cdiffMeanColor40mhz[iphase]->Write(); + cdiffMeanColor40mhz[iphase]->Close(); + + cdiffSigmaColor40mhz[iphase] = new TCanvas(Form("cdiffSigmaColor40mhz[%d]",iphase),Form("colored diff sigma for 40MHz, phase %d",iphase)); + cdiffSigmaColor40mhz[iphase]->cd(); + gdiffSigmaColor40mhz[iphase]->SetTitle(Form("residuals sigma diff by time bin, hits on straws with 40MHz noise, phase == %d",iphase)); + gdiffSigmaColor40mhz[iphase]->SetName(Form("gdiffSigmaColor40mhz[%d]",iphase)); + // need to draw before we can access the axes on a TMultiGraph -- otherwise we segfault!! + gdiffSigmaColor40mhz[iphase]->Draw("AP"); + gdiffSigmaColor40mhz[iphase]->GetXaxis()->SetTitle("LEbin"); + gdiffSigmaColor40mhz[iphase]->GetYaxis()->SetTitle("diff in residual sigma [mm]"); + gdiffSigmaColor40mhz[iphase]->Draw("AP"); + cdiffSigmaColor40mhz[iphase]->Write(); + cdiffSigmaColor40mhz[iphase]->Close(); + + } // end 40mhz phase loop + + + // ------------------------------------------------------- + // write everything else to the TFile + fout->Write(); + + ctemp->Close(); + + // if we close the TFile here, all the histograms disappear from memory +// fout->Close(); + + cout << "-- finalize(): complete" << endl + << " histograms written to file " << s_outfile << endl << endl; + + return 0; +} + +// ******************************************************************** +int TRT_ClockNoiseResidualPlots::fill_noise_map() { + + //first initialize the noise map arrays + for (int i=0;i<nPhi;i++) { + for (int j=0; j<2; j++) { + for (int k=0; k<nTotStraw; k++) { + noisy_straw_phase_map[i][j][k] = -1; + noise_info_map[i][j][k] = NULL; + } + } + } + + ifstream in; + in.open(s_noisetextfile); + int lines = 0; + + // read in a list of noisy straws to look at + if (use_noisy_straw_list) { + + int phi,side,straw,frequency,phase,totalocc; + + while(1) { + + in >> phi >> side >> straw >> frequency >> phase >> totalocc; + if (!in.good() || in.eof()) break; + + int AorC = 0; + if (side > 0) AorC = 1; + + if (frequency == 40) + noisy_straw_phase_map[phi][AorC][straw] = phase; + + lines++; + } + + + } else { // read in file with detailed info + + int phi,side,straw,strawLayer,layer,chip,board; + + while(1) { + strawNoiseInfo* s = new strawNoiseInfo(); + + in >> phi >> side >> straw >> strawLayer >> layer >> chip >> board + >> s->noiseType >> s->phase80 >> s->asym80 >> s->phase40 >> s->asym40 + >> s->occbins >> s->totalocc; + if (!in.good() || in.eof()) break; + + int AorC = 0; + if (side > 0) AorC = 1; + + noise_info_map[phi][AorC][straw] = s; + lines++; + } + + } + + // check that the file contained something + if (lines == 0) { + cerr << "!! problem with file " << s_noisetextfile << endl; + assert(lines > 0); + } + + return 0; +} + +// ******************************************************************** +// put quality cuts on hits here +// !!! need some event phase cut +int TRT_ClockNoiseResidualPlots::cut_hit() { + if ((TOT>7) && (TEbin<24) && (LEbin>0) && (LEbin<24) && (tubeHit<1)) + return 1; + + // failed the cut + return -1; +} + + +// ******************************************************************** +// select the noisy straws here +// - if we're using a list of noisy straws, just check that this straw is on the list +// - if we're using detailed info, impose a cut based on occupancy, asymmetry, etc +int TRT_ClockNoiseResidualPlots::cut_noise() { + + int AorC = 0; + if (side > 0) AorC = 1; + + if (use_noisy_straw_list) { // noisy straw list + if (noisy_straw_phase_map[phi][AorC][straw] > -1) + return 1; + } else { // detailed info + + strawNoiseInfo* s = noise_info_map[phi][AorC][straw]; + + if ((s->asym40 > 0.99) && (s->totalocc >= min_occ)) + return 1; + } + + // failed the cut + return -1; +} + +// ******************************************************************** +// fit with a gaussian from -0.5 to 0.5 +// for fitting residual distributions +void TRT_ClockNoiseResidualPlots::gaus_fit(TH1F* h) { + h->Fit("gaus","Q","",-0.5,0.5); + return; +} + +// ******************************************************************** +// overloaded version of gaus_fit for arrays of histograms +void TRT_ClockNoiseResidualPlots::gaus_fit(TH1F* h[24]) { + for (int ibin=0;ibin<24;ibin++) { + gaus_fit(h[ibin]); + } + return; +} + +// ******************************************************************** +// this will graph the residuals as a function of LEbin, given an output graph and a set of residual histos +// !! the histograms need to be fit with Gaussians before calling this function +void TRT_ClockNoiseResidualPlots::graph_residuals_vs_LEbin( TH1F* h[24], TGraphErrors* gMean, TGraphErrors* gSigma ) { + for (int ibin=0; ibin<24; ibin++) { + double mean,err,sigma,sigmaerr; + + // make sure there are at least some entries in the residual histo + if (h[ibin]->GetEntries() >= min_entries) { + TF1* myfunc = h[ibin]->GetFunction("gaus"); + mean = myfunc->GetParameter(1); + sigma = myfunc->GetParameter(2); + sigmaerr = myfunc->GetParError(2); + err = sigma / sqrt(h[ibin]->GetEntries()); + } else { // too few entries: set the mean, sigma, errors to 0 + mean = 0.; + err = 0.; + sigma = 0.; + sigmaerr = 0.; + } + + gMean->SetPoint(ibin,ibin,mean); + gMean->SetPointError(ibin,0.,err); + + gSigma->SetPoint(ibin,ibin,sigma); + gSigma->SetPointError(ibin,0.,sigmaerr); + } + return; +} + +// ******************************************************************** +// subtracts two TGraphErrors: g - gref, and returns the resulting graph +TGraphErrors* TRT_ClockNoiseResidualPlots::subtract_graphs(TGraphErrors* g, TGraphErrors* gref) { + + TGraphErrors* gdiff = new TGraphErrors(24); + + for (int ibin=0; ibin<24; ibin++) { + double xdummy = 0.; + double y = 0.; + double yref = 0.; + double yerr = g->GetErrorY(ibin); + double yreferr = gref->GetErrorY(ibin); + g->GetPoint(ibin,xdummy,y); + gref->GetPoint(ibin,xdummy,yref); + double ynew = y - yref; + double ynewerr = sqrt(yerr*yerr+yreferr*yreferr); + + // if yerr == 0 or yreferr == 0, the point is bogus + // set the values to 0 here as well + if ((yerr == 0.) || (yreferr == 0.)) { + ynew = 0.; + ynewerr = 0.; + } + + gdiff->SetPoint(ibin,ibin,ynew); + gdiff->SetPointError(ibin,0.,ynewerr); + } + + return gdiff; +} + +// ******************************************************************** +// colors the points on a graph to make periodic effects easier to see by eye +// points separated by N*period are the same color +TMultiGraph* TRT_ClockNoiseResidualPlots::graph_with_colors(TGraphErrors* g, int period, int phase) { + + TMultiGraph* mg = new TMultiGraph(); + for (int i=0; i<period; i++) { + int numbins = int(24/period); + TGraphErrors* gPhase = new TGraphErrors(numbins); + for (int j=0; j<numbins; j++) { + int k = j*period + i; + if (k > 23) std::cout << "!! graph_with_colors: bin index k == " << k << std::endl; + double x = 0.; + double y = 0.; + g->GetPoint(k,x,y); + double erry = g->GetErrorY(k); + gPhase->SetPoint(j,x,y); + gPhase->SetPointError(j,0.,erry); + } + gPhase->SetLineColor((period-phase+i)%period+1); + mg->Add(gPhase,"P"); + } + + return mg; +} + +// ******************************************************************** +void TRT_ClockNoiseResidualPlots::Loop(bool noisy_straw_list) +{ + +// This is the loop skeleton where: +// jentry is the global entry number in the chain +// ientry is the entry number in the current Tree +// Note that the argument to GetEntry must be: +// jentry for TChain::GetEntry +// ientry for TTree::GetEntry and TBranch::GetEntry +// + + use_noisy_straw_list = noisy_straw_list; + + if (use_noisy_straw_list) { + cout << "-- will read in noisy straw list from file: " << s_noisetextfile << endl; + } else { + cout << "-- will read in detailed noise info from file: " << s_noisetextfile << endl; + } + + initialize(); + + if (fChain == 0) return; + + Long64_t nentries = fChain->GetEntriesFast(); + + Long64_t nbytes = 0, nb = 0; + for (Long64_t jentry=0; jentry<nentries;jentry++) { + Long64_t ientry = LoadTree(jentry); + if (ientry < 0) break; + nb = fChain->GetEntry(jentry); nbytes += nb; + + // cut on hit/track quality first + if (cut_hit() < 0) continue; + + hres->Fill(locR - locRpat); + hresLEbin[LEbin]->Fill(locR - locRpat); + + // select out only the noise we want + if (cut_noise() < 0) continue; + + int AorC = 0; + if (side > 0) AorC = 1; + + int phase = -1; + + if (use_noisy_straw_list) { + phase = noisy_straw_phase_map[phi][AorC][straw]; + } else { + phase = noise_info_map[phi][AorC][straw]->phase40; + } + + hres40mhz[phase]->Fill(locR - locRpat); + hresLEbin40mhz[phase][LEbin]->Fill(locR - locRpat); + } // loop over ntuple + + cout << "-- Loop(): finished loop over ntuple" << endl; + + fit_all_histos(); + graph_residuals_vs_LEbin(hresLEbin,gresMean,gresSigma); + + for (int iphase = 0;iphase<PERIOD_40MHZ;iphase++) { + + graph_residuals_vs_LEbin(hresLEbin40mhz[iphase],gresMean40mhz[iphase],gresSigma40mhz[iphase]); + gdiffMean40mhz[iphase] = subtract_graphs(gresMean40mhz[iphase],gresMean); + gdiffSigma40mhz[iphase] = subtract_graphs(gresSigma40mhz[iphase],gresSigma); + + gdiffMeanColor40mhz[iphase] = graph_with_colors(gdiffMean40mhz[iphase],PERIOD_40MHZ,iphase); + gdiffSigmaColor40mhz[iphase] = graph_with_colors(gdiffSigma40mhz[iphase],PERIOD_40MHZ,iphase); + + } // end loop over 40mhz phases + + cout << "-- Loop(): finished making plots" << endl; + + finalize(); +} diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.h new file mode 100644 index 000000000000..e0f5bfe6f142 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_ClockNoiseResidualPlots.h @@ -0,0 +1,222 @@ +////////////////////////////////////////////////////////// +// This class has been automatically generated on +// Wed Oct 22 10:24:41 2008 by ROOT version 5.18/00d +// from TTree ntuple/ntuple +// found on file: timinginfo.root +////////////////////////////////////////////////////////// + +#ifndef TRT_ClockNoiseResidualPlots_h +#define TRT_ClockNoiseResidualPlots_h + +#include <TROOT.h> +#include <TChain.h> +#include <TFile.h> + +#include "Riostream.h" +#include <iostream> +#include <vector> +#include <cmath> +#include <fstream> +#include <ctime> +#include <vector> +#include <fstream> + +#include <TH1.h> +#include <TH2.h> +#include <TStyle.h> +#include <TCanvas.h> +#include <TGraph.h> +#include <TProfile.h> +#include "Riostream.h" +#include <TGraphErrors.h> +#include <TF1.h> +#include <THStack.h> +#include <TLegend.h> +#include <TMultiGraph.h> +#include <TNtuple.h> +#include <TPaveStats.h> + +// detector constants +#define nPhi 32 +#define nSide 5 + +#define nChipB 104 +#define nBoardB 9 +#define nStrawB 1642 + +#define nChipE 120 +#define nBoardE 20 +#define nStrawE 3840 + +// barrel/endcap designations +#define ecC -2 +#define barC -1 +#define barA 1 +#define ecA 2 + +// period for each frequency of noise +#define PERIOD_40MHZ 8 +#define PERIOD_80MHZ 4 + +// minimum number of noise hits to consider a straw +#define min_occ 100 + +// parameters for residual plots +#define rmax 2.0 +#define rbins 40 + +// minimum number of entries to fit a gaussian to a residual plot -- must be >= 1 +#define min_entries 100 + +using namespace std; + +TString s_default = "timinginfo.root"; +TString s_outfile = "clocknoise.plots.root"; +TString s_noisetextfile = "clocknoise.dat"; +const int nTotStraw = nStrawB + nStrawE; + +class strawNoiseInfo{ +public: + float asym80; + int phase80; + float asym40; + int phase40; + int occbins; + int totalocc; + int noiseType; +}; + +class TRT_ClockNoiseResidualPlots { +public : + TTree *fChain; //!pointer to the analyzed TTree or TChain + Int_t fCurrent; //!current Tree number in a TChain + + // Declaration of leaf types + Double_t corLE; + Double_t EP; + Double_t TOT; + Int_t TEbin; + Int_t LEbin; + Int_t wrongSide; + Int_t board; + Double_t locR; + Double_t timeCorChip; + Int_t chip; + Int_t side; + Double_t t0; + Int_t phi; + Int_t straw; + Int_t strawLayer; + Int_t layer; + Int_t nBarHits; + Int_t nEcHits; + Int_t nTRThits_barrelA; + Int_t nTRThits_barrelC; + Int_t nTRThits_ecA; + Int_t nTRThits_ecC; + Int_t nSCThits; + Int_t nPixHits; + Double_t theta; + Double_t eta; + Double_t chi2ndf; + Double_t phi0; + Double_t z0; + Double_t d0; + Int_t tubeHit; + Double_t locRpat; + + // List of branches + TBranch *b_corLE; //! + TBranch *b_EP; //! + TBranch *b_TOT; //! + TBranch *b_TEbin; //! + TBranch *b_LEbin; //! + TBranch *b_wrongSide; //! + TBranch *b_board; //! + TBranch *b_locR; //! + TBranch *b_timeCorChip; //! + TBranch *b_chip; //! + TBranch *b_side; //! + TBranch *b_t0; //! + TBranch *b_phi; //! + TBranch *b_straw; //! + TBranch *b_strawLayer; //! + TBranch *b_layer; //! + TBranch *b_nBarHits; //! + TBranch *b_nEcHits; //! + TBranch *b_nTRThits_barrelA; //! + TBranch *b_nTRThits_barrelC; //! + TBranch *b_nTRThits_ecA; //! + TBranch *b_nTRThits_ecC; //! + TBranch *b_nSCThits; //! + TBranch *b_nPixHits; //! + TBranch *b_theta; //! + TBranch *b_eta; //! + TBranch *b_chi2ndf; //! + TBranch *b_phi0; //! + TBranch *b_z0; //! + TBranch *b_d0; //! + TBranch *b_tubeHit; //! + TBranch *b_locRpat; //! + + // -------- MakeClass methods ------------------------------------------ + TRT_ClockNoiseResidualPlots(TString s_file = s_default, TString s_textfile = s_noisetextfile); + virtual ~TRT_ClockNoiseResidualPlots(); + virtual Int_t GetEntry(Long64_t entry); + virtual Long64_t LoadTree(Long64_t entry); + virtual void Init(TTree *tree); + virtual void Loop(bool noisy_straw_list = true); + virtual Bool_t Notify(); + virtual void Show(Long64_t entry = -1); + + // ----------- user methods ---------------------------------------------- + virtual int initialize(); + virtual int book_histograms(); + virtual int fit_all_histos(); + virtual int finalize(); + virtual int fill_noise_map(); + virtual int cut_hit(); + virtual int cut_noise(); + virtual void gaus_fit(TH1F* h); + virtual void gaus_fit(TH1F* h[24]); + virtual void graph_residuals_vs_LEbin(TH1F* h[24],TGraphErrors* gMean,TGraphErrors* gSigma); + virtual TGraphErrors* subtract_graphs(TGraphErrors* g, TGraphErrors* gref); + virtual TMultiGraph* graph_with_colors(TGraphErrors* g, int period, int phase); + + // ---------- user variables --------------------------------------------- + strawNoiseInfo* noise_info_map[nPhi][2][nTotStraw]; //map to hold all the noise info + int noisy_straw_phase_map[nPhi][2][nTotStraw]; // holds phase for noisy straw, -1 if not noisy + TFile* fout; // output file for histograms + + // if this is set to true, then the text file read in contains just noisy straws, not full info + bool use_noisy_straw_list; + + // ---------- user histos and graphs -------------------------------------- + TCanvas* ctemp; + + // for all hits on track + TH1F* hres; + TH1F* hresLEbin[24]; + TGraphErrors* gresMean; + TGraphErrors* gresSigma; + + // for hits on straws with 40MHz noise + TH1F* hres40mhz[PERIOD_40MHZ]; + TH1F* hresLEbin40mhz[PERIOD_40MHZ][24]; + TGraphErrors* gresMean40mhz[PERIOD_40MHZ]; + TGraphErrors* gresSigma40mhz[PERIOD_40MHZ]; + + TGraphErrors* gdiffMean40mhz[PERIOD_40MHZ]; + TGraphErrors* gdiffSigma40mhz[PERIOD_40MHZ]; + + TMultiGraph* gdiffMeanColor40mhz[PERIOD_40MHZ]; + TCanvas* cdiffMeanColor40mhz[PERIOD_40MHZ]; + TMultiGraph* gdiffSigmaColor40mhz[PERIOD_40MHZ]; + TCanvas* cdiffSigmaColor40mhz[PERIOD_40MHZ]; + +}; + +#endif + +#ifdef TRT_ClockNoiseResidualPlots_cxx +#endif // #ifdef TRT_ClockNoiseResidualPlots_cxx diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DTMROC_HeaderCheck.py b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DTMROC_HeaderCheck.py new file mode 100644 index 000000000000..70fd0dea25fd --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DTMROC_HeaderCheck.py @@ -0,0 +1,19 @@ +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +# Full job is a list of algorithms +from AthenaCommon.AlgSequence import AlgSequence +job = AlgSequence() +# Add top algorithms to be run +from TRT_DetectorPerformance.TRT_DetectorPerformanceConf import InDet__TRT_DTMROC_HeaderCheck +job += InDet__TRT_DTMROC_HeaderCheck( "TRT_DTMROC_HeaderCheck" ) # 1 alg +#-------------------------------------------------------------- +# Set output level threshold (DEBUG, INFO, WARNING, ERROR, FATAL) +#-------------------------------------------------------------- +job.TRT_DTMROC_HeaderCheck.OutputLevel = INFO +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +# Number of events to be processed (default is 10) +#theApp.EvtMax = -1 +#============================================================== diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorPlots.py b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorPlots.py new file mode 100644 index 000000000000..04c4c1b9ec48 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorPlots.py @@ -0,0 +1,19 @@ +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +# Full job is a list of algorithms +from AthenaCommon.AlgSequence import AlgSequence +job = AlgSequence() +# Add top algorithms to be run +from TRT_DetectorPerformance.TRT_DetectorPerformanceConf import InDet__TRT_DetectorPlots +job += InDet__TRT_DetectorPlots( "TRT_DetectorPlots" ) # 1 alg +#-------------------------------------------------------------- +# Set output level threshold (DEBUG, INFO, WARNING, ERROR, FATAL) +#-------------------------------------------------------------- +job.TRT_DetectorPlots.OutputLevel = INFO +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +# Number of events to be processed (default is 10) +#theApp.EvtMax = -1 +#============================================================== diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorTiming.py b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorTiming.py new file mode 100644 index 000000000000..22e071075766 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_DetectorTiming.py @@ -0,0 +1,20 @@ +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +# Full job is a list of algorithms +from AthenaCommon.AlgSequence import AlgSequence +job = AlgSequence() +print job +# Add top algorithms to be run +from TRT_DetectorPerformance.TRT_DetectorPerformanceConf import InDet__TRT_DetectorTiming +job += InDet__TRT_DetectorTiming( "TRT_DetectorTiming" ) # 1 alg +#-------------------------------------------------------------- +# Set output level threshold (DEBUG, INFO, WARNING, ERROR, FATAL) +#-------------------------------------------------------------- +job.TRT_DetectorTiming.OutputLevel = INFO +#-------------------------------------------------------------- +# Event related parameters +#-------------------------------------------------------------- +# Number of events to be processed (default is 10) +#theApp.EvtMax = 10 +#============================================================== diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_calculateTimingConstants.h b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_calculateTimingConstants.h new file mode 100644 index 000000000000..a943e7e1c3f9 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/TRT_calculateTimingConstants.h @@ -0,0 +1,640 @@ +////////////////////////////////////////////////////////// +// This class has been automtically generated on +// Wed Feb 6 10:04:15 2008 by ROOT version 5.17/02 +// from TTree ntuple/data from ascii file +// found on file: ../root/rt.chafik_m4_huge.root +// +// Author: Brett Jackson <brett.david.jackson@cern.ch> +// Author: Dominick Olivito <dominick.john.olivito@cern.ch> +////////////////////////////////////////////////////////// + +#ifndef TRT_calculateTimingConstants_h +#define TRT_calculateTimingConstants_h + +#include <TROOT.h> +#include <TChain.h> +#include <TFile.h> + +#include "Riostream.h" +#include <iostream> +#include <vector> +#include <cmath> +#include <fstream> + +#include <TH1.h> +#include <TH2.h> +#include <TStyle.h> +#include <TCanvas.h> +#include <TGraph.h> +#include <vector> +#include <TProfile.h> +#include <fstream> +#include <cmath> +#include "Riostream.h" +#include <iostream> +#include <TGraphErrors.h> +#include <TF1.h> +#include <THStack.h> +#include <TLegend.h> +#include <TMultiGraph.h> +#include <TNtuple.h> +#include <TPaveStats.h> + +/////////////////////////////////// +/// Parameters to describe the +/// binning in radius histograms +/////////////////////////////////// +const int rbins = 40; +const float rmin = 0.; +const float rmax = 2.; +const int rbinsBd = 20; + +///////////////////////////////// +/// Parameters to describe the +/// binning in time histograms +///////////////////////////////// +//const int tbins = 48; +//const float tmin = -12.5; +//const float tmax = 37.5; +//const int tbins = 60; +//const float tmin = -12.5; +//const float tmax = 50.0; +const int tbins = 68; +const float tmin = -12.5; +const float tmax = 75.0; + +////////////////////////////////////////// +/// Parameters to describe the +/// binning in time residual histograms +////////////////////////////////////////// +//const int trbins = 16; +const int trbins = 75; +const float trmin = -25.; +const float trmax = 50.; +const float trwidth = 8.; + +////////////////////////////////// +/// Values used in the cut when +/// determining residuals +////////////////////////////////// +const float fitmin = -5.; +const float fitmax = 30.; + +///////////////////////////// +/// number of short layers +///////////////////////////// +const int shortLayers = 9; + +/////////////////////////////////////////////////////////////// +/// Number of chips, phi modules, "sides", boards and straws +/////////////////////////////////////////////////////////////// +//const int nChip = 120; +//const int nPhi = 32; +//const int nSide = 5; +//const int nBoard = 9; +//const int nStraw = 1642; +// +const int nChip = 224; +const int nPhi = 32; +const int nSide = 5; +const int nSide_new = 4; +const int nBoard = 29; +const int nStraw = 5482; + +////////////////////////////////////////////////////////// +/// Number of chips, boards and straws in barrel region +////////////////////////////////////////////////////////// +//const int nChip_barrel = 104; +//const int nBoard_barrel = 9; +//const int nStraw_barrel = 1642; +const int nChip_barrel = nChip; +const int nBoard_barrel = nBoard; +const int nStraw_barrel = nStraw; + +////////////////////////////////////////////////////////// +/// Number of chips, boards and straws in endcap region +////////////////////////////////////////////////////////// +//const int nChip_ec = 120; +//const int nBoard_ec = 20; +//const int nStraw_ec = 3840; +const int nChip_ec = nChip; +const int nBoard_ec = nBoard; +const int nStraw_ec = nStraw; + +////////////////////////////////////////////////////// +// barrel/endcap designations for the side variable +////////////////////////////////////////////////////// +const int ecC = -2; +const int barC = -1; +const int barA = 1; +const int ecA = 2; + +//////////////////////////////////////// +/// used to distinguish between upper +/// and lower stacks - This is only +/// used as an array index +//////////////////////////////////////// +const int UPPER = 1; +const int LOWER = 0; + +///////////////////////////////////////////// +/// Minimum number of entries required to +/// compute tr rt relation or the residual +///////////////////////////////////////////// +const int minEntriesTR = 500; +const int minEntriesRes = 100; +//const int minEntriesRes = 50; + +//////////////////////////////////////// +/// Other parameters to determine the +/// quality of the fit +//////////////////////////////////////// +//const float deltat0Thresh = 7.; +const float deltat0Thresh = 15.; +const float chi2Thresh = 10.; +const float sigmaMin = 2.; // we expect a sigma around 3ns for the time residual +//const float sigmaMax = 4.; +//const float sigmaMin = 1.5; // we expect a sigma around 3ns for the time residual +const float sigmaMax = 5; + +//////////////////////////////////////////////////// +/// RMS of pull distribution for boards and chips +/// use to scale up errors +//////////////////////////////////////////////////// +const float boardFactor = 1.6; +const float chipFactor = 1.5; + +// std::cout << "<<<<<<<<<<<<< rt.C usage: >>>>>>>>>>>>>" << std::endl +// << " > TRT_calculateTimingConstants t" << std::endl +// << " > t.Loop(boards = {false,true}, chips = {false,true}, layers = {ALL,INNER,OUTER}, absRes = {false,true}, rtCuts = {true,false})" << std::endl +// << "[defaults are listed first]" << std::endl << std::endl; + + +Double_t p[4] = {0,0.1,-0.00087,0}; // chafik's values +Double_t ptr[4] = {0,7.5,3.5,-0.5}; // from previous fit +Int_t boardChips[nBoard_barrel] = {10, 21, 36, 45, 54, 65, 77, 90, 104}; +Int_t boardChipCount[nBoard_barrel] = {10, 11, 15, 9, 9, 11, 12, 13, 14}; + +enum strawlayers { ALL, SHORT, LONG0, LONGALL, BAR, EC }; + +// std::cout << "<<<<<<<<<<<<< rt.C usage: >>>>>>>>>>>>>" << std::endl +// << " > rt t" << std::endl +// << " > t.Loop(boards = {false,true}, chips = {false,true}, layers = {ALL,INNER,OUTER}, absRes = {false,true}, rtCuts = {true,false})" << std::endl +// << "[defaults are listed first]" << std::endl << std::endl; + +struct t0Data { + double t0; + double sigma; + double entries; +}; + +class TRT_calculateTimingConstants { + public : + + // constructor and destructor + TRT_calculateTimingConstants(TString inputdir, TString runnum, TString outputdir = "./"); + virtual ~TRT_calculateTimingConstants(); + + ///////////////// Loop: this is the only function one needs to call from the root prompt/////////////////////// + // + // - loops over all events in the specified ntuple and performs all other calculations + // - this has lots of options that can be passed to change what is input and output + // + virtual void Loop(bool bds = false, bool chps = false, bool drawErr = false, bool internets = false, bool tres = true, strawlayers lyrs = ALL, bool absRes = false, bool rtcut = true); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // private: + TTree *fChain; //!pointer to the analyzed TTree or TChain + Int_t fCurrent; //!current Tree number in a TChain + + //////////////////////////////// + // Declaration of leave types + //////////////////////////////// + Double_t corLE; + Double_t EP; + Double_t TOT; + Int_t TEbin; + Int_t LEbin; + Int_t wrongSide; + Int_t board; + Double_t locR; + Double_t timeCorChip; + Int_t chip; + Int_t side; + Double_t t0; + Int_t phi; + Int_t straw; + Int_t strawLayer; + Int_t layer; + Int_t nBarHits; + Int_t nEcHits; + Int_t nSCThits; + Int_t nPixHits; + Double_t theta; + Double_t eta; + Double_t chi2ndf; + Double_t phi0; + Double_t z0; + Double_t d0; + + ////////////////////// + // List of branches + ////////////////////// + TBranch *b_corLE; //! + TBranch *b_EP; //! + TBranch *b_TOT; //! + TBranch *b_TEbin; //! + TBranch *b_LEbin; //! + TBranch *b_wrongSide; //! + TBranch *b_board; //! + TBranch *b_locR; //! + TBranch *b_timeCorChip; //! + TBranch *b_chip; //! + TBranch *b_side; //! + TBranch *b_t0; //! + TBranch *b_phi; //! + TBranch *b_straw; //! + TBranch *b_strawLayer; //! + TBranch *b_layer; //! + TBranch *b_nBarHits; //! + TBranch *b_nEcHits; //! + TBranch *b_nSCThits; //! + TBranch *b_nPixHits; //! + TBranch *b_theta; //! + TBranch *b_eta; //! + TBranch *b_chi2ndf; //! + TBranch *b_phi0; //! + TBranch *b_z0; //! + TBranch *b_d0; //! + + /////////////////////////// + /// Histgrams and graphs + /////////////////////////// + TH2F* hrt; + TH2F* hrt_side[nSide_new]; //~~~ + TH2F* hrt_barrel; + TH2F* hrt_ec; + TH2F* htr; + TH2F* htr_side[nSide_new]; //~~~ + TH2F* htr_barrel; + TH2F* htr_ec; + //TH2F* htrBoard[nPhi][nSide][nBoard_ec]; + //TH2F* htrChip[nPhi][nSide][nChip_ec]; + TH2F* htrBoard[nPhi][nSide_new][nBoard]; + TH2F* htrChip[nPhi][nSide_new][nChip]; + + TH1D* hProjBin[rbins]; + //TH1D* hProjBin_side[nSide_new][rbins]; //~~~ + //TH1D* hProjBin_barrel[rbins]; + //TH1D* hProjBin_ec[rbins]; + + TGraphErrors* grt; + TGraphErrors* grt_side[nSide_new]; //~~~ + TGraphErrors* grt_barrel; + TGraphErrors* grt_ec; + TGraphErrors* gtr; + TGraphErrors* gtr_side[nSide_new]; //~~~ + TGraphErrors* gtr_barrel; + TGraphErrors* gtr_ec; + //TGraphErrors* gtrBoard[nPhi][nSide][nBoard_ec]; + //TGraphErrors* gtrChip[nPhi][nSide][nChip_ec]; + TGraphErrors* gtrBoard[nPhi][nSide_new][nBoard]; + TGraphErrors* gtrChip[nPhi][nSide_new][nChip]; + TGraphErrors* gBoardt0[nPhi][nSide_new]; + TGraphErrors* gChipt0[nPhi][nSide_new]; + TH1F* hBoardt0Diff; + TH1F* hChipt0Diff; + TH1F* hRes; + TH1F* hRes_side[nSide_new]; //~~~ + TH1F* hRes_barrel; + TH1F* hRes_ec; + + TH1F* hResBin[rbins]; + TH1F* hResBin_side[nSide_new][rbins]; //~~~ + TH1F* hResBin_barrel[rbins]; + TH1F* hResBin_ec[rbins]; + + TGraphErrors* gRes; + TGraphErrors* gRes_side[nSide_new]; //~~~ + TGraphErrors* gRes_barrel; + TGraphErrors* gRes_ec; + + TH2F* hrTE; + TH2F* hrTE_side[nSide_new]; //~~~ + TH2F* hrTE_barrel; + TH2F* hrTE_ec; + TH2F* hTEr; + TH2F* hTEr_side[nSide_new]; //~~~ + TH2F* hTEr_barrel; + TH2F* hTEr_ec; + TGraphErrors* gTEr; + TGraphErrors* gTEr_side[nSide_new]; //~~~ + TGraphErrors* gTEr_barrel; + TGraphErrors* gTEr_ec; + TH2F* ht0Err; + TH1F* hChi2Board; + TH1F* hChi2Chip; + //TH1F* htResBoard[nPhi][nSide][nBoard_ec]; + //TH1F* htResChip[nPhi][nSide][nChip_ec]; + //TGraphErrors* gChipt0s[nSide][nBoard_ec]; + //TGraph* gChipt0sFD[nSide][nBoard_ec]; + //TH1F* ht0FDdiff[nSide][nBoard_ec]; + //TH1F* htResChipStacked[nSide][nChip_ec]; + //TLine* lBoard[nBoard_ec]; + //TH1F* hChipt0[nPhi][nSide][nBoard_ec]; + TH1F* htResBoard[nPhi][nSide_new][nBoard]; + TH1F* htResChip[nPhi][nSide_new][nChip]; + TGraphErrors* gChipt0s[nSide_new][nBoard]; + TGraph* gChipt0sFD[nSide_new][nBoard]; + TH1F* ht0FDdiff[nSide_new][nBoard]; + TH1F* htResChipStacked[nSide_new][nChip]; + TLine* lBoard[nBoard]; + TH1F* hChipt0[nPhi][nSide_new][nBoard]; + TH1F* hBoardt0Side[nSide_new][2]; + + TH1F* htRes; + TH1F* htRes_side[nSide_new]; //~~~ + TH1F* htRes_barrel; + TH1F* htRes_ec; + TH1F* hTEres; + TH1F* hTEres_side[nSide_new]; //~~~ + TH1F* hTEres_barrel; + TH1F* hTEres_ec; + + TH1F* hTOTcut; + TGraphErrors* gVdrift; + TH1F* ht0Bcomp; + TH1F* ht0Ccomp; + + TF1* rtRel; + TF1* rtRel_side[nSide_new]; //~~~ + TF1* rtRel_barrel; + TF1* rtRel_ec; + TF1* trRel; + TF1* trRel_side[nSide_new]; //~~~ + TF1* trRel_barrel; + TF1* trRel_ec; + //TF1* trRelBoard[nPhi][nSide][nBoard_ec]; + //TF1* trRelChip[nPhi][nSide][nChip_ec]; + TF1* trRelBoard[nPhi][nSide_new][nBoard]; + TF1* trRelChip[nPhi][nSide_new][nChip]; + TF1* rtChafik; + TF1* TErRel; + TF1* TErRel_side[nSide_new]; //~~~ + TF1* TErRel_barrel; + TF1* TErRel_ec; + + + ////////////////////// + /// Other variables + ////////////////////// + TString s_inputdir; + TString s_runnum; + TString s_outputdir; + TString s_boardFile; + TString s_chipFile; + TString s_logFile; + TString s_chipSideFile; + + TFile* fout; + ofstream outBoard; + ofstream outChip; + ofstream log; + ofstream outChipSide; + TString s_save; + TString s_histoSave; + + + Double_t rtmin; + Double_t rtmax; + + Double_t rdelta; + Double_t rdeltaBd; + Double_t tdelta; + + TCanvas* c1; + + bool saveForInternets; + bool savePDF; + bool t0FromRes; + bool drawErrors; + bool boards; + bool chips; + bool showRT; + bool showRes; + bool showt0; + //bool fullB[nPhi][nSide][nBoard_ec]; + bool fullB[nPhi][nSide_new][nBoard]; + bool drawTails; + + //t0Data t0Board[nPhi][nSide][nBoard_ec]; + //t0Data t0Chip[nPhi][nSide][nChip_ec]; + t0Data t0Board[nPhi][nSide_new][nBoard]; + t0Data t0Chip[nPhi][nSide_new][nChip]; + Int_t histoIndex; + // !!! chipCor should be ADDED to LE, not subtracted like a t0... + strawlayers layers; // int? + //Double_t chipCor[nSide][nChip_ec]; + //Int_t shortStrawChips[nChip_barrel]; + //Float_t newt0B[nPhi][nSide][nBoard_ec]; + //Float_t newt0C[nPhi][nSide][nChip_ec]; + //Float_t dbt0[nPhi][nSide][nStraw_ec]; + //Int_t strawToChip[nStraw_ec]; + Double_t chipCor[nSide_new][nChip]; + Int_t shortStrawChips[nChip]; + Float_t newt0B[nPhi][nSide_new][nBoard]; + Float_t newt0C[nPhi][nSide_new][nChip]; + Float_t dbt0[nPhi][nSide_new][nStraw]; +// Int_t strawToChip[nStraw]; + + ////////////////////// + /// Basic functions + ////////////////////// + virtual Int_t GetEntry(Long64_t entry); + virtual Long64_t LoadTree(Long64_t entry); + virtual void Init(TTree *tree); + virtual Bool_t Notify(); + virtual void Show(Long64_t entry = -1); + inline unsigned int getSideIndex(int side); + + //////////////////////////////////// + /// Initialization-type functions + //////////////////////////////////// + + // initialize: this defines some basic names and things, may need to be changed occasionally + // -- also contains bools for controlling which histograms are displayed/saved + virtual void initialize(); + + // histoprep: this sets up all the histograms and graphs. new histos should be added here + virtual void histoPrep(); + + // fillChipCor: this fills an array with fine delay chip-to-chip corrections, from an input file + virtual void fillChipCor(); + + // shortStrawInfo: fills an array with # of short straws on each chip, from an input file + virtual void shortStrawInfo(); + + // fillStrawToChipMapping: fills an array with chip numbers for each straw from input file +// virtual void fillStrawToChipMapping(); + + // closingTime: closes any open files, writes all graphs and TF1s to the open TFile + virtual void closingTime(); + + ///////////////////////////////////////// + /// Loop cuts: + /// + /// These are for use inside of Loop() + ///////////////////////////////////////// + + // Cut: this is where cuts on TOT, LEbin, TEbin, and wrongSide are implemented + // -- also incorporates layerCut + virtual Int_t Cut(Long64_t entry); + + // rtCut: throws out points with t such that r(t) > 2 or r(t) < 0 + // -- used only for calculating residuals + virtual Int_t rtCut(Long64_t entry); + + // layerCut: select short or long straws (or all) + virtual Int_t layerCut(Long64_t entry); + + ///////////////// + /// Other cuts + ///////////////// + + // phi/sideCut: these select which parts of the detector are in the data sample + virtual Int_t phiCut(int iPhi); + virtual Int_t sideCut(int iSide); + + // skipBoard/Chip: here I list bad boards/chips to be skipped when calculating t0s + virtual bool skipBoard(int iPhi, int iSide, int iBoard); + virtual bool skipChip(int iPhi, int iSide, int iChip); + + + ///////////////////////// + /// Major calculations + ///////////////////////// + + // tResCalc: calculates t0s for boards/chips by forming a time residual distribution and fitting a gaussian to that + // -- this is very similar to how chafik determines t0s + // -- also, I trust the errors more for this t0 determination, based on pull distributions + // -- also calculates chip t0 by summing over all stacks on a given side, to compare to fine delay chip values + virtual void tResCalc(); + + // sliceNfit: this takes a 2d rt or tr plot, slices it in distance bins, and fits gaussians to the slices + virtual void sliceNfit(TH2F* h, TGraphErrors* g, bool xaxis = true, bool global = true); + + // curvefits: these fit either an rt or tr curve to a graph made from sliceNfit + virtual void rtCurveFit(TGraphErrors* g, TF1* rtrel); + virtual void trCurveFit(TGraphErrors* g, TF1* rtrel, bool global = true); + + // resBins: makes residual plots for bins in locR + virtual void resBins(bool absRes = false); + + // resCalc: calculates resolution as a function of locR by binning in distance + virtual void resCalc(); + + // boardTR: fits for the constant parameter of a TR relation for each board to find t0 + virtual void boardTR(); + + // chipTR: fits for the constant parameter of a TR relation for each chip to find t0 + virtual void chipTR(); + + // removeOutlier: for fitting TR curves at board/chip level + // -- try removing one point to improve chi2 (in case there's an outlier) + virtual void removeOutlier(TGraphErrors* g, TF1* f1); + + ////////////////////////// + /// simple calculations + ////////////////////////// + + // chipToBoardMapping: looks up which board a given chip belongs to + // --- Currently only works for barrel region. May phase this out + // to be replaced by another entry in the ntuple to store board + // number for each hit in both the barrel and endcap + virtual Int_t chipToBoardMapping(int iChip); + + // chipOnBoard: looks up the relative chip # (i.e. 0-X) for a given chip on a board + // --- Again only for barrel region + virtual Int_t chipOnBoard(int iBoard, int iChip); + + // RofT: calculates r(t) using chafik's constants + virtual Double_t RofT( Double_t t ); + + // ResAbsCuts: calculates the distance residual as + // residual = fabs(locR) - fabs(r(t)) + // - cuts off r(t) at > 2mm, <0mm + virtual Double_t ResAbsCuts( Double_t t, Double_t locR ); + + // ResAbs: calculates the distance residual as + // residual = fabs(locR) - fabs(r(t)) + virtual Double_t ResAbs( Double_t t, Double_t locR ); + + // ResSignCuts: calculates the distance residual as + // residual = +- fabs(locR - r(t)) + // - cuts off r(t) at > 2mm, <0mm + virtual Double_t ResSignCuts( Double_t t, Double_t locR ); + + // gausFit: fits a gaussian from -0.5 to 0.5 + virtual void gausFit(TH1F* h); + + // gausFitPeak: fits a gaussian where the peak is not at 0, from peak-trwidth to peak+trwidth + virtual void gausFitPeak(TH1F* h); + + // chi2NDF: calculates chi2/ndf for a given function + virtual Double_t chi2NDF(TF1* f1); + + // getNboard: returns the number of boards, which differs endcap to barrel + virtual Int_t getNboard( int iSide ); + + // getNchip: returns the number of chips, which differs endcap to barrel + virtual Int_t getNchip( int iSide ); + + // getNstraw: returns the number of straws, which differs endcap to barrel + virtual Int_t getNstraw( int iSide ); + + // isUpper: returns 1 if the phi stack is in the upper half of the detector, 0 if lower + virtual Int_t isUpper( int iPhi ); + + // strawToBoardMapping: returns the board for a given straw +// virtual Int_t strawToBoardMapping( int iStraw ); + + //////////////////////// + /// Drawing functions + //////////////////////// + + // drawTR/RT: these draw the rt plots to the screen and/or to file + virtual void drawRT(bool chafik); + virtual void drawTR(); + virtual void drawTEr(); + virtual void drawTR(TCanvas* c2, int iPhi, int iSide, int iBoard, int iChip, bool save); + + // graphResR: draws resolution as a function of locR to screen/file + virtual void graphResR(); + + // saveCanvas: saves a canvas as pdf with the given name + virtual void saveCanvas(TCanvas* c2, TString name); + + // saveGIF: saves the canvas as a GIF with a generic name for website use + virtual void saveGIF(TCanvas* c2); + + // drawFlows: draws a histogram with over/underflows + virtual void drawFlows(TH1F* h, TString name); + + // graphChipt0s: this graphs chipt0s from the time residual calculation vs fine delay + virtual void graphChipt0s(int iSide); + + // drawBoardLines: draws lines to seperate chips on different boards, for graphChipt0s + virtual void drawBoardLines(double ymin, double ymax); + + // graphVdrift: approximates Vdrift at a few points in locR and graphs these + virtual void graphVdrift(); + + // plott0Comp: makes histos comparing new t0s with DB on board/chip level +// virtual void plott0Comp(); +}; + +#endif + +#ifdef rt_cxx + +#endif // #ifdef rt_cxx diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/finedelays-avg0-chips.txt b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/finedelays-avg0-chips.txt new file mode 100644 index 000000000000..15013a078038 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/finedelays-avg0-chips.txt @@ -0,0 +1,208 @@ +-1 0 0.708 +-1 1 0.568 +-1 2 0.308 +-1 3 0.268 +-1 4 0.0779999 +-1 5 -0.0720001 +-1 6 -0.132 +-1 7 -0.362 +-1 8 -0.582 +-1 9 -0.782 +-1 10 0.99 +-1 11 0.68 +-1 12 0.46 +-1 13 0.45 +-1 14 0.24 +-1 15 -0.0200001 +-1 16 -0.16 +-1 17 -0.37 +-1 18 -0.58 +-1 19 -0.72 +-1 20 -0.97 +-1 21 1.39333 +-1 22 1.10333 +-1 23 0.963333 +-1 24 0.743333 +-1 25 0.523333 +-1 26 0.303333 +-1 27 0.203333 +-1 28 0.0533332 +-1 29 -0.0466669 +-1 30 -0.476667 +-1 31 -0.536667 +-1 32 -0.766667 +-1 33 -0.916667 +-1 34 -1.17667 +-1 35 -1.36667 +-1 36 -0.694444 +-1 37 -0.514444 +-1 38 -0.264444 +-1 39 -0.244444 +-1 40 -0.0144444 +-1 41 0.0655556 +-1 42 0.255556 +-1 43 0.615556 +-1 44 0.795556 +-1 45 0.798889 +-1 46 0.698889 +-1 47 0.338889 +-1 48 0.168889 +-1 49 0.0688889 +-1 50 -0.101111 +-1 51 -0.481111 +-1 52 -0.611111 +-1 53 -0.881111 +-1 54 0.959091 +-1 55 0.729091 +-1 56 0.509091 +-1 57 0.369091 +-1 58 0.229091 +-1 59 -0.140909 +-1 60 -0.290909 +-1 61 -0.370909 +-1 62 -0.490909 +-1 63 -0.670909 +-1 64 -0.830909 +-1 65 1.20083 +-1 66 0.930833 +-1 67 0.730833 +-1 68 0.550833 +-1 69 0.390833 +-1 70 0.160833 +-1 71 0.0808332 +-1 72 -0.309167 +-1 73 -0.639167 +-1 74 -0.839167 +-1 75 -0.999167 +-1 76 -1.25917 +-1 77 1.18231 +-1 78 0.972308 +-1 79 0.752308 +-1 80 0.602308 +-1 81 0.412308 +-1 82 0.172308 +-1 83 0.0223076 +-1 84 -0.107692 +-1 85 -0.267692 +-1 86 -0.697692 +-1 87 -0.887692 +-1 88 -0.987692 +-1 89 -1.16769 +-1 90 1.50357 +-1 91 1.16357 +-1 92 0.883571 +-1 93 0.783571 +-1 94 0.413571 +-1 95 0.183571 +-1 96 0.113571 +-1 97 -0.0264286 +-1 98 -0.286429 +-1 99 -0.656429 +-1 100 -0.756429 +-1 101 -0.816429 +-1 102 -1.12643 +-1 103 -1.37643 +1 0 0.893 +1 1 0.663 +1 2 0.553 +1 3 0.313 +1 4 0.0630001 +1 5 -0.157 +1 6 -0.127 +1 7 -0.427 +1 8 -0.727 +1 9 -1.047 +1 10 0.916364 +1 11 0.826364 +1 12 0.696364 +1 13 0.526364 +1 14 0.356364 +1 15 -0.0136362 +1 16 -0.243636 +1 17 -0.433636 +1 18 -0.643636 +1 19 -0.793636 +1 20 -1.19364 +1 21 0.733333 +1 22 0.803333 +1 23 1.13333 +1 24 1.32333 +1 25 1.52333 +1 26 -0.256667 +1 27 -0.0466667 +1 28 0.123333 +1 29 0.283333 +1 30 -0.746667 +1 31 -0.526667 +1 32 -0.496667 +1 33 -1.21667 +1 34 -1.13667 +1 35 -1.49667 +1 36 -0.753333 +1 37 -0.513333 +1 38 -0.343333 +1 39 -0.193333 +1 40 0.0566667 +1 41 0.116667 +1 42 0.456667 +1 43 0.446667 +1 44 0.726667 +1 45 1.00778 +1 46 0.707778 +1 47 0.497778 +1 48 0.337778 +1 49 -0.0522221 +1 50 -0.262222 +1 51 -0.552222 +1 52 -0.802222 +1 53 -0.882222 +1 54 0.937273 +1 55 0.807273 +1 56 0.687273 +1 57 0.397273 +1 58 0.267273 +1 59 0.0472728 +1 60 -0.282727 +1 61 -0.502727 +1 62 -0.642727 +1 63 -0.752727 +1 64 -0.962727 +1 65 1.325 +1 66 1.105 +1 67 1.065 +1 68 0.765 +1 69 0.375 +1 70 0.145 +1 71 -0.0650001 +1 72 -0.385 +1 73 -0.635 +1 74 -1.025 +1 75 -1.425 +1 76 -1.245 +1 77 0.320769 +1 78 0.140769 +1 79 0.0107692 +1 80 -0.219231 +1 81 -0.369231 +1 82 -0.799231 +1 83 -0.859231 +1 84 -1.29923 +1 85 -1.31923 +1 86 1.53077 +1 87 1.22077 +1 88 0.940769 +1 89 0.700769 +1 90 0.224286 +1 91 0.394286 +1 92 0.614286 +1 93 0.804286 +1 94 1.04429 +1 95 1.36429 +1 96 1.52429 +1 97 -0.215714 +1 98 -0.0657144 +1 99 -0.645714 +1 100 -0.835714 +1 101 -1.12571 +1 102 -1.61571 +1 103 -1.46571 diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/shortStrawChips.txt b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/shortStrawChips.txt new file mode 100644 index 000000000000..b4e1eb18e04b --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/shortStrawChips.txt @@ -0,0 +1,12 @@ +0 16 +1 12 +2 15 +3 16 +4 16 +5 14 +6 16 +7 4 +8 4 +18 8 +19 10 +20 16 diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/swIndex.txt b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/swIndex.txt new file mode 100644 index 000000000000..987bacc3f657 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/share/swIndex.txt @@ -0,0 +1,1649 @@ +# lxplus: ~sfratina/public/TRT/swIndex.txt, columns: +# barrel only, perhaps order of chips for side C is slightly different in one board +# - straw number 0-1641 +# - chip number 0-103 +# - layer number 0-2 +# - straw layer number 0-29 +# - straw number within a layer 0-15 + 0 0 0 0 14 + 1 0 0 0 13 + 2 0 0 0 12 + 3 1 0 0 11 + 4 1 0 0 10 + 5 1 0 0 9 + 6 1 0 0 8 + 7 2 0 0 7 + 8 2 0 0 6 + 9 2 0 0 5 + 10 2 0 0 4 + 11 3 0 0 3 + 12 3 0 0 2 + 13 3 0 0 1 + 14 3 0 0 0 + 15 0 0 1 15 + 16 0 0 1 14 + 17 0 0 1 13 + 18 0 0 1 12 + 19 1 0 1 11 + 20 1 0 1 10 + 21 1 0 1 9 + 22 2 0 1 8 + 23 2 0 1 7 + 24 2 0 1 6 + 25 2 0 1 5 + 26 3 0 1 4 + 27 3 0 1 3 + 28 3 0 1 2 + 29 3 0 1 1 + 30 3 0 1 0 + 31 0 0 2 15 + 32 0 0 2 14 + 33 0 0 2 13 + 34 0 0 2 12 + 35 1 0 2 11 + 36 1 0 2 10 + 37 1 0 2 9 + 38 2 0 2 8 + 39 2 0 2 7 + 40 2 0 2 6 + 41 3 0 2 5 + 42 3 0 2 4 + 43 3 0 2 3 + 44 3 0 2 2 + 45 20 0 2 1 + 46 20 0 2 0 + 47 0 0 3 15 + 48 0 0 3 14 + 49 0 0 3 13 + 50 0 0 3 12 + 51 1 0 3 11 + 52 1 0 3 10 + 53 2 0 3 9 + 54 2 0 3 8 + 55 2 0 3 7 + 56 2 0 3 6 + 57 3 0 3 5 + 58 3 0 3 4 + 59 3 0 3 3 + 60 20 0 3 2 + 61 20 0 3 1 + 62 20 0 3 0 + 63 0 0 4 15 + 64 6 0 4 14 + 65 6 0 4 13 + 66 6 0 4 12 + 67 6 0 4 11 + 68 5 0 4 10 + 69 5 0 4 9 + 70 5 0 4 8 + 71 4 0 4 7 + 72 4 0 4 6 + 73 4 0 4 5 + 74 4 0 4 4 + 75 4 0 4 3 + 76 20 0 4 2 + 77 20 0 4 1 + 78 20 0 4 0 + 79 6 0 5 16 + 80 6 0 5 15 + 81 6 0 5 14 + 82 6 0 5 13 + 83 5 0 5 12 + 84 5 0 5 11 + 85 5 0 5 10 + 86 5 0 5 9 + 87 4 0 5 8 + 88 4 0 5 7 + 89 4 0 5 6 + 90 4 0 5 5 + 91 20 0 5 4 + 92 20 0 5 3 + 93 20 0 5 2 + 94 20 0 5 1 + 95 20 0 5 0 + 96 6 0 6 16 + 97 6 0 6 15 + 98 6 0 6 14 + 99 6 0 6 13 + 100 5 0 6 12 + 101 5 0 6 11 + 102 5 0 6 10 + 103 5 0 6 9 + 104 4 0 6 8 + 105 4 0 6 7 + 106 4 0 6 6 + 107 19 0 6 5 + 108 19 0 6 4 + 109 20 0 6 3 + 110 20 0 6 2 + 111 20 0 6 1 + 112 18 0 6 0 + 113 6 0 7 16 + 114 6 0 7 15 + 115 6 0 7 14 + 116 6 0 7 13 + 117 5 0 7 12 + 118 5 0 7 11 + 119 5 0 7 10 + 120 4 0 7 9 + 121 4 0 7 8 + 122 4 0 7 7 + 123 19 0 7 6 + 124 19 0 7 5 + 125 19 0 7 4 + 126 19 0 7 3 + 127 18 0 7 2 + 128 18 0 7 1 + 129 18 0 7 0 + 130 7 0 8 16 + 131 7 0 8 15 + 132 7 0 8 14 + 133 7 0 8 13 + 134 8 0 8 12 + 135 8 0 8 11 + 136 8 0 8 10 + 137 8 0 8 9 + 138 4 0 8 8 + 139 19 0 8 7 + 140 19 0 8 6 + 141 19 0 8 5 + 142 19 0 8 4 + 143 18 0 8 3 + 144 18 0 8 2 + 145 18 0 8 1 + 146 18 0 8 0 + 147 7 0 9 16 + 148 7 0 9 15 + 149 7 0 9 14 + 150 8 0 9 13 + 151 8 0 9 12 + 152 8 0 9 11 + 153 8 0 9 10 + 154 19 0 9 9 + 155 19 0 9 8 + 156 19 0 9 7 + 157 19 0 9 6 + 158 19 0 9 5 + 159 18 0 9 4 + 160 18 0 9 3 + 161 18 0 9 2 + 162 18 0 9 1 + 163 18 0 9 0 + 164 7 0 10 17 + 165 7 0 10 16 + 166 7 0 10 15 + 167 8 0 10 14 + 168 8 0 10 13 + 169 8 0 10 12 + 170 8 0 10 11 + 171 15 0 10 10 + 172 15 0 10 9 + 173 19 0 10 8 + 174 15 0 10 7 + 175 16 0 10 6 + 176 16 0 10 5 + 177 18 0 10 4 + 178 18 0 10 3 + 179 18 0 10 2 + 180 17 0 10 1 + 181 17 0 10 0 + 182 7 0 11 17 + 183 7 0 11 16 + 184 7 0 11 15 + 185 8 0 11 14 + 186 8 0 11 13 + 187 8 0 11 12 + 188 8 0 11 11 + 189 15 0 11 10 + 190 15 0 11 9 + 191 15 0 11 8 + 192 16 0 11 7 + 193 16 0 11 6 + 194 16 0 11 5 + 195 16 0 11 4 + 196 17 0 11 3 + 197 17 0 11 2 + 198 17 0 11 1 + 199 17 0 11 0 + 200 7 0 12 17 + 201 7 0 12 16 + 202 7 0 12 15 + 203 9 0 12 14 + 204 9 0 12 13 + 205 15 0 12 12 + 206 15 0 12 11 + 207 15 0 12 10 + 208 15 0 12 9 + 209 15 0 12 8 + 210 16 0 12 7 + 211 16 0 12 6 + 212 16 0 12 5 + 213 16 0 12 4 + 214 17 0 12 3 + 215 17 0 12 2 + 216 17 0 12 1 + 217 17 0 12 0 + 218 9 0 13 17 + 219 9 0 13 16 + 220 9 0 13 15 + 221 9 0 13 14 + 222 14 0 13 13 + 223 13 0 13 12 + 224 15 0 13 11 + 225 15 0 13 10 + 226 15 0 13 9 + 227 16 0 13 8 + 228 16 0 13 7 + 229 16 0 13 6 + 230 16 0 13 5 + 231 16 0 13 4 + 232 17 0 13 3 + 233 17 0 13 2 + 234 17 0 13 1 + 235 17 0 13 0 + 236 9 0 14 17 + 237 9 0 14 16 + 238 9 0 14 15 + 239 14 0 14 14 + 240 14 0 14 13 + 241 15 0 14 12 + 242 15 0 14 11 + 243 13 0 14 10 + 244 13 0 14 9 + 245 12 0 14 8 + 246 12 0 14 7 + 247 12 0 14 6 + 248 16 0 14 5 + 249 17 0 14 4 + 250 17 0 14 3 + 251 10 0 14 2 + 252 10 0 14 1 + 253 10 0 14 0 + 254 9 0 15 18 + 255 9 0 15 17 + 256 9 0 15 16 + 257 14 0 15 15 + 258 14 0 15 14 + 259 13 0 15 13 + 260 13 0 15 12 + 261 13 0 15 11 + 262 13 0 15 10 + 263 12 0 15 9 + 264 12 0 15 8 + 265 12 0 15 7 + 266 11 0 15 6 + 267 11 0 15 5 + 268 11 0 15 4 + 269 11 0 15 3 + 270 10 0 15 2 + 271 10 0 15 1 + 272 10 0 15 0 + 273 9 0 16 18 + 274 9 0 16 17 + 275 14 0 16 16 + 276 14 0 16 15 + 277 14 0 16 14 + 278 13 0 16 13 + 279 13 0 16 12 + 280 13 0 16 11 + 281 13 0 16 10 + 282 12 0 16 9 + 283 12 0 16 8 + 284 12 0 16 7 + 285 11 0 16 6 + 286 11 0 16 5 + 287 11 0 16 4 + 288 11 0 16 3 + 289 10 0 16 2 + 290 10 0 16 1 + 291 10 0 16 0 + 292 9 0 17 18 + 293 14 0 17 17 + 294 14 0 17 16 + 295 14 0 17 15 + 296 14 0 17 14 + 297 13 0 17 13 + 298 13 0 17 12 + 299 13 0 17 11 + 300 12 0 17 10 + 301 12 0 17 9 + 302 12 0 17 8 + 303 11 0 17 7 + 304 11 0 17 6 + 305 11 0 17 5 + 306 11 0 17 4 + 307 10 0 17 3 + 308 10 0 17 2 + 309 10 0 17 1 + 310 10 0 17 0 + 311 9 0 18 17 + 312 14 0 18 16 + 313 14 0 18 15 + 314 14 0 18 14 + 315 14 0 18 13 + 316 13 0 18 12 + 317 13 0 18 11 + 318 12 0 18 10 + 319 12 0 18 9 + 320 12 0 18 8 + 321 12 0 18 7 + 322 11 0 18 6 + 323 11 0 18 5 + 324 11 0 18 4 + 325 11 0 18 3 + 326 10 0 18 2 + 327 10 0 18 1 + 328 10 0 18 0 + 329 25 1 0 18 + 330 25 1 0 17 + 331 25 1 0 16 + 332 25 1 0 15 + 333 24 1 0 14 + 334 24 1 0 13 + 335 24 1 0 12 + 336 24 1 0 11 + 337 23 1 0 10 + 338 23 1 0 9 + 339 23 1 0 8 + 340 23 1 0 7 + 341 22 1 0 6 + 342 22 1 0 5 + 343 22 1 0 4 + 344 21 1 0 3 + 345 21 1 0 2 + 346 21 1 0 1 + 347 21 1 0 0 + 348 25 1 1 19 + 349 25 1 1 18 + 350 25 1 1 17 + 351 25 1 1 16 + 352 24 1 1 15 + 353 24 1 1 14 + 354 24 1 1 13 + 355 24 1 1 12 + 356 23 1 1 11 + 357 23 1 1 10 + 358 23 1 1 9 + 359 23 1 1 8 + 360 22 1 1 7 + 361 22 1 1 6 + 362 22 1 1 5 + 363 22 1 1 4 + 364 21 1 1 3 + 365 21 1 1 2 + 366 21 1 1 1 + 367 21 1 1 0 + 368 53 1 2 19 + 369 25 1 2 18 + 370 25 1 2 17 + 371 24 1 2 16 + 372 24 1 2 15 + 373 24 1 2 14 + 374 24 1 2 13 + 375 24 1 2 12 + 376 23 1 2 11 + 377 23 1 2 10 + 378 23 1 2 9 + 379 23 1 2 8 + 380 22 1 2 7 + 381 22 1 2 6 + 382 22 1 2 5 + 383 22 1 2 4 + 384 21 1 2 3 + 385 21 1 2 2 + 386 21 1 2 1 + 387 21 1 2 0 + 388 53 1 3 19 + 389 53 1 3 18 + 390 53 1 3 17 + 391 25 1 3 16 + 392 25 1 3 15 + 393 25 1 3 14 + 394 24 1 3 13 + 395 24 1 3 12 + 396 24 1 3 11 + 397 23 1 3 10 + 398 23 1 3 9 + 399 23 1 3 8 + 400 22 1 3 7 + 401 22 1 3 6 + 402 22 1 3 5 + 403 22 1 3 4 + 404 22 1 3 3 + 405 21 1 3 2 + 406 21 1 3 1 + 407 21 1 3 0 + 408 53 1 4 19 + 409 53 1 4 18 + 410 53 1 4 17 + 411 53 1 4 16 + 412 25 1 4 15 + 413 26 1 4 14 + 414 27 1 4 13 + 415 27 1 4 12 + 416 23 1 4 11 + 417 27 1 4 10 + 418 27 1 4 9 + 419 28 1 4 8 + 420 28 1 4 7 + 421 28 1 4 6 + 422 28 1 4 5 + 423 29 1 4 4 + 424 29 1 4 3 + 425 29 1 4 2 + 426 29 1 4 1 + 427 21 1 4 0 + 428 53 1 5 19 + 429 53 1 5 18 + 430 53 1 5 17 + 431 25 1 5 16 + 432 25 1 5 15 + 433 26 1 5 14 + 434 26 1 5 13 + 435 26 1 5 12 + 436 26 1 5 11 + 437 27 1 5 10 + 438 27 1 5 9 + 439 27 1 5 8 + 440 28 1 5 7 + 441 28 1 5 6 + 442 28 1 5 5 + 443 28 1 5 4 + 444 29 1 5 3 + 445 29 1 5 2 + 446 29 1 5 1 + 447 29 1 5 0 + 448 53 1 6 20 + 449 53 1 6 19 + 450 53 1 6 18 + 451 53 1 6 17 + 452 53 1 6 16 + 453 26 1 6 15 + 454 26 1 6 14 + 455 26 1 6 13 + 456 27 1 6 12 + 457 27 1 6 11 + 458 27 1 6 10 + 459 27 1 6 9 + 460 27 1 6 8 + 461 28 1 6 7 + 462 28 1 6 6 + 463 28 1 6 5 + 464 28 1 6 4 + 465 29 1 6 3 + 466 29 1 6 2 + 467 29 1 6 1 + 468 29 1 6 0 + 469 52 1 7 20 + 470 52 1 7 19 + 471 51 1 7 18 + 472 51 1 7 17 + 473 51 1 7 16 + 474 26 1 7 15 + 475 26 1 7 14 + 476 26 1 7 13 + 477 26 1 7 12 + 478 26 1 7 11 + 479 27 1 7 10 + 480 27 1 7 9 + 481 27 1 7 8 + 482 28 1 7 7 + 483 28 1 7 6 + 484 28 1 7 5 + 485 28 1 7 4 + 486 29 1 7 3 + 487 29 1 7 2 + 488 29 1 7 1 + 489 29 1 7 0 + 490 52 1 8 20 + 491 52 1 8 19 + 492 52 1 8 18 + 493 51 1 8 17 + 494 51 1 8 16 + 495 51 1 8 15 + 496 51 1 8 14 + 497 26 1 8 13 + 498 26 1 8 12 + 499 27 1 8 11 + 500 32 1 8 10 + 501 32 1 8 9 + 502 32 1 8 8 + 503 31 1 8 7 + 504 31 1 8 6 + 505 31 1 8 5 + 506 31 1 8 4 + 507 30 1 8 3 + 508 30 1 8 2 + 509 30 1 8 1 + 510 30 1 8 0 + 511 52 1 9 20 + 512 52 1 9 19 + 513 52 1 9 18 + 514 52 1 9 17 + 515 51 1 9 16 + 516 51 1 9 15 + 517 51 1 9 14 + 518 51 1 9 13 + 519 26 1 9 12 + 520 32 1 9 11 + 521 32 1 9 10 + 522 32 1 9 9 + 523 32 1 9 8 + 524 31 1 9 7 + 525 31 1 9 6 + 526 31 1 9 5 + 527 31 1 9 4 + 528 30 1 9 3 + 529 30 1 9 2 + 530 30 1 9 1 + 531 30 1 9 0 + 532 52 1 10 20 + 533 52 1 10 19 + 534 52 1 10 18 + 535 52 1 10 17 + 536 51 1 10 16 + 537 51 1 10 15 + 538 51 1 10 14 + 539 51 1 10 13 + 540 49 1 10 12 + 541 32 1 10 11 + 542 32 1 10 10 + 543 32 1 10 9 + 544 32 1 10 8 + 545 31 1 10 7 + 546 31 1 10 6 + 547 31 1 10 5 + 548 31 1 10 4 + 549 30 1 10 3 + 550 30 1 10 2 + 551 30 1 10 1 + 552 30 1 10 0 + 553 47 1 11 21 + 554 47 1 11 20 + 555 52 1 11 19 + 556 52 1 11 18 + 557 52 1 11 17 + 558 51 1 11 16 + 559 49 1 11 15 + 560 49 1 11 14 + 561 49 1 11 13 + 562 49 1 11 12 + 563 49 1 11 11 + 564 32 1 11 10 + 565 32 1 11 9 + 566 32 1 11 8 + 567 31 1 11 7 + 568 31 1 11 6 + 569 31 1 11 5 + 570 31 1 11 4 + 571 30 1 11 3 + 572 30 1 11 2 + 573 30 1 11 1 + 574 30 1 11 0 + 575 47 1 12 21 + 576 47 1 12 20 + 577 47 1 12 19 + 578 48 1 12 18 + 579 48 1 12 17 + 580 48 1 12 16 + 581 48 1 12 15 + 582 49 1 12 14 + 583 49 1 12 13 + 584 49 1 12 12 + 585 50 1 12 11 + 586 50 1 12 10 + 587 32 1 12 9 + 588 32 1 12 8 + 589 33 1 12 7 + 590 33 1 12 6 + 591 33 1 12 5 + 592 33 1 12 4 + 593 34 1 12 3 + 594 34 1 12 2 + 595 34 1 12 1 + 596 34 1 12 0 + 597 47 1 13 21 + 598 47 1 13 20 + 599 47 1 13 19 + 600 48 1 13 18 + 601 48 1 13 17 + 602 48 1 13 16 + 603 48 1 13 15 + 604 49 1 13 14 + 605 49 1 13 13 + 606 49 1 13 12 + 607 50 1 13 11 + 608 50 1 13 10 + 609 50 1 13 9 + 610 50 1 13 8 + 611 33 1 13 7 + 612 33 1 13 6 + 613 33 1 13 5 + 614 33 1 13 4 + 615 34 1 13 3 + 616 34 1 13 2 + 617 34 1 13 1 + 618 34 1 13 0 + 619 47 1 14 21 + 620 47 1 14 20 + 621 47 1 14 19 + 622 47 1 14 18 + 623 48 1 14 17 + 624 48 1 14 16 + 625 48 1 14 15 + 626 48 1 14 14 + 627 49 1 14 13 + 628 49 1 14 12 + 629 50 1 14 11 + 630 50 1 14 10 + 631 50 1 14 9 + 632 50 1 14 8 + 633 50 1 14 7 + 634 33 1 14 6 + 635 33 1 14 5 + 636 33 1 14 4 + 637 34 1 14 3 + 638 34 1 14 2 + 639 34 1 14 1 + 640 34 1 14 0 + 641 47 1 15 21 + 642 47 1 15 20 + 643 47 1 15 19 + 644 47 1 15 18 + 645 48 1 15 17 + 646 48 1 15 16 + 647 48 1 15 15 + 648 48 1 15 14 + 649 49 1 15 13 + 650 49 1 15 12 + 651 50 1 15 11 + 652 50 1 15 10 + 653 50 1 15 9 + 654 50 1 15 8 + 655 50 1 15 7 + 656 33 1 15 6 + 657 33 1 15 5 + 658 33 1 15 4 + 659 34 1 15 3 + 660 34 1 15 2 + 661 34 1 15 1 + 662 34 1 15 0 + 663 46 1 16 22 + 664 46 1 16 21 + 665 46 1 16 20 + 666 46 1 16 19 + 667 45 1 16 18 + 668 45 1 16 17 + 669 45 1 16 16 + 670 44 1 16 15 + 671 44 1 16 14 + 672 44 1 16 13 + 673 43 1 16 12 + 674 43 1 16 11 + 675 43 1 16 10 + 676 43 1 16 9 + 677 42 1 16 8 + 678 42 1 16 7 + 679 42 1 16 6 + 680 33 1 16 5 + 681 33 1 16 4 + 682 35 1 16 3 + 683 35 1 16 2 + 684 35 1 16 1 + 685 35 1 16 0 + 686 46 1 17 22 + 687 46 1 17 21 + 688 46 1 17 20 + 689 46 1 17 19 + 690 45 1 17 18 + 691 45 1 17 17 + 692 45 1 17 16 + 693 45 1 17 15 + 694 44 1 17 14 + 695 44 1 17 13 + 696 44 1 17 12 + 697 43 1 17 11 + 698 43 1 17 10 + 699 43 1 17 9 + 700 43 1 17 8 + 701 42 1 17 7 + 702 42 1 17 6 + 703 42 1 17 5 + 704 42 1 17 4 + 705 35 1 17 3 + 706 35 1 17 2 + 707 35 1 17 1 + 708 35 1 17 0 + 709 46 1 18 22 + 710 46 1 18 21 + 711 46 1 18 20 + 712 46 1 18 19 + 713 45 1 18 18 + 714 45 1 18 17 + 715 45 1 18 16 + 716 45 1 18 15 + 717 45 1 18 14 + 718 44 1 18 13 + 719 44 1 18 12 + 720 43 1 18 11 + 721 43 1 18 10 + 722 43 1 18 9 + 723 43 1 18 8 + 724 42 1 18 7 + 725 42 1 18 6 + 726 42 1 18 5 + 727 42 1 18 4 + 728 42 1 18 3 + 729 35 1 18 2 + 730 35 1 18 1 + 731 35 1 18 0 + 732 36 1 19 22 + 733 46 1 19 21 + 734 46 1 19 20 + 735 46 1 19 19 + 736 46 1 19 18 + 737 45 1 19 17 + 738 45 1 19 16 + 739 45 1 19 15 + 740 45 1 19 14 + 741 44 1 19 13 + 742 44 1 19 12 + 743 43 1 19 11 + 744 43 1 19 10 + 745 43 1 19 9 + 746 43 1 19 8 + 747 42 1 19 7 + 748 42 1 19 6 + 749 40 1 19 5 + 750 42 1 19 4 + 751 42 1 19 3 + 752 35 1 19 2 + 753 35 1 19 1 + 754 35 1 19 0 + 755 36 1 20 22 + 756 36 1 20 21 + 757 36 1 20 20 + 758 36 1 20 19 + 759 37 1 20 18 + 760 37 1 20 17 + 761 37 1 20 16 + 762 37 1 20 15 + 763 38 1 20 14 + 764 38 1 20 13 + 765 38 1 20 12 + 766 39 1 20 11 + 767 39 1 20 10 + 768 39 1 20 9 + 769 39 1 20 8 + 770 40 1 20 7 + 771 40 1 20 6 + 772 40 1 20 5 + 773 41 1 20 4 + 774 41 1 20 3 + 775 41 1 20 2 + 776 35 1 20 1 + 777 35 1 20 0 + 778 36 1 21 23 + 779 36 1 21 22 + 780 36 1 21 21 + 781 36 1 21 20 + 782 37 1 21 19 + 783 37 1 21 18 + 784 37 1 21 17 + 785 37 1 21 16 + 786 38 1 21 15 + 787 38 1 21 14 + 788 38 1 21 13 + 789 38 1 21 12 + 790 39 1 21 11 + 791 39 1 21 10 + 792 39 1 21 9 + 793 40 1 21 8 + 794 40 1 21 7 + 795 40 1 21 6 + 796 40 1 21 5 + 797 41 1 21 4 + 798 41 1 21 3 + 799 41 1 21 2 + 800 41 1 21 1 + 801 41 1 21 0 + 802 36 1 22 23 + 803 36 1 22 22 + 804 36 1 22 21 + 805 36 1 22 20 + 806 37 1 22 19 + 807 37 1 22 18 + 808 37 1 22 17 + 809 37 1 22 16 + 810 38 1 22 15 + 811 38 1 22 14 + 812 38 1 22 13 + 813 38 1 22 12 + 814 39 1 22 11 + 815 39 1 22 10 + 816 39 1 22 9 + 817 39 1 22 8 + 818 40 1 22 7 + 819 40 1 22 6 + 820 40 1 22 5 + 821 40 1 22 4 + 822 41 1 22 3 + 823 41 1 22 2 + 824 41 1 22 1 + 825 41 1 22 0 + 826 36 1 23 22 + 827 36 1 23 21 + 828 36 1 23 20 + 829 37 1 23 19 + 830 37 1 23 18 + 831 37 1 23 17 + 832 37 1 23 16 + 833 38 1 23 15 + 834 38 1 23 14 + 835 38 1 23 13 + 836 38 1 23 12 + 837 38 1 23 11 + 838 39 1 23 10 + 839 39 1 23 9 + 840 39 1 23 8 + 841 40 1 23 7 + 842 40 1 23 6 + 843 40 1 23 5 + 844 40 1 23 4 + 845 41 1 23 3 + 846 41 1 23 2 + 847 41 1 23 1 + 848 41 1 23 0 + 849 54 2 0 22 + 850 54 2 0 21 + 851 54 2 0 20 + 852 54 2 0 19 + 853 55 2 0 18 + 854 55 2 0 17 + 855 55 2 0 16 + 856 55 2 0 15 + 857 56 2 0 14 + 858 56 2 0 13 + 859 56 2 0 12 + 860 56 2 0 11 + 861 57 2 0 10 + 862 57 2 0 9 + 863 57 2 0 8 + 864 58 2 0 7 + 865 58 2 0 6 + 866 58 2 0 5 + 867 58 2 0 4 + 868 59 2 0 3 + 869 59 2 0 2 + 870 59 2 0 1 + 871 59 2 0 0 + 872 54 2 1 23 + 873 54 2 1 22 + 874 54 2 1 21 + 875 54 2 1 20 + 876 55 2 1 19 + 877 55 2 1 18 + 878 55 2 1 17 + 879 55 2 1 16 + 880 56 2 1 15 + 881 56 2 1 14 + 882 56 2 1 13 + 883 56 2 1 12 + 884 57 2 1 11 + 885 57 2 1 10 + 886 57 2 1 9 + 887 57 2 1 8 + 888 58 2 1 7 + 889 58 2 1 6 + 890 58 2 1 5 + 891 58 2 1 4 + 892 59 2 1 3 + 893 59 2 1 2 + 894 59 2 1 1 + 895 59 2 1 0 + 896 54 2 2 23 + 897 54 2 2 22 + 898 54 2 2 21 + 899 54 2 2 20 + 900 55 2 2 19 + 901 55 2 2 18 + 902 55 2 2 17 + 903 55 2 2 16 + 904 56 2 2 15 + 905 56 2 2 14 + 906 56 2 2 13 + 907 56 2 2 12 + 908 57 2 2 11 + 909 57 2 2 10 + 910 57 2 2 9 + 911 58 2 2 8 + 912 58 2 2 7 + 913 58 2 2 6 + 914 58 2 2 5 + 915 59 2 2 4 + 916 59 2 2 3 + 917 59 2 2 2 + 918 103 2 2 1 + 919 103 2 2 0 + 920 54 2 3 23 + 921 54 2 3 22 + 922 54 2 3 21 + 923 55 2 3 20 + 924 55 2 3 19 + 925 55 2 3 18 + 926 55 2 3 17 + 927 56 2 3 16 + 928 56 2 3 15 + 929 56 2 3 14 + 930 56 2 3 13 + 931 57 2 3 12 + 932 57 2 3 11 + 933 57 2 3 10 + 934 57 2 3 9 + 935 58 2 3 8 + 936 58 2 3 7 + 937 58 2 3 6 + 938 59 2 3 5 + 939 59 2 3 4 + 940 59 2 3 3 + 941 103 2 3 2 + 942 103 2 3 1 + 943 103 2 3 0 + 944 54 2 4 23 + 945 64 2 4 22 + 946 64 2 4 21 + 947 64 2 4 20 + 948 64 2 4 19 + 949 63 2 4 18 + 950 63 2 4 17 + 951 63 2 4 16 + 952 62 2 4 15 + 953 62 2 4 14 + 954 62 2 4 13 + 955 62 2 4 12 + 956 61 2 4 11 + 957 61 2 4 10 + 958 61 2 4 9 + 959 60 2 4 8 + 960 60 2 4 7 + 961 58 2 4 6 + 962 60 2 4 5 + 963 59 2 4 4 + 964 59 2 4 3 + 965 103 2 4 2 + 966 103 2 4 1 + 967 103 2 4 0 + 968 64 2 5 24 + 969 64 2 5 23 + 970 64 2 5 22 + 971 64 2 5 21 + 972 63 2 5 20 + 973 63 2 5 19 + 974 63 2 5 18 + 975 63 2 5 17 + 976 63 2 5 16 + 977 62 2 5 15 + 978 62 2 5 14 + 979 62 2 5 13 + 980 61 2 5 12 + 981 61 2 5 11 + 982 61 2 5 10 + 983 61 2 5 9 + 984 60 2 5 8 + 985 60 2 5 7 + 986 60 2 5 6 + 987 60 2 5 5 + 988 103 2 5 4 + 989 103 2 5 3 + 990 103 2 5 2 + 991 103 2 5 1 + 992 103 2 5 0 + 993 64 2 6 24 + 994 64 2 6 23 + 995 64 2 6 22 + 996 64 2 6 21 + 997 63 2 6 20 + 998 63 2 6 19 + 999 63 2 6 18 +1000 63 2 6 17 +1001 62 2 6 16 +1002 62 2 6 15 +1003 62 2 6 14 +1004 62 2 6 13 +1005 61 2 6 12 +1006 61 2 6 11 +1007 61 2 6 10 +1008 61 2 6 9 +1009 60 2 6 8 +1010 60 2 6 7 +1011 60 2 6 6 +1012 60 2 6 5 +1013 103 2 6 4 +1014 103 2 6 3 +1015 102 2 6 2 +1016 102 2 6 1 +1017 102 2 6 0 +1018 64 2 7 24 +1019 64 2 7 23 +1020 64 2 7 22 +1021 64 2 7 21 +1022 63 2 7 20 +1023 63 2 7 19 +1024 63 2 7 18 +1025 63 2 7 17 +1026 62 2 7 16 +1027 62 2 7 15 +1028 62 2 7 14 +1029 62 2 7 13 +1030 61 2 7 12 +1031 61 2 7 11 +1032 61 2 7 10 +1033 60 2 7 9 +1034 60 2 7 8 +1035 60 2 7 7 +1036 60 2 7 6 +1037 103 2 7 5 +1038 102 2 7 4 +1039 102 2 7 3 +1040 102 2 7 2 +1041 102 2 7 1 +1042 102 2 7 0 +1043 65 2 8 24 +1044 65 2 8 23 +1045 65 2 8 22 +1046 65 2 8 21 +1047 66 2 8 20 +1048 66 2 8 19 +1049 66 2 8 18 +1050 66 2 8 17 +1051 67 2 8 16 +1052 67 2 8 15 +1053 67 2 8 14 +1054 67 2 8 13 +1055 68 2 8 12 +1056 68 2 8 11 +1057 68 2 8 10 +1058 68 2 8 9 +1059 61 2 8 8 +1060 60 2 8 7 +1061 101 2 8 6 +1062 100 2 8 5 +1063 102 2 8 4 +1064 102 2 8 3 +1065 102 2 8 2 +1066 102 2 8 1 +1067 102 2 8 0 +1068 65 2 9 24 +1069 65 2 9 23 +1070 65 2 9 22 +1071 65 2 9 21 +1072 66 2 9 20 +1073 66 2 9 19 +1074 66 2 9 18 +1075 66 2 9 17 +1076 67 2 9 16 +1077 67 2 9 15 +1078 67 2 9 14 +1079 67 2 9 13 +1080 68 2 9 12 +1081 68 2 9 11 +1082 68 2 9 10 +1083 68 2 9 9 +1084 68 2 9 8 +1085 101 2 9 7 +1086 101 2 9 6 +1087 100 2 9 5 +1088 100 2 9 4 +1089 102 2 9 3 +1090 102 2 9 2 +1091 102 2 9 1 +1092 99 2 9 0 +1093 65 2 10 25 +1094 65 2 10 24 +1095 65 2 10 23 +1096 65 2 10 22 +1097 66 2 10 21 +1098 66 2 10 20 +1099 66 2 10 19 +1100 66 2 10 18 +1101 67 2 10 17 +1102 67 2 10 16 +1103 67 2 10 15 +1104 68 2 10 14 +1105 68 2 10 13 +1106 68 2 10 12 +1107 68 2 10 11 +1108 68 2 10 10 +1109 68 2 10 9 +1110 101 2 10 8 +1111 101 2 10 7 +1112 100 2 10 6 +1113 100 2 10 5 +1114 100 2 10 4 +1115 100 2 10 3 +1116 99 2 10 2 +1117 99 2 10 1 +1118 99 2 10 0 +1119 65 2 11 25 +1120 65 2 11 24 +1121 65 2 11 23 +1122 65 2 11 22 +1123 66 2 11 21 +1124 66 2 11 20 +1125 66 2 11 19 +1126 66 2 11 18 +1127 67 2 11 17 +1128 67 2 11 16 +1129 67 2 11 15 +1130 67 2 11 14 +1131 68 2 11 13 +1132 69 2 11 12 +1133 69 2 11 11 +1134 101 2 11 10 +1135 101 2 11 9 +1136 101 2 11 8 +1137 101 2 11 7 +1138 100 2 11 6 +1139 100 2 11 5 +1140 100 2 11 4 +1141 99 2 11 3 +1142 99 2 11 2 +1143 99 2 11 1 +1144 99 2 11 0 +1145 71 2 12 25 +1146 71 2 12 24 +1147 71 2 12 23 +1148 71 2 12 22 +1149 71 2 12 21 +1150 70 2 12 20 +1151 70 2 12 19 +1152 70 2 12 18 +1153 70 2 12 17 +1154 69 2 12 16 +1155 69 2 12 15 +1156 69 2 12 14 +1157 69 2 12 13 +1158 69 2 12 12 +1159 69 2 12 11 +1160 101 2 12 10 +1161 101 2 12 9 +1162 101 2 12 8 +1163 100 2 12 7 +1164 100 2 12 6 +1165 100 2 12 5 +1166 100 2 12 4 +1167 99 2 12 3 +1168 99 2 12 2 +1169 99 2 12 1 +1170 99 2 12 0 +1171 71 2 13 25 +1172 71 2 13 24 +1173 71 2 13 23 +1174 71 2 13 22 +1175 71 2 13 21 +1176 70 2 13 20 +1177 70 2 13 19 +1178 70 2 13 18 +1179 70 2 13 17 +1180 69 2 13 16 +1181 69 2 13 15 +1182 69 2 13 14 +1183 69 2 13 13 +1184 95 2 13 12 +1185 101 2 13 11 +1186 101 2 13 10 +1187 101 2 13 9 +1188 101 2 13 8 +1189 100 2 13 7 +1190 100 2 13 6 +1191 97 2 13 5 +1192 99 2 13 4 +1193 99 2 13 3 +1194 99 2 13 2 +1195 98 2 13 1 +1196 99 2 13 0 +1197 71 2 14 25 +1198 71 2 14 24 +1199 71 2 14 23 +1200 71 2 14 22 +1201 70 2 14 21 +1202 70 2 14 20 +1203 70 2 14 19 +1204 70 2 14 18 +1205 70 2 14 17 +1206 69 2 14 16 +1207 69 2 14 15 +1208 69 2 14 14 +1209 95 2 14 13 +1210 95 2 14 12 +1211 95 2 14 11 +1212 96 2 14 10 +1213 96 2 14 9 +1214 96 2 14 8 +1215 96 2 14 7 +1216 96 2 14 6 +1217 97 2 14 5 +1218 97 2 14 4 +1219 97 2 14 3 +1220 98 2 14 2 +1221 98 2 14 1 +1222 98 2 14 0 +1223 71 2 15 26 +1224 71 2 15 25 +1225 72 2 15 24 +1226 72 2 15 23 +1227 72 2 15 22 +1228 70 2 15 21 +1229 70 2 15 20 +1230 70 2 15 19 +1231 73 2 15 18 +1232 73 2 15 17 +1233 73 2 15 16 +1234 69 2 15 15 +1235 95 2 15 14 +1236 95 2 15 13 +1237 95 2 15 12 +1238 95 2 15 11 +1239 96 2 15 10 +1240 96 2 15 9 +1241 96 2 15 8 +1242 96 2 15 7 +1243 97 2 15 6 +1244 97 2 15 5 +1245 97 2 15 4 +1246 98 2 15 3 +1247 98 2 15 2 +1248 98 2 15 1 +1249 98 2 15 0 +1250 72 2 16 26 +1251 72 2 16 25 +1252 72 2 16 24 +1253 72 2 16 23 +1254 72 2 16 22 +1255 72 2 16 21 +1256 73 2 16 20 +1257 73 2 16 19 +1258 73 2 16 18 +1259 73 2 16 17 +1260 73 2 16 16 +1261 95 2 16 15 +1262 95 2 16 14 +1263 95 2 16 13 +1264 95 2 16 12 +1265 96 2 16 11 +1266 96 2 16 10 +1267 96 2 16 9 +1268 96 2 16 8 +1269 97 2 16 7 +1270 97 2 16 6 +1271 97 2 16 5 +1272 97 2 16 4 +1273 98 2 16 3 +1274 98 2 16 2 +1275 98 2 16 1 +1276 98 2 16 0 +1277 72 2 17 26 +1278 72 2 17 25 +1279 72 2 17 24 +1280 72 2 17 23 +1281 72 2 17 22 +1282 73 2 17 21 +1283 73 2 17 20 +1284 73 2 17 19 +1285 73 2 17 18 +1286 73 2 17 17 +1287 73 2 17 16 +1288 95 2 17 15 +1289 95 2 17 14 +1290 95 2 17 13 +1291 95 2 17 12 +1292 96 2 17 11 +1293 96 2 17 10 +1294 96 2 17 9 +1295 97 2 17 8 +1296 97 2 17 7 +1297 97 2 17 6 +1298 97 2 17 5 +1299 97 2 17 4 +1300 98 2 17 3 +1301 98 2 17 2 +1302 98 2 17 1 +1303 98 2 17 0 +1304 75 2 18 26 +1305 75 2 18 25 +1306 75 2 18 24 +1307 72 2 18 23 +1308 72 2 18 22 +1309 74 2 18 21 +1310 74 2 18 20 +1311 73 2 18 19 +1312 73 2 18 18 +1313 94 2 18 17 +1314 94 2 18 16 +1315 94 2 18 15 +1316 94 2 18 14 +1317 93 2 18 13 +1318 93 2 18 12 +1319 93 2 18 11 +1320 93 2 18 10 +1321 92 2 18 9 +1322 92 2 18 8 +1323 92 2 18 7 +1324 92 2 18 6 +1325 91 2 18 5 +1326 91 2 18 4 +1327 91 2 18 3 +1328 90 2 18 2 +1329 90 2 18 1 +1330 90 2 18 0 +1331 75 2 19 26 +1332 75 2 19 25 +1333 75 2 19 24 +1334 75 2 19 23 +1335 74 2 19 22 +1336 74 2 19 21 +1337 74 2 19 20 +1338 74 2 19 19 +1339 74 2 19 18 +1340 94 2 19 17 +1341 94 2 19 16 +1342 94 2 19 15 +1343 94 2 19 14 +1344 93 2 19 13 +1345 93 2 19 12 +1346 93 2 19 11 +1347 92 2 19 10 +1348 92 2 19 9 +1349 92 2 19 8 +1350 92 2 19 7 +1351 92 2 19 6 +1352 91 2 19 5 +1353 91 2 19 4 +1354 91 2 19 3 +1355 91 2 19 2 +1356 90 2 19 1 +1357 90 2 19 0 +1358 75 2 20 27 +1359 75 2 20 26 +1360 75 2 20 25 +1361 75 2 20 24 +1362 74 2 20 23 +1363 74 2 20 22 +1364 74 2 20 21 +1365 74 2 20 20 +1366 94 2 20 19 +1367 94 2 20 18 +1368 94 2 20 17 +1369 94 2 20 16 +1370 94 2 20 15 +1371 93 2 20 14 +1372 93 2 20 13 +1373 93 2 20 12 +1374 93 2 20 11 +1375 92 2 20 10 +1376 92 2 20 9 +1377 92 2 20 8 +1378 91 2 20 7 +1379 91 2 20 6 +1380 91 2 20 5 +1381 91 2 20 4 +1382 91 2 20 3 +1383 90 2 20 2 +1384 90 2 20 1 +1385 90 2 20 0 +1386 75 2 21 27 +1387 75 2 21 26 +1388 75 2 21 25 +1389 75 2 21 24 +1390 74 2 21 23 +1391 74 2 21 22 +1392 74 2 21 21 +1393 84 2 21 20 +1394 85 2 21 19 +1395 85 2 21 18 +1396 94 2 21 17 +1397 94 2 21 16 +1398 94 2 21 15 +1399 93 2 21 14 +1400 93 2 21 13 +1401 93 2 21 12 +1402 92 2 21 11 +1403 92 2 21 10 +1404 92 2 21 9 +1405 92 2 21 8 +1406 91 2 21 7 +1407 91 2 21 6 +1408 91 2 21 5 +1409 88 2 21 4 +1410 90 2 21 3 +1411 90 2 21 2 +1412 90 2 21 1 +1413 90 2 21 0 +1414 75 2 22 27 +1415 76 2 22 26 +1416 76 2 22 25 +1417 76 2 22 24 +1418 74 2 22 23 +1419 74 2 22 22 +1420 84 2 22 21 +1421 84 2 22 20 +1422 84 2 22 19 +1423 85 2 22 18 +1424 85 2 22 17 +1425 85 2 22 16 +1426 86 2 22 15 +1427 86 2 22 14 +1428 86 2 22 13 +1429 86 2 22 12 +1430 87 2 22 11 +1431 87 2 22 10 +1432 87 2 22 9 +1433 87 2 22 8 +1434 91 2 22 7 +1435 88 2 22 6 +1436 88 2 22 5 +1437 88 2 22 4 +1438 90 2 22 3 +1439 90 2 22 2 +1440 90 2 22 1 +1441 90 2 22 0 +1442 76 2 23 27 +1443 76 2 23 26 +1444 76 2 23 25 +1445 76 2 23 24 +1446 76 2 23 23 +1447 84 2 23 22 +1448 84 2 23 21 +1449 84 2 23 20 +1450 84 2 23 19 +1451 85 2 23 18 +1452 85 2 23 17 +1453 85 2 23 16 +1454 86 2 23 15 +1455 86 2 23 14 +1456 86 2 23 13 +1457 86 2 23 12 +1458 87 2 23 11 +1459 87 2 23 10 +1460 87 2 23 9 +1461 87 2 23 8 +1462 88 2 23 7 +1463 88 2 23 6 +1464 88 2 23 5 +1465 88 2 23 4 +1466 89 2 23 3 +1467 89 2 23 2 +1468 89 2 23 1 +1469 89 2 23 0 +1470 76 2 24 27 +1471 76 2 24 26 +1472 76 2 24 25 +1473 76 2 24 24 +1474 84 2 24 23 +1475 84 2 24 22 +1476 84 2 24 21 +1477 84 2 24 20 +1478 85 2 24 19 +1479 85 2 24 18 +1480 85 2 24 17 +1481 85 2 24 16 +1482 86 2 24 15 +1483 86 2 24 14 +1484 86 2 24 13 +1485 86 2 24 12 +1486 87 2 24 11 +1487 87 2 24 10 +1488 87 2 24 9 +1489 87 2 24 8 +1490 88 2 24 7 +1491 88 2 24 6 +1492 88 2 24 5 +1493 89 2 24 4 +1494 89 2 24 3 +1495 89 2 24 2 +1496 89 2 24 1 +1497 89 2 24 0 +1498 76 2 25 28 +1499 76 2 25 27 +1500 76 2 25 26 +1501 84 2 25 25 +1502 84 2 25 24 +1503 84 2 25 23 +1504 82 2 25 22 +1505 84 2 25 21 +1506 85 2 25 20 +1507 85 2 25 19 +1508 85 2 25 18 +1509 85 2 25 17 +1510 86 2 25 16 +1511 86 2 25 15 +1512 86 2 25 14 +1513 86 2 25 13 +1514 87 2 25 12 +1515 87 2 25 11 +1516 87 2 25 10 +1517 87 2 25 9 +1518 88 2 25 8 +1519 88 2 25 7 +1520 88 2 25 6 +1521 89 2 25 5 +1522 89 2 25 4 +1523 89 2 25 3 +1524 89 2 25 2 +1525 89 2 25 1 +1526 77 2 25 0 +1527 76 2 26 28 +1528 83 2 26 27 +1529 83 2 26 26 +1530 83 2 26 25 +1531 82 2 26 24 +1532 82 2 26 23 +1533 82 2 26 22 +1534 82 2 26 21 +1535 81 2 26 20 +1536 81 2 26 19 +1537 81 2 26 18 +1538 81 2 26 17 +1539 80 2 26 16 +1540 80 2 26 15 +1541 80 2 26 14 +1542 80 2 26 13 +1543 79 2 26 12 +1544 79 2 26 11 +1545 79 2 26 10 +1546 79 2 26 9 +1547 88 2 26 8 +1548 88 2 26 7 +1549 78 2 26 6 +1550 78 2 26 5 +1551 78 2 26 4 +1552 89 2 26 3 +1553 89 2 26 2 +1554 77 2 26 1 +1555 77 2 26 0 +1556 83 2 27 28 +1557 83 2 27 27 +1558 83 2 27 26 +1559 83 2 27 25 +1560 83 2 27 24 +1561 82 2 27 23 +1562 82 2 27 22 +1563 82 2 27 21 +1564 81 2 27 20 +1565 81 2 27 19 +1566 81 2 27 18 +1567 81 2 27 17 +1568 80 2 27 16 +1569 80 2 27 15 +1570 80 2 27 14 +1571 80 2 27 13 +1572 79 2 27 12 +1573 79 2 27 11 +1574 79 2 27 10 +1575 79 2 27 9 +1576 78 2 27 8 +1577 78 2 27 7 +1578 78 2 27 6 +1579 78 2 27 5 +1580 78 2 27 4 +1581 77 2 27 3 +1582 77 2 27 2 +1583 77 2 27 1 +1584 77 2 27 0 +1585 83 2 28 28 +1586 83 2 28 27 +1587 83 2 28 26 +1588 83 2 28 25 +1589 82 2 28 24 +1590 82 2 28 23 +1591 82 2 28 22 +1592 82 2 28 21 +1593 81 2 28 20 +1594 81 2 28 19 +1595 81 2 28 18 +1596 81 2 28 17 +1597 80 2 28 16 +1598 80 2 28 15 +1599 80 2 28 14 +1600 80 2 28 13 +1601 79 2 28 12 +1602 79 2 28 11 +1603 79 2 28 10 +1604 79 2 28 9 +1605 78 2 28 8 +1606 78 2 28 7 +1607 78 2 28 6 +1608 78 2 28 5 +1609 77 2 28 4 +1610 77 2 28 3 +1611 77 2 28 2 +1612 77 2 28 1 +1613 77 2 28 0 +1614 83 2 29 27 +1615 83 2 29 26 +1616 83 2 29 25 +1617 83 2 29 24 +1618 82 2 29 23 +1619 82 2 29 22 +1620 82 2 29 21 +1621 82 2 29 20 +1622 81 2 29 19 +1623 81 2 29 18 +1624 81 2 29 17 +1625 81 2 29 16 +1626 80 2 29 15 +1627 80 2 29 14 +1628 80 2 29 13 +1629 80 2 29 12 +1630 79 2 29 11 +1631 79 2 29 10 +1632 79 2 29 9 +1633 79 2 29 8 +1634 78 2 29 7 +1635 78 2 29 6 +1636 78 2 29 5 +1637 78 2 29 4 +1638 77 2 29 3 +1639 77 2 29 2 +1640 77 2 29 1 +1641 77 2 29 0 diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_ClockNoise.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_ClockNoise.cxx new file mode 100644 index 000000000000..0f9a9f023d58 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_ClockNoise.cxx @@ -0,0 +1,653 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TRT_DetectorPerformance/TRT_ClockNoise.h" + +//#include "GaudiKernel/IJobOptionsSvc.h" +//#include "GaudiKernel/ITHistSvc.h" +//#include "GaudiKernel/ToolHandle.h" + +#include "StoreGate/DataHandle.h" + +#include "DataModel/DataVector.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" +#include "InDetReadoutGeometry/TRT_Numerology.h" + +#include "InDetRawData/InDetRawDataContainer.h" +#include "InDetRawData/InDetRawDataCLASS_DEF.h" + +#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" +#include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" +#include "InDetRIO_OnTrack/PixelClusterOnTrack.h" +#include "InDetPrepRawData/TRT_DriftCircle.h" + +//#include "TrkParameters/MeasuredPerigee.h" +#include "TrkParameters/TrackParameters.h" +//#include "TrkTrackSummaryTool/ITrackSummaryTool.h" +#include "TrkTrackSummary/TrackSummary.h" +//#include "TrkParameters/MeasuredAtaStraightLine.h" +#include "TRT_ConditionsServices/ITRT_StrawNeighbourSvc.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummarySvc.h" + +#include "TrkTrack/Track.h" +#include "TrkTrack/TrackCollection.h" + +#include "TRT_DetectorPerformance/TRT_StrawMap.h" + +#include "TTree.h" +//#include "TVirtualFFT.h" +#include "TComplex.h" + + +///////////////////////////////////////////////////////////////////////////// + +InDet::TRT_ClockNoise::TRT_ClockNoise(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name, pSvcLocator), + m_trtStrawNeighbourTool("TRT_StrawNeighbourSvc", name), + m_trtStrawMap("InDet::TRT_StrawMap"), + m_TRTStrawStatusSummarySvc("TRT_StrawStatusSummarySvc", name), + m_print_ntuple(false), + m_textfile("clocknoise.dat"), + m_min_noise_hits(100), + m_min_asym(0.9), + m_histSvc("THistSvc", name) +{ + declareProperty("printNtuple", m_print_ntuple); + declareProperty("outputTextFileName", m_textfile); + declareProperty("histogramService", m_histSvc); + declareProperty("minNoiseHits",m_min_noise_hits); + declareProperty("minAsymmetry",m_min_asym); + + m_ntuple = 0; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode InDet::TRT_ClockNoise::initialize(){ + + if (msgLvl(MSG::INFO)) msg() << "TRT_ClockNoise::initialize()" << endreq; + + m_evtNum = 0; + + // initialize occupancy array + for (int iphi=0; iphi<nPhi; ++iphi) { + for (int iside=0; iside<nSide; ++iside) { + for (int istraw=0; istraw<nStraw; ++istraw) { + for (int ibin=0; ibin<nBin; ++ibin) { + m_straw_bin_occ[iphi][iside][istraw][ibin] = 0; + } + } + } + } + + if (m_print_ntuple) { + ////////////////////////////////////////////// + // Create TTree and register it to THistSvc + ////////////////////////////////////////////// + // get StoreGate service + + if ( m_histSvc.retrieve().isFailure() ){ + msg(MSG::FATAL) << "histogram service not found" << endreq; + return StatusCode::FAILURE; + } else + if (msgLvl(MSG::INFO)) msg() << "retrieved histogramService" << endreq; + + if (m_TRTStrawStatusSummarySvc.retrieve().isFailure()) { + msg(MSG::ERROR) << "could not retrieve m_TRTStrawStatusSummarySvc" << endreq; + } else { + msg(MSG::INFO) << "retrieved m_TRTStrawStatusSummarySvc" << endreq; + } + + m_ntuple = new TTree("ntuple" , "ntuple"); + + std::string fullTreeName_ntuple = "/noise/ntuple" ; + if((m_histSvc->regTree(fullTreeName_ntuple, m_ntuple)).isFailure()) + { + msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeName_ntuple << endreq; + return StatusCode::FAILURE; + } + + ////////////////////////////////////////////////////// + /// Book variables to be added to the output ntuple + ////////////////////////////////////////////////////// + m_ntuple->Branch("LEbin" , &m_leadingEdgeBin , "LEbin/I"); + m_ntuple->Branch("board" , &m_board , "board/I"); + m_ntuple->Branch("chip" , &m_chip , "chip/I"); + m_ntuple->Branch("pad" , &m_pad , "pad/I"); + m_ntuple->Branch("side" , &m_side , "side/I"); + m_ntuple->Branch("phi" , &m_phi , "phi/I"); + m_ntuple->Branch("straw" , &m_straw , "straw/I"); + m_ntuple->Branch("strawLayer" , &m_strawLayer , "strawLayer/I"); + m_ntuple->Branch("layer" , &m_layer , "layer/I"); + m_ntuple->Branch("evtNum" , &m_evtNum , "evtNum/I"); + + } + + if (msgLvl(MSG::INFO)) msg() << "end initialize()" << endreq; + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode InDet::TRT_ClockNoise::execute() { + + if (msgLvl(MSG::DEBUG)) msg() << "execute()" << endreq; + + // TRT helper + const TRT_ID * m_trtHelper; + if (detStore()->retrieve(m_trtHelper, "TRT_ID").isFailure()) { + msg(MSG::FATAL) << "Could not get TRT ID helper" << endreq; + return StatusCode::FAILURE; + } + + const DataVector<Trk::Track> *trkCollection = 0; + StatusCode sc = evtStore()->retrieve( trkCollection, "Tracks" ); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Could not find Tracks Collection" << endreq; + return sc; + } + assert( trkCollection ); + if ( trkCollection == 0 ) msg(MSG::ERROR) << "trkCollection == 0 " << endreq; + + sc = m_trtStrawNeighbourTool.retrieve() ; + if (sc.isFailure()) { + msg(MSG::ERROR) << "Could not find TRTStrawNeighbourTool " << endreq; + return sc; + } + + + // vector to keep track of the identifiers for hits on track, so we can exclude them later + std::vector<Identifier> associatedRDO; + + + int nTracks = trkCollection->size(); + int countTracks = 0; + if (msgLvl(MSG::VERBOSE)) msg() << "starting DataVector<Trk::Track> loop over nTracks = " << nTracks << endreq; + // loop over all tracks + for ( DataVector<Trk::Track>::const_iterator trackIt = trkCollection->begin(); trackIt != trkCollection->end(); ++trackIt ) { + + assert( countTracks < nTracks ); ++countTracks; + + + if (msgLvl(MSG::VERBOSE)) msg() << "start DataVector<const Trk::TrackStateOnSurface>* trackStates " << endreq; + const DataVector<const Trk::TrackStateOnSurface>* trackStates = (**trackIt).trackStateOnSurfaces(); + if ( trackStates == 0 ) { + if (msgLvl(MSG::WARNING)) msg() << "Trk::TrackStateOnSurface empty" << endreq; + continue; + } + + if (msgLvl(MSG::VERBOSE)) msg() << "start DataVector<const Trk::TrackStateOnSurface>* trackStatesIt " << trackStates->size() << endreq; + int countTrackStates(0); + + + // loop over all "trackStates", in principle one state is associated to each measurement + one more trackState for track parameters at the Interaction Point + for ( DataVector<const Trk::TrackStateOnSurface>::const_iterator trackStatesIt = trackStates->begin(); trackStatesIt != trackStates->end(); ++trackStatesIt ) { + + if (msgLvl(MSG::VERBOSE)) msg() << "countTrackStates " << countTrackStates << endreq; + assert( countTrackStates < (int) trackStates->size() ); ++countTrackStates; + assert( (*trackStatesIt) != 0 ); + if ( *trackStatesIt == 0 ) { if (msgLvl(MSG::WARNING)) msg() << "*trackStatesIt == 0" << endreq; } + + //CLHEP::Hep3Vector pos(0., 0., 0.); + //CLHEP::Hep3Vector mom(0., 0., 0.); + Amg::Vector3D pos(0., 0., 0.); + Amg::Vector3D mom(0., 0., 0.); + + const Trk::TrackParameters* trackParam = (*trackStatesIt)->trackParameters(); + if ( trackParam != 0 ) { + + pos = trackParam->position(); + mom = trackParam->momentum(); + + } else { + + if (msgLvl(MSG::WARNING)) msg() << "(*trackStatesIt)->trackParameters() == NULL" << endreq; + } + + + + if ( (*trackStatesIt)->type(Trk::TrackStateOnSurface::Measurement) ) { + + // try to dynamic cast as SCT space points etc to count the number of silicon hits + if (dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())!=0) { + continue; + } + + if (dynamic_cast<const InDet::PixelClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())!=0) { + continue; + } + + if (msgLvl(MSG::VERBOSE)) msg() << "drift Circle " << endreq; + const InDet::TRT_DriftCircleOnTrack *driftCircleOnTrack = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>( (*trackStatesIt)->measurementOnTrack() ); + if ( driftCircleOnTrack == 0 ) { +// if (msgLvl(MSG::WARNING)) msg() << "driftCircleOnTrack == 0" << endreq; + continue; + } + //HepGeom::Point3D<double> hit = driftCircleOnTrack->globalPosition(); + Amg::Vector3D hit = driftCircleOnTrack->globalPosition(); + if (msgLvl(MSG::VERBOSE)) msg() << "driftCircleOnTrack global position " << hit << endreq; + + const InDet::TRT_DriftCircle *driftCircle = dynamic_cast<const InDet::TRT_DriftCircle*> (driftCircleOnTrack->prepRawData()); + if ( driftCircle == 0 ) { +// if (msgLvl(MSG::WARNING)) msg() << "driftCircle == 0" << endreq; + continue; + } + if (msgLvl(MSG::VERBOSE)) msg() << "track measurement trail. edge " << driftCircle->trailingEdge() << " " + << ((int) driftCircle->driftTimeValid()) + << " Base valid " << ( (driftCircleOnTrack->detectorElement() == 0) ? 0 : 1 ) << endreq; + +// add this drift circle to me vector of Identifiers from hits on track + const std::vector<Identifier> &listRDO = driftCircle->rdoList(); + // log << MSG::INFO << "test RDO " << listRDO.size() << endreq; + for (unsigned int i=0; i<listRDO.size(); ++i) associatedRDO.push_back(listRDO[i]); + + } // end if(measurement) + } // end loop over trackstates + } // end loop over tracks + + +// -------------------------------------------------------- +// loop over RDO hits, record hits NOT on track: + + + const TRT_RDO_Container* rdoContainer; + sc = evtStore()->retrieve(rdoContainer, "TRT_RDOs"); + if ( sc.isFailure() ) { + + msg(MSG::ERROR) << "no TRT_RDOs container available " << endreq; + return sc; + } + + for (TRT_RDO_Container::const_iterator rdoIt = rdoContainer->begin(); rdoIt != rdoContainer->end(); ++rdoIt) { + + const InDetRawDataCollection<TRT_RDORawData>* TRTCollection(*rdoIt); + if (TRTCollection==0) continue; + + for (DataVector<TRT_RDORawData>::const_iterator trtIt = TRTCollection->begin(); trtIt != TRTCollection->end(); ++trtIt) { + + Identifier elID = (*trtIt)->identify(); + + // check whether this is a dead straw -- will return 1 if dead + if (m_TRTStrawStatusSummarySvc->get_status(elID) == 1) continue; + + // use std::find to see if this identifier is in our vector of hits on track + // if we find the identifier, skip this hit + // if the identifier is not found, std::find returns associatedRDO.end() + if (std::find(associatedRDO.begin(),associatedRDO.end(),elID) != associatedRDO.end()) continue; + + m_trtStrawMap->setNewIdentifier(elID); + + // note that valid leading edge bins are 1-23 + // 0 is not a valid bin, and instead this method will return 24 + int leadingEdgeBin = (*trtIt)->driftTimeBin(); + int side = m_trtHelper->barrel_ec(elID); + int layer = m_trtHelper->layer_or_wheel(elID); + int phi = m_trtHelper->phi_module(elID); + int strawLayer = m_trtHelper->straw_layer(elID); + int myStrawNumber = m_trtStrawMap->straw(); + int chip; m_trtStrawNeighbourTool->getChip(elID, chip); + int pad; m_trtStrawNeighbourTool->getPad(elID, pad); + int myBoard = m_trtStrawMap->board(); + + // need to correct chip numbers in barrel, not in endcap + if(abs(side) == 1) // barrel + { + // set chip number to correct scale + chip-=1; + if(layer == 1) chip+=21; + else if(layer == 2) chip+=54; + } + + if (myStrawNumber < 0 || myStrawNumber>=nStraw) { if (msgLvl(MSG::WARNING)) msg() << "invalid straw number !!! " << myStrawNumber << endreq; continue; } + + // ------ add hit information to array ------------ + int AorC = 0; + if (side > 0) AorC = 1; + + // bin 24 is not valid, so don't consider those hits for calculating clock noise + if (leadingEdgeBin < 24) { + ++(m_straw_bin_occ[phi][AorC][myStrawNumber][leadingEdgeBin]); + } + + if (m_print_ntuple) { + // ------ store hit info in ntuple ---------------- + + m_leadingEdgeBin = leadingEdgeBin; + m_board = myBoard; + m_chip = chip; + m_pad = pad; + m_side = side; + m_phi = phi; + m_straw = myStrawNumber; + m_strawLayer = strawLayer; + m_layer = layer; + + m_ntuple->Fill(); + } + + } + } // loop over RDO container + + // increment our internal event counter + ++m_evtNum; + + if (msgLvl(MSG::DEBUG)) msg() << "end execute()" << endreq; + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +StatusCode InDet::TRT_ClockNoise::finalize() { + + if (msgLvl(MSG::INFO)) msg() << "finalize()" << endreq; + if (msgLvl(MSG::INFO)) msg() << "Calculating noise -- this takes a few seconds" << endreq; + int numNoisyStraws = classify_noise(); + if (msgLvl(MSG::INFO)) msg() << numNoisyStraws << " straws showed clock noise, printed to file " << m_textfile << endreq; + if (m_print_ntuple) { + if (msgLvl(MSG::INFO)) msg() << "occupancy information printed to ntuple" << endreq; + } + + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +// ---------------------------------------------------------------- +// clock noise definition is implemented here +int InDet::TRT_ClockNoise::clock_noise_cut(int totalocc, float asym) { + + if ((totalocc >= m_min_noise_hits) && (asym > m_min_asym)) + return 1; + + return -1; +} + +// ---------------------------------------------------------------- +int InDet::TRT_ClockNoise::classify_noise() { + + // open an output text file + std::ofstream out; + out.open(m_textfile.c_str()); + + int numNoisyStraws = 0; + + // loop over all straws and look at occupancy for clock noise + for (int iphi=0; iphi < nPhi; ++iphi) { + for (int iside=0; iside < nSide; ++iside) { + for (int istraw = 0; istraw < nStraw; ++istraw) { + + // get the occupancy info for this straw + int occ[24]; + int totalocc = 0; + int occbins = 0; + for (int ibin=0;ibin<24;++ibin) { + occ[ibin] = m_straw_bin_occ[iphi][iside][istraw][ibin]; + totalocc += occ[ibin]; + if (occ[ibin] > 0) ++occbins; + } + + // clock noise calculations: + // find the maximum asymmetry and corresponding phase for 40MHz and 80MHz + // then classify the type of noise being seen + + int phase40 = -1; + float occ_above_thermal40 = 0; + bool noisy40 = false; + float asym40 = find_max_asymmetry(occ,PERIOD_40MHZ,&phase40,&occ_above_thermal40); + // see if this passes our definition of clock noise + if (clock_noise_cut(totalocc,asym40) > 0) noisy40 = true; + + + int phase80 = -1; + float occ_above_thermal80 = 0; + bool noisy80 = false; + float asym80 = find_max_asymmetry(occ,PERIOD_80MHZ,&phase80,&occ_above_thermal80); + // see if this passes our definition of clock noise + if (clock_noise_cut(totalocc,asym80) > 0) noisy80 = true; + + // use a discrete fourier transform to pick out frequency components of the noise + float dft_thermal_comp = 0.; + float dft_40mhz_comp = 0.; + float dft_80mhz_comp = 0.; + int dft_phase40 = -1; + int dft_phase80 = -1; + DFT(occ,&dft_thermal_comp,&dft_40mhz_comp,&dft_phase40,&dft_80mhz_comp,&dft_phase80); + + // the most interesting figures of merit from the DFT are: + // - the ratio of the 40mhz component to the thermal component + // - the ratio of the 80mhz component to the thermal component + float dft_40mhz_ratio = 0.; + float dft_80mhz_ratio = 0.; + if (dft_thermal_comp > 0) { + dft_40mhz_ratio = dft_40mhz_comp / dft_thermal_comp; + dft_80mhz_ratio = dft_80mhz_comp / dft_thermal_comp; + } + + if(noisy40 || noisy80) { + + ++numNoisyStraws; + + // if this straw passed the cut, print it to a text file along with some relevant info + // text file format: + // phi | side | straw | frequency | phase | asymmetry | dft_phase | dft_ratio | occ_above_thermal | totalocc + + // make two entries if a straw shows both 40 and 80MHz noise + + if (noisy40) { + out << std::setw(2) << iphi << std::setw(4) << recover_side(iside,istraw) + << std::setw(6) << istraw << " 40" << std::setw(4) << phase40 + << std::setw(12) << asym40 + << std::setw(4) << dft_phase40 + << std::setw(12) << dft_40mhz_ratio + << std::setw(10) << int(occ_above_thermal40) + << std::setw(10) << totalocc << std::endl; + } + + if (noisy80) { + out << std::setw(2) << iphi << std::setw(4) << recover_side(iside,istraw) + << std::setw(6) << istraw << " 80" << std::setw(4) << phase80 + << std::setw(12) << asym80 + << std::setw(4) << dft_phase80 + << std::setw(12) << dft_80mhz_ratio + << std::setw(10) << int(occ_above_thermal80) + << std::setw(10) << totalocc << std::endl; + } + + } // noisy straw + + } // end straw loop + + } // end side loop + + } // end phi loop + + out.close(); + + return numNoisyStraws; +} + +// ---------------------------------------------------------------- +float InDet::TRT_ClockNoise::find_max_asymmetry(int occ[24], int period, int* phase, float* occ_above_thermal) { + float max_asym = 0.; + *phase = -1; + *occ_above_thermal = 0; + + // loop over all possible phases and find the maximum asymmetry + for (int p=0; p<period; ++p) { + float temp_occ; + float asym = find_asymmetry(occ,period,p,&temp_occ); + if (asym > max_asym) { + max_asym = asym; + *phase = p; + *occ_above_thermal = temp_occ; + } + } + + // if none of the asym values are > 0, the return values will be + // 0. for asym and -1 for phase + + return max_asym; +} + + +// ---------------------------------------------------------------- +float InDet::TRT_ClockNoise::find_asymmetry(int occ[24], int period, int phase, float* occ_above_thermal) { + + float sum_max = 0; + float sum_min = 0; + int numbins = 0; + int numbins_to_sum = 24/period; // 6 for 80MHz, 3 for 40MHz + float thermal_occ = 0; + + // sum up the occupancy from bins that should have the maximum number of hits + // these are assumed to be integer multiples of the period away from the bin + // with the max number of hits (which we know from the phase) + // + // note that bin 0 is not valid for leading edge, and there will never be any hits there + // so we weight the sum differently if bin 0 is one of the summed bins (below) + for (int ibin=phase; ibin < 24; ibin += period) { + sum_max += occ[ibin]; + ++numbins; + } + + // check that we did the sum correctly + if (numbins != numbins_to_sum) { + if (msgLvl(MSG::WARNING)) msg() << "!! sum_max: only summed " << numbins << " bins for period " << period << endreq; + } + + // do the same for the bins which should have the minimum number of hits + // these occur a half period away from the maximum + // this sum may need to wrap, depending on the phase + int start_bin = -1; + if ((phase - period/2) >= 0) { + start_bin = phase - period/2; + } else { + start_bin = phase + period/2; + } + + numbins = 0; + for (int ibin = start_bin; ibin < 24; ibin += period) { + sum_min += occ[ibin]; + ++numbins; + } + + // check that we did the sum correctly + if (numbins != numbins_to_sum) { + if (msgLvl(MSG::WARNING)) msg() << "!! sum_min: only summed " << numbins << " bins for period " << period << endreq; + } + + // find the thermal background: + // just use sum_min / (number of bins summed) + thermal_occ = sum_min/float(numbins_to_sum); + + // weight the sums differently if one of them included bin 0 + if (phase == 0) { // sum_max includes bin 0 + sum_min *= float(numbins_to_sum - 1)/float(numbins_to_sum); + } else if (start_bin == 0) { // sum_min includes bin 0 + sum_max *= float(numbins_to_sum - 1)/float(numbins_to_sum); + thermal_occ = sum_min/float(numbins_to_sum - 1); + } + + // now calculate the asymmetry + float asym = (sum_max - sum_min) / (sum_max + sum_min); + + // calcuate the occupancy above the "thermal background" + // if a bin is below the "thermal background," ignore it + *occ_above_thermal = 0; + for (int ibin = 1; ibin<24; ++ibin) { + float occ_extra = float(occ[ibin]) - thermal_occ; + if (occ_extra > 0) { + *occ_above_thermal += occ_extra; + } + } + + return asym; +} + +// ---------------------------------------------------------------- +int InDet::TRT_ClockNoise::DFT(int occ[24], float* comp0mhz, float* comp40mhz, int* phase40mhz, float* comp80mhz, int* phase80mhz) +{ + Int_t N = 16; + Double_t occf[16]; + Int_t offset = 4; + for (int i=0; i<16; ++i) { + occf[i] = float(occ[i+offset]); + } + + // the transform returns 16 (complex valued) bins + // we're interested in the modulus of the following bins: + // bin 0: thermal component (no frequency) + // bin 2: 40Mhz component + // bin 4: 80Mhz component + +// // transform using ROOT class -- requires FFTW libraries to be installed with ROOT +// // which isn't always the case for the LCG installs +// TVirtualFFT *dftr2c = TVirtualFFT::FFT(1, &N, "R2C"); +// dftr2c->SetPoints(occf); +// dftr2c->Transform(); +// Double_t re, im; +// dftr2c->GetPointComplex(0, re, im); +// *comp0mhz = sqrt(re*re + im*im); +// dftr2c->GetPointComplex(2, re, im); +// *comp40mhz = sqrt(re*re + im*im); +// *phase40mhz = find_dft_phase(re,im,PERIOD_40MHZ,offset); +// dftr2c->GetPointComplex(4, re, im); +// *comp80mhz = sqrt(re*re + im*im); +// *phase80mhz = find_dft_phase(re,im,PERIOD_80MHZ,offset); + + // do the transform by hand -- had to resort to this because the ROOT install for LCG56a doesn't have + // the FFTW libraries ROOT needs installed .... + TComplex* trans = new TComplex[N]; + for (int k = 0; k < N; ++k) { + trans[k] = TComplex(0.,0.); + for (int n = 0; n < N; ++n) { + trans[k] += occf[n]*TComplex(1,-2*M_PI*k*n/N,true); + } + } + *comp0mhz = TComplex::Abs(trans[0]); + *comp40mhz = TComplex::Abs(trans[2]); + *phase40mhz = find_dft_phase(trans[2].Re(),trans[2].Im(),PERIOD_40MHZ,offset); + *comp80mhz = TComplex::Abs(trans[4]); + *phase80mhz = find_dft_phase(trans[4].Re(),trans[4].Im(),PERIOD_80MHZ,offset); + + delete[] trans; + + return 0; +} + +// ---------------------------------------------------------------- +int InDet::TRT_ClockNoise::find_dft_phase(float re, float im, int period, int offset) +{ + // determined this relationship by playing around with toy distributions + int phase = int(floor((period*5/4 - ((period/4)*(((atan2(im,re) + M_PI) * 2/M_PI) - 1)))+0.5) + offset)%(period); + + return phase; +} + + +// ---------------------------------------------------------------- +int InDet::TRT_ClockNoise::recover_side(int AorC, int straw) +{ + if (AorC == 0) { // C side + if (straw >= nStrawB) { // endcap C + return -2; + } else { // barrel C + return -1; + } + } else { // A side + if (straw < nStrawB) { // barrel A + return 1; + } else { // endcap A + return 2; + } + } + + // should never get here + return 0; +} diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DTMROC_HeaderCheck.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DTMROC_HeaderCheck.cxx new file mode 100644 index 000000000000..01c45536e9e9 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DTMROC_HeaderCheck.cxx @@ -0,0 +1,348 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TRT_DTMROC_HeaderCheck.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#include "TRT_DetectorPerformance/TRT_DTMROC_HeaderCheck.h" +#include <set> +#include <fstream> +#include <string> + + +using namespace std; + +//================ Constructor ================================================= + +InDet::TRT_DTMROC_HeaderCheck::TRT_DTMROC_HeaderCheck(const std::string& name, ISvcLocator* pSvcLocator) + : + AthAlgorithm(name,pSvcLocator), + m_sgSvc("StoreGateSvc",name), + m_histSvc("THistSvc", name), + m_bytestream_conditionsSvc("TRT_ByteStream_ConditionsSvc",name), + eventCount(-1) +{ + declareProperty("StoreGateSvc", m_sgSvc); + declareProperty("THistSvc", m_histSvc); + declareProperty("TRT_ByteStream_ConditionsSvc", m_bytestream_conditionsSvc); +} + +//================ Destructor ================================================= + +InDet::TRT_DTMROC_HeaderCheck::~TRT_DTMROC_HeaderCheck() +{} + + +//================ Initialisation ================================================= + +StatusCode InDet::TRT_DTMROC_HeaderCheck::initialize() +{ + + if (msgLvl(MSG::VERBOSE)) msg(MSG::INFO) << name() << " initialize()" << endreq; + + // retrieve the StoreGate Service + if ( m_sgSvc.retrieve().isFailure() ) { + msg(MSG::FATAL) << "Failed to retrieve service " << m_sgSvc << endreq; + return StatusCode::FAILURE; + } else + msg(MSG::INFO) << "Retrieved service " << m_sgSvc << endreq; + + //retrieve Bytestream_conditions Service + if ( m_bytestream_conditionsSvc.retrieve().isFailure() ) { + msg(MSG::FATAL) << "Failed to retrieve service " << m_bytestream_conditionsSvc << endreq; + return StatusCode::FAILURE; + } else + if (msgLvl(MSG::VERBOSE)) msg(MSG::INFO) << "Retrieved service " << m_bytestream_conditionsSvc << endreq; + + //retrieve Histogramming Service + if ( m_histSvc.retrieve().isFailure() ){ + msg(MSG::FATAL) << "Failed to retrieve service " << m_histSvc << endreq; + return StatusCode::FAILURE; + } else + if (msgLvl(MSG::VERBOSE)) msg(MSG::INFO) << "Retrieved service " << m_histSvc << endreq; + + //create map for DTMROC id's + + ifstream f("../src/mapping.txt"); //This assumes that the jobOptions are run from a run directory at the same leves as src + if (f.fail()) { + msg(MSG::FATAL) << "Unable to find mapping file" << endreq; + return StatusCode::FAILURE; + } + dtmroc_map = new std::map<uint32_t,uint32_t>; + uint32_t header_word; + uint32_t output_id; + std::string line; + + while (getline(f, line)){ + sscanf(line.c_str(),"%x, %u", &header_word, &output_id); + dtmroc_map->insert(std::pair<uint32_t,uint32_t>(header_word, output_id)); + } + + + /////////////// + //Initialize TTree and register with THistSvc + /////////////// + + m_tree = new TTree("dtmrocHeaders", "dtmrocHeaders"); + + std::string fullTreeName = "/AANT/dtmrocHeaders" ; + if((m_histSvc->regTree(fullTreeName, m_tree)).isFailure()) { + msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeName << endreq; + return StatusCode::FAILURE; + } + + //////////// + //Add Branches to TTree to be output to Ntuple + //////////// + + m_tree->Branch("event_number", &m_event_number, "event_number/i"); + m_tree->Branch("time_stamp", &m_time_stamp, "time_stamp/i"); + m_tree->Branch("time_stamp_ns_offset", &m_time_stamp_ns_offset, "time_stamp_ns_offset/i"); + + m_tree->Branch("total_num_l1id_err", &m_total_num_l1id, "total_num_l1id_err/i"); + m_tree->Branch("total_num_bcid_err", &m_total_num_bcid, "total_num_bcid_err/i"); + m_tree->Branch("total_num_missing_err", &m_total_num_missing, "total_num_missing_err/i"); + m_tree->Branch("total_num_general_err", &m_total_num_general, "total_num_general_err/i"); + m_tree->Branch("total_num_sendid_err", &m_total_num_sendid, "total_num_sendid_err/i"); + + m_tree->Branch("bcid_returned_by_ROD", &m_bcid_returned_by_ROD, "bcid_returned_by_ROD/i"); + m_tree->Branch("l1id_returned_by_ROD", &m_l1id_returned_by_ROD, "l1id_returned_by_ROD/i"); + + m_tree->Branch("l1id_dtmroc_index", &m_l1id_dtmroc_index); + m_tree->Branch("l1id_dtmroc_index_remap", &m_l1id_dtmroc_index_remap); + m_tree->Branch("l1id_rod_index", &m_l1id_rod_index); + m_tree->Branch("l1id_returned_l1id", &m_l1id_returned_l1id); + + m_tree->Branch("bcid_dtmroc_index", &m_bcid_dtmroc_index); + m_tree->Branch("bcid_dtmroc_index_remap", &m_bcid_dtmroc_index_remap); + m_tree->Branch("bcid_rod_index", &m_bcid_rod_index); + m_tree->Branch("bcid_returned_bcid", &m_bcid_returned_bcid); + + m_tree->Branch("missing_dtmroc_index", &m_missing_dtmroc_index); + m_tree->Branch("missing_dtmroc_index_remap", &m_missing_dtmroc_index_remap); + m_tree->Branch("missing_rod_index", &m_missing_rod_index); + + m_tree->Branch("general_dtmroc_index", &m_general_dtmroc_index); + m_tree->Branch("general_dtmroc_index_remap", &m_general_dtmroc_index_remap); + m_tree->Branch("general_rod_index", &m_general_rod_index); + + m_tree->Branch("sendid_dtmroc_index", &m_sendid_dtmroc_index); + m_tree->Branch("sendid_dtmroc_index_remap", &m_sendid_dtmroc_index_remap); + m_tree->Branch("sendid_rod_index", &m_sendid_rod_index); + + //Initialize variables + m_event_number = 0; + m_time_stamp = 0; + m_time_stamp_ns_offset = 0; + + m_total_num_l1id=0; + m_total_num_bcid=0; + m_total_num_missing=0; + m_total_num_general=0; + m_total_num_sendid=0; + + m_bcid_returned_by_ROD = 0; + m_l1id_returned_by_ROD = 0; + + m_l1id_dtmroc_index = new std::vector<uint32_t>; + m_l1id_dtmroc_index_remap = new std::vector<uint32_t>; + m_l1id_rod_index = new std::vector<uint32_t>; + m_l1id_returned_l1id = new std::vector<uint32_t>; + + m_bcid_dtmroc_index = new std::vector<uint32_t>; + m_bcid_dtmroc_index_remap = new std::vector<uint32_t>; + m_bcid_rod_index = new std::vector<uint32_t>; + m_bcid_returned_bcid = new std::vector<uint32_t>; + + m_missing_dtmroc_index = new std::vector<uint32_t>; + m_missing_dtmroc_index_remap = new std::vector<uint32_t>; + m_missing_rod_index = new std::vector<uint32_t>; + + m_general_dtmroc_index = new std::vector<uint32_t>; + m_general_dtmroc_index_remap = new std::vector<uint32_t>; + m_general_rod_index = new std::vector<uint32_t>; + + m_sendid_dtmroc_index = new std::vector<uint32_t>; + m_sendid_dtmroc_index_remap = new std::vector<uint32_t>; + m_sendid_rod_index = new std::vector<uint32_t>; + + if (msgLvl(MSG::VERBOSE)) msg(MSG::INFO) << "initialize() successful in " << name() << endreq; + return StatusCode::SUCCESS; +} + +//================ Finalisation ================================================= + +StatusCode InDet::TRT_DTMROC_HeaderCheck::finalize() +{ + // Code entered here will be executed once at the end of the program run. + return StatusCode::SUCCESS; +} + +//================ Execution ==================================================== + +StatusCode InDet::TRT_DTMROC_HeaderCheck::execute() +{ + + ++eventCount; + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "InDet::TRT_DetectorPlots::execute() event " << eventCount << endreq; + + ////////////////////////// + /// Retrieve event info + ////////////////////////// + if(msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Retrieving event info for event " << eventCount << endreq; + + m_bcid_returned_by_ROD = 0; + TRT_BCIDColl = 0; +/* + StatusCode sc = m_sgSvc->retrieve(TRT_BCIDColl,"TRT_BCID"); + if (sc.isFailure()){ + msg(MSG::ERROR) << "BCID Collection not found in Store Gate" <<endreq; + m_bcid_returned_by_ROD = -1; + } else { + InDetTimeCollection::const_iterator itrt_bcid = TRT_BCIDColl->begin(); + m_bcid_returned_by_ROD = (*itrt_bcid)->second; // perhaps not the best method - just trusting the first ROD to always have the right BCID + } +*/ + m_l1id_returned_by_ROD = 0; + TRT_L1IDColl = 0; +/* + sc = m_sgSvc->retrieve(TRT_L1IDColl,"TRT_LVL1ID"); + if (sc.isFailure()){ + msg(MSG::ERROR) << "L1ID Collection not found in Store Gate" <<endreq; + m_l1id_returned_by_ROD = -1; + } else { + InDetTimeCollection::const_iterator itrt_l1id = TRT_L1IDColl->begin(); + m_l1id_returned_by_ROD = (*itrt_l1id)->second; // perhaps not the best method - just trusting the first ROD to always have the right L1ID + } + */ + const EventInfo* eventInfo; + if (m_sgSvc->retrieve(eventInfo).isFailure()) { + msg(MSG::ERROR) << "Could not retrieve event identifier from Store Gate"<<endreq; + m_event_number =0; + } else { + EventID* evtid = eventInfo->event_ID(); + m_event_number = evtid->event_number(); + m_time_stamp = evtid->time_stamp(); + m_time_stamp_ns_offset = evtid->time_stamp_ns_offset(); + } + + + if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "InDet::TRT_DTMROC_HeaderCheck:: execute() retrieved event info for event " << eventCount << endreq; + + /////////////////// + //Initialize containers + /////////////////// + + m_l1id_dtmroc_index->clear(); + m_l1id_dtmroc_index_remap->clear(); + m_l1id_rod_index->clear(); + m_l1id_returned_l1id->clear(); + + m_bcid_dtmroc_index->clear(); + m_bcid_dtmroc_index_remap->clear(); + m_bcid_rod_index->clear(); + m_bcid_returned_bcid->clear(); + + + m_missing_dtmroc_index->clear(); + m_missing_dtmroc_index_remap->clear(); + m_missing_rod_index->clear(); + + m_general_dtmroc_index->clear(); + m_general_dtmroc_index_remap->clear(); + m_general_rod_index->clear(); + + m_sendid_dtmroc_index->clear(); + m_sendid_dtmroc_index_remap->clear(); + m_sendid_rod_index->clear(); + + ///////////////////////// + //Load/derive Ntuple Data + ///////////////////////// + + m_total_num_l1id = m_bytestream_conditionsSvc->getNumberOfErrors(0); + m_total_num_bcid = m_bytestream_conditionsSvc->getNumberOfErrors(1); + m_total_num_missing = m_bytestream_conditionsSvc->getNumberOfErrors(2); + m_total_num_general = m_bytestream_conditionsSvc->getNumberOfErrors(3); + m_total_num_sendid = m_bytestream_conditionsSvc->getNumberOfErrors(4); + + std::set<std::pair<uint32_t, uint32_t> >::iterator errIt; + + errIt = m_bytestream_conditionsSvc->getL1idErrorSet().begin(); + int size = m_bytestream_conditionsSvc->getL1idErrorSet().size(); + + for (int i =0; i != size; i++) { + + m_l1id_dtmroc_index_remap->push_back(dtmroc_map->find(errIt->first &0xff)->second); + m_l1id_dtmroc_index->push_back(errIt->first & 0xff); + m_l1id_rod_index->push_back((errIt->first & 0xffffff00)/0x100); + m_l1id_returned_l1id->push_back(errIt->second); + ++errIt; + } + + errIt = m_bytestream_conditionsSvc->getBcidErrorSet().begin(); + size = m_bytestream_conditionsSvc->getBcidErrorSet().size(); + + for (int i =0; i != size; i++) { + + m_bcid_dtmroc_index_remap->push_back(dtmroc_map->find(errIt->first &0xff)->second); + m_bcid_dtmroc_index->push_back(errIt->first & 0xff); + m_bcid_rod_index->push_back((errIt->first & 0xffffff00)/0x100); + m_bcid_returned_bcid->push_back(errIt->second); + ++errIt; + } + + std::set<uint32_t>::iterator errIt2; + + errIt2 = m_bytestream_conditionsSvc->getMissingErrorSet().begin(); + size = m_bytestream_conditionsSvc->getMissingErrorSet().size(); + + for (int i =0; i != size; i++) { + + m_missing_dtmroc_index_remap->push_back(dtmroc_map->find(*errIt2 & 0xff)->second); + m_missing_dtmroc_index->push_back(*errIt2 & 0xff); + m_missing_rod_index->push_back((*errIt2 & 0xffffff00)/0x100); + ++errIt2; + } + + + errIt2 = m_bytestream_conditionsSvc->getErrorErrorSet().begin(); + size = m_bytestream_conditionsSvc->getErrorErrorSet().size(); + + for (int i =0; i != size; i++) { + m_general_dtmroc_index_remap->push_back(dtmroc_map->find(*errIt2 & 0xff)->second); + m_general_dtmroc_index->push_back(*errIt2 & 0xff); + m_general_rod_index->push_back((*errIt2 & 0xffffff00)/0x100); + ++errIt2; + } + + errIt2 = m_bytestream_conditionsSvc->getSidErrorSet().begin(); + size = m_bytestream_conditionsSvc->getSidErrorSet().size(); + + for (int i =0; i != size; i++) { + m_sendid_dtmroc_index_remap->push_back(dtmroc_map->find(*errIt2 & 0xff)->second); + m_sendid_dtmroc_index->push_back(*errIt2 & 0xff); + m_sendid_rod_index->push_back((*errIt2 & 0xffffff00)/0x100); + ++errIt2; + } + + + if (m_total_num_missing > 4000){ + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << m_total_num_missing <<" Missing Chips in Event #: " <<eventCount << endreq; + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "ROD BCID is : 0x" << hex << m_bcid_returned_by_ROD << " and L1ID is : 0x" << m_l1id_returned_by_ROD << endreq; + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Number of bcid errors is : " << dec << m_total_num_bcid << endreq; + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Number of L1id errors is : " << m_total_num_l1id << endreq; + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Number of generalized error bits set is : " << m_total_num_sendid <<endreq; + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Number of sendid errors is : " << m_total_num_sendid<< endreq; + + } + + m_tree->Fill(); + + return StatusCode::SUCCESS; +} + +//============================================================================================ diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorPlots.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorPlots.cxx new file mode 100644 index 000000000000..843de912f47d --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorPlots.cxx @@ -0,0 +1,1863 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////////////// + +#include "TRT_DetectorPerformance/TRT_DetectorPlots.h" + +#include "HepMC/GenParticle.h" +#include "HepMC/GenVertex.h" +#include "TrkTruthData/TrackTruthCollection.h" +#include "TrkTruthData/PRD_MultiTruthCollection.h" +#include "InDetSimData/InDetSimDataCollection.h" + +#include "DataModel/DataVector.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" +#include "InDetReadoutGeometry/TRT_Numerology.h" + +#include "InDetRawData/InDetRawDataContainer.h" +#include "InDetRawData/InDetRawDataCLASS_DEF.h" + +#include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" + +#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" +#include "InDetPrepRawData/TRT_DriftCircle.h" + +#include "TrkEventPrimitives/FitQuality.h" +//#include "TrkParameters/MeasuredPerigee.h" +#include "TrkParameters/TrackParameters.h" +#include "TrkTrack/Track.h" +#include "TrkTrack/TrackCollection.h" +#include "TrkSegment/SegmentCollection.h" + +#include "TRT_ConditionsServices/ITRT_CalDbSvc.h" +#include "TRT_ConditionsServices/ITRT_StrawNeighbourSvc.h" + +#include "TRT_ConditionsData/RtRelation.h" +#include "TRT_ConditionsData/BasicRtRelation.h" +#include "CommissionEvent/ComTime.h" + +#include "InDetRecToolInterfaces/ITRT_TrackSegmentsMaker.h" +#include "TRT_TrackSegmentsFinder/TRT_TrackSegmentsFinder.h" +//#include "TRT_TrackSegmentsTool_xk/TRT_TrackSegmentsMaker_BarrelCosmics.h" +//#include "TRT_TrackSegmentsTool_xk/TRT_TrackSegmentsMaker_ATLxk.h" + +#include "InDetIdentifier/SCT_ID.h" +#include "InDetReadoutGeometry/SCT_DetectorManager.h" +#include "InDetIdentifier/PixelID.h" +#include "InDetReadoutGeometry/PixelDetectorManager.h" + +#include "TTree.h" + + +#include "TRT_DetectorPerformance/TRT_StrawMap.h" + + + + + +//#include "TrkEventPrimitives/GlobalPosition.h" + +#include "EventInfo/EventInfo.h" +#include "EventInfo/EventID.h" +#include "EventInfo/TriggerInfo.h" + +#include "EventInfo/EventInfo.h" +#include "EventInfo/TriggerInfo.h" + + +#include "TrigSteeringEvent/Lvl1Result.h" + +//#include "TrigSteering/Chain.h" +#include "TrigSteering/StreamTag.h" +#include "TrigSteering/Signature.h" +#include "TrigSteering/Sequence.h" + +#include "TrigInterfaces/AlgoConfig.h" +#include "TrigInterfaces/Algo.h" + +#include "TrigConfHLTData/HLTChain.h" +#include "TrigConfHLTData/HLTChainList.h" + +#include "TrigConfL1Data/TriggerItem.h" +#include "TrigConfL1Data/CTPConfig.h" +#include "TrigConfL1Data/Menu.h" + +//#include "TrkParameters/MeasuredAtaStraightLine.h" + +#include "InDetRIO_OnTrack/PixelClusterOnTrack.h" +#include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" +#include "InDetRawData/PixelRDORawData.h" +#include "InDetRawData/SCT3_RawData.h" + +#include "TrigInDetEvent/TrigInDetTrackCollection.h" +#include "TrigInDetEvent/TrigSiSpacePoint.h" + +///////////////////////////////////////////////////////////////////////////// + +InDet::TRT_DetectorPlots::TRT_DetectorPlots( const std::string& name + , ISvcLocator* pSvcLocator + ) : AthAlgorithm(name, pSvcLocator) + , m_doMC(0) + , m_doRDO(0) + , m_numNoise(0) + , m_doSegments(0) + , m_barrelSegmentsName("TRT_SegmentsBC") + , m_endcapSegmentsName("TRT_Segments_EC") + , m_tracksName("CombinedInDetTracks") + //, SCT_Cosmic_Tracks + //, Tracks + //, TRT_Cosmic_Tracks + //, InDetCosmic_Tracks + , m_fileName("TRT_DetectorPlots.L2eff.txt") + , m_histSvc("THistSvc", name) + , m_trtDetMgr(0) + , m_trtHelper(0) + , m_trtCondDbTool("TRT_CalDbSvc", name) + , m_trtStrawNeighbourTool("TRT_StrawNeighbourSvc", name) + , m_trtStrawMap("InDet::TRT_StrawMap") + , m_rdoContainer(0) + , m_trtDriftCircleContainer(0) + , m_segmentCollectionBarrel(0) + , m_segmentCollectionEc(0) + , m_trkCollection(0) + , m_truthTrt(0) + , m_runNumber(0) +{ // Properties + + declareProperty("histogramService", m_histSvc); + + declareProperty("doMC", m_doMC); + declareProperty("doRDO", m_doRDO); + declareProperty("numNoise", m_numNoise); + + declareProperty("doSegments", m_doSegments); + declareProperty("barrelSegmentsCollection", m_barrelSegmentsName); + declareProperty("endcapSegmentsCollection", m_endcapSegmentsName); + + declareProperty("tracksCollection", m_tracksName); + declareProperty("fileName", m_fileName); + + return; +} + +///////////////////////////////////////////////////////////////////////////// + +StatusCode InDet::TRT_DetectorPlots::initialize() +{ + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "InDet::TRT_DetectorPlots::initialize(), doSegments: " << m_doSegments + << " do Noise: " << m_numNoise + << endreq; + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "InDet::TRT_DetectorPlots::initialize(), tracks collection: " << m_tracksName + << " segment collections: " << m_barrelSegmentsName << ", " << m_endcapSegmentsName + << endreq; + + ///////////////////////////////////////////////// + // Create TTrees and register them to THistSvc + ///////////////////////////////////////////////// + if ( m_histSvc.retrieve().isFailure() ) + { + if(msgLvl(MSG::FATAL)) msg(MSG::FATAL) << "histogram service not found" << endreq; + return StatusCode::FAILURE; + } + else + { + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "retrieved histogramService" << endreq; + } + m_treeEvent = new TTree("event" , "event" ); + m_treeTrack = new TTree("track" , "track" ); + m_treeSegment = new TTree("segment", "segment"); + m_treeHits = new TTree("hits" , "hits" ); + m_treePixel = new TTree("pixel" , "pixel" ); + + std::string fullTreeNameEvent = "/AANT/event" ; + if((m_histSvc->regTree(fullTreeNameEvent, m_treeEvent)).isFailure()) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeNameEvent << endreq; + return StatusCode::FAILURE; + } + + std::string fullTreeNameTrack = "/AANT/track" ; + if((m_histSvc->regTree(fullTreeNameTrack, m_treeTrack)).isFailure()) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeNameTrack << endreq; + return StatusCode::FAILURE; + } + + std::string fullTreeNameSegment = "/AANT/segment" ; + if((m_histSvc->regTree(fullTreeNameSegment, m_treeSegment)).isFailure()) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeNameSegment << endreq; + return StatusCode::FAILURE; + } + + std::string fullTreeNameHits = "/AANT/hits" ; + if((m_histSvc->regTree(fullTreeNameHits, m_treeHits)).isFailure()) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeNameHits << endreq; + return StatusCode::FAILURE; + } + + std::string fullTreeNamePixel = "/AANT/pixel" ; + if((m_histSvc->regTree(fullTreeNamePixel, m_treePixel)).isFailure()) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeNamePixel << endreq; + return StatusCode::FAILURE; + } + + /////////////////////////////////////////////// + /// Declare vectors that are used in filling + /// the output ntuple + /////////////////////////////////////////////// + m_trackSide = new std::vector<int>; + m_trackLayerOrWheel = new std::vector<int>; + m_trackPhi = new std::vector<int>; + m_trackStrawLayer = new std::vector<int>; + m_trackStraw = new std::vector<int>; + m_trackStrawNum = new std::vector<int>; + m_trackChip = new std::vector<int>; + m_trackBoard = new std::vector<int>; + m_trackDriftTimeBin = new std::vector<int>; + m_trackTrailingEdge = new std::vector<int>; + m_trackHighThreshold = new std::vector<int>; + m_trackDriftCircleWord = new std::vector<int>; + m_trackX = new std::vector<double>; + m_trackY = new std::vector<double>; + m_trackZ = new std::vector<double>; + m_trackT0 = new std::vector<double>; + + m_trackTrackR = new std::vector<double>; + m_trackLocR = new std::vector<double>; + m_trackErrR = new std::vector<double>; + + m_eventPixelX = new std::vector<double>; + m_eventPixelY = new std::vector<double>; + m_eventPixelZ = new std::vector<double>; + m_eventPixelHitTimeBin = new std::vector<int>; + m_eventSCTX = new std::vector<double>; + m_eventSCTY = new std::vector<double>; + m_eventSCTZ = new std::vector<double>; + m_eventSCTHitTimeBin = new std::vector<int>; + m_eventTRTX = new std::vector<double>; + m_eventTRTY = new std::vector<double>; + m_eventTRTZ = new std::vector<double>; + + m_segmentSide = new std::vector<int>; + m_segmentLayerOrWheel = new std::vector<int>; + m_segmentPhi = new std::vector<int>; + m_segmentStrawLayer = new std::vector<int>; + m_segmentStraw = new std::vector<int>; + m_segmentStrawNum = new std::vector<int>; + m_segmentChip = new std::vector<int>; + m_segmentBoard = new std::vector<int>; + m_segmentDriftTimeBin = new std::vector<int>; + m_segmentTrailingEdge = new std::vector<int>; + m_segmentDriftCircleWord = new std::vector<int>; + m_segmentHitOnTrack = new std::vector<int>; + m_segmentX = new std::vector<double>; + m_segmentY = new std::vector<double>; + m_segmentZ = new std::vector<double>; + m_segmentT0 = new std::vector<double>; + + m_onTrackIdentifiers = new std::vector<Identifier>; + + m_pixelL1TimeBin = new std::vector<int>; + + ////////////////////////////////////////////////////// + /// Book variables to be added to the output ntuple + ////////////////////////////////////////////////////// + + m_treeEvent->Branch("run_number" , &m_trackRunNumber , "run_number/I" ); + m_treeEvent->Branch("event_number", &m_trackEventNumber , "event_number/I" ); + m_treeEvent->Branch("n_tracks" , &m_eventNumberOfTracks, "n_tracks/I" ); + + m_treeEvent->Branch("n_TRT_hits" , m_eventNumberOfHitsOnTracks , "n_TRT_hits/I" ); + m_treeEvent->Branch("n_TRT_barrel_hits" , m_eventNumberOfHitsOnTracks+1, "n_TRT_barrel_hits/I" ); + m_treeEvent->Branch("n_TRT_maxonlybarrel_hits", m_eventNumberOfHitsOnTracks+2, "n_TRT_maxonlybarrel_hits/I" ); + m_treeEvent->Branch("n_SCT_hits" , m_eventNumberOfHitsOnTracks+3, "n_SCT_hits/I" ); + m_treeEvent->Branch("n_SCT_barrel_hits" , m_eventNumberOfHitsOnTracks+4, "n_SCT_barrel_hits/I" ); + m_treeEvent->Branch("n_pixel_hits" , m_eventNumberOfHitsOnTracks+5, "n_pixel_hits/I" ); + m_treeEvent->Branch("n_pixel_barrel_hits" , m_eventNumberOfHitsOnTracks+6, "n_pixel_barrel_hits/I" ); + + m_treeEvent->Branch("n_sp_upper" , m_siSP , "n_sp_upper/I" ); + m_treeEvent->Branch("n_sp_lower" , m_siSP+1 , "n_sp_lower/I" ); + m_treeEvent->Branch("SiTrack" , m_eventL2Alg , "SiTrack/I" ); + m_treeEvent->Branch("IDScan" , m_eventL2Alg+1, "IDScan/I" ); + m_treeEvent->Branch("TRTSegFinder", m_eventL2Alg+2, "TRTSegFinder/I" ); + + m_treeEvent->Branch("trigger_L1Type" , &m_eventL1Type , "trigger_L1Type/I" ); + m_treeEvent->Branch("trigger_TGC" , &m_trackTrig1MU1 , "trigger_TGC/I" ); + m_treeEvent->Branch("trigger_RPC" , &m_trackTrig1MU2 , "trigger_RPC/I" ); + m_treeEvent->Branch("trigger_L1Calo" , &m_trackTrigL1Calo , "trigger_L1Calo/I" ); + m_treeEvent->Branch("trigger_IDCosmic", &m_trackTrigAllTeIDSelected, "trigger_IDCosmic/I" ); + + m_treeEvent->Branch("phi0" , m_eventTrackInfo , "phi0/D" ); + m_treeEvent->Branch("d0" , m_eventTrackInfo+1, "d0/D" ); + m_treeEvent->Branch("z0" , m_eventTrackInfo+2, "z0/D" ); + m_treeEvent->Branch("theta" , m_eventTrackInfo+3, "theta/D" ); + m_treeEvent->Branch("qOverP", m_eventTrackInfo+4, "qOverP/D" ); + + m_treeEvent->Branch("comTime" , &m_pixelComTime , "comTime/D" ); + m_treeEvent->Branch("pixelTimeBin", &m_eventPixelTimeBin, "pixelTimeBin/D" ); + + m_treeEvent->Branch("pixelX" , &m_eventPixelX ); + m_treeEvent->Branch("pixelY" , &m_eventPixelY ); + m_treeEvent->Branch("pixelZ" , &m_eventPixelZ ); + m_treeEvent->Branch("pixelHitTimeBin", &m_eventPixelHitTimeBin ); + m_treeEvent->Branch("sctX" , &m_eventSCTX ); + m_treeEvent->Branch("sctY" , &m_eventSCTY ); + m_treeEvent->Branch("sctZ" , &m_eventSCTZ ); + m_treeEvent->Branch("sctHitTimeBin" , &m_eventSCTHitTimeBin ); + m_treeEvent->Branch("trtX" , &m_eventTRTX ); + m_treeEvent->Branch("trtY" , &m_eventTRTY ); + m_treeEvent->Branch("trtZ" , &m_eventTRTZ ); + + m_treeTrack->Branch("run_number" , &m_trackRunNumber , "run_number/I" ); + m_treeTrack->Branch("event_number" , &m_trackEventNumber , "event_number/I" ); + m_treeTrack->Branch("trigger_L1Type" , &m_trackTrigL1Type , "trigger_L1Type/I" ); + m_treeTrack->Branch("trigger_stream_size" , &m_trackTrigStreamSize , "trigger_stream_size/I" ); + m_treeTrack->Branch("trigger_1MU1" , &m_trackTrig1MU1 , "trigger_1MU1/I" ); + m_treeTrack->Branch("trigger_1MU2" , &m_trackTrig1MU2 , "trigger_1MU2/I" ); + m_treeTrack->Branch("trigger_1MU3" , &m_trackTrig1MU3 , "trigger_1MU3/I" ); + m_treeTrack->Branch("trigger_L1Calo" , &m_trackTrigL1Calo , "trigger_L1Calo/I" ); + m_treeTrack->Branch("trigger_NIM0" , &m_trackTrigNIM0 , "trigger_NIM0/I" ); + m_treeTrack->Branch("trigger_NIM4" , &m_trackTrigNIM4 , "trigger_NIM4/I" ); + m_treeTrack->Branch("trigger_MBTS" , &m_trackTrigMBTS , "trigger_MBTS/I" ); + m_treeTrack->Branch("trigger_EMCalo" , &m_trackTrigEML1Calo , "trigger_EMCalo/I" ); + m_treeTrack->Branch("trigger_HLTerror" , &m_trackTrigHLTerror , "trigger_HLTerror/I" ); + m_treeTrack->Branch("trigger_AllTeIDSelected", &m_trackTrigAllTeIDSelected, "trigger_AllTeIDSelected/I" ); + m_treeTrack->Branch("trigger_AllTePixel" , &m_trackTrigAllTePixel , "trigger_AllTePixel/I" ); + m_treeTrack->Branch("n_TRT_tracks" , &m_trackNumTrtTracks , "n_TRT_tracks/I" ); + m_treeTrack->Branch("n_tracks" , &m_trackNumTracks , "n_tracks/I" ); + m_treeTrack->Branch("n_SCT_hits" , &m_trackNumSctHits , "n_SCT_hits/I" ); + m_treeTrack->Branch("n_TRT_hits" , &m_trackNumTrtHits , "n_TRT_hits/I" ); + m_treeTrack->Branch("n_TRT_hits_barrelA" , &m_trackNumTrtHitsBarrelA , "n_TRT_hits_barrelA/I" ); + m_treeTrack->Branch("n_TRT_hits_barrelC" , &m_trackNumTrtHitsBarrelC , "n_TRT_hits_barrelC/I" ); + m_treeTrack->Branch("n_TRT_hits_ecA" , &m_trackNumTrtHitsEcA , "n_TRT_hits_ecA/I" ); + m_treeTrack->Branch("n_TRT_hits_ecC" , &m_trackNumTrtHitsEcC , "n_TRT_hits_ecC/I" ); + m_treeTrack->Branch("ndf" , &m_trackNdf , "ndf/I" ); + m_treeTrack->Branch("chi2" , &m_trackChi2 , "chi2/D" ); + m_treeTrack->Branch("theta" , &m_trackTheta , "theta/D" ); + m_treeTrack->Branch("d0" , &m_trackD0 , "d0/D" ); + m_treeTrack->Branch("z0" , &m_trackZ0 , "z0/D" ); + m_treeTrack->Branch("phi0" , &m_trackPhi0 , "phi0/D" ); + m_treeTrack->Branch("EP" , &m_trackEventPhase , "EP/D" ); + m_treeTrack->Branch("comTime" , &m_pixelComTime , "comTime/D" ); + + m_treeTrack->Branch("side" , &m_trackSide ); + m_treeTrack->Branch("layer_or_wheel", &m_trackLayerOrWheel ); + m_treeTrack->Branch("phi" , &m_trackPhi ); + m_treeTrack->Branch("straw_layer" , &m_trackStrawLayer ); + m_treeTrack->Branch("straw" , &m_trackStraw ); + m_treeTrack->Branch("straw_number" , &m_trackStrawNum ); + m_treeTrack->Branch("chip" , &m_trackChip ); + m_treeTrack->Branch("board" , &m_trackBoard ); + m_treeTrack->Branch("LE" , &m_trackDriftTimeBin ); + m_treeTrack->Branch("TE" , &m_trackTrailingEdge ); + m_treeTrack->Branch("HT" , &m_trackHighThreshold ); + m_treeTrack->Branch("word" , &m_trackDriftCircleWord ); + m_treeTrack->Branch("x" , &m_trackX ); + m_treeTrack->Branch("y" , &m_trackY ); + m_treeTrack->Branch("z" , &m_trackZ ); + m_treeTrack->Branch("t0" , &m_trackT0 ); + + m_treeTrack->Branch("trackR", &m_trackTrackR ); + m_treeTrack->Branch("locR" , &m_trackLocR ); + m_treeTrack->Branch("errR" , &m_trackErrR ); + + m_treeSegment->Branch("side" , &m_segmentSide ); + m_treeSegment->Branch("layer_or_wheel", &m_segmentLayerOrWheel ); + m_treeSegment->Branch("phi" , &m_segmentPhi ); + m_treeSegment->Branch("straw_layer" , &m_segmentStrawLayer ); + m_treeSegment->Branch("straw" , &m_segmentStraw ); + m_treeSegment->Branch("straw_number" , &m_segmentStrawNum ); + m_treeSegment->Branch("chip" , &m_segmentChip ); + m_treeSegment->Branch("board" , &m_segmentBoard ); + m_treeSegment->Branch("LE" , &m_segmentDriftTimeBin ); + m_treeSegment->Branch("TE" , &m_segmentTrailingEdge ); + m_treeSegment->Branch("word" , &m_segmentDriftCircleWord ); + m_treeSegment->Branch("hit_on_track" , &m_segmentHitOnTrack ); + m_treeSegment->Branch("x" , &m_segmentX ); + m_treeSegment->Branch("y" , &m_segmentY ); + m_treeSegment->Branch("z" , &m_segmentZ ); + m_treeSegment->Branch("t0" , &m_segmentT0 ); + + + m_treeHits->Branch("side" , &m_hitsSide , "side/I" ); + m_treeHits->Branch("layer_or_wheel", &m_hitsLayerOrWheel , "layer_or_wheel/I" ); + m_treeHits->Branch("phi" , &m_hitsPhi , "phi/I" ); + m_treeHits->Branch("straw_layer" , &m_hitsStrawLayer , "straw_layer/I" ); + m_treeHits->Branch("straw" , &m_hitsStraw , "straw/I" ); + m_treeHits->Branch("straw_number" , &m_hitsStrawNum , "straw_number/I" ); + m_treeHits->Branch("chip" , &m_hitsChip , "chip/I" ); + m_treeHits->Branch("board" , &m_hitsBoard , "board/I" ); + m_treeHits->Branch("LE" , &m_hitsDriftTimeBin , "LE/I" ); + m_treeHits->Branch("TE" , &m_hitsTrailingEdge , "TE/I" ); + m_treeHits->Branch("word" , &m_hitsDriftCircleWord, "word/I" ); + m_treeHits->Branch("hit_on_track" , &m_hitsHitOnTrack , "hit_on_track/I" ); + m_treeHits->Branch("x" , &m_hitsX , "x/D" ); + m_treeHits->Branch("y" , &m_hitsY , "y/D" ); + m_treeHits->Branch("z" , &m_hitsZ , "z/D" ); + m_treeHits->Branch("t0" , &m_hitsT0 , "t0/D" ); + + m_treePixel->Branch("run_number" , &m_trackRunNumber , "run_number/I"); + m_treePixel->Branch("n_pixel_hits" , &m_pixelNumberOfPixelHits , "n_pixel_hits/I"); + m_treePixel->Branch("n_TRT_hits" , &m_pixelMaxNumberOfTRTBarrelHitsOnTrack, "n_TRT_hits/I"); + m_treePixel->Branch("n_TRT_hits_barrelA", &m_trackNumTrtHitsBarrelA , "n_TRT_hits_barrelA/I"); + m_treePixel->Branch("n_TRT_hits_barrelC", &m_trackNumTrtHitsBarrelC , "n_TRT_hits_barrelC/I"); + m_treePixel->Branch("n_TRT_hits_ecA" , &m_trackNumTrtHitsEcA , "n_TRT_hits_ecA/I"); + m_treePixel->Branch("n_TRT_hits_ecC" , &m_trackNumTrtHitsEcC , "n_TRT_hits_ecC/I"); + + m_treePixel->Branch("d0" , &m_pixelTRTtrackD0 , "d0/D" ); + m_treePixel->Branch("phi0" , &m_pixelTRTtrackPhi0 , "phi0/D" ); + m_treePixel->Branch("EP" , &m_pixelTRTtrackEP , "EP/D" ); + m_treePixel->Branch("comTime" , &m_pixelComTime , "comTime/D" ); + m_treePixel->Branch("trigger_L1Type" , &m_trackTrigL1Type , "trigger_L1Type/I" ); + m_treePixel->Branch("trigger_stream_size", &m_trackTrigStreamSize, "trigger_stream_size/I" ); + m_treePixel->Branch("trigger_1MU1" , &m_trackTrig1MU1 , "trigger_1MU1/I" ); + m_treePixel->Branch("trigger_1MU2" , &m_trackTrig1MU2 , "trigger_1MU2/I" ); + m_treePixel->Branch("trigger_1MU3" , &m_trackTrig1MU3 , "trigger_1MU3/I" ); + m_treePixel->Branch("trigger_L1Calo" , &m_trackTrigL1Calo , "trigger_L1Calo/I" ); + m_treePixel->Branch("trigger_NIM0" , &m_trackTrigNIM0 , "trigger_NIM0/I" ); + m_treePixel->Branch("trigger_NIM4" , &m_trackTrigNIM4 , "trigger_NIM4/I" ); + m_treePixel->Branch("trigger_MBTS" , &m_trackTrigMBTS , "trigger_MBTS/I" ); + m_treePixel->Branch("trigger_EMCalo" , &m_trackTrigEML1Calo , "trigger_EMCalo/I" ); + + m_treePixel->Branch("time_bin", &m_pixelL1TimeBin); + + return StatusCode::SUCCESS; +} + +///////////////////////////////////////////////////////////////////////////// + +StatusCode InDet::TRT_DetectorPlots::execute() +{ + static int eventCount(-1); eventCount++; + // FILE *myFile = fopen("myTRT_DetectorPlots.txt", eventCount?"a":"w"); + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "InDet::TRT_DetectorPlots::execute() event " << eventCount << endreq; + + if (!eventCount) // compare straw mapping + { + m_trtStrawMap->compareWithTRTStrawNeighbour(); + FILE *f = fopen("strawToChipMap.txt", "w"); + for (int i=0; i<m_trtStrawMap->nAllStraws(); i++) + { + fprintf(f, "0 %4d %3d %2d\n", i, m_trtStrawMap->strawToChip(i, 1, 10), m_trtStrawMap->strawToBoard(i)); + if (i>=m_trtStrawMap->nBarrelStraws()) + fprintf(f, "1 %4d %3d %2d\n", i, m_trtStrawMap->strawToChip(i, 1, 0), m_trtStrawMap->strawToBoard(i)); // reversed endcap + } + fclose(f); + } + + StatusCode sc = load(); + + if (sc.isFailure()) + { + msg(MSG::ERROR) << "InDet::TRT_DetectorPlots::load() failed, exiting" << endreq; + return sc; + } + + if (m_trkCollection->size() > 100) + { + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "N tracks greater than 100: " << m_trkCollection->size() << " for event " << eventCount << ", exiting" << endreq; + return sc; + } + + const EventInfo *eventInfo = 0; + sc = evtStore()->retrieve(eventInfo); + if ( sc.isFailure() ) + { + msg(MSG::ERROR) << "Unable to retrieve Event Info " << endreq; + return sc; + } + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "InDet::TRT_DetectorPlots::execute() retrieved eventInfo " << eventCount << endreq; + + if (m_doRDO) RDOhits(); + if (m_doMC) MC(); + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "InDet::TRT_DetectorPlots::execute() retrieved eventInfo " << eventCount << endreq; + + fillEventAndTrackTrees(eventInfo); + + + if (1) { // special print + //if (false) { // special print + + char fileName[300]; + snprintf(fileName, 300, "%s", m_fileName.c_str()); + FILE *f = fopen(fileName, eventCount?"a":"w"); + + fprintf(f, "%d %d %d %d ", m_eventNumberOfTracks, m_eventNumberOfHitsOnTracks[1], m_eventNumberOfHitsOnTracks[3], m_eventNumberOfHitsOnTracks[5]); // N tracks, TRT barrel hits, SCt hits, pixel hits + fprintf(f, "%d %d ", m_siSP[0], m_siSP[1]); // n_sp_upper, lower + if (!m_trackTrigAllTeIDSelected) for (int i=0; i<3; i++) m_eventL2Alg[i] *= -1; + fprintf(f, "%d %d %d %d ", m_eventL1Type, m_eventL2Alg[0], m_eventL2Alg[1], m_eventL2Alg[2]); + for (int i=0; i<5; i++) fprintf(f, "%f ", m_eventTrackInfo[i] ); + fprintf(f, "\n"); + + fclose(f); + + } + + pixelRDOhits(m_runNumber); + + + if (m_doSegments) + { + fillSegmentTree(); + } + + if(m_numNoise) + { + fillHitsTree(); + } + + return StatusCode::SUCCESS; +} + +///////////////////////////////////////////////////////////////////////////// + +StatusCode InDet::TRT_DetectorPlots::finalize() { + + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "InDet::TRT_DetectorPlots::finalize()" << endreq; + + if(m_trackSide) delete m_trackSide; + if(m_trackLayerOrWheel) delete m_trackLayerOrWheel; + if(m_trackPhi) delete m_trackPhi; + if(m_trackStrawLayer) delete m_trackStrawLayer; + if(m_trackStraw) delete m_trackStraw; + if(m_trackStrawNum) delete m_trackStrawNum; + if(m_trackChip) delete m_trackChip; + if(m_trackBoard) delete m_trackBoard; + if(m_trackDriftTimeBin) delete m_trackDriftTimeBin; + if(m_trackTrailingEdge) delete m_trackTrailingEdge ; + if(m_trackDriftCircleWord) delete m_trackDriftCircleWord; + if(m_trackX) delete m_trackX; + if(m_trackY) delete m_trackY; + if(m_trackZ) delete m_trackZ; + if(m_trackT0) delete m_trackT0; + + if(m_segmentSide) delete m_segmentSide; + if(m_segmentPhi) delete m_segmentPhi; + if(m_segmentStrawLayer) delete m_segmentStrawLayer; + if(m_segmentStraw) delete m_segmentStraw; + if(m_segmentStrawNum) delete m_segmentStrawNum; + if(m_segmentChip) delete m_segmentChip; + if(m_segmentBoard) delete m_segmentBoard; + if(m_segmentDriftTimeBin) delete m_segmentDriftTimeBin; + if(m_segmentTrailingEdge) delete m_segmentTrailingEdge; + if(m_segmentDriftCircleWord) delete m_segmentDriftCircleWord; + if(m_segmentX) delete m_segmentX; + if(m_segmentY) delete m_segmentY; + if(m_segmentZ) delete m_segmentZ; + if(m_segmentT0) delete m_segmentT0; + + + if(m_onTrackIdentifiers) delete m_onTrackIdentifiers; + + return StatusCode::SUCCESS; +} + +///////////////////////////////////////////////////////////////////////////// + +StatusCode InDet::TRT_DetectorPlots::load() { + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "InDet::TRT_DetectorPlots::load()" << endreq; + + StatusCode sc = detStore()->retrieve(m_trtDetMgr, "TRT"); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Unable to retrieve TRT Detector Manager " << endreq; + return sc; + } else { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "retrieved TRT Detector Manager " << endreq; + } + + // TRT helper + if (detStore()->retrieve(m_trtHelper, "TRT_ID").isFailure()) { + msg(MSG::FATAL) << "Could not get TRT ID helper" << endreq; + return StatusCode::FAILURE; + } + + sc = detStore()->retrieve(m_SCTDetMgr, "SCT"); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Unable to retrieve SCT Detector Manager " << endreq; + return sc; + } + + // SCT + if (detStore()->retrieve(m_SCTHelper, "SCT_ID").isFailure()) { + msg(MSG::FATAL) << "Could not get SCT ID helper" << endreq; + return StatusCode::FAILURE; + } + + sc = detStore()->retrieve(m_PixelDetMgr, "Pixel"); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Unable to retrieve Pixel Detector Manager " << endreq; + return sc; + } + + // Pixel + if (detStore()->retrieve(m_PixelHelper, "PixelID").isFailure()) { + msg(MSG::FATAL) << "Could not get Pixel ID helper" << endreq; + return StatusCode::FAILURE; + } + + sc = m_trtCondDbTool.retrieve() ; + if (sc.isFailure()) { + msg(MSG::ERROR) << "Could not find TRTCalDbTool " << endreq; + return sc; + } + + sc = evtStore()->retrieve(m_rdoContainer, "TRT_RDOs"); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "no TRT_RDO container available " << endreq; + return sc; + } else { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "retrieved TRT RDOs" << endreq; + } + + sc = evtStore()->retrieve( m_trtDriftCircleContainer, "TRT_DriftCircles" ); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Could not find TRT_DriftCircles collection " << endreq; + return sc; + } + + sc = m_trtStrawNeighbourTool.retrieve() ; + if (sc.isFailure()) { + msg(MSG::ERROR) << "Could not find TRTStrawNeighbourTool " << endreq; + return sc; + } + + if (m_doSegments) { + + sc = evtStore()->retrieve( m_segmentCollectionBarrel, m_barrelSegmentsName);// TRT_SegmentsBC "InDetCosmic_Segments" ); //"TRT_Segments" ); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Could not find TRT Segments Collection" << endreq; + return sc; + } else { + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "TRT_Segments collection found, size = " << m_segmentCollectionBarrel->size() << endreq; + } + + sc = evtStore()->retrieve( m_segmentCollectionEc, m_barrelSegmentsName );// "TRT_Segments_EC" ); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Could not find TRT EC Segments Collection" << endreq; + return sc; + } else { + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "TRT_Segments_ECC collection found, size = " << m_segmentCollectionEc->size() << endreq; + } + } // end if (m_doSegments) + + sc = evtStore()->retrieve( m_trkCollection, m_tracksName ); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Could not find Tracks Collectioni " << m_tracksName << endreq; + return sc; + } + + if (m_doMC) { + sc = evtStore()->retrieve(m_truthTrt,"PRD_MultiTruthTRT"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "Could not retrieve TruthTRT info PRD_MultiTruthTRT" << endreq; + return sc; + } + } + + // get the TRT_Phase -- also called the Event Phase + + m_pixelComTime = 999.; + ComTime* theComTime; + sc = evtStore()->retrieve(theComTime, "TRT_Phase"); + if (sc.isFailure()) { + msg(MSG::ERROR) << "ComTime object not found with name TRT_Phase !!!" << endreq; + sc = StatusCode::SUCCESS; + } else { + m_pixelComTime = theComTime->getTime(); + if ( fabs(m_pixelComTime) > 100. ) m_pixelComTime = 999.; + } + + return sc; +} + +///////////////////////////////////////////////////////////////////////////// + +void InDet::TRT_DetectorPlots::pixelRDOhits(int runNumber) +{ + if (runNumber != m_runNumber) { // first call or new run + ; + } + + m_pixelL1TimeBin->clear(); + const DataHandle<PixelRDO_Container> m_rdocontainer; //container for pixel RDO + + StatusCode sc = evtStore()->retrieve(m_rdocontainer, "PixelRDOs"); + if (sc.isFailure() || !m_rdocontainer) { + msg(MSG::ERROR) << "Could not find the data object PixelRDOs !" << endreq; + return; + } else { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Data object PixelRDOs found" << endreq; + } + + // char line[300]; + // static int event(-1); event++; + // int count(0); + + m_pixelNumberOfPixelHits = 0; + + for (PixelRDO_Container::const_iterator it = m_rdocontainer->begin(); it != m_rdocontainer->end(); it++) { + + const InDetRawDataCollection<PixelRDORawData>* PixelCollection(*it); + if (!PixelCollection) continue; + + for(DataVector<PixelRDORawData>::const_iterator p_rdo = PixelCollection->begin(); p_rdo != PixelCollection->end(); p_rdo++) { + + // sprintf(line, "pixelRDOhits: event %3d, hit %2d, getLVL1ID: %2d TOT: %3d, BCID: %3d", event, count++, (*p_rdo)->getLVL1A(), + // (*p_rdo)->getToT(), (*p_rdo)->getBCID()); + // if (msgLvl(MSG::INFO)) msg(MSG::INFO) << line << endreq; + m_pixelL1TimeBin->push_back( (*p_rdo)->getLVL1A() ); + m_pixelNumberOfPixelHits++; + } + } + + m_treePixel->Fill(); + return; +} + +///////////////////////////////////////////////////////////////////////////// + +void InDet::TRT_DetectorPlots::RDOhits() +{ + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "InDet::TRT_DetectorPlots::RDOhits()" << endreq; + + static int eventCount(-1); eventCount++; + + if (!eventCount) { + + + FILE *f = fopen("TRT_DetectorPlots.TRT_StrawMap.txt", "w"); + + for (std::vector<Identifier>::const_iterator it = m_trtHelper->straw_layer_begin(); it != m_trtHelper->straw_layer_end(); it++ ) { + + int nStrawsInLayer = m_trtHelper->straw_max(*it); + + for (int i=0; i<=nStrawsInLayer; i++) { + + Identifier id = m_trtHelper->straw_id(*it, i); + int index[5]; + m_trtStrawMap->setNewIdentifier(id, index); + + //const HepGeom::Point3D<double> ¢erRef = m_trtDetMgr->getElement( id )->center( id ); + Amg::Vector3D centerRef = m_trtDetMgr->getElement( id )->center( id ); + + for (int i=0; i<5; i++) fprintf(f, "%2d ", index[i]); + fprintf(f, "%4d %3d %2d ", m_trtStrawMap->straw(), m_trtStrawMap->chip(), m_trtStrawMap->board() ); + fprintf(f, "%f %f %f\n", centerRef.x(), centerRef.y(), centerRef.z()); + } + } + + fclose(f); + + + + } + + + + char fileName[300]; snprintf(fileName, 300, "/tmp/sfratina/TRT_DetectorPlots.RDOhits.%07d.txt", m_trackRunNumber); + FILE *f = fopen(fileName, eventCount?"a":"w"); + + for (TRT_RDO_Container::const_iterator rdoIt = m_rdoContainer->begin(); rdoIt != m_rdoContainer->end(); rdoIt++) { + + const InDetRawDataCollection<TRT_RDORawData>* TRTCollection(*rdoIt); + if (TRTCollection==0) continue; + + for (DataVector<TRT_RDORawData>::const_iterator trtIt = TRTCollection->begin(); trtIt != TRTCollection->end(); trtIt++) { + + // possible functions to call: + // unsigned int getWord(), int driftTimeBin() [bins], double timeOverThreshold() [ns], bool highLevel(), Identifier identify(). + + //if ((*trtIt)->timeOverThreshold() < 10.) continue; + + Identifier id = (*trtIt)->identify(); + int index[6]; + m_trtStrawMap->setNewIdentifier(id, index); + index[5] = m_trtStrawMap->straw(); + + //const HepGeom::Point3D<double> ¢erRef = mTRTDetMgr->getElement( id )->center( id ); + + fprintf(f, "%3d %2d %2d %4d %2d %d %2d %2d %9d\n", eventCount, index[0], index[1], index[5], m_trtStrawMap->board(), (*trtIt)->highLevel(), (*trtIt)->driftTimeBin(), (int) ( (*trtIt)->driftTimeBin() + (*trtIt)->timeOverThreshold()/3.125 ), (*trtIt)->getWord() ); + } + } + + + fclose(f); + return; +} + +///////////////////////////////////////////////////////////////////////////// + +void InDet::TRT_DetectorPlots::MC() +{ + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "InDet::TRT_DetectorPlots::MC()" << endreq; + + std::vector<const HepMC::GenParticle*> genParticleList; + + for (PRD_MultiTruthCollection::const_iterator mc=m_truthTrt->begin(); mc != m_truthTrt->end(); mc++){ + + Identifier id = (*mc).first; + if ( abs(m_trtHelper->barrel_ec(id)) != 1) continue; // barrel hits only + + const HepMC::GenParticle* pa = (*mc).second.cptr(); + if (!pa) { if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "PRD_MultiTruthCollection loop, particle link missing" << endreq; continue; } + + int isListed(-1); + for (unsigned int i=0; i<genParticleList.size(); i++) if (pa==genParticleList[i]) {isListed = i; break;} + if (isListed==-1) + { + isListed = (int) genParticleList.size(); + genParticleList.push_back(pa); + } + } + return; +} + + +void InDet::TRT_DetectorPlots::fillEventAndTrackTrees(const EventInfo *eventInfo) +{ + m_trackTrigL1Type = 0; + m_trackTrig1MU1 = 0; + m_trackTrig1MU2 = 0; + m_trackTrig1MU3 = 0; + m_trackTrigL1Calo = 0; + m_trackTrigNIM0 = 0; + m_trackTrigNIM4 = 0; + m_trackTrigMBTS = 0; + m_trackTrigEML1Calo = 0; + m_trackTrigHLTerror = 0; + m_trackTrigAllTeIDSelected = 0; + m_trackTrigAllTePixel = 0; + + + TriggerInfo *triggerInfo = eventInfo->trigger_info(); + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "retrieved TriggerInfo " << endreq; + + if (triggerInfo==0) + { + msg(MSG::ERROR) << "no Trigger Info available" << endreq; + } + else + { + m_trackTrigL1Type = triggerInfo->level1TriggerType(); + + const std::vector<TriggerInfo::StreamTag> &getStreamTag = triggerInfo->streamTags(); + m_trackTrigStreamSize = getStreamTag.size(); + for (int i=0; i < m_trackTrigStreamSize; ++i) + { + if( getStreamTag[i].name() == "IDCosmic" ) // L2 - can be in combination with any of the others + { + m_trackTrigAllTeIDSelected = 1; + continue; + } + if( getStreamTag[i].name() == "HLT_Cosmic_AllTePixel" ) // L2 - can be in combination with any of the others + { + m_trackTrigAllTePixel = 1; + continue; + } + if( getStreamTag[i].name() == "TGCwBeam" ) + { + m_trackTrig1MU1 = 1; + continue; + } + if( getStreamTag[i].name() == "RPCwBeam" ) + { + m_trackTrig1MU2 = 1; + continue; + } + if( getStreamTag[i].name() == "CosmicDownwardMuons" ) + { + m_trackTrig1MU2 = 2; + continue; + } + if( getStreamTag[i].name() == "RNDM" ) + { + m_trackTrig1MU3 = 1; + continue; + } + if( getStreamTag[i].name() == "L1Calo" ) + { + m_trackTrigL1Calo = 1; + continue; + } + if( getStreamTag[i].name() == "IDTracks" ) + { + m_trackTrigNIM0 = 1; + continue; + } + if( getStreamTag[i].name() == "NIM4" ) + { + m_trackTrigNIM4 = 1; + continue; + } + if( getStreamTag[i].name() == "MBTS_BCM_LUCID" ) + { + m_trackTrigMBTS = 1; + continue; + } + if( getStreamTag[i].name() == "CosmicMuons" ) + { + m_trackTrigEML1Calo = 1; + continue; + } + if( getStreamTag[i].name() == "hlterror" ) + { + m_trackTrigHLTerror = 1; + continue; + } + else + { + if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "new unknown trigger name: " << getStreamTag[i].name() << endreq; + } + } + + if( !( m_trackTrig1MU1 + || m_trackTrig1MU2 + || m_trackTrig1MU3 + || m_trackTrigL1Calo + || m_trackTrigNIM0 + || m_trackTrigNIM4 + || m_trackTrigMBTS + || m_trackTrigEML1Calo + || m_trackTrigHLTerror + ) + ) + { + if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "no L1 trigger information available, tag names below, level1TriggerType: " << m_trackTrigL1Type << endreq; + + for (int i=0; i<m_trackTrigStreamSize; i++) + if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "L1 type, stream: " << getStreamTag[i].type() << " " << getStreamTag[i].name() << endreq; + + if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "L1 error, run and event number: " << m_trackRunNumber << " " << eventInfo->event_ID()->event_number() << " counting only input events, event N: " << m_trackEventNumber << endreq; + } // end debug missing L1 trigger + + } // end if (triggerInfo==0) { } else { } + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "end TriggerInfo " << endreq; + + for (int i=0; i<3; i++) + m_eventL2Alg[i] = 0; + + for (int i=0; i<2; i++) + m_siSP[i] = 0; + + // L2 trigger info + + const DataHandle<TrigInDetTrackCollection> trackCollection; + const DataHandle<TrigInDetTrackCollection> lastTrackCollection; + StatusCode sc = evtStore()->retrieve(trackCollection, lastTrackCollection); + + if (sc.isFailure()) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << " didn't find any TrigInDetTrackCollection objects" << endreq; + // return sc; + sc = StatusCode::SUCCESS; + } + else + { + for (int iTrackColl=0; trackCollection != lastTrackCollection; ++trackCollection, ++iTrackColl) + { + // int iTrack = 0; + for (TrigInDetTrackCollection::const_iterator track = trackCollection->begin(); track != trackCollection->end(); track++) + { + int algID = static_cast<int> ((*track)->algorithmId()); + + if (algID < 1 || algID > 3) + { + msg(MSG::ERROR) << "TrigInDetTrack algID error: " << algID << endreq; + continue; + } + ++m_eventL2Alg[algID-1]; + +/* + continue; + + int nSiSpacePoints(0); + if ((*track)->siSpacePoints()) nSiSpacePoints = (int) (*track)->siSpacePoints()->size(); + const TrigInDetTrackFitPar *fitPar = (*track)->param(); + int surfaceType = (int) fitPar->surfaceType();// dynamic_cast<int>(fitPar->surfaceType()); + + std::vector <const TrigSiSpacePoint*>* siHits = (*track)->siSpacePoints(); + + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "track " << iTrack + << " ID " << algID + << " par a0 " << fitPar->a0() + << " z0 " << fitPar->z0() + << " phi " << fitPar->phi0() + << " eta " << fitPar->eta() + << " pT " << fitPar->pT() + << " N TRT hits " << (*track)->NStrawHits() + << " N passed straws " << (*track)->NStraw() + << " N straw time " << (*track)->NStrawTime() + << " nSiSpacePoints " << nSiSpacePoints + << " si hits " << ( (siHits) ? siHits->size() : 9999 ) + << " chi2 " << (*track)->chi2() + << " surface " << surfaceType + << " coordinate " << fitPar->surfaceCoordinate() + << endreq; + +*/ + } + } + } // if failed TrigInDetTrackCollection else + + + ///////////////////////////////// + /// Loop over track collection + ///////////////////////////////// + m_eventNumberOfTracks = 0; + int m_eventNumberOfTRT_HitsOnTracks = 0; + int m_eventNumberOfSCT_HitsOnTracks = 0; + m_eventL1Type = m_trackTrigL1Type; + m_eventL1TagName = 0; + m_eventL1TagName += 2 * m_trackTrig1MU1; + m_eventL1TagName += 4 * m_trackTrig1MU2; + m_eventL1TagName += 8 * m_trackTrig1MU3; + m_eventL1TagName += 16 * m_trackTrigL1Calo; + m_eventL1TagName += 32 * m_trackTrigEML1Calo; + m_eventL1TagName += 64 * m_trackTrigNIM0; + m_eventL1TagName += 128 * m_trackTrigNIM4; + m_eventL1TagName += 256 * m_trackTrigMBTS; + + m_eventPixelX->clear(); + m_eventPixelY->clear(); + m_eventPixelZ->clear(); + m_eventPixelHitTimeBin->clear(); + m_eventSCTHitTimeBin->clear(); + m_eventSCTX->clear(); + m_eventSCTY->clear(); + m_eventSCTZ->clear(); + m_eventTRTX->clear(); + m_eventTRTY->clear(); + m_eventTRTZ->clear(); + + for (int i=0; i<7; i++) + m_eventNumberOfHitsOnTracks[i] = 0; + for (int i=0; i<5; i++) + m_eventTrackInfo[i] = 0.; + + m_eventPixelTimeBin = 0.; + + DataVector<Trk::Track>::const_iterator bestTrackIt = m_trkCollection->end(); + for ( DataVector<Trk::Track>::const_iterator trackIt = m_trkCollection->begin(); trackIt != m_trkCollection->end(); trackIt++ ) + { + const DataVector<const Trk::TrackStateOnSurface>* trackStates = (**trackIt).trackStateOnSurfaces(); + if ( trackStates == 0 ) + continue; + + int count_eventNumberOfHitsOnTracks[7]; + for (int i=0; i<7; i++) + count_eventNumberOfHitsOnTracks[i] = 0; + int eventPixelTimeBin = 0; + + for ( DataVector<const Trk::TrackStateOnSurface>::const_iterator trackStatesIt = trackStates->begin(); trackStatesIt != trackStates->end(); trackStatesIt++ ) + { + if ( *trackStatesIt == 0 ) + { + msg(MSG::ERROR) << "*trackStatesIt == 0" << endreq; + continue; + } + if ( !( (*trackStatesIt)->type(Trk::TrackStateOnSurface::Measurement) ) ) + continue; + + if ( dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>( (*trackStatesIt)->measurementOnTrack() ) ) // TRT hit + { + ++count_eventNumberOfHitsOnTracks[0]; + const InDet::TRT_DriftCircleOnTrack *driftCircleOnTrack = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>( (*trackStatesIt)->measurementOnTrack() ); + Identifier id = (driftCircleOnTrack->prepRawData())->identify(); + if ( abs(m_trtHelper->barrel_ec( id )) == 1 ) // barrel TRT hit + { + count_eventNumberOfHitsOnTracks[1]++; + count_eventNumberOfHitsOnTracks[2]++; + } + + //const CLHEP::Hep3Vector &p3d = (driftCircleOnTrack->prepRawData())->detectorElement()->surface( id ).center(); + Amg::Vector3D p3d = (driftCircleOnTrack->prepRawData())->detectorElement()->surface( id ).center(); + m_eventTRTX->push_back(p3d.x()); + m_eventTRTY->push_back(p3d.y()); + m_eventTRTZ->push_back(p3d.z()); + } + else if ( dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()) ) // SCT hit + { + count_eventNumberOfHitsOnTracks[3]++; + Identifier id = dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())->prepRawData()->identify(); + if ( m_SCTHelper->barrel_ec( id )==0 ) // barrel hits + count_eventNumberOfHitsOnTracks[4]++; + + //Trk::GlobalPosition p3d = dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())->globalPosition(); + Amg::Vector3D p3d = dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())->globalPosition(); + m_eventSCTX->push_back(p3d.x()); + m_eventSCTY->push_back(p3d.y()); + m_eventSCTZ->push_back(p3d.z()); + + const InDet::SCT_Cluster *p_rdo = dynamic_cast<const InDet::SCT_Cluster *> ( (dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()))->prepRawData() ); + const SCT3_RawData* rdo3 = dynamic_cast<const SCT3_RawData*>(p_rdo); + m_eventSCTHitTimeBin->push_back( rdo3 ? (rdo3)->getTimeBin() : 999 ); + + } + else if ( dynamic_cast<const InDet::PixelClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()) ) // pixel hit + { + const InDet::PixelClusterOnTrack *pixelCluster = dynamic_cast<const InDet::PixelClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()); + + count_eventNumberOfHitsOnTracks[5]++; + Identifier id = pixelCluster->prepRawData()->identify(); + if ( m_PixelHelper->barrel_ec( id ) == 0 ) // barrel hits + { + count_eventNumberOfHitsOnTracks[6]++; + eventPixelTimeBin += pixelCluster->prepRawData()->LVL1A(); + } + + m_eventPixelHitTimeBin->push_back( pixelCluster->prepRawData()->LVL1A() ); + + //sprintf(line, "pixelRDOhits: event %3d, hit %2d, getLVL1ID: %2d TOT: %3d, BCID: %3d", event, count++, (*p_rdo)->getLVL1A(), + // (*p_rdo)->getToT(), (*p_rdo)->getBCID()); + //if (msgLvl(MSG::INFO)) msg(MSG::INFO) << line << endreq; + // m_pixelL1TimeBin->push_back( (*p_rdo)->getLVL1A() ); + // InDetDD::SiDetectorElement* si_hit = m_PixelDetMgr->getDetectorElement( id )->surface( id ); + // HepGeom::Point3D<double> p3d = m_PixelDetMgr->getDetectorElement( id )->surface( id ).center(); + //Trk::GlobalPosition p3d = pixelCluster->globalPosition(); + Amg::Vector3D p3d = pixelCluster->globalPosition(); + m_eventPixelX->push_back(p3d.x()); + m_eventPixelY->push_back(p3d.y()); + m_eventPixelZ->push_back(p3d.z()); + + } else + { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "which measurement error?" << endreq; + } + } // end measurements loop + + for (int i=0; i<7; i+=2) + { + if (count_eventNumberOfHitsOnTracks[i]>m_eventNumberOfHitsOnTracks[i]) + { + for (int j=0; j<2; j++) + m_eventNumberOfHitsOnTracks[i+j] = count_eventNumberOfHitsOnTracks[i+j]; + if ( i==5 && m_eventNumberOfHitsOnTracks[6] ) // pixel hits + m_eventPixelTimeBin = (1.*eventPixelTimeBin) / (1.*m_eventNumberOfHitsOnTracks[6]); + if (i==0 && !m_eventNumberOfHitsOnTracks[5] && !m_eventNumberOfHitsOnTracks[3]) // based on TRT if no pixel and SCT hits + bestTrackIt = trackIt; + if (i==3 && !m_eventNumberOfHitsOnTracks[5]) // based on SCT if no pixel hits + bestTrackIt = trackIt; + if (i==5) + bestTrackIt = trackIt; + } + if (!i) // special for TRT - three values + ++i; + } + if (count_eventNumberOfHitsOnTracks[2]>m_eventNumberOfHitsOnTracks[2]) + m_eventNumberOfHitsOnTracks[2] = count_eventNumberOfHitsOnTracks[2]; + + } // end TrkCollection loop + + if ( bestTrackIt != m_trkCollection->end() ) // set track parameters + { + //CLHEP::HepVector perigeeParameters = (**bestTrackIt).perigeeParameters()->parameters(); + const Trk::Perigee* per = (**bestTrackIt).perigeeParameters(); + AmgVector(5) perigeeParameters = per->parameters(); + //m_eventTrackInfo[0] = perigeeParameters[Trk::phi0]; if (m_eventTrackInfo[0]>0.) m_eventTrackInfo[0] -= M_PI; + m_eventTrackInfo[0] = (perigeeParameters[Trk::phi0] <= 0) ? perigeeParameters[Trk::phi0] : perigeeParameters[Trk::phi0] - M_PI; + m_eventTrackInfo[1] = perigeeParameters[Trk::d0]; + m_eventTrackInfo[2] = perigeeParameters[Trk::z0]; + m_eventTrackInfo[3] = perigeeParameters[Trk::theta]; + m_eventTrackInfo[4] = perigeeParameters[Trk::qOverP]; + const DataVector<const Trk::TrackStateOnSurface>* trackStates = (**bestTrackIt).trackStateOnSurfaces(); + if ( trackStates == 0 ) + { + msg(MSG::ERROR) << "bestTrackIt states 0 ptr" << endreq; + } + else + { + for ( DataVector<const Trk::TrackStateOnSurface>::const_iterator trackStatesIt = trackStates->begin(); trackStatesIt != trackStates->end(); trackStatesIt++ ) + { + if ( *trackStatesIt == 0 ) + { + msg(MSG::ERROR) << "*trackStatesIt == 0" << endreq; + continue; + } + if ( !((*trackStatesIt)->type(Trk::TrackStateOnSurface::Measurement)) ) + continue; + + if ( dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()) ) // SCT hit + { + Identifier id = dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())->prepRawData()->identify(); + if ( m_SCTHelper->barrel_ec( id )==0 ) + { + //Trk::GlobalPosition p3d = dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())->globalPosition(); + Amg::Vector3D p3d = dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())->globalPosition(); + ++m_siSP[(p3d.y()>0.)?0:1]; + } + + } + else if ( dynamic_cast<const InDet::PixelClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()) ) // pixel hit + { + const InDet::PixelClusterOnTrack *pixelCluster = dynamic_cast<const InDet::PixelClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()); + Identifier id = pixelCluster->prepRawData()->identify(); + if ( m_PixelHelper->barrel_ec( id ) == 0 ) // barrel hits + { + //Trk::GlobalPosition p3d = pixelCluster->globalPosition(); + Amg::Vector3D p3d = pixelCluster->globalPosition(); + m_siSP[(p3d.y()>0.)?0:1]++; + } + } // end pixel hit + } + } + } + + if ( !m_eventL2Alg[2] && bestTrackIt != m_trkCollection->end() ) // !m_trackTrigAllTeIDSelected + { + for (TRT_RDO_Container::const_iterator rdoIt = m_rdoContainer->begin(); rdoIt != m_rdoContainer->end(); rdoIt++) + { + const InDetRawDataCollection<TRT_RDORawData>* TRTCollection(*rdoIt); + if (TRTCollection==0) + continue; + + for (DataVector<TRT_RDORawData>::const_iterator trtIt = TRTCollection->begin(); trtIt != TRTCollection->end(); trtIt++) + { + if ((*trtIt)->timeOverThreshold()<10.) + continue; + + Identifier id = (*trtIt)->identify(); + //const HepGeom::Point3D<double> &p3d = m_trtDetMgr->getElement( id )->center( id ); + Amg::Vector3D p3d = m_trtDetMgr->getElement( id )->center( id ); + + m_eventTRTX->push_back(p3d.x()); + m_eventTRTY->push_back(p3d.y()); + m_eventTRTZ->push_back(p3d.z()+10000.); + } + } + } // end if () do RDO + + + + + m_pixelMaxNumberOfTRTBarrelHitsOnTrack = 0; + m_pixelTRTtrackD0 = 0.; + m_pixelTRTtrackPhi0 = 0.; + m_pixelTRTtrackEP = 0.; + + + int maxTRThits(0), countTRThits(0), countTRTbarrelHits(0), maxSCThits(0), countSCThits(0); +// double SCTphi(0.), SCTd0(0.), SCTtheta(0.), TRTphi(0.), TRTd0(0.); + + + m_trackNumTrtTracks = 0; + m_trackNumTracks = 0; + + for ( DataVector<Trk::Track>::const_iterator trackIt = m_trkCollection->begin(); trackIt != m_trkCollection->end(); trackIt++ ) + { + const DataVector<const Trk::TrackStateOnSurface>* trackStates = (**trackIt).trackStateOnSurfaces(); + if ( trackStates == 0 ) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Trk::TrackStateOnSurface empty" << endreq; + continue; + } + + m_trackNumTracks++; + int countNumTrtHitsOnTrack(0); + + for ( DataVector<const Trk::TrackStateOnSurface>::const_iterator trackStatesIt = trackStates->begin(); trackStatesIt != trackStates->end(); trackStatesIt++ ) + { + if ( *trackStatesIt == 0 ) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "*trackStatesIt == 0" << endreq; + continue; + } + if ( !((*trackStatesIt)->type(Trk::TrackStateOnSurface::Measurement)) ) + continue; + if ( dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>( (*trackStatesIt)->measurementOnTrack() ) ) + ++countNumTrtHitsOnTrack; + } + if (countNumTrtHitsOnTrack>=10) + ++m_trackNumTrtTracks; + } + + for ( DataVector<Trk::Track>::const_iterator trackIt = m_trkCollection->begin() + ; trackIt != m_trkCollection->end() + ; trackIt++ + ) + { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " track loop start" << endreq; + ++m_eventNumberOfTracks; + + const DataVector<const Trk::TrackStateOnSurface>* trackStates = (**trackIt).trackStateOnSurfaces(); + if ( trackStates == 0 ) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Trk::TrackStateOnSurface empty" << endreq; + continue; + } + + double theta = (**trackIt).perigeeParameters()->parameters()[Trk::theta]; + double d0 = (**trackIt).perigeeParameters()->parameters()[Trk::d0]; + double z0 = (**trackIt).perigeeParameters()->parameters()[Trk::z0]; + double phi0 = (**trackIt).perigeeParameters()->parameters()[Trk::phi0]; + + int nSctHits = 0; + int nTrtHits = 0; + int nTrtHitsBarrelA = 0; + int nTrtHitsBarrelC = 0; + int nTrtHitsEcA = 0; + int nTrtHitsEcC = 0; + + int ndf = 0; + double chi2 = 0; + const Trk::FitQuality *fitQuality = (**trackIt).fitQuality(); + if (fitQuality) + { + ndf = fitQuality->numberDoF(); + chi2 = fitQuality->chiSquared(); + } + + /////////////////////////////////////////////// + /// Loop over track states within this track + /// essentially hits on track + /////////////////////////////////////////////// + for ( DataVector<const Trk::TrackStateOnSurface>::const_iterator trackStatesIt = trackStates->begin() + ; trackStatesIt != trackStates->end() + ; trackStatesIt++ + ) + { + if ( *trackStatesIt == 0 ) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "*trackStatesIt == 0" << endreq; + continue; + } + + if ( !( (*trackStatesIt)->type(Trk::TrackStateOnSurface::Measurement) ) ) + continue; + + if (dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()) != 0) + { + ++nSctHits; + ++m_eventNumberOfSCT_HitsOnTracks; + ++countSCThits; + continue; + } + + const InDet::TRT_DriftCircleOnTrack *driftCircleOnTrack = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>( (*trackStatesIt)->measurementOnTrack() ); + + if( ((*trackStatesIt)->type(Trk::TrackStateOnSurface::Outlier)) + && msgLvl(MSG::INFO) + ) + msg(MSG::INFO) << "Outlier on track " << endreq; + + if( driftCircleOnTrack == 0 ) + { + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "driftCircleOnTrack == 0 " << ( ((*trackStatesIt)->type(Trk::TrackStateOnSurface::Outlier)) ? "Outlier" : "." ) << endreq; + continue; + } + + double locR(999.); + //const Trk::MeasuredAtaStraightLine *trackMeasuredAtLine = dynamic_cast<const Trk::MeasuredAtaStraightLine*>( (**trackIt).perigeeParameters() ); +// if ( trackMeasuredAtLine ) // point of track's closest approach, I believe + locR = ((**trackIt).perigeeParameters())->parameters()[Trk::locR]; + //locR = trackMeasuredAtLine->parameters()[Trk::locR]; + + + + + + const Trk::MeasurementBase* mesb = (*trackStatesIt)->measurementOnTrack(); + if(mesb == 0) + { + msg(MSG::ERROR) << "measurementBase == 0, and we should have had it!!!" << endreq; + continue; + } + float locRPat = mesb->localParameters()[Trk::locR]; + //float errLocR = mesb->localErrorMatrix().covValue(Trk::locR); + float errLocR = mesb->localCovariance()(Trk::locX,Trk::locX) ; + + + + m_eventNumberOfTRT_HitsOnTracks++; + countTRThits++; + + if(driftCircleOnTrack->prepRawData()==0) { + //const Trk::GlobalPosition& gloPos = driftCircleOnTrack->globalPosition(); + Amg::Vector3D gloPos = driftCircleOnTrack->globalPosition(); + msg(MSG::ERROR) << "driftCircleOnTrack->prepRawData()==0, global pos: " << gloPos.x() << " " << gloPos.y() << " " << gloPos.z() << endreq; + continue; + } + + + if( abs(m_trtHelper->barrel_ec((driftCircleOnTrack->prepRawData())->identify())) == 1 ) + countTRTbarrelHits++; + + nTrtHits++; + switch( m_trtHelper->barrel_ec((driftCircleOnTrack->prepRawData())->identify()) ) + { + // if barrel hit, incriment barrel hit count + case 1: + nTrtHitsBarrelA++; + break; + case 2: + nTrtHitsEcA++; + break; + case -1: + nTrtHitsBarrelC++; + break; + case -2: + nTrtHitsEcC++; + break; + default: + msg(MSG::ERROR) << "invalid value for side: " + << m_trtHelper->barrel_ec((driftCircleOnTrack->prepRawData())->identify()) + << endreq; + break; + } + + + const InDet::TRT_DriftCircle *driftCircle = driftCircleOnTrack->prepRawData(); + if ( driftCircle == 0 ) + { + msg(MSG::ERROR) << "driftCircle == 0" << endreq; + continue; + } + + ///////////////////////////////////////////////////////////////////////// + /// Find drift circle parameters to be filled into the "on track" tree + ///////////////////////////////////////////////////////////////////////// + Identifier id = driftCircle->identify(); + m_trtStrawMap->setNewIdentifier(id); + + int side = m_trtHelper->barrel_ec(id); + int layerOrWheel = m_trtHelper->layer_or_wheel(id); + int phi = m_trtHelper->phi_module(id); + int strawLayer = m_trtHelper->straw_layer(id); + int straw = m_trtHelper->straw(id); + int strawNumber = m_trtStrawMap->straw(); + int board = m_trtStrawMap->board(); + int chip; + m_trtStrawNeighbourTool->getChip(id, chip); + + if(abs(side) == 1) // barrel + { + // set chip number to correct scale + chip-=1; + if(layerOrWheel == 1) + chip+=21; + else if(layerOrWheel == 2) + chip+=54; + } + else // endcap + { + if(chip > 11) + chip-=20; + chip+=(104+12*board); + } + + + //const CLHEP::Hep3Vector ¢er = driftCircle->detectorElement()->surface( id ).center(); + Amg::Vector3D center = driftCircle->detectorElement()->surface( id ).center(); + double dbT0 = m_trtCondDbTool->getT0(id, TRTCond::ExpandedIdentifier::STRAW); + + m_trackSide->push_back(side); + m_trackLayerOrWheel->push_back(layerOrWheel); + m_trackPhi->push_back(phi); + m_trackStrawLayer->push_back(strawLayer); + m_trackStraw->push_back(straw); + m_trackStrawNum->push_back(strawNumber); + m_trackChip->push_back(chip); + m_trackBoard->push_back(board); + m_trackDriftTimeBin->push_back(driftCircle->driftTimeBin()); + m_trackTrailingEdge->push_back(driftCircle->trailingEdge()); + m_trackHighThreshold->push_back(driftCircle->highLevel()); + m_trackDriftCircleWord->push_back(driftCircle->getWord()); + m_trackX->push_back(center.x()); + m_trackY->push_back(center.y()); + m_trackZ->push_back(center.z()); + m_trackT0->push_back(dbT0); + + m_trackTrackR->push_back(locR); + m_trackLocR->push_back(locRPat); + m_trackErrR->push_back(errLocR); + + m_onTrackIdentifiers->push_back(driftCircle->identify()); + } + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "track loop start filling tree" << endreq; + + if (nSctHits>maxSCThits) + { + //SCTphi = phi0; + //SCTd0 = d0; + //SCTtheta = theta; + maxSCThits = nSctHits; + } + if (nTrtHits>maxTRThits) + { + //TRTphi = phi0; + //TRTd0 = d0; + maxTRThits = nTrtHits; + } + + m_trackNumSctHits = nSctHits; + m_trackNumTrtHits = nTrtHits; + m_trackNumTrtHitsBarrelA = nTrtHitsBarrelA; + m_trackNumTrtHitsBarrelC = nTrtHitsBarrelC; + m_trackNumTrtHitsEcA = nTrtHitsEcA; + m_trackNumTrtHitsEcC = nTrtHitsEcC; + m_trackNdf = ndf; + m_trackChi2 = chi2; + m_trackTheta = theta; + m_trackD0 = d0; + m_trackZ0 = z0; + m_trackPhi0 = phi0; + + //////////////////////////////////////////////////////// + /// Find event phase for this track and use it to set + /// event phase for all hits in this track + //////////////////////////////////////////////////////// + m_trackEventPhase = 0.; + for(unsigned int hitItr = 0; hitItr < m_trackTrailingEdge->size(); hitItr++) + { + m_trackEventPhase += (double) m_trackTrailingEdge->at(hitItr); + } + m_trackEventPhase /= (double) m_trackTrailingEdge->size(); + + if (countTRTbarrelHits>m_pixelMaxNumberOfTRTBarrelHitsOnTrack) + { + m_pixelTRTtrackD0 = d0; + m_pixelTRTtrackPhi0 = phi0; + m_pixelMaxNumberOfTRTBarrelHitsOnTrack = countTRTbarrelHits; + m_pixelTRTtrackEP = m_trackEventPhase; + } + + ///////////////////////////////////////////////////////////////////// + /// Fill "on track" tree and clear all vectors linked to this tree + ///////////////////////////////////////////////////////////////////// + m_treeTrack->Fill(); + + m_trackSide->clear(); + m_trackLayerOrWheel->clear(); + m_trackPhi->clear(); + m_trackStrawLayer->clear(); + m_trackStraw->clear(); + m_trackStrawNum->clear(); + m_trackChip->clear(); + m_trackBoard->clear(); + m_trackDriftTimeBin->clear(); + m_trackTrailingEdge->clear(); + m_trackHighThreshold->clear(); + m_trackDriftCircleWord->clear(); + m_trackX->clear(); + m_trackY->clear(); + m_trackZ->clear(); + m_trackT0->clear(); + + m_trackTrackR->clear(); + m_trackLocR->clear(); + m_trackErrR->clear(); + + } + + + + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "end track info ttree" << endreq; + + m_eventNumberOfTRT_HitsOnTracks = maxTRThits; + m_eventNumberOfSCT_HitsOnTracks = maxSCThits; + + m_treeEvent->Fill(); + +} + + +void InDet::TRT_DetectorPlots::fillSegmentTree() +{ + /////////////////////////////////////////////// + /// Loop over barrel track segments in event + /////////////////////////////////////////////// + for ( DataVector<Trk::Segment>::const_iterator segIt = m_segmentCollectionBarrel->begin(); segIt != m_segmentCollectionBarrel->end(); segIt++ ) + { + const Trk::TrackSegment *segment = dynamic_cast<const Trk::TrackSegment *>(*segIt); + if (segment==0) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "no segment from segIt???" << endreq; + continue; + } + + unsigned int numberOfHits = segment->numberOfMeasurementBases(); // number of TRT hits in this segment + + for (unsigned int i=0; i<numberOfHits; i++) // access the hits + { + const InDet::TRT_DriftCircleOnTrack *circle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>(segment->measurement(i)); + if (circle==0) + continue; + const InDet::TRT_DriftCircle *driftCircle = circle->prepRawData(); + if ( driftCircle == 0 ) + { + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "driftCircleOnTrack == 0" << endreq; + continue; + } + + ///////////////////////////////////////////////////////////////////////// + /// Find drift circle parameters to be filled into the "segment" tree + ///////////////////////////////////////////////////////////////////////// + Identifier id = driftCircle->identify(); + m_trtStrawMap->setNewIdentifier(id); + + int side = m_trtHelper->barrel_ec(id); + int layerOrWheel = m_trtHelper->layer_or_wheel(id); + int phi = m_trtHelper->phi_module(id); + int strawLayer = m_trtHelper->straw_layer(id); + int straw = m_trtHelper->straw(id); + int strawNumber = m_trtStrawMap->straw(); + int board = m_trtStrawMap->board(); + int chip; + m_trtStrawNeighbourTool->getChip(id, chip); + + if(abs(side) == 1) // barrel + { + // set chip number to correct scale + chip-=1; + if(layerOrWheel == 1) chip+=21; + else if(layerOrWheel == 2) chip+=54; + } + else // endcap + { + if(chip > 11) chip-=20; + chip+=(104+12*board); + } + + //const CLHEP::Hep3Vector ¢er = driftCircle->detectorElement()->surface( id ).center(); + Amg::Vector3D center = driftCircle->detectorElement()->surface( id ).center(); + unsigned int word = driftCircle->getWord(); + double dbT0 = m_trtCondDbTool->getT0(id, TRTCond::ExpandedIdentifier::STRAW); + + m_segmentSide->push_back(side); + m_segmentLayerOrWheel->push_back(layerOrWheel); + m_segmentPhi->push_back(phi); + m_segmentStrawLayer->push_back(strawLayer); + m_segmentStraw->push_back(straw); + m_segmentStrawNum->push_back(strawNumber); + m_segmentChip->push_back(chip); + m_segmentBoard->push_back(board); + m_segmentDriftTimeBin->push_back(driftCircle->driftTimeBin()); + m_segmentTrailingEdge->push_back(driftCircle->trailingEdge()); + m_segmentDriftCircleWord->push_back(word); + //m_segmentHitOnTrack->push_back(_onTrack); + m_segmentX->push_back(center.x()); + m_segmentY->push_back(center.y()); + m_segmentZ->push_back(center.z()); + m_segmentT0->push_back(dbT0); + } // end hits loop + } + + + /////////////////////////////////////////////// + /// Loop over endcap track segments in event + /////////////////////////////////////////////// + for ( DataVector<Trk::Segment>::const_iterator segIt = m_segmentCollectionEc->begin(); segIt != m_segmentCollectionEc->end(); segIt++ ) { + + const Trk::TrackSegment *segment = dynamic_cast<const Trk::TrackSegment *>(*segIt); + if (segment==0) { msg(MSG::ERROR) << "no segment from segIt???" << endreq; continue; } + + unsigned int numberOfHits = segment->numberOfMeasurementBases(); // number of TRT hits in this segment + + for (unsigned int i=0; i<numberOfHits; i++) { // access the hits + + const InDet::TRT_DriftCircleOnTrack *circle = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>(segment->measurement(i)); + if (circle==0) continue; + const InDet::TRT_DriftCircle *driftCircle = circle->prepRawData(); + if ( driftCircle == 0 ) { if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "driftCircleOnTrack == 0" << endreq; continue; } + + ///////////////////////////////////////////////////////////////////////// + /// Find drift circle parameters to be filled into the "segment" tree + ///////////////////////////////////////////////////////////////////////// + Identifier id = driftCircle->identify(); + m_trtStrawMap->setNewIdentifier(id); + + int side = m_trtHelper->barrel_ec(id); + int layerOrWheel = m_trtHelper->layer_or_wheel(id); + int phi = m_trtHelper->phi_module(id); + int strawLayer = m_trtHelper->straw_layer(id); + int straw = m_trtHelper->straw(id); + int strawNumber = m_trtStrawMap->straw(); + int board = m_trtStrawMap->board(); + int chip; + m_trtStrawNeighbourTool->getChip(id, chip); + + if(abs(side) == 1) // barrel + { + // set chip number to correct scale + chip-=1; + if(layerOrWheel == 1) chip+=21; + else if(layerOrWheel == 2) chip+=54; + } + else // endcap + { + // set all chips on a scale from 0-11 + if(chip > 11) chip-=20; + chip+=(104+12*board); + } + + + //const CLHEP::Hep3Vector ¢er = driftCircle->detectorElement()->surface( id ).center(); + Amg::Vector3D center = driftCircle->detectorElement()->surface( id ).center(); + unsigned int word = driftCircle->getWord(); + double dbT0 = m_trtCondDbTool->getT0(id, TRTCond::ExpandedIdentifier::STRAW); + + m_segmentSide->push_back(side); + m_segmentLayerOrWheel->push_back(layerOrWheel); + m_segmentPhi->push_back(phi); + m_segmentStrawLayer->push_back(strawLayer); + m_segmentStraw->push_back(straw); + m_segmentStrawNum->push_back(strawNumber); + m_segmentChip->push_back(chip); + m_segmentBoard->push_back(board); + m_segmentDriftTimeBin->push_back(driftCircle->driftTimeBin()); + m_segmentTrailingEdge->push_back(driftCircle->trailingEdge()); + m_segmentDriftCircleWord->push_back(word); + m_segmentX->push_back(center.x()); + m_segmentY->push_back(center.y()); + m_segmentZ->push_back(center.z()); + m_segmentT0->push_back(dbT0); + + } // end hits loop + } + + + ///////////////////////////////////////////////// + /// Fill tree and clear vectors for next event + ///////////////////////////////////////////////// + m_treeSegment->Fill(); + + m_segmentSide->clear(); + m_segmentLayerOrWheel->clear(); + m_segmentPhi->clear(); + m_segmentStrawLayer->clear(); + m_segmentStraw->clear(); + m_segmentStrawNum->clear(); + m_segmentChip->clear(); + m_segmentBoard->clear(); + m_segmentDriftTimeBin->clear(); + m_segmentTrailingEdge->clear(); + m_segmentDriftCircleWord->clear(); + m_segmentHitOnTrack->clear(); + m_segmentX->clear(); + m_segmentY->clear(); + m_segmentZ->clear(); + m_segmentT0->clear(); +} + + +void InDet::TRT_DetectorPlots::fillHitsTree() +{ + /////////////////////////////////////////// + /// Loop over all drift circles in event + /////////////////////////////////////////// + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "start loop over all hits" << endreq; + + int count=0; + for( InDet::TRT_DriftCircleContainer::const_iterator it=m_trtDriftCircleContainer->begin() + ; it!=m_trtDriftCircleContainer->end() && count<m_numNoise + ; ++it, ++count + ) + { + const InDet::TRT_DriftCircleCollection *colNext = &(**it); + if (!colNext) + { + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "!colNext (mTRTDriftCircleContainer loop)" << endreq; + continue; + } + + for( DataVector<InDet::TRT_DriftCircle>::const_iterator circleit = (*colNext).begin() + ; circleit!=(*colNext).end() + ; ++circleit + ) + { + const InDet::TRT_DriftCircle *driftCircle = *circleit; + if ( driftCircle == 0 ) + { + if(msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "driftCircle == 0" << endreq; + continue; + } + + Identifier id = driftCircle->identify(); + m_trtStrawMap->setNewIdentifier(id); + + //////////////////////////////// + /// Is drift circle on track? + //////////////////////////////// + bool onTrack = false; + //int trackNumber = 0; + for(unsigned int onTrackItr = 0; onTrackItr < m_onTrackIdentifiers->size(); onTrackItr++) + { + if(id == m_onTrackIdentifiers->at(onTrackItr)) + { + onTrack = true; + m_onTrackIdentifiers->erase(m_onTrackIdentifiers->begin()+onTrackItr); + continue; + } + } + + ///////////////////////////////////////////////////////////////////////// + /// Find drift circle parameters to be filled into the "hits" tree + ///////////////////////////////////////////////////////////////////////// + int side = m_trtHelper->barrel_ec(id); + int layerOrWheel = m_trtHelper->layer_or_wheel(id); + int phi = m_trtHelper->phi_module(id); + int strawLayer = m_trtHelper->straw_layer(id); + int straw = m_trtHelper->straw(id); + int strawNumber = m_trtStrawMap->straw(); + int board = m_trtStrawMap->board(); + int chip; + m_trtStrawNeighbourTool->getChip(id, chip); + + + if(abs(side) == 1) // barrel + { + // set chip number to correct scale + chip-=1; + if(layerOrWheel == 1) chip+=21; + else if(layerOrWheel == 2) chip+=54; + } + else // endcap + { + // set all chips on a scale from 0-11 + if(chip > 11) chip-=20; + chip+=(104+12*board); + } + + //const CLHEP::Hep3Vector ¢er = driftCircle->detectorElement()->surface( id ).center(); + Amg::Vector3D center = driftCircle->detectorElement()->surface( id ).center(); + + unsigned int word = driftCircle->getWord(); + double dbT0 = m_trtCondDbTool->getT0(id, TRTCond::ExpandedIdentifier::STRAW); + + m_hitsSide = (side); + m_hitsLayerOrWheel = (layerOrWheel); + m_hitsPhi = (phi); + m_hitsStrawLayer = (strawLayer); + m_hitsStraw = (straw); + m_hitsStrawNum = (strawNumber); + m_hitsChip = (chip); + m_hitsBoard = (board); + m_hitsDriftTimeBin = (driftCircle->driftTimeBin()); + m_hitsTrailingEdge = (driftCircle->trailingEdge()); + m_hitsDriftCircleWord = (word); + m_hitsHitOnTrack = (int) (onTrack); + m_hitsX = (center.x()); + m_hitsY = (center.y()); + m_hitsZ = (center.z()); + m_hitsT0 = (dbT0); + + m_treeHits->Fill(); + } + } +} + diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorTiming.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorTiming.cxx new file mode 100644 index 000000000000..592f687fc657 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_DetectorTiming.cxx @@ -0,0 +1,515 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TRT_DetectorPerformance/TRT_DetectorTiming.h" + + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/IJobOptionsSvc.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/ToolHandle.h" + +#include "StoreGate/DataHandle.h" + +#include "DataModel/DataVector.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" +#include "InDetReadoutGeometry/TRT_Numerology.h" + +#include "InDetRawData/InDetRawDataContainer.h" +#include "InDetRawData/InDetRawDataCLASS_DEF.h" + +#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" +#include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" +#include "InDetRIO_OnTrack/PixelClusterOnTrack.h" +#include "InDetPrepRawData/TRT_DriftCircle.h" + +//#include "TrkParameters/MeasuredPerigee.h" +#include "TrkParameters/TrackParameters.h" +// #include "TrkTrackSummaryTool/ITrackSummaryTool.h" +#include "TrkTrackSummary/TrackSummary.h" +//#include "TrkParameters/MeasuredAtaStraightLine.h" + +#include "TRT_ConditionsServices/ITRT_StrawNeighbourSvc.h" +#include "TRT_ConditionsServices/ITRT_CalDbSvc.h" + +#include "TrkTrack/Track.h" +#include "TrkTrack/TrackCollection.h" +#include "CommissionEvent/ComTime.h" + +#include "TRT_DetectorPerformance/TRT_StrawMap.h" + +#include "TTree.h" + + + +///////////////////////////////////////////////////////////////////////////// + +InDet::TRT_DetectorTiming::TRT_DetectorTiming(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name, pSvcLocator), + m_trtCondDbTool("TRT_CalDbSvc", name), + m_trtStrawNeighbourTool("TRT_StrawNeighbourSvc", name), + m_trtStrawMap("InDet::TRT_StrawMap"), + m_histSvc("THistSvc", name) +{ + declareProperty("histogramService", m_histSvc); + + m_ntuple = 0; +} + + +bool MySortCriteria(InDet::TRT_DetectorTiming::hitParams* hp1, InDet::TRT_DetectorTiming::hitParams* hp2) { + + return (hp1->y > hp2->y); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode InDet::TRT_DetectorTiming::initialize(){ + + if (msgLvl(MSG::INFO)) msg()<< "initialize()" << endreq; + + m_numTrtOnlyTracks = 0; + m_numTrtSctTracks = 0; + + ////////////////////////////////////////////// + // Create TTree and register it to THistSvc + ////////////////////////////////////////////// + + if ( m_histSvc.retrieve().isFailure() ){ + msg(MSG::FATAL) << "histogram service not found" << endreq; + return StatusCode::FAILURE; + } else + if (msgLvl(MSG::INFO)) msg() << "retrieved histogramService" << endreq; + + m_ntuple = new TTree("ntuple" , "ntuple"); + + std::string fullTreeName_ntuple = "/AANT/ntuple" ; + if((m_histSvc->regTree(fullTreeName_ntuple, m_ntuple)).isFailure()) + { + msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeName_ntuple << endreq; + return StatusCode::FAILURE; + } + + ////////////////////////////////////////////////////// + /// Book variables to be added to the output ntuple + ////////////////////////////////////////////////////// + m_ntuple->Branch("corLE" , &m_correctedLeadingEdge, "corLE/D"); + m_ntuple->Branch("EP" , &m_timeCor , "EP/D"); + m_ntuple->Branch("TOT" , &m_timeOverThreshold , "TOT/D"); + m_ntuple->Branch("TEbin" , &m_trailingEdgeBin , "TEbin/I"); + m_ntuple->Branch("LEbin" , &m_leadingEdgeBin , "LEbin/I"); + m_ntuple->Branch("wrongSide" , &m_wrongSide , "wrongSide/I"); // only valid for barrel tracks + m_ntuple->Branch("board" , &m_board , "board/I"); + m_ntuple->Branch("locR" , &m_locR , "locR/D"); + m_ntuple->Branch("timeCorChip" , &m_timeCorChip , "timeCorChip/D"); // currently not implemented -- always 0 + m_ntuple->Branch("chip" , &m_chip , "chip/I"); + m_ntuple->Branch("side" , &m_side , "side/I"); + m_ntuple->Branch("t0" , &m_t0 , "t0/D"); + m_ntuple->Branch("phi" , &m_phi , "phi/I"); + m_ntuple->Branch("straw" , &m_straw , "straw/I"); + m_ntuple->Branch("strawLayer" , &m_strawLayer , "strawLayer/I"); + m_ntuple->Branch("layer" , &m_layer , "layer/I"); + m_ntuple->Branch("nBarHits" , &m_nTrtBarHits , "nBarHits/I"); + m_ntuple->Branch("nEcHits" , &m_nTrtEcHits , "nEcHits/I"); + m_ntuple->Branch("nTRThits_barrelA", &m_nTrtHitsBarrelA , "nTRThits_barrelA/I"); + m_ntuple->Branch("nTRThits_barrelC", &m_nTrtHitsBarrelC , "nTRThits_barrelC/I"); + m_ntuple->Branch("nTRThits_ecA" , &m_nTrtHitsEcA , "nTRThits_ecA/I"); + m_ntuple->Branch("nTRThits_ecC" , &m_nTrtHitsEcC , "nTRThits_ecC/I"); + m_ntuple->Branch("nSCThits" , &m_nSctHits , "nSCThits/I"); + m_ntuple->Branch("nPixHits" , &m_nPixHits , "nPixHits/I"); + m_ntuple->Branch("theta" , &m_theta , "theta/D"); + m_ntuple->Branch("eta" , &m_eta , "eta/D"); + m_ntuple->Branch("chi2ndf" , &m_chi2Ndf , "chi2ndf/D"); + m_ntuple->Branch("phi0" , &m_phi0 , "phi0/D"); + m_ntuple->Branch("z0" , &m_z0 , "z0/D"); + m_ntuple->Branch("d0" , &m_d0 , "d0/D"); + m_ntuple->Branch("tubeHit" , &m_tubeHit , "tubeHit/I"); + m_ntuple->Branch("locRpat" , &m_locRPat , "locRpat/D"); + + if (msgLvl(MSG::INFO)) msg()<< "end initialize()" << endreq; + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +StatusCode InDet::TRT_DetectorTiming::execute() { + + if (msgLvl(MSG::DEBUG)) msg() << "execute()" << endreq; + + // TRT helper + const TRT_ID * m_trtHelper; + if (detStore()->retrieve(m_trtHelper, "TRT_ID").isFailure()) { + msg(MSG::FATAL) << "Could not get TRT ID helper" << endreq; + return StatusCode::FAILURE; + } + + const DataVector<Trk::Track> *trkCollection = 0; + StatusCode sc = evtStore()->retrieve( trkCollection, "Tracks" ); + if ( sc.isFailure() ) { + msg(MSG::ERROR) << "Could not find Tracks Collection" << endreq; + return sc; + } + + if ( trkCollection == 0 ) { + msg(MSG::ERROR) << "trkCollection == 0 " << endreq; + assert( trkCollection ); + return StatusCode::FAILURE; + } + + // get the TRT_Phase -- also called the Event Phase + ComTime* theComTime; + sc = evtStore()->retrieve(theComTime, "TRT_Phase"); + if(sc.isFailure()) + { + msg(MSG::ERROR) << "ComTime object not found with name TRT_Phase !!!" << endreq; + } + + if(StatusCode::SUCCESS!=m_trtCondDbTool.retrieve() ) { + msg(MSG::ERROR) <<"Could not get TRTCalDbTool !"<<endreq; + return StatusCode::FAILURE; + } + + sc = m_trtStrawNeighbourTool.retrieve() ; + if (sc.isFailure()) { + msg(MSG::ERROR) << "Could not find TRTStrawNeighbourTool " << endreq; + return sc; + } + + + // get the event phase - one phase for the entire event + double timeCor=0.; + if(theComTime) + { + timeCor = theComTime->getTime(); + } + + // watch out for sneaky infinity trying to set us up the bomb! + if (timeCor < -100 || timeCor > 100) { + timeCor = 0.; + } + + const float tubeHitErr = 1.33333; + + + // open a file to print + static int firstCall = 0; + FILE *myFile = fopen("myTRToutput.dat", (firstCall)?"a":"w"); // overwrite the old file only at the first call + firstCall++; + + int nTracks = trkCollection->size(); + int countTracks = 0; + if (msgLvl(MSG::VERBOSE)) msg() << "starting DataVector<Trk::Track> loop over nTracks = " << nTracks << endreq; + // loop over all tracks + for ( DataVector<Trk::Track>::const_iterator trackIt = trkCollection->begin(); trackIt != trkCollection->end(); trackIt++ ) { + + assert( countTracks < nTracks ); countTracks++; + + // want to record all these parameters to look for poor tracks + int nTrtBarHits = 0; + int nTrtEcHits = 0; + int nTrtHitsBarrelA = 0; + int nTrtHitsBarrelC = 0; + int nTrtHitsEcA = 0; + int nTrtHitsEcC = 0; + int nSctHits = 0; + int nPixHits = 0; + float theta = 0; + float eta = 0; + float chi2Ndf = 0; + float phi0 = 0; + float d0 = 0; + float z0 = 0; + + std::vector<InDet::TRT_DetectorTiming::hitParams*> hitParamsVec; + + // use perigee parameters to get theta/eta info + theta = (**trackIt).perigeeParameters()->parameters()[Trk::theta]; + phi0 = (**trackIt).perigeeParameters()->parameters()[Trk::phi0]; + d0 = (**trackIt).perigeeParameters()->parameters()[Trk::d0]; + z0 = (**trackIt).perigeeParameters()->parameters()[Trk::z0]; + eta = (**trackIt).perigeeParameters()->eta(); + + // use fitQuality to find chi2/ndf for track + float chi2 = (**trackIt).fitQuality()->chiSquared(); + float ndf = (**trackIt).fitQuality()->numberDoF(); + chi2Ndf = chi2/ndf; + + + if (msgLvl(MSG::VERBOSE)) msg() << "start DataVector<const Trk::TrackStateOnSurface>* trackStates " << endreq; + const DataVector<const Trk::TrackStateOnSurface>* trackStates = (**trackIt).trackStateOnSurfaces(); + if ( trackStates == 0 ) { + if (msgLvl(MSG::WARNING)) msg() << "Trk::TrackStateOnSurface empty" << endreq; + continue; + } + + if (msgLvl(MSG::VERBOSE)) msg() << "start DataVector<const Trk::TrackStateOnSurface>* trackStatesIt " << trackStates->size() << endreq; + unsigned int countTrackStates(0), countTrackSatesMeasurements(0); + + + // loop over all "trackStates", in principle one state is associated to each measurement + one more trackState for track parameters at the Interaction Point + for ( DataVector<const Trk::TrackStateOnSurface>::const_iterator trackStatesIt = trackStates->begin(); trackStatesIt != trackStates->end(); trackStatesIt++ ) { + + if (msgLvl(MSG::VERBOSE)) msg() << "countTrackStates " << countTrackStates << endreq; + assert( countTrackStates < trackStates->size() ); countTrackStates++; + assert( (*trackStatesIt) != 0 ); + if ( *trackStatesIt == 0 ) { if (msgLvl(MSG::WARNING)) msg() << "*trackStatesIt == 0" << endreq; } + + //CLHEP::Hep3Vector pos(0., 0., 0.); + //CLHEP::Hep3Vector mom(0., 0., 0.); + Amg::Vector3D pos(0., 0., 0.); + Amg::Vector3D mom(0., 0., 0.); + + const Trk::TrackParameters* trackParam = (*trackStatesIt)->trackParameters(); + if ( trackParam != 0 ) { + + pos = trackParam->position(); + mom = trackParam->momentum(); + + } else { + + if (msgLvl(MSG::WARNING)) msg() << "(*trackStatesIt)->trackParameters() == NULL" << endreq; + } + + + + if ( (*trackStatesIt)->type(Trk::TrackStateOnSurface::Measurement) ) { + + // try to dynamic cast as SCT space points etc to count the number of silicon hits + if (dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())!=0) { + nSctHits++; + continue; + } + + if (dynamic_cast<const InDet::PixelClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())!=0) { + nPixHits++; + continue; + } + + if (msgLvl(MSG::VERBOSE)) msg() << "drift Circle " << endreq; + const InDet::TRT_DriftCircleOnTrack *driftCircleOnTrack = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>( (*trackStatesIt)->measurementOnTrack() ); + if ( driftCircleOnTrack == 0 ) { if (msgLvl(MSG::WARNING)) msg() << "driftCircleOnTrack == 0" << endreq; continue; } + //HepGeom::Point3D<double> hit = driftCircleOnTrack->globalPosition(); + const Amg::Vector3D hit = driftCircleOnTrack->globalPosition(); + if (msgLvl(MSG::VERBOSE)) msg() << "driftCircleOnTrack global position " << hit << endreq; + + const InDet::TRT_DriftCircle *driftCircle = dynamic_cast<const InDet::TRT_DriftCircle*> (driftCircleOnTrack->prepRawData()); + if ( driftCircle == 0 ) { if (msgLvl(MSG::WARNING)) msg() << "driftCircle == 0" << endreq; continue; } + if (msgLvl(MSG::VERBOSE)) msg() << "track measurement trail. edge " << driftCircle->trailingEdge() << " " + << ((int) driftCircle->driftTimeValid()) + << " Base valid " << ( (driftCircleOnTrack->detectorElement() == 0) ? 0 : 1 ) << endreq; + + + // this flag checks to see if the t0-corrected drift time is in the range -10ns < t < 75ns (I think...) + // !!! this causes seg faults on specific events !!! + if (!driftCircle->driftTimeValid()) continue; + + Identifier elID = driftCircle->identify(); + m_trtStrawMap->setNewIdentifier(elID); + + int side = m_trtHelper->barrel_ec(elID); // -1 for side C, 1 for side A + int layer = m_trtHelper->layer_or_wheel(elID); + int phi = m_trtHelper->phi_module(elID); + int strawLayer = m_trtHelper->straw_layer(elID); + int myStrawNumber = m_trtStrawMap->straw(); + int chip; m_trtStrawNeighbourTool->getChip(elID, chip); + int myBoard = m_trtStrawMap->board(); + + + if(abs(side) == 1) // barrel + { + // set chip number to correct scale + chip-=1; + if(layer == 1) chip+=21; + else if(layer == 2) chip+=54; + } + else // endcap + { + // set all chips on a scale from 0-11 + if(chip > 11) chip-=20; + chip+=(104+12*myBoard); + } + + if (myStrawNumber < 0 || myStrawNumber>=5482) { if (msgLvl(MSG::WARNING)) msg() << MSG::WARNING << "invalid straw number !!! " << myStrawNumber << endreq; continue; } + + // use the identifier to look up the t0 + double t0 = m_trtCondDbTool->getT0(elID, TRTCond::ExpandedIdentifier::STRAW); + + double locR(999.); + //const Trk::MeasuredAtaStraightLine *trackMeasuredAtLine = dynamic_cast<const Trk::MeasuredAtaStraightLine*>( trackParam ); + //if ( trackMeasuredAtLine ) locR = trackMeasuredAtLine->parameters()[Trk::locR]; // point of track's closest approach, I believe + locR = trackParam->parameters()[Trk::locR]; + + + + // determine if we just have a tube hit: + // these have locR == 0 + // error on locR == 4/sqrt(12) + const Trk::MeasurementBase* mesb = (*trackStatesIt)->measurementOnTrack(); + if (mesb == 0) { + if (msgLvl(MSG::WARNING)) msg() << "measurementBase == 0, and we should have had it!!!" << endreq; + continue; + } + float locRPat = mesb->localParameters()[Trk::locR]; + //float errLocR = mesb->localErrorMatrix().covValue(Trk::locR); + float errLocR = mesb->localCovariance()(Trk::locX,Trk::locX) ; + int tubeHit = 0; + if ((fabs(locRPat - 0.) < 0.001) && (fabs(errLocR - tubeHitErr) < 0.01)) { + tubeHit = 1; + } + + + if (abs(side) == 1) { + nTrtBarHits++; + } else if (abs(side) == 2) { + nTrtEcHits++; + } + if(side == 1) ++nTrtHitsBarrelA; + else if(side == -1) ++nTrtHitsBarrelC; + else if(side == 2) ++nTrtHitsEcA; + else if(side == -2) ++nTrtHitsEcC; + + InDet::TRT_DetectorTiming::hitParams* hps = new InDet::TRT_DetectorTiming::hitParams; + + // fill hitParams object with values + hps->leadingEdgeBin = driftCircle->driftTimeBin(); + hps->trailingEdgeBin = driftCircle->trailingEdge(); + hps->leadingEdge = driftCircle->rawDriftTime(); + hps->timeOverThreshold = driftCircle->timeOverThreshold(); + hps->side = side; + hps->wrongSide = 0; + hps->correctedLeadingEdge = driftCircle->rawDriftTime() - timeCor; + hps->x = driftCircleOnTrack->globalPosition().x(); + hps->y = driftCircleOnTrack->globalPosition().y(); + hps->board = myBoard; + hps->locR = locR; + hps->localPos = driftCircle->localPosition()[Trk::driftRadius]; + hps->timeCorChip = 0.; // currently not implemented + hps->chip = chip; + hps->t0 = t0; + hps->phi = phi; + hps->straw = myStrawNumber; + hps->strawLayer = strawLayer; + hps->layer = layer; + hps->tubeHit = tubeHit; + hps->locRPat = locRPat; + + // add hit params object to vector + hitParamsVec.push_back(hps); + + countTrackSatesMeasurements++; + + } // end if "state==measurement" + + } // end loop over "trackStates" + + // sort by y to order the hits + std::sort(hitParamsVec.begin(), hitParamsVec.end(), MySortCriteria); + std::vector<InDet::TRT_DetectorTiming::hitParams*>::iterator hitParamsIt; + + // now flag hits that have flipped in z + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // this is currently only valid for the barrel ! + // needs to be fixed to use this in the endcap ! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + // no need to check for vectors smaller than 2 entries + // more importantly, we get seg faults if we go in to this loop!! + if (hitParamsVec.size() > 2) { + int last = 0; + int check = 0; + int next = 0; + for(hitParamsIt = hitParamsVec.begin(); hitParamsIt != hitParamsVec.end(); hitParamsIt++) { + // special cases for first, last hit + if (hitParamsIt == hitParamsVec.begin()) { + last = (*(hitParamsIt+2))->side; + } + if (hitParamsIt == (hitParamsVec.end()-1)) { + next = (*(hitParamsIt-1))->side; + } else { + next = (*(hitParamsIt+1))->side; + } + + check = (*(hitParamsIt))->side; + + // if the hits before and after this one are on the same side + // but different from the current, flag this one + if ((last == next) && (check != next)) { + (*(hitParamsIt))->wrongSide = 1; + } + + last = (*(hitParamsIt))->side; + } + } // check on empty vector + + + // loop back through hits vector and print output to a file + for(hitParamsIt = hitParamsVec.begin(); hitParamsIt != hitParamsVec.end(); hitParamsIt++) { + + m_correctedLeadingEdge = (*hitParamsIt)->correctedLeadingEdge; + m_timeCor = timeCor; + m_timeOverThreshold = (*hitParamsIt)->timeOverThreshold; + m_trailingEdgeBin = (*hitParamsIt)->trailingEdgeBin; + m_leadingEdgeBin = (*hitParamsIt)->leadingEdgeBin; + m_wrongSide = (*hitParamsIt)->wrongSide; + m_board = (*hitParamsIt)->board; + m_locR = (*hitParamsIt)->locR; + m_timeCorChip = (*hitParamsIt)->timeCorChip; + m_chip = (*hitParamsIt)->chip; + m_side = (*hitParamsIt)->side; + m_t0 = (*hitParamsIt)->t0; + m_phi = (*hitParamsIt)->phi; + m_straw = (*hitParamsIt)->straw; + m_strawLayer = (*hitParamsIt)->strawLayer; + m_layer = (*hitParamsIt)->layer; + m_nTrtBarHits = nTrtBarHits; + m_nTrtEcHits = nTrtEcHits; + m_nTrtHitsBarrelA = nTrtHitsBarrelA; + m_nTrtHitsBarrelC = nTrtHitsBarrelC; + m_nTrtHitsEcA = nTrtHitsEcA; + m_nTrtHitsEcC = nTrtHitsEcC; + m_nSctHits = nSctHits; + m_nPixHits = nPixHits; + m_theta = theta; + m_eta = eta; + m_chi2Ndf = chi2Ndf; + m_phi0 = phi0; + m_z0 = z0; + m_d0 = d0; + m_tubeHit = (*hitParamsIt)->tubeHit; + m_locRPat = (*hitParamsIt)->locRPat; + + m_ntuple->Fill(); + } + + for (unsigned int i=0; i<hitParamsVec.size(); i++) { delete hitParamsVec[i]; hitParamsVec[i] = 0; } // need to first delete the members that were created with new!! + hitParamsVec.clear(); + + if (nSctHits == 0) m_numTrtOnlyTracks++; + else m_numTrtSctTracks++; + + } // end loop over tracks + + fclose(myFile); + + if (msgLvl(MSG::DEBUG)) msg() << "end execute()" << endreq; + return StatusCode::SUCCESS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +StatusCode InDet::TRT_DetectorTiming::finalize() { + + if (msgLvl(MSG::INFO)) msg() << "finalize()" << endreq; + if (msgLvl(MSG::INFO)) msg() << "saw " << m_numTrtOnlyTracks << " TRT only tracks and " + << m_numTrtSctTracks << " combined tracks with the SCT" << endreq; + return StatusCode::SUCCESS; +} + diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_EventPhaseAnalysis.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_EventPhaseAnalysis.cxx new file mode 100644 index 000000000000..6457cf076dff --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_EventPhaseAnalysis.cxx @@ -0,0 +1,545 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TRT_EventPhaseAnalysis.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#include "TRT_DetectorPerformance/TRT_EventPhaseAnalysis.h" + +#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" +#include "InDetPrepRawData/TRT_DriftCircle.h" +#include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" +#include "InDetRIO_OnTrack/PixelClusterOnTrack.h" +//#include "TrkParameters/MeasuredPerigee.h" +//#include "TrkParameters/MeasuredAtaStraightLine.h" +#include "TRT_ConditionsData/RtRelation.h" + +#include "CommissionEvent/ComTime.h" + +#include "TH2F.h" +#include "TF1.h" + +//================ Constructor ================================================= + +InDet::TRT_EventPhaseAnalysis::TRT_EventPhaseAnalysis( const std::string& name + , ISvcLocator* pSvcLocator + ) : AthAlgorithm(name,pSvcLocator) + , m_histSvc("THistSvc", name) + , m_trtCondDbTool("TRT_CalDbSvc", name) + , m_tracksplitter("InDet::InDetTrackSplitterTool") + , m_eventPhaseTool() + , m_tracksCollection(0) + , m_trtHelper(0) + , m_tracksName("CombinedInDetTracks_CTB") + , eventCount(-1) +{ + declareProperty("histogramService", m_histSvc); + declareProperty("tracksCollection", m_tracksName); + + declareProperty("EventPhaseTool", m_eventPhaseTool); + + + m_x_trk = 0; + m_x_top = 0; + m_x_bot = 0; + + m_y_trk = 0; + m_y_top = 0; + m_y_bot = 0; + + m_z_trk = 0; + m_z_top = 0; + m_z_bot = 0; + + m_timeDiff_trk = 0; + m_timeDiff_top = 0; + m_timeDiff_bot = 0; + + m_dbT0_trk = 0; + m_dbT0_top = 0; + m_dbT0_bot = 0; + +} + +//================ Destructor ================================================= + +InDet::TRT_EventPhaseAnalysis::~TRT_EventPhaseAnalysis() +{} + + +//================ Initialisation ================================================= + +StatusCode InDet::TRT_EventPhaseAnalysis::initialize() +{ + // Code entered here will be executed once at program start. + + if(msgLvl(MSG::INFO)) msg(MSG::INFO) << name() << " initialize()" << endreq; + + ///////////////////////////////////////////////// + // Create TTrees and register them to THistSvc + ///////////////////////////////////////////////// + StatusCode sc = m_histSvc.retrieve(); + if ( sc.isFailure() ) + { + msg(MSG::FATAL) << "histogram service not found" << endreq; + return StatusCode::FAILURE; + } else + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "retrieved histogramService" << endreq; + + m_tree = new TTree("splitTracks", "splitTracks"); + + std::string fullTreeName = "/AANT/splitTracks" ; + sc = (m_histSvc->regTree(fullTreeName, m_tree)); + if( sc.isFailure() ) + { + msg(MSG::ERROR) << "Unable to register TTree : " << fullTreeName << endreq; + return StatusCode::FAILURE; + } + + sc = m_trtCondDbTool.retrieve() ; + if (sc.isFailure()) + { + msg(MSG::ERROR) << "Could not find TRTCalDbTool " << endreq; + return sc; + } + + ////////////////////////////// + /// Initialize data vectors + ////////////////////////////// + m_x_trk = new std::vector<float>; + m_x_top = new std::vector<float>; + m_x_bot = new std::vector<float>; + + m_y_trk = new std::vector<float>; + m_y_top = new std::vector<float>; + m_y_bot = new std::vector<float>; + + m_z_trk = new std::vector<float>; + m_z_top = new std::vector<float>; + m_z_bot = new std::vector<float>; + + m_timeDiff_trk = new std::vector<float>; + m_timeDiff_top = new std::vector<float>; + m_timeDiff_bot = new std::vector<float>; + + m_dbT0_trk = new std::vector<float>; + m_dbT0_top = new std::vector<float>; + m_dbT0_bot = new std::vector<float>; + + ////////////////////////////////////////////////////// + /// Book variables to be added to the output ntuple + ////////////////////////////////////////////////////// + m_tree->Branch("nTrtBarrelHits_trk", &m_nTrtBarrelHits_trk, "nTrtBarrelHits_trk/I"); + m_tree->Branch("nTrtBarrelHits_top", &m_nTrtBarrelHits_top, "nTrtBarrelHits_top/I"); + m_tree->Branch("nTrtBarrelHits_bot", &m_nTrtBarrelHits_bot, "nTrtBarrelHits_bot/I"); + + m_tree->Branch("nTrtEndcapHits_trk", &m_nTrtEndcapHits_trk, "nTrtEndcapHits_trk/I"); + m_tree->Branch("nTrtEndcapHits_top", &m_nTrtEndcapHits_top, "nTrtEndcapHits_top/I"); + m_tree->Branch("nTrtEndcapHits_bot", &m_nTrtEndcapHits_bot, "nTrtEndcapHits_bot/I"); + + m_tree->Branch("nSctHits_trk", &m_nSctHits_trk, "nSctHits_trk/I"); + m_tree->Branch("nSctHits_top", &m_nSctHits_top, "nSctHits_top/I"); + m_tree->Branch("nSctHits_bot", &m_nSctHits_bot, "nSctHits_bot/I"); + + m_tree->Branch("nPixelHits_trk", &m_nPixelHits_trk, "nPixelHits_trk/I"); + m_tree->Branch("nPixelHits_top", &m_nPixelHits_top, "nPixelHits_top/I"); + m_tree->Branch("nPixelHits_bot", &m_nPixelHits_bot, "nPixelHits_bot/I"); + + m_tree->Branch("EP_trk", &m_EP_trk, "EP_trk/D"); + m_tree->Branch("EP_top", &m_EP_top, "EP_top/D"); + m_tree->Branch("EP_bot", &m_EP_bot, "EP_bot/D"); + + m_tree->Branch("EPFromTE_trk", &m_EPFromTE_trk, "EPFromTE_trk/D"); + m_tree->Branch("EPFromTE_top", &m_EPFromTE_top, "EPFromTE_top/D"); + m_tree->Branch("EPFromTE_bot", &m_EPFromTE_bot, "EPFromTE_bot/D"); + + m_tree->Branch("tofFitPar0_trk", &m_tofFitPar0_trk, "tofFitPar0_trk/F"); + m_tree->Branch("tofFitPar0_top", &m_tofFitPar0_top, "tofFitPar0_top/F"); + m_tree->Branch("tofFitPar0_bot", &m_tofFitPar0_bot, "tofFitPar0_bot/F"); + + m_tree->Branch("tofFitPar1_trk", &m_tofFitPar1_trk, "tofFitPar1_trk/F"); + m_tree->Branch("tofFitPar1_top", &m_tofFitPar1_top, "tofFitPar1_top/F"); + m_tree->Branch("tofFitPar1_bot", &m_tofFitPar1_bot, "tofFitPar1_bot/F"); + + m_tree->Branch("tofChi2OverNdf_trk", &m_tofChi2OverNdf_trk, "tofChi2OverNdf_trk/F"); + m_tree->Branch("tofChi2OverNdf_top", &m_tofChi2OverNdf_top, "tofChi2OverNdf_top/F"); + m_tree->Branch("tofChi2OverNdf_bot", &m_tofChi2OverNdf_bot, "tofChi2OverNdf_bot/F"); + + m_tree->Branch("trtPhase", &m_trtPhase, "trtPhase/D"); + m_tree->Branch("d0", &m_d0, "d0/D"); + m_tree->Branch("z0", &m_z0, "z0/D"); + m_tree->Branch("phi", &m_phi, "phi/D"); + m_tree->Branch("theta", &m_theta, "theta/D"); + + m_tree->Branch("x_trk", &m_x_trk); + m_tree->Branch("x_top", &m_x_top); + m_tree->Branch("x_bot", &m_x_bot); + + m_tree->Branch("y_trk", &m_y_trk); + m_tree->Branch("y_top", &m_y_top); + m_tree->Branch("y_bot", &m_y_bot); + + m_tree->Branch("z_trk", &m_z_trk); + m_tree->Branch("z_top", &m_z_top); + m_tree->Branch("z_bot", &m_z_bot); + + m_tree->Branch("timeDiff_trk", &m_timeDiff_trk); + m_tree->Branch("timeDiff_top", &m_timeDiff_top); + m_tree->Branch("timeDiff_bot", &m_timeDiff_bot); + + m_tree->Branch("dbT0_trk", &m_dbT0_trk); + m_tree->Branch("dbT0_top", &m_dbT0_top); + m_tree->Branch("dbT0_bot", &m_dbT0_bot); + + if(msgLvl(MSG::INFO)) msg(MSG::INFO) << "initialize() successful in " << name() << endreq; + return StatusCode::SUCCESS; +} + +//============== BeginRun ======================================================= +StatusCode InDet::TRT_EventPhaseAnalysis::beginRun() +{ + m_eventPhaseTool->beginRun(); + + return StatusCode::SUCCESS; +} + +//================ Finalisation ================================================= + +StatusCode InDet::TRT_EventPhaseAnalysis::finalize() +{ + // Code entered here will be executed once at the end of the program run. + + if(m_x_trk) delete m_x_trk; + if(m_x_top) delete m_x_top; + if(m_x_bot) delete m_x_bot; + + if(m_y_trk) delete m_y_trk; + if(m_y_top) delete m_y_top; + if(m_y_bot) delete m_y_bot; + + if(m_z_trk) delete m_z_trk; + if(m_z_top) delete m_z_top; + if(m_z_bot) delete m_z_bot; + + if(m_timeDiff_trk) delete m_timeDiff_trk; + if(m_timeDiff_top) delete m_timeDiff_top; + if(m_timeDiff_bot) delete m_timeDiff_bot; + + if(m_dbT0_trk) delete m_dbT0_trk; + if(m_dbT0_top) delete m_dbT0_top; + if(m_dbT0_bot) delete m_dbT0_bot; + + return StatusCode::SUCCESS; +} + +//================ Execution ==================================================== + +StatusCode InDet::TRT_EventPhaseAnalysis::execute() +{ + ++eventCount; + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "InDet::TRT_DetectorPlots::execute() event " << eventCount << endreq; + + ////////////////////////// + /// Retrieve event info + ////////////////////////// + StatusCode sc = load(); + + if (sc.isFailure()) + { + msg(MSG::ERROR) << "InDet::TRT_DetectorPlots::load() failed, exiting" << endreq; + return sc; + } + + if (m_tracksCollection->size() > 100) + { + if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "N tracks greater than 100: " << m_tracksCollection->size() << " for event " << eventCount << ", exiting" << endreq; + return sc; + } + + for ( DataVector<Trk::Track>::const_iterator trackIt = m_tracksCollection->begin(); trackIt != m_tracksCollection->end(); ++trackIt ) + { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Track loop start" << endreq; + + ////////////////// + /// split tracks + ////////////////// + std::pair<Trk::Track*, Trk::Track*> splitTracks = std::pair<Trk::Track*, Trk::Track*> (0,0); + splitTracks = m_tracksplitter->splitInUpperLowerTrack( **trackIt ); + + /// Is there a top track? + if( splitTracks.first == 0 ) + { + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No top track. Skipping track" << endreq; + + // no top track so delete bottom track if it exists + if(splitTracks.second) delete splitTracks.second; + continue; + } + // is there a bottom track? + if( splitTracks.second == 0 ) + { + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "No bottom track, Skipping track" << endreq; + + // no bottom track so delete top track (we know it exists because we got here) + delete splitTracks.first; + continue; + } + + const ComTime* comtime = 0; + evtStore()->retrieve(comtime,"TRT_Phase"); + + m_trtPhase = comtime->getTime(); + m_d0 = (**trackIt).perigeeParameters()->parameters()[Trk::d0]; + m_z0 = (**trackIt).perigeeParameters()->parameters()[Trk::z0]; + m_phi = (**trackIt).perigeeParameters()->parameters()[Trk::phi]; + m_theta = (**trackIt).perigeeParameters()->parameters()[Trk::theta]; + + + bool analysisFailed = false; + if( !analyzeTrack( (*trackIt) + , m_nTrtBarrelHits_trk + , m_nTrtEndcapHits_trk + , m_nSctHits_trk + , m_nPixelHits_trk + , m_EP_trk + , m_EPFromTE_trk + , m_tofFitPar0_trk + , m_tofFitPar1_trk + , m_tofChi2OverNdf_trk + , m_timeDiff_trk + , m_x_trk + , m_y_trk + , m_z_trk + , m_dbT0_trk + ) || + !analyzeTrack( splitTracks.first + , m_nTrtBarrelHits_top + , m_nTrtEndcapHits_top + , m_nSctHits_top + , m_nPixelHits_top + , m_EP_top + , m_EPFromTE_top + , m_tofFitPar0_top + , m_tofFitPar1_top + , m_tofChi2OverNdf_top + , m_timeDiff_top + , m_x_top + , m_y_top + , m_z_top + , m_dbT0_top + ) || + !analyzeTrack( splitTracks.second + , m_nTrtBarrelHits_bot + , m_nTrtEndcapHits_bot + , m_nSctHits_bot + , m_nPixelHits_bot + , m_EP_bot + , m_EPFromTE_bot + , m_tofFitPar0_bot + , m_tofFitPar1_bot + , m_tofChi2OverNdf_bot + , m_timeDiff_bot + , m_x_bot + , m_y_bot + , m_z_bot + , m_dbT0_bot + ) + ) + { + if(msgLvl(MSG::INFO)) msg(MSG::INFO) << "analysis failed. skipping track." << endreq; + analysisFailed = true; + } + + + if(!analysisFailed) + m_tree->Fill(); + + delete splitTracks.first; + delete splitTracks.second; + } + + return StatusCode::SUCCESS; +} + +//================ Load ========================================================= + +StatusCode InDet::TRT_EventPhaseAnalysis::load() +{ + StatusCode sc = evtStore()->retrieve( m_tracksCollection, m_tracksName ); + if ( sc.isFailure() ) + { + msg(MSG::ERROR) << "Could not find Tracks Collectioni " << m_tracksName << endreq; + return sc; + } + + sc = detStore()->retrieve(m_trtHelper, "TRT_ID"); + if ( sc.isFailure() ) + { + msg(MSG::FATAL) << "Could not get TRT ID helper" << endreq; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +//================ Load ========================================================= + +bool InDet::TRT_EventPhaseAnalysis::analyzeTrack( Trk::Track* track + , int& nTrtBarrelHits + , int& nTrtEndcapHits + , int& nSctHits + , int& nPixelHits + , double& EP + , double& EPFromTE + , float& tofFitPar0 + , float& tofFitPar1 + , float& tofChi2OverNdf + , std::vector<float>* timeDiff + , std::vector<float>* x + , std::vector<float>* y + , std::vector<float>* z + , std::vector<float>* dbT0 + ) +{ + const DataVector<const Trk::TrackStateOnSurface>* trackStates= track->trackStateOnSurfaces(); + if ( trackStates == 0 ) + { + msg(MSG::ERROR) << "Trk::TrackStateOnSurface empty" << endreq; + return false; + } + + nTrtBarrelHits = 0; + nTrtEndcapHits = 0; + nSctHits = 0; + nPixelHits = 0; + + EP = m_eventPhaseTool->findPhase(track); + EPFromTE = m_eventPhaseTool->findPhaseFromTE(track); + + + x->clear(); + y->clear(); + z->clear(); + + timeDiff->clear(); + + dbT0->clear(); + + TH2F* timeDifferenceVsY = new TH2F("timeDifferenceVsY", "Time Difference vs Y", 8000, -1000, 1000, 400, -25, 75); + + ///////////////////////////// + /// loop over track states + ///////////////////////////// + for ( DataVector<const Trk::TrackStateOnSurface>::const_iterator trackStatesIt = trackStates->begin(); + trackStatesIt != trackStates->end(); ++trackStatesIt ) + { + // is there a track state? + if ( *trackStatesIt == 0 ) + { + msg(MSG::ERROR) << "*trackStatesIt == 0" << endreq; + continue; + } + + // is there a measurement on that track state? + if ( !((*trackStatesIt)->type(Trk::TrackStateOnSurface::Measurement)) ) + continue; + + // is this track state an SCT hit? + if (dynamic_cast<const InDet::SCT_ClusterOnTrack*>((*trackStatesIt)->measurementOnTrack())!=0) + { + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "SCT hit on track." << endreq; + ++nSctHits; + continue; + } + + // is this track state a pixel hit? + if ( dynamic_cast<const InDet::PixelClusterOnTrack*>((*trackStatesIt)->measurementOnTrack()) ) // pixel hit + { + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Pixel hit on track." << endreq; + ++nPixelHits; + continue; + } + + const InDet::TRT_DriftCircleOnTrack *driftCircleOnTrack = dynamic_cast<const InDet::TRT_DriftCircleOnTrack *>( (*trackStatesIt)->measurementOnTrack() ); + + // is there a drift circle on this track state? + if ( driftCircleOnTrack == 0 ) + { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "driftCircleOnTrack == 0 " << ( ((*trackStatesIt)->type(Trk::TrackStateOnSurface::Outlier)) ? "Outlier" : "." ) << endreq; + continue; + } + + // is there a measurement base? + if ( (*trackStatesIt)->measurementOnTrack() == 0 ) + { + msg(MSG::ERROR) << "measurementBase == 0, and we should have had it!!!" << endreq; + continue; + } + + // is it possible to prep raw data for this drift circle? + const InDet::TRT_DriftCircle *driftCircle = driftCircleOnTrack->prepRawData(); + //delete driftCircleOnTrack; + if ( driftCircle == 0 ) + { + msg(MSG::ERROR) << "driftCircle == 0" << endreq; + continue; + } + + Identifier id = driftCircle->identify(); + + // Count barrel hits or ec hits + if (abs( m_trtHelper->barrel_ec(id ) ) == 1) + nTrtBarrelHits++; + else if (abs( m_trtHelper->barrel_ec(id) ) == 2) + nTrtEndcapHits++; + + //const CLHEP::Hep3Vector ¢er = driftCircle->detectorElement()->surface( id ).center(); + const Amg::Vector3D center = driftCircle->detectorElement()->surface( id ).center(); + + x->push_back(center.x()); + y->push_back(center.y()); + z->push_back(center.z()); + + //const Trk::MeasuredAtaStraightLine *trackMeasuredAtLine = dynamic_cast<const Trk::MeasuredAtaStraightLine*>( (*trackStatesIt)->trackParameters() ); + + const TRTCond::RtRelation *rtr = m_trtCondDbTool->getRtRelation(id); + + double leadingEdge = 3.125 * driftCircle->driftTimeBin(); + double theDbT0 = m_trtCondDbTool->getT0(id, TRTCond::ExpandedIdentifier::STRAW); + //double estDriftTime = rtr->drifttime( fabs(trackMeasuredAtLine->parameters()[Trk::locR] ) ); + double estDriftTime = rtr->drifttime( fabs(((*trackStatesIt)->trackParameters())->parameters()[Trk::locR] ) ); + + timeDifferenceVsY->Fill(center.y()/1000, leadingEdge - theDbT0 - estDriftTime); // y in meters + + timeDiff->push_back(leadingEdge - theDbT0 - estDriftTime); + dbT0->push_back(theDbT0); + } + + + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "entries: " << timeDifferenceVsY->GetEntries() << endreq; + + timeDifferenceVsY->Fit("pol1", "Q"); + if(timeDifferenceVsY->GetFunction("pol1")) + { + if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "constant: " << timeDifferenceVsY->GetFunction("pol1")->GetParameter(0) << " -- splope: " << timeDifferenceVsY->GetFunction("pol1")->GetParameter(1) << endreq; + + tofFitPar0 = timeDifferenceVsY->GetFunction("pol1")->GetParameter(0); + tofFitPar1 = timeDifferenceVsY->GetFunction("pol1")->GetParameter(1); + tofChi2OverNdf = timeDifferenceVsY->GetFunction("pol1")->GetChisquare() / timeDifferenceVsY->GetFunction("pol1")->GetNDF(); + } + else + { + tofFitPar0 = 0; + tofFitPar1 = 0; + tofChi2OverNdf = -999; + } + + delete timeDifferenceVsY; + + return true; +} + +//============================================================================================ diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_StrawMap.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_StrawMap.cxx new file mode 100644 index 000000000000..d9d0c436921f --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/TRT_StrawMap.cxx @@ -0,0 +1,352 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TRT_StrawMap.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#include "TRT_DetectorPerformance/TRT_StrawMap.h" + +#include "DataModel/DataVector.h" +#include "Identifier/Identifier.h" +#include "InDetIdentifier/TRT_ID.h" +#include "InDetReadoutGeometry/TRT_DetectorManager.h" + +#include "TRT_ConditionsServices/ITRT_StrawNeighbourSvc.h" + +#include "PathResolver/PathResolver.h" + +//================ Constructor ================================================= + +InDet::TRT_StrawMap::TRT_StrawMap(const std::string& t, + const std::string& n, + const IInterface* p ) + : + AthAlgTool(t,n,p), + m_nBarrelStraws(1642), // = 1642; + m_nAllStraws(5482), // = 5482; + m_nBarrelChips(104), // = 104; + m_TRTStrawNeighbourTool("TRT_StrawNeighbourSvc", n) +{ + declareInterface<ITRT_StrawMap>(this); + + // template for property decalration + //declareProperty("PropertyName", m_propertyName); +} + +//================ Destructor ================================================= + +InDet::TRT_StrawMap::~TRT_StrawMap() +{} + + +//================ Initialisation ================================================= + +StatusCode InDet::TRT_StrawMap::initialize() +{ + + StatusCode sc = AthAlgTool::initialize(); + if (sc.isFailure()) return sc; + + if (msgLvl(MSG::VERBOSE)) msg() << name() << "InDet::TRT_StrawMap::initialize()" << endreq; + +/* only in 15 nightlies + + if ( !(evtStore()) ) { + if (msgLvl(MSG::ERROR)) msg() << "missing evtStore StoreGate Svc!" << endreq; + return sc; + } + if ( !(detStore()) ) { + if (msgLvl(MSG::ERROR)) msg() << "missing detStore Svc!" << endreq; + return sc; + } + sc = detStore()->retrieve(m_TRTDetMgr, "TRT"); + if ( sc.isFailure() ) { + if (msgLvl(MSG::ERROR)) msg() << "Unable to retrieve TRT Detector Manager " << endreq; + return sc; + } +*/ + + + + sc = detStore()->retrieve(m_TRTDetMgr, "TRT"); + if ( sc.isFailure() ) { + if (msgLvl(MSG::ERROR)) msg() << "Unable to retrieve TRT Detector Manager " << endreq; + return sc; + } + + // TRT helper + if (detStore()->retrieve(m_TRTHelper, "TRT_ID").isFailure()) { + msg(MSG::FATAL) << "Could not get TRT ID helper" << endreq; + return StatusCode::FAILURE; + } + + // set m_strawToPadMap + + for (int i=0; i<m_nBarrelStraws; i++) m_strawToPadMap[i] = -1; // read strawToChip from the file + + std::string sasa_filename=PathResolver::find_file ("swIndex.txt", "DATAPATH"); + FILE *f = fopen(sasa_filename.c_str(), "r"); + if (f==0) { + if (msgLvl(MSG::ERROR)) msg() << "InDet::TRT_StrawMap::initialize() needs file swIndex.txt!!!" << endreq; + return sc; + } + char line[300]; + int tmp[5]; + while ( fgets(line, 300, f) != 0 ) { + if (line[0]=='#') continue; + sscanf(line, "%d %d %d %d %d\n", tmp, tmp+1, tmp+2, tmp+3, tmp+4); + m_strawToPadMap[ tmp[0] ] = 2 * tmp[1]; // chip -> pad + } + fclose(f); + for (int i=0; i<m_nBarrelStraws; i++) if (m_strawToPadMap[i]<0||m_strawToPadMap[i]>=m_nBarrelChips*2) { + if (msgLvl(MSG::ERROR)) msg() << "InDet::TRT_StrawMap::initialize() m_strawToPadMap[" << i <<"] = " << m_strawToPadMap[i] << " error (barrel)." << endreq; + m_strawToPadMap[i] = 0; // avoid crashing later + } + +// int endcapChipNumbers[] = {8, 11, 9, 10, 4, 7, 5, 6, 0, 3, 1, 2}; + int endcapChipNumbers[] = {1, 2, 0, 3, 5, 6, 4, 7, 9, 10, 8, 11}; + + for (int board=0; board<20; board++) // do the same for endcap + for (int strawLayerNumber=0; strawLayerNumber<8; strawLayerNumber++) + for (int strawNumber = 0; strawNumber<24; strawNumber++) { + int straw = board * 192 + strawNumber * 8 + strawLayerNumber ; + straw += m_nBarrelStraws; + int chip = (strawNumber - strawNumber%4) / 4; // numbering 0-11, see few lines later for hardware numbering consistency + chip *= 2; + if (strawLayerNumber>=4) chip += 1; // this gives you chip number in 0-11 range + chip = endcapChipNumbers[chip]; + + int pad = strawNumber%2; + m_strawToPadMap[ straw ] = 2 * ( chip + board * 12 + m_nBarrelChips ) + pad; + } + for (int i=m_nBarrelStraws; i<m_nAllStraws; i++) { // cross-check + if ( m_strawToPadMap[i] == -1 ) { + if (msgLvl(MSG::ERROR)) msg() << "InDet::TRT_StrawMap::initialize() m_strawToPadMap[" << i <<"] = " << m_strawToPadMap[i] << " error (endcap)." << endreq; + m_strawToPadMap[i] = m_nBarrelChips * 2; + } + } + + return sc; +} + +//================ Finalisation ================================================= + +StatusCode InDet::TRT_StrawMap::finalize() +{ + StatusCode sc = AthAlgTool::finalize(); + return sc; +} + +//============================================================================================ + +int InDet::TRT_StrawMap::board(Identifier id) { + if (id != m_id) setNewIdentifier(id); + return board(); +} + +int InDet::TRT_StrawMap::board() { + return strawToBoard(m_straw); +} + +int InDet::TRT_StrawMap::strawToBoard(int straw) { + return chipToBoard( m_strawToPadMap[straw] / 2 ); +} + +int InDet::TRT_StrawMap::chipToBoard(int chip) { + + // return logical board index: + // barrel + // 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 + // endcap + // 9-28 from smaller |z| to larger |z| + + if (chip >= m_nBarrelChips) return ( 9 + (chip-m_nBarrelChips) / 12 ); + // endcap: always 12 chips per board, easy; +9 such that range is 9-28 + + static int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14}; // N chips on each barrel board + int count = 0; + for (int i=0; i<9; i++) { + count += list[i]; + if (chip < count) return i; + } + + if (msgLvl(MSG::ERROR)) msg() << name() << "InDet::TRT_StrawMap::chipToBoard(), should never come this far! input chip number: " << chip << endreq; + return 0; +} + +int InDet::TRT_StrawMap::chip(Identifier id) { + if (id != m_id) setNewIdentifier(id); + return chip(); +} + +int InDet::TRT_StrawMap::chip() { + return strawToChip(m_straw, m_reverse); +} + +int InDet::TRT_StrawMap::strawToChip(int straw, int side, int phi) { + + int reversed = 0; + if (abs(side)==2&&(phi<8||(phi>=16&&phi<24))) reversed = 1; + if (side==-2) reversed = 3-reversed; + return strawToChip(straw, reversed); +} + +int InDet::TRT_StrawMap::strawToChip(int straw, int reversed) { + + int chip = m_strawToPadMap[straw] / 2; + if (chip < m_nBarrelChips) return chip; // barrel + + int chipInBoard = ( chip - m_nBarrelChips ) % 12; // endcap + chip -= chipInBoard; + if (reversed%2==1) chipInBoard = 10 + 2 * ( chipInBoard % 2 ) - chipInBoard ; + static int reverseSideC[] = {9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2}; // {10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1}; + if (reversed>1) chipInBoard = reverseSideC[chipInBoard]; + chip += chipInBoard; + return chip; +} + +void InDet::TRT_StrawMap::setNewIdentifier(Identifier id, int *index) { + + int side = m_TRTHelper->barrel_ec(id); + int phi = m_TRTHelper->phi_module(id); + int layerNumber = m_TRTHelper->layer_or_wheel(id); + int strawLayerNumber = m_TRTHelper->straw_layer(id); + int strawNumber = m_TRTHelper->straw(id); + + if (index) { index[0] = side; index[1] = phi; index[2] = layerNumber; index[3] = strawLayerNumber; index[4] = strawNumber; } + + int straw(0); + + if (abs(side)==1) { // barrel + + static int firstCall(1); + static int numberOfStraws[74]; + if (firstCall) { + firstCall = 0; + int strawsPerStrawLayer[] = {14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 17, // layer 0, strawlayers 0-18 + 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 22, // layer 1, strawLayers 0-23 + 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 28, 27 }; // layer 2, strawlayers 0-29 + numberOfStraws[0] = 0; + for (int i=0; i<73; i++) numberOfStraws[i+1] = numberOfStraws[i] + strawsPerStrawLayer[i] + 1; + } + + if (layerNumber==1) strawLayerNumber+= 19; + if (layerNumber==2) strawLayerNumber+= 43; + + straw = ( numberOfStraws[strawLayerNumber+1] - strawNumber -1 ); + + } else if (abs(side)==2) { // endcap + + int board = layerNumber; + if (layerNumber<6) { // A-type wheels, two wheels (boards) per "layer" + board *= 2; + if (strawLayerNumber>=8) board += 1; + } else { // shift B wheels accordingly + board += 6; + } // board numbered 0-19 + + straw = board * 192 + strawNumber * 8 + strawLayerNumber % 8; + + int myStraw = straw; // need to cross-check that it is the same as Jim's code + + straw = 0; + + if((layerNumber<6) & (strawLayerNumber>7)) + { + straw=straw+(384*layerNumber); + straw=straw+192+(strawLayerNumber%8)+(strawNumber*8); + } + else if((layerNumber<6) & (strawLayerNumber<8)) + { + straw=straw+(384*layerNumber); + straw=straw + (strawLayerNumber%8) + (strawNumber*8); + } + + else if((layerNumber>5) & (strawLayerNumber>7)) + { + straw = straw + 2304 + 192*(layerNumber-6); + straw = straw + 192 + (strawLayerNumber%8) + (8*strawNumber); + } + else if((layerNumber>5) & (strawLayerNumber<8)) + { + straw = straw + 2304 + 192*(layerNumber-6); + straw = straw + (strawLayerNumber%8) + (8*strawNumber); + } + + if (straw != myStraw) if (msgLvl(MSG::ERROR)) msg() << "endcap numbering problem " << straw << " " << myStraw << endreq; + + straw += m_nBarrelStraws; // shift such that they come after the barrel straws + } + + m_id = id; + m_straw = straw; + m_reverse = (abs(side)==2&&(phi<8||(phi>=16&&phi<24))) ? 1 : 0; + if (side==-2) m_reverse = 3-m_reverse; // just the other phi sectors are reversed in side C, shift by 2 + + return; +} + + +int InDet::TRT_StrawMap::straw(Identifier id) { + if (id != m_id) setNewIdentifier(id); + return straw(); +} + +int InDet::TRT_StrawMap::straw() { + return m_straw; +} + +void InDet::TRT_StrawMap::compareWithTRTStrawNeighbour() { + + if (msgLvl(MSG::VERBOSE)) msg() << "InDet::TRT_StrawMap::compareWithTRTStrawNeighbour: printing out file compareWithTRTStrawNeighbour.txt" << endreq; + + FILE *f = fopen("compareWithTRTStrawNeighbour.txt", "w"); + + for (std::vector<Identifier>::const_iterator it = m_TRTHelper->straw_layer_begin(); it != m_TRTHelper->straw_layer_end(); it++ ) { + + int nStrawsInLayer = m_TRTHelper->straw_max(*it); + + for (int i=0; i<=nStrawsInLayer; i++) { + + Identifier id = m_TRTHelper->straw_id(*it, i); + int index[5]; + this->setNewIdentifier(id, index); + + int myChip = this->chip(); + int myReference(-1); + + if (abs(index[0])==2) { + myReference = ( myChip - m_nBarrelChips ) % 12; // endcap + if ( index[2]<6 && this->board()%2==0 ) myReference += 20; // A wheels + } else if (abs(index[0])==1) { + myReference = myChip; + if (index[2]==0) myReference += 1; + if (index[2]==1) myReference -= 20; + if (index[2]==2) myReference -= 53; + } + + int chip; + m_TRTStrawNeighbourTool->getChip(id, chip); + + //const HepGeom::Point3D<double> ¢erRef = m_TRTDetMgr->getElement( id )->center( id ); + const Amg::Vector3D centerRef = m_TRTDetMgr->getElement( id )->center( id ); + + for (int j=0; j<5; j++) fprintf(f, "%2d ", index[j]); + fprintf(f, " %4d %2d %3d %2d %2d ", this->straw(), this->board(), myChip, myReference, chip); + fprintf(f, "%f %f %f\n", centerRef.x(), centerRef.y(), centerRef.z()); + } + } + + fclose(f); + return; +} diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_entries.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_entries.cxx new file mode 100644 index 000000000000..a0f54a155b97 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_entries.cxx @@ -0,0 +1,25 @@ +#include "TRT_DetectorPerformance/TRT_DetectorPlots.h" +#include "TRT_DetectorPerformance/TRT_DetectorTiming.h" +#include "TRT_DetectorPerformance/TRT_ClockNoise.h" +#include "TRT_DetectorPerformance/TRT_StrawMap.h" +#include "TRT_DetectorPerformance/TRT_EventPhaseAnalysis.h" +#include "TRT_DetectorPerformance/TRT_DTMROC_HeaderCheck.h" +#include "GaudiKernel/DeclareFactoryEntries.h" + +DECLARE_NAMESPACE_ALGORITHM_FACTORY( InDet, TRT_DetectorPlots ) +DECLARE_NAMESPACE_ALGORITHM_FACTORY( InDet, TRT_DetectorTiming ) +DECLARE_NAMESPACE_ALGORITHM_FACTORY( InDet, TRT_ClockNoise ) +DECLARE_NAMESPACE_ALGORITHM_FACTORY( InDet, TRT_EventPhaseAnalysis ) +DECLARE_NAMESPACE_ALGORITHM_FACTORY( InDet, TRT_DTMROC_HeaderCheck ) + +DECLARE_NAMESPACE_TOOL_FACTORY( InDet, TRT_StrawMap ) + +DECLARE_FACTORY_ENTRIES( TRT_DetectorPerformance ) { + DECLARE_NAMESPACE_ALGORITHM( InDet, TRT_DetectorPlots ); + DECLARE_NAMESPACE_ALGORITHM( InDet, TRT_DetectorTiming ); + DECLARE_NAMESPACE_ALGORITHM( InDet, TRT_ClockNoise ); + DECLARE_NAMESPACE_ALGORITHM( InDet, TRT_EventPhaseAnalysis ); + DECLARE_NAMESPACE_ALGORITHM( InDet, TRT_DTMROC_HeaderCheck ); + + DECLARE_NAMESPACE_TOOL( InDet, TRT_StrawMap ); +} diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_load.cxx b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_load.cxx new file mode 100644 index 000000000000..0d5b78ec4a20 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/components/TRT_DetectorPerformance_load.cxx @@ -0,0 +1,2 @@ +#include "GaudiKernel/LoadFactoryEntries.h" +LOAD_FACTORY_ENTRIES(TRT_DetectorPerformance) diff --git a/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/mapping.txt b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/mapping.txt new file mode 100644 index 000000000000..46328955fa65 --- /dev/null +++ b/InnerDetector/InDetPerformance/TRT_DetectorPerformance/src/mapping.txt @@ -0,0 +1,120 @@ +10,0 +4,2 +28,4 +001c,6 +40,8 +34,10 +58,12 +004c,14 +70,16 +64,18 +11,20 +5,22 +29,24 +001d,26 +41,28 +35,30 +59,32 +004d,34 +71,36 +65,38 +000e,40 +2,42 +26,44 +001a,46 +003e,48 +32,50 +56,52 +004a,54 +006e,56 +62,58 +000f,60 +3,62 +27,64 +001b,66 +003f,68 +33,70 +57,72 +004b,74 +006f,76 +63,78 +000c,80 +0,82 +24,84 +18,86 +003c,88 +30,90 +54,92 +48,94 +006c,96 +60,98 +000d,100 +1,102 +25,104 +19,106 +003d,108 +31,110 +55,112 +49,114 +006d,116 +61,118 +16,1 +000a,3 +002e,5 +22,7 +46,9 +003a,11 +005e,13 +52,15 +76,17 +006a,19 +17,21 +000b,23 +002f,25 +23,27 +47,29 +003b,31 +005f,33 +53,35 +77,37 +006b,39 +14,41 +8,43 +002c,45 +20,47 +44,49 +38,51 +005c,53 +50,55 +74,57 +68,59 +15,61 +9,63 +002d,65 +21,67 +45,69 +39,71 +005d,73 +51,75 +75,77 +69,79 +12,81 +6,83 +002a,85 +001e,87 +42,89 +36,91 +005a,93 +004e,95 +72,97 +66,99 +13,101 +7,103 +002b,105 +001f,107 +43,109 +37,111 +005b,113 +004f,115 +73,117 +67,119 -- GitLab