diff --git a/Control/CalypsoExample/TrackerDataAccessExample/CMakeLists.txt b/Control/CalypsoExample/TrackerDataAccessExample/CMakeLists.txt index 365f884fe9009d64c6665bed8cfac529881c66bd..81fea4e212bfe5b9e03aa2725a8f9ac68a678412 100644 --- a/Control/CalypsoExample/TrackerDataAccessExample/CMakeLists.txt +++ b/Control/CalypsoExample/TrackerDataAccessExample/CMakeLists.txt @@ -11,3 +11,10 @@ atlas_add_component( TrackerDataAccessExample LINK_LIBRARIES AthenaBaseComps TrackerRawData ) atlas_install_python_modules( python/*.py ) + +# Test(s) in the package: +atlas_add_test( TrackerDataAccessTest + SCRIPT python/TrackerDataAccessExampleConfig.py ${CMAKE_CURRENT_SOURCE_DIR} + PROPERTIES TIMEOUT 300 ) + + diff --git a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py old mode 100644 new mode 100755 index e4dcd1c1abb13e44df6c8b538affed91ea107ca2..0a2d083a8d0ca8a201bf9b34e4e8947289b57666 --- a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py +++ b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py @@ -1,10 +1,14 @@ +#!/usr/bin/env python + # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -#!/usr/bin/env python import sys from AthenaConfiguration.ComponentFactory import CompFactory from AthenaCommon.Constants import VERBOSE, INFO +Cmake_working_dir = sys.argv[1] +print("Cmake_working_dir = ", Cmake_working_dir) + def TrackerDataAccessExampleCfg(flags, name="TrackerDataAccessExampleAlg", **kwargs): from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg @@ -36,7 +40,7 @@ if __name__ == "__main__": ConfigFlags.GeoModel.FaserVersion = "FASER-01" # FASER geometry ConfigFlags.Input.ProjectName = "data20" # Needed to bypass autoconfig ConfigFlags.GeoModel.Align.Dynamic = False - ConfigFlags.Input.Files = ["cosmics.raw"] + ConfigFlags.Input.Files = [f"{Cmake_working_dir}/../rawdata/Faser-Physics-001920-filtered.raw"] #path is set to test data for ctest ConfigFlags.Output.RDOFileName = "my.RDO.pool.root" ConfigFlags.lock() diff --git a/Control/CalypsoExample/TriggerDataAccessExample/CMakeLists.txt b/Control/CalypsoExample/TriggerDataAccessExample/CMakeLists.txt index 3f8b3f195d33210c6c90cb5e9ee726aecf1d14ac..7d0275a8985377f72a4b120f652b98c32110ec4c 100644 --- a/Control/CalypsoExample/TriggerDataAccessExample/CMakeLists.txt +++ b/Control/CalypsoExample/TriggerDataAccessExample/CMakeLists.txt @@ -11,3 +11,9 @@ atlas_add_component( TriggerDataAccessExample LINK_LIBRARIES AthenaBaseComps xAODFaserTrigger ) atlas_install_python_modules( python/*.py ) + +# Test(s) in the package: +atlas_add_test( TriggerDataAccessTest + SCRIPT python/TriggerDataAccessExampleConfig.py ${CMAKE_CURRENT_SOURCE_DIR} + PROPERTIES TIMEOUT 300 ) + diff --git a/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py b/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py old mode 100644 new mode 100755 index ffab4e9f96e55f559f92fc305de1a6c230ca224d..737d03721f09409e6d88e83dadd2e618cbedd600 --- a/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py +++ b/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py @@ -1,10 +1,14 @@ +#!/usr/bin/env python + # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -#!/usr/bin/env python import sys from AthenaConfiguration.ComponentFactory import CompFactory from AthenaCommon.Constants import VERBOSE, INFO +Cmake_working_dir = sys.argv[1] +print("Cmake_working_dir = ", Cmake_working_dir) + def TriggerDataAccessExampleCfg(flags, name="TriggerDataAccessExampleAlg", **kwargs): from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg @@ -36,7 +40,7 @@ if __name__ == "__main__": ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry ConfigFlags.Input.ProjectName = "data20" ConfigFlags.GeoModel.Align.Dynamic = False - ConfigFlags.Input.Files = ["cosmics.raw"] + ConfigFlags.Input.Files = [f"{Cmake_working_dir}/../rawdata/Faser-Physics-001920-filtered.raw"] #path is set to test data for ctest ConfigFlags.Output.RDOFileName = "trigger.RDO.pool.root" ConfigFlags.lock() diff --git a/Control/CalypsoExample/WaveformDataAccessExample/CMakeLists.txt b/Control/CalypsoExample/WaveformDataAccessExample/CMakeLists.txt index 54626a0a27793e20e595a4dd4d4aef585f1e6c2d..69bfbf2e24d75088351f75892d627d60e1ad302a 100644 --- a/Control/CalypsoExample/WaveformDataAccessExample/CMakeLists.txt +++ b/Control/CalypsoExample/WaveformDataAccessExample/CMakeLists.txt @@ -11,3 +11,9 @@ atlas_add_component( WaveformDataAccessExample LINK_LIBRARIES AthenaBaseComps ScintRawEvent ) atlas_install_python_modules( python/*.py ) + +# Test(s) in the package: +atlas_add_test( WaveformDataAccessTest + SCRIPT python/WaveformDataAccessExampleConfig.py ${CMAKE_CURRENT_SOURCE_DIR} + PROPERTIES TIMEOUT 300 ) + diff --git a/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py b/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py old mode 100644 new mode 100755 index d46ef74914deec6275f1e477888328a536004b55..5d0cfcdeaaac4f96e094b635138edf66466208e2 --- a/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py +++ b/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py @@ -1,10 +1,14 @@ +#!/usr/bin/env python + # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -#!/usr/bin/env python import sys from AthenaConfiguration.ComponentFactory import CompFactory from AthenaCommon.Constants import VERBOSE, INFO +Cmake_working_dir = sys.argv[1] +print("Cmake_working_dir = ", Cmake_working_dir) + def WaveformDataAccessExampleCfg(flags, name="WaveformDataAccessExampleAlg", **kwargs): from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg @@ -36,7 +40,7 @@ if __name__ == "__main__": ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry ConfigFlags.Input.ProjectName = "data20" ConfigFlags.GeoModel.Align.Dynamic = False - ConfigFlags.Input.Files = ["cosmics.raw"] + ConfigFlags.Input.Files = [f"{Cmake_working_dir}/../rawdata/Faser-Physics-001920-filtered.raw"] #path is set to test data for ctest ConfigFlags.Output.RDOFileName = "waveform.RDO.pool.root" ConfigFlags.lock() diff --git a/Control/CalypsoExample/rawdata/Faser-Physics-001920-filtered.raw b/Control/CalypsoExample/rawdata/Faser-Physics-001920-filtered.raw new file mode 100644 index 0000000000000000000000000000000000000000..eecc1b6dc76b0d430312eaf999d95429d63bc6c9 Binary files /dev/null and b/Control/CalypsoExample/rawdata/Faser-Physics-001920-filtered.raw differ diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py b/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py index e645c94bc676149dd92ee6b4357f73f23b462f95..0820c0ad2e863b540776c8ce14612235138fb2a2 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py +++ b/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py @@ -18,11 +18,14 @@ def _setupGeoModel(): from GeoModelSvc.GeoModelSvcConf import GeoModelSvc geoModelSvc = GeoModelSvc() svcMgr += geoModelSvc - theApp.CreateSvc += [ "GeoModelSvc"] + theApp.CreateSvc += [ "GeoModelSvc" ] + + DDversion = jobproperties.Global.DetDescrVersion() # Set up detector tools here - if not hasattr(svcMgr,'NeutrinoGeometryDBSvc'): + + if "FaserNu" in DDversion and not hasattr(svcMgr,'NeutrinoGeometryDBSvc'): from GeometryDBSvc.GeometryDBSvcConf import GeometryDBSvc svcMgr+=GeometryDBSvc("NeutrinoGeometryDBSvc") @@ -39,9 +42,10 @@ def _setupGeoModel(): svcMgr+=GeometryDBSvc("CaloGeometryDBSvc") # from AthenaCommon import CfgGetter - from EmulsionGeoModel.EmulsionGeoModelConf import EmulsionDetectorTool - emulsionDetectorTool = EmulsionDetectorTool(DetectorName = "Emulsion", Alignable = True, RDBAccessSvc = "RDBAccessSvc", GeometryDBSvc = "NeutrinoGeometryDBSvc", GeoDbTagSvc = "GeoDbTagSvc") - geoModelSvc.DetectorTools += [ emulsionDetectorTool ] + if "FaserNu" in DDversion: + from EmulsionGeoModel.EmulsionGeoModelConf import EmulsionDetectorTool + emulsionDetectorTool = EmulsionDetectorTool(DetectorName = "Emulsion", Alignable = True, RDBAccessSvc = "RDBAccessSvc", GeometryDBSvc = "NeutrinoGeometryDBSvc", GeoDbTagSvc = "GeoDbTagSvc") + geoModelSvc.DetectorTools += [ emulsionDetectorTool ] from VetoGeoModel.VetoGeoModelConf import VetoDetectorTool vetoDetectorTool = VetoDetectorTool( DetectorName = "Veto", @@ -79,6 +83,20 @@ def _setupGeoModel(): geoModelSvc.DetectorTools += [ faserSCTDetectorTool ] +# Deal with SCT alignment conditions folders and algorithms + + conddb.addFolderSplitOnline("SCT","/Tracker/Onl/Align","/Tracker/Align",className="AlignableTransformContainer") + from AthenaCommon.AlgSequence import AthSequencer + condSeq = AthSequencer("AthCondSeq") + if not hasattr(condSeq, "FaserSCT_AlignCondAlg"): + from FaserSCT_ConditionsAlgorithms.FaserSCT_ConditionsAlgorithmsConf import FaserSCT_AlignCondAlg + condSeq += FaserSCT_AlignCondAlg(name = "FaserSCT_AlignCondAlg", + UseDynamicAlignFolders = False) + if not hasattr(condSeq, "FaserSCT_DetectorElementCondAlg"): + from FaserSCT_ConditionsAlgorithms.FaserSCT_ConditionsAlgorithmsConf import FaserSCT_DetectorElementCondAlg + condSeq += FaserSCT_DetectorElementCondAlg(name = "FaserSCT_DetectorElementCondAlg") + + from DipoleGeoModel.DipoleGeoModelConf import DipoleTool dipoleTool = DipoleTool( RDBAccessSvc = "RDBAccessSvc", GeometryDBSvc = "TrackerGeometryDBSvc", diff --git a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx index 64e263a8bb64ad5730e1a53358e63631d0d2d67d..8695ec12b9233fff232a3759e78891d8f8caeb90 100644 --- a/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx +++ b/Event/FaserByteStreamCnvSvc/src/FaserByteStreamInputSvc.cxx @@ -57,7 +57,7 @@ FaserByteStreamInputSvc::FaserByteStreamInputSvc( , m_eventInfoKey (this, "EventInfoKey", "EventInfo", "Key of EventInfo in metadata store") { - assert(pSvcLocator != nullptr); + assert(svcloc != nullptr); declareProperty("EventStore", m_storeGate); //declareProperty("MetaDataStore", m_inputMetadata); diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FillFromStringUtility.h b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FillFromStringUtility.h index 6e445fcc875e87dde1b298f5d1f2f5fa4bc3b387..5fb67fa0a0383231aa13b97a385fbe08865cc175 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FillFromStringUtility.h +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms/src/FillFromStringUtility.h @@ -28,6 +28,8 @@ namespace { const Tokenizer::iterator end{tok.end()}; int j{0}; for (Tokenizer::iterator i{tok.begin()}; i!=end; ++i) { + if (j == userContainer.size()) + break; try { userContainer[j]=boost::lexical_cast<V_t>(*i); } catch (const boost::bad_lexical_cast&) { diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/CMakeLists.txt b/Tracker/TrackerRecAlgs/NoisyStripFinder/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..29e80551e078ae78985801f204169932da2dcb94 --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/CMakeLists.txt @@ -0,0 +1,21 @@ +################################################################################ +# Package: NoisyStripFinder +################################################################################ + +# Declare the package name: +atlas_subdir( NoisyStripFinder ) + +# Component(s) in the package: +atlas_add_component( NoisyStripFinder + src/*.cxx src/*.h + src/components/*.cxx + LINK_LIBRARIES AthenaBaseComps StoreGateLib SGtests Identifier GaudiKernel TrackerRawData TrackerPrepRawData FaserDetDescr TrackerIdentifier + TrackerReadoutGeometry AthViews FaserSCT_ConditionsData xAODFaserTrigger ) + +# Install files from the package: +#atlas_install_headers( TrackerPrepRawDataFormation ) + +atlas_install_python_modules( python/*.py ) + +#atlas_install_scripts( test/*.py ) + diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/python/NoisyStripFinderConfig.py b/Tracker/TrackerRecAlgs/NoisyStripFinder/python/NoisyStripFinderConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..5e94a1fb0e944666f4f245e8f47bc1100fcd6929 --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/python/NoisyStripFinderConfig.py @@ -0,0 +1,22 @@ +""" +Copyright (C) 2021 CERN for the benefit of the FASER collaboration +""" + +from AthenaConfiguration.ComponentFactory import CompFactory +from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg + + +def NoisyStripFinderBasicCfg(flags, **kwargs): + acc = FaserSCT_GeometryCfg(flags) + kwargs.setdefault("DataObjectName", "SCT_RDOs") + kwargs.setdefault("OutputHistRootName", "NoisyStripFinderHist.root") + kwargs.setdefault("TriggerMask", 0x10) + Tracker__NoisyStripFinder = CompFactory.Tracker.NoisyStripFinder + acc.addEventAlgo(Tracker__NoisyStripFinder(**kwargs)) + return acc + + +def NoisyStripFinderCfg(flags, **kwargs): + acc = NoisyStripFinderBasicCfg(flags, **kwargs) + return acc + diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/python/__init__.py b/Tracker/TrackerRecAlgs/NoisyStripFinder/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderHist_Analysis.py b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderHist_Analysis.py new file mode 100644 index 0000000000000000000000000000000000000000..349316b31446434c1ad41f58ba2c269e4ce0a93a --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/share/NoisyStripFinderHist_Analysis.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +# This script combines the strip occupancy histograms from NoisyStripFinderHist.root files then it generates a pdf with sumarry plots and an XML file with a list of noisy strips + +# Set up (Py)ROOT. +import ROOT +import xml.etree.ElementTree as ET + +ROOT.gStyle.SetOptStat(0) #take away option box in histograms +ROOT.gStyle.SetOptTitle(1) +#ROOT.gROOT.SetStyle("ATLAS") + +def GetKeyNames( self ): # gets a list of object names in a root file + return [key.GetName() for key in f.GetListOfKeys()] +ROOT.TFile.GetKeyNames = GetKeyNames + +numEvents = 0 +nfiles = 0 +HistDict = {} + +ROOT.TH1.AddDirectory(0) # This is necessary in order to have the histogram data after closing the file + +for inputfile in ["./NoisyStripFinderHist.root"]: + print("opening root file ",inputfile) + f = ROOT.TFile.Open(inputfile, "r") + numEvents += f.Get("numEvents").GetVal() + if nfiles == 0: + trigger = f.Get("trigger").GetVal() + for rootkey in f.GetKeyNames(): + if rootkey == 'numEvents' or rootkey == 'trigger': + continue # skip over the root objects TParameters that store the trigger and number of events data + if rootkey in HistDict: # if sensor histogram has already been stored, then add to it + HistDict[rootkey].Add(f.Get(rootkey),1.0) + else: # if sensor histogram has not already been stored, then store this histogram + HistDict[rootkey] = f.Get(rootkey).Clone() + + nfiles += 1 + + # Good to cleanup + f.Close() + +print("Total # of root files analyzed = ", nfiles) +print("Trigger mask = ", trigger) +print("Total number of events = ", numEvents) + +# Now make some plots +filename = "NoisyStripFinderHist_Analysis.pdf" + +c = ROOT.TCanvas() +c.Print(filename+'[') + +for dictkey in HistDict: + c = ROOT.TCanvas() + c.Divide(1,2) + c.cd(1) + tempHist = HistDict[dictkey].Clone() + tempHist.Draw("") + c.cd(2) + HistDict[dictkey].Scale(1.0/float(numEvents)) # Normalize histrograms by total event number in order to get occupancies + HistDict[dictkey].GetYaxis().SetTitle("Strip Occupancy") + HistDict[dictkey].Draw("") +# ROOT.gPad.SetLogy() + c.Print(filename) + +c.Print(filename+']') # Must close file at the end + +# Now make an XML file to store noisy strip data +root = ET.Element('NoisyStripData') +for dictkey in HistDict: + sensorhash = ET.SubElement(root, "Sensor_Hash") + sensorhash.text = dictkey + bini = 1 + while bini <= 768: + if HistDict[dictkey].GetBinContent(bini) >= 0.1 : + strip = ET.SubElement(sensorhash, "Strip") + strip.text = str(bini - 1) # strip number is offset by histogram bin number by 1 because of underflow bin + occupancy = ET.SubElement(strip, "Occupancy") + occupancy.text = str(HistDict[dictkey].GetBinContent(bini)) + bini += 1 + +tree = ET.ElementTree(root) +tree.write("NoisyPixels.xml") + diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.cxx b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.cxx new file mode 100644 index 0000000000000000000000000000000000000000..71598696beb29fa13256f18193738eaee2b38ee5 --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.cxx @@ -0,0 +1,143 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +#include "NoisyStripFinder.h" + +#include "FaserDetDescr/FaserDetectorID.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerRawData/FaserSCT_RDO_Container.h" +#include "TrackerRawData/FaserSCT_RDORawData.h" +#include "StoreGate/WriteHandle.h" + +#include <sstream> +#include <string.h> +#include <list> +#include <TH1.h> +#include <TFile.h> +#include <TParameter.h> + +namespace Tracker +{ +// Constructor with parameters: +NoisyStripFinder::NoisyStripFinder(const std::string& name, ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name, pSvcLocator), + m_idHelper{nullptr} +{ +} + +// Initialize method: +StatusCode NoisyStripFinder::initialize() { + ATH_MSG_INFO("NoisyStripFinder::initialize()!"); + + ATH_CHECK(m_rdoContainerKey.initialize()); + ATH_CHECK(m_FaserTriggerData.initialize()); + + // Get the SCT ID helper + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + + return StatusCode::SUCCESS; +} + +// Execute method: +StatusCode NoisyStripFinder::execute(const EventContext& ctx) const { + + SG::ReadHandle<xAOD::FaserTriggerData> xaod(m_FaserTriggerData, ctx); + + int trig_int = xaod->tap(); + int trigmask_int = m_triggerMask.value(); + + ATH_MSG_DEBUG("Found FaserTriggerData"); + ATH_MSG_DEBUG("trigger = " << trig_int); + ATH_MSG_DEBUG("mask = " << trigmask_int); + + if (!(xaod->tap() & m_triggerMask.value())) return StatusCode::SUCCESS; // only process events that pass the trigger mask + + ATH_MSG_INFO("trigger passed mask"); + ++m_numberOfEvents; + + // First, we have to retrieve and access the container, not because we want to + // use it, but in order to generate the proxies for the collections, if they + // are being provided by a container converter. + SG::ReadHandle<FaserSCT_RDO_Container> rdoContainer{m_rdoContainerKey, ctx}; + ATH_CHECK(rdoContainer.isValid()); + + // Anything to dereference the DataHandle will trigger the converter + FaserSCT_RDO_Container::const_iterator rdoCollections{rdoContainer->begin()}; + FaserSCT_RDO_Container::const_iterator rdoCollectionsEnd{rdoContainer->end()}; + for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) { + ++m_numberOfRDOCollection; + const TrackerRawDataCollection<FaserSCT_RDORawData>* rd{*rdoCollections}; + ATH_MSG_DEBUG("RDO collection size=" << rd->size() << ", Hash=" << rd->identifyHash()); + for (const FaserSCT_RDORawData* pRawData: *rd) { + ++m_numberOfRDO; + const Identifier firstStripId(pRawData->identify()); + const int thisStrip(m_idHelper->strip(firstStripId)); + ATH_MSG_DEBUG( "---------- new rdo ----------------------------- " ); + ATH_MSG_DEBUG( "rd->identifyHash() = " << rd->identifyHash() ); + ATH_MSG_DEBUG( "strip = " << thisStrip ); + + if ( NoisyStrip_histmap.count(rd->identifyHash()) == 0 ) { // map.count(key) returns 1 if the key exists and 0 if it does not + std::string histname_str = std::to_string(rd->identifyHash()); + char const *histname = histname_str.c_str(); + std::string station_num = std::to_string(m_idHelper->station(firstStripId)); + std::string layer_num = std::to_string(m_idHelper->layer(firstStripId)); + std::string phi_num = std::to_string(m_idHelper->phi_module(firstStripId)); + std::string eta_num = std::to_string(m_idHelper->eta_module(firstStripId)); + std::string side_num = std::to_string(m_idHelper->side(firstStripId)); + std::string hist_title_str = "Station " + station_num + " | Layer " + layer_num + " | phi-module " + phi_num + " | eta-module " + eta_num + " | Side " + side_num + "; strip number; # of events"; + char const *hist_title = hist_title_str.c_str(); + NoisyStrip_histmap[rd->identifyHash()] = new TH1D(histname, hist_title, 768, -0.5, 767.5); + } + NoisyStrip_histmap[rd->identifyHash()]->Fill(thisStrip); // increase the value by one so as to count the number of times the strip was active + } + } + return StatusCode::SUCCESS; +} + +// Finalize method: +StatusCode NoisyStripFinder::finalize() +{ + ATH_MSG_INFO("NoisyStripFinder::finalize()"); + ATH_MSG_INFO( m_numberOfEvents << " events processed" ); + ATH_MSG_INFO( m_numberOfRDOCollection << " RDO collections processed" ); + ATH_MSG_INFO( m_numberOfRDO<< " RawData" ); + ATH_MSG_INFO( "Number of sensors found = " << NoisyStrip_histmap.size() << " out of 144" ); + + for (int ihash = 0; ihash < 144; ++ihash){ // print out the sensors that are missing + if ( NoisyStrip_histmap.count(ihash) == 0 ){ + ATH_MSG_INFO("missing sensor # " << ihash); + } + } + + const char *outputname = m_OutputRootName.value().c_str(); + + TFile* outputfile = new TFile(outputname,"RECREATE"); + + int trigmask_int = m_triggerMask.value(); + + TParameter("numEvents", m_numberOfEvents).Write(); + TParameter("trigger", trigmask_int).Write(); + + std::map<int,TH1D*>::iterator it = NoisyStrip_histmap.begin(); + // Iterate over the map using Iterator till end. + while (it != NoisyStrip_histmap.end()){ + ATH_MSG_INFO( "" ); + ATH_MSG_INFO( "---------- hot strip occupancy >= 0.1 for Tracker Sensor hash = "<< it->first <<" ----------" ); + int i = 1; + while (i <= 768){ + if ( it->second->GetBinContent(i)/(double)m_numberOfEvents >= 0.1 ){ + ATH_MSG_INFO( "hot strip # = " << i-1 << ", hit occupancy = " << it->second->GetBinContent(i)/(double)m_numberOfEvents ); // print out hot strips + } + i++; + } + it->second->Write(); + it++; + } + + outputfile->Close(); + + return StatusCode::SUCCESS; +} +} + diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.h b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.h new file mode 100644 index 0000000000000000000000000000000000000000..a1d977595765f494217f8a63f044ba40cba26540 --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/NoisyStripFinder.h @@ -0,0 +1,85 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef NoisyStripFinder_H +#define NoisyStripFinder_H + +// Base class +#include "AthenaBaseComps/AthReentrantAlgorithm.h" + +////Next contains a typedef so cannot be fwd declared +#include "TrackerRawData/FaserSCT_RDO_Container.h" +#include "xAODFaserTrigger/FaserTriggerData.h" + +//Gaudi +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +#include "StoreGate/ReadHandleKey.h" + + +//STL +#include <map> +#include <TH1.h> +#include <TFile.h> +#include <TParameter.h> + +#include <string> + +class FaserSCT_ID; +class ISvcLocator; +class StatusCode; + +namespace Tracker +{ + +/** + * @class NoisyStripFinder + * @brief Creates histograms with strip occupancy data from SCT Raw Data Objects + * Creates histograms with strip occupancy data from SCT Raw Data Objects. Root files containing strip occupancy histograms can then be combined and analyzed (example pyROOT script in share folder) in order to make an XML database of noisy strips. + */ +class NoisyStripFinder : public AthReentrantAlgorithm { + public: + /// Constructor with parameters: + NoisyStripFinder(const std::string& name, ISvcLocator* pSvcLocator); + + /** @name Usual algorithm methods */ + //@{ + ///Retrieve the tools used and initialize variables + virtual StatusCode initialize() override; + ///Form clusters and record them in StoreGate (detector store) + virtual StatusCode execute(const EventContext& ctx) const override; + ///Clean up and release the collection containers + virtual StatusCode finalize() override; + //Make this algorithm clonable. + virtual bool isClonable() const override { return true; }; + //@} + + private: + /** @name Disallow default instantiation, copy, assignment */ + //@{ + //NoisyStripFinder() = delete; + //NoisyStripFinder(const NoisyStripFinder&) = delete; + //NoisyStripFinder &operator=(const NoisyStripFinder&) = delete; + //@} + + StringProperty m_OutputRootName{this, "OutputHistRootName", "NoisyStripFinderHist.root", "Name of output histogram root file for NoisyStripFinder"}; + + UnsignedIntegerProperty m_triggerMask{this, "TriggerMask", 0x10, "Trigger mask (0x10 = random trig)"}; + + const FaserSCT_ID* m_idHelper; + + SG::ReadHandleKey<FaserSCT_RDO_Container> m_rdoContainerKey{this, "DataObjectName", "FaserSCT_RDOs", "FaserSCT RDOs"}; + SG::ReadHandleKey<xAOD::FaserTriggerData> m_FaserTriggerData{ this, "FaserTriggerDataKey", "FaserTriggerData", "ReadHandleKey for xAOD::FaserTriggerData"}; + + mutable int m_numberOfEvents{0}; + mutable std::atomic<int> m_numberOfRDOCollection{0}; + mutable std::atomic<int> m_numberOfRDO{0}; + + mutable std::map<int,TH1D*> NoisyStrip_histmap; + +}; +} +#endif // NoisyStripFinder_H + diff --git a/Tracker/TrackerRecAlgs/NoisyStripFinder/src/components/NoisyStripFinder_entries.cxx b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/components/NoisyStripFinder_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..811dcec28dea557df88a72e98c0e075565bdc53a --- /dev/null +++ b/Tracker/TrackerRecAlgs/NoisyStripFinder/src/components/NoisyStripFinder_entries.cxx @@ -0,0 +1,4 @@ +#include "../NoisyStripFinder.h" + +DECLARE_COMPONENT( Tracker::NoisyStripFinder ) + diff --git a/Tracker/TrackerRecAlgs/TrackCounts/CMakeLists.txt b/Tracker/TrackerRecAlgs/TrackCounts/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..25fb9fb19d1bad40e89217afba2e9406b29b3bf2 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackCounts/CMakeLists.txt @@ -0,0 +1,17 @@ +################################################################################ +# Package: TrackerClusterFIt +################################################################################ + +# Declare the package name: +atlas_subdir( TrackCounts ) + +# Component(s) in the package: +atlas_add_component( TrackCounts + src/*.cxx src/*.h + src/components/*.cxx + LINK_LIBRARIES AthenaBaseComps StoreGateLib TrkTrack TrackerIdentifier TrackerPrepRawData TrkRIO_OnTrack TrackerRIO_OnTrack + ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) diff --git a/Tracker/TrackerRecAlgs/TrackCounts/python/TrackCountsConfig.py b/Tracker/TrackerRecAlgs/TrackCounts/python/TrackCountsConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..934579044bcf3cd9d731f4199ed374cda045aebf --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackCounts/python/TrackCountsConfig.py @@ -0,0 +1,23 @@ +""" +Copyright (C) 2021 CERN for the benefit of the FASER collaboration +""" + +from AthenaConfiguration.ComponentFactory import CompFactory +from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg + + +def TrackCountsAlgBasicCfg(flags, **kwargs): + acc = FaserSCT_GeometryCfg(flags) + kwargs.setdefault("TrackCollection", "ClusterFit") + Tracker__TrackCountsAlg = CompFactory.Tracker.TrackCountsAlg + acc.addEventAlgo(Tracker__TrackCountsAlg(**kwargs)) + + thistSvc = CompFactory.THistSvc() + thistSvc.Output += ["HIST1 DATAFILE='TrackCountsHist.root' OPT='RECREATE'"] + acc.addService(thistSvc) + return acc + + +def TrackCountsAlgCfg(flags, **kwargs): + acc = TrackCountsAlgBasicCfg(flags, **kwargs) + return acc diff --git a/Tracker/TrackerRecAlgs/TrackCounts/python/__init__.py b/Tracker/TrackerRecAlgs/TrackCounts/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Tracker/TrackerRecAlgs/TrackCounts/src/TrackCountsAlg.cxx b/Tracker/TrackerRecAlgs/TrackCounts/src/TrackCountsAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d353403d1c56b553013def581141d21d7c9477df --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackCounts/src/TrackCountsAlg.cxx @@ -0,0 +1,75 @@ +#include "TrackCountsAlg.h" + +#include "TrkTrack/Track.h" +#include "TrkTrack/TrackStateOnSurface.h" +#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include <TTree.h> +#include <vector> +#include <numeric> + +namespace Tracker +{ + using TrackStatesOnSurface = DataVector<const Trk::TrackStateOnSurface>; + + TrackCountsAlg::TrackCountsAlg(const std::string &name, ISvcLocator *pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator), AthHistogramming(name), + m_idHelper(nullptr), m_histSvc("THistSvc/THistSvc", name) +{ +} + + StatusCode TrackCountsAlg::initialize() { + ATH_MSG_INFO(name() << "::" << __FUNCTION__); + ATH_CHECK(m_trackCollection.initialize()); + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + + m_tree = new TTree("trackCounts", "Track Counts"); + m_tree->Branch("time", &m_time, "time/I"); + m_tree->Branch("station", &m_station, "station/F"); + ATH_CHECK(histSvc()->regTree("/HIST1/trackCounts", m_tree)); + return StatusCode::SUCCESS; + } + + StatusCode TrackCountsAlg::execute(const EventContext &ctx) const { + ATH_MSG_INFO(name() << "::" << __FUNCTION__); + + SG::ReadHandle<TrackCollection> trackCollection {m_trackCollection, ctx}; + if (!trackCollection.isValid()){ + ATH_MSG_ERROR("Could not read " << trackCollection.name()); + return StatusCode::FAILURE; + } + + TrackCollection::const_iterator collItr = trackCollection->begin(); + TrackCollection::const_iterator collItrEnd = trackCollection->end(); + for (; collItr != collItrEnd; ++collItr) + { + m_time = ctx.eventID().time_stamp(); + std::vector<int> stations; + + const Trk::Track* track = *collItr; + TrackStatesOnSurface::const_iterator stateItr = track->trackStateOnSurfaces()->begin(); + TrackStatesOnSurface::const_iterator stateItrEnd = track->trackStateOnSurfaces()->end(); + for (; stateItr !=stateItrEnd; ++stateItr) + { + const Trk::TrackStateOnSurface* trackState = *stateItr; + const auto* clusterOnTrack = dynamic_cast<const FaserSCT_ClusterOnTrack*>(trackState->measurementOnTrack()); + if (clusterOnTrack) + { + const FaserSCT_Cluster* cluster = clusterOnTrack->prepRawData(); + stations.push_back(m_idHelper->station(cluster->identify())); + } + } + m_station = accumulate(stations.begin(), stations.end(), 0.0) / stations.size(); + m_tree->Fill(); + } + + return StatusCode::SUCCESS; + } + + StatusCode TrackCountsAlg::finalize() { + ATH_MSG_INFO(name() << "::" << __FUNCTION__); + return StatusCode::SUCCESS; + } + +} // Tracker diff --git a/Tracker/TrackerRecAlgs/TrackCounts/src/TrackCountsAlg.h b/Tracker/TrackerRecAlgs/TrackCounts/src/TrackCountsAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..ddf08f36e7daeb587c26cd8e5d72f114255102c3 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackCounts/src/TrackCountsAlg.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration +*/ + +#ifndef TRACKCOUNTS_TRACKCOUNTSALG_H +#define TRACKCOUNTS_TRACKCOUNTSALG_H + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthenaBaseComps/AthHistogramming.h" +#include "TrkTrack/TrackCollection.h" + +class FaserSCT_ID; +class TTree; + +namespace Tracker +{ + +class TrackCountsAlg : public AthReentrantAlgorithm, AthHistogramming +{ +public: + TrackCountsAlg(const std::string& name, ISvcLocator* pSvcLocator); + + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + + const ServiceHandle<ITHistSvc>& histSvc() const; + +private: + const FaserSCT_ID* m_idHelper; + SG::ReadHandleKey<TrackCollection> m_trackCollection {this, "TrackCollection", "CLusterFit", "Input track collection name" }; + + ServiceHandle<ITHistSvc> m_histSvc; + + mutable TTree* m_tree; + mutable unsigned int m_time; + mutable float m_station; +}; + +inline const ServiceHandle<ITHistSvc>& TrackCountsAlg::histSvc() const { + return m_histSvc; +} + +} // namespace Tracker + +#endif // TRACKCOUNTS_TRACKCOUNTSALG_H diff --git a/Tracker/TrackerRecAlgs/TrackCounts/src/components/TrackCounts_entries.cxx b/Tracker/TrackerRecAlgs/TrackCounts/src/components/TrackCounts_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e3ed585f3f4558ffbda3819962791a97581e1b6c --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackCounts/src/components/TrackCounts_entries.cxx @@ -0,0 +1,3 @@ +#include "../TrackCountsAlg.h" + +DECLARE_COMPONENT( Tracker::TrackCountsAlg ) diff --git a/Tracker/TrackerRecAlgs/TrackCounts/test/TrackCountsDbg.py b/Tracker/TrackerRecAlgs/TrackCounts/test/TrackCountsDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..bb49fa23f6acc2e6e1340b22009720da2f61a8e8 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackCounts/test/TrackCountsDbg.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +""" +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" + +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg +from ScintRecAlgs.ScintRecAlgsConfig import WaveformReconstructionCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerClusterFit.TrackerClusterFitConfig import ClusterFitAlgCfg +from TrackCounts.TrackCountsConfig import TrackCountsAlgCfg + +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +ConfigFlags.Input.Files = [ + '/eos/project/f/faser-commissioning/TI12Data/Run-001805/Faser-Physics-001805-00000.raw', +] + +ConfigFlags.Output.ESDFileName = "run001805_00.ESD.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" +ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" +ConfigFlags.Input.ProjectName = "data21" +ConfigFlags.Input.isMC = False +ConfigFlags.Common.isOnline = False +ConfigFlags.GeoModel.FaserVersion = "FASER-01" +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Beam.NumberOfCollisions = 0. + +ConfigFlags.Detector.GeometryFaserSCT = True + +ConfigFlags.lock() + +acc = MainServicesCfg(ConfigFlags) +acc.merge(PoolWriteCfg(ConfigFlags)) + +acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) +acc.merge(WaveformReconstructionCfg(ConfigFlags)) +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, DataObjectName="SCT_EDGEMODE_RDOs")) +acc.merge(ClusterFitAlgCfg(ConfigFlags)) +acc.merge(TrackCountsAlgCfg(ConfigFlags)) + +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +itemList = [ "xAOD::EventInfo#*", + "xAOD::EventAuxInfo#*", + "FaserSCT_RDO_Container#*", + "xAOD::FaserTriggerData#*", + "xAOD::FaserTriggerDataAux#*", + "ScintWaveformContainer#*", + "TrackCollection#*", + "xAOD::WaveformHitContainer#*", + "xAOD::WaveformHitAuxContainer#*", + "xAOD::WaveformClock#*", + "xAOD::WaveformClockAuxInfo#*", + ] +acc.merge(OutputStreamCfg(ConfigFlags, "ESD", itemList)) +acc.getEventAlgo("OutputStreamESD").AcceptAlgs = ["Tracker::ClusterFitAlg"] + +# Dump config +# logging.getLogger('forcomps').setLevel(VERBOSE) +# acc.foreach_component("*").OutputLevel = VERBOSE +# acc.foreach_component("*ClassID*").OutputLevel = INFO +# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +# acc.getService("StoreGateSvc").Dump = True +# acc.getService("ConditionStore").Dump = True +# acc.printConfig(withDetails=True) +# ConfigFlags.dump() + +# Execute and finish +sc = acc.run(maxEvents=-1) + +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/CMakeLists.txt b/Tracker/TrackerRecAlgs/TrackerSeedFinder/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b37eb389da8103ef92ad755e133465b92c3b9afa --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/CMakeLists.txt @@ -0,0 +1,24 @@ +################################################################################ +# Package: TrackerSeedFinder +############################################# + +# Declare the package name: +atlas_subdir( TrackerSeedFinder ) + +# External dependencies: +find_package( Eigen ) + +# Component(s) in the package: +atlas_add_library( TrackerSeedFinderLib + src/components/*.cxx src/*.cxx src/*.h + NO_PUBLIC_HEADERS + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerRawData TrackerSimData GeneratorObjects TrackerSimEvent TrackerSpacePoint VxVertex FaserDetDescr xAODEventInfo TrackerIdentifier TrackerPrepRawData AthenaMonitoringKernelLib) + +atlas_add_component( TrackerSeedFinder + src/components/*.cxx src/*.cxx src/*.h + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerRawData TrackerSimData GeneratorObjects TrackerSimEvent TrackerSpacePoint VxVertex FaserDetDescr xAODEventInfo TrackerIdentifier TrackerPrepRawData AthenaMonitoringKernelLib) + +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/python/TrackerSeedFinderConfig.py b/Tracker/TrackerRecAlgs/TrackerSeedFinder/python/TrackerSeedFinderConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..acfbb4e7c80e315b357094519d03e2049e26b593 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/python/TrackerSeedFinderConfig.py @@ -0,0 +1,37 @@ +"""Define methods to construct configured SCT Digitization tools and algorithms + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory + +Tracker__TrackerSeedFinder, THistSvc=CompFactory.getComps("Tracker::TrackerSeedFinder", "THistSvc") + +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + + + +def TrackerSeedFinderBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for TrackerSeedFinder""" + acc = ComponentAccumulator() + kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + kwargs.setdefault("FaserSpacePointsSeedsName", "Seeds_SpacePointContainer") + acc.addEventAlgo(Tracker__TrackerSeedFinder(**kwargs)) + # attach ToolHandles + return acc + +def TrackerSeedFinder_OutputCfg(flags): + """Return ComponentAccumulator with Output for SCT. Not standalone.""" + acc = ComponentAccumulator() + acc.merge(OutputStreamCfg(flags, "ESD")) + ostream = acc.getEventAlgo("OutputStreamESD") + ostream.TakeItemsFromInput = True + return acc + +def TrackerSeedFinderCfg(flags, **kwargs): + acc=TrackerSeedFinderBasicCfg(flags, **kwargs) + histSvc= THistSvc() + histSvc.Output += [ "TrackerSeedFinder DATAFILE='trackseedfinder.root' OPT='RECREATE'" ] + acc.addService(histSvc) + acc.merge(TrackerSeedFinder_OutputCfg(flags)) + return acc diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.cxx b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.cxx new file mode 100755 index 0000000000000000000000000000000000000000..f8aef6daed4a6d9af723ccd7ef7c4fc573c28c6c --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.cxx @@ -0,0 +1,366 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/*************************************************************************** + ------------------- + ATLAS Collaboration + ***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> + + +#include "TrackerSeedFinder.h" + +// For processing clusters +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerReadoutGeometry/SiDetectorDesign.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +// Space point Classes, +#include "TrkSpacePoint/SpacePointCollection.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + +// general Atlas classes +#include "FaserDetDescr/FaserDetectorID.h" +#include "xAODEventInfo/EventInfo.h" +#include "StoreGate/ReadCondHandle.h" + +#include "AthenaMonitoringKernel/Monitored.h" + +//!!!!!!!!!!!!!!!!!!!!!!!! +//#include "Acts/EventData/TrackParameters.hpp" +#include "TrackerReadoutGeometry/SCT_DetectorManager.h" +#include "Acts/Utilities/detail/periodic.hpp" +#include "Acts/Definitions/Common.hpp" +#include "Acts/Definitions/Algebra.hpp" +#include "Acts/Definitions/Units.hpp" +using namespace Acts::UnitLiterals; +//!!!!!!!!!!!!!!!!!!!!!!!! +namespace Tracker +{ + + //------------------------------------------------------------------------ + TrackerSeedFinder::TrackerSeedFinder(const std::string& name, + ISvcLocator* pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) + , m_hist_n(0) + , m_hist_x(0) + , m_hist_y(0) + , m_hist_z(0) + , m_hist_r(0) + , m_hist_phi(0) + , m_hist_eta(0) + , m_hist_layer(0) + , m_hist_strip(0) + , m_hist_station(0) + , m_hist_x_z(0) + , m_hist_y_z(0) + , m_hist_sp_plane (0) + , m_hist_sp_layer (0) + , m_hist_sp_station (0) + , m_thistSvc("THistSvc", name) + {} + + //----------------------------------------------------------------------- + StatusCode TrackerSeedFinder::initialize() { + + ATH_MSG_DEBUG( "TrackerSeedFinder::initialize()" ); + + CHECK(m_thistSvc.retrieve()); + // Check that clusters, space points and ids have names + if ( m_Sct_spcontainerKey.key().empty()){ + ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_Sct_spcontainerKey.initialize() ); + + // create containers (requires the Identifier Helpers) + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + + // Initialize the key of input SiElementPropertiesTable and SiDetectorElementCollection for SCT + ATH_CHECK(m_SCTDetEleCollKey.initialize()); + if (m_seed_spcontainerKey.key().empty()){ + ATH_MSG_FATAL( "No name set for output seeds space points"); + return StatusCode::FAILURE; + } + + ATH_CHECK( m_seed_spcontainerKey.initialize() ); + + ATH_CHECK( m_trackerSeedContainerKey.initialize() ); + if (m_trackerSeedContainerKey.key().empty()){ + ATH_MSG_FATAL( "No name set for output track seeds"); + return StatusCode::FAILURE; + } + + m_hist_n=new TH1D("sp_n","sp_n",20,0,20); + m_hist_x=new TH1D("sp_x","sp_x",100,-200,200); + m_hist_y=new TH1D("sp_y","sp_y",100,-200,200); + m_hist_z=new TH1D("sp_z","sp_z",3500,0,3500); + m_hist_r=new TH1D("sp_r","sp_r",100,0,200); + m_hist_eta=new TH1D("sp_eta","sp_eta",100,0,5); + m_hist_phi=new TH1D("sp_phi","sp_phi",100,-3.2,3.2); + m_hist_strip=new TH1D("sp_strip","sp_strip",1000,0,1000); + m_hist_layer=new TH1D("sp_layer","sp_layer",100,-10,10); + m_hist_station=new TH1D("sp_station","sp_station",100,-10,10); + m_hist_sp_station=new TH1D("sp_all_station","sp_station",100,-10,10); + m_hist_sp_plane=new TH1D("sp_all_plane","sp_station",100,-10,10); + m_hist_sp_layer=new TH1D("sp_all_layer","sp_station",100,-10,10); + m_hist_x_z=new TH2D("sp_x_z","sp_x_z",100,-200,200,3500,0,3500); + m_hist_y_z=new TH2D("sp_y_z","sp_y_z",100,-200,200,3500,0,3500); + m_hist_dx=new TH1D("sp_dx","sp_dx",100,-200,200); + m_hist_dy=new TH1D("sp_dy","sp_dy",100,-200,200); + m_hist_dx_slope=new TH1D("sp_dx_slope","sp_dx_slope",100,-200,200); + m_hist_dy_slope=new TH1D("sp_dy_slope","sp_dy_slope",100,-200,200); + m_hist_dx_intercept=new TH1D("sp_dx_intercept","sp_dx_intercept",100,-200,200); + m_hist_dx_intercept_after=new TH1D("sp_dx_intercept_after","sp_dx_intercept_after",100,-200,200); + m_hist_line=new TH1D("sp_line","sp_line",100,-200,200); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_n",m_hist_n)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_x",m_hist_x)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_y",m_hist_y)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_z",m_hist_z)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_r",m_hist_r)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_eta",m_hist_eta)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_phi",m_hist_phi)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_strip",m_hist_strip)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_layer",m_hist_layer)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_station",m_hist_station)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_all_station",m_hist_sp_station)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_all_layer",m_hist_sp_layer)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_all_plane",m_hist_sp_plane)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_x_z",m_hist_x_z)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_y_z",m_hist_y_z)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_dx",m_hist_dx)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_dy",m_hist_dy)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_dx_slope",m_hist_dx_slope)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_dy_slope",m_hist_dy_slope)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_dx_intercept",m_hist_dx_intercept)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_dx_intercept_after",m_hist_dx_intercept_after)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_line",m_hist_line)); + + ATH_MSG_INFO( "TrackerSeedFinder::initialized for package version " << PACKAGE_VERSION ); + return StatusCode::SUCCESS; + } + + //------------------------------------------------------------------------- + + StatusCode TrackerSeedFinder::make_triplets(vector<vector<const Trk::SpacePoint*> >& vsp, vector<seed>& vt, string st) const { + + int count=0; + double xs=0, ys=0, zs=0, z2s=0, xzs=0, yzs=0; + + for (unsigned int i=0; i<vsp[0].size(); i++) { + for (unsigned int j=0; j<vsp[1].size(); j++) { + for (unsigned int k=0; k<vsp[2].size(); k++) { + + ATH_MSG_VERBOSE( " station " << st << " / list of space points for seeds " + << vsp[0].at(i)->clusterList().first->identify() << " " + << vsp[1].at(j)->clusterList().first->identify() << " " + << vsp[2].at(k)->clusterList().first->identify()); + + count++; + + vector<double> x; vector<double> y; vector<double> z; + x.push_back(vsp[0].at(i)->globalPosition().x()); x.push_back(vsp[1].at(j)->globalPosition().x()); x.push_back(vsp[2].at(k)->globalPosition().x()); + y.push_back(vsp[0].at(i)->globalPosition().y()); y.push_back(vsp[1].at(j)->globalPosition().y()); y.push_back(vsp[2].at(k)->globalPosition().y()); + z.push_back(vsp[0].at(i)->globalPosition().z()); z.push_back(vsp[1].at(j)->globalPosition().z()); z.push_back(vsp[2].at(k)->globalPosition().z()); + + xs=x.at(0)+x.at(1)+x.at(2); ys=y.at(0)+y.at(1)+y.at(2); zs=z.at(0)+z.at(1)+z.at(2); + z2s=pow(z.at(0),2)+pow(z.at(1),2)+pow(z.at(2),2); + xzs=x.at(0)*z.at(0)+x.at(1)*z.at(1)+x.at(2)*z.at(2); + yzs=y.at(0)*z.at(0)+y.at(1)*z.at(1)+y.at(2)*z.at(2); + + seed mt; + mt.axz=(3*xzs-xs*zs)/(3*z2s-zs*zs); + mt.bxz=(z2s*xs-xzs*zs)/(3*z2s-zs*zs); + mt.ayz=(3*yzs-ys*zs)/(3*z2s-zs*zs); + mt.byz=(z2s*ys-yzs*zs)/(3*z2s-zs*zs); + mt.add_sp(vsp[0].at(i)); mt.add_sp(vsp[1].at(j)); mt.add_sp(vsp[2].at(k)); + mt.station=st; + mt.num=count; + + for(int pos=0; pos<3; pos++) { + mt.chi2_xz+=pow(x.at(pos)-(mt.axz*z.at(pos)+mt.bxz),2); + mt.chi2_yz+=pow(x.at(pos)-(mt.ayz*z.at(pos)+mt.byz),2); + } + + ATH_MSG_VERBOSE( " x1 " << x.at(0) << "; x2 " << x.at(1) << "; x3 " << x.at(2)); + ATH_MSG_VERBOSE( " y1 " << y.at(0) << "; y2 " << y.at(1) << "; y3 " << y.at(2)); + ATH_MSG_VERBOSE( " z1 " << z.at(0) << "; z2 " << z.at(1) << "; z3 " << z.at(2)); + ATH_MSG_VERBOSE( " linear fit on plane xz / slope " << mt.axz << "; intercept " << mt.bxz); + ATH_MSG_VERBOSE( " linear fit on plane yz / slope " << mt.ayz << "; intercept " << mt.byz); + ATH_MSG_VERBOSE( " chi2 / on plane xz " << mt.chi2_xz << "; on plane yz " << mt.chi2_yz); + + vt.push_back(mt); + + } + } + } + + return StatusCode::SUCCESS; + } + + //------------------------------------------------------------------------- + + StatusCode TrackerSeedFinder::execute (const EventContext& ctx) const { + + ++m_numberOfEvents; + N_1_0=0, N_1_1=0, N_1_2=0, N_2_0=0, N_2_1=0, N_2_2=0, N_3_0=0, N_3_1=0, N_3_2=0; + + // retrieve tracker spacepoint container + SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); + if (!sct_spcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< sct_spcontainer.name() << " !" << endmsg; + return StatusCode::RECOVERABLE; + } + + ATH_MSG_DEBUG( "Tracker spacepoint container found: " << sct_spcontainer->size() << " collections" ); + SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + + int i=0; + + vector<vector<const Trk::SpacePoint*> > vsp1(3); + vector<vector<const Trk::SpacePoint*> > vsp2(3); + vector<vector<const Trk::SpacePoint*> > vsp3(3); + + vector<pair<int, const Trk::SpacePoint*>> msp; + + vector<vector<pair<int, const Trk::SpacePoint*>>> mseeds; + vector<int> pos; + + ATH_MSG_DEBUG( "Start iteration of spacepoint collections" ); + for (; it != itend; ++it){ + + ++m_numberOfSPCollection; + const SpacePointCollection *colNext=&(**it); + int nReceivedSPSCT = colNext->size(); + + // Create SpacePointCollection + IdentifierHash idHash = colNext->identifyHash(); + Identifier elementID = colNext->identify(); + + ATH_MSG_DEBUG( "Spacepoint collection in iteraction: size = " <<nReceivedSPSCT <<", IDHash = "<<idHash<<", ID = "<<elementID ); + if (nReceivedSPSCT== 0){ + ATH_MSG_VERBOSE( "Algorithm found no space points" ); + ++m_numberOfEmptySPCollection; + } else { + SpacePointCollection::const_iterator sp_begin= colNext->begin(); + SpacePointCollection::const_iterator sp_end= colNext->end(); + + ATH_MSG_DEBUG( "Iterate the spacepoint in collection " ); + + for (; sp_begin != sp_end; ++sp_begin) { + + ++i; + ++m_numberOfSP; + const Trk::SpacePoint* sp=&(**sp_begin); + + const auto identifier = sp->clusterList().first->identify(); + int station = m_idHelper->station(identifier); + int plane = m_idHelper->layer(identifier); + + ATH_MSG_VERBOSE( " layer " << (station-1)*3+plane ); + msp.push_back(make_pair((station-1)*3+plane,sp)); + if ((station-1)*3+plane < 3) { + vsp1.at(plane).push_back(sp); + } else if ((station-1)*3+plane < 6) { + vsp2.at(plane).push_back(sp); + } else if ((station-1)*3+plane < 9) { + vsp3.at(plane).push_back(sp); + } + + if (station==1 && plane==0) {N_1_0++;} if (station==1 && plane==1) {N_1_1++;} if (station==1 && plane==2) {N_1_2++;} + if (station==2 && plane==0) {N_2_0++;} if (station==2 && plane==1) {N_2_1++;} if (station==2 && plane==2) {N_2_2++;} + if (station==3 && plane==0) {N_3_0++;} if (station==3 && plane==1) {N_3_1++;} if (station==3 && plane==2) {N_3_2++;} + + pos.push_back((station-1)*3+plane); + + ATH_MSG_VERBOSE( " spacepoint n " << m_numberOfSP ); + ATH_MSG_VERBOSE( " station " << station << " plane " << plane << " pos " << pos.at(i-1) << " index " << (station-1)*3+plane); + ATH_MSG_VERBOSE( " i " << i << " x " << sp->globalPosition().x() << " y " << sp->globalPosition().y() << " z " << sp->globalPosition().z()); + + m_hist_r->Fill(sp->r()); + m_hist_eta->Fill(sp->eta()); + m_hist_phi->Fill(sp->phi()); + + m_hist_x->Fill(sp->globalPosition().x()); + m_hist_y->Fill(sp->globalPosition().y()); + m_hist_z->Fill(sp->globalPosition().z()); + + m_hist_x_z->Fill(sp->globalPosition().x(),sp->globalPosition().z()); + m_hist_y_z->Fill(sp->globalPosition().y(),sp->globalPosition().z()); + + } + } + } + + ATH_MSG_VERBOSE( " number of space points; event " << m_numberOfEvents); + ATH_MSG_VERBOSE( " 1st station " << N_1_0+N_1_1+N_1_2 << " (" << vsp1.at(0).size() << ";" << vsp1.at(1).size() << ";" << vsp1.at(2).size() << ")"); + ATH_MSG_VERBOSE( " 2nd station " << N_2_0+N_2_1+N_2_2 << " (" << vsp2.at(0).size() << ";" << vsp2.at(1).size() << ";" << vsp2.at(2).size() << ")"); + ATH_MSG_VERBOSE( " 3rd station " << N_3_0+N_3_1+N_3_2 << " (" << vsp3.at(0).size() << ";" << vsp3.at(1).size() << ";" << vsp3.at(2).size() << ")"); + + vector<seed> vseed; + ATH_CHECK(make_triplets(vsp1, vseed, "1")); + ATH_CHECK(make_triplets(vsp2, vseed, "2")); + + vector<seed> vfseed; + for (vector<seed>::iterator it1 = vseed.begin(); it1 != vseed.end(); ++it1) { + for (vector<seed>::iterator it2 = vseed.begin(); it2 != vseed.end(); ++it2) { + + if ((*it1).station == "1" && (*it2).station == "2") { + + ATH_MSG_VERBOSE( "Considering seeds " << (*it1).num << " and " << (*it2).num); + + seed ms; + ms.station="12"; + ms.add_vsp((*it1).vsp); + ms.add_vsp((*it2).vsp); + vfseed.push_back(ms); + } + } + } + + SG::WriteHandle<TrackerSeedCollection> seedContainer(m_trackerSeedContainerKey, ctx); + ATH_CHECK(seedContainer.record( std::make_unique<TrackerSeedCollection>() ) ); + ATH_MSG_INFO("Created track seed container " << m_trackerSeedContainerKey.key()); + + int nseed=0; + + for (vector<seed>::iterator it = vfseed.begin(); it != vfseed.end(); ++it) { + + if ((*it).station != "12") continue; + + nseed++; + + vector<const Trk::SpacePoint*> mseed = (*it).vsp; + + Tracker::TrackerSeed* trackerSeed = new Tracker::TrackerSeed(); + trackerSeed->set_id(TrackerSeed::TRIPLET_SP_FIRSTSTATION); + trackerSeed->add(mseed); + + seedContainer->push_back(trackerSeed); + } + + ATH_MSG_INFO("Saved " << nseed << " seeds in container"); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + StatusCode TrackerSeedFinder::finalize() + { + ATH_MSG_INFO( "Finalizing" ); + ATH_MSG_INFO( m_numberOfEvents << " events processed" ); + ATH_MSG_INFO( m_numberOfSPCollection << " spacepoint collections processed" ); + ATH_MSG_INFO( m_numberOfEmptySPCollection<< " spacepoint collections empty" ); + ATH_MSG_INFO( m_numberOfSP<< " sct SP collections processed" ); + + ATH_MSG_INFO( "Finalizing TrackerSeedFinder" ); + + return StatusCode::SUCCESS; + } + + //-------------------------------------------------------------------------- + +} diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.h b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.h new file mode 100755 index 0000000000000000000000000000000000000000..eabebe327c8d693b2f30e803ed778bd8b4916176 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.h @@ -0,0 +1,135 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration + */ + +/** @file TrackSeedFinder.h + * an algorithm for finding track seeds + * @author Andrea Coccaro + * @date May 2021 + */ + + +#ifndef TRACKERSEEDFINDER_TRACKERSEEDFINDER_H +#define TRACKERSEEDFINDER_TRACKERSEEDFINDER_H + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "Identifier/Identifier.h" + +#include "GeneratorObjects/McEventCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "TrkSpacePoint/SpacePoint.h" +#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrackerSpacePoint/SpacePointForSeedCollection.h" + +#include "TrackerPrepRawData/TrackerSeedCollection.h" +#include "TrackerPrepRawData/TrackerSeed.h" +#include "TrkSpacePoint/SpacePointOverlapCollection.h" +#include "TrackerSimEvent/FaserSiHitCollection.h" +#include "TrackerRawData/FaserSCT_RDO_Container.h" +#include "TrackerSimData/TrackerSimDataCollection.h" + + +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/ToolHandle.h" + +#include <string> +#include <vector> +#include "TH1.h" +#include "TH2.h" + +#include <string> + +using namespace std; + +class FaserSCT_ID; + +namespace Tracker { + + class TrackerSeedFinder:public AthReentrantAlgorithm { + + public: + + TrackerSeedFinder(const std::string& name, ISvcLocator* pSvcLocator); + + virtual ~TrackerSeedFinder() = default; + + virtual StatusCode initialize() override; + + virtual StatusCode execute (const EventContext& ctx) const override; + + virtual StatusCode finalize() override; + + private: + + struct seed { + vector<const Trk::SpacePoint*> vsp; + double axz, bxz, ayz, byz; + double chi2_xz, chi2_yz; + string station; + int num; + + void add_sp(const Trk::SpacePoint* sp) { + vsp.push_back(sp); + } + + void add_vsp(vector<const Trk::SpacePoint*> v) { + for (vector<const Trk::SpacePoint*>::iterator it = v.begin(); it != v.end(); ++it) { + vsp.push_back((*it)); + } + } + }; + + StatusCode make_triplets(vector< vector<const Trk::SpacePoint*> >&, vector<seed>&, string) const; + + TrackerSeedFinder() = delete; + TrackerSeedFinder(const TrackerSeedFinder&) =delete; + TrackerSeedFinder &operator=(const TrackerSeedFinder&) = delete; + SG::ReadHandleKey<SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; + + SG::WriteHandleKey<SpacePointForSeedCollection> m_seed_spcontainerKey{this, "FaserSpacePointsSeedsName", "SpacePointForSeedCollection", "SpacePointForSeedCollection"}; + SG::WriteHandleKey<Tracker::TrackerSeedCollection> m_trackerSeedContainerKey{this, "FaserTrackerSeedName", "FaserTrackerSeedCollection", "FaserTrackerSeedCollection"}; + + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + + const FaserSCT_ID* m_idHelper{nullptr}; + mutable std::atomic<int> m_numberOfEvents{0}; + mutable std::atomic<int> m_numberOfSPCollection{0}; + mutable std::atomic<int> m_numberOfEmptySPCollection{0}; + mutable std::atomic<int> m_numberOfSP{0}; + + TH1* m_hist_n; + TH1* m_hist_x; + TH1* m_hist_y; + TH1* m_hist_z; + TH1* m_hist_r; + TH1* m_hist_phi; + TH1* m_hist_eta; + TH1* m_hist_layer; + TH1* m_hist_strip; + TH1* m_hist_station; + TH2* m_hist_x_z; + TH2* m_hist_y_z; + TH1* m_hist_sp_plane; + TH1* m_hist_sp_layer; + TH1* m_hist_sp_station; + TH1* m_hist_dx; + TH1* m_hist_dy; + TH1* m_hist_dx_slope; + TH1* m_hist_dy_slope; + TH1* m_hist_dx_intercept; + TH1* m_hist_dx_intercept_after; + TH1* m_hist_line; + + ServiceHandle<ITHistSvc> m_thistSvc; + + mutable int N_1_0=0, N_1_1=0, N_1_2=0, N_2_0=0, N_2_1=0, N_2_2=0, N_3_0=0, N_3_1=0, N_3_2=0; + + }; + +} +#endif // TRACKERSEEDFINDER_TRACKERSEEDFINDER_H diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/components/TrackerSeedFinder_entries.cxx b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/components/TrackerSeedFinder_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..89e6db22cc8de4124d9ed41045ace3a79f430cb8 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/components/TrackerSeedFinder_entries.cxx @@ -0,0 +1,3 @@ +#include "../TrackerSeedFinder.h" + +DECLARE_COMPONENT( Tracker::TrackerSeedFinder ) diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/test/TrackerSeedFinderDbg.py b/Tracker/TrackerRecAlgs/TrackerSeedFinder/test/TrackerSeedFinderDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..c6334704f6aef383a1057cd6266efa8398d16a04 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/test/TrackerSeedFinderDbg.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from AthenaConfiguration.MainServicesConfig import MainServicesCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from TrackerSeedFinder.TrackerSeedFinderConfig import TrackerSeedFinderCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = ['my.RDO.pool.root'] +ConfigFlags.Output.ESDFileName = "mySeeds.ESD.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" +ConfigFlags.GeoModel.Align.Dynamic = False +#ConfigFlags.Concurrency.NumThreads = 1 +ConfigFlags.Beam.NumberOfCollisions = 0. + +ConfigFlags.lock() + +# Core components +acc = MainServicesCfg(ConfigFlags) +acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +# Inner Detector +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +acc.merge(TrackerSeedFinderCfg(ConfigFlags)) + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +acc.getService("StoreGateSvc").Dump = True +acc.getService("ConditionStore").Dump = True +acc.printConfig(withDetails=True) +ConfigFlags.dump() + +# Execute and finish +sc = acc.run(maxEvents=-1) + +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt b/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt index 1d7a2f71601ee4a1d46065687afd5db342890c93..d1630abf233ec25789022973377d7c17956c7dd0 100644 --- a/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt @@ -15,7 +15,7 @@ atlas_add_library( TrackerPrepRawData PUBLIC_HEADERS TrackerPrepRawData INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AthLinks CxxUtils AthenaKernel GeoPrimitives Identifier EventPrimitives GaudiKernel TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkPrepRawData TrackerRawData EventContainers + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthLinks CxxUtils AthenaKernel GeoPrimitives Identifier EventPrimitives GaudiKernel TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkPrepRawData TrackerRawData EventContainers TrkSpacePoint PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ) atlas_add_dictionary( TrackerPrepRawDataDict diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeed.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeed.h new file mode 100755 index 0000000000000000000000000000000000000000..02d6a193aa081bbd2188288131a98a6bb2708096 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeed.h @@ -0,0 +1,50 @@ +#ifndef TRACKERRAWDATA_TRACKERSEED_H +#define TRACKERRAWDATA_TRACKERSEED_H + +#include "TrkSpacePoint/SpacePoint.h" + +#include <vector> + +using namespace std; + +class MsgStream; + +namespace Tracker { + + class TrackerSeed { + + public: + + enum StrategyId{NULLID=0, TRIPLET_SP_FIRSTSTATION=1}; + + TrackerSeed(); + TrackerSeed(const StrategyId, const TrackerSeed &); + virtual ~TrackerSeed(); + + TrackerSeed(const StrategyId, vector<const Trk::SpacePoint*> seed); + + void set_id(const StrategyId id) { m_strategyId = id; } + StrategyId id() const { return m_strategyId; } + + void add(vector<const Trk::SpacePoint*> seed); + + int size() const; + + TrackerSeed &operator=(const TrackerSeed &); + + virtual MsgStream& dump(MsgStream& stream) const; + virtual ostream& dump(ostream& stream) const; + + private: + + StrategyId m_strategyId; + vector<const Trk::SpacePoint*> m_seed; + + }; + + MsgStream& operator << (MsgStream& stream, const TrackerSeed& prd); + ostream& operator << (ostream& stream, const TrackerSeed& prd); + +} +#endif // TRACKERRAWDATA_TRACKERSEED_H + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeedCollection.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeedCollection.h new file mode 100755 index 0000000000000000000000000000000000000000..a90dedca94ed8580d9fe74dac784fc9c0ee70e69 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeedCollection.h @@ -0,0 +1,16 @@ +#ifndef TRACKERSEEDCOLLECTION_H +#define TRACKERSEEDCOLLECTION_H + +#include "AthenaKernel/CLASS_DEF.h" +#include "AthContainers/DataVector.h" +#include "GaudiKernel/DataObject.h" +#include "TrackerPrepRawData/TrackerSeed.h" + +namespace Tracker { + typedef DataVector<TrackerSeed> TrackerSeedCollection; +} + +CLASS_DEF(Tracker::TrackerSeedCollection, 1139531114, 1) + +#endif // TRACKERSEEDCOLLECTION_H + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerSeed.cxx b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerSeed.cxx new file mode 100755 index 0000000000000000000000000000000000000000..bd217ec892f499994db0f6eb5d557669357a6ef7 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerSeed.cxx @@ -0,0 +1,44 @@ +#include "TrackerPrepRawData/TrackerSeed.h" + +namespace Tracker { + + TrackerSeed::TrackerSeed() : m_strategyId(NULLID) {} + + TrackerSeed::TrackerSeed(const StrategyId id, const TrackerSeed& trackerSeed) : m_strategyId(id), m_seed(trackerSeed.m_seed) {} + + TrackerSeed::~TrackerSeed() {} + + TrackerSeed::TrackerSeed(const StrategyId id, vector<const Trk::SpacePoint*> seed) { m_strategyId = id; m_seed = seed; } + + void TrackerSeed::add(vector<const Trk::SpacePoint*> seed) { m_seed = seed; } + + int TrackerSeed::size() const { return m_seed.size(); } + + TrackerSeed& TrackerSeed::operator=(const TrackerSeed& trackSeed){ + if(&trackSeed != this) { + TrackerSeed::operator=(trackSeed); + m_seed = trackSeed.m_seed; + } + return *this; + } + + MsgStream& TrackerSeed::dump(MsgStream& stream) const { + stream << "TrackerSeed object" << endl; + this->TrackerSeed::dump(stream); + return stream; + } + + ostream& TrackerSeed::dump(ostream& stream) const { + stream << "TrackerSeed object" << endl; + this->TrackerSeed::dump(stream); + return stream; + } + + MsgStream& operator << (MsgStream& stream, const TrackerSeed& trackSeed) { + return trackSeed.dump(stream); + } + + ostream& operator << (ostream& stream, const TrackerSeed& trackSeed) { + return trackSeed.dump(stream); + } +} diff --git a/graphics/VTI12/README.md b/graphics/VTI12/README.md index 47e64e0abd2bc3e01bd66f6c3bde193ca894ab32..20b87b07520403e8b69da9e888f6fb588154a092 100644 --- a/graphics/VTI12/README.md +++ b/graphics/VTI12/README.md @@ -2,11 +2,11 @@ To run on Calypso MC data (from an installation (run) directory): % source ./setup.sh -% export VP1PLUGINPATH=./lib +% export VP1PLUGINPATH=/home/yourname/path/to/runfolder/lib % vti12 -mc -noautoconf -nosortdbreplicas <input HITS or EVNT file> -Note that VP1PLUGINPATH can be ninja-changed by asetup, and if it does not include the Calypso installation library folder, nothing will work +Note that VP1PLUGINPATH can be ninja-changed by asetup, and if it does not include the Calypso installation library folder, nothing will work. Also note that it must be an ABSOLUTE (not relative) path! You can also give the -detdescr="FASER-01" or -detdescr="FASER-02" and -globcond="OFLCOND-FASER-01" or -globcond="OFLCOND-FASER-02" flags to specify the detector geometry and conditions. diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt index a93fb1a1f3cac4e08a829987eb0533bac47b785f..f8dfd19e8d3c13e9df693506262f6963d17f4e23 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt @@ -34,7 +34,7 @@ atlas_add_library( VTI12TrackSystems VTI12TrackSystems/*.h src/*.cxx ScintIdentifier ScintSimEvent ScintReadoutGeometry TrackerIdentifier TrackerReadoutGeometry TrackerSimEvent FaserCaloIdentifier CaloReadoutGeometry FaserCaloSimEvent - #InDetPrepRawData InDetRIO_OnTrack + TrackerPrepRawData TrackerRIO_OnTrack Particle TrkDetDescrUtils TrkDetElementBase TrkVolumes TrkCompetingRIOsOnTrack TrkMaterialOnTrack TrkMeasurementBase TrkPrepRawData diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandleBase.cxx b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandleBase.cxx index be99be51812f3a25848b52255256d4962169c07d..39ef6f97749d8df801fbbd7930fb3dd369d2b6bb 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandleBase.cxx +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandleBase.cxx @@ -58,6 +58,7 @@ #include "GeoPrimitives/GeoPrimitives.h" #include <cassert> +#include <math.h> @@ -717,9 +718,10 @@ void TrackHandleBase::Imp::rebuild3DObjects() // SoCoin classes don't support Unincode here, apparently. // text << VP1Msg::str("(")+QChar(0x03B7)+","+QChar(0x03D5)+VP1Msg::str(")=(") // +VP1Msg::str(mom.pseudoRapidity())+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() ))+VP1Msg::str(")"); - double pseudoRapidity = mom.eta(); - text << VP1Msg::str("(eta,phi)=(") - +VP1Msg::str(pseudoRapidity)+VP1Msg::str(",")+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() ))+VP1Msg::str(")"); + // double pseudoRapidity = mom.eta(); + double polarAngle = mom.theta(); + text << VP1Msg::str("(theta,phi)=(") + +VP1Msg::str(polarAngle)+VP1Msg::str(",")+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() ))+VP1Msg::str(")"); } } @@ -1360,11 +1362,13 @@ QStringList TrackHandleBase::baseInfo() const } else { l << "Momentum [GeV]: "+VP1Msg::str(mom); l << "|Pt|/|P| [GeV]: "+VP1Msg::str(mom.perp())+" / " + VP1Msg::str(mom.mag()); - l << VP1Msg::str("(")+QChar(0x03B7)+","+QChar(0x03D5)+VP1Msg::str(")=(") - +VP1Msg::str(mom.eta())+VP1Msg::str(",")+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() ))+VP1Msg::str(")"); + l << VP1Msg::str("(")+QChar(0x03B8)+","+QChar(0x03D5)+VP1Msg::str(")=(") + +VP1Msg::str(mom.theta())+VP1Msg::str(",")+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() ))+VP1Msg::str(")"); - l << "Eta: "+VP1Msg::str(mom.eta()); + l << "Theta: "+VP1Msg::str(mom.theta()); l << "Phi: "+VP1Msg::str(VP1LinAlgUtils::phiFromXY(mom.x(), mom.y() )); + l << "ThetaXZ: "+VP1Msg::str(atan2(mom.x(), mom.z() )); + l << "ThetaYZ: "+VP1Msg::str(atan2(mom.y(), mom.z() )); } l<<"Hit summary: SCT["+QString::number(getNSCTHits())+"]."; diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandle_TrkTrack.cxx b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandle_TrkTrack.cxx index dbcd53e653e1c35b9e87f6a3b2a3c946ffcc9e28..4ca64b733809ad98a9ee2e20ddcc1f75433df71d 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandle_TrkTrack.cxx +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackHandle_TrkTrack.cxx @@ -47,6 +47,7 @@ TrackHandle_TrkTrack::~TrackHandle_TrkTrack() //____________________________________________________________________ QStringList TrackHandle_TrkTrack::clicked() const { + ensureInitSubSysHitInfo(); // Object browser stuff QTreeWidget* trkObjBrowser = common()->controller()->trackObjBrowser(); if (trkObjBrowser){ diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrkObjToString.cxx b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrkObjToString.cxx index 75c1c1977ca33c5a81261ebf4ea69edc5b8051a7..3853682034c8578d23c403ad16a32b21ef9af6bc 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrkObjToString.cxx +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrkObjToString.cxx @@ -17,6 +17,8 @@ //ROTs #include "TrkRIO_OnTrack/RIO_OnTrack.h" +#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" + // #include "InDetRIO_OnTrack/PixelClusterOnTrack.h" // #include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h" // #include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" @@ -61,8 +63,8 @@ TrkObjToString::type(const Trk::MeasurementBase* meas) // ROTS // if (dynamic_cast<const InDet::PixelClusterOnTrack*> (meas)) // {return TrkObjToString::Pixel;} - // if (dynamic_cast<const InDet::SCT_ClusterOnTrack*> (meas)) - // {return TrkObjToString::SCT;} + if (dynamic_cast<const Tracker::FaserSCT_ClusterOnTrack*> (meas)) + {return TrkObjToString::SCT;} } else { // Other types if (dynamic_cast<const Trk::CompetingRIOsOnTrack*>(meas) )