diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/CMakeLists.txt deleted file mode 100644 index 0ff406b72e7919f56c9d86d08681d7592f38f346..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -################################################################################ -# Package: MdtCalibDbAsciiTool -################################################################################ - -# Declare the package name: -atlas_subdir( MdtCalibDbAsciiTool ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - GaudiKernel - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibInterfaces - PRIVATE - Control/AthenaKernel - Control/SGTools - Control/StoreGate - DetectorDescription/Identifier - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibSvc - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibUtils - MuonSpectrometer/MuonCalib/MuonCalibUtils/MuonCalibStl - MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry - MuonSpectrometer/MuonIdHelpers - Tools/PathResolver ) - -# External dependencies: -find_package( CLHEP ) - -# Component(s) in the package: -atlas_add_component( MdtCalibDbAsciiTool - src/*.cxx - src/components/*.cxx - INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaBaseComps GaudiKernel MdtCalibData AthenaKernel SGTools StoreGateLib SGtests Identifier MdtCalibSvcLib MdtCalibUtils MuonReadoutGeometry MuonIdHelpersLib PathResolver ) - -# Install files from the package: -atlas_install_headers( MdtCalibDbAsciiTool ) -atlas_install_joboptions( share/*.py ) -atlas_install_runtime( share/DC2_rt_asciiDb.dat ) - diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool.h deleted file mode 100644 index 1bd9bba2773a4b1d6f6eae0c471bfa1806df67a4..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MDTCALIBDB_MDTCALIBDBASCIITOOL_H -#define MDTCALIBDB_MDTCALIBDBASCIITOOL_H - -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -#include "MdtCalibInterfaces/IMdtCalibDBTool.h" -#include "MdtCalibData/MdtTubeCalibContainerCollection.h" -#include "MdtCalibData/MdtRtRelationCollection.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -#include "CLHEP/Random/RandomEngine.h" - -class IAtRndmGenSvc; -class MdtCalibrationRegionSvc; - -namespace MuonCalib { - -class MdtCalibDbAsciiTool: public AthAlgTool, - virtual public IMdtCalibDBTool -{ - -public: - - /** constructor */ - MdtCalibDbAsciiTool(const std::string& type, - const std::string& name, - const IInterface* parent); - - /** required by the IAddressProvider interface */ - virtual StatusCode updateAddress(StoreID::type storeID, - SG::TransientAddress* tad, - const EventContext& ctx); - -private: - - /** Tool initialization */ - StatusCode initialize(); - - /** retrieve from database all the constants: dummy*/ - virtual StatusCode LoadCalibration(IOVSVC_CALLBACK_ARGS); - /** retrieve from database the Rt function(s): dummy*/ - virtual StatusCode loadRt(IOVSVC_CALLBACK_ARGS) {return StatusCode::SUCCESS;}; - /** retrieve from database the T0s: dummy*/ - virtual StatusCode loadTube(IOVSVC_CALLBACK_ARGS) {return StatusCode::SUCCESS;}; - - /** initialize the transient classes for T0s */ - StatusCode defaultT0s(); - /** initialize the transient classes for Rt */ - StatusCode defaultRt(); - /** Build a MuonCalib::MdtTubeCalibContainer for a given Identifier - * @return the MuonCalib::MdtTubeCalibContainer - * @param[in] const reference to the Identifier - */ - MdtTubeCalibContainer * buildMdtTubeCalibContainer(const Identifier& id); - - /** append all rt files from calibration directory */ - void AppendRtFiles(std::vector<std::string> & filenames); - /** interprets file names in the calibration directory */ - bool interpret_chamber_name(const std::string &nm, const char *prefix, std::string & station, int &eta, int & phi) const; - - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - MdtCalibrationRegionSvc* m_regionSvc; - mutable MdtTubeCalibContainerCollection * m_tubeData; - mutable MdtRtRelationCollection * m_rtData; - - bool m_doCommissioning; - double m_bilt0; - double m_bist0; - double m_bmlt0; - double m_bmst0; - double m_bolt0; - double m_bost0; - double m_eilt0; - double m_eist0; - double m_emlt0; - double m_emst0; - double m_eolt0; - double m_eost0; - - StringArrayProperty m_RTfileNames; - - std::string m_rtDataLocation; - std::string m_tubeDataLocation; - -//!directory containing calibratino files as written by the standalone_tarball -//!if set to anythin other than NONE, it overrides all other job options. - std::string m_calib_dir; - - double m_t0Shift; - double m_t0Spread; - double m_rtShift; - - IAtRndmGenSvc* p_AtRndmGenSvc; - CLHEP::HepRandomEngine* p_engine; - -}; - -} - -#endif - diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool/StationT0FromFile.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool/StationT0FromFile.h deleted file mode 100644 index d091b337360b6d893b3ca32e216efdb07cdadd42..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/MdtCalibDbAsciiTool/StationT0FromFile.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 01.02.2007, AUTHOR: OLIVER KORTNER -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef MuonCalib_StationT0FromFileH -#define MuonCalib_StationT0FromFileH - -//::::::::::::::::::::::::::::::::: -//:: CLASS StationT0FromFile :: -//::::::::::::::::::::::::::::::::: - -/// \class StationT0FromFile -/// -/// This class is used to read a t0 text file for a given station and to -/// provide the t0s to the user. It is meant to be an auxiliary class for -/// the stand-alone calibration programme. It might be possible in the future -/// to drop this class. -/// -/// \author Oliver.Kortner@CERN.CH -/// -/// \date 01.02.2007 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// STL // -#include <vector> -#include <string> - -namespace MuonCalib { - -class StationT0FromFile { - -public: -// Constructors // - StationT0FromFile(void) { - init(); - } - ///< Default constructor. - -// Methods // -// get methods // - double t0(const unsigned int & ml, const unsigned int & ly, - const unsigned int & tb) const; - ///< get the t0 value of the tube tb - ///< in layer ly of multilayer ml; - ///< tb, ly, ml>0 - -// set methods // - void readT0File(std::istream &infile); - ///< read the t0s stored in the file - ///< "file_name" - -private: -// t0s // - std::vector< std::vector< std::vector <double> > > m_t0; // t0 values - -// private methods // - void init(void); // initialization method - -}; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/doc/packagedoc.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/doc/packagedoc.h deleted file mode 100644 index 2198f8869ddd92228346c57dfbc6531c705bc384..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/doc/packagedoc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** -@page MdtCalibDbAsciiTool_page MdtCalibDbAsciiTool Package -@author Domizia.Orestano@cern.ch - -@section MdtCalibDbAsciiTool_MdtCalibDbAsciiToolIntro Introduction -This Tool is used by MdtCalibrationDbSvc to retreive some default -calibration constants (from ASCII files declared in jobOptions and from jobOptions), -unpack them and fill the transient classes used by the service. -No IOV is provided for these classes which are intended to be valid for -all the processed events. -For IOV based access to conditions DB please configure MdtCalibrationSvc to use -MdtCalibDbCoolStrTool instead. - -@section MdtCalibDbAsciiTool_MdtCalibDbAsciiToolOverview Class Overview -The package contains a single Tool, -MuonCalib::MdtCalibDbAsciiTool, inheriting from MuonCalib::IMdtCalibDB. -The Tool default options are set in the constructor - -- a single Rt function -for all the MDT chambers taken from the file DC2_rt_asciiDb.dat (default -option for the RT_InputFiles property) - -- all T0s set to 800 ns - -In addition for specific studies on simulated data it is possible to alter the -T0s by shifting them (T0Shift property in ns) and/or smearing them with a -gaussian of given sigma (T0Spread property in ns) and to distort -the default Rt function by a maximum amount in mm (RTShift property). - -For commissioning data (not for commissioning simulation) setting to -true the doCommissioning property sets all T0s to a default which is 150 ns -and enables the usage of the next set of options - -- BMLT0: sets all the BML chambers T0s to the desired value - -- BOLT0: sets all the BOL chambers T0s to the desired value - -- etc...for a large number of types of chambers currently being commissioned -(see the full list in the genConf/MdtCalibDbAsciiToolConf.py file, produced under the root directory of the package after building). - -- RT_InputFiles: if more than one file is listed it is assumed that one -file for each chamber under study will be provided. It is then necessary to -set the penultimate number in the header (first line) -of each file to the hash identifier -of the chamber. To find out the hash identifier XXX of a chamber -do a trial run with few events -setting the OutputLevel to VERBOSE and look in the output for the string -"Adding chamber " followed by "adding tubes at XXX". - - -*/ diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/share/DC2_rt_asciiDb.dat b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/share/DC2_rt_asciiDb.dat deleted file mode 100644 index cb36bdba33cf8a0ad845aff286d1d497b8a94a1b..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/share/DC2_rt_asciiDb.dat +++ /dev/null @@ -1,385 +0,0 @@ -v0.0 1 dummy 0 383 -0.0692666 6.68 0.3 -0.0692666 8.52 0.3 -0.106606 10.36 0.3 -0.115798 12.2 0.3 -0.149383 14.04 0.3 -0.194783 15.88 0.3 -0.218959 17.72 0.3 -0.271053 19.56 0.3 -0.346581 21.4 0.3 -0.39999 23.24 0.3 -0.462598 25.08 0.3 -0.540452 26.92 0.3 -0.614479 28.76 0.3 -0.695729 30.6 0.3 -0.761292 32.44 0.3 -0.85107 34.28 0.3 -0.925544 36.12 0.3 -1.04843 37.96 0.3 -1.11038 39.8 0.3 -1.21077 41.64 0.3 -1.27254 43.48 0.298039 -1.37727 45.32 0.286743 -1.45551 47.16 0.279704 -1.56014 49 0.27715 -1.66297 50.84 0.215272 -1.74228 52.68 0.235402 -1.82712 54.52 0.251147 -1.92306 56.36 0.195674 -2.00964 58.2 0.237623 -2.10612 60.04 0.17815 -2.19337 61.88 0.190519 -2.27856 63.72 0.166802 -2.37668 65.56 0.130951 -2.46557 67.4 0.161228 -2.5453 69.24 0.164203 -2.641 71.08 0.130774 -2.73841 72.92 0.123661 -2.83257 74.76 0.119747 -2.91319 76.6 0.117532 -2.9954 78.44 0.115198 -3.08733 80.28 0.121306 -3.17744 82.12 0.112382 -3.26312 83.96 0.11536 -3.35153 85.8 0.112813 -3.43497 87.64 0.111024 -3.51504 89.48 0.113917 -3.60376 91.32 0.103612 -3.69906 93.16 0.109352 -3.77209 95 0.109998 -3.86832 96.84 0.104344 -3.93755 98.68 0.105225 -4.02426 100.52 0.0995542 -4.10341 102.36 0.104592 -4.17975 104.2 0.10635 -4.25542 106.04 0.0986078 -4.34286 107.88 0.0980133 -4.41498 109.72 0.0979933 -4.49335 111.56 0.0973853 -4.56783 113.4 0.0935731 -4.63394 115.24 0.0946994 -4.71302 117.08 0.0798167 -4.78126 118.92 0.0948228 -4.8599 120.76 0.0932177 -4.92562 122.6 0.0912063 -5.00663 124.44 0.0925192 -5.06404 126.28 0.092037 -5.13151 128.12 0.0868296 -5.19989 129.96 0.0923416 -5.27062 131.8 0.0867673 -5.32751 133.64 0.0863303 -5.39187 135.48 0.0903376 -5.46612 137.32 0.0889405 -5.51375 139.16 0.0821907 -5.58699 141 0.0847349 -5.64455 142.84 0.0844367 -5.69487 144.68 0.0837068 -5.77322 146.52 0.0892484 -5.81754 148.36 0.0800767 -5.88264 150.2 0.0842706 -5.93412 152.04 0.0815737 -5.99061 153.88 0.0805264 -6.04939 155.72 0.0818535 -6.10854 157.56 0.0834201 -6.16493 159.4 0.0842525 -6.21937 161.24 0.0803931 -6.26826 163.08 0.0813391 -6.3219 164.92 0.080909 -6.38101 166.76 0.0801943 -6.43175 168.6 0.0780698 -6.48824 170.44 0.083649 -6.53471 172.28 0.0838482 -6.59491 174.12 0.0849841 -6.63795 175.96 0.0815375 -6.69567 177.8 0.0810432 -6.74135 179.64 0.077515 -6.7892 181.48 0.0746774 -6.83742 183.32 0.0762357 -6.89012 185.16 0.0766787 -6.93041 187 0.0753165 -6.98222 188.84 0.0765539 -7.02411 190.68 0.0738602 -7.07541 192.52 0.0751457 -7.12109 194.36 0.0771605 -7.16915 196.2 0.0718856 -7.21595 198.04 0.0749982 -7.26019 199.88 0.0727997 -7.30849 201.72 0.0794686 -7.34632 203.56 0.0702919 -7.38823 205.4 0.0689174 -7.4371 207.24 0.0729357 -7.48421 209.08 0.0733747 -7.52781 210.92 0.0759943 -7.57027 212.76 0.0774237 -7.60875 214.6 0.0818526 -7.64949 216.44 0.0747268 -7.69832 218.28 0.0711351 -7.74153 220.12 0.0769696 -7.78006 221.96 0.0733954 -7.81308 223.8 0.0733518 -7.86271 225.64 0.0765799 -7.90155 227.48 0.0697613 -7.94517 229.32 0.0707408 -7.98909 231.16 0.0687903 -8.02649 233 0.077148 -8.06674 234.84 0.073534 -8.09826 236.68 0.0695646 -8.14654 238.52 0.0695575 -8.17869 240.36 0.0735805 -8.22393 242.2 0.0645211 -8.26675 244.04 0.0734289 -8.29988 245.88 0.0726436 -8.34035 247.72 0.0770289 -8.36605 249.56 0.066324 -8.41348 251.4 0.0712202 -8.45217 253.24 0.0597781 -8.49333 255.08 0.0712224 -8.5286 256.92 0.0691276 -8.56957 258.76 0.0613351 -8.59613 260.6 0.0707979 -8.6293 262.44 0.0683693 -8.66952 264.28 0.0672602 -8.70992 266.12 0.0690251 -8.74059 267.96 0.0678006 -8.78091 269.8 0.0703603 -8.82342 271.64 0.0698592 -8.85444 273.48 0.0635241 -8.88129 275.32 0.068118 -8.92304 277.16 0.0672615 -8.96539 279 0.0669053 -8.98874 280.84 0.0675214 -9.02936 282.68 0.0626561 -9.05146 284.52 0.0618413 -9.09975 286.36 0.067305 -9.13181 288.2 0.0624808 -9.16223 290.04 0.0738317 -9.19764 291.88 0.0640252 -9.23182 293.72 0.0717089 -9.26432 295.56 0.0715905 -9.29571 297.4 0.0656471 -9.32891 299.24 0.0685867 -9.36796 301.08 0.0566036 -9.3924 302.92 0.0623457 -9.43309 304.76 0.0642572 -9.45892 306.6 0.0673392 -9.49039 308.44 0.0606227 -9.52461 310.28 0.0644356 -9.56191 312.12 0.0599978 -9.58996 313.96 0.0663888 -9.61826 315.8 0.0690972 -9.64881 317.64 0.062358 -9.68532 319.48 0.0640343 -9.71346 321.32 0.0596265 -9.74736 323.16 0.0630057 -9.77449 325 0.065062 -9.80807 326.84 0.0624135 -9.83848 328.68 0.0659018 -9.86994 330.52 0.0654728 -9.89882 332.36 0.05925 -9.94066 334.2 0.0702854 -9.96284 336.04 0.0645058 -9.99215 337.88 0.0711629 -10.0287 339.72 0.0638328 -10.0501 341.56 0.0570624 -10.0768 343.4 0.0598413 -10.111 345.24 0.0554331 -10.1422 347.08 0.0613107 -10.1759 348.92 0.061962 -10.2074 350.76 0.0632222 -10.2257 352.6 0.0628338 -10.2596 354.44 0.0624535 -10.2875 356.28 0.0674524 -10.3238 358.12 0.067111 -10.336 359.96 0.0559219 -10.3757 361.8 0.0550264 -10.4119 363.64 0.0620144 -10.439 365.48 0.0595865 -10.4632 367.32 0.0670355 -10.5009 369.16 0.0617812 -10.5198 371 0.0568518 -10.5447 372.84 0.0614797 -10.5763 374.68 0.0637874 -10.6003 376.52 0.0610665 -10.6331 378.36 0.0683924 -10.6585 380.2 0.0551784 -10.6879 382.04 0.0586231 -10.7191 383.88 0.0607409 -10.7368 385.72 0.0595514 -10.7758 387.56 0.0615865 -10.8008 389.4 0.061683 -10.8324 391.24 0.0741212 -10.8506 393.08 0.0622609 -10.8799 394.92 0.0547387 -10.9025 396.76 0.0592907 -10.9353 398.6 0.0575335 -10.9603 400.44 0.0579517 -10.9847 402.28 0.065585 -11.0166 404.12 0.0634519 -11.0428 405.96 0.0602939 -11.0663 407.8 0.0614555 -11.0958 409.64 0.0646793 -11.1205 411.48 0.056908 -11.1488 413.32 0.0608068 -11.168 415.16 0.0593579 -11.2064 417 0.055742 -11.2293 418.84 0.0620603 -11.2436 420.68 0.0580573 -11.2692 422.52 0.0645223 -11.3027 424.36 0.0508573 -11.328 426.2 0.0606757 -11.3558 428.04 0.0611473 -11.3834 429.88 0.0630417 -11.403 431.72 0.0618116 -11.4216 433.56 0.0594204 -11.4584 435.4 0.0605165 -11.4752 437.24 0.0556878 -11.5148 439.08 0.0614793 -11.5338 440.92 0.0612654 -11.562 442.76 0.0654674 -11.5796 444.6 0.0593629 -11.6075 446.44 0.0557512 -11.6309 448.28 0.0594629 -11.6573 450.12 0.0525619 -11.6905 451.96 0.0657882 -11.707 453.8 0.0573068 -11.7301 455.64 0.0586417 -11.753 457.48 0.059997 -11.7794 459.32 0.0596593 -11.8037 461.16 0.0620554 -11.8268 463 0.0641815 -11.8624 464.84 0.0599538 -11.8769 466.68 0.0638894 -11.905 468.52 0.0622804 -11.921 470.36 0.0561567 -11.951 472.2 0.056057 -11.9702 474.04 0.0541234 -12.003 475.88 0.0631467 -12.0252 477.72 0.0596797 -12.0451 479.56 0.0594589 -12.0728 481.4 0.0601396 -12.0963 483.24 0.0602884 -12.1145 485.08 0.0643149 -12.1433 486.92 0.0621962 -12.166 488.76 0.0614328 -12.1868 490.6 0.0618902 -12.2169 492.44 0.0570669 -12.2322 494.28 0.059827 -12.2484 496.12 0.0578224 -12.2865 497.96 0.0543553 -12.313 499.8 0.0567425 -12.3316 501.64 0.0638583 -12.3527 503.48 0.0596887 -12.3786 505.32 0.0560335 -12.4043 507.16 0.058178 -12.4215 509 0.0560923 -12.447 510.84 0.0586515 -12.4682 512.68 0.0576225 -12.4942 514.52 0.0534317 -12.5082 516.36 0.0547767 -12.5429 518.2 0.0578597 -12.5634 520.04 0.0544057 -12.5789 521.88 0.0544399 -12.6059 523.72 0.0580511 -12.625 525.56 0.0585702 -12.6563 527.4 0.0549335 -12.6702 529.24 0.0591612 -12.6963 531.08 0.0586734 -12.7154 532.92 0.0569275 -12.7409 534.76 0.0522496 -12.7664 536.6 0.0630488 -12.7864 538.44 0.0553176 -12.8121 540.28 0.0573302 -12.8326 542.12 0.0577868 -12.8565 543.96 0.0692002 -12.8707 545.8 0.0589065 -12.8956 547.64 0.0572177 -12.9235 549.48 0.0614194 -12.9283 551.32 0.0577733 -12.9552 553.16 0.0619303 -12.9882 555 0.0584705 -13.0048 556.84 0.0548058 -13.0321 558.68 0.0547714 -13.0483 560.52 0.0554582 -13.0663 562.36 0.0524968 -13.0925 564.2 0.0622274 -13.1214 566.04 0.0515883 -13.1395 567.88 0.0560531 -13.1588 569.72 0.0599552 -13.1793 571.56 0.051617 -13.2047 573.4 0.0546262 -13.2217 575.24 0.062275 -13.2394 577.08 0.0496842 -13.268 578.92 0.0560684 -13.2845 580.76 0.0581454 -13.3135 582.6 0.0599693 -13.328 584.44 0.0468703 -13.3497 586.28 0.0579695 -13.3763 588.12 0.0541198 -13.3894 589.96 0.0484466 -13.421 591.8 0.0581987 -13.4376 593.64 0.0595857 -13.4479 595.48 0.0626497 -13.4762 597.32 0.0560775 -13.4946 599.16 0.0518428 -13.5117 601 0.0615928 -13.5373 602.84 0.0539115 -13.5597 604.68 0.0549599 -13.5871 606.52 0.054173 -13.597 608.36 0.0584947 -13.6221 610.2 0.0584645 -13.6436 612.04 0.0597831 -13.6632 613.88 0.0552515 -13.6885 615.72 0.0566402 -13.7071 617.56 0.0502309 -13.7355 619.4 0.0583362 -13.7478 621.24 0.0520739 -13.7562 623.08 0.0535794 -13.7807 624.92 0.0525544 -13.8094 626.76 0.0551214 -13.8358 628.6 0.0632088 -13.843 630.44 0.0518682 -13.8667 632.28 0.0598049 -13.8885 634.12 0.0562164 -13.905 635.96 0.056 -13.9308 637.8 0.056 -13.9531 639.64 0.056 -13.9676 641.48 0.056 -13.9922 643.32 0.056 -14.0027 645.16 0.056 -14.036 647 0.056 -14.0437 648.84 0.056 -14.064 650.68 0.056 -14.0943 652.52 0.056 -14.0961 654.36 0.056 -14.1284 656.2 0.056 -14.1543 658.04 0.056 -14.1677 659.88 0.056 -14.1828 661.72 0.056 -14.2132 663.56 0.056 -14.2257 665.4 0.056 -14.2396 667.24 0.056 -14.2552 669.08 0.056 -14.2805 670.92 0.056 -14.3045 672.76 0.056 -14.3247 674.6 0.056 -14.3395 676.44 0.056 -14.3629 678.28 0.056 -14.3868 680.12 0.056 -14.3994 681.96 0.056 -14.4194 683.8 0.056 -14.4439 685.64 0.056 -14.4495 687.48 0.056 -14.4678 689.32 0.056 -14.4829 691.16 0.056 -14.4986 693 0.056 -14.5108 694.84 0.056 -14.5318 696.68 0.056 -14.5392 698.52 0.056 -14.5462 700.36 0.056 -14.5523 702.2 0.056 -14.5577 704.04 0.056 -14.5618 705.88 0.056 -14.5760 707.72 0.056 -14.6000 709.56 0.056 -14.6000 711.40 0.056 diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/share/MdtCalibDbAsciiTool.py b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/share/MdtCalibDbAsciiTool.py deleted file mode 100644 index a6b600a450c91f82cd9f136c691d030e892d43bb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/share/MdtCalibDbAsciiTool.py +++ /dev/null @@ -1 +0,0 @@ -log.warning("MdtCalibDbAsciiTool/MdtCalibDbAsciiTool.py - This file is obsolete; MdtCalibDbAsciiTool authomatically configured") diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/MdtCalibDbAsciiTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/MdtCalibDbAsciiTool.cxx deleted file mode 100644 index 3e6fc4cf230fa067e7a714dcc0c426e14d6689cb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/MdtCalibDbAsciiTool.cxx +++ /dev/null @@ -1,545 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "SGTools/TransientAddress.h" - -#include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "MuonReadoutGeometry/MdtReadoutElement.h" - -#include "MdtCalibData/CalibFunc.h" -#include "MuonCalibStl/ToString.h" -#include "MdtCalibUtils/RtDataFromFile.h" -#include "PathResolver/PathResolver.h" -#include "MdtCalibData/MdtCalibrationFactory.h" -#include "MdtCalibData/IRtRelation.h" -#include "MdtCalibData/IRtResolution.h" -#include <fstream> -#include <string> -#include <dirent.h> - -#include "MdtCalibSvc/MdtCalibrationRegionSvc.h" - -#include "MdtCalibData/MdtRtRelationCollection.h" -#include "MdtCalibData/MdtTubeCalibContainerCollection.h" -#include "MdtCalibData/MdtCorFuncSetCollection.h" - -//this -#include "MdtCalibDbAsciiTool/MdtCalibDbAsciiTool.h" -#include "MdtCalibDbAsciiTool/StationT0FromFile.h" - -#include "AthenaKernel/IAtRndmGenSvc.h" -#include "CLHEP/Random/RandGaussZiggurat.h" - -namespace MuonCalib { - -MdtCalibDbAsciiTool::MdtCalibDbAsciiTool (const std::string& type, - const std::string& name, - const IInterface* parent) - : AthAlgTool(type, name, parent), - m_tubeData(NULL), - m_rtData(NULL), - m_doCommissioning(false), - m_bilt0(215.), - m_bist0(150.), - m_bmlt0(190.), - m_bmst0(90.), - m_bolt0(150.), - m_bost0(180.), - m_eilt0(850.), - m_eist0(850.), - m_emlt0(850.), - m_emst0(850.), - m_eolt0(850.), - m_eost0(850.), - m_rtDataLocation("RtKey"), - m_tubeDataLocation("TubeKey"), - m_calib_dir("NONE"), - m_t0Shift(0), - m_t0Spread(0), - m_rtShift(0) -{ - - declareInterface< IMdtCalibDBTool >(this) ; - - // the keys are hardcoded in order to be sure to match the ones - // used in regFcn by the Svc - //declareProperty("TubeKey",m_tubeDataLocation); - //declareProperty("RtKey",m_rtDataLocation); - - declareProperty("doCommissioning",m_doCommissioning,"allow setting T0s by chamber type for commissioning and sets default global T0 to 150 ns"); - declareProperty("BILT0",m_bilt0,"for commissioning (doCommissioning True) sets all BIL chambers T0s to a common value"); - declareProperty("BIST0",m_bist0,"for commissioning (doCommissioning True) sets all BIS chambers T0s to a common value"); - declareProperty("BMLT0",m_bmlt0,"for commissioning (doCommissioning True) sets all BML chambers T0s to a common value"); - declareProperty("BMST0",m_bmst0,"for commissioning (doCommissioning True) sets all BMS chambers T0s to a common value"); - declareProperty("BOLT0",m_bolt0,"for commissioning (doCommissioning True) sets all BOL chambers T0s to a common value"); - declareProperty("BOST0",m_bost0,"for commissioning (doCommissioning True) sets all BOS chambers T0s to a common value"); - declareProperty("EILT0",m_eilt0,"for commissioning (doCommissioning True) sets all EIL chambers T0s to a common value"); - declareProperty("EIST0",m_eist0,"for commissioning (doCommissioning True) sets all EIS chambers T0s to a common value"); - declareProperty("EMLT0",m_emlt0,"for commissioning (doCommissioning True) sets all EML chambers T0s to a common value"); - declareProperty("EMST0",m_emst0,"for commissioning (doCommissioning True) sets all EMS chambers T0s to a common value"); - declareProperty("EOLT0",m_eolt0,"for commissioning (doCommissioning True) sets all EOL chambers T0s to a common value"); - declareProperty("EOST0",m_eost0,"for commissioning (doCommissioning True) sets all EOS chambers T0s to a common value"); - - - declareProperty("T0Shift",m_t0Shift,"for simulation: common shift of all T0s, in ns"); - declareProperty("T0Spread",m_t0Spread,"for simulation: sigma for random smeraing of T0s, in ns"); - declareProperty("RTShift",m_rtShift,"for simulations: maximum RT distortion, in mm"); - declareProperty("CalibDir", m_calib_dir, "directory containg calibration files as written from standalone_tarball. If not NONE all other settings are overridden"); - - // is this the simplest way to initialize a list? - std::ostringstream myse; - std::vector<std::string> myord; - myse<< "DC2_rt_asciiDb.dat"; - myord.push_back(myse.str()); - declareProperty("RT_InputFiles",m_RTfileNames=myord,"list of RT input files, see doxygen main page for the case with multiple input files"); - -} - -StatusCode MdtCalibDbAsciiTool::updateAddress(StoreID::type /*storeID*/, - SG::TransientAddress* tad, - const EventContext& /*ctx*/) { - CLID clid = tad->clID(); - std::string key = tad->name(); - if ( 1221928754== clid && m_tubeDataLocation == key) { - ATH_MSG_DEBUG("OK Tube"); - return StatusCode::SUCCESS; - } - if ( 1270996316== clid && m_rtDataLocation == key) { - ATH_MSG_DEBUG("OK Rt"); - return StatusCode::SUCCESS; - } - return StatusCode::FAILURE; -} - -StatusCode MdtCalibDbAsciiTool::initialize() { - ATH_MSG_DEBUG("Initializing"); - - ATH_CHECK(m_idHelperSvc.retrieve()); - ATH_CHECK(m_DetectorManagerKey.initialize()); - - ATH_CHECK(serviceLocator()->service("MdtCalibrationRegionSvc", m_regionSvc)); - ATH_MSG_DEBUG("Retrieved MdtCalibrationRegionSvc"); - - if( m_t0Spread != 0. ) { - static const bool CREATEIFNOTTHERE(true); - ATH_CHECK(service("AtRndmGenSvc", p_AtRndmGenSvc, CREATEIFNOTTHERE)); - if (0 == p_AtRndmGenSvc) { - ATH_MSG_ERROR(" Could not initialize Random Number Service"); - return StatusCode::FAILURE; - } else{ - ATH_MSG_DEBUG(" initialize Random Number Service: running with t0 shift " - << m_t0Shift << " spread " << m_t0Spread << " rt shift " << m_rtShift); - } - // getting our random numbers stream - p_engine = p_AtRndmGenSvc->GetEngine("MDTCALIBDBASCIITOOL"); - } - - // initialize MdtTubeCalibContainers - ATH_CHECK(defaultT0s()); - ATH_CHECK(detStore()->record( m_tubeData, m_tubeDataLocation, true )); - - // Get the TransientAddress from DetectorStore and set "this" as the - // AddressProvider - SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<MdtTubeCalibContainerCollection>::ID(), m_tubeDataLocation); - if (!proxy) { - ATH_MSG_ERROR("Unable to get the proxy for class MdtTubeCalibContainerCollection"); - return StatusCode::FAILURE; - } - - IAddressProvider* addp = this; - proxy->setProvider(addp, StoreID::DETECTOR_STORE); - ATH_MSG_DEBUG("set address provider for MdtTubeCalibContainerCollection"); - - ATH_CHECK(defaultRt()); - ATH_CHECK(detStore()->record( m_rtData, m_rtDataLocation, true )); - - // Get the TransientAddress from DetectorStore and set "this" as the - // AddressProvider - proxy = detStore()->proxy(ClassID_traits<MdtRtRelationCollection>::ID(), m_rtDataLocation); - if (!proxy) { - ATH_MSG_ERROR("Unable to get the proxy for class MdtRtRelationCollection"); - return StatusCode::FAILURE; - } - - addp = this; - proxy->setProvider(addp, StoreID::DETECTOR_STORE); - ATH_MSG_DEBUG("set address provider for MdtRtRelationCollection"); - - return StatusCode::SUCCESS; -} - -StatusCode MdtCalibDbAsciiTool::LoadCalibration(IOVSVC_CALLBACK_ARGS_P(I,keys)) { - ATH_MSG_DEBUG("LoadCalibration has been triggered for the following keys "); - - std::list<std::string>::const_iterator itr; - for (itr=keys.begin(); itr!=keys.end(); ++itr) { - ATH_MSG_DEBUG(*itr << " I="<<I<<" "); - } - - return StatusCode::SUCCESS; - -} - - -StatusCode MdtCalibDbAsciiTool::defaultT0s() { - // create collection - if(m_tubeData) { - delete m_tubeData; m_tubeData=0; - } - m_tubeData = new MdtTubeCalibContainerCollection(); - m_tubeData->resize( m_idHelperSvc->mdtIdHelper().module_hash_max() ); - ATH_MSG_DEBUG(" Created new MdtTubeCalibContainerCollection size " << m_tubeData->size()); - - MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin(); - MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end(); - for( ; it!=it_end;++it ) { - - MuonCalib::MdtTubeCalibContainer* tubes=0; - // create a MdtTubeContainer - tubes = buildMdtTubeCalibContainer(*it); - - if(tubes) { - std::string rName=tubes->regionKey(); - std::string stationName(rName,0,3); - double t0 = 800.; - - // special treatment of the t0's for commissioning - if( m_doCommissioning ){ - t0 = 150.; - if( stationName == "BIL" ) { - t0 = m_bilt0; - }else if( stationName == "BIS" ){ - t0 = m_bist0; - }else if( stationName == "BML" ){ - t0 = m_bmlt0; - }else if( stationName == "BMS" ){ - t0 = m_bmst0; - }else if( stationName == "BOL" ){ - t0 = m_bolt0; - }else if( stationName == "BOS" ){ - t0 = m_bost0; - }else if( stationName == "EIL" ){ - t0 = m_eilt0; - }else if( stationName == "EIS" ){ - t0 = m_eist0; - }else if( stationName == "EML" ){ - t0 = m_emlt0; - }else if( stationName == "EMS" ){ - t0 = m_emst0; - }else if( stationName == "EOL" ){ - t0 = m_eolt0; - }else if( stationName == "EOS" ){ - t0 = m_eost0; - } - } - int nml=tubes->numMultilayers(); - int nlayers=tubes->numLayers(); - int ntubes=tubes->numTubes(); - int size = nml*nlayers*ntubes; - //look for calibration file - bool from_file(false); - StationT0FromFile station_t0; - if(m_calib_dir != "NONE") { - std::ifstream t0_file((m_calib_dir + "/t0s/T0" + rName + ".dat").c_str()); - if(t0_file.fail()) { - ATH_MSG_VERBOSE("File '" << (m_calib_dir + "/t0s/" + rName + ".dat") << "' not found!"); - ATH_MSG_VERBOSE("Using default t0 for chamber '" << rName << "'!"); - } else { - ATH_MSG_DEBUG("Reading calibraation for '" << rName << "' from calibration directory."); - from_file=true; - station_t0.readT0File(t0_file); - } - } - ATH_MSG_VERBOSE("Adding chamber " << m_idHelperSvc->mdtIdHelper().print_to_string(*it)); - ATH_MSG_VERBOSE(" size " << size - << " ml " << nml << " l " << nlayers << " t " - << ntubes << " address " << tubes); - for( int ml=0;ml<nml;++ml ){ - for( int l=0;l<nlayers;++l ){ - for( int t=0;t<ntubes;++t ){ - MuonCalib::MdtTubeCalibContainer::SingleTubeCalib data; - double tt = t0; - if(from_file) { - tt = station_t0.t0(ml + 1, l + 1, t + 1); - ATH_MSG_VERBOSE("tt="<<tt); - } - if( m_t0Shift != 0 ) { - tt += m_t0Shift; - ATH_MSG_VERBOSE("T0 shift " << m_t0Shift << " t0 " << tt - << " id " << ml << " " << l << " " << t); - } - if(m_t0Spread != 0 ) { - double sh = CLHEP::RandGaussZiggurat::shoot(p_engine,0.,m_t0Spread); - tt += sh; - ATH_MSG_VERBOSE("T0 spread " << sh << " t0 " << tt - << " id " << ml << " " << l << " " << t); - } - data.t0 = tt; - data.adcCal = 1.; - data.inversePropSpeed = 1./299.792458; - tubes->setCalib( ml,l,t,data ); - } - } - } - } - ATH_MSG_VERBOSE(" set t0's done "); - //MdtBasicRegionHash hash; - IdentifierHash hash; - IdContext idCont = m_idHelperSvc->mdtIdHelper().module_context(); - m_idHelperSvc->mdtIdHelper().get_hash( *it, hash, &idCont ); - - if( hash < m_tubeData->size() ){ - (*m_tubeData)[hash] = tubes; - ATH_MSG_VERBOSE(" adding tubes at " << hash << " current size " << m_tubeData->size()); - }else{ - ATH_MSG_WARNING(" HashId out of range " << hash << " max " << m_tubeData->size()); - delete tubes; tubes=0; - } - - } - ATH_MSG_DEBUG(" Done defaultT0s " << m_tubeData->size()); - - return StatusCode::SUCCESS; -} - -MuonCalib::MdtTubeCalibContainer * MdtCalibDbAsciiTool::buildMdtTubeCalibContainer(const Identifier& id) { - MuonCalib::MdtTubeCalibContainer* tubes = 0; - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return tubes; - } - - const MuonGM::MdtReadoutElement* detEl = MuonDetMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(id,1,1,1) ); - const MuonGM::MdtReadoutElement* detEl2 = 0; - if (m_idHelperSvc->mdtIdHelper().numberOfMultilayers(id) == 2){ - detEl2 = MuonDetMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(id,2,1,1) ); - }else{ - ATH_MSG_ERROR("A single multilayer for this station " << m_idHelperSvc->mdtIdHelper().show_to_string(id)); - } - - ATH_MSG_VERBOSE(" new det el " << detEl); - - if( !detEl ){ - ATH_MSG_WARNING("No detEl found for " << m_idHelperSvc->mdtIdHelper().print_to_string(id)); - }else{ - int nml = 2; - if( !detEl2 ) { - nml = 1; - } - - int nlayers = detEl->getNLayers(); - if( detEl2 && detEl2->getNLayers() > nlayers ){ - ATH_MSG_DEBUG("Second multilayer has more layers " << detEl2->getNLayers() << " then first " << nlayers); - nlayers = detEl2->getNLayers(); - } - - int ntubes = detEl->getNtubesperlayer(); - if( detEl2 && detEl2->getNtubesperlayer() > ntubes ){ - ATH_MSG_DEBUG("Second multilayer has more tubes " << detEl2->getNtubesperlayer() << " then first " << ntubes); - ntubes = detEl2->getNtubesperlayer(); - } - - // build the region name in the format STATION_ETA_PHI - std::string rName; - - int stName = m_idHelperSvc->mdtIdHelper().stationName(id); - int stPhi = m_idHelperSvc->mdtIdHelper().stationPhi(id); - int stEta = m_idHelperSvc->mdtIdHelper().stationEta(id); - - std::string seperator("_"); - MuonCalib::ToString ts; - rName = m_idHelperSvc->mdtIdHelper().stationNameString(stName); - rName += seperator + ts( stPhi ) + seperator + ts( stEta ); - tubes=new MuonCalib::MdtTubeCalibContainer( rName,nml, nlayers, ntubes ); - } - - return tubes; -} - -StatusCode MdtCalibDbAsciiTool::defaultRt() { - std::vector<std::string>::const_iterator it = m_RTfileNames.value().begin(); - std::vector<std::string>::const_iterator it_end = m_RTfileNames.value().end(); - -//resolve filenames - std::vector<std::string> resolved_filenames; - for ( ; it != it_end ; ++it) { - std::string fileName = PathResolver::find_file(it->c_str(),"DATAPATH"); - if(fileName.length() == 0) { - ATH_MSG_ERROR("RT Ascii file \"" << it->c_str() << "\" not found"); - continue; - } - resolved_filenames.push_back(fileName); - } - - AppendRtFiles(resolved_filenames); - it = resolved_filenames.begin(); - it_end = resolved_filenames.end(); - - if (it == it_end ) { - ATH_MSG_FATAL("No input RT files found"); - return StatusCode::FAILURE; - } else if (it_end-it>1) { - // many files listed in jobO: assume there is one for each chamber - // people are interested in - m_regionSvc->remapRtRegions("OnePerChamber"); - } - - // create collection - if(m_rtData) { - delete m_rtData; m_rtData=0; - } - m_rtData = new MdtRtRelationCollection(); - m_rtData->resize(m_regionSvc->numberOfRegions()); - ATH_MSG_DEBUG(" Created new MdtRtRelationCollection size " << m_rtData->size()); - - // Loop over RT files - for ( ; it != it_end ; ++it) { - const std::string & fileName(*it); - // Open the Ascii file with the RT relations - std::ifstream inputFile( fileName.c_str() ); - if( !inputFile ) { - ATH_MSG_ERROR("Unable to open RT Ascii file: " << fileName.c_str()); - return StatusCode::FAILURE; - }else{ - ATH_MSG_DEBUG("Opened RT Ascii file: " << fileName.c_str()); - } - RtDataFromFile rts; - rts.read(inputFile); - ATH_MSG_VERBOSE("File contains " << rts.nRts() << " RT relations "); - - int nmax = static_cast <int> (rts.nRts()); - if( nmax > 10000 ) nmax = 10000; //prevent arbirarily large loop range to appease Coverity - for( int n=0; n<nmax; ++n ) { - RtDataFromFile::RtRelation* rt = rts.getRt( n ); - unsigned int regionId = rt->regionId(); - - if( regionId >= m_rtData->size() ){ - ATH_MSG_WARNING(" regionHash out of range: " << regionId << " max " << m_rtData->size()); - delete rt; rt=0; - continue; - } - - const RtDataFromFile::RtRelation::DataVec& times = rt->times(); - const RtDataFromFile::RtRelation::DataVec& radii = rt->radii(); - const RtDataFromFile::RtRelation::DataVec& reso = rt->resolution(); - // check if rt contains data, at least two point on the rt are required - if( times.size() < 2 ) { - ATH_MSG_ERROR(" defaultRt rt table has too few entries"); - continue; - } - - // check if all tables have same size - if( times.size() != radii.size() || times.size() != reso.size() ) { - ATH_MSG_ERROR("defaultRt rt table size mismatch "); - continue; - } - - // check if - double t_min = times[0]; - double bin_size = times[1]-t_min; - - // additional consistency check - if( bin_size <= 0 ) { - ATH_MSG_ERROR("RtCalibrationClassic::defaultRt rt table negative binsize "); - continue; - } - - // create a vector to hold the r values, - // we need two extra fields to store t_min and bin_size - MuonCalib::CalibFunc::ParVec rtPars; - rtPars.push_back( t_min ); - rtPars.push_back( bin_size ); - - if( m_rtShift != 0. ){ - - RtDataFromFile::RtRelation::DataVec::const_iterator rtIt = radii.begin(); - RtDataFromFile::RtRelation::DataVec::const_iterator rtIt_end = radii.end(); - for( ;rtIt!=rtIt_end;++rtIt ){ - double rold = *rtIt; - double rshift = m_rtShift*1.87652e-2*rold*(rold-14.6); - double rnew = rold + rshift; - ATH_MSG_DEBUG("DEFORM RT: old radius " << rold << " new radius " << rnew << " shift " << rshift - << " max shift " << m_rtShift); - rtPars.push_back(rnew); - } - }else{ - // copy r values into vector - rtPars.insert( rtPars.end(), radii.begin(), radii.end() ); - } - - ATH_MSG_DEBUG("defaultRt new MuonCalib::IRtRelation"); - MuonCalib::IRtRelation* rtRel = MuonCalib::MdtCalibrationFactory::createRtRelation( "RtRelationLookUp", rtPars ); - if( !rtRel ){ - ATH_MSG_WARNING("ERROR creating RtRelationLookUp "); - } - - MuonCalib::CalibFunc::ParVec resoPars; - resoPars.push_back( t_min ); - resoPars.push_back( bin_size ); - - // copy r values into vector - resoPars.insert( resoPars.end(), reso.begin(), reso.end() ); - - ATH_MSG_DEBUG("defaultRt new MuonCalib::IRtResolution"); - MuonCalib::IRtResolution* resoRel = MuonCalib::MdtCalibrationFactory::createRtResolution( "RtResolutionLookUp", resoPars ); - if( !rtRel ){ - ATH_MSG_WARNING("ERROR creating RtResolutionLookUp "); - } - - if( resoRel && rtRel ){ - int npoints= rtRel->nPar()-2; - (*m_rtData)[regionId] = new MuonCalib::MdtRtRelation( rtRel, resoRel, 0. ); - ATH_MSG_VERBOSE("defaultRt npoints from rtRel="<< npoints); - - for( int j=0;j<npoints;++j ){ - double t = t_min + j*bin_size; - ATH_MSG_VERBOSE(" " << j << " " << t << " " << rtRel->radius(t) << " " << resoRel->resolution(t)); - } - } - delete rt; rt=0; - - } - } - return StatusCode::SUCCESS; -} - - -void MdtCalibDbAsciiTool::AppendRtFiles(std::vector<std::string> &rt_files) { - DIR *directory(opendir((m_calib_dir + "/rts").c_str())); - if(directory==NULL) return; - struct dirent *dent; - //loop on all files in directory - while((dent=readdir(directory))!=NULL) { - std::string nm(dent->d_name); - std::string station; - int eta, phi; - if(!interpret_chamber_name(nm, "Rt_", station,eta, phi)) continue; - rt_files.push_back(m_calib_dir + "/rts/" + nm); - ATH_MSG_DEBUG("Appending rt file "<<m_calib_dir << "/rts/" << nm); - } - closedir(directory); -} - -bool MdtCalibDbAsciiTool :: interpret_chamber_name(const std::string &nm, const char *prefix, std::string & station, int &eta, int & phi) const { -//check if name begins with the prefix - std::string prefix_st(prefix); - if(nm.find(prefix_st) !=0) return false; - //check if filename ends in .dat - if(static_cast<int>(nm.find(".dat")) <0 || nm.find(".dat")!=nm.size()-4) return false; - //cut prefix and suffix from filename - std::string cutout(nm, prefix_st.size(), nm.size()-4-prefix_st.size()); -//extrect station name - int uscore_pos(cutout.find('_')); - if(uscore_pos<=0) return false; - station=std::string(cutout, 0, uscore_pos); -//get eta and phi - std::string cutout2(cutout, uscore_pos+1); - if(sscanf(cutout2.c_str(), "%80d_%80d", &phi, &eta)!=2) return false; - return true; -} - -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/StationT0FromFile.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/StationT0FromFile.cxx deleted file mode 100644 index 67a7912f7a73c430c0f71daf82669fd0c7e3a34c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/StationT0FromFile.cxx +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include <iostream> -#include <fstream> -#include "MdtCalibDbAsciiTool/StationT0FromFile.h" - -using namespace MuonCalib; - -//***************************************************************************** - -//::::::::::::::::: -//:: METHOD init :: -//::::::::::::::::: - -void StationT0FromFile::init(void) { - - m_t0 = std::vector< std::vector< std::vector<double> > >(2); // two multilayers - for (unsigned int k=0; k<m_t0.size(); k++) { - m_t0[k] = std::vector< std::vector<double> >(4); // up to four layers in - // a multilayer - for (unsigned l=0; l<m_t0[k].size(); l++) { - m_t0[k][l] = std::vector<double>(72, 0); - // up to 72 tubes per layer - } - } - - return; - -} - -//***************************************************************************** - -//::::::::::::::: -//:: METHOD t0 :: -//::::::::::::::: - -double StationT0FromFile::t0(const unsigned int & ml, - const unsigned int & ly, - const unsigned int & tb) const { - - return m_t0[ml-1][ly-1][tb-1]; - -} - -//***************************************************************************** - -//::::::::::::::::::::::: -//:: METHOD readT0File :: -//::::::::::::::::::::::: - -void StationT0FromFile::readT0File(std::istream &infile) { - -/////////////// -// VARIABLES // -/////////////// - - std::string sdummy; // auxiliary string for file reading - int idummy; // auxiliary integer for file reading - double dummy; // auxiliary double for file reading - int ml, ly, tb; // multilayer, layer, tube - -////////////////////// -// READ THE t0 FILE // -////////////////////// - -// ignore the first line // - getline(infile, sdummy); - -// read the t0 look-up table // - while (!infile.eof()) { - - // station name // - infile >> sdummy; - if (infile.eof()) { - break; - } - - // eta, phi, technology index // - infile >> idummy >> idummy >> idummy; - - // multilayer, layer, tube // - infile >> ml >> ly >> tb; - - // t0 // - infile >> m_t0[ml-1][ly-1][tb-1]; - - // the rest of the line // - for (unsigned k=0; k<11; k++) { - infile >> dummy; - } - - } - - return; - -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/components/MdtCalibDbAsciiTool_entries.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/components/MdtCalibDbAsciiTool_entries.cxx deleted file mode 100644 index adcf151ab6adcc905c2ac662ff5b7688bea38fd2..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool/src/components/MdtCalibDbAsciiTool_entries.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "MdtCalibDbAsciiTool/MdtCalibDbAsciiTool.h" - -using namespace MuonCalib; - -DECLARE_COMPONENT( MdtCalibDbAsciiTool ) - diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/CMakeLists.txt deleted file mode 100644 index 468c80f29641618c18c9e38b5a4e479be7b5c43b..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -################################################################################ -# Package: MdtCalibTools -################################################################################ - -# Declare the package name: -atlas_subdir( MdtCalibTools ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - GaudiKernel - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibITools - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibInterfaces - MuonSpectrometer/MuonCalib/MuonCalibITools - PRIVATE - Control/StoreGate - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibEventLoop - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibFitters - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibUtils - MuonSpectrometer/MuonCalib/MuonCalibEventBase - MuonSpectrometer/MuonCalib/MuonCalibNtuple - MuonSpectrometer/MuonCalib/MuonCalibUtils/MuonCalibStl - MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry - MuonSpectrometer/MuonIdHelpers ) - -# Component(s) in the package: -atlas_add_component( MdtCalibTools - src/*.cxx - src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps GaudiKernel MuonCalibITools StoreGateLib SGtests MdtCalibEventLoop MdtCalibFitters MdtCalibUtils MuonCalibEventBase MuonCalibNtuple MuonReadoutGeometry MuonIdHelpersLib ) - -# Install files from the package: -atlas_install_headers( MdtCalibTools ) -atlas_install_joboptions( share/*.py ) - diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/DCSLFitterTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/DCSLFitterTool.h deleted file mode 100644 index 3984b2ac6832a2b496113891189e2207efa21cba..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/DCSLFitterTool.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// DCSLFitterTool.h -// Header file for class DCSLFitterTool -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// Niels.Van.Eldik@cern.ch, -/////////////////////////////////////////////////////////////////// - - -#ifndef MUONCALIB_DCSLFITTERTOOL_H -#define MUONCALIB_DCSLFITTERTOOL_H - -// Gaudi -#include "AthenaBaseComps/AthAlgTool.h" - -#include "MdtCalibITools/IMdtSegmentFitterTool.h" - - -namespace MuonCalib { - - class IMdtSegmentFitter; - -/**@class DCSLFitterTool - Tool creates an instance of a IMdtSegmentFitter implementation. - - @author Niels.Van.Eldik@cern.ch, -*/ - class DCSLFitterTool : public AthAlgTool, virtual public IMdtSegmentFitterTool { - - public: - /**AlgTool constructor */ - DCSLFitterTool(const std::string&,const std::string&,const IInterface*); - - /**Virtual destructor*/ - virtual ~DCSLFitterTool(){}; - - /** AlgTool initailize method.*/ - StatusCode initialize(); - - /** AlgTool finalize method */ - StatusCode finalize(); - - /** Interface method: return the implementation pointer */ - IMdtSegmentFitter* getImp() { return m_implementation; } - - private: - /** Pointer to the concrete implementation */ - IMdtSegmentFitter* m_implementation; - - - }; - -} - -#endif // diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/MdtCalibNtupleMakerTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/MdtCalibNtupleMakerTool.h deleted file mode 100644 index c27c5a4f75283c55eebce2091acc90205b293cf8..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/MdtCalibNtupleMakerTool.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// MdtCalibNtupleMakerTool.h -// Header file for class MdtCalibNtupleMakerTool -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// nveldik@nikhef.nl -/////////////////////////////////////////////////////////////////// - -#ifndef MUONCALIB_MDTCALIBNTUPLEMAKERTOOL_H -#define MUONCALIB_MDTCALIBNTUPLEMAKERTOOL_H - -// Gaudi -#include "AthenaBaseComps/AthAlgTool.h" - -#include "MdtCalibITools/IMdtCalibTool.h" - -#include <string> -#include <vector> - -namespace MuonCalib { - - class IMdtCalibration; - - /**@class MdtCalibNtupleMakerTool - Creates ntuple per calibration region containing segment information - - @author Niels.Van.Eldik@cern.ch, - */ - - class MdtCalibNtupleMakerTool : public AthAlgTool, virtual public IMdtCalibTool { - public: - /**AlgTool constructor */ - MdtCalibNtupleMakerTool(const std::string&,const std::string&,const IInterface*); - - /** AlgTool initailize method.*/ - StatusCode initialize(); - - /** AlgTool finalize method */ - StatusCode finalize(); - - /** Interface method: return the implementation pointer */ - IMdtCalibration* getImp(std::string name); - - /** dummy methode */ - bool writeToDb( const IMdtCalibrationOutput* , std::string ) const { return true; } - - private: - - /** vector to hold pointers to all instances that were created */ - std::vector<IMdtCalibration*> m_instances; - }; - -} - -#endif // - - diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/MdtCalibTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/MdtCalibTool.h deleted file mode 100644 index 1ab21606fcd126cdba799a28c10e567c1e726465..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/MdtCalibTool.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// MdtCalibTool.h -// Header file for class MdtCalibTool -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// Niels.Van.Eldik@cern.ch, -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// Modifications: -// Tue Feb 28 2006 by Oliver Kortner: segment selection added in -// order to avoid ambiguities, -// by default this selection is -// disabled and must be enabled -// via the job option -// MdtCalibTool.SelectorSwitch=1 -/////////////////////////////////////////////////////////////////// - - -#ifndef MUONCALIB_MDTCALIBTOOL_H -#define MUONCALIB_MDTCALIBTOOL_H - -// Gaudi -#include "AthenaBaseComps/AthAlgTool.h" - -#include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ServiceHandle.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" - -#include "MuonCalibITools/IMuonCalibTool.h" -#include "MuonCalibITools/IRegionSelectorTool.h" - -#include <map> - -namespace MuonCalib { - - class IMdtCalibTool; - class IMdtSegmentSelectorTool; - class IMdtSegmentSelector; - class MdtCalibEventLoop; - class IMdtCalibrationOutput; - class MuonCalibEvent; - -/**@class MdtCalibTool - Steers MdtCalibration within athena. - - Modification: 28.02.2006 by O.Kortner: - A simple segment selection can be enabled via the job option - MdtCalibTool.SelectorSwitch=1. If the selection is switchted on, - the following selection is applied to chambers with more than one - segment in an event: the segments which have more hits on the - reconstructed track than the others are kept; if two segments have - the same number of track hits, the segment with the smaller chi^2 is - selected. - - @author Niels.Van.Eldik@cern.ch, -*/ - class MdtCalibTool : public AthAlgTool, virtual public IMuonCalibTool { - public: - /**AlgTool constructor */ - MdtCalibTool(const std::string&,const std::string&,const IInterface*); - - /**Virtual destructor*/ - virtual ~MdtCalibTool()=default; - - /** AlgTool initailize method.*/ - StatusCode initialize(); - - /** Interface method: handle MuonCalibPatternCollection */ - // virtual bool handle( const MuonCalibPatternCollection* patterns ); - - virtual bool handleEvent( const MuonCalibEvent* event ); - - /** perform analysis */ - virtual bool analyse(); - - private: - /** for now create a new eventloop for every calibration region */ - typedef std::map< IRegionSelectorTool::RegionKey, MdtCalibEventLoop* > RegionEventMap; - - private: - /** routines to pass segments to event loop */ - void handleMuonSegment( const MuonCalibSegment* seg ); - - /** generate RegionKey from identifier */ - IRegionSelectorTool::RegionKey keyFromIdentifier( const IRegionSelectorTool::id_type& id ) const; - - /** get EventLoop for given region key */ - MdtCalibEventLoop* getEventLoopForRegion( const IRegionSelectorTool::RegionKey& key ); - - /** Map containing the segments (stored in the eventloop) per calibration region */ - RegionEventMap m_segmentsPerRegion; - - /** RtCalibration initialization */ - ToolHandle<IMdtCalibTool> m_mdtCalibTool; //!< RtCalibrationCreator ToolHandle - - /** Switch for the MdtCalibTool internal segment selection **/ - int m_SelectorSwitch; //!< selector switch (is set to 0 by the default) - - /** MdtSegmentSelector initialization */ - ToolHandle<IMdtSegmentSelectorTool> m_segmentSelectorTool; //!< MdtSegmentSelectorTool ToolHandle - const IMdtSegmentSelector* m_segmentSelector; //!< MdtSegmentSelector - - /** RegionSelector initialization */ - ToolHandle<IRegionSelectorTool> m_regionSelector; //!< RegionSelector ToolHandle - - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - }; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/QuasianalyticLineReconstructionTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/QuasianalyticLineReconstructionTool.h deleted file mode 100644 index e4bb24f641df9c7b2939db32a59a237fafbd1359..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/QuasianalyticLineReconstructionTool.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 07.03.2006, AUTHOR: OLIVER KORTNER -// Modified: 15.07.2006 by O. Kortner, interface to additional functionality -// of QuasianalyticLineReconstruction added. -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef QuasianalyticLineReconstructionToolH -#define QuasianalyticLineReconstructionToolH - -//::::::::::::::::::::::::::::::::::::::::::::::: -//:: CLASS QuasianalyticLineReconstructionTool :: -//::::::::::::::::::::::::::::::::::::::::::::::: - -/// \class QuasianalyticLineReconstructionTool -/// Tool to create an instance of the IMdtSegmentFitter implementation in -/// QuasianalyticLineReconstruction. -/// The user can specify the road width of the pattern recognition in the -/// job-options file by the setting "roadWidth" to the desired value. -/// The user can also request a chi^2 refit at the end of the quasianalytic -/// segment reconstruction. -/// -/// \author Oliver.Kortner@CERN.CH -/// -/// \date 15.07.2006 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// Gaudi // -#include "AthenaBaseComps/AthAlgTool.h" - -// MuonCalib // -#include "MdtCalibITools/IMdtSegmentFitterTool.h" -#include "MdtCalibInterfaces/IMdtSegmentFitter.h" - - -namespace MuonCalib { - -class QuasianalyticLineReconstructionTool : - public AthAlgTool, virtual public IMdtSegmentFitterTool { - -public: -// Constructors // - QuasianalyticLineReconstructionTool(const std::string & type, - const std::string & name, const IInterface *parent); - ///< AlgTool constructor - - virtual ~QuasianalyticLineReconstructionTool(){}; - ///< Virtual destructor - -// Methods // - StatusCode initialize(); - ///< AlgTool initialize method - StatusCode finalize(); - ///< AlgTool finalize method - IMdtSegmentFitter* getImp() { return m_implementation; } - ///< Interface method: return the - ///< implementation pointer - -private: - double m_road_width; // road width used in the pattern recognition of - // QuasianalyticLineReconstruction - bool m_refit; // enable the chi^2 refit at the end of the quasianalytic - // segment reconstruction - IMdtSegmentFitter *m_implementation; // pointer to the concrete - // implementation - -}; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/SimpleMdtSegmentSelectorTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/SimpleMdtSegmentSelectorTool.h deleted file mode 100644 index 06d6abd610ae34e20f109c874f767c3647554868..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/SimpleMdtSegmentSelectorTool.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// SimpleMdtSegmentSelectorTool.h -// Header file for class SimpleMdtSegmentSelectorTool -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// Niels.Van.Eldik@cern.ch, -/////////////////////////////////////////////////////////////////// - - -#ifndef MUONCALIB_SIMPLEMDTSEGMENTSELECTORTOOL_H -#define MUONCALIB_SIMPLEMDTSEGMENTSELECTORTOOL_H - -// Gaudi -#include "AthenaBaseComps/AthAlgTool.h" - -#include "MdtCalibITools/IMdtSegmentSelectorTool.h" - - -namespace MuonCalib { - - class IMdtSegmentSelector; - -/**@class SimpleMdtSegmentSelectorTool - Creates an instance of a IMdtSegmentSelector implementation. - - @author Niels.Van.Eldik@cern.ch, -*/ - class SimpleMdtSegmentSelectorTool : public AthAlgTool, virtual public IMdtSegmentSelectorTool { - - public: - /**AlgTool constructor */ - SimpleMdtSegmentSelectorTool(const std::string&, - const std::string&, - const IInterface*); - - /**Virtual destructor*/ - virtual ~SimpleMdtSegmentSelectorTool(){}; - - /** AlgTool initailize method.*/ - StatusCode initialize(); - - /** AlgTool finalize method */ - StatusCode finalize(); - - /** Interface method: return the implementation pointer */ - virtual const IMdtSegmentSelector* getImp() { return m_implementation; } - - private: - /** Pointer to the concrete implementation */ - const IMdtSegmentSelector* m_implementation; - - /** minimum chi2 */ - double m_chi2; - - /** minimum number of HitOnTrack */ - unsigned int m_minHits; - }; - -} - -#endif // diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/SimplePatternSelectorTool.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/SimplePatternSelectorTool.h deleted file mode 100644 index 2c4914fabf7d6bf0da8b5def2984d8bcdd420aff..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/MdtCalibTools/SimplePatternSelectorTool.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// SimplePatternSelectorTool.h -// Header file for class SimplePatternSelectorTool -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// Niels.Van.Eldik@cern.ch, -/////////////////////////////////////////////////////////////////// - - -#ifndef MUONCALIB_SIMPLEPATTERNSELECTORTOOL_H -#define MUONCALIB_SIMPLEPATTERNSELECTORTOOL_H - -// Gaudi -#include "AthenaBaseComps/AthAlgTool.h" - -#include "MdtCalibITools/IPatternSelectorTool.h" - - - -namespace MuonCalib { - - class ICalibPatternSelector; - -/**@class SimplePatternSelectorTool - Creates an instance of a IGlobalPatternSelector implementation. - - @author Niels.Van.Eldik@cern.ch, -*/ - class SimplePatternSelectorTool : public AthAlgTool, virtual public IPatternSelectorTool { - - public: - /**AlgTool constructor */ - SimplePatternSelectorTool(const std::string&, - const std::string&, - const IInterface*); - - /**Virtual destructor*/ - virtual ~SimplePatternSelectorTool(){}; - - /** AlgTool initailize method.*/ - StatusCode initialize(); - - /** AlgTool finalize method */ - StatusCode finalize(); - - /** Interface method: return the implementation pointer */ - virtual const ICalibPatternSelector* getImp() { return m_implementation; } - - private: - /** Pointer to the concrete implementation */ - const ICalibPatternSelector* m_implementation; - - - }; - -} - -#endif // diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/doc/packagedoc.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/doc/packagedoc.h deleted file mode 100644 index 83eaae904293aaef5d3835ef5b650ffaef35e98f..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/doc/packagedoc.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** -@page MdtCalibTools_page MdtCalibTools Package -@author Niels.Van.Eldik@cern.ch - -@section MdtCalibTools_MdtCalibToolsIntro Introduction -This package contains the implementation of various tools derived from the -abstract MuonCalib::MdtCalibITools classes. - -@section MdtCalibTools_MdtCalibToolsOverview Class Overview -The MdtCalibTools package contains the following Tools selectable from MuonCalib::MuonCalibAlg jobOptions: -- MuonCalib::MdtCalibNtupleMakerTool: creates ntuple per calibration region containing segment information -- MuonCalib::MdtCalibTool: steers Mdt Calibration within athena - -in addition it also contains the following helper Tools: -- MuonCalib::SimpleMdtSegmentSelectorTool: creates an instance of a MuonCalib::IMdtSegmentSelector implementation -- MuonCalib::SimplePatternSelectorTool: creates an instance of a MuonCalib::IGlobalPatternSelector implementation -- MuonCalib::MuCCaFitterTool: creates an instance of a MuonCalib::IMdtSegmentFitter implementation -- MuonCalib::DCSLFitterTool: creates an instance of a MuonCalib::IMdtSegmentFitter implementation - - -*/ diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/share/MdtCalibTool.py b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/share/MdtCalibTool.py deleted file mode 100644 index c3a127d060bd08a7c796a976557fa95603796480..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/share/MdtCalibTool.py +++ /dev/null @@ -1,24 +0,0 @@ -theApp.Dlls += ["MdtCalibTools"] - -ToolSvc = Service( "ToolSvc" ) -MdtCalibTool = Service( "ToolSvc.MuonCalib_MdtCalibTool" ) - -MdtCalibTool.MdtSegmentSelectorToolType = "MuonCalib::SimpleMdtSegmentSelectorTool" -MdtCalibTool.MdtSegmentSelectorToolName = "MdtCalib_SimpleMdtSegmentSelectorTool" -MdtCalib_SimpleMdtSegmentSelectorTool = Service("ToolSvc.MdtCalib_SimpleMdtSegmentSelectorTool" ) -#modify here MdtCalib_SimpleMdtSegmentSelectorTool properties -#MdtCalib_SimpleMdtSegmentSelectorTool.MinHitsOntrack=3. -#MdtCalib_SimpleMdtSegmentSelectorTool.MaxChi2=10. - -if doMuonCalibAtlas: - include( "MuonCalibTools/AtlasRegionSelectorTool.py" ) - MdtCalibTool.RegionSelectorType = "MuonCalib::AtlasRegionSelectorTool" - MdtCalibTool.RegionSelectorName = "MdtCalib_AtlasRegionSelectorTool" - MdtCalib_AtlasRegionSelectorTool = Service("ToolSvc.MdtCalib_AtlasRegionSelectorTool" ) - #modify here MdtCalib_AtlasRegionSelectorTool properties - #MdtCalib_AtlasRegionSelectorTool.Split = 1 -else : - include( "MuonCalibTools/TestbeamRegionSelectorTool.py" ) - MdtCalibTool.RegionSelectorType = "MuonCalib::TestbeamRegionSelectorTool" - MdtCalibTool.RegionSelectorName = "MdtCalib_TestbeamRegionSelectorTool" - MdtCalib_TestbeamRegionSelectorTool = Service("ToolSvc.MdtCalib_TestbeamRegionSelectorTool" ) diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/DCSLFitterTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/DCSLFitterTool.cxx deleted file mode 100644 index 4b2dede519db0a40c43f907c1d2924a23473a2b3..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/DCSLFitterTool.cxx +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibTools/DCSLFitterTool.h" - -// gaudi -#include "GaudiKernel/MsgStream.h" - -#include "MdtCalibFitters/DCSLFitter.h" - -namespace MuonCalib { - - DCSLFitterTool::DCSLFitterTool(const std::string& t, const std::string& n, const IInterface* p) : - AthAlgTool(t,n,p) - { - declareInterface< IMdtSegmentFitterTool >(this) ; - } - - - StatusCode DCSLFitterTool::initialize() - { - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "initialize " << endmsg; - - // create an instance of DCSLFitter - m_implementation = new DCSLFitter(); - - return StatusCode::SUCCESS; - } - - StatusCode DCSLFitterTool::finalize() - { - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "finalize " << endmsg; - - // delete instance - delete m_implementation; - - return StatusCode::SUCCESS; - } - -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/MdtCalibNtupleMakerTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/MdtCalibNtupleMakerTool.cxx deleted file mode 100644 index 3e4aa0bdec83bd57ea3b432fda07f04d7885e9ef..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/MdtCalibNtupleMakerTool.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibTools/MdtCalibNtupleMakerTool.h" - -// gaudi -#include "GaudiKernel/MsgStream.h" - -// calibration -#include "MuonCalibNtuple/MdtCalibNtupleMaker.h" -#include "MuonCalibStl/DeleteObject.h" - -namespace MuonCalib { - - MdtCalibNtupleMakerTool::MdtCalibNtupleMakerTool(const std::string& t, - const std::string& n, - const IInterface* p) - : AthAlgTool(t,n,p) - { - declareInterface< IMdtCalibTool >(this) ; - } - - StatusCode MdtCalibNtupleMakerTool::initialize() - { - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "Initialisation started " << endmsg; - - return StatusCode::SUCCESS; - } - - StatusCode MdtCalibNtupleMakerTool::finalize() - { - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "finalize started " << endmsg; - // delete instances - std::for_each( m_instances.begin(), m_instances.end(), DeleteObject() ); - - return StatusCode::SUCCESS; - } - - IMdtCalibration* MdtCalibNtupleMakerTool::getImp(std::string name){ - - // Create instance of MdtCalibNtupleMaker - IMdtCalibration* implementation = new MdtCalibNtupleMaker( name ); - m_instances.push_back( implementation ); - return implementation; - } - -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/MdtCalibTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/MdtCalibTool.cxx deleted file mode 100644 index b652e28f32ebbf86b75856db37b02420509f2e2a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/MdtCalibTool.cxx +++ /dev/null @@ -1,248 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibTools/MdtCalibTool.h" - -// gaudi -#include "GaudiKernel/MsgStream.h" - -// calibration -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" -#include "MdtCalibITools/IMdtCalibTool.h" -#include "MdtCalibITools/IMdtSegmentSelectorTool.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MdtCalibInterfaces/IMdtSegmentSelector.h" - -#include "MdtCalibEventLoop/MdtCalibEventLoop.h" - -#include "MuonIdHelpers/MdtIdHelper.h" - -#include <algorithm> -#include <fstream> - -namespace MuonCalib { - - MdtCalibTool::MdtCalibTool(const std::string& t, const std::string& n, const IInterface* p) : - AthAlgTool(t,n,p), - m_mdtCalibTool("MuonCalib::MdtCalibNtupleMakerTool"), - m_segmentSelectorTool("MuonCalib::SimpleMdtSegmentSelectorTool"), - m_regionSelector("MuonCalib::AtlasRegionSelectorTool") - { - declareInterface< IMuonCalibTool >(this) ; - - declareProperty("MdtCalibTool", m_mdtCalibTool); - declareProperty("SelectorSwitch", m_SelectorSwitch=0); - declareProperty("MdtSegmentSelectorTool", m_segmentSelectorTool); - declareProperty("RegionSelector", m_regionSelector); - } - - StatusCode MdtCalibTool::initialize() - { - ATH_CHECK(AthAlgTool::initialize()); - ATH_CHECK(m_mdtCalibTool.retrieve()); - ATH_MSG_DEBUG("Retrieved" << m_mdtCalibTool); - ATH_CHECK(m_segmentSelectorTool.retrieve()); - ATH_MSG_DEBUG("Retrieved" << m_segmentSelectorTool); - m_segmentSelector = m_segmentSelectorTool->getImp(); - ATH_CHECK(m_regionSelector.retrieve()); - ATH_MSG_DEBUG("Retrieved" << m_regionSelector); - ATH_CHECK(m_idHelperSvc.retrieve()); - return StatusCode::SUCCESS; - } - - bool MdtCalibTool::handleEvent( const MuonCalibEvent* event ) - { - unsigned int nb_segments(0); - std::vector<MuonCalibSegment *> selected_segment; - bool segment_found; - bool segment_rejected; - ATH_MSG_DEBUG("handleEvent(events) with patSize " << event->numberOfPatterns()); - - // loop over patterns - MuonCalibEvent::MCPVecCit pat_it = event->patternBegin(); - MuonCalibEvent::MCPVecCit pat_it_end = event->patternEnd(); - for( ;pat_it!=pat_it_end; ++pat_it ){ - // loop over segments in pattern - - ATH_MSG_DEBUG("New pattern with segments " << (*pat_it)->muonSegments()); - - MuonCalibPattern::MuonSegCit seg_it = (*pat_it)->muonSegBegin(); - MuonCalibPattern::MuonSegCit seg_it_end = (*pat_it)->muonSegEnd(); - for( ;seg_it!=seg_it_end;++seg_it ){ - MuonCalibSegment* seg = *seg_it; - // protect against null pointer - if (!seg) { - ATH_MSG_WARNING("Got Segment nullptr"); - continue; - } - // Only process segments with MDT hits - if ( seg->mdtHOT().empty() ) { - continue; - } - -// if no internal selection is requested, pass the segment to the algorithm // - if (m_SelectorSwitch==0 && seg) { - handleMuonSegment( seg ); - continue; - } - -// segment selection // - - // reject all segments which contain hits from different chambers // - MuonFixedId id1(seg->mdtHOT()[0]->identify()); - segment_rejected = false; - for (unsigned int k=1; k<seg->mdtHitsOnTrack(); k++) { - MuonFixedId id2(seg->mdtHOT()[k]->identify()); - if (id1.stationName()!=id2.stationName() || id1.eta()!=id2.eta() || - id1.phi()!=id2.phi()) { - segment_rejected = true; - } - } - if (segment_rejected) { - continue; - } - - // if a segment is accepted, only keep it if it has more hits than // - // another segment in the same chamber; if two segments in a chamber have // - // the same number of hits, take the one with the better chi^2 // - segment_found = false; - for (unsigned int k=0; k<nb_segments; k++) { - MuonFixedId id2(selected_segment[k]->mdtHOT()[0]->identify()); - if (id1.stationName()==id2.stationName() && id1.eta()==id2.eta() && - id1.phi()==id2.phi()) { - segment_found = true; - if (selected_segment[k]->mdtHitsOnTrack() < - seg->mdtHitsOnTrack()) { - selected_segment[k] = seg; - break; - } - if (selected_segment[k]->mdtHitsOnTrack() == - seg->mdtHitsOnTrack()) { - if (selected_segment[k]->chi2() > seg->chi2()) { - selected_segment[k] = seg; - break; - } - } - } - } - if (!segment_found) { - selected_segment.push_back(seg); - nb_segments++; - } - } // loop over segments - - } // loop over patterns - - if (m_SelectorSwitch!=0) { - for (unsigned int k=0; k<nb_segments; k++) { - if (selected_segment[k]!=0) { - handleMuonSegment( selected_segment[k] ); - } - } - } - return true; - } - - bool MdtCalibTool::analyse() - { - // loop over all regions - ATH_MSG_INFO("Performing loop over regions: " << m_segmentsPerRegion.size()); - - RegionEventMap::iterator it = m_segmentsPerRegion.begin(); - RegionEventMap::iterator it_end = m_segmentsPerRegion.end(); - for( ; it!=it_end; ++it ){ - ATH_MSG_DEBUG("Performing analysis for region "); - - // create new calibration instance - IMdtCalibration* calibImp = m_mdtCalibTool->getImp( it->first ); - - // set rt calibration implementation - it->second->setCalibImp( calibImp ); - - // perform calibration - it->second->performAnalysis(); - - // get results - const IMdtCalibrationOutput* result = it->second->calibrationResults(); - - // write result to db - m_mdtCalibTool->writeToDb( result, it->first ); - } - - ATH_MSG_INFO("End of calibration started "); - return true; - } - - void MdtCalibTool::handleMuonSegment( const MuonCalibSegment* seg ) - { - // subdivide segment into regions and get key - IRegionSelectorTool::RegionVec rvec = m_regionSelector->splitIntoRegions( seg ); - - ATH_MSG_VERBOSE("RegionSelector produced " << rvec.size() << " subregions for segment "); - - // loop over different region - IRegionSelectorTool::RegionVec::iterator it = rvec.begin(); - IRegionSelectorTool::RegionVec::iterator it_end = rvec.end(); - - for( ; it!=it_end; ++it ){ - - // decompose pair - const MuonCalibSegment * sseg = it->first; - IRegionSelectorTool::RegionKey key = it->second; - - if( !m_segmentSelector->select(*sseg) ){ - ATH_MSG_VERBOSE(" ssegment rejected by selector "); - // return; this prevents the second ML from being accepted! - continue; - } - - // check if region should be calibrated - if( m_regionSelector->useRegion( key ) ){ - - ATH_MSG_VERBOSE("handleMuonSegment with region key " << key); - - // pointer to current event loop - MdtCalibEventLoop* loop = getEventLoopForRegion( key ); - - // fill current ssegment into event loop - loop->handleSegment( sseg ); - }else{ - ATH_MSG_VERBOSE("MuonSegment not selected by RegionSelector " << key); - } - } - } - - - IRegionSelectorTool::RegionKey MdtCalibTool::keyFromIdentifier( const IRegionSelectorTool::id_type& id ) const - { - ATH_MSG_VERBOSE(" keyFromIdentifier "); - return m_regionSelector->getRegionKey(id); - } - - - MdtCalibEventLoop* MdtCalibTool::getEventLoopForRegion( const IRegionSelectorTool::RegionKey& key ) - { - MdtCalibEventLoop* loop = nullptr; - // look up key in map - RegionEventMap::iterator sit = m_segmentsPerRegion.find(key); - - // if not found create new entry in map - if( sit == m_segmentsPerRegion.end() ){ - ATH_MSG_VERBOSE("created new entry in region map for key " << key); - - // create new event loop - loop = new MdtCalibEventLoop( key ); - - // add loop to RegionMap - m_segmentsPerRegion.insert( sit, std::make_pair( key, loop ) ); - }else{ - // get event loop from RegionMap - loop = sit->second; - } - return loop; - } - - -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/QuasianalyticLineReconstructionTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/QuasianalyticLineReconstructionTool.cxx deleted file mode 100644 index 84af831690cdfbe1c54531b0218b276700d9ca38..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/QuasianalyticLineReconstructionTool.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibTools/QuasianalyticLineReconstructionTool.h" -#include "GaudiKernel/MsgStream.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" - -using namespace MuonCalib; - -//:::::::::::::::::::::::::::::::::::::::::::::::::::: -//:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS :: -//:: QuasianalyticLineReconstructionTool :: -//:::::::::::::::::::::::::::::::::::::::::::::::::::: - -//***************************************************************************** - -//::::::::::::::::: -//:: CONSTRUCTOR :: -//::::::::::::::::: - -QuasianalyticLineReconstructionTool::QuasianalyticLineReconstructionTool( - const std::string & type, const std::string & name, - const IInterface *parent) : AthAlgTool(type, name, parent) { - - declareInterface< IMdtSegmentFitterTool>(this); - - m_road_width = 0.5; - declareProperty("roadWidth", m_road_width); - - m_refit = false; - declareProperty("refit", m_refit); - - return; - -} - -//***************************************************************************** - -//::::::::::::::::::::::: -//:: METHOD initialize :: -//::::::::::::::::::::::: - -StatusCode QuasianalyticLineReconstructionTool::initialize() { - ATH_CHECK(AthAlgTool::initialize()); - ATH_MSG_INFO("initialize "); - -// create an instance of QuasianalyticLineReconstruction // - m_implementation = new QuasianalyticLineReconstruction(m_road_width); - - if (m_refit) { - static_cast<QuasianalyticLineReconstruction*>(m_implementation - )->switchOnRefit(); - } else { - static_cast<QuasianalyticLineReconstruction*>(m_implementation - )->switchOffRefit(); - } - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//::::::::::::::::::::: -//:: METHOD finalize :: -//::::::::::::::::::::: - -StatusCode QuasianalyticLineReconstructionTool::finalize() { - ATH_MSG_INFO("finalize "); - delete m_implementation; - ATH_CHECK(AthAlgTool::finalize()); - return StatusCode::SUCCESS; -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/SimpleMdtSegmentSelectorTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/SimpleMdtSegmentSelectorTool.cxx deleted file mode 100644 index 31f5f411e17f8546fbca210ff249e795a1bc60bc..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/SimpleMdtSegmentSelectorTool.cxx +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibTools/SimpleMdtSegmentSelectorTool.h" - -#include "MdtCalibUtils/SimpleMdtSegmentSelector.h" - -namespace MuonCalib { - - SimpleMdtSegmentSelectorTool::SimpleMdtSegmentSelectorTool(const std::string& t, - const std::string& n, - const IInterface* p) : - AthAlgTool(t,n,p) - { - declareInterface< IMdtSegmentSelectorTool >(this) ; - - // chi2 and #hits cuts - m_minHits = 6; - m_chi2 = 10.; - - declareProperty("MinHitsOntrack", m_minHits); - declareProperty("MaxChi2" , m_chi2); - } - - - StatusCode SimpleMdtSegmentSelectorTool::initialize() - { - // Create instance of type SimpleMdtSegmentSelector - m_implementation = new SimpleMdtSegmentSelector(m_chi2,m_minHits); - - return StatusCode::SUCCESS; - } - - StatusCode SimpleMdtSegmentSelectorTool::finalize() - { - // delete instance - delete m_implementation; - - return StatusCode::SUCCESS; - } - -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/SimplePatternSelectorTool.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/SimplePatternSelectorTool.cxx deleted file mode 100644 index a5b1ead5ab3c2792cb135da5021316afe7a2ff85..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/SimplePatternSelectorTool.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibTools/SimplePatternSelectorTool.h" - -#include "MdtCalibUtils/SimplePatternSelector.h" - -namespace MuonCalib { - - SimplePatternSelectorTool::SimplePatternSelectorTool(const std::string& t, - const std::string& n, - const IInterface* p) : - AthAlgTool(t,n,p) - { - declareInterface< IPatternSelectorTool >(this) ; - - } - - - StatusCode SimplePatternSelectorTool::initialize() - { - // set maximum chi2 of segment - double chi2_max = 1000.; - - // set minimum number of mdt segments - unsigned int mdt_min = 1; - - // set minimum number of phi segments - unsigned int phi_min = 1; - - // create an instance of SimplePatternSelector - m_implementation = new SimplePatternSelector(chi2_max,mdt_min,phi_min); - - return StatusCode::SUCCESS; - } - - StatusCode SimplePatternSelectorTool::finalize() - { - // delete pointer - delete m_implementation; - - return StatusCode::SUCCESS; - } - -} diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/components/MdtCalibTools_entries.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/components/MdtCalibTools_entries.cxx deleted file mode 100644 index cf6f4bd8323a7dd28a0709cf59dc24e61870e6f2..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools/src/components/MdtCalibTools_entries.cxx +++ /dev/null @@ -1,17 +0,0 @@ -#include "MdtCalibTools/DCSLFitterTool.h" -#include "MdtCalibTools/QuasianalyticLineReconstructionTool.h" -#include "MdtCalibTools/MdtCalibTool.h" -#include "MdtCalibTools/SimpleMdtSegmentSelectorTool.h" -#include "MdtCalibTools/SimplePatternSelectorTool.h" -#include "MdtCalibTools/MdtCalibNtupleMakerTool.h" - - -using namespace MuonCalib; - -DECLARE_COMPONENT( DCSLFitterTool ) -DECLARE_COMPONENT( QuasianalyticLineReconstructionTool ) -DECLARE_COMPONENT( MdtCalibTool ) -DECLARE_COMPONENT( SimpleMdtSegmentSelectorTool ) -DECLARE_COMPONENT( SimplePatternSelectorTool ) -DECLARE_COMPONENT( MdtCalibNtupleMakerTool ) - diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/CMakeLists.txt deleted file mode 100644 index ba08fcd0e334bf17a645ddce72da77e43adbe641..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -################################################################################ -# Package: MdtCalibValidation -################################################################################ - -# Declare the package name: -atlas_subdir( MdtCalibValidation ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - Control/StoreGate - GaudiKernel - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData - PRIVATE - MuonSpectrometer/MuonCalib/MuonCalibDbOperations - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase - MuonSpectrometer/MuonCalib/MuonCalibUtils/MuonCalibMath - MuonSpectrometer/MuonCalib/MuonCalibUtils/MuonCalibStl - MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry - MuonSpectrometer/MuonIdHelpers ) - -# External dependencies: -find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread Graf Graf3d Gpad Html Postscript Gui GX11TTF GX11 ) - -# tag NEEDS_CORAL_BASE was not recognized in automatic conversion in cmt2cmake - -# Component(s) in the package: -atlas_add_library( MdtCalibValidationLib - src/*.cxx - PUBLIC_HEADERS MdtCalibValidation - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel MdtCalibData StoreGateLib SGtests MuonCalibDbOperationsLib MuonCalibStandAloneBaseLib MuonIdHelpersLib - PRIVATE_LINK_LIBRARIES MuonCalibMath MuonReadoutGeometry ) - -atlas_add_component( MdtCalibValidation - src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps StoreGateLib SGtests GaudiKernel MdtCalibData MuonCalibDbOperationsLib MuonCalibStandAloneBaseLib MuonCalibMath MuonReadoutGeometry MuonIdHelpersLib MdtCalibValidationLib ) - diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/MdtCalibValidation/FixRtEnds.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/MdtCalibValidation/FixRtEnds.h deleted file mode 100644 index d9f27a53ef06c98c69e4bbea55841bf17bd38049..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/MdtCalibValidation/FixRtEnds.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_FixRtEnds_h -#define MuonCalib_FixRtEnds_h - -//std -#include "vector" - -namespace MuonCalib { - -//MuonCalibMath -class SamplePoint; - -class FixRtEnds { - public: -//=============================constructor - destructor========================= - inline FixRtEnds() {} - inline ~FixRtEnds() {} -//=============================public member functions ========================= - //fix the rt ends for monoton - int FixEnds(std::vector<SamplePoint> & points); -//===========================static const ====================================== - //return values for FixEnds - static const int NO_FIX_NEEDED = 0, - FIX_APPLIED = 1, - FIX_FAILED = 2; - private: -//==========================private functions=================================== - bool checkMono(const std::vector<SamplePoint> & points, bool & fix_begin, bool & fix_end) const; - inline bool fixBegin(std::vector<SamplePoint> & points); - inline bool fixEnd(std::vector<SamplePoint> & points); -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/MdtCalibValidation/MdtValidationAlg.h b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/MdtCalibValidation/MdtValidationAlg.h deleted file mode 100644 index 9ba13b110eeaf7734b7df4f60e352dd7ba92fe4e..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/MdtCalibValidation/MdtValidationAlg.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _MDTVALIDATIONALG_H -#define _MDTVALIDATIONALG_H - -// c - c++ - system -#include "vector" -#include "map" -#include <iostream> -#include <fstream> -#include <sstream> -#include <string> -#include <stdio.h> -#include <sys/time.h> - -//root -#include "TFile.h" -#include "TList.h" -#include "TH1.h" -#include "TH2.h" -#include "TList.h" -#include "TF1.h" - -//athena -#include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ServiceHandle.h" - -//MdtCalibData -#include "MdtCalibData/MdtTubeFitContainer.h" - -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" - -class RegionSelectionSvc; - -namespace MuonCalib { - - class SamplePoint; - class CalibDbConnection; - class RtFullInfo; - class CalibRtDbOperations; - class CalibT0DbOperations; - class CalibHeadOperations; - - class MdtValidationAlg : public AthAlgorithm { - //=========================================== - public: - /** Algorithm Constructor */ - MdtValidationAlg(const std::string& name, ISvcLocator* pSvcLocator); - /** Algorithm destrucrtor*/ - ~MdtValidationAlg()=default; - /** Is called at the beginning of the analysis */ - StatusCode initialize(); - /** execute function NOTE: This will read all events at once*/ - StatusCode execute(); - /** finalize functions */ - StatusCode finalize(); - - void filltubeT0(); - void ValidateTubeT0 (const MdtTubeFitContainer::SingleTubeFit *fit, int & validflag); - - int CheckT0Parameters (const MdtTubeFitContainer::SingleTubeFit *fit); - int CheckRtParameters (std::vector<SamplePoint> & points, const RtFullInfo * full_info); - - void SummaryReport(int success); - //// void ValidateTubeT0AllTimes(bool something_done); - - StatusCode ValidateChamberT0(NtupleStationId & id); - - //// void ValidateChamberT0AllTimes(bool something_done); - - StatusCode ValidateRegionRt(const NtupleStationId & id); - const char* NameSelectedChamber(); - bool ReadLimitsFile(); - bool ComputeLimits(); - bool Histos(NtupleStationId & id, const std::vector<int> & validflags = std::vector<int>(0)); - bool RootFile(bool good_tubes=false); - - //============================================ - private: - // Methods - //======== - /** Calibration DataBase handling methods */ - StatusCode ConnectDb(); - - /** */ - double getLeftLimit(TH1F * histo); - double getRightLimit(TH1F * histo); - - //std::vector <MdtOracleTubeTable *> refinelist(std::vector <MdtOracleTubeTable *> tubelist); - -/** check if tube exists */ - inline bool exists(NtupleStationId & id, int ml, int ly, int tb); - - // Attributes - //=========== - - //! pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - - std::vector<MuonCalib::NtupleStationId> m_region_ids; - - MdtTubeFitContainer * m_tube_chamber; - - // helpers // - std::string m_MDT_ID_helper; // name of the MDT ID helper - - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - CalibDbConnection * m_db; - CalibT0DbOperations * m_t0_op; - CalibRtDbOperations * m_rt_op; - CalibHeadOperations * m_head_ops; - CalibDbConnection * m_data_connection; - int m_fitter; - bool m_writeToDbEnable ; - int m_limitslevel; - int m_makeHistos; - int m_lastdate; - std::string m_validationTask; - - std::string m_db_ConnectionString; - std::string m_writer_ConnectionString; - std::string m_db_WorkingSchema; - std::string m_defaultRtFile; - std::string m_reader_account, m_reader_password; - std::string m_writer_account, m_writer_password; - timeval m_t0,m_t1,m_result; - - - /** limits for T0 acceptance */ - double m_minSlope; - double m_maxSlope; - double m_minT0; - double m_maxT0; - double m_minTmax; - double m_maxTmax; - double m_minTtot; - double m_maxTtot; - double m_minPP; - double m_maxPP; - - /** limits for Rt acceptance */ - int m_minSegs; - double m_minDAngle; - - float m_summary[50] ; - std::string m_limitsFile ; - //! output file - TFile* m_Histos; - TList* m_HistosList; - - int m_headid,m_lowrun,m_uprun; - std::string m_sitename; - - bool m_ComputeLimits; - std::string m_chamber; - int m_debug; - int m_tube; - int m_eta; - int m_phi; - }; - -} -#endif diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/doc/README b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/doc/README deleted file mode 100755 index 68407845bd926f4a71a9b49de04e121d4fdb47ba..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/doc/README +++ /dev/null @@ -1,6 +0,0 @@ -Validation of Mdt calibration constants in ORACLE Calibration DBs -author T.Baroncelli - -customization: to run Test.exe -you should specify your DB, the schema name and the password in -authentication.xml and in test.cxx diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/exe/test.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/exe/test.cxx deleted file mode 100755 index 0b0e7aaa6d5611a57e432fbf046039d413101345..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/exe/test.cxx +++ /dev/null @@ -1,18 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -/** - * main program for the Validation - */ -#include "MdtCalibValidation/MdtT0ValidationHandler.h" - -int main() -{ - -// construct the default CalibrationManager - MdtT0ValidationHandler* ValHandl = new MdtT0ValidationHandler::MdtT0ValidationHandler; - ValHandl->initialize(); - ValHandl->execute(); - ValHandl->finalize(); - } diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/run/Validation.datacards b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/run/Validation.datacards deleted file mode 100755 index 0ed4ad4c8f4e4ca9ff2345a4b24a95004d2b1fb0..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/run/Validation.datacards +++ /dev/null @@ -1,12 +0,0 @@ -# Validation datacards for BIL -WriteToDbEnable 1 -Chamber BIL -LastDate 11533 -GetLimits 10 -makeHistos 1 -DebugLevel 2 -Phi 3 -Eta 4 -Layer 0 -MultiLayer 0 -Tube 0 diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/FixRtEnds.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/FixRtEnds.cxx deleted file mode 100644 index c751aae14c3c6c294891efcb24d7300ade52f3d4..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/FixRtEnds.cxx +++ /dev/null @@ -1,143 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibValidation/FixRtEnds.h" -#include "MuonCalibMath/SamplePoint.h" -#include "GaudiKernel/MsgStream.h" -#include "AthenaKernel/getMessageSvc.h" - -#include "TGraph.h" -#include "TF1.h" - -namespace MuonCalib { - -int FixRtEnds::FixEnds(std::vector<SamplePoint> & points) { -//check monotony - bool fix_begin, fix_end; - if(!checkMono(points, fix_begin, fix_end)) { - MsgStream log(Athena::getMessageSvc(),"FixRtEnds"); - log<<MSG::WARNING<<"Monotonic check failed!"<<endmsg; - return FIX_FAILED; - } - if(fix_begin || fix_end) { - TGraph *gr=new TGraph(points.size()); - for(unsigned int i=0; i<points.size(); i++) { - gr->SetPoint(i, points[i].x1(), points[i].x2()); - } - gr->Write("bevor_fix"); - } - if(!fix_begin && !fix_end) { - MsgStream log(Athena::getMessageSvc(),"FixRtEnds"); - log<<MSG::DEBUG<<"Rt relation is monotonic. Ok."<<endmsg; - return NO_FIX_NEEDED; - } - if(fix_begin) { - if(!fixBegin(points)) { - MsgStream log(Athena::getMessageSvc(),"FixRtEnds"); - log<<MSG::WARNING<<"Fix failed!"<<endmsg; - return FIX_FAILED; - } - } - if(fix_end) { - if(!fixEnd(points)) { - MsgStream log(Athena::getMessageSvc(),"FixRtEnds"); - log<<MSG::WARNING<<"Fix failed!"<<endmsg; - return FIX_FAILED; - } - } - TGraph *gr=new TGraph(points.size()); - for(unsigned int i=0; i<points.size(); i++) { - gr->SetPoint(i, points[i].x1(), points[i].x2()); - } - gr->Write("after_fix"); - if(!checkMono(points, fix_begin, fix_end)) { - MsgStream log(Athena::getMessageSvc(),"FixRtEnds"); - log<<MSG::WARNING<<"Monotonic check failed!"<<endmsg; - return FIX_FAILED; - } - if(fix_begin || fix_end) { - MsgStream log(Athena::getMessageSvc(),"FixRtEnds"); - log<<MSG::WARNING<<"Still not monotonic"<<endmsg; - return FIX_FAILED; - } - return FIX_APPLIED; -} - -bool FixRtEnds::checkMono(const std::vector<SamplePoint> & points, bool & fix_begin, bool & fix_end) const { - double last_r(-9e9); - fix_begin=false; fix_end=false; - for(std::vector<SamplePoint>::const_iterator it=points.begin(); it!=points.end(); it++) { - if(it->x2()<last_r) { - if(it->x2()<2.0) { - fix_begin=true; - } else if(it->x2()>13) { - fix_end=true; - } else { //cannot fic if it is in the middle - return false; - } - } - last_r= it->x2(); - } - return true; -} - -inline bool FixRtEnds::fixBegin(std::vector<SamplePoint> & points) { - std::vector<double> r(1, 0.0) ,t(1, 0.0); - int i_max(10000); - for(unsigned int i=0; i<points.size(); i++) { - if(points[i].x2()<2 && r.size()!=0) { - r.clear(); - r.push_back(0.0); - t.clear(); - t.push_back(0.0); - } - if(points[i].x2()>2 && points[i].x2() <4) { - t.push_back(points[i].x1()); - r.push_back(points[i].x2()); - } - if(points[i].x2()<4) i_max=i; - } - if(t.size()<4) return false; - TGraph *fit_gr=new TGraph(r.size()); - for(unsigned int i=0; i<r.size(); i++) { - fit_gr->SetPoint(i, t[i], r[i]); - } - fit_gr->Fit("pol2"); - fit_gr->Write("fix_begin"); - TF1 * fun=fit_gr->GetFunction("pol2"); - if(!fun) return false; - for(int i=0; i<=i_max; i++) { - points[i].set_x2(fun->Eval(points[i].x1())); - } - return true; -} - -inline bool FixRtEnds::fixEnd(std::vector<SamplePoint> & points) { - std::vector<double> r ,t; - int i_min(10000); - for(unsigned int i=0; i<points.size(); i++) { - if(points[i].x2()>12 && points[i].x2() <13) { - t.push_back(points[i].x1()); - r.push_back(points[i].x2()); - } - if(points[i].x2()>12 && i_min==10000) i_min=i; - } - t.push_back(points[points.size()-1].x1()); - r.push_back(14.6); - if(t.size()<4) return false; - TGraph *fit_gr=new TGraph(r.size()); - for(unsigned int i=0; i<r.size(); i++) { - fit_gr->SetPoint(i, t[i], r[i]); - } - fit_gr->Fit("pol2"); - fit_gr->Write("fix_end"); - TF1 * fun=fit_gr->GetFunction("pol2"); - if(!fun) return false; - for(unsigned int i=i_min; i<points.size(); i++) { - points[i].set_x2(fun->Eval(points[i].x1())); - } - return true; -} - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/MdtValidationAlg.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/MdtValidationAlg.cxx deleted file mode 100644 index 190bcfcdce108f1e29b0322983afcc66ef03c756..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/MdtValidationAlg.cxx +++ /dev/null @@ -1,671 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MdtCalibValidation/MdtValidationAlg.h" -#include "MdtCalibValidation/FixRtEnds.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibStl -#include "MuonCalibStl/ToString.h" - -//MuonCalibDbOperations -#include "MuonCalibDbOperations/CalibDbConnection.h" -#include "MuonCalibDbOperations/CalibRtDbOperations.h" -#include "MuonCalibDbOperations/CalibT0DbOperations.h" -#include "MuonCalibDbOperations/CalibHeadOperations.h" - -//MdtCalibData -#include "MdtCalibData/MdtTubeFitContainer.h" -#include "MdtCalibData/RtFullInfo.h" - -//MuonCalibMath -#include "MuonCalibMath/SamplePoint.h" - - -namespace MuonCalib { - -MdtValidationAlg::MdtValidationAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator), -p_reg_sel_svc(NULL), m_tube_chamber(NULL), m_db(NULL), m_t0_op(NULL), m_rt_op(NULL), m_head_ops(NULL), -m_fitter(1), m_writeToDbEnable(true), m_limitslevel(0), m_makeHistos(0), m_lastdate(0), -m_validationTask(""), m_db_ConnectionString(""),m_db_WorkingSchema(""),m_defaultRtFile("./RT_default_comm.dat"), -m_minSegs(-1), m_minDAngle(-999.), m_Histos(NULL), m_HistosList(NULL), -m_lowrun(-1), m_uprun(-1), m_ComputeLimits(false), m_debug(-1), m_tube(-1), m_eta(-1), m_phi(-1) -{ - declareProperty("FitterFlag",m_fitter); - declareProperty("WriteToDbEnable",m_writeToDbEnable); - declareProperty("GetLimits",m_limitslevel); - declareProperty("makeHistos",m_makeHistos); - declareProperty("LastDate",m_lastdate); - declareProperty("ConnectionString",m_db_ConnectionString); - declareProperty("WriterConnectionString",m_writer_ConnectionString); - declareProperty("WorkingSchema",m_db_WorkingSchema); - declareProperty("ValidationTask",m_validationTask); - declareProperty("defaulRtFile", m_defaultRtFile); - declareProperty("SiteName", m_sitename); - m_headid=-1; //take most recent header - declareProperty("HeadId", m_headid); - m_minSlope=-9e9; - declareProperty("MinSlope", m_minSlope); - m_maxSlope=9e9; - declareProperty("MaxSlope", m_maxSlope); - m_minT0=-9e9; - declareProperty("MinT0", m_minT0); - m_maxT0=9e9; - declareProperty("MaxT0", m_maxT0); - m_minTmax=-9e9; - declareProperty("MinTmax", m_minTmax); - m_maxTmax=9e9; - declareProperty("MaxTmax", m_maxTmax); - m_minTtot=-9e9; - declareProperty("MinTtot", m_minTtot); - m_maxTtot=9e9; - declareProperty("MaxTtot", m_maxTtot); - m_minPP=-9e9; - declareProperty("MinPP", m_minPP); - m_maxPP=-9e9; - declareProperty("MaxPP", m_maxPP); - m_db=NULL; - m_data_connection=NULL; - declareProperty("ReaderAccount", m_reader_account); - declareProperty("ReaderPassword", m_reader_password); - declareProperty("WriterAccount", m_writer_account); - declareProperty("WriterPassword", m_writer_password); - m_t0.tv_sec = 0; - m_t0.tv_usec = 0; - m_t1.tv_sec = 0; - m_t1.tv_usec = 0; - m_result.tv_sec = 0; - m_result.tv_usec = 0; -} - -StatusCode MdtValidationAlg::initialize() { - ATH_MSG_INFO("Thank you for using MdtValidationAlg!"); - - ATH_CHECK(m_idHelperSvc.retrieve()); - ATH_CHECK(m_DetectorManagerKey.initialize()); - ATH_CHECK(serviceLocator()->service("RegionSelectionSvc", p_reg_sel_svc)); - m_region_ids=p_reg_sel_svc->GetStationsInRegions(); - ATH_MSG_INFO(" MdtValidationAlg::initialize() - number of selected regions: "<<m_region_ids.size()); - gettimeofday(&m_t0,NULL); - - m_debug=0; -//db connection - StatusCode sc=ConnectDb(); - m_head_ops = new CalibHeadOperations(*m_db); - if(!sc.isSuccess()) return sc; -//get head id if not given - if(m_headid<0) { - m_headid=m_head_ops->GetLatestHeadId(); - if(m_headid<0) { - ATH_MSG_FATAL("Cannot get head_id for '"<<m_sitename<<"'!"); - return StatusCode::FAILURE; - } - } - m_data_connection=m_head_ops->GetDataConnection(m_headid, true, m_writer_ConnectionString, m_writer_account, m_writer_password); - if(m_data_connection==NULL) { - ATH_MSG_FATAL("Cannot get data connection!"); - return StatusCode::FAILURE; - } - m_data_connection->OpenConnection(); -//database opertations classes - m_t0_op=new CalibT0DbOperations(*m_data_connection); - m_rt_op=new CalibRtDbOperations(*m_data_connection); - - ATH_MSG_INFO("Validating for header="<<m_headid<<"/"<<m_sitename); - return StatusCode::SUCCESS; -} - -StatusCode MdtValidationAlg::execute() { - /** execute function */ - ATH_MSG_INFO(" MdtValidationAlg::execute "); - - m_ComputeLimits = 0; - if (m_limitslevel) m_ComputeLimits = 1; - - //loop on all the ids in the selected calibration region - for (std::vector<MuonCalib::NtupleStationId>::const_iterator it=m_region_ids.begin(); it!=m_region_ids.end(); it++) { - if(m_db==NULL) { - ATH_MSG_ERROR(" MdtValidationAlg::execute - no DB connection defined "); - return StatusCode::FAILURE; - } - m_Histos = TFile::Open(((*it).regionId() + ".root").c_str(), "recreate"); - - if(m_validationTask=="T0Val") { - /** Manage Limits file and output RootFile */ - m_chamber = it->regionId(); - m_eta = it->GetEta(); - m_phi = it->GetPhi(); - - RootFile(); - - ATH_MSG_INFO("Reading t0s for region " << it->regionId() <<""); - - m_tube_chamber = m_t0_op->LoadT0Validation(*it, m_headid, m_sitename); - if(m_tube_chamber==NULL) { - ATH_MSG_FATAL("Cannot load t0s for "<<(*it).regionId()); - m_Histos->Close(); - return StatusCode::FAILURE; - } - ATH_MSG_INFO("Validating "<<m_tube_chamber->numMultilayers() * m_tube_chamber-> numLayers() * m_tube_chamber->numTubes() <<" tubes."); - // end reading t0s // - - NtupleStationId id(*it); - Histos(id); - -// T0 Validation limits can be set in MuonCalibJobTransforms/share/skeleton.mdt_calib_validate.py, -// computed from measurements, or read from a limits file - if(m_ComputeLimits) { - ComputeLimits(); - // keep default limits - } - ATH_CHECK(ValidateChamberT0(id)); - int success = -1; - if (m_debug >0) SummaryReport(success); - - m_HistosList->Write(); - delete m_HistosList; - - } else if (m_validationTask=="RtVal"){ - m_minSegs = 1000; - m_minDAngle = 0.0; - ATH_CHECK(ValidateRegionRt(*it)); - - } else { - ATH_MSG_ERROR(" No ValidationTask selected"); - return StatusCode::FAILURE; - } - m_Histos->Close(); - } - return StatusCode::SUCCESS; -} - -StatusCode MdtValidationAlg::finalize() { - /** finalize function */ - ATH_MSG_INFO(" MdtValidationAlg::finalize "); - - gettimeofday(&m_t1,NULL); - timersub(&m_t1,&m_t0,&m_result); - ATH_MSG_INFO("ValidationAlg execution time= "<<m_result.tv_sec+m_result.tv_usec*0.000001<<" seconds"); - - return StatusCode::SUCCESS; -} - -StatusCode MdtValidationAlg::ConnectDb() { - ATH_MSG_INFO("Connecting to "<<m_db_ConnectionString<<" "<<m_db_WorkingSchema); - m_db=new CalibDbConnection(m_db_ConnectionString, m_db_WorkingSchema); - m_db->SetLogin(m_reader_account, m_reader_password); - if(!m_db->OpenConnection()) { - return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; -} - -bool MdtValidationAlg::RootFile(bool good_tubes) { - if(!good_tubes) m_HistosList = new TList(); - TH1F *hslope; - TH1F *ht0; - TH1F *htmax; - TH1F *httot; - TH1F *hsummary; - if(good_tubes) { - hslope = new TH1F("hslope_gd","slope parameter", 90, m_minSlope, m_maxSlope); - ht0 = new TH1F("ht0_gd","T0",800,m_minT0,m_maxT0); - htmax = new TH1F("htmax_gd", "Tmax", 800, m_minTmax, m_maxTmax); - httot = new TH1F("httot_gd", "Total Drift Length", 300, m_minTtot, m_maxTtot); - hsummary = new TH1F("hsummary_gd", "Summary", 50, -0.5, 49.5); - } else { - hslope = new TH1F("hslope","slope parameter", 90, m_minSlope, m_maxSlope); - ht0 = new TH1F("ht0","T0",800,m_minT0,m_maxT0); - htmax = new TH1F("htmax", "Tmax", 800, m_minTmax, m_maxTmax); - httot = new TH1F("httot", "Total Drift Length", 300, m_minTtot, m_maxTtot); - hsummary = new TH1F("hsummary", "Summary", 50, -0.5, 49.5); - } - m_HistosList->Add(hslope) ; - m_HistosList->Add(ht0) ; - m_HistosList->Add(htmax) ; - m_HistosList->Add(httot) ; - m_HistosList->Add(hsummary); - return true; -} - -// Read T0, Tmax, T0slope limits from a file. -// NOT USED (commented out above) -bool MdtValidationAlg::ReadLimitsFile() { - ToString ts; - std::string prefix="Limits_" ; - std::string suffix= ".dat" ; - std::string chambName(m_chamber) ; - std::string middle("_"+ts(m_phi)+"_"+ts(m_eta)) ; - std::string limitsfile(prefix+chambName+middle+suffix) ; - m_limitsFile = limitsfile ; - - std::ifstream LimitsFile(m_limitsFile.c_str()); - - if (LimitsFile) { - char option[20]; - char chComm[] = "#"; - std::string c; - - while( LimitsFile >> option) { - ATH_MSG_INFO(" while while .... "); - while (strncmp(option,chComm,1)==0) { - ATH_MSG_INFO(" ignore .... "); - LimitsFile.ignore(500,'\n'); - LimitsFile>>option; - } - if (strncmp(option,"SLOPE",5)==0 ) { - LimitsFile >> m_minSlope; - LimitsFile >> m_maxSlope; - ATH_MSG_INFO("Slope Limits : " <<m_minSlope << " -- " << m_maxSlope); - } - if (strncmp(option,"T0",2)==0 ) { - LimitsFile >> m_minT0; - LimitsFile >> m_maxT0; - ATH_MSG_INFO("T0 Limits : " << m_minT0 << " -- "<< m_maxT0); - } - if (strncmp(option,"TMAX",4)==0 ) { - LimitsFile >> m_minTmax; - LimitsFile >> m_maxTmax; - ATH_MSG_INFO("TMax Limits : "<< m_minTmax << " -- " << m_maxTmax); - } - if (strncmp(option,"TTOT",4)==0 ) { - LimitsFile >> m_minTtot; - LimitsFile >> m_maxTtot; - ATH_MSG_INFO("TTot Limits : "<<m_minTtot<<" -- "<< m_maxTtot); - } - if (strncmp(option,"PP",2)==0 ) { - LimitsFile >> m_minPP; - LimitsFile >> m_maxPP; - ATH_MSG_INFO("Peak / Plateau Limits : "<<m_minPP<<" -- "<< m_maxPP); - } - } - LimitsFile.close(); - ATH_MSG_INFO("LimitsFile closed : "); - return true; - } - return false; -} - -bool MdtValidationAlg::ComputeLimits() { - - MsgStream log(msgSvc(), name()); - - //TH1F * hchamber = (TH1F *) m_HistosList->FindObject("hchamber") ; - TH1F * ht0 = (TH1F *) m_HistosList->FindObject("ht0") ; - TH1F * hslope = (TH1F *) m_HistosList->FindObject("hslope") ; - TH1F * htmax = (TH1F *) m_HistosList->FindObject("htmax") ; - TH1F * httot = (TH1F *) m_HistosList->FindObject("httot") ; - - if (m_limitslevel == 10 ) { - - /* - m_summary[20] = hslope->GetMean() ; - m_summary[21] = hslope->GetRMS() ; - - m_summary[20] = hslope->GetMean() ; - m_summary[21] = hslope->GetRMS() ; - m_summary[22] = ht0->GetMean() ; - m_summary[23] = ht0->GetRMS() ; - m_summary[24] = htmax->GetMean() ; - m_summary[25] = htmax->GetRMS() ; - m_summary[26] = httot->GetMean() ; - m_summary[27] = httot->GetRMS() ; - */ - m_minSlope = hslope->GetMean() - 3.*hslope->GetRMS(); - m_maxSlope = hslope->GetMean() + 3.*hslope->GetRMS(); - m_minT0 = ht0->GetMean() - 3.*ht0->GetRMS(); - m_maxT0 = ht0->GetMean() + 3.*ht0->GetRMS(); - m_minTmax = htmax->GetMean() - 3.*htmax->GetRMS(); - m_maxTmax = htmax->GetMean() + 3.*htmax->GetRMS(); - m_minTtot = httot->GetMean() - 3.*httot->GetRMS(); - m_maxTtot = httot->GetMean() + 3.*httot->GetRMS(); - } - - if (m_limitslevel>0 && m_limitslevel<10 ) { - m_minSlope = getLeftLimit(hslope); - m_maxSlope = getRightLimit(hslope); - m_minTmax = getLeftLimit(htmax); - m_maxTmax = getRightLimit(htmax); - m_minTtot = getLeftLimit(httot); - m_maxTtot = getRightLimit(httot); - m_minT0 = getLeftLimit(ht0); - m_maxT0 = getRightLimit(ht0); - } - m_minPP = 0. ; - m_maxPP = 10000. ; - - log<<MSG::INFO<<"slope min/max "<<m_minSlope<<"/"<<m_maxSlope<<" Tmax min/max "<<m_minTmax <<"/"<<m_maxTmax<<" Ttot min/max "<<m_minTtot<<"/"<<m_maxTtot<<" T0 min/max "<<m_minT0<<"/"<<m_maxT0<<endmsg; - - return true; -} - -bool MdtValidationAlg::Histos(NtupleStationId & id, const std::vector<int> & validflags){ - //TH1F * hchamber = (TH1F *) m_HistosList->FindObject("hchamber") ; - TH1F *ht0; - TH1F *hslope; - TH1F *htmax; - TH1F *httot; - if(validflags.size()==0) { - ht0 = (TH1F *) m_HistosList->FindObject("ht0"); - hslope = (TH1F *) m_HistosList->FindObject("hslope"); - htmax = (TH1F *) m_HistosList->FindObject("htmax"); - httot = (TH1F *) m_HistosList->FindObject("httot"); - } else { - ht0 = (TH1F *) m_HistosList->FindObject("ht0_gd"); - hslope = (TH1F *) m_HistosList->FindObject("hslope_gd"); - htmax = (TH1F *) m_HistosList->FindObject("htmax_gd"); - httot = (TH1F *) m_HistosList->FindObject("httot_gd"); - } - - unsigned int count(0); - for(unsigned int ml=0; ml<m_tube_chamber->numMultilayers(); ml++) { - for(int ly=0; ly<static_cast<int>(m_tube_chamber->numLayers()); ly++) { - for(int tb=0; tb<static_cast<int>(m_tube_chamber->numTubes()); tb++) { -//check if tube really exists - if (!exists(id, ml, ly, tb)) continue; - count++; - if(count-1 < validflags.size()) { - if(validflags[count-1] != 3) continue; - } - ht0->Fill(m_tube_chamber->getFit(ml, ly, tb)->par[4]); - hslope->Fill(m_tube_chamber->getFit(ml, ly, tb)->par[6]); - htmax->Fill(m_tube_chamber->getFit(ml, ly, tb)->par[5]); - httot->Fill(m_tube_chamber->getFit(ml, ly, tb)->par[5]-m_tube_chamber->getFit(ml, ly, tb)->par[4]); - } //end loop over tubes - } //end loop over layers - } //end loop over ML - - return true; -} - -///////////////////////////////////////////////////////////////////////////// -StatusCode MdtValidationAlg::ValidateChamberT0(NtupleStationId & id) { - MsgStream log(msgSvc(), name()); - log<<MSG::INFO<<"Entering ValidateChamberT0" <<endmsg; - std::vector<int> validflags; - int validflag; - bool all_ok(true); - - for(unsigned int ml=0; ml<m_tube_chamber->numMultilayers(); ml++) { - for(unsigned int ly=0; ly<m_tube_chamber->numLayers(); ly++) { - for(unsigned int tb=0; tb<m_tube_chamber->numTubes(); tb++) { - if(!exists(id, ml, ly, tb)) { //check for dummy tubes - log<<MSG::INFO<< " tube ("<<ml+1<<","<<ly+1<<","<<tb+1<<") is a dummy tube!"<<endmsg; - validflags.push_back(5); - } else { - ValidateTubeT0(m_tube_chamber->getFit(ml, ly, tb), validflag); - validflags.push_back(validflag); - if(validflag !=3) { - all_ok = false; - } - } - } //end loop over tubes - } //end loop over layers - } //end loop over ML - if(!all_ok) { -//fill new histograms with good tubes only - RootFile(true); - Histos(id, validflags); - int count(0); - //for failed tubes set mean values - for(unsigned int ml=0; ml<m_tube_chamber->numMultilayers(); ml++) { - for(unsigned int ly=0; ly<m_tube_chamber->numLayers(); ly++) { - for(unsigned int tb=0; tb<m_tube_chamber->numTubes(); tb++) { - if(validflags[count]!=3 && validflags[count]!=5) { - TH1F * ht0 = (TH1F *) m_HistosList->FindObject("ht0_gd"); - TH1F * hslope = (TH1F *) m_HistosList->FindObject("hslope_gd"); - TH1F * htmax = (TH1F *) m_HistosList->FindObject("htmax_gd"); - m_tube_chamber->getFit(ml, ly, tb)->par[4]=ht0->GetMean(); - m_tube_chamber->getFit(ml, ly, tb)->par[5]=htmax->GetMean(); - m_tube_chamber->getFit(ml, ly, tb)->par[6]=hslope->GetMean(); - m_tube_chamber->getCalib(ml, ly, tb)->t0=ht0->GetMean(); - m_tube_chamber->getFit(ml, ly, tb)->group_by="VAL_FIX"; - log<<MSG::INFO<< " tube ("<<ml+1<<","<<ly+1<<","<<tb+1<<") validated with flag = "<<validflag<<endmsg; - } - count++; - } //end loop over tubes - } //end loop over layers - } //end loop over ML - } - for(std::vector<int>::iterator it=validflags.begin(); it!=validflags.end(); it++) { - ATH_MSG_INFO(*it<<" "); - } - if( m_writeToDbEnable ) { - if(!m_t0_op->WriteT0Chamber(id, m_tube_chamber, validflags, m_headid, m_sitename)) { - log<<MSG::FATAL<<" Cannot write Chamber!"<<endmsg; - return StatusCode::FAILURE; - } - } - return StatusCode::SUCCESS; -} - -///////////////////////////////////////////////////////////////////////////// -void MdtValidationAlg::ValidateTubeT0 (const MdtTubeFitContainer::SingleTubeFit *fit, int &validflag) { -///////////////////////////////////////////////////////////////////////////// - - MsgStream log(msgSvc(), name()); - log<<MSG::INFO<<"Entering ValidateTubeT0" <<endmsg; - - int T0flag = CheckT0Parameters(fit); - - if (T0flag) { - validflag=3; - } else { - validflag=4; - } -} - -///////////////////////////////////////////////////////////////////////////// -int MdtValidationAlg::CheckT0Parameters (const MdtTubeFitContainer::SingleTubeFit *fit) { -///////////////////////////////////////////////////////////////////////////// - MsgStream log(msgSvc(), name()); - log<<MSG::INFO<<"Entering CheckT0Parameters" <<endmsg; - - double t0 = fit->par[4]; - double slope = fit->par[6]; - double tmax = fit->par[5]; - double ttot = tmax-t0; - - bool bsl = (slope >= m_minSlope && slope <= m_maxSlope ); - bool bt0 = (t0 >= m_minT0 && t0 <= m_maxT0); - bool btmax = (tmax >= m_minTmax && tmax <= m_maxTmax); - bool btt = (ttot >= m_minTtot && ttot <= m_maxTtot); -// bool bPP = true ; //what is this? get rid if it below - - int T0flag = 0; - if (bsl && bt0 && btmax && btt ) {T0flag=1;} - - log<<MSG::INFO<<"Result of CheckT0Parameters: T0flag=" << T0flag <<" (T0flag=0 fail, =1 ok) T0_Limits="<<bt0<<" Slope_Limits="<<bsl<<" Tmax_Limits="<<btmax<<" Total_Drifttime_Limits="<<btt <<endmsg; - - return T0flag; -} - - -///////////////////////////////////////////////////////////////////////////// -StatusCode MdtValidationAlg::ValidateRegionRt(const NtupleStationId & id) { -///////////////////////////////////////////////////////////////////////////// - MsgStream log(msgSvc(), name()); - log<<MSG::INFO<< " Entering ValidateRegionRt" <<endmsg; - - RtFullInfo full_info; - std::vector<SamplePoint> points_in; - - if(!m_rt_op->LoadRt(id, m_headid, false, m_sitename, points_in, &full_info)) { - log<<MSG::FATAL<<"Cannot read chamber!"<<endmsg; - return StatusCode::FAILURE; - } - std::vector<SamplePoint> points; - for(std::vector<SamplePoint>::const_iterator it=points_in.begin(); it!=points_in.end(); it++) { - if(it->x2()>-99.) points.push_back(*it); - } - /** any logic for rt validation!!!!!!!! */ - int good1=CheckRtParameters(points, &full_info); -//if rt relation is good - if (good1==1) { - if(m_writeToDbEnable) { - if(!m_rt_op->SetValidflag(3)) { - log<<MSG::FATAL<<"Cannot set validflag for rt!"<<endmsg; - return StatusCode::FAILURE; - } - } -//rt is bad or has been fixed - } else { - //load default rt - int v_flag=5; - if(good1==0) { - //open file - std::ifstream infile(m_defaultRtFile.c_str()); - if(infile.fail()) { - log << MSG::ERROR << "Cannot open file '" << m_defaultRtFile << "' for reading!" << endmsg; - return StatusCode::FAILURE; - } - //sample points - float t,r,s; - std::string sdummy; - float dummy(0); - points.clear(); - //ignore the first line - getline(infile, sdummy); - //read table - while (!(infile.eof() || infile.fail())) { - infile >> r; - if (infile.eof() || infile.fail() || dummy > 15.0) break; - infile >> t; - infile >> s; - SamplePoint p(t,r,s); - points.push_back(p); - } - v_flag=4; - } - if(m_writeToDbEnable) { - if(!m_rt_op->SetValidflag(1, false)) { - log << MSG::FATAL << "Cannot set validflag!"<<endmsg; - return StatusCode::FAILURE; - } - full_info.setImplementation("Validation"); - if(!m_rt_op->WriteUpdateRt(id, m_headid, m_sitename, points, v_flag, &full_info)) { - log << MSG::FATAL << "Cannot write rt-relation!"<<endmsg; - return StatusCode::FAILURE; - } - } - } - return StatusCode::SUCCESS; -} - -///////////////////////////////////////////////////////////////////////////// -int MdtValidationAlg::CheckRtParameters (std::vector<SamplePoint> & points, const RtFullInfo * full_info) { -///////////////////////////////////////////////////////////////////////////// - - MsgStream log(msgSvc(), name()); - log<<MSG::INFO<<"Entering CheckRtParameters" <<endmsg; - - double nsegs = full_info->numSeg(); - double aveangle = full_info->rmsAng(); - - bool bseg = ( nsegs >= m_minSegs ); - bool baveangle = ( aveangle >= m_minDAngle ); - - int RTflag = 0; - if (bseg && baveangle ) {RTflag=1;} - - log<<MSG::INFO<<"Result of CheckRtParameters is: RTflag=" << RTflag <<" (RTflag=0 fail, =1 ok) Number_Segments_Check="<<bseg<<" Ave_Angle_Check="<<baveangle<<endmsg; - - if(RTflag==0) { - return 0; - } - - FixRtEnds fix_end; - int ret=fix_end.FixEnds(points); - log<<MSG::INFO<<"Fix End points returned "<<ret<<endmsg; - switch(ret) { - case FixRtEnds::NO_FIX_NEEDED: - return 1; - break; - case FixRtEnds::FIX_APPLIED: - return 2; - break; - case FixRtEnds::FIX_FAILED: - return 0; - } - return RTflag; -} - -///////////////////////////////////////////////////////////////////////////// -void MdtValidationAlg::SummaryReport(int success) { -///////////////////////////////////////////////////////////////////////////// - ATH_MSG_INFO("======================Validation Summary Report =================="); - ATH_MSG_INFO(" Success in saving Calibration data is "<<success<<" (0=fail, 1=ok), chamber is " <<m_chamber); -} - -double MdtValidationAlg::getLeftLimit(TH1F * histo) { - int ibin; - double left_integral; - double left_limit=0; - double histoIntegral = histo->Integral(); - int nbins = histo->GetNbinsX(); - - double r_limit = .03; - if (m_limitslevel==2){r_limit = .05;} - if (m_limitslevel==3){r_limit = .1;} - - for(ibin=1;ibin<nbins;ibin++) { - left_integral = histo->Integral(1,ibin); - left_limit = histo->GetBinCenter(ibin); - double r = left_integral/histoIntegral; - if(r>r_limit) break; - } - - return left_limit ; -} - -double MdtValidationAlg::getRightLimit(TH1F * histo) { - int ibin; - double right_integral; - double right_limit=0; - double histoIntegral = histo->Integral(); - int nbins = histo->GetNbinsX(); - - double r_limit = .03; - if (m_limitslevel==2){r_limit = .05;} - if (m_limitslevel==3){r_limit = .1;} - for(ibin=nbins;ibin>0;ibin--) { - right_integral = histo->Integral(ibin,nbins); - right_limit = histo->GetBinCenter(ibin); - double r = right_integral/histoIntegral; - if(r>r_limit) break; - } - return right_limit ; -} - -// Check if tube is a real or dummy tube (inserted as placeholder in COOL text blob) -inline bool MdtValidationAlg::exists(NtupleStationId &id, int ml, int ly, int tb) { - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return false; - } - - if(!id.InitializeGeometry(m_idHelperSvc->mdtIdHelper(), MuonDetMgr)) { - return false; - } - if(ml+1>id.NMultilayers()) { - ATH_MSG_INFO(ml+1<<" "<<id.NMultilayers()); - return false; - } - if(ly+1>id.NLayers(ml)) { - ATH_MSG_INFO(ly+1<<" "<<id.NLayers(ml+1)); - return false; - } - if(tb+1>id.NTubes(ml)) { - ATH_MSG_INFO(tb+1<<" "<<id.NTubes(ml+1)); - return false; - } - return true; -} - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/components/MdtValidationAlg_entries.cxx b/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/components/MdtValidationAlg_entries.cxx deleted file mode 100644 index 1bc8abee6dbb1346c65d5826c2eeccf752db602a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation/src/components/MdtValidationAlg_entries.cxx +++ /dev/null @@ -1,3 +0,0 @@ -#include "MdtCalibValidation/MdtValidationAlg.h" - -DECLARE_COMPONENT( MuonCalib::MdtValidationAlg ) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/CMakeLists.txt deleted file mode 100644 index 18fe1fb75e029ba20365a2f0d3edab3d344b9f77..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -################################################################################ -# Package: MuonCalibAlgs -################################################################################ - -# Declare the package name: -atlas_subdir( MuonCalibAlgs ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - GaudiKernel - MuonSpectrometer/MuonCalib/MuonCalibEventBase - MuonSpectrometer/MuonCnv/MuonPrdSelector - PRIVATE - Control/StoreGate - DetectorDescription/GeoPrimitives - Event/EventInfo - Event/xAOD/xAODEventInfo - Generators/GeneratorObjects - LArCalorimeter/LArRecEvent - MuonSpectrometer/MuonCalib/MuonCalibEvent - MuonSpectrometer/MuonCalib/MuonCalibITools - MuonSpectrometer/MuonCalib/MuonCalibIdentifier - MuonSpectrometer/MuonCalib/MuonCalibNtuple - MuonSpectrometer/MuonCalib/MuonCalibUtils/MuonCalibStl - MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry - MuonSpectrometer/MuonDigitContainer - MuonSpectrometer/MuonIdHelpers - MuonSpectrometer/MuonRDO - MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization - MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData - MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData - MuonSpectrometer/MuonSimData - Simulation/G4Sim/TrackRecord - TileCalorimeter/TileEvent - TileCalorimeter/TileIdentifier - Tracking/TrkEvent/TrkEventPrimitives - Trigger/TrigT1/TrigT1Result - Generators/AtlasHepMC ) - -# External dependencies: -find_package( CLHEP ) -find_package( Eigen ) - -# Component(s) in the package: -atlas_add_library( MuonCalibAlgsLib - src/*.cxx - PUBLIC_HEADERS MuonCalibAlgs - PRIVATE_INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES AthenaBaseComps GaudiKernel MuonCalibEventBase StoreGateLib SGtests MuonIdHelpersLib CscClusterizationLib MuonPrdSelectorLib - PRIVATE_LINK_LIBRARIES ${CLHEP_LIBRARIES} AtlasHepMCLib ${EIGEN_LIBRARIES} GeoPrimitives EventInfo xAODEventInfo GeneratorObjects LArRecEvent MuonCalibEvent MuonCalibITools MuonCalibIdentifier MuonCalibNtuple MuonReadoutGeometry MuonDigitContainer MuonRDO MuonPrepRawData MuonTrigCoinData MuonSimData TileEvent TileIdentifier TrkEventPrimitives TrigT1Result TrackRecordLib ) - -atlas_add_component( MuonCalibAlgs - src/components/*.cxx - INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AtlasHepMCLib ${EIGEN_LIBRARIES} AthenaBaseComps GaudiKernel MuonCalibEventBase StoreGateLib SGtests GeoPrimitives EventInfo xAODEventInfo GeneratorObjects LArRecEvent MuonCalibEvent MuonCalibITools MuonCalibIdentifier MuonCalibNtuple MuonReadoutGeometry MuonDigitContainer MuonIdHelpersLib MuonRDO CscClusterizationLib MuonPrepRawData MuonTrigCoinData MuonSimData TileEvent TileIdentifier TrkEventPrimitives TrigT1Result MuonCalibAlgsLib ) - -# Install files from the package: -atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) -atlas_install_joboptions( share/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} --extend-ignore=F401,F821 ) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/MuonCalibAlgs/MuonCalibAlg.h b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/MuonCalibAlgs/MuonCalibAlg.h deleted file mode 100644 index c0e890f6a8e5724e9863c97a5e06d8376f93e556..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/MuonCalibAlgs/MuonCalibAlg.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MUONCALIB_MUONCALIBALG_H -#define MUONCALIB_MUONCALIBALG_H - -#include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ServiceHandle.h" - -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonPrdSelector/MuonIdCutTool.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "CscClusterization/ICscStripFitter.h" -#include "MuonCalibITools/IMuonCalibTool.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" - -class TileTBID; - -namespace Muon { - class RpcPrepData; -} - -namespace MuonCalib { - - class MuonCalibEventInfo; - class MuonCalibTriggerTimeInfo; - class MuonCalibTruthCollection; - class MuonCalibRawHitCollection; - class MuonCalibRawTriggerHitCollection; - class MuonCalibRawRpcHit; - - /** - @class MuonCalibAlg - ATHENA Algorithm retrieving the ingredients for a MuonCalibEvent from storegate and passing them to a calibration tool. - - @author Niels.Van.Eldik@cern.ch, Zdenko.Van.Kesteren@cern.ch - */ - class MuonCalibAlg : public AthAlgorithm { - public: - /** - Algorithm constructor declaring all properties and opening a ROOT file - */ - MuonCalibAlg(const std::string& name, ISvcLocator* pSvcLocator); - - /** - Algorithm destructor (closing the ROOT file) - */ - ~MuonCalibAlg()=default; - - /** - Algorithm initialize: - - retrieves MuonCalibTool - - retrieves auxillairy classes to construct Calib EDM classes (IdHelpers, IdToFixedIdTool) - - */ - StatusCode initialize(); - - /** Algorithm execute, called once per event. It performs the following tasks: - - retrieve MuonCalibEvent - - feeds MuonCalibEvent to chosen MuonCalibTool - */ - StatusCode execute(); - - /** Algorithm finalize - Calls finalize routine of the MuonCalibTool - */ - StatusCode finalize(); - - private: - /** create a MuonCalibRawRpcHit from a RpcPrepData */ - MuonCalibRawRpcHit* createRawRpcHit( const Muon::RpcPrepData& prd ) const; - - /** retrieve patterns, truth, eventinfo and raw hits and store in MuonCalibEvent */ - const MuonCalibEvent* retrieveEvent() const; - - /** retrieve PrepRawData of all technologies, convert them to MuonCalibRawXxxHits and store them on MuonCalibRawHitCollection */ - const MuonCalibRawHitCollection* retrieveRawHits( const MuonCalibEvent::MCPVec &patterns ) const; - - /** retrieve RawTriggerData convert them to MuonCalibRawTriggerXxxHits and store them on MuonCalibRawTriggerHitCollection */ - const MuonCalibRawTriggerHitCollection* retrieveRawTriggerHits() const; - - /** retrieve patterns and segments from storegate */ - const MuonCalibEvent::MCPVec retrievePatterns() const; - - /** retrieve truth information from storegate and convert to MuonCalibTruthCollection */ - const MuonCalibTruthCollection* retrieveTruthCollection() const; - - /** retrieve event information from storegate and convert to MuonCalibEventInfo */ - MuonCalibEventInfo retrieveEventInfo() const; - - /** retrieve event trigger time information from storegate and convert to MuonCalibTriggerTimeInfo */ - const MuonCalibTriggerTimeInfo* retrieveTriggerTimeInfo() const; - - /** retrieve MuonDetectorManager from the conditions store */ - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - std::string m_globalPatternLocation; //!< Location of the MuonCalibPattern in StoreGate - - /* RtCalibration initialization */ - ToolHandle<MuonCalib::IMuonCalibTool> m_muonCalibTool; //!< pointer to RtCalibrationCreator - unsigned int m_eventNumber; //!< counter keeping track of the event - std::string m_eventTag; //!< tag of the event, describing reconstruction mechanism - std::string m_ntupleName; //!< name of the ntuple - - /* IdentifierTool initialization */ - ToolHandle<IIdToFixedIdTool> m_idToFixedIdTool; //!< pointer to IdToFixedIdtool - - // Strip fitter to fit - // time samples and extract strip charge - ToolHandle<ICscStripFitter> m_stripFitter; - - // Tool to cut on identifiers - ToolHandle<IMuonIdCutTool> m_muonIdCutTool; - - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - std::vector <const MuonCalibEvent*> m_events; //!< vector holding pointers to events, for deletion at finalize - - bool m_doTruth; //!< property toggeling if truth info is stored on ntuple - bool m_doTruthMuonOnly; //!< property toggeling to store ONLY muon truth data on ntuple for cavern background - bool m_doRawData ; //!< property toggeling if raw hits are stored on ntuple - bool m_doDeleteEvent; //!< property toggling if event deleted at execute or at finalize, false = delete at finalize (default) - bool m_createRootFile; //!< property toggeling if the ntuple is created - bool m_addTriggerTag; //!< property toggling if the Trigger type should be added to the EventTag - bool m_mdt_tdc_cut; //!< property toggling if a tdc cut should be applied for MDT data - mutable bool m_trigger_waning_printed; - mutable bool m_lar_waning_printed; - mutable bool m_mbts_warning_printed; - bool m_doPrdSelect; //!< property turning on cuts on truth hits if the global flag doPrdSelect = True - bool m_doMDTs; //!< Process MDTs or not - bool m_doCSCs; //!< Process CSCs or not - bool m_doRPCs; //!< Process RPCs or not - bool m_doTGCs; //!< Process TGCs or not - bool m_doRPCCoin; //!< Process Coin RPCs or not - bool m_doTGCCoin; //!< Process Coin TGCs or not - bool m_doRpcSectorLogic; //!< Process rpc sector logic - bool m_doRPCTriggerHits; //!< Process rpc trigger hit info - float m_mbts_threshold; //!< MBTS threshold - const TileTBID* m_tileTBID; //!< TileTBID - bool m_ntupFileOpen; - }; - -} - -#endif - - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/doc/Doxyfile b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/doc/Doxyfile deleted file mode 100644 index 7da36d2e9833458ca748c877d924a42a7df93b50..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/doc/Doxyfile +++ /dev/null @@ -1,215 +0,0 @@ -# Doxyfile 1.3.9.1 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = MuonCalibAlgs -PROJECT_NUMBER = MuonCalibAlgs-01-01-21 -OUTPUT_DIRECTORY = /afs/cern.ch/user/z/zvankest/project/documentation/InstallArea/doc/MuonCalibAlgs -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = YES -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -SUBGROUPING = YES -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = NO -SORT_BRIEF_DOCS = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_DIRECTORIES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = ../src ../MuonCalibAlgs ../doc ../share -FILE_PATTERNS = *.cxx *.h *.py *.xml *.mk -RECURSIVE = YES -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = ../doc ../cmt ../share -EXAMPLE_PATTERNS = *.cxx *.html requirements *.py -EXAMPLE_RECURSIVE = YES -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = YES -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -VERBATIM_HEADERS = NO -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = YES -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = /afs/cern.ch/user/z/zvankest/project/documentation/InstallArea/doc/MuonCalibEventBase.tag /afs/cern.ch/user/z/zvankest/project/documentation/InstallArea/doc/MuonCalibEvent.tag -GENERATE_TAGFILE = /afs/cern.ch/user/z/zvankest/project/documentation/InstallArea/doc/MuonCalibAlgs.tag -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -UML_LOOK = YES -TEMPLATE_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DOT_IMAGE_FORMAT = gif -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 0 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/doc/packagedoc.h b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/doc/packagedoc.h deleted file mode 100644 index 413586cb30bb3280986fcc424452c82ef63e1c33..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/doc/packagedoc.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** - -@page MuonCalibAlgs_page MuonCalibAlgs Package -@author Niels.Van.Eldik@cern.ch - -@section MuonCalibAlgs_MuonCalibAlgsIntro Introduction -This package contains the ATHENA algorithms that are common for all muon -technologies. - -@section MuonCalibAlgs_MuonCalibAlgsOverview Class Overview -The MuonCalibAlgs package contains the following class - -- MuonCalib::MuonCalibAlg: ATHENA Algorithm retrieving the 'ingredients' to construct a MuonCalibEvent from storegate and passing them to a calibration tool. See the MuonCalibEvent class description for the content of a MuonCalibEvent. - - - -*/ diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/python/MuonCalib.py b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/python/MuonCalib.py deleted file mode 100644 index e0c0a09980d95d4ca454e9a16c877547a59cb469..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/python/MuonCalib.py +++ /dev/null @@ -1,230 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from __future__ import print_function - -from AthenaCommon.AlgSequence import AlgSequence -from AthenaCommon.Logging import logging -# flags -from MuonCnvExample.MuonCalibFlags import muonCalibFlags -from MuonRecExample.MuonRecFlags import muonRecFlags -from RecExConfig.RecFlags import rec as recFlags -from AthenaCommon.BeamFlags import jobproperties -beamFlags = jobproperties.Beam - -import os - -log = logging.getLogger("MuonCalib") - -muonCalibFlags.setDefaults() - -topSequence = AlgSequence() - -MuonSegmentToCalibSegment = None -MuonCalibAlg = None -MuonCalibTool = None -MdtCalibTool = None -MuonCalibExtraTreeAlg = None - - -class MuonCalibConfig: - """Configuration object holding the info of the MuonCalibration inputs and outputs""" - __slots__ = ( 'eventTag', 'segmentsKey', 'segmentCombisKey', 'doPhi', 'doTracks', - 'patternsKey', 'tracksKey' ) - def __init__(self,**kwargs): - for n,v in kwargs.items(): - setattr(self,n,v) - - def __str__(self): - """Print the attributes that have been set. One per line""" - lines = [] - for n in self.__slots__: - try: - v = getattr(self,n) - lines.append( "%s=%r" % (n,v) ) - except AttributeError: - pass - return os.linesep.join(lines) - -# end of class MuonCalibConfig - -# -# A list of standard configurations -# -MoMuConfig = MuonCalibConfig( - eventTag = "MoMu", - segmentCombisKey = "MdtSegmentCombinations", - doPhi = True, - doTracks = True, - patternsKey = "MuonHoughPatternCombinations", - tracksKey = "MooreTracks" ) - -MooreConfig = MuonCalibConfig( - eventTag = "Moore", - segmentsKey = "MooreSegments_", - doPhi = True, - doTracks = True, - patternsKey = "phi_patterns_", - tracksKey = "ConvertedMooreTracks" ) - -MuonboyConfig = MuonCalibConfig( - eventTag = "Muonboy", - segmentsKey = "ConvertedMBoySegments", - doPhi = False, - doTracks = True, - patternsKey = "????", - tracksKey = "ConvertedMBoyMuonSpectroOnlyTracks" ) - -MoMuMooreConfig = MuonCalibConfig( - eventTag = "MoMuMoore", - segmentCombisKey = "MdtSegmentCombinations", - doPhi = True, - doTracks = True, - patternsKey = "MuonHoughPatternCombinations", - tracksKey = "ConvertedMooreTracks" ) - - -def configure(config): - """Configure the calibration input and output. - If both segmentsKey and segmentCombisKey are defined, segmentsKey has priority.""" - from AthenaCommon.AppMgr import ToolSvc - global topSequence,MdtCalibTool, MuonSegmentToCalibSegment, MuonCalibAlg, MuonCalibTool, MuonCalibExtraTreeAlg - log.info("Configuring with %s", config) - - calibMode = muonCalibFlags.Mode() - # - # Configure MuonSegmentToCalibSegment - # - try: - MuonSegmentToCalibSegment = topSequence.MuonSegmentToCalibSegment - except AttributeError: - from MuonCalibPatRec.MuonCalibPatRecConf import MuonCalib__MuonSegmentToCalibSegment - MuonSegmentToCalibSegment = MuonCalib__MuonSegmentToCalibSegment("MuonSegmentToCalibSegment") - topSequence += MuonSegmentToCalibSegment - MuonSegmentToCalibSegment.UseCscSegments = muonRecFlags.doCSCs() - - # segmentsKey - try: - segmentsKey = config.segmentsKey - except AttributeError: - MuonSegmentToCalibSegment.ReadSegments = False - else: - MuonSegmentToCalibSegment.SegmentLocation = segmentsKey - MuonSegmentToCalibSegment.ReadSegments = True - # segmentCombisKey - try: - segmentCombisKey = config.segmentCombisKey - except AttributeError: - pass - else: - MuonSegmentToCalibSegment.SegmentCombiLocation = segmentCombisKey - - # - # MuonCalibAlg - # - try: - MuonCalibAlg = topSequence.MuonCalibAlg - except AttributeError: - from MuonCalibAlgs.MuonCalibAlgsConf import MuonCalib__MuonCalibAlg - MuonCalibAlg = MuonCalib__MuonCalibAlg( "MuonCalibAlg" ) - topSequence += MuonCalibAlg - if beamFlags.beamType() == 'singlebeam' or beamFlags.beamType() == 'cosmics': - MuonCalibAlg.addTriggerTag = False - else: - MuonCalibAlg.addTriggerTag = recFlags.doTrigger() - MuonCalibAlg.doMDTs = muonRecFlags.doMDTs() - MuonCalibAlg.doCSCs = muonRecFlags.doCSCs() - MuonCalibAlg.doRPCs = muonRecFlags.doRPCs() - MuonCalibAlg.doTGCs = muonRecFlags.doTGCs() - try: - eventTag = config.eventTag - except AttributeError: - pass - else: - MuonCalibAlg.EventTag = eventTag - - MuonCalibAlg.doTruth = recFlags.doTruth() - - - if calibMode == 'ntuple' or calibMode == 'trackNtuple': - from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker - MuonCalibTool = MuonCalib__PatternNtupleMaker() - if calibMode == 'trackNtuple': - if muonRecFlags.doSegmentsOnly(): - log.warning("Making ntuple instead of trackNtuple because making segments only") - muonCalibFlags.Mode = 'ntuple' - else: - MuonCalibTool.DelayFinish = True - try: - MuonCalibExtraTreeAlg = topSequence.MuonCalibExtraTreeAlg - except AttributeError: - from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg - MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg("MuonCalibExtraTreeAlg") - MuonCalibExtraTreeAlg.NtupleName = "PatternNtupleMaker" - topSequence += MuonCalibExtraTreeAlg - - # doPhi - try: - doPhi = config.doPhi - except AttributeError: - doPhi = False - MuonCalibExtraTreeAlg.doPhi = doPhi - # doTracks - try: - doTracks = config.doTracks - except AttributeError: - doTracks = False - MuonCalibExtraTreeAlg.doTracks = doTracks - # patternsKey - try: - patternsKey = config.patternsKey - except AttributeError: - pass - else: - MuonCalibExtraTreeAlg.PatternLocation = patternsKey - # tracksKey - try: - tracksKey = config.tracksKey - except AttributeError: - pass - else: - MuonCalibExtraTreeAlg.TrackLocation = tracksKey - - else: # other calib modes - from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool - MuonCalibTool = MuonCalib__MdtCalibTool() - if calibMode == 'regionNtuple': - from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool - MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool() - else: - raise RuntimeError( "Unknown Muon Calibration Mode: %r" % calibMode ) - - ToolSvc += MdtCalibTool - MuonCalibTool.MdtCalibTool = MdtCalibTool - - ToolSvc += MuonCalibTool - MuonCalibAlg.MuonCalibTool = MuonCalibTool - - - -def printConfig(): - global MuonSegmentToCalibSegment,MuonCalibAlg,MuonCalibTool,MdtCalibTool,MuonCalibExtraTreeAlg - - print (MuonSegmentToCalibSegment) - print (MuonCalibAlg) - print (MuonCalibTool) - print (MdtCalibTool) - print (MuonCalibExtraTreeAlg) - - -# -# Activate default based on muonCalibFlags.EventTag -# -eventTag = muonCalibFlags.EventTag() -for c in vars().values(): - if isinstance(c,MuonCalibConfig) and c.eventTag == eventTag: - configure(c) - break -else: - log.warning("No standard configuration for muonCalibFlags.EventTag = %r. User needs to call MuonCalib.configure() by hand.", eventTag) -del c -del eventTag diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/share/MuonCalibAlgs.py b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/share/MuonCalibAlgs.py deleted file mode 100644 index c534bb0c7bee7883f5585c392b2a1bbe73e76094..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/share/MuonCalibAlgs.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from AthenaCommon.Logging import logging - -log = logging.getLogger("MuonCalibAlgs") - -log.warning("""include(\"MuonCalibAlgs/MuonCalibAlgs.py\") is deprecated. -use instead: from MuonCalibAlgs import MuonCalib -This is temporarily done for you now, and should be backwards compatible""" ) - -from MuonCalibAlgs.MuonCalib import MuonSegmentToCalibSegment,MuonCalibAlg - -# MuonCalibExtraTreeAlg may or may not be there, depending on the settings -try: - from MuonCalibAlgs.MuonCalib import MuonCalibExtraTreeAlg -except ImportError: - pass diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/src/MuonCalibAlg.cxx b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/src/MuonCalibAlg.cxx deleted file mode 100644 index 1d6f3aa1a05f7a2799e890b847e824bcd611511c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/src/MuonCalibAlg.cxx +++ /dev/null @@ -1,1523 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibAlgs/MuonCalibAlg.h" - -// gaudi -#include "xAODEventInfo/EventInfo.h" -#include "EventInfo/TagInfo.h" -#include "TrackRecord/TrackRecordCollection.h" -#include "TileEvent/TileContainer.h" -#include "TileIdentifier/TileTBID.h" -#include "LArRecEvent/LArCollisionTime.h" -#include "MuonPrepRawData/MuonPrepDataContainer.h" -#include "MuonTrigCoinData/TgcCoinDataContainer.h" -#include "MuonTrigCoinData/RpcCoinDataContainer.h" -#include "MuonDigitContainer/TgcDigit.h" -#include "MuonPrepRawData/CscStripPrepDataContainer.h" -#include "TrkEventPrimitives/ParamDefs.h" -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonSimData/MuonSimData.h" -#include "MuonSimData/MuonSimDataCollection.h" -#include "MuonSimData/CscSimDataCollection.h" -#include "GeneratorObjects/McEventCollection.h" -#include "AtlasHepMC/GenEvent.h" -#include "CLHEP/Vector/LorentzVector.h" -#include "GeoPrimitives/GeoPrimitives.h" - -// calibration -#include "MuonCalibEvent/MuonCalibPatternCollection.h" -#include "MuonCalibNtuple/RootFileManager.h" -#include "MuonCalibIdentifier/MuonFixedId.h" -#include "MuonCalibStl/DeleteObject.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibRawRpcHit.h" -#include "MuonCalibEventBase/MuonCalibRawCscHit.h" -#include "MuonCalibEventBase/MuonCalibRawTgcHit.h" -#include "MuonCalibEventBase/MuonCalibRawTgcCoin.h" -#include "MuonCalibEventBase/MuonCalibRawRpcCoin.h" -#include "MuonCalibEventBase/MuonCalibRawRpcTriggerHit.h" -#include "MuonCalibEventBase/MuonCalibTruth.h" -#include "MuonCalibEventBase/MuonCalibMdtTruthHit.h" -#include "MuonCalibEventBase/MuonCalibRpcTruthHit.h" -#include "MuonCalibEventBase/MuonCalibTgcTruthHit.h" -#include "MuonCalibEventBase/MuonCalibCscTruthHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibEventInfo.h" -#include "MuonCalibEventBase/MuonCalibTriggerTimeInfo.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibTruthCollection.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawTriggerHitCollection.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" - -// trigger includes: -#include "TrigT1Result/CTP_RDO.h" -#include "TrigT1Result/CTP_Decoder.h" - -#include "MuonRDO/RpcPad.h" -#include "MuonRDO/RpcPadContainer.h" -#include "MuonRDO/RpcSectorLogicContainer.h" - -#include <algorithm> -#include <iostream> -#include "iomanip" -#include <map> - -namespace MuonCalib { - - MuonCalibAlg::MuonCalibAlg(const std::string& name, ISvcLocator* pSvcLocator) : - AthAlgorithm(name, pSvcLocator), - m_muonCalibTool("MuonCalib::MdtCalibTool/MdtCalibTool"), - m_idToFixedIdTool("MuonCalib::IdToFixedIdTool"), - m_stripFitter("CalibCscStripFitter/CalibCscStripFitter"), - m_muonIdCutTool("MuonIdCutTool/MuonIdCutTool"), - m_tileTBID(nullptr), - m_ntupFileOpen(false) - { - // Contents in the ntuple: with or without truth? - declareProperty("doTruth", m_doTruth = true); - - declareProperty("doTruthMuonOnly", m_doTruthMuonOnly = true); - - // pattern and mdtsegment location in storegate - declareProperty("GlobalPatternLocation", m_globalPatternLocation="PatternsForCalibration"); - - declareProperty("MuonCalibTool", m_muonCalibTool); - - declareProperty("EventTag", m_eventTag = "MoMu"); - - declareProperty("DoRawData", m_doRawData = true); - - // Delete event at end of execute or at finalize, event needed if immediate calibration performed - declareProperty("deleteEvent", m_doDeleteEvent = true); - - declareProperty("addTriggerTag", m_addTriggerTag = true); - - declareProperty("MDT_TDC_cut",m_mdt_tdc_cut = true); - - // set by job options to turn on or off cuts on truth - declareProperty("DoPrdSelect", m_doPrdSelect = false); - - //for Trigger time info - declareProperty("MBTS_Threshold", m_mbts_threshold = 40.0/222.0 ); // Value in pC - - // flags for ntuple production - m_createRootFile = true; - //declareProperty("CreateFile",m_createRootFile); - - declareProperty("NtupleName",m_ntupleName="CalibrationNtuple.root"); - - declareProperty("doMDTs", m_doMDTs = true ); - - declareProperty("doCSCs", m_doCSCs = true ); - declareProperty("CSCStripFitter", m_stripFitter); - - declareProperty("doRPCs", m_doRPCs = true ); - declareProperty("doTGCs", m_doTGCs = true ); - declareProperty("doRPCCoinData", m_doRPCCoin = true ); - declareProperty("doTGCCoinData", m_doTGCCoin = true ); - declareProperty("doRPCSectorLogic", m_doRpcSectorLogic = true ); - declareProperty("doRPCTriggerHits", m_doRPCTriggerHits = true ); - - m_trigger_waning_printed=false; - m_lar_waning_printed=false; - m_mbts_warning_printed=false; - m_eventNumber=0; - } - - StatusCode MuonCalibAlg::initialize() - { - //----------------------------------------------------- - - ATH_MSG_INFO("Initialisation started "); - ATH_MSG_INFO("================================"); - ATH_MSG_INFO("= Proprieties are:"); - ATH_MSG_INFO("= GlobalPatternLocation " << m_globalPatternLocation); - ATH_MSG_INFO("= MdtCalibTool " << m_muonCalibTool); - ATH_MSG_INFO("= NtupleName " << m_ntupleName << " write " << m_createRootFile); - if(m_doTruth) ATH_MSG_INFO("= Truth information stored on ntuple"); - else ATH_MSG_INFO("= Truth information NOT stored on ntuple"); - if(m_doRawData) ATH_MSG_INFO("= Raw Hit information stored on ntuple"); - else ATH_MSG_INFO("= Raw Hit information NOT stored on ntuple"); - ATH_MSG_INFO("================================"); - - ATH_CHECK(m_idHelperSvc.retrieve()); - - if (!m_stripFitter.empty()) { - if (!m_idHelperSvc->hasCSC()) ATH_MSG_WARNING("The current layout does not have any CSC chamber but you gave a CSCStripFitter, ignoring it, but double-check configuration"); - else ATH_CHECK( m_stripFitter.retrieve() ); - } - if (m_doCSCs && !m_idHelperSvc->hasCSC()) { - ATH_MSG_WARNING("The current layout does not have any CSC chamber but you have set doCSCs to true, setting it to false, but double-check configuration"); - m_doCSCs = false; - } - - m_eventNumber = 0; - - ATH_CHECK( m_idToFixedIdTool.retrieve() ); - - ATH_CHECK( m_muonIdCutTool.retrieve() ); - - // retrieve TileTBID helper - // (The MBTS was added to the Test Beam (TB) list.) - if(detStore()->retrieve(m_tileTBID).isFailure()) { - ATH_MSG_WARNING("Unable to retrieve TileTBID helper from DetectorStore"); - } - - // retrieve MuonDetectorManager from the conditions store - ATH_CHECK(m_DetectorManagerKey.initialize()); - - ATH_MSG_INFO("Initialization ended "); - return StatusCode::SUCCESS; - } - - // Execute - StatusCode MuonCalibAlg::execute(){ - if( m_createRootFile ) { - if(!m_ntupFileOpen) { - // create the root file: - // was originally in the constructor - from where it was not possible to - // configure the file name - please let me know if in some use-case - // having it here causes troubles - domizia.orestano@cern.ch - RootFileManager::getInstance()->openFile(m_ntupleName); - m_ntupFileOpen=true; - ATH_CHECK(m_muonCalibTool.retrieve()); - } - - ATH_MSG_INFO("Write metadata"); - const TagInfo* tagInfo = nullptr; - StatusCode sc = detStore()->retrieve(tagInfo); - if (sc.isFailure() || !tagInfo) { - ATH_MSG_FATAL("No TagInfo in DetectorStore"); - return StatusCode::FAILURE; - } - TagInfo::NameTagPairVec tags; - tagInfo->getTags(tags); - std::map<std::string, std::string> metadata; - for (TagInfo::NameTagPairVec::const_iterator it=tags.begin(); it!=tags.end(); it++) metadata[it->first]=it->second; - RootFileManager::getInstance()->WriteMetaData(metadata, m_ntupleName); - m_createRootFile=false; - } - - const MuonCalibEvent* event = retrieveEvent(); - m_muonCalibTool->handleEvent( event ) ; - if (m_doDeleteEvent == true) delete event; - else m_events.push_back(event); - return StatusCode::SUCCESS; - } - - StatusCode MuonCalibAlg::finalize(){ - ATH_MSG_INFO("Finalisation started "); - - if(m_ntupFileOpen) { - // perform analysis - m_muonCalibTool->analyse(); - - std::for_each(m_events.begin(),m_events.end(),DeleteObject()); - - // close root file - if( m_createRootFile ) RootFileManager::getInstance()->closeFile(); - } - - return StatusCode::SUCCESS; - } - - const MuonCalibEvent::MCPVec MuonCalibAlg::retrievePatterns() const - { - MuonCalibEvent::MCPVec patternVec; - // retrieve MuonCalibPatternCollection - if (!evtStore()->contains<MuonCalibPatternCollection>(m_globalPatternLocation)) { - ATH_MSG_DEBUG("MuonCalibPatternCollection not contained in StoreGate at:" << m_globalPatternLocation); - return patternVec; - } - const MuonCalibPatternCollection* pats = 0; - StatusCode sc = evtStore()->retrieve(pats,m_globalPatternLocation); - if (sc.isFailure()) { - ATH_MSG_WARNING("Could not find MuonCalibPatternCollection at " << m_globalPatternLocation); - }else{ - ATH_MSG_DEBUG("retrieved MuonCalibPatternCollection " << pats->size()); - patternVec.reserve(pats->size()); - - MuonCalibPatternCollection::const_iterator pat_it = pats->begin(); - MuonCalibPatternCollection::const_iterator pat_it_end = pats->end(); - for( ;pat_it!=pat_it_end; ++pat_it ){ - MuonCalibPattern* pat = new MuonCalibPattern(*(*pat_it)) ; - - patternVec.push_back( pat ); - } - } - - return patternVec; - } - - const MuonCalibTruthCollection* MuonCalibAlg::retrieveTruthCollection() const - { - const TrackRecordCollection* truthCollection = nullptr; - std::string location = "MuonEntryLayer"; - bool found = false; - bool filled = false; - if ( evtStore()->contains<TrackRecordCollection>(location) ) found = true ; - if( found ) { - if (evtStore()->retrieve(truthCollection,location).isFailure()) { - ATH_MSG_WARNING("MuonCalibAlg::retrieveTruthCollection: could not retrieve TrackRecordCollection "<<location<<", trying MuonEntryRecord next"); - } - if( truthCollection->size() == 0 ) filled = false ; - else filled = true ; - } else { - ATH_MSG_DEBUG("location " << location << " discarded"); - } - - if(!found){ - location ="MuonEntryRecord"; - if ( evtStore()->contains<TrackRecordCollection>(location) ) found = true ; - if( found ) { - if (evtStore()->retrieve(truthCollection,location).isFailure()) { - ATH_MSG_WARNING("MuonCalibAlg::retrieveTruthCollection: could not retrieve TrackRecordCollection "<<location); - } - if( truthCollection->size() == 0 ) filled = false ; - else filled = true ; - } else { - ATH_MSG_DEBUG("location " << location << " discarded"); - } - } - - if(found && filled){ - ATH_MSG_DEBUG("TracksRecordCollections collected at location: " << location); - } - if(!found){ - ATH_MSG_DEBUG("TracksRecordCollections nowhere to found in Storegate, nor filled"); - } - if(found && !filled){ - ATH_MSG_DEBUG("TracksRecordCollections collected at location: " << location << " are empty "); - } - - MuonCalibTruthCollection* MCtruthCollection = new MuonCalibTruthCollection(); - - std::set < int > muonBarCode; - bool muonfound = false; - if(found && filled ){ - const McEventCollection* mcEventCollection = 0; - std::string MClocation = "TruthEvent"; - if(evtStore()->contains<McEventCollection>(MClocation)) { - StatusCode scmc = evtStore()->retrieve(mcEventCollection, MClocation); - if (StatusCode::SUCCESS == scmc ){ - ATH_MSG_DEBUG(" McEventCollection collection retrieved "); - } - - ATH_MSG_DEBUG("retrieved TrackRecordCollection " << truthCollection->size()); - //Convert TrackRecordCollection to MuonCalibTruthCollection - - TrackRecordConstIterator tr_it = truthCollection->begin(); - TrackRecordConstIterator tr_it_end = truthCollection->end(); - for(;tr_it!=tr_it_end; ++tr_it){ - Amg::Vector3D pos( (*tr_it).GetPosition().x(), (*tr_it).GetPosition().y(), (*tr_it).GetPosition().z() ); - Amg::Vector3D mom( (*tr_it).GetMomentum().x(), (*tr_it).GetMomentum().y(), (*tr_it).GetMomentum().z() ); - double kinEnergy( (*tr_it).GetEnergy() ) ; - int PDGCode( (*tr_it).GetPDGCode() ) ; - int barcode((*tr_it).GetBarCode() ); - double prec = std::sqrt(mom[0]*mom[0]+mom[1]*mom[1]+mom[2]*mom[2]); - int newbarcode = 0; - if (std::abs(PDGCode) == 13 ) { - muonfound = true; - - // Barcode is not set correctly in TrackRecordCollection for earlier versions before June 2006 - // Do matching with MC event collection - - double dotprodbest=-1.; - - if (StatusCode::SUCCESS == scmc ) { - const HepMC::GenEvent* myGenEvent = *(mcEventCollection -> begin()); - HepMC::GenEvent::particle_const_iterator particle = myGenEvent->particles_begin(); - HepMC::GenEvent::particle_const_iterator particle_end = myGenEvent->particles_end(); - for(; particle!=particle_end;++particle){ - if( (*particle)->pdg_id() == PDGCode ) { - Amg::Vector3D moms( (*particle)->momentum().x(), (*particle)->momentum().y(), (*particle)->momentum().z() ); - double dotprod = moms[0]*mom[0] + moms[1]*mom[1] + moms[2]*mom[2]; - double psim = std::sqrt(moms[0]*moms[0]+moms[1]*moms[1]+moms[2]*moms[2]); - psim =std::sqrt(psim); - dotprod = dotprod/(psim*prec); - if (dotprod > 0.5&&dotprod > dotprodbest) { - dotprodbest = dotprod; - newbarcode = (*particle)->barcode(); - } - } - } - } - } - // barcode from TrackRecord - MuonCalibTruth* truth = new MuonCalibTruth(); - truth->setPosition(pos); - truth->setMomentum(mom); - truth->setKinEnergy(kinEnergy); - truth->setPDGCode(PDGCode); - truth->setBarCode(barcode); - //will destroyed in MuonCalibTruthCollection destructor - MCtruthCollection->addTruth(truth); - muonBarCode.insert(barcode); - // Store also newbarcode from MCEvent (negative value); - if (newbarcode>0 && barcode != newbarcode) { - truth = new MuonCalibTruth(); - truth->setPosition(pos); - truth->setMomentum(mom); - truth->setKinEnergy(kinEnergy); - truth->setPDGCode(PDGCode); - truth->setBarCode(-newbarcode); - MCtruthCollection->addTruth(truth); - muonBarCode.insert(newbarcode); - } - } - } - } - bool addmuonatIP = true; - if (!muonfound||addmuonatIP) { //retrieve truth track by other means: via McEventCollection... - - const McEventCollection* mcEventCollection = nullptr; - std::string MClocation = "TruthEvent"; - if(evtStore()->contains<McEventCollection>(MClocation)) { - StatusCode sc = evtStore()->retrieve(mcEventCollection, MClocation); - - if (StatusCode::SUCCESS == sc ) { - ATH_MSG_DEBUG(" McEventCollection collection retrieved "); - - const HepMC::GenEvent* myGenEvent = *(mcEventCollection -> begin()); - HepMC::GenEvent::particle_const_iterator particle = myGenEvent->particles_begin(); - HepMC::GenEvent::particle_const_iterator particle_end = myGenEvent->particles_end(); - for(; particle!=particle_end;++particle){ - if( std::abs( (*particle)->pdg_id() ) == 13) { - CLHEP::HepLorentzVector p((*particle)->momentum().px(), - (*particle)->momentum().py(), - (*particle)->momentum().pz(), - (*particle)->momentum().e()); - Amg::Vector3D pos(999.,999.,999.); - if ((*particle)->production_vertex()) { - pos[0] = (*particle)->production_vertex()->position().x(); - pos[1] = (*particle)->production_vertex()->position().y(); - pos[2] = (*particle)->production_vertex()->position().z(); - } - Amg::Vector3D mom( (*particle)->momentum().x(), (*particle)->momentum().y(), (*particle)->momentum().z() ); - double kinEnergy( p[3] ) ; - int PDGCode( (*particle)->pdg_id() ) ; - - MuonCalibTruth* truth = new MuonCalibTruth(); - - truth->setPosition(pos); - truth->setMomentum(mom); - truth->setKinEnergy(kinEnergy); - truth->setPDGCode(PDGCode); - int barcode = (*particle)->barcode(); - truth->setBarCode(barcode); - MCtruthCollection->addTruth(truth); - muonBarCode.insert(barcode); - } - } - } else { - ATH_MSG_WARNING(" McEventCollection collection NOT retrieved "); - } - }//retrieved other MCtruth - } - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return 0; - } - - std::string sdoKey; - const MuonSimDataCollection* sdoContainer = 0; - if ( m_doMDTs ) { - //Retrieving MDT truth hits from MDT_SDO container and store them in MuonCalibMdtTruthHits - // and feed MuonCalibMdtTruthHits into MuonCalibTruhtCollection - sdoKey= "MDT_SDO"; - bool addDummy = false; - if(!evtStore()->contains<MuonSimDataCollection>(sdoKey)) { - addDummy = true; - }else{ - if (!evtStore()->retrieve(sdoContainer,sdoKey).isSuccess()) { - ATH_MSG_DEBUG("No MDT Sdo Container found"); - addDummy = true; - } - } - - if( addDummy ){ - // Store one entry with zero's to recognize it offline - MuonCalibMdtTruthHit* mdtTruth = new MuonCalibMdtTruthHit(); - mdtTruth->setBarCode(0) ; - mdtTruth->setDriftRadius(0.) ; - mdtTruth->setPositionAlongTube(0.); - MCtruthCollection->addTruth( mdtTruth ); - } else { - ATH_MSG_DEBUG("MDT Sdo Container found"); - MuonSimDataCollection::const_iterator mdt_it = sdoContainer->begin(); - MuonSimDataCollection::const_iterator mdt_it_end = sdoContainer->end(); - bool drop = false; - int nmdtSDO = 0; - int nsdo =0; - for( ; mdt_it!=mdt_it_end; ++mdt_it ){ - std::vector< MuonSimData::Deposit >::const_iterator deposits_it = (*mdt_it).second.getdeposits().begin() ; - std::vector< MuonSimData::Deposit >::const_iterator deposits_it_end = (*mdt_it).second.getdeposits().end() ; - for( ; deposits_it!= deposits_it_end; ++deposits_it) { - int barcode = (*deposits_it).first.barcode(); - if (muonBarCode.count(barcode+10000)!=1&&muonBarCode.count(barcode)!=1&&muonBarCode.count(barcode%10000)!=1&&m_doTruthMuonOnly) continue; - if (nmdtSDO>999) drop = true; - if (!drop || (drop && (*deposits_it).first.barcode() != 0)) { - nmdtSDO++; - - const Identifier& id = (*mdt_it).first; - MuonFixedId mfi = m_idToFixedIdTool->idToFixedId( id ); - if( m_doPrdSelect && m_muonIdCutTool->isCut(mfi) ) continue; - - MuonCalibMdtTruthHit* mdtTruth = new MuonCalibMdtTruthHit(); - mdtTruth->setBarCode( (*deposits_it).first.barcode() ) ; - mdtTruth->setIdentifier( mfi ) ; - nsdo++; - mdtTruth->setDriftRadius( (*deposits_it).second.firstEntry() ) ; - double posAlongAMDB = (*deposits_it).second.secondEntry(); - Amg::Vector3D geoModelLocPos(0.,0.,posAlongAMDB); - const MuonGM::MdtReadoutElement* detEl = MuonDetMgr->getMdtReadoutElement(id); - if( detEl ) { - Amg::Vector3D gpos = detEl->localToGlobalCoords(geoModelLocPos,id); - Amg::Vector3D localAMDBPos = detEl->GlobalToAmdbLRSTransform()*gpos; - posAlongAMDB = localAMDBPos.x(); - } - mdtTruth->setPositionAlongTube( posAlongAMDB ); - mdtTruth->identify(); - MCtruthCollection->addTruth( mdtTruth ); - } - } - } - } - } // if ( m_doMDTs ) - - if ( m_doRPCs ) { - //Retrieving RPC truth hits from RPC_SDO container and store them in MuonCalibRpcTruthHits - // and feed MuonCalibRpcTruthHits into MuonCalibTruthCollection - sdoKey= "RPC_SDO"; - bool addDummy = false; - if(!evtStore()->contains<MuonSimDataCollection>(sdoKey)) { - addDummy = true; - }else{ - if (!evtStore()->retrieve(sdoContainer,sdoKey).isSuccess()) { - addDummy = true; - } - } - - if(addDummy) { - ATH_MSG_DEBUG("No RPC Sdo Container found"); - - // Store one entry with zero's to recognize it offline - - MuonCalibRpcTruthHit* rpcTruth = new MuonCalibRpcTruthHit(); - rpcTruth->setBarCode(0) ; - rpcTruth->setTime(0.) ; - MCtruthCollection->addTruth( rpcTruth ); - } else { - ATH_MSG_DEBUG("RPC Sdo Container found"); - MuonSimDataCollection::const_iterator rpc_it = sdoContainer->begin(); - MuonSimDataCollection::const_iterator rpc_it_end = sdoContainer->end(); - bool drop = false; - int nrpcSDO = 0; - for( ; rpc_it!=rpc_it_end; ++rpc_it ){ - std::vector< MuonSimData::Deposit >::const_iterator deposits_it = (*rpc_it).second.getdeposits().begin() ; - std::vector< MuonSimData::Deposit >::const_iterator deposits_it_end = (*rpc_it).second.getdeposits().end() ; - for( ; deposits_it!= deposits_it_end; ++deposits_it) { - int barcode = (*deposits_it).first.barcode(); - // Check that deposit is from truth muon - if (muonBarCode.count(barcode)!=1&&muonBarCode.count(barcode%10000)!=1&&m_doTruthMuonOnly) continue; - - if (nrpcSDO>999) drop = true; - if (!drop || (drop && (*deposits_it).first.barcode() != 0)) { - nrpcSDO++; - - MuonFixedId mfi = m_idToFixedIdTool->idToFixedId( (*rpc_it).first ); - if( m_doPrdSelect && m_muonIdCutTool->isCut(mfi) ) continue; - - MuonCalibRpcTruthHit* rpcTruth = new MuonCalibRpcTruthHit(); - rpcTruth->setBarCode( (*deposits_it).first.barcode() ) ; - rpcTruth->setIdentifier( mfi ) ; - rpcTruth->setTime( (*deposits_it).second.firstEntry() ) ; - MCtruthCollection->addTruth( rpcTruth ); - } - } - } - } - } // if ( m_doRPCs ) - - if ( m_doTGCs ) { - //Retrieving TGC truth hits from TGC_SDO container and store them in MuonCalibTgcTruthHits - // and feed MuonCalibTgcTruthHits into MuonCalibTruthCollection - sdoKey= "TGC_SDO"; - bool addDummy = false; - if(!evtStore()->contains<MuonSimDataCollection>(sdoKey)) { - addDummy = true; - }else{ - if (!evtStore()->retrieve(sdoContainer,sdoKey).isSuccess()) { - ATH_MSG_DEBUG("No TGC Sdo Container found"); - addDummy = true; - } - } - if (addDummy) { - - // Store one entry with zero's to recognize it offline - - MuonCalibTgcTruthHit* tgcTruth = new MuonCalibTgcTruthHit(); - tgcTruth->setBarCode(0) ; - tgcTruth->setTime(0.) ; - MCtruthCollection->addTruth( tgcTruth ); - } else { - ATH_MSG_DEBUG("Sdo TGC Container found"); - MuonSimDataCollection::const_iterator tgc_it = sdoContainer->begin(); - MuonSimDataCollection::const_iterator tgc_it_end = sdoContainer->end(); - bool drop = false; - int ntgcSDO = 0; - for( ; tgc_it!=tgc_it_end; ++tgc_it ){ - std::vector< MuonSimData::Deposit >::const_iterator deposits_it = (*tgc_it).second.getdeposits().begin() ; - std::vector< MuonSimData::Deposit >::const_iterator deposits_it_end = (*tgc_it).second.getdeposits().end() ; - for( ; deposits_it!= deposits_it_end; ++deposits_it) { - int barcode = (*deposits_it).first.barcode(); - // Check that deposit is from truth muon - if (muonBarCode.count(barcode+10000)!=1&&muonBarCode.count(barcode)!=1&&muonBarCode.count(barcode%10000)!=1&&m_doTruthMuonOnly) continue; - if (ntgcSDO>999) drop = true; - if (!drop || (drop && (*deposits_it).first.barcode() != 0)) { - - MuonFixedId mfi = m_idToFixedIdTool->idToFixedId( (*tgc_it).first ); - if( m_doPrdSelect && m_muonIdCutTool->isCut(mfi) ) continue; - - ntgcSDO++; - MuonCalibTgcTruthHit* tgcTruth = new MuonCalibTgcTruthHit(); - tgcTruth->setBarCode( (*deposits_it).first.barcode() ) ; - tgcTruth->setIdentifier( mfi ) ; - tgcTruth->setTime( (*deposits_it).second.firstEntry() ) ; - MCtruthCollection->addTruth( tgcTruth ); - } - } - } - } - } // if ( m_doTGCs ) - - - if ( m_doCSCs ) { - //Retrieving CSC truth hits from CSC_SDO container and store them in MuonCalibCscTruthHits - // and feed MuonCalibCscTruthHits into MuonCalibTruthCollection - sdoKey= "CSC_SDO"; - if (evtStore()->contains<MuonSimDataCollection>(sdoKey)) - { - if (evtStore()->retrieve(sdoContainer,sdoKey).isSuccess()) { - ATH_MSG_DEBUG("CSC Sdo Container found"); - MuonSimDataCollection::const_iterator csc_it = sdoContainer->begin(); - MuonSimDataCollection::const_iterator csc_it_end = sdoContainer->end(); - bool drop = false; - int ncscSDO = 0; - for( ; csc_it!=csc_it_end; ++csc_it ){ - std::vector< MuonSimData::Deposit >::const_iterator deposits_it = (*csc_it).second.getdeposits().begin() ; - std::vector< MuonSimData::Deposit >::const_iterator deposits_it_end = (*csc_it).second.getdeposits().end() ; - for( ; deposits_it!= deposits_it_end; ++deposits_it) { - int barcode = (*deposits_it).first.barcode(); - // Check that deposit is from truth muon - if (muonBarCode.count(barcode+10000)!=1&&muonBarCode.count(barcode)!=1&&muonBarCode.count(barcode%10000)!=1&&m_doTruthMuonOnly) continue; - if (ncscSDO>999) drop = true; - if (!drop || (drop && (*deposits_it).first.barcode() != 0)) { - ncscSDO++; - MuonFixedId mfi = m_idToFixedIdTool->idToFixedId( (*csc_it).first ); - if( m_doPrdSelect && m_muonIdCutTool->isCut(mfi) ) continue; - - MuonCalibCscTruthHit* cscTruth = new MuonCalibCscTruthHit(); - cscTruth->setBarCode( (*deposits_it).first.barcode() ) ; - cscTruth->setIdentifier( mfi ) ; - cscTruth->setTime( (*deposits_it).second.firstEntry() ) ; - MCtruthCollection->addTruth( cscTruth ); - } - } - } - } - } else { - ATH_MSG_DEBUG("No CSC MuonSimHit Sdo Container found"); - - const CscSimDataCollection* cscSdoContainer; - bool addDummy = false; - if(!evtStore()->contains<CscSimDataCollection>(sdoKey)) { - addDummy = true; - }else{ - if (!evtStore()->retrieve(cscSdoContainer,sdoKey).isSuccess()) { - addDummy = true; - } - } - if (addDummy) { - ATH_MSG_DEBUG("No CSC Sdo Container found"); - - // Store one entry with zero's to recognize it offline - - MuonCalibCscTruthHit* cscTruth = new MuonCalibCscTruthHit(); - cscTruth->setBarCode(0) ; - cscTruth->setTime(0.) ; - MCtruthCollection->addTruth( cscTruth ); - } else { - ATH_MSG_DEBUG("CSC Sdo Container found"); - CscSimDataCollection::const_iterator csc_it = cscSdoContainer->begin(); - CscSimDataCollection::const_iterator csc_it_end = cscSdoContainer->end(); - bool drop = false; - int ncscSDO = 0; - for( ; csc_it!=csc_it_end; ++csc_it ){ - std::vector< CscSimData::Deposit >::const_iterator deposits_it = (*csc_it).second.getdeposits().begin() ; - std::vector< CscSimData::Deposit >::const_iterator deposits_it_end = (*csc_it).second.getdeposits().end() ; - for( ; deposits_it!= deposits_it_end; ++deposits_it) { - int barcode = (*deposits_it).first.barcode(); - // Check that deposit is from truth muon - if (muonBarCode.count(barcode)!=1&&muonBarCode.count(barcode%10000)!=1&&m_doTruthMuonOnly) continue; - if (ncscSDO>999) drop = true; - if (!drop || (drop && (*deposits_it).first.barcode() != 0)) { - ncscSDO++; - Identifier id = (*csc_it).first; - const MuonGM::CscReadoutElement* detEl = MuonDetMgr->getCscReadoutElement(id); - if( !detEl ){ - ATH_MSG_WARNING("Found CSC Identifier which seems to have no readout element " - << m_idHelperSvc->mdtIdHelper().print_to_string(id)); - continue; - } - MuonFixedId mfi = m_idToFixedIdTool->idToFixedId(id); - if( m_doPrdSelect && m_muonIdCutTool->isCut(mfi) ) continue; - - MuonCalibCscTruthHit* cscTruth = new MuonCalibCscTruthHit(); - cscTruth->setBarCode( (*deposits_it).first.barcode() ) ; - cscTruth->setIdentifier( mfi ) ; - double ypos_local = (*deposits_it).second.ypos() ; - double zpos_local = (*deposits_it).second.zpos() ; - const Amg::Vector3D locpos3d = Amg::Vector3D(0.,ypos_local, zpos_local); - const Amg::Vector3D globalPos = (detEl->transform())*locpos3d; - double phipos = std::atan2(globalPos.y(),globalPos.x()); - // use cscTime for phi, since time is no longer set for new SDO format!! - cscTruth->setTime( phipos ) ; - MCtruthCollection->addTruth( cscTruth ); - } - } - } - } - } - } // m_doCSCs - - ATH_MSG_DEBUG("retrieved MCtruthCollection size " << MCtruthCollection->numberOfTruth()); - - return MCtruthCollection; - } - - MuonCalibEventInfo MuonCalibAlg::retrieveEventInfo() const - { - const xAOD::EventInfo* eventInfo=nullptr; - MuonCalibEventInfo MCeventInfo; - StatusCode sc = evtStore()->retrieve(eventInfo); - if ( sc.isFailure() ) { - ATH_MSG_ERROR("Could not find eventInfo "); - return MCeventInfo; - }else{ - ATH_MSG_DEBUG("retrieved eventInfo"); - } - - //Cast eventID into MuonCalibEventInfo class: - - MCeventInfo.setRunNumber( eventInfo->runNumber() ) ; - MCeventInfo.setEventNumber( eventInfo->eventNumber() ); - MCeventInfo.setTimeStamp( eventInfo->timeStamp() ); - MCeventInfo.setLumiBlock( eventInfo->lumiBlock() ); - MCeventInfo.setBcId( eventInfo->bcid() ); - std::string eventTag=m_eventTag; - MCeventInfo.setTag( eventTag ); - if ( m_addTriggerTag ) { - const DataHandle< CTP_RDO > ctpRDO; - if ( ! evtStore()->contains(ctpRDO, "CTP_RDO") ) - { - if(!m_trigger_waning_printed) - { - ATH_MSG_INFO("No trigger info, not added to EventTag"); - m_trigger_waning_printed=true; - } - else - { - ATH_MSG_DEBUG("No trigger info, not added to EventTag"); - } - - return MCeventInfo; - } - if ( evtStore()->retrieve( ctpRDO, "CTP_RDO" ).isFailure() ) { - if(!m_trigger_waning_printed) - { - ATH_MSG_INFO("CTP_RDO trigger info missing, not added to EventTag"); - m_trigger_waning_printed=true; - } - else - { - ATH_MSG_DEBUG("CTP_RDO trigger info missing, not added to EventTag"); - } - return MCeventInfo; - } - CTP_Decoder ctp; - ctp.setRDO(ctpRDO); - uint16_t l1aPos = ctpRDO->getL1AcceptBunchPosition(); - if(l1aPos >= ctp.getBunchCrossings().size()) return MCeventInfo; - const CTP_BC& bunch = ctp.getBunchCrossings().at(l1aPos); - MCeventInfo.setNumberOfTriggerBits(bunch.getTAV().size() + bunch.getTAP().size()); - int nth_bit(0); - for(unsigned int i=0; i<bunch.getTAV().size(); i++) - { - MCeventInfo.setTriggerBit(nth_bit, bunch.getTAV().test(i)); - nth_bit++; - } - for(unsigned int i=0; i<bunch.getTAP().size(); i++) - { - MCeventInfo.setTriggerBit(nth_bit, bunch.getTAP().test(i)); - nth_bit++; - } - } - return MCeventInfo; - } - - /// - const MuonCalibTriggerTimeInfo* MuonCalibAlg::retrieveTriggerTimeInfo() const - { - MuonCalibTriggerTimeInfo trigTimeInfo; - /////////////////////////////////////////////////////// - // MBTS word - copied from: - // http://alxr.usatlas.bnl.gov/lxr/source/atlas/TriggerAlgorithms/TrigT2MinBias/src/T2MbtsFex.cxx - const DataHandle<TileCellContainer> tileCellCnt; - uint32_t mbtsBits = 0; - float timeA = 0.F; - float timeC = 0.F; - int countA = 0; - int countC = 0; - - if(evtStore()->contains(tileCellCnt, "MBTSContainer")) - { - StatusCode sc=evtStore()->retrieve(tileCellCnt, "MBTSContainer"); - if (!sc.isFailure()) { - - uint32_t ibit, bit_pos = 0; - float charge = 0; - // Discriminate the signals - TileCellContainer::const_iterator itr = tileCellCnt->begin(); - TileCellContainer::const_iterator itr_end = tileCellCnt->end(); - for(; itr != itr_end; ++itr) { - charge = (*itr)->energy(); - ATH_MSG_DEBUG("Energy =" << charge << "pC"); - if(charge > m_mbts_threshold) { - Identifier id=(*itr)->ID(); - // cache type, module and channel - // MBTS Id type is "side" +/- 1 - int type_id = m_tileTBID->type(id); - // MBTS Id module is "phi" 0-7 - int module_id = m_tileTBID->module(id); - // MBTS Id channel is "eta" 0-1 zero is closer to beam pipe - int channel_id = m_tileTBID->channel(id); - - if (type_id > 0) { - timeA += (*itr)->time(); - countA++ ; - } else { - timeC += (*itr)->time(); - countC++; - } - - // Catch errors - if( std::abs(type_id) != 1 ){ - ATH_MSG_WARNING("MBTS identifier type is out of range"); - continue; - } - if( channel_id < 0 || channel_id > 1 ){ - ATH_MSG_WARNING("MBTS identifier channel is out of range"); - continue; - } - if( module_id < 0 || module_id > 7 ){ - ATH_MSG_WARNING("MBTS identifier module is out of range"); - continue; - } - bit_pos = 0; // The position of the bit - if(type_id == -1) { - bit_pos += 16; - } - bit_pos += channel_id*8; - bit_pos += module_id; - ibit = 1; // The mbts bit for this TileCell - ibit <<= bit_pos; - mbtsBits += ibit; - } - } - }} - else - { - if(!m_mbts_warning_printed) - { - ATH_MSG_INFO("No MBTS info in store gate"); - m_mbts_warning_printed=true; - } - } - - float timeDiff = -999.; // Or whatever default you want - if (countA > 1 && countC > 1) timeDiff = (timeA/countA) - (timeC/countC); - - //LAr time diff - float LArECtimeDiff=-999.; -// LArCollisionTime* tps; - const DataHandle< LArCollisionTime > tps; - if ( evtStore()->contains(tps, "LArCollisionTime") ) - { - StatusCode sc = evtStore()->retrieve(tps,"LArCollisionTime"); - if (!sc.isFailure()) { - const int nMin=2; - if (tps->ncellA() > nMin && tps->ncellC() > nMin) LArECtimeDiff = tps->timeA()-tps->timeC(); - } - } - else - { - if(!m_lar_waning_printed) - { - ATH_MSG_INFO("LArCollisionTime not in store gate."); - m_lar_waning_printed=true; - } - } - //Cast eventID into MuonCalibEventInfo class: - trigTimeInfo.setdMbtsTime( timeDiff ) ; - trigTimeInfo.setdLarTime( LArECtimeDiff ) ; - - MuonCalibTriggerTimeInfo* ttInfo = new MuonCalibTriggerTimeInfo(trigTimeInfo); - - return ttInfo; - } - //// - - const MuonCalibRawHitCollection* MuonCalibAlg::retrieveRawHits( const MuonCalibEvent::MCPVec &patterns ) const{ - MuonCalibRawHitCollection* rawHits = new MuonCalibRawHitCollection(); - - //First, construct maps of the hits on segment. They are ordered by MuonFixedId, - //keeping track on how many times they're assigned to a segment. - std::map<MuonFixedId,int> mdtMap, rpcMap, tgcMap, cscMap ; - - MuonCalibEvent::MCPVecCit pat_it = patterns.begin(); - MuonCalibEvent::MCPVecCit pat_it_end = patterns.end(); - for( ;pat_it!=pat_it_end; ++pat_it ){ - MuonCalibPattern::MuonSegCit seg_it = (*pat_it)->muonSegBegin(); - MuonCalibPattern::MuonSegCit seg_it_end = (*pat_it)->muonSegEnd(); - for( ;seg_it!=seg_it_end;++seg_it ){ - - //Filling the mdtMap with the hits - MuonCalibSegment::MdtHitCit mdt_it = (*seg_it)->mdtHOTBegin(); - MuonCalibSegment::MdtHitCit mdt_it_end = (*seg_it)->mdtHOTEnd(); - for( ;mdt_it!=mdt_it_end;++mdt_it){ - std::map<MuonFixedId, int>::iterator position = mdtMap.find( (*mdt_it)->identify() ); - if(position == mdtMap.end() ){ - mdtMap[ (*mdt_it)->identify() ] = 1; - } else { - ++mdtMap[ (*mdt_it)->identify() ] ; - } - } - - //Filling the rpcMap with the hits - MuonCalibSegment::RpcHitCit rpc_it = (*seg_it)->rpcHOTBegin(); - MuonCalibSegment::RpcHitCit rpc_it_end = (*seg_it)->rpcHOTEnd(); - for( ;rpc_it!=rpc_it_end;++rpc_it){ - std::map<MuonFixedId, int>::iterator position = rpcMap.find( (*rpc_it)->identify() ); - if(position == rpcMap.end() ){ - rpcMap[ (*rpc_it)->identify() ] = 1; - } else { - ++rpcMap[ (*rpc_it)->identify() ] ; - } - } - - //Filling the tgcMap with the hits - MuonCalibSegment::TgcHitCit tgc_it = (*seg_it)->tgcHOTBegin(); - MuonCalibSegment::TgcHitCit tgc_it_end = (*seg_it)->tgcHOTEnd(); - for( ;tgc_it!=tgc_it_end;++tgc_it){ - std::map<MuonFixedId, int>::iterator position = tgcMap.find( (*tgc_it)->identify() ); - if(position == tgcMap.end() ){ - tgcMap[ (*tgc_it)->identify() ] = 1; - } else { - ++tgcMap[ (*tgc_it)->identify() ] ; - } - } - - //Filling the cscMap with the hits - MuonCalibSegment::CscHitCit csc_it = (*seg_it)->cscHOTBegin(); - MuonCalibSegment::CscHitCit csc_it_end = (*seg_it)->cscHOTEnd(); - for( ;csc_it!=csc_it_end;++csc_it){ - std::map<MuonFixedId, int>::iterator position = cscMap.find( (*csc_it)->identify() ); - if(position == cscMap.end() ){ - cscMap[ (*csc_it)->identify() ] = 1; - } else { - ++cscMap[ (*csc_it)->identify() ] ; - } - } - } - } - - //Now, get PRDs from storegate, cast them into MuonCalibRawHits and use the maps - //constructed above to decide which 'occupancy' flag they hold. - - StatusCode sc; - sc.ignore(); - if ( m_doMDTs ) { - //MDT raw hits.... - - std::vector<const Muon::MdtPrepDataCollection*> mdtCols; - const Muon::MdtPrepDataContainer* mdtPrds = 0; - if( !evtStore()->contains<Muon::MdtPrepDataContainer>("MDT_DriftCircles")){ - ATH_MSG_DEBUG("MdtPrepDataContainer MDT_DriftCircles not contained in SG"); - }else if( evtStore()->retrieve(mdtPrds,"MDT_DriftCircles").isFailure() ){ - ATH_MSG_DEBUG("Cannot retrieve MdtPrepDataContainer MDT_DriftCircles"); - }else{ - - ATH_MSG_DEBUG("Retrieved MdtPrepDataContainer "); - - mdtCols.reserve(mdtPrds->size()); // number of mdt chambers - Muon::MdtPrepDataContainer::const_iterator it = mdtPrds->begin(); - Muon::MdtPrepDataContainer::const_iterator it_end = mdtPrds->end(); - for( ; it!=it_end; ++it ) { - mdtCols.push_back( *it ); - } - } - - std::vector< const Muon::MdtPrepDataCollection*>::const_iterator mdtCollection = mdtCols.begin(); - std::vector< const Muon::MdtPrepDataCollection*>::const_iterator mdtlastColl = mdtCols.end(); - for ( ; mdtCollection != mdtlastColl ; ++mdtCollection ) - { - Amg::Transform3D globalToStation; - - Muon::MdtPrepDataCollection::const_iterator mdt_it = (*mdtCollection)->begin(); - Muon::MdtPrepDataCollection::const_iterator mdt_it_end = (*mdtCollection)->end(); - bool amdbtransform = false; - for( ; mdt_it!=mdt_it_end; ++ mdt_it) - { - if (m_mdt_tdc_cut == true && (*mdt_it)->status()==Muon::MdtStatusMasked) continue; - if((*mdt_it)->localPosition()[Trk::locR]==0) continue; - - MuonCalibRawMdtHit* rawMdtHit = new MuonCalibRawMdtHit(); - MuonFixedId fID = m_idToFixedIdTool->idToFixedId( (*mdt_it)->identify() ) ; - - if ( amdbtransform == false ) { // shouldn't this be done all the time? since there are 2 detector elements (one for each ml) per collection! - const MuonGM::MdtReadoutElement* detEl = (*mdt_it)->detectorElement() ; - globalToStation = detEl->GlobalToAmdbLRSTransform(); - amdbtransform = true; - } - - Amg::Vector3D tubePos = (*mdt_it)->globalPosition(); - Amg::Vector3D tubePosLoc = globalToStation*tubePos; - - rawMdtHit->setId( fID ); - rawMdtHit->setLocalPosition( tubePosLoc ); - rawMdtHit->setGlobalPosition( tubePos ); - rawMdtHit->setAdc( (*mdt_it)->adc() ); - rawMdtHit->setTdc( (*mdt_it)->tdc() ); - rawMdtHit->setDriftTime( 0. ); - rawMdtHit->setDriftRadius( (*mdt_it)->localPosition()[Trk::locR] ); - rawMdtHit->setDriftRadiusError( 1./std::sqrt((*mdt_it)->localCovariance()(Trk::locR,Trk::locR)) ); - - int occupancy = 0; - std::map<MuonFixedId, int>::const_iterator position = mdtMap.find( fID ); - - if( position == mdtMap.end() ) - occupancy = -1; //ID of RawHit not found on any segment - else - occupancy = position->second; //ID of RawHit found n times on a segment in this event - rawMdtHit->setOccupancy(occupancy); - - rawHits->addMuonCalibRawHit( rawMdtHit ); - } - } - } // if ( m_doMDTs ) - - if ( m_doRPCs ) { - //RPC raw hits... - - std::vector<const Muon::RpcPrepDataCollection*> rpcCols; - const Muon::RpcPrepDataContainer* rpcPrds = 0; - if( !evtStore()->contains<Muon::RpcPrepDataContainer>("RPC_Measurements") ){ - ATH_MSG_DEBUG("RpcPrepDataContainer RPC_Measurements not contained in SG"); - }else if(evtStore()->retrieve(rpcPrds,"RPC_Measurements").isFailure()) { - ATH_MSG_DEBUG("Cannot retrieve RpcPrepDataContainer RPC_Measurements"); - }else{ - ATH_MSG_DEBUG("Retrieved RpcPrepDataContainer "); - - rpcCols.reserve(rpcPrds->size()); // number of rpc chambers - Muon::RpcPrepDataContainer::const_iterator it = rpcPrds->begin(); - Muon::RpcPrepDataContainer::const_iterator it_end = rpcPrds->end(); - for( ; it!=it_end; ++it ) { - rpcCols.push_back( *it ); - } - } - - std::vector< const Muon::RpcPrepDataCollection*>::const_iterator rpcCollection = rpcCols.begin(); - std::vector< const Muon::RpcPrepDataCollection*>::const_iterator rpclastColl = rpcCols.end(); - for ( ; rpcCollection != rpclastColl ; ++rpcCollection ) - { - Muon::RpcPrepDataCollection::const_iterator rpc_it = (*rpcCollection)->begin(); - Muon::RpcPrepDataCollection::const_iterator rpc_it_end = (*rpcCollection)->end(); - for( ; rpc_it!=rpc_it_end; ++ rpc_it){ - - MuonCalibRawRpcHit* rawRpcHit = createRawRpcHit(**rpc_it); - - int occupancy = 0; - std::map<MuonFixedId, int>::const_iterator position = rpcMap.find( rawRpcHit->identify() ); - if( position == rpcMap.end() ) occupancy = -1; //ID of RawHit not found on any segment - else occupancy = position->second; //ID of RawHit found n times on a segment in this event - rawRpcHit->setOccupancy(occupancy); - - rawHits->addMuonCalibRawHit( rawRpcHit ); - } - } - } // if ( m_doRPCs ) - - if ( m_doCSCs ) { - //CSC raw hits... - - std::vector<const Muon::CscStripPrepDataCollection*> cscCols; - const Muon::CscStripPrepDataContainer* cscPrds = 0; - if( !evtStore()->contains<Muon::CscStripPrepDataContainer>("CSC_Measurements") ){ - ATH_MSG_DEBUG("CscPrepDataContainer CSC_Measurements not contained in SG"); - }else if(evtStore()->retrieve(cscPrds,"CSC_Measurements").isFailure()) { - ATH_MSG_DEBUG("Cannot retrieve CscPrepDataContainer CSC_Measurements"); - }else{ - ATH_MSG_DEBUG("Retrieved CscPrepDataContainer "); - - cscCols.reserve(cscPrds->size()); - Muon::CscStripPrepDataContainer::const_iterator it = cscPrds->begin(); - Muon::CscStripPrepDataContainer::const_iterator it_end = cscPrds->end(); - for( ; it!=it_end; ++it ) { - cscCols.push_back( *it ); - } - } - - std::vector< const Muon::CscStripPrepDataCollection*>::const_iterator cscCollection = cscCols.begin(); - std::vector< const Muon::CscStripPrepDataCollection*>::const_iterator csclastColl = cscCols.end(); - - for ( ; cscCollection != csclastColl ; ++cscCollection ) - { - Muon::CscStripPrepDataCollection::const_iterator csc_it = (*cscCollection)->begin(); - Muon::CscStripPrepDataCollection::const_iterator csc_it_end = (*cscCollection)->end(); - for( ; csc_it!=csc_it_end; ++ csc_it){ - - MuonCalibRawCscHit* rawCscHit = new MuonCalibRawCscHit(); - MuonFixedId fID = m_idToFixedIdTool->idToFixedId( (*csc_it)->identify() ) ; - rawCscHit->setGlobalPosition( (*csc_it)->globalPosition() ); - rawCscHit->setId( fID ); - // time of first sample is not very useful. we need fitted time - // invoke fitter first and then set the time - int measuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi((*csc_it)->identify()); - int chamberLayer = m_idHelperSvc->cscIdHelper().chamberLayer((*csc_it)->identify()); - float stripWidth = (*csc_it)->detectorElement()->cathodeReadoutPitch( chamberLayer, measuresPhi ); - rawCscHit->setWidth( stripWidth ); - // invoke the strip fitter to fit the time samples (which is a vector of 4 elements) - // fitter outputs the sample charge, time etc. which we can store here - ICscStripFitter::Result fitres; // fit result will be here - fitres = m_stripFitter->fit(**csc_it); - rawCscHit->setCharge(fitres.charge); - rawCscHit->setT(fitres.time); - - int occupancy = 0; - std::map<MuonFixedId, int>::const_iterator position = cscMap.find( fID ); - if( position == cscMap.end() ) occupancy = -1; //ID of RawHit not found on any segment - else occupancy = position->second; //ID of RawHit found n times on a segment in this event - rawCscHit->setOccupancy(occupancy); - - rawHits->addMuonCalibRawHit( rawCscHit ); - } - } - } // if ( m_doCSCs ) - - if ( m_doTGCs ) { - //TGC raw hits... - - std::vector<const Muon::TgcPrepDataCollection*> tgcCols; - const Muon::TgcPrepDataContainer* tgcPrds[3] = { 0, 0, 0 }; - - for(int ibc=0; ibc<3; ibc++){ - int bcTag=ibc+1; - std::ostringstream location; - location << "TGC_Measurements" << (bcTag==TgcDigit::BC_PREVIOUS ? "PriorBC" : "") - << (bcTag==TgcDigit::BC_NEXT ? "NextBC" : ""); - - if( !evtStore()->contains<Muon::TgcPrepDataContainer>(location.str()) ){ - ATH_MSG_DEBUG("Cannot retrieve TgcPrepDataContainer " << location.str()); - }else if(evtStore()->retrieve(tgcPrds[ibc],location.str()).isFailure()) { - ATH_MSG_DEBUG("Cannot retrieve TgcPrepDataContainer " << location.str()); - }else{ - ATH_MSG_DEBUG("Retrieved TgcPrepDataContainer " << location.str()); - - tgcCols.clear(); - tgcCols.reserve(tgcPrds[ibc]->size()); // number of tgc chambers - Muon::TgcPrepDataContainer::const_iterator it = tgcPrds[ibc]->begin(); - Muon::TgcPrepDataContainer::const_iterator it_end = tgcPrds[ibc]->end(); - for( ; it!=it_end; ++it ) { - tgcCols.push_back( *it ); - } - } - - std::vector< const Muon::TgcPrepDataCollection*>::const_iterator tgcCollection = tgcCols.begin(); - std::vector< const Muon::TgcPrepDataCollection*>::const_iterator tgclastColl = tgcCols.end(); - for ( ; tgcCollection != tgclastColl ; ++tgcCollection ) - { - Muon::TgcPrepDataCollection::const_iterator tgc_it = (*tgcCollection)->begin(); - Muon::TgcPrepDataCollection::const_iterator tgc_it_end = (*tgcCollection)->end(); - for( ; tgc_it!=tgc_it_end; ++ tgc_it){ - MuonCalibRawTgcHit* rawTgcHit = new MuonCalibRawTgcHit(); - MuonFixedId fID = m_idToFixedIdTool->idToFixedId( (*tgc_it)->identify() ) ; - bool measuresPhi = (bool) m_idHelperSvc->tgcIdHelper().isStrip((*tgc_it)->identify()); - int gasGap = m_idHelperSvc->tgcIdHelper().gasGap((*tgc_it)->identify()); - int channel = m_idHelperSvc->tgcIdHelper().channel((*tgc_it)->identify()); - - const MuonGM::TgcReadoutElement* detEl = (*tgc_it)->detectorElement(); - double width = -999.; - double short_width = -999.; - double long_width = -999.; - double length = -999.; - if(measuresPhi){ - width = detEl->stripWidth(gasGap,channel); - short_width = detEl->stripShortWidth(gasGap, channel); - long_width = detEl->stripLongWidth(gasGap, channel); - length = detEl->stripLength(gasGap, channel); - }else{ //measures Eta: gangs, not strips - width = detEl->gangLength(gasGap,channel); - short_width = detEl->gangShortWidth(gasGap, channel); - long_width = detEl->gangLongWidth(gasGap, channel); - length = detEl->gangThickness(gasGap, channel); - } - - rawTgcHit->setId( fID ); - rawTgcHit->setGlobalPosition( (*tgc_it)->globalPosition() ); - rawTgcHit->setStation( m_idHelperSvc->tgcIdHelper().stationName((*tgc_it)->identify()) ); - rawTgcHit->setEta( m_idHelperSvc->tgcIdHelper().stationEta((*tgc_it)->identify()) ); - rawTgcHit->setPhi( m_idHelperSvc->tgcIdHelper().stationPhi((*tgc_it)->identify()) ); - rawTgcHit->setGasGap( gasGap ); - rawTgcHit->setIsStrip( static_cast<int>(measuresPhi) ); - rawTgcHit->setChannel( channel ); - rawTgcHit->setBcTag( bcTag ); - - rawTgcHit->setWidth( width ); - rawTgcHit->setShortWidth( short_width ); - rawTgcHit->setLongWidth( long_width ); - rawTgcHit->setLength( length ); - - int occupancy = 0; - std::map<MuonFixedId, int>::const_iterator position = tgcMap.find( fID ); - if( position == tgcMap.end() ) occupancy = -1; //ID of RawHit not found on any segment - else occupancy = position->second; //ID of RawHit found n times on a segment in this event - rawTgcHit->setOccupancy(occupancy);//Will be filled after loop over hits assigned to segment; - - rawHits->addMuonCalibRawHit( rawTgcHit ); - - } - } - } - } // if ( m_doTGCs ) - - // TGC raw coin... - if( m_doTGCCoin ){ - std::vector<const Muon::TgcCoinDataCollection*> tgcCoinCols; - const Muon::TgcCoinDataContainer* tgcCoinPrds[3] = { 0, 0, 0 }; - - for(int ibc=0; ibc<3; ibc++){ - int bcTag=ibc+1; - std::ostringstream location; - location << "TrigT1CoinDataCollection" << (bcTag==TgcDigit::BC_PREVIOUS ? "PriorBC" : "") - << (bcTag==TgcDigit::BC_NEXT ? "NextBC" : ""); - if( !evtStore()->contains<Muon::TgcCoinDataContainer>(location.str()) ){ - ATH_MSG_DEBUG("TgcCoinDataContainer not contained in SG at" << location.str()); - }else if(evtStore()->retrieve(tgcCoinPrds[ibc],location.str()).isFailure()) { - ATH_MSG_DEBUG("Cannot retrieve TgcCoinDataContainer" << location.str()); - }else{ - ATH_MSG_DEBUG("Retrieved TgcCoinDataContainer " << location.str()); - - tgcCoinCols.clear(); - tgcCoinCols.reserve(tgcCoinPrds[ibc]->size()); // number of tgcCoin chambers - Muon::TgcCoinDataContainer::const_iterator it = tgcCoinPrds[ibc]->begin(); - Muon::TgcCoinDataContainer::const_iterator it_end = tgcCoinPrds[ibc]->end(); - for( ; it!=it_end; ++it ) { - tgcCoinCols.push_back( *it ); - } - } - - std::vector< const Muon::TgcCoinDataCollection*>::const_iterator tgcCoinCollection = tgcCoinCols.begin(); - std::vector< const Muon::TgcCoinDataCollection*>::const_iterator tgcCoinlastColl = tgcCoinCols.end(); - - for ( ; tgcCoinCollection != tgcCoinlastColl ; ++tgcCoinCollection ) - { - Muon::TgcCoinDataCollection::const_iterator tgcCoin_it = (*tgcCoinCollection)->begin(); - Muon::TgcCoinDataCollection::const_iterator tgcCoin_it_end = (*tgcCoinCollection)->end(); - for( ; tgcCoin_it!=tgcCoin_it_end; ++ tgcCoin_it){ - - if((*tgcCoin_it)->type()==Muon::TgcCoinData::TYPE_UNKNOWN || - (*tgcCoin_it)->type()==Muon::TgcCoinData::TYPE_TRACKLET_EIFI) continue; - - MuonCalibRawTgcCoin* rawTgcCoin = new MuonCalibRawTgcCoin(); - MuonFixedId fID = m_idToFixedIdTool->idToFixedId( (*tgcCoin_it)->identify() ) ; - rawTgcCoin->setId( fID ); - - //*** calculation of sector ***// - int sector=-1; - if((*tgcCoin_it)->isForward()){//forward - sector=(*tgcCoin_it)->phi()/2+1;//(phi,sector)= (1,1), (2,2), (3,2), (4,3) - }else{//endcap - sector=((*tgcCoin_it)->phi()+1)/4+1;//(phi,sector)= (1,1), (2,1), (3,2), (4,2) - } - if(sector>12)sector=1; - //*** calculation of sector end ***// - - if((*tgcCoin_it)->type()==Muon::TgcCoinData::TYPE_TRACKLET){ - rawTgcCoin->setGlobalPositionIn((*tgcCoin_it)->globalposIn()); - rawTgcCoin->setGlobalPositionOut((*tgcCoin_it)->globalposOut()); - rawTgcCoin->setType(0); - rawTgcCoin->setEta(m_idHelperSvc->tgcIdHelper().stationEta((*tgcCoin_it)->identify())); - rawTgcCoin->setPhi((*tgcCoin_it)->phi()); - rawTgcCoin->setSector(sector); - rawTgcCoin->setIsForward(static_cast<int>((*tgcCoin_it)->isForward())); - rawTgcCoin->setIsStrip(static_cast<int>((*tgcCoin_it)->isStrip())); - rawTgcCoin->setTrackletId((*tgcCoin_it)->trackletId()); - rawTgcCoin->setTrackletIdStrip(0); - rawTgcCoin->setBcTag(bcTag); - rawTgcCoin->setWidthIn((*tgcCoin_it)->widthIn()); - rawTgcCoin->setWidthOut((*tgcCoin_it)->widthOut()); - rawTgcCoin->setWidthR(0); - rawTgcCoin->setWidthPhi(0); - rawTgcCoin->setDelta((*tgcCoin_it)->delta()); - rawTgcCoin->setRoi(0); - rawTgcCoin->setPt(0); - rawTgcCoin->setSub((*tgcCoin_it)->sub()); - rawTgcCoin->setIsPositiveDeltaR(0); - } else if((*tgcCoin_it)->type()==Muon::TgcCoinData::TYPE_HIPT){ - rawTgcCoin->setGlobalPositionIn((*tgcCoin_it)->globalposIn()); - rawTgcCoin->setGlobalPositionOut((*tgcCoin_it)->globalposOut()); - rawTgcCoin->setType(1); - rawTgcCoin->setEta(m_idHelperSvc->tgcIdHelper().stationEta((*tgcCoin_it)->identify())); - rawTgcCoin->setPhi((*tgcCoin_it)->phi()); - rawTgcCoin->setSector(sector); - rawTgcCoin->setIsForward(static_cast<int>((*tgcCoin_it)->isForward())); - rawTgcCoin->setIsStrip(static_cast<int>((*tgcCoin_it)->isStrip())); - rawTgcCoin->setTrackletId((*tgcCoin_it)->trackletId()); - rawTgcCoin->setTrackletIdStrip(0); - rawTgcCoin->setBcTag(bcTag); - rawTgcCoin->setWidthIn((*tgcCoin_it)->widthIn()); - rawTgcCoin->setWidthOut((*tgcCoin_it)->widthOut()); - rawTgcCoin->setWidthR(0); - rawTgcCoin->setWidthPhi(0); - rawTgcCoin->setDelta((*tgcCoin_it)->delta()); - rawTgcCoin->setRoi(0); - rawTgcCoin->setPt(0); - rawTgcCoin->setSub((*tgcCoin_it)->sub()); - rawTgcCoin->setIsPositiveDeltaR(0); - } else if((*tgcCoin_it)->type()==Muon::TgcCoinData::TYPE_SL){ - Amg::Vector3D tmp(0.0,0.0,0.0); - rawTgcCoin->setGlobalPositionIn(tmp); - rawTgcCoin->setGlobalPositionOut((*tgcCoin_it)->globalposOut()); - rawTgcCoin->setType(2); - rawTgcCoin->setEta(m_idHelperSvc->tgcIdHelper().stationEta((*tgcCoin_it)->identify())); - rawTgcCoin->setPhi((*tgcCoin_it)->phi()); - rawTgcCoin->setSector(sector); - rawTgcCoin->setIsForward(static_cast<int>((*tgcCoin_it)->isForward())); - rawTgcCoin->setIsStrip(static_cast<int>((*tgcCoin_it)->isStrip())); - rawTgcCoin->setTrackletId((*tgcCoin_it)->trackletId()); - rawTgcCoin->setTrackletIdStrip((*tgcCoin_it)->trackletIdStrip()); - rawTgcCoin->setBcTag(bcTag); - rawTgcCoin->setWidthIn(0); - rawTgcCoin->setWidthOut(0); - double w1 = 1./std::sqrt((*tgcCoin_it)->errMat()(Trk::loc1,Trk::loc2)); - double w2 = 1./std::sqrt((*tgcCoin_it)->errMat()(Trk::loc2,Trk::loc2)); - rawTgcCoin->setWidthR(w1); - rawTgcCoin->setWidthPhi(w2); - rawTgcCoin->setDelta(0); - rawTgcCoin->setRoi((*tgcCoin_it)->roi()); - rawTgcCoin->setPt((*tgcCoin_it)->pt()); - rawTgcCoin->setSub(0); - rawTgcCoin->setIsPositiveDeltaR((*tgcCoin_it)->isPositiveDeltaR()); - } - - rawHits->addMuonCalibRawHit( rawTgcCoin ); - } - } - } - } // if ( m_doTGCCoin ) - - if( m_doRPCCoin ){ - const Muon::RpcCoinDataContainer* rpcCoinContainer = 0; - if( !evtStore()->contains<Muon::RpcCoinDataContainer>("RPC_triggerHits") ){ - ATH_MSG_DEBUG("RpcCoinDataContainer not contained in SG"); - }else if(evtStore()->retrieve(rpcCoinContainer,"RPC_triggerHits").isFailure()) { - ATH_MSG_DEBUG("Cannot retrieve RpcCoinDataContainer"); - }else{ - - ATH_MSG_DEBUG("Retrieved RpcCoinDataContainer " << rpcCoinContainer->numberOfCollections()); - - Muon::RpcCoinDataContainer::const_iterator it = rpcCoinContainer->begin(); - Muon::RpcCoinDataContainer::const_iterator it_end = rpcCoinContainer->end(); - for( ; it!=it_end; ++it ) { - const Muon::RpcCoinDataCollection* col = *it; - if( !col ) continue; - Muon::RpcCoinDataCollection::const_iterator cit = col->begin(); - Muon::RpcCoinDataCollection::const_iterator cit_end = col->end(); - for( ;cit!=cit_end;++cit ){ - if( !*cit ) continue; - const Muon::RpcCoinData& coinData = **cit; - MuonCalibRawRpcHit* rawRpc = createRawRpcHit(coinData); - if( !rawRpc ) continue; - bool lowPtCm = coinData.isLowPtCoin(); - MuonCalibRawRpcCoin* rawRpcCoin = new MuonCalibRawRpcCoin(*rawRpc, - coinData.ijk(), - coinData.threshold(), - coinData.overlap(), - coinData.parentCmId(), - coinData.parentPadId(), - coinData.parentSectorId(), - lowPtCm); - rawHits->addMuonCalibRawHit(rawRpcCoin); - - if(msgLvl(MSG::DEBUG)){ - MuonCalibRawRpcCoin& hit = *rawRpcCoin; - ATH_MSG_DEBUG(" RpcCoinData: sector " << hit.parentSectorId() << " pad " << hit.parentPadId() - << " CLHEP::cm " << hit.parentCmId() << " ijk " << hit.ijk() << " lowPT " << hit.lowPtCm() - << " overlap " << hit.overlap() << " time " << hit.t() - << " eta " << hit.globalPosition().eta() - << " phi " << hit.globalPosition().phi()); - } - delete rawRpc; - } - } - } - } // if( m_doRPCCoin ) - - return rawHits; - } - - const MuonCalibRawTriggerHitCollection* MuonCalibAlg::retrieveRawTriggerHits() const{ - // Rpc trigger hits - const RpcPadContainer* rpcRDO = nullptr; - const RpcPad* rdoColl = nullptr; - MuonCalibRawTriggerHitCollection* rawTriggerHits = new MuonCalibRawTriggerHitCollection(); - if( !evtStore()->contains<RpcPadContainer>("RPCPAD") ){ - ATH_MSG_DEBUG("RpcPadContainer not contained in SG"); - }else if(evtStore()->retrieve(rpcRDO,"RPCPAD").isFailure()) { - ATH_MSG_DEBUG("Cannot retrieve RpcPadContainer"); - }else{ - ATH_MSG_VERBOSE("Retrieved RawRpcTriggerDataContainer " << rpcRDO->numberOfCollections()); - for (RpcPadContainer::const_iterator rdoColli = rpcRDO->begin(); rdoColli!=rpcRDO->end(); ++rdoColli){ - rdoColl = *rdoColli; - // Now loop on the RDO - if ( (rdoColl)->size() != 0 ) { // number of cma/pad - // for each pad, loop over cma - RpcPad::const_iterator it_cma = (rdoColl)->begin(); - RpcPad::const_iterator it_cma_end = (rdoColl)->end(); - for (; it_cma!=it_cma_end; ++it_cma) { - const RpcCoinMatrix * cma = (*it_cma); - //for each cma loop over fired channels - ATH_MSG_DEBUG("Number of fired channels for this CM is " << (cma)->size()); - RpcCoinMatrix::const_iterator it_chan = (*it_cma)->begin(); - RpcCoinMatrix::const_iterator it_chan_end = (*it_cma)->end(); - for (; it_chan!=it_chan_end; ++it_chan) { - const RpcFiredChannel * fChannel = (*it_chan); - //Make a new trigger hit - MuonCalibRawRpcTriggerHit* rawRpcTriggerHit = new MuonCalibRawRpcTriggerHit( (rdoColl)->sector(), - (rdoColl)->onlineId(), - (rdoColl)->status(), - (rdoColl)->errorCode(), - cma->onlineId(), - cma->fel1Id(), - cma->febcId(), - cma->crc(), - fChannel->bcid(), - fChannel->time(), - fChannel->ijk(), - fChannel->channel(), - fChannel->ijk() == 7 ? fChannel->ovl() : -1, - fChannel->ijk() == 7 ? fChannel->thr() : -1 ); - //and push it back! - rawTriggerHits->addMuonCalibRawTriggerHit(rawRpcTriggerHit); - } - } - } - } //for (RpcPadContainer::const_iterator rdoColli.... - } - ATH_MSG_VERBOSE("rawTriggerHits for this event has " << rawTriggerHits->numberOfMuonCalibRawRpcTriggerHits() << " RPC trigger hits "); - return rawTriggerHits; - } - - const MuonCalibEvent* MuonCalibAlg::retrieveEvent() const { - //Retrieve all ingredients needed to build an MuonCalibEvent - MuonCalibEventInfo eventInfo = retrieveEventInfo(); - - const MuonCalibEvent::MCPVec patterns = retrievePatterns(); - - MuonCalibEvent* event = new MuonCalibEvent( patterns ); - - const MuonCalibTriggerTimeInfo* triggerTimeInfo = retrieveTriggerTimeInfo(); - if(triggerTimeInfo) event->setMuonCalibTriggerTimeInfo( triggerTimeInfo ); - - if(m_doRawData){ - //After constructing the patternVector, use this to set occupancy values - //of the raw hits in the MuonCalibRawHitCollection. - const MuonCalibRawHitCollection* rawHits = retrieveRawHits( patterns ); - event->setMuonCalibRawHitCollection( rawHits ); - } else event->setMuonCalibRawHitCollection( 0 ); - - if( m_doRPCTriggerHits ){ - const MuonCalibRawTriggerHitCollection* trighits = retrieveRawTriggerHits(); - event->setMuonCalibRawTriggerHitCollection( trighits ); - } else event->setMuonCalibRawTriggerHitCollection( 0 ); - - if(m_doTruth){ - const MuonCalibTruthCollection* truth = retrieveTruthCollection(); - event->setMuonCalibTruthCollection( truth ); - } else event->setMuonCalibTruthCollection( 0 ); - - if( m_doRpcSectorLogic ){ - const RpcSectorLogicContainer* slLogic = nullptr; - if( !evtStore()->contains<RpcSectorLogicContainer>("") ){ - ATH_MSG_DEBUG(" RpcSectorLogicContainer not contained in SG"); - }else if(evtStore()->retrieve(slLogic).isFailure()) { - ATH_MSG_DEBUG("Cannot retrieve RpcSectorLogicContainer"); - } - event->setRpcSectorLogicContainer(slLogic); - - if( slLogic ){ - const RpcSectorLogicContainer& slContainer = *slLogic; - // loop over container - RpcSectorLogicContainer::const_iterator slit = slContainer.begin(); - RpcSectorLogicContainer::const_iterator slit_end = slContainer.end(); - for( ;slit!=slit_end;++slit ){ - const RpcSectorLogic& slLogic = **slit; - if( slLogic.empty() ) continue; - ATH_MSG_DEBUG(" RpcSectorLogic: sector " << slLogic.sectorId() - << " felId " << slLogic.fel1Id() - << " bcId " << slLogic.bcid() - << " errCode " << slLogic.errorCode() - << " crc " << slLogic.crc()); - RpcSectorLogic::const_iterator hitIt = slLogic.begin(); - RpcSectorLogic::const_iterator hitIt_end = slLogic.end(); - for( ;hitIt != hitIt_end; ++hitIt ){ - const RpcSLTriggerHit& slHit = **hitIt; - ATH_MSG_DEBUG(" hit: rowinBcid " << slHit.rowinBcid() - << " padId " << slHit.padId() - << " ptid " << slHit.ptId() - << " roi " << slHit.roi() - << " outerPlane" << slHit.outerPlane() - << " overlapPhi " << slHit.overlapPhi() - << " overlapEta " << slHit.overlapEta() - << " triggerBcid " << slHit.triggerBcid() - << " isInput" << slHit.isInput()); - } - } - } - } - event->setMuonCalibEventInfo( eventInfo ); - return event; - } - - MuonCalibRawRpcHit* MuonCalibAlg::createRawRpcHit( const Muon::RpcPrepData& prd ) const { - MuonCalibRawRpcHit* rawRpcHit = new MuonCalibRawRpcHit(); - MuonFixedId fID = m_idToFixedIdTool->idToFixedId( prd.identify() ) ; - rawRpcHit->setGlobalPosition( prd.globalPosition() ); - rawRpcHit->setId( fID ); - rawRpcHit->setT( prd.time() ); - // get detector element - const MuonGM::RpcReadoutElement* detEl = prd.detectorElement(); - rawRpcHit->setWidth( detEl->StripWidth( m_idHelperSvc->rpcIdHelper().measuresPhi(prd.identify()) ) ); - rawRpcHit->setLength( detEl->StripLength(m_idHelperSvc->rpcIdHelper().measuresPhi(prd.identify()))); - return rawRpcHit; - } - -}//end namespace MuonCalib - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/src/components/MuonCalibAlgs_entries.cxx b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/src/components/MuonCalibAlgs_entries.cxx deleted file mode 100644 index 4b3c23806a4479a05644fd5f428ab1f56df3bb73..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/src/components/MuonCalibAlgs_entries.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "MuonCalibAlgs/MuonCalibAlg.h" - -using namespace MuonCalib; - -DECLARE_COMPONENT( MuonCalibAlg ) - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/CMakeLists.txt deleted file mode 100644 index 60a7de2ec5133eb94b6371ce6fed1c69480714d6..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -################################################################################ -# Package: MuonCalibJobTransforms -################################################################################ - -# Declare the package name: -atlas_subdir( MuonCalibJobTransforms ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Tools/PyJobTransformsCore ) - -# Install files from the package: -atlas_install_python_modules( python/*.py ) -atlas_install_runtime( share/RT_default_comm.dat ) - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/GetFitBy.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/GetFitBy.py deleted file mode 100644 index 0cb344b271308795ca69889bac3703dc66b9b2b5..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/GetFitBy.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from __future__ import print_function - -import os - -def GetFitBy(region_string, joblist="joblist.txt", default="CHAMBER"): - if not os.path.exists(joblist): - print ("WARNING", joblist, "does not exist. Using defalut", default) - return default - reg_items=region_string.replace("[", "").replace("]", "").split(",") - if len(reg_items)!=3: - print ("WARNING Cannot interpret region string for GetFitBy. Using default", default) - return default - try: - station_nm=reg_items[0].strip() - station_phi=int(reg_items[1]) - station_eta=int(reg_items[2]) - except ValueError: - print ("WARNING Failed to interpret region string for GetFitBy. Using default", default) - return default - - inf=open(joblist) - inf.readline() - for line in inf.readlines(): - items=line.split() - if not len(items)==4: - continue - try: - ln_station=items[0] - ln_eta=int(items[1]) - ln_phi=int(items[2]) - except ValueError: - continue - if station_nm==ln_station and station_phi==ln_phi and station_eta==ln_eta: - return items[3] - - print ("WARNING", region_string, "not found in joblist. Using default ", default) - return default diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibFitConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibFitConfig.py deleted file mode 100644 index 68e805b4cb7fd3a8992dbaeda3dc74b9fbc80602..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibFitConfig.py +++ /dev/null @@ -1,344 +0,0 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -import os -__all__ = [] - -from PyJobTransformsCore.TransformConfig import * -import PyJobTransformsCore.basic_trfarg as trfarg - -# define configuration properties -class MDTCalibFitConfig(TransformConfig): - # prevent any mistypings by not allowing dynamic members - __slots__ = () - - # list of attributes - postOptions = String("jobOptions fragment to be appended at the end of the skeleton", None) - CalibrationSite = String("Calibration Site", "NONE") - PostProcessCalibration = Boolean("Set to true if you want to insert the calibration constants to the database", True) - NoRecalculation = Boolean("If set to true no drift ties and drift radii will be recalculated. Use this for validation", False) - SelectStation = String("Select Station", "BIL") - SelectEta = Integer("Select Eta", 3) - SelectPhi = Integer("Select Phi", 3) - CalibInputLocation = String("Input Location", None) - outputLocation = String("Output Location", None) - - def __init__(self,name='mdtCalibFitConfig',metaData=None): - TransformConfig.__init__(self,name,metaData) - self.maxeventsstrategy = 'ABORT' - - -class CalibrationAlgorithmArg(trfarg.StringChoicesArg): - """choose here the calibration algorithm to use""" - def __init__(self, choices, caseSensitive=False, help='calibration algorithm to be used', name='calibrationAlgorithm'): - trfarg.StringChoicesArg.__init__(self, choices, help, name, caseSensitive) - def isFullArgument(self): - return True - -class SelectChamberArg(trfarg.StringArg): - """chamber selection""" - def __init__(self, help='select the chamber to be used', name='selectChamber'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class CalibNtupleFileListArg(trfarg.StringArg): - """calibration ntuple file list name""" - def __init__(self, help='calibration ntuple file list to be used', name='calibNtupleFileList'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class CalibSiteArg(trfarg.StringArg): - """calibration site name""" - def __init__(self, help='select the calibration site name', name='calibSite'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class WriteToDBArg(trfarg.BoolArg): - """If set to false, write only to calibration files""" - def __init__(self, help='If set to false, write only to calibration files', name='writeToDB'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class T0FitByArg(trfarg.StringChoicesArg): - """set the tube grouping for the t0 fit""" - def __init__(self, help="set the tube grouping for the t0 fit", name='t0FitBy'): - trfarg.StringChoicesArg.__init__(self, ['AUTO','TUBE', 'LAYER', 'MULTILAYER', 'MEZZ_CARD', 'TUBE'], help, name, True) - def isFullArgument(self): - return True - -class MuonRecoArg(trfarg.IntegerArg): - """select muon reconstruction alg 3=Muonboy 4=Moore""" - def __init__(self, help="select muon reconstruction alg 3=Muonboy 4=Moore", name='MuonReco'): - trfarg.IntegerArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class ADCFitByArg(trfarg.StringChoicesArg): - """set the tube grouping for the adc fit""" - def __init__(self, help="set the tube grouping for the adc fit", name='adcFitBy'): - trfarg.StringChoicesArg.__init__(self, ['TUBE', 'LAYER', 'MULTILAYER', 'MEZZ_CARD', 'TUBE'], help, name, True) - def isFullArgument(self): - return True - -class RefineT0Arg(trfarg.BoolArg): - """ """ - def __init__(self, help=' ', name='refineT0'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class SegmentRefitArg(trfarg.BoolArg): - """perform a segment refit - not for algorithms like MTT0, Integration, RunScan.. """ - def __init__(self, help='perform a segment refit - not for algorithms like MTT0, Integration, RunScan..', name='segmentRefit'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class InputFromDBArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='inputFromDB'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class InputFromFileArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='inputFromFile'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class OutputToDBArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='outputToDB'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class HeadIdArg(trfarg.IntegerArg): - """ calibration DB header used (if -1 take the last one) """ - def __init__(self, help='', name='headId'): - trfarg.IntegerArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class OutputToFileArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='outputToFile'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class MdtDqaFileArg(trfarg.StringArg): - """ """ - def __init__(self, help='', name='mdtDqaFile'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class FillHistosArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='fillHistos'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class DoFinalizeArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='doFinalize'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class DoEfficiencyArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='doEfficiency'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class DoGlobalTimeFitArg(trfarg.BoolArg): - """ """ - def __init__(self, help='', name='doGlobalTimeFit'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class SuppressRecalibrationArg(trfarg.BoolArg): - """ suppress any refit of the segments """ - def __init__(self, help='', name='suppressRecalibration'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class SegsFromRawArg(trfarg.BoolArg): - """ Compute segments from raw hits """ - def __init__(self, help='', name='segsFromRaw'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class CurvedSegsArg(trfarg.BoolArg): - """ Use curved traks to fit hits """ - def __init__(self, help='', name='curvedSegs'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class BfieldCorrArg(trfarg.BoolArg): - """ Apply Bfield corrections """ - def __init__(self, help='', name='bfieldCorr'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class HitResidArg(trfarg.BoolArg): - """ MdtDqa: residuals vs radius """ - def __init__(self, help='', name='hitResid'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class DeadElAlgArg(trfarg.IntegerArg): - """ MdtDqa: Dead Element calculation algorithm """ - def __init__(self, help='', name='DeadElAlg'): - trfarg.IntegerArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class ADCcutArg(trfarg.FloatArg): - """ MdtDqa: ADC cut value """ - def __init__(self, help='', name='ADCcut'): - trfarg.FloatArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class EffNsigArg(trfarg.FloatArg): - """ MdtDqa: N sigma cut for efficiency calculation """ - def __init__(self, help='', name='EffNsig'): - trfarg.FloatArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class EffChiCutArg(trfarg.FloatArg): - """ MdtDqa: chi2 cut in efficiency calculation """ - def __init__(self, help='', name='EffChiCut'): - trfarg.FloatArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class EffUseDefResArg(trfarg.BoolArg): - """ MdtDqa: choose default resolution """ - def __init__(self, help='', name='EffUseDefRes'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - - -class EffiGtfArg(trfarg.BoolArg): - """ MdtDqa: use GTF in efficiency calculation """ - def __init__(self, help='', name='effiGtf'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class EffiReCalArg(trfarg.BoolArg): - """ MdtDqa: recalibrate hits in efficiency calculation """ - def __init__(self, help='', name='effiReCal'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class EffiTimeCorrArg(trfarg.BoolArg): - """ MdtDqa: use timing corrections in efficiency calculation """ - def __init__(self, help='', name='effiTimeCorr'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class TrackPCut(trfarg.FloatArg): - """ TrackPCut <=-2: No segmen t on track selection - -2<TrackPCut<=-1: Select segments on any track - -1<TrackPCut<=0: Select segments on a track with a valid momentum measurement - TrackPCut>0: Select segments on a track with the given p-cut. """ - def __init__(self, help="""TrackPCut <=-2: No segmen t on track selection - -2<TrackPCut<=-1: Select segments on any track - -1<TrackPCut<=0: Select segments on a track with a valid momentum measurement - TrackPCut>0: Select segments on a track with the given p-cut. """, name='trackPCut'): - trfarg.FloatArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class FastTrackMatch(trfarg.BoolArg): - """ Use faster tsegment to track matching """ - def __init__(self, help="Use faster segment to track matching", name="fastTrackMatch"): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class SuperFastTrackMatch(trfarg.BoolArg): - """ Use segment on track info in ntuple """ - def __init__(self, help="Use faster segment to track matching", name="superFastTrackMatch"): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class ApplyTimeSlewingCorrection(trfarg.BoolArg): - """ Apply Time Slewing Corrections """ - def __init__(self, help=" Apply Time Slewing Corrections", name="applyTimeSlewingCorrection"): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class ApplyRtScaling(trfarg.BoolArg): - """Apply multilayerwise rt scaling""" - def __init__(self, help= "Apply multilayerwise rt scaling", name="applyRtScaling"): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self) : - return True - -class SplitterStoreRaw(trfarg.BoolArg): - """Store raw branches in splitter""" - def __init__(self, help= "Store raw branches in splitter", name="splitterStoreRaw"): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self) : - return True - -class SplitterStoreTracks(trfarg.BoolArg): - """Store track branches in splitter""" - def __init__(self, help= "Store track branches in splitter", name="splitterStoreTracks"): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self) : - return True - -class SplitterSplitLevel(trfarg.StringChoicesArg): - """ntuple split level""" - def __init__(self, help="ntuple slpit level", name='splitLevel'): - trfarg.StringChoicesArg.__init__(self, ['NONE', "NAME", "NAME_PHI", "NAME_PHI_ETA"], help, name, True) - def isFullArgument(self): - return True - -class SplitterADCCut(trfarg.IntegerArg): - """ADC cut on rawdata""" - def __init__(self, help='ADC cut on rawdata', name='splitterADCCut'): - trfarg.IntegerArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class SplitterMergeOutputFiles(trfarg.StringArg): - """List of files into which output files are merged""" - def __init__(self, help='List of files into which output files are merged', name='splitterMergeOutputFiles'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - def setValue(self, value): - if value and self.value(): - value=self.value() + "," + str(value) - trfarg.StringArg.setValue(self, value) - - -# make configuration object -mdtCalibFitConfig = MDTCalibFitConfig() diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibFitValConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibFitValConfig.py deleted file mode 100644 index 3fcb695bb914393624e3d01d3ad4ae8f2317782b..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibFitValConfig.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -import os -__all__ = [] - -from PyJobTransformsCore.TransformConfig import * -import PyJobTransformsCore.basic_trfarg as trfarg - -# define configuration properties -class MDTCalibFitValConfig(TransformConfig): - # prevent any mistypings by not allowing dynamic members - __slots__ = () - - # list of attributes - CalibrationSite = String("Calibration Site", "NONE") - PostProcessCalibration = Boolean("Set to true if you want to insert the calibration constants to the database", True) - NoRecalculation = Boolean("If set to true no drift ties and drift radii will be recalculated. Use this for validation", False) - SelectStation = String("Select Station", "BIL") - SelectEta = Integer("Select Eta", 3) - SelectPhi = Integer("Select Phi", 3) - CalibInputLocation = String("Input Location", None) - outputLocation = String("Output Location", None) - postOptionsFitT0 = String("jobOptions fragment to be appended at the end of the T0 fit", None) - postOptionsValT0 = String("jobOptions fragment to be appended at the end of the T0 validation", None) - postOptionsFitRT = String("jobOptions fragment to be appended at the end of the RT fit", None) - postOptionsValRT = String("jobOptions fragment to be appended at the end of the RT validation", None) - - def __init__(self,name='mdtCalibFitValConfig',metaData=None): - TransformConfig.__init__(self,name,metaData) - self.maxeventsstrategy = 'ABORT' - - -# make configuration object -mdtCalibFitValConfig = MDTCalibFitValConfig() diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibNtupleConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibNtupleConfig.py deleted file mode 100644 index 01c85cec0f769d48940161a903ef3088fd49fdb6..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibNtupleConfig.py +++ /dev/null @@ -1,145 +0,0 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -import os -__all__ = [] - -from PyJobTransformsCore.TransformConfig import * -import PyJobTransformsCore.basic_trfarg as trfarg - -# define configuration properties -class MDTCalibNtupleConfig(TransformConfig): - # prevent any mistypings by not allowing dynamic members - __slots__ = () - - # list of attributes - postOptions = String("jobOptions fragment to be appended at the end of the skeleton", None) - #doMScombined = Boolean("Use MScombined", False) - #doMDT = Boolean("Process MDT hits", True) - #doRPC = Boolean("Process RPC hits", True) - #doMoMu = Boolean("Use NIKHEF cosmic pattern", True) - #doMoore = Boolean("Use Moore reconstruction", False) - ##doMuonBoy = Boolean("Use Muonboy reconstruction", False) - - def __init__(self,name='mdtCalibNtupleConfig',metaData=None): - TransformConfig.__init__(self,name,metaData) - self.maxeventsstrategy = 'ABORT' - -class DbT0TagArg(trfarg.StringArg): - """MDT T0 DB folder tag to be used, overwriting the one - from the global tag, set to 'DEFAULT' to keep global tag""" - def __init__(self, help='DB tag for T0', name='dbT0Tag'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return 'DEFAULT' - -class DbRTTagArg(trfarg.StringArg): - """MDT RT DB folder tag to be used, overwriting the one - from the global tag, set to 'DEFAULT' to keep global tag""" - def __init__(self, help='DB tag for RT', name='dbRTTag'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return 'DEFAULT' - -class DbT0SqlArg(trfarg.StringArg): - """SQLite file containing the MDT T0 folder to be used, overwriting default - COOL DB for that folder, set to 'DEFAULT' to keep default""" - def __init__(self, help='SQLite file for T0', name='dbT0Sql'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return 'DEFAULT' - -class DbRTSqlArg(trfarg.StringArg): - """SQLite file containing the MDT RT folder to be used, overwriting default - COOL DB for that folder, set to 'DEFAULT' to keep default""" - def __init__(self, help='SQLite file for RT', name='dbRTSql'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return 'DEFAULT' - -class UseAlignArg(trfarg.BoolArg): - """run segment reconstruction and not tracks""" - def __init__(self, help='run only segment reconstruction', name='useAlign'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class SegOnlyArg(trfarg.BoolArg): - """run segment reconstruction and not tracks""" - def __init__(self, help='run only segment reconstruction', name='segOnly'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class MooreArg(trfarg.BoolArg): - """select Moore for the reconstruction run before filling the calibration ntuple""" - def __init__(self, help='selected muon reconstruction', name='moore'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class MboyArg(trfarg.BoolArg): - """select Mboy for the reconstruction run before filling the calibration ntuple""" - def __init__(self, help='selected muon reocnstruction', name='mboy'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class StandaloneArg(trfarg.BoolArg): - """select 3rd chain for the reconstruction run before filling the calibration ntuple""" - def __init__(self, help='selected muon reocnstruction', name='standalone'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class DoSegmentT0FitArg(trfarg.BoolArg): - """ use the T0 refinement """ - def __init__(self, help='selected muon reocnstruction', name='doSegmentT0Fit'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class CalibNtupleDoSimArg(trfarg.BoolArg): - """process simulated data for the calibration ntuple""" - def __init__(self, help='process simulated data', name='doSim'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class DoCSCArg(trfarg.BoolArg): - """process CSC data""" - def __init__(self, help='process CSC data', name='doCSC'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class RawTgcArg(trfarg.BoolArg): - """put rawTgc and rawTgcCoin branches in calib ntuple""" - def __init__(self, help='put rawTgc and rawTgcCoin branches in calib ntuple', name='rawTgc'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class LumiBlockNumberFromCool(trfarg.BoolArg): - """get lumi block number from coditions database according to time-stamp """ - def __init__(self, help='get lumi block number from coditions database according to time-stamp', name='lumiBlockNumberFromCool'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class RunNumberFromCool(trfarg.BoolArg): - """get run number from coditions database according to time-stamp """ - def __init__(self, help='get run number from coditions database according to time-stamp', name='runNumberFromCool'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class CosmicRun(trfarg.BoolArg): - """Set to true if the run is a cosmic run. TOF will be set to 0 and time slewing correction will be applied""" - def __init__(self, help='Set to true if the run is a cosmic run. TOF will be set to 0 and time slewing correction will be applied', name='cosmicRun'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - - -# make configuration object -mdtCalibNtupleConfig = MDTCalibNtupleConfig() diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibValConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibValConfig.py deleted file mode 100644 index a8fbd50589c2bdb3b5a7ae606a9e0bb9285df9bb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/MDTCalibValConfig.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -import os -__all__ = [] - -from PyJobTransformsCore.TransformConfig import * -import PyJobTransformsCore.basic_trfarg as trfarg - -# define configuration properties -class MDTCalibValConfig(TransformConfig): - # prevent any mistypings by not allowing dynamic members - __slots__ = () - - # list of attributes - WriterConnectionString = String("Calibration Db Writer Connection String", "oracle://atlas-oracle-01.roma1.infn.it/atlrome.roma1.infn.it/atlas_muoncalib_rome") - ReaderConnectionString = String("Calibration Db Reader Connection String", "oracle://atlas-oracle-01.roma1.infn.it/atlrome.roma1.infn.it/atlas_muoncalib_rome") - ReaderWorkingSchema = String("Calibration Db Reader Working Schema", "atlas_muoncalib_rome") - - def __init__(self,name='mdtCalibValConfig',metaData=None): - TransformConfig.__init__(self,name,metaData) - self.maxeventsstrategy = 'ABORT' - -class ValAlgorithmArg(trfarg.StringChoicesArg): - """choose here the calibration algorithm to use""" - def __init__(self, choices, caseSensitive=False, help='calibration algorithm to be used', name='calibrationAlgorithm'): - trfarg.StringChoicesArg.__init__(self, choices, help, name, caseSensitive) - def isFullArgument(self): - return True - -class SelectChamberArg(trfarg.StringArg): - """chamber selection""" - def __init__(self, help='select the chamber to be used', name='selectChamber'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class CalibSiteArg(trfarg.StringArg): - """calibration site name""" - def __init__(self, help='select the calibration site name', name='calibSite'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class HeaderIdArg(trfarg.IntegerArg): - """DB header to validate""" - def __init__(self, help='select the calibration ID to validate', name='headId'): - trfarg.IntegerArg.__init__(self, help, name) - def isFullArgument(self): - return True - -# make configuration object -mdtCalibValConfig = MDTCalibValConfig() diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/RPCCalibNtupleConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/RPCCalibNtupleConfig.py deleted file mode 100644 index f17e99be0e6aa4fea6000a22a395888508c1d98d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/python/RPCCalibNtupleConfig.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -import os -__all__ = [] - -from PyJobTransformsCore.TransformConfig import * -import PyJobTransformsCore.basic_trfarg as trfarg - -# define configuration properties -class RPCCalibNtupleConfig(TransformConfig): - # prevent any mistypings by not allowing dynamic members - __slots__ = () - - # list of attributes - postOptions = String("jobOptions fragment to be appended at the end of the skeleton", None) - doExtrapolNtuple = Boolean("Dump extrapolations to ntuple", True) - clusterTimeSpread = Float("Cluster time spread", 15) - fieldMask = String("defines which parts of the field are on","111") - conditionsTag = String("conditions tag","COMCOND-REPC-001-03") - - def __init__(self,name='rpcCalibNtupleConfig',metaData=None): - TransformConfig.__init__(self,name,metaData) - self.maxeventsstrategy = 'ABORT' - -# make configuration object -rpcCalibNtupleConfig = RPCCalibNtupleConfig() - -class ConditionsTagArg(trfarg.StringArg): - """choose here the IOVDb global tag, i.e. the misalignemnts db""" - def __init__(self, help='IOVDb global tag', name='conditionsTag'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class FieldMaskArg(trfarg.StringArg): - """choose which fields must be turned on""" - def __init__(self, help='field mask', name='fieldMask'): - trfarg.StringArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class trigNtupleArg(trfarg.BoolArg): - """turns on trig ntuple""" - def __init__(self, help='trigger ntuple', name='trigNtuple'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class resNtupleArg(trfarg.BoolArg): - """turns on rpc res ntuple""" - def __init__(self, help='residuals ntuple', name='resNtuple'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - -class extrNtupleArg(trfarg.BoolArg): - """turns on rpc extr ntuple""" - def __init__(self, help='extrapolations ntuple', name='extrNtuple'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - - -class PRDNtupleArg(trfarg.BoolArg): - """turns on trig ntuple""" - def __init__(self, help='rpc prd ntuple', name='prdNtuple'): - trfarg.BoolArg.__init__(self, help, name) - def isFullArgument(self): - return True - - -class recoAlgArg(trfarg.StringChoicesArg): - def __init__(self, choices, caseSensitive=False, help='reco algorithm to be used', name='recoAlg'): - trfarg.StringChoicesArg.__init__(self, choices, help, name, caseSensitive) - def isFullArgument(self): - return True diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/__init__.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/__init__.py deleted file mode 100644 index 1e5bbb9c47f7305f8d2e4255438afc6f1043cc06..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -# Auto-generated by /mnt/classis03/home3/calib/splitter/trf/AtlasProduction/12.0.6.4/Tools/PyJobTransformsCore/share/ensure_init.py -s=../scripts mdt_calib*_trf.py diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_fit_trf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_fit_trf.py deleted file mode 100755 index 56ad2e391ae68a23e30dd5bdb7a869ebab400b6d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_fit_trf.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """Produce calibration fits. -Take the calibration ntuples as input files and produce fitted data.""" - -from PyJobTransformsCore.trf import * -from PyJobTransformsCore.full_trfarg import * -from PyJobTransformsCore.trfutil import * -from MuonCalibJobTransforms.MDTCalibFitConfig import mdtCalibFitConfig -from MuonCalibJobTransforms.MDTCalibFitConfig import CalibrationAlgorithmArg -from MuonCalibJobTransforms.MDTCalibFitConfig import SelectChamberArg -from MuonCalibJobTransforms.MDTCalibFitConfig import CalibNtupleFileListArg -from MuonCalibJobTransforms.MDTCalibFitConfig import CalibSiteArg -from MuonCalibJobTransforms.MDTCalibFitConfig import WriteToDBArg -from MuonCalibJobTransforms.MDTCalibFitConfig import T0FitByArg -from MuonCalibJobTransforms.MDTCalibFitConfig import ADCFitByArg -from MuonCalibJobTransforms.MDTCalibFitConfig import MuonRecoArg -from MuonCalibJobTransforms.MDTCalibFitConfig import RefineT0Arg -from MuonCalibJobTransforms.MDTCalibFitConfig import SegmentRefitArg -from MuonCalibJobTransforms.MDTCalibFitConfig import InputFromDBArg -from MuonCalibJobTransforms.MDTCalibFitConfig import InputFromFileArg -from MuonCalibJobTransforms.MDTCalibFitConfig import OutputToDBArg -from MuonCalibJobTransforms.MDTCalibFitConfig import OutputToFileArg -from MuonCalibJobTransforms.MDTCalibFitConfig import HeadIdArg -from MuonCalibJobTransforms.MDTCalibFitConfig import MdtDqaFileArg -from MuonCalibJobTransforms.MDTCalibFitConfig import FillHistosArg -from MuonCalibJobTransforms.MDTCalibFitConfig import DoFinalizeArg -from MuonCalibJobTransforms.MDTCalibFitConfig import DoEfficiencyArg -from MuonCalibJobTransforms.MDTCalibFitConfig import DoGlobalTimeFitArg -from MuonCalibJobTransforms.MDTCalibFitConfig import SuppressRecalibrationArg -from MuonCalibJobTransforms.MDTCalibFitConfig import SegsFromRawArg -from MuonCalibJobTransforms.MDTCalibFitConfig import CurvedSegsArg -from MuonCalibJobTransforms.MDTCalibFitConfig import BfieldCorrArg -from MuonCalibJobTransforms.MDTCalibFitConfig import HitResidArg -from MuonCalibJobTransforms.MDTCalibFitConfig import DeadElAlgArg -from MuonCalibJobTransforms.MDTCalibFitConfig import ADCcutArg -from MuonCalibJobTransforms.MDTCalibFitConfig import EffNsigArg -from MuonCalibJobTransforms.MDTCalibFitConfig import EffChiCutArg -from MuonCalibJobTransforms.MDTCalibFitConfig import EffUseDefResArg -from MuonCalibJobTransforms.MDTCalibFitConfig import EffiGtfArg -from MuonCalibJobTransforms.MDTCalibFitConfig import EffiReCalArg -from MuonCalibJobTransforms.MDTCalibFitConfig import EffiTimeCorrArg -from MuonCalibJobTransforms.MDTCalibFitConfig import TrackPCut -from MuonCalibJobTransforms.MDTCalibFitConfig import FastTrackMatch -from MuonCalibJobTransforms.MDTCalibFitConfig import SuperFastTrackMatch -from MuonCalibJobTransforms.MDTCalibFitConfig import ApplyTimeSlewingCorrection -from MuonCalibJobTransforms.MDTCalibFitConfig import ApplyRtScaling -from MuonCalibJobTransforms.MDTCalibFitConfig import SplitterStoreRaw, SplitterSplitLevel,SplitterADCCut,SplitterMergeOutputFiles,SplitterStoreTracks - -class MDTCalibFitJobTransform( JobTransform ): - def __init__(self): - JobTransform.__init__(self, - authors = [ Author('Alessandro De Salvo','alessandro.desalvo@roma1.infn.it'), - Author('Fabrizio Petrucci','fabrizio.petrucci@roma3.infn.it') ] , - skeleton='MuonCalibJobTransforms/skeleton.mdt_calib_fit.py', - help = __doc__, - config=mdtCalibFitConfig ) - - #add arguments - self.add( CalibNtupleFileListArg() ) - self.add( MaxEventsArg() ) - self.add( SkipEventsArg() ) - self.add( GeometryVersionArg() ) - self.add( CalibrationAlgorithmArg(['RunScan','ClassicT0','MTT0','Integration', 'ClassicAutocal', 'AnalyticAutocal', 'CurvedAutocal', 'SimpleResolution', 'Chi2Resolution', 'Efficiency', 'RpcTiming', 'ControlHistograms', 'MDTChamberGeometryDetermination', 'MdtDqa', 'Splitter', 'TimeSlewing', 'ResidualVsTimeTool', 'Display']), default='ClassicT0' ) - self.add( SelectChamberArg(), default='[BML,4, 4]' ) - - self.add( CalibSiteArg(), default='RM' ) - self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - self.add( DBReleaseArg(), default='NONE' ) - - self.add(WriteToDBArg(), default="True") - self.add(T0FitByArg(), default='MEZZ_CARD') - self.add(MuonRecoArg(), default='4' ) - self.add(ADCFitByArg(), default='MEZZ_CARD') - self.add(RefineT0Arg(), default='True') - self.add(SegmentRefitArg(), default='False') - self.add(InputFromDBArg(), default='False') - self.add(InputFromFileArg(), default='True') - self.add(OutputToDBArg(), default='False') - self.add(OutputToFileArg(), default='True') - self.add(HeadIdArg(), default='-1') - self.add(MdtDqaFileArg(), default='MdtDqa') - self.add(FillHistosArg(), default='True') - self.add(DoFinalizeArg(), default='False') - self.add(DoEfficiencyArg(), default='True') - self.add(DoGlobalTimeFitArg(), default='False') - self.add(SuppressRecalibrationArg(), default='True') - self.add(SegsFromRawArg(), default='False') - self.add(CurvedSegsArg(), default='False') - self.add(BfieldCorrArg(), default='False') - self.add(HitResidArg(), default='False') - - self.add(DeadElAlgArg(), default='1') - self.add(ADCcutArg(), default='70.') - self.add(EffNsigArg(), default='-1') - self.add(EffChiCutArg(), default='5.') - self.add(EffUseDefResArg(), default='True') - - self.add(EffiGtfArg(), default='False') - self.add(EffiReCalArg(), default='False') - self.add(EffiTimeCorrArg(), default='False') - self.add(TrackPCut(), default=-3.0) - self.add(FastTrackMatch(), default=True) - self.add(SuperFastTrackMatch(), default=False) - self.add(ApplyTimeSlewingCorrection(), default=True) - self.add(ApplyRtScaling(), default=False) - self.add(SplitterStoreRaw(), default=False) - self.add(SplitterStoreTracks(), default=True) - self.add(SplitterSplitLevel(name="splitterFileSplitLevel"), default="NONE") - self.add(SplitterSplitLevel(name="splitterNtupleSplitLevel"), default="NONE") - self.add(SplitterADCCut(), default=0) - self.add(SplitterMergeOutputFiles(), default="") - - #add other features - self.add( SQLiteSupport() ) - -# execute it if not imported -if __name__ == '__main__': - trf = MDTCalibFitJobTransform() - exit_code=trf.exeSysArgs().exitCode() - if not trf.runArgs().splitterMergeOutputFiles or exit_code!=0: - sys.exit(exit_code) - import glob - import shutil - import subprocess - for output in trf.runArgs().splitterMergeOutputFiles.split(","): - out_items=output.split(":") - if len(out_items)>2: - sys.stderr.write("WARNING: Malformed outfile arg " + output + "\n") - continue - glob_string="OutNtuple*.root" - target_file=output - if len(out_items)==2: - glob_string="OutNtuple_" + out_items[0] + "*.root" - target_file = out_items[1] - infiles=glob.glob(glob_string) - if not infiles: - prev_argv=sys.argv[:] - sys.argv=[sys.argv[0], '-b'] - from ROOT import * - dummy_outfile=TFile.Open(target_file, "RECREATE") - dummy_outfile.Write() - sys.argv=prev_argv - continue - if len(infiles)==1: - shutil.move(infiles[0], target_file) - continue - #merge one by one to avoid disk-space restrictions - file1=infiles[0] - for next_file in infiles[1:]: - if subprocess.call(["hadd", target_file, file1, next_file]): - sys.stderr.write("WARNING: hadd failed!\n") - subprocess.call(["rm", next_file, file1]) - if not next_file==infiles[-1]: - shutil.move(target_file, "tmp." + target_file) - file1="tmp." + target_file - - sys.exit(exit_code) - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_fit_val_trf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_fit_val_trf.py deleted file mode 100755 index 5e0ce8e3853705d97e1e36f803de188d28612481..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_fit_val_trf.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """Produce calibration fits and validate them in 4 steps. -Take the calibration ntuples as input files and produce fitted data.""" - -from PyJobTransformsCore.trf import * -from PyJobTransformsCore.full_trfarg import * -from PyJobTransformsCore.trfutil import * -from MuonCalibJobTransforms.mdt_calib_fit_trf import MDTCalibFitJobTransform -from MuonCalibJobTransforms.mdt_calib_val_trf import MDTCalibValJobTransform - - -class MDTCalibFitValJobTransform( JobTransform ): - def __init__(self): - JobTransform.__init__(self, - authors = [ Author('Alessandro De Salvo','alessandro.desalvo@roma1.infn.it'), - Author('Fabrizio Petrucci','fabrizio.petrucci@roma3.infn.it') ] , - help = __doc__ ) - - #add arguments - self.add( CalibNtupleFileListArg() ) - self.add( MaxEventsArg() ) - self.add( SkipEventsArg() ) - self.add( SelectChamberArg(), default='[BML,4, 4]' ) - self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - - def runJob(self): - # get the list of arguments to be used in sub-transforms - argDict = self.argumentOriginalDict() - # Fit T0 phase - t0fit = MDTCalibFitJobTransform() - t0fit.setJobReportOptions('None') - argDict['calibrationAlgorithm'] = argDict['ClassicT0'] - report = t0fit.exeArgDict( argDict ) - # only run t0 validation if the T0 making was successfull - if (report.exitCode() == 0): - # print out short report on first stage - t0fit.dumpReport('Summary,Errors') - # T0 validation phase - t0val = MDTCalibValJobTransform() - t0val.setJobReportOptions('Summary') - argDict['calibrationAlgorithm'] = argDict['T0Val'] - reportT0val = t0val.exeArgDict( argDict ) - report.addReport( reportT0val ) - # Fit RT phase - rtfit = MDTCalibFitJobTransform() - rtfit.setJobReportOptions('None') - argDict['calibrationAlgorithm'] = argDict['ClassicAutocal'] - reportRT = rtfit.exeArgDict( argDict ) - report.addReport( reportRT ) - # only run rt validation if the rt making was successfull - if (reportRT.exitCode() == 0): - # print out short report on first stage - rtfit.dumpReport('Summary,Errors') - # rt validation phase - rtval = MDTCalibValJobTransform() - rtval.setJobReportOptions('Summary') - argDict['calibrationAlgorithm'] = argDict['RtVal'] - reportRTval = rtval.exeArgDict( argDict ) - report.addReport( reportRTval ) - - return report - - -# execute it if not imported -if __name__ == '__main__': - trf = MDTCalibFitJobTransform() - sys.exit(trf.exeSysArgs().exitCode()) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_ntuple_tf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_ntuple_tf.py deleted file mode 100755 index 4099882aaf10f7ef73f4acd0eba02c07a829c63b..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_ntuple_tf.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """mdt_calib_ntuple_tf.py: Produce calibration ntuples for MDT calibrations. -Use calibration stream as input file and produce calibrations ntuples as output files.""" - -import sys -import time - -import logging - -# Setup core logging here -from PyJobTransforms.trfLogger import msg -msg.info('logging set in %s' % sys.argv[0]) - -from PyJobTransforms.transform import transform -from PyJobTransforms.trfExe import athenaExecutor -from PyJobTransforms.trfArgs import addAthenaArguments, addDetectorArguments -from PyJobTransforms.trfDecorators import stdTrfExceptionHandler, sigUsrStackTrace - -import PyJobTransforms.trfArgClasses as trfArgClasses -from PyJobTransforms.trfArgClasses import argFactory - -@stdTrfExceptionHandler -@sigUsrStackTrace -def main(): - - msg.info('This is %s' % sys.argv[0]) - - trf = getTransform() - trf.parseCmdLineArgs(sys.argv[1:]) - trf.execute() - trf.generateReport() - - msg.info("%s stopped at %s, trf exit code %d" % (sys.argv[0], time.asctime(), trf.exitCode)) - sys.exit(trf.exitCode) - -def getTransform(): - executorSet = set() - executorSet.add(athenaExecutor(name='MDTCalibNtuple', skeletonFile='MuonCalibJobTransforms/skeleton.mdt_calib_ntuple_tf.py' )) -# possibly (?) one should specify input/output formats to the transform can check them, however, adding this -# info causes transform to fail. Of course transform does not know about calibstream bytestream, though -# in principle it knows about calib ntuples. -#', inData=['BS'], outData=['NTUP_MUONCALIB'] #specify input/output file formats. - trf = transform(executor = executorSet) - -# for maxEvents skipEvents - actually skipEvents do not work with calibstream -# so do not use addAthenaArguments, but make own arguments for these. -# addAthenaArguments(trf.parser) -# for runNumber geometryVersion DBRelease conditionsTag - addDetectorArguments(trf.parser) -# for parameters specific to calib ntuple production - addMyArgs(trf.parser) - return trf - -def addMyArgs(parser): - # Use arggroup to get these arguments in their own sub-section (of --help) - parser.defineArgGroup('mdt_calib_ntuple_tf', 'MDT calib ntuple job specific options') - parser.add_argument('--inputCSFiles', type=argFactory(trfArgClasses.argList), - help='Input calibration stream file(s)', group='mdt_calib_ntuple_tf') - parser.add_argument('--ntupleFile', type=argFactory(trfArgClasses.argString), - help='Output calib ntuple', group='mdt_calib_ntuple_tf') - -# Cannot use normal maxEvents and skipEvents because these seem to be -# reserved for special use by transform framework, hence use different argument names. - parser.add_argument("--Events", group="mdt_calib_ntuple_tf", - default=trfArgClasses.argInt(-1, runarg=True), - help="the number of events to process", - type=trfArgClasses.argFactory(trfArgClasses.argInt, runarg=True)) - parser.add_argument("--Skip", group="mdt_calib_ntuple_tf", - default=trfArgClasses.argInt(0, runarg=True), - help="the number of events to skip at beginning of the file", - type=trfArgClasses.argFactory(trfArgClasses.argInt, runarg=True)) - - parser.add_argument('--dbT0Tag', type=argFactory(trfArgClasses.argString), default='DEFAULT', - help='Specify T0 Tag', group='mdt_calib_ntuple_tf') - parser.add_argument('--dbRTTag', type=argFactory(trfArgClasses.argString), default='DEFAULT', - help='Specify RT Tag', group='mdt_calib_ntuple_tf') - parser.add_argument('--dbT0Sql', type=argFactory(trfArgClasses.argString), default='DEFAULT', - help='Specify SQLite file for T0s', group='mdt_calib_ntuple_tf') - parser.add_argument('--dbRTSql', type=argFactory(trfArgClasses.argString), default='DEFAULT', - help='Specify SQLite file for RTs', group='mdt_calib_ntuple_tf') -# Transform boolean variables will not be created in runArgs unless you specify them on command line -# Hence, in the skeleton you need to check if they exist before you use them. - parser.add_argument('--useAlign', type=argFactory(trfArgClasses.argBool), - help='Use Alignment corrections', group='mdt_calib_ntuple_tf') -# segOnly False results in calib ntuple not being filled -# parser.add_argument('--segOnly', type=argFactory(trfArgClasses.argBool), -# help='Segments only', group='mdt_calib_ntuple_tf') -# Only standalone exists anymore and is enabled by default so there is no reason to set it anymore -# parser.add_argument('--moore', type=argFactory(trfArgClasses.argBool), -# help='Use Moore segments + tracks', group='mdt_calib_ntuple_tf') -# parser.add_argument('--mboy', type=argFactory(trfArgClasses.argBool), -# help='Use Muonboy segments + tracks', group='mdt_calib_ntuple_tf') -# parser.add_argument('--standalone', type=argFactory(trfArgClasses.argBool), -# help='Use Standalone tracks', group='mdt_calib_ntuple_tf') - parser.add_argument('--doSegmentT0Fit', type=argFactory(trfArgClasses.argBool), - help='Do Segment T0 Fits', group='mdt_calib_ntuple_tf') - parser.add_argument('--doCSC', type=argFactory(trfArgClasses.argBool), - help='Do CSC', group='mdt_calib_ntuple_tf') - parser.add_argument('--rawTgc', type=argFactory(trfArgClasses.argBool), - help='put rawTgc and rawTgcCoin branches in calib ntuple', group='mdt_calib_ntuple_tf') -# doSim is not even used in the skeleton, so skip it. -# parser.add_argument('--doSim', type=argFactory(trfArgClasses.argBool), -# help='Do Simulated data (whatever that means)', group='mdt_calib_ntuple_tf') -# Not sure what the use case is for these, but leave them be. - parser.add_argument('--lumiBlockNumberFromCool', type=argFactory(trfArgClasses.argBool), - help='Fetch Lumiblock Number from COOL', group='mdt_calib_ntuple_tf') - parser.add_argument('--runNumberFromCool', type=argFactory(trfArgClasses.argBool), - help='Fetch Run Number from COOL (?)', group='mdt_calib_ntuple_tf') -# Old TRF had this but I do not think it is needed anymore -# self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - -if __name__ == '__main__': - main() diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_ntuple_trf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_ntuple_trf.py deleted file mode 100755 index 53b260bdeb5c05e19eb3d9e569701264ae865d9a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_ntuple_trf.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """Produce calibration ntuples for fitting. -Take the calibration bytestream as input file and produce ntuples as output files.""" - -from PyJobTransformsCore.trf import * -from PyJobTransformsCore.full_trfarg import * -from PyJobTransformsCore.trfutil import * -from MuonCalibJobTransforms.MDTCalibNtupleConfig import mdtCalibNtupleConfig -from MuonCalibJobTransforms.MDTCalibNtupleConfig import DbT0TagArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import DbRTTagArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import DbT0SqlArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import DbRTSqlArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import UseAlignArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import SegOnlyArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import MooreArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import MboyArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import StandaloneArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import CalibNtupleDoSimArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import DoSegmentT0FitArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import DoCSCArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import RawTgcArg -from MuonCalibJobTransforms.MDTCalibNtupleConfig import LumiBlockNumberFromCool -from MuonCalibJobTransforms.MDTCalibNtupleConfig import RunNumberFromCool -from MuonCalibJobTransforms.MDTCalibNtupleConfig import CosmicRun - -class MDTCalibNtupleJobTransform( JobTransform ): - def __init__(self): - JobTransform.__init__(self, - authors = [ Author('Alessandro De Salvo','alessandro.desalvo@roma1.infn.it'), - Author('Fabrizio Petrucci','fabrizio.petrucci@roma3.infn.it') ] , - skeleton='MuonCalibJobTransforms/skeleton.mdt_calib_ntuple.py', - help = __doc__, - config=mdtCalibNtupleConfig ) - - #add arguments - self.add( InputBSFileArg() ) - self.add( NtupleFileArg() ) - self.add( RunNumberArg() ) - self.add( MaxEventsArg() ) - self.add( SkipEventsArg() ) - self.add( GeometryVersionArg() ) - self.add( ConditionsTagArg() ) - self.add( DbT0TagArg(), default='DEFAULT' ) - self.add( DbRTTagArg(), default='DEFAULT' ) - self.add( DbT0SqlArg(), default='DEFAULT' ) - self.add( DbRTSqlArg(), default='DEFAULT' ) - self.add( UseAlignArg(), default='True' ) - self.add( SegOnlyArg(), default='True' ) - self.add( MooreArg(), default='True' ) - self.add( MboyArg(), default='False' ) - self.add( StandaloneArg(), default='False' ) - self.add( DoSegmentT0FitArg(), default='False' ) - - self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - self.add( CalibNtupleDoSimArg(), default='False' ) - self.add( DBReleaseArg(), default='NONE' ) - - self.add( DoCSCArg(), default='False' ) - self.add( RawTgcArg(), default='False' ) - - self.add( LumiBlockNumberFromCool(), default='False' ) - self.add( RunNumberFromCool(), default='False' ) - - #add other features - self.add( SQLiteSupport() ) - self.add( CosmicRun(), default='False') - -# execute it if not imported -if __name__ == '__main__': - trf = MDTCalibNtupleJobTransform() - sys.exit(trf.exeSysArgs().exitCode()) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_val_trf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_val_trf.py deleted file mode 100755 index cf676f9246a9357fcf284cf09d05333ed40adc28..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/mdt_calib_val_trf.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """Validate calibration fits. -Reads the calibration database and validaes the constants therein""" - -from PyJobTransformsCore.trf import * -from PyJobTransformsCore.full_trfarg import * -from PyJobTransformsCore.trfutil import * -from MuonCalibJobTransforms.MDTCalibValConfig import mdtCalibValConfig -from MuonCalibJobTransforms.MDTCalibValConfig import ValAlgorithmArg -from MuonCalibJobTransforms.MDTCalibValConfig import SelectChamberArg -from MuonCalibJobTransforms.MDTCalibValConfig import CalibSiteArg -from MuonCalibJobTransforms.MDTCalibValConfig import HeaderIdArg - -class MDTCalibValJobTransform( JobTransform ): - def __init__(self): - JobTransform.__init__(self, - authors = [ Author('Alessandro De Salvo','alessandro.desalvo@roma1.infn.it'), - Author('Fabrizio Petrucci','fabrizio.petrucci@roma3.infn.it') ] , - skeleton='MuonCalibJobTransforms/skeleton.mdt_calib_validate.py', - help = __doc__, - config=mdtCalibValConfig ) - - #add arguments - self.add( SelectChamberArg()) - self.add( MaxEventsArg() ) - self.add( GeometryVersionArg() ) - self.add( ValAlgorithmArg(['T0Val','RtVal']), default='T0Val' ) - self.add( CalibSiteArg(), default='RM' ) - self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - self.add( DBReleaseArg(), default='NONE' ) - self.add( HeaderIdArg(), default='-1' ) - - #add other features - self.add( SQLiteSupport() ) - -# execute it if not imported -if __name__ == '__main__': - trf = MDTCalibValJobTransform() - sys.exit(trf.exeSysArgs().exitCode()) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_ESD_trf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_ESD_trf.py deleted file mode 100755 index a386590b603b171fd747eeda10c727ff5290eee2..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_ESD_trf.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """Produce calibration ntuples -Take ESD as input file and produce ntuples as output files.""" - -from PyJobTransformsCore.trf import * -from PyJobTransformsCore.full_trfarg import * -from PyJobTransformsCore.trfutil import * -from MuonCalibJobTransforms.RPCCalibNtupleConfig import rpcCalibNtupleConfig,FieldMaskArg,ConditionsTagArg,resNtupleArg, recoAlgArg, trigNtupleArg,PRDNtupleArg,extrNtupleArg - -class RPCCalibNtupleJobTransform( JobTransform ): - def __init__(self): - JobTransform.__init__(self, - authors = [ Author('Andrea Di Simone','andrea.di.simone@cern.ch')] , - skeleton='MuonCalibJobTransforms/skeleton.rpc_calib_ntuple_ESD.py', - help = __doc__, - config=rpcCalibNtupleConfig ) - - #add arguments - self.add( InputESDFileArg() ) - self.add( NtupleFileArg() ) - self.add( RunNumberArg() ) - self.add( MaxEventsArg() ) - self.add( SkipEventsArg() ) - self.add( GeometryVersionArg() ) - self.add( FieldMaskArg(), default="111") - self.add( ConditionsTagArg(),default="COMCOND-REPC-001-03") - self.add( DBReleaseArg(), default='NONE' ) - self.add( resNtupleArg(), default=True) - self.add( PRDNtupleArg(), default=False) - self.add( extrNtupleArg(), default=False) - self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - -# execute it if not imported -if __name__ == '__main__': - trf = RPCCalibNtupleJobTransform() - sys.exit(trf.exeSysArgs().exitCode()) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_fullStream_trf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_fullStream_trf.py deleted file mode 100755 index 878822bd5ab773a0acc56260665378bf25cd0b44..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_fullStream_trf.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """Produce calibration ntuples -Take the calibration bytestream as input file and produce ntuples as output files.""" - -from PyJobTransformsCore.trf import * -from PyJobTransformsCore.full_trfarg import * -from PyJobTransformsCore.trfutil import * -from MuonCalibJobTransforms.RPCCalibNtupleConfig import rpcCalibNtupleConfig,FieldMaskArg,ConditionsTagArg, resNtupleArg, recoAlgArg, trigNtupleArg,PRDNtupleArg,extrNtupleArg - -class RPCCalibNtupleJobTransform( JobTransform ): - def __init__(self): - JobTransform.__init__(self, - authors = [ Author('Andrea Di Simone','andrea.di.simone@cern.ch')] , - skeleton='MuonCalibJobTransforms/skeleton.rpc_calib_ntuple_fullStream.py', - help = __doc__, - config=rpcCalibNtupleConfig ) - - #add arguments - self.add( InputBSFileArg() ) - self.add( NtupleFileArg() ) - self.add( RunNumberArg() ) - self.add( MaxEventsArg() ) - self.add( SkipEventsArg() ) - self.add( GeometryVersionArg() ) - self.add( FieldMaskArg(), default="111") - self.add( ConditionsTagArg(),default="COMCOND-REPC-001-03") - self.add( DBReleaseArg(), default='NONE' ) - self.add( resNtupleArg(), default=True) - self.add( trigNtupleArg(), default=False) - self.add( PRDNtupleArg(), default=False) - self.add( extrNtupleArg(), default=False) - self.add( recoAlgArg(['Moore','MuonBoy']), default='MuonBoy' ) - self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - -# execute it if not imported -if __name__ == '__main__': - trf = RPCCalibNtupleJobTransform() - sys.exit(trf.exeSysArgs().exitCode()) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_trf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_trf.py deleted file mode 100755 index 20d5253cea6a9f7188d82e5ddd2a0752d95f5789..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/scripts/rpc_calib_ntuple_trf.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -__doc__ = """Produce calibration ntuples -Take the calibration bytestream as input file and produce ntuples as output files.""" - -from PyJobTransformsCore.trf import * -from PyJobTransformsCore.full_trfarg import * -from PyJobTransformsCore.trfutil import * -from MuonCalibJobTransforms.RPCCalibNtupleConfig import rpcCalibNtupleConfig,FieldMaskArg,ConditionsTagArg,resNtupleArg, recoAlgArg, trigNtupleArg,PRDNtupleArg,extrNtupleArg - -class RPCCalibNtupleJobTransform( JobTransform ): - def __init__(self): - JobTransform.__init__(self, - authors = [ Author('Andrea Di Simone','andrea.di.simone@cern.ch')] , - skeleton='MuonCalibJobTransforms/skeleton.rpc_calib_ntuple.py', - help = __doc__, - config=rpcCalibNtupleConfig ) - - #add arguments - self.add( InputBSFileArg() ) - self.add( NtupleFileArg() ) - self.add( RunNumberArg() ) - self.add( MaxEventsArg() ) - self.add( SkipEventsArg() ) - self.add( GeometryVersionArg() ) - self.add( FieldMaskArg(), default="111") - self.add( ConditionsTagArg(),default="COMCOND-REPC-001-03") - self.add( DBReleaseArg(), default='NONE' ) - self.add( resNtupleArg(), default=True) - self.add( trigNtupleArg(), default=False) - self.add( PRDNtupleArg(), default=False) - self.add( extrNtupleArg(), default=False) - self.add( recoAlgArg(['Moore','MuonBoy']), default='MuonBoy' ) - self.add( JobConfigArg(package='MuonCalibJobTransforms'), default='NONE' ) - -# execute it if not imported -if __name__ == '__main__': - trf = RPCCalibNtupleJobTransform() - sys.exit(trf.exeSysArgs().exitCode()) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/RT_default_comm.dat b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/RT_default_comm.dat deleted file mode 100644 index f2d5d7a9f11fa548f06ed78e74ed7a0fe890a5df..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/RT_default_comm.dat +++ /dev/null @@ -1,101 +0,0 @@ -v0.0 1 dummy 0 100 -0.006 -3.75 1 -0.08 3.75 1 -0.12 11.25 1 -0.2 18.75 1 -0.329471 26.25 1 -0.891593 33.75 1 -1.26313 41.25 1 -1.61735 48.75 1 -1.95691 56.25 1 -2.3246 63.75 1 -2.69977 71.25 1 -3.06085 78.75 1 -3.39283 86.25 1 -3.73301 93.75 1 -4.0958 101.25 1 -4.40873 108.75 1 -4.71978 116.25 1 -5.01734 123.75 1 -5.27703 131.25 1 -5.54612 138.75 1 -5.7883 146.25 1 -6.0291 153.75 1 -6.25856 161.25 1 -6.47283 168.75 1 -6.69762 176.25 1 -6.90866 183.75 1 -7.10841 191.25 1 -7.29428 198.75 1 -7.47281 206.25 1 -7.65395 213.75 1 -7.83293 221.25 1 -7.99895 228.75 1 -8.16799 236.25 1 -8.32981 243.75 1 -8.49947 251.25 1 -8.64711 258.75 1 -8.80435 266.25 1 -8.94599 273.75 1 -9.09739 281.25 1 -9.23126 288.75 1 -9.38432 296.25 1 -9.51813 303.75 1 -9.65211 311.25 1 -9.76734 318.75 1 -9.90211 326.25 1 -10.0359 333.75 1 -10.1689 341.25 1 -10.2999 348.75 1 -10.3994 356.25 1 -10.5221 363.75 1 -10.6322 371.25 1 -10.7712 378.75 1 -10.8966 386.25 1 -11.023 393.75 1 -11.1243 401.25 1 -11.2325 408.75 1 -11.34 416.25 1 -11.443 423.75 1 -11.5491 431.25 1 -11.6699 438.75 1 -11.7648 446.25 1 -11.8627 453.75 1 -11.9555 461.25 1 -12.0428 468.75 1 -12.1561 476.25 1 -12.2449 483.75 1 -12.3672 491.25 1 -12.456 498.75 1 -12.5592 506.25 1 -12.652 513.75 1 -12.7501 521.25 1 -12.8264 528.75 1 -12.9499 536.25 1 -13.0109 543.75 1 -13.1288 551.25 1 -13.231 558.75 1 -13.309 566.25 1 -13.4132 573.75 1 -13.4872 581.25 1 -13.5871 588.75 1 -13.6684 596.25 1 -13.7587 603.75 1 -13.8251 611.25 1 -13.9379 618.75 1 -13.9877 626.25 1 -14.0801 633.75 1 -14.1629 641.25 1 -14.2375 648.75 1 -14.3356 656.25 1 -14.3797 663.75 1 -14.441 671.25 1 -14.4219 678.75 1 -14.5433 686.25 1 -14.5433 693.75 1 -14.5433 701.25 1 -14.5433 708.75 1 -14.5433 716.25 1 -14.5433 723.75 1 -14.5433 731.25 1 -14.5433 738.75 1 diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/flags.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/flags.py deleted file mode 100644 index bfc7232ef554277a7280c9ad5d50ee1edb8f5dc5..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/flags.py +++ /dev/null @@ -1,132 +0,0 @@ -# -# Basic class with all the flags to run on cosmics -# -# -include.block("MuonCommissioning/MuDetCosmicFlags_jobOptions.py") -class MuDetCosmicFlags: - # ---- data type (if simulated doSim=True) - EvtMax = 1000 ############## modificabile - SkipEvents = 00000 ############## modificabile - doSim = False - - # --- Flag for M4 runs - doM4 = True - # --- Flag for M3 runs - doM3 = False - # --- Flag for activating the special data format of sector13 2006 runs - doSector13Data = False - - FullFileName = ["input.data"]############## modificabile - NumFile = [] - - doSimpleFile = False - if doM4: - doSimpleFile = True - # --- data specific flags (choose the directory and data file to run) - doMDTRPC = False - doMDTonly = False - doRPConly = False - dooldruns = False - -###----> FLAGS FOR CONVERTERS BS->RDO->PRD - - # --- ROB numbers for MDT/RPC/TGC - doMdtROBNumber = False - doRpcROBNumber = False - doTgcROBNumber = False - MdtSpecialROBNumber = 0x610009 - RpcSpecialROBNumber = 0x000000 - TgcSpecialROBNumber = 0 - - #RDO-->PREPDATA flags - doMDTRDOPRD = False - doRPCRDOPRD = True - doTGCRDOPRD = True - if doRPCRDOPRD: - doRPCPRDphi = True - else: - doRPCPRDphi = False - - # --- digits to prepdata conversion, for 12.0.X - doDigitsToPrepData = False - - #Turn on/off the filter of PRDs (for the moment, for simulation only ) - doSelectPRD = False - #if doSim: - # doSelectPRD = True - - # --- LVL1 Trigger flags - doMUCTPI = False - doCTP = False - - # --- Select data on sector/side of Muon Spectro - Sector = 13 - Side = 1 - doSelectSector = False - -###---> FLAGS FOR DETECTOR DESCRIPTION - - BarrelnoBF = True - BarrelwithBF = False - -###---> FLAGS FOR RECONSTRUCTION - - # ---- Reconstruction packages options - doMoore = False - doMuonboy = False - doMoMu = True - - # ----Conditions database options - doCalibCOOL2 = False ############## modificabile - doCalibCOOLprod= False ############## modificabile - doCalibCOOL13 = False - doAlignCOOLprod = False - - # ----Write ESD - doESD = False - PoolOutputFile = "MuDetRec_cosmics.pool.root" - - # ----Produce calibration Ntuple - doCalibFillNt = True - - # ---- make truth - if doSim: - doTruth = True - else: - doTruth = False - -###---> FLAGS FOR OUTPUT (NTUPLE, MONITORING,GRAPHICS) - - # --- write CBNT ntuple - doNtuple = True - doCBNTAthenaAware = False #default for 13.0.X releases - - # --- Fill ntuple with specific blocks - doMdtRawNt = False - doRpcRawNt = False - doCscRawNt = False - doTgcRawNt = False - if not doM4: - doTgcRawNt = False - - # --- Monitoring - doMonitoring = False - - # --- Graphics - doGraphics = False - JiveXML = False - OnlineJiveXML = False - if doGraphics: - doAtlantis = True - doPersint = True - if doMuonboy: - doNoReco = False - else: - doNoReco = True - else: - doAtlantis = False - doPersint = False - doNoReco = False - - # --- write Atlantis geometry xml file (JiveXML needs to be set True) - AtlantisGeometry = False diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/rpc_trigNtuple.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/rpc_trigNtuple.py deleted file mode 100644 index aa8ddc0c340ea67cb14d1c59fb6b341702a8eefc..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/rpc_trigNtuple.py +++ /dev/null @@ -1,8 +0,0 @@ -from MuonCalibAlgs.MuonCalib import MuonCalibAlg - -MuonCalibAlg.doMDTs = False -MuonCalibAlg.doCSCs = False -MuonCalibAlg.doRPCs = True -MuonCalibAlg.doTGCs = False - -MuonCalibAlg.doTGCCoinData = False diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_fit.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_fit.py deleted file mode 100644 index f0ee53a573958e5f87773ebe8446af50c29dc6f2..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_fit.py +++ /dev/null @@ -1,519 +0,0 @@ - - -# get the logger -from AthenaCommon.Logging import * -from MuonCalibJobTransforms.GetFitBy import * -mdtCalibFitlog = logging.getLogger('mdtCalibFit') - -def GetGroupByList(finest): - if finest=="LAYER": - return ["CHAMBER", "MULTILAYER", "LAYER"] - ret=[] - for group_by in ["CHAMBER", "MULTILAYER", "MEZZ_CARD", "TUBE"]: - ret.append(group_by) - if finest==group_by: - return ret - raise ValueError("Illegal group by parameter " + finest) - return [] - - - -mdtCalibFitlog.info('************** STARTING MDT CalibFit !!!!**************') -#============================================================== -# Job definition parameters: -#============================================================== - -filelist=runArgs.calibNtupleFileList -#file list -if runArgs.calibNtupleFileList[:4].upper() == "CSL:": - import tempfile - fl=tempfile.NamedTemporaryFile(mode="w", dir=".", delete=False) - filelist = fl.name - for inf in runArgs.calibNtupleFileList[4:].split(","): - fl.write(inf) - fl.write("\n") - del fl - - -EvtMax = runArgs.maxEvents -SkipEvents = runArgs.skipEvents -CalibSite = runArgs.calibSite -geover = runArgs.geometryVersion -if geover.upper()=="AUTO": - from CalibNtupleAnalysisAlg.CalibNtupleMetaData import * - meta_data=CalibNtupleMetaData(filelist) - if not 'GeoAtlas' in meta_data.MetaData: - mdtCalibFitlog.fatal("geometry version not found in meta data") - geover="INVALID" - else: - geover=meta_data.MetaData['GeoAtlas'] - mdtCalibFitlog.info("Set Geo-Version to " + geover) - - -if geover.find('NF') >=0: - fieldoff=True -else: - fieldoff=False - -mdtCalibFitlog.info( '**** Transformation run arguments ****' ) -mdtCalibFitlog.info( str(runArgs) ) - -#============================================================== -# Job Configuration parameters: -#============================================================== -from MuonCalibJobTransforms.MDTCalibFitConfig import mdtCalibFitConfig -for cf in runArgs.jobConfig: - include(cf) -mdtCalibFitlog.info( '**** Transformation configuration arguments ****' ) -mdtCalibFitlog.info( str(mdtCalibFitConfig) ) - -### Setup Athena common flags -#include ("AthenaCommon/AthenaCommonFlags.py") -#include.block("AthenaCommon/AthenaCommonFlags.py") - -#include( "IOVDbSvc/IOVRecExCommon.py" ) - -doMuonCalibAtlas=True - -from AthenaCommon.AppMgr import ServiceMgr - -from AthenaCommon.AppMgr import ToolSvc -from CalibNtupleAnalysisAlg.CalibNtupleAnalysisConfig import * -from MuonCalibStandAloneExtraTools.CalibExtraNtupleAnalysisConfig import * -from AthenaCommon.GlobalFlags import globalflags -#GlobalFlags.DetGeo.set_atlas() -#GlobalFlags.DataSource.set_data() -#GlobalFlags.Print() -globalflags.DetGeo.set_Value_and_Lock('atlas') -ToolSvc = Service( "ToolSvc" ) -globalflags.DataSource.set_Value_and_Lock('data') - -from AthenaCommon.DetFlags import DetFlags -DetFlags.detdescr.Muon_setOn() -DetFlags.detdescr.ID_setOff() -DetFlags.detdescr.LAr_setOff() -DetFlags.detdescr.Tile_setOff() - - - -#Set geometry tag -from AtlasGeoModel import SetGeometryVersion, GeoModelInit - -GeoModelSvc = ServiceMgr.GeoModelSvc -GeoModelSvc.AtlasVersion = geover - -#Config=CalibNtupleAnalysisConfig() - -if runArgs.calibrationAlgorithm == "MdtDqa" or (runArgs.calibrationAlgorithm == "Splitter" and runArgs.splitterStoreTracks) or runArgs.trackPCut > -2: - Config=CalibExtraNtupleAnalysisConfig() -else: - Config=CalibNtupleAnalysisConfig() - -#=============================================================================== -#Begin User Settings - -#calibratino algorithm to run: -#select calibration algoritm -# scan run for chambers RunScan -# t0-Fitters: ClassicT0, MTT0 -# create rt by integration Integration -# autocalibration ClassicAutocal, AnalyticAutocal, -# CurvedAutocal -# resolution SimpleResolution, Chi2Resolution -# efficiency Efficiency -# event display Display -# rpc timing RpcTiming -# control histograms ControlHistograms -# MDT DQA MdtDqa -Config.CalibrationAlgorithm = runArgs.calibrationAlgorithm - -Config.FileList = filelist - -#crete segments from the rawdata part -Config.SegmentsFromRawdata=runArgs.segsFromRaw - -#select segment author - 3=MuonBoy 4=Moore - Unused if SegmentsFromRawdata=True -Config.SegmentAuthor=runArgs.MuonReco - -#select only segments on tracks -if hasattr(Config, "SelectTrackSegments"): - Config.SelectTrackSegments= (runArgs.trackPCut >= -1) - -#apply 2nd coordinate of tracks to the segment - only works if SelectTrackSegments=True -if hasattr(Config, "TrackSecondCoordinate"): - Config.TrackSecondCoordinate=False - -if hasattr(Config, "MomentumCut"): - Config.MomentumCut = runArgs.trackPCut - -if hasattr(Config, "FastTrackMatch"): - Config.FastTrackMatch = runArgs.fastTrackMatch - -if hasattr(Config, "SuperFastTrackMatch"): - Config.SuperFastTrackMatch = runArgs.superFastTrackMatch - -#first and last event to analyse -Config.FirstEvent=SkipEvents -Config.LastEvent=EvtMax - -#number of segments to collect -#Config.NumberOfSegments=20000 - -#maximum number of segments for certain algorithms (e.g. Autocalibration) -Config.AutoLimitSegments = 20000 - -#calibration region -if Config.CalibrationAlgorithm != "RunScan": - Config.CalibrationRegion = runArgs.selectChamber - -#perform a segment refit - not for algorithms likr MTT0, Integration, RunScan.. -Config.SegmentRefit=runArgs.segmentRefit - -#segemtn refit parametersConfig. -Config.RefineT0=runArgs.refineT0 -Config.CurvedSegments= runArgs.curvedSegs -Config.RefitRoadWidth=3.0 -Config.RefitTimeOut=2 -Config.RefitMinSegmentHits=4 -Config.RefitMaxSegmentHits=-1 - -#calibrate with b-field -Config.BFieldCorrection=runArgs.bfieldCorr - -#recalculate second coordinate -Config.Recalc2ndCoordinate = False - -#select calibration input -Config.CalibInputFromDB=runArgs.inputFromDB -Config.CalibInputFromFile=runArgs.inputFromFile - -#select calibration output -Config.CalibOutputToDB=runArgs.outputToDB -Config.CalibOutputToFile=runArgs.outputToFile - -#output calibration directory - set None if you do not want to output to diredctory -Config.CalibDir="calibration" - -#output to database - MP/RM/MI/NONE -Config.CalibDB=CalibSite - -#initial data quality list - suppress Tubes -if Config.CalibrationAlgorithm != "RunScan": - Config.InitialDQList = None - -#if set to true no segment recalibraiton will be done, independent on the tool -Config.SuppressRecalibration=runArgs.suppressRecalibration - - -Config.ApplyTimeSlewingCorrections=runArgs.applyTimeSlewingCorrection - -Config.ApplyRtScaling=runArgs.applyRtScaling - -#=============================================================================== -Config.RPCTimingCorr= False -Config.AutoConfig() -if hasattr(Config, "RpcTiming"): - Config.RpcTiming.OffsetFile = 'rpc_offsets.root' -#=============================================================================== - -#set username and passwd and head_id -if hasattr(Config, "DbIoTool"): - Config.DbIoTool.HeadId=runArgs.headId - -if hasattr(Config, "TrackSecondCoordinateTool"): - Config.TrackSecondCoordinateTool.ControlHistograms = False - -if hasattr(Config, "CalibNtupleLoader"): - Config.CalibNtupleLoader.NtupleType = "NORMAL" -# Config.CalibNtupleLoader.NtupleType = "AUTO" -# Config.CalibNtupleLoader.NtupleType = "REGION" - -#++++++++++++++++++Algoritm specific settings+++++++++++++++++++++++++++++++++++ -#-----------------for MdtDqa ---------------------------------------------- -if Config.CalibrationAlgorithm == "MdtDqa": - #----------- jobOptions for MdtDqaNtupleAnalysis : - Config.CalibrationTool.MdtDqaFileName = runArgs.mdtDqaFile - Config.CalibrationTool.Verbose = False - Config.CalibrationTool.FillHistos = runArgs.fillHistos - Config.CalibrationTool.doFinalize = runArgs.doFinalize - Config.CalibrationTool.doSegHitResidsVsRadius = runArgs.hitResid - Config.CalibrationTool.doTracks = False - Config.CalibrationTool.TrkAuthor = 0 - Config.CalibrationTool.DeadElementsAlgorithm = runArgs.DeadElAlg #0=Toni,1=Marco - Config.CalibrationTool.ADCCUT=runArgs.ADCcut - #----------- jobOptions for MdtDqaTubeEfficiency : - Config.CalibrationTool.doEfficiency = runArgs.doEfficiency - Config.CalibrationTool.EffiNSigma = runArgs.EffNsig - Config.CalibrationTool.EffiChi2Cut = runArgs.EffChiCut - Config.CalibrationTool.EffiUseDefaultResolution = runArgs.EffUseDefRes - Config.CalibrationTool.EffiHitADCCut = 0. - Config.CalibrationTool.EffiGTFitON = runArgs.effiGtf - Config.CalibrationTool.EffiUseNewCalibConstants = runArgs.effiReCal - Config.CalibrationTool.EffiUseTimeCorrections = runArgs.effiTimeCorr - - #----------- jobOptions for MdtDqaGlobalTimeFit : - Config.CalibrationTool.doGlobalTimeFit = runArgs.doGlobalTimeFit - Config.CalibrationTool.rtDefaultBfieldON = 0 - Config.CalibrationTool.GTFitSeg_minNumHits = 5 - Config.CalibrationTool.GTFitSeg_maxNumHits = 10 - Config.CalibrationTool.GTFitSeg_chi2Cut = 15.0 - Config.CalibrationTool.GTFitDebug = False - -#------------------------------------for run scan------------------------------- -if Config.CalibrationAlgorithm == "RunScan": -# CalibNtupleAnalysisAlg.RefitSegments = False - #minimum number of hits per fit - Config.CalibrationTool.MinHits = 10000 - #maximum rate of bad hits per chamber - Config.CalibrationTool.MaxBadFits = 0.9999 - #if set to true ommit output for chambers which are not to be fitted - Config.CalibrationTool.SuppressNofit = True - #san all chambers -# CalibNtupleAnalysisAlg.InitialDQList="NONE" -#------------------------------------for MT t0 fitter--------------------------- -if Config.CalibrationAlgorithm == "MTT0" : - #add fitted function to histogram - Config.CalibrationTool.AddFitFun = True - #create TDirectory contining some debugging graphs - Config.CalibrationTool.DrawDebugGraphs = True - #range of histogram ind 25/32 bins - Config.CalibrationTool.NumberOfNegativeBins = 1000 - Config.CalibrationTool.NumberOfPositiveBins = 3000 - #Fit for group of tubes - # TUBE one spectrum per tube - # LAYER one spectrum per layer - # MULTILAYER one spectrum per multilayer - # CHAMBER one spectrum per chamber - # MEZZ_CARD one spectrum per mezzanine card - if type(Config.CalibrationTool.GroupBy) is list: - fit_by=runArgs.t0FitBy - if fit_by=="AUTO": - fit_by=GetFitBy(runArgs.selectChamber) - Config.CalibrationTool.GroupBy=GetGroupByList(fit_by) - Config.CalibrationTool.ADCGroupBy = GetGroupByList(runArgs.adcFitBy) - Config.CalibrationTool.MinumumEntriesPerTimeFit=10000 - Config.CalibrationTool.MinumumEntriesPerADCFit=1000 - else: - if runArgs.t0FitBy=="AUTO": - Config.CalibrationTool.GroupBy = GetFitBy(runArgs.selectChamber) - else: - Config.CalibrationTool.GroupBy = runArgs.t0FitBy - Config.CalibrationTool.ADCGroupBy = runArgs.adcFitBy - Config.CalibrationTool.UseTopChi2 = True - Config.CalibrationTool.ScrambleThreshold = 2 - Config.CalibrationTool.SclicingThreshold = 3 - -#------------------------------for classic t0 fitter---------------------------- -if Config.CalibrationAlgorithm == "ClassicT0": - CalibNtupleAnalysisAlg.RefitSegments = runArgs.segmentRefit - CalibNtupleAnalysisAlg.RefineT0 = runArgs.refineT0 - #range and binning of adc spectrum - Config.CalibrationTool.NAdcBins = 100 - Config.CalibrationTool.MinAdc = 0.0 - Config.CalibrationTool.MaxAdc = 300.0 - #range and binning of the time spectrum - Config.CalibrationTool.NTimeBins = 1280 - Config.CalibrationTool.TimeMin = 0.0 - Config.CalibrationTool.TimeMax = 2000.0 - #switch on/off fitting of time spectrum - Config.CalibrationTool.FitTimeSpectrum = True - #Minimum number of entries - Config.CalibrationTool.MinEntries = 2000 - #InitParam 1 = automatic search for initial fit parameters - Config.CalibrationTool.InitParam = 1 - #maximum chi^2 - Config.CalibrationTool.MaxChi2 = 10.0 - -#----------------------------for integration method----------------------------- -if Config.CalibrationAlgorithm == "Integration": - #mazimum drift time - Config.CalibrationTool.TMaxInt = 710 - #set to true if close hits are stored in the ntuple - Config.CalibrationTool.HaseCloseHits = False - #the inner radius of the drift tube - Config.CalibrationTool.InnerTubeRadius = 14.6 - #write out default resolution - Config.MdtCalibOutputDbSvc.ForceDefaultResolution = True - #set the lower and upper radius of the parabolic at the end of the r-t - Config.CalibrationTool.LowerExtrapolationRadius = 13.0; - Config.CalibrationTool.UpperExtrapolationRadius = 14.0; - Config.CalibrationTool.StoreMultilayerTmaxDiff = runArgs.applyRtScaling - -# --------------------for classical autocalibration----------------------------- -if Config.CalibrationAlgorithm == "ClassicAutocal" : - #range for the number of hits - Config.CalibrationTool.MinimumNumberOfHits = 5 - Config.CalibrationTool.MaximumNumberOfHits = 10 - #maximum number of iterations - Config.CalibrationTool.NumberOfIterations = 10 - #chi2 cuts - ? - Config.CalibrationTool.Chi2CutVec = [ 50, 40, 30, 20, 10, 10, 10, 5, 5, 5 ] - Config.CalibrationTool.Chi2Cut = 10.0 - - -#-------------------for analytic autocalibration-------------------------------- -if Config.CalibrationAlgorithm == "AnalyticAutocal": - #accuracy of the initial rt relation - Config.CalibrationTool.Accuracy = 2.0 - #type of the correction function LEGENDRE|CHEBYSHEV|POLYGON - Config.CalibrationTool.FunctionType = "LEGENDRE" - #order of the correction function - Config.CalibrationTool.FunctionOrder = 10 - #use the full matrix - ? - Config.CalibrationTool.FullMatrix = True - # fix minimum/maximum - Config.CalibrationTool.FixMin = True # fix r(t0) - Config.CalibrationTool.FixMax = False # do not fix r(tmax) - #maximum number of iterations - Config.CalibrationTool.MaximumIterations = 10 - # split the segments up according the multilayers - Config.CalibrationTool.Split = True - # smoothening using the conventional approach after autocalibration - # WARNING: if Split = True and the whole chamber is selected as calibration - # region, curved segments over the whole chambers are - # fitted in the smoothening procedure which cause no smoothening in - # case of a multilayer as calibration region - Config.CalibrationTool.ConventionalSmoothening = False - # parabolic extrapolation for small and large radii; - # set variable to True for parabolic extrapolation - Config.CalibrationTool.ParabolicExtrapolation = True - # control histograms - Config.CalibrationTool.ControlHistograms=True - -#-------------------for curved autocalibration---------------------------------- -if Config.CalibrationAlgorithm == "CurvedAutocal": - #accuracy of the initial rt relation - Config.CalibrationTool.Accuracy = 2.0 - #type of the correction function LEGENDRE|CHEBYSHEV|POLYGON - Config.CalibrationTool.FunctionType = "LEGENDRE" - #order of the correction function - Config.CalibrationTool.FunctionOrder = 10 - # fix minimum/maximum - Config.CalibrationTool.FixMin = True # fix r(t0) - Config.CalibrationTool.FixMax = False # do not fix r(tmax) - #maximum number of iterations - Config.CalibrationTool.MaximumIterations = 10 - # parabolic extrapolation for small and large radii; - # set variable to True for parabolic extrapolation - Config.CalibrationTool.ParabolicExtrapolation = True - #control histograms - Config.CalibrationTool.ControlHistograms=True - Config.CalibrationTool.MultilayerRtScale = runArgs.applyRtScaling - -#-----------------for simple resolution----------------------------------------- -#--select NumberOfSegments=10000 -#--switch on RefineT0 and use HistFitMethod for commissioning data -if Config.CalibrationAlgorithm == "SimpleResolution": - Config.CalibrationTool.CurvedFit = True #use a curved track fit (set it to true - #for data with magnetic field) -#selection criteria - Config.CalibrationTool.RejectLow = 0.1 #default 0.1 - Config.CalibrationTool.RejectTop = 0.40 #default 0.30 -#convergence - Config.CalibrationTool.DeltaConv = 0.06 #default 0.05 - Config.CalibrationTool.DiffMax = 0.007 #default 0.006 microns - Config.CalibrationTool.MaximumIterations = 20 #default 20 -#Replace initial spatial resoluton with flat one (=0.3mm). Used for validation. - Config.CalibrationTool.InitialFlatResolution = False -#Obtain resolution using histogram fitting. Usefull in case of 'noisy' residuals. - Config.CalibrationTool.HistFitMethod = True -#Remove hits with large residuals (outliers). -# Config.CalibrationTool.SuppressOutliers = True -# Config.CalibrationTool.SuppressionLow = 0.17 -# Config.CalibrationTool.SuppressionTop = 0.17 - Config.CalibrationTool.OutputResolutionFunction = "spr_out.root" - - -#-----------------for RCP Timing------------------------------------------------ -if Config.CalibrationAlgorithm == "RpcTiming": - CalibNtupleAnalysisAlg.RefineT0 = runArgs.refineT0 - #analysis cue - defaults to "MODULE", "DOUBLET", "STATION", "PAIRS", "MEAN", "ALLSPEC" -# Config.CalibrationTool.Cue = [ "MODULE" ] - #output and input file for timing constants - #NONE: do not read/ write file - #AUTO: filename is rpc_timing<run_nr>.txt - Config.CalibrationTool.TimingInfile = "NONE" - Config.CalibrationTool.TimingOutfile = "AUTO" - #automatically select all stations for this analysis - CalibNtupleAnalysisAlg.SelectStation = "ANY" - CalibNtupleAnalysisAlg.SelectEta = 0 - CalibNtupleAnalysisAlg.SelectPhi = -1 - -#-----------------for control histograms---------------------------------------- -if Config.CalibrationAlgorithm == "ControlHistograms": - #name of the ROOT output file - Config.CalibrationTool.ROOTFileName = "NtupleControlHistogramsTool.root" - -#-----------------for MDT chamber geometry determination------------------------ -if Config.CalibrationAlgorithm == "MDTChamberGeometryDetermination": - #write out a ROOT control file - Config.CalibrationTool.writeControlHistograms = True - #name of this ROOT file - Config.CalibrationTool.ROOTFileName = "NtupleMDTChamberGeometryDeterminationTool.root" - #granularity: "TUBE", "LAYER", "MULTILAYER" - Config.CalibrationTool.granularity = "MULTILAYER" - #reference multilayer (1 or 2) - Config.CalibrationTool.referenceMultilayer = 1 - #road width for pattern recognition in mm - #(also used in the misalignment cuts) - Config.CalibrationTool.roadWidth = 2.0 - #geometry file tag for the output of the initial and final geometry - Config.CalibrationTool.geometryFileName = "MDTgeom" - #store gate keys - Config.CalibrationTool.detectorStore = "DetectorStore" - Config.CalibrationTool.MDTIdHelper = "MDTIDHELPER" - Config.CalibrationTool.idToFixedIdToolType = "MuonCalib::IdToFixedIdTool" - Config.CalibrationTool.idToFixedIdToolName = "MuonCalib_IdToFixedIdTool" - -#-----------------for efficiencies---------------------------------------------- -if Config.CalibrationAlgorithm == "Efficiency": - Config.CalibrationTool.nSegmentHits = 5 - Config.CalibrationTool.roadWidth = 2.0 - Config.CalibrationTool.fileName = "TubeEfficiencies" - Config.CalibrationTool.Debug = False - Config.CalibrationTool.Chi2Cut = 10 - Config.CalibrationTool.excludeLayer = False - -#-----------------for display--------------------------------------------------- -if Config.CalibrationAlgorithm == "Display": - Config.CalibrationTool.nSegmentHits = 5 - Config.CalibrationTool.roadWidth = 2.0 - Config.CalibrationTool.adcCut = CalibNtupleAnalysisAlg.RawdataAdcCut - #Config.CalibrationTool.displayEvent = 123 - #Config.CalibrationTool.scaleDisplay = 0.5 - -#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++### Setup Athena common flags -if Config.CalibrationAlgorithm == "Splitter": - levels={"NONE":0, "NAME":1, "NAME_PHI":2, "NAME_PHI_ETA":3} - if runArgs.splitterStoreTracks: - Config.CalibrationTool.FillTrackAuthors = [-1] - if hasattr(Config, "RegionSelection"): - if hasattr(Config.RegionSelection, "TrackAutors"): - if len(Config.RegionSelection.TrackAutors): - Config.CalibrationTool.FillTrackAuthors = Config.RegionSelection.TrackAutors - if hasattr(Config.RegionSelection, "MomentumCut"): - Config.CalibrationTool.TrackPCut = Config.RegionSelection.MomentumCut - Config.CalibrationTool.FileSplitLevel =levels[runArgs.splitterFileSplitLevel] - Config.CalibrationTool.NtupleSplitLevel =levels[runArgs.splitterNtupleSplitLevel] - Config.CalibrationTool.FilenamePrefix="OutNtuple" - Config.CalibrationTool.MaxPatterns=200000 - Config.CalibrationTool.StoreTruth=False - Config.CalibrationTool.StoreMdtRawdata=runArgs.splitterStoreRaw - Config.CalibrationTool.StoreRpcRawdata=runArgs.splitterStoreRaw - Config.CalibrationTool.StoreTgcRawdata=runArgs.splitterStoreRaw - Config.CalibrationTool.TriggerForSegmentStationOnly=True - Config.CalibrationTool.AdcCut=runArgs.splitterADCCut - from MuonCalibStandAloneTools.MuonCalibStandAloneToolsConf import MuonCalib__NtupleRunScanTool - Config.CalibrationTool2 = MuonCalib__NtupleRunScanTool() - ToolSvc += Config.CalibrationTool2 - Config.CalibrationTool2.MinHits = 10000 - #maximum rate of bad hits per chamber - Config.CalibrationTool2.MaxBadFits = 0.9999 - #if set to true ommit output for chambers which are not to be fitted - Config.CalibrationTool2.SuppressNofit = True - Config.CalibrationTool.ToolToRun=Config.CalibrationTool2 -printfunc (AlgSequence()) -printfunc (ToolSvc) -printfunc (ServiceMgr) -from ROOT import gROOT, TCanvas, TF1 -theApp.EvtMax = 1 diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_ntuple.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_ntuple.py deleted file mode 100644 index f918325b833af999846632f30a7e7c45334f170c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_ntuple.py +++ /dev/null @@ -1,216 +0,0 @@ -# get the logger - -from RecExConfig.RecFlags import rec as recFlags -recFlags.doFloatingPointException.set_Value_and_Lock(False) - -from AthenaCommon.Logging import * -mdtCalibNtuplelog = logging.getLogger('mdtCalibNtuple') - -mdtCalibNtuplelog.info('************** STARTING MDT CalibNtuple **************') -#============================================================== -# Job definition parameters: -#============================================================== -EvtMax = runArgs.maxEvents -SkipEvents = runArgs.skipEvents -InputFiles = runArgs.inputBSFile -RunNumber = runArgs.runNumber -NtupleFile = runArgs.ntupleFile -doSim = runArgs.doSim -geover = runArgs.geometryVersion -#new params to be implemented -globalTag = runArgs.conditionsTag -useAlign = runArgs.useAlign -dbT0Tag = runArgs.dbT0Tag -dbRTTag = runArgs.dbRTTag -dbT0Sql = runArgs.dbT0Sql -dbRTSql = runArgs.dbRTSql -segOnly = runArgs.segOnly -moore = runArgs.moore -mboy = runArgs.mboy -standalone = runArgs.standalone -doCSC = runArgs.doCSC -rawTgc = runArgs.rawTgc -cosmicRun = runArgs.cosmicRun -doSegmentT0Fit = runArgs.doSegmentT0Fit or cosmicRun -lumiBlockNumberFromCool = runArgs.lumiBlockNumberFromCool -runNumberFromCool = runArgs.runNumberFromCool - -if geover.find('NF') >=0: - field=False -else: - field=True - -mdtCalibNtuplelog.info( '**** Transformation run arguments ****' ) -mdtCalibNtuplelog.info( str(runArgs) ) - -#============================================================== -# Job Configuration parameters: -#============================================================== -from MuonCalibJobTransforms.MDTCalibNtupleConfig import mdtCalibNtupleConfig -for cf in runArgs.jobConfig: - include(cf) -mdtCalibNtuplelog.info( '**** Transformation configuration arguments ****' ) -mdtCalibNtuplelog.info( str(mdtCalibNtupleConfig) ) - -#============================================================== -# Job options file for MDT Calib Ntuple creation -#============================================================== - - -# ####################################################################### -# TopOptions to process calibration stream -# ####################################################################### - -from AthenaCommon.BeamFlags import jobproperties -from AthenaCommon.GlobalFlags import globalflags - - -globalflags.DatabaseInstance.set_Value_and_Lock('CONDBR2') #Fabrizio -globalflags.DataSource.set_Value_and_Lock('data') -if globalflags.DataSource() == 'data': - if cosmicRun: - jobproperties.Beam.beamType.set_Value_and_Lock("cosmics") - globalflags.DetGeo.set_Value_and_Lock('commis') - else: - globalflags.DetGeo.set_Value_and_Lock('atlas') - globalflags.DetDescrVersion.set_Value_and_Lock(geover) - recFlags.doTruth.set_Value_and_Lock(False) - -from AthenaCommon.BFieldFlags import jobproperties -if field: - jobproperties.BField.solenoidOn.set_Value_and_Lock(True) - jobproperties.BField.barrelToroidOn.set_Value_and_Lock(True) - jobproperties.BField.endcapToroidOn.set_Value_and_Lock(True) -else: - jobproperties.BField.solenoidOn.set_Value_and_Lock(False) - jobproperties.BField.barrelToroidOn.set_Value_and_Lock(False) - jobproperties.BField.endcapToroidOn.set_Value_and_Lock(False) - - -from AthenaCommon.AlgSequence import AlgSequence -from RecExConfig.RecFlags import rec #Ben (avoid Run1, COMP200 selection) -rec.projectName="calb15_um" #Ben -from MuonRecExample import MuonRecStandaloneFlags -from MuonRecExample import MuonRecStandaloneOnlySetup -from MuonRecExample.MuonRecFlags import muonRecFlags -from AthenaCommon.DetFlags import DetFlags - -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -athenaCommonFlags.PoolRDOInput.set_Value_and_Lock([]) -athenaCommonFlags.RuntimeStrictness.set_Value_and_Lock("none") - -# Run on CSC data or not -muonRecFlags.doCSCs=doCSC - -globalflags.ConditionsTag.set_Value_and_Lock(globalTag)##### SET VIA COMMAND LINE IN THE TRF -from IOVDbSvc.CondDB import conddb -if globalflags.ConditionsTag(): - conddb.setGlobalTag(globalflags.ConditionsTag()) -printfunc (globalflags) -DetFlags.Calo_setOff() -DetFlags.TRT_setOff() -DetFlags.ID_setOff() -from AtlasGeoModel import SetGeometryVersion -from AtlasGeoModel import GeoModelInit - -# Run Moore -muonRecFlags.doMoore = moore #### SET VIA COMMAND LINE IN THE TRF -# Run Muonboy -#muonRecFlags.doMuonboy = (mboy or standalone) #### SET VIA COMMAND LINE IN THE TRF -muonRecFlags.doMuonboy = mboy -#NOTE: In 17.2 the 3rd chain cannot run w/o muonboy. -#turn on/off track reconstruction -muonRecFlags.doSegmentsOnly = segOnly #### SET VIA COMMAND LINE IN THE TRF -muonRecFlags.doStandalone = standalone #3rd chain - - -# for MDT calibration constants -muonRecFlags.dataPeriod.set_Value_and_Lock('LHC') - -# Switch on the alignment corrections -muonRecFlags.useAlignmentCorrections = useAlign##### SET VIA COMMAND LINE IN THE TRF - -# calibration ntuple -muonRecFlags.doCalib = False -muonRecFlags.doCalibNtuple = True -muonRecFlags.calibNtupleOutput=NtupleFile ##### SET VIA COMMAND LINE IN THE TRF -muonRecFlags.calibNtupleSegments = True -muonRecFlags.calibNtupleTracks = True -muonRecFlags.calibNtupleRawTGC = rawTgc ##### SET VIA COMMAND LINE IN THE TRF - -# Switch off the T0 fit (on by default for data) -#muonRecFlags.doSegmentT0Fit = False -muonRecFlags.doSegmentT0Fit = doSegmentT0Fit - -topSequence = AlgSequence() -if muonRecFlags.doMDTs: - DetFlags.makeRIO.MDT_setOff() -if muonRecFlags.doRPCs: - DetFlags.makeRIO.RPC_setOn() -if muonRecFlags.doTGCs: - DetFlags.makeRIO.TGC_setOn() - -#Set up new cabling. -from MuonMDT_Cabling.MuonMDT_CablingConf import MuonMDT_CablingSvc -#svcMgr += MuonMDT_CablingSvc(name="MuonMDT_CablingSvc", false , false) -#svcMgr.MuonMDT_CablingSvc.doCalStreamInit=True -svcMgr += MuonMDT_CablingSvc(name="MuonMDT_CablingSvc", UseOldCabling=False, ForcedUse=False, doCalStreamInit=True) -#svcMgr.MuonMDT_CablingSvc.doCalStreamInit=True -printfunc ('skeleton: setting doCalStreamInit true') - -include("MuonRecExample/MuonRDO_to_PRD_jobOptions.py") - -# to alter DB options -#overwriting the tag -if dbT0Tag!='DEFAULT': - if dbT0Sql!='DEFAULT': - conddb.blockFolder("/MDT/T0BLOB") - conddb.addFolder(dbT0Sql,"/MDT/T0BLOB <tag>"+dbT0Tag+"</tag>",True) - else: - conddb.addOverride("/MDT/T0BLOB",dbT0Tag) -if dbRTTag!='DEFAULT': - if dbRTSql!='DEFAULT': - conddb.blockFolder("/MDT/RTBLOB") - conddb.addFolder(dbRTSql,"/MDT/RTBLOB <tag>"+dbRTTag+"</tag>",True) - else: - conddb.addOverride("/MDT/RTBLOB",dbRTTag) - -include ("MuonCalibStreamCnvSvc/MuonCalibStream_jobOptions.py") -theApp.EvtMax = EvtMax ##### SET VIA COMMAND LINE IN THE TRF -EventSelectorMuonCalibStream.SkipEvents=SkipEvents ##### SET VIA COMMAND LINE IN THE TRF -svcMgr.MuonCalibStreamDataProviderSvc.RunNumber=RunNumber ##### SET VIA COMMAND LINE IN THE TRF -svcMgr.MuonCalibStreamFileInputSvc.InputFiles = InputFiles ##### SET VIA COMMAND LINE IN THE TRF - -svcMgr.MuonCalibStreamDataProviderSvc.LumiBlockNumberFromCool=lumiBlockNumberFromCool -svcMgr.MuonCalibStreamDataProviderSvc.RunNumberFromCool=runNumberFromCool - -printfunc (topSequence) - -# obselete -#include ("BFieldAth/BFieldAth_jobOptions.py") -import MagFieldServices.SetupField - -# lock all flags. Very important! -muonRecFlags.lock_JobProperties() - -# Enable conversion of old eventInfo to xAOD eventInfo (Dongliang) -from xAODEventInfoCnv.xAODEventInfoCnvConf import xAODMaker__EventInfoCnvAlg -topSequence += xAODMaker__EventInfoCnvAlg('EventInfoCnvAlg') -topSequence.EventInfoCnvAlg.AODKey='MuonCalibStreamEventInfo' - -include ("MuonRecExample/MuonRec_jobOptions.py") -try: - ToolSvc.CscSegmentUtilTool.Add2hitSegments = True -except AttributeError: - pass - -#ToolSvc.CscSegmentUtilTool.OutputLevel = VERBOSE -#ToolSvc.MooTrackSteering.DumpCombinatorics = True -svcMgr += CfgMgr.MessageSvc( Format = "% F%50W%S%7W%R%T %0W%M", - defaultLimit=1000000, OutputLevel =INFO) - -#if not mboy and not segOnly and hasattr(topSequence.MuonCalibExtraTreeAlg, "Track2MELocation"): -# topSequence.MuonCalibExtraTreeAlg.Track2MELocation="" - -from AthenaCommon.ConfigurationShelve import saveToAscii -saveToAscii("config.txt") diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_ntuple_tf.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_ntuple_tf.py deleted file mode 100644 index 88b004cf0dcfb24fd76ae26a4d9fdb73e21b86aa..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_ntuple_tf.py +++ /dev/null @@ -1,226 +0,0 @@ -from RecExConfig.RecFlags import rec as recFlags -recFlags.doFloatingPointException.set_Value_and_Lock(False) - -# get the logger -import logging -mdtCalibNtuplelog = logging.getLogger('mdt_calib_ntuple') -mdtCalibNtuplelog.info('************** STARTING MDTCalibNtuple **************') -mdtCalibNtuplelog.info( '**** Transformation run arguments ****' ) -mdtCalibNtuplelog.info( str(runArgs) ) - -#============================================================== -# Job definition parameters: -#============================================================== -# Set defaults for boolean variables in runArgs -# Boolean variables do not exist in runArgs if they are not on the command line -# so check if they exist before using them -#doSim = runArgs.doSim #Never used so skip it -useAlign = True -# If segOnly = True ntuple has no variables filled which is pointless -#segOnly = False -#moore = False -#mboy = False -# If standalone = False all ntuple variables are filled with zeros which is pointless -#standalone = True -doSegmentT0Fit = False -doCSC = True -rawTgc = False -cosmicRun = False -lumiBlockNumberFromCool = False -runNumberFromCool = False - -if hasattr(runArgs,'useAlign'): - useAlign = runArgs.useAlign -#if hasattr(runArgs,'segOnly'): -# segOnly = runArgs.segOnly -#if hasattr(runArgs,'moore'): -# moore = runArgs.moore -#if hasattr(runArgs,'nboy'): -# mboy = runArgs.mboy -#if hasattr(runArgs,'standalone'): -# standalone = runArgs.standalone -if hasattr(runArgs,'doCSC'): - doCSC = runArgs.doCSC -if hasattr(runArgs,'rawTgc'): - rawTgc = runArgs.rawTgc -if hasattr(runArgs,'cosmicRun'): - cosmicRun = runArgs.cosmicRun -if hasattr(runArgs,'doSegmentT0Fit'): - doSegmentT0Fit = runArgs.doSegmentT0Fit or cosmicRun -if hasattr(runArgs,'lumiBlockNumberFromCool'): - lumiBlockNumberFromCool = runArgs.lumiBlockNumberFromCool -if hasattr(runArgs,'runNumberFromCool'): - runNumberFromCool = runArgs.runNumberFromCool - -#============================================================== -# Job Configuration parameters: -#============================================================== -from MuonCalibJobTransforms.MDTCalibNtupleConfig import mdtCalibNtupleConfig -# hardcode UseOracle.py which enables use of Frontier DB replicas. -# As far as I can see you always want to do this. -include("RecJobTransforms/UseOracle.py") -# UseOracle.py used to be loaded here via be commandline argument -#for cf in runArgs.jobConfig: -# include(cf) -mdtCalibNtuplelog.info( '**** Transformation configuration arguments ****' ) -mdtCalibNtuplelog.info( str(mdtCalibNtupleConfig) ) - -#============================================================== -# Job options file for MDT Calib Ntuple creation -#============================================================== - -from AthenaCommon.BeamFlags import jobproperties -from AthenaCommon.GlobalFlags import globalflags - -globalflags.DataSource.set_Value_and_Lock('data') -# This if is sort of silly since 'data' is the only option. -if globalflags.DataSource() == 'data': - if cosmicRun: - jobproperties.Beam.beamType.set_Value_and_Lock("cosmics") - globalflags.DetGeo.set_Value_and_Lock('commis') - else: - globalflags.DetGeo.set_Value_and_Lock('atlas') - globalflags.DetDescrVersion.set_Value_and_Lock(runArgs.geometryVersion) - recFlags.doTruth.set_Value_and_Lock(False) - -# Check if Bfield is on -from AthenaCommon.BFieldFlags import jobproperties -if runArgs.geometryVersion.find('NF') >=0: #no field - jobproperties.BField.solenoidOn.set_Value_and_Lock(False) - jobproperties.BField.barrelToroidOn.set_Value_and_Lock(False) - jobproperties.BField.endcapToroidOn.set_Value_and_Lock(False) -else: - jobproperties.BField.solenoidOn.set_Value_and_Lock(True) - jobproperties.BField.barrelToroidOn.set_Value_and_Lock(True) - jobproperties.BField.endcapToroidOn.set_Value_and_Lock(True) - -# CONDBR2 (Run2 COOL instance) will be selected by default -# If processing Run1 calibstream force COMP200 selection by setting -# a project name which has the digits "12" so Athena knows this is Run1 -if runArgs.runNumber < 220000: #Run1 - from RecExConfig.RecFlags import rec - rec.projectName="calb12_um" #Force Run1, COMP200 selection -from MuonRecExample import MuonRecStandaloneFlags -from MuonRecExample import MuonRecStandaloneOnlySetup -from MuonRecExample.MuonRecFlags import muonRecFlags -from AthenaCommon.DetFlags import DetFlags - -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -athenaCommonFlags.PoolRDOInput.set_Value_and_Lock([]) -athenaCommonFlags.RuntimeStrictness.set_Value_and_Lock("none") - -# Run on CSC data or not (why would you not want to?) -muonRecFlags.doCSCs=doCSC - -# Add rawTgc and rawTgcCoin branches to calib ntuple -muonRecFlags.calibNtupleRawTGC = rawTgc - -globalflags.ConditionsTag.set_Value_and_Lock(runArgs.conditionsTag) -from IOVDbSvc.CondDB import conddb -if globalflags.ConditionsTag(): - conddb.setGlobalTag(globalflags.ConditionsTag()) -printfunc (globalflags) - -# Turn off detectors which are not present in calibstream -DetFlags.Calo_setOff() -DetFlags.TRT_setOff() -DetFlags.ID_setOff() - -from AtlasGeoModel import SetGeometryVersion -from AtlasGeoModel import GeoModelInit - -# No longer needed, standalone is the only option set True by default. -# ntuple variables will be filled with zero's if it is set False -# Run Moore -#muonRecFlags.doMoore = moore #### SET VIA COMMAND LINE IN THE TRF -# Run Muonboy -#muonRecFlags.doMuonboy = (mboy or standalone) #### SET VIA COMMAND LINE IN THE TRF -#muonRecFlags.doMuonboy = mboy -#NOTE: In 17.2 the 3rd chain cannot run w/o muonboy. -#turn on/off track reconstruction -#muonRecFlags.doSegmentsOnly = segOnly #### SET VIA COMMAND LINE IN THE TRF -#muonRecFlags.doStandalone = standalone #3rd chain - -# for MDT calibration constants -muonRecFlags.dataPeriod.set_Value_and_Lock('LHC') - -# Switch for alignment corrections (on by default) -muonRecFlags.useAlignmentCorrections = useAlign - -# calibration ntuple -muonRecFlags.doCalib = False -muonRecFlags.doCalibNtuple = True -muonRecFlags.calibNtupleOutput = runArgs.ntupleFile -muonRecFlags.calibNtupleSegments = True -muonRecFlags.calibNtupleTracks = True - -# Switch for T0 segment fit (on by default) -muonRecFlags.doSegmentT0Fit = doSegmentT0Fit - -from AthenaCommon.AlgSequence import AlgSequence -topSequence = AlgSequence() -if muonRecFlags.doMDTs: - DetFlags.makeRIO.MDT_setOff() -if muonRecFlags.doRPCs: - DetFlags.makeRIO.RPC_setOn() -if muonRecFlags.doTGCs: - DetFlags.makeRIO.TGC_setOn() - -#Set up cabling which is different for Run1/Run2. -from MuonMDT_Cabling.MuonMDT_CablingConf import MuonMDT_CablingSvc -if runArgs.runNumber > 220000: #Run2 - svcMgr += MuonMDT_CablingSvc(name="MuonMDT_CablingSvc", UseOldCabling=False, ForcedUse=False, doCalStreamInit=True) -else: - svcMgr += MuonMDT_CablingSvc(name="MuonMDT_CablingSvc", UseOldCabling=True, ForcedUse=False, doCalStreamInit=True) - -include("MuonRecExample/MuonRDO_to_PRD_jobOptions.py") - -# Options to select tag for T0/RT or to read from SQLite files. -# If reading from SQLite, you must specify the tag used in the SQLite file -if runArgs.dbT0Tag!='DEFAULT': - if runArgs.dbT0Sql!='DEFAULT': - conddb.blockFolder("/MDT/T0BLOB") - conddb.addFolder(runArgs.dbT0Sql,"/MDT/T0BLOB <tag>"+runArgs.dbT0Tag+"</tag>",True) - else: - conddb.addOverride("/MDT/T0BLOB",runArgs.dbT0Tag) -if runArgs.dbRTTag!='DEFAULT': - if runArgs.dbRTSql!='DEFAULT': - conddb.blockFolder("/MDT/RTBLOB") - conddb.addFolder(runArgs.dbRTSql,"/MDT/RTBLOB <tag>"+runArgs.dbRTTag+"</tag>",True) - else: - conddb.addOverride("/MDT/RTBLOB",runArgs.dbRTTag) - -# This code disables the ordinary Athena event loop and installs the calibstream event loop -include ("MuonCalibStreamCnvSvc/MuonCalibStream_jobOptions.py") - -theApp.EvtMax = runArgs.Events -EventSelectorMuonCalibStream.SkipEvents = runArgs.Skip -svcMgr.MuonCalibStreamDataProviderSvc.RunNumber = runArgs.runNumber -svcMgr.MuonCalibStreamFileInputSvc.InputFiles = runArgs.inputCSFiles - -svcMgr.MuonCalibStreamDataProviderSvc.LumiBlockNumberFromCool = lumiBlockNumberFromCool -svcMgr.MuonCalibStreamDataProviderSvc.RunNumberFromCool = runNumberFromCool - -printfunc (topSequence) - -import MagFieldServices.SetupField - -# lock all flags. Very important! -muonRecFlags.lock_JobProperties() - -# Enable conversion of old eventInfo to xAOD eventInfo (Dongliang) -from xAODEventInfoCnv.xAODEventInfoCnvConf import xAODMaker__EventInfoCnvAlg -topSequence += xAODMaker__EventInfoCnvAlg('EventInfoCnvAlg') -topSequence.EventInfoCnvAlg.AODKey='MuonCalibStreamEventInfo' - -include ("MuonRecExample/MuonRec_jobOptions.py") -try: - ToolSvc.CscSegmentUtilTool.Add2hitSegments = True -except AttributeError: - pass - -svcMgr += CfgMgr.MessageSvc( Format = "% F%50W%S%7W%R%T %0W%M", - defaultLimit=1000000, OutputLevel =INFO) - -from AthenaCommon.ConfigurationShelve import saveToAscii -saveToAscii("config.txt") diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_validate.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_validate.py deleted file mode 100644 index 615724890cf1b94eb10fdfd098274994fa71d127..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.mdt_calib_validate.py +++ /dev/null @@ -1,113 +0,0 @@ -# get the logger -from AthenaCommon.Logging import * -mdtCalibFitlog = logging.getLogger('mdtCalibFit') - -mdtCalibFitlog.info('************** STARTING MDT CalibFit !!!!**************') -#============================================================== -# Job definition parameters: -#============================================================== -CalibSite = runArgs.calibSite -geover = runArgs.geometryVersion -mdtCalibFitlog.info( '**** Transformation run arguments ****' ) -#mdtCalibFitlog.info( str(runArgs) ) - -#============================================================== -# Job Configuration parameters: -#============================================================== -from MuonCalibJobTransforms.MDTCalibFitConfig import mdtCalibFitConfig -#for cf in runArgs.jobConfig: -# include(cf) -mdtCalibFitlog.info( '**** Transformation configuration arguments ****' ) -mdtCalibFitlog.info( str(mdtCalibFitConfig) ) - -### Setup Athena common flags -#include ("AthenaCommon/AthenaCommonFlags.py") -#include.block("AthenaCommon/AthenaCommonFlags.py") - -#include( "IOVDbSvc/IOVRecExCommon.py" ) - -#load atlas geometry -from AthenaCommon.GlobalFlags import globalflags -#GlobalFlags.DetGeo.set_atlas() -#GlobalFlags.DataSource.set_data() -#GlobalFlags.Print() -globalflags.DetGeo.set_Value_and_Lock('atlas') -ToolSvc = Service( "ToolSvc" ) -globalflags.DataSource.set_Value_and_Lock('data') - -from AthenaCommon.DetFlags import DetFlags -DetFlags.detdescr.Muon_setOn() -DetFlags.detdescr.ID_setOff() -DetFlags.detdescr.LAr_setOff() -DetFlags.detdescr.Tile_setOff() -DetFlags.Print() -#Set geometry tag -from AtlasGeoModel import SetGeometryVersion, GeoModelInit -GeoModelSvc = ServiceMgr.GeoModelSvc -GeoModelSvc.AtlasVersion = geover - -from AthenaCommon.AppMgr import ServiceMgr -from AthenaCommon.AppMgr import ToolSvc - -from MdtCalibValidation.MdtCalibValidationConf import MuonCalib__MdtValidationAlg -MdtValidationAlg = MuonCalib__MdtValidationAlg() - -from AthenaCommon.AlgSequence import AlgSequence -topSequence = AlgSequence() -topSequence += MdtValidationAlg - -theApp.EvtMax = 1 - -from MuonCalibStandAloneBase.MuonCalibStandAloneBaseConf import RegionSelectionSvc -RegionSelectionSvc = RegionSelectionSvc() -RegionSelectionSvc.PrintList = True -ServiceMgr += RegionSelectionSvc -#RegionSelectionSvc.Region = "[BIL,4,6]" -RegionSelectionSvc.Region = runArgs.selectChamber - -MdtValidationAlg.SiteName=CalibSite -if (CalibSite == "MP"): -# MPI - MdtValidationAlg.ConnectionString = "oracle://oracle01.mppmu.mpg.de/ATLMPI.mppmu.mpg.de/atlas_muoncalib_mpi" - MdtValidationAlg.WorkingSchema = "atlas_muoncalib_mpi" -elif (CalibSite == "MP_NEW"): -# MPI - MdtValidationAlg.ConnectionString = "oracle://oracle01.mppmu.mpg.de/ATLMPI.mppmu.mpg.de/ATLAS_MUONCALIB_READER" - MdtValidationAlg.WorkingSchema = "ATLAS_MUONCALIB_MPI_META" - MdtValidationAlg.WriterConnectionString = "oracle://oracle01.mppmu.mpg.de/ATLMPI.mppmu.mpg.de/ATLAS_MUONCALIB_WRITER" -elif (CalibSite == "MI"): -# Michigan - VlidationAlgalidationAlg.ConnectionString = "oracle://umors.grid.umich.edu/muoncal.grid.umich.edu/atlas_muoncalib_mich" - MdtValidationAlg.WorkingSchema = "atlas_muoncalib_mich" -elif (CalibSite == "MI_NEW"): -# Michigan - MdtValidationAlg.ConnectionString = "oracle://umors.grid.umich.edu/muoncal.grid.umich.edu/ATLAS_MUONCALIB_READER" - MdtValidationAlg.WorkingSchema = "ATLAS_MUONCALIB_UMICH" - MdtValidationAlg.WriterConnectionString = "oracle://umors.grid.umich.edu/muoncal.grid.umich.edu/ATLAS_MUONCALIB_WRITER" -elif (CalibSite == "RM"): -# ROMA - MdtValidationAlg.ConnectionString = "oracle://atlas-oracle-01.roma1.infn.it/atlrome.roma1.infn.it/atlas_muoncalib_rome" - MdtValidationAlg.WorkingSchema = "atlas_muoncalib_rome" -elif (CalibSite == "RM_NEW"): -# ROMA - MdtValidationAlg.ConnectionString = "oracle://atlas-cluster.cr.cnaf.infn.it:1521/atlcnafsrv.cr.cnaf.infn.it/ATLAS_MUONCALIB_READER" - MdtValidationAlg.WorkingSchema = "ATLAS_MUONCALIB_RM_META" - MdtValidationAlg.WriterConnectionString = "oracle://atlas-cluster.cr.cnaf.infn.it:1521/atlcnafsrv.cr.cnaf.infn.it/ATLAS_MUONCALIB_WRITER" - -MdtValidationAlg.GetLimits = 0 -MdtValidationAlg.MinSlope = 1. -MdtValidationAlg.MaxSlope = 5 -# Run2 Values -MdtValidationAlg.MinT0 = -100 -MdtValidationAlg.MaxT0 = 400 -#MdtValidationAlg.MinT0 = 190 -#MdtValidationAlg.MaxT0 = 850 -MdtValidationAlg.HeadId = runArgs.headId -#MdtValidationAlg.GetLimits = runArgs.getLimits - -#MdtValidationAlg.ValidationTask = "RtVal" -#MdtValidationAlg.ValidationTask = "T0Val" -MdtValidationAlg.ValidationTask = runArgs.calibrationAlgorithm - -if mdtCalibFitConfig.postOptions is not None: - include(mdtCalibFitConfig.postOptions) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple.py deleted file mode 100644 index 14754fe3117f7c92fc591796cef284a8afc371f0..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple.py +++ /dev/null @@ -1,279 +0,0 @@ -# get the logger -from AthenaCommon.Logging import * -rpcCalibNtuplelog = logging.getLogger('rpcCalibNtuple') - -rpcCalibNtuplelog.info('************** STARTING RPC CalibNtuple **************') -#============================================================== -# Job definition parameters: -#============================================================== -EvtMax = runArgs.maxEvents -SkipEvents = runArgs.skipEvents -InputFiles = runArgs.inputBSFile -RunNumber = runArgs.runNumber -NtupleFile = runArgs.ntupleFile -FieldMask = runArgs.fieldMask -condTag = runArgs.conditionsTag -trignt = runArgs.trigNtuple -resnt = runArgs.resNtuple -prdnt = runArgs.prdNtuple -extrnt = runArgs.extrNtuple -recoalg = runArgs.recoAlg - -GeoVersion=runArgs.geometryVersion - -rpcCalibNtuplelog.info( '**** Transformation run arguments ****' ) -rpcCalibNtuplelog.info( str(runArgs) ) - -from RecExConfig.RecFlags import rec as recFlags -recFlags.doFloatingPointException.set_Value_and_Lock(False) - - -#============================================================== -# Job Configuration parameters: -#============================================================== - -include("RecJobTransforms/UseOracle.py") - - -from MuonCalibJobTransforms.RPCCalibNtupleConfig import rpcCalibNtupleConfig -for cf in runArgs.jobConfig: - include(cf) -rpcCalibNtuplelog.info( '**** Transformation configuration arguments ****' ) -rpcCalibNtuplelog.info( str(rpcCalibNtupleConfig) ) - -rpcClusterTimeSpread=rpcCalibNtupleConfig.clusterTimeSpread - -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -from AthenaCommon.BeamFlags import jobproperties -from AthenaCommon.GlobalFlags import globalflags -from AthenaCommon.BFieldFlags import jobproperties -from AthenaCommon.AlgSequence import AlgSequence -from AthenaCommon.DetFlags import DetFlags -from AthenaCommon.AppMgr import ServiceMgr as svcMgr -from AthenaCommon.AppMgr import ToolSvc - -from RecExConfig.RecFlags import rec -from RecExConfig.RecConfFlags import recConfFlags - -# in Standalone mode, don't allow any configuration errors -athenaCommonFlags.AllowIgnoreConfigError = False - -# For Trigger MBTS and L1 Calo we need the Tile Calorimeter -# the algorithm: MuonCalibExtraTreeTriggerAlg stores trigger info -#DetFlags.makeRIO.Calo_setOn() - -#DetFlags.detdescr.LVL1_setOn() -#DetFlags.readRDOBS.LVL1_setOn() - -#DetFlags.Calo_setOff() - -# Max number of events to run, number of events to skip -#athenaCommonFlags.EvtMax.set_Value_and_Lock(EvtMax) -#athenaCommonFlags.SkipEvents.set_Value_and_Lock(0) - -theApp.EvtMax = EvtMax - -# input BS file -athenaCommonFlags.PoolRDOInput.set_Value_and_Lock([]) -athenaCommonFlags.RuntimeStrictness.set_Value_and_Lock("none") - -# Set properly beam type, DataSource, InputFormat, Detector Description, Conditions Tag -globalflags.DataSource.set_Value_and_Lock('data') -globalflags.DetGeo.set_Value_and_Lock('commis') -globalflags.DetDescrVersion.set_Value_and_Lock(GeoVersion) -globalflags.ConditionsTag.set_Value_and_Lock(condTag) - -# field ++++ uncomment if you want to set them by hand +++++ -fieldFlag=[bool(int(FieldMask[0])),bool(int(FieldMask[1])),bool(int(FieldMask[2]))] - -jobproperties.BField.solenoidOn.set_Value_and_Lock(fieldFlag[0]) -jobproperties.BField.barrelToroidOn.set_Value_and_Lock(fieldFlag[1]) -jobproperties.BField.endcapToroidOn.set_Value_and_Lock(fieldFlag[2]) - -from MuonRecExample import MuonRecStandaloneFlags -from MuonRecExample import MuonRecStandaloneOnlySetup -from MuonRecExample.MuonRecFlags import muonRecFlags -from AthenaCommon.DetFlags import DetFlags - -from IOVDbSvc.CondDB import conddb -if globalflags.ConditionsTag(): - conddb.setGlobalTag(globalflags.ConditionsTag()) - - -from AtlasGeoModel import SetGeometryVersion -from AtlasGeoModel import GeoModelInit - - -topSequence = AlgSequence() - - -##################################################### - -# Start at formation of PRDs only -#muonRecFlags.Enabled = False - -# Disable MDTs +++ set to True also to permit the track reconstruction algos to run +++ -muonRecFlags.doMDTs=True - -# Disable RPCs -muonRecFlags.doRPCs=True - -# Disable TGCs -muonRecFlags.doTGCs=False - -# Run on CSC data or not -muonRecFlags.doCSCs.set_Value_and_Lock(False) - -muonRecFlags.doCalib.set_Value_and_Lock(False) - -muonRecFlags.doCalibNtuple.set_Value_and_Lock(False) - -# Stop Muonboy at segment level -#muonboyFlags.doSegmentsOnly = False - -# Stop Moore at segment level -#mooreFlags.doSegmentsOnly = False - -muonRecFlags.doSegmentsOnly = False - -muonRecFlags.dataPeriod.set_Value_and_Lock('LHC') - -if(trignt or prdnt): - muonRecFlags.doRPCs = True - -if recoalg=='Moore': - # Run Moore - muonRecFlags.doMoore = True -else: - muonRecFlags.doMoore = False - -if recoalg=='MuonBoy': - # Run Muonboy - muonRecFlags.doMuonboy = True -else: - muonRecFlags.doMuonboy = False - - -if muonRecFlags.doMDTs: - DetFlags.makeRIO.MDT_setOff() -if muonRecFlags.doRPCs: - DetFlags.makeRIO.RPC_setOn() -if muonRecFlags.doTGCs: - DetFlags.makeRIO.TGC_setOn() - - -# for MDT calibration constants -muonRecFlags.dataPeriod.set_Value_and_Lock('LHC') - -include("MuonRecExample/MuonRDO_to_PRD_jobOptions.py") - - -############ -## specific tuning for calib stream -############ - -include ("MuonCalibStreamCnvSvc/MuonCalibStream_jobOptions.py") -svcMgr.MuonCalibStreamDataProviderSvc.RunNumber=RunNumber -svcMgr.MuonCalibStreamFileInputSvc.InputFiles = InputFiles ##### SET VIA COMMAND LINE IN THE TRF -EventSelectorMuonCalibStream.SkipEvents=SkipEvents - -include ("BFieldAth/BFieldAth_jobOptions.py") - -# lock all flags. Very important! -muonRecFlags.lock_JobProperties() - -#rec.readRDO.set_Value_and_Lock(False) - - -### General Reco flags jobproperties -#from RecExConfig.RecFlags import rec -## -### no truth when running on data -#rec.doTruth = False -# -#rec.doMuon=True -# -## -### Switch Perfmon studies -#rec.doPerfMon = False -#rec.doDetailedPerfMon = False -#rec.doNameAuditor = False -# -# -#muonRecFlags.lock_JobProperties() -#rec.lock_JobProperties() -# -include ("MuonRecExample/MuonRec_jobOptions.py") - -include("MuonRecExample/MuonCBNT_jobOptions.py") - - -#include ("RecExCommon/RecExCommon_topOptions.py") - -#from CBNT_Athena.CBNT_AthenaConf import CBNT_AthenaAware -#topSequence += CBNT_AthenaAware() - -THistSvc = CfgMgr.THistSvc() -ServiceMgr += THistSvc -outputString="AANT DATAFILE=\'"+NtupleFile+"\' OPT=\'RECREATE\'" -THistSvc.Output = [outputString] - -try: - topSequence.AANTupleStream.OutputName=NtupleFile - -except AttributeError: - topSequence += CfgMgr.AANTupleStream(ExtraRefNames = [ "" ], - OutputName = NtupleFile, - ExistDataHeader = False ) - - -# activate RPC-specific ntuples - -if(extrnt): - include('RpcCalibAlgs/RpcExtrapolNtuple_jobOptions.py' ) - -if(resnt): - include('RpcCalibAlgs/RpcResidualsNtuple_jobOptions.py') - if recoalg=='Moore': - topSequence.CBNT_AthenaAware.RpcResidualsNtuple.TrackCollection = "MooreTracks" - -if(prdnt): - - topSequence.CBNT_AthenaAware.RpcPrepRawDataNtuple.Hit=True - topSequence.CBNT_AthenaAware.RpcPrepRawDataNtuple.Enable=True -else: - try: - topSequence.CBNT_AthenaAware.RpcPrepRawDataNtuple.Enable=False - except AttributeError: - pass - -if(trignt): - include('MuonCalibJobTransforms/rpc_trigNtuple.py') -else: - try: - topSequence.CBNT_AthenaAware.RpcRawDataNtuple.Enable=False - except AttributeError: - pass -try: - topSequence.CBNT_AthenaAware.MdtPrepRawDataNtuple.Enable=False -except AttributeError: - pass -try: - topSequence.CBNT_AthenaAware.MdtRawDataNtuple.Enable=False -except AttributeError: - pass -try: - topSequence.CBNT_AthenaAware.CBNTAA_Muon.Enable=False -except AttributeError: - pass -try: - topSequence.CBNT_AthenaAware.CBNTAA_Audit.Enable=False -except AttributeError: - pass -try: - topSequence.CBNT_AthenaAware.RpcRawDataNtuple.Enable=False -except AttributeError: - pass - -ServiceMgr.MessageSvc.infoLimit=10000000 -#ServiceMgr.MessageSvc.OutputLevel = DEBUG diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple_ESD.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple_ESD.py deleted file mode 100644 index 09577664447eeeb30f32ba4f7f7c04c724e71036..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple_ESD.py +++ /dev/null @@ -1,165 +0,0 @@ -# get the logger -from AthenaCommon.Logging import * -rpcCalibNtuplelog = logging.getLogger('rpcCalibNtuple') - -rpcCalibNtuplelog.info('************** STARTING RPC CalibNtuple **************') -#============================================================== -# Job definition parameters: -#============================================================== - -EvtMax = runArgs.maxEvents -SkipEvents = runArgs.skipEvents -InputFiles = runArgs.inputESDFile -RunNumber = runArgs.runNumber -NtupleFile = runArgs.ntupleFile -FieldMask = runArgs.fieldMask -condTag = runArgs.conditionsTag -trignt = runArgs.trigNtuple -resnt = runArgs.resNtuple -prdnt = runArgs.prdNtuple -extrnt = runArgs.extrNtuple -recoalg = runArgs.recoAlg - -GeoVersion=runArgs.geometryVersion -rpcCalibNtuplelog.info( '**** Transformation run arguments ****' ) -rpcCalibNtuplelog.info( str(runArgs) ) - -#============================================================== -# Job Configuration parameters: -#============================================================== -from MuonCalibJobTransforms.RPCCalibNtupleConfig import rpcCalibNtupleConfig -for cf in runArgs.jobConfig: - include(cf) -rpcCalibNtuplelog.info( '**** Transformation configuration arguments ****' ) -rpcCalibNtuplelog.info( str(rpcCalibNtupleConfig) ) - -rpcClusterTimeSpread=rpcCalibNtupleConfig.clusterTimeSpread -doSim=rpcCalibNtupleConfig.doSim - - - -from AthenaCommon.AlgSequence import AlgSequence -from RecExConfig.RecFlags import rec -from AthenaCommon.BeamFlags import jobproperties -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -from AthenaCommon.GlobalFlags import globalflags -from AthenaCommon.BFieldFlags import jobproperties - - - -from AthenaCommon.DetFlags import DetFlags - -topSequence = AlgSequence() - -##################### -## common/global config -##################### - - -DetFlags.detdescr.Muon_setOn() -DetFlags.detdescr.ID_setOn() -DetFlags.detdescr.LAr_setOff() -DetFlags.detdescr.Tile_setOff() -DetFlags.Print() - -#Minimally required flags for commissioning -#include("RecExCommission/MinimalCommissioningSetup.py") - -athenaCommonFlags.PoolESDInput.set_Value_and_Lock(InputFiles) -athenaCommonFlags.SkipEvents.set_Value_and_Lock(SkipEvents) -athenaCommonFlags.EvtMax.set_Value_and_Lock(EvtMax) - -globalflags.DetDescrVersion.set_Value_and_Lock(GeoVersion) -globalflags.ConditionsTag.set_Value_and_Lock(condTag) - -# field -fieldFlag=[bool(int(FieldMask[0])),bool(int(FieldMask[1])),bool(int(FieldMask[2]))] - -jobproperties.BField.solenoidOn.set_Value_and_Lock(fieldFlag[0]) -jobproperties.BField.barrelToroidOn.set_Value_and_Lock(fieldFlag[1]) -jobproperties.BField.endcapToroidOn.set_Value_and_Lock(fieldFlag[2]) - - -##################### -## rec config -##################### - -rec.doJetMissingETTag.set_Value_and_Lock(False) -from JetRec.JetRecFlags import jetFlags -jetFlags.Enabled.set_Value_and_Lock(False) -from RecExConfig.RecAlgsFlags import recAlgs -recAlgs.doMissingET.set_Value_and_Lock(False) -rec.doTau.set_Value_and_Lock(False) -recAlgs.doMuonSpShower.set_Value_and_Lock(False) - -rec.doHist.set_Value_and_Lock(False) -# don't want CBNT from RecExCommon. Will config it ourselves -rec.doCBNT.set_Value_and_Lock(False) -rec.doWriteTAGCOM.set_Value_and_Lock(False) -rec.doWriteTAG.set_Value_and_Lock(False) -rec.doWriteAOD.set_Value_and_Lock(False) -rec.doAOD.set_Value_and_Lock(False) -rec.doMonitoring.set_Value_and_Lock(False) - -rec.readESD.set_Value_and_Lock(True) -rec.doESD.set_Value_and_Lock(False) -rec.doWriteESD.set_Value_and_Lock(False) -globalflags.InputFormat.set_Value_and_Lock('pool') - -################### -## specific config -################### - -# add RPC clusterization at the beginning - -from RpcClusterization.RpcClusterizationConf import RpcClusterBuilderPRD -topSequence+=RpcClusterBuilderPRD(ClusterTimeSpread = 10000, OutputLevel = FATAL) - -#-------------------------------------------------------------- -# ntuple config -#-------------------------------------------------------------- -theApp.HistogramPersistency = "ROOT" - -THistSvc = CfgMgr.THistSvc() -ServiceMgr += THistSvc -outputString="AANT DATAFILE=\'"+NtupleFile+"\' OPT=\'RECREATE\'" -THistSvc.Output = [outputString] -topSequence += CfgMgr.AANTupleStream(ExtraRefNames = [ "" ], - OutputName = NtupleFile, - ExistDataHeader = False ) - -include( "CBNT_Athena/CBNT_AthenaAware_jobOptions.py" ) -include( "CBNT_Athena/CBNT_EventInfo_jobOptions.py" ) -from CBNT_Athena.CBNT_AthenaConf import CBNTAA_Audit -CBNT_AthenaAware += CBNTAA_Audit() - -# activate RPC-specific ntuples - -if(extrnt): - include('RpcCalibAlgs/RpcExtrapolNtuple_jobOptions.py' ) - -if(resnt): - include('RpcCalibAlgs/RpcResidualsNtuple_jobOptions.py') - if recoalg=='Moore': - CBNT_AthenaAware.RpcResidualsNtuple.TrackCollection = "MooreTracks" -if(prdnt): - - CBNT_AthenaAware.RpcPrepRawDataNtuple.Hit=False - CBNT_AthenaAware.RpcPrepRawDataNtuple.Enable=True -else: - try: - CBNT_AthenaAware.RpcPrepRawDataNtuple.Enable=False - except AttributeError: - pass - - -#load muon rec tools -include ("MuonRecExample/MuonRecLoadTools.py") - - -# the main jobOpt -include("RecExCommission/RecExCommission.py") - -include ("RecExCommon/RecExCommon_topOptions.py") - - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple_fullStream.py b/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple_fullStream.py deleted file mode 100644 index 42c9ed92adc7161f74b95818e59f0d57a8dacd06..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibJobTransforms/share/skeleton.rpc_calib_ntuple_fullStream.py +++ /dev/null @@ -1,213 +0,0 @@ -# get the logger -from AthenaCommon.Logging import * -rpcCalibNtuplelog = logging.getLogger('rpcCalibNtuple') - -rpcCalibNtuplelog.info('************** STARTING RPC CalibNtuple **************') -#============================================================== -# Job definition parameters: -#============================================================== -EvtMax = runArgs.maxEvents -SkipEvents = runArgs.skipEvents -InputFiles = runArgs.inputBSFile -RunNumber = runArgs.runNumber -NtupleFile = runArgs.ntupleFile -FieldMask = runArgs.fieldMask -condTag = runArgs.conditionsTag -trignt = runArgs.trigNtuple -resnt = runArgs.resNtuple -prdnt = runArgs.prdNtuple -extrnt = runArgs.extrNtuple -recoalg = runArgs.recoAlg - -GeoVersion=runArgs.geometryVersion - -rpcCalibNtuplelog.info( '**** Transformation run arguments ****' ) -rpcCalibNtuplelog.info( str(runArgs) ) - -#============================================================== -# Job Configuration parameters: -#============================================================== -from MuonCalibJobTransforms.RPCCalibNtupleConfig import rpcCalibNtupleConfig -for cf in runArgs.jobConfig: - include(cf) -rpcCalibNtuplelog.info( '**** Transformation configuration arguments ****' ) -rpcCalibNtuplelog.info( str(rpcCalibNtupleConfig) ) - -rpcClusterTimeSpread=rpcCalibNtupleConfig.clusterTimeSpread - -from AthenaCommon.AlgSequence import AlgSequence -from AthenaCommon.AppMgr import ToolSvc,ServiceMgr -from AthenaCommon import CfgMgr - -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -from AthenaCommon.BeamFlags import jobproperties -from AthenaCommon.GlobalFlags import globalflags -from AthenaCommon.BFieldFlags import jobproperties -from AthenaCommon.AlgSequence import AlgSequence -from AthenaCommon.DetFlags import DetFlags - -from RecExConfig.RecFlags import rec as recFlags - -from MuonRecExample.MuonCBNTFlags import muonCBNT -from MuonRecExample.MuonRecFlags import muonRecFlags -from MuonCalibAlgs.MuonCalibFlags import muonCalibFlags - -from MuonRecExample import MuonRecStandaloneOnlySetup - -topSequence = AlgSequence() - - -##################### -## common/global config -##################### - -# For Trigger MBTS and L1 Calo we need the Tile Calorimeter -# the algorithm: MuonCalibExtraTreeTriggerAlg stores trigger info -DetFlags.makeRIO.Calo_setOn() -DetFlags.detdescr.LVL1_setOn() -DetFlags.readRDOBS.LVL1_setOn() - -# Max number of events to run, number of events to skip -athenaCommonFlags.EvtMax.set_Value_and_Lock(EvtMax) -athenaCommonFlags.SkipEvents.set_Value_and_Lock(SkipEvents) - -athenaCommonFlags.BSRDOInput.set_Value_and_Lock(InputFiles) - -globalflags.DataSource.set_Value_and_Lock('data') -jobproperties.Beam.beamType.set_Value_and_Lock("cosmics") -globalflags.InputFormat.set_Value_and_Lock('bytestream') -globalflags.DetDescrVersion.set_Value_and_Lock(GeoVersion) -globalflags.ConditionsTag.set_Value_and_Lock(condTag) - -# field -fieldFlag=[bool(int(FieldMask[0])),bool(int(FieldMask[1])),bool(int(FieldMask[2]))] - -jobproperties.BField.solenoidOn.set_Value_and_Lock(fieldFlag[0]) -jobproperties.BField.barrelToroidOn.set_Value_and_Lock(fieldFlag[1]) -jobproperties.BField.endcapToroidOn.set_Value_and_Lock(fieldFlag[2]) - -############################ -## muon specific -############################ - -# we want tracks, not just segments -muonRecFlags.doSegmentsOnly = False - -################################################################################ -# Set your user flags here -################################################################################ - -muonCBNT.doMdtRaw = False -muonCBNT.doRpcRaw = False -muonCBNT.doCscRaw = False -muonCBNT.doTgcRaw = False -muonCBNT.doMuonboy = False -muonCBNT.doMoore = False - -if(trignt or prdnt): - muonCBNT.doRpcRaw = True - -if recoalg=='Moore': - # Run Moore - muonRecFlags.doMoore = True -else: - muonRecFlags.doMoore = False - -if recoalg=='MuonBoy': - # Run Muonboy - muonRecFlags.doMuonboy = True -else: - muonRecFlags.doMuonboy = False - -# Run on CSC data or not -muonRecFlags.doCSCs=False - -# Switch on the alignment corrections -muonRecFlags.useAlignmentCorrections = True -muonRecFlags.doCalib = False - -recFlags.doTruth = False - -#rec.doCBNT = True -recFlags.doESD.set_Value_and_Lock( False ) -recFlags.doWriteESD.set_Value_and_Lock( False ) -recFlags.Commissioning = True - -from GeoModelSvc.GeoModelSvcConf import GeoModelSvc -GeoModelSvc = GeoModelSvc() -GeoModelSvc.MuonVersionOverride = "MuonSpectrometer-R.03.02.Initial.Light.BML.S13.Patch" - -# the following two lines are needed to remove annoying file ESD.pool.root -include("RecExCommission/RecExCommissionFlags_jobOptions.py") -ATLASCosmicFlags.doFilteredESD=False - -recFlags.lock_JobProperties() -muonRecFlags.lock_JobProperties() - - -# The main jobOption file -include("RecExCommission/RecExCommission.py") -include ("RecExCommon/RecExCommon_topOptions.py") - -# Tune RPC clusterization - -CfgMgr.RpcClusterBuilderPRD.ClusterTimeSpread = 10000 -CfgMgr.RpcClusterBuilderPRD.OutputLevel = FATAL - -##-------------------------------------------------------------- -## Ntuple configuration -##-------------------------------------------------------------- -#theApp.HistogramPersistency = "ROOT" -# -THistSvc = CfgMgr.THistSvc() -ServiceMgr += THistSvc -outputString="AANT DATAFILE=\'"+NtupleFile+"\' OPT=\'RECREATE\'" -THistSvc.Output = [outputString] - -try: - topSequence.AANTupleStream.OutputName=NtupleFile - -except AttributeError: - topSequence += CfgMgr.AANTupleStream(ExtraRefNames = [ "" ], - OutputName = NtupleFile, - ExistDataHeader = False ) - -# activate RPC-specific ntuples - -if(extrnt): - include('RpcCalibAlgs/RpcExtrapolNtuple_jobOptions.py' ) - -if(resnt): - include('RpcCalibAlgs/RpcResidualsNtuple_jobOptions.py') - if recoalg=='Moore': - CBNT_AthenaAware.RpcResidualsNtuple.TrackCollection = "MooreTracks" -if(prdnt): - - CBNT_AthenaAware.RpcPrepRawDataNtuple.Hit=False - CBNT_AthenaAware.RpcPrepRawDataNtuple.Enable=True -else: - try: - CBNT_AthenaAware.RpcPrepRawDataNtuple.Enable=False - except AttributeError: - pass - -if(trignt): - include('MuonCalibJobTransforms/rpc_trigNtuple.py') -else: - try: - CBNT_AthenaAware.RpcRawDataNtuple.Enable=False - except AttributeError: - pass - -#CBNT_AthenaAware.TgcRawDataNtuple.Enable=False -#CBNT_AthenaAware.RpcRawDataNtuple.Enable=False -#CBNT_AthenaAware.MdtRawDataNtuple.Enable=False -#CBNT_AthenaAware.MdtPrepRawDataNtuple.Enable=False -#CBNT_AthenaAware.RpcPrepRawDataNtuple.Enable=True -#CBNT_AthenaAware.RpcPrepRawDataNtuple.Hit=False -#CBNT_AthenaAware.CBNTAA_Muon.Enable=True -#CBNT_AthenaAware.MuonMakeTrackNtuple.Enable=False -#CBNT_AthenaAware.MuonMakeSegmentNtuple.Enable=False - -#if(resnt): -# topSequence.AANTupleStream.FilterAlgs+=['RpcResidualsNtuple/RpcResidualsNtuple'] diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CMakeLists.txt deleted file mode 100644 index 0f364468ef86a6970f2ca1af02506b32a0e8dc94..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -################################################################################ -# Package: CalibNtupleAnalysisAlg -################################################################################ - -# Declare the package name: -atlas_subdir( CalibNtupleAnalysisAlg ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - DataQuality/GoodRunsLists - DetectorDescription/GeoPrimitives - GaudiKernel - MagneticField/MagFieldElements - MagneticField/MagFieldConditions - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase - MuonSpectrometer/MuonIdHelpers - PRIVATE - Control/StoreGate - DetectorDescription/GeoModel/GeoModelInterfaces - Event/EventInfo - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibFitters - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibRt - MuonSpectrometer/MuonCalib/MuonCalibEventBase - MuonSpectrometer/MuonCalib/MuonCalibITools - MuonSpectrometer/MuonCalib/MuonCalibIdentifier - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleReader - MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry ) - -# External dependencies: -find_package( CLHEP ) -find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) -find_package( Eigen ) -find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) - -# Component(s) in the package: -atlas_add_library( CalibNtupleAnalysisAlgLib - src/*.cxx - PUBLIC_HEADERS CalibNtupleAnalysisAlg - INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps GeoPrimitives GaudiKernel MagFieldElements MagFieldConditions MdtCalibData GoodRunsListsLib MdtCalibIOSvcLib MuonCalibStandAloneBaseLib MuonIdHelpersLib StoreGateLib SGtests - PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} EventInfo MdtCalibFitters MdtCalibRt MuonCalibEventBase MuonCalibITools MuonCalibIdentifier CalibNtupleReader MuonReadoutGeometry ) - -atlas_add_component( CalibNtupleAnalysisAlg - src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps GoodRunsListsLib GeoPrimitives GaudiKernel MagFieldElements MagFieldConditions MdtCalibData MdtCalibIOSvcLib MuonCalibStandAloneBaseLib MuonIdHelpersLib StoreGateLib SGtests EventInfo MdtCalibFitters MdtCalibRt MuonCalibEventBase MuonCalibITools MuonCalibIdentifier CalibNtupleReader MuonReadoutGeometry CalibNtupleAnalysisAlgLib ) - -atlas_add_dictionary( CalibNtupleAnalysisAlgDict - CalibNtupleAnalysisAlg/GeoDraw.h - CalibNtupleAnalysisAlg/selection.xml - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps GoodRunsListsLib GeoPrimitives GaudiKernel MagFieldElements MagFieldConditions MdtCalibData MdtCalibIOSvcLib MuonCalibStandAloneBaseLib MuonIdHelpersLib StoreGateLib SGtests EventInfo MdtCalibFitters MdtCalibRt MuonCalibEventBase MuonCalibITools MuonCalibIdentifier CalibNtupleReader MuonReadoutGeometry CalibNtupleAnalysisAlgLib ) - -# Install files from the package: -atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) -atlas_install_joboptions( share/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} --extend-ignore=F401,F821 ) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/ApplyRawTimes.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/ApplyRawTimes.h deleted file mode 100644 index c44bae8dac0b3d1abde4a86c9e32d694c22ff722..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/ApplyRawTimes.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_ApplyRawTimes_H -#define MuonCalib_ApplyRawTimes_H - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -class RegionSelectionSvc; - -namespace MuonCalib { -class IIdToFixedIdTool; - -class ApplyRawTimes : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - ApplyRawTimes(const std::string &t, const std::string &n, const IInterface *p); - inline ~ApplyRawTimes()=default; -//=========================public member functions============================== - StatusCode initialize(void); - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //! pointer to regino selectin service - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - -}; - -}//namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/BFieldCorrectionUpdateTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/BFieldCorrectionUpdateTool.h deleted file mode 100644 index b9b7242debb5f6d5bf7c2129a9263dbf4827a625..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/BFieldCorrectionUpdateTool.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_BFieldCorrectionUpdateToolH -#define MuonCalib_BFieldCorrectionUpdateToolH - -//:::::::::::::::::::::::::::::::::::::: -//:: CLASS BFieldCorrectionUpdateTool :: -//:::::::::::::::::::::::::::::::::::::: - -/// \class BFieldCorrectionUpdateTool -/// -/// This class can be used to add the Lorentz angle effect to simulated drift -/// times for Monte-Carlo data without the Lorentz angle effect. The main -/// purpose of this class is to test the Lorentz angle correction in combination -/// with calibration algorithms. -/// -/// \author Oliver.Kortner@CERN.CH -/// -/// \date 02.02.2009 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - - -// MuonCalib // -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" -#include "MdtCalibData/BFieldCorFunc.h" -#include "AthenaBaseComps/AthAlgTool.h" - -namespace MuonCalib { - -class BFieldCorrectionUpdateTool : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: - // Constructor // - BFieldCorrectionUpdateTool(const std::string &t, const std::string &n, const IInterface *p); - ///< Constructor of the tool. - - ~BFieldCorrectionUpdateTool()=default; - ///< Destructor of the tool. - -// Methods // -// methods required by the base classes // - StatusCode initialize(void); - - void prepareSegments( - const MuonCalibEvent *& /*event*/, - std::map<NtupleStationId, MuonCalibSegment *> &segments); - ///< Method to add the Lorentz effect to the - ///< measured drift times. - - private: - std::string m_rt_file_name; // name of the r-t files to be used for the - // B field correction - IRtRelation *m_rt; // pointer to the reference r-t relationship at B=0 - BFieldCorFunc *m_corr_func; // pointer to the B field correction function - - bool initialize_BFieldCorFunc(void); // method to initialize the Lorentz angle correction - -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/BarrelSecondCoordinatePreparationTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/BarrelSecondCoordinatePreparationTool.h deleted file mode 100644 index 8c7d1564b58a77f67dc94240ea0e0a686737400f..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/BarrelSecondCoordinatePreparationTool.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_BarrelSecondCoordinatePreparationToolH -#define MuonCalib_BarrelSecondCoordinatePreparationToolH - -//::::::::::::::::::::::::::::::::::::::::::::::::: -//:: CLASS BarrelSecondCoordinatePreparationTool :: -//::::::::::::::::::::::::::::::::::::::::::::::::: - -/// \class BarrelSecondCoordinatePreparationTool -/// -/// This class can be used to recalculate the second coordinates of MDT hits -/// using raw RPC hits. It is limited to the application to barrel MDT chambers. -/// -/// \author Oliver.Kortner@CERN.CH -/// -/// \date 23.01.2009 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// MuonCalib // -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -// AtlasCore // -// AtlasConditions // - -//CLHEP -#include "CLHEP/Matrix/Matrix.h" -#include "CLHEP/Matrix/Vector.h" - -namespace MuonCalib { - -class IIdToFixedIdTool; -class MuonCalibRawRpcHit; -class BarrelSecondCoordinatePreparationTool : public AthAlgTool, virtual public CalibSegmentPreparationTool { - - public: -// Constructor // - BarrelSecondCoordinatePreparationTool(const std::string &t, - const std::string &n, const IInterface *p); - -// Destructor // - ~BarrelSecondCoordinatePreparationTool()=default; - -// Methods // -// methods required by the base classes // - StatusCode initialize(void); - ///< initialization of the tools - StatusCode finalize(void); - ///< finalization of the tool - void prepareSegments( const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - ///< Method to calculate the second coordinate of - ///< MDT hits in the barrel based on RPC hits. - ///< \param event Current event (contains raw hits - ///< and other useful objects). - ///> \param segments Vector of segments to be - ///> prepared. - - bool handleRPChits(MuonCalibSegment &MDT_segment, std::vector<MuonCalibRawRpcHit *> &raw_hits); - - int rpcFit(std::vector<CLHEP::HepVector> &RPC_hits, std::vector<int> in_sect, - std::vector<int> num_same, double max_r, CLHEP::HepVector &tr_par, double &angle_err); - - private: - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - const MuonCalib::IIdToFixedIdTool *m_id_tool; // identifier converter - - FILE* m_rpcHitsFile; //File to store RPC entries - bool m_write_rpc_hits; - -// RPCTrackAssociator m_RPC_track_associator; // tool for the determination of - // the second coordinates of MDT hits - -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg2.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg2.h deleted file mode 100644 index 02727eb795f5932878e8429e73f5e815b605c994..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg2.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _CALIBRATIONNTUPLEANALYSISALG2_H -#define _CALIBRATIONNTUPLEANALYSISALG2_H - -// c - c++ -#include "string" - -//athena -#include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ServiceHandle.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -// segment preparation tools - -class MdtCalibOutputDbSvc; -/** -@class CalibNtupleAnalysis -Port of the calibration_programme as an Athena Algorithm -Read calibration N-tuples and performs the calibration of the MDT chambers -*/ - -class MdtCalibInputSvc; -class RegionSelectionSvc; - -namespace MuonCalib { -class NtupleCalibrationTool; - -class CalibNtupleAnalysisAlg2 : public AthAlgorithm { -//=========================================== - public: -/** Algorithm Constructor */ - CalibNtupleAnalysisAlg2(const std::string &name, ISvcLocator *pSvcLocator); -/** Algorithm destrucrtor*/ - ~CalibNtupleAnalysisAlg2(); -/** Is called at the beginning of the analysis */ - StatusCode initialize(); -/** execute function NOTE: This will read all events at once*/ - StatusCode execute(); -/** finalize functions */ - StatusCode finalize(); -//============================================ - private: -//! segment preparation tools - ToolHandleArray<CalibSegmentPreparationTool> m_seg_prep_tool_handles; - ToolHandle<NtupleCalibrationTool> m_calib_tool_handle; -//! number of segments to process - int m_num_segments; -//!output db service - ServiceHandle<MdtCalibOutputDbSvc> m_dbservice; -//! calibration input service - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; -//! Calibration tool - NtupleCalibrationTool *p_calib_tool; -//! Crash job, if no segments are read - bool m_crash_if_no_segments; -//! stored segments - std::vector<MuonCalibSegment *> m_stored_segment; -//!internal event counter - int m_eventnumber; -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/CalibNtupleLoader.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/CalibNtupleLoader.h deleted file mode 100644 index 167300a84b7397845c57864bbe2cd954b87576f8..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/CalibNtupleLoader.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_CalibNtupleLoader_h -#define MuonCalib_CalibNtupleLoader_h - -//Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -//c - c++ -#include "string" - -class RegionSelectionSvc; -class IIncidentSvc ; -class TChain; - -namespace MuonCalib { - -class NTReader; - -//load events from CalibrationNtuple - -class CalibNtupleLoader: public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - CalibNtupleLoader(const std::string &t, const std::string &n, const IInterface *p); - ~CalibNtupleLoader()=default; -//=========================public member functions============================== - StatusCode initialize(void); - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //!path to the file list - job option - std::string m_filelist; - //! type of ntuple - AUTO/NORMAL/REGION - - //! NOTE: Do not use auto if you are directly reading ntuples from - //! castor or dcache. In this case all files have to be opened at initialisation. - std::string m_ntuple_type; - int m_ntuple_type_num; - //! skip double events (event numbers) - job options - bool m_skip_double_events; - //!prev event number - int m_prev_event_nr; - //! prev run number - unsigned int m_prev_run_nr ; - - //! first event - jobOption - int m_first; - //! last event - jobOption - int m_last; - //! ntuple reader - NTReader *m_reader; - //! pointer to region selection service - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - //! ntuple chain - TChain *m_chain; - - //! pointer to IncidentSvc to fire Incidents for IOV changes - ServiceHandle<IIncidentSvc> m_incSvc ; - inline StatusCode read_dictionary(std::istream &fl, int &tot_count); - -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/GeoDraw.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/GeoDraw.h deleted file mode 100644 index 414271f407065073f348d92485825bfc483b3eaf..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/GeoDraw.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib__GeoDraw_h -#define MuonCalib__GeoDraw_h - -#include "map" - -namespace MuonCalib { - -class GeoDraw_Data; - -class GeoDraw { - public: - static void Load(const char *filename); - - static double PosX(unsigned int tube_id); - static double PosY(unsigned int tube_id); - static double PosZ(unsigned int tube_id); - - static double GPosX(unsigned int tube_id); - static double GPosY(unsigned int tube_id); - static double GPosZ(unsigned int tube_id); - - static double LocalToGlobalX(unsigned int id, double x, double y, double z); - static double LocalToGlobalY(unsigned int id, double x, double y, double z); - static double LocalToGlobalZ(unsigned int id, double x, double y, double z); - - static double GlobalToLocalX(unsigned int id, double x, double y, double z); - static double GlobalToLocalY(unsigned int id, double x, double y, double z); - static double GlobalToLocalZ(unsigned int id, double x, double y, double z); - - private: - static GeoDraw_Data *s_data; -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/GoodRunListFilter.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/GoodRunListFilter.h deleted file mode 100644 index 78686c6c332db7a62ed7c000079b322d3cda730e..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/GoodRunListFilter.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib__GoodRunListFilter_h -#define MuonCalib__GoodRunListFilter_h - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/ToolHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -//GoodRunsLists -#include "GoodRunsLists/IGoodRunsListSelectorTool.h" - -namespace MuonCalib { - -class GoodRunListFilter: public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - GoodRunListFilter(const std::string &t, const std::string &n, const IInterface *p); - ~GoodRunListFilter()=default; -//=========================public member functions============================== - StatusCode initialize(void); - //load event - void prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: - ToolHandle<IGoodRunsListSelectorTool> m_good_runlist_tool; - }; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/InitialDqFilter.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/InitialDqFilter.h deleted file mode 100644 index 0c1a5cbb0e69536b5dac5c0ba8d31635c667f5a0..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/InitialDqFilter.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib__InitialDqFilter_h -#define MuonCalib__InitialDqFilter_h - -//Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -//c- c++ -#include "set" - -class RegionSelectionSvc; - -namespace MuonCalib { - -class InitialDqFilter: public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - InitialDqFilter(const std::string &t, const std::string &n, const IInterface *p); - ~InitialDqFilter()=default; -//=========================public member functions============================== - StatusCode initialize(void); - //load event - void prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //location of initial dq file - jo - std::string m_initial_dq_path; - //list of suppressed tubes - std::set<MuonFixedId> m_suppressed_tubes; - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - }; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h deleted file mode 100644 index 6f45e6933f842ab725ecffac48a70c93e7baf702..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalibGeometryDumper_h -#define MuonCalibGeometryDumper_h - -//athena -#include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ServiceHandle.h" - - -namespace coral { - class IRelationalDomain; - class AttributeList; - class IConnection; - class ISession; - class Context; - class ITableDataEditor; -} - -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -namespace MuonGM { - class MuonDetectorManager; - class MdtReadoutElement; -} - -class TFile; -class TTree; -#include "CLHEP/Geometry/Transform3D.h" -namespace ROOT { - namespace Math{ - class Transform3D; - } -} - -namespace MuonCalib { - -class IIdToFixedIdTool; -class MdtTubeGeomertyRow; -class MdtChamberGeometryRow; - -class MuonCalibGeometryDumper : public AthAlgorithm { - public: -//=============================constructor - destructor========================= - /** Algorithm Constructor */ - MuonCalibGeometryDumper(const std::string& name, ISvcLocator *pSvcLocator); - /** Algorithm destrucrtor*/ - ~MuonCalibGeometryDumper()=default; -//=============================public members=================================== - /** Is called at the beginning of the analysis */ - StatusCode initialize(); - /** execute function NOTE: This will read all events at once*/ - inline StatusCode execute() { - return StatusCode::SUCCESS; - } -//============================private members=================================== - private: - void loadServices(); - std::string m_rootFile; - std::string m_idToFixedIdToolType; // type of the muon fixed id tool - std::string m_idToFixedIdToolName; // name of the muon fixed id tool - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - const MuonGM::MuonDetectorManager *m_detMgr; // pointer to the muon detector manager - const IIdToFixedIdTool *m_id_tool; // identifier converter - inline bool dump_mdt_geometry(); - inline void fillLayer(const Identifier &ch_id, const MuonGM::MdtReadoutElement *detEl, MdtTubeGeomertyRow &row, TTree *tree, const int &ml, const int &ly); - inline void init_root_transform(ROOT::Math::Transform3D &local_to_global, const HepGeom::Transform3D &hep_transform); -}; - -}//namespace MuonCalib -#endif //code guard diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRawdataSelector.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRawdataSelector.h deleted file mode 100644 index 9c2d8f652a5b02c7a10b5342a83d11d97f90ebf7..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRawdataSelector.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_SegmentRawdataSelector_h -#define MuonCalib_SegmentRawdataSelector_h - -//Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -#include "set" - -#include "GeoPrimitives/GeoPrimitives.h" - -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -class RegionSelectionSvc; - -namespace MuonCalib { -class IIdToFixedIdTool; -class MuonCalibRawMdtHit; -class MuonCalibRawHitCollection; - -class SegmentRawdataSelector : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - SegmentRawdataSelector(const std::string &t, const std::string &n, const IInterface *p); - inline ~SegmentRawdataSelector()=default; -//=========================public member functions============================== - StatusCode initialize(); - - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //minimum and maximum number of segment hits - int m_min_hits, m_max_hits; - //adc cut on raw hits - int m_adc_cut; - //! pointer to region selection service - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - // helpers // - std::string m_idToFixedIdToolType; // type of the muon fixed id tool - std::string m_idToFixedIdToolName; // name of the muon fixed id tool - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - const MuonCalib::IIdToFixedIdTool *m_id_tool;// identifier converter - //store segments, because we have to delete them - std::set<MuonCalibSegment *> m_segments; -/** get a the position of the raw hit - search for matching rpc-hits in order to get the x coordinate */ - inline const Amg::Vector3D get_raw_position(const MuonCalibRawMdtHit *hit, const MuonCalibRawHitCollection *coll, const Amg::Transform3D &local_to_global) const; - -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRecalibration.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRecalibration.h deleted file mode 100644 index 72a2ecc4bcdfda4e4b33566c26491a09c5cce7fc..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRecalibration.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_SegmentRecalibration_h -#define MuonCalib_SegmentRecalibration_h - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -class MdtCalibInputSvc; -namespace MuonCalib { -class IMdtSlewCorFunc; - -class SegmentRecalibration : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - SegmentRecalibration(const std::string &t, const std::string &n, const IInterface *p); - ~SegmentRecalibration()=default; -//=========================public member functions============================== - StatusCode initialize(void); - //load event - void prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //! switches for tube by tube correction - //! LEAVE: Take it as it is in calibraition file - //! UNAPPLY: Add correction which is stored in the ntuple - //! FILE: Read correction from file or recalculate - this entails UNAPPLY - std::string m_t0_switch; - std::string m_B_corr_switch; - std::string m_time_slwing_corr_switch; - std::string m_rt_scaling_switch; - //! numeric values for the switches - //! 0=LEAVE - //! 1=UNAPPLY - //! 2=FILE - int m_t0_numswitch, m_B_corr_numswitch, m_time_slwing_numswitch, m_rt_scaling_numswitch; - //! switches for recalculation of r and dr OFF|ON - bool m_recalc_r_switch; - //! replace drift radius by true radius (mc only) - jo - bool m_use_true_r; - //! undo segmentwise fitted t0 - //! <0: Automatic - //! 0: Don't - //! 1: Do - int m_undo_refitted_t0; - float m_prop_factor; - //! calibration input service - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; - IMdtSlewCorFunc *p_ts_corr_func; - //convert text switches to numerical values - inline bool convert_switch(const std::string &s_switch, int &num_switch, const char *switchname) const; -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRefitter.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRefitter.h deleted file mode 100644 index bb53fb2e9367f741987c86f6bee8ac855fa98205..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRefitter.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_SegmentRefitter_h -#define MuonCalib_SegmentRefitter_h - -//Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -class MdtCalibInputSvc; - -namespace MuonCalib { - -class IMdtPatRecFitter; -class T0Refinement; - -class SegmentRefitter : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - SegmentRefitter(const std::string &t, const std::string &n, const IInterface *p); - ~SegmentRefitter()=default; -//=========================public member functions============================== - StatusCode initialize(void); - //load event - void prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //! if set to true, curved segments are fitted - jo - bool m_curved; - //! if set to true fitting with t0-refinement is activated - jo - bool m_t0_refine; - //! if set to true,the hit selection will be refined. - bool m_refine_hit_selection; - //! road width for segment fitting - jo - double m_road_width; - //! abort fitting if it takes longer that m_time_out seconds - double m_time_out; - //! minimum and maximum number of hits after the segment refit - int m_min_hits, m_max_hits; - //! fitter class (no t0 refinement) - IMdtPatRecFitter *p_qfitter; - //! t0 refinement - T0Refinement *p_t0_refinement; - //! calibration input service - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; - //refine t0 - inline bool refine_t0(MuonCalibSegment *&segment); - -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRegionSelector.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRegionSelector.h deleted file mode 100644 index b44ae94948548f81cf605394a3b6df4855984312..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRegionSelector.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_SegmentRegionSelector_h -#define MuonCalib_SegmentRegionSelector_h - -//Gaudi -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -class RegionSelectionSvc; - -namespace MuonCalib { - -class SegmentRegionSelector : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - SegmentRegionSelector(const std::string &t, const std::string &n, const IInterface *p); - ~SegmentRegionSelector()=default; -//=========================public member functions============================== - StatusCode initialize(void); - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //if set to true, segments which are not completely in the selected calibration region will be dropped - job options - bool m_exclusive_segments; - //minimum and maximum number of segment hits - int m_min_hits, m_max_hits; - //select segment author - int m_select_seg_author; - //adc cut - int m_adc_cut; - //! pointer to region selection service - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - - }; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/UpdateBField.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/UpdateBField.h deleted file mode 100644 index 83bd001e61c9f3bcca3fe99b5e8783b82d5f42bb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/UpdateBField.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_UpdateBField_h -#define MuonCalib_UpdateBField_h - -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "StoreGate/ReadCondHandleKey.h" -#include "MagFieldConditions/AtlasFieldCacheCondObj.h" - -namespace MuonCalib { - - class UpdateBField: public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//===========================constructor - destructor=========================== - UpdateBField(const std::string &t, const std::string &n, const IInterface *p); - ~UpdateBField()=default; -//===========================public member functions============================ - StatusCode initialize(); - void prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: - SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj"}; - }; //class - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/WriteMdtGeometry.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/WriteMdtGeometry.h deleted file mode 100644 index 82ee8cc66452d4751489905d8e776b7a6945783f..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/WriteMdtGeometry.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef WriteMdtGeometry_h -#define WriteMdtGeometry_h - -//athena -#include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ServiceHandle.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" - -namespace coral { - class IRelationalDomain; - class AttributeList; - class ISessionProxy; - class Context; - class ITableDataEditor; -} - -namespace MuonGM { - class MuonDetectorManager; - class MdtReadoutElement; -} - -namespace MuonCalib { - -class IIdToFixedIdTool; - -class WriteMdtGeometry : public AthAlgorithm { - public: -//=============================constructor - destructor========================= - /** Algorithm Constructor */ - WriteMdtGeometry(const std::string &name, ISvcLocator *pSvcLocator); - /** Algorithm destrucrtor*/ - ~WriteMdtGeometry()=default; -//=============================public members=================================== - /** Is called at the beginning of the analysis */ - StatusCode initialize(); - /** execute function NOTE: This will read all events at once*/ - inline StatusCode execute() { - return StatusCode::SUCCESS; - } -//============================private members=================================== - private: - coral::Context *m_context; - coral::IRelationalDomain& domain( const std::string &connectionString ); - void loadServices(); - - std::string m_connectionString; - std::string m_WorkingSchema; - std::string m_username, m_password; - std::string m_idToFixedIdToolType; // type of the muon fixed id tool - std::string m_idToFixedIdToolName; // name of the muon fixed id tool - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - coral::ISessionProxy *m_session; - const MuonGM::MuonDetectorManager *m_detMgr; // pointer to the muon - const IIdToFixedIdTool *m_id_tool; // identifier converter - - inline bool fill_db(coral::ITableDataEditor& editor); - inline void fillLayer(const MuonGM::MdtReadoutElement *detEl, coral::AttributeList &rowBuffer, const int &ml, const int &ly); - - void OpenConnection(); - void CloseConnection(bool commit); -}; - -}//namespace MuonCalib -#endif //code guard diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/selection.xml b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/selection.xml deleted file mode 100644 index dc4948517a56ee0b3d4c4ff53dd9aac9c5efb62a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/selection.xml +++ /dev/null @@ -1,5 +0,0 @@ -<lcgdict> - - <class name="MuonCalib::GeoDraw" /> - -</lcgdict> diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/python/CalibNtupleAnalysisConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/python/CalibNtupleAnalysisConfig.py deleted file mode 100644 index dc3c551565c35911b70360ec8c98083a29a93adf..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/python/CalibNtupleAnalysisConfig.py +++ /dev/null @@ -1,398 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from __future__ import print_function - -from CalibNtupleAnalysisAlg.CalibNtupleAnalysisAlgConf import (MuonCalib__ApplyRawTimes, - MuonCalib__CalibNtupleAnalysisAlg2, - MuonCalib__CalibNtupleLoader, - MuonCalib__UpdateBField, - MuonCalib__GoodRunListFilter, - MuonCalib__InitialDqFilter, - MuonCalib__BarrelSecondCoordinatePreparationTool, - MuonCalib__SegmentRawdataSelector, - MuonCalib__SegmentRefitter, - MuonCalib__SegmentRecalibration, - MuonCalib__SegmentRegionSelector) - -from MuonCalibStandAloneBase.MuonCalibStandAloneBaseConf import MuonCalib__CalibrationTeeIOTool, RegionSelectionSvc -from MdtCalibIOSvc.MdtCalibIOSvcConf import MdtCalibOutputDbSvc, MdtCalibInputSvc, MuonCalib__CalibrationFileIOTool -from MuonCalibDbOperations.MuonCalibDbOperationsConf import MuonCalib__CalibrationDbIOTool -from AthenaCommon.AppMgr import ServiceMgr, ToolSvc -from AthenaCommon.AlgSequence import AlgSequence -from CalibNtupleAnalysisAlg.CalibNtupleMetaData import CalibNtupleMetaData -import MuonCalibStandAloneTools.MuonCalibStandAloneToolsConfig as calibtools - -import sys - -class CalibNtupleAnalysisConfig: - -#--------------------------------------user settings---------------------------- -#calibration algorithm to run: -#select calibration algoritm -# scan run for chambers RunScan -# t0-Fitters: ClassicT0, MTT0 -# create rt by integration Integration -# autocalibration ClassicAutocal, AnalyticAutocal, -# CurvedAutocal -# resolution SimpleResolution, Chi2Resolution -# efficiency Efficiency -# event display Display -# rpc timing RpcTiming -# control histograms ControlHistograms - - CalibrationAlgorithm = "RunScan" - -#file list - FileList="fl.txt" - -#create segments from the rawdata part - SegmentsFromRawdata=False - -#replace drift times by raw times in existing segments - ApplyRawTimes=False - -#update the magnetic field values in the segments - UpdateBField=False - RefitAfterBFieldUpdate=False - -#select segment author - 3=MuonBoy 4=Moore - Unused if SegmentsFromRawdata=True - SegmentAuthor=4 - -#first and last event to analyse - FirstEvent=0 - LastEvent=-1 - -#number of segments to collect - NumberOfSegments=-1 - -#maximum number of segments for certain algorithms (e.g. Autocalibration) - AutoLimitSegments = 20000 - -#calibration region - CalibrationRegion = "" - -#adc cut - ADCCut = 0 - -#minimum and maximum number of hits BEFORE refit - MinSegmentHits = 0 - MaxSegmentHits = -1 - -#perform a segment refit - not for algorithms likr MTT0, Integration, RunScan.. - SegmentRefit=False - -#segment refit parameters - RefineT0=False - CurvedSegments=False - RefitRoadWidth=2.0 - RefitTimeOut=2 - RefitMinSegmentHits=4 - RefitMaxSegmentHits=-1 - -#calibrate with b-field - BFieldCorrection=False - -#apply RPC Timing Correction - RPCTimingCorr=False - -#recalculate second coordinate - Recalc2ndCoordinate = False - -#select calibration input - CalibInputFromDB=False - CalibInputFromFile=True - -#select calibration output - CalibOutputToDB=False - CalibOutputToFile=True - -#output calibration directory - set None if you do not want to output to diredctory - CalibDir="calibration" - -#output to database - MP/RM/MI/NONE - CalibDB=None - -#initial data quality list - suppress Tubes - InitialDQList = None - -#if set to true no segment recalibraiton will be done, independent on the tool - SuppressRecalibration=False - -#use good run list to filter events - GoodRunList=None - -#apply time slewing corrections - ApplyTimeSlewingCorrections=False - -#apply multilayer rt-scaling - ApplyRtScaling=True - - sToolSvc= ToolSvc - sServiceMgr = ServiceMgr - - SegmentRecalibration={} - SegmentRefitter={} - - def AutoConfig(self): - self.metadata=CalibNtupleMetaData(self.FileList) - if 'GeoAtlas' in self.metadata.MetaData: - self.sServiceMgr.GeoModelSvc.AtlasVersion = self.metadata.MetaData['GeoAtlas'] - self._create_CalibNtupleAnalysisAlg() - #ntuple loader - self.CalibNtupleLoader = MuonCalib__CalibNtupleLoader() - self.sToolSvc += self.CalibNtupleLoader - self.CalibNtupleLoader.FileList = self.FileList - self.CalibNtupleLoader.FirstEvent = self.FirstEvent - self.CalibNtupleLoader.LastEvent = self.LastEvent - self.CalibNtupleLoader.NtupleType = "AUTO" - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.CalibNtupleLoader) - #region selection - self._region_selection() - #good run list selection - self._good_run_list_filter() - #raw times - if self.ApplyRawTimes: - self.RawTimesReplacement=MuonCalib__ApplyRawTimes() - self.sToolSvc += self.RawTimesReplacement - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append(self.RawTimesReplacement) - #initial DQ list - self._initial_DQ_list() - #apply RPC Timing Correction - if self.RPCTimingCorr: - from CalibNtupleAnalysisAlg.CalibNtupleAnalysisAlgConf import MuonCalib__RpcTimingCorr - self.RpcTiming=MuonCalib__RpcTimingCorr() - self.sToolSvc += self.RpcTiming - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append(self.RpcTiming) - #recalculate 2nd coordinate: - self._second_coordinate() - #segment recalibration - if not self.SuppressRecalibration: - self._configure_segment_recalibration("SegmentRecalibration") - #segment refitter - if self.SegmentRefit: - self._config_segment_refitter() - #B field updater - if self.UpdateBField: - self._config_UpdateBField() - self._configure_segment_recalibration("SegmentRecalibration2") - if self.SegmentRefit and self.RefitAfterBFieldUpdate: - self._config_segment_refitter("SegmentRefitter2") - #calibration IO - self._config_calibIO() - #create tool - self._create_calib_tool() - -#-----------------------protected functions------------------------------------ - def _create_CalibNtupleAnalysisAlg(self): - topSequence = AlgSequence() - self.CalibNtupleAnalysisAlg = MuonCalib__CalibNtupleAnalysisAlg2() - self.CalibNtupleAnalysisAlg.NumberOfSegments = self.NumberOfSegments - if self.CalibrationAlgorithm in calibtools.LimitSegmentsFor: - self.CalibNtupleAnalysisAlg.NumberOfSegments = self.AutoLimitSegments - topSequence += self.CalibNtupleAnalysisAlg - - def _good_run_list_filter(self): - if not self.GoodRunList: - return - from GoodRunsLists.GoodRunsListsConf import GoodRunsListSelectorTool - self.__good_run_list_tool=GoodRunsListSelectorTool() - self.sToolSvc += self.__good_run_list_tool - self.__good_run_list_tool.GoodRunsListVec = [self.GoodRunList] - self.__good_run_list_filter=MuonCalib__GoodRunListFilter() - self.__good_run_list_filter.GoodRunListTool = self.__good_run_list_tool - self.sToolSvc +=self.__good_run_list_filter - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.__good_run_list_filter ) -# self.__good_run_list_tool.EventSelectorMode = True - self.__good_run_list_tool.PassThrough = False - - def _initial_DQ_list(self): - if self.InitialDQList: - if self.InitialDQList.upper()=="NONE": - return - self.InitialDqFilter = MuonCalib__InitialDqFilter() - self.InitialDqFilter.InitialDqFile = self.InitialDQList - self.sToolSvc += self.InitialDqFilter - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.InitialDqFilter) - - def _region_selection(self): - if self.SegmentsFromRawdata: - self.RegionSelection = MuonCalib__SegmentRawdataSelector() - else: - self.RegionSelection = MuonCalib__SegmentRegionSelector() - self.RegionSelection.SelectSegmentAuthor = self.SegmentAuthor - self.sToolSvc += self.RegionSelection - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.RegionSelection ) - self.RegionSelectionSvc = RegionSelectionSvc() - self.RegionSelectionSvc.Region = self.CalibrationRegion - self.RegionSelectionSvc.PrintList = True - self.RegionSelection.AdcCut = self.ADCCut - self.RegionSelection.MinHits = self.MinSegmentHits - self.RegionSelection.MaxHits = self.MaxSegmentHits - self.sServiceMgr += self.RegionSelectionSvc - - def _second_coordinate(self): - if self.Recalc2ndCoordinate: - self.BarrelSecondCoordinatePreparationTool = MuonCalib__BarrelSecondCoordinatePreparationTool() - self.sToolSvc += self.BarrelSecondCoordinatePreparationTool - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.BarrelSecondCoordinatePreparationTool) - - def _configure_segment_recalibration(self, ToolName=""): - #tools that do not need segment recalibration - if self.CalibrationAlgorithm in calibtools.NoRecalibration: - return - if ToolName: - self.SegmentRecalibration[ToolName] = MuonCalib__SegmentRecalibration(ToolName) - else: - ToolName = "default" - self.SegmentRecalibration[ToolName] = MuonCalib__SegmentRecalibration() - self.sToolSvc += self.SegmentRecalibration[ToolName] - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.SegmentRecalibration[ToolName] ) - if self.ApplyTimeSlewingCorrections: - self.SegmentRecalibration[ToolName].TimeSlewingSwitch='FILE' - else: - self.SegmentRecalibration[ToolName].TimeSlewingSwitch='UNAPPLY' - #tools that revert all calibrations - if self.CalibrationAlgorithm in calibtools.RevertT0: - self.SegmentRecalibration[ToolName].T0Switch = "UNAPPLY" - self.SegmentRecalibration[ToolName].BSwitch = "LEAVE" - self.SegmentRecalibration[ToolName].RecalcR = False - if self.CalibrationAlgorithm in calibtools.RecalibT0 : - self.SegmentRecalibration[ToolName].T0Switch = "FILE" - self.SegmentRecalibration[ToolName].BSwitch = "LEAVE" - self.SegmentRecalibration[ToolName].RecalcR = False - if self.CalibrationAlgorithm in calibtools.RecalibAll: - self.SegmentRecalibration[ToolName].T0Switch = "FILE" - self.SegmentRecalibration[ToolName].BSwitch = "LEAVE" - self.SegmentRecalibration[ToolName].RecalcR = True - #id b-field should be corrected, set BSwitch either to "UNAPPLY" or to "FILE" - if self.CalibrationAlgorithm in calibtools.RevertRtScaling: - self.SegmentRecalibration[ToolName].RtMultilayerScaling = "UNAPPLY" - if self.CalibrationAlgorithm in calibtools.ApplRtScaling and self.ApplyRtScaling: - self.SegmentRecalibration[ToolName].RtMultilayerScaling = "FILE" - if self.BFieldCorrection: - if self.SegmentRecalibration[ToolName].RecalcR: - self.SegmentRecalibration[ToolName].BSwitch = "FILE" -# else: -# self.SegmentRecalibration[ToolName].BSwitch = "UNAPPLY" - - def _config_UpdateBField(self): - if self.UpdateBField in calibtools.NoSegmentRefit: - self.UpdateBField = None - return - self.UpdateBField = MuonCalib__UpdateBField() - self.sToolSvc += self.UpdateBField - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.UpdateBField ) - - def _config_segment_refitter(self, ToolName=""): - if self.CalibrationAlgorithm in calibtools.NoSegmentRefit: - return - if ToolName: - self.SegmentRefitter[ToolName] = MuonCalib__SegmentRefitter(ToolName) - else: - ToolName = "default" - self.SegmentRefitter[ToolName] = MuonCalib__SegmentRefitter(ToolName) - self.sToolSvc += self.SegmentRefitter[ToolName] - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.SegmentRefitter[ToolName] ) - self.SegmentRefitter[ToolName].Curved = self.CurvedSegments - self.SegmentRefitter[ToolName].RefineT0 = self.RefineT0 - self.SegmentRefitter[ToolName].RoadWidth = self.RefitRoadWidth - self.SegmentRefitter[ToolName].TimeOut = self.RefitTimeOut - self.SegmentRefitter[ToolName].MinSegmentHits = self.RefitMinSegmentHits - self.SegmentRefitter[ToolName].MaxSegmentHits = self.RefitMaxSegmentHits - - def _config_calibIO(self): - if self.CalibDir: - self.CalibrationFileIOTool = MuonCalib__CalibrationFileIOTool() - self.sToolSvc += self.CalibrationFileIOTool - self.CalibrationFileIOTool.outputLocation = self.CalibDir - if self.CalibDB and not self.CalibDB.upper()=="NONE": - self.DbIoTool = MuonCalib__CalibrationDbIOTool() - self.sToolSvc += MuonCalib__CalibrationDbIOTool() - if not self.__set_db(): - print ("Unknown database location " + str(self.CalibOutputDB)) - sys.exit(1) - - self.MdtCalibOutputDbSvc = MdtCalibOutputDbSvc() - self.MdtCalibOutputDbSvc.PostprocessCalibration = True - self.sServiceMgr += self.MdtCalibOutputDbSvc - if self.CalibOutputToDB and self.CalibOutputToFile: - self.TeeIoTool=MuonCalib__CalibrationTeeIOTool() - self.sToolSvc += self.TeeIoTool - self.TeeIoTool.IOTool2 = self.CalibrationFileIOTool - self.TeeIoTool.IOTool1 = self.DbIoTool - self.MdtCalibOutputDbSvc.OutputTool=self.TeeIoTool - elif self.CalibOutputToFile: - self.MdtCalibOutputDbSvc.OutputTool = self.CalibrationFileIOTool - elif self.CalibOutputToDB: - self.CalibOutputDB = self.DbIoTool - self.MdtCalibOutputDbSvc.OutputTool=self.DbIoTool - #input - self.MdtCalibInputSvc = MdtCalibInputSvc() - self.sServiceMgr += self.MdtCalibInputSvc - if self.CalibInputFromDB: - if not self.DbIoTool: - print ("Set calibratino database location!") - sys.exit(1) - self.MdtCalibInputSvc.CalibrationInputTool = self.DbIoTool - if self.CalibInputFromFile: - if not self.CalibrationFileIOTool: - print ("give a calibdir!") - sys.exit(1) - self.MdtCalibInputSvc.CalibrationInputTool = self.CalibrationFileIOTool - - def _create_calib_tool(self): - self.CalibrationTool=calibtools.CreateCalibTool(self.CalibrationAlgorithm) - if self.CalibrationTool: - self.sToolSvc += self.CalibrationTool - self.CalibNtupleAnalysisAlg.CalibrationTool = self.CalibrationTool - -#------------------------------------------------------------ - def __set_db(self): - self.DbIoTool.SiteName = self.CalibDB - self.DbIoTool.UseValidaedT0 = self.CalibrationAlgorithm in calibtools.ValidatedT0 - self.DbIoTool.UseValidaedRt = self.CalibrationAlgorithm in calibtools.ValidatedRt - if (self.CalibDB == "MP"): - self.DbIoTool.ConnectionString = "oracle://oracle01.mppmu.mpg.de/ATLMPI.mppmu.mpg.de/ATLAS_MUONCALIB_MPI" - self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_MPI" - elif (self.CalibDB == "MP_NEW"): - # MPI - self.DbIoTool.ConnectionString = "oracle://oracle01.mppmu.mpg.de/ATLMPI.mppmu.mpg.de/ATLAS_MUONCALIB_READER" - self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_MPI_META" - self.DbIoTool.WriterConnectionString = "oracle://oracle01.mppmu.mpg.de/ATLMPI.mppmu.mpg.de/ATLAS_MUONCALIB_WRITER" - elif (self.CalibDB == "MP_INTR"): - # MPI - self.DbIoTool.ConnectionString = "oracle://INTR/ATLAS_MUONCALIB_READER" - self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_MPI_META" - self.DbIoTool.WriterConnectionString = "oracle://INVALID/ATLAS_MUONCALIB_WRITER" - elif (self.CalibDB == "MI"): - # Michigan - self.DbIoTool.ConnectionString = "oracle://umors.grid.umich.edu/muoncal.grid.umich.edu/atlas_muoncalib_mich" - self.DbIoTool.WorkingSchema = "atlas_muoncalib_mich" - elif (self.CalibDB == "MI_NEW"): - # Michigan - self.DbIoTool.ConnectionString = "oracle://umors.grid.umich.edu/muoncal.grid.umich.edu/ATLAS_MUONCALIB_READER" - self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_UMICH" - self.DbIoTool.WriterConnectionString = "oracle://umors.grid.umich.edu/muoncal.grid.umich.edu/ATLAS_MUONCALIB_WRITER" - elif (self.CalibDB == "MI_INTR"): - # Michigan - self.DbIoTool.ConnectionString = "oracle://INTR/ATLAS_MUONCALIB_READER" - self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_UM_META" - self.DbIoTool.WriterConnectionString = "oracle://INVALID/ATLAS_MUONCALIB_WRITER" - elif (self.CalibDB == "RM_NEW"): - # ROMA - self.DbIoTool.ConnectionString = "oracle://atlas-cluster.cr.cnaf.infn.it:1521/atlcnafsrv.cr.cnaf.infn.it/ATLAS_MUONCALIB_READER" - self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_RM_META" - #self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_RM_2012" - self.DbIoTool.WriterConnectionString = "oracle://atlas-cluster.cr.cnaf.infn.it:1521/atlcnafsrv.cr.cnaf.infn.it/ATLAS_MUONCALIB_WRITER" - elif (self.CalibDB == "RM_INTR"): - # ROMA - self.DbIoTool.ConnectionString = "oracle://INTR/ATLAS_MUONCALIB_READER" - self.DbIoTool.WorkingSchema = "ATLAS_MUONCALIB_RM_META" - self.DbIoTool.WriterConnectionString = "oracle://INVALID/ATLAS_MUONCALIB_WRITER" - elif (self.CalibDB == "RM"): - # ROMA - self.DbIoTool.ConnectionString = "oracle://atlas-cluster.cr.cnaf.infn.it/atlcnaf.cr.cnaf.infn.it//atlas_muoncalib_rome" - self.DbIoTool.WorkingSchema = "atlas_muoncalib_rome" - else: - return False - return True diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/python/CalibNtupleMetaData.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/python/CalibNtupleMetaData.py deleted file mode 100644 index 7858f4574c955e605079c72510832e9810986ca6..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/python/CalibNtupleMetaData.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from __future__ import print_function - -from ROOT import TFile -import sys - -class CalibNtupleMetaData: - - def __init__(self, filelist): - self.MetaData={} - fl=open(filelist) - root_file=None - inf=None - for line in fl.readlines(): - items=line.replace('\n', '').split() - print (line.replace('\n', ''), items) - if len(items)==0 or items[0][0]=="#": - continue - if items[0]=="[": - if len(items)<2: - continue - root_file=items[1] - else: - root_file=items[0] - inf=TFile.Open(root_file) - if not inf: - sys.stderr.write("CalibNtupleMetaData WARNING: cannot open first file in filelist\n") - continue - - if not inf: - sys.stderr.write("CalibNtupleMetaData WARNING: find an input file in filelist\n") - return - - tree=inf.Get("meta_data") - if not tree: - sys.stderr.write("CalibNtupleMetaData WARNING: input file does not contain meta_data\n") - return - - i=0 - while tree.GetEntry(i): - i+=1 - self.MetaData[str(tree.key)] = str(tree.value) - print ("Found meta data:") - for k in self.MetaData: - print (k, self.MetaData[k]) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/share/dump_muon_geometry.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/share/dump_muon_geometry.py deleted file mode 100644 index 2474f83a3312f58e83829d342d56526f507647e1..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/share/dump_muon_geometry.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -### Setup Athena common flags -include ("AthenaCommon/AthenaCommonFlags.py") -include.block("AthenaCommon/AthenaCommonFlags.py") - -include( "IOVDbSvc/IOVRecExCommon.py" ) - -doMuonCalibAtlas=True - - -from AthenaCommon.AppMgr import ServiceMgr -#need to load atlas geometry for the efficiency determination -from AthenaCommon.GlobalFlags import GlobalFlags -GlobalFlags.DetGeo.set_atlas() -GlobalFlags.DataSource.set_data() -GlobalFlags.Print() -from AthenaCommon.DetFlags import DetFlags -DetFlags.detdescr.Muon_setOn() -DetFlags.detdescr.ID_setOff() -DetFlags.detdescr.LAr_setOff() -DetFlags.detdescr.Tile_setOff() -DetFlags.Print() - - -from CalibNtupleAnalysisAlg.CalibNtupleAnalysisAlgConf import MuonCalib__MuonCalibGeometryDumper - -MuonCalibGeometryDumper = MuonCalib__MuonCalibGeometryDumper() - -from AthenaCommon.AlgSequence import AlgSequence -topSequence = AlgSequence() -topSequence += MuonCalibGeometryDumper -#Set geometry tag -from AtlasGeoModel import SetGeometryVersion, GeoModelInit - -GeoModelSvc = ServiceMgr.GeoModelSvc -GeoModelSvc.AtlasVersion = "ATLAS-GEO-16-00-01" - - -MuonCalibGeometryDumper.RootFile = "geom.root" -theApp.EvtMax = 1 diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/share/write_geometry.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/share/write_geometry.py deleted file mode 100644 index e9e6b1304dc81672137be3dfe55f4beacffbe056..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/share/write_geometry.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -### Setup Athena common flags -include ("AthenaCommon/AthenaCommonFlags.py") -include.block("AthenaCommon/AthenaCommonFlags.py") - -include( "IOVDbSvc/IOVRecExCommon.py" ) - -doMuonCalibAtlas=True - - -from AthenaCommon.AppMgr import ServiceMgr -#need to load atlas geometry for the efficiency determination -from AthenaCommon.GlobalFlags import GlobalFlags -GlobalFlags.DetGeo.set_atlas() -GlobalFlags.DataSource.set_data() -GlobalFlags.Print() -from AthenaCommon.DetFlags import DetFlags -DetFlags.detdescr.Muon_setOn() -DetFlags.detdescr.ID_setOff() -DetFlags.detdescr.LAr_setOff() -DetFlags.detdescr.Tile_setOff() -DetFlags.Print() - - -from CalibNtupleAnalysisAlg.CalibNtupleAnalysisAlgConf import MuonCalib__WriteMdtGeometry - -WriteMdtGeometry = MuonCalib__WriteMdtGeometry() - -from AthenaCommon.AlgSequence import AlgSequence -topSequence = AlgSequence() -topSequence += WriteMdtGeometry -#Set geometry tag -from AtlasGeoModel import SetGeometryVersion, GeoModelInit - -GeoModelSvc = ServiceMgr.GeoModelSvc -GeoModelSvc.AtlasVersion = "ATLAS-GEO-16-00-01" - - -WriteMdtGeometry.ConnectionString = "sqlite_file:empty_geometry.db" -theApp.EvtMax = 1 diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/ApplyRawTimes.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/ApplyRawTimes.cxx deleted file mode 100644 index 1ecf2bd839cdb0e8eed74f590e5decbe41e3a2fe..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/ApplyRawTimes.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/ApplyRawTimes.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" - -//MuonCalibIdentifier -#include "MuonCalibIdentifier/MuonFixedId.h" - - -#include "map" -#include "set" - - -namespace MuonCalib { - -ApplyRawTimes::ApplyRawTimes(const std::string &t, const std::string &n, const IInterface *p) - : AthAlgTool(t, n, p), m_reg_sel_svc("RegionSelectionSvc", n) { - declareInterface< CalibSegmentPreparationTool >(this); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); -} - -StatusCode ApplyRawTimes::initialize(void) { - ATH_CHECK( m_reg_sel_svc.retrieve() ); - return StatusCode::SUCCESS; -} - -void ApplyRawTimes::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - std::map<MuonFixedId, std::set<int> > raw_times; - const MuonCalibRawHitCollection *raw_coll(event->rawHitCollection()); - for(MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it=raw_coll->rawMdtHitCollectionBegin(); it!=raw_coll->rawMdtHitCollectionEnd(); it++) { - if(m_reg_sel_svc->isInRegion((*it)->identify())) - raw_times[(*it)->identify()].insert((*it)->tdcCount()); - } - std::set<NtupleStationId> to_delete; - for(std::map<NtupleStationId, MuonCalibSegment *>::iterator it=segments.begin(); it!=segments.end(); it++) { - MuonCalibSegment::MdtHitCit h_it(it->second->mdtHOTBegin()); - for(; h_it!=it->second->mdtHOTEnd(); h_it++) { - if(raw_times.find((*h_it)->identify()) == raw_times.end()) { - ATH_MSG_WARNING( "No Raw time found for this hit!" ); - to_delete.insert(it->first); - break; - } - int tdc(*(raw_times[(*h_it)->identify()].begin())); - (*h_it)->setDriftTime((25.0/32.0) * tdc); - (*h_it)->setDriftRadius(0.0, 0.0); - (*h_it)->setDistanceToTrack(0.0, 0.0); - (*h_it)->setTimeFromTrackDistance(0.0, 0.0); - (*h_it)->setSlewingTime(0.0); - (*h_it)->setBFieldTime(0.0); - (*h_it)->setPropagationTime(0.0); - (*h_it)->setTimeOfFlight(0.0); - (*h_it)->setWiresagTime(0.0); - (*h_it)->setTemperatureTime(0.0); - (*h_it)->setBackgroundTime(0.0); - (*h_it)->setTubeT0(0.0); - (*h_it)->setTdc(tdc); - } - it->second->setFittedT0(0.0); - } - for(std::set<NtupleStationId>::iterator it=to_delete.begin(); it!=to_delete.end(); it++) { - segments.erase(segments.find(*it)); - } -} //end ApplyRawTimes::prepareSegments - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/BFielCorrectionUpdateTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/BFielCorrectionUpdateTool.cxx deleted file mode 100644 index d457919d2319972a501d451df095b9911afca0e3..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/BFielCorrectionUpdateTool.cxx +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include <iostream> -#include <fstream> - -#include "MdtCalibData/RtSpline.h" -#include "CalibNtupleAnalysisAlg/BFieldCorrectionUpdateTool.h" - -using namespace MuonCalib; - -//***************************************************************************** - -//::::::::::::::::: -//:: CONSTRUCTOR :: -//::::::::::::::::: -BFieldCorrectionUpdateTool::BFieldCorrectionUpdateTool( - const std::string &t, - const std::string &n, - const IInterface *p) : AthAlgTool(t, n, p) { - -///////////////// -// JOB OPTIONS // -///////////////// - m_rt_file_name = std::string("truth_rt.dat"); - declareProperty("rtFile", m_rt_file_name); - -/////////////////////// -// DECLARE INTERFACE // -/////////////////////// - declareInterface< CalibSegmentPreparationTool >(this); - -//////////////////// -// RESET POINTERS // -//////////////////// - m_rt = 0; -} - -//***************************************************************************** - -//::::::::::::::::::::::: -//:: METHOD initialize :: -//::::::::::::::::::::::: -StatusCode BFieldCorrectionUpdateTool::initialize(void) { - -///////////// -// OBJECTS // -///////////// - -///////////// -// MESSAGE // -///////////// - ATH_MSG_INFO( "Initializing tool..." ); - -///////////////////////////////////////////////////////////////// -// READ r-t RELATIONSHIP AND INITIALIZE THE B-FIELD CORRECTION // -///////////////////////////////////////////////////////////////// - if (!initialize_BFieldCorFunc()) { - ATH_MSG_FATAL( "Could not initialize the magnetic field correction!" ); - return StatusCode::FAILURE; - } - - return StatusCode::SUCCESS; -} //end BFieldCorrectionUpdateTool::initialize - -//***************************************************************************** - -//:::::::::::::::::::::::::::: -//:: METHOD prepareSegments :: -//:::::::::::::::::::::::::::: -void BFieldCorrectionUpdateTool::prepareSegments( - const MuonCalibEvent *& /*event*/, - std::map<NtupleStationId, MuonCalibSegment *> &segments) { - -////////////////////////////////////////////////////////////////////////////// -// LOOP OVER THE SEGMENTS AND THEIR HITS TO ADD THE LORENTZ ANGLE EFFECT TO // -// THE MEASURED DRIFT TIMES // -////////////////////////////////////////////////////////////////////////////// - for (std::map<NtupleStationId, MuonCalibSegment *> :: iterator it= - segments.begin(); it!= segments.end(); it++) { - - for (unsigned int k=0; k<it->second->mdtHOT().size(); k++) { - MdtCalibHitBase *hit = it->second->mdtHOT()[k]; - hit->setDriftTime(hit->driftTime() + - m_corr_func->correction_to_B(hit->driftTime(), hit->bFieldPara(), hit->bFieldPerp())); - } - - } - - return; -} //end BFieldCorrectionUpdateTool::prepareSegments - -//***************************************************************************** - -//::::::::::::::::::::::::::::::::::::: -//:: METHOD initialize_BFieldCorFunc :: -//::::::::::::::::::::::::::::::::::::: -bool BFieldCorrectionUpdateTool::initialize_BFieldCorFunc(void) { - -///////////// -// OBJECTS // -///////////// - std::ifstream rt_file; - char s[255]; // auxiliary character pointer - double dummy; // auxiliary double - std::vector<double> r,t; // entries in the r-t table - std::vector<double> B_corr_param(2); - -////////////////////////////////////////////// -// OPEN THE r-t FILE AND READ THE r-t TABLE // -////////////////////////////////////////////// - -// check that the file exists // - rt_file.open(m_rt_file_name.c_str()); - if (rt_file.fail()) { - ATH_MSG_FATAL( "Could not open file '" << m_rt_file_name << "'!" ); - return false; - } - -// read the file // - rt_file.getline(s, 255); - - while (!rt_file.eof()) { - rt_file >> dummy; - if (rt_file.eof()) { - break; - } - r.push_back(dummy); - rt_file >> dummy; t.push_back(dummy); - rt_file >> dummy; - } - -// create a spline r-t relationship // - std::vector<double> param(2*r.size()); - for (unsigned int k=0; k<r.size(); k++) { - param[2*k] = t[k]; - param[2*k+1] = r[k]; - } - - m_rt = new RtSpline(param); - -//////////////////////////////////////////// -// CREATE THE B FIELD CORRECTION FUNCTION // -//////////////////////////////////////////// - B_corr_param[0] = 3080.0; - B_corr_param[1] = 0.11; - - m_corr_func = new BFieldCorFunc("high", B_corr_param, m_rt); - - return true; -} //end BFieldCorrectionUpdateTool::initialize_BFieldCorFunc diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/BarrelSecondCoordinatePreparationTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/BarrelSecondCoordinatePreparationTool.cxx deleted file mode 100644 index c6880673600487433380cc7a6e0389404b489d4d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/BarrelSecondCoordinatePreparationTool.cxx +++ /dev/null @@ -1,421 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include <iostream> -#include <fstream> - -#include "CalibNtupleAnalysisAlg/BarrelSecondCoordinatePreparationTool.h" -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MuonCalibEventBase/MuonCalibRawRpcHit.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" - -using namespace MuonCalib; - -//***************************************************************************** - -//::::::::::::::::: -//:: CONSTRUCTOR :: -//::::::::::::::::: -BarrelSecondCoordinatePreparationTool::BarrelSecondCoordinatePreparationTool( - const std::string &t, - const std::string &n, - const IInterface *p) : AthAlgTool(t, n, p) { - -/////////////////////// -// DECLARE INTERFACE // -/////////////////////// - declareInterface< CalibSegmentPreparationTool >(this); -} - -//***************************************************************************** - -/////////////////////// -// METHOD initialize // -/////////////////////// -StatusCode BarrelSecondCoordinatePreparationTool::initialize(void) { - -///////////// -// OBJECTS // -///////////// - -///////////// -// MESSAGE // -///////////// - ATH_MSG_INFO( "Initializing tool..." ); - -//retrieve detector manager from the conditions store - ATH_CHECK(m_DetectorManagerKey.initialize()); - -// muon fixed id tool // - ATH_CHECK( toolSvc()->retrieveTool("MuonCalib::IdToFixedIdTool", - "MuonCalib_IdToFixedIdTool", m_id_tool) ); - - m_write_rpc_hits = false; - - if((m_rpcHitsFile=fopen("RpcHits.txt","w"))==NULL) { - ATH_MSG_INFO( "can't open file" ); - } - - return StatusCode::SUCCESS; -} //end BarrelSecondCoordinatePreparationTool - -//***************************************************************************** - -///////////////////// -// METHOD finalize // -///////////////////// -StatusCode BarrelSecondCoordinatePreparationTool::finalize(void) { - -///////////// -// OBJECTS // -///////////// - -///////////// -// MESSAGE // -///////////// - ATH_MSG_INFO( "Finalizing tool..." ); - fclose(m_rpcHitsFile); - - return StatusCode::SUCCESS; -} //end BarrelSecondCoordinatePreparationTool::finalize - -//***************************************************************************** - -//////////////////////////// -// METHOD prepareSegments // -//////////////////////////// -void BarrelSecondCoordinatePreparationTool::prepareSegments( - const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - -///////////// -// OBJECTS // -///////////// - std::vector<MuonCalibRawRpcHit*>::const_iterator raw_RPC_begin_it( - event->rawHitCollection()->rawRpcHitCollectionBegin()); - std::vector<MuonCalibRawRpcHit*>::const_iterator raw_RPC_end_it( - event->rawHitCollection()->rawRpcHitCollectionEnd()); - -/////////////////////////////////////////////////////////////////////////////// -// LOOP OVER THE SEGMENTS AND PASS THE BARREL SEGMENTS TO THE 2ND COORDINATE // -// RECONSTRUCTION TOOL // -/////////////////////////////////////////////////////////////////////////////// - std::set<NtupleStationId> to_delete; - for (std::map<NtupleStationId, MuonCalibSegment *> :: iterator it= - segments.begin(); it!= segments.end(); it++) { - -// ignore end-cap chambers // - if (it->second->mdtHOT()[0]->identify().stationNameString()[0]!='B') { - continue; - } - -// COLLECT RAW RPC HITS - std::vector<MuonCalibRawRpcHit *> raw_hits; - for (std::vector<MuonCalibRawRpcHit *>::const_iterator it1=raw_RPC_begin_it; it1!=raw_RPC_end_it; it1++) { - raw_hits.push_back(*it1); - } - - if(m_write_rpc_hits) fprintf(m_rpcHitsFile,"START %i %s %i %i\n", - event->eventInfo().eventNumber(), - it->second->mdtHOT()[0]->identify().stationNameString().c_str(), - it->second->mdtHOT()[0]->identify().phi(), - it->second->mdtHOT()[0]->identify().eta()); - -// reconstruct the second coordinate // - if (!handleRPChits(*(it->second), raw_hits)) { - to_delete.insert(it->first); - } - - } - - for(std::set<NtupleStationId> :: const_iterator it=to_delete.begin(); it!=to_delete.end(); it++) { - segments.erase(segments.find(*it)); - } - - return; -} //end BarrelSecondCoordinatePreparationTool::prepareSegments - -//:::::::::::::::::::::::::: -//:: METHOD handleRPChits :: -//:::::::::::::::::::::::::: -bool BarrelSecondCoordinatePreparationTool::handleRPChits(MuonCalibSegment & MDT_segment, - std::vector<MuonCalibRawRpcHit *> & raw_hits) { - //Segment parameters - MuonFixedId seg_ID(MDT_segment.mdtHOT()[0]->identify()); - - Amg::Vector3D seg_pos(MDT_segment.position()); - Amg::Vector3D seg_dir(MDT_segment.direction()); - - Amg::Transform3D Segment2Global(MDT_segment.localToGlobal()); - Amg::Transform3D Global2Segment((MDT_segment.localToGlobal()).inverse()); - - if(m_write_rpc_hits) { - Amg::Vector3D old_point = Amg::Vector3D(seg_pos.x(), 0.0, seg_pos.z()); - Amg::Vector3D old_vector = Amg::Vector3D(seg_dir.x()/seg_dir.z(), 0, 1.0); - old_point = Segment2Global*old_point; - old_vector = Segment2Global.linear()*old_vector; - - fprintf(m_rpcHitsFile,"old_line: x=%11.3f y=%11.3f a=%10.5f\n", - old_point.x(), old_point.y(), old_vector.x()/old_vector.y()); - } - - int seg_sector_ind; //hardware phi-index - if(seg_ID.stationNameString()[2]=='L' || seg_ID.stationNameString()[2]=='R' || - seg_ID.stationNameString()[2]=='M') { - seg_sector_ind = 2*seg_ID.phi() - 1; - } else { - seg_sector_ind = 2*seg_ID.phi(); - } - - seg_pos[0]=0.; - if(std::isnan(seg_dir.y())) return false; - seg_dir[0]=0.; - seg_dir = seg_dir.unit(); - - /////////////////// - //Handle RPC hits// - /////////////////// - int old_name(0); - int old_phi(0); - int old_eta(0); - int old_R(0); - int num_total(0); - int num_current(0); - - std::vector<CLHEP::HepVector> RPChits; - std::vector<int> in_seg_sector; - std::vector<int> num_hits_same_layer; - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return false; - } - - std::vector<MuonCalibRawRpcHit *>::iterator raw_it = raw_hits.begin(); - while (raw_it != raw_hits.end()) { - bool bad_hit = false; - MuonFixedId ID((*raw_it)->identify()); - if(ID.rpcMeasuresPhi() != 1) bad_hit = true; - - int sector_ind; //hardware phi-index - if(ID.stationNameString()[2]=='L' || ID.stationNameString()[2]=='R' || - ID.stationNameString()[2]=='M') { - sector_ind = 2*ID.phi() - 1; - } else { - sector_ind = 2*ID.phi(); - } - - int in_sector(2);//0-in the same sector; 1-in the adjacent sector; 2-other sectors - if(sector_ind==seg_sector_ind) in_sector=0; - if(std::abs(sector_ind-seg_sector_ind)==1) in_sector=1; - if(std::abs(sector_ind-seg_sector_ind)==15) in_sector=1; - - //RPC hits positions - Amg::Vector3D glb_pos((*raw_it)->globalPosition()); - Amg::Vector3D hit_pos(Global2Segment*glb_pos); - - CLHEP::HepVector p_x(3,0); - p_x[0] = hit_pos.x(); - p_x[1] = hit_pos.z(); - p_x[2] = ((*raw_it)->width())/3.464; - - //r-phi pattern - double diff; - diff = hit_pos.y() - (seg_pos.y() + (hit_pos.z()-seg_pos.z())*seg_dir.y()/seg_dir.z()); - if(!(std::abs(diff)<((*raw_it)->length()+400.0))) bad_hit = true; - - if(m_write_rpc_hits){ - if(ID.rpcMeasuresPhi()==1){ - fprintf(m_rpcHitsFile,"%i %i %i x=%11.3f y=%11.3f z=%11.3f %i\n", - ID.stationName(), ID.phi(), ID.eta(), glb_pos.x(), - glb_pos.y(), glb_pos.z(), int(bad_hit)); - } - } - - if(bad_hit) { - raw_it=raw_hits.erase(raw_it); - } else { - raw_it++; - RPChits.push_back(p_x); - in_seg_sector.push_back(in_sector); - //calculate number of hits in the same RPC layer (for downweighting) - num_hits_same_layer.push_back(1); - if(ID.stationName()==old_name && ID.phi()==old_phi && ID.eta()==old_eta && - ID.rpcDoubletR()==old_R) { - num_current++; - } else { - if(num_total) { - num_current++; - for(int m=(num_total-num_current); m<num_total; m++) { - num_hits_same_layer[m] = num_current; - } - } - num_current=0; - old_name = ID.stationName(); - old_phi = ID.phi(); - old_eta = ID.eta(); - old_R = ID.rpcDoubletR(); - } - num_total++; - } - } - - if(num_total) { - num_current++; - for(int m=(num_total-num_current); m<num_total; m++) { - num_hits_same_layer[m] = num_current; - } - } - - bool x_fit = false; - CLHEP::HepVector alph(2,0); - double ang_err(100.0); - if(!rpcFit(RPChits, in_seg_sector, num_hits_same_layer, 25.0, alph, ang_err) - && ang_err<0.05) x_fit=true; - - if(!x_fit) return false; - - // update second coordinate for MDT hits - for (unsigned int l=0; l<MDT_segment.mdtHOT().size(); l++) { - MuonFixedId ID(MDT_segment.mdtHOT()[l]->identify()); - Identifier atl_id = m_id_tool->fixedIdToId(ID); - const MuonGM::MdtReadoutElement *MdtRoEl = MuonDetMgr->getMdtReadoutElement(atl_id); - double tube_length(MdtRoEl->tubeLength(atl_id)); - - Amg::Vector3D loc_position(MDT_segment.mdtHOT()[l]->localPosition()); - double x_loc = alph[0] + alph[1]*loc_position.z(); - if(std::abs(x_loc)>(0.5*tube_length + 300.0)) { - return false; - } - if(std::abs(x_loc) > 0.5*tube_length) { - x_loc = 0.5*(std::abs(x_loc)/x_loc)*tube_length; - } - - loc_position[0]=(x_loc); - MDT_segment.mdtHOT()[l]->setLocalPos(loc_position); - MDT_segment.mdtHOT()[l]->setGlobalPos(Segment2Global*loc_position); - //set signal propagatino time - MDT_segment.mdtHOT()[l]->setDriftTime( MDT_segment.mdtHOT()[l]->driftTime() + MDT_segment.mdtHOT()[l]->propagationTime()); - MDT_segment.mdtHOT()[l]->setDistanceToReadout(MdtRoEl-> distanceFromRO( MDT_segment.mdtHOT()[l]->globalPosition(), atl_id)); - MDT_segment.mdtHOT()[l]->setPropagationTime( (MDT_segment.mdtHOT()[l]->distanceToReadout() - tube_length/2.0) * 0.0033356409519815205); - MDT_segment.mdtHOT()[l]->setDriftTime( MDT_segment.mdtHOT()[l]->driftTime() - MDT_segment.mdtHOT()[l]->propagationTime()); - - } - - // update second coordinate for MDT segment - seg_pos[0]=(alph[0] + alph[1]*seg_pos.z()); - - seg_dir[0]=(alph[1]); - seg_dir[1]=(seg_dir.y()/seg_dir.z()); - seg_dir[2]=1.0; - - MDT_segment.set(MDT_segment.chi2(), seg_pos, seg_dir); - - if(m_write_rpc_hits) { - Amg::Vector3D fit_point = Amg::Vector3D(alph[0], 0, 0); - Amg::Vector3D fit_vector = Amg::Vector3D(alph[1], 0, 1.0); - fit_point = Segment2Global*fit_point; - fit_vector = Segment2Global*fit_vector; - - fprintf(m_rpcHitsFile,"fit_line: x=%11.3f y=%11.3f a=%10.5f\n", - fit_point.x(), fit_point.y(), fit_vector.x()/fit_vector.y()); - } - - return true; -} //end BarrelSecondCoordinatePreparationTool::handleRPChits - - -///////////////////////////////////////////// -// Fit by RPC hits // -///////////////////////////////////////////// -int BarrelSecondCoordinatePreparationTool::rpcFit(std::vector<CLHEP::HepVector> &RPC_hits, - std::vector<int> in_sect, std::vector<int> num_same, double max_r, - CLHEP::HepVector &tr_par, double &angle_err) { - int ierr(0); // Status of Matrix Inversion - - if(RPC_hits.size()<2) return -1; - - CLHEP::HepMatrix Gmm = CLHEP::HepMatrix(2,2,0); - CLHEP::HepVector bth = CLHEP::HepVector(2,0); - for(unsigned int j=0;j<RPC_hits.size();j++) { - CLHEP::HepVector dlt = CLHEP::HepVector(2,0); - dlt[0] = 1.0; - dlt[1] = RPC_hits[j][1]; - if(RPC_hits[j][2]<=0) RPC_hits[j][2]=10000.0; - double wght = 1.0/(RPC_hits[j][2]*RPC_hits[j][2]); - wght = wght/(double(num_same[j])); - if(in_sect[j]==1) wght = wght/4.0; - if(in_sect[j]==2) wght = wght/25.0; - if(in_sect[j]==3) wght = wght/100.0; - Gmm += wght*dlt*dlt.T(); - bth += wght*RPC_hits[j][0]*dlt; - } - - Gmm.invert(ierr); - if(ierr) { - ATH_MSG_ERROR( "Gmm matrix inversion ERROR:"<<ierr<<" Can't invert matrix" ); - return -1; - } - - tr_par = Gmm*bth; - - double tmp_cut(800.0); - int count(0); - - while(count!=2) { - bth[0]=0.0; - bth[1]=0.0; - Gmm[0][0]=0.0; - Gmm[0][1]=0.0; - Gmm[1][0]=0.0; - Gmm[1][1]=0.0; - - for(unsigned int j=0;j<RPC_hits.size();j++) { - double res = (tr_par[0] + tr_par[1]*RPC_hits[j][1] - RPC_hits[j][0])/RPC_hits[j][2]; - - double c_norm = 1.345; - double addweight; - if(std::abs(res)<c_norm) addweight=1; - else addweight=c_norm/std::abs(res); - - CLHEP::HepVector dlt = CLHEP::HepVector(2,0); - dlt[0] = 1.0; - dlt[1] = RPC_hits[j][1]; - if(RPC_hits[j][2]<=0) RPC_hits[j][2]=10000.0; - double wght = 1.0/(RPC_hits[j][2]*RPC_hits[j][2]); - wght = wght/(double(num_same[j])); - wght = wght*addweight; - if(in_sect[j]==1) wght = wght/4.0; - if(in_sect[j]==2) wght = wght/25.0; - if(in_sect[j]==3) wght = wght/100.0; - Gmm += wght*dlt*dlt.T(); - bth += wght*RPC_hits[j][0]*dlt; - } - - Gmm.invert(ierr); - if(ierr) { - ATH_MSG_ERROR( "Gmm matrix inversion ERROR:"<<ierr<<" Can't invert matrix" ); - return -1; - } - tr_par = Gmm*bth; - - for(unsigned int j=0;j<RPC_hits.size();j++) { - double res = (tr_par[0] + tr_par[1]*RPC_hits[j][1] - RPC_hits[j][0])/RPC_hits[j][2]; - if(std::abs(res)>3.0*tmp_cut && std::abs(res)>max_r) { - RPC_hits[j][2]=100000.0; - } - } - if(tmp_cut<=max_r) { - count++; - } - tmp_cut = 0.5*tmp_cut; - } - - if(Gmm[1][1]<0) return -2; - angle_err = std::sqrt(Gmm[1][1]); - - return 0; -} //end BarrelSecondCoordinatePreparationTool::rpcFit diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/CalibNtupleAnalysisAlg2.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/CalibNtupleAnalysisAlg2.cxx deleted file mode 100644 index b6d2a77fae8fa65a42fc17eb27a8378b10b87e6e..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/CalibNtupleAnalysisAlg2.cxx +++ /dev/null @@ -1,138 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" - -//MdrCalibRt -#include "MdtCalibRt/RtCalibrationOutput.h" - -//this -#include "CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg2.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "MuonCalibStandAloneBase/MdtStationT0Container.h" -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" - -//MdtCalibIOSvc -#include "MdtCalibIOSvc/MdtCalibOutputDbSvc.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -namespace MuonCalib { - -CalibNtupleAnalysisAlg2::CalibNtupleAnalysisAlg2(const std::string &name, ISvcLocator *pSvcLocator) : AthAlgorithm(name, pSvcLocator), -m_calib_tool_handle("MuonCalib::NtupleRunScanTool"), m_num_segments(-1), m_dbservice("MdtCalibOutputDbSvc", name), -m_calib_input_svc("MdtCalibInputSvc", name), p_calib_tool(NULL), m_crash_if_no_segments(false), m_eventnumber(0) { - declareProperty("CalibrationTool", m_calib_tool_handle); - declareProperty("CalibSegmentPreparationTools", m_seg_prep_tool_handles); - declareProperty("NumberOfSegments", m_num_segments); - declareProperty("CrashIfNoSegments", m_crash_if_no_segments); - declareProperty("MdtCalibOutputDbSvc", m_dbservice); - declareProperty("MdtCalibInputSvc", m_calib_input_svc); -} - -CalibNtupleAnalysisAlg2::~CalibNtupleAnalysisAlg2() { -} - -StatusCode CalibNtupleAnalysisAlg2::initialize() { -//greet user -// ATH_MSG_INFO( "Thank you for using CalibNtupleAnalysisAlg2!" ); -//get MdtCalibOutptSvc - ATH_CHECK( m_dbservice.retrieve() ); - ATH_MSG_INFO( "Retrieved MdtCalibOutputDbSvc"); -//get MdtCalibInputSvc - ATH_CHECK( m_calib_input_svc.retrieve() ); - ATH_MSG_INFO( "Retrieved MdtCalibInputSvc"); -//create the segment preparation tools - ATH_CHECK( m_seg_prep_tool_handles.retrieve() ); - for (unsigned int k=0; k<m_seg_prep_tool_handles.size(); k++) { - ATH_MSG_INFO( m_seg_prep_tool_handles[k].type() << " retrieved" ); - } - ATH_CHECK( m_calib_tool_handle.retrieve(p_calib_tool) ); - ATH_MSG_INFO( "Retrieved Tool " << m_calib_tool_handle.type() ); - - return StatusCode::SUCCESS; -} //end CalibNtupleAnalysisAlg2::initialize - -StatusCode CalibNtupleAnalysisAlg2::execute() { -////////////////////////////////////////////// -//run calibration segment preparation tools // -////////////////////////////////////////////// - const MuonCalibEvent *event(NULL); - std::map<NtupleStationId, MuonCalibSegment *> segments; - m_eventnumber = 0; - while(1) { -// Print number of segments every 1k events for first 20k events, then every 10k to avoid maxing out number of allowed messages - if( (m_eventnumber < 20000 && m_eventnumber%1000 == 0) || m_eventnumber%10000 == 0 ) { - ATH_MSG_INFO( m_eventnumber << " events read, " << m_stored_segment.size() << " segments collected" ); - } - if (static_cast<int>(m_stored_segment.size()) >= m_num_segments && m_num_segments>=0) { - ATH_MSG_INFO( "Enough segments collected!" ); - return StatusCode::SUCCESS; - } - segments.clear(); - for (unsigned int k=0; k<m_seg_prep_tool_handles.size(); k++) { - m_seg_prep_tool_handles[k]->prepareSegments(event, segments); - if(event==NULL) { - return StatusCode::SUCCESS; - } - } - int current_pos = m_stored_segment.size(); - for(std::map<NtupleStationId, MuonCalibSegment *>::const_iterator it=segments.begin(); it!= segments.end(); it++) { - if(p_calib_tool->KeepSegments()) { - m_stored_segment.push_back(new MuonCalibSegment(*(it->second))); - } else { - m_stored_segment.push_back(it->second); - } - } - ATH_CHECK( p_calib_tool->handleEvent(*event, m_eventnumber, m_stored_segment, current_pos) ); - m_eventnumber++; - } - return StatusCode::SUCCESS; -} //end CalibNtupleAnalysisAlg2::execute - -StatusCode CalibNtupleAnalysisAlg2::finalize() { - if(m_stored_segment.size()==0) { - if(m_crash_if_no_segments) { - ATH_MSG_FATAL("No Segments found!"); - return StatusCode::FAILURE; - } else { - ATH_MSG_WARNING("No Segments found!"); - return StatusCode::SUCCESS; - } - } -// Final tally of events/segments - ATH_MSG_INFO( m_eventnumber << " events read, " << m_stored_segment.size() << " segments collected" ); - - ATH_CHECK( p_calib_tool->analyseSegments(m_stored_segment) ); -//special sausage for resolution fitters - const IRtResolution *resolution(p_calib_tool->getResolution()); - if(resolution != NULL) { - ATH_MSG_INFO( "Storing resolution calibration!" ); - const IRtRelation *rt_rel(m_calib_input_svc->GetRtRelation()); - if(rt_rel == NULL) { - ATH_MSG_FATAL( "Cannot store a resolution without an rt-relation!" ); - return StatusCode::FAILURE; - } - RtCalibrationOutput *output(new RtCalibrationOutput(rt_rel, new RtFullInfo(std::string("Resolution"), 1, m_stored_segment.size(), 0.0, 0.0, 0.0, 0.0))); - m_dbservice->memorize(output, resolution); - } else { - ATH_MSG_INFO( "Storing calibration!" ); - const IMdtCalibrationOutput *calib_res(p_calib_tool->getResults()); - if(calib_res == NULL) { - ATH_MSG_WARNING( "Calibration Tool returned NULL-Pointer to Calibration Results!" ); - return StatusCode::SUCCESS; - } - if(! m_dbservice.empty() ) { - m_dbservice->memorize(p_calib_tool->getResults()); - } - } -// ATH_MSG_INFO( "Bye!" ); -// m_calibration_programme->endOfData(); - return StatusCode::SUCCESS; -} //end CalibNtupleAnalysisAlg2::finalize - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/CalibNtupleLoader.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/CalibNtupleLoader.cxx deleted file mode 100644 index c07cf88bc700d572631e07750a3f8fbf9b227a4b..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/CalibNtupleLoader.cxx +++ /dev/null @@ -1,244 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/CalibNtupleLoader.h" - -//CalibNtupleReader -#include "CalibNtupleReader/NTReader.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibEventInfo.h" - -// StoreGateSvc, IncidentSvc -#include "GaudiKernel/IIncidentSvc.h" -#include "GaudiKernel/Incident.h" -#include "GaudiKernel/ThreadLocalContext.h" - -// Athena EventInfo -#include "EventInfo/EventType.h" -#include "EventInfo/EventInfo.h" -#include "EventInfo/EventID.h" - -//root -#include "TChain.h" -#include "TFile.h" -#include "TKey.h" - -//c - c++ -#include "fstream" - -namespace MuonCalib { - -/////////////////////// -// CalibNtupleLoader // -/////////////////////// -CalibNtupleLoader::CalibNtupleLoader(const std::string &t, const std::string &n, const IInterface *p): - AthAlgTool(t, n, p), m_prev_event_nr(-1), m_prev_run_nr(0), m_reg_sel_svc("RegionSelectionSvc", n), - m_incSvc("IncidentSvc", n) { - m_filelist="file_list.txt"; - declareProperty("FileList", m_filelist); - m_first = 0; - declareProperty("FirstEvent", m_first); - m_last = -1; - declareProperty("LastEvent", m_last); - m_ntuple_type="AUTO"; - declareProperty("NtupleType", m_ntuple_type); - m_skip_double_events = false; - declareProperty("SkipDoubleEvents", m_skip_double_events); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - declareProperty("IncidentSvc", m_incSvc); - declareInterface< CalibSegmentPreparationTool >(this); -} - -//////////////// -// initialize // -//////////////// -StatusCode CalibNtupleLoader::initialize(void) { - ATH_MSG_INFO( "Filelist is '"<<m_filelist<<"'" ); - //convert Ntuple Type - if(m_ntuple_type == "AUTO") { - m_ntuple_type_num = 0; - } else if (m_ntuple_type == "NORMAL") { - m_ntuple_type_num = 1; - } else if (m_ntuple_type == "REGION") { - m_ntuple_type_num = 2; - } else { - ATH_MSG_FATAL("Invalid ntuple type. Must be AUTO/NORMAL/REGION!"); - return StatusCode::FAILURE; - } -//read filelist an build chain - m_chain = new TChain("/PatternNtupleMaker/Segments"); - std::string sdummy; - int count(0); - std::ifstream fl(m_filelist.c_str()); - if(fl.fail()) { - ATH_MSG_INFO( "Cannot open file '"<<m_filelist<<"' for reading!" ); - return StatusCode::FAILURE; - } - while (!fl.eof()) { - fl >> sdummy; - if (fl.eof()) break; - if (sdummy=="[") { - ATH_CHECK( read_dictionary(fl,count) ); - continue; - } - bool is_region(false); - if(m_ntuple_type_num == 2) is_region = true; - if(m_ntuple_type_num == 0) { - TFile *testf=TFile::Open(sdummy.c_str()); - if(!testf) { - ATH_MSG_WARNING( "Cannot open file '"<<sdummy.c_str()<<"'" ); - continue; - } - if(testf->GetKey("PatternNtupleMaker") == NULL) { - is_region = true; - } else { - is_region = false; - } - delete testf; - } - if (is_region) { - std::list<std::string> dummy_lst; - if(m_reg_sel_svc.empty()) { - ATH_CHECK( m_reg_sel_svc.retrieve() ); - } - ATH_MSG_INFO( "Added "<<m_reg_sel_svc->AddRegionNtuples(sdummy.c_str(), m_chain, dummy_lst)<<" regions from file "<<sdummy ); - } else { - m_chain->AddFile(sdummy.c_str()); - ATH_MSG_INFO( "Added file '"<<sdummy<<"' to filelist!" ); - } - count++; - } - if(count==0) { - ATH_MSG_FATAL( "No files in filelist!" ); - return StatusCode::FAILURE; - } - m_reader = new NTReader(m_chain); - - // retrieve IncidentService to fire Incidents after changing EventInfo - ATH_CHECK( m_incSvc.retrieve() ) ; - - return StatusCode::SUCCESS; -} //end CalibNtupleLoader::initialize - -///////////////////// -// prepareSegments // -///////////////////// -void CalibNtupleLoader::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> & /*segments*/) { - if(m_last>0 && m_last<=m_first) { - ATH_MSG_INFO( "Enough events read!" ); - event=NULL; - return; - } - event = &(m_reader->getEvent(m_first)); - if (event->rawHitCollection()==NULL) { - ATH_MSG_INFO( "End of file reached" ); - event=NULL; - return; - } - if(m_skip_double_events) { - while(static_cast<int>(event->eventInfo().eventNumber()) == m_prev_event_nr) { - m_first++; - if(m_last>0 && m_last<=m_first) { - ATH_MSG_INFO( "Enough events read!" ); - event=NULL; - return; - } - event = &(m_reader->getEvent(m_first)); - if (event->rawHitCollection()==NULL) { - ATH_MSG_INFO( "End of file reached" ); - event=NULL; - return; - } - } - } - m_prev_event_nr = event->eventInfo().eventNumber(); - m_first++; - - // get the current EventInfo from StoreGateSvc - const EventInfo *currentEvent(NULL) ; - StatusCode sc = evtStore()->retrieve(currentEvent) ; - if ( sc.isFailure() ) { - ATH_MSG_INFO( "Couldnt retrieve EventInfo from StoreGateSvc" ); - event = NULL ; - return ; - } - - // Fire the EndEvent incident; this is normally done by the - // AthenaEventLoopMgr after calling the "execute" method of all - // Algorithms - m_incSvc->fireIncident(Incident(name(),IncidentType::EndEvent,Gaudi::Hive::currentContext())); - - // Change the EventInfo in StoreGate to the correct info from - // the event in the ntuple - EventInfo *nonconst_currentEvent = - const_cast<EventInfo*>(currentEvent) ; - nonconst_currentEvent->event_ID()->set_run_number(event->eventInfo().runNumber()); - nonconst_currentEvent->event_ID()->set_event_number(event->eventInfo().eventNumber()); - nonconst_currentEvent->event_ID()->set_time_stamp(event->eventInfo().timeStamp()); - - ATH_MSG_DEBUG( "Hacked Run.Event,Time: " - << "[" << currentEvent->event_ID()->run_number() - << "." << currentEvent->event_ID()->event_number() - << "," << currentEvent->event_ID()->time_stamp() - << "]" ); - - // Fire EndRun and BeginRun Incidents if the run number changed - if ( event->eventInfo().runNumber() != m_prev_run_nr ) { - m_prev_run_nr = event->eventInfo().runNumber() ; - m_incSvc->fireIncident(Incident(name(),"EndRun")); - m_incSvc->fireIncident(Incident(name(),IncidentType::BeginRun,Gaudi::Hive::currentContext())); - } - - // Fire BeginEvent Incident - m_incSvc->fireIncident(Incident(name(),IncidentType::BeginEvent,Gaudi::Hive::currentContext())); - -} //end CalibNtupleLoader::prepareSegments - -inline StatusCode CalibNtupleLoader::read_dictionary(std::istream &fl, int &tot_count) { - MsgStream log(msgSvc(), name()); - std::string filename; - fl>>filename; - if(fl.eof()) { - ATH_MSG_FATAL( "Filelist has wrong format" ); - return StatusCode::FAILURE; - } -//read regions - int count=0; - std::list<std::string> regions; - while(1) { - std::string region; - fl>>region; - if(region=="]") { - break; - } - if(fl.eof()) { - ATH_MSG_FATAL( "Filelist has wrong format" ); - return StatusCode::FAILURE; - } - if (region=="PatternNtupleMaker") { - m_chain->AddFile(filename.c_str()); - count++; - } else { - regions.push_back(region); - } - } - if(regions.size()>0) { - if(m_reg_sel_svc.empty()) { - ATH_CHECK( m_reg_sel_svc.retrieve() ); - } - count+=m_reg_sel_svc->AddRegionNtuples(filename.c_str(), m_chain, regions); - } - if (count>0) { - ATH_MSG_INFO( "Added " << count << " regions from "<< filename ); - } - tot_count+=count; - return StatusCode::SUCCESS; -} //end CalibNtupleLoader::read_dictionary - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/GeoDraw.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/GeoDraw.cxx deleted file mode 100644 index 2b3e5f723b2127a33a5e3374b66e46c8a27aef06..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/GeoDraw.cxx +++ /dev/null @@ -1,179 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CalibNtupleAnalysisAlg/GeoDraw.h" -#include "MuonCalibIdentifier/MuonFixedId.h" -#include "CLHEP/Geometry/Transform3D.h" -#include "CLHEP/Geometry/Point3D.h" -#include "MdtStationGeometryRow.h" -#include "GaudiKernel/MsgStream.h" -#include "AthenaKernel/getMessageSvc.h" - -#include "TTree.h" -#include "TFile.h" -#include "TDirectory.h" -#include "MdtStationGeometryRow.h" -#include "iostream" - -namespace MuonCalib { - -inline unsigned int get_station_id(unsigned int &tube_id) { - MuonFixedId id(tube_id); - return id.mdtChamberId().getIdInt(); -} - -class GeoDraw_Data { -public: - std::map<unsigned int, HepGeom::Point3D<double> > tube_positions; - std::map<unsigned int, HepGeom::Transform3D> local_to_global; - std::map<unsigned int, HepGeom::Transform3D> global_to_local; -}; - -GeoDraw_Data *GeoDraw::s_data = NULL; - -void GeoDraw::Load(const char *filename) { - if(s_data) delete s_data; - s_data = new GeoDraw_Data(); - TDirectory *lastdir=gDirectory; - TFile inf(filename); - TTree *mdt_tubes=dynamic_cast<TTree *>(inf.Get("mdt_tubes")); - if(!mdt_tubes) return; - UInt_t id; - Float_t pos_x, pos_y, pos_z; - mdt_tubes->SetBranchAddress("id", &id); - mdt_tubes->SetBranchAddress("pos_x", &pos_x); - mdt_tubes->SetBranchAddress("pos_y", &pos_y); - mdt_tubes->SetBranchAddress("pos_z", &pos_z); - TNamed *ATLASVersion = dynamic_cast<TNamed *>(inf.Get("ATLASVersion")); - MsgStream log(Athena::getMessageSvc(),"GeoDraw"); - if (ATLASVersion) log<<MSG::INFO<<"Reading geometry "<<ATLASVersion->GetTitle()<<endmsg; - log<<MSG::INFO<<"Loading "<<mdt_tubes->GetEntries()<<" tubes"<<endmsg; - for(int i=0; i<mdt_tubes->GetEntries(); i++) { - mdt_tubes->GetEntry(i); - s_data->tube_positions[id].setX(pos_x); - s_data->tube_positions[id].setY(pos_y); - s_data->tube_positions[id].setZ(pos_z); - } - - TTree *mdt_station=dynamic_cast<TTree *>(inf.Get("mdt_station")); - if (!mdt_station) return; - MdtStationGeometryRow row; - row.SetBranchAddress(mdt_station); - mdt_station->SetBranchAddress("id", &id); - log<<MSG::INFO<<"Loading "<<mdt_station->GetEntries()<<" stations"<<endmsg; - for(int i=0; i<mdt_station->GetEntries(); i++) { - mdt_station->GetEntry(i); - s_data->local_to_global[id] = row.GetTransform(); - s_data->global_to_local[id] = s_data->local_to_global[i].inverse(); - } - lastdir->cd(); -} //end GeoDraw::Load - -double GeoDraw::PosX(unsigned int tube_id) { - std::map<unsigned int, HepGeom::Point3D<double> >::const_iterator it(s_data->tube_positions.find(tube_id)); - if(it==s_data->tube_positions.end()) { - MsgStream log(Athena::getMessageSvc(),"GeoDraw"); - log<<MSG::WARNING<<"Tube not found"<<endmsg; - return 9e9; - } - return it->second.x(); -} - -double GeoDraw::PosY(unsigned int tube_id) { - std::map<unsigned int, HepGeom::Point3D<double> >::const_iterator it(s_data->tube_positions.find(tube_id)); - if(it==s_data->tube_positions.end()) { - MsgStream log(Athena::getMessageSvc(),"GeoDraw"); - log<<MSG::WARNING<<"Tube not found"<<endmsg; - return 9e9; - } - return it->second.y(); -} - -double GeoDraw::PosZ(unsigned int tube_id) { - std::map<unsigned int, HepGeom::Point3D<double> >::const_iterator it(s_data->tube_positions.find(tube_id)); - if(it==s_data->tube_positions.end()) { - MsgStream log(Athena::getMessageSvc(),"GeoDraw"); - log<<MSG::WARNING<<"Tube not found"<<endmsg; - return 9e9; - } - return it->second.z(); -} - -double GeoDraw::GPosX(unsigned int tube_id) { - unsigned int station_id(get_station_id(tube_id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->local_to_global.find(station_id)); - if(tr_it==s_data->local_to_global.end()) return -9e9; - std::map<unsigned int, HepGeom::Point3D<double> >::const_iterator it(s_data->tube_positions.find(tube_id)); - if(it==s_data->tube_positions.end()) return 9e9; - return (tr_it->second * it->second).x(); -} - -double GeoDraw::GPosY(unsigned int tube_id) { - unsigned int station_id(get_station_id(tube_id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->local_to_global.find(station_id)); - if(tr_it==s_data->local_to_global.end()) return -9e9; - std::map<unsigned int, HepGeom::Point3D<double> - >::const_iterator it(s_data->tube_positions.find(tube_id)); - if(it==s_data->tube_positions.end()) return 9e9; - return (tr_it->second * it->second).y(); -} - -double GeoDraw::GPosZ(unsigned int tube_id) { - unsigned int station_id(get_station_id(tube_id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->local_to_global.find(station_id)); - if(tr_it==s_data->local_to_global.end()) return -9e9; - std::map<unsigned int, HepGeom::Point3D<double> >::const_iterator it(s_data->tube_positions.find(tube_id)); - if(it==s_data->tube_positions.end()) return 9e9; - return (tr_it->second * it->second).z(); -} - -double GeoDraw::LocalToGlobalX(unsigned int id, double x, double y, double z) { - unsigned int station_id(get_station_id(id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->local_to_global.find(station_id)); - if(tr_it==s_data->local_to_global.end()) return -9e9; - HepGeom::Point3D<double> p(x, y, z); - return (tr_it->second * p).x(); -} - -double GeoDraw::LocalToGlobalY(unsigned int id, double x, double y, double z) { - unsigned int station_id(get_station_id(id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->local_to_global.find(station_id)); - if(tr_it==s_data->local_to_global.end()) return -9e9; - HepGeom::Point3D<double> p(x, y, z); - return (tr_it->second * p).y(); -} - -double GeoDraw::LocalToGlobalZ(unsigned int id, double x, double y, double z) { - unsigned int station_id(get_station_id(id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->local_to_global.find(station_id)); - if(tr_it==s_data->local_to_global.end()) return -9e9; - HepGeom::Point3D<double> p(x, y, z); - return (tr_it->second * p).z(); -} - -double GeoDraw::GlobalToLocalX(unsigned int id, double x, double y, double z) { - unsigned int station_id(get_station_id(id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->global_to_local.find(station_id)); - if(tr_it==s_data->global_to_local.end()) return -9e9; - HepGeom::Point3D<double> p(x, y, z); - return (tr_it->second * p).x(); -} - -double GeoDraw::GlobalToLocalY(unsigned int id, double x, double y, double z) { - unsigned int station_id(get_station_id(id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->global_to_local.find(station_id)); - if(tr_it==s_data->global_to_local.end()) return -9e9; - HepGeom::Point3D<double> p(x, y, z); - return (tr_it->second * p).y(); -} - -double GeoDraw::GlobalToLocalZ(unsigned int id, double x, double y, double z) { - unsigned int station_id(get_station_id(id)); - std::map<unsigned int, HepGeom::Transform3D>::const_iterator tr_it(s_data->global_to_local.find(station_id)); - if(tr_it==s_data->global_to_local.end()) return -9e9; - HepGeom::Point3D<double> p(x, y, z); - return (tr_it->second * p).z(); -} - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/GoodRunListFilter.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/GoodRunListFilter.cxx deleted file mode 100644 index 593baceb749ed79a34e2d2e5df780bce4a7ee238..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/GoodRunListFilter.cxx +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/GoodRunListFilter.h" - -//GoodRunsLists -#include "GoodRunsLists/IGoodRunsListSelectorTool.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibEventInfo.h" -namespace MuonCalib { - -GoodRunListFilter::GoodRunListFilter(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p) { - declareProperty("GoodRunListTool", m_good_runlist_tool); - declareInterface< CalibSegmentPreparationTool >(this); -} - -StatusCode GoodRunListFilter::initialize(void) { - ATH_CHECK( m_good_runlist_tool.retrieve() ); - return StatusCode::SUCCESS; -} - -void GoodRunListFilter::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - const MuonCalibEventInfo &event_info=event->eventInfo(); - if(!m_good_runlist_tool->passRunLB(event_info.runNumber(), event_info.lumiBlock())) { - segments.clear(); - } -} - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/InitialDqFilter.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/InitialDqFilter.cxx deleted file mode 100644 index 9334f30678e3b8142248fc3beccf616fad0671c0..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/InitialDqFilter.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/InitialDqFilter.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" - -//MuonCalibIdentifier -#include "MuonCalibIdentifier/MuonFixedId.h" - -//c- c++ -#include "fstream" - - -namespace MuonCalib { - -InitialDqFilter::InitialDqFilter(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p), m_reg_sel_svc("RegionSelectionSvc", n) { - m_initial_dq_path = "initial_dq.txt"; - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - declareProperty("InitialDqFile", m_initial_dq_path); - declareInterface< CalibSegmentPreparationTool >(this); -} - -StatusCode InitialDqFilter::initialize(void) { -//get region selection svc - ATH_CHECK( m_reg_sel_svc.retrieve() ); -//read initial dq list - std::ifstream lst(m_initial_dq_path.c_str()); - if(!lst.good()) return StatusCode::FAILURE; - std::string station, s_name; - int ml, ly, tb, severity, dummy, eta, phi; - //read line - while(1) { - lst>>station; - if(!lst.good()) break; - lst>>ml; - if(!lst.good()) break; - lst>>ly; - if(!lst.good()) break; - lst>>tb; - if(!lst.good()) break; - lst>>severity; - if(!lst.good()) break; - lst>>dummy; - if(!lst.good()) break; - lst>>dummy; - if(!lst.good()) break; - if(severity<2) continue; - MuonFixedId id; - id.set_mdt(); - for(unsigned int i=0; i<station.size(); i++) - if(station[i]=='_') station[i]=' '; - std::istringstream st_stream(station); - st_stream>>s_name; - st_stream>>phi; - st_stream>>eta; - id.setStationName(id.stationStringToFixedStationNumber(s_name)); - id.setStationEta(eta); - id.setStationPhi(phi); - id.setMdtMultilayer(ml); - id.setMdtTubeLayer(ly); - id.setMdtTube(tb); - //only insert relevant tubes - if(!m_reg_sel_svc->isInRegion(id)) continue; - ATH_MSG_INFO( "Suppressing "<<s_name<<","<<phi<<","<<eta<<" ml="<<ml<<" ly="<<ly<<" tb="<<tb ); - m_suppressed_tubes.insert(id); - } - return StatusCode::SUCCESS; -} //end InitialDqFilter::initialize - -void InitialDqFilter::prepareSegments(const MuonCalibEvent *& /*event*/, -std::map<NtupleStationId, MuonCalibSegment *> &segments) { -//reject empty segments - std::set<NtupleStationId> empty_segments; - for(std::map<NtupleStationId, MuonCalibSegment *>::iterator it=segments.begin(); it!=segments.end(); it++) { - std::vector<unsigned int> new_selection; - bool is_empty(true); - for(MuonCalibSegment::MdtHitIt h_it=(it->second)->mdtHOTBegin(); h_it!=(it->second)->mdtHOTEnd(); h_it++) { - if (m_suppressed_tubes.find((*h_it)->identify()) == m_suppressed_tubes.end()) { - is_empty = false; - new_selection.push_back(0); - } else { - new_selection.push_back(1); - } - } - if(is_empty) { - empty_segments.insert(it->first); - } else { - it->second->refineMdtSelection(new_selection); - } - } - for(std::set<NtupleStationId> ::iterator it=empty_segments.begin(); it!=empty_segments.end(); it++) { - if(segments.find(*it)!=segments.end()) - segments.erase(segments.find(*it)); - } -} //end InitialDqFilter::prepareSegments - -}//namespace MuonClib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MdtStationGeometryRow.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MdtStationGeometryRow.h deleted file mode 100644 index fe33c4fa81196a5ef56e3751f375b0766c03993d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MdtStationGeometryRow.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_MdtStationGeometryRow_h -#define MuonCalib_MdtStationGeometryRow_h - -#include "CLHEP/Geometry/Transform3D.h" -#include "CLHEP/Vector/Rotation.h" -#include "CLHEP/Vector/ThreeVector.h" -#include "GeoPrimitives/GeoPrimitives.h" -#include "TTree.h" - -namespace MuonCalib { - -class MdtStationGeometryRow { - public: - Float_t xx, xy, xz, - yx, yy, yz, - zx, zy, zz; - Float_t dx, dy, dz; - - inline void CreateBranches(TTree * tree) { - tree->Branch("xx", &xx, "xx/F"); - tree->Branch("xy", &xy, "xy/F"); - tree->Branch("xz", &xz, "xz/F"); - tree->Branch("yx", &yx, "yx/F"); - tree->Branch("yy", &yy, "yy/F"); - tree->Branch("yz", &yz, "yz/F"); - tree->Branch("zx", &zx, "zx/F"); - tree->Branch("zy", &zy, "zy/F"); - tree->Branch("zz", &zz, "zz/F"); - tree->Branch("dx", &dx, "dx/F"); - tree->Branch("dy", &dy, "dy/F"); - tree->Branch("dz", &dz, "dz/F"); - } - - inline void ReadHepTransform(const Amg::Transform3D &hep_transform) { - Amg::RotationMatrix3D hep_rot(hep_transform.rotation()); - Amg::Vector3D hep_trans(hep_transform.translation()); - xx = hep_rot.col(0).x(); - xy = hep_rot.col(0).y(); - xz = hep_rot.col(0).z(); - yx = hep_rot.col(1).x(); - yy = hep_rot.col(1).y(); - yz = hep_rot.col(1).z(); - zx = hep_rot.col(2).x(); - zy = hep_rot.col(2).y(); - zz = hep_rot.col(2).z(); - dx = hep_trans.x(); - dy = hep_trans.y(); - dz = hep_trans.z(); - } - - inline void SetBranchAddress(TTree * tree) { - tree->SetBranchAddress("xx", &xx); - tree->SetBranchAddress("xy", &xy); - tree->SetBranchAddress("xz", &xz); - tree->SetBranchAddress("yx", &yx); - tree->SetBranchAddress("yy", &yy); - tree->SetBranchAddress("yz", &yz); - tree->SetBranchAddress("zx", &zx); - tree->SetBranchAddress("zy", &zy); - tree->SetBranchAddress("zz", &zz); - tree->SetBranchAddress("dx", &dx); - tree->SetBranchAddress("dy", &dy); - tree->SetBranchAddress("dz", &dz); - } - - inline HepGeom::Transform3D GetTransform() { - CLHEP::Hep3Vector colx( xx ,xy, xz ); - CLHEP::Hep3Vector coly( yx, yy, yz ); - CLHEP::Hep3Vector colz( zx, zy, zz ); - CLHEP::HepRotation rotation( colx, coly, colz ); - CLHEP::Hep3Vector translation(dx, dy, dz); - HepGeom::Transform3D trans( rotation, translation ); - return trans; - } - -}; - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MdtTubeGeomertyRow.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MdtTubeGeomertyRow.h deleted file mode 100644 index 228deff6d7d347f6c6187ae9f7fb057a90f4fd16..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MdtTubeGeomertyRow.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib__MdtTubeGeomertyRow_h -#define MuonCalib__MdtTubeGeomertyRow_h - -#include "TTree.h" - -namespace MuonCalib { - -class MdtTubeGeomertyRow { - public: - UInt_t tube_id; - Float_t pos_x, pos_y, pos_z; -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MuonCalibGeometryDumper.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MuonCalibGeometryDumper.cxx deleted file mode 100644 index 185919a2438a9e6742794aea1fa0fd6227be58cb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MuonCalibGeometryDumper.cxx +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h" -#include "MdtTubeGeomertyRow.h" -#include "MdtStationGeometryRow.h" - - -#include <stdexcept> - -// MuonReadoutGeometry // -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -#include "MuonCalibIdentifier/MuonFixedId.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" - -//geomodel -#include "GeoModelInterfaces/IGeoModelSvc.h" - -//root -#include "TFile.h" -#include "TTree.h" -#include "TNamed.h" - - -namespace MuonCalib { - -MuonCalibGeometryDumper::MuonCalibGeometryDumper(const std::string &name, ISvcLocator *pSvcLocator) : - AthAlgorithm(name, pSvcLocator), - m_detMgr(nullptr), - m_id_tool(nullptr) { - - m_idToFixedIdToolType = std::string("MuonCalib::IdToFixedIdTool"); - declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); - - m_idToFixedIdToolName = std::string("MuonCalib_IdToFixedIdTool"); - declareProperty("idToFixedIdToolName", m_idToFixedIdToolName); - - m_rootFile = "geom.root"; - declareProperty("RootFile", m_rootFile); - -} //end MuonCalibGeometryDumper::MuonCalibGeometryDumper - -StatusCode MuonCalibGeometryDumper::initialize() { - - ATH_CHECK(m_idHelperSvc.retrieve()); -// muon detector manager // - ATH_CHECK(detStore()->retrieve(m_detMgr)); - -// muon fixed id tool // - ATH_CHECK( toolSvc()->retrieveTool(m_idToFixedIdToolType, m_idToFixedIdToolName, m_id_tool)); - - const IGeoModelSvc *geoModel=nullptr; - ATH_CHECK( service ("GeoModelSvc", geoModel) ); - if (!geoModel) { - ATH_MSG_FATAL("Could not retrieve GeoModelSvc"); - return StatusCode::FAILURE; - } - - TFile *output_file = new TFile(m_rootFile.c_str(), "RECREATE"); - TNamed geometry_version("ATLASVersion", geoModel->atlasVersion().c_str()); - geometry_version.Write(); - dump_mdt_geometry(); - output_file->Write(); - return StatusCode::SUCCESS; -} //end MuonCalibGeometryDumper::initialize - -inline bool MuonCalibGeometryDumper::dump_mdt_geometry() { - MdtTubeGeomertyRow row; - TTree * mdt_tubes=new TTree("mdt_tubes", "mdt tubes"); - mdt_tubes->Branch("id", &row.tube_id, "id/i"); - mdt_tubes->Branch("pos_x", &row.pos_x, "pos_x/F"); - mdt_tubes->Branch("pos_y", &row.pos_y, "pos_y/F"); - mdt_tubes->Branch("pos_z", &row.pos_z, "pos_z/F"); - MdtStationGeometryRow station_row; - UInt_t station_id; - TTree * mdt_station = new TTree ("mdt_station", "mdt station"); - mdt_station->Branch("id", &station_id, "id/i"); - station_row.CreateBranches(mdt_station); -//loop on chambers - MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin(); - MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end(); - for( ; it!=it_end;++it ) { - const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(*it,1,1,1)); - if(!detEl) continue; - station_row.ReadHepTransform(detEl->AmdbLRSToGlobalTransform()); - MuonFixedId fixed_id(m_id_tool->idToFixedId(*it)); - station_id=fixed_id.mdtChamberId().getIdInt(); - mdt_station->Fill(); - //get number of mls; - int n_mls=m_idHelperSvc->mdtIdHelper().numberOfMultilayers(*it); - //loop on multilayers - for(int ml=1; ml<=n_mls; ml++) { - const MuonGM::MdtReadoutElement *detEl_ml = m_detMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(*it,ml ,1,1)); - int n_layers=detEl_ml->getNLayers(); - for(int ly=1; ly<=n_layers; ly++) { - fillLayer(*it, detEl_ml, row, mdt_tubes, ml, ly); - } - } - } - return true; -} //end MuonCalibGeometryDumper::dump_mdt_geometry - -inline void MuonCalibGeometryDumper::fillLayer(const Identifier &ch_id, -const MuonGM::MdtReadoutElement *detEl, MdtTubeGeomertyRow &row, TTree *tree, const int &ml, const int &ly) { - int n_tubes=detEl->getNtubesperlayer(); - for(int tb=1; tb<=n_tubes; tb++) { - Identifier tid(m_idHelperSvc->mdtIdHelper().channelID(ch_id ,ml ,ly, tb)); - MuonFixedId fixed_id(m_id_tool->idToFixedId(tid)); - row.tube_id=fixed_id.getIdInt(); - Amg::Vector3D tube_pos_g=detEl->tubePos(ml, ly, tb); - Amg::Vector3D tube_pos_l=detEl->GlobalToAmdbLRSCoords(tube_pos_g); - row.pos_x=tube_pos_l.x(); - row.pos_y=tube_pos_l.y(); - row.pos_z=tube_pos_l.z(); - tree->Fill(); - } -} //end MuonCalibGeometryDumper::fillLayer - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRawdataSelector.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRawdataSelector.cxx deleted file mode 100644 index c4babaddd65b46e374364fcf24d4e3025c2f694c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRawdataSelector.cxx +++ /dev/null @@ -1,160 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/SegmentRawdataSelector.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibRawRpcHit.h" - -// MuonReadoutGeometry // -#include "MuonReadoutGeometry/MdtReadoutElement.h" - -// MuonCalib // -#include "MuonCalibITools/IIdToFixedIdTool.h" -namespace MuonCalib { - -/////////////////////////// -// SegmentRawdataSelector // -/////////////////////////// -SegmentRawdataSelector::SegmentRawdataSelector(const std::string &t, const std::string &n, const IInterface *p): - AthAlgTool(t, n, p), m_reg_sel_svc("RegionSelectionSvc", n), m_id_tool(nullptr) { - m_min_hits = 1; - declareProperty("MinHits", m_min_hits); - m_max_hits = -1; - declareProperty("MaxHits", m_max_hits); - m_adc_cut = 0; - declareProperty("AdcCut", m_adc_cut); - declareInterface< CalibSegmentPreparationTool >(this); - - m_idToFixedIdToolType = std::string("MuonCalib::IdToFixedIdTool"); - declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); - - m_idToFixedIdToolName = std::string("MuonCalib_IdToFixedIdTool"); - declareProperty("idToFixedIdToolName", m_idToFixedIdToolName); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); -} //end SegmentRawdataSelector::SegmentRawdataSelector - -//////////////// -// initialize // -//////////////// -StatusCode SegmentRawdataSelector::initialize(void) { - - ATH_CHECK(m_reg_sel_svc.retrieve()); - ATH_CHECK(m_idHelperSvc.retrieve()); - ATH_CHECK(m_DetectorManagerKey.initialize()); - ATH_CHECK(toolSvc()->retrieveTool(m_idToFixedIdToolType, m_idToFixedIdToolName, m_id_tool)); - - return StatusCode::SUCCESS; -} //end SegmentRawdataSelector::initialize - -void SegmentRawdataSelector::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> & segments) { - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return; - } - -//delete old segments - for(std::set<MuonCalibSegment *>::iterator it=m_segments.begin(); it!=m_segments.end(); it++) { - delete (*it); - } - m_segments.clear(); - segments.clear(); - double TDC_to_ns(0.78125); - const MuonCalibRawHitCollection *raw_hits(event->rawHitCollection()); -// loop over the raw hits // - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { - MuonCalibRawMdtHit *hit(*it); - //check for adc cut - if (hit->adcCount() < m_adc_cut) continue; - // get the raw hit and check whether it is in the calibration region // - if(!m_reg_sel_svc->isInRegion(hit->identify())) continue; - NtupleStationId station_identifier(hit->identify()); - station_identifier.SetMultilayer(0); - Identifier station_id = m_id_tool->fixedIdToId(hit->identify()); - const MuonGM::MdtReadoutElement *MdtRoEl = - MuonDetMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(station_id, - hit->identify().mdtMultilayer(),hit->identify().mdtTubeLayer(),hit->identify().mdtTube())); - - if (MdtRoEl==0) { - continue; - } - // create a segment if necessary // - if (segments.find(station_identifier)==segments.end()) { - Amg::Vector3D local_pos=get_raw_position(hit, raw_hits, MdtRoEl-> GlobalToAmdbLRSTransform()); - segments[station_identifier] = - new MuonCalibSegment(1.0, - local_pos, - Amg::Vector3D(0.0, 0.0, 1.0), - MdtRoEl->AmdbLRSToGlobalTransform()); - } - Amg::Vector3D hit_position=hit->localPosition(); - hit_position[0]=(segments[station_identifier]->position()[0]); - MdtCalibHitBase *MDT_calib_hit(new MdtCalibHitBase( - hit->tdcCount(),hit->adcCount(),hit->globalPosition(),hit_position)); - MDT_calib_hit->setDriftTime(TDC_to_ns*hit->tdcCount()); - MDT_calib_hit->setTubeT0(0.0); - MDT_calib_hit->setDriftRadius(0.02*TDC_to_ns*hit->tdcCount(),0.2); - MDT_calib_hit->setIdentifier(hit->identify()); - MDT_calib_hit->setDistanceToReadout(0.0); - MDT_calib_hit->setPropagationTime(0.0); - segments[station_identifier]->addHitOnTrack(MDT_calib_hit); - } - std::set<NtupleStationId> to_delte; - for(std::map<NtupleStationId, MuonCalibSegment *>::iterator it=segments.begin(); it!=segments.end(); it++) { - if((static_cast<int>(it->second->hitsOnTrack()) > m_max_hits && m_max_hits>0)|| static_cast<int>(it->second->hitsOnTrack()) < m_min_hits) { - to_delte.insert(it->first); - } else { - m_segments.insert(it->second); - } - } - for(std::set<NtupleStationId> ::iterator it=to_delte.begin(); it!=to_delte.end(); it++) { - std::map<NtupleStationId, MuonCalibSegment *>::iterator map_it(segments.find(*it)); - if(map_it!=segments.end()) { - delete map_it->second; - segments.erase(map_it); - } - } -} //end SegmentRawdataSelector::prepareSegments - -inline const Amg::Vector3D SegmentRawdataSelector::get_raw_position(const MuonCalibRawMdtHit *hit, -const MuonCalibRawHitCollection *coll, const Amg::Transform3D &global_to_local) const { - double x_pos=0.0; - int n_rpc_hits=0; - int mdt_station=hit->identify().stationName(); - int mdt_eta=hit->identify().eta(); - int mdt_phi=hit->identify().phi(); - for(MuonCalibRawHitCollection::MuonCalibRawRpcHitVecCit it = coll->rawRpcHitCollectionBegin(); it != coll->rawRpcHitCollectionEnd(); it++) { - MuonCalibRawRpcHit *rpc_hit(*it); - //check that rpc and mdt hit are in the same chamber - if(mdt_station != rpc_hit->identify().stationName() || mdt_eta != rpc_hit->identify().eta() || mdt_phi != rpc_hit->identify().phi()) { - continue; - } - //we need only phi strips - if(rpc_hit->identify().rpcMeasuresPhi() == 0) continue; - Amg::Vector3D local_strip_pos = global_to_local*rpc_hit->globalPosition(); - x_pos += local_strip_pos.x(); - n_rpc_hits++; - } - if(n_rpc_hits>0) { - x_pos /= static_cast<double>(n_rpc_hits); - } - return Amg::Vector3D(x_pos, hit->localPosition().y(), hit->localPosition().z()); -} //end SegmentRawdataSelector::get_raw_position - -} // namespace Muoncalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRecalibration.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRecalibration.cxx deleted file mode 100644 index 17b8bff28ace0240c387f9dde46f606209af088d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRecalibration.cxx +++ /dev/null @@ -1,206 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/SegmentRecalibration.h" - -//MdtCalibData -#include "MdtCalibData/BFieldCorFunc.h" -#include "MdtCalibData/IRtResolution.h" -#include "MdtCalibData/IRtRelation.h" -#include "MdtCalibData/MdtSlewCorFuncHardcoded.h" -#include "MdtCalibData/RtScaleFunction.h" - - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" -#include "MuonCalibEventBase/MuonCalibTruthCollection.h" -#include "MuonCalibEventBase/MuonCalibMdtTruthHit.h" - -//MdtCalibIOSvc -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/MdtStationT0Container.h" - -namespace MuonCalib { - -SegmentRecalibration::SegmentRecalibration(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p), -m_calib_input_svc("MdtCalibInputSvc", n) { - m_t0_switch="LEAVE"; - declareProperty("T0Switch", m_t0_switch); - m_B_corr_switch="LEAVE"; - declareProperty("BSwitch", m_B_corr_switch); - m_recalc_r_switch=false; - declareProperty("RecalcR", m_recalc_r_switch); - m_use_true_r=false; - declareProperty("UseTrueR", m_use_true_r); - m_undo_refitted_t0 = -1; - declareProperty("UndoRefittedT0", m_undo_refitted_t0); - m_time_slwing_corr_switch="FILE"; - declareProperty("TimeSlewingSwitch", m_time_slwing_corr_switch); - m_rt_scaling_switch="LEAVE"; - declareProperty("RtMultilayerScaling", m_rt_scaling_switch); - p_ts_corr_func=NULL; - m_prop_factor=1.0; - declareProperty("PrpagationFactor", m_prop_factor); - declareProperty("MdtCalibInputSvc", m_calib_input_svc); - declareInterface< CalibSegmentPreparationTool >(this); -} //end SegmentRecalibration::SegmentRecalibration - -StatusCode SegmentRecalibration::initialize(void) { - //get calibration input service - ATH_CHECK( m_calib_input_svc.retrieve() ); -//convert threefold switch settings - if(!convert_switch(m_t0_switch, m_t0_numswitch, "t0")) { - return StatusCode::FAILURE; - } - if(!convert_switch(m_B_corr_switch, m_B_corr_numswitch, "B-field")) { - return StatusCode::FAILURE; - } - if(!convert_switch(m_time_slwing_corr_switch, m_time_slwing_numswitch, "time-slewing")) { - return StatusCode::FAILURE; - } - if(!convert_switch(m_rt_scaling_switch, m_rt_scaling_numswitch, "multilayer-scaling")) { - return StatusCode::FAILURE; - } - if(m_time_slwing_numswitch==2) { - CalibFunc::ParVec pv; - p_ts_corr_func = static_cast<IMdtSlewCorFunc *>(new MdtSlewCorFuncHardcoded(pv)); - } - return StatusCode::SUCCESS; -} //end SegmentRecalibration::SegmentRecalibration - -void SegmentRecalibration::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - const MdtStationT0Container *t0(NULL); - const BFieldCorFunc *B_corr(NULL); - const IRtResolution *spat_res(NULL); - const IRtRelation *rt_relation(NULL); - for(std::map<NtupleStationId, MuonCalibSegment *>::const_iterator it= segments.begin(); it!= segments.end(); it++) { - for(unsigned int j=0; j<it->second->mdtHitsOnTrack(); j++) { - //pointer and references - MdtCalibHitBase *hit = it->second->mdtHOT()[j]; - if(m_time_slwing_numswitch>0) { - hit->setDriftTime(hit->driftTime() + hit->slewingTime()); - hit->setSlewingTime(0); - } - if(m_prop_factor!=1.0) { - float old_prop_time(hit->propagationTime()); - float new_prop_time(old_prop_time/m_prop_factor); - hit->setPropagationTime(new_prop_time); - hit->setDriftTime(hit->driftTime() + old_prop_time - new_prop_time); - } - if(m_time_slwing_numswitch==2) { - hit->setSlewingTime(p_ts_corr_func->correction( hit->driftTime(), hit->adcCount())); - hit->setDriftTime(hit->driftTime() - hit->slewingTime()); - } - if(m_rt_scaling_numswitch>0 && hit->TemperatureTime() != MdtCalibHitBase::kNoValue) { - hit->setDriftTime(hit->driftTime() + hit->TemperatureTime()); - hit->setTemperatureTime(0); - } - const MuonFixedId & id(hit->identify()); - //undo refitted t0 - if((m_undo_refitted_t0<0 && hit->segmentT0Applied()) || m_undo_refitted_t0>0) { - hit->setDriftTime(hit->driftTime() + it->second->fittedT0()); - } - //overwrite t0 correction - if(m_t0_numswitch > 0 && hit->tubeT0() != MdtCalibHitBase::kNoValue) { - hit->setDriftTime(hit->driftTime() + hit->tubeT0()); - hit->setTubeT0(0.0); - } - if(m_t0_numswitch ==2) { - //get t0 if it was not already selected for this station - if((t0=m_calib_input_svc->GetT0(id)) == NULL) { - ATH_MSG_FATAL( "No t0 correction loaded for this chamber!" ); - event = NULL; - return; - } - hit->setDriftTime(hit->driftTime() - t0->t0(id.mdtMultilayer(), id.mdtTubeLayer(), id.mdtTube())); - hit->setTubeT0(t0-> t0(id.mdtMultilayer(), id.mdtTubeLayer(), id.mdtTube())); - } - //overwrite magnetic field correction of selected - if(m_B_corr_numswitch > 0 && hit->bFieldTime() != MdtCalibHitBase::kNoValue) { - hit->setDriftTime(hit->driftTime() + hit->bFieldTime()); - } - if(m_B_corr_numswitch == 2) { - if((B_corr = m_calib_input_svc->GetBCorr(id)) == NULL) { - ATH_MSG_FATAL( "No rt relation loaded for this chamber!" ); - event=NULL; - return; - } - hit->setBFieldTime(B_corr-> correction(hit->driftTime(), hit->bFieldPara(), hit->bFieldPerp())); - hit->setDriftTime(hit->driftTime() - hit->bFieldTime()); - } - if(m_rt_scaling_numswitch==2) { - if((rt_relation = m_calib_input_svc->GetRtRelation(id)) == NULL) { - ATH_MSG_FATAL( "No rt relation loaded for this chamber! Needed for scaling!" ); - event=NULL; - return; - } - double corr_val=RtScaleFunction(hit->driftTime(), id.mdtMultilayer()==2, *rt_relation); - hit->setTemperatureTime(corr_val); - hit->setDriftTime(hit->driftTime() - corr_val); - } - - //overwrite drift radius if selected - if(m_recalc_r_switch) { - if((rt_relation = m_calib_input_svc->GetRtRelation(id)) == NULL) { - ATH_MSG_FATAL( "No rt relation loaded for this chamber!" ); - event=NULL; - return; - } - if((spat_res = m_calib_input_svc->GetResolution(id)) == NULL) { - ATH_MSG_FATAL( "No rt relation loaded for this chamber!" ); - event=NULL; - return; - } - double dt=hit->driftTime(); - hit->setDriftRadius( rt_relation->radius(dt), spat_res->resolution(dt)); - } else { - //if drift radius is not recalculated re,ove sign from radius - hit-> setDriftRadius(std::abs(hit-> driftRadius()), hit->sigmaDriftRadius()); - } - if (m_use_true_r) { - double r=9e9; - const MuonCalibTruthCollection* tk= event->calibTruthCollection(); - for(MuonCalibTruthCollection::MdtTruthVecCit t_it=tk->mdtTruthCollectionBegin(); t_it!=tk->mdtTruthCollectionEnd(); t_it++) { - const MuonCalibMdtTruthHit *thit=*t_it; - if(hit->identify() == thit->identify()) { - r=thit->driftRadius(); - break; - } - } - if(r<8e8) { - hit->setDriftRadius(std::abs(r), hit->sigmaDriftRadius()); - } else { - hit->setDriftRadius(9e9, 9e9); - } - } - } - if(m_undo_refitted_t0) { - it->second->setFittedT0(0.0); - } - } -} //end SegmentRecalibration::prepareSegments - -inline bool SegmentRecalibration::convert_switch(const std::string &s_switch, int &num_switch, const char *switchname) const { - if(s_switch=="LEAVE") { - num_switch=0; - return true; - } - if(s_switch=="UNAPPLY") { - num_switch=1; - return true; - } - if(s_switch=="FILE") { - num_switch=2; - return true; - } - ATH_MSG_FATAL( "Invalid switch setting "<<s_switch<< " for "<< switchname<<"!" ); - return false; -} //end SegmentRecalibration::convert_switch - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRefitter.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRefitter.cxx deleted file mode 100644 index cde7dd683290965be913eb1dfebfd7399ba379ef..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRefitter.cxx +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/SegmentRefitter.h" - -//MdtCalibFitters -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MdtCalibFitters/StraightPatRec.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/T0Refinement.h" - -//MdtCalibData -#include "MdtCalibData/IRtResolution.h" - -//MdtCalibIOSvc -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -//c - c++ -#include "set" -#include "iostream" - -namespace MuonCalib { - -SegmentRefitter::SegmentRefitter(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p), -m_calib_input_svc("MdtCalibInputSvc", n) { - m_curved = false; - declareProperty("Curved", m_curved); - m_t0_refine = false; - declareProperty("RefineT0", m_t0_refine); - m_refine_hit_selection = true; - declareProperty("RefineHitSelection", m_refine_hit_selection); - m_road_width = 2.0; - declareProperty("RoadWidth", m_road_width); - m_time_out = 2.0; - declareProperty("TimeOut", m_time_out); - m_min_hits=0; - declareProperty("MinSegmentHits", m_min_hits); - m_max_hits=-1; - declareProperty("MaxSegmentHits", m_max_hits); - declareProperty("MdtCalibInputSvc", m_calib_input_svc); - declareInterface< CalibSegmentPreparationTool >(this); -} - -StatusCode SegmentRefitter::initialize(void) { - if(m_t0_refine) { - p_t0_refinement = new T0Refinement(); - p_t0_refinement->setTimeOut(m_time_out); - p_t0_refinement->setRoadWidth(m_road_width); - } else { - if(m_curved) { - CurvedPatRec *cfitter=new CurvedPatRec(); - cfitter->setTimeOut(m_time_out); - p_qfitter = cfitter; - } else { - p_qfitter = new StraightPatRec(); - } - p_qfitter->setRoadWidth(m_road_width); - p_qfitter->SetRefineSegmentFlag(m_refine_hit_selection); - } - ATH_CHECK( m_calib_input_svc.retrieve() ); - return StatusCode::SUCCESS; -} //end SegmentRefitter::initialize - -void SegmentRefitter::prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - std::set<NtupleStationId> dropped_segments; - for(std::map<NtupleStationId, MuonCalibSegment *>::iterator it=segments.begin(); it!= segments.end(); it++) { - if(m_t0_refine) { - if(!refine_t0(it->second)) { - dropped_segments.insert(it->first); - } - } else { - if(!p_qfitter->fit(*it->second)) { - dropped_segments.insert(it->first); - } - } - int n_hits(static_cast<int>(it->second->hitsOnTrack())); - if((m_max_hits>0 && n_hits>m_max_hits) || n_hits<m_min_hits) { - dropped_segments.insert(it->first); - } - } - for(std::set<NtupleStationId>::iterator it=dropped_segments.begin(); it!=dropped_segments.end(); it++) { - std::map<NtupleStationId, MuonCalibSegment *>::iterator map_it(segments.find(*it)); - if(map_it!=segments.end()) { - segments.erase(map_it); - } - } -} //end SegmentRefitter::prepareSegments - -inline bool SegmentRefitter::refine_t0(MuonCalibSegment *&segment) { - double err; - bool failed; - p_t0_refinement->setRoadWidth(1.25*m_road_width); - p_t0_refinement->getDeltaT0(segment, m_calib_input_svc->GetRtRelation(segment->mdtHOT()[0]->identify()), true, err, failed, m_curved); - if (failed) return false; - p_t0_refinement->setRoadWidth(m_road_width); - p_t0_refinement->getDeltaT0(segment, m_calib_input_svc->GetRtRelation(segment->mdtHOT()[0]->identify()), true, err, failed, m_curved); - if (failed) return false; - for (unsigned int h=0; h<segment->mdtHitsOnTrack(); h++) { - const IRtResolution *resol( m_calib_input_svc->GetResolution( segment->mdtHOT()[h]->identify())); - double radius(segment->mdtHOT()[h]->driftRadius()); - segment->mdtHOT()[h]->setDriftRadius(radius, resol->resolution(segment->mdtHOT()[h]->driftTime())); - } - return true; -} //end SegmentRefitter::refine_t0 - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRegionSelector.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRegionSelector.cxx deleted file mode 100644 index 00e7465529c70247211ed6c298b4e50656ebd6d3..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRegionSelector.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/SegmentRegionSelector.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" - -namespace MuonCalib { - -/////////////////////////// -// SegmentRegionSelector // -/////////////////////////// -SegmentRegionSelector::SegmentRegionSelector(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p), -m_reg_sel_svc("RegionSelectionSvc", n) { - m_exclusive_segments = false; - declareProperty("ExclusiveSegments", m_exclusive_segments); - m_min_hits = 1; - declareProperty("MinHits", m_min_hits); - m_max_hits = 0; - declareProperty("MaxHits", m_max_hits); - m_select_seg_author = 4; - declareProperty("SelectSegmentAuthor", m_select_seg_author); - m_adc_cut = 0; - declareProperty("AdcCut", m_adc_cut); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - declareInterface< CalibSegmentPreparationTool >(this); -} - -//////////////// -// initialize // -//////////////// -StatusCode SegmentRegionSelector::initialize(void) { - ATH_CHECK( m_reg_sel_svc.retrieve() ); - return StatusCode :: SUCCESS; -} - -void SegmentRegionSelector::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - segments.clear(); - std::vector<unsigned int> calib_region_hit_map; -//---------------------loop on all patterns------------------------------------- - MuonCalibEvent::MCPVecCit pat_it = event->patternBegin(); - MuonCalibEvent::MCPVecCit pat_it_end = event->patternEnd(); - for( ;pat_it!=pat_it_end; ++pat_it) { -//--------------------loop on all segemnts-------------------------------------- - MuonCalibPattern::MuonSegmentVec::const_iterator seg_it = (*pat_it)->muonSegBegin(); - MuonCalibPattern::MuonSegmentVec::const_iterator seg_it_end = (*pat_it)->muonSegEnd(); - for ( ; seg_it!=seg_it_end; ++seg_it) { - MuonCalibSegment *seg = *seg_it; - if(m_select_seg_author>0 && seg->author()>0) - if (m_select_seg_author != seg->author()) - continue; - //check count hits in the calibration region and remove others - calib_region_hit_map.clear(); - bool reject(false); - int count(0); - for(MuonCalibSegment::MdtHitCit hit_it=seg->mdtHOTBegin(); hit_it!=seg->mdtHOTEnd(); hit_it++) { - unsigned int is_in_region(static_cast<unsigned int>(!m_reg_sel_svc->isInRegion((*hit_it)->identify())));// || m_suppressed_tubes.find((*hit_it)->identify())!=m_suppressed_tubes.end())); - if(is_in_region!=0 && m_exclusive_segments) { - reject=true; - break; - } - if((*hit_it)->adcCount()<m_adc_cut) is_in_region=1; - calib_region_hit_map.push_back(is_in_region); - if(is_in_region==0) count++; - } - if(reject) continue; - if(count<m_min_hits || (count>m_max_hits && m_max_hits>0)) continue; - if(count==0) continue; - seg->refineMdtSelection(calib_region_hit_map); - NtupleStationId id(seg->mdtHOT()[0]->identify()); - id.SetMultilayer(0); - //store segment if it is the first in the station - if(segments[id] == NULL) { - segments[id] = seg; - continue; - } - //overwrite segment if this has more hits than the stored segment - MuonCalibSegment *stored(segments[id]); - if(stored->mdtHitsOnTrack() < seg->mdtHitsOnTrack()) { - segments[id] = seg; - continue; - } - if(stored->mdtHitsOnTrack() > seg->mdtHitsOnTrack()) { - continue; - } - //overwrite segment if the new one has a better chi^2 - if(stored->chi2() > seg->chi2()) { - segments[id] = seg; - } - } - } -} //end SegmentRegionSelector::prepareSegments - -} // namespace Muoncalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/UpdateBField.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/UpdateBField.cxx deleted file mode 100644 index 2819ec2108b069c4ee4a149729cf50550eda24df..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/UpdateBField.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CalibNtupleAnalysisAlg/UpdateBField.h" -#include <TString.h> // for Form - -namespace MuonCalib { - -UpdateBField::UpdateBField(const std::string &t, const std::string &n, const IInterface *p) : - AthAlgTool(t, n, p) { - declareInterface< CalibSegmentPreparationTool >(this); -} - -StatusCode UpdateBField::initialize() { - ATH_CHECK(AthAlgTool::initialize()); - ATH_CHECK(m_fieldCondObjInputKey.initialize()); - return StatusCode::SUCCESS; -} - -void UpdateBField::prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - /// magnetic field - MagField::AtlasFieldCache fieldCache; - SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCondObjInputKey, Gaudi::Hive::currentContext()}; - const AtlasFieldCacheCondObj* fieldCondObj{*readHandle}; - if (!fieldCondObj) { - throw std::runtime_error(Form("File: %s, Line: %d\nUpdateBField::prepareSegments() - Failed to retrieve AtlasFieldCacheCondObj with key %s", __FILE__, __LINE__, (m_fieldCondObjInputKey.key()).c_str())); - } - fieldCondObj->getInitializedCache(fieldCache); - - for(std::map<NtupleStationId, MuonCalibSegment *>::iterator it = segments.begin(); it!=segments.end(); it++) { - for(unsigned int j=0; j<it->second->mdtHitsOnTrack(); j++) { - MdtCalibHitBase *hit = it->second->mdtHOT()[j]; - Amg::Transform3D gToStation= it->second->localToGlobal().inverse(); - double XYZ[3], BGXYZ[3]; - XYZ[0] = hit->globalPosition().x(); - XYZ[1] = hit->globalPosition().y(); - XYZ[2] = hit->globalPosition().z(); - fieldCache.getField(XYZ,BGXYZ); - Amg::Vector3D B_global(BGXYZ[0], BGXYZ[1], BGXYZ[2]); - Amg::Vector3D B_loc(gToStation.linear()*B_global); - hit->setBFieldPara(B_loc.x()); - Amg::Vector3D dir(0.0, - it->second->direction().y(), - it->second->direction().z()); - hit->setBFieldPerp(B_loc. dot(dir.unit())); - } - } -} //end UpdateBField::prepareSegments - -}//namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/WriteMdtGeometry.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/WriteMdtGeometry.cxx deleted file mode 100644 index b9c5d46331695a98b6ff31c2c30e5181ae61be64..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/WriteMdtGeometry.cxx +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "CalibNtupleAnalysisAlg/WriteMdtGeometry.h" - -//coral -#include "RelationalAccess/IRelationalService.h" -#include "RelationalAccess/IConnectionService.h" -#include "RelationalAccess/ConnectionService.h" -#include "RelationalAccess/ISessionProxy.h" -#include "RelationalAccess/IRelationalDomain.h" -#include "RelationalAccess/ITransaction.h" -#include "RelationalAccess/IQuery.h" - -#include "RelationalAccess/ISchema.h" -#include "RelationalAccess/ICursor.h" -#include "RelationalAccess/ITable.h" -#include "RelationalAccess/ITableDataEditor.h" -#include "RelationalAccess/IAuthenticationService.h" -#include "RelationalAccess/IAuthenticationCredentials.h" -#include "RelationalAccess/SchemaException.h" -#include "CoralBase/AttributeList.h" -#include "CoralBase/Attribute.h" -#include "CoralBase/AttributeSpecification.h" -#include "CoralKernel/Context.h" - -#include <stdexcept> - -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -#include "MuonCalibIdentifier/MuonFixedId.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" - -namespace MuonCalib { - -WriteMdtGeometry::WriteMdtGeometry(const std::string &name, ISvcLocator *pSvcLocator) : - AthAlgorithm(name, pSvcLocator), - m_context( &coral::Context::instance() ), - m_idToFixedIdToolType("MuonCalib::IdToFixedIdTool"), - m_idToFixedIdToolName("MuonCalib_IdToFixedIdTool"), - m_session(nullptr), - m_detMgr(nullptr), - m_id_tool(nullptr) { - - declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); - declareProperty("idToFixedIdToolName", m_idToFixedIdToolName); - declareProperty("ConnectionString", m_connectionString); - declareProperty("WorkingSchema", m_WorkingSchema); - -} //end WriteMdtGeometry::WriteMdtGeometry - -StatusCode WriteMdtGeometry::initialize() { - ATH_CHECK(m_idHelperSvc.retrieve()); - ATH_CHECK(detStore()->retrieve(m_detMgr)); - ATH_CHECK(toolSvc()->retrieveTool(m_idToFixedIdToolType, m_idToFixedIdToolName, m_id_tool)); - - loadServices(); - - try { - OpenConnection(); - coral::ITableDataEditor &editor = m_session->nominalSchema().tableHandle("MDT_CHAMBER").dataEditor(); - if (!fill_db(editor)) { - CloseConnection(false); - return StatusCode::FAILURE; - } - CloseConnection(true); - } - catch ( coral::SchemaException &e ) { - ATH_MSG_ERROR( "Schema exception : " << e.what() ); - CloseConnection(false); - return StatusCode::FAILURE; - } - ATH_MSG_INFO( "Initialisation done!" ); - return StatusCode::SUCCESS; -} //end WriteMdtGeometry::initialize - -void WriteMdtGeometry::loadServices() { - coral::IHandle<coral::IConnectionService> lookSvcH = m_context->query<coral::IConnectionService>(); - if (!lookSvcH.isValid()) { - m_context->loadComponent( "CORAL/Services/ConnectionService" ); - lookSvcH = m_context->query<coral::IConnectionService>(); - } - if (!lookSvcH.isValid()) { - throw std::runtime_error( "Could not locate the connection service" ); - } - m_context->loadComponent( "CORAL/Services/XMLAuthenticationService" ); - m_context->loadComponent( "CORAL/Services/RelationalService" ); -} //end WriteMdtGeometry::loadServices - -inline bool WriteMdtGeometry::fill_db(coral::ITableDataEditor &editor) { - ATH_MSG_INFO( "Filling db" ); - coral::AttributeList rowBuffer; - rowBuffer.extend<int>("CHAMBER"); - rowBuffer.extend<int>("LY"); - rowBuffer.extend<int>("ML"); - rowBuffer.extend<int>("N_TUBES"); - rowBuffer.extend<float>("LOC_Y"); - rowBuffer.extend<float>("LOC_Z"); - rowBuffer.extend<float>("Y_SPACING"); - //loop on chambers - MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin(); - MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end(); - for( ; it!=it_end;++it ) { - const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(*it,1,1,1)); - if(!detEl) continue; - //get number of mls; - int n_mls=m_idHelperSvc->mdtIdHelper().numberOfMultilayers(*it); - //fixed id - MuonFixedId fixed_id(m_id_tool->idToFixedId(*it)); - rowBuffer["CHAMBER"].data<int>() = fixed_id.mdtChamberId().getIdInt(); - //loop on multilayers - for(int ml=1; ml<=n_mls; ml++) { - rowBuffer["ML"].data<int>()=ml; - const MuonGM::MdtReadoutElement *detEl_ml = m_detMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(*it,ml ,1,1)); - int n_layers=detEl_ml->getNLayers(); - int n_tubes=detEl_ml->getNtubesperlayer(); - rowBuffer["N_TUBES"].data<int>()=n_tubes; - for(int ly=1; ly<=n_layers; ly++) { - rowBuffer["LY"].data<int>()=ly; - fillLayer(detEl_ml, rowBuffer, ml, ly); - editor.insertRow(rowBuffer); - } - } - } - return true; -} //end WriteMdtGeometry::fill_db - -inline void WriteMdtGeometry::fillLayer(const MuonGM::MdtReadoutElement *detEl, coral::AttributeList &rowBuffer, const int &ml, const int &ly) { - Amg::Vector3D TubePos1 = detEl->GlobalToAmdbLRSCoords(detEl->tubePos(ml,ly,1)); - Amg::Vector3D TubePos2 = detEl->GlobalToAmdbLRSCoords(detEl->tubePos(ml,ly,2)); - rowBuffer["LOC_Y"].data<float>()=TubePos1.y(); - rowBuffer["LOC_Z"].data<float>()=TubePos1.z(); - rowBuffer["Y_SPACING"].data<float>()=TubePos2.y() - TubePos1.y(); -} //end WriteMdtGeometry::fillLayer - -void WriteMdtGeometry::OpenConnection() { - coral::ConnectionService connSvc; - m_session = connSvc.connect( m_connectionString ); -} - -void WriteMdtGeometry::CloseConnection(bool commit) { - if(m_session != NULL) { - if(commit) - m_session->transaction().commit(); - else - m_session->transaction().rollback(); - } - m_session=NULL; -} - -coral::IRelationalDomain& WriteMdtGeometry::domain( const std::string &connectionString ) { - coral::IHandle<coral::IRelationalService> relationalService= m_context->query<coral::IRelationalService>(); - if ( !relationalService.isValid() ) { - throw std::runtime_error( "Could not locate the relational service" ); - } - if(connectionString.find("sqlite")!=0) { - coral::IHandle<coral::IAuthenticationService> authenticationService= m_context->query<coral::IAuthenticationService>(); - if ( !authenticationService.isValid() ) { - throw std::runtime_error( "Could not locate the authentication service" ); - } - - const coral::IAuthenticationCredentials &credentials = authenticationService->credentials( connectionString ); - m_username = credentials.valueForItem( "user" ); - m_password = credentials.valueForItem( "password" ); - } else { - m_username=""; - m_password=""; - } - return relationalService->domainForConnection( connectionString ); -} //end WriteMdtGeometry::domain - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/components/CalibNtupleAnalysisAlg_entries.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/components/CalibNtupleAnalysisAlg_entries.cxx deleted file mode 100644 index 62d3acb077fcad0fa5d783ecbc700f7fe9172d47..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/components/CalibNtupleAnalysisAlg_entries.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg2.h" -#include "CalibNtupleAnalysisAlg/BarrelSecondCoordinatePreparationTool.h" -#include "CalibNtupleAnalysisAlg/BFieldCorrectionUpdateTool.h" -#include "CalibNtupleAnalysisAlg/WriteMdtGeometry.h" -#include "CalibNtupleAnalysisAlg/UpdateBField.h" -#include "CalibNtupleAnalysisAlg/CalibNtupleLoader.h" -#include "CalibNtupleAnalysisAlg/SegmentRegionSelector.h" -#include "CalibNtupleAnalysisAlg/SegmentRawdataSelector.h" -#include "CalibNtupleAnalysisAlg/SegmentRecalibration.h" -#include "CalibNtupleAnalysisAlg/SegmentRefitter.h" -#include "CalibNtupleAnalysisAlg/InitialDqFilter.h" -#include "CalibNtupleAnalysisAlg/ApplyRawTimes.h" -#include "CalibNtupleAnalysisAlg/GoodRunListFilter.h" -#include "CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h" - -using namespace MuonCalib; - -DECLARE_COMPONENT( CalibNtupleAnalysisAlg2 ) -DECLARE_COMPONENT( WriteMdtGeometry ) -DECLARE_COMPONENT( MuonCalibGeometryDumper ) -DECLARE_COMPONENT( BarrelSecondCoordinatePreparationTool ) -DECLARE_COMPONENT( BFieldCorrectionUpdateTool ) -DECLARE_COMPONENT( UpdateBField ) -DECLARE_COMPONENT( CalibNtupleLoader ) -DECLARE_COMPONENT( SegmentRegionSelector ) -DECLARE_COMPONENT( SegmentRawdataSelector ) -DECLARE_COMPONENT( SegmentRecalibration ) -DECLARE_COMPONENT( InitialDqFilter ) -DECLARE_COMPONENT( SegmentRefitter ) -DECLARE_COMPONENT( ApplyRawTimes ) -DECLARE_COMPONENT( GoodRunListFilter ) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/CMakeLists.txt deleted file mode 100644 index 8157722ec6a954a2057a70da3594f66c6e895e1f..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -################################################################################ -# Package: MuonCalibStandAloneExtraTools -################################################################################ - -# Declare the package name: -atlas_subdir( MuonCalibStandAloneExtraTools ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - GaudiKernel - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibFitters - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibUtils - MuonSpectrometer/MuonCalib/MuonCalibEventBase - MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeEvent - MuonSpectrometer/MuonCalib/MuonCalibIdentifier - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase - PRIVATE - Control/StoreGate - DetectorDescription/Identifier - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibInterfaces - MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraNtuple - MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg - MuonSpectrometer/MuonCalib/MuonCalibITools - MuonSpectrometer/MuonCalib/MuonCalibNtuple - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleUtils - MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry - MuonSpectrometer/MuonIdHelpers ) - -# External dependencies: -find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread MathMore Minuit Minuit2 Matrix Physics HistPainter Rint Graf Graf3d Gpad Html Postscript Gui GX11TTF GX11 ) - -# Component(s) in the package: -atlas_add_library( MuonCalibStandAloneExtraToolsLib - src/*.cxx - PUBLIC_HEADERS MuonCalibStandAloneExtraTools - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel MdtCalibData MdtCalibFitters MdtCalibUtils MuonCalibEventBase MuonCalibExtraTreeEvent MuonCalibIdentifier MdtCalibIOSvcLib MuonCalibStandAloneBaseLib StoreGateLib SGtests MuonCalibExtraTreeAlgLib MuonIdHelpersLib - PRIVATE_LINK_LIBRARIES Identifier MuonCalibExtraNtuple MuonCalibITools MuonCalibNtuple CalibNtupleUtils MuonReadoutGeometry ) - -atlas_add_component( MuonCalibStandAloneExtraTools - src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel MdtCalibData MdtCalibFitters MdtCalibUtils MuonCalibEventBase MuonCalibExtraTreeEvent MuonCalibIdentifier MdtCalibIOSvcLib MuonCalibStandAloneBaseLib StoreGateLib SGtests Identifier MuonCalibExtraNtuple MuonCalibExtraTreeAlgLib MuonCalibITools MuonCalibNtuple CalibNtupleUtils MuonReadoutGeometry MuonIdHelpersLib MuonCalibStandAloneExtraToolsLib ) - -# Install files from the package: -atlas_install_python_modules( python/*.py ) - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/CalibExtraNtupleLoader.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/CalibExtraNtupleLoader.h deleted file mode 100644 index 5691b050e5cc65742cd7233c84697bb90cc10d63..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/CalibExtraNtupleLoader.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_CalibExtraNtupleLoader_h -#define MuonCalib_CalibExtraNtupleLoader_h - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -//c - c++ -#include "string" - -class RegionSelectionSvc; -class TChain; - -namespace MuonCalib { - -class NTReader_E; - -//load events from CalibrationNtuple - -class CalibExtraNtupleLoader: public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - CalibExtraNtupleLoader(const std::string &t, const std::string &n, const IInterface *p); - ~CalibExtraNtupleLoader()=default; -//=========================public member functions============================== - StatusCode initialize(void); - - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //!path to the file list - job option - std::string m_filelist; - //! type of ntuple - AUTO/NORMAL/REGION - //! NOTE: Do not use auto if you are directly reading ntuples from castor or dcache. - //! In this case all files have to be opened at initialisation. - std::string m_ntuple_type; - int m_ntuple_type_num; - //! first event - jobOption - int m_first; - //! last event - jobOption - int m_last; - //! ntuple reader - NTReader_E *m_reader; - //! pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - //! ntuple chain - TChain *m_chain; -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelector.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelector.h deleted file mode 100644 index 48570352cc6a687aa23e69a88df01ea80815f66b..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelector.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_ExtraRegionSelector_h -#define MuonCalib_ExtraRegionSelector_h - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -//MuonCalibExtraTreeEvent -#include "MuonCalibExtraTreeEvent/EventHandler.h" - -class RegionSelectionSvc; - -class TFile; -class TH1F; - -namespace MuonCalib { - -class MuonCalibSegment; - -class ExtraRegionSelector : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - ExtraRegionSelector(const std::string & t, const std::string & n, const IInterface *p); - inline ~ExtraRegionSelector() {} -//=========================public member functions============================== - //initialize and finalize - StatusCode initialize(void); - StatusCode finalize(void); - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //if set to true, segments wich are not completely in the selected calibration region will be dropped - job options - bool m_exclusive_segments; - //if true select muonboy tracks, else moore - bool m_muonboy; - //minimum and maximum number of segment hits - int m_min_hits, m_max_hits; - //select segment author - int m_select_seg_author; - //momentum cut - float m_momentum_cut; - //if set to true, an debug root file is created - bool m_do_debug_file; - //! pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - //track author id; - int m_track_author_id; - //Event handler for generating ExtraEvents - EventHandler m_evt_handler; - inline void process_segment(MuonCalibSegment *seg); //debug root file - TFile *m_debug_file; - TH1F *m_all_p; - TH1F *m_selected_p_by_track; - TH1F *m_selected_p_by_segment; - -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelectorFast.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelectorFast.h deleted file mode 100644 index 5fc899503c10d21e0eddfe0f279e0e654bec080e..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelectorFast.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_ExtraRegionSelectorFast_h -#define MuonCalib_ExtraRegionSelectorFast_h - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -#include "set" -#include "list" - -class RegionSelectionSvc; - -class TFile; -class TH1F; -class TH2F; - -namespace MuonCalib { - -class MuonCalibSegment; -class MuonFixedId; - -class ExtraRegionSelectorFast : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - ExtraRegionSelectorFast(const std::string &t, const std::string &n, const IInterface *p); - inline ~ExtraRegionSelectorFast() {} -//=========================public member functions============================== - //initialize and finalize - StatusCode initialize(void); - StatusCode finalize(void); - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //if set to true, segments wich are not completely in the selected calibration region will be dropped - job options - bool m_exclusive_segments; - //minimum and maximum number of segment hits - int m_min_hits, m_max_hits; - //select segment author - std::set<int> m_track_author; - std::vector<int> m_track_author_vec; - int m_select_seg_author; - //momentum cut - float m_momentum_cut; - //minimum number of segment hits on track - int m_min_hits_on_track; - //maximum number of hits not on track - int m_max_hits_not_on_track; - //if set to true, an debug root file is created - bool m_do_debug_file; - //! pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - //track author id; - int m_track_author_id; - //Event handler for generating ExtraEvents - inline void process_segment(MuonCalibSegment *seg); //debug root file - TFile *m_debug_file; - TH1F *m_all_p; - TH1F *m_selected_p_by_track; - TH1F *m_selected_p_by_segment; - TH2F *m_n_match_vs_missing; - inline bool isOnTrack(const MuonCalibSegment &seg, const std::list<std::set<MuonFixedId> > &track_hits); -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelectorSuperFast.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelectorSuperFast.h deleted file mode 100644 index 51064dade9f87b188594e931d9734c07839f1c30..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/ExtraRegionSelectorSuperFast.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_ExtraRegionSelectorSuperFast_h -#define MuonCalib_ExtraRegionSelectorSuperFast_h - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -#include "set" -#include "list" - -class RegionSelectionSvc; - -class TFile; -class TH1F; -class TH2F; - -namespace MuonCalib { - -class MuonCalibSegment; -class MuonFixedId; - -class ExtraRegionSelectorSuperFast : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - ExtraRegionSelectorSuperFast(const std::string &t, const std::string &n, const IInterface *p); - inline ~ExtraRegionSelectorSuperFast() {} -//=========================public member functions============================== - //initialize and finalize - StatusCode initialize(void); - StatusCode finalize(void); - //load event - void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: - //=========================private data========================================= - //if set to true, segments wich are not completely in the selected calibration region will be dropped - job options - bool m_exclusive_segments; - //minimum and maximum number of segment hits - int m_min_hits, m_max_hits; - //select segment author - std::set<int> m_track_author; - std::vector<int> m_track_author_vec; - //momentum cut - float m_momentum_cut; - //if set to true, an debug root file is created - bool m_do_debug_file; - //! pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - //Event handler for generating ExtraEvents - inline void process_segment(MuonCalibSegment *seg); //debug root file - TFile *m_debug_file; - TH1F *m_all_p; - TH1F *m_selected_p_by_track; - TH1F *m_selected_p_by_segment; - TH2F *m_n_match_vs_missing; -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/HistogramManager.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/HistogramManager.h deleted file mode 100644 index df57373bb447c3311a1e5531331774be2c90a1ad..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/HistogramManager.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SRC_HISTOGRAMMANAGER_H -#define SRC_HISTOGRAMMANAGER_H - -#include <string.h> -#include <stdio.h> - -#include <sstream> -#include <iostream> -#include <fstream> - -#include <TFile.h> -#include <TString.h> -#include <vector> -#include "TH1.h" -#include "TH2.h" -#include "TH3.h" -#include "TObjArray.h" - -#include "MuonCalibStandAloneExtraTools/StringUtil.h" -#include "MuonCalibStandAloneExtraTools/MDTName.h" -#include "MuonIdHelpers/MdtIdHelper.h" - -#define UPDATETIME 2000 - -class MdtChamber { -public: - std::string m_region; - std::string m_side; - int m_sector; - int m_absEta; - int m_eta_id; - int m_phi_id; - std::string m_chamberType; - std::string m_chamberName; - std::string m_athenaChamberName; - - void Fill(std::string region, std::string side, int sector, std::string chamberType, int absEta_id) { - ToString ts; - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - m_region = region; - m_side = side; - m_sector = sector; - m_chamberType = chamberType; - m_absEta = absEta_id; - int eta_id = absEta_id; - if (side=="C") eta_id = -absEta_id; - m_eta_id = eta_id; - int phi_id = (int) (sector+1)/2; - m_phi_id = phi_id; - std::string chName = chamberType+ts(absEta_id)+side+sectorString; - m_chamberName = chName; - std::string chAthenaName = chamberType+"_"+ts(phi_id)+"_"+ts(eta_id); - m_athenaChamberName = chAthenaName; - return; - } -}; - -struct sortMdtChambersByName { - bool operator()(MuonCalib::MDTName a ,MuonCalib::MDTName b) { - std::string t1=a.getOnlineName(); - std::string t2=b.getOnlineName(); - return (t1 < t2); - } -}; - -class HistogramManager { -public: - HistogramManager(); - HistogramManager(const Muon::IMuonIdHelperSvc *idHelper); - ~HistogramManager()=default; - void buildGlobalHistos(); - void buildTrackHistos(); - void buildDebugHistos(); - void buildTopLevel(std::string region, std::string side, int sectorMin, int sectorMax); - void buildSector(std::string region,std::string side, int sector); - void buildChamberHistos(MuonCalib::MDTName); - - void setChamberCutOut(std::string chamber, TH1F *href ); - void setChamberDisconnectedTubes(std::string chamber, TH1F *href ); - int GetTubeOffsetML1(std::string chamberName); - int GetTubeOffsetAtEndML1(std::string chamberName); - - std::vector<MuonCalib::MDTName> GetChamberList(std::string region, std::string side, int sector); - - bool openOutputFile(std::string filename); - bool openReadOnlyFile(std::string filename); - bool openUpdateFile(std::string filename); - void WriteAndCloseFile(); - - void SetDoTracks(bool); - - TObject * GetMdtHisto(std::string histo_name); - TObject * GetMdtHisto(std::string histo_name, std::string region, std::string side); - TObject * GetMdtHisto(std::string histo_name, std::string region, std::string side, int sector); - TObject * GetMdtHisto(std::string histo_name, MuonCalib::MDTName); - - std::string GetMdtDirectoryName(); - std::string GetMdtDirectoryName(std::string region, std::string side); - std::string GetMdtDirectoryName(std::string region, std::string side, int sector); - std::string GetMdtDirectoryName(std::string region, std::string side, int sector, std::string chamberType, int eta); - std::string GetMdtDirectoryName(MuonCalib::MDTName); - - TObject * GetTDaqHisto(std::string histo_name, std::string region); - TObject * GetTDaqHisto(std::string histo_name, std::string region, std::string side); - TObject * GetTDaqHisto(std::string histo_name, std::string region, std::string side, int sector); - TObject * GetTDaqHisto(std::string histo_name, std::string region, std::string side, int sector, std::string chamberType, int eta); - - std::string GetTDaqDirectoryName(std::string region); - std::string GetTDaqDirectoryName(std::string region, std::string side); - std::string GetTDaqDirectoryName(std::string region, std::string side, int sector); - std::string GetTDaqDirectoryName(std::string region, std::string side, int sector, std::string chamberType, int eta); - - TObject* GetHisto(std::string main_dir, std::string histo_name); - - void ReadChamberMapFile (std::string chamberName, int *chamberGeoParams, int numParams); - int GetChamberNumOfML (std::string chamberName); - int GetChamberNumOfMezzPerML (std::string chamberName); - int GetChamberTubesPerMezz (std::string chamberName); - - int GetEtaMax(std::string region, std::string side, int sector, std::string chamberType); - - TFile* rootFile(){return m_rootfile;}; - TFile *m_rootfile; - - private: - TObjArray m_hList; - const MdtIdHelper* m_mdtIdHelper; - - bool m_doTracks; - -}; - -#endif //SRC_HISTOMANAGER_H - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTDeadElementsAnalysis.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTDeadElementsAnalysis.h deleted file mode 100644 index a6e2fe68f315fc441d9ab9c0a2ed2483908bc157..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTDeadElementsAnalysis.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SRC_MDTTUBEANA_H -#define SRC_MDTTUBEANA_H - -#include <string> -#include <stdio.h> -#include <vector> -#include "RtypesCore.h" // for Double_t etc. - -class TH1; -class TH1I; -class TH1F; -class TF1; -class TFile; -class TString; - -static const int nmmax=100; -static const int ntmax=600; -Double_t polnml3(Double_t *x, Double_t *parf); -double completefunc(double *x, double *parf); -class MDTDeadElementsAnalysis { - public: - MDTDeadElementsAnalysis(); - ~MDTDeadElementsAnalysis()=default; - - TF1 *polfunc ; - std::string chamberName; - TH1I *deadTubesMap; - TH1I *geo; - // static const int nmmax=20; - int ndeadmezz; - double deadmezz[nmmax]; - double deadmezzMLay[nmmax]; - - std::vector<TString> noisyChamber; - - std::vector<TString> deadChamber; - - std::vector<int> deadLayer; - std::vector<TString> deadLayerChamber; - - std::vector<int> deadMultilayer; - std::vector<TString> deadMLChamber; - std::vector<double> deadMLCounts; - std::vector<double> deadMLLevel; - - std::vector<int> deadMezz; - std::vector<int> deadMezz_red; - std::vector<int> deadMezz_csm; - std::vector<TString> deadMezzChamber; - std::vector<int> deadMezzML; - std::vector<double> deadMezzEffi; - std::vector<double> deadMezzErrEffi; - std::vector<double> deadMezzChi2; - - std::vector<TString> deadTubeChamber; - std::vector<int> deadTube; - std::vector<int> deadTubeId; - std::vector<double> deadTubeHistoBin; - std::vector<int> deadTubeLay; - std::vector<int> deadTubeML; - std::vector<double> deadTubeChi2; - std::vector<double> deadTubeEffi; - std::vector<double> deadTubeErrEffi; - - int ndeadtubes; - - int position_spikes[ntmax]; - double deadtube[ntmax]; - double deadtubeseed[ntmax]; - double deadtubeLay[ntmax]; - double deadtubeML[ntmax]; - double deadtubelen[ntmax]; - double deadtubechi2[ntmax]; - double deadtubeeffi[ntmax]; - double deadtubeerr[ntmax]; - double deadtubestat[ntmax][3]; - - bool verbose; - bool drawPlots; - bool writeResultsToAsciFile; - - bool deadMezzDone; - bool deadTubesDone; - bool deadMultilayerDone; - - void histogramScanGnam(std::string rootfile); - void histogramScanCalibCenters(TFile * rootfile); - void getBasicGeometry(TH1F* geo, std::string chambname); - void getBasicGeometry(TH1F* geo, int nlayers_ml, std::string chambname); - void deadElementsAnalysis(TH1F* idh1, TH1F* geo, TH1F* deadTubesMap, int nlayers_ml, std::string chambname); - void deadElementsAnalysis(TH1F* idh1, TH1F* geo, TH1F* deadTubesMap, int nlayers_ml, - std::string chambname, int convert_mezzanine[20]); - void deadChambers(TH1F* idh1, TH1F* HRef, TH1F* deadTubesMap, std::string chambname); - void deadLayers(TH1F* idh1,TH1F* HRef, TH1F* deadTubesMap, std::string chambname); - void Clear(int ntubes); - void ClearList(); - void deadTubes(TH1F *idh1 , TH1F* HRef, TH1F* deadTubesMap, std::string chambername); - void getAverageLevelInInterval(TH1F*, int firsttube, int lasttube); - void getSpikesInInterval(TH1F*, int firsttube, int lasttube, TF1 *polfunc); - void getHolesInInterval(TH1F*, int firsttube, int lasttube, int ntubes, TF1 *polfunc); - void getHolesInInterval_strategy5(TH1F*, int firsttube, int lasttube, int ntubes, TF1 *polfunc); - std::string validateDeadTubes(double chi2cut, TH1F* HRef, TH1F* deadTubesMap, std::string chambname); - void deadMezzanines(TH1F *idh1, TH1F* HRef, TH1F* deadTubesMap, std::string chambername); - void deadMezzanines(TH1F *idh1, TH1F* HRef, TH1F* deadTubesMap, - std::string chambernamee, int convert_mezzanine[20]); - void deadMultilayers(TH1F *idh1 , TH1F* HRef, TH1F* deadTubesMap, std::string chambername); - bool NoisyChamber(TH1F *idh1, std::string chambername); - void setVerbose(); - void setNoVerbose(); - void setChamberName(std::string chambname); - std::string getChamberName(); - void printSummary(); - void printSummaryToAsciFile(); - void printCompactSummaryToAsciFile(); - void WriteAsciFile(); - - // Basic chamber geometry - std::string schamber; - std::string chtype; - int nlayers; - int nbins_per_layer[2]; - int nlayers_per_ml; - int ntubes[2]; - double tstep[2]; - int nmezz[2]; - int ntubes_per_mezz; - int firstbinML[2]; - int lastbinML[2]; - double chi2poly; - double polyparf[4]; - double average_entry; - double n_entry; - int holes[100]; - int nholes; - double eff_hole[100]; - int position_holes[1000]; -}; //MDTDeadElementsAnalysis - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTDqaDeadElements.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTDqaDeadElements.h deleted file mode 100644 index 4d7590a3c9a97a51a02666d19af574cca4afc7a5..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTDqaDeadElements.h +++ /dev/null @@ -1,287 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//Author Marco Vanadia mvanadia@cern.ch -//Class based on algorithms introduced by Philipp Fleischmann in GnaMon - -#ifndef MUONCALIBSTANDALONEEXTRATOOLS_MDTDQADEADELEMENTS_H -#define MUONCALIBSTANDALONEEXTRATOOLS_MDTDQADEADELEMENTS_H - - -#include <cmath> -#include <iostream> -#include <algorithm> -#include <fstream> -#include <TFile.h> -#include <TH1.h> -#include <TH2.h> -#include <TKey.h> -#include <vector> - -namespace MuonCalib{ - -class Tube; -class Layer; -class Mezzanine; -class Multilayer; -class MDTChamber; -class MDTDqaDeadElementsAnalysis; - -//class Tube////////////////////////////////////////////////////////////////////////////////////// - -class Tube{ - - private: - int m_status; - int m_value; - int m_position; - int m_layer; - int m_ml; - Layer *m_parent_layer; - - public: - Tube(int,int, Layer*); - - int getStatus(); - int getValue(); - int getLayer(); - int getML(); - int getPosition(); - void setValue(int); - void setStatus(int); - void setPosition(int); - void setLayer(int); - void setML(int); - - Layer* getParentLayer(); - - }; -//end of class Tube//////////////////////////////////////////////////////////////////////////////// - -//class Layer////////////////////////////////////////////////////////////////////////////////////// - - class Layer{ - - private: - int m_ntubes; - double m_entries; - int m_status; - double m_median; - double m_median_deviation; - std::vector<Tube*> m_tubes; - - public: - Layer(); - - Tube* addTube(int,int); - Tube* getTube(int); - - int getNtubes(); - double getEntries(); - int getStatus(); - double getMedian(); - double getMedianDeviation(); - - void setStatus(int); - void addEntries(double); - - void calculateStatistics(); - int getNrealtubes(); - - }; -//end of class Layer//////////////////////////////////////////////////////////////////////////// - -//class Mezzanine////////////////////////////////////////////////////////////////////////////// - - class Mezzanine{ - - private: - int m_ntubes; - double m_entries; - int m_status; - double m_median; - double m_median_deviation; - std::vector<Tube*> m_tubes; - int m_70min; - int m_70max; - - public: - Mezzanine(); - - void addTube(Tube*); - Tube* getTube(int); - - int getNtubes(); - double getEntries(); - int getStatus(); - double getMedian(); - double getMedianDeviation(); - int get70min(); - int get70max(); - - void addEntries(double); - void setStatus(int); - - void calculateStatistics(); - - }; - -//End of class Mezzanine///////////////////////////////////////////////////////////////////////////////////////// - -//class Multilayer/////////////////////////////////////////////////////////////////////////////////////////////// - - class Multilayer{ - - private: - int m_nlayers; - int m_nmezzanines; - double m_entries; - int m_status; - double m_median; - double m_median_deviation; - - std::vector<Layer*> m_layers; - std::vector<Mezzanine*> m_mezzanines; - - public: - Multilayer(); - - void addLayer(); - Tube* addTube(int,int,int); - Layer* getLayer(int); - Mezzanine* addMezzanine(); - Mezzanine* getMezzanine(int); - - int getNlayers(); - int getNmezzanines(); - double getEntries(); - int getStatus(); - double getMedian(); - double getMedianDeviation(); - - void setStatus(int); - void addEntries(double the_entries); - - void calculateStatistics(); - }; - -//End of class Multilayer////////////////////////////////////////////////////////////////////////////////// - -//Class MDTChamber///////////////////////////////////////////////////////////////////////////////////////// - - class MDTChamber{ - - private: - int m_nmultilayers; - - double m_entries; - int m_status; - double m_median; - double m_median_deviation; - double m_mean; - double m_standard_deviation; - int m_90min; - int m_90max; - int m_70; - - TString m_name; - - std::vector<Multilayer*> m_multilayers; - - public: - - MDTChamber(TH1*,TString); - - void addMultilayer(); - Multilayer* getMultilayer(int); - Tube* addTube(int,int,int,int); - - int getNmultilayers(); - double getEntries(); - int getStatus(); - double getMedian(); - double getMedianDeviation(); - double getMean(); - double getStandardDeviation(); - TString getName(); - int get90min(); - int get90max(); - int get70(); - - - void setStatus(int); - void addEntries(double); - - void buildMezzanines(); - void calculateStatistics(); - void updateStatistics(); - - void Print(); - - }; - -//End of class MDTChamber//////////////////////////////////////////////////////////////////////////////// - -//class MDTDqaDeadElements/////////////////////////////////////////////////////////////////////////////// - - class MDTDqaDeadElements{ - - private: - bool m_verbose; - bool m_write_report; - bool m_write_compact_report; - bool m_do_analysis; - bool m_print_chambers; - bool m_write_list_of_dead_tubes; - bool m_do_noisy; - std::ofstream m_file_report; - std::ofstream m_comp_report; - std::ofstream m_filelistofdeads; - int m_deadtubes; - int m_deadmezzanines; - int m_deadlayers; - int m_deadmultilayers; - int m_deadchambers; - int m_noisytubes; - int m_lowstatmezzanines; - int m_lowstatisticschambers; - int m_lowstatisticsfortubeschambers; - int m_ntubes; - - int m_dead_tubes_per_sector; - int m_dead_mezzanines_per_sector; - int m_dead_layers_per_sector; - int m_dead_multilayers_per_sector; - int m_dead_chambers_per_sector; - int m_lowstat_chambers_per_sector; - - public: - MDTDqaDeadElements(); - void setVerbose(bool); - void setWriteReport(bool); - void setWriteCompactReport(bool); - void setDoAnalysis(bool); - void setPrintChambers(bool); - void setDoNoisy(bool); - void setWriteListOfDeadTubes(bool); - - void MDTDqaDeadElementsAnalysis(TFile*); - - void fillChamber(MDTChamber*, TH1*); - void fillDeadMap(MDTChamber*, TH2F*, TH2F*,TH1F*, TDirectory*,TDirectory*); - - void doAnalysis(MDTChamber*); - void analyseMultilayers(MDTChamber*); - void analyseLayers(MDTChamber*); - void analyseMezzanines(MDTChamber*); - void reanalyseMezzanines(MDTChamber*); - void analyseTubes(MDTChamber*); - - void PrintListOfDeadTubes(MDTChamber*); - - }; - -}//namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTName.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTName.h deleted file mode 100644 index 08643ba1fc2b47dc52e80133e20bb275622ddae0..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MDTName.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -/* Author: Marco Vanadia vanadiam@roma1.infn.it*/ - -#ifndef MUONCALIBSTANDALONEEXTRATOOLS_MDTNAME_H -#define MUONCALIBSTANDALONEEXTRATOOLS_MDTNAME_H - -#include "MuonCalibIdentifier/MuonFixedId.h" -#include <string> -#include <sstream> -#include <stdlib.h> -#include "TString.h" - -namespace MuonCalib{ - -class MDTName{ - -private: - TString m_name; - int m_eta_on; - int m_eta_off; - int m_sector_on; - int m_sector_off; - char m_side; - -public: - MDTName(); - MDTName(const MuonFixedId&); - MDTName(const TString&); - MDTName(const char*); - MDTName(const std::string&); - MDTName(const std::string&,const int,const int); - MDTName(const std::string&,const int,const std::string&,const int); - void MDTName_init(const TString&); - std::string getOnlineName(); - std::string getOfflineName(); - bool isBarrel(); - bool isEndcap(); - bool isInner(); - bool isMiddle(); - bool isOuter(); - bool isExtra(); - bool isForward(); - bool isBackward(); - bool isLarge(); - bool isSmall(); - int getOnlineSector(); - int getOfflineSector(); - int getOnlineEta(); - int getOfflineEta(); - std::string getRegion(); - std::string getStation(); - std::string getSize(); - std::string getSide(); - std::string getName(); - TString OnlineToOfflineName(const TString&); - TString OnlineToOfflineName(const char*); - TString OnlineToOfflineName(const std::string&); - TString OfflineToOnlineName(const TString&); - TString OfflineToOnlineName(const char*); - TString OfflineToOnlineName(const std::string&); - -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaDb.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaDb.h deleted file mode 100644 index 1fe3f5ebb7f054aacea1bb8af6055e8bbc789214..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaDb.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MDTDQADB_H -#define MDTDQADB_H - -#include <iostream> -#include <fstream> -#include <sstream> -#include <map> -#include <string.h> -#include <vector> - -class MdtDqaDb { - std::string m_chamberName; - int m_timeFlag, m_deadFlag; - float m_t0ML1, m_t0ML2, m_tdriftML1, m_tdriftML2; - float m_chi2ndofML1, m_chi2ndofML2, m_t0errML1, m_t0errML2; - float m_tdrifterrML1, m_tdrifterrML2; - int m_numDeadML, m_numDeadMezz, m_numDeadTube; - int m_numNoisyMezz, m_numNoisyTube; - std::vector<int> m_listDeadML, m_listDeadMezz, m_listDeadTube; - std::vector<std::pair<int,float> > m_listNoisyMezz, m_listNoisyTube; - -public: - MdtDqaDb(std::string chamName); - MdtDqaDb(); - virtual ~MdtDqaDb(); - void Clear(); - void Print(); //method to print to screen - void Print(std::ofstream *outfile); //print to file - void FillDb(/*some db info*/);//method to fill the cool tables - - //Set methods - void SetChamberName(std::string chamName); - void SetTimeFlag(int timeFlag); //method to update the time flag by hand - void SetDeadFlag(int deadFlag); //method to update the dead flag by hand - void SetML1(float t0, float tdrift, float chi2ndof, float t0err, float tdrifterr); - void SetML2(float t0, float tdrift, float chi2ndof, float t0err, float tdrifterr); - void SetDeadML(std::vector<int> deadML); - void SetDeadMezz(std::vector<int> deadMezz); - void SetDeadTube(std::vector<int> deadTube); - void SetNoisyMezz(std::vector<std::pair<int,float> > noisyMezz); - void SetNoisyTube(std::vector<std::pair<int,float> > noisyTube); - - //get methods - std::string getChamberName(); - int getTimeFlag(); - int getDeadFlag(); - int getNumDeadML(); - int getNumDeadMezz(); - int getNumDeadTube(); - int getNumNoisyMezz(); - int getNumNoisyTube(); - float getT0ML1(); - float getT0ML2(); - float getTdriftML1(); - float getTdriftML2(); - float getChi2ndofML1(); - float getChi2ndofML2(); - float getT0errML1(); - float getT0errML2(); - float getTdrifterrML1(); - float getTdrifterrML2(); - std::vector<int> getDeadML(); - std::vector<int> getDeadMezz(); - std::vector<int> getDeadTube(); - std::vector<std::pair<int,float> > getNoisyMezz(); - std::vector<std::pair<int,float> > getNoisyTube(); -}; - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h deleted file mode 100644 index 7c87f18f208b1618f85deda61fa960da54ce8a28..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_MdtDqaGlobalTimeFitH -#define MuonCalib_MdtDqaGlobalTimeFitH - -//:::::::::::::::::::::::::::::::::::: -//:: CLASS MdtDqaGlobalTimeFit :: -//:::::::::::::::::::::::::::::::::::: - -/// \class MdtDqaGlobalTimeFit -/// -/// This class determines -/// -/// \author mauro.iodice@roma3.infn.it -/// -/// \date 05.09.2008 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -#include "MdtCalibData/IRtRelation.h" -#include "MdtCalibData/RtRelationLookUp.h" -#include "MdtCalibData/MdtCalibrationFactory.h" - -#include "MdtCalibUtils/GlobalTimeFitter.h" - -class RegionSelectionSvc; -class HistogramManager; - -//root -class TFile; -class TNtuple; -class TH1F; -class TH1I; - -namespace MuonGM{ - class MuonDetectorManager; -} - -namespace MuonCalib { - -class QuasianalyticLineReconstruction; -class IIdToFixedIdTool; -class MuonCalibSegment; -class NtupleStationId; -class MuonCalibEvent; - -// NOT MAINTAINED ANYMORE -- class MuCCaFitter; -class DCSLFitter; - -class MdtDqaGlobalTimeFit { - - public: - // Constructors // - MdtDqaGlobalTimeFit(int nbHitsMin, int nbHitsMax, float chi2cut, int BfieldON, bool debug); - ~MdtDqaGlobalTimeFit()=default; - - // Methods // - - /** tool initialize */ - StatusCode initialize(const MuonGM::MuonDetectorManager*, const MuonCalib::IIdToFixedIdTool *,RegionSelectionSvc *, HistogramManager *); - - StatusCode handleEvent(const MuonCalibEvent &event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - ///< analysis of the given segment of - ///< event eventnumber, event contains - ///< the raw hits - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - ///< analysis at the end of the data - ///< file - inline bool KeepSegments() const { - return false; - } - - IRtRelation *getDefaultRtRelation(int BfieldON); - - private: - const MuonGM::MuonDetectorManager *m_detMgr; - const MuonCalib::IIdToFixedIdTool *m_id_tool; - // pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - - HistogramManager *m_histoManager; - std::string m_chamberAthenaName; - std::string m_chamberHardwareName; - - std::string m_file_name; //root file name - int m_minNumHits; //minimum number of hits in segment - int m_maxNumHits; //maximum number of hits in segment - float m_chi2_cut; //track chi2 cut; - int m_BfieldON; // BField was ON (1) or OFF (0) used for rtDefault choice; - bool m_debug; //write debugging rootfile - - // line reconstruction // - IRtRelation *m_rtRel; - //QuasianalyticLineReconstruction *m_qfitter; - // NOT MAINTAINED ANYMORE MuCCaFitter * m_muFitter; - DCSLFitter *m_muFitter; - GlobalTimeFitter *m_GTFitter; - -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaNtupleAnalysis.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaNtupleAnalysis.h deleted file mode 100644 index 8d20c20e17addb4e9a6e755eaaf79dbff34b5ee9..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaNtupleAnalysis.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SRC_MDTDQANTUPLEANALYSIS_H -#define SRC_MDTDQANTUPLEANALYSIS_H - -#include "GaudiKernel/Algorithm.h" -#include "MuonCalibStandAloneExtraTools/StringUtil.h" -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaDb.h" -#include "MuonCalibStandAloneExtraTools/MDTDqaDeadElements.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -#include <iostream> -#include <vector> -#include <math.h> -#include <fstream> -#include <string> -#include <iomanip> -#include <sstream> - -#include "TFile.h" - -namespace MuonCalib { - - class MuonCalibEvent; - class MuonCalibSegment; - - /** - @class NtupleAnalysis - An example analysis class. One can use this class as a skeleton analysis. See the description of the separate methods for the possibilites of the Calib-EDM and standalone analysis (such as the use of Display and MuonCalib::T0Fitter) - @author Zdenko.Van.Kesteren@cern.ch - */ - class MdtDqaNtupleAnalysis { - public: - MdtDqaNtupleAnalysis(bool verbose, std::string outputFileName); //!< default constructor - virtual ~MdtDqaNtupleAnalysis()=default; - - StatusCode initialize(RegionSelectionSvc *, HistogramManager *, int, float); - - void handleEvent(const MuonCalibEvent &event, int eventnumber, const std::vector<MuonCalibSegment *> &segments, unsigned int position ); - void histogramAnalysis(TFile * rootfile); - - int segmentStation(MuonCalibSegment *segment ); - int segmentEta(MuonCalibSegment *segment ); - int segmentPhi(MuonCalibSegment *segment ); - - private: - RegionSelectionSvc *p_reg_sel_svc; - HistogramManager *m_histoManager; - bool m_verbose; - int m_DeadElementsAlgorithm; - int m_SectorMin; - int m_SectorMax; - bool m_analyseBarrel; - bool m_analyseEndcapA; - bool m_analyseEndcapC; - - float m_ADCCUT; - int m_evtCounter; - - std::string m_outputFileName; - std::vector<MdtDqaDb*> m_MdtDqaDbList; - - }; - -} //namespace MuonCalib - -#endif // MdtDqaNtupleAnalysis_h diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTrackAnalysis.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTrackAnalysis.h deleted file mode 100644 index 4f902ed94a6df59899d38879f16cfd43cd4f4679..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTrackAnalysis.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_TrackAnalysisH -#define MuonCalib_TrackAnalysisH - -#include <iostream> -#include <vector> -#include <math.h> -#include <fstream> -#include <string> -#include <iomanip> -#include <sstream> - -#include "MuonCalibExtraTreeEvent/MuonCalibExtendedTrack.h" -#include "MuonCalibExtraTreeEvent/MuonCalibExtendedSegment.h" -#include "MuonCalibExtraTreeEvent/EventHandler.h" -#include "MuonCalibExtraTreeEvent/MuonCalibTrack_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibEvent_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibHit_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibSelector.h" -#include "MuonCalibExtraTreeEvent/MuonCalibHit_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibCaloHit.h" -#include "MuonCalibExtraTreeEvent/MuonCalibTrackSummary.h" -#include "MuonCalibExtraTreeEvent/MuonCalibSelector.h" -#include "MuonCalibExtraTreeEvent/MuonCalibTriggerInfo.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibTruthCollection.h" -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneExtraTools/SegmentAnalysis.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -namespace MuonCalib{ - -class MdtDqaTrackAnalysis{ - - private: - int m_TrkAuthor; - HistogramManager *m_histoManager; - bool m_verbose; - // pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - int number_IDhits(MuonCalibSelector::TrackVec::const_iterator, int); - int cutflow(MuonCalibSelector::TrackVec::const_iterator, double , int , int , int , int ); - int MDTtiming(const std::vector<const MuonCalibExtendedSegment*> &segments); - //void MDTtiming(const std::vector<MuonCalibSegment*>&); - - public: - MdtDqaTrackAnalysis(RegionSelectionSvc*,int, HistogramManager*, bool); - void handleEvent(const MuonCalibEvent&, int , const std::vector<MuonCalibSegment*>&, unsigned int); - -}; - -} //namespace MuonCalib - -#endif - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h deleted file mode 100644 index cf459178ef9df7efa0645d4e38834d05890f2f90..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 13.08.2008, AUTHOR: MAURO IODICE -// ALGORITHM TAKEN FROM STEFFEN KAISER slightly modified -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef MuonCalib_MdtDqaTubeEfficiencyH -#define MuonCalib_MdtDqaTubeEfficiencyH - -//:::::::::::::::::::::::::::::::::::: -//:: CLASS MdtDqaTubeEfficiency :: -//:::::::::::::::::::::::::::::::::::: - -/// \class MdtDqaTubeEfficiency -/// -/// This class determines the single tube efficiencies and fakerates -/// and writes them to a TubeEfficiencies_<regionId>.txt and .root file. -/// (The fakerate only compares the raw hits to the tubes traversed by -/// one segment.) -/// -/// The combined efficiencies for the layer, multilayer and chamber are -/// calculated as weighted mean of the single tube efficiencies, according to -/// -/// eff = (Sum_i 1/sigma_i^2 * eff_i)/(Sum_i 1/sigma_i^2) -/// sigma = Sqrt( 1/(Sum_i 1/sigma_i^2) ) -/// -/// \author Steffen.Kaiser@cern.ch -/// -/// \date 10.04.2007 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// this -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" -class RegionSelectionSvc; -class HistogramManager; - -//root -class TFile; -class TNtuple; -class TH1F; -class TH1I; - -namespace Muon { - class IMuonIdHelperSvc; -} - -namespace MuonGM{ - class MuonDetectorManager; -} - -namespace MuonCalib { - -class QuasianalyticLineReconstruction; -class IIdToFixedIdTool; -class MuonCalibSegment; -class NtupleStationId; -class MuonCalibEvent; - - -class MdtDqaTubeEfficiency { - - public: - // Constructors // - MdtDqaTubeEfficiency(float nsigma, float chi2Cut, - bool defaultResol, float adcCut, bool GTFitON, bool useNewCalibConstants, bool useTimeCorrections ); - - ///< Default constructor. - inline ~MdtDqaTubeEfficiency(){} - ///< Destructor - - // Methods // - - /** tool initialize */ - StatusCode initialize(const Muon::IMuonIdHelperSvc*, const MuonGM::MuonDetectorManager*, const MuonCalib::IIdToFixedIdTool *, - RegionSelectionSvc *, MdtCalibInputSvc *, HistogramManager *); - - StatusCode handleEvent(const MuonCalibEvent &event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - ///< analysis of the given segment of - ///< event eventnumber, event contains - ///< the raw hits - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - ///< analysis at the end of the data - ///< file - inline bool KeepSegments() const { - return false; - } - - inline double defaultResolution(double radius) { - double P0 = 2.887916e-01 ; - double P1 = -4.391942e-02 ; - double P2 = 3.207732e-03 ; - double P3 = -1.593081e-04 ; - double P4 = 9.127890e-06 ; - double P5 = -2.565923e-07 ; - double resol = P0+P1*radius+P2*std::pow(radius,2)+P3*std::pow(radius,3)+P4*std::pow(radius,4)+P5*std::pow(radius,5); - return resol ; - } ; - - private: - const Muon::IMuonIdHelperSvc* m_idHelper; - const MuonGM::MuonDetectorManager *m_detMgr; - const MuonCalib::IIdToFixedIdTool *m_id_tool; - // pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - MdtCalibInputSvc *p_calib_input_svc; - - HistogramManager *m_histoManager ; - std::string m_chamberAthenaName; - std::string m_chamberHardwareName; - - std::string m_file_name; // root file name - float m_nsigma; // efficiency at nsigma*resol(r) - float m_chi2Cut; // segment chi2/ndof cut; - bool m_defaultResol; // use default resolution instead of that found in the hit - float m_adcCut; // only consider hit above adcCut ; - bool m_GTFitON; // refit with GlobalTimeFitter the initial segment - bool m_useNewCalibConstants; - bool m_useTimeCorrections; - - // line reconstruction // - QuasianalyticLineReconstruction *m_qfitter; - - // counter/numbers // - int m_nb_stations ; - int m_nb_layers_tubes[1500][4] ; - -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h deleted file mode 100644 index 01b3e795f0edacc9cd9539785ffce21d75260ad2..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 13.08.2008, AUTHOR: MAURO IODICE -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef MuonCalib_NtupleMdtDqaToolH -#define MuonCalib_NtupleMdtDqaToolH - -//:::::::::::::::::::::::::::::::::::: -//:: CLASS NtupleMdtDqaTool :: -//:::::::::::::::::::::::::::::::::::: - -/// \class NtupleMdtDqaTool -/// -/// This class performs low level MdtDqa analysis mainly focusing on -/// hits occupancies and segment quality. -/// -/// \author Mauro.Iodice@cern.ch -/// -/// \date 13.08.2008 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" - -#include "MuonCalibStandAloneExtraTools/StringUtil.h" -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaDb.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaNtupleAnalysis.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaTrackAnalysis.h" -#include "MuonCalibStandAloneExtraTools/SegmentAnalysis.h" - -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" - -class RegionSelectionSvc; -class MdtCalibInputSvc; - -class HistogramManager; - -//root -class TFile; -class TNtuple; -class TH1F; -class TH1I; - -namespace MuonGM{ -class MuonDetectorManager; -} - -namespace MuonCalib { - -class QuasianalyticLineReconstruction; -class IIdToFixedIdTool; -class MuonCalibSegment; -class NtupleStationId; -class MuonCalibEvent; - -class NtupleMdtDqaTool : public AthAlgTool, virtual public NtupleCalibrationTool { - - public: - // Constructors // - NtupleMdtDqaTool(const std::string& t, const std::string& n, const IInterface* p); - - ~NtupleMdtDqaTool()=default; - - // Methods // - - /** tool initialize */ - StatusCode initialize(); - - /** tool finalize */ - StatusCode finalize(); - - StatusCode handleEvent(const MuonCalibEvent &event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - ///< analysis of the given segment of - ///< event eventnumber, event contains - ///< the raw hits - - // StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> &segments); - - ///< analysis at the end of the data - ///< file - inline bool KeepSegments() const { - return false; - } - - private: - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - const MuonGM::MuonDetectorManager *m_detMgr; - const MuonCalib::IIdToFixedIdTool *m_id_tool; - - // pointer to region selection service - RegionSelectionSvc* p_reg_sel_svc; - - // pointer to the calibration service - MdtCalibInputSvc* p_calib_input_svc; - // Manager tools // - HistogramManager* m_histoManager; - - // Analysis tools and variables : // - // - // MdtDqaNtupleAnalysis - // - MdtDqaNtupleAnalysis *m_ntupleAna; - MdtDqaTrackAnalysis *m_trackAnalyzer; - SegmentAnalysis *m_segmentAnalyzer; - bool m_verbose; - bool m_fillHistos; - bool m_doFinalize; - std::string m_MdtDqa_file_name; // .root and .txt are root and text file names - bool m_doHitResids; // Toggle between calculating the hit(or fit) residuals for SegResidVsRadius instead - - float m_ADCCUT; - - // - // MdtDqaTubeEfficiency - // - bool m_doEfficiency; - MdtDqaTubeEfficiency * m_tubeEffi; - float m_EffiNSigma; // efficiency at nsigma*resol(r) - float m_EffiChi2Cut; // segment chi2/ndof cut; - bool m_EffiUseDefaultResolution; //use default resolution instead of that found in the hit - float m_EffiHitADCCut; // only consider hit above adcCut; - bool m_EffiGTFitON; // refit with GlobalTimeFitter the initial segment - bool m_EffiUseNewCalibConstants; - bool m_EffiUseTimeCorrections; - - // - // MdtDqaGlobalTimeFit - // - bool m_doGlobalTimeFit; - // bool m_doGTFit_t0Refit; // TO BE IMPLEMENTED - MdtDqaGlobalTimeFit * m_globalTimeFit; - int m_rtDefaultBfieldON; - float m_GTFitSeg_chi2Cut; - int m_GTFitSeg_minNumHits; - int m_GTFitSeg_maxNumHits; - bool m_GTFitDebug; - - // TRACK ANALYSIS - bool m_doTracks; - //bool m_quickTrack; - int m_TrkAuthor; - - //Dead Tube analysis - int m_DeadElementsAlgorithm; - - // calibration region// - //const NtupleStationId *m_cal_region; - - // line reconstruction // - //QuasianalyticLineReconstruction *m_qfitter; - - // counter/numbers // - //int m_nb_trigger; - //int m_nb_multilayers; - //int m_nb_layers; - //int m_nb_tubes; - - // histograms // - //TH1F *h_distance; - //TH1I *h_nb_hit_tubes; - -/* - std::vector< std::vector< std::vector<TH1F*> > > h_efficiency; - std::vector< std::vector< std::vector<TH1F*> > > h_fakerate; - - std::vector< std::vector<TH1F*> > h_tube_efficiency; - std::vector< std::vector<TH1F*> > h_tube_fakerate; - - std::vector< std::vector<TH1F*> > h_tube_entries_efficiency; - std::vector< std::vector<TH1F*> > h_tube_entries_fakerate; -*/ - //TH1F *h_layer_efficiency; - //TH1F *h_layer_fakerate; - - //TH1F *h_chamber_efficiency; - //TH1F *h_chamber_fakerate; - - //TH1F *h_chi2; - -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/PhiEtaUtils.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/PhiEtaUtils.h deleted file mode 100644 index 42f6754ccca5c219f67f73df4c2c1bea9bb6c823..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/PhiEtaUtils.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SRC_PHIETAUTIL_H -#define SRC_PHIETAUTIL_H - -#include "MuonCalibIdentifier/MuonFixedId.h" -#include "MuonCalibStandAloneExtraTools/StringUtil.h" - -class PhiEtaNameConverter { - - public: - PhiEtaNameConverter() {}; //!< default constructor - ~PhiEtaNameConverter() {}; //!< destructor - - inline std::string chamberHardwareName(int stationId, int phi, int eta){ - std::string chamberName = "UNDEFINED" ; - MuonCalib::MuonFixedId id(stationId) ; - ToString ts ; - if (!id.is_mdt() ) return chamberName ; - chamberName = id.stationNumberToFixedStationString(stationId); - int absoluteEta = std::abs(eta) ; - std::string side = "A"; - if(eta<0) side="C"; - int sector = phi_8to16(stationId, phi) ; - std::string sectorString ; - if(sector<10) sectorString = "0"+ts(sector); - if(sector>=10) sectorString = ts(sector); - chamberName += ts(absoluteEta)+side+sectorString ; - return chamberName ; - } - - inline std::string chamberAthenaName(int stationId, int phi, int eta){ - std::string chamberName = "UNDEFINED" ; - MuonCalib::MuonFixedId id(stationId) ; - ToString ts ; - if (!id.is_mdt() ) return chamberName ; - chamberName = id.stationNumberToFixedStationString(stationId); - chamberName += "_"+ts(phi)+"_"+ts(eta) ; - return chamberName ; - } - - inline int phi_8to16(int station, int phi8){ - // ENDCAP : - if (station>13 && station<25) { - if (station==15 || station==16 ||station==19 ||station==22) { - return phi8*2-1 ; - } else { - return phi8*2 ; - } - } - - //large BIL,BML,BOL - if(station==1||station==3||station==5 - || station==8 //BIR - || station==13 //BIM - || station==12 //BME - ){ - return phi8*2-1; - } - //small. BIS,BMS,BOS - if(station==2||station==4||station==6 - || station==7 //BEE - || station==9 //BMF - || station==10 //BOF - || station==11 //BOG - || station==35 //BMG - ){ - return phi8*2; - } - - if( station%2 == 0 ){ - return phi8*2; - } - return phi8*2-1; - } //end phi_8to16 - - inline int phi_16to8(int station, int phi16){ - if(station==1||station==3||station==5 - || station==8 //BIR - || station==13 //BIM - || station==12 //BME - ){ - return (phi16+1)/2; - } - if(station==2||station==4||station==6 - || station==7 //BEE - || station==9 //BMF - || station==10 //BOF - || station==11 //BOG - || station==35 //BMG - ){ - return phi16/2; - } - - if(phi16%2 == 0 ){ - return phi16/2; - } - - return (phi16+1)/2; - - } //end phi_16to8 - -// CHE E' STA ROBBBA ???? -// -inline int eta_atlas2loc(int eta){ - int eta2= eta+7; - if(eta<0) eta2=eta+8; - return eta2; -} - -inline int eta_loc2atlas(int eta){ - int eta2; - if(eta<=7) eta2=eta-8; - if(eta>=8) eta2=eta-7; - return eta2; -} - -}; - -#endif // SRC_PHIETAUTIL_H diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/SegmentAnalysis.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/SegmentAnalysis.h deleted file mode 100644 index c9c11354374141634484f9b3645efc8ead1cfef6..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/SegmentAnalysis.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_SegmentAnalysisH -#define MuonCalib_SegmentAnalysisH - -#include <iostream> -#include <vector> -#include <math.h> -#include <fstream> -#include <string> -#include <iomanip> -#include <sstream> - -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" - -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -namespace MuonCalib{ - -class SegmentAnalysis{ - - private: - HistogramManager *m_histoManager; - // pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; - bool m_verbose; - int multiChambSeg( MuonCalibSegment *segment ); - int segmentStation( MuonCalibSegment *segment ); - int segmentEta( MuonCalibSegment *segment ); - int segmentPhi( MuonCalibSegment *segment ); - - int m_SectorMin; - int m_SectorMax; - - bool m_doHitResids; - - public: - SegmentAnalysis(RegionSelectionSvc*,HistogramManager*, bool, bool); - void handleEvent(const MuonCalibEvent&, int , const std::vector<MuonCalibSegment*>&, unsigned int position); -}; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/StringUtil.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/StringUtil.h deleted file mode 100644 index 4c3304ef205be380a1140fd5c2f6b04b4249da3f..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/StringUtil.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SRC_STRINGUTIL_H -#define SRC_STRINGUTIL_H - -class ToString{ - public: - template< class T > std::string operator()( const T& i ) { - std::ostringstream os; - os << i; - return os.str(); - } -}; - -/* -class ToChar { - public: - char* operator()( const string i ) - { - return i.c_str(); - } - char* operator()( const int i ) - { - ToString ts; - return ts(i).c_str(); - } - char* operator()( const float i ) - { - ToString ts; - return ts(i).c_str(); - } - char* operator()( const char * i ) - { - return i; - } - -}; -*/ - -#endif // SRC_STRINGUTIL_H diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/TimeAndAdcFitter.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/TimeAndAdcFitter.h deleted file mode 100644 index c0efdcd5e8f945415ac67a12e8f811b5e250f97a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/TimeAndAdcFitter.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef SRC_TIMEANDADCFITTER_H -#define SRC_TIMEANDADCFITTER_H - -#include <string.h> -#include <stdio.h> - -#include <sstream> -#include <iostream> -#include <fstream> - -#include <TFile.h> -#include <TString.h> -#include <vector> -#include "TH1.h" -#include "TObjArray.h" - -class TimeAndAdcFitter { -public: - TimeAndAdcFitter() : m_verbose(0) {}; - ~TimeAndAdcFitter() {}; - void doTimeFit(TH1F * h, const int nParams, double * pfit, double * errfit, double* chi2, int* ndof ) ; - // void doTimeFit(TH1F * h); - void doAdcFit(TH1F * h, const int nAdcParams, double * Adcpfit, double * errAdcpfit, double* chi2Adc, int* ndofAdc ) ; - void searchParams(TH1 * h, double * p, int np); - void setVerbose(int lvl) { m_verbose = lvl; } - -private: - int m_verbose; - -}; - -//////////////////////////////////////////////////////////////////// -// -// UTILITIES of General use -// -/* -class ToString { - public: - template< class T > - std::string operator()( const T& i ) - { - std::ostringstream os; - os << i; - return os.str(); - } -}; -*/ -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/TrackSecondCoordinateToSegment.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/TrackSecondCoordinateToSegment.h deleted file mode 100644 index 21e059790ddfa5e95abdf7383a3a4f95ce0dbd8d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/TrackSecondCoordinateToSegment.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_TrackSecondCoordinateToSegment_h -#define MuonCalib_TrackSecondCoordinateToSegment_h - -//Gaudi -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" - -//root -class TFile; -class TH1F; -class TH2F; -namespace MuonCalib { - -class MuonCalibSegment; -class MuonCalibExtendedTrack; - -class TrackSecondCoordinateToSegment : public AthAlgTool, virtual public CalibSegmentPreparationTool { - public: -//=========================constructor========================================== - TrackSecondCoordinateToSegment(const std::string &t, const std::string &n, const IInterface *p); - inline ~TrackSecondCoordinateToSegment() {} -//=========================public member functions============================== - //initialize and finalize - StatusCode initialize(void); - StatusCode finalize(void); - //load event - void prepareSegments(const MuonCalibEvent *& /*event*/, std::map<NtupleStationId, MuonCalibSegment *> &segments); - private: -//=========================private data========================================= - //control histrograms - plot changes of x coordinate - bool m_control_histos; - TFile *m_root_file; - TH1F *m_delta_x; - TH1F *m_delta_sx; - TH1F *m_delta_hit_x; - inline void apply_2n_coordinate(const MuonCalibExtendedTrack *track, MuonCalibSegment *segment) const; - inline void updatePosition(Amg::Vector3D & position, const Amg::Vector3D & seg_pos, const Amg::Vector3D &seg_dir) const; - // inline void updatePosition(HepGeom::Point3D<double> &position, const HepGeom::Point3D<double> &seg_pos, const HepGeom::Vector3D<double> &seg_dir) const; -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/python/CalibExtraNtupleAnalysisConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/python/CalibExtraNtupleAnalysisConfig.py deleted file mode 100644 index 3c0db0a2392946e58f376daed55ee4493c589beb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/python/CalibExtraNtupleAnalysisConfig.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from __future__ import print_function - -from MuonCalibStandAloneExtraTools.MuonCalibStandAloneExtraToolsConfig import * -print ("NoRecalibration=", NoRecalibration) -from CalibNtupleAnalysisAlg.CalibNtupleAnalysisConfig import * -print ("NoRecalibration=", NoRecalibration) -from MuonCalibStandAloneExtraTools.MuonCalibStandAloneExtraToolsConf import * -print ("NoRecalibration=", NoRecalibration) -#ToolSvc = Service( "ToolSvc" ) - - -def GenTrackAuthorCodes(author, primary_only=False, combined_only=False, stand_alone_only=False): -# With this section commented out, code will not work on Run1 calib ntuples -# Maybe, can have both Run1 and Run2 tracks authors in list, need to check. -# Athena <=17, Run1 calib ntuples -# track_types=range(0, 5) -# if combined_only: -# track_types=[2,3] -# if stand_alone_only: -# track_types=[0] - -# ret=[] -# for tp in track_types: -# ret.append(tp + 100* author + 10) -# if not primary_only: -# for tp in track_types: -# ret.append(tp + 100* author) -# Athena >= 20, Run2 ntuples -# Calibstream has track author 200 only -# Raw data (Reco_tf.py) has track authors 206 (standalone), 208 (combined) - track_types=range(0, 1) - if combined_only: - track_types=[8] - if stand_alone_only: - track_types=[0,6] - - ret=[] - for tp in track_types: - ret.append(tp + 200) -# if not primary_only: -# for tp in track_types: -# ret.append(tp + 100* author) - - return ret - -class CalibExtraNtupleAnalysisConfig(CalibNtupleAnalysisConfig): - LoadExtraNtuple=True - SelectTrackSegments=True - TrackSecondCoordinate=True #THIS IS OVERWRITTEN in skeleton.mdt_calib_ntuple_trf.py - need to modify that to run TrackSecondCoordinate - MomentumCut=-1.0 - FastTrackMatch=True - SuperFastTrackMatch=False - - def AutoConfig(self): - self._create_CalibNtupleAnalysisAlg() - #ntuple loader - if self.LoadExtraNtuple: - self.CalibNtupleLoader = MuonCalib__CalibExtraNtupleLoader() - else: - self.CalibNtupleLoader = MuonCalib__CalibNtupleLoader() - self.sToolSvc += self.CalibNtupleLoader - self.CalibNtupleLoader.FileList = self.FileList - self.CalibNtupleLoader.FirstEvent = self.FirstEvent - self.CalibNtupleLoader.LastEvent = self.LastEvent - if not self.LoadExtraNtuple: - self.CalibNtupleLoader.NtupleType = "AUTO" - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.CalibNtupleLoader) - #region selection - if not self.SelectTrackSegments or not self.LoadExtraNtuple: - self._region_selection() - else: - self._track_region_selection() - #raw times - self._good_run_list_filter() - if self.ApplyRawTimes: - self.RawTimesReplacement=MuonCalib__ApplyRawTimes() - self.sToolSvc += self.RawTimesReplacement - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append(self.RawTimesReplacement) - #initial DQ list - self._initial_DQ_list() - #apply RPC Timing Correction - if self.RPCTimingCorr: - self.RpcTiming=MuonCalib__RpcTimingCorr() - self.sToolSvc += self.RpcTiming - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append(self.RpcTiming) - #correct segment second coordinate using tracks - if self.SelectTrackSegments and self.TrackSecondCoordinate and self.LoadExtraNtuple: - self.TrackSecondCoordinateTool = MuonCalib__TrackSecondCoordinateToSegment() - self.TrackSecondCoordinateTool.ControlHistograms=True - self.sToolSvc += self.TrackSecondCoordinateTool - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append(self.TrackSecondCoordinateTool) - #recalculate 2nd coordinate: - self._second_coordinate() - #segment recalibration - if not self.SuppressRecalibration: - self._configure_segment_recalibration("SegmentRecalibration") - #segment refitter - if self.SegmentRefit: - self._config_segment_refitter() - #B field updater - if self.UpdateBField: - self._config_UpdateBField() - self._configure_segment_recalibration("SegmentRecalibration2") - if self.SegmentRefit and self.RefitAfterBFieldUpdate: - self._config_segment_refitter("SegmentRefitter2") - #calibration IO - self._config_calibIO() - #create tool - self._create_calib_tool_extra() - -#------------------------------------------------------------------------------ - def _create_calib_tool_extra(self): - self._create_calib_tool() - if self.CalibrationTool: - return - self.CalibrationTool=CreateCalibExtraTool(self.CalibrationAlgorithm) - if self.CalibrationTool: - self.sToolSvc += self.CalibrationTool - self.CalibNtupleAnalysisAlg.CalibrationTool = self.CalibrationTool - - def _track_region_selection(self): - if self.SuperFastTrackMatch: - self.RegionSelection = MuonCalib__ExtraRegionSelectorSuperFast() - if self.SegmentAuthor == 3: #Muonboy, Athena <= 17 only - self.RegionSelection.TrackAutors=GenTrackAuthorCodes(1) - elif self.SegmentAuthor == 4: #Moore, Run1+Run2 - self.RegionSelection.TrackAutors=GenTrackAuthorCodes(0) - elif self.SegmentAuthor == 5: #what is this? - self.RegionSelection.TrackAutors=GenTrackAuthorCodes(2) - - elif self.FastTrackMatch: - self.RegionSelection = MuonCalib__ExtraRegionSelectorFast() - self.RegionSelection.SelectSegmentAuthor = self.SegmentAuthor - if self.SegmentAuthor == 3: - self.RegionSelection.TrackAutors=GenTrackAuthorCodes(1) - elif self.SegmentAuthor == 4: - self.RegionSelection.TrackAutors=GenTrackAuthorCodes(0) - elif self.SegmentAuthor == 5: - self.RegionSelection.TrackAutors=GenTrackAuthorCodes(2) - else: - self.RegionSelection = MuonCalib__ExtraRegionSelector() - self.RegionSelection.MuonBoyTracks = (self.SegmentAuthor == 3) - self.RegionSelection.SelectSegmentAuthor = self.SegmentAuthor - self.RegionSelectionSvc = RegionSelectionSvc() - self.RegionSelectionSvc.Region = self.CalibrationRegion - self.RegionSelection.MomentumCut = self.MomentumCut - self.RegionSelection.MinHits = self.MinSegmentHits - self.RegionSelection.MaxHits = self.MaxSegmentHits - self.sToolSvc += self.RegionSelection - self.CalibNtupleAnalysisAlg.CalibSegmentPreparationTools.append( self.RegionSelection ) - RegionSelectionSvc.PrintList = True - self.sServiceMgr += self.RegionSelectionSvc diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/python/MuonCalibStandAloneExtraToolsConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/python/MuonCalibStandAloneExtraToolsConfig.py deleted file mode 100644 index 13449cc99bfd844ee50ef2ba91b906523bd9d7eb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/python/MuonCalibStandAloneExtraToolsConfig.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from __future__ import print_function - -from MuonCalibStandAloneTools.MuonCalibStandAloneToolsConfig import * -from MuonCalibStandAloneExtraTools.MuonCalibStandAloneExtraToolsConf import * - -#list tools that do not need any recalibration -NoRecalibration += ["Splitter"] - -#list tools that needs the t0 reverted -#RevertT0 += [] - -#list tools, that needs the t0 recalibrated -#RecalibT0 += [] - -#list tools that need all recalibrated -#RecalibAll += [] - -#algorithms for which no segment refit should be done, even if requested by user -NoSegmentRefit += ["Splitter"] - -#algorithms fotr which the number of read segments should be limited -#LimitSegmentsFor += [] - -#algorithms, that need validated t0 and rt -ValidatedT0 += [ "MdtDqa", "Splitter" ] - -ValidatedRt += [ "MdtDqa", "Splitter" ] - - -def CreateCalibExtraTool(CalibrationTool): - dir() - if CalibrationTool == "MdtDqa": - return MuonCalib__NtupleMdtDqaTool() - if CalibrationTool == "Splitter": - return MuonCalib__NtupleSplitterTool() - else: - print ("WARNING: Unknown tool name '" + CalibrationTool + "'!") - return None - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/CalibExtraNtupleLoader.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/CalibExtraNtupleLoader.cxx deleted file mode 100644 index 120d0031cccb6da96c39e8e5991c05fe1e94bf67..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/CalibExtraNtupleLoader.cxx +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "MuonCalibStandAloneExtraTools/CalibExtraNtupleLoader.h" - -//CalibNtupleReader -#include "MuonCalibExtraNtuple/NTReader_E.h" - -//MuonCalibExtraTreeEvent -#include "MuonCalibExtraTreeEvent/MuonCalibEvent_E.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//root -#include "TChain.h" -#include "TFile.h" -#include "TKey.h" - -//c - c++ -#include "fstream" - -namespace MuonCalib { - -/////////////////////// -// CalibExtraNtupleLoader // -/////////////////////// -CalibExtraNtupleLoader::CalibExtraNtupleLoader(const std::string &t, const std::string &n, const IInterface *p): - AthAlgTool(t, n, p), p_reg_sel_svc(NULL) { - m_filelist="file_list.txt"; - declareProperty("FileList", m_filelist); - m_first = 0; - declareProperty("FirstEvent", m_first); - m_last = -1; - declareProperty("LastEvent", m_last); - m_ntuple_type="AUTO"; - declareProperty("NtupleType", m_ntuple_type); - declareInterface< CalibSegmentPreparationTool >(this); -} - -//////////////// -// initialize // -//////////////// -StatusCode CalibExtraNtupleLoader::initialize(void) { - ATH_MSG_INFO( "Filelist is '"<<m_filelist<<"'" ); - //convert Ntuple Type - if(m_ntuple_type == "AUTO") { - m_ntuple_type_num = 0; - } else if (m_ntuple_type == "NORMAL") { - m_ntuple_type_num = 1; - } else if (m_ntuple_type == "REGION") { - m_ntuple_type_num = 2; - } else { - ATH_MSG_FATAL("Invalid ntuple type. Must be AUTO/NORMAL/REGION!"); - return StatusCode::FAILURE; - } -//read filelist an build chain - m_chain = new TChain("/PatternNtupleMaker/Segments"); - std::string sdummy; - int count(0); - std::ifstream fl(m_filelist.c_str()); - if(fl.fail()) { - ATH_MSG_INFO("Cannot open file '"<<m_filelist<<"' for reading!"); - return StatusCode::FAILURE; - } - while (!fl.eof()) { - fl >> sdummy; - if (fl.eof()) - break; - bool is_region(false); - if(m_ntuple_type_num == 3) - is_region = true; - if(m_ntuple_type_num == 0) { - TFile testf(sdummy.c_str()); - if(testf.GetKey("PatternNtupleMaker") == NULL){ - is_region = true; - } else { - is_region = false; - } - } - if (is_region) { - if(p_reg_sel_svc == NULL) { - StatusCode sc=service("RegionSelectionSvc", p_reg_sel_svc); - if(!sc.isSuccess()) { - ATH_MSG_ERROR("Cannot retrieve RegionSelectionSvc!"); - return sc; - } - } - ATH_MSG_INFO("Added "<<p_reg_sel_svc->AddRegionNtuples(sdummy.c_str(), m_chain)<<" regions from file "<<sdummy); - } else { - m_chain->Add(sdummy.c_str()); - ATH_MSG_INFO("Added file '"<<sdummy<<"' to filelist!"); - } - count++; - } - if(count==0){ - ATH_MSG_FATAL("No files in filelist!"); - return StatusCode::FAILURE; - } - m_reader = new NTReader_E(m_chain); - return StatusCode::SUCCESS; -} //end CalibExtraNtupleLoader::initialize - -///////////////////// -// prepareSegments // -///////////////////// -void CalibExtraNtupleLoader::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> & /*segments*/){ - if(m_last>0 && m_last<=m_first) { - ATH_MSG_INFO("Enough events read!"); - event=NULL; - return; - } - const MuonCalibEvent_E &evt = m_reader->getEvent(m_first); - event = static_cast<const MuonCalibEvent *>(&evt); - if( event->rawHitCollection() == NULL ) { - ATH_MSG_INFO("End of file reached"); - event=NULL; - return; - } - m_first++; -} //end CalibExtraNtupleLoader::prepareSegments - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelector.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelector.cxx deleted file mode 100644 index c142f61cb8854c6ef439b96f575aee804512f275..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelector.cxx +++ /dev/null @@ -1,157 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "MuonCalibStandAloneExtraTools/ExtraRegionSelector.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibExtraTreeEvent -#include "MuonCalibExtraTreeEvent/MuonCalibEvent_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibExtendedSegment.h" -#include "MuonCalibExtraTreeEvent/MuonCalibExtendedTrack.h" - -#include "MuonCalibEventBase/MuonCalibEvent.h" - -#include "TFile.h" -#include "TH1.h" -#include "TDirectory.h" - -namespace MuonCalib { - -/////////////////////////// -// ExtraRegionSelector // -/////////////////////////// -ExtraRegionSelector::ExtraRegionSelector(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p) { - m_exclusive_segments = false; - declareProperty("ExclusiveSegments", m_exclusive_segments); - m_muonboy = false; - declareProperty("MuonBoyTracks", m_muonboy); - m_min_hits = 1; - declareProperty("MinHits", m_min_hits); - m_max_hits = 0; - declareProperty("MaxHits", m_max_hits); - m_select_seg_author = 4; - declareProperty("SelectSegmentAuthor", m_select_seg_author); - m_momentum_cut=-1.5; - declareProperty("MomentumCut", m_momentum_cut); - m_do_debug_file=false; - declareProperty("DoDebugFile", m_do_debug_file); - m_debug_file=NULL; - m_all_p=NULL; - m_selected_p_by_track=NULL; - m_selected_p_by_segment=NULL; - declareInterface< CalibSegmentPreparationTool >(this); -} //end ExtraRegionSelector::ExtraRegionSelector - -//////////////// -// initialize // -//////////////// -StatusCode ExtraRegionSelector::initialize(void) { - MsgStream log(msgSvc(), name()); - StatusCode sc=service("RegionSelectionSvc", p_reg_sel_svc); - if(!sc.isSuccess()) { - log << MSG::ERROR <<"Cannot retrieve RegionSelectionSvc!" <<endmsg; - } - if(m_muonboy) { - m_track_author_id = m_evt_handler.muonboyIndices().track; - } else { - m_track_author_id = m_evt_handler.mooreIndices().track; - } - if(m_do_debug_file) { - TDirectory *prev_dir=gDirectory; - m_debug_file = new TFile("ExtraRegionSelector.root", "RECREATE"); - m_all_p = new TH1F("all_p", "" ,20000, -100000, 100000); - m_selected_p_by_track = new TH1F("selected_p_by_track", "" ,20000, -100000, 100000); - m_selected_p_by_segment = new TH1F("selected_p_by_segment", "" ,20000, -100000, 100000); - prev_dir->cd(); - } - return sc; -} //end ExtraRegionSelector::initialize - -StatusCode ExtraRegionSelector::finalize(void) { - if(m_do_debug_file) { - m_debug_file->Write(); - delete m_all_p; - delete m_selected_p_by_track; - delete m_selected_p_by_segment; - delete m_debug_file; - } - return StatusCode::SUCCESS; -} - -void ExtraRegionSelector::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - MsgStream log(msgSvc(), name()); - if(event==NULL) { - log << MSG::FATAL << "event=NULL"<<endmsg; - event=NULL; - return; - } - const MuonCalibEvent *e(event); - const MuonCalibEvent_E *e_event=dynamic_cast<const MuonCalibEvent_E *>(e); - if(e_event==NULL) { - log << MSG::FATAL << "This tool works only with extra events!"<<endmsg; - event=NULL; - return; - } - segments.clear(); - m_evt_handler.setEvent(*e_event); - std::vector<unsigned int> calib_region_hit_map; - const EventHandler::TrackVec& e_trks(m_evt_handler.extendedTracks(m_track_author_id)); - for(EventHandler::TrkCit tit = e_trks.begin(); tit!=e_trks.end(); tit++) { - const MuonCalibExtendedTrack *trk(*tit); - const std::vector<const MuonCalibExtendedSegment*> &segs(trk->associatedSegments()); - if(m_all_p) m_all_p->Fill(trk->p()); - if (m_momentum_cut>-1) { - if(trk->p()>1e8) continue; - if(m_momentum_cut>=0 && std::abs(trk->p())<m_momentum_cut) continue; - } - if(m_selected_p_by_track) m_selected_p_by_track->Fill(trk->p()); - for(std::vector<const MuonCalibExtendedSegment*>::const_iterator seg_it=segs.begin(); seg_it!=segs.end(); seg_it++) { - MuonCalibExtendedSegment *seg = const_cast<MuonCalibExtendedSegment *>(*seg_it); - //check count hits in the calibration region and remove others - calib_region_hit_map.clear(); - bool reject(false); - int count(0); - for(MuonCalibSegment::MdtHitCit hit_it=seg->mdtHOTBegin(); hit_it!=seg->mdtHOTEnd(); hit_it++){ - unsigned int is_in_region(static_cast<unsigned int>(!p_reg_sel_svc->isInRegion((*hit_it)->identify())));// || m_suppressed_tubes.find((*hit_it)->identify())!=m_suppressed_tubes.end())); - calib_region_hit_map.push_back(is_in_region); - if(is_in_region!=0 && m_exclusive_segments){ - reject=true; - break; - } - if(is_in_region==0) - count++; - } - if(reject) continue; - if(count<m_min_hits || (count>m_max_hits && m_max_hits>0)) continue; - if(count==0) continue; - seg->refineMdtSelection(calib_region_hit_map); - NtupleStationId id(seg->mdtHOT()[0]->identify()); - id.SetMultilayer(0); - if(m_selected_p_by_segment) m_selected_p_by_segment->Fill(trk->p()); - //store segment if it is the first in the station - if(segments[id] == NULL) { - segments[id] = seg; - continue; - } - //overwrite segment if this has more hits than the stored segment - MuonCalibSegment *stored(segments[id]); - if(stored->mdtHitsOnTrack() < seg->mdtHitsOnTrack()) { - segments[id] = seg; - continue; - } - if(stored->mdtHitsOnTrack() > seg->mdtHitsOnTrack()) { - continue; - } - //overwrite segment if the new one has a better chi^2 - if(stored->chi2() > seg->chi2()){ - segments[id] = seg; - } - } - } -} //end ExtraRegionSelector::prepareSegments - -} // namespace Muoncalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelectorFast.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelectorFast.cxx deleted file mode 100644 index cebfdd019aa2abac53228915b834c39ba2835f41..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelectorFast.cxx +++ /dev/null @@ -1,217 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "MuonCalibStandAloneExtraTools/ExtraRegionSelectorFast.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibExtraTreeEvent -#include "MuonCalibExtraTreeEvent/MuonCalibEvent_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibTrack_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibHit_E.h" - -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" - -#include "TFile.h" -#include "TH1.h" -#include "TH2.h" -#include "TDirectory.h" -#include <algorithm> - -namespace MuonCalib { - -inline void fill_histogram(TH1F *&hist, const Double_t &val) { - if (hist) hist->Fill(val); -} - -inline bool ExtraRegionSelectorFast::isOnTrack(const MuonCalibSegment &seg, const std::list<std::set<MuonFixedId> > &track_hits) { - int n_max_match(0); - int max_missing(seg.mdtHitsOnTrack() - m_max_hits_not_on_track); - int n_min_hits_on_track(max_missing<m_min_hits_on_track ? m_min_hits_on_track : max_missing); - for(std::list<std::set<MuonFixedId> >::const_iterator it=track_hits.begin(); it!=track_hits.end(); it++) { - int n_match(0); - for(MuonCalibSegment::MdtHitCit hit_it=seg.mdtHOTBegin(); hit_it!=seg.mdtHOTEnd(); hit_it++) { - if(it->find((*hit_it)->identify()) != it->end()) { - n_match++; - } - if((!m_n_match_vs_missing) && n_match>=n_min_hits_on_track) return true; - } - if(n_max_match<n_match) { - n_max_match=n_match; - } - } - if(m_n_match_vs_missing) { - m_n_match_vs_missing->Fill(seg.mdtHitsOnTrack() - n_max_match, n_max_match); - if(n_max_match>=n_min_hits_on_track) return true; - } - return false; -} //end ExtraRegionSelectorFast::isOnTrack - -/////////////////////////// -// ExtraRegionSelectorFast // -/////////////////////////// -ExtraRegionSelectorFast::ExtraRegionSelectorFast(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p) { - m_exclusive_segments = false; - declareProperty("ExclusiveSegments", m_exclusive_segments); - declareProperty("TrackAutors", m_track_author_vec); - m_min_hits = 1; - declareProperty("MinHits", m_min_hits); - m_max_hits = 0; - declareProperty("MaxHits", m_max_hits); - m_select_seg_author = 4; - declareProperty("SelectSegmentAuthor", m_select_seg_author); - m_momentum_cut=-1.5; - declareProperty("MomentumCut", m_momentum_cut); - m_min_hits_on_track=3; - declareProperty("MinHitsOnTrack", m_min_hits_on_track); - m_max_hits_not_on_track=1; - declareProperty("MaxHitsNotOnTrack", m_max_hits_not_on_track); - m_do_debug_file=false; - declareProperty("DoDebugFile", m_do_debug_file); - m_debug_file=NULL; - m_all_p=NULL; - m_selected_p_by_track=NULL; - m_selected_p_by_segment=NULL; - m_n_match_vs_missing=NULL; - declareInterface< CalibSegmentPreparationTool >(this); -} //end ExtraRegionSelectorFast::ExtraRegionSelectorFast - -//////////////// -// initialize // -//////////////// -StatusCode ExtraRegionSelectorFast::initialize(void) { - MsgStream log(msgSvc(), name()); - StatusCode sc=service("RegionSelectionSvc", p_reg_sel_svc); - if(!sc.isSuccess()) { - log << MSG::ERROR <<"Cannot retrieve RegionSelectionSvc!" <<endmsg; - } - if(m_do_debug_file) { - TDirectory *prev_dir=gDirectory; - m_debug_file = new TFile("ExtraRegionSelectorFast.root", "RECREATE"); - m_all_p = new TH1F("all_p", "" ,20000, -100000, 100000); - m_selected_p_by_track = new TH1F("selected_p_by_track", "" ,20000, -100000, 100000); - m_selected_p_by_segment = new TH1F("selected_p_by_segment", "" ,20000, -100000, 100000); - m_n_match_vs_missing = new TH2F("n_match", "", 30, -0.5, 29.5, 30, -0.5, 29.5); - prev_dir->cd(); - } - m_track_author.clear(); - m_track_author.insert(m_track_author_vec.begin(), m_track_author_vec.end()); - return sc; -} //end ExtraRegionSelectorFast::initialize - -StatusCode ExtraRegionSelectorFast::finalize(void) { - if(m_do_debug_file) { - m_debug_file->Write(); - delete m_all_p; - delete m_selected_p_by_track; - delete m_selected_p_by_segment; - delete m_debug_file; - } - return StatusCode::SUCCESS; -} - -void ExtraRegionSelectorFast::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - MsgStream log(msgSvc(), name()); - if(event==NULL) { - log << MSG::FATAL << "event=NULL"<<endmsg; - event=NULL; - return; - } - const MuonCalibEvent *e(event); - const MuonCalibEvent_E *e_event=dynamic_cast<const MuonCalibEvent_E *>(e); - if(e_event==NULL) { - log << MSG::FATAL << "This tool works only with extra events!"<<endmsg; - event=NULL; - return; - } - segments.clear(); - std::list<std::set<MuonFixedId> > track_hits; - for(MuonCalibEvent_E::TrackVec::const_iterator tit=e_event->beginTrack(); tit!=e_event->endTrack(); tit++){ - const MuonCalibTrack_E *trk(*tit); - if (m_track_author.size()>0 && m_track_author.find(trk->author())==m_track_author.end()) - continue; - fill_histogram(m_all_p, 1.0/trk->qOverP()); - if (m_momentum_cut>-1) { - if(trk->qOverP()==0 || trk->p()>1e8) continue; - if(m_momentum_cut>=0 && std::abs(trk->p())<m_momentum_cut) continue; - } - fill_histogram(m_selected_p_by_segment, 1.0/trk->qOverP()); - std::set<MuonFixedId> selected_hits; - bool has_hits_in_region(false); - for(MuonCalibTrack_E::HitVector::const_iterator hitit=trk->beginHit(); hitit!=trk->endHit(); hitit++) { - const MuonCalibHit_E *hit(*hitit); - const MuonFixedId id(hit->identify()); - if(!id.is_mdt()) continue; - if(!has_hits_in_region && p_reg_sel_svc->isInRegion(id)){ - has_hits_in_region=true; - } - selected_hits.insert(id); - } - if(selected_hits.size()>0 && has_hits_in_region) - track_hits.push_back(selected_hits); - } - if(track_hits.size()==0) - return; - std::vector<unsigned int> calib_region_hit_map; -//---------------------loop on all patterns------------------------------------- - MuonCalibEvent::MCPVecCit pat_it = event->patternBegin(); - MuonCalibEvent::MCPVecCit pat_it_end = event->patternEnd(); - for( ;pat_it!=pat_it_end; ++pat_it) { - //--------------------loop on all segments-------------------------------------- - MuonCalibPattern::MuonSegmentVec::const_iterator seg_it = (*pat_it)->muonSegBegin(); - MuonCalibPattern::MuonSegmentVec::const_iterator seg_it_end = (*pat_it)->muonSegEnd(); - for ( ; seg_it!=seg_it_end; ++seg_it) { - MuonCalibSegment *seg = *seg_it; - if (m_select_seg_author && m_select_seg_author!=seg->author()) - continue; - if(!isOnTrack(*seg, track_hits)) - continue; - //check count hits in the calibration region and remove others - calib_region_hit_map.clear(); - bool reject(false); - int count(0); - for(MuonCalibSegment::MdtHitCit hit_it=seg->mdtHOTBegin(); hit_it!=seg->mdtHOTEnd(); hit_it++){ - unsigned int is_in_region(static_cast<unsigned int>(!p_reg_sel_svc->isInRegion((*hit_it)->identify())));// || m_suppressed_tubes.find((*hit_it)->identify())!=m_suppressed_tubes.end())); - calib_region_hit_map.push_back(is_in_region); - if(is_in_region!=0 && m_exclusive_segments) { - reject=true; - break; - } - if(is_in_region==0) - count++; - } - if(reject) continue; - if(count<m_min_hits || (count>m_max_hits && m_max_hits>0)) continue; - if(count==0) continue; - seg->refineMdtSelection(calib_region_hit_map); - NtupleStationId id(seg->mdtHOT()[0]->identify()); - id.SetMultilayer(0); - id.SetAuthor(seg->author()); - //store segment if it is the first in the station - if(segments[id] == NULL){ - segments[id] = seg; - continue; - } - //overwrite segment if this has more hits than the stored segment - MuonCalibSegment *stored(segments[id]); - if(stored->mdtHitsOnTrack() < seg->mdtHitsOnTrack()) { - segments[id] = seg; - continue; - } - if(stored->mdtHitsOnTrack() > seg->mdtHitsOnTrack()) { - continue; - } - //overwrite segment if the new one has a better chi^2 - if(stored->chi2() > seg->chi2()){ - segments[id] = seg; - } - } - } -} //end ExtraRegionSelectorFast::prepareSegments - -} // namespace Muoncalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelectorSuperFast.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelectorSuperFast.cxx deleted file mode 100644 index e48691238722f67c07f515bc649ad7ae6645c939..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/ExtraRegionSelectorSuperFast.cxx +++ /dev/null @@ -1,169 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "MuonCalibStandAloneExtraTools/ExtraRegionSelectorSuperFast.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//MuonCalibExtraTreeEvent -#include "MuonCalibExtraTreeEvent/MuonCalibEvent_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibTrack_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibHit_E.h" - -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" - -#include "TFile.h" -#include "TH1.h" -#include "TH2.h" -#include "TDirectory.h" -#include <algorithm> - -namespace MuonCalib { - - inline void fill_histogram(TH1F * & hist, const Double_t & val) { - if (hist) hist->Fill(val); - } - - -/////////////////////////// -// ExtraRegionSelectorSuperFast // -/////////////////////////// - -ExtraRegionSelectorSuperFast::ExtraRegionSelectorSuperFast(const std::string &t, const std::string &n, const IInterface *p): AthAlgTool(t, n, p) { - m_exclusive_segments = false; - declareProperty("ExclusiveSegments", m_exclusive_segments); - declareProperty("TrackAutors", m_track_author_vec); - m_min_hits = 1; - declareProperty("MinHits", m_min_hits); - m_max_hits = 0; - declareProperty("MaxHits", m_max_hits); - m_momentum_cut=-1.5; - declareProperty("MomentumCut", m_momentum_cut); - m_do_debug_file=false; - declareProperty("DoDebugFile", m_do_debug_file); - m_debug_file=NULL; - m_all_p=NULL; - m_selected_p_by_track=NULL; - m_selected_p_by_segment=NULL; - m_n_match_vs_missing=NULL; - declareInterface< CalibSegmentPreparationTool >(this); -} - -//////////////// -// initialize // -//////////////// -StatusCode ExtraRegionSelectorSuperFast::initialize(void) { - MsgStream log(msgSvc(), name()); - StatusCode sc=service("RegionSelectionSvc", p_reg_sel_svc); - if(!sc.isSuccess()) { - log << MSG::ERROR <<"Cannot retrieve RegionSelectionSvc!" <<endmsg; - } - if(m_do_debug_file) { - TDirectory *prev_dir=gDirectory; - m_debug_file = new TFile("ExtraRegionSelectorSuperFast.root", "RECREATE"); - m_all_p = new TH1F("all_p", "" ,20000, -100000, 100000); - m_selected_p_by_track = new TH1F("selected_p_by_track", "" ,20000, -100000, 100000); - m_selected_p_by_segment = new TH1F("selected_p_by_segment", "" ,20000, -100000, 100000); - m_n_match_vs_missing = new TH2F("n_match", "", 30, -0.5, 29.5, 30, -0.5, 29.5); - prev_dir->cd(); - } - m_track_author.clear(); - m_track_author.insert(m_track_author_vec.begin(), m_track_author_vec.end()); - return sc; -} - -StatusCode ExtraRegionSelectorSuperFast::finalize(void) { - if(m_do_debug_file) { - m_debug_file->Write(); - delete m_all_p; - delete m_selected_p_by_track; - delete m_selected_p_by_segment; - delete m_debug_file; - } - return StatusCode::SUCCESS; -} - -void ExtraRegionSelectorSuperFast::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - MsgStream log(msgSvc(), name()); - if(event==NULL) { - log << MSG::FATAL << "event=NULL"<<endmsg; - event=NULL; - return; - } - const MuonCalibEvent *e(event); - const MuonCalibEvent_E *e_event=dynamic_cast<const MuonCalibEvent_E *>(e); - if(e_event==NULL) { - log << MSG::FATAL << "This tool works only with extra events!"<<endmsg; - event=NULL; - return; - } - segments.clear(); - std::list<const MuonCalibSegment *> track_segments; - for(MuonCalibEvent_E::TrackVec::const_iterator tit=e_event->beginTrack(); tit!=e_event->endTrack(); tit++) { - const MuonCalibTrack_E *trk(*tit); - if (m_track_author.size()>0 && m_track_author.find(trk->author())==m_track_author.end()) - continue; - fill_histogram(m_all_p, 1.0/trk->qOverP()); - if (m_momentum_cut>-1) { - if(trk->qOverP()==0 || trk->p()>1e8) continue; - if(m_momentum_cut>=0 && std::abs(trk->p())<m_momentum_cut) continue; - } - const std::vector<const MuonCalibSegment *> &trkseg(trk->segmetnsOnTrack()); - for(unsigned int i=0; i<trkseg.size(); i++) { - track_segments.push_back(trkseg[i]); - } - fill_histogram(m_selected_p_by_segment, 1.0/trk->qOverP()); - } - if(track_segments.size()==0) - return; - std::vector<unsigned int> calib_region_hit_map; -//--------------------loop on all segemnts-------------------------------------- - for (std::list<const MuonCalibSegment *>::iterator seg_it=track_segments.begin() ; seg_it!=track_segments.end(); ++seg_it) { - MuonCalibSegment *seg = const_cast<MuonCalibSegment *>(*seg_it); - //check count hits in the calibration region and remove others - calib_region_hit_map.clear(); - bool reject(false); - int count(0); - for(MuonCalibSegment::MdtHitCit hit_it=seg->mdtHOTBegin(); hit_it!=seg->mdtHOTEnd(); hit_it++) { - unsigned int is_in_region(static_cast<unsigned int>(!p_reg_sel_svc->isInRegion((*hit_it)->identify())));// || m_suppressed_tubes.find((*hit_it)->identify())!=m_suppressed_tubes.end())); - calib_region_hit_map.push_back(is_in_region); - if(is_in_region!=0 && m_exclusive_segments) { - reject=true; - break; - } - if(is_in_region==0) count++; - } - if(reject) continue; - if(count<m_min_hits || (count>m_max_hits && m_max_hits>0)) continue; - if(count==0) continue; - seg->refineMdtSelection(calib_region_hit_map); - NtupleStationId id(seg->mdtHOT()[0]->identify()); - id.SetMultilayer(0); - id.SetAuthor(seg->author()); - //store segment if it is the first in the station - if(segments[id] == NULL) { - segments[id] = seg; - continue; - } - //overwrite segment if this has more hits than the stored segment - MuonCalibSegment *stored(segments[id]); - if(stored->mdtHitsOnTrack() < seg->mdtHitsOnTrack()) { - segments[id] = seg; - continue; - } - if(stored->mdtHitsOnTrack() > seg->mdtHitsOnTrack()) { - continue; - } - //overwrite segment if the new one has a better chi^2 - if(stored->chi2() > seg->chi2()) { - segments[id] = seg; - } - } -} //end ExtraRegionSelectorSuperFast::prepareSegments - -} // namespace Muoncalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/HistogramManager.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/HistogramManager.cxx deleted file mode 100644 index 91c2ab6259c16944caf8251e9e24490b2d6abd86..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/HistogramManager.cxx +++ /dev/null @@ -1,2073 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneExtraTools/MDTName.h" - -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include <array> - -namespace { - template<int n> - inline void - setArray(const std::array<int,n> & a, TH1F * href){ - for (const auto & i:a){ - href->SetBinContent(i,0); - } - } - const std::vector<int> bir4={1,2,3, 31,32,33, 61,62,63, 91,92,93}; - const std::vector<int> bir2={28,29,30, 58,59,60, 88,89,90, 118,119,120}; - const std::vector<int> bir1={1,2,3,4,5,6, 31,32,33,34,35,36, 61,62,63,64,65,66, 91,92,93,94,95,96}; - const std::vector<int> bir5={22,23,24, 46,47,48, 70,71,72, 94,95,96}; - const std::vector<int> bir3={34,35,36, 70,71,72, 106,107,108, 142,143,144, 178,179,180, 214,215,216, 250,251,252, 286,287,288}; - - const std::vector<int> bms4or6={41,42,43,44,45,46,47, 89,90,91,92,93,94,95,96, 137,138,139,140,141,142,143,144}; - const std::map<const std::string, const std::vector<int> & > string2Vec ={ - {"BIR2A11", bir2}, - {"BIR1A11", bir1}, - {"BIR2A15", bir2}, - {"BIR1A15", bir1}, - {"BIR4A11", bir4}, - //{"BIR3A11", bir3}, - {"BIR4A15", bir4}, - //{"BIR3A15", bir3}, - {"BMS4A02", bms4or6}, - {"BMS4A04", bms4or6}, - {"BMS4A06", bms4or6}, - {"BMS4A08", bms4or6}, - {"BMS4A10", bms4or6}, - {"BMS4A16", bms4or6}, - {"BIR5A11", bir5}, - {"BIR5A15", bir5}, - {"BMS6A02", bms4or6}, - {"BMS6A04", bms4or6}, - {"BMS6A06", bms4or6}, - {"BMS6A08", bms4or6}, - {"BMS6A10", bms4or6}, - {"BMS6A16", bms4or6}, - {"BIR2C11", bir2}, - {"BIR1C11", bir1}, - {"BIR2C15", bir2}, - {"BIR1C15", bir1}, - {"BIR4C11", bir4}, - //{"BIR3C11", bir3}, - {"BIR4C15", bir4}, - //{"BIR3C15, bir3}, - {"BMS4C02", bms4or6}, - {"BMS4C04", bms4or6}, - {"BMS4C06", bms4or6}, - {"BMS4C08", bms4or6}, - {"BMS4C10", bms4or6}, - {"BMS4C16", bms4or6}, - {"BIR5C11", bir5}, - {"BIR5C15", bir5}, - {"BMS6C02", bms4or6}, - {"BMS6C04", bms4or6}, - {"BMS6C06", bms4or6}, - {"BMS6C08", bms4or6}, - {"BMS6C10", bms4or6}, - {"BMS6C16", bms4or6} - }; - const - std::map<std::string,std::vector<std::pair<int, int> > > disconnected={ - {"BIL1C09",{ {219,41} } }, - {"BIL2A05",{ {144,-41} } }, - {"BIL2C01",{ {207,21} } }, - {"BIL3C09",{ {151,21} } }, - {"BIL4A07",{ {185,21} } }, - {"BIL5A01",{ {151,21} } }, - {"BIL5A13",{ {222,41} } }, - {"BIL5C03",{ {223,41} } }, - {"BIL5C09",{ {25,-11}, {73,-31}, {88,-31} } }, - {"BIL6A01",{ {37,-21} } }, - {"BIR4A11",{ {34,-21} } }, - {"BIR4C11",{ {79,-31}, {80,-31}, {81,-31} } }, - {"BIS1A14",{ {152,11} } }, - {"BIS1C08",{ {190,21} } }, - {"BIS1C12",{ {61,-21}, {108,-31}, {136,-41} } }, - {"BIS2C02",{ {77,-31} } }, - {"BIS2C04",{ {30,-11}, {240,41} } }, - {"BIS2C08",{ {1,-11}, {10,-11}, {127,11}, {202,31} } }, - {"BIS2C10",{ {94,-41}, {96,-41} } }, - {"BIS3A02",{ {188,31}, {195,31} } }, - {"BIS3A12",{ {184,31}, {185,31}, {214,41}, {215,41} } }, - {"BIS3C06",{ {140,11} } }, - {"BIS3C10",{ {90,-31} } }, - {"BIS3C16",{ {90,-31} } }, - {"BIS4C06",{ {3,-11} } }, - {"BIS4C08",{ {4,-11}, {214,41} } }, - {"BIS5A10",{ {181,31} } }, - {"BIS6A14",{ {60,-21}, {68,-31}, {76,-31} } }, - {"BIS7A08",{ {157,21} } }, - {"BMF1A12",{ {273,11} } }, - {"BMF1A14",{ {217,11}, {218,11}, {219,11} } }, - {"BMF1C14",{ {10,-11}, {55,-11}, {142,-21}, {231,11} } }, - {"BMF2A12",{ {184,-31} } }, - {"BMF2A14",{ {339,31} } }, - {"BMF2C12",{ {208,11}, {217,11}, {223,11}, {241,11} } }, - {"BMF2C14",{ {30,-11}, {60,-11}, {92,-21}, {97,-21}, {103,-21}, {245,11} } }, - {"BMF3C12",{ {38,-11} } }, - {"BML1A01",{ {250,21} } }, - {"BML1A09",{ {14,-11} } }, - {"BML1C03",{ {52,-21} } }, - {"BML2A01",{ {100,-21}, {236,21}, {295,31}, {304,31} } }, - {"BML2A07",{ {237,21}, {240,21} } }, - {"BML2A09",{ {57,-21} } }, - {"BML2C03",{ {68,-21} } }, - {"BML2C05",{ {42,-11}, {164,-31} } }, - {"BML2C07",{ {134,-31}, {221,11}, {234,21} } }, - {"BML2C15",{ {138,-31}, {162,-31} } }, - {"BML3A13",{ {302,31} } }, - {"BML3A15",{ {225,21} } }, - {"BML3C01",{ {322,31} } }, - {"BML3C15",{ {62,-21} } }, - {"BML4A01",{ {5,-11} } }, - {"BML4A03",{ {36,-11} } }, - {"BML4A11",{ {90,-31} } }, - {"BML4C05",{ {107,-31} } }, - {"BML4C09",{ {99,-31} } }, - {"BML4C15",{ {107,-31} } }, - {"BML5A11",{ {207,31} } }, - {"BML6A07",{ {162,11} } }, - {"BML6A09",{ {132,-31} } }, - {"BML6C07",{ {182,11} } }, - {"BML6C13",{ {200,21} } }, - {"BMS1A02",{ {1,-11}, {56,-11} } }, - {"BMS1A06",{ {248,21} } }, - {"BMS1C10",{ {244,21} } }, - {"BMS1C16",{ {264,21} } }, - {"BMS2A08",{ {63,-21} } }, - {"BMS2A10",{ {25,-11} } }, - {"BMS2A16",{ {49,-21}, {133,-31} } }, - {"BMS2C02",{ {240,21} } }, - {"BMS3A02",{ {86,-21} } }, - {"BMS3A04",{ {150,11}, {261,31} } }, - {"BMS3A06",{ {117,-31}, {175,11} } }, - {"BMS3A16",{ {1,-11} } }, - {"BMS3C08",{ {249,31} } }, - {"BMS3C10",{ {3,-11} } }, - {"BMS4A08",{ {199,21} } }, - {"BMS4A16",{ {127,-31} } }, - {"BMS4C02",{ {28,-11} } }, - {"BMS4C04",{ {184,11} } }, - {"BMS5C02",{ {22,-11} } }, - {"BMS5C04",{ {44,-21} } }, - {"BMS6A06",{ {56,-21} } }, - {"BMS6A10",{ {115,-31} } }, - {"BMS6C02",{ {102,-31} } }, - {"BOF1A12",{ {146,-31}, {225,11}, {249,11} } }, - {"BOF1A14",{ {188,-31}, {278,11} } }, - {"BOF3A12",{ {147,-31}, {345,31}, {370,31} } }, - {"BOF5A14",{ {1,-11} } }, - {"BOF5C14",{ {163,11}, {189,11} } }, - {"BOF7C12",{ {104,-31} } }, - {"BOG2C12",{ {148,11}, {197,21} } }, - {"BOL1A01",{ {32,-11}, {189,-31} } }, - {"BOL1A13",{ {1,-11}, {49,-11} } }, - {"BOL1C09",{ {52,-11} } }, - {"BOL2A01",{ {81,-21} } }, - {"BOL2A05",{ {389,31} } }, - {"BOL2A07",{ {72,-11} } }, - {"BOL3A13",{ {31,-11}, {41,-11} } }, - {"BOL3C15",{ {235,21} } }, - {"BOL4C01",{ {241,11}, {242,11}, {380,31}, {381,31} } }, - {"BOL5A01",{ {204,-31} } }, - {"BOL6A03",{ {19,-11} } }, - {"BOL6A11",{ {147,-31}, {148,-31}, {149,-31}, {150,-31} } }, - {"BOL6A13",{ {281,31} } }, - {"BOS1A02",{ {323,21} } }, - {"BOS1A08",{ {99,-31} } }, - {"BOS1C06",{ {44,-11} } }, - {"BOS1C16",{ {72,-11} } }, - {"BOS2C02",{ {145,-31}, {180,-31} } }, - {"BOS2C08",{ {54,-11}, {154,-31}, {209,-31} } }, - {"BOS2C10",{ {392,31} } }, - {"BOS2C16",{ {360,21} } }, - {"BOS3A08",{ {117,-21} } }, - {"BOS3A16",{ {369,31} } }, - {"BOS3C02",{ {217,11} } }, - {"BOS3C06",{ {305,21} } }, - {"BOS3C08",{ {227,11} } }, - {"BOS3C16",{ {55,-11} } }, - {"BOS4A04",{ {310,21} } }, - {"BOS4A06",{ {204,-31} } }, - {"BOS4A08",{ {432,31} } }, - {"BOS4A10",{ {2,-11} } }, - {"BOS4A16",{ {20,-11} } }, - {"BOS4C16",{ {145,-31} } }, - {"BOS5A04",{ {21,-11}, {28,-11} } }, - {"BOS5A08",{ {50,-11}, {122,-21}, {243,11} } }, - {"BOS5A16",{ {147,-31} } }, - {"BOS5C10",{ {417,31} } }, - {"BOS6A02",{ {21,-11} } }, - {"BOS6A10",{ {337,31}, {362,31} } }, - {"BOS6A16",{ {384,31} } }, - {"EIL1A01",{ {267,41} } }, - {"EIL4A13",{ {247,11}, {393,41} } }, - {"EIL4C13",{ {432,41} } }, - {"EIL5A01",{ {191,11} } }, - {"EIL5C01",{ {169,11} } }, - {"EIS1A14",{ {51,-21} } }, - {"EIS1C04",{ {322,41}, {323,41} } }, - {"EML1C03",{ {113,-31} } }, - {"EML1C09",{ {319,31} } }, - {"EML1C11",{ {36,-11} } }, - {"EML2A13",{ {76,-21} } }, - {"EML2A15",{ {330,31} } }, - {"EML2C07",{ {185,-31}, {190,-31}, {191,-31}, {192,-31} } }, - {"EML2C15",{ {161,-31} } }, - {"EML3C05",{ {235,11} } }, - {"EML3C07",{ {291,21} } }, - {"EML3C09",{ {60,-11} } }, - {"EML4A03",{ {199,11}, {321,31} } }, - {"EML4A05",{ {8,-11} } }, - {"EML4A07",{ {326,31}, {327,31} } }, - {"EML4A09",{ {100,-21}, {102,-21}, {103,-21}, {255,11}, {256,11}, {257,21}, {320,21} } }, - {"EML4A11",{ {30,-11}, {69,-21}, {91,-21}, {140,-31}, {198,11}, {259,21}, {260,21}, {261,21} } }, - {"EML4A13",{ {162,-31}, {228,11}, {271,21}, {359,31} } }, - {"EML4C03",{ {296,21}, {335,31} } }, - {"EML4C05",{ {158,-31} } }, - {"EMS2A08",{ {219,11} } }, - {"EMS2C14",{ {64,-11}, {90,-21} } }, - {"EMS3A02",{ {187,-31} } }, - {"EMS3A12",{ {1,-11} } }, - {"EMS3C04",{ {252,11} } }, - {"EMS3C12",{ {142,-31} } }, - {"EMS3C16",{ {54,-11}, {357,31} } }, - {"EMS4A12",{ {119,-21} } }, - {"EMS5A02",{ {336,31} } }, - {"EMS5A06",{ {109,-21}, {191,-31} } }, - {"EMS5A08",{ {112,-21} } }, - {"EMS5A12",{ {236,11} } }, - {"EOL3A01",{ {74,-21}, {159,11}, {216,21} } }, - {"EOL3A15",{ {167,11}, {168,11} } }, - {"EOL4C01",{ {177,11}, {178,11} } }, - {"EOL5A05",{ {42,-11}, {67,-21} } }, - {"EOL5C07",{ {152,11} } }, - {"EOL6A03",{ {4,-11} } }, - {"EOL6A11",{ {38,-11} } }, - {"EOS4A12",{ {191,11}, {233,21} } }, - {"EOS5A02",{ {11,-11} } }, - {"EOS5C14",{ {176,11} } }, - {"EOS6C04",{ {203,21} } } - }; - -} - -using namespace MuonCalib; - -HistogramManager::HistogramManager() { - m_idHelper = nullptr; - m_rootfile = nullptr; - m_hList(0); - m_doTracks = false; -} -HistogramManager::HistogramManager(const Muon::IMuonIdHelperSvc* idHelper) { - m_idHelper = idHelper; - m_rootfile = nullptr; - m_hList(0); - m_doTracks = false; -} - -void HistogramManager::SetDoTracks(bool the_tracks) { - m_doTracks=the_tracks; -} - -void HistogramManager::buildGlobalHistos() { - - if (!m_rootfile->IsOpen()){ - std::string defaultOutputFile="outDQA.root"; - openOutputFile(defaultOutputFile); - } - - m_rootfile->cd(); - - std::string dir_name; - // Building Base directory : - // /GLOBAL/ - dir_name="/GLOBAL"; - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - // A new TDirectoryFile gets owned by the current directory (side effect). - new TDirectoryFile("GLOBAL","GLOBAL"); - } - - m_rootfile->cd("/GLOBAL"); - - TH2F * globalOccupancy; - - // Inner,Middle,Outer,(extra) chambers of the region (BA/BC/EA/EC) : - - globalOccupancy = new TH2F("Global_HitsPerML_Inner","Global HitsPerML Inner", - 45, -22.5, 22.5, 32, 0.5, 16.5 ); - globalOccupancy->GetXaxis()->SetTitle("Chamber_etaId"); - globalOccupancy->GetYaxis()->SetTitle("sectors"); - - globalOccupancy = new TH2F("Global_HitsPerML_Middle","Global HitsPerML Middle", - 45, -22.5, 22.5, 32, 0.5, 16.5 ); - globalOccupancy->GetXaxis()->SetTitle("Chamber_etaId"); - globalOccupancy->GetYaxis()->SetTitle("sectors"); - - globalOccupancy = new TH2F("Global_HitsPerML_Outer","Global HitsPerML Outer", - 45, -22.5, 22.5, 32, 0.5, 16.5 ); - globalOccupancy->GetXaxis()->SetTitle("Chamber_etaId"); - globalOccupancy->GetYaxis()->SetTitle("sectors"); - - TH2F * phiVseta; - phiVseta = new TH2F("phi_vs_eta","Global Segment_phi Vs Segment_eta", - 40, -4., 4., 90, -180., 180. ); - phiVseta->GetYaxis()->SetTitle("Segment_phi (deg)"); - phiVseta->GetXaxis()->SetTitle("Segment_eta"); - -} - // TRACK Histograms .... -void HistogramManager::buildTrackHistos() { - - if (!m_rootfile->IsOpen()){ - std::string defaultOutputFile="outDQA.root"; - openOutputFile(defaultOutputFile); - } - - m_rootfile->cd(); - std::string dir_name; - dir_name="TRACKS"; - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - // A new TDirectoryFile gets owned by the current directory (side effect). - new TDirectoryFile("TRACKS","TRACKS"); - } - - m_rootfile->cd("/TRACKS"); - - TH1F * tmbts1; - tmbts1=new TH1F("mbts1_time","Time mbts 1 (plus)",200,-100.,100.); - tmbts1->GetXaxis()->SetTitle("time (ns)"); - - TH1F * tmbts2; - tmbts2=new TH1F("mbts2_time","Time mbts 2 (minus)",200,-100.,100.); - tmbts2->GetXaxis()->SetTitle("time (ns)"); - - TH2F * tmbts12; - tmbts12=new TH2F("mbts1VSmbts2","Time mbts 1 VS 2 ",200,-100.,100., 200,-100.,100.); - tmbts12->GetXaxis()->SetTitle("time (ns)"); - tmbts12->GetYaxis()->SetTitle("time (ns)"); - - TH1F * Dtmbts; - Dtmbts=new TH1F("mbts_Dtime","Time difference mbts",200,-100.,100.); - Dtmbts->GetXaxis()->SetTitle("#Delta t (ns)"); - - TH1F * trkIDmult; - trkIDmult=new TH1F("trk_ID_mult","ID Tracks per Event",51,-0.5,50.5); - trkIDmult->GetXaxis()->SetTitle("num_ID_Tracks_per_event"); - - TH1F * seg_nb; - seg_nb=new TH1F("seg_nb","Segments per Track",12,-1.5,10.5); - seg_nb->GetXaxis()->SetTitle("Associated Segments per track"); - - TH1F * trk_nb; - trk_nb=new TH1F("trk_nb","Tracks per Event",10,-0.5,9.5); - trk_nb->GetXaxis()->SetTitle("numTracks_per_event"); - - TH1F * trk_nb_sel; - trk_nb_sel=new TH1F("trk_nb_sel","Tracks per Event",10,-0.5,9.5); - trk_nb_sel->GetXaxis()->SetTitle("numTracks_per_event"); - - TH1F * trk_author1; - trk_author1=new TH1F("trk_authorMoore","Track Author Moore",14,-0.5,13.5); - trk_author1->GetXaxis()->SetBinLabel(1,"ID"); - trk_author1->GetXaxis()->SetBinLabel(2,"Moore"); - trk_author1->GetXaxis()->SetBinLabel(3,"ExtrSA nocalo"); - trk_author1->GetXaxis()->SetBinLabel(4,"ExtrSA calo"); - trk_author1->GetXaxis()->SetBinLabel(5,"MuidSA"); - trk_author1->GetXaxis()->SetBinLabel(6,"MuidCB"); - trk_author1->GetXaxis()->SetBinLabel(7,"MuonCombined?"); - trk_author1->GetXaxis()->SetBinLabel(8,"MuTagIMO"); - trk_author1->GetXaxis()->SetBinLabel(9,"MuGirl"); - trk_author1->GetXaxis()->SetBinLabel(10,"AODMuidSA"); - trk_author1->GetXaxis()->SetBinLabel(11,"AODMuidCB"); - trk_author1->GetXaxis()->SetBinLabel(12,"AODMuTagIMO"); - trk_author1->GetXaxis()->SetBinLabel(13,"AODMuGirl"); - - TH1F * trk_author2; - trk_author2=new TH1F("trk_authorMuBoy","Track Author MuonBoy",14,-0.5,13.5); - trk_author2->GetXaxis()->SetBinLabel(1,"ID"); - trk_author2->GetXaxis()->SetBinLabel(2,"MuonBoy"); - trk_author2->GetXaxis()->SetBinLabel(3,"Staco"); - trk_author2->GetXaxis()->SetBinLabel(4,"MuTagTracks"); - trk_author2->GetXaxis()->SetBinLabel(5,"StacoMuonSA"); - trk_author2->GetXaxis()->SetBinLabel(6,"StacoMuonCB"); - trk_author2->GetXaxis()->SetBinLabel(7,"StacoMuonTag"); - - new TH1F("trk_pt","; pt (GeV)",1000,0.,1000.); - - new TH1F("trk_eta","; #eta",80,-4.,4.); - new TH1F("trk_phi","; #phi",80,-4.,4.); - new TH2F("trk_etaVSphi",";#eta; #phi",80,-4.,4.,80,-4.,4.); - new TH2F("trk_d0VSz0",";d0(mm); z0(mm)",2000,-5000.,5000.,200,-500.,500.); - TH2F * h2 = new TH2F("trk_yVSx","y Vs x",1000,-15000.,15000.,1000,-15000.,15000.); - h2->GetXaxis()->SetTitle("x(mm)"); - h2->GetYaxis()->SetTitle("y(mm)"); - new TH1F("trk_qOverP","; Q over P",1000,-0.001,0.001); - new TH1F("trk_chi2dof","; #chi^{2}/ndof",100,0.,10.); - new TH2F("trk_chi2dof_VS_author","; #chi^{2}/ndof; Track Author",100,0.,10., 2220,-10.,1100.); - new TH2F("trk_chi2dof_VS_eta",";#eta; #chi^{2}/ndof",80, -4.,4.,100,0.,10.); - new TH1F("trk_d0","; d0 ",200,-500.,500.); - new TH1F("trk_z0ip","; z0ip (mm)",2000,-5000.,5000.); - new TH2F("trk_mdthits_VS_eta",";#eta; nr hits per track",80, -4.,4.,100,-0.5,99.5); - new TH2F("trk_mdthits_VS_phi",";#phi; nr hits per track",80, -4.,4.,100,-0.5,99.5); - new TH1F("hit_driftR","; drift Radius (mm)",300,-15.,15.); - new TH1F("hit_pull","; pull (mm)",200,-10.,10.); - new TH1F("hit_mdt","; mdt hits per track", 50, -0.5, 49.5); - new TH2F("hit_mdtVSrpc","; rpc hits; mdt hits", 50, -0.5, 49.5, 50, -0.5, 49.5); - new TH1F("hit_rpc","; rpc hits per track", 50, -0.5, 49.5); - new TH1F("hit_tgc","; tgc hits per track", 50, -0.5, 49.5); - new TH1F("hit_csc","; csc hits per track", 50, -0.5, 49.5); - - TH1F * h1 = new TH1F("trk_ID_ntrack","ID tracks",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("nb ID tracks"); - h1 = new TH1F("trk_ID_npixel","Pixel Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("Pixel Hits"); - h1 = new TH1F("trk_ID_nsct","SCT Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("SCT Hits"); - h1 = new TH1F("trk_ID_ntrt","TRT Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("TRT Hits"); - new TH1F("trk_ID_p","P in the Inner Tracker; p (GeV)",200,0.,100.); - new TH1F("trk_Ev_trkveto","TRACK VETO in the Inner Tracker; TRACK VETO",20,-0.5,19.5); - h1 = new TH1F("trk_Ev_pveto","P VETO in the Inner Tracker",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("PVETO"); - new TH2F("trk_ID_pixsctVStrt","pix+sct VS trt; npixel + nsct; ntrt",105,-5.5,99.5,105,-5.5,99.5); - new TH2F("trk_ID_pixVSsct","pix VS sct; npixel; nsct",55,-5.5,49.5,55,-5.5,49.5); - - h1 = new TH1F("trk_SA_ntrack","SA tracks",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("nb SA tracks"); - - h1=new TH1F("trk_SAIP_ntrack","SAIP tracks",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("nb SAIP tracks"); - - h1 = new TH1F("trk_Tag_ntrack","nb Tag tracks",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("nb Tag tracks"); - h1=new TH1F("trk_Tag_npixel","Pixel Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("Pixel Hits"); - h1=new TH1F("trk_Tag_nsct","SCT Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("SCT Hits"); - h1 = new TH1F("trk_Tag_ntrt","TRT Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("TRT Hits"); - h1 = new TH1F("trk_Tag_pveto","P VETO in the Inner Tracker",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("PVETO"); - new TH2F("trk_Tag_pixsctVStrt","pix+sct VS trt; npixel + nsct; ntrt",55,-5.5,49.5,55,-5.5,49.5); - new TH2F("trk_Tag_pixVSsct","pix VS sct; npixel; nsct",55,-5.5,49.5,55,-5.5,49.5); - - - h1 = new TH1F("trk_CB_ntrack","CB tracks",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("nb CB tracks"); - h1=new TH1F("trk_CB_npixel","Pixel Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("Pixel Hits"); - h1=new TH1F("trk_CB_nsct","SCT Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("SCT Hits"); - h1=new TH1F("trk_CB_ntrt","TRT Hits in the Inner Tracker",50,-0.5,49.5); - h1->GetXaxis()->SetTitle("TRT Hits"); - h1=new TH1F("trk_CB_pveto","P VETO in the Inner Tracker",20,-0.5,19.5); - h1->GetXaxis()->SetTitle("PVETO"); - new TH2F("trk_CB_pixsctVStrt","pix+sct VS trt; npixel + nsct; ntrt",55,-5.5,49.5,55,-5.5,49.5); - new TH2F("trk_CB_pixVSsct","pix VS sct; npixel; nsct",55,-5.5,49.5,55,-5.5,49.5); - - TH2F * trk_cutflow; - trk_cutflow=new TH2F("trk_cutflow","cut flow",5,0.5,5.5,9,-0.5,8.5); - trk_cutflow->GetXaxis()->SetBinLabel(1,"ID"); - trk_cutflow->GetXaxis()->SetBinLabel(2,"SA"); - trk_cutflow->GetXaxis()->SetBinLabel(3,"SA_IP"); - trk_cutflow->GetXaxis()->SetBinLabel(4,"Tag"); - trk_cutflow->GetXaxis()->SetBinLabel(5,"CB"); - trk_cutflow->GetYaxis()->SetBinLabel(1,"no cut"); - trk_cutflow->GetYaxis()->SetBinLabel(2,"cut 1"); - trk_cutflow->GetYaxis()->SetBinLabel(3,"cut 2"); - trk_cutflow->GetYaxis()->SetBinLabel(4,"cut 3"); - trk_cutflow->GetYaxis()->SetBinLabel(5,"cut 4"); - trk_cutflow->GetYaxis()->SetBinLabel(6,"cut 5"); - trk_cutflow->GetYaxis()->SetBinLabel(7,"cut 6"); - trk_cutflow->GetYaxis()->SetBinLabel(8,"cut 7"); - trk_cutflow->GetYaxis()->SetBinLabel(9,"cut 8"); - - new TH1F("trk_selected_cut5_pt","; pt (GeV)",200,0.,100.); - new TH1F("trk_selected_cut5_p","; p (GeV)",200,0.,100.); - new TH2F("trk_selected_cut5_etaVSphi","#eta; #phi",90,-4.5,4.5,90,-4.5,4.5); - - new TH1F("trk_selected_pt","; pt (GeV)",200,0.,100.); - new TH1F("trk_selected_p","; p (GeV)",200,0.,100.); - new TH1F("trk_selected_eta","; #eta",90,-4.5,4.5); - new TH1F("trk_selected_phi","; #phi",90,-4.5,4.5); - new TH2F("trk_selected_etaVSphi","#eta; #phi",90,-4.5,4.5,90,-4.5,4.5); - - new TH1F("trk_associated_Deltapt","; pt (GeV)",200,-10.,10.); - new TH1F("trk_associated_Deltap","; p (GeV)",200,-10.,10.); - - new TH1F("trk_associatedIP_Deltapt","; pt (GeV)",200,-10.,10.); - new TH1F("trk_associatedIP_Deltap","; p (GeV)",200,-10.,10.); - - buildDebugHistos(); - -} - -void HistogramManager::buildDebugHistos() { - - - if (!m_rootfile->IsOpen()){ - std::string defaultOutputFile="outDQA.root"; - openOutputFile(defaultOutputFile); - } - - m_rootfile->cd(); - std::string dir_name; - // Building Base directory : - // /DEBUG/ - dir_name=GetMdtDirectoryName(); - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - // A new TDirectoryFile gets owned by the current directory (side effect). - new TDirectoryFile("DEBUG","DEBUG"); - } - m_rootfile->cd("/DEBUG"); - - TH1F * h1 = new TH1F("nSegPerTrack","n Segments",21,-0.5,20.5); - h1->GetXaxis()->SetTitle("nSegments"); - TH2F * h2 = new TH2F("nSegPerTrack_HitCut","; Sector n.; nSegments",16,0.5,16.5,21,-0.5,20.5); - h2->SetTitle("Segment Per Track"); - - new TH2F("t0_BI","; Sector n.; t0Refit_BI (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_BM","; Sector n.; t0Refit_BM (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_BO","; Sector n.; t0Refit_BO (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_BO_BM","; Sector n.; t0Refit_BO-BM (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_BO_BI","; Sector n.; t0Refit_BO-BI (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_BM_BI","; Sector n.; t0Refit_BM-BI (ns)",16,0.5,16.5,400,-200.,200.); - - new TH2F("t0_EI","; Sector n.; t0Refit_EI (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_EM","; Sector n.; t0Refit_EM (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_EO","; Sector n.; t0Refit_EO (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_EO_EM","; Sector n.; t0Refit_EO-EM (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_EO_EI","; Sector n.; t0Refit_EO-EI (ns)",16,0.5,16.5,400,-200.,200.); - new TH2F("t0_EM_EI","; Sector n.; t0Refit_EM-EI (ns)",16,0.5,16.5,400,-200.,200.); - - new TH2F("trk_d0VSz0_GoodTime","d0(mm); z0(mm)",2000,-5000.,5000.,200,-500.,500.); - new TH2F("trk_d0VSz0_BadTime","d0(mm); z0(mm)",2000,-5000.,5000.,200,-500.,500.); - new TH2F("trk_d0VSz0_noSeg","d0(mm); z0(mm)",2000,-5000.,5000.,200,-500.,500.); -} - - -void HistogramManager::buildTopLevel(std::string region, std::string side,int sectorMin, int sectorMax) { - - std::string regionSide = region+"_"+side; - std::string dir_name="none"; - - if (!m_rootfile->IsOpen()){ - std::string defaultOutputFile="outDQA.root"; - openOutputFile(defaultOutputFile); - } - - m_rootfile->cd(); - - // if not already created building directory "GLOBAL" - dir_name="/GLOBAL"; - TDirectoryFile * global_dir=0; - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - global_dir = new TDirectoryFile("GLOBAL","GLOBAL"); - } else { - global_dir = (TDirectoryFile *) m_rootfile->GetDirectory(dir_name.c_str()); - } - - global_dir->cd(); - - TH2F * globalOccupancy; - - // all chambers of the region (BA/BC) : - if (region=="Barrel") { - globalOccupancy = (TH2F*) GetHisto("GLOBAL","Global_HitsPerML_Barrel"); - if (!globalOccupancy) { - globalOccupancy = new TH2F("Global_HitsPerML_Barrel","Global HitsPerML Barrel", - 81, -40.5, 40.5, 32, 0.5, 16.5 ); - globalOccupancy->GetXaxis()->SetTitle("Chamber_etaId (Inn,Mid,Out)"); - globalOccupancy->GetYaxis()->SetTitle("sectors"); - globalOccupancy->SetNdivisions(16,"Y"); - if (side=="A") { - globalOccupancy->SetAxisRange(0.5,40.5,"X"); - globalOccupancy->SetTitle("Global HitsPerML BA"); - } - if (side=="C") { - globalOccupancy->SetAxisRange(-40.5,-0.5,"X"); - globalOccupancy->SetTitle("Global HitsPerML BC"); - } - } else { - globalOccupancy->SetAxisRange(-40.5,40.5,"X"); - globalOccupancy->SetTitle("Global HitsPerML Barrel"); - } - } - // all chambers of the region (EA/EC) : - if (region=="Endcap") { - globalOccupancy = (TH2F*) GetHisto("GLOBAL","Global_HitsPerML_Endcap"); - if (!globalOccupancy) { - globalOccupancy = new TH2F("Global_HitsPerML_Endcap","Global HitsPerML Endcap", - 81, -40.5, 40.5, 32, 0.5, 16.5 ); - globalOccupancy->GetXaxis()->SetTitle("Chamber_etaId (Inn,Mid,Out,Extra)"); - globalOccupancy->GetYaxis()->SetTitle("sectors"); - globalOccupancy->SetNdivisions(16,"Y"); - if (side=="A") { - globalOccupancy->SetAxisRange(0.5,40.5,"X"); - globalOccupancy->SetTitle("Global HitsPerML EA"); - } - if (side=="C") { - globalOccupancy->SetAxisRange(-40.5,-0.5,"X"); - globalOccupancy->SetTitle("Global HitsPerML EC"); - } - } else { - globalOccupancy->SetAxisRange(-40.5,40.5,"X"); - globalOccupancy->SetTitle("Global HitsPerML Endcap"); - } - } - - m_rootfile->cd(); - // Building Base directory : - // /MDT/ - dir_name=GetMdtDirectoryName(); - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - // A new TDirectoryFile gets owned by the current directory (side effect). - new TDirectoryFile("MDT","MDT"); - } - // Building Base directory : - // /MDTvsRPC/ (for Barrel) - /MDTvsTGC/ (for Endcap) - dir_name = GetTDaqDirectoryName(region); - std::string MDTvsTriggerChambers="Undefined"; - if (region == "Barrel") MDTvsTriggerChambers="MDTvsRPC"; - if (region == "Endcap") MDTvsTriggerChambers="MDTvsTGC"; - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - // A new TDirectoryFile gets owned by the current directory (side effect). - new TDirectoryFile(MDTvsTriggerChambers.c_str(),MDTvsTriggerChambers.c_str()); - } - - // Building <region-side> (ex. Barrel_A) directories : - // motherdir = /MDT/; - std::string motherdir; - motherdir = GetMdtDirectoryName(); - m_rootfile->cd(motherdir.c_str()); - dir_name=GetMdtDirectoryName(region,side); - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - TDirectoryFile * mdt_region = new TDirectoryFile(regionSide.c_str(),regionSide.c_str()); - mdt_region->cd(); - TH1F * h; - TH2F * h2; - float t0Min=200.; - float t0Max=1200.; - int t0Nbins = 250; - float tdriftMin=600.; - float tdriftMax=800.; - int tdriftNbins = 100; - - std::string histoType; - std::string histoTitle; - // - histoType="t0PerSector_Inner"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,t0Nbins,t0Min,t0Max); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("t0 per ML (ns)"); - - histoType="t0PerSector_Middle"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,t0Nbins,t0Min,t0Max); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("t0 per ML (ns)"); - - histoType="t0PerSector_Outer"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,t0Nbins,t0Min,t0Max); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("t0 per ML (ns)"); - - if(region=="Endcap") - { - histoType="t0PerSector_extra"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,t0Nbins,t0Min,t0Max); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("t0 per ML (ns)"); - } - - histoType="tdriftPerSector_Inner"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,tdriftNbins,tdriftMin,tdriftMax); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("tdrift per ML (ns)"); - - histoType="tdriftPerSector_Middle"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,tdriftNbins,tdriftMin,tdriftMax); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("tdrift per ML (ns)"); - - histoType="tdriftPerSector_Outer"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,tdriftNbins,tdriftMin,tdriftMax); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("tdrift per ML (ns)"); - - if(region=="Endcap") - { - histoType="tdriftPerSector_extra"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5,tdriftNbins,tdriftMin,tdriftMax); - h2->GetXaxis()->SetTitle("Sector nr."); - h2->GetYaxis()->SetTitle("tdrift per ML (ns)"); - } - - histoType="time_Fit_t0"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),t0Nbins,t0Min,t0Max); - h->GetXaxis()->SetTitle("t0 (ns)"); - - histoType="time_Fit_tdrift"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),tdriftNbins,tdriftMin,tdriftMax); - h->GetXaxis()->SetTitle("tDrift (ns)"); - - histoType="time_Fit_tslope"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),40,0.,40.); - h->GetXaxis()->SetTitle("tSlope (ns)"); - - histoType="time_Fit_chi2"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),200,0.,50.); - h->GetXaxis()->SetTitle("tChi2perDof (ns)"); - - histoType="adc_Fit_peak"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),150,0.,300.); - h->GetXaxis()->SetTitle("ADC counts"); - - histoType="adc_Fit_width"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),50,0.,50.); - h->GetXaxis()->SetTitle("ADC counts"); - - histoType="hits_perML_belowADCCUT"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,0.,1.); - h->GetXaxis()->SetTitle("Fraction of Hits"); - - histoType="TubeEfficiency_Inner"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,0.,1.1); - h->GetXaxis()->SetTitle("TubeEfficiency"); - - histoType="TubeEfficiency_Middle"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,0.,1.1); - h->GetXaxis()->SetTitle("TubeEfficiency"); - - histoType="TubeEfficiency_Outer"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,0.,1.1); - h->GetXaxis()->SetTitle("TubeEfficiency"); - - if(region=="Endcap") - { - histoType="TubeEfficiency_extra"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,0.,1.1); - h->GetXaxis()->SetTitle("TubeEfficiency"); - } - - histoType="ResidualsWidth"; - histoTitle = histoType+" Vs Radius"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),15,-15,15,100,0.,1.0); - h2->GetXaxis()->SetTitle("Radius (mm)"); - h2->GetYaxis()->SetTitle("Residuals width (mm)"); - - histoType="ResidualsMean"; - histoTitle = histoType+" Vs Radius"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),15,-15,15,100,-1.0,1.0); - h2->GetXaxis()->SetTitle("Radius (mm)"); - h2->GetYaxis()->SetTitle("Residuals mean (mm)"); - - histoType="DeadElements"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5, 6,0.5,6.5); - h2->GetYaxis()->SetBinLabel(1,"Low_Stat_Ch"); - h2->GetYaxis()->SetBinLabel(2,"dead_Chamber"); - h2->GetYaxis()->SetBinLabel(3,"dead_ML"); - h2->GetYaxis()->SetBinLabel(4,"dead_Layer"); - h2->GetYaxis()->SetBinLabel(5,"dead_Mezz"); - h2->GetYaxis()->SetBinLabel(6,"dead_Tube"); - h2->GetXaxis()->SetTitle("Sector Id"); - h2->SetMarkerSize(1.6); - - // Here the Overview occupancy plots per chamber in Sector_Vs_Eta view for Barrel and Endcap - if ( region == "Barrel" ) { - histoType="A_HitsPerML_Inner"; - histoTitle="HitsPerML_B"+side+"_Inner"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),12,-0.5,11.5,32,0.5,16.5); - h2->GetXaxis()->SetTitle("eta_id"); - h2->GetYaxis()->SetTitle("Sector nr."); - h2->SetAxisRange(0.5,11.5,"X"); // same range as the others but better display - - histoType="A_HitsPerML_Middle"; - histoTitle="HitsPerML_B"+side+"_Middle"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),12,-0.5,11.5,32,0.5,16.5); - h2->GetXaxis()->SetTitle("eta_id"); - h2->GetYaxis()->SetTitle("Sector nr."); - h2->SetAxisRange(0.5,6.5,"X"); // same range as the others but better display - - histoType="A_HitsPerML_Outer"; - histoTitle="HitsPerML_B"+side+"_Outer"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),12,-0.5,11.5,32,0.5,16.5); - h2->GetXaxis()->SetTitle("eta_id"); - h2->GetYaxis()->SetTitle("Sector nr."); - h2->SetAxisRange(-0.5,8.5,"X"); // same range as the others but better display - } - if ( region == "Endcap" ) { - // - // CHECK IF THIS IS CORRECT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // - histoType="A_HitsPerML_Inner"; - histoTitle="HitsPerML_E"+side+"_Inner"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),8,0.5,8.5,32,0.5,16.5); - h2->GetXaxis()->SetTitle("eta_id"); - h2->GetYaxis()->SetTitle("Sector nr."); - - histoType="A_HitsPerML_Middle"; - histoTitle="HitsPerML_E"+side+"_Middle"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),6,0.5,6.5,32,0.5,16.5); - h2->GetXaxis()->SetTitle("eta_id"); - h2->GetYaxis()->SetTitle("Sector nr."); - - histoType="A_HitsPerML_Outer"; - histoTitle="HitsPerML_E"+side+"_Outer"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),6,0.5,6.5,32,0.5,16.5); - h2->GetXaxis()->SetTitle("eta_id"); - h2->GetYaxis()->SetTitle("Sector nr."); - - histoType="A_HitsPerML_extra"; - histoTitle="HitsPerML_E"+side+"_extra"; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),4,0.5,4.5,32,0.5,16.5); - h2->GetXaxis()->SetTitle("eta_id"); - h2->GetYaxis()->SetTitle("Sector nr."); - } - // End of Overview occupancy plots - } - - - // motherdir = /TrigDaq/; - motherdir = GetTDaqDirectoryName(region); - m_rootfile->cd(motherdir.c_str()); - dir_name = GetTDaqDirectoryName(region,side); - if (!m_rootfile->GetDirectory(dir_name.c_str())) { - // A new TDirectoryFile gets owned by the current directory (side effect). - new TDirectoryFile(regionSide.c_str(),regionSide.c_str()); - } - - // Build Sectors : - for (int sector=sectorMin; sector<=sectorMax; sector++) { // LOOP on Sectors - buildSector(region,side,sector); - } -} - - -void HistogramManager::buildSector(std::string region, std::string side, int sector) { - - std::string sectordir=GetMdtDirectoryName(region, side, sector); - if (m_rootfile->GetDirectory(sectordir.c_str())) { - return; - } - - std::vector<MDTName> chamberList = GetChamberList(region, side, sector); - - // Sort Chambers By chamberType - std::stable_sort(chamberList.begin(), chamberList.end(), sortMdtChambersByName() ) ; - int numTotChambers=chamberList.size(); - - std::string previousChamberType = "XXX"; - std::vector<MDTName> chamberListPerType[7]; - int totChamberTypes = 0; - for (int ichamber = 0; ichamber<numTotChambers; ichamber++ ) { - if ( chamberList[ichamber].getName() != previousChamberType) { - previousChamberType = chamberList[ichamber].getName(); - totChamberTypes++; - } - chamberListPerType[totChamberTypes-1].push_back(chamberList[ichamber]); - } - - - ToString ts; - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - std::string sector_name="Sector"+sectorString; - std::string sector_title="Sector "+sectorString; - - std::string motherdir= GetMdtDirectoryName(region,side); - m_rootfile->cd(motherdir.c_str()); - TH1F * h; - TH1F * h1; - TH2F * h2; - - TDirectoryFile * sector_dir = new TDirectoryFile(sector_name.c_str(),sector_title.c_str()); - TDirectoryFile * overview = new TDirectoryFile("OVERVIEW","OVERVIEW","",sector_dir); - - overview->cd(); - std::string histoTitPart2 = region+"_"+side+" Sector "+sectorString; - std::string histoType; - std::string histoTitle; - - int nbinMultipl=50; - float xminMultipl=0.5; - float xmaxMultipl=50.5; - /////////////////////////////////////////////////////////////////////// - // DEFINITION OF HISTOGRAMS in directory /MDT/<region>_{A,C}/SectorXX/OVERVIEW : - // - Occupancies - // - histoType="z_HitsVsMezzanine"; - histoTitle = "HitsVsMezzanine "+histoTitPart2; - TH2F * HitsVsMezzanine = new TH2F(histoType.c_str(),histoTitle.c_str(), - numTotChambers,0.,(float)numTotChambers,20,-0.5,19.5); - HitsVsMezzanine->GetYaxis()->SetTitle("Mezzanine nr."); - - std::string chamberType; - for (int ichamber = 0; ichamber<numTotChambers; ichamber++ ) { - std::string chamberName = chamberList[ichamber].getOnlineName(); - HitsVsMezzanine->GetXaxis()->SetBinLabel(ichamber+1,chamberName.c_str()); - } - - float TDCmin=0.; - float TDCmax=3000.; - int nbinTDC=300; - // - histoType="TDC_AllChambers_Inner"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - h->GetXaxis()->SetTitle("TDC counts"); - // - histoType="TDC_AllChambers_Middle"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - h->GetXaxis()->SetTitle("TDC counts"); - // - histoType="TDC_AllChambers_Outer"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - h->GetXaxis()->SetTitle("TDC counts"); - // - if(region=="Endcap") { - histoType="TDC_AllChambers_extra"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - h->GetXaxis()->SetTitle("TDC counts"); - } - // - if(region=="Barrel") { - histoType="z_MDT_RPC"; - histoTitle = "Distance BM Segment to RPC "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,-50.,50.); - h->GetXaxis()->SetTitle("Distance MDT segment to RPC hit (mm)"); - } - - if(region=="Endcap") { - histoType="z_MDT_TGC"; - histoTitle = "Distance EM Segment to TGC "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,-50.,50.); - h->GetXaxis()->SetTitle("Distance MDT segment to TGC hit (mm)"); - } - - int etaMinI = 99; // Inner chambers - int etaMaxI = -99; - int etaMinM = 99; // Middle - int etaMaxM = -99; - int etaMinO = 99; // Outer - int etaMaxO = -99; - int etaMinE = 99; // Extra - int etaMaxE = -99; - - int tubeMaxBM[10]; - for (int i=0;i<10;i++) tubeMaxBM[i]=1; - int etaMinBM = 99; - int etaMaxBM = -99; - int tubeMaxEM[10]; - for (int i=0;i<10;i++) tubeMaxEM[i]=1; - int etaMinEM = 99; - int etaMaxEM = -99; - int etaBins=98; - float fetaMin=-24.5; - float fetaMax=24.5; - for (int ichamber=1; ichamber<=totChamberTypes; ichamber++){ - chamberType=chamberListPerType[ichamber-1].at(0).getName(); - // - // check if it is a reasonable name ! - // - if ( !(chamberType.substr(0,1)=="B" || chamberType.substr(0,1)=="E") ) { - continue; - } - // - // FIND HERE etaMin and etaMax from the list chamberListPerType[ichamber-1] - // - int etaMin = 9; - int etaMax = -9; - - for (unsigned int ic=0; ic<chamberListPerType[ichamber-1].size(); ic++){ - int etaic = chamberListPerType[ichamber-1].at(ic).getOnlineEta(); - if (etaic < etaMin ) etaMin = etaic; - if (etaic > etaMax ) etaMax = etaic; - if (chamberType.substr(0,2)=="BM" ) { - if (etaic < etaMinBM ) etaMinBM = etaic; - if (etaic > etaMaxBM ) etaMaxBM = etaic; - tubeMaxBM[etaic]=56; // HERE SUBSTITUTE WITH tubeMax OBTAINED FROM MdtChamber - } - if (chamberType.substr(0,2)=="EM" ) { - if (etaic < etaMinEM ) etaMinEM = etaic; - if (etaic > etaMaxEM ) etaMaxEM = etaic; - tubeMaxEM[etaic]=64; // HERE SUBSTITUTE WITH tubeMax OBTAINED FROM MdtChamber - } - if (chamberType.substr(1,1)=="I" ) { - if (etaic < etaMinI ) etaMinI = etaic; - if (etaic > etaMaxI ) etaMaxI = etaic; - } - if (chamberType.substr(1,1)=="M" ) { - if (etaic < etaMinM ) etaMinM = etaic; - if (etaic > etaMaxM ) etaMaxM = etaic; - } - if (chamberType.substr(1,1)=="O" ) { - if (etaic < etaMinO ) etaMinO = etaic; - if (etaic > etaMaxO ) etaMaxO = etaic; - } - if (chamberType.substr(1,1)=="E" ) { - if (etaic < etaMinE ) etaMinE = etaic; - if (etaic > etaMaxE ) etaMaxE = etaic; - } - } - - etaBins = 2*(etaMax-etaMin+1); - fetaMin = (float)etaMin-0.5; - fetaMax = (float)etaMax+0.5; - histoType="HitsOnSegment"+chamberType; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); - h->SetAxisRange(xminMultipl,20.5); - // - if ( (chamberType=="BOG" || chamberType=="BOF") ) { - histoType="t0PerMLBOGBOF"; - histoTitle = histoType+" "+histoTitPart2; - if (side=="A") h = new TH1F(histoType.c_str(),histoTitle.c_str(),18,-0.5,8.5); // BOG0 only for side A - if (side=="C") h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,8.5); - h->GetXaxis()->SetTitle("eta_id"); - h->GetYaxis()->SetTitle("t0 (ns)"); - h->SetAxisRange(200.,1000.,"Y"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - // - histoType="tdriftPerMLBOGBOF"; - histoTitle = histoType+" "+histoTitPart2; - if (side=="A") h = new TH1F(histoType.c_str(),histoTitle.c_str(),18,-0.5,8.5); // BOG0 only for side A - if (side=="C") h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,8.5); - h->GetXaxis()->SetTitle("eta_id"); - h->GetYaxis()->SetTitle("tdrift (ns)"); - h->SetAxisRange(600.,800.,"Y"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - - } else { - histoType="t0PerML"+chamberType; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBins,fetaMin,fetaMax); - h->GetXaxis()->SetTitle("eta_id"); - h->GetYaxis()->SetTitle("t0 (ns)"); - h->SetAxisRange(200.,1000.,"Y"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - // - histoType="tdriftPerML"+chamberType; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBins,fetaMin,fetaMax); - h->GetXaxis()->SetTitle("eta_id"); - h->GetYaxis()->SetTitle("tdrift (ns)"); - h->SetAxisRange(600.,800.,"Y"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - } - }//ichamber - - int etaBinsX; - float fetaMinX; - float fetaMaxX; - - etaBinsX = 2*(etaMaxI-etaMinI+1); - fetaMinX = (float)etaMinI-0.5; - fetaMaxX = (float)etaMaxI+0.5; - histoType="HitsPerML_Inner"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBinsX,fetaMinX,fetaMaxX); - h->GetXaxis()->SetTitle("eta_id"); - // - etaBinsX = 2*(etaMaxM-etaMinM+1); - fetaMinX = (float)etaMinM-0.5; - fetaMaxX = (float)etaMaxM+0.5; - histoType="HitsPerML_Middle"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBinsX,fetaMinX,fetaMaxX); - h->GetXaxis()->SetTitle("eta_id"); - // - etaBinsX = 2*(etaMaxO-etaMinO+1); - fetaMinX = (float)etaMinO-0.5; - fetaMaxX = (float)etaMaxO+0.5; - histoType="HitsPerML_Outer"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBinsX,fetaMinX,fetaMaxX); - h->GetXaxis()->SetTitle("eta_id"); - - if(region=="Endcap") - { - etaBinsX = 2*(etaMaxE-etaMinE+1); - fetaMinX = (float)etaMinE-0.5; - fetaMaxX = (float)etaMaxE+0.5; - histoType="HitsPerML_extra"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBinsX,fetaMinX,fetaMaxX); - h->GetXaxis()->SetTitle("eta_id"); - } - /////////////////////////////////////////////////////////////////////// - // - /////////////////////////////////////////////////////////////////////// - // DEFINITION OF HISTOGRAMS in directory /MDTvsRPC/Barrel_{A,C}/SectorXX : - // - if (region=="Barrel") { - motherdir= GetTDaqDirectoryName(region,side); - m_rootfile->cd(motherdir.c_str()); - - TDirectoryFile * sector_tdaqdir = new TDirectoryFile(sector_name.c_str(),sector_title.c_str()); - sector_tdaqdir->cd(); - histoType="MDT_RPC"; - histoTitle = "Distance Segment to RPC "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,-50.,50.); - h->GetXaxis()->SetTitle("Distance MDT segment to RPC hit (mm)"); - - // GLOBAL TIME FIT HISTOGRAMS : - // - - histoType="ResidualsVsRadius"; - histoTitle = "Residuals Vs Radius "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),30,-15,15.,200,-5.,5.); - h2->GetXaxis()->SetTitle("Radius (mm)"); - h2->GetYaxis()->SetTitle("Residuals (mm)"); - - histoType="Segment_chi2"; - histoTitle = "eta_id Vs Segment_chi2 "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),50, 0.,50.,6,0.5,6.5); - h2->GetXaxis()->SetTitle("chi2/DoF"); - h2->GetYaxis()->SetTitle("BM chamber eta_id"); - - histoType="Segment_ProbChi2"; - histoTitle = "Segment_ProbChi2 "+histoTitPart2; - h1 = new TH1F(histoType.c_str(),histoTitle.c_str(),50,0.,1.); - h1->GetXaxis()->SetTitle("Prob(chi2,DoF)"); - - histoType="Residuals"; - histoTitle = "eta_id Vs Residuals "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),200,-5.,5.,6,0.5,6.5); - h2->GetXaxis()->SetTitle("Residuals (mm)"); - h2->GetYaxis()->SetTitle("BM chamber eta_id"); - - histoType="HitsOnSegment"; - histoTitle = "eta_id Vs HitsOnSegment "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),10,0.5,10.5,6,0.5,6.5); - h2->GetXaxis()->SetTitle("nr. of hits on Segment"); - h2->GetYaxis()->SetTitle("BM chamber eta_id"); - - histoType="HitRadius"; - histoTitle = "Hit Radius "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),80,-20.,20.); - h->GetXaxis()->SetTitle("Hit Radius (mm)"); - - for (int ic=etaMinBM; ic<=etaMaxBM; ic++){ - histoType="TrigTime_BM_eta_"+ts(ic); - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),768,0.,1200.); - h->GetXaxis()->SetTitle("TriggerTime (ns)"); - - histoType="TrigTimeVsROdistance_BM_eta_"+ts(ic); - histoTitle = histoType+" "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),72, 0.,3600.,192,0.,1200.); - h2->GetXaxis()->SetTitle("Position along the wires (mm)"); - h2->GetYaxis()->SetTitle("TriggerTime (ns)"); - - histoType="TriggerCoverage_BM_eta_"+ts(ic); - histoTitle = histoType+" "+histoTitPart2; - - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),72, 0.,3600., - tubeMaxBM[ic],0.5,(float)tubeMaxBM[ic]+0.5); - h2->GetXaxis()->SetTitle("Position along the wires (mm)"); - h2->GetYaxis()->SetTitle("Position perp to the wires (mm)"); - } - // DEBUG HISTOGRAMS TO BE REMOVED ! - bool detailedAnalysis = false; - if (detailedAnalysis) { - histoType="a_old_Vs_a_new"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),200,-4.,4.,200,-4.,4.); - h2->GetXaxis()->SetTitle("aSegment_new"); - h2->GetYaxis()->SetTitle("aSegment_old"); - - histoType="b_old_Vs_b_new"; - histoTitle = histoType; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),500,-50.,200.,500,-50.,200.); - h2->GetXaxis()->SetTitle("bSegment_new"); - h2->GetYaxis()->SetTitle("bSegment_old"); - - histoType="a_diff"; - histoTitle = histoType; - h1 = new TH1F(histoType.c_str(),histoTitle.c_str(),1000,-0.5,0.5); - h1->GetXaxis()->SetTitle("aSegment_new-aSegment_old"); - - histoType="b_diff"; - histoTitle = histoType; - h1 = new TH1F(histoType.c_str(),histoTitle.c_str(),1000,-10.,10.); - h1->GetXaxis()->SetTitle("bSegment_new-bSegment_old"); - - } - } - - - /////////////////////////////////////////////////////////////////////// - // - /////////////////////////////////////////////////////////////////////// - // DEFINITION OF HISTOGRAMS in directory /MDTvsTGC/Endcap_{A,C}/SectorXX : - // - if (region=="Endcap") { - motherdir= GetTDaqDirectoryName(region,side); - m_rootfile->cd(motherdir.c_str()); - - TDirectoryFile * sector_tdaqdir = new TDirectoryFile(sector_name.c_str(),sector_title.c_str()); - sector_tdaqdir->cd(); - histoType="MDT_TGC"; - histoTitle = "Distance Segment to TGC "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,-50.,50.); - h->GetXaxis()->SetTitle("Distance MDT segment to TGC hit (mm)"); - // - // histoType="MDT_TGC_Vs_Event"; - // histoTitle = "Distance Segment to TGC Vs Event "+histoTitPart2; - // h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),200,0.,2000000.,100,-50.,50.); - // - // GLOBAL TIME FIT HISTOGRAMS : - // - - histoType="Track_chi2"; - histoTitle = "eta_id Vs Track_chi2 "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),50, 0.,50.,6,0.5,6.5); - h2->GetXaxis()->SetTitle("chi2/DoF"); - h2->GetYaxis()->SetTitle("EM chamber eta_id"); - - histoType="Residuals"; - histoTitle = "eta_id Vs Residuals "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),200,-5.,5.,6,0.5,6.5); - h2->GetXaxis()->SetTitle("Residuals (mm)"); - h2->GetYaxis()->SetTitle("EM chamber eta_id"); - - histoType="Hit_Res_Chi2DoF"; - histoTitle = "eta_id Vs Hit Residuals Chi2/DoF"+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),100,0.,50.,6,0.5,6.5); - h2->GetXaxis()->SetTitle("Hit Residuals Chi2/DoF"); - h2->GetYaxis()->SetTitle("EM chamber eta_id"); - - histoType="HitsOnSegment"; - histoTitle = "eta_id Vs HitsOnSegment "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),10,0.5,10.5,6,0.5,6.5); - h2->GetXaxis()->SetTitle("nr. of hits on Segment"); - h2->GetYaxis()->SetTitle("EM chamber eta_id"); - - histoType="HitRadius"; - histoTitle = "Hit Radius "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),80,-20.,20.); - h->GetXaxis()->SetTitle("Hit Radius (mm)"); - - for (int ic=etaMinEM; ic<=etaMaxEM; ic++){ - histoType="TrigTime_EM_eta_"+ts(ic); - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),768,0.,1200.); - h->GetXaxis()->SetTitle("TriggerTime (ns)"); - - histoType="TrigTimeVsROdistance_EM_eta_"+ts(ic); - histoTitle = histoType+" "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),72, 0.,3600.,192,0.,1200.); - h2->GetXaxis()->SetTitle("Position along the wires (mm)"); - h2->GetYaxis()->SetTitle("TriggerTime (ns)"); - - histoType="TriggerCoverage_EM_eta_"+ts(ic); - histoTitle = histoType+" "+histoTitPart2; - - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),72, 0.,3600., - tubeMaxEM[ic],0.5,(float)tubeMaxEM[ic]+0.5); - h2->GetXaxis()->SetTitle("Position along the wires (mm)"); - h2->GetYaxis()->SetTitle("Position perp to the wires (mm)"); - } - } -} - -void HistogramManager::buildChamberHistos(MDTName chamb) { - - - int eta_id = chamb.getOfflineEta(); - int phi_id = chamb.getOfflineSector(); - int sector=chamb.getOnlineSector(); - - ToString ts; - - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - std::string sector_name="Sector"+sectorString; - std::string sector_title="Sector "+sectorString; - - std::string region=chamb.getRegion(); - std::string side=chamb.getSide(); - - std::string chamberName=chamb.getOnlineName(); - std::string chamberType=chamb.getName(); - - std::string motherdir=GetMdtDirectoryName(region, side, sector); - m_rootfile->cd(motherdir.c_str()); - - TDirectoryFile * chamber_dir = new TDirectoryFile(chamberName.c_str(),chamberName.c_str()); - TDirectoryFile * occupancy_dir = new TDirectoryFile("Occupancy","occupancy","",chamber_dir); - TDirectoryFile * efficiency_dir = new TDirectoryFile("Efficiency","efficiency","",chamber_dir); - TDirectoryFile * deadStatus_dir = new TDirectoryFile("DeadStatus","DeadStatus","",chamber_dir); - TDirectoryFile * expert_dir = new TDirectoryFile("Expert","Expert","",chamber_dir); - TDirectoryFile * noiseStatus_dir = new TDirectoryFile("NoiseStatus","NoiseStatus","",chamber_dir); - chamber_dir->cd(); - - // - // The following values should be read in from a Chamber Layout File - - int numTubesPerLayer[2], numOfMezzPerML[2]; - numTubesPerLayer[0] = 0; - numTubesPerLayer[1] = 0; - numOfMezzPerML[0] = 0; - numOfMezzPerML[1] = 0; - int numLayersPerML, numML, numTubesPerMezz, numMezzanines, numMaxTubesPerLayer; - int numTotTubesML[2]; - int tubeNumberOffsetML[2]; - // - // tubeNumberOffsetML1, tubeNumberOffsetML1 MUST BE SET to match online tube numbering - // I think a method in HistogramManager could be used. (or in phi_eta_utils......) - // for the moment do not add any offset: - tubeNumberOffsetML[0] = GetTubeOffsetML1(chamberName); - tubeNumberOffsetML[1] = 0; - - if ( m_idHelper ) { - Identifier station_id = m_mdtIdHelper->elementID(chamberType, eta_id, phi_id); - numML = m_mdtIdHelper->numberOfMultilayers(station_id); - Identifier MdtML1_id = m_mdtIdHelper->multilayerID(station_id,1); - Identifier MdtML2_id; - if ( numML>1) MdtML2_id = m_mdtIdHelper->multilayerID(station_id,2); - numLayersPerML = m_mdtIdHelper->tubeLayerMax(MdtML1_id) - m_mdtIdHelper->tubeLayerMin(MdtML1_id) + 1; - if (chamberName.substr(0,4)=="BIS8") numLayersPerML=3; // PATCH TO MdtIdHelper BUG (should be fixed in next release) - numTubesPerLayer[0] = m_mdtIdHelper->tubeMax(MdtML1_id) - m_mdtIdHelper->tubeMin(MdtML1_id) + 1; - - if ( numML>1 ) numTubesPerLayer[1] = m_mdtIdHelper->tubeMax(MdtML2_id) - m_mdtIdHelper->tubeMin(MdtML2_id) + 1; - - numMaxTubesPerLayer = numTubesPerLayer[0]; - if (numTubesPerLayer[1]>numTubesPerLayer[0]) numMaxTubesPerLayer = numTubesPerLayer[1]; - numTubesPerMezz = 8; - if (numLayersPerML==4) numTubesPerMezz = 6; - numOfMezzPerML[0] = numTubesPerLayer[0]/numTubesPerMezz; - numOfMezzPerML[1] = numTubesPerLayer[1]/numTubesPerMezz; - numMezzanines = numOfMezzPerML[0]+numOfMezzPerML[1]; - } else { - numLayersPerML=3; - numML = GetChamberNumOfML(chamberName); - numTubesPerMezz = GetChamberTubesPerMezz(chamberName); - numOfMezzPerML[0] = GetChamberNumOfMezzPerML(chamberName); - if (numML>1) numOfMezzPerML[1] = numOfMezzPerML[0]; - if (numTubesPerMezz==6) numLayersPerML=4; - numTubesPerLayer[0]=numTubesPerMezz*numOfMezzPerML[0]; - numTubesPerLayer[1]=numTubesPerMezz*numOfMezzPerML[1]; - numMaxTubesPerLayer = numTubesPerLayer[0]; - if (numTubesPerLayer[1]>numTubesPerLayer[0]) numMaxTubesPerLayer = numTubesPerLayer[1]; - numMezzanines = numOfMezzPerML[0]+numOfMezzPerML[1]; - } - numTotTubesML[0]=numLayersPerML*numTubesPerLayer[0]; - numTotTubesML[1]=numLayersPerML*numTubesPerLayer[1]; - - float allTubesMin = 0.5; - float allTubesMax = (float) numTotTubesML[0]; - if (numTotTubesML[0]<numTotTubesML[1]) allTubesMax = (float) numTotTubesML[1]; - if (numML>1) allTubesMax = 2.*allTubesMax; - allTubesMax = allTubesMax + 0.5; - int nbinAllTubes = (int) (allTubesMax-allTubesMin); - - int nbinMultipl=50; - float xminMultipl=0.; - float xmaxMultipl=50.; - - float TDCmin=0.; - float TDCmax=3000.; - int nbinTDC=300; - int nbinTDCcoarse=60; - - float ADCmin=0.; - float ADCmax=400.; - int nbinADC=200; - int nbinADCcoarse=40; - - TH1F * h; - TH1F * h1; - TH2F * h2; - - std::string histoTitPart2=chamberName; - std::string histoType; - std::string histoTitle; - /////////////////////////////////////////////////////////////////////////////// - // - // DEFINITION OF HISTOGRAMS in directory /MDT/Barrel_{A,C}/SectorXX/<chamber> : - // - // - Multiplicities - // - histoType="B_ChamberHitMultiplicity"; - histoTitle = "ChamberHitMultiplicity "+histoTitPart2; - TH1F * HitMult = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); - HitMult->GetXaxis()->SetTitle("Chamber tot nr. hits"); - - histoType="D_ChamberHitsOnSegment"; - histoTitle = "ChamberHitsOnSegment "+histoTitPart2; - TH1F * HitsOnSeg = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); - HitsOnSeg->GetXaxis()->SetTitle("nr. hits on segment"); - HitsOnSeg->SetAxisRange(xminMultipl,20.5); - - // - occupancies - // - - histoType="b_DeadTubeStatus"; - histoTitle = "DeadTubeStatus "+histoTitPart2; - TH1F * DeadTubeStatus = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - DeadTubeStatus->GetXaxis()->SetTitle("Tube_id"); - - histoType="a_ChamberHitOccupancy"; - histoTitle = "ChamberHitOccupancy "+histoTitPart2; - TH2F * ChamberHits = new TH2F(histoType.c_str(),histoTitle.c_str(), - numMaxTubesPerLayer,0.5,numMaxTubesPerLayer+0.5,10,0.5,10.5); - ChamberHits->GetXaxis()->SetTitle("Tube nr."); - ChamberHits->GetYaxis()->SetTitle("Layer"); - // - - histoType="a_HitsPerTube"; - histoTitle = "HitsPerTube "+histoTitPart2; - TH1F * HitsPerTube = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - HitsPerTube->GetXaxis()->SetTitle("Tube_id"); - // - histoType="a_HitsPerTubeAdcCut"; - histoTitle = "HitsPerTubeAdcCut "+histoTitPart2; - TH1F * HitsPerTubeAdcCut = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - HitsPerTubeAdcCut->GetXaxis()->SetTitle("Tube_id"); - // - // - efficiencies - - histoType="b_EfficiencyPerTube"; - histoTitle = "EfficiencyPerTube "+histoTitPart2; - TH1F * EfficiencyPerTube = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - EfficiencyPerTube->GetXaxis()->SetTitle("Tube_id"); - EfficiencyPerTube->GetYaxis()->SetTitle("efficiency"); - EfficiencyPerTube->SetMarkerStyle(20); - EfficiencyPerTube->SetMarkerSize(1.0); - EfficiencyPerTube->Sumw2(); - - - // - // - RESIDUALS - // - histoType="b_SegResidVsRadius"; - histoTitle = "Residuals Vs Radius "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),30,-15,15.,200,-5.,5.); - h2->GetXaxis()->SetTitle("Radius (mm)"); - h2->GetYaxis()->SetTitle("Residuals (mm)"); - // - histoType="b_SegmentResidual"; - histoTitle = "Segment Residuals "+histoTitPart2; - h1 = new TH1F(histoType.c_str(),histoTitle.c_str(),200,-5.,5.); - h1->GetXaxis()->SetTitle("Residuals (mm)"); - // - // - Segment Prob(chi2,ndeg) - // - histoType="c_Segment_ProbChi2"; - histoTitle = "Segment_ProbChi2 "+histoTitPart2; - h1 = new TH1F(histoType.c_str(),histoTitle.c_str(),50,0.,1.); - h1->GetXaxis()->SetTitle("Prob(chi2,DoF)"); - - // - // - TDC and ADC - // - histoType="A_TDC_ML1"; - histoTitle = "TDC_ML1 "+histoTitPart2; - TH1F * TDC_ML1 = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - TDC_ML1->GetXaxis()->SetTitle("TDC counts"); - // - histoType="A_TDC_ML2"; - histoTitle = "TDC_ML2 "+histoTitPart2; - TH1F * TDC_ML2 = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - TDC_ML2->GetXaxis()->SetTitle("TDC counts"); - // - histoType="C_ADC_ML1"; - histoTitle = "ADC_ML1 "+histoTitPart2; - TH1F * ADC_ML1 = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinADC,ADCmin,ADCmax); - ADC_ML1->GetXaxis()->SetTitle("ADC counts"); - // - histoType="C_ADC_ML2"; - histoTitle = "ADC_ML2 "+histoTitPart2; - TH1F * ADC_ML2 = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinADC,ADCmin,ADCmax); - ADC_ML2->GetXaxis()->SetTitle("ADC counts"); - // - // - TDC Vs ADC spectra per Mezzanine : - // - for (int imezz=0; imezz<numMezzanines; imezz++) { - histoType="tdc_Vs_adc_mezz_"+ts(imezz); - histoTitle = histoType+" "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),nbinADCcoarse,ADCmin,ADCmax,nbinTDCcoarse,TDCmin,TDCmax); - h2->GetXaxis()->SetTitle("ADC counts"); - h2->GetYaxis()->SetTitle("TDC counts"); - } - - - //////////////////////////////////////////////////////////////////////////////// - // - // Histograms in the subdirectories: ...... - // - - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::::::::::::EXPERT:::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - expert_dir->cd(); - - histoType="ChamberYZOccupancy"; - histoTitle = histoType+" "+histoTitPart2; - TH2F * ChamberHitsYZ = new TH2F(histoType.c_str(),histoTitle.c_str(), - 220,0.,2200.,100,0.,1000.); - ChamberHitsYZ->GetXaxis()->SetTitle("Hit_y (mm) "); - ChamberHitsYZ->GetYaxis()->SetTitle("Hit_z (mm) "); - // - - histoType="DeadTubeRefMap"; - histoTitle = histoType+" "+histoTitPart2; - TH1F * href = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - href->GetXaxis()->SetTitle("Tube_id"); - int tubesMLextended = nbinAllTubes/2; - if (numTubesPerLayer[1]==0) tubesMLextended = nbinAllTubes; - int tubesLayerExtended = tubesMLextended/numLayersPerML; - for (int ibin=1;ibin<=nbinAllTubes;ibin++) { - - int binSign, layercode; - if (ibin<=tubesMLextended) { - binSign = -1; - layercode = ((ibin-1)/tubesLayerExtended) + 1; - layercode = layercode*10*binSign; - } else { - binSign = 1; - layercode = ((ibin-tubesMLextended-1)/tubesLayerExtended) + 1; - layercode = layercode*10*binSign; - } - - href->SetBinContent(ibin,layercode); - } - - setChamberCutOut(chamberName, href ); - - histoType="DeadTubeMap"; - histoTitle = histoType+" "+histoTitPart2; - - h = (TH1F*) href->Clone(histoType.c_str()); - h->SetTitle(histoTitle.c_str()); - - histoType="ChamberDeadChannels"; - histoTitle = histoType+" "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(), - numMaxTubesPerLayer,0.5,numMaxTubesPerLayer+0.5,10,0.5,10.5); - h2->GetXaxis()->SetTitle("Tube nr."); - h2->GetYaxis()->SetTitle("Layer"); - // - - histoType="EffiResidVsRadius"; - histoTitle = histoType+" "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(), - 30,0.,15.,640,-16.,16.); - h2->GetXaxis()->SetTitle("Segment distance from wire (mm)"); - h2->GetYaxis()->SetTitle("Residual (mm)"); - // - histoType="EfficiencyEntries"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - h->GetXaxis()->SetTitle("Tube_id"); - h->GetYaxis()->SetTitle("Nr of events the tube should fire"); - - histoType="EfficiencyCounts"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - h->GetXaxis()->SetTitle("Tube_id"); - h->GetYaxis()->SetTitle("Nr. of events the tube HAS fired"); - - - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::DEADSTATUS::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - deadStatus_dir->cd(); - - histoType="ChamberDeadTubes"; - histoTitle = histoType+" "+histoTitPart2; - h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),numMaxTubesPerLayer,0.5,numMaxTubesPerLayer+0.5,10,0.5,10.5); - h2->GetXaxis()->SetTitle("Tube nr."); - h2->GetYaxis()->SetTitle("Layer"); - - for (int ML=1;ML<=numML;ML++){ - for (int layer=1; layer<=numLayersPerML; layer++){ - int nbin=numTubesPerLayer[ML-1]; - float xmin = 0.5 + (float)tubeNumberOffsetML[ML-1]; - float xmax = (float)numTubesPerLayer[ML-1] + xmin; - - occupancy_dir->cd(); - histoType="HitsPerTube_ML"+ts(ML)+"_L"+ts(layer); - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbin,xmin,xmax); - h->GetXaxis()->SetTitle("Tube nr."); - - efficiency_dir->cd(); - histoType="EffiPerTube_ML"+ts(ML)+"_L"+ts(layer); - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbin,xmin,xmax); - h->GetXaxis()->SetTitle("Tube nr."); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - deadStatus_dir->cd(); - histoType="DeadTubes_ML"+ts(ML)+"_L"+ts(layer); - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbin,xmin,xmax); - h->GetXaxis()->SetTitle("Tube nr."); - noiseStatus_dir->cd(); - histoType="NoisePerTube_ML"+ts(ML)+"_L"+ts(layer); - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbin,xmin,xmax); - h->GetXaxis()->SetTitle("Tube nr."); - } - } - - /////////////////////////////////////////////////////////////////////// -} - - -void HistogramManager::setChamberCutOut(std::string chamber, TH1F * href ) { - //find the 'setBinContent' vector corresponding to the chamber name - auto pvecPair = string2Vec.find(chamber); - if (pvecPair != string2Vec.end()){ - for(const auto & i:pvecPair->second) - href->SetBinContent(i,0); - } //if not found, do nothing. -} - -void HistogramManager::setChamberDisconnectedTubes(std::string chamber, TH1F * href ) { - auto pdisconnectedVectorOfPairs = disconnected.find(chamber); - if (pdisconnectedVectorOfPairs != disconnected.end()){ - for(const auto & thisPair:pdisconnectedVectorOfPairs->second){ - href->SetBinContent(thisPair.first,thisPair.second); - } - } - -} - - -int HistogramManager::GetTubeOffsetML1(std::string chamber){ - int tubeOffset=0; - if (chamber=="BIR1A11" ) tubeOffset=6; - if (chamber=="BIR1A15" ) tubeOffset=6; - if (chamber=="BIR4A11" ) tubeOffset=3; - if (chamber=="BIR4A15" ) tubeOffset=3; - if (chamber=="BIR1C11" ) tubeOffset=6; - if (chamber=="BIR1C15" ) tubeOffset=6; - if (chamber=="BIR4C11" ) tubeOffset=3; - if (chamber=="BIR4C15" ) tubeOffset=3; - return tubeOffset; -} - -int HistogramManager::GetTubeOffsetAtEndML1(std::string chamber){ - int tubeOffset=0; - if (chamber.substr(0,4)=="BMS4") tubeOffset=8; - if (chamber.substr(0,4)=="BMS6") tubeOffset=8; - if (chamber=="BIR2A11" ) tubeOffset=3; - if (chamber=="BIR2A15" ) tubeOffset=3; - if (chamber=="BIR5A11" ) tubeOffset=3; - if (chamber=="BIR5A15" ) tubeOffset=3; - if (chamber=="BIR2C11" ) tubeOffset=3; - if (chamber=="BIR2C15" ) tubeOffset=3; - if (chamber=="BIR5C11" ) tubeOffset=3; - if (chamber=="BIR5C15" ) tubeOffset=3; - return tubeOffset; -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -TObject * HistogramManager::GetMdtHisto(std::string histo_name) { - TObject * h = NULL; - std::string dir_name=GetMdtDirectoryName(); - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if(dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} -TObject * HistogramManager::GetMdtHisto(std::string histo_name, std::string region, std::string side) { - TObject * h = NULL; - std::string dir_name=GetMdtDirectoryName(region, side); - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if(dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} -TObject * HistogramManager::GetMdtHisto(std::string histo_name,std::string region, std::string side, int sector) { - TObject * h = NULL; - - std::string dir_name=GetMdtDirectoryName(region,side,sector); - dir_name+="/OVERVIEW"; - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if(dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} - -TObject * HistogramManager::GetMdtHisto(std::string histo_name, MDTName chamb) { - - - TObject * h = NULL; - std::string dir_name=GetMdtDirectoryName(chamb); - - if(histo_name.substr(0,14)=="HitsPerTube_ML"){ - dir_name += "/Occupancy"; - } - if(histo_name.substr(0,18)=="ActivityPerTube_ML"){ - dir_name += "/DeadStatus"; - } - if(histo_name.substr(0,15)=="NoisePerTube_ML"){ - dir_name += "/NoiseStatus"; - } - if(histo_name.substr(0,14)=="EffiPerTube_ML"){ - dir_name=dir_name+"/Efficiency"; - } - if(histo_name=="EffiResidVsRadius"){ - dir_name=dir_name+"/Expert"; - } - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if(dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} - -std::string HistogramManager::GetMdtDirectoryName() { - std::string Mdt_dirName="/MDT"; - return Mdt_dirName; -} - -std::string HistogramManager::GetMdtDirectoryName(std::string region, std::string side) { - std::string Mdt_dirName="/MDT/"+region+"_"+side; - return Mdt_dirName; -} - -std::string HistogramManager::GetMdtDirectoryName(std::string region, std::string side, int sector) { - ToString ts; - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - std::string Mdt_dirName="/MDT/"+region+"_"+side+"/Sector"+sectorString; - return Mdt_dirName; -} - -std::string HistogramManager::GetMdtDirectoryName(std::string region, std::string side, int sector, std::string chamberType, int eta) { - ToString ts; - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - std::string chamberName = chamberType+ts(eta)+side+sectorString; - std::string Mdt_dirName="/MDT/"+region+"_"+side+"/Sector"+sectorString+"/"+chamberName; - return Mdt_dirName; -} - -std::string HistogramManager::GetMdtDirectoryName(MDTName chamb) { - - int sector=chamb.getOnlineSector(); - ToString ts; - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - std::string Mdt_dirName="/MDT/"+chamb.getRegion()+"_"+chamb.getSide()+"/Sector"+sectorString+"/"+chamb.getOnlineName(); - return Mdt_dirName; - -} - -TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region) { - TObject * h = NULL; - std::string dir_name=GetTDaqDirectoryName(region); - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if (dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} -TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region, std::string side) { - TObject * h = NULL; - std::string dir_name=GetTDaqDirectoryName(region, side); - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if (dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} -TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region, std::string side, int sector) { - TObject * h = NULL; - std::string dir_name=GetTDaqDirectoryName(region, side,sector); - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if (dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} -TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region, std::string side, int sector, std::string chamberType, int eta) { - TObject * h = NULL; - std::string dir_name=GetTDaqDirectoryName(region,side,sector,chamberType,eta); - TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); - if (dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} - -std::string HistogramManager::GetTDaqDirectoryName(std::string region) { - std::string TDaq_dirName="Undefined"; - if (region=="Barrel") TDaq_dirName="/MDTvsRPC"; - if (region=="Endcap") TDaq_dirName="/MDTvsTGC"; - return TDaq_dirName; -} - -std::string HistogramManager::GetTDaqDirectoryName(std::string region, std::string side) { - std::string TDaq_dirName="undefined"; - if (region=="Barrel") TDaq_dirName="/MDTvsRPC/"+region+"_"+side; - if (region=="Endcap") TDaq_dirName="/MDTvsTGC/"+region+"_"+side; - return TDaq_dirName; -} - -std::string HistogramManager::GetTDaqDirectoryName(std::string region, std::string side, int sector) { - ToString ts; - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - std::string TDaq_dirName="undefined"; - if (region=="Barrel") TDaq_dirName="/MDTvsRPC/"+region+"_"+side+"/Sector"+sectorString; - if (region=="Endcap") TDaq_dirName="/MDTvsTGC/"+region+"_"+side+"/Sector"+sectorString; - return TDaq_dirName; -} - -std::string HistogramManager::GetTDaqDirectoryName(std::string region, std::string side, int sector, std::string chamberType, int eta) { - ToString ts; - std::string sectorString=ts(sector); - if(sector<10) sectorString="0"+sectorString; - std::string chamberName = chamberType+ts(eta)+side+sectorString; - std::string TDaq_dirName="undefined"; - if (region=="Barrel") TDaq_dirName="/MDTvsRPC/"+region+"_"+side+"/Sector"+sectorString+"/"+chamberName; - if (region=="Endcap") TDaq_dirName="/MDTvsTGC/"+region+"_"+side+"/Sector"+sectorString+"/"+chamberName; - return TDaq_dirName; -} - -TObject * HistogramManager::GetHisto(std::string main_dir, std::string histo_name) { - TObject * h = NULL; - TDirectory* dir = m_rootfile->GetDirectory(main_dir.c_str()); - if(dir) h = dir->FindObjectAny(histo_name.c_str()); - return h; -} -//////////////////////////////////////////////////////////////////////////////// - -bool HistogramManager::openOutputFile(std::string outFileName) { - m_rootfile = new TFile(outFileName.c_str(),"recreate"); - if (!m_rootfile) { - return false; - } else { - return true; - } -} - -bool HistogramManager::openReadOnlyFile(std::string outFileName) { - m_rootfile = new TFile(outFileName.c_str(),"readonly"); - if (!m_rootfile) { - return false; - } else { - return true; - } -} - -bool HistogramManager::openUpdateFile(std::string outFileName) { - m_rootfile = new TFile(outFileName.c_str(),"update"); - if (!m_rootfile) { - return false; - } else { - return true; - } -} - -void HistogramManager::WriteAndCloseFile() { - // m_rootfile->Write(); - m_rootfile->Write("",TObject::kOverwrite); - m_rootfile->Close(); -} - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// - -int HistogramManager::GetEtaMax(std::string /* region*/, std::string /*side*/, int /*sector*/, std::string /*chamberType*/) { - int etaMax = 6; - return etaMax; -} -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -std::vector<MDTName> HistogramManager::GetChamberList(std::string region, std::string side, int sector) { - - //ToString ts; - std::vector<MDTName> chamberList; - - if ( m_mdtIdHelper ) { - MdtIdHelper::const_id_iterator it = m_mdtIdHelper->module_begin(); - MdtIdHelper::const_id_iterator it_end = m_mdtIdHelper->module_end(); - for(; it!=it_end;++it ) { - - if ( !m_mdtIdHelper->is_mdt(*it) ) continue; - int station_index = m_mdtIdHelper->stationName(*it); - std::string stationName = m_mdtIdHelper->stationNameString(station_index); - int phi_id = m_mdtIdHelper->stationPhi(*it); - int eta_id = m_mdtIdHelper->stationEta(*it); - - MDTName chamber(stationName,phi_id,eta_id); - - if(chamber.getRegion()!=region) continue; - if(chamber.getOnlineSector()!=sector) continue; - if(chamber.getSide()!=side) continue; - - //Problem with BML in sector13, it should be automatically treated by MDTName, but it gives some problem - //only here, I don't know why. This line should resolve it, check if it shows in other part of the code - //It seems like the problem is in MdtIdHelper however. - - if((chamber.getName()=="BML")&&(chamber.getOnlineEta()==7)) continue; - - chamberList.push_back(chamber); - - } // loop over MdtID_iterator - } // if m_MdtHelper - - return chamberList; -} -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -int HistogramManager::GetChamberNumOfML (std::string chamberName){ - int numOfML=0; - const int numParams=10; - int chamberGeo[numParams]; - for (int i=0;i<=9;i++) chamberGeo[i]=0; - ReadChamberMapFile(chamberName,chamberGeo,numParams); - numOfML=chamberGeo[0]; - return numOfML; -} -int HistogramManager::GetChamberNumOfMezzPerML (std::string chamberName){ - int numOfMezzPerML=0; - const int numParams=10; - int chamberGeo[numParams]; - for (int i=0;i<=9;i++) chamberGeo[i]=0; - ReadChamberMapFile(chamberName,chamberGeo,numParams); - numOfMezzPerML=chamberGeo[1]; - return numOfMezzPerML; -} -int HistogramManager::GetChamberTubesPerMezz (std::string chamberName){ - int numOfTubesPerMezz=0; - const int numParams=10; - int chamberGeo[numParams]; - for (int i=0;i<=9;i++) chamberGeo[i]=0; - ReadChamberMapFile(chamberName,chamberGeo,numParams); - numOfTubesPerMezz=chamberGeo[2]; - return numOfTubesPerMezz; -} - -void HistogramManager::ReadChamberMapFile(std::string chamberName, int * chamberGeoParams, int numParams) { - - for (int i=0; i<numParams; i++) chamberGeoParams[i]=0; - std::string s; - std::ifstream inf("ChambersLayout.txt"); - - if(!inf.good()){ - return; - } - - // scanning of map file - while(getline(inf,s)){ - - // bool test=false; - std::string name, tag; - std::istringstream is(s); - is>>tag; - - if(tag=="name"){ //scan chamber block - - if(!(is>>name).good()){//1. take the name - break; - } - - /* - Check if any chamber on the mapfile is a chamber to test; - it's the best way to scan the mapfile just one time. - */ - - if(name!=chamberName){ - //if what I find in file is NOT a chamber to be tested - continue; - } else { //3. read full information - unsigned int ReadInfo=0; - - for(int i=0;i<20;i++){ - //chamber block is supposed to be shorter than 20 lines - - if(!getline(inf,s).good()){ - continue; - } - if(s.c_str()[0]=='#') { - continue; - } - if(s=="END_CHAMBER") { - break; //out of "for" over 20 lines - } - - std::istringstream is(s); - is>>tag; - - if (tag=="MLayers"){ - if (!(is>>chamberGeoParams[0]).good()) { - break; - } - ReadInfo++; - } - - if(tag=="MezzPerML"){ - if (!(is>>chamberGeoParams[1]).good()) { - break; - } - ReadInfo++; - } - - if(tag=="MezzTypeML1"){ - int mezzType=0; - int tubesPerMezz=0; - is>>mezzType; - if (mezzType<1 || mezzType>4) { - break; - } - if (mezzType==1 || mezzType==2) tubesPerMezz=8; - if (mezzType==3 || mezzType==4) tubesPerMezz=6; - chamberGeoParams[2]=tubesPerMezz; - ReadInfo++; - } - - if(tag=="MezzTypeML2"){ - ReadInfo++; - } - - if(tag=="IncreaseWithZ"){ - ReadInfo++; - } - - if(tag=="ZeroMezzML"){ - ReadInfo++; - break; //out of "for" over 20 lines - } - - }// end for over 20 lines - - break; //out of "for" loop on ChambList - }// else if(name...) - - }// end if tag=name - - } // end while - - return; -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTDeadElementsAnalysis.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTDeadElementsAnalysis.cxx deleted file mode 100644 index 91e7313c5f4717f4495d7f3913d685fb1440d1e6..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTDeadElementsAnalysis.cxx +++ /dev/null @@ -1,2229 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibStandAloneExtraTools/MDTDeadElementsAnalysis.h" -#include "GaudiKernel/MsgStream.h" -#include "AthenaKernel/getMessageSvc.h" - -#include <cmath> -#include <fstream> -#include <sstream> -#include <iostream> -#include <TH1F.h> -#include <TH2F.h> -#include <TF1.h> -#include <TFile.h> -#include <TKey.h> -#include <TCanvas.h> -#include <TStyle.h> - -class ToString { -public: - template< class T > - std::string operator()( const T &i ) { - std::ostringstream os; - os << i; - return os.str(); - } -}; - -MDTDeadElementsAnalysis::MDTDeadElementsAnalysis() : - polfunc(NULL), deadTubesMap(NULL), geo(NULL), ndeadmezz(-1), ndeadtubes(-1), - deadMezzDone(false), deadTubesDone(false), deadMultilayerDone(false), - nlayers(-1), nlayers_per_ml(-1), ntubes_per_mezz(-1), chi2poly(-1.), - average_entry(-1.), n_entry(-1.), nholes(-1) { - verbose=false; - drawPlots=false; - writeResultsToAsciFile=false; -} - -// ============================================================================== -// -// MDTDeadElementsAnalysis::histogramScanCalibCenters -// -// ============================================================================== - -void MDTDeadElementsAnalysis::histogramScanCalibCenters(TFile *rootfile) { - - int nregionsanalysed=0; - int nsectorsanalysed=0; - - if(rootfile->IsZombie()) { - return; - } - - int n_processed_chambers=0; - - std::string sector; - std::string chamber; - - TH1F* hadccut; - TH1F* hgeom; - TH1F* hdeadmap; - TH2F* hdeadchannels; - TH2F* hsummary; - - for (int iregion=1; iregion<=4; iregion++) { - std::string region_name; - if (iregion==1) region_name="Barrel_A"; - if (iregion==2) region_name="Barrel_C"; - if (iregion==3) region_name="Endcap_A"; - if (iregion==4) region_name="Endcap_C"; - std::string regiondir_name="/MDT/"+region_name; - - TDirectory* regiondir=(TDirectory*)rootfile->Get(regiondir_name.c_str()); - if(!regiondir) { - continue; - } - - hsummary = (TH2F*) regiondir->Get("DeadElements"); - if(hsummary) hsummary->Reset(); - - nregionsanalysed++; - - for (int isector=1; isector<=16; isector++) { - - TString sector_name=(isector<10)?("Sector0"):("Sector"); - sector_name+=isector; - TDirectory* sectordir=(TDirectory*)regiondir->Get((const char*)sector_name); - - nsectorsanalysed++; - - TIter next(sectordir->GetListOfKeys()); - TKey *key; - while ( (key = (TKey*)next()) ) { - std::string chamber_name=key->GetName(); - if (chamber_name=="OVERVIEW") continue; - - TDirectory* chamberdir=(TDirectory*)sectordir->Get(chamber_name.c_str()); - TDirectory* deadstatusdir=(TDirectory*)sectordir->Get((chamber_name+"/DeadStatus").c_str()); - TDirectory* expertdir=(TDirectory*)sectordir->Get((chamber_name+"/Expert").c_str()); - - if(!chamberdir) { - continue; - } - - if(!deadstatusdir) { - continue; - } - - if(!expertdir) { - continue; - } - - hadccut = (TH1F*) chamberdir->Get("a_HitsPerTubeAdcCut"); - hgeom = (TH1F*) expertdir->Get("DeadTubeRefMap"); - hdeadmap = (TH1F*) expertdir->Get("DeadTubeMap"); - - // RESET hdeadmap and make it a copy of hgeom : - // - int nbinshref=hgeom->GetNbinsX(); - int nbinshres=hdeadmap->GetNbinsX(); - if (nbinshref!=nbinshres) { - continue; - } - hdeadmap->Reset(); - for (int bin=1;bin<=nbinshref;bin++){ - hdeadmap->SetBinContent(bin,hgeom->GetBinContent(bin)); - } - - // Clone a_HitsPerTubeAdcCut - // - TH1F *HhitsCopy = (TH1F*)hadccut->Clone(); - getBasicGeometry(hgeom,chamber_name); - deadElementsAnalysis(HhitsCopy,hgeom,hdeadmap,4,chamber_name); - - HhitsCopy->Delete(); - n_processed_chambers++; - - // report here the results in the 2D chamber view histogram: - TH1F *hdeadtubestatus=(TH1F*)chamberdir->FindObjectAny("b_DeadTubeStatus"); - if(hdeadtubestatus) hdeadtubestatus->Reset(); - - TH2F *hdeadtubes=(TH2F*) deadstatusdir->FindObjectAny("ChamberDeadTubes"); - hdeadtubes->Reset(); - - hdeadchannels = (TH2F*) expertdir->Get("ChamberDeadChannels"); - - hdeadchannels->Reset(); - hdeadchannels->SetMinimum(0); - hdeadchannels->SetMaximum(10); - int totBins = hdeadmap->GetNbinsX(); - - std::vector<int> ntubes_per_layer; - for(int j=1; j<=2;j++){ - ntubes_per_layer.push_back(nbins_per_layer[j-1]); - } - - if( chamber_name =="BIR1A11") ntubes_per_layer[0] = 30; - if( chamber_name =="BIR4A11") ntubes_per_layer[0] = 30; - if( chamber_name =="BIR1A15") ntubes_per_layer[0] = 30; - if( chamber_name =="BIR4A15") ntubes_per_layer[0] = 30; - - - for(int jML=1; jML<=2;jML++){ - - for(int jLay=1; jLay<=nlayers_per_ml;jLay++){ - - TString deadlayername="DeadTubes_ML"; - deadlayername+=jML; - deadlayername+="_L"; - deadlayername+=jLay; - - TH1F *hdeadperlayer =(TH1F*)deadstatusdir->FindObjectAny((const char*)deadlayername); - if(hdeadperlayer) hdeadperlayer->Reset(); - - - int bincounter=0; - - // for(int jbin=1; jbin<=nbins_per_layer[jML-1];jbin++){ - for(int jbin=1; jbin<=ntubes_per_layer[jML-1];jbin++){ - - int alltubes = (jML-1)*(nlayers_per_ml)*(ntubes_per_layer[jML-1]) + (jLay-1)*(ntubes_per_layer[jML-1])+jbin; - - int ires = (int)hdeadmap->GetBinContent(alltubes); - - if (ires==0) continue; -// int iML = 1; -// if (ires>0) iML = 2; -// int iLy = (jbin-1)/(int)ntubes_per_layer[jML-1] + 1; -// if (iML==2) iLy = iLy+1; -// int iTube = (jbin-1)%ntubes_per_layer[jML-1] + 1; - int icode = ires%10; - - if (icode<0) icode=-icode; - if (icode==0) icode=10; - - double contr=0; - - if(icode==0){ - } else if(icode==10){ - contr=1; - } else if(icode==7 ){ - } else{ - } - double contr2=contr; - if(icode!=0 && contr==0) contr2=0.1; - - bincounter++; - if(hdeadperlayer) hdeadperlayer->SetBinContent(bincounter,contr2); - } - } - } - - for (int bin=1;bin<=totBins;bin++){ - int ires = (int)hdeadmap->GetBinContent(bin); - if (ires==0) continue; - int iML = 1; - if (ires>0) iML = 2; - // int iLy = (bin-1)/(int)nbins_per_layer[iML-1] + 1; - int iLy = (bin-1)/(int)ntubes_per_layer[iML-1] + 1; - if (iML==2) iLy = iLy+1; - // int iTube = (bin-1)%nbins_per_layer[iML-1] + 1; - int iTube = (bin-1)%ntubes_per_layer[iML-1] + 1; - int icode = ires%10; - - if (icode<0) icode=-icode; - if (icode==0) icode=10; - hdeadchannels->SetBinContent(iTube,iLy,(float)icode); - - int Lay_offset = 0; - if(nlayers_per_ml ==3) Lay_offset = 1; - iLy = iLy + Lay_offset; - - double contr=0; - - if(icode==0){ - hdeadtubes->SetBinContent(iTube,iLy,1); //white - } else if(icode==10){ - contr=1; - hdeadtubes->SetBinContent(iTube,iLy,2); //green - } else if(icode==7 ){ - hdeadtubes->SetBinContent(iTube,iLy,3); // yellow - } else { - hdeadtubes->SetBinContent(iTube,iLy,4); // red - } - double contr2=contr; - if(icode!=0 && contr==0) contr2=0.1; - - if(hdeadtubestatus) hdeadtubestatus->SetBinContent(bin,contr2); - - } - - if (hsummary){ - hsummary->Fill(isector,2, (float) deadChamber.size() ); - hsummary->Fill(isector,3, (float) deadMultilayer.size() ); - hsummary->Fill(isector,4, (float) deadLayer.size() ); - hsummary->Fill(isector,5, (float) deadMezz.size() ); - hsummary->Fill(isector,6, (float) deadTube.size() ); - } - } // end loop on chambers - } // end loop over sectors - } // end loop over regions BA/BC/EA/EC -} //end MDTDeadElementsAnalysis::histogramScanCalibCenters - -// ============================================================================== -// -// MDTDeadElementsAnalysis::histogramScanGnam -// -// ============================================================================== - -void MDTDeadElementsAnalysis::histogramScanGnam(std::string rootfile){ - - TFile f(rootfile.c_str()); - - if(f.IsZombie()) { - return; - } - - MDTDeadElementsAnalysis *mdtTubeAna = new MDTDeadElementsAnalysis; - - f.cd("MDT"); - TDirectory *dir = gDirectory; - TIter next(dir->GetListOfKeys()); - TKey *key; - int n_processed_chambers=0; - - while ((key=(TKey*)next())) { - TString chambname=key->GetName(); - if(chambname!="Overview"){ - TString path1 = "BARREL_A" + chambname + "/HitsPerTube_gt_100_ADC_counts"; - TString path2 = "DEBUG/MDT/" + chambname + "/HitsPerTube<AdcCut"; - n_processed_chambers++; - }//if !OVERVIEW - }//key while - - - mdtTubeAna->printSummary(); - - // --------- - f.Close(); - - delete mdtTubeAna; mdtTubeAna=0; - return; -} //end MDTDeadElementsAnalysis::histogramScanGnam - -// ============================================================================== -// -// MDTDeadElementsAnalysis::WriteAsciFile -// -// ============================================================================== -void MDTDeadElementsAnalysis::WriteAsciFile(){ - writeResultsToAsciFile = true; -} // WriteAsciFile - -// ============================================================================== -// -// MDTDeadElementsAnalysis::getChamberName() -// -// ============================================================================== -std::string MDTDeadElementsAnalysis::getChamberName(){ - return chamberName; -} // getChamberName - -// ============================================================================== -// -// MDTDeadElementsAnalysis::setChamberName(string chambname) -// -// ============================================================================== -void MDTDeadElementsAnalysis::setChamberName(std::string chambname){ - chamberName = chambname; -} // setChamberName - -// ============================================================================== -// -// MDTDeadElementsAnalysis::setVerbose -// -// ============================================================================== -void MDTDeadElementsAnalysis::setVerbose(){ - verbose = true; -} // setVerbose - -// ============================================================================== -// -// MDTDeadElementsAnalysis::setNoVerbose -// -// ============================================================================== -void MDTDeadElementsAnalysis::setNoVerbose(){ - verbose = false; -} // setNoVerbose - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadElementsAnalysis -// -// ============================================================================== -void MDTDeadElementsAnalysis::deadElementsAnalysis(TH1F *idh1, TH1F *HRef, TH1F *deadTubesMap, int /*nlayers_ml*/, std::string chambname) { - - getBasicGeometry(HRef,chambname); - // Initialization - - ClearList(); - int total_bins= (int) idh1->GetNbinsX(); - Clear(total_bins); - setChamberName(chambname); - // Processing - chamberName=chambname; - deadChambers(idh1,HRef, deadTubesMap, chambname); - if (deadChamber.size()==0) deadMultilayers(idh1,HRef, deadTubesMap, chambname); - if (deadChamber.size()==0) deadLayers(idh1,HRef, deadTubesMap, chambname); - if (deadChamber.size()==0) deadMezzanines(idh1,HRef, deadTubesMap, chambname); - if (deadChamber.size()==0) deadTubes(idh1,HRef, deadTubesMap, chambname); - - // Finalize - if(verbose) { - printSummary(); - if (drawPlots) { - TCanvas *c1 = new TCanvas(); - c1->cd(); - deadTubesMap->Draw(); - } - } - if (writeResultsToAsciFile){ - printCompactSummaryToAsciFile(); - } - - return; -}// deadElementsAnalysis - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadElementsAnalysis -// -// ============================================================================== -void MDTDeadElementsAnalysis::deadElementsAnalysis(TH1F* idh1, TH1F* HRef, TH1F* deadTubesMap, - int /*nlayers_ml*/, std::string chambname, int convert_mezzanine[20]){ - - getBasicGeometry(HRef,chambname); - // Initialization - ClearList(); - int total_bins= (int) idh1->GetNbinsX(); - Clear(total_bins); - setChamberName(chambname); - // Processing - chamberName=chambname; - deadChambers(idh1,HRef, deadTubesMap, chambname); - if (deadChamber.size()==0) deadMultilayers(idh1,HRef, deadTubesMap, chambname); - if (deadChamber.size()==0) deadLayers(idh1,HRef, deadTubesMap, chambname); - if (deadChamber.size()==0) deadMezzanines(idh1,HRef, deadTubesMap, chambname, convert_mezzanine); - if (deadChamber.size()==0) deadTubes(idh1,HRef, deadTubesMap, chambname); - - // Finalize - if(verbose) { - printSummary(); - if (drawPlots) { - TCanvas * c1 = new TCanvas(); - c1->cd(); - deadTubesMap->Draw(); - } - } - if (writeResultsToAsciFile){ - printSummaryToAsciFile(); - } - - return; -}// deadElementsAnalysis - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadChambers -// -// ============================================================================== -void MDTDeadElementsAnalysis::deadChambers(TH1F *idh1, TH1F */*HRef*/, TH1F */*deadTubesMap*/, std::string chambname){ - if (idh1->GetEntries() == 0.) deadChamber.push_back(chambname); -}// deadChambers - - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadLayers -// -// ============================================================================== -void MDTDeadElementsAnalysis::deadLayers(TH1F* idh1,TH1F* HRef, TH1F* deadTubesMap, std::string chambname){ - double layer_content[8]; - int layer_non_zero_bins[8]; - for(int ii=0; ii<8; ii++){ - layer_content[ii] = 0.; - layer_non_zero_bins[ii] = 0; - } - int binstart = 1; - int binend = nbins_per_layer[0]; - int indlayer=0; - for(int ml=1;ml<3;ml++){ - // protection if only 1 ml - if (nbins_per_layer[ml-1]==0) continue; - for(int l=1;l<=nlayers_per_ml;l++){ - layer_content[indlayer]=0.; - layer_non_zero_bins[indlayer-1]=0; - for(int bin=binstart;bin<=binend;bin++){ - double c=idh1->GetBinContent(bin); - layer_content[indlayer-1]=layer_content[indlayer-1]+c; - if(c>0.)layer_non_zero_bins[indlayer-1]++; - } - binstart=binstart+nbins_per_layer[0]; - binend=binend+nbins_per_layer[0]; - indlayer++; - } // loop layers of 1 ml - } // loop 2 multilayers - - // analysis now: 1) minimum & average - - int minimum_position=1; - int minimum_content=layer_non_zero_bins[0]; - double average_non_zero_bins=0.; - for(int l=1;l<indlayer-1;l++){ - if(layer_non_zero_bins[l-1]<minimum_content){ - minimum_position=l; - minimum_content=layer_non_zero_bins[l-1]; - } - average_non_zero_bins = average_non_zero_bins + - double(layer_non_zero_bins[l-1]); - } - average_non_zero_bins = average_non_zero_bins - minimum_content; - average_non_zero_bins = average_non_zero_bins / double(indlayer-1-1); - - // analysis 2) rms - - double rms_non_zero_bins=0.; - for(int l=1;l<indlayer;l++){ - if(l!=minimum_position){ - rms_non_zero_bins = std::pow(average_non_zero_bins - double(layer_non_zero_bins[l-1]),2) - + rms_non_zero_bins; - } - } - rms_non_zero_bins = std::pow(rms_non_zero_bins/double(indlayer-1),0.5); - if(rms_non_zero_bins<1.) rms_non_zero_bins=1.; - - // analysis 3) spot dead layer when average-3*rms/(layers-1)>content of minimum && rms!=1 - // analysys 4) average bin content < 20. - float average_bin_content = (float)layer_content[minimum_position-1]/(float)nbins_per_layer[0]; - bool test = average_non_zero_bins-8.*rms_non_zero_bins/std::pow(double(indlayer-1),0.5)>minimum_content - &&rms_non_zero_bins!=1.&&average_bin_content<10.; - if(test) { - int tubestart = (minimum_position-1)*nbins_per_layer[0]+1; - int tubeend = minimum_position*nbins_per_layer[0]; - deadLayer.push_back(minimum_position); - deadLayerChamber.push_back(chambname); - for(int j=tubestart;j<=tubeend;j++){ - Double_t cgeo = HRef->GetBinContent(j); - Double_t signML = cgeo/std::abs(cgeo); - int igeo = (int) cgeo; - Int_t refquantity = igeo%10; - if(std::abs(cgeo)!=0.&& refquantity == 0){ - deadTubesMap->Fill(j,4.*signML); - } - } - } - // verbose=false; -}// deadLayers - -// ============================================================================== -// -// MDTDeadElementsAnalysis::getBasicGeometry -// -// ============================================================================== - -void MDTDeadElementsAnalysis::getBasicGeometry(TH1F* HRef, int nlayers_ml, std::string chambname){ - int nbins=HRef->GetNbinsX(); - schamber = chambname; - chtype = schamber.substr(1,1); - nlayers_per_ml = nlayers_ml; - int firstbinML1=1; - int firstbinML2=10000; - int lastbinML1=-1; - int lastbinML2=-1; - for(int bin=1;bin<=nbins;bin++){ - float content = HRef->GetBinContent(bin); - if(content<0.) { - if(bin>lastbinML1) lastbinML1 = bin; - } - if(content>0.) { - if(bin<firstbinML2) firstbinML2 = bin; - if(bin>lastbinML2) lastbinML2 = bin; - } - } - - firstbinML[0]=firstbinML1; - firstbinML[1]=firstbinML2; - lastbinML[0]=lastbinML1; - lastbinML[1]=lastbinML2; - - nbins_per_layer[0] = (lastbinML[0]-firstbinML[0]+1)/nlayers_ml; - nbins_per_layer[1] = (lastbinML[1]-firstbinML[1]+1)/nlayers_ml; - ntubes_per_mezz=6; - if(chtype=="O" || chtype=="M") { - nlayers=6; - ntubes_per_mezz=8; - } - for(int MultiLayer=0;MultiLayer<2;MultiLayer++){ - nmezz[MultiLayer]=nbins_per_layer[MultiLayer]/ntubes_per_mezz; - // Algos parameters - ntubes[MultiLayer]=15; - tstep[MultiLayer]=5.; - if(nbins_per_layer[MultiLayer]==36){ - ntubes[MultiLayer]=18; - tstep[MultiLayer]=6.; - } - if(nbins_per_layer[MultiLayer]==72){ - ntubes[MultiLayer]=12; - tstep[MultiLayer]=6.; - } - if(nbins_per_layer[MultiLayer]==64){ - ntubes[MultiLayer]=16; - tstep[MultiLayer]=8.; - } - if(nbins_per_layer[MultiLayer]==48){ - ntubes[MultiLayer]=16; - tstep[MultiLayer]=8.; - } - if(nbins_per_layer[MultiLayer]==56){ - ntubes[MultiLayer]=14; - tstep[MultiLayer]=7.; - } - } -} // getBasicGeometry - - // ============================================================================== - // - // MDTDeadElementsAnalysis::getBasicGeometry - // - // ============================================================================== - -void MDTDeadElementsAnalysis::getBasicGeometry(TH1F* HRef, std::string chambname){ - int nbins=HRef->GetNbinsX(); - schamber = chambname; - chtype = schamber.substr(1,1); - int firstbinML1=10000; - int firstbinML2=10000; - int lastbinML1=-1; - int lastbinML2=-1; - int nlayers_ml1=0; - int nlayers_ml2=0; - for(int bin=1;bin<=nbins;bin++){ - float content = HRef->GetBinContent(bin); - if(content<0.) { - float f_level=std::abs(content)/10.; - int i_level= (int) f_level; - if(i_level==(int) f_level && i_level>nlayers_ml1) { - nlayers_ml1=i_level; - } - if(i_level<(int) f_level && i_level+1>nlayers_ml1) { - nlayers_ml1=i_level+1; - } - if(bin<firstbinML1) firstbinML1 = bin; - if(bin>lastbinML1) lastbinML1 = bin; - } - if(content>0.) { - float f_level=std::abs(content)/10.; - int i_level= (int) f_level; - if(i_level==(int) f_level && i_level>nlayers_ml2) { - nlayers_ml2=i_level; - } - if(i_level<(int) f_level && i_level+1>nlayers_ml2) { - nlayers_ml2=i_level+1; - } - if(bin<firstbinML2) firstbinML2 = bin; - if(bin>lastbinML2) lastbinML2 = bin; - } - } - if(nlayers_ml1>0&&nlayers_ml2>0){ - // two real multilayers - if(lastbinML1+1!=firstbinML2){ - // cut out multilayer - lastbinML1=nbins/2; - firstbinML2=lastbinML1+1; - } - } - firstbinML[0]=firstbinML1; - firstbinML[1]=firstbinML2; - lastbinML[0]=lastbinML1; - lastbinML[1]=lastbinML2; - nbins_per_layer[0]=0; - nbins_per_layer[1]=0; - if(nlayers_ml1>0){ - nbins_per_layer[0] = (lastbinML[0]-firstbinML[0]+1)/nlayers_ml1; - } - if(nlayers_ml2>0){ - nbins_per_layer[1] = (lastbinML[1]-firstbinML[1]+1)/nlayers_ml2; - } - ntubes_per_mezz=6; - nlayers_per_ml=nlayers_ml1; - if(chtype=="O" || chtype=="M") { - nlayers=6; - ntubes_per_mezz=8; - } - for(int MultiLayer=0;MultiLayer<2;MultiLayer++){ - nmezz[MultiLayer]=nbins_per_layer[MultiLayer]/ntubes_per_mezz; - // Algos parameters - ntubes[MultiLayer]=15; - tstep[MultiLayer]=5.; - if(nbins_per_layer[MultiLayer]==36){ - ntubes[MultiLayer]=18; - tstep[MultiLayer]=6.; - } - if(nbins_per_layer[MultiLayer]==72){ - ntubes[MultiLayer]=12; - tstep[MultiLayer]=6.; - } - if(nbins_per_layer[MultiLayer]==64){ - ntubes[MultiLayer]=16; - tstep[MultiLayer]=8.; - } - if(nbins_per_layer[MultiLayer]==56){ - ntubes[MultiLayer]=14; - tstep[MultiLayer]=7.; - } - } - -} // getBasicGeometry - - // ============================================================================== - // - // MDTDeadElementsAnalysis::printSummary - // - // ============================================================================== - -void MDTDeadElementsAnalysis::printSummary(){ - -}// printSummary -// ============================================================================== -// -// MDTDeadElementsAnalysis::printSummaryToAsciFile -// -// ============================================================================== - -void MDTDeadElementsAnalysis::printSummaryToAsciFile(){ - std::ofstream deadAna; - deadAna.open("deadana.dat",std::ios::app); - - unsigned im=0; - if(noisyChamber.size()+deadMultilayer.size()+deadLayer.size()+deadMezz.size()+deadTube.size()>0) - deadAna<<"Examine chamber "<<chamberName<<std::endl; - - if(noisyChamber.size()>0){ - deadAna<<"number of noisy chambers "<<noisyChamber.size()<<std::endl; - for(im=0;im<noisyChamber.size();im++){ - deadAna<<" "<<noisyChamber[im]<<std::endl; - } - } - - if(deadMultilayer.size()>0){ - deadAna<<"number of dead MultiLayers "<<deadMultilayer.size()<<std::endl; - for(im=0;im<deadMultilayer.size();im++){ - deadAna<<" dead MultiLayer "<<deadMultilayer[im]<<" found in chamber "<<deadMLChamber[im]<<std::endl; - } - } - - if(deadLayer.size()>0){ - deadAna<<"number of dead Layers "<<deadLayer.size()<<std::endl; - for(im=0;im<deadLayer.size();im++){ - deadAna<<" dead Layer "<<deadLayer[im]<<" found in chamber "<<deadLayerChamber[im]<<std::endl; - } - } - - if(deadMezz.size()>0){ - deadAna<<"number of dead mezz "<<deadMezz.size()<<std::endl; - for(im=0;im<deadMezz.size();im++){ - deadAna <<" chamber "<<deadMezzChamber[im]<<" mezzanine "<<deadMezz[im]<< - " reduced numbering mezzanine "<<deadMezz_red[im]<< - " csm mezzanine "<<deadMezz_csm[im]<< - " dead in layer "<<deadMezzML[im]<<std::endl; - } - } - - if(deadTube.size()>0){ - deadAna<<"number of dead tubes "<<deadTube.size()<<std::endl; - for(im=0;im<deadTube.size();im++){ - deadAna<<" "<<deadTubeChamber[im]<<" "<<deadTube[im]<<" "<<deadTubeML[im]<<" "<<deadTubeLay[im]<<std::endl; - } - } - -}// printSummaryToAsciFile - -// ============================================================================== -// -// MDTDeadElementsAnalysis::printCompactSummaryToAsciFile -// -// ============================================================================== - - -void MDTDeadElementsAnalysis::printCompactSummaryToAsciFile(){ - - std::ofstream deadAna; - deadAna.open("deadana.dat",std::ios::app); - - unsigned im=0; - - if(deadChamber.size()>0){ - deadAna<<chamberName<< " dead_CHAMBER "<<std::endl; - } - - if(deadMultilayer.size()>0){ - for(im=0;im<deadMultilayer.size();im++){ - deadAna<<deadMLChamber[im]<< " dead_MULTILAYER "<<deadMultilayer[im]<<std::endl; - } - } - - if(deadLayer.size()>0){ - for(im=0;im<deadLayer.size();im++){ - int lay=deadLayer[im]; - int ml=1; - if (lay>nlayers_per_ml) { - lay=lay-nlayers_per_ml; - ml=2; - } - deadAna<<deadLayerChamber[im]<< " dead_LAYER "<<ml<<" "<<lay<<std::endl; - } - } - - if(deadMezz.size()>0){ - for(im=0;im<deadMezz.size();im++){ - deadAna <<deadMezzChamber[im]<<" dead_MEZZANINE "<<deadMezz[im]<< - " reduced numbering mezzanine "<<deadMezz_red[im]<< - " csm mezzanine "<<deadMezz_csm[im]<< - " dead in MultiLayer "<<deadMezzML[im]<<std::endl; - } - } - - if(deadTube.size()>0){ - for(im=0;im<deadTube.size();im++){ - deadAna<<deadTubeChamber[im]<<" dead_TUBE "<<deadTubeML[im]<<" "<<deadTubeLay[im]<<" "<<deadTube[im]<<std::endl; - } - } - -}// printCompactSummaryToAsciFile -// ============================================================================== -// -// MDTDeadElementsAnalysis::NoisyChamber -// -// ============================================================================== - -bool MDTDeadElementsAnalysis::NoisyChamber(TH1F* idh1, std::string chambname){ - - double binsbelow2=0; - double binsabove1=0; - int nbins=idh1->GetNbinsX(); - int Entries=0; - for(int bin=1;bin<=nbins;bin++){ - Entries = Entries + (int) idh1->GetBinContent(bin); - } - double bins = (double) nbins; - for (int nb=1;nb<=nbins;nb++){ - if (idh1->GetBinContent(nb)<2.) { - binsbelow2++; - } else { - binsabove1++; - } - } - - double ratio=0.; - - if (Entries>0) { - ratio= binsbelow2 / bins;} - bool Noise=false; - if (ratio>0.5) { - Noise=true; - noisyChamber.push_back(chambname); - } - - return Noise; - -}// NoisyChamber - -// ============================================================================== -// -// MDTDeadElementsAnalysis::ClearList -// -// ============================================================================== - -void MDTDeadElementsAnalysis::ClearList(){ - - noisyChamber.clear(); - deadChamber.clear(); - deadLayer.clear(); - deadLayerChamber.clear(); - deadMLChamber.clear(); - deadMLCounts.clear(); - deadMLLevel.clear(); - deadMultilayer.clear(); - deadMezzChamber.clear(); - deadMezz.clear(); - deadMezzML.clear(); - deadMezz_csm.clear(); - deadMezz_red.clear(); - deadMezzEffi.clear(); - deadMezzErrEffi.clear(); - deadMezzChi2.clear(); - deadTube.clear(); - deadTubeId.clear(); - deadTubeHistoBin.clear(); - deadTubeChamber.clear(); - deadTubeLay.clear(); - deadTubeML.clear(); - deadTubeChi2.clear(); - deadTubeEffi.clear(); - deadTubeErrEffi.clear(); - -} // ClearList - - // ============================================================================== - // - // MDTDeadElementsAnalysis::Clear - // - // ============================================================================== - -void MDTDeadElementsAnalysis::Clear(int ntubes){ - - chamberName="NULL"; - deadMezzDone=false; - deadTubesDone=false; - ndeadmezz=0; - for(int i=0;i<nmmax;i++){ - deadmezz[i]=0; - deadmezzMLay[i]=0; - } - ndeadtubes=0; - if(ntubes>ntmax || ntubes<0) ntubes=ntmax; - for (int i=0;i<ntubes;i++){ - deadtube[i]=0; - deadtubeseed[i]=0.; - deadtubelen[i]=0.; - deadtubeLay[i]=0; - deadtubeML[i]=0; - deadtubechi2[i]=0; - deadtubeeffi[i]=0; - deadtubeerr[i]=0; - for(int j=0;j<3;j++) deadtubestat[i][j]=0; - } - -}// Clear - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadTubes -// -// ============================================================================== - -void MDTDeadElementsAnalysis::deadTubes(TH1F* idh, TH1F* HRef, TH1F* deadTubesMap, std::string chambname){ - - std::string codepart="MDTDeadElementsAnalysis"; - std::string option="Q"; - - TH1F * idh1 = (TH1F*)idh->Clone(); - - int tottubes= (int) idh1->GetNbinsX(); - for (int nb=1;nb<=tottubes;nb++){ - if(idh1->GetBinContent(nb)==0.) { - // test test test - float cref=HRef->GetBinContent(nb); - if(cref!=0.) { - idh1->SetBinError(nb,2.3); - } - } - } - - MDTDeadElementsAnalysis::deadTubesDone=true; - - int nbins=idh1->GetNbinsX(); - int Entries=0; - for(int bin=1;bin<=nbins;bin++){ - Entries = Entries + (int) idh1->GetBinContent(bin); - } - float averageEntries = float(Entries) / float(nbins); - if(Entries>4000 || averageEntries > 10.){ - - double chi2cut=30.; - if(Entries>50000.) { - chi2cut=60.; - } - - std::vector<double> parf(7, 0.0); - polfunc = new TF1("fit0",polnml3,1.,(double)2.*ntubes[0],4); - TF1 *fitfunc = new TF1("fit1",completefunc,1.,(double)2.*ntubes[0],7); - - // loop over ML's - for(int ML=0;ML<2;ML++){ - if (nbins_per_layer[ML]==0) continue; - /* - Make sure not to loop over a dead ML - */ - bool MLdead = false; - for(unsigned int im=0;im<deadMultilayer.size();im++){ - if(deadMultilayer[im]==ML+1) MLdead = true; - } - if(MLdead) { - break; - } - double tubestart=1.+ML*(firstbinML[1]-1); - fitfunc->SetParameters(-51.,180.,-10.,0.,9.,1.,0.5); - - for (int nlay=1; nlay<=nlayers_per_ml;nlay++){ - double tube0 = (nlay-1)*nbins_per_layer[ML]+1+ML*nbins_per_layer[1]*nlayers_per_ml; - double tube1 = tube0 + nbins_per_layer[ML]-1; - - for (tubestart = tube0; tubestart <=tube1-ntubes[ML]+1; tubestart=tubestart+tstep[ML]) { - // here the scan starts; you have a sliding fit interval which goes from - // t0start to t0start + ntubes[0] - - // if a polnml3 fit gives a good chi2 -> no dead tube - // - - option="Q"; - if(verbose) { - option=""; - } - if (verbose){ - idh1->SetMinimum(0.); - idh1->SetAxisRange(tubestart-2.5,tubestart+ntubes[ML]+1.5); - idh1->Fit(polfunc,option.c_str(),"",(double)tubestart,(double)tubestart+ntubes[ML]-1); - if (drawPlots) { - TCanvas *c1 = new TCanvas(); - c1->WaitPrimitive(); - int inutile; - std::cin>>inutile; - } - } else { - idh1->Fit(polfunc,option.c_str(),"",(double)tubestart,(double)tubestart+ntubes[ML]-1); - } - double chi2pol3=polfunc->GetChisquare(); - for (int n=0;n<=3;n++) polyparf[n]=polfunc->GetParameter(n); - if(chi2pol3<chi2cut) continue; - - double chi2min=99999999.; - double xbinmin; - int ibinmin = 0; - - average_entry=0.; - n_entry=0.; - - int firsttube = int (tubestart); - int mtubes = int(ntubes[ML]); - getSpikesInInterval(idh1,firsttube,firsttube+mtubes-1,polfunc); - getHolesInInterval(idh1,firsttube,firsttube+mtubes-1,mtubes, polfunc); - getHolesInInterval_strategy5(idh1,firsttube,firsttube+mtubes-1,mtubes, polfunc); - - std::string oldoption=option; - // setVerbose(); - if(average_entry==0) continue; - - double err[10]; - // remove all holes from the fit! - for(int nh=0;nh<nholes;nh++){ - // put error=0.-> bin does not count in fit - err[nh]=idh1->GetBinError(holes[nh]); - idh1->SetBinError(holes[nh],0.); - } - // loop over all holes ! - - for(int nh=0;nh<nholes;nh++){ - option="Q"; - if(verbose) { - option=""; - } - // stop analysis if eff_hole is > .4 - if(eff_hole[nh]>0.4) continue; - for(int i=0;i<4;i++){ - fitfunc->SetParameter(i,polyparf[i]); - } - ibinmin = holes[nh]; - xbinmin=idh1->GetBinCenter(ibinmin); - if(err[nh]>0.) idh1->SetBinError(ibinmin,err[nh]); - if(err[nh]==0.) idh1->SetBinError(ibinmin,2.3); - idh1->SetBinError(ibinmin,2.3); - fitfunc->SetParameter(6,1.); - fitfunc->SetParameter(4,xbinmin); - fitfunc->SetParameter(5,1.); - fitfunc->SetParLimits(4,0.,36.); - fitfunc->SetParLimits(6,-2.,2.); // TEST TEST - chi2min = 99999999999999.; - double lenmin; - double effimin; - double errmin; - double binminfit; - double len=1.; - // prepare complete fit - for(int ipar=0;ipar<4;ipar++){ - fitfunc->SetParameter(ipar,polyparf[ipar]); - } - fitfunc->SetParameter(4,xbinmin); - fitfunc->FixParameter(4,xbinmin); - fitfunc->SetParameter(5,len); - fitfunc->FixParameter(5,len); - fitfunc->SetParameter(6,eff_hole[nh]); - option = option+"B"; - idh1->Fit("fit1",option.c_str(),"",(double)tubestart-0.5,(double)tubestart+ntubes[0]-0.5); - if(verbose){ - idh1->SetMinimum(0.); - } - double chi2 = fitfunc->GetChisquare(); - double deltachi2=chi2pol3-chi2; - if((chi2<chi2cut&&fitfunc->GetParError(6)>.1)||deltachi2/chi2pol3>.3){ - option = option+"E"; // TEST TEST - if(average_entry<50.) option=option+"L"; - // if error on hole efficiency if > 5% refine fit using option 'E' - - if(verbose){ - idh1->Fit("fit1",option.c_str(),"",(double)tubestart-0.5,(double)tubestart+ntubes[ML]-0.5); - } else { - idh1->Fit("fit1",option.c_str(),"",(double)tubestart-0.5,(double)tubestart+ntubes[ML]-0.5); - } - option = oldoption; - } - - chi2min=chi2; - if(average_entry<50.) chi2min=-chi2min; - lenmin=len; - effimin=fitfunc->GetParameter(6); - errmin=fitfunc->GetParError(6); - binminfit=fitfunc->GetParameter(4); - - // the command below (->Wait) is very usefull - // corresponds to the 'wait' of PAW - - if(verbose&&effimin<0.9){ - idh1->SetAxisRange(tubestart-2.5,tubestart+ntubes[ML]+1.5); - if (drawPlots) { - TCanvas *c1 = new TCanvas(); - idh1->Draw(); - c1->WaitPrimitive(); - int inutile; - std::cin>>inutile; - } - } - - // every fit gives a dead tube by definition - // the selection of real dead tubes is done afterward - - // count dead tubes candidates & fill vectors - - int ib=(int) (binminfit);//round it to next integer - binminfit=float(ib)+0.5;//put it in the middle of the bin! - ndeadtubes++; - deadtubeseed[ndeadtubes-1]=ibinmin; - deadtube[ndeadtubes-1]=binminfit; - deadtubelen[ndeadtubes-1]=lenmin; - deadtubechi2[ndeadtubes-1]=chi2min; - deadtubeeffi[ndeadtubes-1]=effimin; - deadtubeerr[ndeadtubes-1]=errmin; - - // compute now difference between polynomial at the position of the dead tube - // and compute [poly-hist(dead-tube)]/stat-error - - // double mrtest=0.; - - double mrtest=0.; - - for(double mr=deadtube[ndeadtubes-1];mr<deadtube[ndeadtubes-1]+deadtubelen[ndeadtubes-1];mr++){ - double emr=idh1->GetBinError(int(mr)); - if(emr==0.) emr=2.3; - double cmr=idh1->GetBinContent(int(mr)); - double pol=parf[0] - +mr*parf[1] - +mr*mr*parf[2] - +mr*mr*mr*parf[3]; - double diff = pol-cmr; - if(diff>0.)mrtest=diff; - if(emr!=0.){mrtest=diff/emr;} - int index=(int) (mr-deadtube[ndeadtubes-1]); - deadtubestat[ndeadtubes-1][index]=mrtest; - }//for mr= - - // put back stat error of the hole to 0 - idh1->SetBinError(ibinmin,0.); - } // end loop holes - // put back error! - for(int nh=0;nh<nholes;nh++){ - idh1->SetBinError(ibinmin,err[nh]); - } - - // end complete fit ================== - - }// loop tubestart - } //loop nlayers - - } // end loop over ML's - - //gabri - validateDeadTubes(chi2cut,HRef,deadTubesMap,chambname); - } //if(Entries>0) - delete idh1; -}// deadTubes - -// ============================================================================== -// -// MDTDeadElementsAnalysis::validateDeadTubes -// -// ============================================================================== - -std::string MDTDeadElementsAnalysis::validateDeadTubes(double chi2cut, TH1F *HRef, TH1F *deadTubesMap, std::string chambname){ - for (int nd=0;nd<ndeadtubes;nd++){ - Double_t cgeo = HRef->GetBinContent(int(deadtube[nd])); - bool stat_significance = ((1.- deadtubeeffi[nd])/deadtubeerr[nd] > 7.)|| - (deadtubestat[nd][0]>5.); - if (deadtubeerr[nd]==0.) continue; - double effective_cut=chi2cut; - if(deadtubechi2[nd])effective_cut=chi2cut*6.; - if (std::abs(deadtubechi2[nd])< effective_cut && stat_significance &&deadtubeeffi[nd]<=0.2 - && cgeo !=0.){ - for(int nt=0;nt<1;nt++){ - int nlay = (int)(((int) deadtube[nd]-1)/nbins_per_layer[0])+1; - int ML=(int)((nlay-1)/nlayers_per_ml)+1; - int tube_in_layer=((int) deadtube[nd])-(nlay-1)*nbins_per_layer[0]; - if(nlay>nlayers_per_ml) nlay=nlay-nlayers_per_ml; - bool alreadyFound = false; - Double_t cdead = deadTubesMap->GetBinContent(int(deadtube[nd])); - // already found in deadTubesMap - int idead = (int) cdead; - Int_t deadquantity = idead%10; - if (deadTubeHistoBin.size()>0) { - if ( deadtube[nd] == deadTubeHistoBin.back() ){ - alreadyFound = true; - } - } - if (!alreadyFound&& deadquantity==0) { - deadTubeHistoBin.push_back(deadtube[nd]); - deadTube.push_back(tube_in_layer); - deadTubeId.push_back(ML*1000+nlay*100+tube_in_layer); - deadTubeChamber.push_back(chambname); - deadTubeLay.push_back(nlay); - deadTubeML.push_back(ML); - deadTubeEffi.push_back(deadtubeeffi[nd]); - deadTubeErrEffi.push_back(deadtubeerr[nd]); - deadTubeChi2.push_back(deadtubechi2[nd]); - Double_t c = (Double_t) deadtube[nd]; - Double_t cgeo = HRef->GetBinContent(int(c)); - Double_t signML = cgeo/std::abs(cgeo); - int igeo = (int) cgeo; - Int_t refquantity = igeo%10; - if(std::abs(cgeo)!=0.&& refquantity ==0){ - deadTubesMap->Fill(int(c),2.*signML); - } - } - - } //for mt = bin - }// end first test ================== - } // for nd=0, dead tubes - return "end processing"; -}//deadTubes - -// ============================================================================== -// -// MDTDeadElementsAnalysis::getHolesInInterval_strategy5 -// -// ============================================================================== - -void MDTDeadElementsAnalysis::getHolesInInterval_strategy5(TH1F* idh1, int firsttube, int lasttube, int /*ntubes*/, TF1 * /*polfunc*/){ - TH1F * distr_of_entries = new TH1F("","",1000,0.,1000.); - for(int ib=firsttube; ib<=lasttube;ib++){ - float cont = idh1->GetBinContent(ib); - distr_of_entries->Fill(cont); -} - MsgStream log(Athena::getMessageSvc(),"MDTDeadElementsAnalysis"); - TF1 *f1 = new TF1("f1", "gaus", 1, 1000); - distr_of_entries->Fit("f1", "RLQ0"); - double mean = f1->GetParameter(2); - double sigma = f1->GetParameter(3); - for(int ib=1;ib<=mean-3.*sigma;ib++){ - double cont = distr_of_entries->GetBinContent(ib); - if(cont!=0) { - for(int ib2=firsttube; ib2<=lasttube;ib2++){ - float cont2 = idh1->GetBinContent(ib2); - if(cont2==float(ib-1)) { - log<<MSG::WARNING<<"bin "<<ib2<<"is dead or inefficient"<<endmsg; - } - } - } - } - -} // getHolesInInterval -// ============================================================================== -// -// MDTDeadElementsAnalysis::getHolesInInterval -// -// ============================================================================== - -void MDTDeadElementsAnalysis::getHolesInInterval(TH1F* idh1, int firsttube, int lasttube, int ntubes, TF1 *polfunc){ - double better_average=average_entry; - double better_entry =n_entry; - std::vector<double> parf(7, 0.0); - std::string codepart="GetHolesInInterval"; - double bestchi2 = 1000000.; - chi2poly=0.; - polfunc->SetParameter(0,polyparf[0]); - polfunc->SetParameter(1,polyparf[1]); - polfunc->SetParameter(2,polyparf[2]); - polfunc->SetParameter(3,polyparf[3]); - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - polyparf[0]=polfunc->GetParameter(0); - polyparf[1]=polfunc->GetParameter(1); - polyparf[2]=polfunc->GetParameter(2); - polyparf[3]=polfunc->GetParameter(3); - double chi2_pol=polfunc->GetChisquare(); - nholes=0; - - // ================== start strategy average > 100 && chi2_pol<100. - // first try comparing wrt average entry - - if(average_entry>100.&& chi2_pol<100.){ - - polyparf[0]=average_entry; - polyparf[1]=0.; - polyparf[2]=0.; - polyparf[3]=0.; - double olderror[10]; - for(int j=0;j<10;j++){holes[j]=0;} - for(int ibin=firsttube;ibin<=lasttube;ibin++){ - double xbin=double(ibin); - double c=idh1->GetBinContent(ibin); - double cerr=idh1->GetBinError(ibin); - double polinomial=polyparf[0] - +xbin*polyparf[1] - +xbin*xbin*polyparf[2] - +xbin*xbin*xbin*polyparf[3]; - double residual = c-average_entry; - // new def!! Use pol fit with all points unless chi2 is very bad - residual=c-polinomial; - if(residual<-3.*cerr&&nholes<10&&c/average_entry<0.9){ - if(nholes<10) nholes++; - olderror[nholes-1]=cerr; - holes[nholes-1]=(int) xbin; - eff_hole[nholes-1]=c/average_entry; - idh1->SetBinError(ibin,0.); - } - } //for(ibin - for(int ih=0;ih<nholes;ih++){ - int holepos=holes[ih]; - double cerr=olderror[ih]; - idh1->SetBinError(holepos,cerr); - } - - } - - // ================== end strategy average > 100 - - // ================== refine strategy average > 100 if chi2>50 - - if(average_entry>100.&& chi2_pol>50.){ - nholes=0; - for(int j=0;j<10;j++){holes[j]=0;} - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - chi2poly = polfunc->GetChisquare(); - bestchi2 = chi2poly; - int bestposition = 0; - double besteff = 1.; - for(int ibin=firsttube;ibin<=lasttube;ibin++){ - double xbin=double(ibin); - double olderr = idh1->GetBinError(ibin); - idh1->SetBinError(ibin,0.); - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - chi2_pol = polfunc->GetChisquare(); - if(bestchi2>chi2_pol){ - bestchi2 = chi2_pol; - bestposition = ibin; - parf[0]=polfunc->GetParameter(0); - parf[1]=polfunc->GetParameter(1); - parf[2]=polfunc->GetParameter(2); - parf[3]=polfunc->GetParameter(3); - double polinomial=parf[0] - +xbin*parf[1] - +xbin*xbin*parf[2] - +xbin*xbin*xbin*parf[3]; - double c=idh1->GetBinContent(ibin); - besteff=c/polinomial; - for(int i=0;i<4;i++){polyparf[i]=parf[i];} - } //if(bestchi2 ... - idh1->SetBinError(ibin,olderr); - } //for (int bin - if(bestchi2<350.){ - nholes=1; - holes[0]=bestposition; - eff_hole[0]=besteff; - } //if(effi ... - } - - // - // INSERT HERE NEW PATCH FOR TWO TUBES !!!! - // - // if still bad try removing two bins ... - - // if(average_entry>100.&& chi2_pol>50.){ - if(average_entry>100.&& bestchi2>50.){ - nholes=0; - int bestposition1 = 0; - double besteff1 = 1.; - int bestposition2 = 0; - double besteff2 = 1.; - - for(int j=0;j<10;j++){holes[j]=0;} - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - chi2poly = polfunc->GetChisquare(); - bestchi2 = chi2poly; - for(int ibin=firsttube;ibin<lasttube;ibin++){ - double xbin1=double(ibin); - double olderr1 = idh1->GetBinError(ibin); - idh1->SetBinError(ibin,0.); - for(int lbin=ibin+1;lbin<=lasttube;lbin++){ - double xbin2=double(lbin); - double olderr2 = idh1->GetBinError(lbin); - idh1->SetBinError(lbin,0.); - - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - chi2_pol = polfunc->GetChisquare(); - if(bestchi2>chi2_pol){ - bestchi2 = chi2_pol; - bestposition1 = ibin; - bestposition2 = lbin; - parf[0]=polfunc->GetParameter(0); - parf[1]=polfunc->GetParameter(1); - parf[2]=polfunc->GetParameter(2); - parf[3]=polfunc->GetParameter(3); - double polinomial=parf[0] - +xbin1*parf[1] - +xbin1*xbin1*parf[2] - +xbin1*xbin1*xbin1*parf[3]; - double c=idh1->GetBinContent(ibin); - besteff1=c/polinomial; - polinomial=parf[0] - +xbin2*parf[1] - +xbin2*xbin2*parf[2] - +xbin2*xbin2*xbin2*parf[3]; - c=idh1->GetBinContent(lbin); - besteff2=c/polinomial; - for(int i=0;i<4;i++){polyparf[i]=parf[i];} - } - idh1->SetBinError(lbin,olderr2); - } - if(bestchi2<50.){ - nholes=2; - holes[0]=bestposition1; - eff_hole[0]=besteff1; - holes[1]=bestposition2; - eff_hole[1]=besteff2; - } - idh1->SetBinError(ibin,olderr1); - } - } //if(average>100.&&chi2poly>50.) - - - - // ================== end refine strategy average > 100 if chi2>50 - // - // INSERT HERE NEW PATCH FOR THREE TUBES IN SEQUENCE !!!! - // - // if still bad try removing three bins ... - if(average_entry>100.&& bestchi2>50.){ - //================================================== - nholes=0; - int bestposition1 = 0; - double besteff1 = 1.; - int bestposition2 = 0; - double besteff2 = 1.; - int bestposition3 = 0; - double besteff3 = 1.; - for(int j=0;j<10;j++){holes[j]=0;} - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - chi2poly = polfunc->GetChisquare(); - bestchi2 = chi2poly; - double initial_pol_chi2= chi2poly; - double olderr1(0.0); - double olderr2(0.0); - double olderr3(0.0); - for(int ibin=firsttube;ibin<lasttube-3;ibin++){ - double xbin1=double(ibin); - olderr1 = idh1->GetBinError(ibin); - double xbin2=double(ibin+1); - olderr2 = idh1->GetBinError(ibin+1); - double xbin3=double(ibin+2); - olderr3 = idh1->GetBinError(ibin+2); - idh1->SetBinError(ibin,0.); - idh1->SetBinError(ibin+1,0.); - idh1->SetBinError(ibin+2,0.); - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - chi2_pol = polfunc->GetChisquare(); - if(bestchi2>chi2_pol){ - bestchi2 = chi2_pol; - bestposition1 = ibin; - bestposition2 = ibin+1; - bestposition3 = ibin+2; - parf[0]=polfunc->GetParameter(0); - parf[1]=polfunc->GetParameter(1); - parf[2]=polfunc->GetParameter(2); - parf[3]=polfunc->GetParameter(3); - - double polinomial=parf[0] - +xbin1*parf[1] - +xbin1*xbin1*parf[2] - +xbin1*xbin1*xbin1*parf[3]; - double c=idh1->GetBinContent(ibin); - besteff1=c/polinomial; - polinomial=parf[0] - +xbin2*parf[1] - +xbin2*xbin2*parf[2] - +xbin2*xbin2*xbin2*parf[3]; - c=idh1->GetBinContent(ibin+1); - besteff2=c/polinomial; - c=idh1->GetBinContent(ibin); - besteff1=c/polinomial; - polinomial=parf[0] - +xbin3*parf[1] - +xbin3*xbin3*parf[2] - +xbin3*xbin3*xbin3*parf[3]; - c=idh1->GetBinContent(ibin+2); - besteff3=c/polinomial; - for(int i=0;i<4;i++){polyparf[i]=parf[i];} - } - if(bestchi2<50.){ - if(besteff1<0.2&&besteff2<0.2&&besteff3<0.2){ - nholes=3; - holes[0]=bestposition1; - eff_hole[0]=besteff1; - holes[1]=bestposition2; - eff_hole[1]=besteff2; - holes[2]=bestposition3; - eff_hole[2]=besteff3; - } - } - idh1->SetBinError(ibin,olderr1); - idh1->SetBinError(ibin+1,olderr2); - idh1->SetBinError(ibin+2,olderr3); - } //for (int ibin - //================================================== - double gain = bestchi2/initial_pol_chi2; - if(gain<0.3) { - int ibin1=bestposition1; - idh1->SetBinError(ibin1,0.); - idh1->SetBinError(ibin1+1,0.); - idh1->SetBinError(ibin1+2,0.); - - for(int ibin=firsttube;ibin<lasttube;ibin++){ - if(ibin<ibin1||ibin>ibin1+2){ - idh1->Fit(polfunc,"Q","",(double)firsttube,(double)lasttube); - chi2_pol = polfunc->GetChisquare(); - if(bestchi2>chi2_pol){ - bestchi2 = chi2_pol; - parf[0]=polfunc->GetParameter(0); - parf[1]=polfunc->GetParameter(1); - parf[2]=polfunc->GetParameter(2); - parf[3]=polfunc->GetParameter(3); - double xbin1=double(ibin); - double polinomial=parf[0] - +xbin1*parf[1] - +xbin1*xbin1*parf[2] - +xbin1*xbin1*xbin1*parf[3]; - double c=idh1->GetBinContent(ibin); - besteff1=c/polinomial; - - for(int i=0;i<4;i++){polyparf[i]=parf[i];} - } - idh1->SetBinError(ibin,olderr1); - idh1->SetBinError(ibin+1,olderr2); - idh1->SetBinError(ibin+2,olderr3); - }//if(ibin<ibin1 ... - } //for (int ibin - - } - } //if(average>100.&&chi2poly>50.) - - - - // ================== end refine strategy average > 100 if chi2>50 for 3 tubes in sequence - - - // ================== start strategy average < 100 - - if(average_entry<100.){ - nholes=0; - for(int j=0;j<10;j++){holes[j]=0;} - better_average=0.; - better_entry =0.; - for(int nb=firsttube;nb<=lasttube;nb++){ - double c=idh1->GetBinContent(nb); - double cerr=idh1->GetBinError(nb); - /* - tag 'holes' candidates using criterium c deviates from average by more than 4stat-errors - remember not to use bins of dead mezzanines tagged using SetBinError(nb,0.) in deadMezz - */ - if((average_entry-c)>3.5*std::sqrt(average_entry)&&n_entry>double(ntubes)-3.){ - position_holes[nb]=1; - if(nholes<10){ - // this is one dead tube candidate! - // remember eff_hole, to cut on it - nholes++; - holes[nholes-1]=nb; - eff_hole[nholes-1]=c/average_entry; - } - }else { - if(cerr>0.){ - better_average=better_average+c; - better_entry++; - } - } - } // for int=nb.. - if(better_entry>0.) better_average = better_average/better_entry; - polyparf[0]=better_average; - for(int i=1;i<4;i++){polyparf[i]=0.;} - } // else if average_entry<100. - - // ================== end strategy average < 100 - average_entry=better_average; -} // getHolesInInterval - - // ============================================================================== - // - // MDTDeadElementsAnalysis::getAverageInInterval - // - // ============================================================================== - -void MDTDeadElementsAnalysis::getAverageLevelInInterval(TH1F* idh1, int firsttube, int lasttube){ - average_entry=0.; - n_entry=0.; - for(int nb=firsttube;nb<=lasttube;nb++){ - average_entry=average_entry+idh1->GetBinContent(nb); - n_entry++; - } - average_entry=average_entry/n_entry; -} -// ============================================================================== -// -// MDTDeadElementsAnalysis::getSpikesInInterval -// -// ============================================================================== - -void MDTDeadElementsAnalysis::getSpikesInInterval(TH1F* idh1, int firsttube, int lasttube, TF1 * /*polfunc*/){ - - average_entry=0.; - n_entry=0.; - for(int nb=firsttube;nb<=lasttube;nb++){ - average_entry=average_entry+idh1->GetBinContent(nb); - n_entry++; - } - - average_entry=average_entry/n_entry; - // look for max entries - - // int position_spikes[1000]; - for(int index=0; index<ntmax; index++){position_spikes[index]=0;} - double old_average=average_entry; - - while(1) { - // remove bins 'well' above average until average gets stable - // if a bin has been removed already position_spikes[nb]=1 - double largest_num_entries=0.; - int pos_largest_num_entries=0; - for(int nb=firsttube;nb<=lasttube;nb++){ - double c=idh1->GetBinContent(nb); - if(c>largest_num_entries&&position_spikes[nb]!=1){ - largest_num_entries=c; - pos_largest_num_entries=nb; - } - } - // check average when bin with max entries is removed! - // if largest bin accounts for more than 80% of total -> spike - - if(largest_num_entries>1.5*average_entry) { - position_spikes[pos_largest_num_entries]=1; - average_entry=(average_entry*n_entry-largest_num_entries)/(n_entry-1.); - n_entry--; - // if error of one bin is put to zero-> bin not used in the fit - idh1->SetBinError(pos_largest_num_entries,0.); - } - double ratio=99999.; - if(old_average>0.) ratio=average_entry/old_average; - if( ratio>0.8 || n_entry<=6 ) break; - - old_average=average_entry; - - }//end while -} - -// ============================================================================== -// -// Polnml3 -// -// ============================================================================== -Double_t polnml3(Double_t * x, Double_t * parf) { - - Double_t poly=parf[0] - +x[0]*parf[1] - +x[0]*x[0]*parf[2] - +x[0]*x[0]*x[0]*parf[3]; - - return poly; -}//polnml3 - -// ============================================================================== -// -// completefunc -// -// ============================================================================== - -double completefunc(double * x, double * parf) { - - double poly=parf[0] - +x[0]*parf[1] - +x[0]*x[0]*parf[2] - +x[0]*x[0]*x[0]*parf[3]; - - double eff=1.; - int tubefit = (int) parf[4]; - double par4=tubefit; - if(x[0]>par4-0.5 && x[0]<par4+std::abs(parf[5])-0.5) { - eff=parf[6]; - } - double value=poly*eff; - - return value; -}//completefunc - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadMezzanines -// -// ============================================================================== - -void MDTDeadElementsAnalysis::deadMezzanines(TH1F* idh, TH1F* HRef, TH1F* deadTubesMap, std::string chambname){ - - TH1F * idh1 = (TH1F*)idh->Clone(); - - MDTDeadElementsAnalysis::deadMezzDone=true; - - int Entries=0; - int nbins=idh1->GetNbinsX(); - for(int bin=1;bin<=nbins;bin++){ - Entries = Entries + (int) idh1->GetBinContent(bin); - } - - std::ostringstream deadAna; - double cmax = -1.; - int pos_maximum = -1; - for(int ib=1; ib<=nbins; ib++){ - double cont=idh1->GetBinContent(ib); - if(cont>cmax) { - cmax=cont; - pos_maximum = ib; - } - } - - if(Entries-cmax>1000) { - TH1F * hmezz = new TH1F("hmezz","hmezz", - nbins_per_layer[0]+nbins_per_layer[1],0.5, - nbins_per_layer[0]+nbins_per_layer[1]+0.5); - TH1F * hmezzRef = new TH1F("hmezzRef","hmezzRef", - nbins_per_layer[0]+nbins_per_layer[1],0.5, - nbins_per_layer[0]+nbins_per_layer[1]+0.5); - hmezz->SetTitle(chambname.c_str()); - hmezzRef->SetTitle(chambname.c_str()); - for(int MultiLayer=0;MultiLayer<2;MultiLayer++){ - if (nbins_per_layer[MultiLayer]==0) continue; - int ibstart = (MultiLayer)*nbins_per_layer[0]*nlayers_per_ml+1; - int ibend = (MultiLayer)*nbins_per_layer[0]*nlayers_per_ml - +nbins_per_layer[MultiLayer]*nlayers_per_ml; - for(int ib=ibstart; ib<=ibend; ib++){ - int nlay = (ib-firstbinML[MultiLayer])/nbins_per_layer[MultiLayer]+1; - int ML=MultiLayer+1; - int tube_in_layer=ib-(nlay-1)*nbins_per_layer[MultiLayer]-firstbinML[MultiLayer]; - if(nlay>nlayers_per_ml) nlay=nlay-nlayers_per_ml; - double cont=idh1->GetBinContent(ib); - double contRef=HRef->GetBinContent(ib); - hmezz->Fill(tube_in_layer+(ML-1)*nbins_per_layer[MultiLayer]+1,cont); - hmezzRef->Fill(tube_in_layer+(ML-1)*nbins_per_layer[MultiLayer]+1,contRef); - } - } - // treat correctly zeros & compute average - // remember bins with zero entries (I should rather say zero error!) are NOT included in a chi2 fit - // thus to take them into account you need to give them a non zero error - - average_entry=0.; - n_entry=0.; - for (int nb=1;nb<=nbins_per_layer[0]*2;nb++){ - average_entry=average_entry+hmezz->GetBinContent(nb); - n_entry++; - double contRef=std::abs(hmezzRef->GetBinContent(nb)); - if (hmezz->GetBinContent(nb)==0.&&contRef!=nlayers_per_ml&&contRef!=0.) { - hmezz->SetBinError(nb,2.3); - } - } - average_entry=average_entry/n_entry; - // look for max entries - - for(int index=0; index<ntmax; index++){position_spikes[index]=0;} - double old_average=average_entry; - - while(1) { - // remove bins 'well' above average until average gets stable - // if a bin has been removed already position_spikes[nb]=1 - double largest_num_entries=0.; - int pos_largest_num_entries=0; - for (int nb=1;nb<=nbins_per_layer[0]*2;nb++){ - double c=hmezz->GetBinContent(nb); - if (c>largest_num_entries&&position_spikes[nb]!=1){ - largest_num_entries=c; - pos_largest_num_entries=nb; - } - } - // check average when bin with max entries is removed! - // if largest bin accounts for more than 80% of total -> spike - - if(largest_num_entries>1.5*average_entry) { - position_spikes[pos_largest_num_entries]=1; - average_entry=(average_entry*n_entry-largest_num_entries)/(n_entry-1.); - n_entry--; - // if error of one bin is put to zero-> bin not used in the fit - hmezz->SetBinError(pos_largest_num_entries,0.); - } - double ratio=99999.; - if(old_average>0.) ratio=average_entry/old_average; - if( ratio>0.8 || n_entry<=6 ) break; - - old_average=average_entry; - - }//end while - - double chi2cut=30.; - if(Entries>50000.) chi2cut=60.; - TF1 *fitfunc = new TF1("fit1",completefunc,1.,(double)2.*ntubes[0],7); - polfunc = new TF1("fit0",polnml3,1.,(double)2.*ntubes[0],4); - fitfunc->SetParameters(-51.,180.,-10.,0.,9.,1.,0.5); - for(int ml=1;ml<=2;ml++){ - if (nbins_per_layer[ml-1]==0) continue; - double fit_start=1.+(ml-1)*nbins_per_layer[1]; - double fit_end=nbins_per_layer[0]+(ml-1)*nbins_per_layer[1]; - if(verbose){ - hmezz->Fit(polfunc,"","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit(polfunc,"Q","",(double)fit_start,(double)fit_end); - } - hmezz->SetMinimum(0.); - hmezz->SetMaximum(500.); - double chi2 = polfunc->GetChisquare(); - double ndf= nbins_per_layer[0]-4; - if(chi2/ndf > 10 ) { - hmezz->SetBinError(pos_maximum,0.); - if(verbose) { - hmezz->Fit(polfunc,"","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit(polfunc,"Q","",(double)fit_start,(double)fit_end); - } - - double olderr[8]; - for(int ii=0; ii<8; ii++) olderr[ii] = 0.; - for (int imezz=1+(ml-1)*nmezz[1];imezz<=nmezz[0]+(ml-1)*nmezz[1];imezz++){ - for (int ic=(imezz-1)*ntubes_per_mezz+1+(ml-1)*nbins_per_layer[1]; - ic<=(imezz)*ntubes_per_mezz+(ml-1)*nbins_per_layer[1];ic++){ - int index = (ic-1)%8; - olderr[index]=hmezz->GetBinError(ic); - hmezz->SetBinError(ic,0.); - } - hmezz->Fit(polfunc,"Q","",(double)fit_start,(double)fit_end); - if(verbose){ - if (drawPlots) { - TCanvas *c1 = new TCanvas(); - hmezz->Draw(); - c1->WaitPrimitive(); - int inutile; - std::cin>>inutile; - } - } - // chi2 = poly->GetChisquare(); - chi2 = polfunc->GetChisquare(); - fitfunc->SetParameter(0,polfunc->GetParameter(0)); - fitfunc->SetParameter(1,polfunc->GetParameter(1)); - fitfunc->SetParameter(2,polfunc->GetParameter(2)); - fitfunc->SetParameter(3,polfunc->GetParameter(3)); - fitfunc->FixParameter(4,(imezz-1)*ntubes_per_mezz+1.); - fitfunc->FixParameter(5,ntubes_per_mezz); - fitfunc->SetParameter(6,.1); - fitfunc->SetParLimits(6,-2.,2.); - - for(int ic=(imezz-1)*ntubes_per_mezz+1+(ml-1)*nbins_per_layer[0] - ;ic<=(imezz)*ntubes_per_mezz+(ml-1)*nbins_per_layer[0];ic++){ - int index = (ic-1)%8; - hmezz->SetBinError(ic,olderr[index]); - } - - if(!verbose){ - hmezz->Fit("fit1","BQ","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit("fit1","B","",(double)fit_start,(double)fit_end); - if (drawPlots) { - TCanvas *c1 = new TCanvas(); - hmezz->Draw(); - c1->WaitPrimitive(); - int inutile; - std::cin>>inutile; - } - } - double chi2 = fitfunc->GetChisquare(); - double efficiency = fitfunc->GetParameter(6); - double err_efficiency = fitfunc->GetParError(6); - if(err_efficiency>0.05) { - if(verbose){ - hmezz->Fit("fit1","BEL","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit("fit1","BQEL","",(double)fit_start,(double)fit_end); - } - efficiency = fitfunc->GetParameter(6); - err_efficiency = fitfunc->GetParError(6); - } - if(chi2/ndf<chi2cut&&(1.-efficiency)/err_efficiency>7&&efficiency<0.3){ - - - deadMezz.push_back(imezz); - int imezz_red=imezz%(nmezz[ml-1]+1); - deadMezz_red.push_back(imezz_red); - deadMezzChamber.push_back(chambname); - deadMezzML.push_back(ml); - deadMezzEffi.push_back(efficiency); - deadMezzErrEffi.push_back(err_efficiency); - deadMezzChi2.push_back(chi2); - deadMezz_csm.push_back(-1); - int layer_start=(ml-1)*nlayers_per_ml+1; - int layer_end=nlayers_per_ml*ml; - for(int l=layer_start;l<=layer_end;l++){ - int tube_start=1+(imezz-1)*ntubes_per_mezz+(l-1)*nbins_per_layer[0]; - int tube_end=tube_start+ntubes_per_mezz-1; - for(int t=tube_start;t<=tube_end;t++){ - Double_t cgeo = HRef->GetBinContent(t); - Double_t signML = cgeo/std::abs(cgeo); - int igeo = (int) cgeo; - Int_t refquantity = igeo%10; - if(std::abs(cgeo)!=0. && refquantity==0){ - idh1->SetBinError(t,0.); - - deadTubesMap->Fill(t,3.*signML); - } - } - } - } - } // for mezz - } // if(chi2) - } // for ml - hmezz->Delete(); - hmezzRef->Delete(); - } // if(Entries.. - - delete idh1; - - return; - -}//deadMezzanines - - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadMezzanines -// -// ============================================================================== - -void MDTDeadElementsAnalysis::deadMezzanines(TH1F* idh, TH1F* HRef, TH1F* deadTubesMap, - std::string chambname, int /*convert_mezzanine*/[20]){ - - TH1F * idh1 = (TH1F*)idh->Clone(); - - MDTDeadElementsAnalysis::deadMezzDone=true; - - int Entries=0; - int nbins=idh1->GetNbinsX(); - for(int bin=1;bin<=nbins;bin++){ - Entries = Entries + (int) idh1->GetBinContent(bin); - } - - std::ostringstream deadAna; - double cmax = -1.; - int pos_maximum = -1; - for(int ib=1; ib<=nbins; ib++){ - double cont=idh1->GetBinContent(ib); - if(cont>cmax) { - cmax=cont; - pos_maximum = ib; - } - } - - if(Entries-cmax>1000) { - TH1F * hmezz = new TH1F("hmezz","hmezz", - nbins_per_layer[0]+nbins_per_layer[1],0.5, - nbins_per_layer[0]+nbins_per_layer[1]+0.5); - TH1F * hmezzRef = new TH1F("hmezzRef","hmezzRef", - nbins_per_layer[0]+nbins_per_layer[1],0.5, - nbins_per_layer[0]+nbins_per_layer[1]+0.5); - hmezz->SetTitle(chambname.c_str()); - hmezzRef->SetTitle(chambname.c_str()); - for(int MultiLayer=0;MultiLayer<2;MultiLayer++){ - if (nbins_per_layer[MultiLayer]==0) continue; - int ibstart = (MultiLayer)*nbins_per_layer[0]*nlayers_per_ml+1; - int ibend = (MultiLayer)*nbins_per_layer[0]*nlayers_per_ml - +nbins_per_layer[MultiLayer]*nlayers_per_ml; - for(int ib=ibstart; ib<=ibend; ib++){ - int nlay = (ib-firstbinML[MultiLayer])/nbins_per_layer[MultiLayer]+1; - int ML=MultiLayer+1; - int tube_in_layer=ib-(nlay-1)*nbins_per_layer[MultiLayer]-firstbinML[MultiLayer]; - if(nlay>nlayers_per_ml) nlay=nlay-nlayers_per_ml; - double cont=idh1->GetBinContent(ib); - double contRef=HRef->GetBinContent(ib); - hmezz->Fill(tube_in_layer+(ML-1)*nbins_per_layer[MultiLayer]+1,cont); - hmezzRef->Fill(tube_in_layer+(ML-1)*nbins_per_layer[MultiLayer]+1,contRef); - } - } - // treat correctly zeros & compute average - // remember bins with zero entries (I should rather say zero error!) are NOT included in a chi2 fit - // thus to take them into account you need to give them a non zero error - - average_entry=0.; - n_entry=0.; - for (int nb=1;nb<=nbins_per_layer[0]*2;nb++){ - average_entry=average_entry+hmezz->GetBinContent(nb); - n_entry++; - double contRef=std::abs(hmezzRef->GetBinContent(nb)); - if (hmezz->GetBinContent(nb)==0.&&contRef!=nlayers_per_ml&&contRef!=0.) { - hmezz->SetBinError(nb,2.3); - } - } - average_entry=average_entry/n_entry; - // look for max entries - - for(int index=0; index<ntmax; index++){position_spikes[index]=0;} - double old_average=average_entry; - - while(1) { - // remove bins 'well' above average until average gets stable - // if a bin has been removed already position_spikes[nb]=1 - double largest_num_entries=0.; - int pos_largest_num_entries=0; - for (int nb=1;nb<=nbins_per_layer[0]*2;nb++){ - double c=hmezz->GetBinContent(nb); - if (c>largest_num_entries&&position_spikes[nb]!=1){ - largest_num_entries=c; - pos_largest_num_entries=nb; - } - } - // check average when bin with max entries is removed! - // if largest bin accounts for more than 80% of total -> spike - - if(largest_num_entries>1.5*average_entry) { - position_spikes[pos_largest_num_entries]=1; - average_entry=(average_entry*n_entry-largest_num_entries)/(n_entry-1.); - n_entry--; - // if error of one bin is put to zero-> bin not used in the fit - hmezz->SetBinError(pos_largest_num_entries,0.); - } - double ratio=99999.; - if(old_average>0.) ratio=average_entry/old_average; - if( ratio>0.8 || n_entry<=6 ) break; - - old_average=average_entry; - - }//end while - double chi2cut=30.; - if(Entries>50000.) chi2cut=60.; - - polfunc = new TF1("fit0",polnml3,1.,(double)2.*ntubes[0],4); - TF1 *fitfunc = new TF1("fit1",completefunc,1.,(double)2.*ntubes[0],7); - fitfunc->SetParameters(-51.,180.,-10.,0.,9.,1.,0.5); - for(int ml=1;ml<=2;ml++){ - if (nbins_per_layer[ml-1]==0) continue; - double fit_start=1.+(ml-1)*nbins_per_layer[1]; - double fit_end=nbins_per_layer[0]+(ml-1)*nbins_per_layer[1]; - if(verbose){ - hmezz->Fit(polfunc,"","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit(polfunc,"Q","",(double)fit_start,(double)fit_end); - } - hmezz->SetMinimum(0.); - hmezz->SetMaximum(500.); - double chi2 = polfunc->GetChisquare(); - double ndf= nbins_per_layer[0]-4; - if(chi2/ndf > 10 ) { - hmezz->SetBinError(pos_maximum,0.); - if(verbose) { - hmezz->Fit(polfunc,"","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit(polfunc,"Q","",(double)fit_start,(double)fit_end); - } - - double olderr[8]; - for(int ii=0; ii<8; ii++) olderr[ii] = 0.; - for (int imezz=1+(ml-1)*nmezz[1];imezz<=nmezz[0]+(ml-1)*nmezz[1];imezz++){ - for (int ic=(imezz-1)*ntubes_per_mezz+1+(ml-1)*nbins_per_layer[1]; - ic<=(imezz)*ntubes_per_mezz+(ml-1)*nbins_per_layer[1];ic++){ - int index = (ic-1)%8; - olderr[index]=hmezz->GetBinError(ic); - hmezz->SetBinError(ic,0.); - } - hmezz->Fit(polfunc,"Q","",(double)fit_start,(double)fit_end); - if(verbose){ - if (drawPlots) { - TCanvas *c1 = new TCanvas(); - hmezz->Draw(); - c1->WaitPrimitive(); - } - } - chi2 = polfunc->GetChisquare(); - fitfunc->SetParameter(0,polfunc->GetParameter(0)); - fitfunc->SetParameter(1,polfunc->GetParameter(1)); - fitfunc->SetParameter(2,polfunc->GetParameter(2)); - fitfunc->SetParameter(3,polfunc->GetParameter(3)); - fitfunc->FixParameter(4,(imezz-1)*ntubes_per_mezz+1.); - fitfunc->FixParameter(5,ntubes_per_mezz); - fitfunc->SetParameter(6,.1); - fitfunc->SetParLimits(6,-2.,2.); - - for(int ic=(imezz-1)*ntubes_per_mezz+1+(ml-1)*nbins_per_layer[0] - ;ic<=(imezz)*ntubes_per_mezz+(ml-1)*nbins_per_layer[0];ic++){ - int index = (ic-1)%8; - hmezz->SetBinError(ic,olderr[index]); - } - - if(!verbose){ - hmezz->Fit("fit1","BQ","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit("fit1","B","",(double)fit_start,(double)fit_end); - if (drawPlots) { - TCanvas *c1 = new TCanvas(); - hmezz->Draw(); - c1->WaitPrimitive(); - } - } - double chi2 = fitfunc->GetChisquare(); - double efficiency = fitfunc->GetParameter(6); - double err_efficiency = fitfunc->GetParError(6); - if(err_efficiency>0.05) { - if(verbose){ - hmezz->Fit("fit1","BEL","",(double)fit_start,(double)fit_end); - } else { - hmezz->Fit("fit1","BQEL","",(double)fit_start,(double)fit_end); - } - efficiency = fitfunc->GetParameter(6); - err_efficiency = fitfunc->GetParError(6); - } - if(chi2/ndf<chi2cut&&(1.-efficiency)/err_efficiency>7&&efficiency<0.3){ - - - deadMezz.push_back(imezz); - int imezz_red=imezz%(nmezz[ml-1]+1); - deadMezz_red.push_back(imezz_red); - deadMezzChamber.push_back(chambname); - deadMezzML.push_back(ml); - deadMezzEffi.push_back(efficiency); - deadMezzErrEffi.push_back(err_efficiency); - deadMezzChi2.push_back(chi2); - deadMezz_csm.push_back(-1); - int layer_start=(ml-1)*nlayers_per_ml+1; - int layer_end=nlayers_per_ml*ml; - for(int l=layer_start;l<=layer_end;l++){ - int tube_start=1+(imezz-1)*ntubes_per_mezz+(l-1)*nbins_per_layer[0]; - int tube_end=tube_start+ntubes_per_mezz-1; - for(int t=tube_start;t<=tube_end;t++){ - Double_t cgeo = HRef->GetBinContent(t); - Double_t signML = cgeo/std::abs(cgeo); - int igeo = (int) cgeo; - Int_t refquantity = igeo%10; - if(std::abs(cgeo)!=0. && refquantity==0){ - idh1->SetBinError(t,0.); - - deadTubesMap->Fill(t,3.*signML); - } - } - } - } - } // for mezz - } // if(chi2) - } // for ml - hmezz->Delete(); - hmezzRef->Delete(); - } // if(Entries.. - - delete idh1; - - return; - -}//deadMezzanines - -// ============================================================================== -// -// MDTDeadElementsAnalysis::deadMultilayers -// -// ============================================================================== - -void MDTDeadElementsAnalysis::deadMultilayers(TH1F *idh1, TH1F *HRef, TH1F *deadTubesMap, std::string chambname){ - - MDTDeadElementsAnalysis::deadMultilayerDone=true; - std::ostringstream deadAna; - int nbins=idh1->GetNbinsX(); - - int nML = 2; - if ( nbins_per_layer[1]==0 ) nML=1; - int binsML1 = nbins/nML; - int binsML2 = binsML1; - if ( nML==1 ) { - deadAna << "DeadMultilayers Analysis SKIPPED since chamber "<<chambname<<" has 1 ML only "<<std::endl; - return ; - } - - polfunc = new TF1("fit0",polnml3,1.,(double)2.*ntubes[0],4); - getSpikesInInterval(idh1,1,binsML1,polfunc); - float isolatedCountsML1 = 0.; - float nonisolatedCountsML1 = 0.; - float averageLevelML1 = average_entry; - for(int j=2;j<binsML1;j++){ - if(position_spikes[j]!=1) { - if(idh1->GetBinContent(j-1)==0&&idh1->GetBinContent(j+1)==0)isolatedCountsML1++; - if(idh1->GetBinContent(j-1)>0&&idh1->GetBinContent(j+1)>0)nonisolatedCountsML1++; - } - } - - getSpikesInInterval(idh1,binsML1+1,binsML1+binsML2,polfunc); - float isolatedCountsML2 = 0.; - float nonisolatedCountsML2 = 0.; - float averageLevelML2 = average_entry; - for(int j=binsML1+2;j<binsML1+binsML2;j++){ - if(position_spikes[j]!=1) { - if(idh1->GetBinContent(j-1)==0&&idh1->GetBinContent(j+1)==0)isolatedCountsML2++; - if(idh1->GetBinContent(j-1)>0&&idh1->GetBinContent(j+1)>0)nonisolatedCountsML2++; - } - } - // ML1 - - if(float(nonisolatedCountsML1)/float(binsML1)<.2|| - std::abs(averageLevelML1/averageLevelML2)<0.1) { - deadAna <<" dead MultiLayer 1 found in chamber "<<chambname<<std::endl; - deadMultilayer.push_back(1); - deadMLChamber.push_back(chambname); - deadMLCounts.push_back(nonisolatedCountsML1); - deadMLLevel.push_back(averageLevelML1); - for(int j=1;j<=binsML1;j++){ - Double_t cgeo = HRef->GetBinContent(j); - Double_t signML = cgeo/std::abs(cgeo); - int igeo = (int) cgeo; - Int_t refquantity = igeo%10; - if(std::abs(cgeo)!=0.&& refquantity==0){ - deadTubesMap->Fill(j,5.*signML); - } - } - - } else { - deadAna << " MultiLayer 1 in chamber is alive"<<std::endl; - } - // ML2 - - if(float(nonisolatedCountsML2)/float(binsML2)<.2|| - std::abs(averageLevelML2/averageLevelML1)<0.1) { - deadAna <<" dead MultiLayer 2 found in chamber "<<chambname<<std::endl; - deadMultilayer.push_back(2); - deadMLChamber.push_back(chambname); - deadMLCounts.push_back(nonisolatedCountsML2); - deadMLLevel.push_back(averageLevelML2); - for(int j=binsML1+1;j<=binsML1+binsML2;j++){ - Double_t cgeo = HRef->GetBinContent(j); - Double_t signML = cgeo/std::abs(cgeo); - int igeo = (int) cgeo; - Int_t refquantity = igeo%10; - if(std::abs(cgeo)!=0.&& refquantity==0){ - deadTubesMap->Fill(j,5.*signML); - } - } - } else { - deadAna << " MultiLayer 2 in chamber is alive"<<std::endl; - } - return; -}//deadMultilayers diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTDqaDeadElements.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTDqaDeadElements.cxx deleted file mode 100644 index 4f196f0cc8f9d65378a64ca7f51361e0c43fa250..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTDqaDeadElements.cxx +++ /dev/null @@ -1,1646 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//Author Marco Vanadia vanadiam@roma1.infn.it -//Class based on algorithms introduced by Philipp Fleischmann in GnaMon - -//Be careful that in order to preserve a chamber-like structure, the first tube in a layer is tube #1 -//the first layer in a ML is layer#1, the first ML in a chamber is ML #1, but the first mezzanine in a -//ML is mezzanine #0. So to get the first tube in a layer you've got to use the method Layer::getTube(1), -//to get the first Mezzanine in a ML you've got to use the method Multilayer::getMezzanine(0); -//further more, loops involving tubes, layers and multilayer must have ending conditions like -// i<=Ntubes, while loops involving Mezzanines must have ending conditions like i<Nmezzanines - -//In chambers with ML1 shorter than ML2, -//empty spaces are treated just like tubes, but a special status value NOTUBE is assigned to them, -//and they are ignored in the rest of the analysis. In this way the real tubes are assigned to the -//right positions in the layer. -//So the method Layer::getNtubes() returns the number of both real and fake tubes, that is the right number -//to use in loops; if you want the number of REAL tubes in layer, use Layer::getNrealtubes(); - -//#include "./MDTDqaDeadElements.h" -#include "MuonCalibStandAloneExtraTools/MDTDqaDeadElements.h" - -#define NOTUBE 0 //Used for chambers with ML1 smaller than ML2 -#define DEADCHAMBER 1 -#define LOWSTATISTICSCHAMBER 7 -#define DEADML 2 -#define INEFFICIENTML 2 -#define DEADLAYER 3 -#define NOISYLAYER 8 -#define INEFFICIENTLAYER 3 -#define DEADMEZZANINE 4 -#define NOISYMEZZANINE 8 -#define LOWSTATMEZZANINE 7 -#define INEFFICIENTMEZZANINE 10 -#define DEADTUBE 5 -#define NOISYTUBE 8 - -namespace MuonCalib { - -/////////////////////////////////////////////////////////////////////////////////////////////////////// - //methods of class Tube - - Tube::Tube(int the_status, int the_position, Layer *the_layer) { - m_status=the_status; - m_position=the_position; - m_value=-999; //Arbitrary, it makes easier to find tubes which were not filled - m_parent_layer=the_layer; - m_layer=-1; - m_ml=-1; - } - - int Tube::getStatus() { - return m_status; - } - int Tube::getValue() { - return m_value; - } - int Tube::getPosition() { - return m_position; - } - int Tube::getLayer() { - return m_layer; - } - int Tube::getML() { - return m_ml; - } - void Tube::setStatus(int the_status) { - m_status=the_status; - } - void Tube::setValue(int the_value) { - m_value=the_value; - } - void Tube::setPosition(int the_position) { - m_position=the_position; - } - Layer* Tube::getParentLayer() { - return m_parent_layer; - } - void Tube::setLayer(int the_layer) { - m_layer=the_layer; - } - void Tube::setML(int the_ml) { - m_ml=the_ml; - } -////////////////////////////////////////////////////////////////////////////////////////////////////// - //methods of class Layer - - Layer::Layer() { - m_ntubes=0; - m_entries=0; - m_status=10; - m_median=-1; - m_median_deviation=-1; - } - - Tube* Layer::addTube(int the_status, int the_position) { - Tube *t = new Tube(the_status, the_position, this); - m_tubes.push_back(t); - m_ntubes++; - return t; - } - - Tube* Layer::getTube(int the_position) { - return m_tubes[the_position-1]; - } - - int Layer::getNtubes() { - return m_ntubes; - } - - double Layer::getEntries() { - return m_entries; - } - - int Layer::getStatus() { - return m_status; - } - - double Layer::getMedian() { - return m_median; - } - - double Layer::getMedianDeviation() { - return m_median_deviation; - } - - void Layer::setStatus(int the_status) { - m_status=the_status; - for(int i=1; i<=getNtubes(); i++) { - Tube *t=getTube(i); - if(t->getStatus()==0) continue; - t->setStatus(the_status); - } - } - - void Layer::addEntries(double the_entries) { - m_entries+=the_entries; - } - - void Layer::calculateStatistics() { - //calculateStatistics only calculate median and median deviation of the object, not of its sub-objects - //to calculate these values for the whole chamber and its sub-parts, use the method MDTChamber::updateStatistics() - - std::vector<double> values; - - for(int k=1; k<=this->getNtubes(); k++) { - Tube *t= getTube(k); - if((t->getStatus())!=10) continue; - values.push_back(t->getValue()); - - } - //Calculate median - int size=values.size(); - if(size==0) return; - sort(values.begin(), values.end()); - if((size%2)==1) m_median=values[(size-1)/2]; - else m_median=(double)(values[size/2]+values[(size/2)-1])/2.; - - //Calculate median absolute deviation - - for(int i=0; i<size; i++) values[i]=std::abs(values[i]-m_median); - - sort(values.begin(), values.end()); - - if((size%2)==1) m_median_deviation=values[(size-1)/2]; - else m_median_deviation=(double)(values[size/2]+values[(size/2)-1])/2.; - - return; - } - - int Layer::getNrealtubes() { - int ntubes=0; - for(int i=1; i<=getNtubes(); i++) { - Tube *t=getTube(i); - if(t->getStatus()==0) continue; - ntubes++; - } - return ntubes; - } - -////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //methods of class Mezzanine - - Mezzanine::Mezzanine() { - m_entries=0; - m_ntubes=0; - m_status=10; - m_median=-1; - m_median_deviation=-1; - m_70min=-999; - m_70max=-999; - } - void Mezzanine::addTube(Tube *t) { - m_tubes.push_back(t); - m_ntubes++; - } - Tube* Mezzanine::getTube(int the_position) { - return m_tubes[the_position-1]; - } - - int Mezzanine::getNtubes() { - return m_ntubes; - } - int Mezzanine::get70min() { - return m_70min; - } - int Mezzanine::get70max() { - return m_70max; - } - - double Mezzanine::getEntries() { - return m_entries; - } - - int Mezzanine::getStatus() { - return m_status; - } - - double Mezzanine::getMedian() { - return m_median; - } - - double Mezzanine::getMedianDeviation() { - return m_median_deviation; - } - - void Mezzanine::addEntries(double the_entries) { - m_entries+=the_entries; - } - - void Mezzanine::setStatus(int the_status) { - m_status=the_status; - for(int i=1; i<=getNtubes(); i++) { - Tube *t=getTube(i); - if(t->getStatus()==0) continue; - t->setStatus(the_status); - } - } - - void Mezzanine::calculateStatistics() { - //calculateStatistics only calculate median and median deviation of the object, not of its sub-objects - //to calculate these values for the whole chamber and its sub-parts, use the method MDTChamber::updateStatistics() - - //Here we must also compute the entries in mezzanine, because of the way we built it - - std::vector<double> values; - for(int k=1; k<=this->getNtubes(); k++) { - Tube *t= getTube(k); - if((t->getStatus())==0) continue; //Double check just not to lose entries; - this->addEntries(t->getValue()); - if((t->getStatus())!=10) continue; - values.push_back(t->getValue()); - } - //Calculate median - - int size=values.size(); - if(size==0) return; - sort(values.begin(), values.end()); - - m_70min=(int)values[(int)(3.0*(double)size/10.)]; - m_70max=(int)values[(int)(7.0*((double)size/10.))]; - - if((size%2)==1) m_median=values[(size-1)/2]; - else m_median=(double)(values[size/2]+values[(size/2)-1])/2.; - - //Calculate median absolute deviation - - for(int i=0; i<size; i++) values[i]=std::abs(values[i]-m_median); - - sort(values.begin(), values.end()); - - if((size%2)==1) m_median_deviation=values[(size-1)/2]; - else m_median_deviation=(double)(values[size/2]+values[(size/2)-1])/2.; - - return; - } //end Mezzanine::calculateStatistics - - //////////////////////////////////////////////////////////////////////////////////////////////////// - //methods of class Multilayer - - Multilayer::Multilayer() { - m_nlayers=0; - m_entries=0; - m_nmezzanines=0; - m_status=10; - m_median=-1; - m_median_deviation=-1; - } - - void Multilayer::addLayer() { - Layer *l= new Layer(); - m_layers.push_back(l); - m_nlayers++; - } - - Tube* Multilayer::addTube(int the_layer, int the_status, int the_position) { - while(the_layer>getNlayers()) addLayer(); - return (getLayer(the_layer))->addTube(the_status, the_position); - } - Layer* Multilayer::getLayer(int the_position) { - return m_layers[the_position-1]; - } - - Mezzanine* Multilayer::addMezzanine() { - Mezzanine *mezz=new Mezzanine(); - m_mezzanines.push_back(mezz); - m_nmezzanines++; - return mezz; - } - - Mezzanine* Multilayer::getMezzanine(int pos) { - if(pos>=static_cast<int>(m_mezzanines.size())) return NULL; - return m_mezzanines[pos]; - } - - int Multilayer::getNlayers() { - return m_nlayers; - } - int Multilayer::getNmezzanines() { - return m_nmezzanines; - } - double Multilayer::getEntries() { - return m_entries; - } - int Multilayer::getStatus() { - return m_status; - } - double Multilayer::getMedian() { - return m_median; - } - double Multilayer::getMedianDeviation() { - return m_median_deviation; - } - - void Multilayer::setStatus(int the_status) { - m_status=the_status; - for(int i=1; i<=getNlayers(); i++) { - Layer *l=getLayer(i); - l->setStatus(the_status); - } - for(int i=0; i<getNmezzanines(); i++) { - Mezzanine *mezz=getMezzanine(i); - mezz->setStatus(the_status); - } - - } - - void Multilayer::addEntries(double the_entries) { - m_entries+=the_entries; - } - - void Multilayer::calculateStatistics() { - //calculateStatistics only calculate median and median deviation of the object, not of its sub-objects - //to calculate these values for the whole chamber and its sub-parts, use the method MDTChamber::updateStatistics() - - std::vector<double> values; - - for(int j=1; j<=getNlayers(); j++) { - Layer *l=getLayer(j); - for(int k=1; k<=l->getNtubes(); k++) { - Tube *t= l->getTube(k); - if((t->getStatus())!=10) continue; - values.push_back(t->getValue()); - } - } - //Calculate median - - int size=values.size(); - if(size==0) return; - sort(values.begin(), values.end()); - if((size%2)==1) m_median=values[(size-1)/2]; - else m_median=(double)(values[size/2]+values[(size/2)-1])/2.; - - //Calculate median absolute deviation - - for(int i=0; i<size; i++) values[i]=std::abs(values[i]-m_median); - - sort(values.begin(), values.end()); - - if((size%2)==1) m_median_deviation=values[(size-1)/2]; - else m_median_deviation=(double)(values[size/2]+values[(size/2)-1])/2.; - - return; - } //end Multilayer::calculateStatistics - -/////////////////////////////////////////////////////////////////////////////////////////////////////// -//Methods of Class MDTChamber - -//This method reads the reference histograms and builds the chamber with the correct geometry - - MDTChamber::MDTChamber(TH1 *href, TString the_name) : - m_mean(-999.), m_standard_deviation(-999.), m_90min(-1), m_90max(-1), m_70(-1) { - m_nmultilayers=0; - m_entries=0; - m_status=10; - m_name=the_name; - m_median=-1; - m_median_deviation=-1; - - //Now we use a complicated strategy to read the Reference histogram in the correct way; - //the main difficulty is in chambers that have layers smaller than others, so we have to understand - //whether an empty space must be assigned to the end of the previous layer or to the beginning of the - //next one. - //Empty spaces are treated just like tubes, but a special status value NOTUBE is assigned to them, - //and they are ignored in the rest of the analysis. In this way the real tubes are assigned to the - //right positions in the layers. - - int the_multilayer=1; - int the_layer=1; - - int nbins=href->GetNbinsX(); - - int old_layer=the_layer; - bool holesx=false; - int pos=1; - bool newml=true; - bool afterfirstempty=false; - int lastbin=-1; - - for(int bin=1; bin<=nbins; bin++) { - int bincontent=(int)href->GetBinContent(bin); - if((bincontent==0)&&(bin==1)) holesx=true; - if((bincontent!=0)&&(!afterfirstempty))afterfirstempty=true; - if((lastbin!=0)&&(bincontent==0)&&holesx) pos=1; - lastbin=bincontent; - - if(bincontent==0) { - if(holesx==true) { - if(afterfirstempty) { - addTube(the_multilayer,the_layer+1,NOTUBE,pos++); - old_layer=the_layer+1; - } else { - addTube(the_multilayer,the_layer,NOTUBE,pos++); - } - continue; - } else { - addTube(the_multilayer,the_layer, NOTUBE, pos++); - continue; - } - } - if((bincontent>0)&&(newml)) { - the_multilayer=2; - pos=1; - newml=false; - holesx=false; - } - bincontent=std::abs(bincontent); - the_layer=(int)floor(((double)bincontent)/10.); - if(old_layer!=the_layer) { - pos=1; - } - - int the_status; - if((bincontent%10)==0) the_status=10; - else the_status=bincontent%10; - addTube(the_multilayer, the_layer, the_status, pos++); - old_layer=the_layer; - } - //Here we build the mezzanine structure of the chamber - buildMezzanines(); - } - //end MDTChamber::MDTChamber - - void MDTChamber::addMultilayer() { - Multilayer *ml=new Multilayer(); - m_multilayers.push_back(ml); - m_nmultilayers++; - } - Multilayer* MDTChamber::getMultilayer(int the_position) { - return m_multilayers[the_position-1]; - } - Tube* MDTChamber::addTube(int the_multilayer, int the_layer, int the_status, int the_position) { - while(the_multilayer>getNmultilayers()) addMultilayer(); - Tube *t= getMultilayer(the_multilayer)->addTube(the_layer, the_status, the_position); - - if(t!=NULL) { - t->setLayer(the_layer); - t->setML(the_multilayer); - } - return t; - } - - int MDTChamber::getNmultilayers() { - return m_nmultilayers; - } - - double MDTChamber::getEntries() { - return m_entries; - } - - int MDTChamber::getStatus() { - return m_status; - } - - double MDTChamber::getMedian() { - return m_median; - } - - double MDTChamber::getMedianDeviation() { - return m_median_deviation; - } - - double MDTChamber::getMean() { - return m_mean; - } - - double MDTChamber::getStandardDeviation() { - return m_standard_deviation; - } - - TString MDTChamber::getName() { - return m_name; - } - - // These three values are explained later in the tube analysis - int MDTChamber::get90min() { - return m_90min; - } - - int MDTChamber::get90max() { - return m_90max; - } - - int MDTChamber::get70() { - return m_70; - } - - void MDTChamber::setStatus(int the_status) { - m_status=the_status; - for(int i=1; i<=getNmultilayers(); i++) { - Multilayer *ml=getMultilayer(i); - ml->setStatus(the_status); - } - } - - void MDTChamber::addEntries(double the_entries) { - m_entries+=the_entries; - } - - void MDTChamber::buildMezzanines() { - int ntubespermezzanine=0; - int mezzanine=0; - - for(int i=1; i<=getNmultilayers(); i++) { - Multilayer *ml=getMultilayer(i); - for(int j=1; j<=ml->getNlayers();j++) { - if(ml->getNlayers()==3) ntubespermezzanine=8; - if(ml->getNlayers()==4) ntubespermezzanine=6; - if((i==1)&&(getName().Contains("BIR4"))) ntubespermezzanine=3; - //BIR wiht eta=4 are the only chambers with the - Layer *l=ml->getLayer(j); //FIRST mezzanine made off rows of only 4 tubes - int tubeinmezzanine=0; - mezzanine=0; - - for(int k=1; k<=l->getNtubes();k++) { - Tube *t=l->getTube(k); - if((t->getStatus()==0)) continue; - while((mezzanine+1)>ml->getNmezzanines()) ml->addMezzanine(); - Mezzanine *mezz=ml->getMezzanine(mezzanine); - mezz->addTube(t); - //DEBUG - //t->setStatus(mezzanine+1); - // - tubeinmezzanine++; - if(tubeinmezzanine==ntubespermezzanine) { - mezzanine++; - tubeinmezzanine=0; - if(getName().Contains("BIR4")) ntubespermezzanine=6; //Same as before - } - - } - } - } - - return; - } //end MDTChamber::buildMezzanines - - void MDTChamber::calculateStatistics() { - //calculateStatistics only calculate median and median deviation of the object, not of its sub-objects - //to calculate these values for the whole chamber and its sub-parts, use the method MDTChamber::updateStatistics() - - std::vector<double> values; - double sum=0; - int ntubes=0; - for(int i=1; i<=getNmultilayers(); i++) { - Multilayer *ml=getMultilayer(i); - for(int j=1; j<=ml->getNlayers(); j++) { - Layer *l=ml->getLayer(j); - - for(int k=1; k<=l->getNtubes(); k++) { - Tube *t= l->getTube(k); - if((t->getStatus())!=10) continue; - sum+=t->getValue(); - ntubes++; - values.push_back(t->getValue()); - - } - } - } - int size=values.size(); - if(size==0) return; - - //Calculate mean - - if(ntubes!=0) m_mean=sum/(double)ntubes; - else m_mean = -1.; - - //Calulate standard deviation - - double SD =0; - for(int i=0; i<size;i++) SD+=std::pow(m_mean-values[i],2); - m_standard_deviation=std::sqrt(SD/(double)size); - - //Calculate median - sort(values.begin(), values.end()); - - //Here I use this vector to calculate the minumum tube value calculated without the 10% less popoulated tube - //and the maximum tube value calulated without the 10% more popoulated tubes - //and also the maximum tube value calulated without the 30% more popoulated tubes; - //These values are used in the tube analysis - m_90min=(int)values[(int)((double)size/10.)]; - m_90max=(int)values[(int)(9.*((double)size/10.))]; - m_70=(int)values[(int)(7.*((double)size/10.))]; - - if((size%2)==1) m_median=values[(size-1)/2]; - else m_median=(double)(values[size/2]+values[(size/2)-1])/2.; - - - //Calculate median absolute deviation - - for(int i=0; i<size; i++) { - values[i]=std::abs(values[i]-m_median); - } - sort(values.begin(), values.end()); - - if((size%2)==1) m_median_deviation=values[(size-1)/2]; - else m_median_deviation=(values[size/2]+values[(size/2)-1])/2; - - return; - } //end MDTChamber::calculateStatistics - - void MDTChamber::updateStatistics() { - //Recalculate statistics for the whole object and its sub-parts - - this->calculateStatistics(); - - for(int i=1; i<=getNmultilayers(); i++) - { - Multilayer *ml=getMultilayer(i); - for(int j=1; j<=ml->getNlayers(); j++) - { - Layer *l=ml->getLayer(j); - l->calculateStatistics(); - } - for(int j=0; j<ml->getNmezzanines(); j++) - { - Mezzanine *mezz=ml->getMezzanine(j); - mezz->calculateStatistics(); - } - ml->calculateStatistics(); - } - this->calculateStatistics(); - } - - void MDTChamber::Print() { - } //end MDTChamber::Print - - //////////////////////////////////////////////////////////////////////////////////////////////// - //Methods of class MDTDqaDeadElements - - MDTDqaDeadElements::MDTDqaDeadElements() { - m_verbose=false; - m_write_report=true; //Set to true to have a debug report with all the values needed for the analysis - m_write_compact_report=true; //Set to true to have a compact report on dead/noisy objects found - m_do_analysis=true; //Set to true to do the analysis - m_print_chambers=false; //Set to true to print the chambers layout in stdout, usually for debug - m_write_list_of_dead_tubes=false; //Set to true to get in output a list of dead tubes; It doesn't matter - //whether they are in a dead ML, L, mezzanine or they are single dead tubes, - //they are presented one by one in output. - m_do_noisy=false; //Set to true to do the analisys for noisy objects - //Be careful, at the moment it is not well tuned yet - - m_deadtubes=0; - m_deadmezzanines=0; - m_deadlayers=0; - m_deadmultilayers=0; - m_deadchambers=0; - m_lowstatisticschambers=0; - m_lowstatisticsfortubeschambers=0; - m_noisytubes=0; - m_ntubes=0; - m_lowstatmezzanines=0; - - m_dead_tubes_per_sector=0; - m_dead_mezzanines_per_sector=0; - m_dead_layers_per_sector=0; - m_dead_multilayers_per_sector=0; - m_dead_chambers_per_sector=0; - m_lowstat_chambers_per_sector=0; - } - - void MDTDqaDeadElements::setVerbose(bool the_verbose) { - m_verbose=the_verbose; - } - - void MDTDqaDeadElements::setWriteReport(bool the_write_report) { - m_write_report=the_write_report; - } - void MDTDqaDeadElements::setWriteCompactReport(bool the_write_compact_report) { - m_write_compact_report=the_write_compact_report; - } - - void MDTDqaDeadElements::setDoAnalysis(bool the_do_analysis) { - m_do_analysis=the_do_analysis; - } - - void MDTDqaDeadElements::setPrintChambers(bool the_print_chambers) { - m_print_chambers=the_print_chambers; - } - - void MDTDqaDeadElements::setDoNoisy(bool the_do_noisy) { - m_do_noisy=the_do_noisy; - } - - void MDTDqaDeadElements::setWriteListOfDeadTubes(bool the_write_list_of_dead_tubes) { - m_write_list_of_dead_tubes=the_write_list_of_dead_tubes; - } - - void MDTDqaDeadElements::MDTDqaDeadElementsAnalysis(TFile *f) { - //This is the "main" method of the class, it controls the reading, the analysis and the writing of histograms - //calling the appropriate method - - int nregionsanalysed=0; - int nsectorsanalysed=0; - int nchambersanalysed=0; - - if(m_write_report) { - TString filename=f->GetName(); - filename+="_DeadElementsAnalysis_Report.txt"; - m_file_report.open((const char*)filename); - } - if(m_write_compact_report) { - TString filename=f->GetName(); - filename+="_DeadElementsAnalysis_CompactReport.txt"; - m_comp_report.open((const char*)filename); - } - if(m_write_list_of_dead_tubes) { - TString filename=f->GetName(); - filename+="_ListOfDeadTubes.txt"; - m_filelistofdeads.open((const char*)filename); - } - for(int iregion=1; iregion<=4; iregion++) { - std::string region_name; - if(iregion==1) region_name="Barrel_A"; - if(iregion==2) region_name="Barrel_C"; - if(iregion==3) region_name="Endcap_A"; - if(iregion==4) region_name="Endcap_C"; - std::string regiondir_name="/MDT/"+region_name; - - TDirectory* regiondir=(TDirectory*)f->Get(regiondir_name.c_str()); - if(!regiondir) { - continue; - } - TH2F *hsummary=(TH2F*)regiondir->FindObjectAny("DeadElements"); - if(!hsummary) { - continue; - } - hsummary->Reset(); - - if(m_do_analysis)nregionsanalysed++; - - for(int isector=1; isector<=16; isector++) { - //These values are necessary to fill the summary plot "DeadElements" in the region folder - m_dead_tubes_per_sector=0; - m_dead_mezzanines_per_sector=0; - m_dead_layers_per_sector=0; - m_dead_multilayers_per_sector=0; - m_dead_chambers_per_sector=0; - m_lowstat_chambers_per_sector=0; - - TString sector_name=(isector<10)?("Sector0"):("Sector"); - sector_name+=isector; - TDirectory *sectordir=(TDirectory*)regiondir->Get((const char*)sector_name); - - if(!sectordir) { - continue; - } - if(m_do_analysis)nsectorsanalysed++; - - TIter next(sectordir->GetListOfKeys()); - TKey *key; - while((key=(TKey*)next())) { - std::string chamber_name=key->GetName(); - if(chamber_name=="OVERVIEW") continue; - TDirectory *chamberdir=(TDirectory*)sectordir->Get(chamber_name.c_str()); - TDirectory *deadstatusdir=(TDirectory*)sectordir->Get((chamber_name+"/DeadStatus").c_str()); - TDirectory *expertdir=(TDirectory*)sectordir->Get((chamber_name+"/Expert").c_str()); - - if(!chamberdir) { - continue; - } - - if(!deadstatusdir) { - continue; - } - - if(!expertdir) { - continue; - } - - TH1F *hgeom=(TH1F*)expertdir->FindObjectAny("DeadTubeRefMap"); - if(!hgeom) { - continue; - } - MDTChamber *chamber= new MDTChamber(hgeom,TString(chamber_name)); - - TH1F *hadccut=(TH1F*)chamberdir->FindObjectAny("a_HitsPerTubeAdcCut"); - if(!hadccut) { - delete chamber; chamber=0; - continue; - } - TH2F *hdeadchannels=(TH2F*) expertdir->FindObjectAny("ChamberDeadChannels"); - if(!hdeadchannels) { - delete chamber; chamber=0; - continue; - } - TH2F *hdeadtubes=(TH2F*) deadstatusdir->FindObjectAny("ChamberDeadTubes"); - if(!hdeadtubes) { - delete chamber; chamber=0; - continue; - } - TH1F *hdeadmap=(TH1F*) expertdir->FindObjectAny("DeadTubeMap"); - if(!hdeadmap) { - delete chamber; chamber=0; - continue; - } - fillChamber(chamber,hadccut); - - hdeadmap->Reset(); - hdeadchannels->Reset(); - hdeadtubes->Reset(); - - if(m_do_analysis)doAnalysis(chamber); - if(m_print_chambers) chamber->Print(); - if(m_do_analysis) nchambersanalysed++; - - //To fix the correct values in the output histograms - hdeadchannels->SetMinimum(0); - hdeadchannels->SetMaximum(10); - hdeadtubes->SetMinimum(0); - hdeadtubes->SetMaximum(4); - hdeadmap->SetMinimum(-50); - hdeadmap->SetMaximum(50); - - fillDeadMap(chamber,hdeadchannels,hdeadtubes,hdeadmap,deadstatusdir,chamberdir); - - if(m_write_list_of_dead_tubes) PrintListOfDeadTubes(chamber); - delete chamber; chamber=0; - - } - - hsummary->SetBinContent(isector,1,m_lowstat_chambers_per_sector); - hsummary->SetBinContent(isector,2,m_dead_chambers_per_sector); - hsummary->SetBinContent(isector,3,m_dead_multilayers_per_sector); - hsummary->SetBinContent(isector,4,m_dead_layers_per_sector); - hsummary->SetBinContent(isector,5,m_dead_mezzanines_per_sector); - hsummary->SetBinContent(isector,6,m_dead_tubes_per_sector); - - }//end of loop on sectors - }//end of loop on regions - - if(m_write_report) { - m_file_report.close(); - } - if(m_write_compact_report) { - m_comp_report.close(); - } - if(m_write_list_of_dead_tubes) { - m_filelistofdeads.close(); - } - - if(m_write_list_of_dead_tubes) { - TString filename=f->GetName(); - filename+="_DeadElementsAnalysis_Report.txt"; - } - f->Write(); - return; - } //end MDTDqaDeadElements::MDTDqaDeadElementsAnalysis - - void MDTDqaDeadElements::fillChamber(MDTChamber *chamber, TH1 *h) { - //This method fills tubes values - - int nbins=1; - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - int bincontent=-1; - - Multilayer *ml=chamber->getMultilayer(i); - - for(int j=1; j<=ml->getNlayers(); j++) { - Layer *l=ml->getLayer(j); - - for(int k=1; k<=l->getNtubes(); k++) { - Tube *t= l->getTube(k); - bincontent=(int)h->GetBinContent(nbins++); - t->setValue(bincontent); - - //Here we equalize the answer from BOG0,1,2,3 shorter tubes; - - if(((chamber->getName()).Contains("BOG"))&&(!((chamber->getName()).Contains("BOG8")))) { - if(k<=6) t->setValue(t->getValue()*2); - if(k>(l->getNtubes()-6)) t->setValue((int)(t->getValue()*2.2)); - } - - //Add entries to ml,l, chamber; it is necessary to do it - //manually because you first build chamber structure, than you fill it; - //The mezzanine entries are updated later, when you call the mezzanine->calculateStatistics(); - chamber->addEntries(bincontent); - ml->addEntries(bincontent); - l->addEntries(bincontent); - - } - - } - } - } //end MDTDqaDeadElements::fillChamber - - void MDTDqaDeadElements::fillDeadMap(MDTChamber *chamber, TH2F *hdeadchannels, TH2F *hdeadtubes, TH1F *hdeadmap, TDirectory *deadstatusdir, TDirectory *chamberdir ) { - //This method, after the analysis, fills the output histograms - - int ntubes=1; - TH1F *hdeadtubestatus=(TH1F*)chamberdir->FindObjectAny("b_DeadTubeStatus"); - if(!hdeadtubestatus) { - return; - } - hdeadtubestatus->Reset(); - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - for(int j=1; j<=ml->getNlayers(); j++) { - Layer *l=ml->getLayer(j); - TString deadlayername="DeadTubes_ML"; - deadlayername+=i; - deadlayername+="_L"; - deadlayername+=j; - int ntubeslayer=1; - - TH1F *hdeadperlayer=(TH1F*)deadstatusdir->FindObjectAny((const char*)deadlayername); - if(!hdeadperlayer) { - continue; - } - hdeadperlayer->Reset(); - - for(int k=1; k<=l->getNtubes(); k++) { - Tube *t= l->getTube(k); - - int iML = i ; - int iLy = j ; - int iTube = k ; - int ibin = (iML-1)*(ml->getNlayers())*(l->getNtubes()) + (iLy-1)*(l->getNtubes())+iTube ; - - if(t->getStatus()==NOTUBE) { - hdeadmap->SetBinContent(ntubes,0); - } else { - int ml; - if(i==1) ml=-1; - else ml=1; - int layer=j; - hdeadmap->SetBinContent(ntubes,ml*(10*layer+(t->getStatus())%10)); - hdeadchannels->SetBinContent(k,j+5*(i-1),t->getStatus()); - double contr=0; - if(t->getStatus()==7) { // status 7 used for lowstat obj - contr=0.5; - } - if(t->getStatus()==0) { // status 0 used for no tube in chamber - hdeadtubes->SetBinContent(k,j+5*(i-1),1); //white - } else if(t->getStatus()==10) { // status 10 used for working obj - contr=1; - hdeadtubes->SetBinContent(k,j+5*(i-1),2); //green - } else if(t->getStatus()==7 ) { - hdeadtubes->SetBinContent(k,j+5*(i-1),3); // yellow - } else { - hdeadtubes->SetBinContent(k,j+5*(i-1),4); // red - } - double contr2=contr ; - if(t->getStatus()!=0 && contr==0) contr2=0.1 ; - if(hdeadperlayer) hdeadperlayer->SetBinContent(ntubeslayer,contr2); - if(hdeadtubestatus) hdeadtubestatus->SetBinContent(ibin,contr2); - ntubeslayer++; - } - ntubes++; - - } - } - } - } //end MDTDqaDeadElements::fillDeadMap - - void MDTDqaDeadElements::doAnalysis(MDTChamber *chamber) { - //This methods decides whether the chamber seems dead as it has MINENTRIES entries, or the chamber has not enough - //statistics to be analysed, or the chamber can be analysed; in the latter case, this method starts the - //analysis on MLs, Layers, Mezzanines, Tubes - - const int MINENTRIES=0; //number of entries under or equal to the chamber is considered empty - const int MINMEDIAN=10; //median of chamber under or equal to you looks to the ratio to decide if you have enough - // statistics - const int MAXRATIO=3; //median/median_dev value; if you are under or equal to MAXRATIO and - //under or equal to MINMEDIAN, the - //chamber has too low statistics and too high fluctuations to be analysed; - - if(m_write_report) m_file_report<<std::endl<<"Analysing Chamber "<<chamber->getName()<<"------------------------"<<std::endl; - - if(chamber->getEntries()<=MINENTRIES) { - chamber->setStatus(DEADCHAMBER); - if(m_write_report) m_file_report<<chamber->getName()<<" Appears to be dead chamber as it has no entries"<<std::endl<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" dead_CHAMBER"<<std::endl; - m_deadchambers++; - m_dead_chambers_per_sector++; - return; - } - - chamber->calculateStatistics(); - - double median=chamber->getMedian(); - double median_deviation=chamber->getMedianDeviation(); - - double ratio=10; - if((median!=0)&&(median_deviation==0)) ratio=-1; - if((median!=0)&&(median_deviation!=0)) ratio=median/median_deviation; - if(m_write_report) m_file_report<<"entries="<<chamber->getEntries(); - if(m_write_report) m_file_report<<" median= "<<median<<"; median_dev= "<<median_deviation<<"; ratio="<<ratio<<std::endl; - - if((median<=MINMEDIAN)&&(ratio<=MAXRATIO)) { - chamber->setStatus(LOWSTATISTICSCHAMBER); - if(m_write_report) m_file_report<<chamber->getName()<<" Has Low Statistics, it won't be analysed"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" LOW STATISTICS"<<std::endl; - m_lowstatisticschambers++; - m_lowstat_chambers_per_sector++; - return; - } - if(m_write_report) m_file_report<<chamber->getName()<<" Has enough statistics, starting other analysis"<<std::endl; - - //Here you start with chamber's sub-parts analysis - - analyseMultilayers(chamber); - analyseLayers(chamber); - analyseMezzanines(chamber); - - chamber->updateStatistics(); //It is necessary to update the chamber statistics because - //dead elements you've found before this point must not be considered - //in median and median deviation value of the chamber in order to analyse the tubes - analyseTubes(chamber); - //reanalyseMezzanines(chamber); - //this method sets a mezzanine as dead if more than 50% of its tubes are dead. For the moment keep it diasbled until the dead tube analysis is fixed - - if(m_write_report) m_file_report<<std::endl<<"END OF ANALYSIS "<<chamber->getName()<<"------------------------"<<std::endl; - if(m_write_report) m_file_report<<std::endl<<std::endl; - /*DEBUG for mezzanines - for(int i=1; i<=chamber->getNmultilayers(); i++) - { - Multilayer *ml=chamber->getMultilayer(i); - for(int j=0; j<ml->getNmezzanines(); j++) - { - (ml->getMezzanine(j))->setStatus(j+1); - } - - } - */ - - } //end MDTDqaDeadElements::doAnalysis - - void MDTDqaDeadElements::analyseMultilayers(MDTChamber *chamber) { - //This method decides whether both multilayers have to low statistics to be compared one with the other one, - //or one of the multilayer gives so much less hits than the other than it is dead or inefficient - //ot the two multilayers gives similar responses, so we assume that they ar both ok; - //If one ML is noisy and the other is ok, the noisy one will appear ok, the other one inefficient or dead; - //here we're assuming that the higher is the better; - - const int MIN_MAXMEDIAN_ML=2; //The low statistic condition is: higher median of the two MLs below MIN_MAXMEDIAN_ML; - - const int MIN_ML_MED=1; //Dead condition is {[(mlmed<MIN_ML_MED)OR(10*mlmed<ml2med)] - const int SPREADDEAD=3; // AND[(mlmed1-mlmed2)/meanmeddev]<-SPREADDEAD - // AND[higher mezzanine med of ml< ml2med-SPREADDEAD*meanmeddev]} - - //The check on the mezzanines is beacuse some chambers have MLs with only 1 mezzanine - //working properly - - const int SPREADINEFFICIENT=5; //Inefficient condition is {[(mlmed-ml2med)/meanmeddev)<-SPREADINEFFICIENT] - // AND[higher mezzanine med of ml< ml2med-SPREADINEFFICIENT*meanmeddev]; - - double maxMLmedian=0; - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - ml->calculateStatistics(); - double med=ml->getMedian(); - if(med>maxMLmedian) maxMLmedian=med; - } - if(m_write_report) m_file_report<<"MLs MAXMEDIAN="<<maxMLmedian<<std::endl; - if(maxMLmedian<MIN_MAXMEDIAN_ML) { - if(m_write_report) m_file_report<<"MLs have not enough statistics to be analized"<<std::endl; - return; - } - if(chamber->getNmultilayers()==1) { - if(m_write_report) m_file_report<<"Only 1ML in chamber; ML analysis ok;"<< std::endl; - return; - } - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - Multilayer *ml2; - if(i==1) ml2=chamber->getMultilayer(i+1); - else ml2=chamber->getMultilayer(i-1); - - double maxMezzMed=0; - - for(int j=0; j<ml->getNmezzanines(); j++) { - Mezzanine *mezz=ml->getMezzanine(j); - mezz->calculateStatistics(); - double medmezz=mezz->getMedian(); - if(medmezz>maxMezzMed) maxMezzMed=medmezz; - } - - double meanMedDev=(ml->getMedianDeviation()+ml2->getMedianDeviation())/2.; - double diff=ml->getMedian()-ml2->getMedian(); - - double diffToOther=diff/meanMedDev; - if(m_write_report) m_file_report<<"ML"<<i<<"entries="<<ml->getEntries(); - if(m_write_report) m_file_report<<"; median="<<ml->getMedian()<<"; diffToOther="<<diffToOther<<"; "; - if(m_write_report) m_file_report<<"maxMezzMed="<<maxMezzMed<<std::endl; - - int contr=0; - if((ml->getMedian()<=MIN_ML_MED)||((10*ml->getMedian())<ml2->getMedian())) { - if(diffToOther<-SPREADDEAD) { - if(maxMezzMed<(ml2->getMedian()-SPREADDEAD*meanMedDev)) { - if(m_write_report) m_file_report<<"ML "<<i<<" seems to be dead ML"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" dead_MULTILAYER "<<i<<std::endl; - ml->setStatus(DEADML); - m_deadmultilayers++; - m_dead_multilayers_per_sector++; - contr=1; - } - } - } else if((diffToOther<-SPREADINEFFICIENT)&&(maxMezzMed<(ml2->getMedian()-SPREADINEFFICIENT*meanMedDev))) { - if(m_write_report) m_file_report<<"ML "<<i<<" seems to be inefficient ML"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" inefficient_MULTILAYER "<<i<<std::endl; - ml->setStatus(INEFFICIENTML); - m_deadmultilayers++; - m_dead_multilayers_per_sector++; - contr=1; - } - - if(contr==0) {if(m_write_report) m_file_report<<"ML "<<i<<" OK"<<std::endl;} - - } - return; - } //end MDTDqaDeadElements::analyseMultilayers - - void MDTDqaDeadElements::analyseLayers(MDTChamber *chamber) { - //This method first of all decides if layers have or not enough statistics to be analysed; - //then it compares layers with all other layers of the whole chamber in order to find dead or inefficient ones - - const int MIN_MAXLAYER_MED=2; //If max median of layers is below this value, the statistics is too low to analyze them; - - const int MIN_LAYER_MED=2; //Dead condition is {[ lmed<MINLAYERMED]} - const int SPREADDEAD=3; // AND{[(lmed-medofotherlayersmed)/medofotherlayersmeddev]<-SPREADDEAD - const int MIN_OTHERMEDIANS_DEAD=50; // OR[medianofothermedians>MIN_OTHERMEDIANS_DEAD]} - // AND{[maxMezzMedian<(medofothermed-SPREADDEAD*medofothermeddev)] - // OR[maxMezzMedian<=MIN_OTHERMEDIANS_DEAD]} - - - const int SPREADINEFFICIENT=5; // Inefficient condition is - // {[(lmed-medofotherlayersmed)/medofotherlayersmeddev]<-SPREADINEFFICIENT} - // AND {maxMezzMedian<(medofothermed-SPREADINEFFICIENT*medofothermeddev)} - - const int SPREADHOT=100; //These values used for the hot layers analysis need to be tuned - const int MINMEDHOT=100; - - double maxMedianLayers=0; - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - if(ml->getStatus()!=10) continue; - for(int j=1; j<=ml->getNlayers(); j++) { - Layer *l=ml->getLayer(j); - l->calculateStatistics(); - double med=l->getMedian(); - if(med>maxMedianLayers) maxMedianLayers=med; - } - - } - if(maxMedianLayers<MIN_MAXLAYER_MED) { - if(m_write_report) m_file_report<<"Layers without enough statistics, not analysed"<<std::endl; - return; - } - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - if(ml->getStatus()!=10) continue; - for(int j=1; j<=ml->getNlayers(); j++) { - Layer *l=ml->getLayer(j); - //double med=l->getMedian(); - double medianOfOtherMedians=0; - double medianOfOtherMediansDevs=0; - - std::vector<double> values; - std::vector<double> values_dev; - - double maxMezzMedian=0; - - for(int k=0; k<ml->getNmezzanines(); k++) { - Mezzanine *mezz=ml->getMezzanine(k); - std::vector<double> values_mezz; - for(int y=1; y<=mezz->getNtubes(); y++) { - Tube *t=mezz->getTube(y); - if(t->getStatus()!=10) continue; - if(t->getParentLayer()!=l) continue; - values_mezz.push_back(t->getValue()); - } - int size_mezz=values_mezz.size(); - double mezzmed; - sort(values_mezz.begin(), values_mezz.end()); - if((size_mezz%2)==1) mezzmed=values_mezz[(size_mezz-1)/2]; - else mezzmed=(double)(values_mezz[size_mezz/2]+values_mezz[(size_mezz/2)-1])/2.; - if (mezzmed>maxMezzMedian) maxMezzMedian=mezzmed; - } - for(int k=1; k<=chamber->getNmultilayers(); k++) { - Multilayer *ml2=chamber->getMultilayer(k); - for(int t=1; t<=ml2->getNlayers(); t++) { - Layer *l2=ml->getLayer(t); - if (l2==l) continue; - values.push_back(l2->getMedian()); - values_dev.push_back(l2->getMedianDeviation()); - } - } - - int size=values.size(); - sort(values.begin(), values.end()); - if((size%2)==1) medianOfOtherMedians=values[(size-1)/2]; - else medianOfOtherMedians=(double)(values[size/2]+values[(size/2)-1])/2.; - - int size_dev=values_dev.size(); - sort(values_dev.begin(), values_dev.end()); - if((size_dev%2)==1) medianOfOtherMediansDevs=values_dev[(size_dev-1)/2]; - else medianOfOtherMediansDevs=(values_dev[size_dev/2]+values_dev[(size_dev/2)-1])/2.; - - int contr=0; - double diff=l->getMedian()-medianOfOtherMedians; - double diffToOthers; - if(diff==0) diffToOthers=0; - else { - if(medianOfOtherMediansDevs==0) diffToOthers=100; - else diffToOthers=diff/medianOfOtherMediansDevs; - } - if(m_write_report) m_file_report<<"Layer"<<j<<" entries= "<<l->getEntries()<<" median="<<l->getMedian()<<"; diffToOther="<<diffToOthers<<"; "; - if(m_write_report) m_file_report<<"medianOfOthersMedian="<<medianOfOtherMedians<<"; "; - if(m_write_report) m_file_report<<"medianOfOthersMedianDev="<<medianOfOtherMediansDevs<<"; "; - if(m_write_report) m_file_report<<"maxMezzMedian="<<maxMezzMedian<<std::endl; - - if((diffToOthers>SPREADHOT)&&(l->getMedian()>MINMEDHOT)) { - if(!m_do_noisy) continue; - - if(m_write_report) m_file_report<<"ML "<<i<<" Layer "<<j<<" seems to be noisy layer"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" noisy_LAYER "<<i<<" "<<j<<std::endl; - l->setStatus(NOISYLAYER); - contr=1; - } - - if(l->getMedian()<MIN_LAYER_MED) { - if((diffToOthers<=-SPREADDEAD)||(medianOfOtherMedians>MIN_OTHERMEDIANS_DEAD)) { - if((maxMezzMedian<(medianOfOtherMedians-SPREADDEAD*medianOfOtherMediansDevs))||(maxMezzMedian<=MIN_OTHERMEDIANS_DEAD)) { - if(m_write_report) m_file_report<<"ML "<<i<<" Layer "<<j<<" seems to be dead layer"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" dead_LAYER "<<i<<" "<<j<<std::endl; - l->setStatus(DEADLAYER); - m_deadlayers++; - m_dead_layers_per_sector++; - contr=1; - } - } - } else if((diffToOthers<-SPREADINEFFICIENT)&&(maxMezzMedian<(medianOfOtherMedians-SPREADINEFFICIENT*medianOfOtherMediansDevs))) { - if(m_write_report) m_file_report<<"ML "<<i<<" Layer "<<j<<" seems to be inefficient layer"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" inefficient_LAYER "<<i<<" "<<j<<std::endl; - l->setStatus(INEFFICIENTLAYER); - m_deadlayers++; - m_dead_layers_per_sector++; - contr=1; - } - if(contr==0) {if(m_write_report) m_file_report<<"ML "<<i<<" Layer "<<j<<" ok"<<std::endl;} - - } - } - - return; - - } //end MDTDqaDeadElements::analyseLayers - - void MDTDqaDeadElements::reanalyseMezzanines(MDTChamber *chamber) { - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - if(ml->getStatus()!=10) continue; - for(int j=0; j<ml->getNmezzanines(); j++) { - Mezzanine *mezz=ml->getMezzanine(j); - int ntubes=0; - int ndeadtubes=0; - for(int k=1; k<=mezz->getNtubes(); k++) { - Tube *t=mezz->getTube(k); - if(t->getStatus()==0) continue; - ntubes++; - if(t->getStatus()==DEADTUBE) ndeadtubes++; - } - if(ntubes==0) continue; - else if((double)((double)ndeadtubes/(double)ntubes)>0.5) { - if(m_write_report) m_file_report<<"ML "<<i<<" Mezzanine "<<j<<" appears to be dead mezzanine"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" dead_MEZZANINE_rean "<<i<<" "<<j<<std::endl; - mezz->setStatus(DEADMEZZANINE); - //m_dead_tubes_per_sector-=ntubes; - m_dead_tubes_per_sector-=ndeadtubes; - // m_deadtubes-=ntubes; - m_deadtubes-=ndeadtubes; - m_dead_mezzanines_per_sector++; - m_deadmezzanines++; - - } - } - } - - } //end MDTDqaDeadElements::reanalyseMezzanines - - void MDTDqaDeadElements::analyseMezzanines(MDTChamber *chamber) { - //This method first of all decides if mezzanines have or not enough statistics to be analysed; - //then it compares mezzanines with all other mezzanines of the whole chamber in order to find dead or inefficient ones; - //Because of some chambers that suffers of complex geometry/trigger effects, showing very uneven distributions - //here we define a flatness value, and use different strategy for "normal" chambers and "strang" chambers; - - //Chamber flatness is a value defined as medianDeviationOfMezzanineMedians/medianOfMezzanineMediansDeviation - //A chamber is considered flat if this value is <=1; - - const int MIN_MAXMEDIAN=2; //If max median of mezzanines is below this value, the statistics is to low to analyze them - - -// const int MIN_ENTRIES=1; //Dead condition: {[mezz.entries<=MINENTRIES] -// const int SPREADDEAD=5; // AND[diffToOthers<-SPREADDEAD]} - -// const int SPREADINEFFICIENT=10; //Inefficient condition: - //flat chambers: [diffToOthers<=-SPREADINEFFICIENT]; - //unflat chambers: [diffToOthers<=-SPREADINEFFICIENT*chamberflatness]; - //chamber with flatness>5 not analyzed - -// const int SPREADHOT=10; //The noisy mezzanine analysis needs to be tuned - - double maxMedianMezzanines=0; - - double medianOfMedians=0; - double medianOfMediansDeviation=0; - double medianDeviationOfMedians=0; - - std::vector<double> values; - std::vector<double> values_dev; - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - if(ml->getStatus()!=10) continue; - for(int j=0; j<ml->getNmezzanines(); j++) { - Mezzanine *mezz=ml->getMezzanine(j); - mezz->calculateStatistics(); //It is necessary to recalculate the statistics in order to exclude dead layers - double med=mezz->getMedian(); - values.push_back(med); - values_dev.push_back(mezz->getMedianDeviation()); - if(med>maxMedianMezzanines) maxMedianMezzanines=med; - } - - } - int size=values.size(); - sort(values.begin(), values.end()); - if((size%2)==1) medianOfMedians=values[(size-1)/2]; - else medianOfMedians=(double)(values[size/2]+values[(size/2)-1])/2.; - - for(int l=0; l<size; l++) values[l]=std::abs(values[l]-medianOfMedians); - sort(values.begin(), values.end()); - if((size%2)==1) medianDeviationOfMedians=values[(size-1)/2]; - else medianDeviationOfMedians=(double)(values[size/2]+values[(size/2)-1])/2.; - - int size_dev=values_dev.size(); - sort(values_dev.begin(), values_dev.end()); - if((size_dev%2)==1) medianOfMediansDeviation=values_dev[(size_dev-1)/2]; - else medianOfMediansDeviation=(double)(values_dev[size_dev/2]+values_dev[(size_dev/2)-1])/2.; - - double chamberFlatness=medianDeviationOfMedians/medianOfMediansDeviation; - - if(maxMedianMezzanines<MIN_MAXMEDIAN) { - if(m_write_report) m_file_report<<"Mezzanines without enough statistics, not analysed"<<std::endl; - return; - } - if(m_write_report) m_file_report<<"ChamberFlatness="<<chamberFlatness<<std::endl; - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - Multilayer *other_ml=NULL; - if(chamber->getNmultilayers()>1) { - if(i==1) other_ml=chamber->getMultilayer(2); - if(i==2) other_ml=chamber->getMultilayer(1); - } - - if(ml->getStatus()!=10) continue; - - for(int j=0; j<ml->getNmezzanines(); j++) { - Mezzanine *mezz=ml->getMezzanine(j); - if(mezz->getNtubes()==0) continue; - double med=mezz->getMedian(); - double meddev=mezz->getMedianDeviation(); - double medianOfOtherMedians=0; - double medianOfOtherMediansDevs=0; - - std::vector<double> values; - std::vector<double> values_dev; - - double minOtherLargerMedians=-1; - - for(int k=1; k<=chamber->getNmultilayers(); k++) { - Multilayer *ml2=chamber->getMultilayer(k); - if(ml2->getStatus()!=10) continue; - - for(int t=0; t<ml2->getNmezzanines(); t++) { - - Mezzanine *mezz2=ml2->getMezzanine(t); - if (mezz2==mezz) continue; - values.push_back(mezz2->getMedian()); - values_dev.push_back(mezz2->getMedianDeviation()); - if((minOtherLargerMedians==-1)||((mezz2->getMedian()>med)&&(mezz2->getMedian()<minOtherLargerMedians))) { - minOtherLargerMedians=mezz2->getMedian(); - } - } - } - - int size=values.size(); - sort(values.begin(), values.end()); - if((size%2)==1) medianOfOtherMedians=values[(size-1)/2]; - else medianOfOtherMedians=(double)(values[size/2]+values[(size/2)-1])/2.; - - int size_dev=values_dev.size(); - sort(values_dev.begin(), values_dev.end()); - if((size_dev%2)==1) medianOfOtherMediansDevs=values_dev[(size_dev-1)/2]; - else medianOfOtherMediansDevs=(values_dev[size_dev/2]+values_dev[(size_dev/2)-1])/2.; - - //int contr=0; - double diff=mezz->getMedian()-medianOfOtherMedians; - double diffToOthers; - diffToOthers=diff/(std::max(1.,std::max(mezz->getMedianDeviation(),medianOfOtherMediansDevs))); - - std::vector<Mezzanine*> near_mezz; - - //lowstat case - bool isLowStat=false; - if(med>0&&meddev>0&&((med-1.5*meddev)<0)) isLowStat=true; - if(isLowStat) { - mezz->setStatus(LOWSTATMEZZANINE); - m_lowstatmezzanines++; - continue; - } - - if(j>0) { - if(ml->getMezzanine(j-1)!=NULL) { - near_mezz.push_back(ml->getMezzanine(j-1)); - } - } - if(j<(ml->getNmezzanines()-1)) { - if(ml->getMezzanine(j+1)!=NULL) { - near_mezz.push_back(ml->getMezzanine(j+1)); - } - } - if(other_ml!=NULL) { - if(other_ml->getMezzanine(j)!=NULL) { - near_mezz.push_back(other_ml->getMezzanine(j)); - } - } - - if(near_mezz.size()>0) { - bool isDead=false; - bool OneGood=false; - double lower_limit=9999999; - for(unsigned int k=0; k<near_mezz.size(); k++) { - double other_min70=near_mezz[k]->get70min(); - OneGood=true; - if(other_min70<lower_limit) lower_limit=other_min70; - } - - double max70= mezz->get70max(); - if(OneGood&&max70<(lower_limit/5.)&&(lower_limit>5)&&med==0) isDead=true; - if(isDead) { - if(m_write_report) m_file_report<<chamber->getName()<<" ML "<<i<<" Mezzanine "<<j<<" appears to be dead_mezzanine; low_limit="<<lower_limit<<" median="<<med<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" dead_MEZZANINE "<<i<<" "<<j<<std::endl; - mezz->setStatus(DEADMEZZANINE); - m_deadmezzanines++; - m_dead_mezzanines_per_sector++; - } - - } - if(mezz->getStatus()==10 && med<10) { //med=10 is compatible with 0! - mezz->setStatus(LOWSTATMEZZANINE); - m_lowstatmezzanines++; - continue; - } - if(m_write_report) m_file_report<<"ML"<<i<<" mezz"<<j<<": med="<<mezz->getMedian()<<"; "<<" mad="<<mezz->getMedianDeviation(); - if(m_write_report) m_file_report<<"medev"<<medianOfOtherMediansDevs<<"; "; - if(m_write_report) m_file_report<<"entries="<<mezz->getEntries()<<"; diffToOthers="<<diffToOthers<<"; "; - if(m_write_report) m_file_report<<"minlargermed="<<minOtherLargerMedians<<std::endl; - if(m_write_report) m_file_report<<"inefficient if med below="; - if(m_write_report) m_file_report<<(minOtherLargerMedians-5*medianOfOtherMediansDevs)<<std::endl; - - } - } - - return; - - } //end MDTDqaDeadElements::analyseMezzanines - - void MDTDqaDeadElements::analyseTubes(MDTChamber *chamber) { - //This method first of all decides if the chamber has enough statistics to analyze single tubes - //then it search for dead tubes - - //There are chambers which looks completely dead except one mezzanine; finding them using median criteria is impossible - //they just looks like LOW STATISTICS chambers; so, before the low statistics check, I' ve implemented another one - //If, after ML, L, Mezz analysis, more than 70% of chambers tubes has 0 entries and there is a mezzanine - //with a median.=50, than the chamber is signed as DEAD, to show that there is a big problem. - - const int MINCHAMBERMED=20; //chambers with med<MINCHAMBERMED are considered to have - //too low statistics to analyze single tubes - - const int SPREADDEAD=5; //Dead condition {[tube.entries<(chambermed-SPREADDEAD*chambermemddev)] - // AND[tube.entries<(chambermed/10)]AND[chambermed>=MINCHAMBERMED]} - // OR{tube.entries==0 AND chambermed>=50} - - //Because of chambers with geometry/trigger effects, some tubes which actually are dead - //cannot be found (this is whem chambermeddev is very high) - //So, I've added a new check: a tube is considered dead also if it has less than - //10% entries respect to the tube with the minimum value of the chamber calculated excluding - //the 10% less popoulate tubes of the chamber; - - //The noisy tubes analysis is not used for now - - int ndeadtubes=0; - int nnoisytubes=0; - if(m_write_report) m_file_report<<"Starting Tube Analysis"<<std::endl; - - double median=chamber->getMedian(); - //double median_deviation=chamber->getMedianDeviation(); - double standard_deviation=chamber->getStandardDeviation(); - - double maxMezzMed=0; - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - if(ml->getStatus()!=10) continue; - for(int j=0; j<ml->getNmezzanines(); j++) { - Mezzanine *mezz=ml->getMezzanine(j); - if(mezz->getMedian()>maxMezzMed) maxMezzMed=mezz->getMedian(); - } - - } - if((maxMezzMed>=50)&&(chamber->get70()==0)) { - chamber->setStatus(DEADCHAMBER); - if(m_write_report) m_file_report<<chamber->getName()<<" Appears to be a chamber with only few live tubes"<<std::endl<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" strange_CHAMBER"<<std::endl; - m_deadchambers++; - m_dead_chambers_per_sector++; - return; - - } - - if(median<MINCHAMBERMED) { - m_lowstatisticsfortubeschambers++; - m_lowstat_chambers_per_sector++; - if(m_write_report) m_file_report<<"This chamber has too low statistics to analyze single tubes"<<std::endl; - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" LOW STATISTICS FOR TUBES"<<std::endl; - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - if(ml->getStatus()!=10) continue; - for(int j=1; j<=ml->getNlayers(); j++) { - Layer *l=ml->getLayer(j); - if(l->getStatus()!=10) continue; - for(int k=1; k<=l->getNtubes(); k++) { - Tube *t=l->getTube(k); - if(t->getStatus()!=10) continue; - t->setStatus(LOWSTATISTICSCHAMBER); - } - } - } - - return; - } - - double marco_limit=0.1*(chamber->get90min())-1.; - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - if(ml->getStatus()!=10) continue; - double medML=ml->getMedian(); - double medDevML=ml->getMedianDeviation(); - double limit=medML-SPREADDEAD*medDevML; - - if(m_write_report) { - m_file_report<<"ML"<<i<<" Tube Limit="<<limit<<"; medML="<<medML<<" ;medDevML="<<medDevML<<"; medML/10="<<((double)medML/10.)<<"; tube noisy over="<<(10*standard_deviation+median)<<" marcolimit="<<marco_limit<<std::endl; - } - - for(int j=0; j<ml->getNmezzanines(); j++) { - Mezzanine *mezz=ml->getMezzanine(j); - if(mezz->getStatus()!=10) continue; - double marco_limitMezz=0.1*mezz->get70min()-1; - for(int k=1; k<=mezz->getNtubes(); k++) { - - Tube *t=mezz->getTube(k); - if(t->getStatus()!=10) continue; - m_ntubes++; - int value=t->getValue(); - if(value<marco_limitMezz) { - if(m_write_compact_report) m_comp_report<<chamber->getName()<<" dead_TUBE "<<t->getML()<<" "<<t->getLayer()<<" "<<t->getPosition()<<std::endl; - t->setStatus(DEADTUBE); - ndeadtubes++; - m_deadtubes++; - m_dead_tubes_per_sector++; - } - } - } - } - if(m_write_report) m_file_report<<"End of tube analysis; "<<ndeadtubes<<"dead tubes found"<<nnoisytubes<<"noisy tubes found"<<std::endl; - - } //end MDTDqaDeadElements::analyseTubes - - void MDTDqaDeadElements::PrintListOfDeadTubes(MDTChamber *chamber) { - - for(int i=1; i<=chamber->getNmultilayers(); i++) { - Multilayer *ml=chamber->getMultilayer(i); - for(int j=1; j<=ml->getNlayers(); j++) { - Layer *l=ml->getLayer(j); - for(int k=1; k<=l->getNtubes(); k++) { - Tube *t=l->getTube(k); - if((t->getStatus()==10)||(t->getStatus()==0)) continue; - m_filelistofdeads<<"Chamber "<<chamber->getName()<<" ML "<<i<<" L "<<j<<" Tube "<<k<<" DEAD"<<std::endl; - } - } - } - return; - } //end MDTDqaDeadElements::PrintListOfDeadTubes - -} //namespace MuonCalib - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTName.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTName.cxx deleted file mode 100644 index ca1c4d701472569054884616af827fe92a39e3ae..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MDTName.cxx +++ /dev/null @@ -1,306 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibStandAloneExtraTools/MDTName.h" - -namespace MuonCalib { - - MDTName::MDTName() : m_eta_on(-1), m_eta_off(-1), m_sector_on(-1), m_sector_off(-1), m_side('X') - {} - - MDTName::MDTName(const MuonFixedId& the_id) { - m_name=TString(the_id.stationNameString()); - m_eta_off=the_id.eta(); - m_eta_on=std::abs(m_eta_off); - if(m_eta_off<0) m_side='C'; - if(m_eta_off>=0) m_side='A'; - //Here chambers with eta=0 are included in m_side A; - m_sector_off=the_id.phi(); - if((m_name[2]=='L')||(m_name[2]=='M')||(m_name[2]=='R')) m_sector_on=((the_id.phi())*2)-1; - else m_sector_on=((the_id.phi())*2); - if((m_name=="BML")&&(m_sector_on==13)&&(m_eta_off>3)) m_eta_on++; - if((m_name=="BML")&&(m_sector_on==13)&&(m_eta_off<(-3))) m_eta_on++; - if(((m_sector_on==12)||(m_sector_on==14))&&(m_name=="BOF")) { - m_eta_on=m_eta_on*2-1; - } - if(((m_sector_on==12)||(m_sector_on==14))&&(m_name=="BOG")){ - m_eta_on=m_eta_on*2; - } - if((m_name=="EIL")&&((m_sector_on==1)||(m_sector_on==9))&&((m_eta_on==4)||(m_eta_on==5))) { - if(m_eta_on==4) m_eta_on=5; - else m_eta_on=4; - } - if((m_name=="EEL")&&(m_sector_on==5)&&(m_eta_on==1)) { - m_eta_on=2; - } - } - - MDTName::MDTName(const std::string& the_name) { - TString s(the_name); - MDTName_init(s); - } - - MDTName::MDTName(const char *the_name) { - TString s(the_name); - MDTName_init(s); - } - - MDTName::MDTName(const TString& the_name) { - MDTName_init(the_name); - } - - MDTName::MDTName(const std::string& the_name, const int sector, const int eta) { - TString temp=the_name; - temp+="_"; - temp+=sector; - temp+="_"; - temp+=eta; - MDTName_init(temp); - } - - MDTName::MDTName(const std::string& the_name, const int eta, const std::string& side, const int sector) { - TString temp=the_name; - temp+=eta; - temp+=side; - temp+=sector; - MDTName_init(temp); - } - - void MDTName::MDTName_init(const TString& name) { - TString the_name(name); - the_name.ToUpper(); - m_name=the_name(0,3); - if(the_name.Contains('_')) { - the_name.Remove(0,4); - m_sector_off=(TString(the_name(0,1))).Atoi(); - the_name.Remove(0,2); - if(the_name.Contains('-')) { - m_eta_off=the_name.Atoi(); - m_side='C'; - m_eta_on=std::abs(m_eta_off); - } else { - m_eta_off=the_name.Atoi(); - m_side='A'; - //Here chambers with eta=0 are included in m_side A; - //if(m_eta_off==0) m_side='B'; - m_eta_on=m_eta_off; - } - - if((m_name[2]=='L')||(m_name[2]=='M')||(m_name[2]=='R')) m_sector_on=(m_sector_off*2)-1; - else m_sector_on=2*m_sector_off; - - if((m_name=="BML")&&(m_sector_on==13)&&(m_eta_off>3)) m_eta_on++; - if((m_name=="BML")&&(m_sector_on==13)&&(m_eta_off<-3)) m_eta_on++; - - if(((m_sector_on==12)||(m_sector_on==14))&&(m_name=="BOF")) { - m_eta_on=m_eta_on*2-1; - } - if(((m_sector_on==12)||(m_sector_on==14))&&(m_name=="BOG")) { - m_eta_on=m_eta_on*2; - } - if((m_name=="EIL")&&((m_sector_on==1)||(m_sector_on==9))&&((m_eta_on==4)||(m_eta_on==5))) { - if(m_eta_on==4) m_eta_on=5; - else m_eta_on=4; - } - if((m_name=="EEL")&&(m_sector_on==5)&&(m_eta_on==1)) { - m_eta_on=2; - } - - } else { - the_name.Remove(0,3); - m_eta_on=(TString(the_name(0,1))).Atoi(); - the_name.Remove(0,1); - m_side=the_name[0]; - the_name.Remove(0,1); - m_sector_on=the_name.Atoi(); - - if((m_name[2]=='L')||(m_name[2]=='M')||(m_name[2]=='R')) m_sector_off=(m_sector_on+1)/2; - else m_sector_off=m_sector_on/2; - if(m_side=='C') m_eta_off=-m_eta_on; - else m_eta_off=m_eta_on; - - if((m_name=="BML")&&(m_sector_on==13)&&(m_eta_on>4)&&(m_side=='A')) m_eta_off--; - if((m_name=="BML")&&(m_sector_on==13)&&(m_eta_on>4)&&(m_side=='C')) m_eta_off++; - - if((m_name=="EEL")&&(m_sector_on==5)&&(m_eta_on==2)) { - if(m_side=='A') m_eta_off=1; - if(m_side=='C') m_eta_off=-1; - } - - if(((m_sector_on==12)||(m_sector_on==14))&&(m_name=="BOF")) { - if(m_side=='A') { - m_eta_off=(m_eta_on+1)/2; - } else { - m_eta_off=-(m_eta_on+1)/2; - } - } - if(((m_sector_on==12)||(m_sector_on==14))&&(m_name=="BOG")) { - if(m_side=='A') { - m_eta_off=(m_eta_on)/2; - } else { - m_eta_off=-(m_eta_on)/2; - } - } - if((m_name=="EIL")&&((m_sector_on==1)||(m_sector_on==9))&&((m_eta_on==4)||(m_eta_on==5))) { - if(m_side=='A') { - if(m_eta_on==4) m_eta_off=5; - else m_eta_off=4; - } else { - if(m_eta_on==4) m_eta_off=-5; - else m_eta_off=-4; - } - } - - } - } //end MDTName::MDTName_init - - std::string MDTName::getOnlineName() { - TString the_name(m_name); - the_name+=m_eta_on; - the_name+=m_side; - if(m_sector_on<10) the_name+="0"; - the_name+=m_sector_on; - return (std::string)the_name; - } - - std::string MDTName::getOfflineName() { - TString the_name(m_name); - the_name+='_'; - the_name+=m_sector_off; - the_name+='_'; - the_name+=m_eta_off; - return (std::string)the_name; - } - - bool MDTName::isBarrel() { - if((m_name=="BIS")&&(m_eta_on==7)) return false; - if((m_name=="BIS")&&(m_eta_on==8)) return false; - if((m_name=="BEE")) return false; - if(m_name[0]=='B') return true; - return false; - } - - bool MDTName::isEndcap() { - if(m_name[0]=='E') return true; - if((m_name=="BIS")&&(m_eta_on==7)) return true; - if((m_name=="BIS")&&(m_eta_on==8)) return true; - if((m_name=="BEE")) return true; - return false; - } - - bool MDTName::isInner() { - if(m_name[1]=='I') return true; - return false; - } - - bool MDTName::isMiddle() { - if(m_name[1]=='M') return true; - return false; - } - - bool MDTName::isOuter() { - if(m_name[1]=='O') return true; - return false; - } - - bool MDTName::isExtra() { - if(m_name[1]=='E') return true; - return false; - } - - bool MDTName::isForward() { - if (m_eta_off>=0) return true; //Here chambers with eta=0 are treated as Forward - return false; - } - - bool MDTName::isBackward() { - if(m_eta_off<0) return true; - return false; - } - - bool MDTName::isLarge() { - if(m_name[2]=='L') return true; - return false; - } - - bool MDTName::isSmall() { - if(m_name[2]=='S') return true; - return false; - } - - int MDTName::getOnlineSector() { - return m_sector_on; - } - - int MDTName::getOfflineSector() { - return m_sector_off; - } - - int MDTName::getOnlineEta() { - return m_eta_on; - } - - int MDTName::getOfflineEta() { - return m_eta_off; - } - - std::string MDTName::getRegion() { - std::string temp="Barrel"; - if(this->isEndcap()) temp="Endcap"; - return temp; - } - - std::string MDTName::getStation() { - std::string temp=""; - temp+=m_name[1]; - return temp; - } - - std::string MDTName::getSize() { - std::string temp=""; - temp+=m_name[2]; - return temp; - } - - std::string MDTName::getSide() { - std::string temp=""; - temp+=m_side; - return temp; - } - - std::string MDTName::getName() { - return (std::string)m_name; - } - - TString MDTName::OnlineToOfflineName(const TString& the_name) { - MDTName temp(the_name); - return temp.getOfflineName(); - } - - TString MDTName::OnlineToOfflineName(const char *the_name) { - MDTName temp(the_name); - return temp.getOfflineName(); - } - - TString MDTName::OnlineToOfflineName(const std::string& the_name) { - MDTName temp(the_name); - return temp.getOfflineName(); - } - - TString MDTName::OfflineToOnlineName(const TString& the_name) { - MDTName temp(the_name); - return temp.getOnlineName(); - } - - TString MDTName::OfflineToOnlineName(const char* the_name) { - MDTName temp(the_name); - return temp.getOnlineName(); - } - - TString MDTName::OfflineToOnlineName(const std::string& the_name) { - MDTName temp(the_name); - return temp.getOnlineName(); - } - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaDb.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaDb.cxx deleted file mode 100644 index aa55ef10b14cad889012753e96f849b7c13e6b0c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaDb.cxx +++ /dev/null @@ -1,179 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibStandAloneExtraTools/MdtDqaDb.h" - -#include <iostream> -#include <fstream> -#include <sstream> -#include <map> -#include <string.h> -#include <vector> - -MdtDqaDb::MdtDqaDb(std::string chamName) : m_numNoisyMezz(-1), m_numNoisyTube(-1) { - Clear(); - m_chamberName = chamName; -} -MdtDqaDb::MdtDqaDb() : m_numNoisyMezz(-1), m_numNoisyTube(-1) { - Clear(); -} - -MdtDqaDb::~MdtDqaDb() {} - -void MdtDqaDb::Clear() { - m_listDeadML.clear(); - m_listDeadMezz.clear(); - m_listDeadTube.clear(); - m_listNoisyMezz.clear(); - m_listNoisyTube.clear(); - m_chamberName = ""; - m_t0ML1 = -1; - m_t0ML2 = -1; - m_tdriftML1 = -1; - m_tdriftML2 = -1; - m_chi2ndofML1 = -1; - m_chi2ndofML2 = -1; - m_t0errML1 = -1; - m_t0errML2 = -1; - m_tdrifterrML1 = -1; - m_tdrifterrML2 = -1; - m_numDeadML = -1; - m_numDeadMezz = -1; - m_numDeadTube = -1; - m_timeFlag = -1; - m_deadFlag = -1; -} - -void MdtDqaDb::Print(std::ofstream *outputFile) { - *outputFile << " ==================================================== " << std::endl ; - *outputFile << " MdtDqaDb output: ---- Chamber name : " << m_chamberName << std::endl ; - *outputFile << " timeFlag : " << getTimeFlag() << std::endl ; - *outputFile << " deadFlag : " << getDeadFlag() << std::endl ; - *outputFile << " chi2 per dof ML1 : " << m_chi2ndofML1 << std::endl ; - *outputFile << " chi2 per dof ML2 : " << m_chi2ndofML2 << std::endl ; - *outputFile << " t0 ML1 (ns) " << m_t0ML1 << " +/- " << m_t0errML1 << std::endl ; - *outputFile << " t0 ML2 (ns) " << m_t0ML2 << " +/- " << m_t0errML2 << std::endl ; - *outputFile << " tdrift ML1 (ns) " << m_tdriftML1 << " +/- " << m_tdrifterrML1 << std::endl ; - *outputFile << " tdrift ML2 (ns) " << m_tdriftML2 << " +/- " << m_tdrifterrML2 << std::endl ; - - *outputFile << " Number of Dead ML : " << m_numDeadML << " ---- list of dead/inefficient Multilayers : " << std::endl ; - for ( int n=0 ; n< m_numDeadML ; n++ ) *outputFile << m_listDeadML[n] << std::endl ; - *outputFile << " Number of Dead Mezzanine : " << m_numDeadMezz << " ---- list of dead/inefficient Mezzanine : " << std::endl ; - for ( int n=0 ; n< m_numDeadMezz ; n++ ) *outputFile << m_listDeadMezz[n] << std::endl ; - *outputFile << " Number of Dead Tubes : " << m_numDeadTube << " ---- list of dead/inefficient Tubes : " << std::endl ; - for ( int n=0 ; n< m_numDeadTube ; n++ ) *outputFile << m_listDeadTube[n] << std::endl ; - - *outputFile << std::endl ; -} - -void MdtDqaDb::Print() { -} - -void MdtDqaDb::SetChamberName(std::string chamName) { - m_chamberName = chamName; -} - -void MdtDqaDb::SetTimeFlag(int timeFlag) { - m_timeFlag = timeFlag; -} - -void MdtDqaDb::SetDeadFlag(int deadFlag) { - m_deadFlag = deadFlag; -} - -void MdtDqaDb::SetML1(float t0, float tdrift, float chi2ndof, float t0err, float tdrifterr) { - m_t0ML1 = t0; - m_tdriftML1 = tdrift; - m_chi2ndofML1 = chi2ndof; - m_t0errML1 = t0err; - m_tdrifterrML1 = tdrifterr; -} - -void MdtDqaDb::SetML2(float t0, float tdrift, float chi2ndof, float t0err, float tdrifterr) { - m_t0ML2 = t0; - m_tdriftML2 = tdrift; - m_chi2ndofML2 = chi2ndof; - m_t0errML2 = t0err; - m_tdrifterrML2 = tdrifterr; -} - -void MdtDqaDb::SetDeadML(std::vector<int> deadML) { - m_listDeadML = deadML; - m_numDeadML = m_listDeadML.size(); -} - -void MdtDqaDb::SetDeadMezz(std::vector<int> deadMezz) { - m_listDeadMezz = deadMezz; - m_numDeadMezz = m_listDeadMezz.size(); -} - -void MdtDqaDb::SetDeadTube(std::vector<int> deadTube) { - m_listDeadTube = deadTube; - m_numDeadTube = m_listDeadTube.size(); -} - -void MdtDqaDb::SetNoisyMezz(std::vector<std::pair<int,float> > noisyMezz) { - m_listNoisyMezz = noisyMezz; - m_numNoisyMezz = m_listNoisyMezz.size(); -} - -void MdtDqaDb::SetNoisyTube(std::vector<std::pair<int, float> > noisyTube) { - m_listNoisyTube = noisyTube; - m_numNoisyTube = m_listNoisyTube.size(); -} - -//Get methods -std::string MdtDqaDb::getChamberName() { return m_chamberName; } - -int MdtDqaDb::getTimeFlag() { - if(m_timeFlag == -1) { //calculate m_timeFlag if needed - int timeFlag = 0 ; - // HERE the LIMITS are ...CARVED OUT OF THE ROCK ! - float limit_chi2Min = 0.1 ; - float limit_chi2Max = 10. ; - float limit_tdriftMin = 600. ; - float limit_tdriftMax = 760. ; - - if (m_chi2ndofML1 < limit_chi2Min || m_chi2ndofML1 > limit_chi2Max ) timeFlag++ ; - if (m_chi2ndofML2 < limit_chi2Min || m_chi2ndofML2 > limit_chi2Max ) timeFlag++ ; - if (m_tdriftML1 < limit_tdriftMin || m_tdriftML1 > limit_tdriftMax ) timeFlag++ ; // HERE also the error should be taken into account - if (m_tdriftML2 < limit_tdriftMin || m_tdriftML2 > limit_tdriftMax ) timeFlag++ ; // HERE also the error should be taken into account - - m_timeFlag = timeFlag ; - } - return m_timeFlag; -} //end MdtDqaDb::getTimeFlag - -int MdtDqaDb::getDeadFlag() { - if(m_deadFlag == -1) { - int deadFlag = 0 ; - // HERE the LIMITS are ...CARVED OUT OF THE ROCK ! - if ( m_numDeadML > 0 || m_numDeadMezz > 0 || m_numDeadTube > 0 ) deadFlag = 1 ; - - m_deadFlag = deadFlag ; - } - return m_deadFlag ; -} - -int MdtDqaDb::getNumDeadML() { return m_numDeadML; } -int MdtDqaDb::getNumDeadMezz() { return m_numDeadMezz; } -int MdtDqaDb::getNumDeadTube() { return m_numDeadTube; } -int MdtDqaDb::getNumNoisyMezz() { return m_numNoisyMezz; } -int MdtDqaDb::getNumNoisyTube() { return m_numNoisyTube; } -float MdtDqaDb::getT0ML1() { return m_t0ML1; } -float MdtDqaDb::getT0ML2() { return m_t0ML2; } -float MdtDqaDb::getTdriftML1() { return m_tdriftML1; } -float MdtDqaDb::getTdriftML2() { return m_tdriftML2; } -float MdtDqaDb::getChi2ndofML1() { return m_chi2ndofML1; } -float MdtDqaDb::getChi2ndofML2() { return m_chi2ndofML2; } -float MdtDqaDb::getT0errML1() { return m_t0errML1; } -float MdtDqaDb::getT0errML2() { return m_t0errML2; } -float MdtDqaDb::getTdrifterrML1() { return m_tdrifterrML1; } -float MdtDqaDb::getTdrifterrML2() { return m_tdrifterrML2; } -std::vector<int> MdtDqaDb::getDeadML() { return m_listDeadML; } -std::vector<int> MdtDqaDb::getDeadMezz() { return m_listDeadMezz; } -std::vector<int> MdtDqaDb::getDeadTube() { return m_listDeadTube; } -std::vector<std::pair<int,float> > MdtDqaDb::getNoisyMezz() { return m_listNoisyMezz; } -std::vector<std::pair<int,float> > MdtDqaDb::getNoisyTube() { return m_listNoisyTube; } - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaGlobalTimeFit.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaGlobalTimeFit.cxx deleted file mode 100644 index d8af9658827956c1ecd1cac94e87fb7cf9d1dace..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaGlobalTimeFit.cxx +++ /dev/null @@ -1,482 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -// standard C++ // -#include <iostream> -#include <fstream> -#include <string> -#include <vector> -#include <cstdlib> - -// MuonReadoutGeometry // -#include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "MuonReadoutGeometry/MdtReadoutElement.h" - -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MdtCalibInterfaces/IMdtSegmentFitter.h" - -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h" -#include "MuonCalibStandAloneExtraTools/PhiEtaUtils.h" - -// MuonCalib // -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" - -// Rt stuff ------ -#include "MdtCalibData/IRtRelation.h" -#include "MdtCalibUtils/GlobalTimeFitter.h" - -#include "MdtCalibData/RtRelationLookUp.h" -#include "MdtCalibData/RtFullInfo.h" -#include "MdtCalibData/MdtCalibrationFactory.h" - -#include "MdtCalibFitters/LocalSegmentResolver.h" -#include "MdtCalibFitters/DCSLFitter.h" - -//this -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//root -#include "TFile.h" -#include "TH1.h" -#include "TNtuple.h" -#include "TString.h" -#include "TDirectory.h" -#include "TMath.h" // for TMath::Prob() - -//:::::::::::::::::::::::: -//:: NAMESPACE SETTINGS :: -//:::::::::::::::::::::::: - -namespace MuonCalib { - -//***************************************************************************** - -MdtDqaGlobalTimeFit::MdtDqaGlobalTimeFit(int nbHitsMin, int nbHitsMax, float chi2cut, int BfieldON, bool debug) : - m_detMgr(nullptr), - m_id_tool(nullptr), - p_reg_sel_svc(nullptr), - m_histoManager(nullptr), - m_rtRel(nullptr), - m_muFitter(nullptr), - m_GTFitter(nullptr) -{ - m_minNumHits = nbHitsMin; - m_maxNumHits = nbHitsMax; - m_chi2_cut = chi2cut; - m_BfieldON = BfieldON; - m_debug = debug; -} - -//::::::::::::::::: -//:: METHOD init :: -//::::::::::::::::: - -StatusCode MdtDqaGlobalTimeFit::initialize(const MuonGM::MuonDetectorManager *detMgr, - const MuonCalib::IIdToFixedIdTool *id_tool, RegionSelectionSvc *reg_sel_svc, - HistogramManager *histoManager) { - - m_detMgr = detMgr; - m_id_tool = id_tool; - p_reg_sel_svc = reg_sel_svc; - m_histoManager = histoManager; - - m_muFitter = new DCSLFitter(); - - m_rtRel = getDefaultRtRelation(m_BfieldON); - m_GTFitter = new GlobalTimeFitter(m_muFitter, m_rtRel); - - return StatusCode::SUCCESS; -} //end MdtDqaGlobalTimeFit::initialize - -//***************************************************************************** - - //:::::::::::::::::::::::: - //:: METHOD handleEvent :: - //:::::::::::::::::::::::: - -StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, - int /*eventnumber*/, - const std::vector<MuonCalibSegment *> &segments, - unsigned int position) { - - if (segments.size()<=position) return StatusCode::SUCCESS; - for (unsigned int k=position; k<segments.size(); k++) { // LOOP OVER SEGMENTS - - MuonCalibSegment segment(*segments[k]); - - //---------------// - //-- Variables --// - //---------------// - - int nhits = (int) segment.mdtHitsOnTrack(); - bool REFIT_GTFIT = true; // THIS SHOULD BE PASSED VIA JOBOPTIONS !!!!!!!!!!!!! - // station identifiers // - - MuonFixedId Mid((segment.mdtHOT()[0])->identify()); - - //this has to be set in order to get the m_detMgr->getMdtReadoutElement() method working correctly - //otherwise also for the first multilayer, the second is returned - Mid.setMdtMultilayer(1); - - //----------// - //-- Hits --// - //----------// - - if(nhits<m_minNumHits || nhits>m_maxNumHits) continue; - - // - // Get REGION and STATION of the segment : - // - // and access to MdtDqa histograms - // - // TFile * mdtDqaRoot = m_histoManager->rootFile(); - ToString ts; - int stationNameId = Mid.stationName(); - int phi = Mid.phi(); - int eta = Mid.eta(); - int absEta = eta; - if (eta<0) absEta=-eta; - std::string stationNameStr = Mid.stationNameString(); - - // - // HERE WE LIMIT THE ANALYSIS TO BM(L,S) and EM(L,S) CHAMBERS : - // - if ( !(stationNameStr.substr(0,2)=="BM" || stationNameStr.substr(0,2)=="EM") ) continue; - - std::string region = "Barrel"; - if ( stationNameStr.substr(0,1) == "E" ) region = "Endcap"; - std::string side = "A"; - if (eta<0) side = "C"; - - PhiEtaNameConverter phiEtaConverter; - std::string chamberType = stationNameStr; - - std::string fullStationName = chamberType+"_"+ts(phi)+"_"+ts(eta); - - int sector = phiEtaConverter.phi_8to16(stationNameId,phi); - - TH1F *h1; - TH2F *h2; - - float toffset(999.); - if ( REFIT_GTFIT ) toffset =m_GTFitter->GTFit(&segment); - - float SegChi2DoF = segment.chi2(); - int DoF = segment.mdtHitsOnTrack() - 2; - if ( REFIT_GTFIT ) DoF = DoF-1; - float SegChi2 = SegChi2DoF*((float)DoF); - - - if (SegChi2DoF<=m_chi2_cut){ // chi2DoF cut - // get MDT coordinates from first hit - // (this can be changed in future by averaging over the hit for example) - - // TRY THE FOLLOWING - float distRO = (segment.mdtHOT()[0])->distanceToReadout(); // along the tube - float tube = (float) ((segment.mdtHOT()[0])->identify()).mdtTube(); - - // FILLING Histograms - // - std::string histoType; - - std::string station = "undefined"; - if ( region == "Barrel" )station = "BM"; - if ( region == "Endcap" )station = "EM"; - - histoType="TrigTime_"+station+"_eta_"+ts(absEta); - h1 = (TH1F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - if (h1) { - h1->Fill(toffset); - } - - histoType="TrigTimeVsROdistance_"+station+"_eta_"+ts(absEta); - - h2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - if (h2) h2->Fill(distRO,toffset); - - histoType="TriggerCoverage_"+station+"_eta_"+ts(absEta); - h2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - if (h2) h2->Fill(distRO,tube); - - histoType="Segment_chi2"; - h2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - if (h2) h2->Fill(SegChi2DoF,absEta); - - histoType="Segment_ProbChi2"; - h1 = (TH1F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - if (h1) h1->Fill(TMath::Prob(SegChi2,DoF)); - - histoType="HitsOnSegment"; - h2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - if (h2) h2->Fill(segment.mdtHitsOnTrack(),absEta); - - histoType="HitRadius"; - h1 = (TH1F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - for (std::vector<MdtCalibHitBase*>::iterator it =segment.mdtHOTBegin(); - it!=segment.mdtHOTEnd();++it) { - - float radius=(*it)->driftRadius(); - - if ((*it)->signedDistanceToTrack()<0.) radius=-radius; - if (h1) h1->Fill(radius); - } - - histoType="Residuals"; - h2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - for (std::vector<MdtCalibHitBase*>::iterator it =segment.mdtHOTBegin(); - it!=segment.mdtHOTEnd();++it) { - float resid=(*it)->radialResidual(); - if (h2) h2->Fill(resid,absEta); - } - - histoType="ResidualsVsRadius"; - h2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - for (std::vector<MdtCalibHitBase*>::iterator it =segment.mdtHOTBegin(); - it!=segment.mdtHOTEnd();++it) { - float resid=(*it)->radialResidual(); - float radius=(*it)->driftRadius(); - if ((*it)->signedDistanceToTrack()<0.) radius=-radius; - if (h2) h2->Fill(radius,resid); - } - - } // End if over chi2DoF - } // end LOOP OVER SEGMENTS - - return StatusCode::SUCCESS; -} //end MdtDqaGlobalTimeFit::handleEvent - -//***************************************************************************** - - //:::::::::::::::::::::::::::: - //:: METHOD analyseSegments :: - //:::::::::::::::::::::::::::: -StatusCode MdtDqaGlobalTimeFit::analyseSegments(const std::vector<MuonCalibSegment *> & /*segments*/) { - return StatusCode::SUCCESS; -} - -IRtRelation *MdtDqaGlobalTimeFit::getDefaultRtRelation(int BfieldON ) { - MuonCalib::CalibFunc::ParVec rtPars; - rtPars.push_back( -50. ); // t_Start - rtPars.push_back( 8. ); // t_binSize - - // B field is OFF : - if ( BfieldON == 0) { - rtPars.push_back(0.2); // r(-50) - rtPars.push_back(0.2); // r(-50+8) - rtPars.push_back(0.2); // ... - rtPars.push_back(0.25); - rtPars.push_back(0.294403); - rtPars.push_back(0.311703); - rtPars.push_back(0.485873); - rtPars.push_back(0.804235); - rtPars.push_back(1.19624); - rtPars.push_back(1.5562); - rtPars.push_back(1.91466); - rtPars.push_back(2.3147); - rtPars.push_back(2.66996); - rtPars.push_back(3.05436); - rtPars.push_back(3.40371); - rtPars.push_back(3.80574); - rtPars.push_back(4.13506); - rtPars.push_back(4.45473); - rtPars.push_back(4.77338); - rtPars.push_back(5.05294); - rtPars.push_back(5.33755); - rtPars.push_back(5.58459); - rtPars.push_back(5.8718); - rtPars.push_back(6.09389); - rtPars.push_back(6.37129); - rtPars.push_back(6.56824); - rtPars.push_back(6.73359); - rtPars.push_back(6.96923); - rtPars.push_back(7.16944); - rtPars.push_back(7.38872); - rtPars.push_back(7.55627); - rtPars.push_back(7.73885); - rtPars.push_back(7.86403); - rtPars.push_back(8.07223); - rtPars.push_back(8.26818); - rtPars.push_back(8.39531); - rtPars.push_back(8.54069); - rtPars.push_back(8.69377); - rtPars.push_back(8.86487); - rtPars.push_back(9.01724); - rtPars.push_back(9.16516); - rtPars.push_back(9.24791); - rtPars.push_back(9.45596); - rtPars.push_back(9.56237); - rtPars.push_back(9.69553); - rtPars.push_back(9.80647); - rtPars.push_back(9.9432); - rtPars.push_back(10.039); - rtPars.push_back(10.207); - rtPars.push_back(10.2884); - rtPars.push_back(10.3977); - rtPars.push_back(10.6045); - rtPars.push_back(10.6181); - rtPars.push_back(10.7883); - rtPars.push_back(10.9057); - rtPars.push_back(10.9908); - rtPars.push_back(11.1615); - rtPars.push_back(11.2359); - rtPars.push_back(11.3409); - rtPars.push_back(11.4451); - rtPars.push_back(11.5412); - rtPars.push_back(11.6896); - rtPars.push_back(11.7487); - rtPars.push_back(11.8853); - rtPars.push_back(11.9571); - rtPars.push_back(12.0381); - rtPars.push_back(12.1739); - rtPars.push_back(12.2601); - rtPars.push_back(12.3892); - rtPars.push_back(12.4406); - rtPars.push_back(12.5809); - rtPars.push_back(12.6297); - rtPars.push_back(12.7495); - rtPars.push_back(12.8314); - rtPars.push_back(12.9463); - rtPars.push_back(13.0487); - rtPars.push_back(13.1337); - rtPars.push_back(13.2417); - rtPars.push_back(13.2706); - rtPars.push_back(13.3917); - rtPars.push_back(13.5107); - rtPars.push_back(13.60); - rtPars.push_back(13.69); - rtPars.push_back(13.71); - rtPars.push_back(13.8088); - rtPars.push_back(13.8577); - rtPars.push_back(14.0212); - rtPars.push_back(14.0671); - rtPars.push_back(14.1225); - rtPars.push_back(14.2112); - rtPars.push_back(14.3113); - rtPars.push_back(14.3747); - rtPars.push_back(14.3531); - rtPars.push_back(14.4799); - rtPars.push_back(14.458); - rtPars.push_back(14.516); - rtPars.push_back(14.8312); - rtPars.push_back(14.85); - rtPars.push_back(14.86); - rtPars.push_back(14.87); - - } - // B field is ON : - if ( BfieldON == 1) { - rtPars.push_back(0.2); - rtPars.push_back(0.2); - rtPars.push_back(0.2); - rtPars.push_back(0.22); - rtPars.push_back(0.27); - rtPars.push_back(0.33); - rtPars.push_back(0.37); - rtPars.push_back(0.460902); - rtPars.push_back(0.805728); - rtPars.push_back(1.10767); - rtPars.push_back(1.53996); - rtPars.push_back(1.9101); - rtPars.push_back(2.36668); - rtPars.push_back(2.71068); - rtPars.push_back(3.06689); - rtPars.push_back(3.41867); - rtPars.push_back(3.78364); - rtPars.push_back(4.11741); - rtPars.push_back(4.41084); - rtPars.push_back(4.73491); - rtPars.push_back(5.02635); - rtPars.push_back(5.24373); - rtPars.push_back(5.5519); - rtPars.push_back(5.80729); - rtPars.push_back(5.98834); - rtPars.push_back(6.26835); - rtPars.push_back(6.42993); - rtPars.push_back(6.62648); - rtPars.push_back(6.85403); - rtPars.push_back(6.99663); - rtPars.push_back(7.21787); - rtPars.push_back(7.32455); - rtPars.push_back(7.64958); - rtPars.push_back(7.73685); - rtPars.push_back(7.90371); - rtPars.push_back(8.0533); - rtPars.push_back(8.18414); - rtPars.push_back(8.44938); - rtPars.push_back(8.60877); - rtPars.push_back(8.65394); - rtPars.push_back(8.84461); - rtPars.push_back(8.95214); - rtPars.push_back(9.14024); - rtPars.push_back(9.24901); - rtPars.push_back(9.37823); - rtPars.push_back(9.5724); - rtPars.push_back(9.60793); - rtPars.push_back(9.74432); - rtPars.push_back(9.89992); - rtPars.push_back(10.0009); - rtPars.push_back(10.1321); - rtPars.push_back(10.187); - rtPars.push_back(10.3244); - rtPars.push_back(10.4858); - rtPars.push_back(10.6038); - rtPars.push_back(10.7109); - rtPars.push_back(10.8385); - rtPars.push_back(10.8563); - rtPars.push_back(10.977); - rtPars.push_back(11.0865); - rtPars.push_back(11.2767); - rtPars.push_back(11.3279); - rtPars.push_back(11.4734); - rtPars.push_back(11.5325); - rtPars.push_back(11.6352); - rtPars.push_back(11.793); - rtPars.push_back(11.8545); - rtPars.push_back(11.9321); - rtPars.push_back(12.0367); - rtPars.push_back(12.091); - rtPars.push_back(12.1884); - rtPars.push_back(12.3246); - rtPars.push_back(12.3793); - rtPars.push_back(12.5348); - rtPars.push_back(12.6328); - rtPars.push_back(12.7038); - rtPars.push_back(12.7699); - rtPars.push_back(12.9211); - rtPars.push_back(12.9866); - rtPars.push_back(13.0501); - rtPars.push_back(13.1832); - rtPars.push_back(13.2441); - rtPars.push_back(13.2971); - rtPars.push_back(13.4107); - rtPars.push_back(13.562); - rtPars.push_back(13.5098); - rtPars.push_back(13.6794); - rtPars.push_back(13.7281); - rtPars.push_back(13.8953); - rtPars.push_back(13.9238); - rtPars.push_back(14.0338); - rtPars.push_back(14.0898); - rtPars.push_back(14.1931); - rtPars.push_back(14.2 ); - rtPars.push_back(14.4053); - rtPars.push_back(14.41 ); - rtPars.push_back(14.4481); - rtPars.push_back(14.4606); - rtPars.push_back(14.49); - rtPars.push_back(14.5283); - } - - IRtRelation *rt = MuonCalib::MdtCalibrationFactory::createRtRelation( "RtRelationLookUp", rtPars ); - - return rt; -} //end MdtDqaGlobalTimeFit::getDefaultRtRelation - -} // namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaNtupleAnalysis.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaNtupleAnalysis.cxx deleted file mode 100644 index 52ca5b25428f4fde34e81f3dfb0fbdb806c595e2..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaNtupleAnalysis.cxx +++ /dev/null @@ -1,1018 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibStandAloneExtraTools/MdtDqaNtupleAnalysis.h" - -#include "MuonCalibStandAloneExtraTools/PhiEtaUtils.h" -#include "MuonCalibStandAloneExtraTools/MDTName.h" - -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneExtraTools/MDTDeadElementsAnalysis.h" -#include "MuonCalibStandAloneExtraTools/MDTDqaDeadElements.h" -#include "MuonCalibStandAloneExtraTools/TimeAndAdcFitter.h" - -//CalibNtupleAnalysis container classes -#include "CalibNtupleUtils/TimedSegment.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibTruthCollection.h" -#include "MuonCalibEventBase/MuonCalibTruth.h" -#include "MuonCalibEventBase/MuonCalibMdtTruthHit.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" - -//MuonCalib container classes -#include "MuonCalibEventBase/MuonCalibPattern.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" - -#include "TKey.h" -#include "TF1.h" -#include "TH1F.h" -#include "TH2F.h" - -namespace MuonCalib { - -//==================================================================================== -MdtDqaNtupleAnalysis::MdtDqaNtupleAnalysis(bool verbose, std::string outputFileName) : - m_histoManager(NULL), m_DeadElementsAlgorithm(-1), m_SectorMin(-1), m_SectorMax(-1), - m_analyseBarrel(false), m_analyseEndcapA(false), m_analyseEndcapC(false), m_ADCCUT(-1.) { - m_verbose = verbose ; - m_outputFileName = outputFileName ; - p_reg_sel_svc = NULL ; -} - -//==================================================================================== -StatusCode MdtDqaNtupleAnalysis::initialize(RegionSelectionSvc *reg_sel_svc, HistogramManager *histoManager, int DeadElementsAlgorithm, float ADCCUT) { - p_reg_sel_svc = reg_sel_svc; - m_histoManager = histoManager; - m_DeadElementsAlgorithm = DeadElementsAlgorithm; - m_ADCCUT=ADCCUT; - - PhiEtaNameConverter phiEtaConverter; - std::string testName="BIL1A01"; - MDTName NameConverter(testName); - m_SectorMin = 20; - m_SectorMax = 0; - const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions(); - std::vector<MuonCalib::NtupleStationId>::const_iterator itstation; - for (itstation = stationsInRegion.begin(); itstation!=stationsInRegion.end(); itstation++) { - int stationNameId = itstation->GetStation(); - int phi = itstation->GetPhi(); - int sector = phiEtaConverter.phi_8to16(stationNameId,phi); - if(sector>m_SectorMax) m_SectorMax = sector; - if(sector<m_SectorMin) m_SectorMin = sector; - } - - m_evtCounter=0; - - return StatusCode::SUCCESS; -} - -//==================================================================================== -void MdtDqaNtupleAnalysis::handleEvent( const MuonCalibEvent& event, int /*eventnumber*/, -const std::vector<MuonCalibSegment *> &/*segments*/,unsigned int /*position*/){ - - std::string histoType; - - TFile *mdtDqaRoot = m_histoManager->rootFile(); - - float ADCCUT=m_ADCCUT; - - if( !p_reg_sel_svc){ - return; - } - - ToString ts; - PhiEtaNameConverter phiEtaConverter; - - //Event counting - m_evtCounter++; - - // Some checks. ..... ----------------------- - int minNumberHits = 0; - int maxNumberHits = 1000000; - int minEventCounter = 0; - int maxEventCounter = 10000000; - - const MuonCalibRawHitCollection* rawColl = event.rawHitCollection(); - - // SELECT RANGE IN EVENT COUNTER !!!!!! - if( m_evtCounter<minEventCounter || m_evtCounter>maxEventCounter ) return; - - if( rawColl->numberOfMuonCalibRawMdtHits() + event.numberOfHits() > maxNumberHits) return; - if( rawColl->numberOfMuonCalibRawMdtHits() + event.numberOfHits() < minNumberHits) return; - //------------------------------------------------------------------------------ - - MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit rmdt_hit_it = rawColl->rawMdtHitCollectionBegin(); - MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit rmdt_hit_it_end = rawColl->rawMdtHitCollectionEnd(); - - //===== RAW HITS LOOP =========================================================== - - const int nStations=36; - const int nEta=8; - const int nSectors=16; - const int nSides=2; - int chamberMulti[nSides][nSectors][nStations][nEta]; - int chamberMultiAdcCut[nSides][nSectors][nStations][nEta]; - - for(int iside=0;iside<nSides;iside++){ - for(int isec=0;isec<nSectors;isec++){ - for(int istation=0;istation<nStations;istation++){ - for(int ieta=0;ieta<nEta;ieta++){ - chamberMulti[iside][isec][istation][ieta]=0; - chamberMultiAdcCut[iside][isec][istation][ieta]=0; - }}}} - - // === RAW HITS LOOP START ======================================================= - for(; rmdt_hit_it!=rmdt_hit_it_end; ++rmdt_hit_it){ - - if (p_reg_sel_svc->isInRegion((*rmdt_hit_it)->identify())) { - - MuonFixedId id = (*rmdt_hit_it)->identify(); - - MDTName chamb(id); - - int rawCharge = (*rmdt_hit_it)->adcCount(); - int rawTime = (*rmdt_hit_it)->tdcCount(); - - int rstn=id.stationName(); - int rphi2=chamb.getOnlineSector(); - - double localPos_y = (*rmdt_hit_it)->localPosition().y(); - double localPos_z = (*rmdt_hit_it)->localPosition().z(); - - bool doSector=false; - if(rphi2>= m_SectorMin && rphi2<=m_SectorMax) doSector=true; - if(!doSector) continue; - - std::string region = chamb.getRegion(); - // THE FOLLOWING ASSIGNMENT TO Endcap Chambers can change if, - // for example, BEE or BIS7,8 chambers have to be assigned to Endcap - - std::string stn = id.stationNumberToFixedStationString(rstn); - std::string side=chamb.getSide(); - int rside = 1; - if(chamb.isBackward()) rside=-1; - - std::string phisec; - if(rphi2<10) phisec = "0"+ts(rphi2); - if(rphi2>=10) phisec = ts(rphi2); - - int absEta=chamb.getOnlineEta(); - //format BIL5A03 - std::string chamberName = chamb.getOnlineName(); - - //-- Multiplicity - int iside = 1; - if(chamb.isBackward()) iside=0; - chamberMulti[iside][rphi2-1][rstn-1][absEta-1]++; //Controllare!!!! - if(rawCharge > ADCCUT) chamberMultiAdcCut[iside][rphi2-1][rstn-1][absEta-1]++; - - //---------------------- - int tubestot; - int tubesPerLayer; - int imezz = 0; - int tubeOffset[2]; - tubeOffset[0]=m_histoManager->GetTubeOffsetML1(chamberName) ; - tubeOffset[1]=0; - - int itubeLong=0; - - int nLayersPerML=3; - if(stn.substr(0,2)=="BI" || stn.substr(0,2)=="EI" || stn.substr(0,3)=="BEE") { // CHECK THIS FURTHER !!!!!!!!! - nLayersPerML=4; - } - - int nLayers=nLayersPerML*2; - - if(stn.substr(0,3)=="BIS" && absEta==8) { - nLayersPerML=3; - nLayers=nLayersPerML; - } - - if(stn.substr(0,3)=="BEE") nLayers=nLayersPerML; - - // hit tube : - int tube = id.mdtTube(); - int layer = id.mdtTubeLayer(); - int Mlayer= id.mdtMultilayer(); - if (Mlayer==1) tube = tube+tubeOffset[0]; // this conver OFFLINE to ONLINE tube numbering - if (Mlayer==2) tube = tube+tubeOffset[1]; // this conver OFFLINE to ONLINE tube numbering - - TH1F *h; - TH2F *h2; - - // Chamber Hit occupancy - histoType = "a_ChamberHitOccupancy"; - h2 = (TH2F*) m_histoManager->GetMdtHisto(histoType,chamb); - if (h2 && rawCharge > ADCCUT) { - float layMl = layer + (Mlayer-1)*6; - h2->Fill( (float)tube, layMl ); - } - - std::string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb); - std::string expertDirName = chamberDirName+"/Expert"; - TDirectory *expertRootDir = mdtDqaRoot->GetDirectory(expertDirName.c_str()); - - expertRootDir->cd(); - - // moved to Expert folder by Dani 01.03.2010 - histoType = "ChamberYZOccupancy"; - h2 = (TH2F*) expertRootDir->FindObjectAny(histoType.c_str()); - if (h2 && rawCharge > ADCCUT) { - h2->Fill( (float)localPos_y, (float)localPos_z ); - } - - // Hits per tube - histoType = "a_HitsPerTube"; - h = (TH1F*) m_histoManager->GetMdtHisto(histoType,chamb); - if (h) { - tubestot=h->GetNbinsX(); - tubesPerLayer=tubestot/nLayers; - imezz=(id.mdtMezzanine())%100; - itubeLong=tube+tubesPerLayer*(layer-1)+tubesPerLayer*nLayersPerML*(Mlayer-1); - h->Fill( itubeLong*1. ); - } - histoType = "a_HitsPerTubeAdcCut"; - h = (TH1F*) m_histoManager->GetMdtHisto(histoType,chamb); - if( (*rmdt_hit_it)->adcCount() > ADCCUT){ - if (h) h->Fill( itubeLong*1. ); - } - - //Hits per tube ML 1,2 - histoType = "HitsPerTube_ML"+ts(Mlayer)+"_L"+ts(layer); - h = (TH1F*) m_histoManager->GetMdtHisto(histoType,chamb); - if(rawCharge > ADCCUT){ - if(h) h->Fill( tube*1.); - } - - //tdc ML 1,2 - histoType = "A_TDC_ML"+ts(Mlayer); - h = (TH1F*) m_histoManager->GetMdtHisto(histoType,chamb); - if(h && rawCharge > ADCCUT) h->Fill( rawTime ); - - //adc ML 1,2 - histoType = "C_ADC_ML"+ts(Mlayer); - h = (TH1F*) m_histoManager->GetMdtHisto(histoType,chamb); - if(h) h->Fill( rawCharge ); - - //tdc vs adc mezz - histoType = "tdc_Vs_adc_mezz_"+ts(imezz); - if(imezz<20) { - h2 = (TH2F*) m_histoManager->GetMdtHisto(histoType,chamb); - if(h2) h2->Fill( rawCharge, rawTime ); - } - - // OVERVIEW - // region Overview plot - std::string stationLayer = "UNDEFINED"; - if(chamb.isInner()) stationLayer = "Inner"; - if(chamb.isMiddle()) stationLayer = "Middle"; - if(chamb.isOuter()) stationLayer = "Outer"; - if(chamb.isExtra()) stationLayer = "extra"; //for now, extra station stored in middle station histogram - - std::string title2=""; - if(region=="Barrel") title2+="B"; - else title2+="E"; - - title2+=side; - title2+="_"; - - histoType = "A_HitsPerML_"+stationLayer; - h2 = (TH2F*) m_histoManager->GetMdtHisto(histoType,region,side); - float xbin = absEta; - if (stn == "BIM" ) xbin=absEta+6; - if (stn == "EEL") xbin=absEta+2; - if (stn == "EES") xbin=absEta+2; - if(h2 && rawCharge > ADCCUT) h2->Fill( xbin , rphi2 + 0.25*(2*Mlayer-3) ); - - // GLOBAL plot --- All Chambers together - if(region=="Barrel") histoType = "Global_HitsPerML_Barrel"; - if(region=="Endcap") histoType = "Global_HitsPerML_Endcap"; - h2 = (TH2F*) m_histoManager->GetHisto("GLOBAL",histoType); - float shiftGlobalEta(0); - if(stationLayer=="Inner") shiftGlobalEta = 0; - if(stationLayer=="Middle") shiftGlobalEta = 14; - if(stationLayer=="Outer") shiftGlobalEta = 24; - if(stationLayer=="extra") shiftGlobalEta = 34; - float xbinGlobal = (xbin+shiftGlobalEta)*rside; - if(h2 && rawCharge > ADCCUT) h2->Fill( xbinGlobal , rphi2 + 0.25*(2*Mlayer-3) ); - - // GLOBAL plot --- Chambers divided in Inner,Middle,Outer stations (extra goes with Middle) - histoType = "Global_HitsPerML_"+stationLayer; - if(stationLayer=="extra") histoType = "Global_HitsPerML_Middle"; - h2 = (TH2F*) m_histoManager->GetHisto("GLOBAL",histoType); - xbinGlobal = xbin*rside; - if (stn.substr(0,1)=="E") xbinGlobal = rside*(absEta+14); - if (chamb.getName()=="BEE") xbinGlobal= rside*(absEta+8); - if (chamb.getName()=="EEL") xbinGlobal= rside*(absEta+11); - if (chamb.getName()=="EES") xbinGlobal= rside*(absEta+11); - - if(h2 && rawCharge > ADCCUT) h2->Fill( xbinGlobal , rphi2 + 0.25*(2*Mlayer-3) ); - - histoType = "HitsPerML_"+stationLayer; - h = (TH1F*) m_histoManager->GetMdtHisto(histoType,region,side,rphi2); - if(h && rawCharge > ADCCUT) h->Fill( absEta + 0.1*(2*Mlayer-3) ); - - histoType = "TDC_AllChambers_"+stationLayer; - h = (TH1F*) m_histoManager->GetMdtHisto(histoType,region,side,rphi2); - if(h && rawCharge > ADCCUT) h->Fill( rawTime ); - - histoType = "z_HitsVsMezzanine"; - h2 = (TH2F*) m_histoManager->GetMdtHisto(histoType,region,side,rphi2); - if( h2 && rawCharge > ADCCUT) h2->Fill(chamberName.c_str(),imezz,1); - - } // p_reg -> hit IsInRegion - }//for - - //---- Fill Multiplicity --------- - TH1F *hmulti; - - std::string side="C"; - std::string region = "Barrel"; - - for (int nregions=0;nregions<2;nregions++) { - if (nregions==1) region = "Endcap"; - for (int iside=0;iside<nSides;iside++){ - if (iside==1) side="A"; - for (int isec=0;isec<nSectors;isec++){ - float sectorMulti = 0; - float sectorMultiAdcCut = 0; - for (int istation=0;istation<nStations;istation++){ - // THE FOLLOWING ASSIGNMENT TO Endcap Chambers can change if, - // for example, BEE or BIS7,8 chambers have to be assigned to Endcap - if ( nregions==0 && istation+1 > 13 ) continue; // the loop was on the barrel - if ( nregions==1 && istation+1 <= 13 ) continue; // the loop was on the endcap - - for (int ieta=0;ieta<nEta;ieta++){ - sectorMulti += chamberMulti[iside][isec][istation][ieta]; - sectorMultiAdcCut += chamberMultiAdcCut[iside][isec][istation][ieta]; - - double multi = chamberMulti[iside][isec][istation][ieta]; - double multiAdcCut = chamberMultiAdcCut[iside][isec][istation][ieta]; - - if (multi !=0 ){ - MuonFixedId id; - std::string stn=id.stationNumberToFixedStationString(istation+1); - - MDTName chamb_mult(stn,ieta+1,side,isec+1); - - histoType="B_ChamberHitMultiplicity"; - hmulti = (TH1F*) m_histoManager->GetMdtHisto(histoType,chamb_mult); - if(hmulti) hmulti->Fill(multiAdcCut); - - }// if multi!=0 - }// loop on eta - }//loop on chamber - }//sector - }//side - }//regions - - -} //end MdtDqaNtupleAnalysis::handleEvent - -void MdtDqaNtupleAnalysis::histogramAnalysis(TFile *f) { - - bool WriteMdtDqaDbToTextFile = false; - - ToString ts; - - if(f->IsZombie()) return; - - bool doDeadElementsAnalysis = true; - bool doTubeEfficiency = true; - bool doTDCADCfitting = true; - bool doResidualsFit = true; - - if (doDeadElementsAnalysis) { - if(m_DeadElementsAlgorithm==0) { - MDTDeadElementsAnalysis *mdtTubeAna = new MDTDeadElementsAnalysis(); - mdtTubeAna->setNoVerbose(); - mdtTubeAna->WriteAsciFile(); - mdtTubeAna->histogramScanCalibCenters(f); - delete mdtTubeAna; mdtTubeAna=0; - } else { - MDTDqaDeadElements *mdtTubeAna = new MDTDqaDeadElements(); - mdtTubeAna->setVerbose(false); - mdtTubeAna->setWriteReport(false); // this is for debug - mdtTubeAna->setWriteCompactReport(true); - mdtTubeAna->setWriteListOfDeadTubes(false); - mdtTubeAna->setDoNoisy(false); - mdtTubeAna->MDTDqaDeadElementsAnalysis(f); - delete mdtTubeAna; mdtTubeAna=0; - } - } - - if (doTubeEfficiency) { - // LOOP over chambers and apply algorithms per chamber. - std::string region; - std::string sector; - std::string chamber; - std::string regionDirName; - std::string sectorDirName; - std::string chamberDirName; - std::string deadStatusDirName; - std::string expertDirName; - std::string effiDirName; - TDirectory *RegionDir; - TDirectory *SectorDir; - TDirectory *ChamberDir; - TDirectory *DeadStatusDir; - TDirectory *ExpertDir; - TDirectory *EffiDir; - - for (int iregion=1; iregion<=4; iregion++) { - if (iregion==1) region="Barrel_A"; - if (iregion==2) region="Barrel_C"; - if (iregion==3) region="Endcap_A"; - if (iregion==4) region="Endcap_C"; - - regionDirName = "/MDT/"+region; - RegionDir = (TDirectory*)f->Get(regionDirName.c_str()); - if (!RegionDir) continue; - - // reset output histograms - TH1F *hgI = (TH1F*) RegionDir->Get("TubeEfficiency_Inner"); - TH1F *hgM = (TH1F*) RegionDir->Get("TubeEfficiency_Middle"); - TH1F *hgO = (TH1F*) RegionDir->Get("TubeEfficiency_Outer"); - - TH1F *hgE(NULL); - if(iregion>2) hgE = (TH1F*) RegionDir->Get("TubeEfficiency_extra"); - if(hgI) hgI->Reset(); - if(hgM) hgM->Reset(); - if(hgO) hgO->Reset(); - if(iregion>2 && hgE) hgE->Reset(); - - for (int isector=1; isector<=16; isector++) { - - if (isector<10) sector="0"+ts(isector); - if (isector>=10) sector=ts(isector); - sectorDirName = "/MDT/"+region+"/Sector"+sector; - - SectorDir = (TDirectory*)f->Get(sectorDirName.c_str()); - if (!SectorDir) continue; - TIter next(SectorDir->GetListOfKeys()); - TKey *key; - while ( (key = (TKey*)next()) ) { - chamber=key->GetName(); - if (chamber=="OVERVIEW") continue; - - MDTName chamb(chamber); - - chamberDirName = sectorDirName+"/"+chamber; - effiDirName = chamberDirName+"/Efficiency"; - deadStatusDirName = chamberDirName+"/DeadStatus"; - expertDirName = chamberDirName+"/Expert"; - - ChamberDir = (TDirectory*)f->Get(chamberDirName.c_str()); - EffiDir = (TDirectory*)f->Get(effiDirName.c_str()); - DeadStatusDir = (TDirectory*)f->Get(deadStatusDirName.c_str()); - ExpertDir = (TDirectory*)f->Get(expertDirName.c_str()); - - if (!ChamberDir) continue; - if (!EffiDir) { - continue; - } - if (!DeadStatusDir) { - continue; - } - if (!ExpertDir) { - continue; - } - - // - // APPLY ALGORITHMS TO chamber histograms HERE - // - std::string histoName; - - TH1F *heffiEntries; - TH1F *heffiCounts; - TH1F *heffi; - TH1F *heffiPerLy; - TH1F *hg; - - ExpertDir->cd(); - - histoName = "EfficiencyEntries"; - heffiEntries = (TH1F*) ExpertDir->Get(histoName.c_str()); - histoName = "EfficiencyCounts"; - heffiCounts = (TH1F*) ExpertDir->Get(histoName.c_str()); - - ChamberDir->cd(); - histoName = "b_EfficiencyPerTube"; - heffi = (TH1F*) ChamberDir->Get(histoName.c_str()); - - if (!heffiEntries || !heffiCounts || !heffi) { - continue; - } - - histoName = "UNDEFINED"; - if (chamb.isInner()) histoName = "TubeEfficiency_Inner"; - if (chamb.isMiddle()) histoName = "TubeEfficiency_Middle"; - if (chamb.isOuter()) histoName = "TubeEfficiency_Outer"; - if (chamb.isExtra()) histoName = "TubeEfficiency_extra"; - hg = (TH1F*) RegionDir->Get(histoName.c_str()); - if (!hg) { - continue; - } - - // reset output histograms - heffi->Reset(); - - // Now we use this strange strategy to obtain chamber layout parameters: - EffiDir->cd(); - int numberOfML=0; - int numberOfLayers=0; - int numberOfTubesPerLy[2]; - numberOfTubesPerLy[0]=0; - numberOfTubesPerLy[1]=0; - - int tubeOffset[2]; - tubeOffset[0]=m_histoManager->GetTubeOffsetML1(chamber) ; - tubeOffset[1]=0; - - int tubeOffset_atend[2]; - tubeOffset_atend[0]=m_histoManager->GetTubeOffsetAtEndML1(chamber) ; - tubeOffset_atend[1]=0; - - for (int ML=1; ML<=2; ML++) { - for (int Ly=1; Ly<=4; Ly++) { - histoName = "EffiPerTube_ML"+ts(ML)+"_L"+ts(Ly); - heffiPerLy= (TH1F*) EffiDir->FindObjectAny(histoName.c_str()); - if (heffiPerLy) { - numberOfML = ML; - numberOfLayers = Ly; - if (ML==1 && !numberOfTubesPerLy[0] ) numberOfTubesPerLy[0] = heffiPerLy->GetNbinsX(); - if (ML==2 && !numberOfTubesPerLy[1] ) numberOfTubesPerLy[1] = heffiPerLy->GetNbinsX(); - } - } - } - - ChamberDir->cd(); - - // HERE NOW COMPUTE EFFICIENCIES, ERRORS AND FILL THE HISTOGRAMS - if (heffiEntries->GetEntries() != 0 ) { - //loop over multilayers - for (int k=0; k<numberOfML; k++) { - //loop over layers - for (int l=0; l<numberOfLayers; l++) { - //loop over tubes - for (int m=0; m<numberOfTubesPerLy[k]; m++) { - int iML = k+1; - int iLy = l+1; - int iTube = m+1; - - // THE FOLLOWING HAS TO BE FIXED AFTER THE EfficiencyPerTube HISTOGRAM HAS BEEN FIXED! - // FOR NOW WE CONSIDER OFFSET AT 0 ....WHICH IS WRONG ! - iTube = iTube + tubeOffset[iML-1]; - - int ibin = (iML-1)*numberOfLayers*numberOfTubesPerLy[k]+(iLy-1)*(numberOfTubesPerLy[k]+tubeOffset[iML-1]+tubeOffset_atend[iML-1])+iTube; - //calculate efficiency and errors - - // HERE WE USE THE Efficiency definition and Error using the Bayesian Statistics: - float entries = heffiEntries->GetBinContent(ibin); - float counts = heffiCounts->GetBinContent(ibin); - float efficiency = (counts+1.)/(entries+2.); - float error = std::sqrt(efficiency*(1-efficiency))/std::sqrt(entries+3.); - - // Fill MdtDqa Histos - heffi->SetBinContent(ibin,efficiency); - heffi->SetBinError(ibin,error); - // Filling Global plots - if (hg && efficiency>0. && error >0. && entries>40) { - hg->Fill(efficiency); - } - } // loop over tube - } // loop over Layer - } // loop over ML - } - - // Now we should fill the histograms histoName = "EffiPerTube_ML"+ts(iML)+"_L"+ts(iLy); - EffiDir->cd(); - //loop over multilayers - for (int ML=1; ML<=numberOfML; ML++) { - //loop over layers - for (int Ly=1; Ly<=numberOfLayers; Ly++) { - histoName = "EffiPerTube_ML"+ts(ML)+"_L"+ts(Ly); - heffiPerLy= (TH1F*) EffiDir->FindObjectAny(histoName.c_str()); - if (!heffiPerLy) continue; - // reset output histograms - heffiPerLy->Reset(); - //loop over tubes - for (int TubeBin=1; TubeBin<=numberOfTubesPerLy[ML-1]; TubeBin++) { - - if (heffiPerLy) { - // THE FOLLOWING HAS TO BE FIXED AFTER THE EfficiencyPerTube HISTOGRAM HAS BEEN FIXED! - // FOR NOW WE CONSIDER OFFSET AT 0 ....WHICH IS WRONG ! - int Tube = TubeBin + tubeOffset[ML-1]; - - // AND ATTENTION WHEN THE EfficiencyPerTube WILL BE OK YOU MUST UNCOMMENT THE FOLLOWING LINE !!!! - int ibin = (ML-1)*numberOfLayers*numberOfTubesPerLy[ML-1]+(Ly-1)*(numberOfTubesPerLy[ML-1]+tubeOffset[ML-1]+tubeOffset_atend[ML-1])+Tube; - - // get from heffi(ibin) and put in heffiPerLy(TubeBin) - heffiPerLy->SetBinContent(TubeBin, heffi->GetBinContent(ibin)); - heffiPerLy->SetBinError(TubeBin, heffi->GetBinError(ibin)); - } - } // loop over tube - } // loop over Layer - } // loop over ML - - } // end of chambers loop - } //end of sectors loop - } //end of regions loop - - } //end if doTubeEfficiency - - // - if (doTDCADCfitting ) { - TimeAndAdcFitter *myFitter = new TimeAndAdcFitter(); - float tdc2ns = 0.78125; - - double minEntries = 1000.; - double entries(0); - - std::string histoName; - TH1F *hh; - TH1F *htpar; - TH1F *hapar; - const int nParams = 8; - double pdefault[nParams]; - pdefault[0]= 0.; - pdefault[1]= 100.; - pdefault[2]= 5.; - pdefault[3]= 100.; - pdefault[4]= 600.; - pdefault[5]= 1300.; - pdefault[6]= 10.; - pdefault[7]= 10.; - - const int nParamsAdc = 4; - double AdcpfitDefault[nParamsAdc]; - AdcpfitDefault[0]= 0.; - AdcpfitDefault[1]= 0.; - AdcpfitDefault[2]= 0.; - AdcpfitDefault[3]= 0.; - - std::string region; - std::string sector; - std::string chamber; - std::string chamberType; - std::string regionDirName; - std::string sectorDirName; - std::string chamberDirName; - TDirectory *RegionDir; - TDirectory *SectorDir; - TDirectory *ChamberDir; - - for (int iregion=1; iregion<=4; iregion++) { - if (iregion==1) region="Barrel_A"; - if (iregion==2) region="Barrel_C"; - if (iregion==3) region="Endcap_A"; - if (iregion==4) region="Endcap_C"; - - std::string Region="Barrel"; - std::string Side="A"; - if (iregion==3||iregion==4 ) Region="Endcap"; - if (iregion==2||iregion==4 ) Side="C"; - - regionDirName = "/MDT/"+region; - RegionDir = (TDirectory*)f->Get(regionDirName.c_str()); - if (!RegionDir) continue; - - for (int isector=1; isector<=16; isector++) { - if (isector<10) sector="0"+ts(isector); - if (isector>=10) sector=ts(isector); - sectorDirName = "/MDT/"+region+"/Sector"+sector; - - SectorDir = (TDirectory*)f->Get(sectorDirName.c_str()); - if (!SectorDir) continue; - - // - // APPLY ALGORITHMS TO SECTOR histograms HERE - // - int KMAX=3; - if(iregion>2) KMAX=4; - for (int k=1;k<=KMAX;k++) { - std::string stationLayer; - if (k==1) stationLayer = "Inner"; - if (k==2) stationLayer = "Middle"; - if (k==3) stationLayer = "Outer"; - if (k==4) stationLayer = "extra"; - histoName = "TDC_AllChambers_"+stationLayer; - hh = (TH1F*) m_histoManager->GetMdtHisto(histoName,Region,Side,isector); - - if (!hh) { - continue; - } - - entries = hh->GetEntries(); - if ( entries >= minEntries ) { - double *pfit = new double[nParams]; - double *errfit = new double[nParams]; - double chi2 = 0.; - int ndof = 0; - for ( int ii=0; ii<nParams; ii++ ) errfit[ii]=0.; - for ( int ii=0; ii<nParams; ii++ ) pfit[ii]=pdefault[ii]; - - myFitter->doTimeFit(hh,nParams,&pfit[0],&errfit[0],&chi2,&ndof ); - - } - } - - // - // Now go inside the SectorDir to loop over chambers - // - TIter next(SectorDir->GetListOfKeys()); - TKey *key; - while ( (key = (TKey*)next()) ) { - chamber=key->GetName(); - if (chamber=="OVERVIEW") continue; - chamberDirName = sectorDirName+"/"+chamber; - ChamberDir = (TDirectory*)f->Get(chamberDirName.c_str()); - if (!ChamberDir) continue; - ChamberDir->cd(); - chamberType = chamber.substr(0,3); - MDTName chamb(chamber); - std::string side = chamb.getSide(); - std::string stationLayer = "UNDEFINED"; - if(chamb.isInner()) stationLayer = "Inner"; - if(chamb.isMiddle()) stationLayer = "Middle"; - if(chamb.isOuter()) stationLayer = "Outer"; - if(chamb.isExtra()) stationLayer = "extra"; - std::string hnamet0Sect=regionDirName+"/t0PerSector_"+stationLayer; - std::string hnametdriftSect=regionDirName+"/tdriftPerSector_"+stationLayer; - TH2F *ht0Sect = (TH2F*) f->Get(hnamet0Sect.c_str()); - TH2F *htdriftSect = (TH2F*) f->Get(hnametdriftSect.c_str()); - - int eta_id = atoi((chamber.substr(3,1).c_str())); - // - // APPLY ALGORITHMS TO chamber histograms HERE - // - MdtDqaDb *chamberDqaDb = new MdtDqaDb(chamber); - for (int ML=1; ML<=2; ML++) { // loop over ML - // start the TDC FIT : - if (ML==1) histoName = "A_TDC_ML1"; - if (ML==2) histoName = "A_TDC_ML2"; - hh = (TH1F*) ChamberDir->Get(histoName.c_str()); - if (!hh) { - continue; - } - - entries=hh->GetEntries(); - if ( entries >= minEntries ) { - double *pfit = new double[nParams]; - double *errfit = new double[nParams]; - double chi2 = 0.; - int ndof = 0; - for ( int ii=0; ii<nParams; ii++ ) errfit[ii]=0.; - for ( int ii=0; ii<nParams; ii++ ) pfit[ii]=pdefault[ii]; - - myFitter->doTimeFit(hh,nParams,&pfit[0],&errfit[0],&chi2,&ndof ); - - float t0 = pfit[4]*tdc2ns; - float t0slope = pfit[6]*tdc2ns; - float tdrift = (pfit[5]-pfit[4])*tdc2ns; - float chi2ndof = chi2/ndof; - float t0err = errfit[4]*tdc2ns; - float tdrifterr = std::pow(errfit[4]*errfit[4] + errfit[5]*errfit[5], 0.5)*tdc2ns; - if (ML==1) chamberDqaDb->SetML1(t0,tdrift,chi2ndof,t0err,tdrifterr ); - if (ML==2) chamberDqaDb->SetML2(t0,tdrift,chi2ndof,t0err,tdrifterr ); - // here add t0 and tdrift to the Sector OVERVIEW histograms : - std::string hnamet0=sectorDirName+"/OVERVIEW/t0PerML"+chamberType; - std::string hnametdrift=sectorDirName+"/OVERVIEW/tdriftPerML"+chamberType; - if (chamberType=="BOG" || chamberType=="BOF") { - hnamet0=sectorDirName+"/OVERVIEW/t0PerMLBOGBOF"; - hnametdrift=sectorDirName+"/OVERVIEW/tdriftPerMLBOGBOF"; - } - TH1F *ht0 = (TH1F*) f->Get(hnamet0.c_str()); - TH1F *htdrift = (TH1F*) f->Get(hnametdrift.c_str()); - - if (!ht0) { - continue; - } - if (!htdrift) { - continue; - } - int ibin = eta_id*2-1; - if (ML==2) ibin = eta_id*2; - if ((chamberType=="BOG" || chamberType=="BOF") && side=="A") ibin = ibin+2; - - float MLshift = 0.; - if (ML==1) MLshift = -0.25; - if (ML==2) MLshift = 0.25; - - int truebin = ht0->FindBin(eta_id+MLshift); - - ht0->SetBinContent(truebin,t0); - ht0->SetBinError(truebin,t0err); - htdrift->SetBinContent(truebin,tdrift); - htdrift->SetBinError(truebin,tdrifterr); - - if (ht0Sect) ht0Sect->Fill(float(isector),t0); - if (htdriftSect) htdriftSect->Fill(float(isector),tdrift); - - htpar = (TH1F*) m_histoManager->GetMdtHisto("time_Fit_t0",Region,Side); - if (htpar) htpar->Fill(t0); - htpar = (TH1F*) m_histoManager->GetMdtHisto("time_Fit_tdrift",Region,Side); - if (htpar) htpar->Fill(tdrift); - htpar = (TH1F*) m_histoManager->GetMdtHisto("time_Fit_tslope",Region,Side); - if (htpar) htpar->Fill(t0slope); - htpar = (TH1F*) m_histoManager->GetMdtHisto("time_Fit_chi2",Region,Side); - if(chi2ndof > 49.) chi2ndof=49.; - if (htpar) htpar->Fill(chi2ndof); - } - - // TDC FIT DONE - - // - // start the ADC FIT - if (ML==1) histoName = "C_ADC_ML1"; - if (ML==2) histoName = "C_ADC_ML2"; - hh = (TH1F*) ChamberDir->Get(histoName.c_str()); - if (!hh) { - continue; - } - float ADCCUT= m_ADCCUT; // MUST BE SET BY JOB OPTION ! - - entries =hh->GetEntries(); - int binADCCUT = hh->GetXaxis()->FindBin(ADCCUT); - double belowADCCUT = hh->Integral(1,binADCCUT); - hapar = (TH1F*) m_histoManager->GetMdtHisto("hits_perML_belowADCCUT",Region,Side); - if (hapar && entries>0) hapar->Fill(belowADCCUT/entries); - - if ( entries >= minEntries ) { - double *Adcpfit = new double[nParamsAdc]; - double *errAdcpfit = new double[nParamsAdc]; - double chi2Adc = 0.; - int ndofAdc = 0; - for ( int ii=0; ii<nParamsAdc; ii++ ) errAdcpfit[ii]=0.; - for ( int ii=0; ii<nParamsAdc; ii++ ) Adcpfit[ii]=AdcpfitDefault[ii]; - - myFitter->doAdcFit(hh,nParamsAdc,&Adcpfit[0],&errAdcpfit[0],&chi2Adc,&ndofAdc ); - hapar = (TH1F*) m_histoManager->GetMdtHisto("adc_Fit_peak",Region,Side); - if (hapar) hapar->Fill((float)Adcpfit[1]); - hapar = (TH1F*) m_histoManager->GetMdtHisto("adc_Fit_width",Region,Side); - if (hapar) hapar->Fill((float)Adcpfit[2]); - - } - // ADC FIT DONE - } // end loop over ML - - if ( WriteMdtDqaDbToTextFile ) m_MdtDqaDbList.push_back(chamberDqaDb); - - } // endo of chambers loop - } //end of sectors loop - } //end of regions loop - - } // close if doTDCADCfitting - - if (doResidualsFit) { - // LOOP over chambers and apply algorithms per chamber. - // - std::string region; - std::string sector; - std::string chamber; - std::string regionDirName; - std::string sectorDirName; - std::string chamberDirName; - TDirectory *RegionDir; - TDirectory *SectorDir; - TDirectory *ChamberDir; - - for (int iregion=1; iregion<=4; iregion++) { - if (iregion==1) region="Barrel_A"; - if (iregion==2) region="Barrel_C"; - if (iregion==3) region="Endcap_A"; - if (iregion==4) region="Endcap_C"; - - regionDirName = "/MDT/"+region; - RegionDir = (TDirectory*)f->Get(regionDirName.c_str()); - if (!RegionDir) continue; - - // reset output histograms - TH1F *hMean = (TH1F*) RegionDir->Get("ResidualsMean"); - TH1F *hWidth = (TH1F*) RegionDir->Get("ResidualsWidth"); - if(hMean) hMean->Reset(); - if(hWidth) hWidth->Reset(); - - for (int isector=1; isector<=16; isector++) { - - if (isector<10) sector="0"+ts(isector); - if (isector>=10) sector=ts(isector); - sectorDirName = "/MDT/"+region+"/Sector"+sector; - - SectorDir = (TDirectory*)f->Get(sectorDirName.c_str()); - if (!SectorDir) continue; - TIter next(SectorDir->GetListOfKeys()); - TKey *key; - while ( (key = (TKey*)next()) ) { - chamber=key->GetName(); - if (chamber=="OVERVIEW") continue; - chamberDirName = sectorDirName+"/"+chamber; - ChamberDir = (TDirectory*)f->Get(chamberDirName.c_str()); - if (!ChamberDir) continue; - ChamberDir->cd(); - - // - // APPLY ALGORITHMS TO chamber histograms HERE - // - std::string histoName; - - TH2F *hsegResid; - - histoName = "b_SegResidVsRadius"; - hsegResid = (TH2F*) ChamberDir->Get(histoName.c_str()); - - if (!hsegResid) { - continue; - } - - // HERE make Projection and Fit Residuals with double gaussian - if (hsegResid->GetEntries() != 0 ) { - TH1D *hresidProx = hsegResid->ProjectionX("ResidProx"); - - // PREPARE LOOP OVER Radius Slices - int nbins = hresidProx->GetNbinsX(); - int binStart = 1; - int groupBins = 2; - int nsteps = (nbins-binStart)/groupBins + 1; - int bin1; - int bin2 = binStart-1; - for (int n=0; n<nsteps; n++){ - bin1 = bin2+1; - bin2 = bin1+groupBins-1; - float r1 = hresidProx->GetBinCenter(bin1); - float r2 = hresidProx->GetBinCenter(bin2); - float radius = (r1+r2)/2.; - TH1D *hres = hsegResid->ProjectionY("Residuals",bin1,bin2); - if (hres->GetEntries() < 100.) { - hres->Delete(); - continue; - } - -// FIT Constant+Gaussian : - - TF1 *func = new TF1("cgaus","pol0(0)+gaus(1)"); - double hmax = hres->GetMaximum(); - int binMax = hres->GetMaximumBin(); - double hmean = hres->GetBinCenter(binMax); - double hrms = hres->GetRMS(); - func->SetParameter(0,hmax/20.); - func->SetParameter(1,hmax); - func->SetParameter(2,hmean); - func->SetParameter(3,0.2); - double xmin = hmean - hrms; - double xmax = hmean + hrms; - hres->Fit("cgaus","Q,0","",xmin,xmax); - double amplitNoise = func->GetParameter(0); - double amplitNarrow = func->GetParameter(1); - double meanNarrow = func->GetParameter(2); - double widthNarrow = func->GetParameter(3); - - bool badChi2 = (func->GetChisquare())/(func->GetNDF()) > 20.; - bool badWidths = (widthNarrow>1.); - bool badMean = (meanNarrow<-1.) || (meanNarrow>1.); - bool badNoise = (amplitNoise>hmax/3.) || (amplitNoise>amplitNarrow/2. ); - - if (badChi2 || badWidths || badMean || badNoise ) { - widthNarrow = 0.9; - meanNarrow = 0.9; - } - - if(hWidth) hWidth->Fill(radius,(float)widthNarrow); - if(hMean) hMean->Fill(radius,(float)meanNarrow); - - hres->Delete(); - } //END LOOP over SLICES - hresidProx->Delete(); - - } // Entries > 0 - - } // endo of chambers loop - } //end of sectors loop - } //end of regions loop - } // end doResidualsFit - - // HERE is the OUTPUT to stdOutput and to TEXT file and EVENTUALLY to DataBase - // TO BE ACTIVATED VIA JOB_OPTION - still to do - // - if ( WriteMdtDqaDbToTextFile ) { - std::string mdtDqaTextFileName = m_outputFileName+".txt"; - std::ofstream outputFile(mdtDqaTextFileName.c_str()); - std::vector<MdtDqaDb*>::iterator it; - for (it = m_MdtDqaDbList.begin(); - it!=m_MdtDqaDbList.end();++it) { - (*it)-> Print(); - (*it)-> Print(&outputFile); - } - outputFile.close(); - } - - // Clean (reset) m_MdtDqaDbList - - return; -} // MdtDqaNtupleAnalysis::histogramAnalysis - -}//namespace MuonCalib - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTrackAnalysis.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTrackAnalysis.cxx deleted file mode 100644 index 3443ed7637c32d814b854fb16c86a56c6b99d169..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTrackAnalysis.cxx +++ /dev/null @@ -1,990 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_TrackAnalysisCXX -#define MuonCalib_TrackAnalysisCXX - -#include "MuonCalibStandAloneExtraTools/MdtDqaTrackAnalysis.h" -#include "MuonCalibStandAloneExtraTools/MDTName.h" -#include "TH1.h" -#include "TProfile.h" - -namespace MuonCalib { - -MdtDqaTrackAnalysis::MdtDqaTrackAnalysis(RegionSelectionSvc *punt, int trkauthor, HistogramManager *histoman, bool verbose) { - m_TrkAuthor=trkauthor; - m_histoManager=histoman; - p_reg_sel_svc=punt; - m_verbose=verbose; -} - -void MdtDqaTrackAnalysis::handleEvent(const MuonCalibEvent &event, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) { - - std::string histoType; - - const MuonCalibEvent_E& extra_event(dynamic_cast<const MuonCalibEvent_E&>(event)); - - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::::::::: ... preparing histos ::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - histoType="mbts1_time"; TH1F *h1tmbts1 = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="mbts2_time"; TH1F *h1tmbts2 = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="mbts1VSmbts2"; TH2F *h2mbts1VSmbts2 = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="mbts_Dtime"; TH1F *h1Dtmbts = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - - histoType="trk_ID_mult"; TH1F *h1trkIDmult = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - - histoType="seg_nb"; TH1F *h1segments = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_nb"; TH1F *h1tracks = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_nb_sel"; TH1F *h1tracks_sel = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_authorMoore"; TH1F *h1author1 = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_authorMuBoy"; TH1F *h1author2 = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_pt"; TH1F *h1pt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_eta"; TH1F *h1eta = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_phi"; TH1F *h1phi = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_etaVSphi"; TH2F *h2etaVSphi = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_d0VSz0"; TH2F *h2d0VSz0 = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_yVSx"; TH2F *h2yVSx = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_qOverP"; TH1F *h1qoverp = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_chi2dof"; TH1F *h1chi2dof = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_chi2dof_VS_author"; TH2F *h2chi2dof_VS_author = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_chi2dof_VS_eta"; TH2F *h2chi2dof_VS_eta = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_d0"; TH1F *h1d0 = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_z0ip"; TH1F *h1z0ip = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_mdthits_VS_eta"; TH2F *h2mdthits_VS_eta = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_mdthits_VS_phi"; TH2F *h2mdthits_VS_phi = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="hit_mdt"; TH1F *h1mdt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="hit_rpc"; TH1F *h1rpc = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="hit_mdtVSrpc"; TH2F *h2mdtVSrpc = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="hit_tgc"; TH1F *h1tgc = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="hit_csc"; TH1F *h1csc = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="hit_driftR"; TH1F *h1driftR = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="hit_pull"; TH1F *h1pull = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - - histoType="trk_Ev_pveto"; TH1F *h1_Ev_pveto = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_Ev_trkveto"; TH1F *h1_Ev_trkveto = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_ID_p"; TH1F *h1_ID_p = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_ID_ntrack"; TH1F *h1_ID_ntrack = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_ID_npixel"; TH1F *h1_ID_npixel = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_ID_nsct"; TH1F *h1_ID_nsct = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_ID_ntrt"; TH1F *h1_ID_ntrt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_ID_pixsctVStrt"; TH2F *h2_ID_pixsctVStrt = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_ID_pixVSsct"; TH2F *h2_ID_pixVSsct = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_Tag_ntrack"; TH1F *h1_Tag_ntrack = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_Tag_npixel"; TH1F *h1_Tag_npixel = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_Tag_nsct"; TH1F *h1_Tag_nsct = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_Tag_ntrt"; TH1F *h1_Tag_ntrt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_Tag_pixsctVStrt"; TH2F *h2_Tag_pixsctVStrt = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_Tag_pixVSsct"; TH2F *h2_Tag_pixVSsct = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_SA_ntrack"; TH1F *h1_SA_ntrack = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_SAIP_ntrack"; TH1F *h1_SAIP_ntrack = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_CB_ntrack"; TH1F *h1_CB_ntrack = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_CB_npixel"; TH1F *h1_CB_npixel = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_CB_nsct"; TH1F *h1_CB_nsct = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_CB_ntrt"; TH1F *h1_CB_ntrt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_CB_pixsctVStrt"; TH2F *h2_CB_pixsctVStrt = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_CB_pixVSsct"; TH2F *h2_CB_pixVSsct = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - - histoType="trk_cutflow"; TH2F *h2_cutflow = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - - histoType="trk_selected_cut5_pt"; TH1F *h1_selected_cut5_pt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_selected_cut5_p"; TH1F *h1_selected_cut5_p = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_selected_cut5_etaVSphi"; TH2F *h2_selected_cut5_etaVSphi = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - - histoType="trk_selected_pt"; TH1F *h1_selected_pt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_selected_p"; TH1F *h1_selected_p = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_selected_eta"; TH1F *h1_selected_eta = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_selected_phi"; TH1F *h1_selected_phi = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_selected_etaVSphi"; TH2F *h2_selected_etaVSphi = (TH2F*) m_histoManager->GetHisto("TRACKS",histoType); - - histoType="trk_associated_Deltapt"; TH1F *h1_associated_Deltapt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_associated_Deltap"; TH1F *h1_associated_Deltap = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_associatedIP_Deltapt"; TH1F *h1_associatedIP_Deltapt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_associatedIP_Deltap"; TH1F *h1_associatedIP_Deltap = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_SAIP_Deltapt"; TH1F *h1_SAIP_Deltapt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_SAIP_Deltap"; TH1F *h1_SAIP_Deltap = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_SAIP2_Deltapt"; TH1F *h1_SAIP2_Deltapt = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - histoType="trk_SAIP2_Deltap"; TH1F *h1_SAIP2_Deltap = (TH1F*) m_histoManager->GetHisto("TRACKS",histoType); - - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::comparison MuID(id<100) and STACO (id>=100)::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::MuonBoy <-> Moore::::::::::::::::::::::::::::::::*/ - /*:::::::::::::StacoMuonSA <-> MuidSA:::::::::::::::::::::::::::::::*/ - /*:::::::::::::StacoMuonTag <-> MuTagIMO:::::::::::::::::::::::::::::*/ - /*:::::::::::::StacoMuonCombined <-> MuidCB:::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - - MuonCalibEvent_E::TrackVec::const_iterator trk=extra_event.beginTrack(); - MuonCalibEvent_E::TrackVec::const_iterator trk_end=extra_event.endTrack(); - - EventHandler EventHandler; - EventHandler.setEvent(extra_event); - - MuonCalibSelector::TrackVec trk_selected = EventHandler.extendedTracks(m_TrkAuthor); - MuonCalibSelector::TrackVec trk_inner = EventHandler.extendedTracks(1000); - MuonCalibSelector::TrkCit track_it = trk_selected.begin(); - MuonCalibSelector::TrkCit track_it_end = trk_selected.end(); - - int Id_TrackID = 1000 ; // ID Track - int Id_TrackSA = 0 ; // Moore (Moore - Default) - int Id_TrackSA_IP = 10; // MuidSA (Moore - Default) - int Id_TrackTag = 30; // MuTagIMO (Moore - Default) - int Id_TrackCB = 20; // MuidCB (Moore - Default) - if (m_TrkAuthor==100) { - Id_TrackSA = 100; // MuonBoy - Id_TrackSA_IP = 141; // StacoMuonSA - Id_TrackTag = 142; // StacoMuonTag - Id_TrackCB = 140; // StacoMuonCB - } - - MuonCalibSelector::TrackVec trk_ID = EventHandler.extendedTracks(Id_TrackID); - MuonCalibSelector::TrackVec trk_SA = EventHandler.extendedTracks(Id_TrackSA); - MuonCalibSelector::TrackVec trk_SA_IP = EventHandler.extendedTracks(Id_TrackSA_IP); - MuonCalibSelector::TrackVec trk_Tag = EventHandler.extendedTracks(Id_TrackTag); - MuonCalibSelector::TrackVec trk_CB = EventHandler.extendedTracks(Id_TrackCB); - - MuonCalibSelector::TrkCit trk_ID_it = trk_ID.begin(); - MuonCalibSelector::TrkCit trk_ID_end = trk_ID.end(); - MuonCalibSelector::TrkCit trk_SA_it = trk_SA.begin(); - MuonCalibSelector::TrkCit trk_SA_end = trk_SA.end(); - MuonCalibSelector::TrkCit trk_SAIP_it = trk_SA_IP.begin(); - MuonCalibSelector::TrkCit trk_SAIP_end = trk_SA_IP.end(); - MuonCalibSelector::TrkCit trk_Tag_it = trk_Tag.begin(); - MuonCalibSelector::TrkCit trk_Tag_end = trk_Tag.end(); - MuonCalibSelector::TrkCit trk_CB_it = trk_CB.begin(); - MuonCalibSelector::TrkCit trk_CB_end = trk_CB.end(); - - MuonCalibSelector::TrkCit trk_ID_it2 = trk_ID.begin(); - MuonCalibSelector::TrkCit trk_ID_end2 = trk_ID.end(); - MuonCalibSelector::TrkCit trk_SA_it2 = trk_SA.begin(); - MuonCalibSelector::TrkCit trk_SA_end2 = trk_SA.end(); - MuonCalibSelector::TrkCit trk_SAIP_it2 = trk_SA_IP.begin(); - MuonCalibSelector::TrkCit trk_SAIP_end2 = trk_SA_IP.end(); - MuonCalibSelector::TrkCit trk_Tag_it2 = trk_Tag.begin(); - MuonCalibSelector::TrkCit trk_Tag_end2 = trk_Tag.end(); - MuonCalibSelector::TrkCit trk_CB_it2 = trk_CB.begin(); - MuonCalibSelector::TrkCit trk_CB_end2 = trk_CB.end(); - - MuonCalibSelector::TrkCit trk_SAIP_it3 = trk_SA_IP.begin(); - MuonCalibSelector::TrkCit trk_SAIP_end3 = trk_SA_IP.end(); - - int i_trk_sel = 0; - - /*::::::::::::::::::::::::::::::::::::::::::*/ - /*:::info from scintillators::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::*/ - MuonCalibEvent_E::MBTSVec::const_iterator mbhit = extra_event.beginMBTS(); - MuonCalibEvent_E::MBTSVec::const_iterator mbhit_end = extra_event.endMBTS(); - int nMBTS1 = 0; - double chargeMBTS1[100]; - double timeMBTS1[100]; - int nMBTS2 = 0; - double chargeMBTS2[100]; - double timeMBTS2[100]; - Amg::Vector3D posMBTS(0.,0.,0.); - - for(; mbhit != mbhit_end; ++mbhit ){ // Loop over MBTS hits - if ( (*mbhit)->charge() > 0.) { - posMBTS = (*mbhit)->position(); - if( posMBTS.z() > 1000. ) { - chargeMBTS1[nMBTS1] = (*mbhit)->charge(); - timeMBTS1[nMBTS1] = (*mbhit)->time(); - nMBTS1++; - } - if( posMBTS.z() < -1000. ) { - chargeMBTS2[nMBTS2] = (*mbhit)->charge(); - timeMBTS2[nMBTS2] = (*mbhit)->time(); - nMBTS2++; - } - // if (h1tmbts) h1tmbts->Fill( timeMBTS ); - } - } // end loop over MBTS hits - - double time1_mean = 0.; - double chargeWeight1 = 0.; - for (int i=0; i<nMBTS1; i++){ - time1_mean += timeMBTS1[i]*chargeMBTS1[i]; - chargeWeight1 += chargeMBTS1[i]; - } - time1_mean = time1_mean/chargeWeight1; - - double time2_mean = 0.; - double chargeWeight2 = 0.; - for (int i=0; i<nMBTS2; i++){ - time2_mean += timeMBTS2[i]*chargeMBTS2[i]; - chargeWeight2 += chargeMBTS2[i]; - } - time2_mean = time2_mean/chargeWeight2; - - double dTimeMBTS = -1000.; - if (nMBTS1>0 && h1tmbts1 ) h1tmbts1->Fill(time1_mean); - if (nMBTS2>0 && h1tmbts2 ) h1tmbts2->Fill(time2_mean); - if (nMBTS1>0 && nMBTS2>0) { - if (h2mbts1VSmbts2) h2mbts1VSmbts2->Fill(time2_mean,time1_mean); - dTimeMBTS = time1_mean-time2_mean; - if (h1Dtmbts) h1Dtmbts->Fill(dTimeMBTS); - } - - /*:::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::loop to check the authors:::::::::::*/ - /*:::::::::::::::::::::::::::::::::::::::::::*/ - - for(;trk!=trk_end;++trk) { - if(*trk) { - - if (h1author1) { - if ((*trk)->author() == 1000) h1author1->Fill(0.); // ID - if ((*trk)->author() == 0) h1author1->Fill(1.); // Moore - if ((*trk)->author() == 1) h1author1->Fill(2.); // BackExtrapolated SA - if ((*trk)->author() == 2) h1author1->Fill(3.); // BackExtrapolated SA calo energy correction - if ((*trk)->author() == 10) h1author1->Fill(4.); // MuidSA - if ((*trk)->author() == 20) h1author1->Fill(5.); // MuidCB - if ((*trk)->author() == 25) h1author1->Fill(6.); // MuonCombined ??? - if ((*trk)->author() == 30) h1author1->Fill(7.); // MuTagIMO - if ((*trk)->author() == 35) h1author1->Fill(8.); // MuGirl - if ((*trk)->author() == 41) h1author1->Fill(9.); // AODMuidSA - if ((*trk)->author() == 40) h1author1->Fill(10.); // AODMuidCB - if ((*trk)->author() == 42) h1author1->Fill(11.); // AODMuTagIMO - if ((*trk)->author() == 43) h1author1->Fill(12.); // AODMuGirl - } - - if (h1author2) { - if ((*trk)->author() == 1000) h1author2->Fill(0.); // ID - if ((*trk)->author() == 100) h1author2->Fill(1.); // MuonBoy - if ((*trk)->author() == 120) h1author2->Fill(2.); // Staco - if ((*trk)->author() == 130) h1author2->Fill(3.); // MuTagTracks - if ((*trk)->author() == 141) h1author2->Fill(4.); // StacoMuonSA - if ((*trk)->author() == 140) h1author2->Fill(5.); // StacoMuonCB - if ((*trk)->author() == 142) h1author2->Fill(6.); // StacoMuonTag - } - if (h2chi2dof_VS_author) h2chi2dof_VS_author->Fill( (*trk)->chi2()/(*trk)->ndof(),(*trk)->author() ); - } - } - - if (h1trkIDmult) h1trkIDmult->Fill(trk_ID.size()); - - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::::::::::::ALGORITHM DEPENDENT (MUID or STACO)::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - - int ID_ntrack = 0; - int SA_ntrack = 0; - int SAIP_ntrack = 0; - int Tag_ntrack = 0; - int CB_ntrack = 0; - int Ev_pveto = 0; - int Ev_ngoodtrack = 0; - int Ev_npixel_veto = 0; - int Ev_nsct_veto = 0; - int ID_npixel = 0; - int ID_nsct = 0; - int ID_ntrt = 0; - // int ID_ntrtb = 0; - int Tag_npixel= 0; - int Tag_nsct = 0; - int Tag_ntrt = 0; - // int Tag_ntrtb = 0; - int CB_npixel = 0; - int CB_nsct = 0; - int CB_ntrt = 0; - // int CB_ntrtb = 0; - - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::INNER DETECTOR :::::::::::::::::::*/ - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - for(; trk_ID_it != trk_ID_end; ++trk_ID_it ){ - ID_ntrack++; - ID_npixel = 0; - ID_nsct = 0; - ID_ntrt = 0; - // ID_ntrtb = 0; - ID_npixel = number_IDhits( trk_ID_it, 1); - ID_nsct = number_IDhits( trk_ID_it, 2); - ID_ntrt = number_IDhits( trk_ID_it, 3); - // ID_ntrtb = number_IDhits( trk_ID_it, 4); - - if(ID_npixel>0) Ev_npixel_veto++; - if(ID_nsct>5) Ev_nsct_veto++; - if(ID_npixel>0 && ID_nsct>5) Ev_ngoodtrack++; - if( h1_ID_npixel ) h1_ID_npixel->Fill(ID_npixel); - if( h1_ID_nsct ) h1_ID_nsct->Fill(ID_nsct); - if( h1_ID_ntrt ) h1_ID_ntrt->Fill(ID_ntrt); - if( h2_ID_pixsctVStrt ) h2_ID_pixsctVStrt->Fill(ID_npixel+ID_nsct, ID_ntrt); - if( h2_ID_pixVSsct ) h2_ID_pixVSsct->Fill(ID_npixel,ID_nsct); - - float ID_p = (*trk_ID_it)->p()/1000.; - if(h1_ID_p) h1_ID_p->Fill(ID_p); - if(ID_p>4) Ev_pveto++; - } // end loop on tracks - if ( h1_ID_ntrack ) h1_ID_ntrack->Fill(ID_ntrack); - if ( h1_Ev_pveto ) h1_Ev_pveto->Fill(Ev_pveto); - if ( h1_Ev_trkveto ) h1_Ev_trkveto->Fill(Ev_ngoodtrack); - - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::MUON SPECTROMETER STANDALONE:::::::::::::*/ - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - - for(; trk_SA_it != trk_SA_end; ++trk_SA_it ){ - SA_ntrack++; - } - if ( h1_SA_ntrack ) h1_SA_ntrack->Fill(SA_ntrack); - - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::MUON SPECTROMETER STANDALONE IP:::::::::*/ - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - - for(; trk_SAIP_it != trk_SAIP_end; ++trk_SAIP_it ){ - SAIP_ntrack++; - } - if ( h1_SAIP_ntrack ) h1_SAIP_ntrack->Fill(SAIP_ntrack); - - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::: TAG (ID + segment in the SM)::::::::::::*/ - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - - for(; trk_Tag_it != trk_Tag_end; ++trk_Tag_it ){ - Tag_ntrack++; - Tag_npixel = 0; - Tag_nsct = 0; - Tag_ntrt = 0; - // Tag_ntrtb = 0; - Tag_npixel = number_IDhits( trk_Tag_it, 1); - Tag_nsct = number_IDhits( trk_Tag_it, 2); - Tag_ntrt = number_IDhits( trk_Tag_it, 3); - // Tag_ntrtb = number_IDhits( trk_Tag_it, 4); - - if ( h1_Tag_npixel ) h1_Tag_npixel->Fill(Tag_npixel); - if ( h1_Tag_nsct ) h1_Tag_nsct->Fill(Tag_nsct); - if ( h1_Tag_ntrt ) h1_Tag_ntrt->Fill(Tag_ntrt); - if( h2_Tag_pixsctVStrt ) h2_Tag_pixsctVStrt->Fill(Tag_npixel+Tag_nsct, Tag_ntrt); - if( h2_Tag_pixVSsct ) h2_Tag_pixVSsct->Fill(Tag_npixel,Tag_nsct); - - } - if ( h1_Tag_ntrack ) h1_Tag_ntrack->Fill(Tag_ntrack); - - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::::COMBINED MUONS::::::::::::::::::*/ - /*:::::::::::::::::::::::::::::::::::::::::::::::*/ - - for(; trk_CB_it != trk_CB_end; ++trk_CB_it ){ - CB_ntrack++; - CB_npixel = 0; - CB_nsct = 0; - CB_ntrt = 0; - // CB_ntrtb = 0; - CB_npixel = number_IDhits( trk_CB_it, 1); - CB_nsct = number_IDhits( trk_CB_it, 2); - CB_ntrt = number_IDhits( trk_CB_it, 3); - // CB_ntrtb = number_IDhits( trk_CB_it, 4); - - if ( h1_CB_npixel ) h1_CB_npixel->Fill(CB_npixel); - if ( h1_CB_nsct ) h1_CB_nsct->Fill(CB_nsct); - if ( h1_CB_ntrt ) h1_CB_ntrt->Fill(CB_ntrt); - if( h2_CB_pixsctVStrt ) h2_CB_pixsctVStrt->Fill(CB_npixel+CB_nsct,CB_ntrt); - if( h2_CB_pixVSsct ) h2_CB_pixVSsct->Fill(CB_npixel,CB_nsct); - if ( h1_CB_ntrack ) h1_CB_ntrack->Fill(CB_ntrack); - } - - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::::::::::CUT FLOW:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - - bool IsCombined = false; - // MuonCalibSelector::TrkCit trk_ID_it3 = trk_ID.begin(); - // MuonCalibSelector::TrkCit trk_ID_end3 = trk_ID.end(); - - for(; trk_CB_it2 != trk_CB_end2; ++trk_CB_it2 ) { - double eta = 0; - double phi = 0; - double pt = 0; - double p = 0; - - phi = (*trk_CB_it2)->phi(); - eta = -std::log(std::tan((*trk_CB_it2)->theta()/2.)); - pt = (*trk_CB_it2)->pt()/1000; - p = (*trk_CB_it2)->p()/1000; - int CB_npixel = 0; - int CB_nsct = 0; - CB_npixel = number_IDhits( trk_CB_it2, 1); - CB_nsct = number_IDhits( trk_CB_it2, 2); - int CB_HasCutLevel = -10; - CB_HasCutLevel = cutflow( trk_CB_it2, dTimeMBTS, Ev_ngoodtrack, Ev_pveto, CB_npixel, CB_nsct); - for(int i =0;i<=CB_HasCutLevel;i++){ - if(h2_cutflow) h2_cutflow->Fill(5,i); - } - /*:::: BASIC DISTRIBUTIONS OF THE SELECTED COMBINED MUON :::::::::::::::::::::::::::::::*/ - if(CB_HasCutLevel>4){ - if(h1_selected_cut5_pt) h1_selected_cut5_pt->Fill(pt); - if(h1_selected_cut5_p) h1_selected_cut5_p->Fill(p); - if(h2_selected_cut5_etaVSphi) h2_selected_cut5_etaVSphi->Fill(phi,eta); - } - if(CB_HasCutLevel>6){ - if(h1_selected_pt) h1_selected_pt->Fill(pt); - if(h1_selected_p) h1_selected_p->Fill(p); - if(h1_selected_eta) h1_selected_eta->Fill(eta); - if(h1_selected_phi) h1_selected_phi->Fill(phi); - if(h2_selected_etaVSphi) h2_selected_etaVSphi->Fill(phi,eta); - IsCombined = true; - } - - if(CB_HasCutLevel>0 && m_TrkAuthor==0 && (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag) && (*trk_CB_it2)->getAssociatedTrack(Id_TrackSA) ){ - if(h1_associated_Deltapt ) h1_associated_Deltapt->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->pt() - (*trk_CB_it2)->getAssociatedTrack(Id_TrackSA)->pt())/1000. ); - if(h1_associated_Deltap) h1_associated_Deltap->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->p() - (*trk_CB_it2)->getAssociatedTrack(Id_TrackSA)->p())/1000. ); - } - if(CB_HasCutLevel>0 && m_TrkAuthor==0 && (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag) && (*trk_CB_it2)->getAssociatedTrack(Id_TrackSA_IP) ){ - if(h1_associatedIP_Deltapt ) h1_associatedIP_Deltapt->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->pt() - (*trk_CB_it2)->getAssociatedTrack(Id_TrackSA_IP)->pt())/1000. ); - if(h1_associatedIP_Deltap) h1_associatedIP_Deltap->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->p() - (*trk_CB_it2)->getAssociatedTrack(Id_TrackSA_IP)->p())/1000. ); - } - - for(; trk_SAIP_it3 != trk_SAIP_end3; ++trk_SAIP_it3 ){ - if(CB_HasCutLevel>0 && m_TrkAuthor==0 && (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag) && (*trk_CB_it2)->getAssociatedTrack(Id_TrackSA) && (*trk_SAIP_it3) ){ - if(h1_SAIP_Deltapt ) h1_SAIP_Deltapt->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->pt() - (*trk_SAIP_it3)->pt())/1000. ); - if(h1_SAIP_Deltap) h1_SAIP_Deltap->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->p() - (*trk_SAIP_it3)->p())/1000. ); - } - if(CB_HasCutLevel>0 && m_TrkAuthor==0 && (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag) && (*trk_SAIP_it3) ){ - if(h1_SAIP2_Deltapt ) h1_SAIP2_Deltapt->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->pt() - (*trk_SAIP_it3)->pt())/1000. ); - if(h1_SAIP2_Deltap) h1_SAIP2_Deltap->Fill( - ( (*trk_CB_it2)->getAssociatedTrack(Id_TrackTag)->p() - (*trk_SAIP_it3)->p())/1000. ); - } - } - - } - - for(; trk_ID_it2 != trk_ID_end2; ++trk_ID_it2 ){ - int ID_npixel = 0; - int ID_nsct = 0; - ID_npixel = number_IDhits( trk_ID_it2, 1); - ID_nsct = number_IDhits( trk_ID_it2, 2); - int ID_HasCutLevel = -10; - ID_HasCutLevel = cutflow( trk_ID_it2, dTimeMBTS, Ev_ngoodtrack, Ev_pveto, ID_npixel, ID_nsct); - for(int i =0;i<=ID_HasCutLevel;i++){ - if(h2_cutflow) h2_cutflow->Fill(1,i); - } - if(ID_HasCutLevel>1 && IsCombined){ - } - } - - for(; trk_SA_it2 != trk_SA_end2; ++trk_SA_it2 ){ - int SA_npixel = 0; - int SA_nsct = 0; - SA_npixel = number_IDhits( trk_SA_it2, 1); - SA_nsct = number_IDhits( trk_SA_it2, 2); - int SA_HasCutLevel = -10; - SA_HasCutLevel = cutflow( trk_SA_it2, dTimeMBTS, Ev_ngoodtrack, Ev_pveto, SA_npixel, SA_nsct); - - for(int i =0;i<=SA_HasCutLevel;i++){ - if(h2_cutflow) h2_cutflow->Fill(2,i); - } - } - - for(; trk_SAIP_it2 != trk_SAIP_end2; ++trk_SAIP_it2 ){ - int SAIP_npixel = 0; - int SAIP_nsct = 0; - SAIP_npixel = number_IDhits( trk_SAIP_it2, 1); - SAIP_nsct = number_IDhits( trk_SAIP_it2, 2); - int SAIP_HasCutLevel = -10; - SAIP_HasCutLevel = cutflow( trk_SAIP_it2, dTimeMBTS, Ev_ngoodtrack, Ev_pveto, SAIP_npixel, SAIP_nsct); - for(int i =0;i<=SAIP_HasCutLevel;i++){ - if(h2_cutflow) h2_cutflow->Fill(3,i); - } - } - - for(; trk_Tag_it2 != trk_Tag_end2; ++trk_Tag_it2 ) { - int Tag_npixel = 0; - int Tag_nsct = 0; - Tag_npixel = number_IDhits( trk_Tag_it2, 1); - Tag_nsct = number_IDhits( trk_Tag_it2, 2); - int Tag_HasCutLevel = -10; - Tag_HasCutLevel = cutflow( trk_Tag_it2, dTimeMBTS, Ev_ngoodtrack, Ev_pveto, Tag_npixel, Tag_nsct); - for(int i =0;i<=Tag_HasCutLevel;i++){ - if(h2_cutflow) h2_cutflow->Fill(4,i); - } - } - - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ - - int i_mdt = 0; // mdt hits for each track - int i_rpc = 0; // rpc hits for each track - int i_csc = 0; // csc hits for each track - int i_tgc = 0; // tgc hits for each track - - // MODIFICATIONS INTRODUCED FOR MUON VETO ANALYSIS WITH SEGMENTS refitted-t0 - - bool CollisionEvent = false; - if(std::abs(dTimeMBTS)<10 && Ev_ngoodtrack>2 && Ev_pveto>0 ) CollisionEvent=true; - - // ----------- Choose datacards here according to your analysis ----- - // HERE DECIDE WHETHER THE EVENT MUST BE A COLLISION CANDIDATE OR NOT : - bool goodEvent = true; - goodEvent = CollisionEvent; // IN CASE YOU WANT ALL EVENTS, just COMMENT THIS LINE - - // HERE SELECT THE TRACK TYPE - std::string TrackMDTtime_selection = "SA"; - - - // HERE SELECT THE CUT THE TRACK MUST PASS - // int PASSEDCUT = 0; // if goodEvent = CollisionEvent is enables - // PASSEDCUT = 0,1,2,3 is equivalent to PASSEDCUT = 4 - int PASSEDCUT = 0; - // ----------- END of datacards according to your analysis ----- - - if (goodEvent) { - - histoType="trk_d0VSz0_GoodTime"; TH2F *h2d0VSz0_goodT = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="trk_d0VSz0_BadTime"; TH2F *h2d0VSz0_badT = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="trk_d0VSz0_noSeg"; TH2F *h2d0VSz0_noSeg = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - - MuonCalibSelector::TrkCit trkMDTtime_it; - MuonCalibSelector::TrkCit trkMDTtime_it_end; - - if (TrackMDTtime_selection == "SA") { - trkMDTtime_it = trk_SA.begin(); - trkMDTtime_it_end = trk_SA.end(); - } - if (TrackMDTtime_selection == "SA_IP") { - trkMDTtime_it = trk_SA.begin(); - trkMDTtime_it_end = trk_SA.end(); - } - if (TrackMDTtime_selection == "Tag") { - trkMDTtime_it = trk_Tag.begin(); - trkMDTtime_it_end = trk_Tag.end(); - } - if (TrackMDTtime_selection == "CB") { - trkMDTtime_it = trk_CB.begin(); - trkMDTtime_it_end = trk_CB.end(); - } - - if (TrackMDTtime_selection == "NONE") { - std::vector<const MuonCalibExtendedSegment*> segs; - - for (unsigned int k=position; k<segments.size(); k++) { // LOOP OVER SEGMENTS - MuonCalibSegment *segment(segments[k]); - - const MuonCalibExtendedSegment *segext = (const MuonCalibExtendedSegment* ) segment; - segs.push_back(segext); - } - - } else { - for(;trkMDTtime_it!=trkMDTtime_it_end;++trkMDTtime_it){ - - int iMDTtime = -99; - int TRACK_npixel = 0; - int TRACK_nsct = 0; - TRACK_npixel = number_IDhits( trkMDTtime_it, 1); - TRACK_nsct = number_IDhits( trkMDTtime_it, 2); - int TRACK_HasCutLevel = -10; - TRACK_HasCutLevel = cutflow( trkMDTtime_it, dTimeMBTS, Ev_ngoodtrack, Ev_pveto, TRACK_npixel, TRACK_nsct); - if (TRACK_HasCutLevel<PASSEDCUT) { - continue; - } - const std::vector<const MuonCalibExtendedSegment*> assoSegments = (*trkMDTtime_it)->associatedSegments(); - bool additionalCut = true; - if (assoSegments.size()>0 && additionalCut ) iMDTtime = MDTtiming(assoSegments); - if (iMDTtime==1) { - if (h2d0VSz0_goodT) { - h2d0VSz0_goodT->Fill( (*trkMDTtime_it)->z0ip(), (*trkMDTtime_it)->d0()); - } - } - if (iMDTtime==0) { - if (h2d0VSz0_badT) { - h2d0VSz0_badT->Fill( (*trkMDTtime_it)->z0ip(), (*trkMDTtime_it)->d0()); - } - } - if (iMDTtime==-1) { - if (h2d0VSz0_noSeg) { - h2d0VSz0_noSeg->Fill( (*trkMDTtime_it)->z0ip(), (*trkMDTtime_it)->d0()); - } - } - } - } - } // close IF goodEvent - // - // END MODIFICATIONS INTRODUCED FOR MUON VETO ANALYSIS WITH SEGMENTS refitted-t0 - - /*::::::::::::::::::::::::::::::::::::::::::::::*/ - /*:::::::loop on non cut tracks :::::::*/ - /*::::::::::::::::::::::::::::::::::::::::::::::*/ - for(;track_it!=track_it_end;++track_it) { - - double eta = -std::log ( std::tan ( (*track_it)->theta()/2)); - - i_trk_sel++; - - if (h1pt) h1pt->Fill( (*track_it)->pt()/1000. ); // in GeV - if (h1eta) h1eta->Fill( eta ); - if (h1phi) h1phi->Fill( (*track_it)->phi() ); - if (h2etaVSphi) h2etaVSphi->Fill( eta, (*track_it)->phi()); - if (h1d0) h1d0->Fill( (*track_it)->d0()); - if (h1z0ip) h1z0ip->Fill( (*track_it)->z0ip()); - if (h2d0VSz0) h2d0VSz0->Fill( (*track_it)->z0ip(), (*track_it)->d0()); - if (h2yVSx) h2yVSx->Fill( (*track_it)->x0() , (*track_it)->y0() ); - if (h1qoverp) h1qoverp->Fill( (*track_it)->qOverP()*1000. ); // in Gev^-1 - if (h1chi2dof) h1chi2dof->Fill( (*track_it)->chi2()/(*track_it)->ndof() ); - if (h2chi2dof_VS_eta) h2chi2dof_VS_eta->Fill( eta, (*track_it)->chi2()/(*track_it)->ndof() ); - if (h1segments) h1segments->Fill( (*track_it)->associatedSegments().size() ); - - MuonCalibTrack_E::HitVector::const_iterator hit=(*track_it)->beginHit(); - MuonCalibTrack_E::HitVector::const_iterator hit_end=(*track_it)->endHit(); - - for(;hit!=hit_end;++hit){ - - MuonFixedId identifier = (*hit)->identify(); - - if( identifier.is_mdt() ){ // MDT hits - if (h1pull) h1pull->Fill( (*hit)->pull()); - if (h1driftR) h1driftR->Fill( (*hit)->driftRadius()); - i_mdt++; - } - if( identifier.is_rpc() ){ // RPC hits - i_rpc++; - } - if( identifier.is_tgc() ){ // TGC hits - i_tgc++; - } - if( identifier.is_csc() ){ // CSC hits - i_csc++; - } - } - - if(i_mdt>0){ - if (h1mdt) h1mdt->Fill(i_mdt); - } - if(i_rpc>0){ - if (h1rpc) h1rpc->Fill(i_rpc); - if(i_mdt>0){ - if (h2mdtVSrpc) h2mdtVSrpc->Fill(i_rpc,i_mdt); - } - } - if(i_tgc>0){ - if (h1tgc) h1tgc->Fill(i_tgc); - } - if(i_csc>0){ - if (h1csc) h1csc->Fill(i_csc); - } - - if (h2mdthits_VS_eta) h2mdthits_VS_eta->Fill( eta,i_mdt ); - if (h2mdthits_VS_phi) h2mdthits_VS_phi->Fill((*track_it)->phi() ,i_mdt ); - - // if(i_tgc>0 || i_rpc>0){ - // } - } - - /********************************************************************************************/ - - if (h1tracks) h1tracks->Fill(extra_event.nrTracks()); // including all authors - if (h1tracks_sel) h1tracks_sel->Fill( i_trk_sel ); // only selected author - - return; -} //end MdtDqaTrackAnalysis::handleEvent - -int MdtDqaTrackAnalysis::number_IDhits(MuonCalibSelector::TrackVec::const_iterator track, int detector){ - int npixel = 0; - int nsct = 0; - int ntrt = 0; - int ntrtb = 0; - int nhit = 0; - MuonCalibTrack_E::HitVector::const_iterator it_hit = (*track)->beginHit(); - MuonCalibTrack_E::HitVector::const_iterator it_hit_end = (*track)->endHit(); - for (;it_hit != it_hit_end; ++it_hit) { - if ((*it_hit)->type() != 1) continue; - if ((*it_hit)->position().perp() < 200.) { - npixel++; - if(detector ==1) nhit++; - } else if ((*it_hit)->position().perp() < 540.) { - nsct++; - if(detector ==2) nhit++; - } else if ((*it_hit)->position().perp() < 1100.) { - ntrt++; - if(detector ==3) nhit++; - if(std::abs((*it_hit)->position().z()) < 750.){ - ntrtb++; - if(detector ==4) nhit++; - } - } - } - - return nhit; -} //end MdtDqaTrackAnalysis::number_IDhits - -int MdtDqaTrackAnalysis::cutflow(MuonCalibSelector::TrackVec::const_iterator track, double dTimeMBTS, int Ev_ngoodtrack, int Ev_pveto, int npixel, int nsct) { - int HasPassedLevel = -10; - - double eta = 0; - double pt = 0; - double p = 0; - eta = -std::log(std::tan((*track)->theta()/2.)); - pt = (*track)->pt()/1000; - p = (*track)->p()/1000; - - HasPassedLevel = 0; - HasPassedLevel = 1; - if(HasPassedLevel == 1 && std::abs(dTimeMBTS)<10) HasPassedLevel = 2; - if(HasPassedLevel == 2 && Ev_ngoodtrack>2) HasPassedLevel = 3; - if(HasPassedLevel == 3 && Ev_pveto>0) HasPassedLevel = 4; - if(HasPassedLevel == 4) HasPassedLevel = 5; - if(HasPassedLevel == 5 && std::abs(eta)<2.5 && pt>2.5) HasPassedLevel = 6; - if(HasPassedLevel == 6 && p>4.) HasPassedLevel = 7; - if(HasPassedLevel == 7 && npixel>0 && nsct>5) HasPassedLevel = 8; - - return HasPassedLevel; -} //end MdtDqaTrackAnalysis::cutflow - -int MdtDqaTrackAnalysis::MDTtiming(const std::vector<const MuonCalibExtendedSegment*> &segments ){ - // - // MODIFICATIONS INTRODUCED FOR MUON VETO ANALYSIS WITH SEGMENTS refitted-t0 - // - std::string histoType; - histoType="nSegPerTrack"; TH1F *h1_nSegAll = (TH1F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="nSegPerTrack_HitCut"; TH2F *h2_nSegHitCut = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - - histoType="t0_BI"; TH2F *h2_t0BI = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_BM"; TH2F *h2_t0BM = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_BO"; TH2F *h2_t0BO = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_EI"; TH2F *h2_t0EI = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_EM"; TH2F *h2_t0EM = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_EO"; TH2F *h2_t0EO = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - - histoType="t0_BO_BM"; TH2F *h2_t0BOBM = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_BO_BI"; TH2F *h2_t0BOBI = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_BM_BI"; TH2F *h2_t0BMBI = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_EO_EM"; TH2F *h2_t0EOEM = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_EO_EI"; TH2F *h2_t0EOEI = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - histoType="t0_EM_EI"; TH2F *h2_t0EMEI = (TH2F*) m_histoManager->GetHisto("DEBUG",histoType); - - // bool debug_seg = false; - - if(h1_nSegAll) h1_nSegAll->Fill(segments.size()); - - const int NSEGMAX = 20; // Maximum of Segments in the same Layer (Inner, Middle, Outer) - float t0acceptedSeg[NSEGMAX]; - int nAcceptedSeg=0; - float t0refit_BI[NSEGMAX][2]; - float t0refit_BM[NSEGMAX][2]; - float t0refit_BO[NSEGMAX][2]; - float t0refit_EI[NSEGMAX][2]; - float t0refit_EM[NSEGMAX][2]; - float t0refit_EO[NSEGMAX][2]; - int nseg_BI = 0; - int nseg_BM = 0; - int nseg_BO = 0; - int nseg_EI = 0; - int nseg_EM = 0; - int nseg_EO = 0; - for (int i=0; i<NSEGMAX; i++) { - t0refit_BI[i][0] = 99999.; - t0refit_BM[i][0] = 99999.; - t0refit_BO[i][0] = 99999.; - t0refit_EI[i][0] = 99999.; - t0refit_EM[i][0] = 99999.; - t0refit_EO[i][0] = 99999.; - } - - unsigned int MINNUMHITS = 5; - int nseg_hitCut = 0; - std::vector<const MuonCalibExtendedSegment*>::const_iterator seg_it; - for (seg_it = segments.begin(); seg_it!=segments.end(); seg_it++) { // START LOOP ON SEGMENTS - if ((*seg_it)->mdtHitsOnTrack() >= MINNUMHITS) { // IF segment has >= MINNUMHITS - nseg_hitCut++; - if ( nseg_hitCut >=NSEGMAX ) { - continue; - } - - // MDT hits on segment - std::vector<MdtCalibHitBase*>::const_iterator aHit_it = (*seg_it)->mdtHOTBegin(); - std::vector<MdtCalibHitBase*>::const_iterator aHit_it_end = (*seg_it)->mdtHOTEnd(); - - float t0refit = (*seg_it)->fittedT0(); - - if (t0refit!= 0.) { - int hitCount(0); - std::string chamberName_firstHit; - int chamberEta_firstHit(0); - bool sameChamber = true; - bool adjacentChamber = false; - int sectorid(0.0); - for (; aHit_it != aHit_it_end; ++aHit_it){ // start loop over hits - hitCount++; - MuonFixedId id = (*aHit_it)->identify(); - MDTName chamb(id); - std::string chamberName = chamb.getOnlineName(); - if (hitCount==1) { - chamberName_firstHit = chamberName; - chamberEta_firstHit = chamb.getOnlineEta(); - sectorid = chamb.getOnlineSector(); - } else { - if (chamberName!=chamberName_firstHit) { - sameChamber = false; - if (!(chamberName.substr(0,3)==chamberName_firstHit.substr(0,3) - && chamb.getOnlineSector()==sectorid)) adjacentChamber = false; - if (chamberName.substr(0,3)==chamberName_firstHit.substr(0,3) && chamb.getOnlineSector()==sectorid){ - if (chamb.getOnlineEta()==chamberEta_firstHit+1 || chamb.getOnlineEta()==chamberEta_firstHit-1) adjacentChamber = true; - } - - } - } - } // end loop over hits - - if (sameChamber || adjacentChamber) { // IF all hits are in the same or adjacent Chamber - t0acceptedSeg[nAcceptedSeg]=t0refit; - nAcceptedSeg++; - if (chamberName_firstHit.substr(0,2) == "BI") { - t0refit_BI[nseg_BI][0] = t0refit; - t0refit_BI[nseg_BI][1] = sectorid; - nseg_BI++; - } - if (chamberName_firstHit.substr(0,2) == "BM") { - t0refit_BM[nseg_BM][0] = t0refit; - t0refit_BM[nseg_BM][1] = sectorid; - nseg_BM++; - } - if (chamberName_firstHit.substr(0,2) == "BO") { - t0refit_BO[nseg_BO][0] = t0refit; - t0refit_BO[nseg_BO][1] = sectorid; - nseg_BO++; - } - if (chamberName_firstHit.substr(0,2) == "EI") { - t0refit_EI[nseg_EI][0] = t0refit; - t0refit_EI[nseg_EI][1] = sectorid; - nseg_EI++; - } - if (chamberName_firstHit.substr(0,2) == "EM") { - t0refit_EM[nseg_EM][0] = t0refit; - t0refit_EM[nseg_EM][1] = sectorid; - nseg_EM++; - } - if (chamberName_firstHit.substr(0,2) == "EO") { - t0refit_EO[nseg_EO][0] = t0refit; - t0refit_EO[nseg_EO][1] = sectorid; - nseg_EO++; - } - } // end IF same or adjacent Chamber - } // end IF t0refit != 0 - } // end IF segment has >= MINNUMHITS - } // END LOOP ON SEGMENTS - - int sectorWithSegments[17]; - for (int i=0;i<17;i++) sectorWithSegments[i]=0; - - for (int n=0;n<nseg_BI;n++) { - h2_t0BI->Fill(t0refit_BI[n][1],t0refit_BI[n][0]); - sectorWithSegments[(int)t0refit_BI[n][1]]++; - } - for (int n=0;n<nseg_BM;n++) { - h2_t0BM->Fill(t0refit_BM[n][1],t0refit_BM[n][0]); - sectorWithSegments[(int)t0refit_BM[n][1]]++; - } - for (int n=0;n<nseg_BO;n++) { - h2_t0BO->Fill(t0refit_BO[n][1],t0refit_BO[n][0]); - sectorWithSegments[(int)t0refit_BO[n][1]]++; - } - for (int n=0;n<nseg_EI;n++) { - h2_t0EI->Fill(t0refit_EI[n][1],t0refit_EI[n][0]); - sectorWithSegments[(int)t0refit_EI[n][1]]++; - } - for (int n=0;n<nseg_EM;n++) { - h2_t0EM->Fill(t0refit_EM[n][1],t0refit_EM[n][0]); - sectorWithSegments[(int)t0refit_EM[n][1]]++; - } - for (int n=0;n<nseg_EO;n++) { - h2_t0EO->Fill(t0refit_EO[n][1],t0refit_EO[n][0]); - sectorWithSegments[(int)t0refit_EO[n][1]]++; - } - - int topnSegInSector = 0; - int sectorWithHighestNseg = 0; - for (int i=1;i<17;i++) { - if (sectorWithSegments[i]>topnSegInSector) { - topnSegInSector=sectorWithSegments[i]; - sectorWithHighestNseg = i; - } - } - h2_nSegHitCut->Fill( (float)sectorWithHighestNseg, (float)topnSegInSector ); - if (topnSegInSector>1) { - // look for combinations BO-BM - for (int n1=0;n1<nseg_BO;n1++) { - for (int n2=0;n2<nseg_BM;n2++) { - if (t0refit_BO[n1][1]==(float)sectorWithHighestNseg && t0refit_BM[n2][1]==(float)sectorWithHighestNseg) { - float deltat0_BOBM = t0refit_BO[n1][0]-t0refit_BM[n2][0]; - h2_t0BOBM->Fill((float)sectorWithHighestNseg,deltat0_BOBM); - } - } - } - // look for combinations BO-BI - for (int n1=0;n1<nseg_BO;n1++) { - for (int n2=0;n2<nseg_BI;n2++) { - if (t0refit_BO[n1][1]==(float)sectorWithHighestNseg && t0refit_BI[n2][1]==(float)sectorWithHighestNseg) { - float deltat0_BOBI = t0refit_BO[n1][0]-t0refit_BI[n2][0]; - h2_t0BOBI->Fill((float)sectorWithHighestNseg,deltat0_BOBI); - } - } - } - // look for combinations BM-BI - for (int n1=0;n1<nseg_BM;n1++) { - for (int n2=0;n2<nseg_BI;n2++) { - if (t0refit_BM[n1][1]==(float)sectorWithHighestNseg && t0refit_BI[n2][1]==(float)sectorWithHighestNseg) { - float deltat0_BMBI = t0refit_BM[n1][0]-t0refit_BI[n2][0]; - h2_t0BMBI->Fill((float)sectorWithHighestNseg,deltat0_BMBI); - } - } - } - - // look for combinations EO-EM - for (int n1=0;n1<nseg_EO;n1++) { - for (int n2=0;n2<nseg_EM;n2++) { - if (t0refit_EO[n1][1]==(float)sectorWithHighestNseg && t0refit_EM[n2][1]==(float)sectorWithHighestNseg) { - float deltat0_EOEM = t0refit_EO[n1][0]-t0refit_EM[n2][0]; - h2_t0EOEM->Fill((float)sectorWithHighestNseg,deltat0_EOEM); - } - } - } - // look for combinations EO-EI - for (int n1=0;n1<nseg_EO;n1++) { - for (int n2=0;n2<nseg_EI;n2++) { - if (t0refit_EO[n1][1]==(float)sectorWithHighestNseg && t0refit_EI[n2][1]==(float)sectorWithHighestNseg) { - float deltat0_EOEI = t0refit_EO[n1][0]-t0refit_EI[n2][0]; - h2_t0EOEI->Fill((float)sectorWithHighestNseg,deltat0_EOEI); - } - } - } - // look for combinations EM-EI - for (int n1=0;n1<nseg_EM;n1++) { - for (int n2=0;n2<nseg_EI;n2++) { - if (t0refit_EM[n1][1]==(float)sectorWithHighestNseg && t0refit_EI[n2][1]==(float)sectorWithHighestNseg) { - float deltat0_EMEI = t0refit_EM[n1][0]-t0refit_EI[n2][0]; - h2_t0EMEI->Fill((float)sectorWithHighestNseg,deltat0_EMEI); - } - } - } - } // CLOSE IF topnSegInSector>1 - - int iMDTtime = -99; - if (nAcceptedSeg==0) iMDTtime = -1; - int nacc=0; - for (int ns=0; ns<nAcceptedSeg; ns++) { - if (t0acceptedSeg[ns]>-50. && t0acceptedSeg[ns]<30.) nacc++; - } - if (nAcceptedSeg>0 && nacc==nAcceptedSeg) iMDTtime = 1; // THIS CONDITION is verified if ALL segments are good ! - if (nAcceptedSeg>0 && nacc<nAcceptedSeg) iMDTtime = 0; - - return iMDTtime; -} //end MdtDqaTrackAnalysis::MDTtiming - -} //namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx deleted file mode 100644 index f24b9441971e9ade66c5e6e693429a767c553b53..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx +++ /dev/null @@ -1,699 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include <iostream> -#include <fstream> -#include <string> -#include <vector> -#include <cstdlib> - -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MdtCalibInterfaces/IMdtSegmentFitter.h" - -#include "MdtCalibUtils/GlobalTimeFitter.h" -#include "MuonCalibStandAloneExtraTools/HistogramManager.h" -#include "MuonCalibStandAloneExtraTools/PhiEtaUtils.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MdtCalibFitters/DCSLFitter.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h" - -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" -#include "MuonCalibStandAloneBase/MdtStationT0Container.h" - -#include "MdtCalibData/IRtResolution.h" - -#include "TFile.h" -#include "TH1.h" -#include "TNtuple.h" -#include "TString.h" -#include "TDirectory.h" - -namespace MuonCalib { - -//***************************************************************************** -// constructor -MdtDqaTubeEfficiency::MdtDqaTubeEfficiency(float nsigma, float chi2Cut, - bool defaultResol, float adcCut, bool GTFitON, - bool useNewCalibConstants, bool useTimeCorrections) : - m_idHelper(nullptr), - m_detMgr(nullptr), - m_id_tool(nullptr), - p_reg_sel_svc(nullptr), - p_calib_input_svc(nullptr), - m_histoManager(nullptr), - m_qfitter(nullptr), - m_nb_stations(-1) -{ - m_nsigma = nsigma; - m_chi2Cut = chi2Cut; - m_defaultResol = defaultResol; - m_adcCut = adcCut; - m_GTFitON = GTFitON; - m_useNewCalibConstants = useNewCalibConstants; - m_useTimeCorrections = useTimeCorrections; -} - -//::::::::::::::::: -//:: METHOD init :: -//::::::::::::::::: -StatusCode MdtDqaTubeEfficiency::initialize(const Muon::IMuonIdHelperSvc *idHelper, const MuonGM::MuonDetectorManager *detMgr, - const MuonCalib::IIdToFixedIdTool *id_tool, RegionSelectionSvc *reg_sel_svc, - MdtCalibInputSvc *calib_input_svc, HistogramManager *histoManager) { - m_idHelper = idHelper; - m_detMgr = detMgr; - m_id_tool = id_tool; - p_reg_sel_svc = reg_sel_svc; - p_calib_input_svc = calib_input_svc; - m_histoManager = histoManager; - - std::string RegionName = p_reg_sel_svc->GetRegionSelection(); - - const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions(); - - //----------------------------------// - //-- Create Root Files and Histos --// - //----------------------------------// - - m_qfitter = NULL; - - // loop over stations in region - m_nb_stations = stationsInRegion.size(); - for (int istation=0;istation<m_nb_stations;istation++) { - for (int k=0;k<4;k++) m_nb_layers_tubes[istation][k] = -1; - } - - for (int istation=0;istation<m_nb_stations;istation++) { - std::string stationNameString = stationsInRegion.at(istation).regionId(); - std::string chamberType = stationNameString.substr(0,3); - int phi_id = stationsInRegion.at(istation).GetPhi(); - int eta_id = stationsInRegion.at(istation).GetEta(); - - Identifier station_id = m_idHelper->mdtIdHelper().elementID(chamberType, eta_id, phi_id); - int stationIntId = static_cast<int>(station_id.get_identifier32().get_compact()); - int numberOfML = m_idHelper->mdtIdHelper().numberOfMultilayers(station_id); - - for (int multilayer=1;multilayer<=numberOfML; multilayer++) { - Identifier MdtML = m_idHelper->mdtIdHelper().multilayerID(station_id, multilayer); - int layerMin = m_idHelper->mdtIdHelper().tubeLayerMin(MdtML); - int layerMax = m_idHelper->mdtIdHelper().tubeLayerMax(MdtML); - int tubeMin = m_idHelper->mdtIdHelper().tubeMin(MdtML); - int tubeMax = m_idHelper->mdtIdHelper().tubeMax(MdtML); - m_nb_layers_tubes[istation][0] = stationIntId; - m_nb_layers_tubes[istation][1] = layerMax-layerMin+1; - m_nb_layers_tubes[istation][1+multilayer] = tubeMax-tubeMin+1; - } - } //end loop on stations - - return StatusCode::SUCCESS; -} //end MdtDqaTubeEfficiency::initialize - -//***************************************************************************** - -//:::::::::::::::::::::::: -//:: METHOD handleEvent :: -//:::::::::::::::::::::::: -StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event, - int /*eventnumber*/, - const std::vector<MuonCalibSegment *> &segments, - unsigned int position) { - - bool RPCTimeCorrection = false; // SHOULD BE SETVIA jobOption if useful in the future! - bool t0RefinementTimeCorrection = true; // SHOULD BE SET VIA jobOption if useful in the future! - if( RPCTimeCorrection && t0RefinementTimeCorrection ) return StatusCode::FAILURE; - - if (segments.size()<=position) return StatusCode::SUCCESS; - - DCSLFitter *fitter = new DCSLFitter(); - GlobalTimeFitter *GTFitter = new GlobalTimeFitter(fitter); - const IRtRelation *calibRt(0); - const IRtRelation *GTFitRt(0); - if ( m_GTFitON ) { - if (!m_useNewCalibConstants ) { - GTFitRt = GTFitter->getDefaultRtRelation(); - GTFitter->setRtRelation(GTFitRt); - } - } - - for (unsigned int k=position; k<segments.size(); k++) { // LOOP OVER SEGMENTS - - MuonCalibSegment segment(*segments[k]); - - //---------------// - //-- Variables --// - //---------------// - - int nb_hits; - - // station identifiers // - - MuonFixedId Mid((segment.mdtHOT()[0])->identify()); - MDTName chamb(Mid); - - //this has to be set in order to get the m_detMgr->getMdtReadoutElement() method working correctly - //otherwise also for the first multilayer, the second is returned - // - // M.I. ----> ???? TO CHECK FURTHER ! - Mid.setMdtMultilayer(1); - - // - // Get REGION and STATION of the first hit of the segment : - // - int phi = Mid.phi(); - int eta = Mid.eta(); - std::string stationNameStr = Mid.stationNameString(); - - // - // Check that all the hits in the segment belongs to the same chamber : - // - bool segInOneChamber = true; - for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) { - bool samestation( ((segment.mdtHOT()[l])->identify()).stationNameString()==stationNameStr ); - bool samephi( ((segment.mdtHOT()[l])->identify()).phi()==phi ); - bool sameeta( ((segment.mdtHOT()[l])->identify()).eta()==eta ); - bool sameChamber = samestation && samephi && sameeta; - if (!sameChamber){ - segInOneChamber = false; - // REINCLUDE THE BREAK ! - break; - } - } - - // WE SHOULD DECIDE IF A SEGMENT BUILT ON ADJACIENT CHAMBERS SHOULD BE SKIPPED - // ...now skipped - if (!segInOneChamber) continue; - - // - // Get numberOfMultiLayers, numberOfLayers, numberOfTubes : - // - int stationIntId = static_cast<int>(m_idHelper->mdtIdHelper(). elementID(stationNameStr,eta,phi).get_compact()); - Identifier station_id = m_id_tool->fixedIdToId(Mid); - - int numberOfML, numberOfLayers, numberOfTubes[2]; - numberOfML = 0; - numberOfLayers = 0; - numberOfTubes[0] = 0; - numberOfTubes[1] = 0; - - for (int ii=0; ii<m_nb_stations; ++ii) { - if (m_nb_layers_tubes[ii][0] == stationIntId) { - numberOfLayers = m_nb_layers_tubes[ii][1]; - numberOfTubes[0] = m_nb_layers_tubes[ii][2]; - numberOfTubes[1] = m_nb_layers_tubes[ii][3]; - if (numberOfTubes[0]>0 || numberOfTubes[1]>0 ) numberOfML = 1; - if (numberOfTubes[0]>0 && numberOfTubes[1]>0 ) numberOfML = 2; - break; - } - } - - if (numberOfML == 1 ) continue; // GO TO NEXT SEGMENT - - int minNumOfHits = numberOfLayers*2 - 1; - - if((int)segment.mdtHitsOnTrack()<minNumOfHits) continue; // GO TO NEXT SEGMENT - - // Get Histograms - TFile *mdtDqaRoot = m_histoManager->rootFile(); - std::string region = chamb.getRegion(); - std::string side = chamb.getSide(); - - PhiEtaNameConverter phiEtaConverter; - std::string chamberType = chamb.getName(); - - std::string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb); - std::string effiDirName = chamberDirName+"/Efficiency"; - std::string expertDirName = chamberDirName+"/Expert"; - - TDirectory *chamberRootDir = mdtDqaRoot->GetDirectory(chamberDirName.c_str()); - TDirectory *effiRootDir = mdtDqaRoot->GetDirectory(effiDirName.c_str()); - TDirectory *expertRootDir = mdtDqaRoot->GetDirectory(expertDirName.c_str()); - - if ( !chamberRootDir || !effiRootDir ) { - delete GTFitter; GTFitter=0; - return StatusCode::FAILURE; - } - - std::string histoName; - TH1F* heffiEntries; - TH1F* heffiCounts; - TH2F* heffiVsRadius; - - expertRootDir->cd(); - histoName = "EfficiencyEntries"; - heffiEntries = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str()); - histoName = "EfficiencyCounts"; - heffiCounts = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str()); - if (!heffiEntries || !heffiCounts ) { - delete GTFitter; GTFitter=0; - return StatusCode::FAILURE; - } - - histoName = "EffiResidVsRadius"; - heffiVsRadius = (TH2F*) m_histoManager->GetMdtHisto(histoName,chamb); - - chamberRootDir->cd(); - float toffset(-9999.); - float timeCorrection(-9999.); - - if( m_useTimeCorrections && RPCTimeCorrection ) timeCorrection = segment.mdtHOT()[0]->timeOfFlight(); - if( m_useTimeCorrections && t0RefinementTimeCorrection ) timeCorrection = segment.fittedT0(); - - if ( m_GTFitON ) { - MdtCalibHitBase *segHit = segment.mdtHOT()[0]; - MuonFixedId id(segHit->identify()); - if (m_useNewCalibConstants ) { - calibRt = p_calib_input_svc->GetRtRelation(id); - if (calibRt==NULL ) { - continue; - } - GTFitRt = calibRt; - GTFitter->setRtRelation(GTFitRt); - // here a method on GTFitter should be implemented to setResolution ! - // something like - } - - toffset = GTFitter->GTFit(&segment); - if ((int)segment.mdtHitsOnTrack() < minNumOfHits ) continue; - - // Recalibrate all rawhits on this chamber - const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { // LOOP OVER RawHitCollection - - if (GTFitRt==NULL) { - continue; - } - MuonCalibRawMdtHit *hit = *it; - bool samestation( (hit->identify()).stationNameString()==stationNameStr ); - bool samephi( (hit->identify()).phi()==phi ); - bool sameeta( (hit->identify()).eta()==eta ); - bool sameChamber = samestation && samephi && sameeta; - if (p_reg_sel_svc->isInRegion(hit->identify()) && sameChamber ){ - int rawTime = hit->tdcCount(); - double newDriftTime = (double)rawTime*25./32. - toffset; - double newRadius = GTFitRt->radius(newDriftTime); - double newResol(9999.); - if (m_defaultResol) newResol = defaultResolution(newRadius); - if (!m_defaultResol) newResol = GTFitter->getDefaultResolution(newRadius); //it is in fact the same - hit->setDriftTime(newDriftTime); - hit->setDriftRadius(newRadius); - hit->setDriftRadiusError(newResol); - - } // close IF the hit is in the same chamber - } // END LOOP OVER RawHitCollection - } //END IF GTFIT ON - - // RECALIBRATION with NEW CALIB CONSTANTS if GTFIT is OFF - if (m_useNewCalibConstants && !m_GTFitON ) { - // Recalibrate all MdtCalibHitBase on the segment - // (in case calibrations used now are different from those of original segments) - for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) { // LOOP OVER MdtCalibHitBase in the segment - MdtCalibHitBase * segHit = segment.mdtHOT()[l]; - MuonFixedId id(segHit->identify()); - const MdtStationT0Container *t0=p_calib_input_svc->GetT0(id); - const IRtRelation *rt_relation = p_calib_input_svc->GetRtRelation(id); - const IRtResolution *spat_res = p_calib_input_svc->GetResolution(id); - if (t0==NULL || rt_relation==NULL || spat_res==NULL) { - continue; - } - - unsigned short rawTime = segHit->tdcCount(); - double newDriftTime = (double)rawTime*25./32. - t0->t0(id.mdtMultilayer(),id.mdtTubeLayer(),id.mdtTube()); - if( m_useTimeCorrections ) newDriftTime = newDriftTime - timeCorrection; - double newRadius = rt_relation->radius(newDriftTime); - double newResol(9999.); - if (!m_defaultResol) newResol = spat_res->resolution(newDriftTime); - if (m_defaultResol) newResol = defaultResolution(newRadius); - segHit->setDriftTime(newDriftTime); - segHit->setDriftRadius(newRadius, newResol); - } // END OVER MdtCalibHitBase in the segment - - // Recalibrate all rawhits on this chamber - const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { // LOOP OVER RawHitCollection - - MuonCalibRawMdtHit *hit = *it; - bool samestation( (hit->identify()).stationNameString()==stationNameStr ); - bool samephi( (hit->identify()).phi()==phi ); - bool sameeta( (hit->identify()).eta()==eta ); - bool sameChamber = samestation && samephi && sameeta; - if (p_reg_sel_svc->isInRegion(hit->identify()) && sameChamber ) { - const MuonFixedId & id(hit->identify()); - const MdtStationT0Container *t0=p_calib_input_svc->GetT0(id); - const IRtRelation *rt_relation = p_calib_input_svc->GetRtRelation(id); - const IRtResolution *spat_res = p_calib_input_svc->GetResolution(id); - - if (t0==NULL || rt_relation==NULL || spat_res==NULL) { - continue; - } - - int rawTime = hit->tdcCount(); - double newDriftTime = (double)rawTime*25./32. - t0->t0(id.mdtMultilayer(),id.mdtTubeLayer(),id.mdtTube()); - newDriftTime = newDriftTime - timeCorrection; - double newRadius = rt_relation->radius(newDriftTime); - double newResol(9999.); - if (!m_defaultResol) newResol = spat_res->resolution(newDriftTime); - if (m_defaultResol) newResol = defaultResolution(newRadius); - hit->setDriftTime(newDriftTime); - hit->setDriftRadius(newRadius); - hit->setDriftRadiusError(newResol); - - } // close IF the hit is in the same chamber - } // END LOOP OVER RawHitCollection - } // CLOSE If m_useNewCalibConstants - // END RECALIBRATION with NEW CALIB CONSTANTS - - - // Now everything is recalibrated and segments are ready. - // Will start to remove one hit per layer - MTStraightLine track0; - track0 = MTStraightLine(segment.position(),segment.direction(), - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0)); - - // loop over MultiLayers - for (int multilayer=1; multilayer<=numberOfML; multilayer++) { // LOOP OVER MULTILAYERS - - const MuonGM::MdtReadoutElement *MdtRoEl = - m_detMgr->getMdtReadoutElement( m_idHelper->mdtIdHelper().channelID(station_id,multilayer,1,1) ); - - //loop over layers - for (int layer=1; layer<=numberOfLayers; layer++) { // LOOP OVER LAYERS - - nb_hits = 0; - - // hit selection vector for refits: - // Exclude hit in the current layer - IMdtSegmentFitter::HitSelection - hit_selection = IMdtSegmentFitter::HitSelection(segment.mdtHitsOnTrack()); - - for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) { - MuonFixedId id((segment.mdtHOT()[l])->identify()); - if (id.mdtMultilayer() == multilayer && - id.mdtTubeLayer() == layer) { - hit_selection[l] = 1; - } else { - hit_selection[l] = 0; - nb_hits = nb_hits+1; - } - } - - if (nb_hits<minNumOfHits) continue; // GO TO NEXT LAYER - - fitter->fit(segment,hit_selection); - - if ((int)segment.mdtHitsOnTrack() < minNumOfHits ) continue; - if (segment.chi2()>m_chi2Cut) continue; - - // counts the hits per Layers in the segment with the excluded layer - int hit_ML_Ly[2][4]; - int totLayersWithHits = 0; - for (int iml=0; iml<2; iml++) { - for (int il=0; il<4; il++) hit_ML_Ly[iml][il]= 0; - } - - for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) { - MuonFixedId id((segment.mdtHOT()[l])->identify()); - hit_ML_Ly[id.mdtMultilayer()-1][id.mdtTubeLayer()-1]++; - } - for (int iml=0; iml<2; iml++) { - for (int il=0; il<4; il++) if (hit_ML_Ly[iml][il]>0) totLayersWithHits++; - } - if ( totLayersWithHits < minNumOfHits ) continue; - - // NOW WE HAVE A SELECTED SEGMENT WITH EXCLUDED HIT - - MTStraightLine track1; - track1 = MTStraightLine(segment.position(),segment.direction(), - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0)); - - std::vector<int> traversed_tube(0); - std::vector<int> hit_tube(0); - std::vector<int> hit_found(0); - double distanceTraversedTube(0); - - // find tubes which have been traversed by the track // - for (int k=0; k<numberOfTubes[multilayer-1]; k++) { - Amg::Vector3D TubePos = - MdtRoEl->GlobalToAmdbLRSCoords(MdtRoEl->tubePos(multilayer,layer,k+1)); - - Amg::Vector3D tube_position = Amg::Vector3D(TubePos.x(), TubePos.y(), TubePos.z()); - Amg::Vector3D tube_direction = Amg::Vector3D(1,0,0); - - MTStraightLine tube = MTStraightLine( tube_position, tube_direction, - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) ); - - double distance = std::abs(track1.signDistFrom(tube)); - - if ( distance < (MdtRoEl->innerTubeRadius()) ){ - int traversedTube = k+1; - traversed_tube.push_back(k+1); - distanceTraversedTube = distance; - - // TRAVERSED TUBE FOUND! NOW CHECK WHETHER THERE IS A HIT IN THIS TUBE FROM THE RAW HIT COLLECTION: - - bool hitFound = false; - const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { // LOOP OVER RawHitCollection - - MuonCalibRawMdtHit *hit = *it; - bool samestation( (hit->identify()).stationNameString()==stationNameStr ); - bool samephi( (hit->identify()).phi()==phi ); - bool sameeta( (hit->identify()).eta()==eta ); - bool sameChamber = samestation && samephi && sameeta; - if (p_reg_sel_svc->isInRegion(hit->identify()) && sameChamber && - (hit->identify()).mdtMultilayer() == multilayer && - (hit->identify()).mdtTubeLayer() == layer) { - - if ( hit->adcCount() < m_adcCut ) continue; - - int tubeHit = (hit->identify()).mdtTube(); - - if (tubeHit == traversedTube) { // THE HIT IS FOUND - // check if the same hit was already found - bool alreadyThere = false; - //loop over hit tubes - for (unsigned int j=0; j<hit_found.size(); j++) { - if (tubeHit==hit_found[j]){ - alreadyThere=true; - break; - } - } - - if (!alreadyThere) { // A NEW HIT HAS BEEN FOUND - hitFound = true; - hit_found.push_back( tubeHit ); - if ( m_nsigma < 0 ) hit_tube.push_back( tubeHit ); - - Amg::Vector3D TubePos = - MdtRoEl->GlobalToAmdbLRSCoords(MdtRoEl->tubePos(multilayer,layer,tubeHit)); - - Amg::Vector3D tube_position = Amg::Vector3D(TubePos.x(), TubePos.y(), TubePos.z()); - Amg::Vector3D tube_direction = Amg::Vector3D(1,0,0); - - MTStraightLine tube = MTStraightLine( tube_position, tube_direction, - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) ); - - double distance = std::abs(track1.signDistFrom(tube)); - double hitRadius = std::abs(hit->driftRadius()); - double resol = hit->driftRadiusError(); - double resid = distance-hitRadius; - if(heffiVsRadius) heffiVsRadius->Fill(distance, resid); - float averageExtrapolError = 0.090; // ..an educated guess! - float sig = std::hypot(resol, averageExtrapolError); - - if ( m_nsigma>0. && std::abs(resid) < m_nsigma*sig ) hit_tube.push_back( tubeHit ); - } // END NEW HIT FOUND - } // close IF the Hit is found - } // close IF the hit is in the same chamber, same layer - } // END LOOP OVER RawHitCollection - if (!hitFound) if(heffiVsRadius) heffiVsRadius->Fill(distanceTraversedTube,15.5); - - } // Close IF Traversed Tube Found - } // END LOOP OVER ALL TUBES IN THE LAYER - - // Efficiencies // - - //loop over traversed tubes - for (unsigned int k=0; k<traversed_tube.size(); k++) { - int hit_flag = 0; - //loop over hit tubes - for (unsigned int j=0; j<hit_tube.size(); j++) { - if(traversed_tube[k]==hit_tube[j]){ - hit_flag = 1; - break; - } - } - int offset=0; - if(multilayer==1) offset= m_histoManager->GetTubeOffsetML1(chamb.getOnlineName()); - - int offset_atend=0; - if(multilayer==1) offset_atend= m_histoManager->GetTubeOffsetAtEndML1(chamb.getOnlineName()); - - float iTube = traversed_tube[k]; - float ibin = (multilayer-1)*numberOfLayers*numberOfTubes[multilayer-1]+ - (layer-1)*(numberOfTubes[multilayer-1]+offset+offset_atend)+iTube+offset; - heffiEntries->Fill(ibin); - if ( hit_flag) heffiCounts->Fill(ibin); - } - } //end of loop over layers - } //end of loop over multilayers - - } // end LOOP OVER SEGMENTS - - delete fitter; - delete GTFitter; - - return StatusCode::SUCCESS; -} //end MdtDqaTubeEfficiency::handleEvent - -//***************************************************************************** - -//:::::::::::::::::::::::::::: -//:: METHOD analyseSegments :: -//:::::::::::::::::::::::::::: - -StatusCode MdtDqaTubeEfficiency::analyseSegments(const std::vector<MuonCalibSegment *> & /*segments*/) { - - TFile *mdtDqaRoot = m_histoManager->rootFile(); - const std::vector<MuonCalib::NtupleStationId> stationsInRegion = - p_reg_sel_svc->GetStationsInRegions(); - - ToString ts; - //loop over stations in region - for ( int istation=0; istation<m_nb_stations; istation++ ) { - int phi = stationsInRegion.at(istation).GetPhi(); - int eta = stationsInRegion.at(istation).GetEta(); - std::string stationNameString = stationsInRegion.at(istation).regionId(); - std::string chamberType = stationNameString.substr(0,3); - - MDTName chamb(chamberType,phi,eta); - - // In the following lines the numberOfML, numberOfLayers, numberOfTubes - // are extracted RELYING on the order of the vector m_nb_layers_tubes[istation][] - // with istation following the same order of stationsInRegion.at(istation) - // ...if this is not the case, then the service m_mdtIdHelper should be used - // matching the stationIntId : - int numberOfML = 0; - int numberOfTubes[2]; - int numberOfLayers = m_nb_layers_tubes[istation][1]; - numberOfTubes[0] = m_nb_layers_tubes[istation][2]; - numberOfTubes[1] = m_nb_layers_tubes[istation][3]; - if (numberOfTubes[0]>0 || numberOfTubes[1]>0 ) numberOfML = 1; - if (numberOfTubes[0]>0 && numberOfTubes[1]>0 ) numberOfML = 2; - - std::string region= chamb.getRegion(); - std::string side=chamb.getSide(); - - PhiEtaNameConverter phiEtaConverter; - std::string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb); - - std::string effiDirName = chamberDirName+"/Efficiency"; - std::string expertDirName = chamberDirName+"/Expert"; - TDirectory *chamberRootDir = mdtDqaRoot->GetDirectory(chamberDirName.c_str()); - TDirectory *effiRootDir = mdtDqaRoot->GetDirectory(effiDirName.c_str()); - TDirectory *expertRootDir = mdtDqaRoot->GetDirectory(expertDirName.c_str()); - - if ( !chamberRootDir || !effiRootDir ) { - return StatusCode::FAILURE; - } - - std::string histoName; - TH1F *heffiEntries; - TH1F *heffiCounts; - - expertRootDir->cd(); - histoName = "EfficiencyEntries"; - heffiEntries = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str()); - histoName = "EfficiencyCounts"; - heffiCounts = (TH1F*) expertRootDir->FindObjectAny(histoName.c_str()); - if (!heffiEntries || !heffiCounts ) { - return StatusCode::FAILURE; - } - - chamberRootDir->cd(); - TH1F *hg; - histoName = "UNDEFINED"; - if (stationNameString.substr(1,1) == "I" ) histoName = "TubeEfficiency_Inner"; - if (stationNameString.substr(1,1) == "M" ) histoName = "TubeEfficiency_Middle"; - if (stationNameString.substr(1,1) == "O" ) histoName = "TubeEfficiency_Outer"; - hg = (TH1F*) m_histoManager->GetMdtHisto(histoName,region,side); - - // HERE NOW COMPUTE EFFICIENCY ERRORS AND FILL THE HISTOGRAMS - - if (heffiEntries->GetEntries() != 0 ) { - //loop over multilayers - for (int k=0; k<numberOfML; k++) { - - //loop over layers - for (int l=0; l<numberOfLayers; l++) { - - //loop over tubes - for (int m=0; m<numberOfTubes[k]; m++) { - int iML = k+1; - int iLy = l+1; - int iTube = m+1; - int ibin = (iML-1)*numberOfLayers*numberOfTubes[k]+(iLy-1)*numberOfTubes[k]+iTube; - //calculate efficiency and errors - - // HERE WE USE THE Efficiency definition and Error using the Bayesian Statistics: - // - float entries = heffiEntries->GetBinContent(ibin); - float counts = heffiCounts->GetBinContent(ibin); - float efficiency = (counts+1.)/(entries+2.); - float error = std::sqrt(efficiency*(1-efficiency))/std::sqrt(entries+3.); - // - // Fill MdtDqa Histos - // - - std::string histoName; - TH1F *heffi; - chamberRootDir->cd(); - histoName = "b_EfficiencyPerTube"; - heffi = (TH1F*) chamberRootDir->FindObjectAny(histoName.c_str()); - if (!heffi) { - continue; - } - heffi->SetBinContent(ibin,efficiency); - heffi->SetBinError(ibin,error); - - histoName = "EffiPerTube_ML"+ts(iML)+"_L"+ts(iLy); - effiRootDir->cd(); - heffi= (TH1F*) effiRootDir->FindObjectAny(histoName.c_str()); - if (!heffi) { - continue; - } - heffi->SetBinContent(iTube,efficiency); - heffi->SetBinError(iTube,error); - - // Filling Global plots - if (hg && efficiency>0. && error >0. && error<0.05) hg->Fill(efficiency); - - // HERE WE MUST ADD THE EFFICIENCY PER MULTILAYER - // and in case per chamber to put in a NEW overview plot! - // ... - // - - } // loop over tube - } // loop over Layer - } // loop over ML - } - - } //LOOP on istation - - return StatusCode::SUCCESS; -} //end MdtDqaTubeEfficiency::analyseSegments - -} // namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleMdtDqaTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleMdtDqaTool.cxx deleted file mode 100644 index 93c00b1246a303dd8181cc4d05ed4c8c1ddeca1d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleMdtDqaTool.cxx +++ /dev/null @@ -1,360 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -//:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS NtupleMdtDqaTool :: -//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// standard C++ // -#include <iostream> -#include <fstream> -#include <string> -#include <vector> -#include <cstdlib> - -// MuonReadoutGeometry // -#include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MdtCalibInterfaces/IMdtSegmentFitter.h" - -// MuonCalib // -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" - -// NtupleMdtDqaTool // -#include "MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h" -#include "MuonCalibStandAloneExtraTools/PhiEtaUtils.h" -#include "MuonCalibStandAloneExtraTools/MDTName.h" - -//this -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -//root -#include "TFile.h" -#include "TH1.h" -#include "TNtuple.h" -#include "TString.h" -#include "TDirectory.h" - -namespace MuonCalib { - -//***************************************************************************** - -// constructor -// -// a parte le declareProperty ....come deve essere fatto questo costruttore? che sono qui "t" "n" e "p" ??? -// -// - -NtupleMdtDqaTool::NtupleMdtDqaTool( const std::string &t, const std::string &n, - const IInterface *p) : AthAlgTool(t, n, p) { - - declareInterface< NtupleCalibrationTool >(this); - - m_MdtDqa_file_name = std::string("MdtDqa"); - declareProperty("MdtDqaFileName", m_MdtDqa_file_name); - - m_verbose = false; - declareProperty("Verbose", m_verbose); - - m_doHitResids = true; - declareProperty("doSegHitResidsVsRadius", m_doHitResids); - - m_fillHistos = true; - declareProperty("FillHistos", m_fillHistos); - - m_doFinalize = true; - declareProperty("doFinalize", m_doFinalize); - - m_doEfficiency = true; - declareProperty("doEfficiency", m_doEfficiency); - - m_ADCCUT=70.; - declareProperty("ADCCUT", m_ADCCUT); - - m_EffiNSigma = -1.; // set a negative value for Hardware Eficiency - declareProperty("EffiNSigma", m_EffiNSigma); - - m_EffiChi2Cut = 5.; // cut on chi2/dof - declareProperty("EffiChi2Cut", m_EffiChi2Cut); - - m_EffiHitADCCut = 0.; - declareProperty("EffiHitADCCut", m_EffiHitADCCut); - - m_EffiUseDefaultResolution = false; - declareProperty("EffiUseDefaultResolution", m_EffiUseDefaultResolution); - - m_EffiGTFitON = false; - declareProperty("EffiGTFitON", m_EffiGTFitON); - - m_EffiUseNewCalibConstants = false; - declareProperty("EffiUseNewCalibConstants", m_EffiUseNewCalibConstants); - - m_EffiUseTimeCorrections = false; - declareProperty("EffiUseTimeCorrections", m_EffiUseTimeCorrections); - - // - // MdtDqaGlobalTimeFit jobOptions : - // - m_doGlobalTimeFit = true; - declareProperty("doGlobalTimeFit", m_doGlobalTimeFit); - - m_rtDefaultBfieldON = 0; - declareProperty("rtDefaultBfieldON",m_rtDefaultBfieldON); - - m_GTFitSeg_chi2Cut = 15.; - declareProperty("GTFitSeg_chi2Cut",m_GTFitSeg_chi2Cut); - - m_GTFitSeg_minNumHits = 4; - declareProperty("GTFitSeg_minNumHits",m_GTFitSeg_minNumHits); - - m_GTFitSeg_maxNumHits = 10; - declareProperty("GTFitSeg_maxNumHits",m_GTFitSeg_maxNumHits); - - m_GTFitDebug = false; - declareProperty("GTFitDebug",m_GTFitDebug); - - // DO TRACK ANALYSIS - m_doTracks = false; - declareProperty("doTracks",m_doTracks); - - m_TrkAuthor = -1; - declareProperty("TrkAuthor",m_TrkAuthor); - - m_DeadElementsAlgorithm= 1; //1 = analysis by Marco, 0 = analysis by Toni - declareProperty("DeadElementsAlgorithm",m_DeadElementsAlgorithm); -} - -//::::::::::::::::: -//:: METHOD init :: -//::::::::::::::::: -StatusCode NtupleMdtDqaTool::initialize() { - - ATH_MSG_INFO("Initializing NtupleMdtDqaTool"); - - ATH_CHECK(m_idHelperSvc.retrieve()); - - ATH_CHECK(detStore()->retrieve(m_detMgr)); - - //retrieve fixed id tool - std::string idToFixedIdToolType("MuonCalib::IdToFixedIdTool"); - std::string idToFixedIdToolName("MuonCalib_IdToFixedIdTool"); - - ATH_CHECK(toolSvc()->retrieveTool(idToFixedIdToolType, idToFixedIdToolName, m_id_tool)); - - //get region selection service - ATH_CHECK(service("RegionSelectionSvc", p_reg_sel_svc)); - - //get pointer to Calibration input service - ATH_CHECK(service("MdtCalibInputSvc", p_calib_input_svc)); - - //------------------------------------------------------// - //-- Check Region and book histograms --// - //------------------------------------------------------// - - PhiEtaNameConverter phiEtaConverter; - - // loop on stations to find SectorMin and SectorMax - int barrelEndCap; // 1 = Barrel ; 2 = EndCap - int iside; // iside = 1 => "A" ; iside = 2 => "C" - - int sectorMin = 20; - int sectorMax = 0; - int SectorMin[2][2] ; - int SectorMax[2][2] ; - int SectorMinMax[2][2][2]; - std::string spectrometerRegion[2]; - std::string spectrometerSide[2]; - spectrometerRegion[0] = "Barrel"; - spectrometerRegion[1] = "Endcap"; - spectrometerSide[0] = "A"; - spectrometerSide[1] = "C"; - for (int i=0;i<=1;i++) { - for (int j=0;j<=1;j++) { - SectorMin[i][j] = 20; - SectorMax[i][j] = 0; - SectorMinMax[i][j][0] = 20; - SectorMinMax[i][j][1] = 0; - } - } - - const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions(); - std::vector<MuonCalib::NtupleStationId>::const_iterator itstation; - for (itstation = stationsInRegion.begin(); itstation!=stationsInRegion.end(); itstation++) { - std::string stationName = itstation->regionId(); - std::string chamberType = stationName.substr(0,3); - int phi = itstation->GetPhi(); - int eta = itstation->GetEta(); - - MDTName chamb(chamberType,phi,eta); - int sector=chamb.getOnlineSector(); - iside = 1; - if (chamb.isBackward()) iside = 2; - barrelEndCap = 1; - if ( chamb.isEndcap() ) barrelEndCap = 2; - if(sector>SectorMax[barrelEndCap-1][iside-1]) SectorMax[barrelEndCap-1][iside-1] = sector; - if(sector<SectorMin[barrelEndCap-1][iside-1]) SectorMin[barrelEndCap-1][iside-1] = sector; - if(sector>sectorMax) sectorMax = sector; - if(sector<sectorMin) sectorMin = sector; - - if(sector<SectorMinMax[barrelEndCap-1][iside-1][0]) SectorMinMax[barrelEndCap-1][iside-1][0] = sector; - if(sector>SectorMinMax[barrelEndCap-1][iside-1][1]) SectorMinMax[barrelEndCap-1][iside-1][1] = sector; - } - - - //------------------------------------------------------------// - // Attach chamber name to output file name, // - // only if 1 chamber is analysed and filling is requested // - //------------------------------------------------------------// - if (stationsInRegion.size() ==1 && m_fillHistos ) - m_MdtDqa_file_name +="_"+stationsInRegion.at(0).regionId(); - - //-----------------------------------------------------------// - //-- Create Histogram Manager, Root Files and Book Histos --// - //-----------------------------------------------------------// - - // m_histoManager = new HistogramManager(); - - // use HistogramManager constructor with MdtIdHelper to retrieve the chamber geometry - m_histoManager = new HistogramManager(m_idHelperSvc.get()); - m_histoManager->SetDoTracks(m_doTracks); - - std::string mdtDqaRootFileName = m_MdtDqa_file_name+".root"; - if (m_fillHistos || m_doTracks) { - if(!m_histoManager->openOutputFile(mdtDqaRootFileName)) return StatusCode::FAILURE; - } - - if(m_doTracks) m_histoManager->buildTrackHistos(); - - if (m_fillHistos) { - // - // loop over REGIONS and Book TopLevel histograms : - // - // here below we should replace the use of SectorMin[i][j] with : SectorMinMax[i][j][0,1] - // - m_histoManager->buildGlobalHistos(); - for (int i=0;i<=1;i++) { - for (int j=0;j<=1;j++) { - int secMin = SectorMin[i][j]; - int secMax = SectorMax[i][j]; - if (secMin>0&&secMin<=16 && secMax>0&&secMax<=16 && secMin<=secMax ) { - m_histoManager->buildTopLevel(spectrometerRegion[i],spectrometerSide[j], secMin, secMax); - } - } - } - // - // loop over stations and Book Chamber histograms : - // - for (itstation = stationsInRegion.begin(); itstation!=stationsInRegion.end(); itstation++) { - // int stationNameId = itstation->GetStation(); - std::string stationName = itstation->regionId(); - std::string chamberType = stationName.substr(0,3); - int phi = itstation->GetPhi(); - int eta = itstation->GetEta(); - - MDTName chamb(chamberType,phi,eta); - std::string region = chamb.getRegion(); - std::string side = chamb.getSide(); - m_histoManager->buildChamberHistos(chamb); - } - } - - // put a protection if file is not open! - if (!(m_fillHistos || m_doTracks)) { - if (!m_histoManager->openUpdateFile(mdtDqaRootFileName)) return StatusCode::FAILURE; - } - - //------------------------------------------------------// - //-- Create Analysis Tools --// - //------------------------------------------------------// - - m_ntupleAna = new MdtDqaNtupleAnalysis(m_verbose, m_MdtDqa_file_name); - if(!m_ntupleAna->initialize(p_reg_sel_svc, m_histoManager, m_DeadElementsAlgorithm, m_ADCCUT).isSuccess()) { - return StatusCode::FAILURE; - } - - m_segmentAnalyzer=new SegmentAnalysis(p_reg_sel_svc,m_histoManager,m_verbose,m_doHitResids); - - if (m_doEfficiency) { - m_tubeEffi = new MdtDqaTubeEfficiency(m_EffiNSigma, m_EffiChi2Cut, - m_EffiUseDefaultResolution, m_EffiHitADCCut, m_EffiGTFitON, - m_EffiUseNewCalibConstants, m_EffiUseTimeCorrections); - if(!m_tubeEffi->initialize(m_idHelperSvc.get(), m_detMgr, m_id_tool, p_reg_sel_svc, p_calib_input_svc, m_histoManager).isSuccess()) return StatusCode::FAILURE; - } - - if (m_doGlobalTimeFit) { - m_globalTimeFit = new MdtDqaGlobalTimeFit(m_GTFitSeg_minNumHits,m_GTFitSeg_maxNumHits,m_GTFitSeg_chi2Cut, - m_rtDefaultBfieldON, m_GTFitDebug); - if(!m_globalTimeFit->initialize(m_detMgr, m_id_tool, p_reg_sel_svc, m_histoManager).isSuccess()) return StatusCode::FAILURE; - } - //FOR THE TRACK ANALYSIS - if (m_doTracks) { - m_trackAnalyzer=new MdtDqaTrackAnalysis(p_reg_sel_svc,m_TrkAuthor, m_histoManager,m_verbose); - } - return StatusCode::SUCCESS; -} - -//***************************************************************************** - -//::::::::::::::::::::: -//:: METHOD finalize :: -//::::::::::::::::::::: - -StatusCode NtupleMdtDqaTool::finalize(void) { - - ATH_MSG_INFO("Finalizing NtupleMdtDqaTool"); - - if (m_doFinalize) { - ATH_MSG_INFO("Executing MdtDqaNtupleAnalysis::histogramAnalysis "); - m_ntupleAna->histogramAnalysis(m_histoManager->rootFile()); - } - - m_histoManager->WriteAndCloseFile(); - return StatusCode::SUCCESS; -} //end NtupleMdtDqaTool::initialize - -//***************************************************************************** - -//:::::::::::::::::::::::: -//:: METHOD handleEvent :: -//:::::::::::::::::::::::: -StatusCode NtupleMdtDqaTool::handleEvent( const MuonCalibEvent &event, - int eventnumber, - const std::vector<MuonCalibSegment *> &segments, - unsigned int position) { - - if ( m_fillHistos) m_ntupleAna->handleEvent(event, eventnumber,segments,position); - if ( m_fillHistos) m_segmentAnalyzer->handleEvent(event, eventnumber, segments, position); - if ( m_doEfficiency) - if(!m_tubeEffi->handleEvent(event, eventnumber, segments, position).isSuccess()) return StatusCode::FAILURE; - if ( m_doGlobalTimeFit) - if(!m_globalTimeFit->handleEvent(event, eventnumber, segments, position).isSuccess()) return StatusCode::FAILURE; - if (m_doTracks) { - m_trackAnalyzer->handleEvent(event, eventnumber, segments, position); - } - return StatusCode::SUCCESS; -} - -//***************************************************************************** - -//:::::::::::::::::::::::::::: -//:: METHOD analyseSegments :: -//:::::::::::::::::::::::::::: -StatusCode NtupleMdtDqaTool::analyseSegments(const std::vector<MuonCalibSegment *> &/*segments*/) { - ATH_MSG_INFO("NtupleMdtDqaTool::analyseSegments ...it does nothing analysis moved elsewhere"); - return StatusCode::SUCCESS; -} - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleSplitterTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleSplitterTool.cxx deleted file mode 100644 index 25308b11b6f5aa2c94f62ffeed54f788281ae814..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleSplitterTool.cxx +++ /dev/null @@ -1,430 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//c - c++ -#include "iostream" -#include "fstream" -#include "sstream" -#include <string.h> - -//root -#include "TFile.h" -#include "TTree.h" - - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibPattern.h" -#include "MuonCalibEventBase/MuonCalibTruthCollection.h" -#include "MuonCalibEventBase/MuonCalibTruth.h" -#include "MuonCalibEventBase/MuonCalibMdtTruthHit.h" -#include "MuonCalibEventBase/MuonCalibRpcTruthHit.h" -#include "MuonCalibEventBase/MuonCalibTgcTruthHit.h" -#include "MuonCalibEventBase/MuonCalibCscTruthHit.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibRawRpcHit.h" -#include "MuonCalibEventBase/MuonCalibRawTgcHit.h" - -//MuonCalibExtraTreeAlg -#include "MuonCalibExtraTreeAlg/MuonCalibHit_EBranch.h" -#include "MuonCalibExtraTreeAlg/MuonCalibTrack_EBranch.h" - -//MuonCalibExtraTreeEvent -#include "MuonCalibExtraTreeEvent/MuonCalibEvent_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibHit_E.h" -#include "MuonCalibExtraTreeEvent/MuonCalibTrack_E.h" - - -//MuonCalibIdentifier -#include "MuonCalibIdentifier/MuonFixedId.h" - -//MuonCalibNtuple -#include "MuonCalibNtuple/MuonCalibBranchNtuple.h" -#include "MuonCalibNtuple/RootFileManager.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//this -#include "NtupleSplitterTool.h" - - -namespace MuonCalib { - -NtupleSplitterTool::NtupleSplitterTool(const std::string &t, const std::string &n, const IInterface *p): - AthAlgTool(t, n, p), m_split_level(1), m_ntuple_split_level(2), - m_calib_tool_handle("MuonCalib::NtupleRunScanTool"), m_file_number(0), m_stored_patterns(0) { - declareInterface< NtupleCalibrationTool >(this); - declareProperty("FileSplitLevel",m_split_level ); - declareProperty("NtupleSplitLevel", m_ntuple_split_level); - declareProperty("ToolToRun", m_calib_tool_handle); - m_max_patterns=0; - declareProperty("MaxPatterns", m_max_patterns); - m_filename_prefix="Ntuple"; - declareProperty("FilenamePrefix", m_filename_prefix); - m_store_truth = false; - declareProperty("StoreTruth", m_store_truth); - m_store_mdt_rawdata = false; - declareProperty("StoreMdtRawdata", m_store_mdt_rawdata); - m_adc_cut =0; - declareProperty("AdcCut", m_adc_cut); - m_store_rpc_rawdata=false; - declareProperty("StoreRpcRawdata", m_store_rpc_rawdata); - m_store_tgc_rawdata=false; - declareProperty("StoreTgcRawdata", m_store_tgc_rawdata); - m_trigger_only_segment_stations = true; - declareProperty("TriggerForSegmentStationOnly", m_trigger_only_segment_stations); - m_store_raw_triger = false; - declareProperty("StoreRawTriggerData", m_store_raw_triger); - declareProperty("FillTrackAuthors", m_track_authors); - m_all_fill_tracks=false; - m_track_p_cut=-3.; - declareProperty("TrackPCut", m_track_p_cut); -} //end NtupleSplitterTool::NtupleSplitterTool - -StatusCode NtupleSplitterTool::initialize() { -//get region selection service - StatusCode sc=service("RegionSelectionSvc", p_reg_sel_svc); - if(!sc.isSuccess()) { - ATH_MSG_ERROR("Cannot retrieve RegionSelectionSvc!"); - return sc; - } - sc = m_calib_tool_handle.retrieve(); - if (m_ntuple_split_level<m_split_level) { - ATH_MSG_WARNING("Setting ntuple split level to file split level!"); - m_ntuple_split_level = m_split_level; - } - for(std::vector<int>::iterator it=m_track_authors.begin(); it!=m_track_authors.end(); it++) { - if ((*it)<0) { - m_all_fill_tracks=true; - break; - } - m_track_authors_set.insert(*it); - } - return sc; -} //end NtupleSplitterTool::initialize - -StatusCode NtupleSplitterTool::finalize() { - RootFileManager * rfm=RootFileManager::getInstance(); - rfm->closeFile(); - return StatusCode::SUCCESS; -} - -StatusCode NtupleSplitterTool::handleEvent(const MuonCalibEvent &event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position) { -//loop over al lnew segments - m_stations_with_seg_hits.clear(); - std::map<NtupleStationId, MuonCalibPattern *> region_patterns; - for (unsigned int i=position; i<segments.size(); i++) { - MuonCalibSegment *segment=segments[i]; - //get list of regions - std::set<NtupleStationId> current_regions; - for(MuonCalibSegment::MdtHitCit it=segment->mdtHOTBegin(); it!=segment->mdtHOTEnd(); it++) { - NtupleStationId c_id((*it)->identify()); - c_id.SetMultilayer(0); - m_stations_with_seg_hits.insert(c_id); - c_id=ntuple_region_id((*it)->identify()); - //create new pattern if needed - if(region_patterns[c_id]==NULL) { - region_patterns[c_id] = new MuonCalibPattern(); - } - //fill segment in patttern, if it is not already inserted - if(current_regions.find(c_id)==current_regions.end()) { - region_patterns[c_id]->addMuonSegment(new MuonCalibSegment(*segment)); - current_regions.insert(c_id); - } - } - } - -//fill patterns - m_ntuples_initialized.clear(); - for(std::map<NtupleStationId,MuonCalibPattern * >::iterator it=region_patterns.begin(); it!=region_patterns.end(); it++) { - m_stored_patterns++; - MuonCalibBranchNtuple *ntpl(get_ntuple(it->first)); - m_ntuples_initialized.insert(it->first); - ntpl->fillEventToTree(event.eventInfo()); - ntpl->handlePattern(*(it->second)); - } - -//fill rawdata collections - const MuonCalibRawHitCollection *raw_hit_coll(event.rawHitCollection()); - if(raw_hit_coll!=NULL) { - m_rawdata_collections.clear(); - //mdt hits - if(m_store_mdt_rawdata) - process_rawdata<MuonCalibRawMdtHit>( raw_hit_coll->rawMdtHitCollectionBegin(), raw_hit_coll->rawMdtHitCollectionEnd()); - if(m_store_rpc_rawdata) - process_rawdata<MuonCalibRawRpcHit>( raw_hit_coll->rawRpcHitCollectionBegin(), raw_hit_coll->rawRpcHitCollectionEnd()); - if(m_store_tgc_rawdata) - process_rawdata<MuonCalibRawTgcHit>( raw_hit_coll->rawTgcHitCollectionBegin(), raw_hit_coll->rawTgcHitCollectionEnd()); - - for(std::map<NtupleStationId, MuonCalibRawHitCollection *>::iterator it = m_rawdata_collections.begin(); it!= m_rawdata_collections.end(); it++) { - MuonCalibBranchNtuple *ntpl(get_ntuple(it->first)); - if(m_ntuples_initialized.find(it->first) == m_ntuples_initialized.end()) { - m_ntuples_initialized.insert(it->first); - ntpl->fillEventToTree(event.eventInfo()); - } - ntpl->handleRawHits(*(it->second)); - } - } - -//loop on truth - const MuonCalibTruthCollection *truth(event.calibTruthCollection()); - if(truth != NULL && m_store_truth) { - m_truth_ntuples.clear(); -//fill mdt truth - fill_truth(truth->mdtTruthCollectionBegin(), truth->mdtTruthCollectionEnd(), event); -//fill rpc truth - fill_truth(truth->rpcTruthCollectionBegin(), truth->rpcTruthCollectionEnd(), event); -//fill tgc truth - fill_truth(truth->tgcTruthCollectionBegin(), truth->tgcTruthCollectionEnd(), event); -//fill csc truth - fill_truth(truth->cscTruthCollectionBegin(), truth->cscTruthCollectionEnd(), event); - }//if(truth != NULL && m_store_truth) -//fill ntuples - -//fill tracks - if(m_track_authors.size()) { - try { - const MuonCalibEvent_E & extra_event = dynamic_cast<const MuonCalibEvent_E &>(event); - fillTrackNtuple(extra_event); - } - catch(const std::bad_cast& exp) { - ATH_MSG_WARNING("Not reading extra tree, but track writing is requested!"); - m_track_authors.clear(); - } - } - - for(std::set<NtupleStationId>::const_iterator it=m_ntuples_initialized.begin(); it != m_ntuples_initialized.end(); it++) { - MuonCalibBranchNtuple *ntpl(m_ntuples[*it]); - if(!ntpl) continue; - if(m_store_raw_triger) - ntpl->handleRawTriggerHits( *event.rawTriggerHitCollection() ); - ntpl->finishEvent(); - } -//clear - for(std::map<NtupleStationId,MuonCalibPattern * >::iterator it=region_patterns.begin(); it!=region_patterns.end(); it++) { - delete it->second; - } - for(std::map<NtupleStationId, MuonCalibRawHitCollection *>::iterator it = m_rawdata_collections.begin(); it!= m_rawdata_collections.end(); it++) { - delete it->second; - } - return m_calib_tool_handle->handleEvent(event, evnt_nr, segments, position); -} //end NtupleSplitterTool::handleEvent - -inline void NtupleSplitterTool::fillTrackNtuple(const MuonCalibEvent_E &extra_event) { - for(std::map<NtupleStationId, MuonCalibHit_EBranch *>::iterator it=m_track_hit_branch.begin(); it!=m_track_hit_branch.end(); it++) - (it->second)->reset(); - for(std::map<NtupleStationId, MuonCalibTrack_EBranch *>::iterator it=m_track_branch.begin(); it!=m_track_branch.end(); it++) - (it->second)->reset(); - - for(MuonCalibEvent_E::TrackVec::const_iterator t_it = extra_event.beginTrack(); t_it!=extra_event.endTrack(); t_it++) { - const MuonCalibTrack_E *track(*t_it); - if(!m_all_fill_tracks && m_track_authors_set.find(track->author()) == m_track_authors_set.end()) { - continue; - } - if (m_track_p_cut>-1) { - if(track->qOverP()==0 || track->p()>1e8) { - continue; - } - if(m_track_p_cut>=0 && std::abs(track->p())<m_track_p_cut) { - continue; - } - } - std::list<MuonCalibHit_EBranch *> hit_branches; - std::list<MuonCalibTrack_EBranch *> track_branches; - std::set<NtupleStationId> station_ids; - - for(MuonCalibTrack_E::HitVector::const_iterator h_it=track->beginHit(); h_it!=track->endHit(); h_it++) { - const MuonCalibHit_E *hit(*h_it); - if(hit->type()!=1) continue; - const MuonFixedId &id(hit->identify()); - if(!p_reg_sel_svc->isInRegion(id)) continue; - for(std::map<NtupleStationId, MuonCalibHit_EBranch *>::const_iterator map_it=m_track_hit_branch.begin(); map_it!=m_track_hit_branch.end(); map_it++) { - if(station_ids.find(map_it->first) != station_ids.end()) - continue; - if(map_it->first == id) { - station_ids.insert(map_it->first); - hit_branches.push_back(map_it->second); - track_branches.push_back( m_track_branch[map_it->first] ); - m_ntuples_initialized.insert(map_it->first); - } - } - } - std::list<MuonCalibHit_EBranch *>::iterator hb_it=hit_branches.begin(); - std::list<MuonCalibTrack_EBranch *>::iterator tb_it=track_branches.begin(); - while (hb_it!=hit_branches.end() && tb_it!=track_branches.end()) { - if(!(*tb_it)->fillBranch(*track)) { - ATH_MSG_WARNING("Overfull track branch!"); - hb_it++; - tb_it++; - continue; - } - for(MuonCalibTrack_E::HitVector::const_iterator h_it=track->beginHit(); h_it!=track->endHit(); h_it++) { - const MuonCalibHit_E *hit(*h_it); - if(!((*hb_it)->fillBranch(*hit, 0., (*tb_it)->getBranchEntries() - 1))) { - ATH_MSG_WARNING("Overfull hit branch! "<<(*hb_it)->getBranchEntries()); - } - } - hb_it++; - tb_it++; - } - } -} //end NtupleSplitterTool::fillTrackNtuple - -inline MuonCalibBranchNtuple* NtupleSplitterTool::get_ntuple(const NtupleStationId &id) { - if(m_max_patterns>0 && m_stored_patterns>=m_max_patterns) { - RootFileManager *rfm=RootFileManager::getInstance(); - rfm->closeFile(); - for(std::map<NtupleStationId, MuonCalibBranchNtuple *>::iterator it=m_ntuples.begin(); it!=m_ntuples.end(); it++) - delete it->second; - m_ntuples.clear(); - m_stored_patterns=0; - m_file_number++; - } - if(m_ntuples[id]==NULL) { - RootFileManager *rfm=RootFileManager::getInstance(); - //generate file name - MuonFixedId fixid; - std::ostringstream filename; - filename<<m_filename_prefix; - if (m_split_level>0) { - filename<<"_"<<fixid.stationNumberToFixedStationString( id.GetStation()); - } - if (m_split_level>1) { - filename<<"_"<<id.GetPhi(); - } - if (m_split_level>2) { - filename<<"_"<<id.GetEta(); - } - filename<<"."<<m_file_number<<".root"; - rfm->openFile(filename.str()); - //generate region id - std::ostringstream region_id; - if (m_ntuple_split_level<1) { - region_id<<"PatternNtupleMaker"; - } else { - region_id<<fixid.stationNumberToFixedStationString( id.GetStation()); - } - if(m_ntuple_split_level>1) { - region_id<<"_"<<id.GetPhi(); - } - if(m_ntuple_split_level>2) { - region_id<<"_"<<id.GetEta(); - } - MuonCalibBranchNtuple *ntup=new MuonCalibBranchNtuple(region_id.str()); - m_ntuples[id] = ntup; - MuonCalibHit_EBranch *h_br=new MuonCalibHit_EBranch(); - h_br->createBranch(ntup->getTTree()); - m_track_hit_branch[id] = h_br; - MuonCalibTrack_EBranch *t_br=new MuonCalibTrack_EBranch(); - t_br->createBranch(ntup->getTTree()); - m_track_branch[id] = t_br; - } - return m_ntuples[id]; -} //end NtupleSplitterTool::get_ntuple - -inline NtupleStationId NtupleSplitterTool::ntuple_region_id(const MuonFixedId &id) { - if (m_ntuple_split_level<1) { - NtupleStationId c_id; - return c_id; - } - NtupleStationId c_id(id); - c_id.SetMultilayer(0); - if (m_ntuple_split_level<3) - c_id.SetEta(-99); - if (m_ntuple_split_level<2) - c_id.SetPhi(-1); - return c_id; -} - -inline void NtupleSplitterTool::add_truth(const MuonCalibTruthCollection *truth, MuonCalibBranchNtuple *ntpl) { - for(MuonCalibTruthCollection::TruthVecCit it=truth->truthCollectionBegin(); it!=truth->truthCollectionEnd(); it++) { - ntpl->fillTruthToTree(**it); - } -} - -inline MuonCalibBranchNtuple * NtupleSplitterTool ::get_ntuple_for_truth(const NtupleStationId &c_id, const MuonCalibEvent &event) { - const MuonCalibTruthCollection *truth(event.calibTruthCollection()); - MuonCalibBranchNtuple *ntpl=m_truth_ntuples[c_id]; - if(ntpl==NULL) { - ntpl = get_ntuple(c_id); - m_truth_ntuples[c_id] = ntpl; - add_truth(truth, ntpl); - if(m_ntuples_initialized.find(c_id) == m_ntuples_initialized.end()) { - ntpl->fillEventToTree(event.eventInfo()); - m_ntuples_initialized.insert(c_id); - m_truth_ntuples[c_id] = ntpl; - } - } - return ntpl; -} - -template<typename T, typename Tit> -void NtupleSplitterTool ::process_rawdata(Tit begin, Tit end) { - for(Tit it = begin; it != end; it++) { - if(!p_reg_sel_svc->isInRegion((*it)->identify())) - continue; - if(!rawdata_selector(**it)) continue; - NtupleStationId c_id(ntuple_region_id((*it)->identify())); - MuonCalibRawHitCollection * coll(m_rawdata_collections[c_id]); - if (coll==NULL) { - coll = new MuonCalibRawHitCollection(); - m_rawdata_collections[c_id] =coll; - } - coll->addMuonCalibRawHit(new T(**it)); - } -} - -inline bool NtupleSplitterTool ::rawdata_selector(const MuonCalibRawMdtHit &hit) { - return hit.adcCount() >= m_adc_cut; -} - -inline bool NtupleSplitterTool ::rawdata_selector(const MuonCalibRawRpcHit &hit) { - if(!m_trigger_only_segment_stations) - return true; - - const MuonFixedId &id(hit.identify()); - NtupleStationId s_id(id.stationNameString(), id.eta(), id.phi()); - return m_stations_with_seg_hits.find(s_id) != m_stations_with_seg_hits.end(); -} - -inline bool NtupleSplitterTool ::rawdata_selector(const MuonCalibRawTgcHit &hit) { - if(!m_trigger_only_segment_stations) - return true; - - const MuonFixedId &id(hit.identify()); - NtupleStationId s_id(id.stationNameString(), id.eta(), id.phi()); - return m_stations_with_seg_hits.find(s_id) != m_stations_with_seg_hits.end(); -} - -template<typename Tit> -void NtupleSplitterTool ::fill_truth(Tit begin, Tit end, const MuonCalibEvent &event) { - for (Tit it=begin; it!=end; it++) { - if(!p_reg_sel_svc->isInRegion((*it)->identify())) - continue; - NtupleStationId c_id(ntuple_region_id((*it)->identify())); - MuonCalibBranchNtuple *ntpl=get_ntuple_for_truth(c_id, event); - fill_truth_hit(**it, ntpl); - } -} - -inline void NtupleSplitterTool ::fill_truth_hit(const MuonCalibMdtTruthHit &it, MuonCalibBranchNtuple *ntpl) { - ntpl->fillMdtTruthToTree(it); -} - -inline void NtupleSplitterTool ::fill_truth_hit(const MuonCalibRpcTruthHit &it, MuonCalibBranchNtuple *ntpl) { - ntpl->fillRpcTruthToTree(it); -} - -inline void NtupleSplitterTool ::fill_truth_hit(const MuonCalibTgcTruthHit &it, MuonCalibBranchNtuple *ntpl) { - ntpl->fillTgcTruthToTree(it); -} - -inline void NtupleSplitterTool ::fill_truth_hit(const MuonCalibCscTruthHit &it, MuonCalibBranchNtuple *ntpl) { - ntpl->fillCscTruthToTree(it); -} - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleSplitterTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleSplitterTool.h deleted file mode 100644 index 82b4c2f1689bd488cfe668b69a4c98d76c07db03..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleSplitterTool.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _NtupleSplitterTool_H -#define _NtupleSplitterTool_H - -//c - c++ -#include "map" - -//Gaudi -#include "GaudiKernel/ToolHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" - -//root -class TFile; - -//MuonCalibStandAloneBase -class RegionSelectionSvc; - -namespace MuonCalib { - -class MuonCalibBranchNtuple; -class MuonCalibTruthCollection; -class MuonCalibRawMdtHit; -class MuonCalibRawRpcHit; -class MuonCalibRawTgcHit; -class MuonCalibMdtTruthHit; -class MuonCalibRpcTruthHit; -class MuonCalibTgcTruthHit; -class MuonCalibCscTruthHit; -class MuonCalibHit_EBranch; -class MuonCalibTrack_EBranch; -class MuonCalibEvent_E; - -/** @class NtupleSplitterTool -Scans a run and checks for present chambers and number of hits -@author rauscher@cern.ch -*/ - -class NtupleSplitterTool: public AthAlgTool, virtual public NtupleCalibrationTool { - public: -//============================================================================== - /** Tool Constructor*/ - NtupleSplitterTool(const std::string &t, const std::string &n, const IInterface *p); - /** tool initialization */ - StatusCode initialize(); - /** tool finalization */ - StatusCode finalize(); - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** we dont need to keep the segments*/ - bool KeepSegments() const { - return m_calib_tool_handle->KeepSegments(); - } - inline StatusCode analyseSegments(const std::vector<MuonCalibSegment *> &segments) { - return m_calib_tool_handle->analyseSegments(segments); - } - inline const IMdtCalibrationOutput* getResults() const { - return m_calib_tool_handle->getResults(); - } - inline const IRtResolution* getResolution() const { - return m_calib_tool_handle->getResolution(); - } - -//============================================================================== - private: - /** vector with ntuples*/ - std::map<NtupleStationId, MuonCalibBranchNtuple *> m_ntuples; - std::map<NtupleStationId, MuonCalibHit_EBranch *> m_track_hit_branch; - std::map<NtupleStationId, MuonCalibTrack_EBranch *> m_track_branch; - /** file split by level: <1 do not split file - 1 split by station - 2 split by station and phi - >2 split by station and phi and eta*/ - int m_split_level; - /** ntuple split level - minimum is split by station*/ - int m_ntuple_split_level; - /** create new files after given number of patterns */ - int m_max_patterns; - /** store truth information - jo*/ - bool m_store_truth; - /** store rawdata - jo */ - bool m_store_mdt_rawdata; - /** store rpc rawdata */ - bool m_store_rpc_rawdata; - bool m_store_tgc_rawdata; - /** store rpc data only for stations with segments */ - bool m_trigger_only_segment_stations; - /** store raw trigger data */ - bool m_store_raw_triger; - /** fill track branches - job-option */ - std::vector<int> m_track_authors; - std::set<int> m_track_authors_set; - bool m_all_fill_tracks; - double m_track_p_cut; - int m_adc_cut; - /** filename prefix **/ - std::string m_filename_prefix; - /** calibration tool to run while splitting */ - ToolHandle<NtupleCalibrationTool> m_calib_tool_handle; - //book keeping - std::map<NtupleStationId, MuonCalibBranchNtuple *> m_truth_ntuples; - std::set<NtupleStationId> m_ntuples_initialized; - //rawdata collections - std::map<NtupleStationId, MuonCalibRawHitCollection *> m_rawdata_collections; - //stations with segment hits - std::set<NtupleStationId> m_stations_with_seg_hits; - /** current file number and number of stored patterns */ - // calibration region // - RegionSelectionSvc *p_reg_sel_svc; - int m_file_number; - int m_stored_patterns; - inline MuonCalibBranchNtuple* get_ntuple(const NtupleStationId &id); - inline NtupleStationId ntuple_region_id(const MuonFixedId &id); - inline void add_truth(const MuonCalibTruthCollection *truth, MuonCalibBranchNtuple *ntpl); - inline MuonCalibBranchNtuple* get_ntuple_for_truth(const NtupleStationId &id, const MuonCalibEvent &event); - - template<typename T, typename Tit> - void process_rawdata(Tit begin, Tit end); - inline bool rawdata_selector(const MuonCalibRawMdtHit &hit); - inline bool rawdata_selector(const MuonCalibRawRpcHit &hit); - inline bool rawdata_selector(const MuonCalibRawTgcHit &hit); - - template<typename Tit> - void fill_truth(Tit begin, Tit end, const MuonCalibEvent &event); - inline void fill_truth_hit(const MuonCalibMdtTruthHit &it, MuonCalibBranchNtuple *ntpl); - inline void fill_truth_hit(const MuonCalibRpcTruthHit &it, MuonCalibBranchNtuple *ntpl); - inline void fill_truth_hit(const MuonCalibTgcTruthHit &it, MuonCalibBranchNtuple *ntpl); - inline void fill_truth_hit(const MuonCalibCscTruthHit &it, MuonCalibBranchNtuple *ntpl); - inline void fillTrackNtuple(const MuonCalibEvent_E &extra_event); -}; - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/SegmentAnalysis.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/SegmentAnalysis.cxx deleted file mode 100644 index a0d7dbf2d474181bc9b94b3936dc90679133c210..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/SegmentAnalysis.cxx +++ /dev/null @@ -1,388 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_SegmentAnalysisCXX -#define MuonCalib_SegmentAnalysisCXX - -#include "MuonCalibStandAloneExtraTools/SegmentAnalysis.h" -#include "TH1.h" -#include "TMath.h" // for TMath::Prob() -#include <cmath> - -#include "MdtCalibFitters/DCSLFitter.h" -#include "MuonCalibStandAloneExtraTools/PhiEtaUtils.h" -#include "MuonCalibStandAloneExtraTools/StringUtil.h" -#include "MuonCalibStandAloneExtraTools/MDTName.h" - -namespace MuonCalib{ - -SegmentAnalysis::SegmentAnalysis(RegionSelectionSvc *punt, HistogramManager *histoman, bool verbose, bool dohitresids) { - m_histoManager=histoman; - p_reg_sel_svc=punt; - m_verbose=verbose; - m_doHitResids=dohitresids; - - PhiEtaNameConverter phiEtaConverter; - std::string testName="BIL1A01" ; - MDTName NameConverter(testName) ; - m_SectorMin = 20 ; - m_SectorMax = 0 ; - const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions() ; - std::vector<MuonCalib::NtupleStationId>::const_iterator itstation ; - for (itstation = stationsInRegion.begin() ; itstation!=stationsInRegion.end(); itstation++) { - int stationNameId = itstation->GetStation() ; - int phi = itstation->GetPhi() ; - int sector = phiEtaConverter.phi_8to16(stationNameId,phi); - if(sector>m_SectorMax) m_SectorMax = sector ; - if(sector<m_SectorMin) m_SectorMin = sector ; - } -} //end SegmentAnalysis::SegmentAnalysis - -void SegmentAnalysis::handleEvent(const MuonCalibEvent &event, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) { - - float CHI2CUT=50. ; - - //Event number - int evtNumber = event.eventInfo().eventNumber() ; - - ToString ts; - PhiEtaNameConverter phiEtaConverter; - - if( !p_reg_sel_svc){ - return; - } - - std::string histoType="seg"; - TH1F *h1seg = (TH1F*) m_histoManager->GetHisto("GLOBAL",histoType); - float NumOfSeg = (float) segments.size() - position ; - if (h1seg) h1seg->Fill( NumOfSeg ); - - //=========================================================================== - - // ==== SEGMENT LOOP ========================================================= - //Looping over all segments in the event - // - TH1F * hseg; - TH2F * h2; - - for (unsigned int k=position; k<segments.size(); k++) { // LOOP OVER SEGMENTS - MuonCalibSegment *segment(segments[k]); - - unsigned int MinNumOfHitsPerSegment = 4 ; - - if ( segment->mdtHitsOnTrack()==0) { - continue; - } - - if ( segment->mdtHitsOnTrack()<MinNumOfHitsPerSegment) { - continue; - } - - std::vector<MdtCalibHitBase*>::const_iterator hit_it ; - std::vector<MdtCalibHitBase*>::const_iterator hit_it_start = segment->mdtHOTBegin(); - std::vector<MdtCalibHitBase*>::const_iterator hit_it_end = segment->mdtHOTEnd(); - - bool segmentIsInRegion = false ; - for (hit_it=hit_it_start; hit_it != hit_it_end; ++hit_it) { - if (p_reg_sel_svc->isInRegion((*hit_it)->identify())) segmentIsInRegion = true ; - } - if (!segmentIsInRegion) { - continue; - } - - //========= - int crossing = multiChambSeg(segment); - if (crossing) { - continue; - } - - int segStation = segmentStation(segment); - int segEta = segmentEta(segment); - int segPhi = segmentPhi(segment); - - int segPhi2=phiEtaConverter.phi_8to16(segStation,segPhi); - - bool doSector=false; - if(segPhi2>=m_SectorMin && segPhi2<=m_SectorMax) doSector=true; - if(!doSector) continue; - - //== build chamber name - - MuonFixedId id; - std::string segstn = id.stationNumberToFixedStationString(segStation); - MDTName chambseg(segstn,segPhi,segEta); - - std::string chamberName = chambseg.getOnlineName(); - std::string side=chambseg.getSide(); - std::string region=chambseg.getRegion(); - - // Fill HitsOnSegments and Prob(chi2,ndeg) - // - float hitsOnSeg = (float) segment->mdtHitsOnTrack() ; - float SegChi2DoF = segment->chi2() ; // this returns the reduced chi2. - // Hopefully the correct nDoF is considered when t0-refit is active! - float nSegParams = 2. ; - if (segment->hasFittedT0()) nSegParams = 3. ; - float DoF = hitsOnSeg - nSegParams ; - float SegChi2 = SegChi2DoF*DoF ; - - histoType="HitsOnSegment"+segstn; - hseg = (TH1F*) m_histoManager->GetMdtHisto(histoType,region,side,segPhi2); - if(hseg) hseg->Fill(hitsOnSeg); - - histoType="D_ChamberHitsOnSegment"; - hseg = (TH1F*) m_histoManager->GetMdtHisto(histoType,chambseg); - if(hseg) hseg->Fill(hitsOnSeg); - - histoType="c_Segment_ProbChi2"; - hseg = (TH1F*) m_histoManager->GetMdtHisto(histoType,chambseg); - if (hseg) hseg->Fill(TMath::Prob(SegChi2,(int)DoF)); - // - // HIT and FIT Residuals (HIT: hit included in segment ; FIT: hit excluded ) - // - // NIR. REPLACED BY HITRESID vs Radius - ///////////////////// SNIP BEGIN - - float hitsOnSeg2 = 0; - - histoType="b_SegResidVsRadius"; - h2 = (TH2F*) m_histoManager->GetMdtHisto(histoType,chambseg); - histoType="b_SegmentResidual"; - hseg = (TH1F*) m_histoManager->GetMdtHisto(histoType,chambseg); - - MuonCalib::DCSLFitter dcslFitter; - IMdtSegmentFitter::HitSelection ref_hitsel(segment->mdtHitsOnTrack(), 0); // Reference hit selection, containing 0 for all hits in segment - for (std::vector<MdtCalibHitBase*>::iterator hit_it =segment->mdtHOTBegin() ; - hit_it!=segment->mdtHOTEnd(); ++hit_it) { // Loop on all hits on tracks - - hitsOnSeg2++; - - float resid = 0.0; // residual - float radius = 0.0; // hit drift radius - if (m_doHitResids) { // Do hit residuals vs radius - unsigned int iHit = hit_it-segment->mdtHOTBegin(); - IMdtSegmentFitter::HitSelection hitsel = ref_hitsel; - // Ignore hit iHit; - hitsel[iHit] = 1; - // Clone segment: - MuonCalibSegment segmentClone(*segment); - dcslFitter.fit(segmentClone, hitsel); - - //Get the residual of the ignored hit: - resid = segmentClone.mdtHOT()[iHit]->radialResidual(); - radius = segmentClone.mdtHOT()[iHit]->driftRadius(); - - } else { // Do fit residuals vs radius - resid = (*hit_it)->radialResidual(); - radius = (*hit_it)->driftRadius(); - } - if (radius<0) radius = -radius ; // First take the absolute value of radius - if ((*hit_it)->signedDistanceToTrack()<0.) radius=-radius ; // Then assign the sign of signedDistanceToTrack - - if (h2) h2->Fill(radius,resid); - if (hseg) hseg->Fill(resid); - - } // End loop over hits - ///////////////////// SNIP END - - - //==================================================================================== - //==================================================================================== - // GLOBAL segment_Phi Vs segment_Eta plot - // - float gdirX = segment->globalDirection().x(); - float gdirY = segment->globalDirection().y(); - float gdirZ = segment->globalDirection().z(); - float globalPhi = std::atan2(gdirY,gdirX)* 180./M_PI; ; - float globalTheta = std::acos(gdirZ) ; - float globalEta = -std::log(std::tan(globalTheta/2.)) ; - histoType="phi_vs_eta"; - - h2 = (TH2F*) m_histoManager->GetHisto("GLOBAL",histoType); - if(h2) h2->Fill( globalEta, globalPhi ); - - //==================================================================================== - //==================================================================================== - // slope corr - Still here but no Histograms Filled anymore !!! - // - - //==================================================================================== - //==================================================================================== - // MDT-RPC Correlations FOR THE BARREL - // - if ( region=="Barrel") { - TH1F *hrpc; - TH2F *h2rpc; - std::vector<RpcCalibHitBase*>::const_iterator rpc_hit_it = segment->rpcHOTBegin(); - std::vector<RpcCalibHitBase*>::const_iterator rpc_hit_it_end = segment->rpcHOTEnd(); - for(; rpc_hit_it != rpc_hit_it_end; ++rpc_hit_it){ - //local - double y = (*rpc_hit_it)->localPosition().y(); - double z = (*rpc_hit_it)->localPosition().z(); - MuonFixedId ID = (*rpc_hit_it)->identify(); - std::string cname = ID.stationNumberToFixedStationString( ID.stationName() ) ; - if(segment->chi2() > CHI2CUT ) continue; - int eta=ID.eta(); - int phi2=phiEtaConverter.phi_8to16(segStation,segPhi); - std::string side="A"; - if(eta<0) side="C"; - std::string phisec=ts(phi2); - if(phi2<10) phisec="0"+phisec; - - bool doSector=false; - if(phi2>=m_SectorMin && phi2<=m_SectorMax) doSector=true; - if(!doSector) continue; - //local - double dirY=segment->direction().y(); - double dirZ=segment->direction().z(); - double posY=segment->position().y(); - double posZ=segment->position().z(); - double aseg=0.; - double bseg=0.; - if(dirZ !=0. ) { - aseg=dirY/dirZ; - bseg= posY - aseg*posZ; - } - double dist=(-1*aseg*z+y-bseg)/std::sqrt(aseg*aseg+1); - - - histoType="MDT_RPC"; - hrpc = (TH1F*) m_histoManager->GetTDaqHisto(histoType,region,side,phi2); - if(hrpc)hrpc->Fill(dist); - - histoType="z_MDT_RPC"; - hrpc = (TH1F*) m_histoManager->GetMdtHisto(histoType,region,side,phi2); - if(hrpc)hrpc->Fill(dist); - - histoType="MDT_RPC_Vs_Event"; - h2rpc = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,phi2); - if(h2rpc) h2rpc->Fill((float)evtNumber,dist); - - } // end RPC hit loop - } // end if region == Barrel - - //==================================================================================== - //==================================================================================== - // MDT-TGC Correlations FOR THE ENDCAP - // added by D. Levin,march 18, 2009 - if ( region=="Endcap") { - - TH1F *htgc; - TH2F *h2tgc; - - std::vector<TgcCalibHitBase*>::const_iterator tgc_hit_it = segment->tgcHOTBegin(); - std::vector<TgcCalibHitBase*>::const_iterator tgc_hit_it_end = segment->tgcHOTEnd(); - - for(; tgc_hit_it != tgc_hit_it_end; ++tgc_hit_it){ - - //local - double y = (*tgc_hit_it)->localPosition().y(); - double z = (*tgc_hit_it)->localPosition().z(); - - MuonFixedId ID = (*tgc_hit_it)->identify(); - std::string cname = ID.stationNumberToFixedStationString( ID.stationName() ) ; - - if(segment->chi2() > CHI2CUT ) continue; - - int eta=ID.eta(); - int phi2=phiEtaConverter.phi_8to16(segStation,segPhi); - std::string side="A"; - if(eta<0) side="C"; - std::string phisec=ts(phi2); - if(phi2<10) phisec="0"+phisec; - - bool doSector=false; - if(phi2>=m_SectorMin && phi2<=m_SectorMax) doSector=true; - if(!doSector) continue; - - //local - double dirY=segment->direction().y(); - double dirZ=segment->direction().z(); - double posY=segment->position().y(); - double posZ=segment->position().z(); - - double aseg=0.; - double bseg=0.; - if(dirZ !=0. ) { - aseg=dirY/dirZ; - bseg= posY - aseg*posZ; - } - double dist=(-1*aseg*z+y-bseg)/std::sqrt(aseg*aseg+1); - - - histoType="MDT_TGC"; - htgc = (TH1F*) m_histoManager->GetTDaqHisto(histoType,region,side,phi2); - if(htgc)htgc->Fill(dist); - - histoType="z_MDT_TGC"; - htgc = (TH1F*) m_histoManager->GetMdtHisto(histoType,region,side,phi2); - if(htgc)htgc->Fill(dist); - - histoType="MDT_TGC_Vs_Event"; - h2tgc = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,phi2); - if(h2tgc) h2tgc->Fill((float)evtNumber,dist); - - } // end TGC hit loop - } // end if region == Endcpa - - }//End LOOP over Segments - - return; -} //end SegmentAnalysis::handleEvent - -int SegmentAnalysis::multiChambSeg( MuonCalibSegment *segment ){ - - int flag = false; - - if(segment->mdtHitsOnTrack()<=0) return flag; - - std::vector<MdtCalibHitBase*>::const_iterator hit_it = segment->mdtHOTBegin(); - std::vector<MdtCalibHitBase*>::const_iterator hit_it_end = segment->mdtHOTEnd(); - - MuonFixedId ID1; - ID1 = (*hit_it)->identify() ; - - MuonFixedId ID; - - //Loop over all hits in the segment - for(; hit_it != hit_it_end; ++hit_it) { - - ID = (*hit_it)->identify(); - - if(ID.eta()!=ID1.eta()) flag= true; - if(ID.stationName()!=ID1.stationName()) flag= true; - if(ID.phi()!=ID1.phi()) flag= true; - - if(flag) { - return flag; - } - - }//loop - - return flag; -} //end SegmentAnalysis::multiChambSeg - -int SegmentAnalysis::segmentStation( MuonCalibSegment *segment ){ - std::vector<MdtCalibHitBase*>::const_iterator hit_it = segment->mdtHOTBegin(); - MuonFixedId ID; - ID = (*hit_it)->identify() ; - return ID.stationName(); -} - -int SegmentAnalysis::segmentEta( MuonCalibSegment *segment ){ - std::vector<MdtCalibHitBase*>::const_iterator hit_it = segment->mdtHOTBegin(); - MuonFixedId ID; - ID = (*hit_it)->identify() ; - return ID.eta(); -} - -int SegmentAnalysis::segmentPhi( MuonCalibSegment *segment ){ - std::vector<MdtCalibHitBase*>::const_iterator hit_it = segment->mdtHOTBegin(); - MuonFixedId ID; - ID = (*hit_it)->identify() ; - return ID.phi(); -} - -}//namespace MuonCalib -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/TimeAndAdcFitter.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/TimeAndAdcFitter.cxx deleted file mode 100644 index 2825ce47ffba6f59fe2160966336ff71b4f0c235..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/TimeAndAdcFitter.cxx +++ /dev/null @@ -1,172 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibStandAloneExtraTools/TimeAndAdcFitter.h" -#include "TF1.h" - -void TimeAndAdcFitter::doTimeFit(TH1F *h, const int nParams, double *pfit, double *errfit, double *pchi2, int *pndof ) { - - double minTime = 0.; - double maxTime = 2000.; - - double chi2; - int ndof; - - TF1 *TimeSpectrum = new TF1("TimeSpectrum", - "[0]+([1]*(1+[2]*exp(-(x-[4])/[3])))/((1+exp((-x+[4])/[6]))*(1+exp((x-[5])/[7]))) ", - minTime,maxTime); - TimeSpectrum->SetLineColor(3); - - searchParams(h,&pfit[0],nParams); - - TimeSpectrum->SetParameters(pfit); - TimeSpectrum->SetParLimits(0,0.,100.); - TimeSpectrum->SetParLimits(1,0.,10000.); - TimeSpectrum->SetParLimits(2,0.,40.); - TimeSpectrum->SetParLimits(3,50.,400.); - TimeSpectrum->SetParLimits(4,0.,1500.); - // 5 parameters fit - TimeSpectrum->SetParLimits(5,pfit[5],pfit[5]); - TimeSpectrum->SetParLimits(6,pfit[6],pfit[6]); - TimeSpectrum->SetParLimits(7,pfit[7],pfit[7]); - h->Fit("TimeSpectrum","QLB"); - // 6 parameters fit - TimeSpectrum->SetParLimits(5,500.,2000.); - TimeSpectrum->SetParLimits(6,pfit[6],pfit[6]); - TimeSpectrum->SetParLimits(7,pfit[7],pfit[7]); - h->Fit("TimeSpectrum","QLB"); - // 7 parameters fit - TimeSpectrum->SetParLimits(6,4.,30.); - h->Fit("TimeSpectrum","QLB"); - // final 8 parameters fit - TimeSpectrum->SetParLimits(6,4.,30.); - TimeSpectrum->SetParLimits(7,4.,30.); - double xmin = h->GetBinLowEdge(1); - double xmax = TimeSpectrum->GetParameter(5)+250.; - h->Fit("TimeSpectrum","QLB","",xmin,xmax); - - for (int i=0; i<nParams; i++){ - pfit[i] = TimeSpectrum->GetParameter(i); - errfit[i] = TimeSpectrum->GetParError(i); - } - chi2 = TimeSpectrum->GetChisquare(); // total chi2 - ndof = TimeSpectrum->GetNDF(); // number of degrees of freedom - - *pchi2 = chi2; - *pndof = ndof; - return; -} //end TimeAndAdcFitter::doTimeFit - -void TimeAndAdcFitter::doAdcFit(TH1F *h, const int /*nAdcParams*/, double *Adcpfit, double *errAdcpfit, double* /*chi2Adc*/, int* /*ndofAdc*/ ) { - - double adcThreshold = 50.; - double minAdc = 80.; - double maxAdc = 300.; - - double m=h->GetMean(); - double r=h->GetRMS(); - double maxval=h->GetMaximum(); - double adcpar[4]; - adcpar[0] = maxval*2.; - adcpar[1] = m; - adcpar[2] = r; - adcpar[3] = r/3.; - - TF1 *AdcSpectrum = new TF1("AdcSpectrum"," ([0]*exp((x-[1])/[2]))/ (1.+exp((x-[1])/[3])) ", minAdc,maxAdc ); - AdcSpectrum->SetLineColor(3); - AdcSpectrum->SetParameters(adcpar); - double fitMin = m-(3*r); - double fitMax = m+(3*r); - if (fitMin<adcThreshold) fitMin = adcThreshold; - if (fitMax>maxAdc ) fitMax = maxAdc; - h->Fit("AdcSpectrum","Q"," ",fitMin,fitMax); - for (int i=0; i<4; i++) { - Adcpfit[i] = AdcSpectrum->GetParameter(i); - errAdcpfit[i] = AdcSpectrum->GetParError(i); - } - // THE NEW HISTOGRAM HAS BEEN FIT - - return; -} //end TimeAndAdcFitter::doAdcFit - -void TimeAndAdcFitter::searchParams(TH1 *h, double *p, int /*nParams*/) { - double sizeX = h->GetBinWidth(1); - double oldSizeX=sizeX; - int RebinFactor = (int) (10./sizeX); - // extract starting values for fit params p[nParams] from the Time Spectrum h - TH1 *hnew = h->Rebin(RebinFactor,"hnew"); // creates a new histogram hnew - //merging 5 bins of h1 in one bin - float minDeriv(9999.); - int minDerivBin(0); - sizeX = hnew->GetBinWidth(1); - int newbins = hnew->GetNbinsX(); - for(int i=0; i<newbins-1; ++i) { - if(hnew->GetBinContent(i)-hnew->GetBinContent(i+1) - <minDeriv) { - minDeriv = hnew->GetBinContent(i)-hnew->GetBinContent(i+1); - minDerivBin = i; - } - } - float t0guess = hnew->GetBinCenter(minDerivBin); - if (minDerivBin<newbins-1) { - t0guess += (hnew->GetBinCenter(minDerivBin+1)-hnew->GetBinCenter(minDerivBin))/2.; - } - // - // =================== Noise level search =================================== - // - float noise(0); - int numOfBins(10), numOfBinsOffset(3); - int imin, imax; - if (minDerivBin>numOfBins+numOfBinsOffset) { - imin = minDerivBin-numOfBins-numOfBinsOffset; - imax = minDerivBin-numOfBinsOffset; - } else { - imin = 0; - if (minDerivBin>numOfBinsOffset) { - imax = minDerivBin-numOfBinsOffset; - } else { - imax = minDerivBin; - } - } - int icount(0); - for (int i=imin; i<=imax; ++i) { - noise += hnew->GetBinContent(i); - icount++; - } - - noise = noise/(float)(icount); - // - // =================== Normalization ========================================= - // - int t0bin = minDerivBin; - int ix1 = t0bin+(int)(50/sizeX); - int ix2 = t0bin+(int)(500/sizeX); - float P1=p[1]; - float P2=p[2]; - float P3=p[3]; - p[0]=noise; - p[4]=t0guess; - p[5]=p[4]+700; - p[1]=20.; - p[2]=10.; - if (0<ix1 && ix1<newbins && 0<ix2 && ix2<newbins ) { - float a1=hnew->GetBinCenter(ix1); - float a2=hnew->GetBinCenter(ix2); - float cont1=hnew->GetBinContent(ix1); - float cont2=hnew->GetBinContent(ix2); - if (cont1>0. && cont2>0. ){ - float A1=std::exp(-(a1-t0guess)/P3); - float A2=std::exp(-(a2-t0guess)/P3); - // do not forget rebinning! - P2 = (cont1/cont2-1.)/(A1-cont1/cont2*A2); - P1 = cont1/(1+P2*A1); - P1=P1*oldSizeX/sizeX; - P2=P2*oldSizeX/sizeX; - p[1]=P1; - p[2]=P2; - } - } - delete hnew; - return; -} //end TimeAndAdcFitter::searchParams diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/TrackSecondCoordinateToSegment.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/TrackSecondCoordinateToSegment.cxx deleted file mode 100644 index c256164f0af0803fb5bba3e58adf84379e79affe..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/TrackSecondCoordinateToSegment.cxx +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "MuonCalibStandAloneExtraTools/TrackSecondCoordinateToSegment.h" - -//MuonCalibExtraTreeEvent -#include "MuonCalibExtraTreeEvent/MuonCalibExtendedSegment.h" -#include "MuonCalibExtraTreeEvent/MuonCalibExtendedTrack.h" - -//root -#include "TFile.h" -#include "TH1.h" - -namespace MuonCalib { - -TrackSecondCoordinateToSegment::TrackSecondCoordinateToSegment(const std::string &t, const std::string &n, const IInterface *p): - AthAlgTool(t, n, p), m_root_file(NULL), m_delta_x(NULL), m_delta_sx(NULL), m_delta_hit_x(NULL) { - m_control_histos = true; - declareProperty("ControlHistograms", m_control_histos); - declareInterface< CalibSegmentPreparationTool >(this); -} - -//////////////// -// initialize // -//////////////// -StatusCode TrackSecondCoordinateToSegment::initialize(void) { - if(m_control_histos) { - m_root_file = new TFile("TrackSecondCoordinateToSegment.root", "RECREATE"); - m_delta_x = new TH1F("delta_x", "", 4000, -8000, 8000); - m_delta_sx = new TH1F("delta_sx", "", 100, -10, 10); - m_delta_hit_x= new TH1F("delta_hit_x", "", 4000, -8000, 8000); - } - return StatusCode::SUCCESS; -} - -StatusCode TrackSecondCoordinateToSegment::finalize(void) { - if(m_root_file != NULL) { - m_root_file->Write(); - } - return StatusCode::SUCCESS; -} - -void TrackSecondCoordinateToSegment::prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments) { - ATH_MSG_INFO("START TrackSecondCoordinateToSegment::prepareSegments"); - //loop over segments - for(std::map<NtupleStationId, MuonCalibSegment *>::iterator it=segments.begin(); it!= segments.end(); it++) { - MuonCalibExtendedSegment *e_segment(dynamic_cast<MuonCalibExtendedSegment *>(it->second)); - if(e_segment==NULL) { - ATH_MSG_FATAL("This tool only works with MuonCalibExtendedSegment!"); - event = NULL; - return; - } - //select best track - const MuonCalibExtendedTrack *track(NULL); - for(std::vector<const MuonCalibExtendedTrack*>::const_iterator t_it=e_segment->associatedTracks().begin(); t_it != e_segment->associatedTracks().end(); t_it++) { - if(track==NULL) { - track = *t_it; - continue; - } - if(track->nrHits() < (*t_it)->nrHits()) { - track = *t_it; - continue; - } - if(track->nrHits() > (*t_it)->nrHits()) { - continue; - } - double prev_chi2 = track->chi2()/static_cast<double>(track->ndof()); - double cur_chi2 = (*t_it)->chi2()/static_cast<double>((*t_it)->ndof()); - if(cur_chi2 < prev_chi2) { - track = *t_it; - } - } - if(track==NULL) { - ATH_MSG_WARNING("No track assigned to segment!"); - continue; - } - - apply_2n_coordinate(track, e_segment); - } -} //end TrackSecondCoordinateToSegment::prepareSegments - -inline void TrackSecondCoordinateToSegment::apply_2n_coordinate(const MuonCalibExtendedTrack *track, MuonCalibSegment *segment) const { - //get transformations - Amg::Transform3D global_to_local((segment->localToGlobal()).inverse()); - Amg::Transform3D local_to_global((segment->localToGlobal())); - //transform track position and direction to local coordinates - const Amg::Vector3D trk_pos(global_to_local *track->position()); - const Amg::Vector3D trk_dir(global_to_local *track->direction()); - //get local track parameters - const Amg::Vector3D &seg_pos(segment->position()); - const Amg::Vector3D &seg_dir(segment->direction()); - //fit 2nd coordinate in to existing parameters - double new_x = trk_pos.x() + ((seg_pos.z() - trk_pos.z())/trk_dir.z()) * trk_dir.x(); - double new_dx = (trk_dir.x()/trk_dir.z()) * seg_dir.z(); - //update track position and direction - Amg::Vector3D new_pos(new_x, seg_pos.y(), seg_pos.z()); - Amg::Vector3D new_dir(new_dx, seg_dir.y(), seg_dir.z()); - if(m_root_file != NULL) { - m_delta_x->Fill(new_pos.x() - seg_pos.x()); - m_delta_sx->Fill(new_dir.x()/seg_dir.z() - seg_dir.x()/seg_dir.z()); - } - segment->SetSegment(new_pos, new_dir); - //update mdt hit positions - for(MuonCalibSegment::MdtHitVec::iterator h_it = segment->mdtHOTBegin(); h_it != segment->mdtHOTEnd(); h_it++) { - MdtCalibHitBase &hit(*(*h_it)); - Amg::Vector3D local_position(hit.localPosition()); - updatePosition(local_position, new_pos, new_dir); - if(m_delta_hit_x) { - m_delta_hit_x->Fill(local_position.x() - hit.localPosition().x()); - } - hit.setLocalPos(local_position); - hit.setGlobalPos(local_to_global *local_position); - Amg::Vector3D point_of_closest_ap( hit.localPointOfClosestApproach() ); - updatePosition(point_of_closest_ap, new_pos, new_dir); - hit.setLocalPointOfClosestApproach(point_of_closest_ap); - hit.setGlobalPointOfClosestApproach( local_to_global*point_of_closest_ap); - } -} //end TrackSecondCoordinateToSegment::apply_2n_coordinate - -inline void TrackSecondCoordinateToSegment::updatePosition(Amg::Vector3D &position, const Amg::Vector3D &seg_pos, const Amg::Vector3D &seg_dir) const { - double new_x = seg_pos.x() + ((position.z() - seg_pos.z())/seg_dir.z()) * seg_dir.x(); - //position.setX(new_x); - position=Amg::Vector3D(new_x, position.y(), position.z()); -} - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/components/MuonCalibStandAloneExtraTools_entries.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/components/MuonCalibStandAloneExtraTools_entries.cxx deleted file mode 100644 index 2a4cb2212d0768496787afd0701a73db83fd6a85..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/components/MuonCalibStandAloneExtraTools_entries.cxx +++ /dev/null @@ -1,18 +0,0 @@ -#include "MuonCalibStandAloneExtraTools/CalibExtraNtupleLoader.h" -#include "MuonCalibStandAloneExtraTools/ExtraRegionSelector.h" -#include "MuonCalibStandAloneExtraTools/ExtraRegionSelectorSuperFast.h" -#include "MuonCalibStandAloneExtraTools/ExtraRegionSelectorFast.h" -#include "MuonCalibStandAloneExtraTools/TrackSecondCoordinateToSegment.h" -#include "MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h" -#include "../NtupleSplitterTool.h" - -using namespace MuonCalib; - -DECLARE_COMPONENT( CalibExtraNtupleLoader ) -DECLARE_COMPONENT( ExtraRegionSelector ) -DECLARE_COMPONENT( ExtraRegionSelectorFast ) -DECLARE_COMPONENT( ExtraRegionSelectorSuperFast ) -DECLARE_COMPONENT( TrackSecondCoordinateToSegment ) -DECLARE_COMPONENT( NtupleMdtDqaTool ) -DECLARE_COMPONENT( NtupleSplitterTool ) - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/CMakeLists.txt deleted file mode 100644 index 6e001bddcf50c2eab09908cb610f8a3c225908a8..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -################################################################################ -# Package: MuonCalibStandAloneTools -################################################################################ - -# Declare the package name: -atlas_subdir( MuonCalibStandAloneTools ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/AthenaBaseComps - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibFitters - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibInterfaces - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibT0 - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibUtils - MuonSpectrometer/MuonCalib/MuonCalibEventBase - MuonSpectrometer/MuonCalib/MuonCalibITools - MuonSpectrometer/MuonCalib/MuonCalibIdentifier - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc - MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase - MuonSpectrometer/MuonIdHelpers - PRIVATE - DetectorDescription/Identifier - GaudiKernel - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibData - MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibRt - MuonSpectrometer/MuonCalib/MuonCalibUtils/MuonCalibStl - MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry ) - -# External dependencies: -find_package( CLHEP ) -find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread MathMore Minuit Minuit2 Matrix Physics HistPainter Rint Graf Graf3d Gpad Html Postscript Gui GX11TTF GX11 ) - -# Component(s) in the package: -atlas_add_library( MuonCalibStandAloneToolsLib - src/*.cxx - PUBLIC_HEADERS MuonCalibStandAloneTools - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps MdtCalibFitters MdtCalibT0 MdtCalibUtils MuonCalibEventBase MuonCalibITools MuonCalibIdentifier MdtCalibIOSvcLib MuonCalibStandAloneBaseLib MuonIdHelpersLib - PRIVATE_LINK_LIBRARIES Identifier GaudiKernel MdtCalibData MdtCalibRt MuonReadoutGeometry ) - -atlas_add_component( MuonCalibStandAloneTools - src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps MdtCalibFitters MdtCalibT0 MdtCalibUtils MuonCalibEventBase MuonCalibITools MuonCalibIdentifier MdtCalibIOSvcLib MuonCalibStandAloneBaseLib MuonIdHelpersLib Identifier GaudiKernel MdtCalibData MdtCalibRt MuonReadoutGeometry MuonCalibStandAloneToolsLib ) - -# Install files from the package: -atlas_install_python_modules( python/*.py ) -atlas_install_joboptions( share/*.py ) - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/HitCounter.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/HitCounter.h deleted file mode 100644 index f0794889758d66c752f040af24bc578684b4d1a4..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/HitCounter.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef HitCounter_H -#define HitCounter_H - -//c - c++ -#include "map" -#include "string" - -//root -class TH1F; -class TDirectory; -#include "MuonCalibStandAloneBase/NtupleStationId.h" - -namespace MuonCalib { - - -class MuonCalibSegment; - - -/** @class HitCounter -Counts hits per tube, mezzanine, multilayer and layer, and decides how the chambers are to be fitted -@author rauscher@cern.ch -*/ - - -class HitCounter - { - public: - /** id classes*/ - class TubeId - { - public: - inline TubeId():ml(0),ly(0),tb(0) {} - int ml, ly, tb; - inline bool operator < (const TubeId &other) const - { - if(ml != other.ml) return (ml < other.ml); - if(ly != other.ly) return (ly < other.ly); - return (tb < other.tb); - } - }; - class MezzId - { - public: - inline MezzId():ml(0),mezz(0) {} - int ml, mezz; - inline bool operator < (const MezzId & other) const - { - if(ml != other.ml) return (ml < other.ml); - return mezz < other.mezz; - } - }; - class DQInfo - { - public: - inline DQInfo(): m_severity(0), m_noisy(false), m_dead(false) - {} - inline void SetNoisy() - { - if(m_severity<2) - m_severity=2; - m_noisy=true; - } - inline void SetDead() - { - if(m_severity<1) - m_severity=1; - m_dead=true; - } - inline const int & GetSeverity() const - { - return m_severity; - } - inline const bool & GetNoisy() const - { - return m_noisy; - } - inline const bool & GetDead() const - { - return m_dead; - } - private: - int m_severity; - bool m_noisy; - bool m_dead; - }; -//============================================================================== - /** default constructor */ - inline HitCounter() : m_is_initialized(false), m_per_chamber(0), m_n_dead_tubes(0), - m_n_dead_mezz(0), m_n_dead_ml(0), m_fit_by_int(0), m_hits_per_segments(NULL), - m_wd(NULL) - { - } - /** initialize class */ - bool Initialize(const NtupleStationId &id); - /** process segment */ - void ProcessSegment(const MuonCalibSegment & segment); - /** decide on how to fit */ - const std::string & FittingBy(int min_hits, double bad_fit_rate); - /** return true if class is initialized */ - inline bool IsInitialized() - { - return m_is_initialized; - } - inline int FitByInt() const - { - return m_fit_by_int; - } - inline int NHits() const - { - return m_per_chamber; - } - /** return number of dead tubes - mezzanines - multilayers */ - inline int NDeadTubes() const - { - return m_n_dead_tubes; - } - inline int NDeadMezzanines() const - { - return m_n_dead_mezz; - } - inline int NDeadMultilayers() const - { - return m_n_dead_ml; - } - std::map<HitCounter::TubeId, HitCounter::DQInfo> InitialDQ(int noisy_tube_factor) const; - private: -//============================================================================== - //! is true if class is initialized - bool m_is_initialized; - //! name string - std::string m_name; - //! hit counter - std::map<TubeId, int> m_per_tube; - std::map<MezzId, int> m_per_mezz; - std::map<int, int> m_per_ml; - int m_per_chamber; - //! number of dead tubes - dead mezzanines - dead tubs - int m_n_dead_tubes; - int m_n_dead_mezz; - int m_n_dead_ml; - //! number of tubes per layer and mezzanine - std::map<int,int> m_mezz_width; - //! fitt by - std::string m_fit_by; - int m_fit_by_int; - //!root histograms - TH1F *m_hits_per_segments; - TDirectory *m_wd; - //! station id to which this counter applies - NtupleStationId m_id; - }; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleAnalyticAutocalibrationTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleAnalyticAutocalibrationTool.h deleted file mode 100644 index 5d4c3404ea704a1b4daeb8ebb5bf8407ac88972a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleAnalyticAutocalibrationTool.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef NtupleAnalyticAutocalibrationTool_H -#define NtupleAnalyticAutocalibrationTool_H - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -class MdtCalibInputSvc; - -namespace MuonCalib { - -class RtCalibrationAnalytic; - -/** @class NtupleAnalyticAutocalibrationTool - Interface tool for the Integration Method for finding an initial r-t - relation. - @author rauscher@cern.ch -*/ - - -class NtupleAnalyticAutocalibrationTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor */ - NtupleAnalyticAutocalibrationTool(const std::string& t, const std::string& n, const IInterface* p); - /** Tool initialization */ - StatusCode initialize(); - - /** analyze segments */ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & segemnts); - /** set calibratino region */ - void setRegion(); - /** get calibration results */ - const IMdtCalibrationOutput * getResults() const; -//============================================================================== - private: - //! pointer to algoritm - RtCalibrationAnalytic *m_autocalibration; - //! estimateted initial rt acuracy - job option - double m_rt_accuracy; - //! the type of the correction function (LEGENDRE|CHEBYSHEV|POLYGON - job option - std::string m_func_type; - //! the function type as a numeric value - //! = 1: Legendre polynomial, - //! = 2: Chebyshev polynomial - //! = 3: polygon equidistant in r - int m_func_type_num; - //! order of the correctio nfunctino - int m_order; - //! restrict segments to mutilayers - job option - bool m_split; - //! lets the algorithm use the full matrix - job option - bool m_full_matrix; - //! fix_min, fix_max=true: fix r(t_min), r(t_max) - job option - bool m_fix_min, m_fix_max; - //! maximum number of iterations. - job otion - int m_max_it; - //! force monotonuous rt relation - job option - bool m_force_mono; - //! control histogram output - job option - bool m_control_histograms; - //! calibratin input service - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; - //! is set to true if the analysis failed - bool m_failed; - //! is set to true if r(t) should be smoothened using the conventional - //! autocalibration - bool m_smoothening; - //! is set to true if parabolic extrapolation should be performed for small - //! and large radii - bool m_parabolic_extrapolation; - }; - -#endif - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleCalibADCTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleCalibADCTool.h deleted file mode 100644 index a3807fbb385e6412fb3816eac536a8aefb0a49f6..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleCalibADCTool.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 20.06.2007, AUTHOR: Zhen YAN -// Used for ADC data studies and product the ADC parameters for time slewing -// 2009.01.14 new Tool NtupleCalibADCTool -// 2009.01.21 Empty frame is working in Athena frame -// 2009.01.22 Add ADC plot for ADC data studies -// 2009.02.26 Add new array histogram for radius range analysis -// 2009.03.06 Add new array histogram for studing the ADC varation with differnet segment AngleXZ -// 2009.06.22 Test the current version in new package, working on the producting of timeslewing coefficient -// 2009.07.02 v320 input_svc ->T0 and RT , slewing factor from r_MDT_residual_vs_ADC[15] -// 2009.07.15 v330 TS_factor[15] change range. Range 0 to 0.5, 0.5~1.5£¬13.5~15 -// 2009.07.23 v400 introduce the TS_cor and reset the driftRadius before the refit. new plot Residual_vs_Radius[3] -// 2009.08.27 v440 new plot radius_vs_distanceTowire ->> check the bugs on the NTUP filling -// 2009.08.31 v500 running version except r_MDT_residual_vs_ADC[15] -// 2009.09.02 v510 new ADC correction array, compile ok -// -// Todo list 1) Try to use GTFitter for the segment refit -// 2) Introduce TrRelation() class in CalibData -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef MuonCalib_NtupleCalibADCToolH -#define MuonCalib_NtupleCalibADCToolH - -//::::::::::::::::::::::::::::::::::::::: -//:: CLASS NtupleCalibADCTool :: -//::::::::::::::::::::::::::::::::::::::: - -/// \class NtupleCalibADCTool - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// STL // -#include <string> -#include <map> - -// ROOT // -#include "TFile.h" -#include "TH1.h" -#include "TH2.h" -class TF1; -class TTree; -class TProfile; - -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -// MuonCalib // -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MdtCalibFitters/CurvedPatRec.h" -#include "MuonCalibStandAloneBase/T0Refinement.h" -#include "MdtCalibUtils/GlobalTimeFitter.h" -#include "MdtCalibFitters/DCSLFitter.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -class RegionSelectionSvc; - -namespace MuonCalib { - -class T0MTHistos; - -class NtupleCalibADCTool : public AthAlgTool, - virtual public NtupleCalibrationTool { - -public: -// Constructors // - NtupleCalibADCTool(const std::string & t, - const std::string & n, const IInterface * p); - ///< Constructor of the tool. - - ~NtupleCalibADCTool(void); - ///< Destructor of the tool. - -// Methods // -// methods required by the base classes // - StatusCode initialize(void); - ///< initialization of the tool - StatusCode finalize(void); - ///< finilization of the tool - StatusCode handleEvent(const MuonCalibEvent & event, int evnt_nb, - const std::vector<MuonCalibSegment *> & segments, - unsigned int position); - ///< analysis of the event, - ///< raw data and segment histograms - ///< are filled - bool KeepSegments(void) const; - ///< returns true, if segments should - ///< be stored in memory, false - ///< otherwise - -private: -// job options // - bool m_refit_segments; // = true, if the segments should be refitted, - // = false, if the segments are not refitted - bool m_Recalc2ndCoordinate; // use for certifate ADC_vs_distX and ADC_vs_DirXYZ - bool m_curved_fits; // = true, if curved segment fits should be performed, - // = false, if straight segment fits should be performed - double m_time_out; // time out for pattern finding - double m_road_width; // road width for pattern recognition - std::string m_MDT_ID_helper; // name of the MDT ID helper - std::string m_RPC_ID_helper; // name of the RPC ID helper - std::string m_idToFixedIdToolType; // type of the muon fixed id tool - std::string m_idToFixedIdToolName; // name of the muon fixed id tool - std::string m_ROOT_file_name; // name of the output ROOT file - //std::string m_group_by; // name of the output ROOT file -// double RA_table[30]; - -// ROOT file // - TFile *m_tfile; // pointer to the ROOT file in which the data have to - // be stored - -// calibration region // - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; -// calibration parameters // - ServiceHandle<MdtCalibInputSvc> m_input_service; // pointer to the calibration input - // service -// chamber parameters // - std::map<NtupleStationId, unsigned int> m_nb_ml; // number of - // multilayers - std::map<NtupleStationId, unsigned int> m_nb_ly; // number of layers per - // multilayer - std::map<NtupleStationId, unsigned int> m_nb_tb; // number of tubes per - // layer - - -// event data // - // number of raw MDT hits in - // the chambers - unsigned int m_nb_events; - // number of events - // strips [rDoublet][zDoublett] -// straight-line fitter // - QuasianalyticLineReconstruction *m_qfitter; - -// curved-line fitter // - CurvedPatRec *m_cfitter; - -// t0 refinement // - T0Refinement *m_t0_refinement; - -// histograms // - // segment histograms // -// ########## Group 1, the histograms for generating ADC correction factor ############### - - std::map<NtupleStationId, TH2F *> m_MDT_adc_vs_radius; - std::map<NtupleStationId, TH2F *> m_MDT_adc_vs_pathD; - std::map<NtupleStationId, TH2F *> m_MDT_adc_vs_residual; - std::map<NtupleStationId, TH2F *> m_MDT_adc_vs_posX; - std::map<NtupleStationId, TH2F *> m_MDT_adc_vs_DistanceToSegmentTrack; - std::map<NtupleStationId, TH2F *> m_MDT_radius_vs_t; - std::map<NtupleStationId, TH2F *> m_MDT_radius_vs_DistanceToSegmentTrack; - - - std::map<NtupleStationId, TH2F*> m_r_MDT_residual_vs_adc[15]; - - std::map<NtupleStationId, TH1F *> m_MDT_segment_localangle_YZ; //local incidence angle XZ, YZ distributions of the segments - std::map<NtupleStationId, TH1F *> m_MDT_segment_localangle_XZ; - -// ########## Group 2, Histograms for compare the refit inprovement ############### - - std::map<NtupleStationId, TH2F *> m_MDT_residual_vs_radius[3]; - std::map<NtupleStationId, TH1F *> m_MDT_segment_hits[3]; - std::map<NtupleStationId, TH1F *> m_MDT_segment_chi2[3]; - std::map<NtupleStationId, TH1F *> m_MDT_segment_delta_chi2; -// std::map<NtupleStationId, TH1F *> m_MDT_segment_delta_residual; - - -// ########## Group 3, Histograms for ADC specify checking ############### -// 3.1 double hits -> ADC distribution v440 - std::map<NtupleStationId, TH2F *> m_MDT_SiHitAdc; - std::map<NtupleStationId, TH2F *> m_MDT_fhit_adc; -// 3.2 big residual hits -> working on - -// helpers // -// - - - const MdtIdHelper *m_MdtIdHelper; // pointer to the MDT ID helper - const RpcIdHelper *m_RpcIdHelper; // pointer to the RPC ID helper - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - const MuonCalib::IIdToFixedIdTool *m_id_tool; // identifier converter - -// private methods // - void createMaps(const MuonFixedId & id); - // create the histograms for the - // given station id if they do not - // exist -}; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleChisqResolutionTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleChisqResolutionTool.h deleted file mode 100644 index 25129ff28c30529db4d4d6f062d55fc03759c10d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleChisqResolutionTool.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef NtupleChisqResolutionTool_H -#define NtupleChisqResolutionTool_H - -//c - c++ -#include <vector> -#include <map> - -// root -class TMinuit; -class TH1F; -class TH2F; -class TFile; - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -class MdtCalibInputSvc; - -namespace MuonCalib { - -//muoncalib -class IRtRelation; -class MuonCalibSegment; -class IRtResolution; - - -class NtupleChisqResolutionTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//===============================public section================================= - /** Tool constructor */ - NtupleChisqResolutionTool(const std::string& t, const std::string& n, const IInterface* p); - /** Destructor */ - ~NtupleChisqResolutionTool()=default; - /** tool initialize */ - StatusCode initialize(); - /** tool finalize */ - StatusCode finalize(); - /** analyse the segments */ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & segemnts); - /** set calibration region */ - void setRegion(); - /** get the resolution */ - const IRtResolution * getResolution() const; - //!? - inline void fcn(int &/*npar*/, double */*gin*/, double &f, double *par, int /*iflag*/); - private: -//============================private section=================================== - //!? - inline double recalculate(double *par); - //!? - const std::vector<MuonCalibSegment*> *m_seg; - //! some root stuff - TMinuit *m_minuit; - TH1F *m_prob_dist; - int m_minuitoutputlevel; - TFile * m_resolfile; - //! Calibration input service - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; - //! the rt relation - const IRtRelation *p_rt_rel; - - IRtResolution *m_final_resolution; // final resolution curve - inline double t_from_r(const double & r, const IRtRelation * rt_rel); - // get t(r) for the r-t relationship rt_rel, - // the method is auxiliary and not optimized; - // it will disappear when the t(r) will be - // available in the MuonCalib framework; - - }; -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleClassicT0Tool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleClassicT0Tool.h deleted file mode 100644 index d36919d2a1a3e13e879ebf6609d3940a90323552..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleClassicT0Tool.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _NtupleClassicT0Tool_H -#define _NtupleClassicT0Tool_H - - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -class RegionSelectionSvc; - -//t0 algorithm -#include "MdtCalibT0/T0CalibrationClassic.h" - - -namespace MuonCalib { - -/** @class NtupleClassicT0Tool - Interface tool for the MT T0-Fitter - @author rauscher@cern.ch - */ - -class NtupleClassicT0Tool: public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor*/ - NtupleClassicT0Tool(const std::string& t, const std::string& n, const IInterface* p); - /** tool initialization */ - StatusCode initialize(); - - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** analyze segments */ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segments*/); - /** set calibratino region */ - void setRegion(); - /** get calibration results */ - const IMdtCalibrationOutput * getResults() const; - /** we dont need to keep the segments*/ - inline bool KeepSegments() const - { - return false; - } -//============================================================================== - private: - //! pointer to algorithm - T0CalibrationClassic * p_alg; - //! settings class - T0ClassicSettings *m_settings; - //! pointe rto region selectin service - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - //! number of adc bins - int m_adcBins; - //! adc range - double m_minAdc, m_maxAdc; - //! number of time bins - int m_timeBins; - //! time range - double m_minTime, m_maxTime; - //! if true fit time - bool m_fitTime; - //! minimum number of entries - int m_minEntries; - //! init param marameter - int m_initParam; - //! maximum value for chi2 - double m_chiMax; - }; - -} - - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleControlHistogramsTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleControlHistogramsTool.h deleted file mode 100644 index 7c773f659547ecb4432781cef401304792dec6aa..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleControlHistogramsTool.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 20.06.2007, AUTHOR: OLIVER KORTNER -// Modified: 26.06.2007 by O. Kortner, new naming convention for directories: -// station-phi-eta. -// 26.06.2007 by O. Kortner, new histograms added. -// 19.07.2007 by O. Kortner, no t0 refinement without r-t calibration. -// 18.08.2008 by O. Kortner, curved track fit + time-out option added. -// 03.11.2008 by O. Kortner, allow the user to turn off the t0 -// refinement histograms. -// 21.02.2009 by O. Kortner, additional residual histograms -// after t0 refinement. -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef MuonCalib_NtupleControlHistogramsToolH -#define MuonCalib_NtupleControlHistogramsToolH - -//::::::::::::::::::::::::::::::::::::::: -//:: CLASS NtupleControlHistogramsTool :: -//::::::::::::::::::::::::::::::::::::::: - -/// \class NtupleControlHistogramsTool -/// -/// This class makes control histograms for the calibration regions selected -/// by the user. The user can ask for a refit of the segments with the -/// r-t relationship as loaded by the master stand-alone programme via -/// job options. -/// -/// \author Oliver.Kortner@CERN.CH -/// -/// \date 20.06.2007 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// STL // -#include <string> -#include <map> - -// ROOT // -#include "TFile.h" -#include "TH1.h" -#include "TH2.h" -class TF1; -class TTree; -class TProfile; - -namespace MuonGM { -class RpcDetectorElement; -} -class RpcIdHelper; - -// MuonCalib // -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MdtCalibFitters/StraightPatRec.h" -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MdtCalibFitters/StraightPatRec.h" -#include "MdtCalibFitters/CurvedPatRec.h" -#include "MuonCalibStandAloneBase/T0Refinement.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -class RegionSelectionSvc; -class MdtCalibInputSvc; - -namespace MuonCalib { - -class T0MTHistos; - -class NtupleControlHistogramsTool : public AthAlgTool, - virtual public NtupleCalibrationTool { - -public: -// Constructors // - NtupleControlHistogramsTool(const std::string & t, - const std::string & n, const IInterface * p); - ///< Constructor of the tool. - - ~NtupleControlHistogramsTool(void); - ///< Destructor of the tool. - -// Methods // -// methods required by the base classes // - StatusCode initialize(void); - ///< initialization of the tool - StatusCode finalize(void); - ///< finilization of the tool - StatusCode handleEvent(const MuonCalibEvent & event, int evnt_nb, - const std::vector<MuonCalibSegment *> & segments, - unsigned int position); - ///< analysis of the event, - ///< raw data and segment histograms - ///< are filled - bool KeepSegments(void) const; - ///< returns true, if segments should - ///< be stored in memory, false - ///< otherwise - -private: -// job options // - bool m_refit_segments; // = true, if the segments should be refitted, - // = false, if the segments are not refitted - bool m_curved_fits; // = true, if curved segment fits should be performed, - // = false, if straight segment fits should be performed - bool m_refine_t0; // = true, if t0 refinement plots should be made, - // = false otherwise - double m_time_out; // time out for pattern finding - double m_road_width; // road width for pattern recognition - std::string m_MDT_ID_helper; // name of the MDT ID helper - std::string m_RPC_ID_helper; // name of the RPC ID helper - std::string m_idToFixedIdToolType; // type of the muon fixed id tool - std::string m_idToFixedIdToolName; // name of the muon fixed id tool - std::string m_ROOT_file_name; // name of the output ROOT file - -// ROOT file // - TFile *m_tfile; // pointer to the ROOT file in which the data have to - // be stored - -// calibration region // - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; -// calibration parameters // - ServiceHandle<MdtCalibInputSvc> m_input_service; // pointer to the calibration input - // service - -// chamber parameters // - std::map<NtupleStationId, unsigned int> m_nb_ml; // number of - // multilayers - std::map<NtupleStationId, unsigned int> m_nb_ly; // number of layers per - // multilayer - std::map<NtupleStationId, unsigned int> m_nb_tb; // number of tubes per - // layer - std::map<NtupleStationId, unsigned int> m_nb_totalEtaStrips; // number of eta strips - std::map<NtupleStationId, unsigned int> m_nb_totalEtaStrips2; // number of eta strips in - // RDoublet=2 rpcs - -// event data // - std::map<NtupleStationId, unsigned int> m_nb_raw_MDT_hits; - // number of raw MDT hits in - // the chambers - unsigned int m_nb_events; - // number of events - int m_nb_etaStrips[2][4]; // number of rpc eta - // strips [rDoublet][zDoublett] -// straight-line fitter // - StraightPatRec *m_qfitter; - -// curved-line fitter // - CurvedPatRec *m_cfitter; - -// t0 refinement // - T0Refinement *m_t0_refinement; - -// histograms // - // raw-data histograms // - std::map<NtupleStationId, TH1F *> m_MDT_raw_nb_hits; - // number of raw hits per MDT chamber - std::map<NtupleStationId, TH1F *> m_MDT_raw_hit_distribution; - // distribution of raw hits per MDT chamber - std::map<NtupleStationId, TH1F *> m_MDT_raw_TDC; - // raw TDC spectrum per MDT chamber - std::map<NtupleStationId, TH1F *> m_MDT_raw_ADC; - // raw ADC spectrum per MDT chamber - //histograms to check mdt-rpc correlations - std::map<NtupleStationId, TH1F *> m_RPC_raw_etaStrip; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCor; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCor_adcCut; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCorVsEvent; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCorVsEvent_adcCut; - std::map<NtupleStationId, TH1F *> m_RPC_raw_etaStrip2; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCor2; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCor_adcCut2; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCorVsEvent2; - std::map<NtupleStationId, TH2F *> m_MDT_RPC_raw_tubeStripCorVsEvent_adcCut2; - - //histograms to check db - std::map<NtupleStationId, TH1F *> m_t0_diff; - // t0 from tuple minus t0 from file - std::map<NtupleStationId, TH1F *> m_r_mintrt; - // r minus r(t) - TH1F *m_t0_diff_global, *m_r_mintrt_global; - TH2F *m_r_minrt_vs_r; - - // segment histograms // - std::map<NtupleStationId, TH1F *> m_MDT_segment_hits; - // number of hits on the MDT segment - std::map<NtupleStationId, TH1F *> m_MDT_segment_hist_to_raw_hits_ratio; - // number of hits on the MDT segment divided - // by the number of raw hits in the MDT chamber - std::map<NtupleStationId, TH1F *> m_MDT_segment_CL; - // confidence level distribution of the segment - // fits - std::map<NtupleStationId, TH1F *> m_MDT_segment_TDC; - // TDC spectra of hits in the segments - std::map<NtupleStationId, T0MTHistos *> m_MDT_segment_tspec_ml[3]; - //fitter for segment spectra - per multilayer; - std::map<NtupleStationId, TH1F *> m_MDT_segment_t; - // drift-time spectra of hits in the segments - std::map<NtupleStationId, TH1F *> m_MDT_segment_r; - // drift-radius spectra of hits in the segments - std::map<NtupleStationId, TH1F *> m_MDT_segment_hit_dis; - // drift-radius spectra of hits in the segments - std::map<NtupleStationId, TH1F *> m_MDT_segment_ADC; - // ADC spectra of hits in the segments - std::map<NtupleStationId, TH1F *> m_MDT_segment_slope; - // slope distributions of the segments - std::map<NtupleStationId, TH2F *> m_MDT_residuals; - std::map<NtupleStationId, TH2F *> m_MDT_residuals_vs_x; - std::map<NtupleStationId, TH2F *> m_MDT_r_vs_rtrack; - std::map<NtupleStationId, TH2F *> m_MDT_t_vs_rtrack; - - // residual distribution per MDT chamber - std::map<NtupleStationId, TH2F *> m_MDT_residuals_ml1; - // residual distribution in multilayer 1 - std::map<NtupleStationId, TH2F *> m_MDT_residuals_ml2; - // residual distribution in multilayer 1 - std::map<NtupleStationId, TH1F *> m_MDT_t0_refinement; - // delta t0 from track fit - std::map<NtupleStationId, TH1F *> m_MDT_t_refined; - // t0 corrected drift time spectrum - std::map<NtupleStationId, TH2F *> m_MDT_residuals_t0_refined; - // residuals after t0 refinement - std::map<NtupleStationId, TH2F *> m_MDT_residuals_t0_refined_gt4hits; - // residuals after t0 refinement for segments with >4 hitss - -//for root tree -//pointer to root tree - TTree *m_chamber_tree; -// helpers // - const MdtIdHelper *m_MdtIdHelper; // pointer to the MDT ID helper - const RpcIdHelper *m_RpcIdHelper; // pointer to the RPC ID helper - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - const MuonCalib::IIdToFixedIdTool *m_id_tool; // identifier converter - -// private methods // - void createMaps(const MuonFixedId & id); - // create the histograms for the - // given station id if they do not - // exist - inline double getChi2(const TF1 *fun, const TH1F *hist) const; - inline double getResidualChi2(TProfile *px) const; -}; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleCurvedAutocalibrationTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleCurvedAutocalibrationTool.h deleted file mode 100644 index 7407769e5a460ba97cc1435526827d4e2bf2e9cf..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleCurvedAutocalibrationTool.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef NtupleCurvedAutocalibrationTool_H -#define NtupleCurvedAutocalibrationTool_H - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -class MdtCalibInputSvc; - -namespace MuonCalib { - -class RtCalibrationCurved; - -/** @class NtupleCurvedAutocalibrationTool - Interface tool for the Integration Method for finding an initial r-t - relation. - @author rauscher@cern.ch -*/ - - -class NtupleCurvedAutocalibrationTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor */ - NtupleCurvedAutocalibrationTool(const std::string& t, const std::string& n, const IInterface* p); - /** Tool initialization */ - StatusCode initialize(); - - /** analyze segments */ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & segemnts); - /** set calibratino region */ - void setRegion(); - /** get calibration results */ - const IMdtCalibrationOutput * getResults() const; -//============================================================================== - private: - //! pointer to algoritm - RtCalibrationCurved *m_autocalibration; - //! estimateted initial rt acuracy - job option - double m_rt_accuracy; - //! the type of the correction function (LEGENDRE|CHEBYSHEV|POLYGON - job option - std::string m_func_type; - //! the function type as a numeric value - //! = 1: Legendre polynomial, - //! = 2: Chebyshev polynomial - //! = 3: polygon equidistant in r - int m_func_type_num; - //! order of the correctio nfunctino - int m_order; - //! fix_min, fix_max=true: fix r(t_min), r(t_max) - job option - bool m_fix_min, m_fix_max; - //! maximum number of iterations. - job otion - int m_max_it; - //! force monotonuous rt relation - job option - bool m_force_mono; - //! control histogram output - job option - bool m_control_histograms; - //! calibratin input service - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; - //! is set to true if the analysis failed - bool m_failed; - //! is set to true if parabolic extrapolation should be performed for small - //! and large radii - bool m_parabolic_extrapolation; - //! is set to true if r(t) should be smoothened using the conventional - //! autocalibration - bool m_smoothing; - //! if set to true multilayer rt scale will be deterined - bool m_multilayer_rt_difference; - }; - -#endif - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDBCheckTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDBCheckTool.h deleted file mode 100644 index 555a7c22ea088403e03c30dd06180d2a54080e59..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDBCheckTool.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef NtupleDbCheckTool_h -#define NtupleDbCheckTool_h - -//root -#include "TTree.h" -#include "TFile.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -//MdtCalibIoSvc -class MdtCalibInputSvc; - -namespace MuonCalib { - - -class NtupleDbCheckTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - public: - //contructor - NtupleDbCheckTool(const std::string & t, -const std::string & n, const IInterface * p); - ~NtupleDbCheckTool(); - - //initialize - finalize - StatusCode initialize(void); - StatusCode finalize(void); - //handle event - StatusCode handleEvent(const MuonCalibEvent & /*event*/, int /*evnt_nb*/, const std::vector<MuonCalibSegment *> & segments, unsigned int position); - //keep seg - inline bool KeepSegments() const - { - return false; - } - - private: - TFile * m_outfile; - TTree * m_outtree; - Int_t m_station, m_eta, m_phi; - Double_t m_ntuple_t0, m_calib_t0; - Double_t m_ntuple_r, m_calib_r; - - //calibration input service - ServiceHandle<MdtCalibInputSvc> m_input_service; - }; //class - - -} //namespace MuonCalib - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDisplayTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDisplayTool.h deleted file mode 100644 index 8f1fd8eb8e0de9a9cabb39deaba2eb7dd5c5c15d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDisplayTool.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MuonCalib_NtupleDisplayToolH -#define MuonCalib_NtupleDisplayToolH - -//::::::::::::::::::::::::::::: -//:: CLASS NtupleDisplayTool :: -//::::::::::::::::::::::::::::: - -/// \class NtupleDisplayTool -/// -/// This class serves as display of events in mdt chambers. -/// -/// \author Steffen.Kaiser@cern.ch -/// -/// \date 19.10.2007 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -//root -#include "TEllipse.h" -class TCanvas; -class TControlBar; -class TApplication; - -// STL // -#include <string> - -// MuonCalib -#include "MdtCalibInterfaces/IMdtPatRecFitter.h" - -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -class RegionSelectionSvc; - -namespace MuonCalib { - -class IIdToFixedIdTool; -class MuonCalibSegment; -class NtupleStationId; -class MuonCalibEvent; - -class TubeCircle; - -class NtupleDisplayTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - - public: - // Constructors // - NtupleDisplayTool(const std::string& t, const std::string& n, const IInterface* p); - - ~NtupleDisplayTool()=default; - ///< Destructor - - /** tool initialize */ - StatusCode initialize(); - - StatusCode handleEvent(const MuonCalibEvent & event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - ///< analysis of the given segment of - ///< event eventnumber, event contains - ///< the raw hits - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - ///< analysis at the end of the data - ///< file - inline bool KeepSegments() const - { - return false; - } - - private: - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - const MuonCalib::IIdToFixedIdTool *m_id_tool; - - - TApplication *m_root; //to display graphics within athena - TControlBar *m_bar; //the control bar - - TCanvas *m_canvas; //canvas for chamber display - TCanvas *m_canvas_leg; //canvas for legend - - - std::string m_fitter_name; // name of the track fitter - unsigned int m_nb_hits; //minimum number of hits in displayed segment - double m_road_width; //road width for pattern recognition - int m_chosen_event; //to chose a single event - double m_scalefactor; //scale factor for the size of the display - double m_adc_cut; //adc cut to define noise hits - - // calibration region // - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - // line reconstruction // - IMdtPatRecFitter *m_qfitter; - - // numbers // - int m_nb_multilayers; - int m_nb_layers; - int m_nb_tubes; - - - std::vector<int> m_colors; //vector of colors to be used - - // vectors of tube circles // - std::vector< std::vector< std::vector<TubeCircle*> > > m_tube_circle; - //used for identification of the tubes - - std::vector<TubeCircle*> m_tube_circle_lin; - //used for drawing and resetting - - }; - - - class TubeCircle : public TEllipse { - - public: - - // Constructors // - TubeCircle(); - ///< Default constructor. - TubeCircle(std::vector<int> colors, double m_adc_cut = 50.); - ///< constructor which sets to vector of colors and the adc cut - TubeCircle(Amg::Vector3D TubePos, std::vector<int> colors, double m_adc_cut = 50.); - ///< constructor which sets to vector of colors, the adc cut and the tube position - - void setPosition(Amg::Vector3D TubePos); - ///< set the tube position - void setColors(std::vector<int> colors); - ///< set the vector of colors to be used (size=5), - ///< 0: segment hit, 1: raw hit, 2: drift radius > 14.6, - ///< 3: adc < 70, 4: drift time < 0 - void setAdcCut(double adc_cut); - ///< set adc cut to define noise hit - - void setUsedFlag(bool flag); ///<set used flag - bool isUsed(void); ///<get used flag - - void setSegmentHit(double radius, double time, double adc); - ///< set segment hit(drift radius, drift time, adc) - - bool hasSegmentHit(void); - ///< return flag if the tube has a segment hit - - void setRawHit(double radius, double time, double adc); - ///< set raw hit(drift radius, drift time, adc) - - bool hasRawHit(void); - ///< return flag if the tube has a raw hit - - - void reset(void); - ///< reset the tube to a clean and empty tube - - int tube, layer, multilayer; - private: - - void setRadius(double radius, double time, double adc, int hit); - //set the properties of the hit (drift radius, drift time, adc), - //hit = 0: segment hit, = 1: raw hit - - bool m_used_flag; //is the tube used - bool m_rawhit_flag; //has the tube a raw hit - bool m_segmenthit_flag; //has the tube a segment hit - double m_adc_cut; //adc cut to define noi - std::vector<int> m_colors; //vector of colors to be used - - }; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleIntegrationTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleIntegrationTool.h deleted file mode 100644 index 4a9478ae391c118f72aeb8c679be41eeb8b21f5f..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleIntegrationTool.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef NtupleIntegrationTool_H -#define NtupleIntegrationTool_H - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//root -class TFile; - -namespace MuonCalib { - -class RtCalibrationIntegration; - -/** @class NtupleIntegrationTool - Interface tool for the Integration Method for finding an initial r-t - relation. - @author rauscher@cern.ch -*/ - - -class NtupleIntegrationTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor */ - NtupleIntegrationTool(const std::string& t, - const std::string& n, - const IInterface* p); - /** Tool initialization */ - StatusCode initialize(); - /** Tool finalization */ - StatusCode finalize(); - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** end of events analysis */ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - /** get calibration results */ - const IMdtCalibrationOutput * getResults() const; - /** we dont need to keep the segments*/ - inline bool KeepSegments() const - { - return false; - } -//============================================================================== - private: - //! pointer to algoritm - RtCalibrationIntegration *m_integration; - //! tmax for integration - job option - double m_t_max_int; - //! is true if close hits are filled - job option - bool m_has_close_hits; - //! inner tube radius - job option - double m_inner_tube_radius; - //! lower radius for parabolic extrapolation at the upper end of the r-t - double m_lower_extrapolation_radius; - //! higher radius for parabolic extrapolation at the upper end of the r-t - double m_upper_extrapolation_radius; - //! write multilayer t_max-difference - bool m_multilayer_tmax_diff; - //! root file - TFile *p_file; - }; - -#endif - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleMTT0Tool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleMTT0Tool.h deleted file mode 100644 index e4af5a0585f62bc43231f408ab68bf58ddff812c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleMTT0Tool.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _NtupleMTT0Tool_H -#define _NtupleMTT0Tool_H - - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -class RegionSelectionSvc; - -//t0 algorithm -#include "MdtCalibT0/T0CalibrationMT.h" -#include "MdtCalibT0/T0MTSettings.h" - -namespace MuonCalib { - -/** @class NtupleMTT0Tool - Interface tool for the MT T0-Fitter - @author rauscher@cern.ch - */ - -class NtupleMTT0Tool: public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor*/ - NtupleMTT0Tool(const std::string& t, const std::string& n, const IInterface* p); - /** tool initialization */ - StatusCode initialize(); - - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** end of events analysis */ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - /** set calibratino region */ - void setRegion(); - /** get calibration results */ - const IMdtCalibrationOutput * getResults() const; - /** we dont need to keep the segments*/ - inline bool KeepSegments() const - { - return false; - } -//============================================================================== - private: - //! pointer to algorithm - T0CalibrationMT * p_alg; - //! settings class - T0MTSettings m_settings; - //! pointe rto region selectin service - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - //! number of negative and positive bins - int m_n_bins_neg, m_n_bins_pos; - //! use top chi2 instead of the normal one - bool m_use_top_chi2; - //! threshold for the application of the scrambling method - double m_scramble_thresh, m_sclicing_thresh; - //! minimum number of entries per fit - int m_min_entries_time, m_min_entries_adc; - //! group by - std::vector<std::string> m_group_by; - std::vector<int> m_sort_by; - std::vector<std::string> m_adc_group_by; - std::vector<int> m_adc_sort_by; - //! correct for relative t0 - bool m_correct_rel_t0; - - inline bool eval_group_by(const std::string & group_by, int & sort_by); - }; - -} - - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleResidualTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleResidualTool.h deleted file mode 100644 index 0fe9af020038f16c968f79ccb6916ece85576d3c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleResidualTool.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _NtupleResidualTool_H -#define _NtupleResidualTool_H - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - -//root -class TH2F; -class TH1F; -class TFile; -#include "TTree.h" - -namespace MuonCalib { - - -class QuasianalyticLineReconstruction; - -/** @class NtupleResidualTool - Interface tool for the MT T0-Fitter - @author rauscher@cern.ch - */ - -class NtupleResidualTool: public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor*/ - NtupleResidualTool(const std::string& t, const std::string& n, const IInterface* p); - /** tool initialization */ - StatusCode initialize(); - /** tool finalization */ - StatusCode finalize(); - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** we dont need to keep the segments*/ - inline bool KeepSegments() const - { - return false; - } -//============================================================================== - private: - TH2F *m_residual_distribution; - TH1F *m_r_spec; - TFile *m_outfile; - TH1F *m_chi2; - TH1F *m_nhits; - //quasianalytic fitter - QuasianalyticLineReconstruction *m_fitter; - - }; - -} - - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleResidualVsTimeTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleResidualVsTimeTool.h deleted file mode 100644 index 5029357d17ed21eee8ff2b81aa460f90b86f42e0..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleResidualVsTimeTool.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _NtupleResidualVsTimeTool_H -#define _NtupleResidualVsTimeTool_H - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - - -//root -class TH2F; -class TFile; -#include <map> - -namespace MuonCalib { - - -class IMdtPatRecFitter; - -/** @class NtupleResidualVsTimeTool - Interface tool for the MT T0-Fitter - @author rauscher@cern.ch - */ - -class NtupleResidualVsTimeTool: public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor*/ - NtupleResidualVsTimeTool(const std::string& t, const std::string& n, const IInterface* p); - /** tool initialization */ - StatusCode initialize(); - /** tool finalization */ - StatusCode finalize(); - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &event, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** we dont need to keep the segments*/ - inline bool KeepSegments() const - { - return false; - } -//============================================================================== - private: - bool m_curved_segments; - int m_min_hits; - std::map<std::pair<unsigned int, unsigned int> ,TH2F *> m_residual_distribution; - TH2F *m_last_residual_distribution; - TFile *m_outfile; - //quasianalytic fitter - IMdtPatRecFitter *m_fitter; - std::pair<unsigned int, unsigned int> m_last_lumiblock; - - }; - -} - - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleRunScanTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleRunScanTool.h deleted file mode 100644 index 1a60f0e423da9f1d3d46002c3745b0d8c3050b9d..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleRunScanTool.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _NtupleRunScanTool_H -#define _NtupleRunScanTool_H - -//c - c++ -#include "map" - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneTools/HitCounter.h" - -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -class TFile; - -namespace MuonCalib { - - -/** @class NtupleRunScanTool -Scans a run and checks for present chambers and number of hits -@author rauscher@cern.ch -*/ - -class NtupleRunScanTool: public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor*/ - NtupleRunScanTool(const std::string& t, const std::string& n, const IInterface* p); - ~NtupleRunScanTool()=default; - /** tool initialization */ - StatusCode initialize(); - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &event, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** end of events analysis - segemnts are not used here*/ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - /** we dont need to keep the segments*/ - inline bool KeepSegments() const - { - return false; - } -//============================================================================== - private: - //! minimum number of hits per drift time spectrum - job option - int m_min_hits; - //! maximum rate of bad fits - job option - double m_max_bad_fits; - //! suppress output for chambers which should not be fitted - bool m_suppress_nofit; - //! noisy tube factor: A tube is considered noisy, if n_hits > <n_hits> * m_noisy_tube_factor * n_tubes - int m_noisy_tube_factor; - //! hit counter classes - sortet by station - std::map<NtupleStationId, HitCounter> m_hit_counters; - //!access to geomodel - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - //!iov informatino - unsigned int m_time_min, m_time_max; - unsigned int m_run_min, m_run_max; - //! output file - TFile *p_outfile; - }; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleSimpleresolutionTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleSimpleresolutionTool.h deleted file mode 100644 index 3dca009b1d61397c823704cabb54fe424ffbed20..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleSimpleresolutionTool.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef NtupleSimpleResolutionToolH -#define NtupleSimpleResolutionToolH - -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -#include "string" -#include "vector" - -#define RBIN 30 - -/* ROOT */ -class TFile; -class TH2F; -class TF1; -class TGraphErrors; - -class MdtCalibInputSvc; - -namespace MuonCalib { - -class MuonCalibSegment; -class IRtRelation; - -class NtupleSimpleResolutionTool : public AthAlgTool, virtual public NtupleCalibrationTool - { -public: -/** Constructors **/ - NtupleSimpleResolutionTool(const std::string& t, const std::string& n, const IInterface* p); - - virtual ~NtupleSimpleResolutionTool()=default; - -/** Tool initialize **/ - StatusCode initialize(); - -/** Is called at the end of the analysis - The argumet is only there to overload the interface function*/ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & segemnts); - - void handle_segment(MuonCalibSegment & seg, double *par_lim_low, double - *par_lim_upp); - -/** get the final resolution after the algorithm has been run **/ - inline const IRtResolution * getResolution() const - { - return m_final_resolution; - } - -/** set calibratino region */ - void setRegion(); - -protected: - static const unsigned int MAXNUMHITS; - -private: - - void end_of_data(const IRtRelation * rt_rel); -/* resolution curves */ - IRtResolution *m_final_resolution; // final resolution curve - -/* segments */ - unsigned int m_number_of_segments; // number of selected segments - std::vector<MuonCalibSegment *> m_refitted_segment; - /* vector with the refitted segments - (used to store the segments for the autocalibration iteration) */ - - unsigned int m_MINNUMHITS; -/* bining and ranges for Histograms*/ - static const unsigned int SBIN = 500; - static const unsigned int RESBIN = 60; - static constexpr float SRANGE = 2.0; - static constexpr float RRANGE = 15.0; - static constexpr float RESRANGE = 6.0; - - -/* JOB OPTION PARAMETERS */ -/* do curved track fit - job option */ - bool m_curved; -/* track error entries limit - job optins */ - float m_REJ_LOW, m_REJ_TOP; -/* Relative difference betwen iterations for convergence. - job optins */ - float m_DELTA_CONV, m_DIFF_MAX; -/* maximimum number of iteration - job options */ - int m_MAX_NUM_IT; - bool m_hist_fit_method; - bool m_replace_with_flat; -/* Name of output file with resolution curve */ - std::string m_spr_out_name; -/* Outlier removal */ - bool m_suppress_outliers; - float m_SUPPRESS_LOW, m_SUPPRESS_TOP; - float m_low[RBIN], m_top[RBIN]; - -/* Calibration input service */ - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; -/* calibration region */ - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - -/* rt relation */ - const IRtRelation *m_rt_relation; - -/* is true if initialize is called - needed for genvonf */ - bool m_is_initialized; - - TFile *m_outfile; - - TH2F *m_residual; - TH2F *m_residual0; - TH2F *m_residual2; - TH2F *m_residual3; - - TH2F *m_sigma_track; - TH2F *m_sigma_track_lim; - - TF1 *m_sprfun; // - TF1 *m_sprfun_r; // - TGraphErrors *m_sprgr; - TGraphErrors *m_sprgr_r; - -/* private methods */ - void destruct(void); /* destruction routine */ - - int trackFit(int num_hit, double *dist_hit, double *y, - double *sigma2_hit, double &shift, double &sigma_track); - - int trkErrorFix(double *par_l, double *par_u); - - int spResCalc(bool SfromR); - - double t_from_r(const double & r, const IRtRelation * rt_rel); - /* //get t(r) for the r-t relationship rt_rel, - // the method is auxiliary and not optimized; - // it will disappear when the t(r) will be - // available in the MuonCalib framework; */ - -/* Functions for Root Fitting */ - static double ttt(double *x, double *par); - static double ttt0(double *x, double *par); -}; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h deleted file mode 100644 index f930c92a109efa3b0f718e2e8843bfa28843ec7e..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 10.04.2007, AUTHOR: STEFFEN KAISER -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#ifndef MuonCalib_NtupleTubeEfficiencyToolH -#define MuonCalib_NtupleTubeEfficiencyToolH - -//:::::::::::::::::::::::::::::::::::: -//:: CLASS NtupleTubeEfficiencyTool :: -//:::::::::::::::::::::::::::::::::::: - -/// \class NtupleTubeEfficiencyTool -/// -/// This class determines the single tube efficiencies and fakerates -/// and writes them to a TubeEfficiencies_<regionId>.txt and .root file. -/// (The fakerate only compares the raw hits to the tubes traversed by -/// one segment.) -/// -/// The combined efficiencies for the layer, multilayer and chamber are -/// calculated as weighted mean of the single tube efficiencies, according to -/// -/// eff = (Sum_i 1/sigma_i^2 * eff_i)/(Sum_i 1/sigma_i^2) -/// sigma = Sqrt( 1/(Sum_i 1/sigma_i^2) ) -/// -/// \author Steffen.Kaiser@cern.ch -/// -/// \date 10.04.2007 - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - -// this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" - -class RegionSelectionSvc; - -//root -class TFile; -class TNtuple; -class TH1F; -class TH1I; - -namespace MuonCalib { - -class QuasianalyticLineReconstruction; -class IIdToFixedIdTool; -class MuonCalibSegment; -class NtupleStationId; -class MuonCalibEvent; - - -class NtupleTubeEfficiencyTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - - public: - // Constructors // - NtupleTubeEfficiencyTool(const std::string& t, const std::string& n, const IInterface* p); - - ~NtupleTubeEfficiencyTool()=default; - ///< Destructor - - /** tool initialize */ - StatusCode initialize(); - - /** tool finalize */ - StatusCode finalize(); - - StatusCode handleEvent(const MuonCalibEvent & event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - ///< analysis of the given segment of - ///< event eventnumber, event contains - ///< the raw hits - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - ///< analysis at the end of the data - ///< file - inline bool KeepSegments() const - { - return false; - } - private: - - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - // MuonDetectorManager from the conditions store - SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", - "MuonDetectorManager", - "Key of input MuonDetectorManager condition data"}; - - const MuonCalib::IIdToFixedIdTool *m_id_tool; - - // ROOT file and analysis ntuples/trees // - TFile *m_tfile; // ROOT file - TFile *m_tfile_debug; // ROOT file for debug purposes - TNtuple *m_hit_ntuple; // hit ntuple - - std::string m_file_name; //root file name - double m_nb_hits; //minimum number of hits in segment - double m_road_width; //road width for pattern recognition - bool m_debug; //write debugging rootfile - double m_chi2_cut; //track chi2 cut; - bool m_exclude_layer; //exclude layer and refit for eff determination - - // calibration region// - //const NtupleStationId * m_cal_region; - - // line reconstruction // - QuasianalyticLineReconstruction *m_qfitter; - //! pointe rto region selectin service - ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; - - // counter/numbers // - int m_nb_trigger; - int m_nb_multilayers; - int m_nb_layers; - int m_nb_tubes; - - // histograms // - TH1F *m_h_distance; - TH1I *m_h_nb_hit_tubes; - - std::vector< std::vector< std::vector<TH1F*> > > m_h_efficiency; - std::vector< std::vector< std::vector<TH1F*> > > m_h_fakerate; - - std::vector< std::vector<TH1F*> > m_h_tube_efficiency; - std::vector< std::vector<TH1F*> > m_h_tube_fakerate; - - std::vector< std::vector<TH1F*> > m_h_tube_entries_efficiency; - std::vector< std::vector<TH1F*> > m_h_tube_entries_fakerate; - - TH1F *m_h_layer_efficiency; - - TH1F *m_h_chamber_efficiency; - - TH1F *m_h_chi2; - - }; - -} - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleWireCentricityTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleWireCentricityTool.h deleted file mode 100644 index e92b55bb778bed64249611dc480cd20f9f25bd1f..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleWireCentricityTool.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef MUONCALIBSTANDALONETOOLS_NTUPLEWIRECENTRICITYTOOL_H -#define MUONCALIBSTANDALONETOOLS_NTUPLEWIRECENTRICITYTOOL_H - - -//c - c++ -#include "map" - -//root -class TFile; -class TH1F; -#include "TTree.h" - -//MuonCalibIdentifier -#include "MuonCalibIdentifier/MuonFixedId.h" - -//this -#include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ServiceHandle.h" - -class MdtCalibInputSvc; - -namespace MuonCalib { - -class MuonCalibHitBase; - -/** @class NtupleWireCentricityTool - Checks for the centricity of the anode wire - @author rauscher@cern.ch - - */ - -class NtupleWireCentricityTool : public AthAlgTool, virtual public NtupleCalibrationTool - { - public: -//============================================================================== - /** Tool Constructor*/ - NtupleWireCentricityTool(const std::string& t, const std::string& n, const IInterface* p); - /** tool initialization */ - StatusCode initialize(); - - /**analyse event - fill hits into specra*/ - StatusCode handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); - /** end of events analysis */ - StatusCode analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/); - /** we dont need to keep the segments*/ - inline bool KeepSegments() const - { - return false; - } - void setRegion(); -//============================================================================== - private: - //! minimum track track slope - job option - double m_min_track_slope; - //! width of region in the middle of the tube tobe analysed - job option - double m_region_width; - //! root file - TFile *p_root_file; - //! drift time spectra for left and right side of the wire - TH1F *p_dt_spec_left, *p_dt_spec_right; - //! drift time spectra for tracks above, and below the wire - TH1F *p_dt_spec_above, *p_dt_spec_below; - //! track slope - TH1F *p_track_slope; - //! track slope - TH1F *p_track_slope_cut; - //! x coordinate - TH1F *m_x_coordinate; - //! track radius - TH1F *m_track_radius; - //! calibration input service - ServiceHandle<MdtCalibInputSvc> m_calib_input_svc; - //! drift velocity for large radii - Double_t m_drift_velocity; - //! region id - Int_t m_station, m_eta, m_phi, m_hw_phi; - //!tree data - Double_t m_mean_track_slope; - Int_t m_n_hits; - -//============================================================================== - inline void process_hit(const MdtCalibHitBase * hit, const double & track_slope); - }; - - - - -} - - - -#endif diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/python/MuonCalibStandAloneToolsConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/python/MuonCalibStandAloneToolsConfig.py deleted file mode 100644 index 979f3b50551056c0099a6e399ddb33c967e14975..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/python/MuonCalibStandAloneToolsConfig.py +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -from __future__ import print_function - -from MuonCalibStandAloneTools.MuonCalibStandAloneToolsConf import * - -#list tools that do not need any reclaibration -NoRecalibration = [ "RunScan", "DbCheck", "MTT0", "ResidualVsTimeTool" ] -#list tools that needs the t0 revertetd -RevertT0 = [ "ClassicT0" ] -#list tools, that needs the t0 recalibrated -RecalibT0 = [ "Integration" ] -#list tools that need all recalibrated -RecalibAll = [ "CalibADC", "ClassicAutocal", "AnalyticAutocal", "CurvedAutocal", "SimpleResolution", "Chi2Resolution", "Efficiency", "Display", "RPCTiming", "ControlHistograms", "MDTChamberGeometryDetermination", "MdtDqa"] -#list tools for which rt-scaling is to be reverted -RevertRtScaling = [ "Integration", "MTT0" ] -#list tools for which rt-scaling is to be reapplied -ApplRtScaling = RecalibAll[:] - - -#algorithms for which no segment refit should be done, even if requested by user -NoSegmentRefit = [ "RunScan", "DbCheck", "MTT0", "ClassicT0", "Integration"] - -#algorithms fotr which the number of read segments should be limited -LimitSegmentsFor = ["ClassicAutocal", "AnalyticAutocal", "CurvedAutocal", "SimpleResolution"] - -#algorithms, that need validated t0 and rt -ValidatedT0 = [ "CalibADC", "Integration", "ClassicAutocal", "AnalyticAutocal", "CurvedAutocal", "SimpleResolution", "Chi2Resolution", "Efficiency", "Display", "RPCTiming", "ControlHistograms", "MDTChamberGeometryDetermination" , "DbCheck"] - -ValidatedRt = [ "CalibADC", "ControlHistograms", "DbCheck", "RPCTiming", "Display"] - -def CreateCalibTool(CalibrationTool): - if CalibrationTool=="MTT0": - return MuonCalib__NtupleMTT0Tool() - if CalibrationTool=="CalibADC": - return MuonCalib__NtupleCalibADCTool() - elif CalibrationTool=="ClassicT0": - return MuonCalib__NtupleClassicT0Tool() - elif CalibrationTool=="Integration": - return MuonCalib__NtupleIntegrationTool() - elif CalibrationTool=="AnalyticAutocal": - return MuonCalib__NtupleAnalyticAutocalibrationTool() - elif CalibrationTool=="ClassicAutocal": - return MuonCalib__NtupleClassicAutocalibrationTool() - elif CalibrationTool=="CurvedAutocal": - return MuonCalib__NtupleCurvedAutocalibrationTool() - elif CalibrationTool=="SimpleResolution": - return MuonCalib__NtupleSimpleResolutionTool() - elif CalibrationTool=="Chi2Resolution": - return MuonCalib__NtupleChi2ResolutionTool() - elif CalibrationTool=="Efficiency": - return MuonCalib__NtupleEfficiencyTool() - elif CalibrationTool=="RunScan": - return MuonCalib__NtupleRunScanTool() - elif CalibrationTool=="ControlHistograms": - CalibrationTool = MuonCalib__NtupleControlHistogramsTool() - #store gate keys - CalibrationTool.detectorStore = "DetectorStore" - CalibrationTool.MDTIdHelper = "MDTIDHELPER" - CalibrationTool.idToFixedIdToolType = "MuonCalib::IdToFixedIdTool" - CalibrationTool.idToFixedIdToolName = "MuonCalib_IdToFixedIdTool" - return CalibrationTool - elif CalibrationTool=="MDTChamberGeometryDetermination": - return MuonCalib__NtupleMDTChamberGeometryDeterminationTool() - elif CalibrationTool=="Display": - return MuonCalib__NtupleDisplayTool() - elif CalibrationTool=="WireCentricity": - return MuonCalib__NtupleWireCentricityTool() - elif CalibrationTool == "DbCheck": - return MuonCalib__NtupleDbCheckTool() - elif CalibrationTool == "RPCTiming": - return MuonCalib__NtupleRPCTimingTool() - elif CalibrationTool == "ResidualVsTimeTool": - return MuonCalib__NtupleResidualVsTimeTool() - else: - print ("WARNING: Unnknown tool name '" + CalibrationTool + "'!") - return None diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/share/Calib2_MdtDqa.py b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/share/Calib2_MdtDqa.py deleted file mode 100755 index fdea2468f440b3264452257f37a562636a84541e..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/share/Calib2_MdtDqa.py +++ /dev/null @@ -1,338 +0,0 @@ -### Setup Athena common flags -include ("AthenaCommon/AthenaCommonFlags.py") -include.block("AthenaCommon/AthenaCommonFlags.py") - -include( "IOVDbSvc/IOVRecExCommon.py" ) - -doMuonCalibAtlas=True - -from AthenaCommon.AppMgr import ServiceMgr -from MuonCalibStandAloneBase.MuonCalibStandAloneBaseConf import RegionSelectionSvc -RegionSelectionSvc = RegionSelectionSvc() -#RegionSelectionSvc.Region = "[B??,5] & !([BEE])" -#RegionSelectionSvc.Region = "[BML,4,1]" -RegionSelectionSvc.Region = "[B??]" -# RegionSelectionSvc.Region = "[BIR,6,1]" -RegionSelectionSvc.PrintList = True -ServiceMgr += RegionSelectionSvc -printfunc (RegionSelectionSvc) -##################################USER SETTINGS################################# - -#select calibration algoritm -# scan run for chambers RunScan -# t0-Fitters: ClassicT0, MTT0 -# create rt by integration Integration -# autocalibration ClassicAutocal, AnalyticAutocal -# resolution SimpleResolution, Chi2Resolution -# efficiency Efficiency -# MDT DQA MdtDqa -# event display Display -# rpc timing RpcTiming -# control histograms ControlHistograms -# MDT chamber geometry determination MDTChamberGeometryDetermination -CalibrationAlgorithm = "MdtDqa" - -#select calibration site for the database access NONE|ROMA -#for different sites, you will have to edit -#CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg2.py -CalibrationSite = "NONE" - -#if set to true no drift ties and drift radii will be recalculated -#use this for validaion -NoRecalculation = False - -####################DO NOT CHANGE THS ############################# -include( "CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg13.py" ) ## -include( "MdtCalibIOSvc/MdtCalibIOSvc.py" ) ## -include( "MuonCalibStandAloneTools/MuonCalibStandAloneTools.py" )## -#include( "RpcTimingTool/RpcTimingTool.py") ## -from MuonCalibStandAloneBase.MuonCalibStandAloneBaseConf import MuonCalib__CalibrationTeeIOTool -CalibrationTeeIOTool = MuonCalib__CalibrationTeeIOTool() ## -ToolSvc += CalibrationTeeIOTool ## -################################################################### - -#set to true if you want to insert the calibration constants to the database -MdtCalibOutputDbSvc.PostprocessCalibration = True - -# list on files to be read in -CalibNtupleAnalysisAlg.FileList = "file_list.txt" - -#first event to be read in -CalibNtupleAnalysisAlg.FirstEvent = 0 - -#Trigger bit selection -#CalibNtupleAnalysisAlg.RequestedTAV = [ 53 ] -#CalibNtupleAnalysisAlg.VetoedTAV = [ 54 ] -#CalibNtupleAnalysisAlg.RequestedTAP = [ 53 ] -#CalibNtupleAnalysisAlg.VetoedTAP = [ 53 ] - - -#last event to be read in -#CalibNtupleAnalysisAlg.LastEvent = 20000 - -#number of segments needed for calibration -#reading of tuple will stop when number of segments are read -#an error will occur when not enough segments are read -#CalibNtupleAnalysisAlg.NumberOfSegments = 2000 - -#select output location for file io -#CalibrationFileIOTool.outputLocation = "calib_alt" - -#use a flat resolution as default -#MdtCalibOutputDbSvc.FlatDefaultResolution=0.5 - -#reject segments which extend over more than one station -CalibNtupleAnalysisAlg.RejectMultistationTracks = True - -#use mdt raw tdc as drift time -#CalibNtupleAnalysisAlg.TakeMdtRaw = False - -#set to true if you -CalibNtupleAnalysisAlg.segmentsFromRawData = False - -#refit segments -CalibNtupleAnalysisAlg.RefitSegments = False -CalibNtupleAnalysisAlg.RefitRoadwidth = 2 -#refine t0 -CalibNtupleAnalysisAlg.RefineT0 = False -#limit the number of rawdata hits which are converted to one segemnt -CalibNtupleAnalysisAlg.MaxRawdataHits = 16 -CalibNtupleAnalysisAlg.RawdataAdcCut = 0 - -#Minimum number of hits per segment -CalibNtupleAnalysisAlg.MinSegmentHits=3 - -#Request hits in both multilayers -CalibNtupleAnalysisAlg.HitsInBothMultilayers = False - -#get b-field from service -CalibNtupleAnalysisAlg.UseMagFieldSvc = True - -#MdtCalibInputSvc.CalibrationInputTool = CalibrationFileIOTool - -#read calibration constants from this directory -if CalibrationAlgorithm != "MTT0" and CalibrationAlgorithm != "ClassicT0" and CalibrationAlgorithm != "RunScan" and not NoRecalculation: - MdtCalibInputSvc.CalibrationInputTool = CalibrationFileIOTool - - -#Set geometry tag -from AthenaCommon.AppMgr import ServiceMgr -from AtlasGeoModel import SetGeometryVersion, GeoModelInit - -GeoModelSvc = ServiceMgr.GeoModelSvc -#GeoModelSvc.AtlasVersion = "ATLAS-CSC-01-02-00" - - -#select output tool -CalibrationTeeIOTool.IOTool1=CalibrationFileIOTool -CalibrationTeeIOTool.IOTool2=CalibrationOracleFileIOTool -MdtCalibOutputDbSvc.OutputTool=CalibrationTeeIOTool - -#++++++++++++++++++Algoritm specific settings+++++++++++++++++++++++++++++++++++ - -#------------------------------------for run scan------------------------------- -if CalibrationAlgorithm == "RunScan": - CalibNtupleAnalysisAlg.RefitSegments = False - #minimum number of hits per fit - CalibrationTool.MinHits = 2000 - #maximum rate of bad hits per chamber - CalibrationTool.MaxBadFits = 0.05 - #if set to true ommit output for chambers which are not to be fitted - CalibrationTool.SuppressNofit = True - #san all chambers - RegionSelectionSvc.Region = "" -#------------------------------------for MT t0 fitter--------------------------- -if CalibrationAlgorithm == "MTT0" : - CalibNtupleAnalysisAlg.RefitSegments = False - CalibNtupleAnalysisAlg.RefineT0 = False - #add fitted function to histogram - CalibrationTool.AddFitFun = True - #create TDirectory contining some debugging graphs - CalibrationTool.DrawDebugGraphs = True - #range of histogram ind 25/32 bins - CalibrationTool.NumberOfNegativeBins = 1000 - CalibrationTool.NumberOfPositiveBins = 3000 - #Fit for group of tubes - # TUBE one spectrum per tube - # LAYER one spectrum per layer - # MULTILAYER one spectrum per multilayer - # CHAMBER one spectrum per chamber - # MEZZ_CARD one spectrum per mezzanine card - CalibrationTool.GroupBy = "MEZZ_CARD" - -#------------------------------for classic t0 fitter---------------------------- -if CalibrationAlgorithm == "ClassicT0": - CalibNtupleAnalysisAlg.RefitSegments = False - CalibNtupleAnalysisAlg.RefineT0 = False - #range and binning of adc spectrum - CalibrationTool.NAdcBins = 100 - CalibrationTool.MinAdc = 0.0 - CalibrationTool.MaxAdc = 300.0 - #range and binning of the time spectrum - CalibrationTool.NTimeBins = 1280 - CalibrationTool.TimeMin = 0.0 - CalibrationTool.TimeMax = 2000.0 - #switch on/off fitting of time spectrum - CalibrationTool.FitTimeSpectrum = True - #Minimum number of entries - CalibrationTool.MinEntries = 2000 - #? - CalibrationTool.InitParam = 1 - #maximum chi^2 - CalibrationTool.MaxChi2 = 10.0 - -#----------------------------for integration method----------------------------- -if CalibrationAlgorithm == "Integration": - CalibNtupleAnalysisAlg.RefineT0 = False - #mazimum drift time - CalibrationTool.TMaxInt = 710 - #set to true if close hits are stored in the ntuple - CalibrationTool.HaseCloseHits = False - #the inner radius of the drift tube - CalibrationTool.InnerTubeRadius = 14.6 - -# --------------------for classical autocalibration----------------------------- -if CalibrationAlgorithm == "ClassicAutocal" : - #range for the number of hits - CalibrationTool.MinimumNumberOfHits = 5 - CalibrationTool.MaximumNumberOfHits = 10 - #maximum number of iterations - CalibrationTool.NumberOfIterations = 10 - #chi2 cuts - ? - CalibrationTool.Chi2CutVec = [ 50, 40, 30, 20, 10, 10, 10, 5, 5, 5 ] - CalibrationTool.Chi2Cut = 10.0 - - -#-------------------for analytic autocalibration-------------------------------- -if CalibrationAlgorithm == "AnalyticAutocal": - #accuracy of the initial rt relation - CalibrationTool.Accuracy = 0.5 - #type of the correction function LEGENDRE|CHEBYSHEV|POLYGON - CalibrationTool.FunctionType = "LEGENDRE" - #order of the correction function - CalibrationTool.FunctionOrder = 15 - #use the full matrix - ? - CalibrationTool.FullMatrix = True - # fix minimum/maximum - CalibrationTool.FixMin = True # fix r(t0) - CalibrationTool.FixMax = False # do not fix r(tmax) - #maximum number of iterations - CalibrationTool.MaximumIterations = 15 - -#-----------------for simple resolution----------------------------------------- -#--select NumberOfSegments=10000 -#--switch on RefineT0 and use HistFitMethod for commissioning data -if CalibrationAlgorithm == "SimpleResolution": - CalibrationTool.CurvedFit = False #use a curved track fit (set it to true - #for data with magnetic field) -#selection criteria - CalibrationTool.RejectLow = 0.1 #default 0.1 - CalibrationTool.RejectTop = 0.40 #default 0.30 -#convergence - CalibrationTool.DeltaConv = 0.06 #default 0.05 - CalibrationTool.DiffMax = 0.007 #default 0.006 microns - CalibrationTool.MaximumIterations = 20 #default 20 -#Replace initial spatial resoluton with flat one (=0.3mm). Used for validation. - CalibrationTool.InitialFlatResolution = False -#Obtain resolution using histogram fitting. Usefull in case of 'noisy' residuals. - CalibrationTool.HistFitMethod = True -#Remove hits with large residuals (outliers). -# CalibrationTool.SuppressOutliers = True -# CalibrationTool.SuppressionLow = 0.17 -# CalibrationTool.SuppressionTop = 0.17 - CalibrationTool.OutputResolutionFunction = "spr_out.root" - - -#-----------------for RCP Timing------------------------------------------------ -if CalibrationAlgorithm == "RpcTiming": - CalibNtupleAnalysisAlg.RefineT0 = False - #analysis cue - defaults to "MODULE", "DOUBLET", "STATION", "PAIRS", "MEAN", "ALLSPEC" -# CalibrationTool.Cue = [ "MODULE" ] - #output and input file for timing constants - #NONE: do not read/ write file - #AUTO: filename is rpc_timing<run_nr>.txt - CalibrationTool.TimingInfile = "NONE" - CalibrationTool.TimingOutfile = "AUTO" - #automatically select all stations for this analysis - CalibNtupleAnalysisAlg.SelectStation = "ANY" - CalibNtupleAnalysisAlg.SelectEta = 0 - CalibNtupleAnalysisAlg.SelectPhi = -1 - -#-----------------for control histograms---------------------------------------- -if CalibrationAlgorithm == "ControlHistograms": - #refit segments with the given calibration - CalibrationTool.segmentRefit = True - #road width for segment refit in mm - CalibrationTool.roadWidth = 1 - #store gate keys - CalibrationTool.detectorStore = "DetectorStore" - CalibrationTool.MDTIdHelper = "MDTIDHELPER" - CalibrationTool.idToFixedIdToolType = "MuonCalib::IdToFixedIdTool" - CalibrationTool.idToFixedIdToolName = "MuonCalib_IdToFixedIdTool" - #name of the ROOT output file - CalibrationTool.ROOTFileName = "NtupleControlHistogramsTool.root" - -#-----------------for MDT chamber geometry determination------------------------ -if CalibrationAlgorithm == "MDTChamberGeometryDetermination": - #write out a ROOT control file - CalibrationTool.writeControlHistograms = True - #name of this ROOT file - CalibrationTool.ROOTFileName = "NtupleMDTChamberGeometryDeterminationTool.root" - #granularity: "TUBE", "LAYER", "MULTILAYER" - CalibrationTool.granularity = "MULTILAYER" - #reference multilayer (1 or 2) - CalibrationTool.referenceMultilayer = 1 - #road width for pattern recognition in mm - #(also used in the misalignment cuts) - CalibrationTool.roadWidth = 2.0 - #geometry file tag for the output of the initial and final geometry - CalibrationTool.geometryFileName = "MDTgeom" - #store gate keys - CalibrationTool.detectorStore = "DetectorStore" - CalibrationTool.MDTIdHelper = "MDTIDHELPER" - CalibrationTool.idToFixedIdToolType = "MuonCalib::IdToFixedIdTool" - CalibrationTool.idToFixedIdToolName = "MuonCalib_IdToFixedIdTool" - -#-----------------for efficiencies---------------------------------------------- -if CalibrationAlgorithm == "Efficiency": - CalibrationTool.nSegmentHits = 5 - CalibrationTool.roadWidth = 2.0 - CalibrationTool.fileName = "TubeEfficiencies" - CalibrationTool.Debug = False - CalibrationTool.Chi2Cut = 10 - CalibrationTool.excludeLayer = False - -#-----------------for MdtDqa ---------------------------------------------- -if CalibrationAlgorithm == "MdtDqa": - #----------- jobOptions for MdtDqaNtupleAnalysis : - CalibrationTool.MdtDqaFileName = "MdtDqa" - CalibrationTool.Verbose = False - CalibrationTool.FillHistos = True - CalibrationTool.doFinalize = True - CalibrationTool.doEfficiency = True - #----------- jobOptions for NtupleTubeEfficiency : - CalibrationTool.fileName = "TubeEfficiency" - CalibrationTool.nSegmentHits = 5 - CalibrationTool.roadWidth = 2.0 - CalibrationTool.Chi2Cut = 10 - CalibrationTool.excludeLayer = False - CalibrationTool.Debug = False - -#-----------------for display--------------------------------------------------- -if CalibrationAlgorithm == "Display": - CalibrationTool.nSegmentHits = 5 - CalibrationTool.roadWidth = 2.0 - CalibrationTool.adcCut = CalibNtupleAnalysisAlg.RawdataAdcCut - #CalibrationTool.displayEvent = 123 - #CalibrationTool.scaleDisplay = 0.5 - -#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++### Setup Athena common flags - - -printfunc (CalibrationTool) -printfunc (MdtCalibOutputDbSvc) -printfunc (ServiceMgr) -printfunc (MdtCalibInputSvc) -printfunc (AlgSequence()) -from ROOT import gROOT, TCanvas, TF1 - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/share/spr_root.C b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/share/spr_root.C deleted file mode 100644 index fcfcb2e7d01b7edeecc4a1960bdd25138c0f9f90..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/share/spr_root.C +++ /dev/null @@ -1,81 +0,0 @@ -// ROOTSYS/tutorials -{ - const unsigned int SBIN=500, RESBIN=60, RBIN=30; - const float RESRANGE=6.0, SRANGE=0.75, RRANGE=15.0; - -gStyle->SetCanvasColor(10); -gStyle->SetPadColor(10); -gStyle->SetCanvasBorderMode(0); -gStyle->SetPadBorderMode(0); - -TCanvas *c2 = new TCanvas("c2","c2",1000,1000); -c2->Divide(2,3); -gStyle->SetOptStat(1); -gStyle->SetOptFit(1); - - TFile *top = 0; -// top = new TFile("run_26462/sprBOL5.root","read"); - top = new TFile("../spr_out.root","read"); - if(!top->IsOpen()) { - printf("no such file\n"); - return 0; - } - -// TTree *tree = 0; -// tree = (TTree *)top->Get("ntuple"); - - c2->cd(1); gPad->SetGrid(); - TH2F *residuals2 = 0; - residuals2 = (TH2F *)top->Get("m_residual2"); - residuals2->SetTitle("INITIAL RESIDUALS"); - residuals2->Draw(); - - - TH2F *sigma_track ; - sigma_track = (TH2F *)top->Get("m_sigma_track"); - - gStyle->SetOptStat(1); - c2->cd(3); gPad->SetGrid(); - - sigma_track->SetTitle("TRACK FIT ERROR"); - sigma_track->Draw(); - - c2->cd(4); gPad->SetGrid(); - TH2F *sigma_track_lim = (TH2F *)top->Get("m_sigma_track_lim"); - TProfile *tr_lim_prf = (TProfile *)sigma_track_lim->ProfileX(); - sigma_track_lim->SetTitle("TRACK FIT ERROR (SELECTED REGION)"); - sigma_track_lim->Draw(); - tr_lim_prf->SetLineColor(7); - tr_lim_prf->SetLineWidth(3); - tr_lim_prf->Draw("SAME"); - - c2->cd(5); gPad->SetGrid(); - TH2F *residuals = 0; - residuals = (TH2F *)top->Get("m_residual"); - residuals->SetTitle("RESIDUALS AFTER REFIT (hit excluded)"); - residuals->Draw(); - - c2->cd(6); gPad->SetGrid(); - TH2D *empty = new TH2D("empty","Resolution",1000, 0.0, RRANGE,1000, 0, SRANGE); - empty->SetTitle("RESOLUTION vs DRIFT RADIUS"); - empty->DrawCopy(); -// tree->Draw("SigmaDriftRadius:DriftRadius>>empty","","SAME P"); - TGraphErrors *sprgr_r=0; - sprgr_r = (TGraphErrors*)top->Get("sprgr_r"); - sprgr_r->SetMarkerStyle(20); - sprgr_r->SetMarkerSize(0.7); - sprgr_r->SetMarkerColor(6); - sprgr_r->Draw("P SAME"); - TF1 *sprf_r = 0; - sprf_r = (TF1*)top->Get("sprfun_r"); - sprf_r->SetLineColor(6); - sprf_r->DrawCopy("SAME"); -/* -TCanvas *c1 = new TCanvas("c1","c1",1024,800); - c1->cd(); gPad->SetGrid(); - TH2F *residuals2 = 0; - residuals2 = (TH2F *)top->Get("m_residual2"); - residuals2->SetTitle("RESIDUALS vs DRIFT RADIUS"); - residuals2->Draw(); -*/ -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/HitCounter.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/HitCounter.cxx deleted file mode 100644 index 5cd36156b70354f7251748af99efc769e88f252a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/HitCounter.cxx +++ /dev/null @@ -1,200 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" -#include "MuonCalibStandAloneTools/HitCounter.h" -#include "GaudiKernel/MsgStream.h" -#include "AthenaKernel/getMessageSvc.h" - -#include "iostream" -#include "TDirectory.h" -#include "TH1.h" - -namespace MuonCalib { - -bool HitCounter::Initialize(const NtupleStationId &id) { - m_id=id; - if(id.NMultilayers() == -1) { - MsgStream log(Athena::getMessageSvc(),"HitCounter"); - log<<MSG::WARNING<<"HitCounter::Initialize:Geometry for idenifier not initialized!"<<endmsg; - return false; - } - m_per_chamber=0; - for(int i=0; i<id.NMultilayers(); i++) - { - m_per_ml[i]=0; - m_mezz_width[i]=8; - if(id.NLayers(i)==4) m_mezz_width[i]=6; - TubeId tid; - tid.ml=i; - for(tid.ly=0; tid.ly<id.NLayers(i); tid.ly++) - for(tid.tb=0; tid.tb<id.NTubes(i); tid.tb++) - { - m_per_tube[tid]=0; - } - MezzId mid; - mid.ml=i; - for(mid.mezz=0; mid.mezz<id.NTubes(i)/m_mezz_width[i]; mid.mezz++) - { - m_per_mezz[mid]=0; - } - } - m_n_dead_tubes=0; - m_n_dead_mezz=0; - m_n_dead_ml=0; - m_name = id.regionId(); - m_is_initialized=true; - m_wd = gDirectory->mkdir(m_name.c_str(), m_name.c_str()); - m_wd->cd(); - m_hits_per_segments = new TH1F("hits_per_segments", "", 433, -0.5, 432.5); - return true; - } - - -void HitCounter::ProcessSegment(const MuonCalibSegment & segment) - { - m_hits_per_segments->Fill(static_cast<Axis_t>(segment.hitsOnTrack())); - MuonCalibSegment::MdtHitCit it(segment.mdtHOTBegin()); - for(; it!=segment.mdtHOTEnd(); it++) - { - m_per_chamber++; - TubeId tid; - if (!(m_id==(*it)->identify())) continue; - NtupleStationId id((*it)->identify()); - tid.ml = (*it)->identify().mdtMultilayer()-1; - tid.ly = (*it)->identify().mdtTubeLayer()-1; - tid.tb = (*it)->identify().mdtTube()-1; - m_per_tube[tid]=m_per_tube[tid]+1; - MezzId mid; - mid.ml=tid.ml; - mid.mezz=tid.tb/m_mezz_width[tid.ml]; - m_per_mezz[mid]=m_per_mezz[mid]+1; - m_per_ml[tid.ml]=m_per_ml[tid.ml]+1; - } - } - -const std::string & HitCounter::FittingBy(int min_hits, double bad_fit_rate) - { - m_wd->cd(); -//try per tube - double n_bad(0.0), n_total(0.0); - Axis_t index(0.0); - TH1F *tubes = new TH1F("Tubes", "Tubes", m_per_tube.size(), -0.5, m_per_tube.size() - 0.5); - TH1F *tubes_index = new TH1F("tubes_index", "", 576, -0.5,575.5); - for (int i=1; i<=576; i++) - tubes_index->SetBinContent(i, -1.0); - m_fit_by_int = -1; - for(std::map<TubeId, int>::const_iterator it=m_per_tube.begin(); it!=m_per_tube.end(); it++) - { - if(it->second>0) - { - n_total++; - if(it->second<min_hits) n_bad++; - } - else - { - m_n_dead_tubes++; - } - tubes->Fill(index, it->second); - index++; - int fix_index = it->first.tb + 72*(it->first.ly) + 288*(it->first.ml); - tubes_index->SetBinContent(fix_index + 1, it->second); - } - tubes->SetEntries(m_per_chamber); - if(n_bad/n_total <= bad_fit_rate) - { - m_fit_by="TUBE"; - m_fit_by_int = 1; - } -//try per mezzanine - n_bad=0; n_total=0; - index=0.0; - TH1F *mezzanaines = new TH1F("Mezzanine", "Mezzanine", m_per_mezz.size(), -0.5, m_per_mezz.size() - 0.5); - for(std::map<MezzId, int>::const_iterator it=m_per_mezz.begin(); it!=m_per_mezz.end(); it++) - { - if(it->second > 0) - { - n_total++; - if(it->second<min_hits) n_bad++; - } - else - { - m_n_dead_mezz++; - } - mezzanaines->Fill(index, it->second); - index++; - } - mezzanaines->SetEntries(m_per_chamber); - if(n_bad/n_total <= bad_fit_rate && m_fit_by_int == -1) - { - m_fit_by="MEZZ_CARD"; - m_fit_by_int=2; - } -//try per multilayer - n_bad=0; n_total=0; - index=0.0; - TH1F *mls = new TH1F("Multilayers", "Mulitlayers", m_per_ml.size(), -0.5, m_per_ml.size() - 0.5); - for(std::map<int, int>::const_iterator it=m_per_ml.begin(); it!=m_per_ml.end(); it++) - { - if(it->second > 0) - { - n_total++; - if(it->second<min_hits) n_bad++; - } - else - { - m_n_dead_ml++; - } - mls->Fill(index, it->second); - index++; - } - mls->SetEntries(m_per_chamber); - if(n_bad/n_total <= bad_fit_rate && m_fit_by_int == -1) - { - m_fit_by="MULTILAYER"; - m_fit_by_int = 3; - } -// m_wd->Write(); -//try total - if(m_per_chamber>=min_hits &&m_fit_by_int == -1 ) - { - m_fit_by="CHAMBER"; - m_fit_by_int = 4; - return m_fit_by; - } - if(m_fit_by_int == -1) - { - m_fit_by="NOFIT"; - } - return m_fit_by; - } - -std::map<HitCounter::TubeId, HitCounter::DQInfo> HitCounter::InitialDQ(int noisy_tube_factor) const - { - double mean_nhits(0.0); - double n(0.0); - for(std::map<TubeId, int>::const_iterator it=m_per_tube.begin(); it!=m_per_tube.end(); it++) - { - if(it->second>0) - { - mean_nhits+=1.0/static_cast<double>(it->second); - n++; - } - } - mean_nhits=n/mean_nhits; - std::map<TubeId, DQInfo> ret; - for(std::map<TubeId, int>::const_iterator it=m_per_tube.begin(); it!=m_per_tube.end(); it++) - { - if(it->second == 0) - ret[it->first].SetDead(); - if(it->second > n * noisy_tube_factor * mean_nhits) - { - ret[it->first].SetNoisy(); - } - } - return ret; - } - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleAnalyticAutocalibrationTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleAnalyticAutocalibrationTool.cxx deleted file mode 100644 index e1a438441789a688da881265ab3e41f7d9d99f4a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleAnalyticAutocalibrationTool.cxx +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//MdtCalibRt -#include "MdtCalibRt/RtCalibrationAnalytic.h" -#include "MdtCalibRt/RtCalibrationOutput.h" - - -//MdtCalibData -#include "MdtCalibData/RtFullInfo.h" -//this -#include "MuonCalibStandAloneTools/NtupleAnalyticAutocalibrationTool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -namespace MuonCalib { - -NtupleAnalyticAutocalibrationTool :: NtupleAnalyticAutocalibrationTool(const std::string& t, const std::string& n, const IInterface* p): - AthAlgTool(t, n, p), - m_autocalibration(NULL), - m_rt_accuracy(0.5), - m_func_type("LEGENDRE"), - m_order(15), - m_split(false), - m_full_matrix(true), - m_fix_min(true), - m_fix_max(false), - m_max_it(100), - m_force_mono(false), - m_control_histograms(false), - m_calib_input_svc("MdtCalibInputSvc", n), - m_failed(false), - m_smoothening(false), - m_parabolic_extrapolation(false) - { - declareInterface< NtupleCalibrationTool >(this); - declareProperty("Accuracy", m_rt_accuracy); - declareProperty("FunctionType", m_func_type); - declareProperty("FunctionOrder", m_order); - declareProperty("Split", m_split); - declareProperty("FullMatrix", m_full_matrix); - declareProperty("FixMin", m_fix_min); - declareProperty("FixMax", m_fix_max); - declareProperty("MaximumIterations", m_max_it); - declareProperty("ForceMonotonous", m_force_mono); - declareProperty("ControlHistograms", m_control_histograms); - declareProperty("ConventionalSmoothening", m_smoothening); - declareProperty("ParabolicExtrapolation", m_parabolic_extrapolation); - declareProperty("MdtCalibInputSvc", m_calib_input_svc); - } - -StatusCode NtupleAnalyticAutocalibrationTool :: initialize() - { - ATH_MSG_INFO( "initialize()" ); -//interpret functino type - if(m_func_type == "LEGENDRE") - { - m_func_type_num = 1; - } - else if (m_func_type == "CHEBYSHEV") - { - m_func_type_num = 2; - } - else if (m_func_type == "POLYGON") - { - m_func_type_num = 3; - } - else - { - ATH_MSG_FATAL( "Invalid function type '" << m_func_type << "'!" ); - return StatusCode ::FAILURE; - } - if(m_force_mono) - { - ATH_MSG_INFO( "Forcing monotonous rt-relation" ); - } -//get pointer to Calibration input service - ATH_CHECK( m_calib_input_svc.retrieve() ); - setRegion(); - return StatusCode :: SUCCESS; - } - -void NtupleAnalyticAutocalibrationTool :: setRegion() - { -//retrieve rt-relationid - const IRtRelation *rt_relation(m_calib_input_svc->GetRtRelation()); - if(rt_relation == NULL) - { - ATH_MSG_FATAL( "No rt-relation stored for this region!" ); - return; - } -//create objects - ATH_MSG_INFO( "Creating RtCalibrationAnalytic!" ); - m_autocalibration = new RtCalibrationAnalytic("RT", m_rt_accuracy, m_func_type_num, m_order, m_split, m_full_matrix, m_fix_min, m_fix_max, m_max_it, m_smoothening, m_parabolic_extrapolation); - ATH_MSG_INFO( "setInput!" ); - m_autocalibration->setInput(new RtCalibrationOutput(rt_relation, new RtFullInfo())); - if(m_force_mono) - { - m_autocalibration->forceMonotony(); - } - if(m_control_histograms) - { - m_autocalibration-> switch_on_control_histograms("AnalyticAutocalibration.root"); - } - } - -StatusCode NtupleAnalyticAutocalibrationTool :: analyseSegments(const std::vector<MuonCalibSegment *> & segemnts) - { - if(m_autocalibration == NULL) - { - ATH_MSG_FATAL( "Algorithm not created!" ); - m_failed=true; - return StatusCode::FAILURE; - } - if(m_autocalibration->analyseSegments(segemnts)==NULL) - { - m_autocalibration->switch_off_control_histograms(); - m_failed=true; - return StatusCode :: FAILURE; - } - m_autocalibration->switch_off_control_histograms(); - return StatusCode::SUCCESS; - } - -const IMdtCalibrationOutput * NtupleAnalyticAutocalibrationTool :: getResults() const - { - if(m_autocalibration == NULL) - { - ATH_MSG_FATAL( "Algorithm not created!" ); - return NULL; - } - if (m_failed) return NULL; - return m_autocalibration->getResults(); - } - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleCalibADCTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleCalibADCTool.cxx deleted file mode 100644 index b17989955f06bd79f4f0b5b2ac0310a4ab9d3cab..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleCalibADCTool.cxx +++ /dev/null @@ -1,767 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 14.04.2009, AUTHOR: Zhen YAN -// Use for ADC parameters studies. -// -// 2009.09.02 v510 1) Study double hits ( second peak in TDC spectrum ) -// 2) Get the ADC normalize parameter and ADC correction factors -// 3) validate the Residual_vs_Radius by applying ADC correction -// -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::: -//:: IMPLEMENTATION OF THE METHODS DEFINED IN THE CLASS :: -//:: NtupleCalibADCTool :: -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -// standard C++ // -#include <iostream> -#include <fstream> - -// CLHEP // -#include "CLHEP/GenericFunctions/CumulativeChiSquare.hh" - -// MuonGeoModel // -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonReadoutGeometry/RpcReadoutElement.h" - -// MuonCalib // -#include "MdtCalibUtils/GlobalTimeFitter.h" -#include "MdtCalibFitters/DCSLFitter.h" -// -#include "MuonCalibStandAloneTools/NtupleCalibADCTool.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibRawRpcHit.h" -#include "MuonCalibStl/ToString.h" -#include "MuonCalibIdentifier/MuonFixedId.h" -#include "MdtCalibT0/T0MTHistos.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -#include "TF1.h" -#include "TTree.h" -#include "TProfile.h" -#include <stdio.h> - -//:::::::::::::::::::::::: -//:: NAMESPACE SETTINGS :: -//:::::::::::::::::::::::: -using namespace MuonCalib; - -//***************************************************************************** - -//::::::::::::::::: -//:: CONSTRUCTOR :: -//::::::::::::::::: - -NtupleCalibADCTool::NtupleCalibADCTool(const std::string & t, - const std::string & n, const IInterface * p) : AthAlgTool(t, n, p), - m_reg_sel_svc("RegionSelectionSvc", n), m_input_service("MdtCalibInputSvc", n) { - -///////////////// -// JOB OPTIONS // -///////////////// - - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - declareProperty("MdtCalibInputSvc", m_input_service); - - m_refit_segments = true ; // by default refit the segments - declareProperty("segmentRefit", m_refit_segments); - - m_Recalc2ndCoordinate = false ; // check this flag to dicide if ADC_vs_DistanceToReadout can be use or not - declareProperty("Recalc2ndCoordinate", m_Recalc2ndCoordinate); - - m_curved_fits = false ; // by default straight refits of the segments - declareProperty("curvedSegmentRefit", m_curved_fits); - - m_time_out = 2.0; // by default 2 s time-out for pattern finding - declareProperty("timeOut", m_time_out); - - m_road_width = 3.0; // by default road width = 1 mm - declareProperty("roadWidth", m_road_width); - - m_MDT_ID_helper = std::string("MDTIDHELPER"); - declareProperty("MDTIdHelper", m_MDT_ID_helper); - - m_RPC_ID_helper = std::string("RPCIDHELPER"); - declareProperty("RPCIdHelper", m_RPC_ID_helper); - - m_idToFixedIdToolType = std::string("MuonCalib::IdToFixedIdTool"); - declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); - - m_idToFixedIdToolName = std::string("MuonCalib_IdToFixedIdTool"); - declareProperty("idToFixedIdToolName", m_idToFixedIdToolName); - - m_ROOT_file_name = std::string("NtupleCalibADCTool.root"); - declareProperty("ROOTFileName", m_ROOT_file_name); - -///////////////////////////// -// RESET PRIVATE VARIABLES // -///////////////////////////// - m_MDT_adc_vs_radius.clear(); - m_MDT_adc_vs_pathD.clear(); - m_MDT_adc_vs_residual.clear(); - m_MDT_adc_vs_posX.clear(); - m_MDT_adc_vs_DistanceToSegmentTrack.clear(); - m_MDT_radius_vs_DistanceToSegmentTrack.clear(); - m_MDT_radius_vs_t.clear(); - m_MDT_segment_localangle_YZ.clear(); //local incidence angle XZ, YZ distributions of the segments - m_MDT_segment_localangle_XZ.clear(); - // mc_MDT_adc_vs_radius.clear(); - // m_MDT_adc_vs_tdc.clear(); - // m_MDT_adc_vs_t.clear(); - // m_MDT_posX_vs_radius.clear(); - // m_MDT_Revadc_vs_residual.clear(); - // m_MDT_radius_vs_residual.clear(); - // m_MDT_posX_vs_residual.clear(); - // m_MDT_pathD_vs_residual.clear(); - - // m_MDT_adc_vs_segment_localangle_YZ.clear(); //local incidence angle XZ, YZ distributions of the segments - // m_MDT_adc_vs_segment_localangle_XZ.clear(); - // m_MDT_adc_vs_segment_globalangle_YZ.clear(); //global incidence angle XZ, YZ distributions of the segments - // m_MDT_adc_vs_segment_globalangle_XZ.clear(); - - // v410 -for(int i=0;i<3;++i) -{ - m_MDT_residual_vs_radius[i].clear(); - m_MDT_segment_hits[i].clear(); - m_MDT_segment_chi2[i].clear(); -} - m_MDT_segment_delta_chi2.clear(); - // m_MDT_residual_vs_radius_NoRefit.clear(); - // m_MDT_residual_vs_radius_Refit.clear(); - // m_MDT_residual_vs_radius_TimeSlewing.clear(); - for(int i=0;i<15;++i) -{ - m_r_MDT_residual_vs_adc[i].clear(); -} - -/*for(int i=0;i<6;++i) - { -// a_MDT_adc_vs_posX[i].clear(); -// a_MDT_adc_vs_residual[i].clear(); - a_MDT_adc_vs_radius_XZ[i].clear(); - a_MDT_adc_vs_radius_YZ[i].clear(); - } -*/ -m_MDT_fhit_adc.clear(); -m_MDT_SiHitAdc.clear(); - - // Other parameter - m_nb_events = 0; - m_MdtIdHelper = 0; - m_RpcIdHelper = 0; - m_id_tool = 0; - - m_qfitter = new QuasianalyticLineReconstruction(); - m_cfitter = new CurvedPatRec(); - m_t0_refinement = new T0Refinement(); - - declareInterface< NtupleCalibrationTool >(this); - -} - -//***************************************************************************** - -//:::::::::::::::: -//:: DESTRUCTOR :: -//:::::::::::::::: - -NtupleCalibADCTool::~NtupleCalibADCTool(void) { - -} - -//***************************************************************************** - -//::::::::::::::::::::::: -//:: METHOD initialize :: -//::::::::::::::::::::::: - -StatusCode NtupleCalibADCTool::initialize(void) { - -/////////////// -// VARIABLES // -/////////////// - - -///////////// -// MESSAGE // -///////////// - - ATH_MSG_INFO( "Initializing tool..." ); - -//////////////////////////////////////////////////// -// STORE GATE AND GEOMODEL RELATED INITIALIZATION // -//////////////////////////////////////////////////// - -// MDT ID helper // - ATH_CHECK( detStore()->retrieve(m_MdtIdHelper, m_MDT_ID_helper) ); - -// RPC ID helper // - ATH_CHECK( detStore()->retrieve(m_RpcIdHelper, m_RPC_ID_helper) ); - -//retrieve detector manager from the conditions store - ATH_CHECK(m_DetectorManagerKey.initialize()); - -// muon fixed id tool // - ATH_CHECK( toolSvc()->retrieveTool(m_idToFixedIdToolType, - m_idToFixedIdToolName, m_id_tool) ); - -// calibration input service // - ATH_CHECK( m_input_service.retrieve() ); - -//////////////////////// -// OPEN THE ROOT FILE // -//////////////////////// - - m_tfile = new TFile(m_ROOT_file_name.c_str(), "RECREATE"); - -///////////////////////////////// -// SET UP STRAIGHT-LINE FITTER // -///////////////////////////////// - - m_qfitter->setRoadWidth(m_road_width); - m_qfitter->switchOnRefit(); - m_qfitter->setTimeOut(m_time_out); - m_cfitter->setRoadWidth(m_road_width); - m_cfitter->setTimeOut(m_time_out); - -//get region selection service - ATH_CHECK( m_reg_sel_svc.retrieve() ); - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//::::::::::::::::::::: -//:: METHOD finalize :: -//::::::::::::::::::::: - -StatusCode NtupleCalibADCTool::finalize(void) { - -/////////////// -// VARIABLES // -/////////////// - - -///////////// -// MESSAGE // -///////////// - - ATH_MSG_INFO( "Finalizing tool..." ); -//the summary tree creation crashes if the refit option is not set -- To be fixed! - if (!m_refit_segments) - { - m_tfile->Write(); - - return StatusCode::SUCCESS; - } - -/////////////////////////////// -// Postprocess histogramms // -/////////////////////////////// - m_tfile->cd(); -//station id - -///////////////////////// -// WRITE THE ROOT FILE // -///////////////////////// - - m_tfile->Write(); - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//:::::::::::::::::::::::: -//:: METHOD handleEvent :: -//:::::::::::::::::::::::: - -StatusCode NtupleCalibADCTool::handleEvent( - const MuonCalibEvent & event, - int /*evnt_nb*/, - const std::vector<MuonCalibSegment *> & segments, - unsigned int position) { - -/////////////// -// VARIABLES // -/////////////// -0.00205705 for BML4A05 only -/* double cor[15] = {0,-0.00354407,-0.00306112,-0.00193288,-0.00109093,-0.000831173,-0.00066971,-0.000611956,-0.000610348,-0.00048119,-0.00045121,-0.000412511,-0.000346831,-0.00027503,0.000124506 }; - double low_bin[15] = {48.8971,53.4205,63.7885,74.7095,79.9586,81.4944,81.2939,79.9401,79.2682,77.0589,75.6614,74.56,73.1008,71.8534,64.8691 }; - double high_bin[15] = {241.69,242.37,260.751,270.535,275.781,276.369,272.933,269.351,261.99,258.231,251.039,242.985,235.595,226.821,219.6 }; - double ADC0[15]={-49.9848,131.757,168.377,180.345,168.991,174.58,209.455,230.637,214.304,200.673,200.648,199.065,163.635,161.754,89.7234 }; -*/ -double cor[15] = {-0.00427636,-0.00594769,-0.00331729,-0.0026683,-0.00112401,-0.000616045,-0.000536907,-0.000297823,-4.62138e-005,0.000156364,0.000120936,-7.1578e-005,0.000259177,-0.000340251,5.11028e-005 } ; -double ADC0[15] = {73.7515,110.755,103.724,122.37,136.487,195.278,221.442,296.233,1432.72,-166.977,-182.321,577.875,-23.6606,195.662,-187.745 } ; -// ADCmean[15] = {125.011,135.959,149.799,156.222,159.417,158.154,156.026,153.048,149.845,146.659,142.953,138.728,134.282,130.304,120.176 } ; -double high_bin[15] = {197.886,212.367,226.685,232.567,236.377,233.817,230.829,225.595,221.07,216.012,210.1,203.221,195.506,188.455,178.88 } ; -double low_bin[15] = {52.1363,59.5508,72.9139,79.8775,82.4582,82.4905,81.2233,80.5007,78.6199,77.3049,75.8061,74.2353,73.0578,72.1533,61.4726 } ; - -// const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); -// const MuonCalibSegment *rpcHits(event.rpcHitCollection()); -// unsigned int ml, ly, tb; // multilayer, layer, tube/ -// unsigned int ndof; // number of degrees of freedom of the segment fit -// int strip, strip2; // rpc strip -// double r, d; // drift radius and track distance from the wire -// int mdt_close_layer, mdt_close_multi; - IMdtPatRecFitter *segment_fitter(0); // pointer to the segment fitter - IMdtPatRecFitter *segment_fitter2(0); // pointer to the segment fitter - if (m_curved_fits) { - segment_fitter = m_cfitter; - segment_fitter2 = m_cfitter; - } else { - segment_fitter = m_qfitter; - segment_fitter2 = m_qfitter; - } - // DCSLFitter * betterFitter = new DCSLFitter(); -/* GlobalTimeFitter * GTFitter = new GlobalTimeFitter(betterFitter) ; - if ( m_refit_segments ) { - IRtRelation * defaultRt = GTFitter->getDefaultRtRelation() ; - GTFitter->setRtRelation(defaultRt) ; - } -*/ - -//////////////////// -// RESET COUNTERS // -//////////////////// -//setEvent(event); -// cor[0] = {0} ;-0.00205705 - - - -////////////////////////////// -// FILL RAW DATA HISTOGRAMS // -////////////////////////////// -// -// -// -//Loop RAW data -> hitselection -> udpate segment by ADC correction factor -//Increase hitsOnTracks? -//v500 will -// - -/////////////////////////////// -// Validate the Segment hits // -/////////////////////////////// - -// loop over the raw hits // - for (unsigned int k=position; k<segments.size(); k++) { - - // get the first hit to check if it is in the calibration region // - if(!m_reg_sel_svc->isInRegion(segments[k]->mdtHOT()[0] ->identify())) continue; - NtupleStationId station_identifier((segments[k]->mdtHOT()[0])->identify()); - station_identifier.SetMultilayer(0); - - createMaps((segments[k]->mdtHOT()[0])->identify()); -//const MdtStationT0Container *t0(m_input_service->GetT0(station_identifier)); -// const IRtRelation *rt=m_input_service->GetRtRelation(station_identifier); -// rt->t_from_r(r); - -//////############################################################################################## -///////// step 1 check the MDT with - -// segments selection -// -// 1) segment hits in same chamber -// 2) segment hits no double hits -// bool NoDoubleHitsSegments = true; -// int Event_counter =0; -// int Segment_counter =0; - - const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); - // const MuonCalibSegment *rpcHits(event.rpcHitCollection()); - int ml, ly, tb; // multilayer, layer, tube - - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it=raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { - - // get the raw hit and check whether it is in the calibration region // - MuonCalibRawMdtHit *hit(*it); - - if(!m_reg_sel_svc->isInRegion(hit->identify())) continue; - ml = (hit->identify()).mdtMultilayer(); - ly = (hit->identify()).mdtTubeLayerIndex()+1; - tb = (hit->identify()).mdtTubeIndex(); - // tdc0 = (hit->.tdcCount(); - //second loop - //int counter = 0; - // while(it!=raw_hits->rawMdtHitCollectionEnd()) { - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it2=raw_hits->rawMdtHitCollectionBegin(); - it2!=raw_hits->rawMdtHitCollectionEnd(); ++it2) { - MuonCalibRawMdtHit *hit2(*it2); - if(!m_reg_sel_svc->isInRegion(hit2->identify())) continue; - bool same_ml(ml==(hit2->identify()).mdtMultilayer()); - bool same_ly(ly==(hit2->identify()).mdtTubeLayerIndex()); - bool same_tb(tb==(hit2->identify()).mdtTubeIndex()); - bool sameTubeHit=same_ml && same_ly && same_tb; - if(!sameTubeHit) continue; - if(hit2->tdcCount()==hit->tdcCount()) continue; - if(!((hit2->adcCount()>50)&&(hit->adcCount()>50))) continue; - if(hit2->tdcCount()>hit->tdcCount()) { - m_MDT_fhit_adc[station_identifier]->Fill(hit->tdcCount(),hit->adcCount(),1.0); - m_MDT_SiHitAdc[station_identifier]->Fill(hit2->tdcCount(),hit2->adcCount(),1.0); - } - else { - m_MDT_fhit_adc[station_identifier]->Fill(hit2->tdcCount(),hit2->adcCount(),1.0); - m_MDT_SiHitAdc[station_identifier]->Fill(hit->tdcCount(),hit->adcCount(),1.0); - } - } - } //end raw Mdthit loop - - -//////############################################################################################## -// Selection segment - - if (m_refit_segments) { - Double_t slopeYZ=57.30*std::atan((segments[k]->direction()).y()/(segments[k]->direction()).z()); - Double_t slopeXZ=57.30*std::atan((segments[k]->direction()).x()/(segments[k]->direction()).z()); - m_MDT_segment_localangle_YZ[station_identifier]->Fill(slopeYZ,1.0); - m_MDT_segment_localangle_XZ[station_identifier]->Fill(slopeXZ,1.0); - - for (unsigned int l=0; l<segment_fitter->numberOfTrackHits();l++) { - Int_t adcCount = (segment_fitter->trackHits())[l]->adcCount(); - if(adcCount<50) continue; - Double_t r = (segment_fitter->trackHits())[l]->driftRadius(); - Double_t d = (segment_fitter->trackHits())[l]->signedDistanceToTrack(); - Double_t t = (segment_fitter->trackHits())[l]->driftTime() ; - Double_t distX=(segment_fitter->trackHits())[l]->distanceToReadout(); - if((std::abs(d)>15.0)||(std::abs(r)>15.0)) continue; - m_MDT_radius_vs_DistanceToSegmentTrack[station_identifier]->Fill(d,r,1.0); - m_MDT_radius_vs_t[station_identifier]->Fill(t, r,1.0); - m_MDT_adc_vs_radius[station_identifier]->Fill(r, adcCount,1.0); - m_MDT_adc_vs_DistanceToSegmentTrack[station_identifier]->Fill(d, adcCount,1.0); - Double_t resi = std::abs(r)-std::abs(d); - m_MDT_adc_vs_residual[station_identifier]->Fill(resi, adcCount,1.0); - if((m_Recalc2ndCoordinate)&&(std::abs(slopeXZ)<80.0)) { - m_MDT_adc_vs_posX[station_identifier]->Fill(distX, adcCount,1.0); - Double_t lenD=2.0*std::sqrt(225.0-d*d)/std::cos(std::abs(slopeXZ)/57.30); - m_MDT_adc_vs_pathD[station_identifier]->Fill(lenD, adcCount,1.0); - - } - } - } - else { // aux line for no refit segment - Double_t slopeYZ=57.30*std::atan((segments[k]->direction()).y()/(segments[k]->direction()).z()); - Double_t slopeXZ=57.30*std::atan((segments[k]->direction()).x()/(segments[k]->direction()).z()); - m_MDT_segment_localangle_YZ[station_identifier]->Fill(slopeYZ,1.0); - m_MDT_segment_localangle_XZ[station_identifier]->Fill(slopeXZ,1.0); - - } - -//////############################################################################################## - -// Loop all hits in segments[k] and update the driftRadius by ADC correction v500 -// only for the segments-chi2() < 5.0 segments -// Refit one more time to check if refit did same function -// next hold a vector for compare the residual and radius - if(segments[k]->chi2() > 5.0) continue; - if(segments[k]->hitsOnTrack() < 5 ) continue; - m_MDT_segment_hits[0][station_identifier]->Fill(segments[k]->hitsOnTrack(),1.0); - m_MDT_segment_chi2[0][station_identifier]->Fill(segments[k]->chi2(),1.0); - for (unsigned int l=0; l<segment_fitter->numberOfTrackHits();l++) { - Double_t r0 = (segment_fitter->trackHits())[l]->driftRadius(); - Double_t d0 = (segment_fitter->trackHits())[l]->signedDistanceToTrack(); - m_MDT_residual_vs_radius[0][station_identifier]->Fill(r0,std::abs(r0)-std::abs(d0),1.0); - } - - if( !(segment_fitter->fit(*(segments[k])) ) ) ATH_MSG_WARNING( "Segment fit failed. Just going on." ); - Double_t oldchi2 = segments[k]->chi2() ; - m_MDT_segment_hits[1][station_identifier]->Fill(segment_fitter->numberOfTrackHits(), 1.0); - m_MDT_segment_chi2[1][station_identifier]->Fill(segments[k]->chi2(),1.0); - for (unsigned int l=0; l<segment_fitter->numberOfTrackHits();l++) { - Double_t r1 = (segment_fitter->trackHits())[l]->driftRadius(); - Double_t d1 = (segment_fitter->trackHits())[l]->signedDistanceToTrack(); - m_MDT_residual_vs_radius[1][station_identifier]->Fill(r1,std::abs(r1)-std::abs(d1),1.0); - Int_t radius=static_cast<int>(std::abs(r1)); - if(radius>14) radius = 14; - Int_t adcCount = (segment_fitter->trackHits())[l]->adcCount(); - m_r_MDT_residual_vs_adc[radius][station_identifier]->Fill(adcCount,std::abs(r1)-std::abs(d1),1.0); // remove the delta ray - } - - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool goodSeg = true; - for (unsigned int l=0; l<segments[k]->hitsOnTrack();l++) { - Double_t oldr=(segments[k]->mdtHOT())[l]->driftRadius(); - Double_t oldrsigma=(segments[k]->mdtHOT())[l]->sigmaDriftRadius(); - Int_t binr=static_cast<int>(oldr); - if(binr>14) break; - if((((segments[k]->mdtHOT())[l]->adcCount())>low_bin[binr])&&(((segments[k]->mdtHOT())[l]->adcCount())<high_bin[binr])) { - // if ADCcount inside the range, update the Radius by ADC value - Double_t dr=(((segments[k]->mdtHOT())[l]->adcCount())-ADC0[binr])*cor[binr]; - Double_t newr=oldr-dr; - if(newr<0.0) newr = 0.0; - (segments[k]->mdtHOT())[l]->setDriftRadius(newr, oldrsigma); - } - - } - - if(goodSeg && (segment_fitter2->fit(*(segments[k])))) { -// 2nd Segment Refit, see the residual improvement - m_MDT_segment_hits[2][station_identifier]->Fill(segment_fitter2->numberOfTrackHits(), 1.0); - Double_t newchi2 = segments[k]->chi2() ; - m_MDT_segment_chi2[2][station_identifier]->Fill(newchi2,1.0); - m_MDT_segment_delta_chi2[station_identifier]->Fill(oldchi2 - newchi2 , 1.0); - for (unsigned int l=0; l<segment_fitter2->numberOfTrackHits();l++) { - Double_t r2 = (segment_fitter2->trackHits())[l]->driftRadius(); - Double_t d2 = (segment_fitter2->trackHits())[l]->signedDistanceToTrack(); - m_MDT_residual_vs_radius[2][station_identifier]->Fill(r2,std::abs(r2)-std::abs(d2),1.0); - } - } - - - } //end of segment loop - - return StatusCode::SUCCESS; - -} - - - - - - -//***************************************************************************** - -// statusCode NtupleCalibADCTool::analyseSegments(const std::vector<MuonCalibSegment *> & /*segments*/) { -// v600 start to analysis plot and output ADC coefficiency factor -// -// -// -// -// -// -//::::::::::::::::::::::::: -//:: METHOD KeepSegments :: -//::::::::::::::::::::::::: - -bool NtupleCalibADCTool::KeepSegments(void) const { - - return false; - -} - -//***************************************************************************** - -//::::::::::::::::::::::: -//:: METHOD createMaps :: -//::::::::::::::::::::::: - -void NtupleCalibADCTool::createMaps(const MuonFixedId & id) { - -/////////////// -// VARIABLES // -/////////////// - - NtupleStationId station_identifier(id); - station_identifier.SetMultilayer(0); - std::map<NtupleStationId, unsigned int>::iterator end_it = - m_nb_ml.end(); - -//////////////////////////////////// -// FIND THE IDENTIFIER IN m_nb_ml // -//////////////////////////////////// - - if (m_nb_ml.find(station_identifier)!=end_it) { - return; - } - -/////////////////////////////////////////// -// GET THE GEOMETRY OF THE GIVEN CHAMBER // -/////////////////////////////////////////// - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return; - } - - Identifier station_id = m_id_tool->fixedIdToId(id); - const MuonGM::MdtReadoutElement *MdtRoEl =MuonDetMgr->getMdtReadoutElement(m_MdtIdHelper->channelID(station_id,1,1,1)); - - m_nb_ml[station_identifier] = m_MdtIdHelper->numberOfMultilayers(station_id); - m_nb_ly[station_identifier] = MdtRoEl->getNLayers(); - m_nb_tb[station_identifier] = MdtRoEl->getNtubesperlayer(); - - -/////////////////////////////// -// CREATE THE REMAINING MAPS // -/////////////////////////////// - -// counter // - -// histograms // - ToString tostring; - std::string file_dir(id.stationNumberToFixedStationString(id.stationName()) - +"_"+tostring(id.phi())+"_"+tostring(id.eta())); - std::string tempside=(id.eta()>0)?"A":"C"; - std::string tempeta=std::to_string(std::abs(id.eta())); - int tempphi=(file_dir.substr(2,1)=="L")?(2*(id.phi())-1):(2*(id.phi())); - char sphi[4]; - snprintf(sphi,sizeof(sphi),"%02d",tempphi); - std::string chambername=file_dir.substr(0,3)+tempeta+tempside+sphi; - - m_tfile->mkdir(file_dir.c_str()); - m_tfile->cd(file_dir.c_str()); - - - //v2.0 move const char* category[5]={"CalibSeg","Muonboy","Moore","Mean140","CalibSegCalibADC"}; - char radc[100],/*mc_radc[100],*//*m_tadc[100],*//*m_tdcadc[100],*/resiadc[100],rt[100],/*m_posXresi[100],*/pathadc[100],posXadc[100],/*m_Revadcresi[100],*/resir[100],/*m_pathresi[100],*//*m_posXr[100],*/dadc[100],dr[200]; - // char m_hit_dis[100],m_localXZ[100],m_localYZ[100],m_globalXZ[100],m_globalYZ[100]; - char XZ[100],YZ[100]; - sprintf(pathadc,"%.7s_ADC_vs_PathLength",chambername.c_str()); - sprintf(resiadc,"%.7s_ADC_vs_Residual",chambername.c_str()); - sprintf(radc,"%.7s_ADC_vs_Radius",chambername.c_str()); - sprintf(dadc,"%.7s_ADC_vs_DistanceToSegmentTrack",chambername.c_str()); - sprintf(dr,"%.7s_Radius_vs_DistanceToSegmentTrack",chambername.c_str()); - sprintf(posXadc,"%.7s_ADC_vs_DistanceToReadout",chambername.c_str()); - sprintf(resir,"%.7s_Residual_vs_Radius",chambername.c_str()); - sprintf(rt,"%.7s_Radius_vs_DriftTime",chambername.c_str()); - m_MDT_adc_vs_pathD[station_identifier]= new TH2F(pathadc,pathadc,1000,0, 100, 350, 50, 400); - m_MDT_adc_vs_pathD[station_identifier]->SetXTitle("PathLength(mm)"); - m_MDT_adc_vs_pathD[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_posX[station_identifier]= new TH2F(posXadc,posXadc,600,0, 6000, 350, 50, 400); - m_MDT_adc_vs_posX[station_identifier]->SetXTitle("DistanceToReadout(mm)"); - m_MDT_adc_vs_posX[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_DistanceToSegmentTrack[station_identifier]= new TH2F(dadc,dadc,300,-15,15,350, 50, 400); - m_MDT_adc_vs_DistanceToSegmentTrack[station_identifier]->SetXTitle("DistanceToSegmentTrack(mm)"); - m_MDT_adc_vs_DistanceToSegmentTrack[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_radius[station_identifier]= new TH2F(radc,radc,150,0, 15, 350, 50, 400); - m_MDT_adc_vs_radius[station_identifier]->SetXTitle("Radius(mm)"); - m_MDT_adc_vs_radius[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_residual[station_identifier]= new TH2F(resiadc,resiadc,300,-15, 15, 350, 50, 400); - m_MDT_adc_vs_residual[station_identifier]->SetXTitle("Residual(mm)"); - m_MDT_adc_vs_residual[station_identifier]->SetYTitle("ADC count(ns)"); - - m_MDT_radius_vs_DistanceToSegmentTrack[station_identifier]= new TH2F(dr,dr,300,-15,15,300,-15,15); - m_MDT_radius_vs_DistanceToSegmentTrack[station_identifier]->SetXTitle("DistanceToSegmentTrack(mm)"); - m_MDT_radius_vs_DistanceToSegmentTrack[station_identifier]->SetYTitle("Radius(mm)"); - m_MDT_radius_vs_t[station_identifier]= new TH2F(rt,rt,1000, -100, 900, 150,0,15); - m_MDT_radius_vs_t[station_identifier]->SetYTitle("Radius(mm)"); - m_MDT_radius_vs_t[station_identifier]->SetXTitle("DriftTime(ns)"); - sprintf(XZ,"%.7s_LocalAngle_XZ",chambername.c_str()); - sprintf(YZ,"%.7s_LocalAngle_YZ",chambername.c_str()); - m_MDT_segment_localangle_YZ[station_identifier] =new TH1F(YZ,YZ,180, -90, 90); - m_MDT_segment_localangle_YZ[station_identifier]->SetXTitle("Incidence Angle at local YZ plane(degrees)"); - m_MDT_segment_localangle_XZ[station_identifier] =new TH1F(XZ,XZ,180, -90, 90); - m_MDT_segment_localangle_XZ[station_identifier]->SetXTitle("Incidence Angle at local XZ plane(degrees)"); - // 1D plot - /* - mc_MDT_adc_vs_radius[station_identifier]= new TH2F(mc_radc,mc_radc,1500,0, 15, 350, 50, 400); - mc_MDT_adc_vs_radius[station_identifier]->SetXTitle("Radius(mm)"); - mc_MDT_adc_vs_radius[station_identifier]->SetYTitle("CalibADC count(ns)"); - sprintf(m_localXZ,"%.7s_ADC_vs_LocalAngle_XZ",chambername.c_str()); - sprintf(m_localYZ,"%.7s_ADC_vs_LocalAngle_YZ",chambername.c_str()); - sprintf(m_globalXZ,"%.7s_ADC_vs_GlobalAngle_XZ",chambername.c_str()); - sprintf(m_globalYZ,"%.7s_ADC_vs_GlobalAngle_YZ",chambername.c_str()); - m_MDT_adc_vs_segment_localangle_YZ[station_identifier] =new TH2F(m_localYZ,m_localYZ,1800, -90, 90,350,50,400); - m_MDT_adc_vs_segment_localangle_YZ[station_identifier]->SetXTitle("Incidence Angle at local YZ plane(degrees)"); - m_MDT_adc_vs_segment_localangle_YZ[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_segment_localangle_XZ[station_identifier] =new TH2F(m_localXZ,m_localXZ,1800, -90, 90,350,50,400); - m_MDT_adc_vs_segment_localangle_XZ[station_identifier]->SetXTitle("Incidence Angle at local XZ plane(degrees)"); - m_MDT_adc_vs_segment_localangle_XZ[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_segment_globalangle_YZ[station_identifier] =new TH2F(m_globalYZ,m_globalYZ,1800, -90, 90,350,50,400); - m_MDT_adc_vs_segment_globalangle_YZ[station_identifier]->SetXTitle("Incidence Angle at global YZ plane(degrees)"); - m_MDT_adc_vs_segment_globalangle_YZ[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_segment_globalangle_XZ[station_identifier] =new TH2F(m_globalXZ,m_globalXZ,1800, -90, 90,350,50,400); - m_MDT_adc_vs_segment_globalangle_XZ[station_identifier]->SetXTitle("Incidence Angle at global XZ plane(degrees)"); - m_MDT_adc_vs_segment_globalangle_YZ[station_identifier]->SetYTitle("ADC count(ns)"); - - sprintf(XZ,"%.7s_LocalAngle_XZ",chambername.c_str()); - sprintf(YZ,"%.7s_LocalAngle_YZ",chambername.c_str()); - m_MDT_segment_localangle_YZ[station_identifier] =new TH1F(YZ,YZ,1800, -90, 90); - m_MDT_segment_localangle_YZ[station_identifier]->SetXTitle("Incidence Angle at local YZ plane(degrees)"); - m_MDT_segment_localangle_XZ[station_identifier] =new TH1F(XZ,XZ,1800, -90, 90); - m_MDT_segment_localangle_XZ[station_identifier]->SetXTitle("Incidence Angle at local XZ plane(degrees)"); - - sprintf(m_pathresi,"%.7s_Residual_vs_PathLength",chambername.c_str()); - sprintf(radc,"%.7s_ADC_vs_Radius",chambername.c_str()); - sprintf(dadc,"%.7s_ADC_vs_DistanceToSegmentTrack",chambername.c_str()); - sprintf(posXadc,"%.7s_ADC_vs_DistanceToReadout",chambername.c_str()); - - m_MDT_Revadc_vs_residual[station_identifier]= new TH2F(m_Revadcresi,m_Revadcresi,200,0, 20, 3000,-15, 15); - m_MDT_Revadc_vs_residual[station_identifier]->SetYTitle("Residual(mm)"); - m_MDT_Revadc_vs_residual[station_identifier]->SetXTitle("Reverse ADC count(1/ns)"); - m_MDT_radius_vs_residual[station_identifier]= new TH2F(resir,resir, 1500,0,15,3000,-15, 15); - m_MDT_radius_vs_residual[station_identifier]->SetXTitle("Radius(mm)"); - m_MDT_radius_vs_residual[station_identifier]->SetYTitle("Residual(mm)"); - m_MDT_pathD_vs_residual[station_identifier]= new TH2F(m_pathresi,m_pathresi,2000,0, 100, 3000, -15, 15); - m_MDT_pathD_vs_residual[station_identifier]->SetXTitle("PathLength(mm)"); - m_MDT_pathD_vs_residual[station_identifier]->SetYTitle("Residual(mm)"); - m_MDT_posX_vs_residual[station_identifier]= new TH2F(m_posXresi,m_posXresi,6000,0, 6000, 3000,-15,15); - m_MDT_posX_vs_residual[station_identifier]->SetXTitle("DistanceToReadout(mm)"); - m_MDT_posX_vs_residual[station_identifier]->SetYTitle("Residual(mm)"); - m_MDT_posX_vs_radius[station_identifier]= new TH2F(m_posXr,m_posXr,6000,0, 6000, 1500,0,15); - m_MDT_posX_vs_radius[station_identifier]->SetXTitle("DistanceToReadout(mm)"); - m_MDT_posX_vs_radius[station_identifier]->SetYTitle("Radius(mm)"); - m_MDT_adc_vs_tdc[station_identifier]= new TH2F(m_tdcadc,m_tdcadc,2500,0, 2500, 350, 50, 400); - m_MDT_adc_vs_tdc[station_identifier]->SetXTitle("TDC count(ns)"); - m_MDT_adc_vs_tdc[station_identifier]->SetYTitle("ADC count(ns)"); - m_MDT_adc_vs_t[station_identifier]= new TH2F(m_tadc,m_tadc,1000,-100, 900, 350, 50, 400); - m_MDT_adc_vs_t[station_identifier]->SetXTitle("DriftTime(ns)"); - m_MDT_adc_vs_t[station_identifier]->SetYTitle("ADC count(ns)"); - // - // v400 new residual - char m_resir1[100]; - sprintf(m_resir1,"%.7s_Residual_vs_Radius_NoRefit",chambername.c_str()); - m_MDT_residual_vs_radius_NoRefit[station_identifier]= new TH2F(m_resir1,m_resir1, 1500,0,15,3000,-15, 15); - m_MDT_residual_vs_radius_NoRefit[station_identifier]->SetXTitle("Radius(mm)"); - m_MDT_residual_vs_radius_NoRefit[station_identifier]->SetYTitle("Residual(mm)"); - char m_resir2[100]; - sprintf(m_resir2,"%.7s_Residual_vs_Radius_Refit",chambername.c_str()); - m_MDT_residual_vs_radius_Refit[station_identifier]= new TH2F(m_resir2,m_resir2, 1500,0,15,3000,-15, 15); - m_MDT_residual_vs_radius_Refit[station_identifier]->SetXTitle("Radius(mm)"); - m_MDT_residual_vs_radius_Refit[station_identifier]->SetYTitle("Residual(mm)"); - char m_resir3[100]; - sprintf(m_resir3,"%.7s_Residual_vs_Radius_TimeSlewing",chambername.c_str()); - m_MDT_residual_vs_radius_TimeSlewing[station_identifier]= new TH2F(m_resir3,m_resir3, 1500,0,15,3000,-15, 15); - m_MDT_residual_vs_radius_TimeSlewing[station_identifier]->SetXTitle("Radius(mm)"); - m_MDT_residual_vs_radius_TimeSlewing[station_identifier]->SetYTitle("Residual(mm)"); - */ - for(int i=0;i<15;i++) { - char r_adcresi[200]; - sprintf(r_adcresi,"%.7s_Radius%02d_Residual_vs_ADC",chambername.c_str(),i); - m_r_MDT_residual_vs_adc[i][station_identifier]= new TH2F(r_adcresi,r_adcresi,350,50, 400,300 ,-15, 15); - m_r_MDT_residual_vs_adc[i][station_identifier]->SetYTitle("Residual(mm)"); - m_r_MDT_residual_vs_adc[i][station_identifier]->SetXTitle("ADC Count(ns)"); - } - const char* FitFlag[3] = {"NoRefit","Refit","TimeSlewing"}; - char hits[100],chi2[100],rresi[100]; - for(int i=0;i<3;i++) { - sprintf(hits,"%.7s_Segment_hits_%s",chambername.c_str(),FitFlag[i]); - m_MDT_segment_hits[i][station_identifier] =new TH1F(hits,hits,100, 0, 100); - m_MDT_segment_hits[i][station_identifier]->SetXTitle("Hits per segment"); - sprintf(chi2,"%.7s_Segment_chi2_%s",chambername.c_str(),FitFlag[i]); - m_MDT_segment_chi2[i][station_identifier] =new TH1F(chi2,chi2,500, 0, 50); - m_MDT_segment_chi2[i][station_identifier]->SetXTitle("Segment chi2/ndf"); - sprintf(rresi,"%.7s_Residual_vs_Radius_%s",chambername.c_str(),FitFlag[i]); - m_MDT_residual_vs_radius[i][station_identifier] = new TH2F(rresi,rresi, 1500,0,15,3000,-15, 15); - m_MDT_residual_vs_radius[i][station_identifier]->SetXTitle("Radius(mm)"); - m_MDT_residual_vs_radius[i][station_identifier]->SetYTitle("Residual(mm)"); - } - char delta_chi2[100]; - sprintf(delta_chi2,"%.7s_Segment_delta_chi2",chambername.c_str()); - m_MDT_segment_delta_chi2[station_identifier]= new TH1F(delta_chi2,delta_chi2,100,-5,5); - m_MDT_segment_delta_chi2[station_identifier]->SetXTitle("Delta_Segment_chi2()"); - char fhit[100],SiHit[100]; - sprintf(fhit,"%.7s_fristHit_ADC_vs_TDC",chambername.c_str()); - sprintf(SiHit,"%.7s_secondHit_ADC_vs_TDC",chambername.c_str()); - m_MDT_fhit_adc[station_identifier]= new TH2F(fhit,SiHit,3000, 0,3000,500, 0, 500); - m_MDT_fhit_adc[station_identifier]->SetXTitle("ADC count(ns)"); - m_MDT_fhit_adc[station_identifier]->SetYTitle("TDC count(ns)"); - m_MDT_SiHitAdc[station_identifier]= new TH2F(SiHit,SiHit,3000,0,3000, 500, 0, 500); - m_MDT_SiHitAdc[station_identifier]->SetXTitle("ADC count(ns)"); - m_MDT_SiHitAdc[station_identifier]->SetYTitle("TDC count(ns)"); - - m_tfile->cd(".."); - return; - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleChisqResolutionTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleChisqResolutionTool.cxx deleted file mode 100644 index 4e5ead47b5240df2d2c287787ec5a89092e91c97..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleChisqResolutionTool.cxx +++ /dev/null @@ -1,279 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//c - c++ -#include "iostream" - -//MdtCalibFitters -#include "MdtCalibFitters/DCSLFitter.h" - -//MuonCalibStl -#include "MuonCalibStl/ToString.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" - -//MuonCalibData -#include "MdtCalibData/RtResolutionFromPoints.h" -#include "MdtCalibData/RtChebyshev.h" -#include "MdtCalibData/RtRelationLookUp.h" -#include "MdtCalibData/IRtResolution.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" - -//MuonCalibStandAloneTools -#include "MuonCalibStandAloneTools/NtupleChisqResolutionTool.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -//root -#include "TFile.h" -#include "TH1.h" -#include "TMinuit.h" -#include "TString.h" -#include "TF1.h" -#include "TMath.h" // for TMath::Prob() -#include <TString.h> // for Form - -namespace MuonCalib { - - //****************************************************************************** - static NtupleChisqResolutionTool* static_NtupleChisqResolutionTool_pointer = nullptr; - - inline void NtupleChisqResolutionTool_fcn_wrapper(int &npar, double *gin, double &f, double *par, int iflag) { - if(!static_NtupleChisqResolutionTool_pointer) { - throw std::runtime_error(Form("File: %s, Line: %d\nNtupleChisqResolutionTool_fcn_wrapper() - ERROR: static_NtupleChisqResolutionTool_pointer is nullptr", __FILE__, __LINE__)); - } - static_NtupleChisqResolutionTool_pointer->fcn(npar, gin, f, par, iflag); - } - - //**************************************************************************** - - NtupleChisqResolutionTool::NtupleChisqResolutionTool(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t, n, p), m_calib_input_svc("MdtCalibInputSvc", n), m_final_resolution(NULL) - { - declareInterface< NtupleCalibrationTool >(this) ; - declareProperty("MdtCalibInputSvc", m_calib_input_svc); - } - - //****************************************************************************** - - StatusCode NtupleChisqResolutionTool::initialize() - { - ATH_MSG_INFO( "initialize()" ); - ATH_CHECK( m_calib_input_svc.retrieve() ); - return StatusCode::SUCCESS; - } - - //****************************************************************************** - - StatusCode NtupleChisqResolutionTool::finalize() - { - m_resolfile->Write(); - return StatusCode::SUCCESS; - } - - - //****************************************************************************** - - - void NtupleChisqResolutionTool::setRegion() - { - //try to get rt relation - p_rt_rel = m_calib_input_svc->GetRtRelation(); - //root stuff - m_resolfile = TFile::Open("resolfile.root","RECREATE"); - m_prob_dist = new TH1F("egment_probability_distribution" ,"segment probability distribution",50,0.,1.); - } - - //****************************************************************************** - - StatusCode NtupleChisqResolutionTool::analyseSegments(const std::vector<MuonCalibSegment *> & segemnts) - { - if(p_rt_rel == NULL) - { - ATH_MSG_FATAL( "Rt relation not set!" ); - return StatusCode::FAILURE; - } - m_seg=&segemnts; - // double *par; - // recalculate(par); - m_minuit = new TMinuit(3); //initialize TMinuit with 3 parameters - static_NtupleChisqResolutionTool_pointer = this; - m_minuit->SetFCN(NtupleChisqResolutionTool_fcn_wrapper); - m_minuitoutputlevel=1; - Double_t vstart[3]={.1,-.3,.05}; - Double_t step[3]={.01,.01,.01}; - double arglist[10]; - int ierflg=0; - m_minuit->mnparm(0,"resol_0", vstart[0], step[0], .01, .5, ierflg); - m_minuit->mnparm(1,"tauexp", vstart[1], step[1], .01, .8, ierflg); - m_minuit->mnparm(2,"resol_1", vstart[2], step[2], .05, .2, ierflg); - arglist[0]=1; - m_minuit->mnexcm("SET ERR",arglist,1,ierflg); - arglist[0]=0; - m_minuit->mnexcm("SET STR",arglist,1,ierflg); - arglist[0]=1.e11; - arglist[1]=0.1; - m_minuit->mnexcm("SIMPLEX",arglist,2,ierflg); - - //formerly finalize - TString name[3] = {"resol_0", "tauexp", "resol_1"}; - double fitpar[3]; - double dummy1, dummy2, dummy3; - int idummy; - m_minuit->mnpout(0, name[0], fitpar[0], dummy1, dummy2, dummy3, idummy); - m_minuit->mnpout(1, name[1], fitpar[1], dummy1, dummy2, dummy3, idummy); - m_minuit->mnpout(2, name[2], fitpar[2], dummy1, dummy2, dummy3, idummy); - - // get minimum and maximum drift time // - RtResolutionFromPoints res_from_points; - double t_min=0, t_max=800; - const RtChebyshev *rt_Chebyshev(dynamic_cast<const RtChebyshev *>(p_rt_rel)); - const RtRelationLookUp *rt_LookUp( - dynamic_cast<const RtRelationLookUp *>(p_rt_rel)); - // RtChebyshev // - if (rt_Chebyshev!=0) { - t_min = rt_Chebyshev->tLower(); - t_max = rt_Chebyshev->tUpper(); - } - - // RtRelationLookUp, dangerous implementation, but the only way right now // - if (rt_LookUp!=0) { - t_min = rt_LookUp->par(0); - t_max = rt_LookUp->par(1)*(rt_LookUp->nPar()-2); - } - - // perform sigma-t fit // - std::vector<SamplePoint> point(31); - double r_min(p_rt_rel->radius(t_min)); - double r_max(p_rt_rel->radius(t_max)); - double bin_width((r_max-r_min)/static_cast<double>(point.size()-1)); - for (unsigned int k=0; k<point.size(); k++) { - double radius(r_min+k*bin_width); - point[k].set_x1(t_from_r(radius, p_rt_rel)); - point[k].set_x2(fitpar[0]*std::exp(-fitpar[1]*radius)+fitpar[2]); - point[k].set_error(1.0); - } - m_final_resolution = new RtResolutionChebyshev( - (res_from_points.getRtResolutionChebyshev( - point, 8))); - - return StatusCode::SUCCESS; - } - - - - void NtupleChisqResolutionTool::fcn(int&/*npar*/, double * /*gin*/, double &f, double *par, int iflag) - { - ATH_MSG_INFO( "entering fcn"<<" iflag ="<<iflag ); - m_prob_dist->Reset("ICE"); - f = recalculate(par); - m_prob_dist->Print("all"); - m_prob_dist->Fit("pol0","L","L",0.02,1.); - TF1 *pol0fit = m_prob_dist->GetFunction("pol0"); - double chidue = pol0fit->GetChisquare(); - /* - now account for first bin - */ - Double_t first_bin = m_prob_dist->GetBinContent(1); - Double_t total_sum = m_prob_dist->Integral(); - double expected_first_bin = total_sum/50.; - double ratio = (first_bin / expected_first_bin)*5.; - f=chidue+ratio*100.; - } - double NtupleChisqResolutionTool::recalculate(double *par) - { - double r; - for (unsigned int k=0; k<m_seg->size(); k++) { - - for(std::vector<MdtCalibHitBase*>::iterator it =(m_seg->at(k))->mdtHOTBegin() ; - it!=(m_seg->at(k))->mdtHOTEnd();++it) - { - r=(*it)->driftRadius(); - double newResol = par[0]*std::exp(-par[1]*r)+par[2]; - (*it)->setDriftRadius(r,newResol); - } - - DCSLFitter fitter; - fitter.fit(*(m_seg->at(k))); - double redchi2=(m_seg->at(k))->chi2(); - int nmdthits=(m_seg->at(k))->hitsOnTrack(); - - float probability=(float) TMath::Prob(redchi2 * (nmdthits-2),nmdthits-2); - - m_prob_dist->Fill(probability); - } - - return 1.; - } - - - //************************************************************ - - ///////////////////// - // METHOD t_from_r // - ///////////////////// - - double NtupleChisqResolutionTool::t_from_r(const double & r, - const IRtRelation * rt_rel) { - - /////////////// - // VARIABLES // - /////////////// - - double precision(0.010); // spatial precision of the inversion - double t_max(0.0); // upper time search limit - double t_min(1000.0); // lower time search limit - - /////////////////////////////// - // DETERMINE t_min and t_max // - /////////////////////////////// - - const RtChebyshev *rt_Chebyshev( - dynamic_cast<const RtChebyshev *>(rt_rel)); - const RtRelationLookUp *rt_LookUp( - dynamic_cast<const RtRelationLookUp *>(rt_rel)); - // RtChebyshev // - if (rt_Chebyshev!=0) { - t_min = rt_Chebyshev->tLower(); - t_max = rt_Chebyshev->tUpper(); - } - - // RtRelationLookUp, dangerous implementation, but the only way right now // - if (rt_LookUp!=0) { - t_min = rt_LookUp->par(0); - t_max = rt_LookUp->par(1)*(rt_LookUp->nPar()-2); - } - - ///////////////////////////////////////////// - // SEARCH FOR THE CORRESPONDING DRIFT TIME // - ///////////////////////////////////////////// - - while (t_max-t_min>0.1 && - std::abs(rt_rel->radius(0.5*(t_min+t_max))-r)>precision) { - - if (rt_rel->radius(0.5*(t_min+t_max))>r) { - t_max = 0.5*(t_min+t_max); - } else { - t_min = 0.5*(t_min+t_max); - } - - } - - return 0.5*(t_min+t_max); - - } - - - const IRtResolution * NtupleChisqResolutionTool::getResolution() const - { - if(m_final_resolution == 0) - { - ATH_MSG_FATAL( "No resolution Calculated!" ); - } - return m_final_resolution; - } - - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleClassicT0Tool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleClassicT0Tool.cxx deleted file mode 100644 index 4369a16019fe47a7385ff36f3d626899576f23ec..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleClassicT0Tool.cxx +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//MdtCalibData -#include "MdtCalibData/MdtTubeFitContainer.h" - -//MdtCalibT0 -#include "MdtCalibT0/T0CalibrationOutput.h" - -//this -#include "MuonCalibStandAloneTools/NtupleClassicT0Tool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -namespace MuonCalib{ - -NtupleClassicT0Tool::NtupleClassicT0Tool(const std::string& t, const std::string& n, const IInterface* p): AthAlgTool(t, n, p), m_reg_sel_svc("RegionSelectionSvc", n), m_adcBins(100), m_minAdc(0.0), m_maxAdc(300.0), m_timeBins(500), m_minTime(0.0), m_maxTime(1000.0), m_fitTime(true), m_minEntries(1000), m_initParam(1), m_chiMax(5.0) - { - declareInterface< NtupleCalibrationTool >(this) ; - declareProperty("NAdcBins", m_adcBins); - declareProperty("MinAdc", m_minAdc); - declareProperty("MaxAdc", m_maxAdc); - declareProperty("NTimeBins", m_timeBins); - declareProperty("TimeMin", m_minTime); - declareProperty("TimeMax", m_maxTime); - declareProperty("FitTimeSpectrum", m_fitTime); - declareProperty("MinEntries", m_minEntries); - declareProperty("InitParam", m_initParam); - declareProperty("MaxChi2", m_chiMax); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - } - - -StatusCode NtupleClassicT0Tool::initialize() - { - ATH_MSG_INFO( "Initializing MT T0 Tool" ); - double *params = new double[8]; - params[0] = 0. ;/* initial parameters for spectrum fit */ - params[1] = 9. ; - params[2] = 3. ; - params[3] = 200. ; - params[4] = 800. ; - params[5] = 1470. ; - params[6] = 5. ; - params[7] = 10. ; - - m_settings = new T0ClassicSettings( - m_minAdc, - m_maxAdc, - m_adcBins, - m_minTime, - m_maxTime, - m_timeBins, - m_fitTime, - m_minEntries, - m_initParam, - 8, params, - m_chiMax, 4 - ); -//get region selection service - ATH_CHECK( m_reg_sel_svc.retrieve() ); - return StatusCode :: SUCCESS; - } - -StatusCode NtupleClassicT0Tool::handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) - { - if(p_alg == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return StatusCode :: FAILURE; - } - for(unsigned int i=position; i<segments.size(); i++) - { - if(!p_alg->handleSegment((*segments[i]))) return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; - } - - -StatusCode NtupleClassicT0Tool::analyseSegments(const std::vector<MuonCalibSegment *> & /*segments*/) - { - if(p_alg == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return StatusCode :: FAILURE; - } - if(p_alg->analyse()) return StatusCode :: SUCCESS; - return StatusCode :: FAILURE; - } - - -void NtupleClassicT0Tool::setRegion() - { - p_alg = new T0CalibrationClassic(std::string("Classic_t0_fitter"), m_settings); - p_alg->setInput(new T0CalibrationOutput(new MdtTubeFitContainer(m_reg_sel_svc->GetRegionSelection(), 2, 4, 72))); - } - -const IMdtCalibrationOutput * NtupleClassicT0Tool::getResults() const - { - if(p_alg == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return NULL; - } - return p_alg->getResults(); - } - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleControlHistogramsTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleControlHistogramsTool.cxx deleted file mode 100644 index 4c275fe09487a27938c69d6af0e1147d1cedcc4a..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleControlHistogramsTool.cxx +++ /dev/null @@ -1,1357 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 20.06.2007, AUTHOR: OLIVER KORTNER -// Modified: 26.06.2007 by O. Kortner, new naming convention for directories: -// station-phi-eta -// 26.06.2007 by O. Kortner, new histograms added. -// 19.07.2007 by O. Kortner, no t0 refinement without r-t calibration. -// 18.08.2008 by O. Kortner, curved track fit + time-out option added. -// 03.11.2008 by O. Kortner, allow the user to turn off the t0 -// refinement histograms. -// 21.02.2009 by O. Kortner, additional residual histograms -// after t0 refinement. -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::: -//:: IMPLEMENTATION OF THE METHODS DEFINED IN THE CLASS :: -//:: NtupleControlHistogramsTool :: -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -// standard C++ // -#include <iostream> -#include <fstream> - -// CLHEP // -#include "CLHEP/GenericFunctions/CumulativeChiSquare.hh" - -#include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "MuonReadoutGeometry/RpcReadoutElement.h" -#include "MuonCalibStandAloneTools/NtupleControlHistogramsTool.h" -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibRawRpcHit.h" -#include "MuonCalibStl/ToString.h" -#include "MuonCalibStandAloneBase/MdtStationT0Container.h" -#include "MuonCalibIdentifier/MuonFixedId.h" -#include "MdtCalibT0/T0MTHistos.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" -#include "TF1.h" -#include "TTree.h" -#include "TProfile.h" - -using namespace MuonCalib; - -//***************************************************************************** - -//::::::::::::::::: -//:: CONSTRUCTOR :: -//::::::::::::::::: - -NtupleControlHistogramsTool::NtupleControlHistogramsTool(const std::string & t, - const std::string & n, const IInterface * p) : AthAlgTool(t, n, p), - m_reg_sel_svc("RegionSelectionSvc", n), m_input_service("MdtCalibInputSvc",n) { - -///////////////// -// JOB OPTIONS // -///////////////// - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - declareProperty("MdtCalibInputSvc", m_input_service); - - m_refit_segments = false; // by default refit the segments - declareProperty("segmentRefit", m_refit_segments); - - m_curved_fits = false; // by default straight refits of the segments - declareProperty("curvedSegmentRefit", m_curved_fits); - - m_refine_t0 = false; // by default t0 refinement plots are made - declareProperty("t0RefinementPlots", m_refine_t0); - - m_time_out = 2.0; // by default 2 s time-out for pattern finding - declareProperty("timeOut", m_time_out); - - m_road_width = 1.0; // by default road width = 1 mm - declareProperty("roadWidth", m_road_width); - - m_MDT_ID_helper = std::string("MDTIDHELPER"); - declareProperty("MDTIdHelper", m_MDT_ID_helper); - - m_RPC_ID_helper = std::string("RPCIDHELPER"); - declareProperty("RPCIdHelper", m_RPC_ID_helper); - - m_idToFixedIdToolType = std::string("MuonCalib::IdToFixedIdTool"); - declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); - - m_idToFixedIdToolName = std::string("MuonCalib_IdToFixedIdTool"); - declareProperty("idToFixedIdToolName", m_idToFixedIdToolName); - - m_ROOT_file_name = std::string("NtupleControlHistogramsTool.root"); - declareProperty("ROOTFileName", m_ROOT_file_name); - -///////////////////////////// -// RESET PRIVATE VARIABLES // -///////////////////////////// - - m_MDT_raw_nb_hits.clear(); - m_MDT_raw_hit_distribution.clear(); - m_MDT_raw_TDC.clear(); - m_MDT_raw_ADC.clear(); - m_t0_diff.clear(); - m_r_mintrt.clear(); - m_MDT_segment_hits.clear(); - m_MDT_segment_hist_to_raw_hits_ratio.clear(); - m_MDT_segment_CL.clear(); - m_MDT_segment_t.clear(); - m_MDT_segment_r.clear(); - m_MDT_segment_TDC.clear(); - m_MDT_segment_ADC.clear(); - m_MDT_segment_slope.clear(); - m_MDT_residuals.clear(); - m_MDT_residuals_vs_x.clear(); - m_MDT_residuals_ml1.clear(); - m_MDT_residuals_ml2.clear(); - m_MDT_t0_refinement.clear(); - m_MDT_t_refined.clear(); - m_MDT_residuals_t0_refined.clear(); - m_MDT_residuals_t0_refined_gt4hits.clear(); - m_MDT_RPC_raw_tubeStripCorVsEvent.clear(); - - m_nb_ml.clear(); - m_nb_ly.clear(); - m_nb_tb.clear(); - m_nb_totalEtaStrips.clear(); - m_nb_totalEtaStrips2.clear(); - m_nb_raw_MDT_hits.clear(); - m_nb_events = 0; - m_MdtIdHelper = 0; - m_RpcIdHelper = 0; - m_id_tool = 0; - - m_qfitter = new StraightPatRec(); - m_cfitter = new CurvedPatRec(); - m_t0_refinement = new T0Refinement(); - - declareInterface< NtupleCalibrationTool >(this); - -} - -//***************************************************************************** - -//:::::::::::::::: -//:: DESTRUCTOR :: -//:::::::::::::::: - -NtupleControlHistogramsTool::~NtupleControlHistogramsTool(void) { - -} - -//***************************************************************************** - -//::::::::::::::::::::::: -//:: METHOD initialize :: -//::::::::::::::::::::::: - -StatusCode NtupleControlHistogramsTool::initialize(void) { - -/////////////// -// VARIABLES // -/////////////// - -///////////// -// MESSAGE // -///////////// - - ATH_MSG_INFO( "Initializing tool..." ); - -//////////////////////////////////////////////////// -// STORE GATE AND GEOMODEL RELATED INITIALIZATION // -//////////////////////////////////////////////////// - -// MDT ID helper // - ATH_CHECK( detStore()->retrieve(m_MdtIdHelper, m_MDT_ID_helper) ); - -// RPC ID helper // - ATH_CHECK( detStore()->retrieve(m_RpcIdHelper, m_RPC_ID_helper) ); - -//retrieve detector manager from the conditions store - ATH_CHECK(m_DetectorManagerKey.initialize()); - -// muon fixed id tool // - ATH_CHECK( toolSvc()->retrieveTool(m_idToFixedIdToolType, - m_idToFixedIdToolName, m_id_tool) ); - -// calibration input service // - ATH_CHECK( m_input_service.retrieve() ); - -//////////////////////// -// OPEN THE ROOT FILE // -//////////////////////// - - m_tfile = new TFile(m_ROOT_file_name.c_str(), "RECREATE"); - - m_t0_diff_global = new TH1F("mt_t0_diff_global", "", 201, -100.5, 100.5); - m_r_mintrt_global = new TH1F ("r_min_rt_global", "", 101, -0.1, 0.1); - - m_r_minrt_vs_r = new TH2F ("m_r_minrt_vs_r", "", 100, 0.0, 15.0, 101, -0.1, 0.1); -///////////////////////////////// -// SET UP STRAIGHT-LINE FITTER // -///////////////////////////////// - - m_qfitter->setRoadWidth(m_road_width); - m_qfitter->switchOnRefit(); -// m_qfitter->switchOffRefit(); - m_qfitter->setTimeOut(m_time_out); - m_cfitter->setRoadWidth(m_road_width); - m_cfitter->setTimeOut(m_time_out); - -//get region selection service - ATH_CHECK( m_reg_sel_svc.retrieve() ); - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//::::::::::::::::::::: -//:: METHOD finalize :: -//::::::::::::::::::::: - -StatusCode NtupleControlHistogramsTool::finalize(void) { - -/////////////// -// VARIABLES // -/////////////// - - -///////////// -// MESSAGE // -///////////// - - ATH_MSG_INFO( "Finalizing tool..." ); -//the summary tree creation crashes if the refit option is not set -- To be fixed! - if (!m_refit_segments) - { - m_tfile->Write(); - - return StatusCode::SUCCESS; - } - -/////////////////////////////// -// Postprocess histogramms // -/////////////////////////////// - m_tfile->cd(); -//station id - Int_t station_eta, station_phi, station_name; - char station_name_str[10]; - char software_id[100]; - char hardware_id[100]; -//t0 tmax fit information - Double_t t0[3], T0[3], tmax[3], Tmax[3], chi2_t0[3], chi2_tmax[3]; - Double_t t0_err[3], T0_err[3], tmax_err[3], Tmax_err[3]; - Int_t n_hits[3], ml_nr[3]; - for(int i=0; i<3; i++) - { - ml_nr[i]=i; - } -//residual information - Double_t res_chi2, res_chi2_t0_improved; - - m_chamber_tree = new TTree("chamber_tree", "Summary information listed by chamber"); - m_chamber_tree->Branch("station_eta", &station_eta, "station_eta/I"); - m_chamber_tree->Branch("station_phi", &station_phi, "station_phi/I"); - m_chamber_tree->Branch("station_name", &station_name, "station_name/I"); - m_chamber_tree->Branch("station_name_str", &station_name_str, "station_name_str/C"); - m_chamber_tree->Branch("software_id", &software_id, "software_id/C"); - m_chamber_tree->Branch("hardware_id", &hardware_id, "hardware_id/C"); - m_chamber_tree->Branch("t0", &t0, "t0[3]/D"); - m_chamber_tree->Branch("t0_err", &t0_err, "t0_err[3]/D"); - m_chamber_tree->Branch("T0", &T0, "T0[3]/D"); - m_chamber_tree->Branch("T0_err", &T0_err, "T0_err[3]/D"); - m_chamber_tree->Branch("tmax", &tmax, "tmax[3]/D"); - m_chamber_tree->Branch("tmax_err", &tmax_err, "tmax_err[3]/D"); - m_chamber_tree->Branch("Tmax", &Tmax, "Tmax[3]/D"); - m_chamber_tree->Branch("Tmax_err", &Tmax_err, "Tmax_err[3]/D"); - m_chamber_tree->Branch("chi2_t0", &chi2_t0, "chi2_t0[3]/D"); - m_chamber_tree->Branch("chi2_tmax", &chi2_tmax, "chi2_tmax[3]/D"); - m_chamber_tree->Branch("ml_nr", &ml_nr, "ml_nr[3]/I"); - m_chamber_tree->Branch("n_hits", &n_hits, "n_hits[3]/I"); - m_chamber_tree->Branch("res_chi2", &res_chi2, "res_chi2/D"); - m_chamber_tree->Branch("res_chi2_t0_improved", &res_chi2_t0_improved, "res_chi2_t0_improved/D"); - MuonFixedId id; -//loop on all chambers - for(std::map<NtupleStationId, T0MTHistos *>::iterator it = m_MDT_segment_tspec_ml[0].begin(); it!=m_MDT_segment_tspec_ml[0].end(); it++) - { - //chamber id - station_eta = it->first.GetEta(); - station_phi = it->first.GetPhi(); - station_name = it->first.GetStation(); - strncpy(station_name_str, id.stationNumberToFixedStationString(it->first.GetStation()).c_str(), 9); - std::ostringstream sw_id; - std::ostringstream hw_id; - hw_id<<station_name_str<<std::abs(station_eta); - if(station_eta>0) - hw_id<<"A"; - else - hw_id<<"C"; - int hw_phi=station_phi*2; - if(station_name_str[2]=='L') - hw_phi-=1; - if(hw_phi<10) - hw_id<<0; - hw_id<<hw_phi; - sw_id<<station_name_str<<" #eta"<<station_eta<<" #phi"<<station_phi; - strncpy(software_id, sw_id.str().c_str(), 99); - strncpy(hardware_id, hw_id.str().c_str(), 99); - - //specra fit - for(int i=0; i<3; i++) { - T0MTHistos *histo=m_MDT_segment_tspec_ml[i][it->first]; - n_hits[i] = static_cast<Int_t>(histo->GetTSpec()->GetEntries()); - if(n_hits[i]<2000) - { - t0[i]=9e9; - t0_err[i]=9e9; - T0[i]=9e9; - T0_err[i]=9e9; - tmax[i]=9e9; - tmax_err[i]=9e9; - Tmax[i]=9e9; - Tmax_err[i]=9e9; - chi2_t0[i]=9e9; - chi2_tmax[i]=9e9; - } - else { - if(!histo->FitT0()) - { - ATH_MSG_WARNING( " T0 fit faild for " << it->first.regionId() ); - t0[i]=9e9; - t0_err[i]=9e9; - T0[i]=9e9; - T0_err[i]=9e9; - tmax[i]=9e9; - tmax_err[i]=9e9; - Tmax[i]=9e9; - Tmax_err[i]=9e9; - chi2_t0[i]=9e9; - chi2_tmax[i]=9e9; - } - else - { - const TF1 *t0_fun=histo->GetT0Function(); - t0[i]=t0_fun->GetParameter(T0MTHistos::T0_PAR_NR_T0); - t0_err[i]=t0_fun->GetParError(T0MTHistos :: T0_PAR_NR_T0); - T0[i]=t0_fun->GetParameter(T0MTHistos::T0_PAR_NR_T); - T0_err[i]=t0_fun->GetParError(T0MTHistos :: T0_PAR_NR_T); - chi2_t0[i]=getChi2(t0_fun, it->second->GetTSpec()); - if(!histo->FitTmax()) - { - ATH_MSG_WARNING( " TMax fit faild for " << it->first.regionId() ); - tmax[i]=9e9; - tmax_err[i]=9e9; - Tmax[i]=9e9; - Tmax_err[i]=9e9; - chi2_tmax[i]=9e9; - } - else - { - const TF1 *tmax_fun=histo->GetTMaxFunction(); - tmax[i]=tmax_fun-> GetParameter(T0MTHistos :: TMAX_PAR_NR_TMAX); - tmax_err[i]=tmax_fun-> GetParError(T0MTHistos :: TMAX_PAR_NR_TMAX); - Tmax[i]=tmax_fun-> GetParameter(T0MTHistos :: TMAX_PAR_NR_T); - Tmax_err[i]=tmax_fun-> GetParError(T0MTHistos :: TMAX_PAR_NR_T); - chi2_tmax[i]=getChi2(tmax_fun, it->second->GetTSpec()); - } - } - } - } - //residual analysis - TProfile *px=m_MDT_residuals[it->first]->ProfileX(); - res_chi2=getResidualChi2(px); - px=m_MDT_residuals_t0_refined[it->first]->ProfileX(); - res_chi2_t0_improved=getResidualChi2(px); - m_chamber_tree->Fill(); - } - - -///////////////////////// -// WRITE THE ROOT FILE // -///////////////////////// - - m_tfile->Write(); - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//:::::::::::::::::::::::: -//:: METHOD handleEvent :: -//:::::::::::::::::::::::: - -StatusCode NtupleControlHistogramsTool::handleEvent( - const MuonCalibEvent & event, - int evnt_nb, - const std::vector<MuonCalibSegment *> & segments, - unsigned int position) { - -/////////////// -// VARIABLES // -/////////////// - - const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); - unsigned int ml, ly, tb; // multilayer, layer, tube - unsigned int ndof; // number of degrees of freedom of the segment fit - int strip, strip2; // rpc strip - double r, d; // drift radius and track distance from the wire - int mdt_close_layer, mdt_close_multi; - IMdtPatRecFitter *segment_fitter(0); // pointer to the segment fitter - if (m_curved_fits) { - segment_fitter = m_cfitter; - } else { - segment_fitter = m_qfitter; - } - -//////////////////// -// RESET COUNTERS // -//////////////////// - - m_nb_raw_MDT_hits.clear(); - -////////////////////////////// -// FILL RAW DATA HISTOGRAMS // -////////////////////////////// - - -// loop over the raw hits // - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { - - // get the raw hit and check whether it is in the calibration region // - MuonCalibRawMdtHit *hit(*it); - - if(!m_reg_sel_svc->isInRegion(hit->identify())) continue; - - - // create maps if necessary // - NtupleStationId station_identifier(hit->identify()); - station_identifier.SetMultilayer(0); - createMaps(hit->identify()); - - // calculate the number of raw MDT hits per chamber // - m_nb_raw_MDT_hits[station_identifier]++; - - // fill raw histograms as far as possible // - // raw MDT hit distribution // - ml = (hit->identify()).mdtMultilayer(); - ly = (hit->identify()).mdtTubeLayerIndex()+1; - tb = (hit->identify()).mdtTubeIndex(); - - m_MDT_raw_hit_distribution[station_identifier]->Fill( - tb+(ly-1)*m_nb_tb[station_identifier] - +(ml-1)*m_nb_tb[station_identifier]* - m_nb_ly[station_identifier], 1.0); - - // raw MDT TDC spectrum // - m_MDT_raw_TDC[station_identifier]->Fill(hit->tdcCount(), 1.0); - - // raw MDT ADC spectra // - m_MDT_raw_ADC[station_identifier]->Fill(hit->adcCount(), 1.0); - - } - - // fill histograms with number of raw MDT hits // - std::map<NtupleStationId, unsigned int>::iterator it = - m_nb_raw_MDT_hits.begin(); - std::map<NtupleStationId, unsigned int>::iterator end_it = - m_nb_raw_MDT_hits.end(); - - while(it!=end_it) { - m_MDT_raw_nb_hits[(*it).first]->Fill((*it).second, 1.0); - ++it; - }; - -// Loop over the raw rpc hits - - for (MuonCalibRawHitCollection::MuonCalibRawRpcHitVecCit rit= - raw_hits->rawRpcHitCollectionBegin(); - rit!=raw_hits->rawRpcHitCollectionEnd(); ++rit){ - mdt_close_multi=0; //ML next to RPC - mdt_close_layer=0; //Layer next to RPC - strip = -1; // tmp var for the right strip number - strip2 = -1; // tmp var for the right strip number in r doublet 2 rpc - - - // get the raw rpc hit and check whether it is in the calibration region // - MuonCalibRawRpcHit *rhit(*rit); - - if(!m_reg_sel_svc->isInRegion(rhit->identify())) continue; - - // create maps if necessary // - NtupleStationId station_identifier(rhit->identify()); - station_identifier.SetMultilayer(0); - createMaps(rhit->identify()); - - // select hits on eta strips - if ( (rhit->identify()).rpcMeasuresPhiIndex() ){ - continue; - } - - //find and select closest mdt layer to the hit rpc - //BML / BMS - if ( (rhit->identify()).stationNameIndex() == 2 - || (rhit->identify()).stationNameIndex() ==3 ){ - // the BMx chambers have two rpcs, select by the R doublet - switch ( (rhit->identify()).rpcDoubletRIndex() ){ - case (0): - mdt_close_multi = 1; - mdt_close_layer = 1; - // add offset if there is a second rpc Z doublet - if (! (rhit->identify()).rpcDoubletZIndex() ){ - strip = (rhit->identify()).rpcStripIndex(); - } - else{ - strip = (rhit->identify()).rpcStripIndex() - + m_nb_etaStrips[0][0]; - } - break; - - case (1): - mdt_close_multi = 2; - mdt_close_layer = 3; - // add offset if there is a second rpc Z doublet - if (! (rhit->identify()).rpcDoubletZIndex() ){ - strip2 = (rhit->identify()).rpcStripIndex(); - } - else{ - strip2 = (rhit->identify()).rpcStripIndex() - + m_nb_etaStrips[1][0]; - } - break; - - default: - ATH_MSG_INFO( "no second rpc found for chambertype: " << - (rhit->identify()).stationNameIndex() ); - break; - } - - } - // BOL - else if ( (rhit->identify()).stationNameIndex() == 4 ){ - mdt_close_multi = 2; - mdt_close_layer = 3; - - // add offset if there is a second rpc Z doublet - if (! (rhit->identify()).rpcDoubletZIndex() ){ - strip = (rhit->identify()).rpcStripIndex(); - } - else{ - strip = (rhit->identify()).rpcStripIndex() - + m_nb_etaStrips[0][0]; - } - } - // BOS - else if ( (rhit->identify()).stationNameIndex() == 5 ){ - mdt_close_multi = 1; - mdt_close_layer = 1; - - // add offset if there is a second rpc Z doublet - if (! (rhit->identify()).rpcDoubletZIndex() ){ - strip = (rhit->identify()).rpcStripIndex(); - } - else{ - strip = (rhit->identify()).rpcStripIndex() - + m_nb_etaStrips[0][0]; - } - - } - else{ - ATH_MSG_WARNING( "MDT close layer could no be set for rpc with stationNameIndex: " - << (rhit->identify()).stationNameIndex() ); - } - - //now loop over all raw mdt hits in the layer which is next to the rpc - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { - // get the raw mdt hit and check whether it is in the same chamber as the rpc hit // - MuonCalibRawMdtHit *hit(*it); - - if ( (hit->identify()).stationName() != (rhit->identify()).stationName() ){ - continue; - } - if ( (hit->identify()).etaIndex() != (rhit->identify()).etaIndex() ){ - continue; - } - if ( (hit->identify()).phiIndex() != (rhit->identify()).phiIndex() ){ - continue; - } - // select layer next to the rpc - if ( (hit->identify()).mdtMultilayerIndex()+1 != mdt_close_multi ){ - continue; - } - if ( (hit->identify()).mdtTubeLayerIndex()+1 != mdt_close_layer ){ - continue; - } - if (strip != -1){ - m_RPC_raw_etaStrip[station_identifier]->Fill(strip); - m_MDT_RPC_raw_tubeStripCor[station_identifier]->Fill( - (hit->identify()).mdtTubeIndex() + 1, - strip + 1 - ); - m_MDT_RPC_raw_tubeStripCorVsEvent[station_identifier]->Fill( - evnt_nb, - ((hit->identify()).mdtTubeIndex()) - strip - ); - - if (hit->adcCount() > 80 ){ // to cut elx noise - m_MDT_RPC_raw_tubeStripCor_adcCut[station_identifier]->Fill( - (hit->identify()).mdtTubeIndex() + 1,strip + 1); - m_MDT_RPC_raw_tubeStripCorVsEvent_adcCut[station_identifier]->Fill( - evnt_nb, ((hit->identify()).mdtTubeIndex()) - strip ); - } - } - - // Fill histos for 2nd rpc r doublet if BMx chamber - if (m_nb_totalEtaStrips2[station_identifier] - && strip2 != -1){ - m_RPC_raw_etaStrip2[station_identifier]->Fill(strip2); - m_MDT_RPC_raw_tubeStripCor2[station_identifier]->Fill( - (hit->identify()).mdtTubeIndex() + 1, - strip2 + 1 - ); - m_MDT_RPC_raw_tubeStripCorVsEvent2[station_identifier]->Fill( - evnt_nb, - ((hit->identify()).mdtTubeIndex()) - strip2 - ); - if (hit->adcCount() > 80 ){ // to cut elx noise - m_MDT_RPC_raw_tubeStripCor_adcCut2[station_identifier]->Fill( - (hit->identify()).mdtTubeIndex() + 1,strip2 + 1); - m_MDT_RPC_raw_tubeStripCorVsEvent_adcCut2[station_identifier]->Fill( - evnt_nb, ((hit->identify()).mdtTubeIndex()) - strip2 ); - } - - } - - } - - } - - -//////////////////////// -// SEGMENT HISTOGRAMS // -//////////////////////// - -// loop over the segments // - for (unsigned int k=position; k<segments.size(); k++) { - - - // get the first hit to check if it is in the calibration region // - if(!m_reg_sel_svc->isInRegion(segments[k]->mdtHOT()[0] ->identify())) continue; - - // create maps if necessary // - NtupleStationId station_identifier((segments[k]->mdtHOT()[0])->identify()); - station_identifier.SetMultilayer(0); - createMaps((segments[k]->mdtHOT()[0])->identify()); - - // perform a refit if requested // - if (m_refit_segments) { - if(!segment_fitter->fit(*(segments[k]))) return StatusCode :: SUCCESS; - } - - // number of hits on the segment // - if (m_refit_segments) { - m_MDT_segment_hits[station_identifier]->Fill( - segment_fitter->numberOfTrackHits(), 1.0); - } else { - m_MDT_segment_hits[station_identifier]->Fill( - segments[k]->mdtHitsOnTrack(), 1.0); - } - - // ratio of hits on the segment and the number of raw MDT hits // - if (m_refit_segments) { - m_MDT_segment_hist_to_raw_hits_ratio[station_identifier - ]->Fill(segment_fitter->numberOfTrackHits()/ - static_cast<double>(m_nb_raw_MDT_hits[ - station_identifier]), 1.0); - } else { - m_MDT_segment_hist_to_raw_hits_ratio[station_identifier - ]->Fill(segments[k]->mdtHitsOnTrack()/ - static_cast<double>(m_nb_raw_MDT_hits[ - station_identifier]), 1.0); - } - - // CL of the segment fit // - if (m_refit_segments) { - if (m_curved_fits) { - ndof = segment_fitter->numberOfTrackHits()-3; - } else { - ndof = segment_fitter->numberOfTrackHits()-2; - } - } else { - ndof = segments[k]->mdtHitsOnTrack()-2; - } - if (ndof>0 && !std::isnan(segments[k]->chi2())) { - Genfun::CumulativeChiSquare one_minus_CL(ndof); - m_MDT_segment_CL[station_identifier]->Fill( - 1.0-one_minus_CL(std::abs(segments[k]->chi2())), - 1.0); - } - - // drift-time and ADC spectra // - if (m_refit_segments) { - for (unsigned int l=0; l<segment_fitter->numberOfTrackHits(); - l++) { - m_MDT_segment_t[station_identifier]->Fill( - (segment_fitter->trackHits())[l - ]->driftTime(), 1.0); - m_MDT_segment_r[station_identifier]->Fill( - (segment_fitter->trackHits())[l - ]->driftRadius(), 1.0); - const MuonFixedId &h_id((segment_fitter-> trackHits())[l]-> identify()); - m_MDT_segment_hit_dis[station_identifier]-> Fill((h_id.mdtMultilayer() - 1) * 216 + (h_id.mdtTubeLayer() - 1) * 72 + h_id.mdtTube() -1); - m_MDT_segment_tspec_ml[0][station_identifier]-> - FillT((segment_fitter->trackHits())[l - ]->driftTime()); - MuonFixedId id((segment_fitter->trackHits())[l - ]->identify()); - m_MDT_segment_tspec_ml[id.mdtMultilayer()] [station_identifier]-> FillT((segment_fitter->trackHits())[l]->driftTime()); - m_MDT_segment_TDC[station_identifier]->Fill( - (segment_fitter->trackHits())[l - ]->tdcCount(), 1.0); - m_MDT_segment_ADC[station_identifier]->Fill( - (segment_fitter->trackHits())[l - ]->adcCount(), 1.0); - - } - } else { - for (unsigned int l=0; l<segments[k]->hitsOnTrack(); - l++) { - const MuonFixedId &h_id((segments[k]->mdtHOT())[l]-> identify()); - m_MDT_segment_hit_dis[station_identifier]-> Fill((h_id.mdtMultilayer() - 1) * 216 + (h_id.mdtTubeLayer() - 1) * 72 + h_id.mdtTube() -1); - m_MDT_segment_t[station_identifier]->Fill( - (segments[k]->mdtHOT())[l - ]->driftTime(), 1.0); - m_MDT_segment_r[station_identifier]->Fill( - (segments[k]->mdtHOT())[l - ]->driftRadius(), 1.0); - m_MDT_segment_TDC[station_identifier]->Fill( - (segments[k]->mdtHOT())[l - ]->tdcCount(), 1.0); - m_MDT_segment_ADC[station_identifier]->Fill( - (segments[k]->mdtHOT())[l - ]->adcCount(), 1.0); - } - } - - // segment slopes // - m_MDT_segment_slope[station_identifier]->Fill( - 57.30*std::atan((segments[k]->direction()).y()/ - (segments[k]->direction()).z()), 1.0); - - // track residuals // - if (m_refit_segments) { - if (ndof>0 && !std::isnan(segments[k]->chi2())) { - for (unsigned int l=0; l<segment_fitter->numberOfTrackHits(); - l++) { - r = std::abs((segment_fitter->trackHits())[l - ]->driftRadius()); - d = (segment_fitter->trackHits())[l - ]->signedDistanceToTrack(); - double t = (segment_fitter->trackHits())[l] -> driftTime(); - m_MDT_residuals[station_identifier]->Fill( - std::abs(d), r-std::abs(d), 1.0); - m_MDT_residuals_vs_x[station_identifier]->Fill( - (segment_fitter->trackHits())[l - ]->localPosition().x(), r-std::abs(d), 1.0); - m_MDT_r_vs_rtrack[station_identifier]->Fill( - d, r, 1.0); - m_MDT_t_vs_rtrack[station_identifier]->Fill( - d, t, 1.0); - - MuonFixedId id((segment_fitter->trackHits())[l - ]->identify()); - if (id.mdtMultilayer()==1) { - m_MDT_residuals_ml1[station_identifier - ]->Fill(d, r-std::abs(d), 1.0); - } else { - m_MDT_residuals_ml2[station_identifier - ]->Fill(d, r-std::abs(d), 1.0); - } - } - } - } else { - for (unsigned int l=0; l<segments[k]->hitsOnTrack(); - l++) { - r = std::abs((segments[k]->mdtHOT())[l - ]->driftRadius()); - d = (segments[k]->mdtHOT())[l - ]->signedDistanceToTrack(); - double xx = (segments[k]->mdtHOT())[l] -> localPosition().x(); - m_MDT_residuals[station_identifier]->Fill( - std::abs(d), r-std::abs(d), 1.0); - m_MDT_residuals_vs_x[station_identifier]->Fill( xx, r-std::abs(d), 1.0); - - MuonFixedId id((segments[k]->mdtHOT())[l - ]->identify()); - if (id.mdtMultilayer()==1) { - m_MDT_residuals_ml1[station_identifier - ]->Fill(d, r-std::abs(d), 1.0); - } else { - m_MDT_residuals_ml2[station_identifier - ]->Fill(d, r-std::abs(d), 1.0); - } - } - } - - -//test histograms - const MdtStationT0Container *t0(m_input_service->GetT0(station_identifier)); - const IRtRelation *rt=m_input_service->GetRtRelation( - station_identifier); - if(t0!=NULL) - for (unsigned int l=0; l<segments[k]->hitsOnTrack();l++) - { - const MdtCalibHitBase *hot((segments[k]->mdtHOT())[l]); - const MuonFixedId &id(hot->identify()); - m_t0_diff[station_identifier]->Fill(hot->tubeT0() - t0->t0(id.mdtMultilayer(), id.mdtTubeLayer(), id.mdtTube())); - m_t0_diff_global->Fill(hot->tubeT0() - t0->t0(id.mdtMultilayer(), id.mdtTubeLayer(), id.mdtTube())); - } - if(rt!=NULL) - for (unsigned int l=0; l<segments[k]->hitsOnTrack();l++) - { - const MdtCalibHitBase *hot((segments[k]->mdtHOT())[l]); - m_r_mintrt[station_identifier]-> Fill(std::abs(hot->driftRadius()) - std::abs(rt->radius(hot->driftTime()))); - m_r_mintrt_global->Fill(std::abs(hot->driftRadius()) - std::abs(rt->radius(hot->driftTime()))); - m_r_minrt_vs_r ->Fill(std::abs(hot->driftRadius()), std::abs(hot->driftRadius()) - std::abs(rt->radius(hot->driftTime()))); - } - -// t0 refinement // - MuonCalibSegment seg(*segments[k]); - if (!m_refine_t0 || !m_refit_segments) { - m_MDT_t0_refinement[station_identifier]->Fill(seg.fittedT0()); - for (unsigned int l=0; l<seg.hitsOnTrack();l++) - { - double t = (seg.mdtHOT())[l]->driftTime() + seg.fittedT0(); - m_MDT_t_refined[station_identifier]->Fill(t); - } - } - - if (!m_refit_segments) { - continue; - } - if (rt==0) { - continue; - } - if (!m_refine_t0) { - continue; - } - - - double error; - bool fail; - m_t0_refinement->SetDeltaT0(12.5); - double delta(m_t0_refinement->getDeltaT0(&seg, rt, true, - error, fail)); - if (!fail) { - m_MDT_t0_refinement[station_identifier]->Fill( - delta, 1.0); - - // refit the segment // - if (m_refit_segments) { - if(!segment_fitter->fit(*(segments[k]))) return StatusCode :: SUCCESS; - } - - for (unsigned int l=0; l<seg.hitsOnTrack();l++) { - r = std::abs((seg.mdtHOT())[l - ]->driftRadius()); - d = std::abs((seg.mdtHOT())[l - ]->signedDistanceToTrack()); - double t = (seg.mdtHOT())[l - ]->driftTime(); - m_MDT_residuals_t0_refined[station_identifier - ]->Fill(d, r-d, 1.0); - if (seg.hitsOnTrack()>4) { - m_MDT_residuals_t0_refined_gt4hits[station_identifier - ]->Fill(d, r-d, 1.0); - } - m_MDT_t_refined[station_identifier]->Fill(t); - } - } - } - - return StatusCode::SUCCESS; - -} - - - -//***************************************************************************** - -//::::::::::::::::::::::::: -//:: METHOD KeepSegments :: -//::::::::::::::::::::::::: - -bool NtupleControlHistogramsTool::KeepSegments(void) const { - - return false; - -} - -//***************************************************************************** - -//::::::::::::::::::::::: -//:: METHOD createMaps :: -//::::::::::::::::::::::: - -void NtupleControlHistogramsTool::createMaps(const MuonFixedId & id) { - -/////////////// -// VARIABLES // -/////////////// - - NtupleStationId station_identifier(id); - station_identifier.SetMultilayer(0); - std::map<NtupleStationId, unsigned int>::iterator end_it = - m_nb_ml.end(); - -//////////////////////////////////// -// FIND THE IDENTIFIER IN m_nb_ml // -//////////////////////////////////// - - if (m_nb_ml.find(station_identifier)!=end_it) { - return; - } - -/////////////////////////////////////////// -// GET THE GEOMETRY OF THE GIVEN CHAMBER // -/////////////////////////////////////////// - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return; - } - - Identifier station_id = m_id_tool->fixedIdToId(id); - const MuonGM::MdtReadoutElement *MdtRoEl = - MuonDetMgr->getMdtReadoutElement( - m_MdtIdHelper->channelID(station_id,1,1,1)); - - m_nb_ml[station_identifier] = m_MdtIdHelper->numberOfMultilayers( - station_id); - m_nb_ly[station_identifier] = MdtRoEl->getNLayers(); - m_nb_tb[station_identifier] = MdtRoEl->getNtubesperlayer(); - - // get the rpc geom information - - // loop over possible R doublets - m_nb_totalEtaStrips[station_identifier]=0; - m_nb_totalEtaStrips2[station_identifier]=0; - for (int r_doublet=0; r_doublet<2; r_doublet++){ - // loop over possible Z doublets - for (int z_doublet=0; z_doublet<4; z_doublet++){ - const MuonGM::RpcReadoutElement *RpcRoEl = - MuonDetMgr->getRpcRElement_fromIdFields( - m_MdtIdHelper -> stationName(station_id),// int stationName, - m_MdtIdHelper -> stationEta(station_id), // int stationEta, - m_MdtIdHelper -> stationPhi(station_id), // int stationPhi - r_doublet+1,z_doublet+1,1// int doubletR, int doubletZ, int doubletPhi - ); - - //save nuber of eta strips per doublet, if there is one - if (RpcRoEl){ - m_nb_etaStrips[r_doublet][z_doublet] = RpcRoEl->NetaStrips(); - } - else { - m_nb_etaStrips[r_doublet][z_doublet] = 0; - } - - //save the total number of eta strips for the two different R doublets - if (!r_doublet){ - m_nb_totalEtaStrips[station_identifier] = m_nb_totalEtaStrips[station_identifier] - + m_nb_etaStrips[r_doublet][z_doublet]; - } - else{ - m_nb_totalEtaStrips2[station_identifier] = m_nb_totalEtaStrips2[station_identifier] - + m_nb_etaStrips[r_doublet][z_doublet]; - } - } - - } - - -/////////////////////////////// -// CREATE THE REMAINING MAPS // -/////////////////////////////// - -// counter // - m_nb_raw_MDT_hits[station_identifier] = 0; - -// histograms // - ToString tostring; - std::string file_dir(id.stationNumberToFixedStationString(id.stationName()) - +"_"+tostring(id.phi())+"_"+tostring(id.eta())); - m_tfile->mkdir(file_dir.c_str()); - m_tfile->cd(file_dir.c_str()); - - m_MDT_raw_nb_hits[station_identifier] = - new TH1F("MDT_raw_nb_hits", - "Number of Raw MDT Hits", - 1+m_nb_ml[station_identifier]*( - m_nb_ly[station_identifier]* - m_nb_tb[station_identifier]), - -0.5, - 0.5+m_nb_ml[station_identifier]*( - m_nb_ly[station_identifier]* - m_nb_tb[station_identifier])); - m_MDT_raw_nb_hits[station_identifier - ]->SetXTitle("Number of Hits"); - m_MDT_raw_nb_hits[station_identifier - ]->SetYTitle("Entries / 1"); - - - m_MDT_raw_hit_distribution[station_identifier] = - new TH1F("MDT_raw_hit_distribution", - "Raw MDT Hit Profile", - m_nb_ml[station_identifier]*( - m_nb_ly[station_identifier]* - m_nb_tb[station_identifier]), - 0.5, - 0.5+m_nb_ml[station_identifier]*( - m_nb_ly[station_identifier]* - m_nb_tb[station_identifier])); - m_MDT_raw_hit_distribution[station_identifier - ]->SetXTitle("Channel"); - m_MDT_raw_hit_distribution[station_identifier - ]->SetYTitle("Entries / Channel"); - - m_MDT_raw_TDC[station_identifier] = - new TH1F("MDT_raw_TDC", - "Raw MDT TDC Counts", - 2*4096+1, -4096.5, 4096.5); - m_MDT_raw_TDC[station_identifier]->SetXTitle("TDC Count"); - m_MDT_raw_TDC[station_identifier - ]->SetYTitle("Entries / (0.78125 ns)"); - - m_MDT_raw_ADC[station_identifier] = - new TH1F("MDT_raw_ADC", - "Raw MDT ADC Counts", - 4096+1, -0.5, 4096.5); - m_MDT_raw_ADC[station_identifier]->SetXTitle("ADC count"); - m_MDT_raw_ADC[station_identifier - ]->SetYTitle("Entries / (0.78125 ns)"); - if (m_nb_totalEtaStrips[station_identifier]){ - m_RPC_raw_etaStrip[station_identifier] = - new TH1F("RPC_raw_etaStrip", - "Raw Hits: RPC Eta Strip; RPC Eta Strip; Entries / Strip", - m_nb_totalEtaStrips[station_identifier], - 0.5, - 0.5 + m_nb_totalEtaStrips[station_identifier]); - m_MDT_RPC_raw_tubeStripCor[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCor", - "Raw Hits: RPC Eta Strip vs. Raw MDT Tube; MDT Tube; RPC Eta Strip", - m_nb_tb[station_identifier], - 0.5, - 0.5+m_nb_tb[station_identifier], - m_nb_totalEtaStrips[station_identifier], - 0.5, - 0.5+m_nb_totalEtaStrips[station_identifier]); - m_MDT_RPC_raw_tubeStripCorVsEvent[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCorVsEvent", - "Raw Hits: (MDT Tube - RPC Strip) vs. First 100k Events; Event ; (MDT Tube - RPC strip)", - 1000, - 0.5, - 100000, - 2 * m_nb_tb[station_identifier], - -0.5 - m_nb_tb[station_identifier], - 0.5+m_nb_tb[station_identifier]); - m_MDT_RPC_raw_tubeStripCorVsEvent_adcCut[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCorVsEvent_adcCut", - "Raw Hits: (MDT Tube - RPC Strip) vs. first 100k Events (MDT ADC > 80); Event ; (MDT Tube - RPC strip)", - 1000, - 0.5, - 100000, - 2 * m_nb_tb[station_identifier], - -0.5 - m_nb_tb[station_identifier], - 0.5+m_nb_tb[station_identifier]); - m_MDT_RPC_raw_tubeStripCor_adcCut[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCor_adcCut", - "Raw RPC Eta Strip vs. Raw MDT Tube (MDT ADC > 80); MDT Tube; RPC Eta Strip", - m_nb_tb[station_identifier], - 0.5, - 0.5+m_nb_tb[station_identifier], - m_nb_totalEtaStrips[station_identifier], - 0.5, - 0.5+m_nb_totalEtaStrips[station_identifier]); - - if (m_nb_totalEtaStrips2[station_identifier]){ - m_RPC_raw_etaStrip2[station_identifier] = - new TH1F("RPC_raw_etaStrip2", - "Raw Hits: RPC Eta Strip (2nd RDoublet); RPC Eta Strip; Entries / Strip", - m_nb_totalEtaStrips2[station_identifier], - 0.5, - 0.5 + m_nb_totalEtaStrips2[station_identifier]); - m_MDT_RPC_raw_tubeStripCor2[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCor2", - "Raw Hits: RPC Eta Strip vs. Raw MDT Tube (2nd RDoublet); MDT Tube; RPC Eta Strip", - m_nb_tb[station_identifier], - 0.5, - 0.5+m_nb_tb[station_identifier], - m_nb_totalEtaStrips2[station_identifier], - 0.5, - 0.5+m_nb_totalEtaStrips2[station_identifier]); - m_MDT_RPC_raw_tubeStripCorVsEvent2[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCorVsEvent2", - "Raw Hits: (MDT Tube - RPC Strip) vs. First 100k Events (2nd RDoublet); Event ; (MDT Tube - RPC strip)", - 1000, - 0.5, - 100000, - 2 * m_nb_tb[station_identifier], - -0.5 - m_nb_tb[station_identifier], - 0.5+m_nb_tb[station_identifier]); - m_MDT_RPC_raw_tubeStripCorVsEvent_adcCut2[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCorVsEvent_adcCut2", - "Raw Hits: (MDT Tube - RPC Strip) vs. first 100k Events (MDT ADC > 80) (2nd RDoublet); Event ; (MDT Tube - RPC strip)", - 1000, - 0.5, - 100000, - 2 * m_nb_tb[station_identifier], - -0.5 - m_nb_tb[station_identifier], - 0.5+m_nb_tb[station_identifier]); - m_MDT_RPC_raw_tubeStripCor_adcCut2[station_identifier] = - new TH2F("MDT_RPC_raw_tubeStripCor_adcCut2", - "Raw RPC Eta Strip vs. Raw MDT Tube (MDT ADC > 80) (2nd RDoublet); MDT Tube; RPC Eta Strip", - m_nb_tb[station_identifier], - 0.5, - 0.5+m_nb_tb[station_identifier], - m_nb_totalEtaStrips2[station_identifier], - 0.5, - 0.5+m_nb_totalEtaStrips2[station_identifier]); - - } - - } - m_t0_diff[station_identifier] = new TH1F ("t0_diff", "", 201, -100.5, 100.5); - m_r_mintrt[station_identifier] = new TH1F ("r_min_rt", "", 101, -0.1, 0.1); - m_MDT_segment_hits[station_identifier] = - new TH1F("MDT_segments_hits", - "Number of MDT Segment Hits", - 31, -0.5, 30.5); - m_MDT_segment_hits[station_identifier - ]->SetXTitle("Number of Hits"); - m_MDT_segment_hits[station_identifier - ]->SetYTitle("Entries / Hit"); - - m_MDT_segment_hist_to_raw_hits_ratio[station_identifier] = - new TH1F("MDT_segment_hist_to_raw_hits_ratio", - "Ratio of the Number of Segments and Raw MDT Hits", - 100, -0.1, 2.1); - m_MDT_segment_hits[station_identifier - ]->SetXTitle("Ratio"); - - m_MDT_segment_CL[station_identifier] = - new TH1F("MDT_segment_CL", - "Segment Confidence Level Distribution", - 120, -0.1, 1.1); - m_MDT_segment_CL[station_identifier - ]->SetXTitle("confidence level"); - m_MDT_segment_CL[station_identifier - ]->SetYTitle("dn/dCL (1/0.01)"); - - m_MDT_segment_TDC[station_identifier] = - new TH1F("MDT_segment_TDC", - "Segment MDT Hit TDC Counts", - 2*4096+1, -4096.5, 4096.5); - m_MDT_raw_TDC[station_identifier]->SetXTitle("TDC count"); - m_MDT_raw_TDC[station_identifier - ]->SetYTitle("entries/(TDC count)"); - m_MDT_raw_TDC[station_identifier]->SetXTitle("drift time (ns)"); - m_MDT_raw_TDC[station_identifier - ]->SetYTitle("entries/(0.78125 ns)"); - - T0MTSettings *settings = new T0MTSettings; - settings->NBinsTime()=2*4096+1; - settings->TimeMin()=-4096.5*0.78125; - settings->TimeMax()=4096.5*0.78125; - settings->AddFitfun()=true; - for(unsigned int i=0; i<3; i++) - { - m_MDT_segment_tspec_ml[i][station_identifier]= new T0MTHistos(); - std::ostringstream name; - name<<"segments_ml"<<i+1; - m_MDT_segment_tspec_ml[i][station_identifier]->Initialize(i, settings, name.str().c_str()); - } - m_MDT_segment_t[station_identifier] = new TH1F("MDT_segment_t", - "Segment MDT Hit TDC Counts", - 2*4096+1, -4096.5*0.78125, 4096.5*0.78125); - m_MDT_segment_r[station_identifier] = new TH1F("MDT_segment_r", - "Segment Drift radius", - 200, -15.0, 15.0); - m_MDT_segment_hit_dis[station_identifier] = new TH1F("MDT_segment_hit_dis", - "hit distribution", - 432, -0.5, 431.5); - m_MDT_segment_t[station_identifier]->SetXTitle("Drift Time (ns)"); - m_MDT_segment_t[station_identifier - ]->SetYTitle("Entries / ns"); - - m_MDT_segment_ADC[station_identifier] = - new TH1F("MDT_segment_ADC", - "Segment MDT Hit ADC Counts", - 4096+1, -0.5, 4096.5); - m_MDT_raw_ADC[station_identifier]->SetXTitle("ADC count"); - m_MDT_raw_ADC[station_identifier - ]->SetYTitle("entries/(ADC count)"); - - m_MDT_segment_slope[station_identifier] = - new TH1F("MDT_segment_slope", - "Segment Slopes", - 181, -90.5, 90.5); - m_MDT_raw_ADC[station_identifier]->SetXTitle("slope (degrees)"); - m_MDT_raw_ADC[station_identifier - ]->SetYTitle("dn/dslope (1/degree)"); - - m_MDT_residuals[station_identifier] = - new TH2F("MDT_residuals", - "MDT residuals", - 152, -0.1, 15.1, 200, -1.0, 1.0); - m_MDT_residuals[station_identifier - ]->SetXTitle("r (mm)"); - m_MDT_residuals[station_identifier - ]->SetYTitle("residual (mm)"); - m_MDT_residuals_vs_x[station_identifier] = - new TH2F("MDT_residuals_vs_x", - "MDT residuals versus the local x coordinate", - 500, -3100.0, 3100.0, 200, -1.0, 1.0); - m_MDT_residuals_vs_x[station_identifier - ]->SetXTitle("x (mm)"); - m_MDT_residuals_vs_x[station_identifier - ]->SetYTitle("residual (mm)"); - m_MDT_r_vs_rtrack[station_identifier] = - new TH2F("MDT_r_vs_rtrack", - "MDT MDT_r_vs_rtrack", - 4000, -15.1, 15.1, 2000, 0, 15.1); - m_MDT_residuals[station_identifier - ]->SetXTitle("r (mm)"); - m_MDT_residuals[station_identifier - ]->SetYTitle("residual (mm)"); - m_MDT_t_vs_rtrack[station_identifier] = - new TH2F("MDT_t_vs_rtrack", - "MDT MDT_t_vs_rtrack", - 1000, -15.1, 15.1, 1000, -100, 800); - m_MDT_residuals[station_identifier - ]->SetXTitle("r (mm)"); - m_MDT_residuals[station_identifier - ]->SetYTitle("residual (mm)"); - - m_MDT_residuals_ml1[station_identifier] = - new TH2F("MDT_residuals_ml1", - "MDT residuals in multilayer 1", - 302, -15.1, 15.1, 200, -1.0, 1.0); - m_MDT_residuals_ml1[station_identifier - ]->SetXTitle("r (mm)"); - m_MDT_residuals_ml1[station_identifier - ]->SetYTitle("residual (mm)"); - - m_MDT_residuals_ml2[station_identifier] = - new TH2F("MDT_residuals_ml2", - "MDT residuals in multilayer 2", - 302, -15.1, 15.1, 200, -1.0, 1.0); - m_MDT_residuals_ml2[station_identifier - ]->SetXTitle("r (mm)"); - m_MDT_residuals_ml2[station_identifier - ]->SetYTitle("residual (mm)"); - - m_MDT_t0_refinement[station_identifier] = - new TH1F("MDT_t0_refinement", - "#Delta t_{0} from Segment Fit", - 901, -150.5, 150.5); - m_MDT_t0_refinement[station_identifier - ]->SetXTitle("#Delta t_{0} (ns)"); - m_MDT_t0_refinement[station_identifier - ]->SetYTitle("entries (1/ns)"); - - if(!m_refine_t0) - { - m_MDT_t_refined[station_identifier] = new - TH1F("m_MDT_t_unrefined", - "Segment MDT t without t0 refinement", - 2*4096+1, -4096.5*0.78125, 4096.5*0.78125); - - } - if (m_refine_t0) { - m_MDT_t_refined[station_identifier] = new - TH1F("m_MDT_t_refined", - "Segment MDT t t0 refined", - 2*4096+1, -4096.5*0.78125, 4096.5*0.78125); - - m_MDT_residuals_t0_refined[station_identifier] = - new TH2F("MDT_residuals_t0_refined", - "MDT residuals after t_{0} refinement", - 152, -0.1, 15.1, 200, -1.0, 1.0); - m_MDT_residuals[station_identifier - ]->SetXTitle("r (mm)"); - m_MDT_residuals[station_identifier - ]->SetYTitle("residual (mm)"); - - m_MDT_residuals_t0_refined_gt4hits[station_identifier] = - new TH2F("MDT_residuals_t0_refined_gt4hits", - "MDT residuals after t_{0} refinement for segments with more than 4 hits", - 152, -0.1, 15.1, 200, -1.0, 1.0); - m_MDT_residuals[station_identifier - ]->SetXTitle("r (mm)"); - m_MDT_residuals[station_identifier - ]->SetYTitle("residual (mm)"); - } - - m_tfile->cd(".."); - - return; - -} - - -inline double NtupleControlHistogramsTool :: getChi2(const TF1 *fun, const TH1F *hist) const - { - double chi2=0; - int n_bins_used=0; - Double_t x_min, x_max; - fun->GetRange(x_min, x_max); - for(int i=1; i<=hist->GetNbinsX(); i++) - { - double x=hist->GetBinCenter(i); - if(x<x_min || x>x_max) continue; - double diff=hist->GetBinContent(i) - fun->Eval(x); - double error=hist->GetBinError(i); - if(error<1.0) continue; - chi2+=(diff*diff)/(error*error); - n_bins_used++; - } - if(n_bins_used==0) return 9e9; - return chi2/n_bins_used; - } - - -inline double NtupleControlHistogramsTool :: getResidualChi2(TProfile *px) const - { -//loop over all bins - double chi2=0.0; - int n_bins_used=0; - for(int i=1; i<=px->GetNbinsX(); i++) - { - if(px->GetBinCenter(i)<1.0 || px->GetBinCenter(i)>14) continue; - double x = px->GetBinContent(i); - double error = px->GetBinError(i); - if(error < 1e-6 ) continue; - chi2+=x*x/(error*error); - n_bins_used++; - } - if(n_bins_used==0) return 9e9; - return chi2/n_bins_used; - } diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleCurvedAutocalibrationTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleCurvedAutocalibrationTool.cxx deleted file mode 100644 index 65dcf0a15d52031ba3e7e600c76008bff50e6715..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleCurvedAutocalibrationTool.cxx +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//MdtCalibRt -#include "MdtCalibRt/RtCalibrationCurved.h" -#include "MdtCalibRt/RtCalibrationOutput.h" -//MdtCalibData -#include "MdtCalibData/RtFullInfo.h" - -//this -#include "MuonCalibStandAloneTools/NtupleCurvedAutocalibrationTool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -namespace MuonCalib { - -NtupleCurvedAutocalibrationTool :: NtupleCurvedAutocalibrationTool(const std::string& t, const std::string& n, const IInterface* p): - AthAlgTool(t, n, p), - m_autocalibration(NULL), - m_rt_accuracy(0.5), - m_func_type("LEGENDRE"), - m_order(15), - m_fix_min(true), - m_fix_max(false), - m_max_it(100), - m_force_mono(false), - m_control_histograms(false), - m_calib_input_svc("MdtCalibInputSvc", n), - m_failed(false), - m_parabolic_extrapolation(false), - m_smoothing(false), - m_multilayer_rt_difference(false) - { - declareInterface< NtupleCalibrationTool >(this); - declareProperty("Accuracy", m_rt_accuracy); - declareProperty("FunctionType", m_func_type); - declareProperty("FunctionOrder", m_order); - declareProperty("FixMin", m_fix_min); - declareProperty("FixMax", m_fix_max); - declareProperty("MaximumIterations", m_max_it); - declareProperty("ForceMonotonous", m_force_mono); - declareProperty("ControlHistograms", m_control_histograms); - declareProperty("ParabolicExtrapolation", m_parabolic_extrapolation); - declareProperty("ConventionalSmoothing", m_smoothing); - declareProperty("MultilayerRtScale", m_multilayer_rt_difference); - declareProperty("MdtCalibInputSvc", m_calib_input_svc); - } - -StatusCode NtupleCurvedAutocalibrationTool :: initialize() - { - ATH_MSG_INFO( "initialize()" ); -//interpret functino type - if(m_func_type == "LEGENDRE") - { - m_func_type_num = 1; - } - else if (m_func_type == "CHEBYSHEV") - { - m_func_type_num = 2; - } - else if (m_func_type == "POLYGON") - { - m_func_type_num = 3; - } - else - { - ATH_MSG_FATAL( "Invalid function type '" << m_func_type << "'!" ); - return StatusCode ::FAILURE; - } - if(m_force_mono) - { - ATH_MSG_INFO( "Forcing monotonous rt-relation" ); - } -//get pointer to Calibration input service - ATH_CHECK( m_calib_input_svc.retrieve() ); - setRegion(); - return StatusCode :: SUCCESS; - } - -void NtupleCurvedAutocalibrationTool :: setRegion() - { -//retrieve rt-relationid - const IRtRelation *rt_relation(m_calib_input_svc->GetRtRelation()); - if(rt_relation == NULL) - { - ATH_MSG_FATAL( "No rt-relation stored for this region!" ); - return; - } -//create objects - ATH_MSG_INFO( "Creating RtCalibrationCurved!" ); - m_autocalibration = new RtCalibrationCurved("RT", m_rt_accuracy, - m_func_type_num, m_order, - m_fix_min, m_fix_max, m_max_it, - m_parabolic_extrapolation, - m_smoothing, - m_multilayer_rt_difference); - ATH_MSG_INFO( "setInput!" ); - m_autocalibration->setInput(new RtCalibrationOutput(rt_relation, new RtFullInfo())); - if(m_force_mono) - { - m_autocalibration->forceMonotony(); - } - if(m_control_histograms) - { - m_autocalibration-> switch_on_control_histograms("CurvedAutocalibration.root"); - } - } - -StatusCode NtupleCurvedAutocalibrationTool :: analyseSegments(const std::vector<MuonCalibSegment *> & segemnts) - { - if(m_autocalibration == NULL) - { - ATH_MSG_FATAL( "Algorithm not created!" ); - m_failed=true; - return StatusCode::FAILURE; - } - if(m_autocalibration->analyseSegments(segemnts)==NULL) - { - m_autocalibration->switch_off_control_histograms(); - m_failed=true; - return StatusCode :: FAILURE; - } - m_autocalibration->switch_off_control_histograms(); - return StatusCode::SUCCESS; - } - -const IMdtCalibrationOutput * NtupleCurvedAutocalibrationTool :: getResults() const - { - if(m_autocalibration == NULL) - { - ATH_MSG_FATAL( "Algorithm not created!" ); - return NULL; - } - if (m_failed) return NULL; - return m_autocalibration->getResults(); - } - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDBCheckTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDBCheckTool.cxx deleted file mode 100644 index 75eabd82d7dc1c6a7bb8ffffa6d062d3b53ebbb1..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDBCheckTool.cxx +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//this -#include "MuonCalibStandAloneTools/NtupleDBCheckTool.h" - -//MdtCalibIoSvc -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" - -//MuonCalibIdentifier -#include "MuonCalibIdentifier/MuonFixedId.h" - -//MuonCalibStandAloneBase -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/MdtStationT0Container.h" -# -//MdtCalibIOSvc -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - - -//MdtCalibData -#include "MdtCalibData/IRtRelation.h" - -namespace MuonCalib { - -NtupleDbCheckTool::NtupleDbCheckTool(const std::string & t, const std::string & n, const IInterface * p) - : AthAlgTool(t, n, p), m_input_service("MdtCalibInputSvc", n) - { - declareProperty("MdtCalibInputSvc", m_input_service); - declareInterface< NtupleCalibrationTool >(this); - } - - -NtupleDbCheckTool::~NtupleDbCheckTool() - { - } - -StatusCode NtupleDbCheckTool::initialize(void) - { - m_outfile = new TFile("NtupleDbCheckTool.root", "RECREATE"); - m_outtree = new TTree("tree", "tree"); - - m_outtree->Branch("station", &m_station, "station/I"); - m_outtree->Branch("eta", &m_eta, "eta/I"); - m_outtree->Branch("phi", &m_phi, "phi/I"); - m_outtree->Branch("ntuple_t0", &m_ntuple_t0, "ntuple_t0/D"); - m_outtree->Branch("calib_t0", &m_calib_t0, "calib_t0/D"); - m_outtree->Branch("ntuple_r", &m_ntuple_r, "ntuple_r/D"); - m_outtree->Branch("calib_r", &m_calib_r, "calib_r/D"); -// calibration input service // - ATH_CHECK( m_input_service.retrieve() ); - return StatusCode::SUCCESS; - } - - -StatusCode NtupleDbCheckTool::handleEvent(const MuonCalibEvent & /*event*/, int /*evnt_nb*/, const std::vector<MuonCalibSegment *> & segments, unsigned int position) - { - for(unsigned int i=position; i<segments.size(); i++) - { - MuonCalibSegment seg(*segments[i]); - for(MuonCalibSegment::MdtHitCit it=segments[i]->mdtHOTBegin(); it!= segments[i]->mdtHOTEnd(); it++) - { - const MdtCalibHitBase *hit(*it); - const MuonFixedId &hit_id(hit->identify()); - const NtupleStationId st_id(hit_id); - m_station=st_id.GetStation(); - m_eta=st_id.GetEta(); - m_phi=st_id.GetPhi(); - m_ntuple_t0=hit->tubeT0(); - const MdtStationT0Container *t0(m_input_service->GetT0(st_id)); - if(t0!=NULL) - { - m_calib_t0 = t0->t0(hit_id.mdtMultilayer(), hit_id.mdtTubeLayer(), hit_id.mdtTube()); - } - else - { - m_calib_t0=9e9; - } - const IRtRelation *rt=m_input_service-> GetRtRelation(st_id); - if(rt!=NULL) - { - m_calib_r = std::abs(rt->radius(hit->driftTime())); - } - else - { - m_calib_r = 9e9; - } - m_ntuple_r = std::abs(hit->driftRadius()); - m_outtree->Fill(); - } - } - return StatusCode::SUCCESS; - } - -StatusCode NtupleDbCheckTool::finalize(void) - { - m_outfile->Write(); - m_outfile->Close(); - return StatusCode::SUCCESS; - } - -} //namespace MuonCalib diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDisplayTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDisplayTool.cxx deleted file mode 100644 index 8e247286f64ebc41be65bf9a66036ee37b09e809..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDisplayTool.cxx +++ /dev/null @@ -1,748 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -// standard C++ // -#include <iostream> -#include <fstream> -#include <string> -#include <vector> -#include <cstdlib> -#include <sstream> - -// MuonReadoutGeometry // -#include "MuonReadoutGeometry/MdtReadoutElement.h" - -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MdtCalibInterfaces/IMdtSegmentFitter.h" - -// MuonCalib // -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MdtCalibFitters/StraightPatRec.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" - -// NtupleDisplayTool // -#include "MuonCalibStandAloneTools/NtupleDisplayTool.h" - -//this -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//root -#include "TCanvas.h" -#include "TControlBar.h" -#include "TApplication.h" -#include "TLine.h" -#include "TPaveText.h" -#include "TLatex.h" - -// STL // -#include <string> - -namespace MuonCalib { - -//***************************************************************************** - -// constructor -NtupleDisplayTool::NtupleDisplayTool( const std::string& t, - const std::string& n, - const IInterface* p) : - AthAlgTool(t, n, p), - m_reg_sel_svc("RegionSelectionSvc", n){ - - declareInterface< NtupleCalibrationTool >(this); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - - //-----------------// - //-- Job Options --// - //-----------------// - - m_fitter_name = std::string("QuasianalyticLineReconstruction"); - declareProperty("fitterName", m_fitter_name); - - m_nb_hits = 5; - declareProperty("nSegmentHits", m_nb_hits); - - m_road_width = 2.0; - declareProperty("roadWidth", m_road_width); - - m_adc_cut = 50.; - declareProperty("adcCut", m_adc_cut); - - m_chosen_event = -1; - declareProperty("displayEvent", m_chosen_event); - - m_scalefactor = 1; - declareProperty("scaleDisplay", m_scalefactor); - -} - -//::::::::::::::::::::::: -//:: METHOD initialize :: -//::::::::::::::::::::::: - -StatusCode NtupleDisplayTool::initialize() { - - ATH_MSG_INFO( "Initializing NtupleDisplayTool" ); - - - //----------------------// - //-- Set the Graphics --// - //----------------------// - - m_root = new TApplication("m_root", 0, 0, NULL, 0); - m_canvas = NULL; - m_canvas_leg = NULL; - - m_bar = new TControlBar("vertical","Display Control"); - m_bar->AddButton(" Next Event ","gApplication->Terminate()", "Go to the next event"); - m_bar->AddButton("Exit",".qqqqqqq", "Exit athena"); - - - //-----------------------------// - //-- Get the StoreGate Stuff --// - //-----------------------------// - - ATH_CHECK(m_idHelperSvc.retrieve()); - - //retrieve detector manager from the conditions store - ATH_CHECK(m_DetectorManagerKey.initialize()); - - //retrieve fixed id tool - std::string idToFixedIdToolType("MuonCalib::IdToFixedIdTool"); - std::string idToFixedIdToolName("MuonCalib_IdToFixedIdTool"); - - ATH_CHECK( toolSvc()->retrieveTool(idToFixedIdToolType, idToFixedIdToolName, m_id_tool) ); - - //---------------// - //-- Variables --// - //---------------// - - m_qfitter = NULL; - - m_nb_multilayers = -1; - m_nb_layers = -1; - m_nb_tubes = -1; - - //vector of colors to be used - m_colors = std::vector<int>(5); - m_colors[0] = 3; //segment hit - m_colors[1] = 14; //raw hit - m_colors[2] = 1; //drift radius>14.6 - m_colors[3] = 2; //adc<m_adc_cut - m_colors[4] = 0; //drift time<0 - - // tube circles - m_tube_circle = std::vector< std::vector< std::vector<TubeCircle*> > >(2); //up to two multilayers - - for (unsigned int k=0; k<m_tube_circle.size(); k++) { - - m_tube_circle[k] = std::vector< std::vector<TubeCircle*> >(4); // up to four layers per multilayer - for (unsigned int l=0; l<m_tube_circle[k].size(); l++) { - - m_tube_circle[k][l] = std::vector<TubeCircle*>(72); // up to 72 tubes per layer - for (unsigned int m=0; m<m_tube_circle[k][l].size(); m++) { - - m_tube_circle[k][l][m] = new TubeCircle(m_colors,m_adc_cut); - - } - } - } - -//get region selection service - ATH_CHECK( m_reg_sel_svc.retrieve() ); - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//:::::::::::::::::::::::: -//:: METHOD handleEvent :: -//:::::::::::::::::::::::: - -StatusCode -NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, - int eventnumber, - const std::vector<MuonCalibSegment *> &segments, - unsigned int position) { - - if(segments.size()<=position) return StatusCode::SUCCESS; - - MuonCalibSegment segment(*segments[position]); - - //if displaying only one event - if(m_chosen_event!=-1){ - if(eventnumber!=m_chosen_event){ - return StatusCode::SUCCESS; - } - } - - - //---------------// - //-- VARIABLES --// - //---------------// - - if(m_qfitter==NULL){ - if (m_fitter_name==std::string("QuasianalyticLineReconstruction")) { - m_qfitter = new QuasianalyticLineReconstruction(); - } - if (m_fitter_name==std::string("StraightPatRec")) { - m_qfitter = new StraightPatRec(); - } - if (m_fitter_name!=std::string("QuasianalyticLineReconstruction") && - m_fitter_name!=std::string("StraightPatRec")) { - ATH_MSG_FATAL( "Unknown track fitter!" ); - return StatusCode::FAILURE; - } - } - - - // station identifiers // - - MuonFixedId Mid((segment.mdtHOT()[0])->identify()); - - //this has to be set in order to get the m_detMgr->getMdtReadoutElement() method - //working correctly, otherwise also for the first multilayer, the second is returned - Mid.setMdtMultilayer(1); - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return StatusCode::FAILURE; - } - - Identifier station_id = m_id_tool->fixedIdToId(Mid); - NtupleStationId st_id((segment.mdtHOT()[0])->identify()); - st_id.SetMultilayer(0); - if (!st_id.InitializeGeometry(m_idHelperSvc->mdtIdHelper(), MuonDetMgr)) - return StatusCode::SUCCESS; - - if(m_nb_multilayers<0){ - m_nb_multilayers = m_idHelperSvc->mdtIdHelper().numberOfMultilayers(station_id); - } - - - //----------------------------// - //-- Determine the Geometry --// - //----------------------------// - - double y_min(1e6); - double z_min(1e6); - double y_max(-1e6); - double z_max(-1e6); - - if(m_tube_circle_lin.size()<1){ - - //loop over multilayers - for (int multilayer=1; multilayer<m_nb_multilayers+1; multilayer++) { - - const MuonGM::MdtReadoutElement* MdtRoEl = - MuonDetMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(station_id,multilayer,1,1) ); - - //loop over layers - for (int layer=st_id.LayerMin(multilayer-1); layer<=st_id.LayerMax(multilayer-1); layer++) { - - for (int k=st_id.TubeMin(multilayer-1); k<=st_id.TubeMax(multilayer-1); k++) { - - Amg::Vector3D TubePos = - MdtRoEl->GlobalToAmdbLRSCoords(MdtRoEl->tubePos(multilayer,layer,k)); - - //set the tube position - m_tube_circle[multilayer-1][layer-1][k-1] ->setPosition(TubePos); - m_tube_circle[multilayer-1][layer-1][k-1]->multilayer= multilayer; - m_tube_circle[multilayer-1][layer-1][k-1]->layer= layer; - m_tube_circle[multilayer-1][layer-1][k-1]->tube= k; - - m_tube_circle_lin.push_back( m_tube_circle[multilayer-1][layer-1][k-1]); - - //determine the size of the chamber - if(TubePos.y()<y_min){ - y_min = TubePos.y(); - } - if(TubePos.z()<z_min){ - z_min = TubePos.z(); - } - if(TubePos.y()>y_max){ - y_max = TubePos.y(); - } - if(TubePos.z()>z_max){ - z_max = TubePos.z(); - } - - } //for: tube - - } //for: layers - - } //for: multilayers - - } //if: size<1 - - //set the display canvas - if(m_canvas==NULL){ - - double scale(1); - if(m_nb_tubes<60){ - scale = 0.85; - } - else{ - scale = 0.56; - } - scale *= m_scalefactor; - - int canvas_size_x = std::round((y_max - y_min)*scale); //1200x500 72er 0.56, 0.71 //48er 0.85, 1.08 - int canvas_size_y = std::round((z_max - z_min)*scale*1.2); - m_canvas = new TCanvas("mdt_display", - "MDT Chamber Display" , - canvas_size_x,canvas_size_y); - m_canvas->Range(y_min-20, z_min-20.0, y_max+20.0, z_max+20.0); - m_canvas->SetFillColor(0); - m_canvas->Clear(); - m_canvas->Update(); - - //draw the control bar - m_bar->Show(); - } - - - //------------------// - //-- Segment Hits --// - //------------------// - - //check if segment has at least m_nb_hits hits (set in the job options) - if(segment.mdtHitsOnTrack()<m_nb_hits){ - return StatusCode::SUCCESS; - } - - for (unsigned int k=0; k<segment.mdtHitsOnTrack(); k++) { - - MuonFixedId id((segment.mdtHOT()[k])->identify()); - - int ml(id.mdtMultilayer()); - int ly(id.mdtTubeLayer()); - int tu(id.mdtTube()); - double radius((segment.mdtHOT()[k])->driftRadius()); - double time((segment.mdtHOT()[k])->driftTime()); - double adc((segment.mdtHOT()[k])->adcCount()); - - m_tube_circle[ml-1][ly-1][tu-1]->setSegmentHit(radius, time, adc); - - } - - - //--------------// - //-- Raw Hits --// - //--------------// - - const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); - - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { - - MuonCalibRawMdtHit *hit = *it; - MuonFixedId id(hit->identify()); - - if (m_reg_sel_svc->isInRegion(hit->identify())){ - - int ml(id.mdtMultilayer()); - int ly(id.mdtTubeLayer()); - int tu(id.mdtTube()); - double radius(hit->driftRadius()); - double time(hit->driftTime()); - double adc(hit->adcCount()); - - m_tube_circle[ml-1][ly-1][tu-1]->setRawHit(radius, time, adc); - - } - } - - - //-----------// - //-- Track --// - //-----------// - - //get track from segment - MTStraightLine track = MTStraightLine(segment.position(),segment.direction(), - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) - ); - - double y1, z1, y2, z2; - z1 = z_min-15; - z2 = z_max+15; - y1 = track.a_x2()*z1+track.b_x2(); - y2 = track.a_x2()*z2+track.b_x2(); - - TLine* line = new TLine(y1, z1, y2, z2); - line->SetLineWidth(2); - line->SetLineColor(m_colors.at(0)); - - //refit segment - bool fit_success(false); - if(m_qfitter) - { - m_qfitter->setRoadWidth(m_road_width); //0.65 - m_qfitter->switchOnRefit(); - - - fit_success = m_qfitter->fit(segment); - } - MTStraightLine track_refit(segment.position(),segment.direction(), - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0)); - - y1 = track_refit.a_x2()*z1+track_refit.b_x2(); - y2 = track_refit.a_x2()*z2+track_refit.b_x2(); - - TLine* line_refit = new TLine(y1, z1, y2, z2); - line_refit->SetLineWidth(2); - line_refit->SetLineColor(4); - - - //------------------// - //-- Build Legend --// - //------------------// - - if(m_canvas_leg==NULL){ - - - int c_x_max = 220; - int c_y_max = 260; - - double x_max = 1.6*c_x_max; - double y_max = 1.6*c_y_max; - - m_canvas_leg = new TCanvas("mdt_display_legend", "Display Legend",c_x_max,c_y_max); - m_canvas_leg->Range(0, 0, x_max, y_max); - m_canvas_leg->SetFillColor(0); - m_canvas_leg->Clear(); - m_canvas_leg->Update(); - - int offset = 40; - int leftspace = 40; - int tleftspace = 70; - double tsize = 0.065; - - TubeCircle* circle1 = new TubeCircle(m_colors,m_adc_cut); - circle1->setPosition(Amg::Vector3D(0,leftspace,y_max-offset)); - circle1->setSegmentHit(11, 1, 2*m_adc_cut); - circle1->Draw(); - - TubeCircle* circle2 = new TubeCircle(m_colors,m_adc_cut); - circle2->setPosition(Amg::Vector3D(0,leftspace,y_max-2*offset)); - circle2->setRawHit(11, 1, 2*m_adc_cut); - circle2->Draw(); - - TubeCircle* circle3 = new TubeCircle(m_colors,m_adc_cut); - circle3->setPosition(Amg::Vector3D(0,leftspace,y_max-4*offset)); - circle3->setSegmentHit(20, 1, 2*m_adc_cut); - circle3->Draw(); - - TubeCircle* circle4 = new TubeCircle(m_colors,m_adc_cut); - circle4->setPosition(Amg::Vector3D(0,leftspace,y_max-5*offset)); - circle4->setSegmentHit(14.6, -1, 2*m_adc_cut); - circle4->Draw(); - - TubeCircle* circle5 = new TubeCircle(m_colors,m_adc_cut); - circle5->setPosition(Amg::Vector3D(0,leftspace,y_max-6*offset)); - circle5->setSegmentHit(14.6, 1, 0.5*m_adc_cut); - circle5->Draw(); - m_canvas_leg->Update(); - - TLine* line_leg = new TLine(leftspace-15,y_max-8*offset,leftspace+15,y_max-8*offset); - line_leg->SetLineWidth(2); - line_leg->SetLineColor(m_colors.at(0)); - line_leg->Draw(); - - TLine* line_refit_leg = new TLine(leftspace-15,y_max-9*offset,leftspace+15,y_max-9*offset); - line_refit_leg->SetLineWidth(2); - line_refit_leg->SetLineColor(line_refit->GetLineColor()); - line_refit_leg->Draw(); - - TLine* line1_leg = new TLine(0.5*leftspace,y_max-3*offset,x_max-0.5*leftspace,y_max-3*offset); - line1_leg->SetLineWidth(1); - line1_leg->SetLineColor(16); - line1_leg->SetLineStyle(2); - line1_leg->Draw(); - - TLine* line2_leg = new TLine(0.5*leftspace,y_max-7*offset,x_max-0.5*leftspace,y_max-7*offset); - line2_leg->SetLineWidth(1); - line2_leg->SetLineColor(16); - line2_leg->SetLineStyle(2); - line2_leg->Draw(); - - - TPaveText* text1 = new TPaveText(tleftspace, y_max-offset-15, x_max, y_max-offset+15); - text1->SetFillColor(0); // text is black on white - text1->SetTextSize(tsize); - text1->SetTextAlign(12); - text1->SetBorderSize(0); - text1->AddText("Segment Hit"); - text1->Draw(); - - TPaveText* text2 = new TPaveText(tleftspace, y_max-2*offset-15, x_max, y_max-2*offset+15); - text2->SetFillColor(0); - text2->SetTextSize(tsize); - text2->SetTextAlign(12); - text2->SetBorderSize(0); - text2->AddText("Raw Hit"); - text2->Draw(); - - TPaveText* text3 = new TPaveText(tleftspace, y_max-4*offset-15, x_max, y_max-4*offset+15); - text3->SetFillColor(0); - text3->SetTextSize(tsize); - text3->SetTextAlign(12); - text3->SetBorderSize(0); - text3->AddText("Drift Radius > 14.6 mm"); - text3->Draw(); - - TPaveText* text4 = new TPaveText(tleftspace, y_max-5*offset-15, x_max, y_max-5*offset+15); - text4->SetFillColor(0); - text4->SetTextSize(tsize); - text4->SetTextAlign(12); - text4->SetBorderSize(0); - text4->AddText("Drift Time < 0"); - text4->Draw(); - - TPaveText* text5 = new TPaveText(tleftspace, y_max-6*offset-15, x_max, y_max-6*offset+15); - text5->SetFillColor(0); - text5->SetTextSize(tsize); - text5->SetTextAlign(12); - text5->SetBorderSize(0); - text5->AddText(Form("ADC < %.1f",m_adc_cut)); - text5->Draw(); - - TPaveText* text6 = new TPaveText(tleftspace, y_max-8*offset-15, x_max, y_max-8*offset+15); - text6->SetFillColor(0); - text6->SetTextSize(tsize); - text6->SetTextAlign(12); - text6->SetBorderSize(0); - text6->AddText("Track (Segment)"); - text6->Draw(); - - TPaveText* text7 = new TPaveText(tleftspace, y_max-9*offset-15, x_max, y_max-9*offset+15); - text7->SetFillColor(0); - text7->SetTextSize(tsize); - text7->SetTextAlign(12); - text7->SetBorderSize(0); - text7->AddText("Refitted Track"); - text7->Draw(); - - } - - m_canvas_leg->Update(); - m_canvas->cd(); - - - //---------------------// - //-- Draw Everything --// - //---------------------// - - ATH_MSG_INFO( "Event: " << eventnumber ); - - for (unsigned int k=0; k<m_tube_circle_lin.size(); k++) { - m_tube_circle_lin[k]->Draw(); - if(m_tube_circle_lin[k]->tube==1) - { - std::ostringstream ostr; - ostr << m_tube_circle_lin[k]->multilayer << "/" << m_tube_circle_lin[k]->layer << "/" <<m_tube_circle_lin[k]->tube; - TLatex *txt=new TLatex( m_tube_circle_lin[k]->GetX1() - 2* m_tube_circle_lin[k]->GetR1(), m_tube_circle_lin[k]->GetY1(), ostr.str().c_str()); - txt->Draw(); - ATH_MSG_INFO( ostr.str() ); - } - - } - line->Draw(); - - if(fit_success){ - line_refit->Draw(); - } - else{ - ATH_MSG_WARNING( "refit not successfull!" ); - } - - m_canvas->Update(); - m_root->Run(true); //run the TApplication - - //------------------// - //-- Reset Canvas --// - //------------------// - - //reset tube circles - for (unsigned int k=0; k<m_tube_circle_lin.size(); k++) { - m_tube_circle_lin[k]->reset(); - } - m_canvas->Clear(); - - - return StatusCode::SUCCESS; - -} - - -//***************************************************************************** - -//:::::::::::::::::::::::::::: -//:: METHOD analyseSegments :: -//:::::::::::::::::::::::::::: - -StatusCode -NtupleDisplayTool::analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/) { - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//:::::::::::::::::::::: -//:: CLASS TubeCircle :: -//:::::::::::::::::::::: - -TubeCircle::TubeCircle(void) : TEllipse(){ - - layer=0; multilayer=0; tube=0; - - this->reset(); - this->setColors(std::vector<int>(5,1)); - this->setAdcCut(50.); - - -} - -TubeCircle::TubeCircle(std::vector<int> colors, double adc_cut) : TEllipse(){ - layer=0; multilayer=0; tube=0; - - this->reset(); - this->setColors(colors); - this->setAdcCut(adc_cut); -} - - -TubeCircle::TubeCircle(Amg::Vector3D TubePos, std::vector<int> colors, double adc_cut) : TEllipse(){ - - layer=0; multilayer=0; tube=0; - this->reset(); - this->setPosition(TubePos); - this->setColors(colors); - this->setAdcCut(adc_cut); - -} - -void -TubeCircle::reset(void){ - - m_used_flag=0; - m_rawhit_flag=0; - m_segmenthit_flag=0; - - this->SetR1(14.6); - this->SetR2(14.6); - this->SetPhimin(0.0); - this->SetPhimax(360.0); - this->SetFillColor(0); - this->SetLineColor(1); - this->SetLineWidth(2); - -} - -void -TubeCircle::setPosition(Amg::Vector3D TubePos){ - - this->SetX1(TubePos.y()); - this->SetY1(TubePos.z()); - -} - -void -TubeCircle::setColors(std::vector<int> colors){ - - m_colors = colors; -} - -void -TubeCircle::setAdcCut(double adc_cut){ - - m_adc_cut = adc_cut; -} - - -void -TubeCircle::setUsedFlag(bool flag){ - - m_used_flag = flag; -} - -bool -TubeCircle::isUsed(void){ - - return m_used_flag; -} - -void -TubeCircle::setSegmentHit(double radius, double time, double adc){ - - m_segmenthit_flag = true; - this->setRadius(radius, time, adc, 0); - -} - -bool -TubeCircle::hasSegmentHit(void){ - - return m_segmenthit_flag; -} - -void -TubeCircle::setRawHit(double radius, double time, double adc){ - - m_rawhit_flag = true; - - if(!this->hasSegmentHit()){ - this->setRadius(radius, time, adc, 1); - } -} - -bool -TubeCircle::hasRawHit(void){ - - return m_rawhit_flag; -} - -void -TubeCircle::setRadius(double radius, double time, double adc, int hit){ - - if(adc<m_adc_cut){ - this->SetFillColor(m_colors.at(3)); - this->SetLineColor(m_colors.at(hit)); - } - else if(time<0){ - this->SetFillColor(m_colors.at(4)); - this->SetLineColor(m_colors.at(hit)); - } - else if(radius>14.6){ - this->SetFillColor(m_colors.at(hit)); - this->SetLineColor(m_colors.at(2)); - } - else{ - this->SetR1(radius); - this->SetR2(radius); - this->SetLineWidth(0); - this->SetLineColor(m_colors.at(hit)); - this->SetFillColor(m_colors.at(hit)); - } - - //set minimum visible radius - if(radius<2){ - this->SetR1(2); - this->SetR2(2); - } - -} - -} - diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleIntegrationTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleIntegrationTool.cxx deleted file mode 100644 index 9261a6a83b8cf060e242e821022e4c70632c05b8..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleIntegrationTool.cxx +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//RtCalibrationIntegration -#include "MdtCalibRt/RtCalibrationIntegration.h" - -//root -#include "TFile.h" - -//this -#include "MuonCalibStandAloneTools/NtupleIntegrationTool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" - -namespace MuonCalib { - - NtupleIntegrationTool::NtupleIntegrationTool(const std::string& t, - const std::string& n, - const IInterface* p):AthAlgTool(t, n, p), - m_t_max_int(710.0), - m_has_close_hits(false), - m_inner_tube_radius(14.6), - m_lower_extrapolation_radius(13.0), - m_upper_extrapolation_radius(14.0), -m_multilayer_tmax_diff(false), -p_file(NULL) - { - declareInterface< NtupleCalibrationTool >(this); - declareProperty("TMaxInt", m_t_max_int); - declareProperty("HaseCloseHits",m_has_close_hits); - declareProperty("InnerTubeRadius", m_inner_tube_radius); - declareProperty("LowerExtrapolationRadius", m_lower_extrapolation_radius); - declareProperty("UpperExtrapolationRadius", m_upper_extrapolation_radius); - declareProperty("StoreMultilayerTmaxDiff", m_multilayer_tmax_diff); - } - - -StatusCode NtupleIntegrationTool::initialize() - { - ATH_MSG_INFO( "Initializing Integration Tool" ); -//create algorithm - m_integration = new RtCalibrationIntegration("IM", - m_has_close_hits, - m_inner_tube_radius, - m_lower_extrapolation_radius, - m_upper_extrapolation_radius, m_multilayer_tmax_diff); - p_file = new TFile("Integration.root", "RECREATE"); - return StatusCode :: SUCCESS; - } - - -StatusCode NtupleIntegrationTool::handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) - { - if(m_integration == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return StatusCode :: FAILURE; - } - for(unsigned int i=position; i<segments.size(); i++) - { - if(!m_integration->handleSegment((*segments[i]))) return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; - } - - - -StatusCode NtupleIntegrationTool::analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/) - { - if(m_integration == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return StatusCode :: FAILURE; - } - if(m_integration->analyse()) - return StatusCode :: SUCCESS; - else - return StatusCode :: FAILURE; - } - -const IMdtCalibrationOutput * NtupleIntegrationTool :: getResults() const - { - return m_integration->getResults(); - } - - -StatusCode NtupleIntegrationTool :: finalize() - { - p_file->Write(); - return StatusCode::SUCCESS; - } -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleMTT0Tool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleMTT0Tool.cxx deleted file mode 100644 index cc950c792f70415213a555970e34416c128661fd..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleMTT0Tool.cxx +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//MdtCalibData -#include "MdtCalibData/MdtTubeFitContainer.h" - -//MdtCalibT0 -#include "MdtCalibT0/T0CalibrationOutput.h" -#include "MdtCalibT0/HistogramId.h" - -//this -#include "MuonCalibStandAloneTools/NtupleMTT0Tool.h" -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - - -namespace MuonCalib{ - -NtupleMTT0Tool::NtupleMTT0Tool(const std::string& t, const std::string& n, const IInterface* p) - : AthAlgTool(t, n, p), p_alg(NULL), m_reg_sel_svc("RegionSelectionSvc", n) - { - declareInterface< NtupleCalibrationTool >(this) ; - m_settings.AddFitfun()=true; - m_settings.DrawDebugGraphs()=true; - m_n_bins_neg=1000; - m_n_bins_pos=2000; - m_min_entries_time=10000; - m_min_entries_adc=1000; - declareProperty("AddFitFun", m_settings.AddFitfun()); - declareProperty("DrawDebugGraphs", m_settings.DrawDebugGraphs()); - declareProperty("NumberOfNegativeBins", m_n_bins_neg); - declareProperty("NumberOfPositiveBins", m_n_bins_pos); - declareProperty("GroupBy", m_group_by); - declareProperty("ADCGroupBy", m_adc_group_by); - m_use_top_chi2=true; - declareProperty("UseTopChi2", m_use_top_chi2); - m_scramble_thresh=2.0; - declareProperty("ScrambleThreshold", m_scramble_thresh); - m_sclicing_thresh=3.0; - declareProperty("SclicingThreshold", m_sclicing_thresh); - declareProperty("MinumumEntriesPerTimeFit", m_min_entries_time); - declareProperty("MinumumEntriesPerADCFit", m_min_entries_adc); - m_correct_rel_t0=true; - declareProperty("CorrectForRelativeT0", m_correct_rel_t0); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - } - - - -StatusCode NtupleMTT0Tool::initialize() - { - ATH_MSG_INFO( "Initializing MT T0 Tool" ); -//complete settings class - m_settings.NBinsTime()=m_n_bins_neg+m_n_bins_pos; - m_settings.TimeMin()= (25.0/32.0)*(0.5 - m_n_bins_neg); - m_settings.TimeMax()= (25.0/32.0)*(0.5 + m_n_bins_pos); - m_settings.T0Settings()->UseTopChi2() = m_use_top_chi2; - m_settings.T0Settings()->ScrambleThreshold() = m_scramble_thresh; - m_settings.T0Settings()->SlicingThreshold() = m_sclicing_thresh; - m_settings.T0Settings()->CorrectRelT0s() = m_correct_rel_t0; - m_settings.MinEntriesTime() = m_min_entries_time; - m_settings.MinEntriesADC() = m_min_entries_adc; - -//evaluate sort by arguments - m_sort_by.resize(m_group_by.size()); - for(unsigned int i=0; i<m_group_by.size(); i++) - { - if(!eval_group_by(m_group_by[i], m_sort_by[i])) - { - ATH_MSG_FATAL( "Invalid GroupBy option!" ); - return StatusCode :: FAILURE; - } - } - m_adc_sort_by.resize(m_adc_group_by.size()); - for(unsigned int i=0; i<m_adc_group_by.size(); i++) - { - if(!eval_group_by(m_adc_group_by[i], m_adc_sort_by[i])) - { - ATH_MSG_FATAL( "Invalid ADCGroupBy option!" ); - return StatusCode :: FAILURE; - } - } -//get region selection service - ATH_CHECK( m_reg_sel_svc.retrieve() ); - setRegion(); - return StatusCode :: SUCCESS; - } - -StatusCode NtupleMTT0Tool::handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) - { - if(p_alg == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return StatusCode :: FAILURE; - } - for(unsigned int i=position; i<segments.size(); i++) - { - if(!p_alg->handleSegment((*segments[i]))) return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; - } - - - -StatusCode NtupleMTT0Tool::analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/) - { - if(p_alg == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return StatusCode :: FAILURE; - } - if(p_alg->analyse()) - return StatusCode :: SUCCESS; - else - return StatusCode :: FAILURE; - } - - -void NtupleMTT0Tool::setRegion() - { - p_alg = new T0CalibrationMT("MT_t0_fitter", &m_settings, m_sort_by, m_adc_sort_by); - T0CalibrationOutput input(NULL); - for(std::vector<MuonCalib :: NtupleStationId> :: const_iterator it=m_reg_sel_svc->GetStationsInRegions().begin(); it!=m_reg_sel_svc->GetStationsInRegions().end(); it++) - { - input.GetMap()[*it]=new MdtTubeFitContainer(it->regionId(), 2, 4, 78); - } - p_alg->setInput(&input); - } - -const IMdtCalibrationOutput * NtupleMTT0Tool::getResults() const - { - if(p_alg == NULL) - { - ATH_MSG_FATAL( "Not correctly initialized!" ); - return NULL; - } - return p_alg->getResults(); - } - -inline bool NtupleMTT0Tool::eval_group_by(const std::string & group_by, int & sort_by) - { - sort_by=-99; - if(group_by == "TUBE") - { - sort_by = HistogramId :: TUBE; - return true; - } - if(group_by == "LAYER") - { - sort_by = HistogramId :: LAYER; - return true; - } - if(group_by == "MULTILAYER") - { - sort_by = HistogramId :: MULTILAYER; - return true; - } - if(group_by == "CHAMBER") - { - sort_by = HistogramId :: CHAMBER; - return true; - } - if(group_by == "MEZZ_CARD") - { - sort_by = HistogramId :: MEZZ_CARD; - return true; - } - return false; - } - - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleResidualTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleResidualTool.cxx deleted file mode 100644 index ce2572d5f28d96a92a64fe9c6351941f1e9f7f59..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleResidualTool.cxx +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" - -//MdtCalibFitters -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" - - -//this -#include "MuonCalibStandAloneTools/NtupleResidualTool.h" -//root -#include "TFile.h" -#include "TH2.h" -#include "TH1.h" - -namespace MuonCalib{ - -NtupleResidualTool::NtupleResidualTool(const std::string& t, const std::string& n, const IInterface* p): AthAlgTool(t, n, p) - { - declareInterface< NtupleCalibrationTool >(this) ; - } - - - -StatusCode NtupleResidualTool::initialize() - { - m_outfile=new TFile("Residuals.root", "RECREATE"); - m_residual_distribution = new TH2F ("residual", "residuals" , 152, -0.1, 15.1, 200, -1.0, 1.0); - m_r_spec=new TH1F("r_spec", "r_spec", 100, 0, 15); - m_chi2=new TH1F("chi2", "chi^{2}", 100, 0, 50); - m_nhits=new TH1F("nhits", "nhits", 20, -0.5, 19.5); - m_fitter=new QuasianalyticLineReconstruction(1.0); - m_fitter->switchOnRefit(); - return StatusCode::SUCCESS; - } - - -StatusCode NtupleResidualTool::handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) - { -//loop on segewmnts - for(unsigned int i=position; i<segments.size(); i++) - { - m_fitter->fit(*(segments[i])); - //loop on hits - for(std::vector<const MdtCalibHitBase*>::const_iterator it = m_fitter->trackHits().begin(); it!=m_fitter->trackHits().end(); it++) - { - double track_residual(std::abs((*it)->signedDistanceToTrack()) - (*it)->driftRadius()); - m_residual_distribution -> Fill(static_cast<Axis_t>(std::abs((*it)->signedDistanceToTrack())), static_cast<Axis_t>(track_residual)); - m_r_spec->Fill( static_cast<Axis_t>((*it)->driftRadius())); - } - m_chi2->Fill(segments[i]->chi2()); - m_nhits->Fill(segments[i]->hitsOnTrack()); - } - return StatusCode::SUCCESS; - } - -StatusCode NtupleResidualTool::finalize() - { - m_outfile->Write(); - return StatusCode::SUCCESS; - } - - - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleResidualVsTimeTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleResidualVsTimeTool.cxx deleted file mode 100644 index 63e2406db9004e23dc7df47f63c00b977fea06da..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleResidualVsTimeTool.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" -#include "MuonCalibEventBase/MuonCalibEventInfo.h" - -//MdtCalibFitters -#include "MdtCalibFitters/StraightPatRec.h" -#include "MdtCalibFitters/CurvedPatRec.h" - -//this -#include "MuonCalibStandAloneTools/NtupleResidualVsTimeTool.h" -//root -#include "TFile.h" -#include "TH2.h" -#include "cmath" - -namespace MuonCalib{ - -NtupleResidualVsTimeTool::NtupleResidualVsTimeTool(const std::string& t, const std::string& n, const IInterface* p): AthAlgTool(t, n, p) - { - declareInterface< NtupleCalibrationTool >(this) ; - m_curved_segments=false; - declareProperty("CurvedSegment", m_curved_segments); - m_min_hits=5; - declareProperty("MinHits", m_min_hits); - m_last_lumiblock=std::pair<unsigned int, unsigned int>(0,0); - m_last_residual_distribution=NULL; - } - - - -StatusCode NtupleResidualVsTimeTool::initialize() - { - m_outfile=new TFile("Residuals.root", "RECREATE"); - if(m_curved_segments) - { - CurvedPatRec *cfitter=new CurvedPatRec(); - cfitter->setTimeOut(2); - m_fitter=cfitter; - } - else - { - m_fitter=new StraightPatRec(); - } - m_fitter->setRoadWidth(2.); - return StatusCode::SUCCESS; - } - - -StatusCode NtupleResidualVsTimeTool::handleEvent(const MuonCalibEvent &event, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) - { - std::pair<unsigned int, unsigned int> current(event.eventInfo().runNumber(), event.eventInfo().lumiBlock()); -//create new histogram if needed - if(current != m_last_lumiblock || !m_last_residual_distribution) - { - m_last_lumiblock=current; - std::map<std::pair<unsigned int, unsigned int> ,TH2F *>::iterator it=m_residual_distribution.find(m_last_lumiblock); - if(it==m_residual_distribution.end()) - { - std::ostringstream nm; - nm<<"residual_r"<<m_last_lumiblock.first<<"_lb"<<m_last_lumiblock.second; - m_last_residual_distribution = new TH2F(nm.str().c_str(), "", 15, 0, 15, 200, -1.0, 1.0); - m_residual_distribution[m_last_lumiblock] = m_last_residual_distribution; - } - else - { - m_last_residual_distribution=it->second; - } - } -//loop on segewmnts - for(unsigned int i=position; i<segments.size(); i++) - { - MuonCalibSegment *seg=segments[i]; - if(seg->hitsOnTrack() < static_cast<unsigned int>(m_min_hits)) - continue; - IMdtSegmentFitter::HitSelection sel(segments[i]->hitsOnTrack(), 0); - for(unsigned int j=0; j<seg->hitsOnTrack(); j++) - { - if(j>0) - sel[j-1]=0; - sel[j]=1; - m_fitter->fit(*seg, sel); - MdtCalibHitBase *hit(seg->mdtHOT()[j]); - m_last_residual_distribution->Fill(std::abs(hit->signedDistanceToTrack()) , hit->trackResidual()); - } - } - return StatusCode::SUCCESS; - } - -StatusCode NtupleResidualVsTimeTool::finalize() - { - m_outfile->Write(); - return StatusCode::SUCCESS; - } - - - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleRunScanTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleRunScanTool.cxx deleted file mode 100644 index d05afe571c5bf431392a4771b2543422119e23fb..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleRunScanTool.cxx +++ /dev/null @@ -1,196 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//c - c++ -#include "iostream" -#include "fstream" -#include "sstream" -#include "set" -#include <string.h> - -//root -#include "TFile.h" -#include "TTree.h" -#include "TNtuple.h" - -//MuonCalibEventBase -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MuonCalibEventInfo.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" - -// MuonReadoutGeometry // -#include "MuonReadoutGeometry/MdtReadoutElement.h" - -//MuonCalibIdentifier -#include "MuonCalibIdentifier/MuonFixedId.h" - -//this -#include "MuonCalibStandAloneTools/NtupleRunScanTool.h" - -namespace MuonCalib{ - -NtupleRunScanTool::NtupleRunScanTool(const std::string& t, const std::string& n, const IInterface* p): AthAlgTool(t, n, p), m_min_hits(2000), m_max_bad_fits(0.1), m_suppress_nofit(false), m_noisy_tube_factor(1), m_time_min(std::numeric_limits<unsigned int>::max()), m_time_max(0), m_run_min(std::numeric_limits<unsigned int>::max()), m_run_max(0) - { - declareInterface< NtupleCalibrationTool >(this); - declareProperty("MinHits", m_min_hits); - declareProperty("MaxBadFits", m_max_bad_fits); - declareProperty("SuppressNofit", m_suppress_nofit); - declareProperty("NoisyTubeFactor", m_noisy_tube_factor); - } - - -StatusCode NtupleRunScanTool::initialize() - { - if(m_max_bad_fits<0 || m_max_bad_fits>1) - { - ATH_MSG_FATAL( "MaxBadFits must be between 0 and 1!" ); - return StatusCode::FAILURE; - } - ATH_CHECK(m_idHelperSvc.retrieve()); - - //retrieve detector manager from the conditions store - ATH_CHECK(m_DetectorManagerKey.initialize()); - - p_outfile = new TFile("RunScan.root", "RECREATE"); - return StatusCode :: SUCCESS; - } - - -StatusCode NtupleRunScanTool::handleEvent(const MuonCalibEvent &event, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) - { -//iov - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return StatusCode::FAILURE; - } - - const MuonCalibEventInfo & eventinfo(event.eventInfo()); - if(eventinfo.timeStamp()<m_time_min) - { - m_time_min=eventinfo.timeStamp(); - } - if(eventinfo.timeStamp()>m_time_max) - { - m_time_max=eventinfo.timeStamp(); - } - if(eventinfo.runNumber()<m_run_min) - { - m_run_min=eventinfo.runNumber(); - } - if(eventinfo.runNumber()>m_run_max) - { - m_run_max=eventinfo.runNumber(); - } - for(unsigned int i=position; i<segments.size(); i++) - { - std::set<NtupleStationId> hit_stations; - MuonCalibSegment :: MdtHitCit it(segments[i]->mdtHOTBegin()); - for(; it!=segments[i]->mdtHOTEnd(); it++) - { - NtupleStationId id((*(segments[i]->mdtHOTBegin()))->identify()); - id.SetMultilayer(0); - hit_stations.insert(id); - HitCounter &counter(m_hit_counters[id]); - if(!counter.IsInitialized()) - { - if(!id.InitializeGeometry(m_idHelperSvc->mdtIdHelper(), MuonDetMgr)) - { - ATH_MSG_FATAL( "Cannot initialize Geometry!" ); - return StatusCode::FAILURE; - } - p_outfile->cd(); - counter.Initialize(id); - } - } - for(std::set<NtupleStationId> :: iterator it=hit_stations.begin(); it!=hit_stations.end(); it++) - m_hit_counters[*it].ProcessSegment(*segments[i]); - } - return StatusCode::SUCCESS; - } - - -StatusCode NtupleRunScanTool::analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/) - { - std::ofstream header_insert_sql("header_insert.sql"); - header_insert_sql<<"insert into MDT_HEAD (implementation, lowrun, uprun, luminosity, rootfile, lowtime, uptime) values ('xX_IMPLEMENTATION_Xx', "<<m_run_min<<", "<< m_run_max <<", 1, 'xX_ROOT_FILE_Xx', "<< m_time_min <<", "<< m_time_max <<");"<<std::endl; - p_outfile->cd(); - ATH_MSG_INFO( "Location: "<<gDirectory->GetName() ); - TTree *statistics_tree=new TTree("statistics_tree", "statistics tree"); - MuonFixedId id; -//statistics tree - Int_t station, eta, phi; - char station_str[100]; - Int_t n_hits, fit_by; - char fit_by_str[100]; - Int_t n_dead_tubes, n_dead_mezz, n_dead_ml; - char software_id[100], hardware_id[100]; - statistics_tree->Branch("station", &station, "station/I"); - statistics_tree->Branch("eta", &eta, "eta/I"); - statistics_tree->Branch("phi", &phi, "phi/I"); - statistics_tree->Branch("n_hits", &n_hits, "n_hits/I"); - statistics_tree->Branch("fit_by", &fit_by, "fit_by/I"); - statistics_tree->Branch("station_str", &station_str, "station_str/C"); - statistics_tree->Branch("fit_by_str", &fit_by_str, "fit_by_str/C"); - statistics_tree->Branch("n_dead_tubes", &n_dead_tubes, "n_dead_tubes/I"); - statistics_tree->Branch("n_dead_mezz", &n_dead_mezz, "n_dead_mezz/I"); - statistics_tree->Branch("n_dead_ml", &n_dead_ml, "n_dead_ml/I"); - statistics_tree->Branch("software_id", &software_id, "software_id/C"); - statistics_tree->Branch("hardware_id", &hardware_id, "hardware_id/C"); - std::ofstream joblist("joblist.txt"); - std::ofstream initial_dq_file("initial_dq.txt"); - joblist<<"xX_STATION_Xx xX_ETA_Xx xX_PHI_Xx xX_SORT_BY_Xx"<<std::endl; - for(std::map<NtupleStationId, HitCounter> :: iterator it=m_hit_counters.begin(); it!= m_hit_counters.end(); it++) - { - p_outfile->cd(); - const std::string &output(it->second.FittingBy(m_min_hits, m_max_bad_fits)); - std::map<HitCounter::TubeId, HitCounter::DQInfo> dqinfo(it->second.InitialDQ(m_noisy_tube_factor)); - for(std::map<HitCounter::TubeId, HitCounter::DQInfo> :: const_iterator jt=dqinfo.begin(); jt!=dqinfo.end(); jt++) - { - if(jt->second.GetSeverity()>0) - { - initial_dq_file<<it->first.regionId()<<" "<< - jt->first.ml+1<<" "<<jt->first.ly+1<<" "<<jt->first.tb+1<<" "<<jt->second.GetSeverity()<<" "<<jt->second.GetNoisy()<<" "<<jt->second.GetDead()<<std::endl; - } - } - if(!m_suppress_nofit || output!="NOFIT") - joblist << id.stationNumberToFixedStationString(it->first.GetStation()) << " " << it->first.GetEta() << " " << it->first.GetPhi() << " " << output<<std::endl; - //fill tree - station = it->first.GetStation(); - strncpy(station_str, id.stationNumberToFixedStationString(it->first.GetStation()).c_str(), 99); - strncpy(fit_by_str, output.c_str(), 99); - eta = it->first.GetEta(); - phi = it->first.GetPhi(); - fit_by = it->second.FitByInt(); - n_hits = it->second.NHits(); - n_dead_tubes = it->second.NDeadTubes(); - n_dead_mezz = it->second.NDeadMezzanines(); - n_dead_ml = it->second.NDeadMultilayers(); - std::ostringstream sw_id; - std::ostringstream hw_id; - hw_id<<station_str<<std::abs(eta); - if(eta>0) - hw_id<<"A"; - else - hw_id<<"C"; - int hw_phi=phi*2; - if(station_str[2]=='L') - hw_phi-=1; - if(hw_phi<10) - hw_id<<0; - hw_id<<hw_phi; - sw_id<<station_str<<" #eta"<<eta<<" #phi"<<phi; - strncpy(software_id, sw_id.str().c_str(), 99); - strncpy(hardware_id, hw_id.str().c_str(), 99); - statistics_tree->Fill(); - } - p_outfile->cd(); - TNtuple *ntup=new TNtuple("run_range", "Range of the runs", "min:max"); - ntup->Fill(m_time_min, m_time_max); - ntup->Fill(m_run_min, m_run_max); - p_outfile->Write(); - return StatusCode::SUCCESS; - } -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleSimpleResolutionTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleSimpleResolutionTool.cxx deleted file mode 100644 index 8df0822cdbcd5ec9538ec3e69042efd501d4665c..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleSimpleResolutionTool.cxx +++ /dev/null @@ -1,827 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -// standard C++ // -#include <iostream> -#include <fstream> -#include <string> -#include <vector> -#include <cstdlib> - -// MuonCalib classes // -#include "MuonCalibEventBase/MuonCalibPattern.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" -#include "MdtCalibData/RtResolutionFromPoints.h" -#include "MdtCalibData/RtChebyshev.h" -#include "MdtCalibData/RtRelationLookUp.h" - -// NtupleSimpleResolutionTool // -#include "MuonCalibStandAloneTools/NtupleSimpleresolutionTool.h" -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -//root -#include "TFile.h" -#include "TH1.h" -#include "TH2.h" -#include "TF1.h" -#include "TGraphErrors.h" -#include "TTree.h" -#include "TProfile.h" -// HEP MATRIX // -#include "CLHEP/Matrix/Matrix.h" -#include "CLHEP/Matrix/Vector.h" - -namespace MuonCalib { - -const unsigned int NtupleSimpleResolutionTool::MAXNUMHITS=50; - -///////////////// -// Constructor // -///////////////// - -NtupleSimpleResolutionTool :: NtupleSimpleResolutionTool(const std::string& t, const std::string& -n, const IInterface* p) : AthAlgTool(t, n, p), m_final_resolution(NULL), -m_calib_input_svc("MdtCalibInputSvc", n), m_reg_sel_svc("RegionSelectionSvc", n), m_is_initialized(false) - { - declareInterface< NtupleCalibrationTool >(this); - declareProperty("MdtCalibInputSvc", m_calib_input_svc); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - m_curved = true; - declareProperty("CurvedFit", m_curved); - m_REJ_LOW = 0.1; - declareProperty("RejectLow", m_REJ_LOW); - m_REJ_TOP = 0.3; - declareProperty("RejectTop", m_REJ_TOP); - m_DELTA_CONV = 0.05; - declareProperty("DeltaConv", m_DELTA_CONV); - m_DIFF_MAX = 0.006; - declareProperty("DiffMax", m_DIFF_MAX); - m_MAX_NUM_IT = 20; - declareProperty("MaximumIterations" ,m_MAX_NUM_IT); - m_replace_with_flat = false; - declareProperty("InitialFlatResolution", m_replace_with_flat); - m_hist_fit_method = false; - declareProperty("HistFitMethod", m_hist_fit_method); - m_suppress_outliers = false; - declareProperty("SuppressOutliers", m_suppress_outliers); - m_SUPPRESS_LOW = 0.2; - declareProperty("SuppressionLow", m_SUPPRESS_LOW); - m_SUPPRESS_TOP = 0.2; - declareProperty("SuppressionTop", m_SUPPRESS_TOP); - m_spr_out_name = std::string("spr_out.root"); - declareProperty("OutputResolutionFunction", m_spr_out_name); - } - - -/////////////////////// -// METHOD initialize // -/////////////////////// - -StatusCode NtupleSimpleResolutionTool::initialize() - { - - ATH_MSG_INFO( "Initializing Simple resolution Tool" ); - //StatusCode sc; - -//get pointer to Calibration input service - ATH_CHECK( m_calib_input_svc.retrieve() ); -//get pointer to region selection service - ATH_CHECK( m_reg_sel_svc.retrieve() ); - -///////////////////// -// OTHER VARIABLES // -///////////////////// - m_MINNUMHITS = 4; - if(m_curved) m_MINNUMHITS = 5; - - m_sprgr=0; - m_sprgr_r=0; - m_number_of_segments = 0; - -//////////////////////////////////////////////////////// -// DECLARATION OF HISTOGRAMS AND NTUPLES // -//////////////////////////////////////////////////////// -// histograms // - m_residual = new TH2F("m_residual", "RESIDUALS", - RBIN, 0.0, RRANGE, RESBIN, -0.5*RESRANGE, 0.5*RESRANGE); - m_residual0 = new TH2F("m_residual0", "RESIDUALS", - RBIN, 0.0, RRANGE, RESBIN, -0.5*RESRANGE, 0.5*RESRANGE); - - m_residual2 = new TH2F("m_residual2", "RESIDUALS2", - RBIN, 0.0, RRANGE, RESBIN, -0.5*RESRANGE, 0.5*RESRANGE); - - m_residual3 = new TH2F("m_residual3", "RESIDUALS3", - RBIN, 0.0, RRANGE, RESBIN, -0.5*RESRANGE, 0.5*RESRANGE); - - m_sigma_track = new TH2F("m_sigma_track", "SIGMA OF TRACK FIT", - RBIN, 0.0, RRANGE, SBIN, 0, SRANGE); - m_sigma_track_lim = new TH2F("m_sigma_track_lim", - "SIGMA OF TRACK FIT (LIMITED)", RBIN, 0.0, RRANGE, SBIN, 0, SRANGE); - - m_is_initialized=true; - setRegion(); - return StatusCode::SUCCESS; -} - -//****************************************************************************** - -////////////////////// -// METHOD setRegion // -////////////////////// - - -void NtupleSimpleResolutionTool :: setRegion() - { - - m_rt_relation = m_calib_input_svc->GetRtRelation(); - if(m_rt_relation == NULL) - { - ATH_MSG_FATAL( "Cannot find rt-relatino for this region" ); - return; - } - } - - - -//***************************************************************************** - -/////////////////////// -// METHOD destruct // -/////////////////////// - -void NtupleSimpleResolutionTool::destruct(void) { - - if(!m_is_initialized) return; - - return; -} - -//********************************************************************* - -//////////////////////////// -// METHOD analyseSegments // -//////////////////////////// -StatusCode NtupleSimpleResolutionTool::analyseSegments(const std::vector<MuonCalibSegment *> & segments) -{ -if(segments.size() == 0) - { - ATH_MSG_FATAL( "No Segments collected!" ); - return StatusCode :: FAILURE; - } - -for(unsigned int i=0; i<segments.size(); i++) { - const MuonCalibSegment *seg=segments[i]; - - if (seg->mdtHitsOnTrack()<m_MINNUMHITS) continue; - - bool seg_rej = false; - for (unsigned int l=0;l<seg->mdtHitsOnTrack();l++) { - if (std::abs(seg->mdtHOT()[l]->driftRadius())>15.0 || - std::abs(seg->mdtHOT()[l]->driftRadius())<0.0) { - seg_rej = true; - continue; - } - } - if(seg_rej) continue; - - for (unsigned int l=0;l<seg->mdtHitsOnTrack();l++) { - if(std::abs(seg->mdtHOT()[l]->radialResidual())<0.5*RESRANGE) { - m_residual2->Fill(std::abs(seg->mdtHOT()[l]->driftRadius()), - seg->mdtHOT()[l]->radialResidual(), 1.0); - } - -// replace initial space resolution with flat 0.3 - if(m_replace_with_flat) { - seg->mdtHOT()[l]->setDriftRadius(std::abs(seg->mdtHOT()[l]->driftRadius()),0.3); - } - - } - m_number_of_segments = m_refitted_segment.size(); - m_refitted_segment.push_back(new MuonCalibSegment(*(seg))); - } - end_of_data(m_rt_relation); - - return StatusCode :: SUCCESS; -} - -//******************************************************** - -/////////////////////////// -// METHOD handle_segment // -/////////////////////////// - -void NtupleSimpleResolutionTool::handle_segment(MuonCalibSegment &seg, double *par_lim_low, -double *par_lim_upp) { - - if(seg.mdtHitsOnTrack()<m_MINNUMHITS || seg.mdtHitsOnTrack()>MAXNUMHITS) return; - bool seg_rej = false; - for (unsigned int l=0; l<seg.mdtHitsOnTrack();l++) { - if (std::abs(seg.mdtHOT()[l]->driftRadius())>15.0 || - std::abs(seg.mdtHOT()[l]->driftRadius())<0.0) { - seg_rej = true; - continue; - } - } - if(seg_rej) return; - - double dir = (seg.direction ()[1])/(seg.direction ()[2]); - for (unsigned int l=0; l<seg.mdtHitsOnTrack();l++) { - double z_exhit, y_exhit, dtty; // Locale coordinates of excluded hit - dtty=(seg.position ()[1]+dir*(seg.mdtHOT()[l]->localPosition ()[2])- - seg.mdtHOT()[l]->localPosition ()[1])/(1.0+std::pow(dir,2)); - y_exhit=seg.mdtHOT()[l]->localPosition ()[1]+dtty; - z_exhit=seg.mdtHOT()[l]->localPosition ()[2]-dtty*dir; - - double d_hit[MAXNUMHITS]; - double s2_hit[MAXNUMHITS]; - double delta_hit[MAXNUMHITS]; - bzero(d_hit, MAXNUMHITS*sizeof(double)); - bzero(s2_hit, MAXNUMHITS*sizeof(double)); - bzero(delta_hit, MAXNUMHITS*sizeof(double)); - - for (unsigned int i=0;i<seg.mdtHitsOnTrack();i++) { - if(i!=l) { - double z_hit, y_hit; // Local coordinates of hits used in refit - dtty=(seg.position ()[1]+dir*(seg.mdtHOT()[i]->localPosition ()[2])- - seg.mdtHOT()[i]->localPosition ()[1])/(1.0+std::pow(dir,2)); - y_hit=seg.mdtHOT()[i]->localPosition ()[1]+dtty; - z_hit=seg.mdtHOT()[i]->localPosition ()[2]-dtty*dir; - - d_hit[i]=std::sqrt((z_hit-z_exhit)*(z_hit-z_exhit)+(y_hit-y_exhit)*(y_hit-y_exhit))* - ((z_hit-z_exhit)/std::abs(z_hit-z_exhit)); - s2_hit[i]=seg.mdtHOT()[i]->sigma2DriftRadius(); - } - else { - d_hit[i] = 0.0; - s2_hit[i] = 100.0; // Exclusion of a hit under consideration from a track fit - } - double dtt=seg.mdtHOT()[i]->signedDistanceToTrack(); - double drad=std::abs(seg.mdtHOT()[i]->driftRadius()); - delta_hit[i]=(drad-std::abs(dtt))*dtt/std::abs(dtt); - // Exclusion of hits with huge residuals from a track fit - if(std::abs(seg.mdtHOT()[i]->radialResidual())>1.0) s2_hit[i] = 100.0; - } - - double dr_radius(0), dist_to_track(0), rad_residual(0); - double trk_sigma(0), dist_diff(0); - dr_radius = std::abs(seg.mdtHOT()[l]->driftRadius()); - dist_to_track = seg.mdtHOT()[l]->signedDistanceToTrack(); - -// Track refit (hit under consideration is excluded) - - if(trackFit(seg.mdtHitsOnTrack(), d_hit, - delta_hit, s2_hit, dist_diff, trk_sigma)) continue; - - dist_to_track = dist_to_track + dist_diff; - rad_residual = dr_radius - std::abs(dist_to_track); - double dist = std::abs(dist_to_track); - - double lim_low(0), lim_upp(0); - for(int i=0;i<6;i++) { - lim_low += par_lim_low[i]*std::pow(dist,i); - lim_upp += par_lim_upp[i]*std::pow(dist,i); - } - - if(trk_sigma<SRANGE&&dist<RRANGE&&dr_radius>0&&dr_radius<RRANGE) { - m_sigma_track->Fill(dist, trk_sigma, 1.0); - if(std::abs(rad_residual)<0.5*RESRANGE) { - m_residual3->Fill(dr_radius, rad_residual, 1.0); - } - if(trk_sigma>lim_low&&trk_sigma<lim_upp){ - m_sigma_track_lim->Fill(dist, trk_sigma, 1.0); - int nbin = int (RBIN*dist/RRANGE); - if(rad_residual>m_low[nbin] && rad_residual<m_top[nbin]) { - m_residual->Fill(dr_radius, rad_residual, 1.0); - m_residual0->Fill(dist, rad_residual, 1.0); - } - } - } - - } - - return; -} - -//***************************************************************************** - -//////////////////////// -// METHOD end_of_data // -//////////////////////// - -void NtupleSimpleResolutionTool::end_of_data(const IRtRelation * rt_rel) { - -/////////////// -// VARIABLES // -/////////////// - // double t_min(0.0), t_max(1000.0); // minimum and maximum drift time - RtResolutionFromPoints res_from_points; // class to convert look-up - // table for resolution - // functions into any existing - // format - m_sprfun = new TF1("sprfun",ttt0,0.0,RRANGE,7); - m_sprfun_r = new TF1("sprfun_r",ttt0,0.0,RRANGE,7); - -// TF1 *sprfun_old = new TF1("sprfun_old",ttt0,0.001,RRANGE,5); - TF1 *sprfun_old = new TF1("sprfun_old",ttt0,0.001,RRANGE,7); - - double delta_conv = 100; - double r_conv = 0; - unsigned int iteration(0); - - for(int it=0; (delta_conv>m_DELTA_CONV)&&(it<m_MAX_NUM_IT); it++) { - - double par_low[6] = {0,0,0,0,0,0}; - double par_upp[6] = {SRANGE,0,0,0,0,0}; - -//////////////////////////////////////////////////// -// First cycle by segments (TrkError calculation) // -//////////////////////////////////////////////////// - m_sigma_track->Reset(); - m_residual0->Reset(); - m_residual->Reset(); - - for(unsigned int j=0;j<RBIN;j++) { - m_low[j]=-0.5*RESRANGE; - m_top[j]= 0.5*RESRANGE; - } - - for (unsigned int k=0; k<m_refitted_segment.size(); k++) { - - handle_segment(*(m_refitted_segment[k]), par_low, par_upp); - - } - - trkErrorFix(par_low, par_upp); - - if(m_suppress_outliers) { - for(unsigned int j=0;j<RBIN;j++) { -// TH1D *proj_y = m_residual0->ProjectionY("_y", j+1,j+1); - TH1D *proj_y = m_residual->ProjectionY("_y", j+1,j+1); - Double_t num(0), sum_low(0), sum_top(0); - - for(unsigned int i=0;i<RESBIN;i++) { - num += proj_y->GetBinContent(i+1); - } - for(int i=0;sum_low<m_SUPPRESS_LOW*num;i++) { - sum_low += proj_y->GetBinContent(i+1); - m_low[j]= -0.5*RESRANGE + RESRANGE*i/float(RESBIN); - } - for(int i=0;sum_top<(1-m_SUPPRESS_TOP)*num;i++) { - sum_top += proj_y->GetBinContent(i+1); - m_top[j]= -0.5*RESRANGE + RESRANGE*i/float(RESBIN); - } - } - } - -/////////////////////////////////////////////////////// -// Second cycle by segments (Resolution calculation) // -/////////////////////////////////////////////////////// - m_sigma_track->Reset(); - m_sigma_track_lim->Reset(); - m_residual->Reset(); - m_residual0->Reset(); - m_residual3->Reset(); - - for (unsigned int k=0; k<m_refitted_segment.size(); k++) { - handle_segment(*(m_refitted_segment[k]), par_low, par_upp); - } - - spResCalc(true); - - for (unsigned int k=0; k<m_refitted_segment.size(); k++) { - for(unsigned int l=0;l<m_refitted_segment[k]->mdtHitsOnTrack();l++) { - double dr_radi = std::abs(m_refitted_segment[k]->mdtHOT()[l]->driftRadius()); - double sp_resol = m_sprfun_r->Eval(dr_radi); - if(sp_resol < 0.050) sp_resol = 0.050; - m_refitted_segment[k]->mdtHOT()[l]->setDriftRadius(dr_radi, sp_resol); - } - } - - if(it>0) { - delta_conv = 0; - r_conv = 0; - Double_t x[RBIN]; - for(unsigned int j=1;j<RBIN-2;j++) { - x[j]=RRANGE*(j+0.5)/float(RBIN); - double diff = std::abs((m_sprfun_r->Eval(x[j]))-(sprfun_old->Eval(x[j]))); - double d_diff = diff/std::abs(m_sprfun_r->Eval(x[j])); - if(d_diff>delta_conv && diff> m_DIFF_MAX) { - delta_conv=d_diff; - r_conv=x[j]; - } - } - } - - m_sprfun_r->Copy(*sprfun_old); - iteration=it; - ATH_MSG_INFO( "Iteration "<<iteration<<" conv "<<delta_conv<<" r_conv "<<r_conv << "\n" ); - - } - -// SpRes from DistToTrack calculation: - spResCalc(false); - - std::ofstream outfile("spr.out", std::ios::app); - outfile<<m_reg_sel_svc->GetRegionSelection()<<": NumIt-s ="<<std::setw(3)<<iteration<< - " conv ="<<std::setw(6)<<std::setprecision(2)<<delta_conv<< - " r_conv ="<<std::setw(6)<<std::setprecision(2)<<r_conv<< - " NumOfSegments ="<<std::setw(6)<<m_refitted_segment.size()<<std::endl; - outfile.close(); - - delete sprfun_old; - - ATH_MSG_INFO( m_reg_sel_svc->GetRegionSelection()<<" NumOfSegments: " - <<m_refitted_segment.size() ); - ATH_MSG_INFO( "NumOfIts "<<iteration<<" convergence "<<delta_conv<<" r_conv "<<r_conv ); - -///////////////////////////////////// writing output -// m_sfile->Write(); - - m_outfile = new TFile(m_spr_out_name.c_str(), "RECREATE"); - m_sprfun_r->Write(); - m_sprgr_r->Write(); - m_sigma_track->Write(); - m_sigma_track_lim->Write(); - m_residual->Write(); - m_residual0->Write(); - m_residual2->Write(); - - m_outfile->Close(); - if (rt_rel==NULL) - { - return; - } - -///////////////////////////////////////////////////////////////////////////// -// CONVERT THE RESOLUTION FUNCTION INTO A RESOLUTION FUNCTION DEPENDING ON // -// TIME. // -///////////////////////////////////////////////////////////////////////////// - -// get minimum and maximum drift time // - // const RtChebyshev *rt_Chebyshev( - // dynamic_cast<const RtChebyshev *>(rt_rel)); - // const RtRelationLookUp *rt_LookUp( - // dynamic_cast<const RtRelationLookUp *>(rt_rel)); - // RtChebyshev // - // if (rt_Chebyshev!=0) { - // t_min = rt_Chebyshev->tLower(); - // t_max = rt_Chebyshev->tUpper(); - // } - - // RtRelationLookUp, dangerous implementation, but the only way right now // - // if (rt_LookUp!=0) { - // t_min = rt_LookUp->par(0); - // t_max = rt_LookUp->par(1)*(rt_LookUp->nPar()-2); - // } - -// perform sigma-t fit // - std::vector<SamplePoint> point(31); - double r_min(rt_rel->radius(rt_rel->tLower())); - double r_max(rt_rel->radius(rt_rel->tUpper())); - double bin_width((r_max-r_min)/static_cast<double>(point.size()-1)); - - for (unsigned int k=0; k<point.size(); k++) { -// double sp_res_out = m_sprfun->Eval(r_min+k*bin_width); - double sp_res_out = m_sprfun_r->Eval(r_min+k*bin_width); - if(sp_res_out<0.050) sp_res_out = 0.050; - point[k].set_x2(sp_res_out); - point[k].set_error(sp_res_out); - if (k==0) { - point[k].set_x1(rt_rel->tLower()-0.2); - } else { - point[k].set_x1(t_from_r(r_min+k*bin_width, rt_rel)); - } - if (k==point.size()-1) { - point[k].set_x1(rt_rel->tUpper()+0.2); - } - } - - m_final_resolution = new RtResolutionChebyshev( - (res_from_points.getRtResolutionChebyshev( - point, 8))); - - return; -} -//*********************************************************** - -////////////////////////////////////// -// trkErrorFix // -// TrackError region selection // -////////////////////////////////////// - -int NtupleSimpleResolutionTool::trkErrorFix(double *par_l, double *par_u) { - - Double_t x[RBIN], x_err[RBIN], y_low[RBIN],y_top[RBIN], y_err[RBIN]; - TF1 *func1 = new TF1("fitf1","pol5"); - TF1 *func2 = new TF1("fitf2","pol5"); - - for(unsigned int j=0;j<RBIN;j++) { - TH1D *proj_y = m_sigma_track->ProjectionY("_y", j+1,j+1); - Double_t num(0), sum_low(0), sum_top(0); - float thr_low(0),thr_top(0); - - for(unsigned int i=0;i<SBIN;i++) { - num += proj_y->GetBinContent(i+1); - } - for(int i=0;sum_low<m_REJ_LOW*num;i++) { - sum_low += proj_y->GetBinContent(i+1); - thr_low=SRANGE*i/float(SBIN); - } - for(int i=0;sum_top<m_REJ_TOP*num;i++) { - sum_top += proj_y->GetBinContent(i+1); - thr_top=SRANGE*i/float(SBIN); - } - - if(std::abs(thr_top-thr_low)<0.006) { - thr_low=0.5*(thr_low+thr_top)-0.003; - thr_top=0.5*(thr_low+thr_top)+0.003; - } - - y_err[j]=thr_top-thr_low; - - x[j]=RRANGE*(j+0.5)/float(RBIN); - x_err[j]=(RRANGE/RBIN)/std::sqrt(12.0); - - y_low[j]=thr_low; - y_top[j]=thr_top; - - } - - TGraphErrors *gr1 = new TGraphErrors (RBIN,x,y_low,x_err,y_err); - gr1->Fit(func1,"Q","",0.001*RRANGE,0.97*RRANGE); - - TGraphErrors *gr2 = new TGraphErrors (RBIN,x,y_top,x_err,y_err); - gr2->Fit(func2,"Q","",0.001*RRANGE,0.97*RRANGE); - - func1->GetParameters (par_l); - func2->GetParameters (par_u); - - delete gr1; - delete gr2; - delete func1; - delete func2; - - return 0; -} - -//*********************************************************************** - -////////////////////////////////////// -// spResCalc // -// Spatial resolution calculation // -////////////////////////////////////// - -int NtupleSimpleResolutionTool::spResCalc(bool SfromR) { - - Double_t sigma_dr[RBIN], sigma_dr_err[RBIN]; - Double_t x[RBIN], x_err[RBIN]; - - for(unsigned int j=0;j<RBIN;j++) { - sigma_dr[j]=0.0; - sigma_dr_err[j]=0.0; - x[j]=RRANGE*(j+0.5)/float(RBIN); - x_err[j]=(RRANGE/RBIN)/std::sqrt(12.0); - } - for(unsigned int j=0;j<RBIN-1;j++) { - - TH1D *dr_y = 0; - if(SfromR) dr_y = m_residual->ProjectionY("dry_y", j+1,j+1); - else dr_y = m_residual0->ProjectionY("dry_y", j+1,j+1); - double rms_f = 0; - double sigma_tr, sigma_r, s_dr, s_tr; - Double_t entr = 0; - - if(m_hist_fit_method) { - - for(unsigned int k=0;k<RESBIN;k++) { - dr_y->SetBinError(k+1,1.0); - } - - dr_y->Fit("gaus","Q","", -1.0, 1.0); - - rms_f = dr_y->GetFunction("gaus")->GetParameter(2); - if(rms_f<0.0001) rms_f=0.0001; - - sigma_tr = m_sigma_track_lim->ProfileX()->GetBinContent(j+1); - sigma_r = rms_f*rms_f-sigma_tr*sigma_tr; - if(sigma_r<0.0001) sigma_r=0.0001; - sigma_r=std::sqrt(sigma_r); - - s_dr = dr_y->GetFunction("gaus")->GetParError(2); - s_dr = std::sqrt(s_dr*s_dr + 0.01*0.01); - s_tr = m_sigma_track_lim->ProjectionY("str_y", j+1,j+1)->GetRMS(); - - } else { - - for(unsigned int k=0;k<RESBIN;k++) { - float x_x =(float(k)+0.5-0.5*RESBIN)*(RESRANGE/RESBIN); - rms_f += x_x*x_x*(dr_y->GetBinContent(k+1)); - entr += dr_y->GetBinContent(k+1); - } - if(entr==0||rms_f==0) rms_f=0.0001; - else rms_f = std::sqrt(rms_f/entr); - - float xx_cut = 5*rms_f; - - rms_f=0; - entr = 0; - for(unsigned int k=0;k<RESBIN;k++) { - float x_x =(float(k)+0.5-0.5*RESBIN)*(RESRANGE/RESBIN); - if(std::abs(x_x)<xx_cut) { - rms_f += x_x*x_x*(dr_y->GetBinContent(k+1)); - entr += dr_y->GetBinContent(k+1); - } - } - - if(entr==0||rms_f==0) rms_f=0.0001; - else rms_f = std::sqrt(rms_f/entr); - sigma_tr = m_sigma_track_lim->ProfileX()->GetBinContent(j+1); - sigma_r = rms_f*rms_f-sigma_tr*sigma_tr; - if(sigma_r<0.0001) sigma_r=0.0001; - sigma_r=std::sqrt(sigma_r); - - s_dr = dr_y->GetRMSError(); - if(s_dr<0.00001) s_dr=0.5; - s_tr = m_sigma_track_lim->ProjectionY("str_y", j+1,j+1)->GetRMS(); - - } - - sigma_dr[j] = sigma_r; - sigma_dr_err[j] = std::sqrt(s_dr*s_dr+s_tr*s_tr); - - if(sigma_dr[j]<=0.050) sigma_dr[j]=0.050; - } - if(SfromR) { - if(m_sprgr_r) delete m_sprgr_r; - m_sprgr_r = new TGraphErrors (RBIN,x,sigma_dr,x_err,sigma_dr_err); - m_sprgr_r->SetName("sprgr_r"); - - m_sprfun_r->SetParameter(0,0.3); - m_sprfun_r->SetParLimits(0,0.1,2.0); - float rlim = 1.0/RRANGE; - m_sprfun_r->SetParameter(1,0.0); - m_sprfun_r->SetParLimits(1,0.0,2.0*rlim); - rlim = rlim/RRANGE; - m_sprfun_r->SetParameter(2,0.0); - m_sprfun_r->SetParLimits(2,-10.0*rlim,10.0*rlim); - rlim = rlim/RRANGE; - m_sprfun_r->SetParameter(3,0.0); - m_sprfun_r->SetParLimits(3,-10.0*rlim,10.0*rlim); - m_sprfun_r->SetParameter(4,4.0); - m_sprfun_r->SetParLimits(4,1.0,10.0); - m_sprfun_r->SetParameter(5,0.1); - m_sprfun_r->SetParLimits(5,0.01,2.0); - m_sprfun_r->SetParameter(6,3.0); - m_sprfun_r->SetParLimits(6,0.0,6.0); - - m_sprgr_r->Fit(m_sprfun_r,"Q","0",RRANGE*1.0/30.0,RRANGE*29.0/30.0); - } - else { - if(m_sprgr) delete m_sprgr; - m_sprgr = new TGraphErrors (RBIN,x,sigma_dr,x_err,sigma_dr_err); - m_sprgr->SetName("sprgr"); - - m_sprfun->SetParameter(0,0.3); - m_sprfun->SetParLimits(0,0.1,2.0); - float rlim = 1.0/RRANGE; - m_sprfun->SetParameter(1,0.0); - m_sprfun->SetParLimits(1,0.0,2.0*rlim); - rlim = rlim/RRANGE; - m_sprfun->SetParameter(2,0.0); - m_sprfun->SetParLimits(2,-10.0*rlim,10.0*rlim); - rlim = rlim/RRANGE; - m_sprfun->SetParameter(3,0.0); - m_sprfun->SetParLimits(3,-10.0*rlim,10.0*rlim); - m_sprfun->SetParameter(4,4.0); - m_sprfun->SetParLimits(4,1.0,10.0); - m_sprfun->SetParameter(5,0.1); - m_sprfun->SetParLimits(5,0.01,2.0); - m_sprfun->SetParameter(6,3.0); - m_sprfun->SetParLimits(6,0.0,6.0); - - m_sprgr->Fit(m_sprfun,"Q","0",RRANGE*1.0/30.0,RRANGE*29.0/30.0); - } - - return 0; -} - - - -//************************************************************ - -///////////////////// -// METHOD t_from_r // -///////////////////// - -double NtupleSimpleResolutionTool::t_from_r(const double & r, - const IRtRelation * rt_rel) { - -/////////////// -// VARIABLES // -/////////////// - - double precision(0.010); // spatial precision of the inversion - double t_max(0.0); // upper time search limit - double t_min(1000.0); // lower time search limit - -/////////////////////////////// -// DETERMINE t_min and t_max // -/////////////////////////////// - - const RtChebyshev *rt_Chebyshev( - dynamic_cast<const RtChebyshev *>(rt_rel)); - const RtRelationLookUp *rt_LookUp( - dynamic_cast<const RtRelationLookUp *>(rt_rel)); - // RtChebyshev // - if (rt_Chebyshev!=0) { - t_min = rt_Chebyshev->tLower(); - t_max = rt_Chebyshev->tUpper(); - } - - // RtRelationLookUp, dangerous implementation, but the only way right now // - if (rt_LookUp!=0) { - t_min = rt_LookUp->par(0); - t_max = rt_LookUp->par(1)*(rt_LookUp->nPar()-2); - } - -///////////////////////////////////////////// -// SEARCH FOR THE CORRESPONDING DRIFT TIME // -///////////////////////////////////////////// - - while (t_max-t_min>0.1 && - std::abs(rt_rel->radius(0.5*(t_min+t_max))-r)>precision) { - - if (rt_rel->radius(0.5*(t_min+t_max))>r) { - t_max = 0.5*(t_min+t_max); - } else { - t_min = 0.5*(t_min+t_max); - } - - } - - return 0.5*(t_min+t_max); - -} - -//************************************************************ - -////////////////////////////////////////// -// Functions for root histogram fitting // -////////////////////////////////////////// - -double NtupleSimpleResolutionTool::ttt(double *x, double *par) { - double y; - - y=0.025+x[0]*(par[4]*std::exp(-x[0]/ - (par[0]*(1+par[1]*x[0]+par[2]*x[0]*x[0]+par[3]*x[0]*x[0]*x[0])))+ - par[5]*std::exp(-x[0]*x[0]/(par[6]*par[6]))); - return y; -} - -double NtupleSimpleResolutionTool::ttt0(double *x, double *par) { - double y; - y=(par[0]-(par[0]-par[5])/(1.0+std::exp(-(x[0]-par[6])/par[4])))* - (1+par[1]*x[0]+par[2]*x[0]*x[0]+par[3]*x[0]*x[0]*x[0]); - return y; -} - -//************************************************************ - -///////////////////////////////////////////////////////////////////// -// Track Fitting Function. Calculates position of a track (shift) // -//and track error (sigma_track) at the point under consideration // -///////////////////////////////////////////////////////////////////// - -int NtupleSimpleResolutionTool::trackFit(int num_hit, double *dist_hit, double *y, - double *sigma2_hit, double &shift, double &sigma_track) { - - int NLC=2; - if(m_curved) NLC=3; - CLHEP::HepMatrix Gamma = CLHEP::HepMatrix(NLC,NLC,0); - CLHEP::HepVector betha = CLHEP::HepVector(NLC,0); - CLHEP::HepVector alpha = CLHEP::HepVector(NLC,0); - CLHEP::HepVector delta = CLHEP::HepVector(NLC,0); - - for(int k=0;k<num_hit;k++) { - if(sigma2_hit[k]<=0) return 1; - for(int i=0;i<NLC;i++) delta[i] = std::pow(dist_hit[k],i); - Gamma += (delta*delta.T())/sigma2_hit[k]; - betha += y[k]*delta/sigma2_hit[k]; - } - - int ierr(0); // Status of Matrix Inversion - Gamma.invert(ierr); - if(ierr) return 2; - alpha = Gamma*betha; - - if(std::isnan(alpha[0]) || std::isnan(Gamma[0][0])) return 2; - if(Gamma[0][0]<=0) return 2; - shift = alpha[0]; - sigma_track = std::sqrt(Gamma[0][0]); - - return 0; -} - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleTubeEfficiencyTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleTubeEfficiencyTool.cxx deleted file mode 100644 index 08c487e3cacd383195356e5a8b9ec392113806d0..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleTubeEfficiencyTool.cxx +++ /dev/null @@ -1,774 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -// standard C++ // -#include <iostream> -#include <fstream> -#include <string> -#include <vector> -#include <cstdlib> - -// MuonReadoutGeometry // -#include "MuonReadoutGeometry/RpcReadoutElement.h" -#include "MuonReadoutGeometry/MdtReadoutElement.h" - -#include "MuonCalibITools/IIdToFixedIdTool.h" -#include "MdtCalibInterfaces/IMdtSegmentFitter.h" - -// MuonCalib // -#include "MuonCalibEventBase/MuonCalibRawHitCollection.h" -#include "MuonCalibEventBase/MuonCalibRawMdtHit.h" -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MdtCalibFitters/QuasianalyticLineReconstruction.h" -#include "MuonCalibEventBase/MuonCalibEvent.h" - -// NtupleTubeEfficiencyTool // -#include "MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h" - -//this -#include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -//root -#include "TFile.h" -#include "TH1.h" -#include "TNtuple.h" -#include "TString.h" -#include "TDirectory.h" - -namespace MuonCalib { - -//***************************************************************************** - -// constructor - -NtupleTubeEfficiencyTool::NtupleTubeEfficiencyTool( const std::string& t, - const std::string& n, - const IInterface* p) : - AthAlgTool(t, n, p), m_reg_sel_svc("RegionSelectionSvc", n) { - - declareInterface< NtupleCalibrationTool >(this); - declareProperty("RegionSelectionSvc", m_reg_sel_svc); - - m_nb_hits = 5; - declareProperty("nSegmentHits", m_nb_hits); - - m_road_width = 2.0; - declareProperty("roadWidth", m_road_width); - - m_debug = false; - declareProperty("Debug", m_debug); - - m_file_name = std::string("TubeEfficiencies"); - declareProperty("fileName", m_file_name); - - m_chi2_cut = 10.0; - declareProperty("Chi2Cut", m_chi2_cut); - - m_exclude_layer = false; - declareProperty("excludeLayer", m_exclude_layer); - -} - -//::::::::::::::::: -//:: METHOD init :: -//::::::::::::::::: - -StatusCode NtupleTubeEfficiencyTool::initialize() { - - ATH_MSG_INFO( "Initializing NtupleTubeEfficiencyTool" ); - - //-----------------------------// - //-- Get the StoreGate Stuff --// - //-----------------------------// - - ATH_CHECK( m_idHelperSvc.retrieve() ); - - //retrieve detector manager from the conditions store - ATH_CHECK(m_DetectorManagerKey.initialize()); - - //retrieve fixed id tool - std::string idToFixedIdToolType("MuonCalib::IdToFixedIdTool"); - std::string idToFixedIdToolName("MuonCalib_IdToFixedIdTool"); - - ATH_CHECK( toolSvc()->retrieveTool(idToFixedIdToolType, idToFixedIdToolName, m_id_tool) ); - - //get region selection service - ATH_CHECK( m_reg_sel_svc.retrieve() ); - - //----------------------------------// - //-- Create Root Files and Histos --// - //----------------------------------// - - TDirectory* workdir = gDirectory; - m_tfile = new TFile(TString(m_file_name)+".root", "RECREATE"); - - if(m_debug){ - - m_tfile_debug = new TFile(TString(m_file_name)+"_debug.root", "RECREATE"); - - ATH_MSG_INFO( "NtupleTubeEfficiencyTool: Debug mode is switched on" ); - - m_hit_ntuple = new TNtuple("hit_ntuple", "MDT HIT NTUPLE", - "event_nb:station:eta:phi:ml:layer:tube:w_x:w_y:w_z:x:t:r:d"); - } - - - m_qfitter = NULL; - - m_nb_trigger = 0; - - m_nb_multilayers = -1; - m_nb_layers = -1; - m_nb_tubes = -1; - - if(m_debug){ - m_tfile_debug->cd(); - } - else{ - workdir->cd(); - } - - //control histos - - m_h_chi2 = new TH1F("h_chi2", "", 500, 0, 100); - - m_h_distance = new TH1F("h_distance", - "distance between track and wire", - 150, 0, 15); - m_h_nb_hit_tubes = new TH1I("h_nb_hit_tubes", - "nb of hit tubes in exluded layer", - 51, 0, 50); - - - //efficiency and fakerate histos (per tube) - - m_h_efficiency = std::vector< std::vector< std::vector<TH1F*> > >(2); //up to two multilayers - - for (unsigned int k=0; k<m_h_efficiency.size(); k++) { - - m_h_efficiency[k] = std::vector< std::vector<TH1F*> >(4); // up to four layers per multilayer - for (unsigned int l=0; l<m_h_efficiency[k].size(); l++) { - - m_h_efficiency[k][l] = std::vector<TH1F*>(72); // up to 72 tubes per layer - for (unsigned int m=0; m<m_h_efficiency[k][l].size(); m++) { - - m_h_efficiency[k][l][m] - = new TH1F( Form("efficiency_%i_%i_%i",k+1,l+1,m+1), - "Efficiency", 2, -0.5, 1.5) ; - } - } - } - - - m_h_fakerate = std::vector< std::vector< std::vector<TH1F*> > >(2); //up to two multilayers - - for (unsigned int k=0; k<m_h_fakerate.size(); k++) { - - m_h_fakerate[k] = std::vector< std::vector<TH1F*> >(4); // up to four layers per multilayer - for (unsigned int l=0; l<m_h_fakerate[k].size(); l++) { - - m_h_fakerate[k][l] = std::vector<TH1F*>(72); // up to 72 tubes per layer - for (unsigned int m=0; m<m_h_fakerate[k][l].size(); m++) { - - m_h_fakerate[k][l][m] - = new TH1F( Form("fakerate_%i_%i_%i",k+1,l+1,m+1), - "Fakerate", 2, -0.5, 1.5) ; - - } - } - } - - //efficiency and fakerate histos (per layer) - - m_tfile->cd(); - - m_h_tube_efficiency = std::vector< std::vector<TH1F*> >(2); //up to two multilayers - for (unsigned int k=0; k<m_h_tube_efficiency.size(); k++) { - - m_h_tube_efficiency[k] = std::vector<TH1F*>(4); // up to four layers per multilayer - for (unsigned int l=0; l<m_h_tube_efficiency[k].size(); l++) { - - m_h_tube_efficiency[k][l] - = new TH1F( Form("tube_efficiency_%i_%i",k+1,l+1), - "Tube Efficiency", 72, 0.5, 72.5) ; - - m_h_tube_efficiency[k][l]->GetXaxis()->SetTitle("Tube"); - m_h_tube_efficiency[k][l]->GetYaxis()->SetTitle("Efficiency"); - m_h_tube_efficiency[k][l]->SetMarkerStyle(8); - } - } - - m_h_tube_fakerate = std::vector< std::vector<TH1F*> >(2); //up to two multilayers - for (unsigned int k=0; k<m_h_tube_fakerate.size(); k++) { - - m_h_tube_fakerate[k] = std::vector<TH1F*>(4); // up to four layers per multilayer - for (unsigned int l=0; l<m_h_tube_fakerate[k].size(); l++) { - - m_h_tube_fakerate[k][l] - = new TH1F( Form("tube_fakerate_%i_%i",k+1,l+1), - "Tube Fakerate", 72, 0.5, 72.5) ; - - m_h_tube_fakerate[k][l]->GetXaxis()->SetTitle("Tube"); - m_h_tube_fakerate[k][l]->GetYaxis()->SetTitle("Fakerate"); - m_h_tube_fakerate[k][l]->SetMarkerStyle(8); - - } - } - - - //entry histos (per layer) - - m_h_tube_entries_efficiency = std::vector< std::vector<TH1F*> >(2); //up to two multilayers - for (unsigned int k=0; k<m_h_tube_entries_efficiency.size(); k++) { - - m_h_tube_entries_efficiency[k] = std::vector<TH1F*>(4); // up to four layers per multilayer - for (unsigned int l=0; l<m_h_tube_entries_efficiency[k].size(); l++) { - - m_h_tube_entries_efficiency[k][l] - = new TH1F( Form("tube_entries_efficiency_%i_%i",k+1,l+1), - "Tube Entries Efficiency", 72, 0.5, 72.5) ; - - m_h_tube_entries_efficiency[k][l]->GetXaxis()->SetTitle("Tube"); - m_h_tube_entries_efficiency[k][l]->GetYaxis()->SetTitle("Entries"); - } - } - - m_h_tube_entries_fakerate = std::vector< std::vector<TH1F*> >(2); //up to two multilayers - for (unsigned int k=0; k<m_h_tube_entries_fakerate.size(); k++) { - - m_h_tube_entries_fakerate[k] = std::vector<TH1F*>(4); // up to four layers per multilayer - for (unsigned int l=0; l<m_h_tube_entries_fakerate[k].size(); l++) { - - m_h_tube_entries_fakerate[k][l] - = new TH1F( Form("tube_entries_fakerate_%i_%i",k+1,l+1), - "Tube Entries Fakerate", 72, 0.5, 72.5) ; - - m_h_tube_entries_fakerate[k][l]->GetXaxis()->SetTitle("Tube"); - m_h_tube_entries_fakerate[k][l]->GetYaxis()->SetTitle("Entries"); - } - } - - - //efficiency and fakerate histos (per chamber) - - m_h_layer_efficiency = new TH1F("layer_efficiency", "Layer Efficiency", 8, 0.5, 8.5); - m_h_chamber_efficiency = new TH1F("chamber_efficiency", "Chamber Efficiency", 3, -0.5, 2.5); - - m_h_layer_efficiency->GetXaxis()->SetTitle("Layer"); - m_h_layer_efficiency->GetYaxis()->SetTitle("Efficiency"); - m_h_layer_efficiency->SetMarkerStyle(8); - - m_h_chamber_efficiency->GetYaxis()->SetTitle("Efficiency"); - m_h_chamber_efficiency->SetMarkerStyle(8); - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//::::::::::::::::::::: -//:: METHOD finalize :: -//::::::::::::::::::::: - -StatusCode NtupleTubeEfficiencyTool::finalize(void) { - - ATH_MSG_INFO( "Finalizing NtupleTubeEfficiencyTool" ); - - m_tfile->Write(); - if(m_debug){ - m_tfile_debug->Write(); - } - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//:::::::::::::::::::::::: -//:: METHOD handleEvent :: -//:::::::::::::::::::::::: - -StatusCode -NtupleTubeEfficiencyTool::handleEvent( const MuonCalibEvent & event, - int eventnumber, - const std::vector<MuonCalibSegment *> &segments, - unsigned int position) { - - if(segments.size()<=position) return StatusCode::SUCCESS; - - MuonCalibSegment segment(*segments[position]); - - //---------------// - //-- Variables --// - //---------------// - - m_nb_trigger++; - - if(m_qfitter==NULL){ - m_qfitter = new QuasianalyticLineReconstruction(); - } - - - int nb_hits; - - // station identifiers // - - MuonFixedId Mid((segment.mdtHOT()[0])->identify()); - - //this has to be set in order to get the m_detMgr->getMdtReadoutElement() method working correctly - //otherwise also for the first multilayer, the second is returned - Mid.setMdtMultilayer(1); - - Identifier station_id = m_id_tool->fixedIdToId(Mid); - - - if(m_nb_multilayers<0){ - m_nb_multilayers = m_idHelperSvc->mdtIdHelper().numberOfMultilayers(station_id); - } - - - //----------// - //-- Hits --// - //----------// - - if(segment.mdtHitsOnTrack()<m_nb_hits){ - return StatusCode::SUCCESS; - } - - if(m_debug){ - - for (unsigned int k=0; k<segment.mdtHitsOnTrack(); k++) { - - MuonFixedId id((segment.mdtHOT()[k])->identify()); - - m_hit_ntuple->Fill(eventnumber, - id.stationName(), id.eta(), id.phi(), - id.mdtMultilayer(), id.mdtTubeLayer(), - id.mdtTube(), - (segment.mdtHOT()[k])->localPosition().x(), - (segment.mdtHOT()[k])->localPosition().y(), - (segment.mdtHOT()[k])->localPosition().z(), - (segment.mdtHOT()[k])->distanceToReadout(), - (segment.mdtHOT()[k])->driftTime(), - (segment.mdtHOT()[k])->driftRadius(), - (segment.mdtHOT()[k])->signedDistanceToTrack()); - - } - } - - //----------------// - //-- Efficiency --// - //----------------// - - m_qfitter->setRoadWidth(m_road_width); //0.65 - m_qfitter->switchOnRefit(); - - SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; - const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); - if(MuonDetMgr==nullptr){ - ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); - return StatusCode::FAILURE; - } - - //loop over multilayers - for (int multilayer=1; multilayer<m_nb_multilayers+1; multilayer++) { - - const MuonGM::MdtReadoutElement* MdtRoEl = - MuonDetMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(station_id,multilayer,1,1) ); - - if(m_nb_layers<0) m_nb_layers = MdtRoEl->getNLayers(); - if(m_nb_tubes<0) m_nb_tubes = MdtRoEl->getNtubesperlayer(); - - //loop over layers - for (int layer=1; layer<m_nb_layers+1; layer++) { - - nb_hits = 0; - - // hit selection vector for refits - IMdtSegmentFitter::HitSelection - hit_selection = IMdtSegmentFitter::HitSelection(segment.mdtHitsOnTrack()); - - - //exclude layer: layer in multilayer: multilayer // - - for (unsigned int l=0; l<segment.mdtHitsOnTrack(); l++) { - - MuonFixedId id((segment.mdtHOT()[l])->identify()); - - if (id.mdtMultilayer() == multilayer && - id.mdtTubeLayer() == layer) { - - hit_selection[l] = 1; - - } else { - - hit_selection[l] = 0; - nb_hits = nb_hits+1; - } - } - - if(m_exclude_layer){ - - m_h_chi2->Fill(m_qfitter->chi2PerDegreesOfFreedom()); - - if (!m_qfitter->fit(segment, hit_selection)) { - continue; - } - if (m_qfitter->numberOfTrackHits()<3) { - continue; - } - if(m_qfitter->chi2PerDegreesOfFreedom()>m_chi2_cut){ - continue; - } - - }else{ - - m_h_chi2->Fill(segment.chi2()); - - if(segment.chi2()>m_chi2_cut){ - continue; - } - } - - // find tube which has been traversed by the track // - - MTStraightLine track; - - if(m_exclude_layer){ - track = m_qfitter->track(); - } - else{ - track = MTStraightLine(segment.position(),segment.direction(), - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) - ); - } - - std::vector<int> traversed_tube(0); - - for (int k=0; k<m_nb_tubes; k++) { - - Amg::Vector3D TubePos = - MdtRoEl->GlobalToAmdbLRSCoords(MdtRoEl->tubePos(multilayer,layer,k+1)); - - Amg::Vector3D tube_position = Amg::Vector3D(TubePos.x(), TubePos.y(), TubePos.z()); - Amg::Vector3D tube_direction = Amg::Vector3D(1,0,0); - - MTStraightLine tube = MTStraightLine( tube_position, tube_direction, - Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) - ); - - double distance = std::abs(track.signDistFrom(tube)); - - if ( distance < (MdtRoEl->innerTubeRadius()) ){ - traversed_tube.push_back(k+1); - m_h_distance->Fill(distance); - } - } - - m_h_nb_hit_tubes->Fill(traversed_tube.size()); - - - // check whether the traversed tubes give a hit // - - //collect raw hits in the excluded layer // - const MuonCalibRawHitCollection *raw_hits(event.rawHitCollection()); - - std::vector<int> hit_tube(0); - - for (MuonCalibRawHitCollection::MuonCalibRawMdtHitVecCit it= - raw_hits->rawMdtHitCollectionBegin(); - it!=raw_hits->rawMdtHitCollectionEnd(); ++it) { - - MuonCalibRawMdtHit *hit = *it; - - if (m_reg_sel_svc->isInRegion(hit->identify()) && - (hit->identify()).mdtMultilayer() == multilayer && - (hit->identify()).mdtTubeLayer() == layer) { - - hit_tube.push_back( (hit->identify()).mdtTube() ); - - } - } - - // Efficiencies // - - //loop over traversed tubes - for (unsigned int k=0; k<traversed_tube.size(); k++) { - - int hit_flag = 0; - - //loop over hit tubes - for (unsigned int j=0; j<hit_tube.size(); j++) { - - if(traversed_tube[k]==hit_tube[j]){ - hit_flag = 1; - break; - } - } - - m_h_efficiency[multilayer-1][layer-1][ traversed_tube[k]-1 ]->Fill(hit_flag); - } - - - // Fakerate // - - //loop over hit tubes - for (unsigned int k=0; k<hit_tube.size(); k++) { - - int fake_flag = 0; - - //loop over traversed tubes - for (unsigned int j=0; j<traversed_tube.size(); j++) { - - if(hit_tube[k]!=traversed_tube[j]){ - fake_flag = 1; - } - } - - m_h_fakerate[multilayer-1][layer-1][ hit_tube[k]-1 ]->Fill(fake_flag); - } - - - } //end of loop over layers - - } //end of loop over multilayers - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - -//:::::::::::::::::::::::::::: -//:: METHOD analyseSegments :: -//:::::::::::::::::::::::::::: - -StatusCode -NtupleTubeEfficiencyTool::analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/) { - - std::string outfilename = m_file_name + ".txt"; - - std::ofstream outfile(outfilename.c_str()); - outfile << "ml \t ly \t tube \t efficiency \t error \t fakerate \t ferror" << std::endl; - - //initialize summary variables - - int chamber_ntubes; - double chamber_efficiency; - double chamber_error; - double chamber_entries; - - std::vector<int> multilayer_ntubes(m_nb_multilayers); - std::vector<double> multilayer_efficiency(m_nb_multilayers); - std::vector<double> multilayer_error(m_nb_multilayers); - std::vector<double> multilayer_entries(m_nb_multilayers); - - std::vector<std::vector<int> > layer_ntubes(m_nb_multilayers, std::vector<int>(m_nb_layers)); - std::vector<std::vector<double> > layer_efficiency(m_nb_multilayers, std::vector<double>(m_nb_layers)); - std::vector<std::vector<double> > layer_error(m_nb_multilayers, std::vector<double>(m_nb_layers)); - std::vector<std::vector<double> > layer_entries(m_nb_multilayers, std::vector<double>(m_nb_layers)); - - chamber_ntubes = 0; - chamber_efficiency = 0.; - chamber_error = 0.; - chamber_entries = 0; - - for (int k=0; k<m_nb_multilayers; k++) { - - multilayer_ntubes[k] = 0; - multilayer_efficiency[k] = 0.; - multilayer_error[k] = 0.; - multilayer_entries[k] = 0; - - for (int l=0; l<m_nb_layers; l++) { - layer_ntubes[k][l] = 0; - layer_efficiency[k][l] = 0.; - layer_error[k][l] = 0.; - layer_entries[k][l] = 0; - } - } - - //calculate and fill tube efficiencies - - //loop over multilayers - for (int k=0; k<m_nb_multilayers; k++) { - - //loop over layers - for (int l=0; l<m_nb_layers; l++) { - - //loop over tubes - for (int m=0; m<m_nb_tubes; m++) { - - //calculate efficiency, fakerate and errors - - double efficiency = m_h_efficiency[k][l][m]->GetMean(); - double entries = m_h_efficiency[k][l][m]->GetEntries(); - double error = 0.; - - if(entries!=0){ - error = ( 1/std::sqrt(entries) ) * std::sqrt( efficiency*(1-efficiency) ); - } - - double fakerate = m_h_fakerate[k][l][m]->GetMean() / (double)m_nb_trigger; - double fentries = m_h_fakerate[k][l][m]->GetEntries(); - double ferror = 0; - - if(fentries!=0){ - ferror = ( 1/std::sqrt(fentries) ) * std::sqrt( fakerate*(1-fakerate) ); - } - - - //fill histos - - TString title = "Tube Efficiency "; - title += TString(m_reg_sel_svc->GetRegionSelection()); - title += Form(" (ml%i, ly%i)",k+1,l+1); - - m_h_tube_efficiency[k][l]->SetTitle(title); - m_h_tube_fakerate[k][l]->SetTitle(title.ReplaceAll("Efficiency","Fakerate")); - - m_h_tube_efficiency[k][l]->SetBinContent(m+1,efficiency); - m_h_tube_efficiency[k][l]->SetBinError(m+1,error); - - m_h_tube_fakerate[k][l]->SetBinContent(m+1,fakerate); - m_h_tube_fakerate[k][l]->SetBinError(m+1,ferror); - - m_h_tube_efficiency[k][l]->GetXaxis()->SetRange(1,m_nb_tubes); - m_h_tube_fakerate[k][l]->GetXaxis()->SetRange(1,m_nb_tubes); - - - //write text file - - outfile << k+1 << "\t" << l+1 << "\t" << m+1 << "\t" - << Form("%1.3f",efficiency) << "\t" - << Form("%1.3f",error) << "\t" - << Form("%1.8f",fakerate) << "\t" - << Form("%1.3f",ferror) << std::endl; - - - //entry histos - - TString entry_title = "Tube Entries (Efficiency) "; - entry_title += TString(m_reg_sel_svc->GetRegionSelection()); - entry_title += Form(" (ml%i, ly%i)",k+1,l+1); - - m_h_tube_entries_efficiency[k][l]->SetTitle(entry_title); - m_h_tube_entries_fakerate[k][l]->SetTitle(entry_title.ReplaceAll("Efficiency","Fakerate")); - - m_h_tube_entries_efficiency[k][l]->SetBinContent(m+1,entries); - m_h_tube_entries_fakerate[k][l]->SetBinContent(m+1,fentries); - - m_h_tube_entries_efficiency[k][l]->GetXaxis()->SetRange(1,m_nb_tubes); - m_h_tube_entries_fakerate[k][l]->GetXaxis()->SetRange(1,m_nb_tubes); - - //summarized efficiencies - if(error>0){ - - layer_ntubes[k][l]++; - layer_efficiency[k][l] += 1./std::pow(error,2)*efficiency; - layer_error[k][l] += 1./std::pow(error,2); - layer_entries[k][l] += entries; - - multilayer_ntubes[k]++; - multilayer_efficiency[k] += 1./std::pow(error,2)*efficiency; - multilayer_error[k] += 1./std::pow(error,2); - multilayer_entries[k] += entries; - - chamber_ntubes++; - chamber_efficiency += 1./std::pow(error,2)*efficiency; - chamber_error += 1./std::pow(error,2); - chamber_entries += entries; - - } - } - } - } - - //fill summary histos - TString layer_title = "Layer Efficiency "; - layer_title += TString(m_reg_sel_svc->GetRegionSelection()); - - m_h_layer_efficiency->SetTitle(layer_title); - m_h_layer_efficiency->GetXaxis()->SetRange(1,m_nb_multilayers*m_nb_layers); - - TString chamber_title = "Efficiency "; - chamber_title += TString(m_reg_sel_svc->GetRegionSelection()); - - m_h_chamber_efficiency->SetTitle(chamber_title); - m_h_chamber_efficiency->GetXaxis()->SetRange(1,m_nb_multilayers+1); - - int layer_bin = 1; - int chamber_bin = 2; - - for (int k=0; k<m_nb_multilayers; k++) { - - for (int l=0; l<m_nb_layers; l++) { - - double layer_eff = 0.; - double layer_err = 0.; - - if(layer_error[k][l]>0){ - layer_eff = layer_efficiency[k][l]/layer_error[k][l]; - layer_err = std::sqrt(1./layer_error[k][l]); - } - - m_h_layer_efficiency->SetBinContent(layer_bin, layer_eff); - m_h_layer_efficiency->SetBinError(layer_bin, layer_err); - - layer_bin++; - } - - double ml_eff = 0.; - double ml_err = 0.; - - if(multilayer_error[k]>0){ - ml_eff = multilayer_efficiency[k]/multilayer_error[k]; - ml_err = std::sqrt(1./multilayer_error[k]); - } - - m_h_chamber_efficiency->SetBinContent(chamber_bin, ml_eff); - m_h_chamber_efficiency->SetBinError(chamber_bin, ml_err); - m_h_chamber_efficiency->GetXaxis()->SetBinLabel(chamber_bin, TString(Form("ml%i",k+1)).Data()); - - chamber_bin++; - } - - double ch_eff = 0.; - double ch_err = 0.; - - if(chamber_error>0){ - ch_eff = chamber_efficiency/chamber_error; - ch_err = std::sqrt(1./chamber_error); - } - - m_h_chamber_efficiency->SetBinContent(1, ch_eff); - m_h_chamber_efficiency->SetBinError(1, ch_err); - m_h_chamber_efficiency->GetXaxis()->SetBinLabel(1,"chamber"); - m_h_chamber_efficiency->LabelsOption("d"); - - - //delete not used histos - - for (int k=0; k<2; k++) { //multilayers - - for (int l=0; l<4; l++) { //layers - - if(k>m_nb_multilayers-1 || l>m_nb_layers-1){ - delete m_h_tube_efficiency[k][l]; - delete m_h_tube_fakerate[k][l]; - delete m_h_tube_entries_efficiency[k][l]; - delete m_h_tube_entries_fakerate[k][l]; - } - } - } - - - return StatusCode::SUCCESS; - -} - -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleWireCentricity.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleWireCentricity.cxx deleted file mode 100644 index 925c391bb7b7d3243b62f23ad40056931bd5edad..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleWireCentricity.cxx +++ /dev/null @@ -1,214 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -// standard C++ // -#include <iostream> -#include <fstream> - -//root -#include "TFile.h" -#include "TH1.h" -#include "TF1.h" - -// MuonCalibEventBase // -#include "MuonCalibEventBase/MuonCalibSegment.h" -#include "MuonCalibEventBase/MdtCalibHitBase.h" - -//this - #include "MuonCalibStandAloneTools/NtupleWireCentricityTool.h" - - -//MdtCalibT0 -#include "MdtCalibT0/T0MTHistos.h" -#include "MdtCalibT0/T0MTSettings.h" - - -//MdtCalibIOSvc -#include "MdtCalibIOSvc/MdtCalibInputSvc.h" - -//MdtcalibData -#include "MdtCalibData/IRtRelation.h" - - -namespace MuonCalib { - -///////////////// -// Constructor // -///////////////// - -NtupleWireCentricityTool :: NtupleWireCentricityTool(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t, n, p), m_min_track_slope(0.6), m_region_width(8e8), m_calib_input_svc("MdtCalibInputSvc", n) - { - declareInterface< NtupleCalibrationTool >(this) ; - declareProperty("MinTrackSlope", m_min_track_slope); - declareProperty("RegionWidth", m_region_width); - declareProperty("MdtCalibInputSvc", m_calib_input_svc); - } - - -//////////////// -// initialize // -//////////////// - -StatusCode NtupleWireCentricityTool :: initialize() - { - ATH_MSG_INFO( "Initializing NtupleWireCentricityTool" ); - - -//create root file and histograms - p_root_file = new TFile("WireCentricity.root", "RECREATE"); - p_dt_spec_left = new TH1F("p_dt_spec_left", "", 1701, -200.5 * (25.0 / 32.0), 1500.5 * (25.0 / 32.0)); - p_dt_spec_right = new TH1F("p_dt_spec_right", "", 1701, -200.5 * (25.0 / 32.0), 1500.5 * (25.0 / 32.0)); - p_dt_spec_above = new TH1F("p_dt_spec_above", "", 1701, -200.5 * (25.0 / 32.0), 1500.5 * (25.0 / 32.0)); - p_dt_spec_below = new TH1F("p_dt_spec_below", "", 1701, -200.5 * (25.0 / 32.0), 1500.5 * (25.0 / 32.0)); - m_track_radius = new TH1F("track_radius", "", 200, -16.0, 16.0); - p_track_slope_cut = new TH1F("track_slope_cut", "", 1000, 0, 3); - p_track_slope = new TH1F("track_slope", "", 1000, -3, 3); - m_x_coordinate = new TH1F("x_coordinate", "", 4000, -2000, 2000); - - ATH_MSG_INFO( "tool initialized." ); -//get calibration input service - ATH_CHECK( m_calib_input_svc.retrieve() ); - setRegion(); - return StatusCode::SUCCESS; - } - - -///////////////// -// handleEvent // -///////////////// - -StatusCode NtupleWireCentricityTool :: handleEvent(const MuonCalibEvent &/*event*/, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) - { - for(unsigned int i=position; i<segments.size(); i++) - { - //chaeck for minimal track inclination - // !!not valid for end-cap chambers!! - const MuonCalibSegment *seg(segments[i]); - double track_slope(seg->direction().y() / seg->direction().z()); - if(std::isnan(track_slope)) continue; - p_track_slope->Fill(track_slope); - - //loop on all track hits - for(MuonCalibSegment::MdtHitCit it = seg->mdtHOTBegin(); it!=seg->mdtHOTEnd(); it++) - { - const MdtCalibHitBase *hit=(*it); - process_hit(hit, track_slope); - } - for(MuonCalibSegment::MdtHitCit it = seg->mdtCloseHitsBegin(); it!=seg->mdtCloseHitsEnd(); it++) - { - const MdtCalibHitBase *hit=(*it); - process_hit(hit, track_slope); - } - } - return StatusCode::SUCCESS; - } - - -//////////////////// -//analyseSegments // -//////////////////// - -StatusCode NtupleWireCentricityTool :: analyseSegments(const std::vector<MuonCalibSegment *> & /*segemnts*/) - { - T0MTHistos histos; - T0MTSettings settings; - settings.AddFitfun()=true; - settings.DrawDebugGraphs()=true; - std::ofstream summary_file; -//create summary tree - TTree *summary_tree=new TTree("summary_tree", ""); - summary_tree->Branch("station", &m_station, "station/I"); - summary_tree->Branch("eta", &m_eta, "eta/I"); - summary_tree->Branch("phi", &m_phi, "phi/I"); - summary_tree->Branch("hw_phi", &m_hw_phi, "hw_phi/I"); - summary_tree->Branch("mean_track_slope", &m_mean_track_slope, "mean_track_slope/D"); - summary_tree->Branch("n_hits", &m_n_hits, "n_hits/I"); - summary_tree->Branch("drift_velocity", &m_drift_velocity, "drift_velocity/D"); - Double_t l_above(9e9), l_below(9e9); - summary_tree->Branch("l_above", &l_above, "l_above/D"); - summary_tree->Branch("l_below", &l_below, "l_below/D"); - - Double_t mean_x(m_x_coordinate->GetMean()); - Double_t all_mean_slope(p_track_slope->GetMean()); - summary_tree->Branch("mean_x", &mean_x, "mean_x/D"); - summary_tree->Branch("all_mean_slope", &all_mean_slope, "all_mean_slope/D"); - Int_t n_hits_above(static_cast<Int_t>(p_dt_spec_above->GetEntries())), n_hits_below(static_cast<Int_t>(p_dt_spec_below->GetEntries())); - summary_tree->Branch("n_hits_above", &n_hits_above, "n_hits_above/I"); - summary_tree->Branch("n_hits_below", &n_hits_below, "n_hits_below/I"); - - Double_t l_left(9e9), l_right(9e9); - summary_tree->Branch("l_left", &l_left, "l_left/D"); - summary_tree->Branch("l_right", &l_right, "l_right/D"); - - m_n_hits = static_cast<Int_t>(p_track_slope_cut->GetEntries()); - m_mean_track_slope = p_track_slope_cut->GetMean(); - histos.SetTSpec(0, p_dt_spec_left, &settings); - if(histos.FitT0()) - { - if(histos.FitTmax()) - l_left=histos.GetTMaxFunction()-> GetParameter(T0MTHistos :: TMAX_PAR_NR_TMAX) - histos.GetT0Function()->GetParameter(T0MTHistos :: T0_PAR_NR_T0); - } - histos.SetTSpec(1, p_dt_spec_right, &settings); - if(histos.FitT0()) - { - if(histos.FitTmax()) - l_right=histos.GetTMaxFunction()-> GetParameter(T0MTHistos :: TMAX_PAR_NR_TMAX) - histos.GetT0Function()->GetParameter(T0MTHistos :: T0_PAR_NR_T0); - } - histos.SetTSpec(2, p_dt_spec_below, &settings); - if(histos.FitT0()) - { - if(histos.FitTmax()) - l_above=histos.GetTMaxFunction()-> GetParameter(T0MTHistos :: TMAX_PAR_NR_TMAX) - histos.GetT0Function()->GetParameter(T0MTHistos :: T0_PAR_NR_T0); - } - histos.SetTSpec(3, p_dt_spec_above, &settings); - if(histos.FitT0()) - { - if(histos.FitTmax()) - l_below=histos.GetTMaxFunction()-> GetParameter(T0MTHistos :: TMAX_PAR_NR_TMAX) - histos.GetT0Function()->GetParameter(T0MTHistos :: T0_PAR_NR_T0); - } - ATH_MSG_INFO( "Summary:" ); - ATH_MSG_INFO( "left/right: "<<l_left - l_right <<" ns " << (l_left - l_right)*m_drift_velocity << "mm: slope is "<<p_track_slope->GetMean() ); - ATH_MSG_INFO( "above/below: "<<l_above - l_below <<" ns " << (l_above - l_below)*m_drift_velocity << "mm: slope is "<<m_mean_track_slope ); - summary_tree->Fill(); - p_root_file->Write(); - - return StatusCode::SUCCESS; - } - -void NtupleWireCentricityTool :: setRegion() - { - const IRtRelation *rtrel=m_calib_input_svc->GetRtRelation(); - if(rtrel==NULL) return; - m_drift_velocity = rtrel->driftvelocity(rtrel->tUpper() - 50); - ATH_MSG_INFO( "Drift velocity is "<<m_drift_velocity ); - } - -inline void NtupleWireCentricityTool :: process_hit(const MdtCalibHitBase * hit, const double & track_slope) - { - double r_track=hit->signedDistanceToTrack(); - m_track_radius->Fill(r_track); - m_x_coordinate->Fill(hit->localPosition().x()); - if(std::abs(hit->localPosition().x())>m_region_width/2) return; - //fill right left histograms - if(r_track<0) - p_dt_spec_left->Fill(static_cast<Axis_t>(hit-> driftTime())); - else - p_dt_spec_right->Fill(static_cast<Axis_t>(hit-> driftTime())); - //check for track slope - if(std::abs(track_slope) < m_min_track_slope) return; - if((r_track < 0 && track_slope < 0) || (r_track > 0 && track_slope > 0)) - { - p_dt_spec_below->Fill(static_cast<Axis_t>(hit-> driftTime())); - } - else - { - p_dt_spec_above->Fill(static_cast<Axis_t>(hit-> driftTime())); - } - p_track_slope_cut->Fill(std::abs(track_slope)); - m_station=hit->identify().stationName(); - m_eta=hit->identify().eta(); - m_phi=hit->identify().phi(); - m_hw_phi=m_phi * 2 - (m_station % 2); - } -} diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/components/MuonCalibStandAloneTools_entries.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/components/MuonCalibStandAloneTools_entries.cxx deleted file mode 100644 index 1df9a40a0b5b3a2a2b8d21ed46a3cb3cd466d370..0000000000000000000000000000000000000000 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/components/MuonCalibStandAloneTools_entries.cxx +++ /dev/null @@ -1,36 +0,0 @@ -#include "MuonCalibStandAloneTools/NtupleMTT0Tool.h" -#include "MuonCalibStandAloneTools/NtupleCalibADCTool.h" -#include "MuonCalibStandAloneTools/NtupleClassicT0Tool.h" -#include "MuonCalibStandAloneTools/NtupleIntegrationTool.h" -#include "MuonCalibStandAloneTools/NtupleAnalyticAutocalibrationTool.h" -#include "MuonCalibStandAloneTools/NtupleSimpleresolutionTool.h" -#include "MuonCalibStandAloneTools/NtupleChisqResolutionTool.h" -#include "MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h" -#include "MuonCalibStandAloneTools/NtupleRunScanTool.h" -#include "MuonCalibStandAloneTools/NtupleControlHistogramsTool.h" -#include "MuonCalibStandAloneTools/NtupleResidualTool.h" -#include "MuonCalibStandAloneTools/NtupleDisplayTool.h" -#include "MuonCalibStandAloneTools/NtupleWireCentricityTool.h" -#include "MuonCalibStandAloneTools/NtupleCurvedAutocalibrationTool.h" -#include "MuonCalibStandAloneTools/NtupleDBCheckTool.h" -#include "MuonCalibStandAloneTools/NtupleResidualVsTimeTool.h" - -using namespace MuonCalib; - -DECLARE_COMPONENT( NtupleMTT0Tool ) -DECLARE_COMPONENT( NtupleCalibADCTool ) -DECLARE_COMPONENT( NtupleClassicT0Tool ) -DECLARE_COMPONENT( NtupleIntegrationTool ) -DECLARE_COMPONENT( NtupleAnalyticAutocalibrationTool ) -DECLARE_COMPONENT( NtupleChisqResolutionTool ) -DECLARE_COMPONENT( NtupleSimpleResolutionTool ) -DECLARE_COMPONENT( NtupleTubeEfficiencyTool ) -DECLARE_COMPONENT( NtupleRunScanTool ) -DECLARE_COMPONENT( NtupleControlHistogramsTool ) -DECLARE_COMPONENT( NtupleResidualTool ) -DECLARE_COMPONENT( NtupleDisplayTool ) -DECLARE_COMPONENT( NtupleWireCentricityTool ) -DECLARE_COMPONENT( NtupleCurvedAutocalibrationTool ) -DECLARE_COMPONENT( NtupleDbCheckTool ) -DECLARE_COMPONENT( NtupleResidualVsTimeTool ) - diff --git a/Projects/Athena/package_filters.txt b/Projects/Athena/package_filters.txt index e4bfa72fa677aeb520df2040746d9f0216b176c7..5530f3b9e71993f334456547ea88cabe95ab926a 100644 --- a/Projects/Athena/package_filters.txt +++ b/Projects/Athena/package_filters.txt @@ -63,13 +63,3 @@ # Old packages that don't work with AthenaMT - LArCalorimeter/LArSim - PhysicsAnalysis/HiggsPhys/HSG5/HSG5DPDUtils - -# some MDT calibration tools which might be removed from athena, disable compilation -- MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibDbAsciiTool -- MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibTools -- MuonSpectrometer/MuonCalib/MdtCalib/MdtCalibValidation -- MuonSpectrometer/MuonCalib/MuonCalibAlgs -- MuonSpectrometer/MuonCalib/MuonCalibJobTransforms -- MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg -- MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools -- MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools