Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wfilali/calypso
  • andesai/calypso
  • sazhang/calypso
  • yuxu/calypso
  • bewilson/calypso
  • ovaldesm/calypso
  • xai/calypso
  • ymaruya/calypso
  • anburger/calypso
  • seley/calypso
  • sudatta/calypso
  • notarann/calypso
  • hhjelm/calypso
  • tarai/calypso
  • lmccoy/calypso
  • agarabag/calypso
  • fneuhaus/calypso
  • vlian/calypso
  • yechou/calypso
  • vlian/calypso-official
  • fasermc/calypso
  • schsu/calypso
  • maprim/calypso
  • cantel/calypso
  • jwspence/calypso
  • diwang/calypso
  • ccavanag/calypso
  • gwilliam/calypso
  • asalman/calypso
  • toinada/calypso
  • jboyd/calypso
  • abarkley/calypso
  • yafik/calypso
  • cpandini/calypso
  • tboeckh/calypso
  • sshively/calypso
  • keli/calypso
  • dfellers/calypso
  • torrence/calypso
  • coccaro/calypso
  • dcasper/calypso
  • faser/calypso
42 results
Show changes
Commits on Source (22)
...@@ -23,3 +23,4 @@ tmp.* ...@@ -23,3 +23,4 @@ tmp.*
.idea/** .idea/**
cmake-debug-build/** cmake-debug-build/**
.vscode/** .vscode/**
.vscode
[submodule "faser-common"] [submodule "faser-common"]
path = faser-common path = faser-common
url = https://gitlab.cern.ch/faser/faser-common.git url = ../../faser/faser-common.git
This diff is collapsed.
################################################################################
# Package: TrackerClusterFIt
################################################################################
# Declare the package name:
atlas_subdir( ClusterReadExample )
# Component(s) in the package:
atlas_add_component( ClusterReadExample
src/*.cxx src/*.h
src/components/*.cxx
LINK_LIBRARIES AthenaBaseComps AthViews StoreGateLib SGtests Identifier GaudiKernel TrackerRawData TrackerPrepRawData FaserDetDescr TrackerIdentifier TrackerReadoutGeometry xAODFaserTrigger TrkTrack TrkEventPrimitives TrackerSimEvent TrkRIO_OnTrack GeneratorObjects)
atlas_install_python_modules( python/*.py )
Example algorithm to access RDO data & its corresponding simulation data (given generated from simulation)
For each RDO, uses the identifier and TrackerSimDataCollection to get the TrackerSimData associated with it
Then loops through the energy deposits of that TrackerSimData to find the particle barcode of the highest energy deposit
Then find the FaserSiHit corresponding to the particle with the same barcode collision at the same place as the RDO
And plots the RDO GroupSize versus the incident angle the particle made when it was detected
Currently reads from a RDO root file named my.RDO.pool.root, which can be generated from the digitization:
https://gitlab.cern.ch/faser/calypso/tree/master/Tracker/TrackerDigitization/FaserSCT_Digitization
After calypso is installed and compiled & digitization generated
run > python python/RDOReadExample/RDOReadExampleConfig.py
\ No newline at end of file
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#!/usr/bin/env python
import sys
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
def ClusterReadExampleCfg(flags, **kwargs):
"""Return ComponentAccumulator for ClusterReadAlg"""
acc = ComponentAccumulator()
# clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags))
# kwargs.setdefault("SCT_ClusteringTool", clusterTool)
# kwargs.setdefault("DataObjectName", "SCT_RDOs")
kwargs.setdefault("ClustersName", "SCT_ClusterContainer")
# kwargs.setdefault("SCT_FlaggedCondData", "SCT_Flags")
Tracker__ClusterReadAlg=CompFactory.ClusterReadAlg
acc.addEventAlgo(Tracker__ClusterReadAlg(**kwargs))
thistSvc = CompFactory.THistSvc()
thistSvc.Output += ["HIST DATAFILE='ClusterReadHistograms.root' OPT='RECREATE'"]
acc.addService(thistSvc)
return acc
if __name__ == "__main__":
from AthenaCommon.Configurable import Configurable
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
Configurable.configurableRun3Behavior = True
# Flags for this job
ConfigFlags.Input.isMC = True # Needed to bypass autoconfig
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Needed to bypass autoconfig, only the "OFLCOND" matters at the moment
ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry
#ConfigFlags.Detector.SimulateFaserSCT = True
ConfigFlags.Input.Files = ["run001332.ESD.pool.root"]#["my.COSMICHITS.pool.root"]
ConfigFlags.lock()
# Configure components
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolReadCfg(ConfigFlags))
# Set things up to create a conditions DB with neutral Tracker alignment transforms
acc.merge(ClusterReadExampleCfg(ConfigFlags))
# Execute and finish
sys.exit(int(acc.run(maxEvents=-1).isFailure()))
# __author__ = 'Savannah Shively'
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/** @file ClusterReadAlg.cxx
* Implementation file for the ClusterReadAlg class.
* @author Dave Casper
* @date 28 February 2021
*/
#include "ClusterReadAlg.h"
#include "TrackerPrepRawData/FaserSCT_Cluster.h"
#include "FaserDetDescr/FaserDetectorID.h"
#include "TrackerIdentifier/FaserSCT_ID.h"
#include "TrkEventPrimitives/FitQuality.h"
#include "TrkEventPrimitives/ParticleHypothesis.h"
#include "TrkEventPrimitives/LocalParameters.h"
#include "TrkRIO_OnTrack/RIO_OnTrack.h"
#include "StoreGate/ReadHandle.h"
#include <TH1F.h>
#include <TTree.h>
#include <TBranch.h>
/*
To add as new branches:
POOLCollectiontree - IsSimulation (0 or 1)
- event number
- event time
check issimulation before continuing
- coords, energy deposit, etc
*/
//static const std::string moduleFailureReason{"ClusterReadAlg: Exceeds max clusters"};
// Constructor with parameters:
ClusterReadAlg::ClusterReadAlg(const std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm(name, pSvcLocator),
AthHistogramming( name ),
m_idHelper{nullptr},
m_histSvc ( "THistSvc/THistSvc", name ){}
// Initialize method:
StatusCode ClusterReadAlg::initialize() {
ATH_MSG_INFO("ClusterReadAlg::initialize()");
ATH_CHECK(m_mcEventKey.initialize() );
ATH_CHECK( m_faserSiHitKey.initialize() );
//TH_CHECK( m_faserRdoKey.initialize());
//ATH_CHECK( m_sctMap.initialize());
ATH_CHECK(m_faserTriggerDataKey.initialize());
ATH_CHECK(m_clusterContainerKey.initialize());
ATH_CHECK(m_trackCollection.initialize());
// Get the SCT ID helper
ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID"));
// Histograms
// Tree
m_tree = new TTree("residTree","Cosmics residuals");
m_tree->Branch("id", &m_hash, "id/I");
m_tree->Branch("mc_Event", &m_mcEventKey, "mcEvent/F");
m_tree->Branch("waveformExists", &m_waveformExists, "waveform/B");
m_tree->Branch("station", &m_station, "station/I");
//hist test
m_hist = new TH1D("Stations", "Stations hit", 4, 0, 3);
ATH_CHECK(histSvc()->regHist("/HIST/myhist", m_hist));
m_hist2 = new TH1D("EnergyLoss", "Energy",100,0,0.1);
ATH_CHECK(histSvc()->regHist("/HIST/Ehist", m_hist2));
return StatusCode::SUCCESS;
}
// Execute method:
StatusCode ClusterReadAlg::execute(const EventContext& ctx) const
{
++m_numberOfEvents;
setFilterPassed(false, ctx);
SG::WriteHandle trackContainer{m_trackCollection, ctx};
std::unique_ptr<TrackCollection> outputTracks = std::make_unique<TrackCollection>();
SG::ReadHandle<xAOD::FaserTriggerData> triggerContainer{m_faserTriggerDataKey, ctx};
m_triggerisValid = triggerContainer.isValid();
++m_numberOfTriggeredEvents;
SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> clusterContainer{m_clusterContainerKey, ctx};
m_clusterisValid = clusterContainer.isValid();
// Loop over stations
ATH_CHECK(trackContainer.record(std::move(outputTracks)));
//RDO borrowed stuff
// Handles created from handle keys behave like pointers to the corresponding container
SG::ReadHandle<McEventCollection> h_mcEvents(m_mcEventKey);
ATH_MSG_INFO("Read McEventContainer with " << h_mcEvents->size() << " events");
ATH_MSG_INFO("\n\nTRIGGERS: Cluster:"<<m_clusterisValid<<" Trigger:"<<m_triggerisValid);
if (h_mcEvents->size() == 0) return StatusCode::FAILURE;
if (m_clusterisValid || m_triggerisValid) {
m_waveformExists = true;
}
if (m_clusterisValid && m_triggerisValid) {
m_allTriggered = true;
ATH_MSG_INFO("\n\nALL TRIGGERED\n\n");
}
// h_mcEvents->at(0)->print( msg().stream() );
SG::ReadHandle<FaserSiHitCollection> h_siHits(m_faserSiHitKey);
ATH_MSG_INFO("Read FaserSiHitCollection with " << h_siHits->size() << " hits");
for (const FaserSiHit& hit : *h_siHits){
int station= hit.getStation();
int plane =hit.getPlane();
int row =hit.getRow();
int module = hit.getModule();
int sensor = hit.getSensor();
float energyloss= hit.energyLoss();
//std::cout<<"St:"<<station<<"\tPl:"<<plane<<"\tMod:"<<module<<"\n";
++m_station[station];
m_hist->Fill(station);
if (energyloss!=0) {
m_hist2->Fill(energyloss);
std::cout<<"\nENERGY LOSS"<<energyloss<<'\n';
}
}
//SG::ReadHandle<FaserSCT_RDO_Container> h_sctRDO(m_faserRdoKey);
//SG::ReadHandle<TrackerSimDataCollection> h_collectionMap(m_sctMap);
m_tree->Fill();
// Done
return StatusCode::SUCCESS;
}
// Finalize method:
StatusCode ClusterReadAlg::finalize()
{
ATH_MSG_INFO("ClusterReadAlg::finalize()");
ATH_MSG_INFO( m_numberOfEvents << " events processed" );
ATH_MSG_INFO( m_numberOfTriggeredEvents << " triggered events processed" );
ATH_MSG_INFO( m_numberOfClusterCollection<< " cluster collections processed" );
ATH_MSG_INFO( m_numberOfCluster<< " cluster processed" );
ATH_MSG_INFO("station distribution" << m_station[0] <<" "<< m_station[1]<<" "<< m_station[2]<< m_station[3]);
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2021 CERN for the benefit of the FASER collaboration
*/
/** @file ClusterReadAlg
* Header file for the ClusterReadAlg class (an Algorithm).
* @author Dave Casper
* @date 28 February 2021
*/
#ifndef FASERCLUSTERREAD_CLUSTERREADALG_H
#define FASERCLUSTERREAD_CLUSTERREADALG_H
// Base class
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "AthenaBaseComps/AthHistogramming.h"
////Next contains a typedef so cannot be fwd declared
#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h"
#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h"
#include "TrackerPrepRawData/TrackerClusterContainer.h"
#include "Identifier/IdentifierHash.h"
#include "xAODFaserTrigger/FaserTriggerData.h"
#include "TrkTrack/TrackCollection.h"
//Gaudi
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
//STL
#include <map>
#include <string>
//RDO
#include <TH1.h>
#include <math.h>
#include <TProfile.h>
#include "GeneratorObjects/McEventCollection.h"
#include "TrackerSimEvent/FaserSiHitCollection.h"
#include "TrackerRawData/FaserSCT_RDO_Container.h"
//#include "TrackerSimData/TrackerSimDataCollection.h"
class FaserSCT_ID;
class ISvcLocator;
class StatusCode;
class TH1;
class TTree;
namespace Trk
{
class TrackStateOnSurface;
}
/**
* @class SCT_Clusterization
* @brief Form clusters from SCT Raw Data Objects
* The class loops over an RDO grouping strips and creating collections of clusters, subsequently recorded in StoreGate
* Uses SCT_ConditionsTools to determine which strips to include.
*/
class ClusterReadAlg : public AthReentrantAlgorithm, AthHistogramming
{
public:
/// Constructor with parameters:
ClusterReadAlg(const std::string& name, ISvcLocator* pSvcLocator);
virtual ~ClusterReadAlg(){};
/** @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; }
//@}
const ServiceHandle<ITHistSvc>& histSvc() const;
private:
/** @name Disallow default instantiation, copy, assignment */
//@{
ClusterReadAlg() = delete;
ClusterReadAlg(const ClusterReadAlg&) = delete;
ClusterReadAlg &operator=(const ClusterReadAlg&) = delete;
//@}
const FaserSCT_ID* m_idHelper;
SG::ReadHandleKey<xAOD::FaserTriggerData> m_faserTriggerDataKey { this, "FaserTriggerDataKey", "FaserTriggerData", "ReadHandleKey for xAOD::FaserTriggerData" };
SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_clusterContainerKey { this, "ClustersName", "SCT_ClusterContainer", "FaserSCT cluster container" };
SG::WriteHandleKey<TrackCollection> m_trackCollection { this, "OutputCollection", "ClusterRead", "Output track collection name" };
DoubleProperty m_zCenter { this, "ZCenter", 2300.0, "Global z position at which to reconstruct track parameters"};
UnsignedIntegerProperty m_triggerMask { this, "TriggerMask", 0x0, "Trigger mask to analyze (0 = pass all)" };
/// a handle on the Hist/TTree registration service
ServiceHandle<ITHistSvc> m_histSvc;
//RDO
SG::ReadHandleKey<McEventCollection> m_mcEventKey { this, "McEventCollection", "TruthEvent" };
SG::ReadHandleKey<FaserSiHitCollection> m_faserSiHitKey { this, "FaserSiHitCollection", "SCT_Hits" };
SG::ReadHandleKey<FaserSCT_RDO_Container> m_faserRdoKey { this, "FaserSCT_RDO_Container", "SCT_RDOs"};
//SG::ReadHandleKey<TrackerSimDataCollection> m_sctMap {this, "TrackerSimDataCollection", "SCT_SDO_Map"};
mutable TTree* m_tree;
mutable int m_hash;
mutable bool m_waveformExists=false;
mutable bool m_allTriggered=false;
mutable int m_station[5]={}; //replace with coordinate vector later
mutable float m_energyLoss;
mutable std::atomic<int> m_numberOfEvents{0};
mutable std::atomic<int> m_numberOfTriggeredEvents{0};
mutable std::atomic<int> m_numberOfClusterCollection{0};
mutable std::atomic<int> m_numberOfCluster{0};
//isvalids
mutable bool m_triggerisValid = false;
mutable bool m_clusterisValid = false;
//RDO
TH1* m_hist; // Example histogram
TH1* m_hist2;
TProfile* m_hprof;
};
// For the THistSvc
inline const ServiceHandle<ITHistSvc>& ClusterReadAlg::histSvc() const
{
return m_histSvc;
}
#endif // FASERCLUSTERREAD_CLUSTERREADLG_H
#include "../ClusterReadAlg.h"
DECLARE_COMPONENT( ClusterReadAlg ) //change alg name if update file/class etc
\ No newline at end of file