Skip to content

Commit

Permalink
Update ported DDSimpleMuonDigi
Browse files Browse the repository at this point in the history
  • Loading branch information
Katerina Kostova authored and jmcarcell committed Aug 8, 2024
1 parent 58e3454 commit 3d1af12
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 374 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ endif()
include(CTest)

add_subdirectory(k4GaudiPandora)
add_subdirectory(DDSimpleMuon)

include(cmake/CreateProjectConfig.cmake)
37 changes: 19 additions & 18 deletions k4GaudiPandora/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,31 @@ See the License for the specific language governing permissions and
limitations under the License.
]]

file(GLOB _plugin_sources src/components/*.cpp )

list(APPEND _plugin_sources
# src/DDBFieldPlugin.cc
# src/DDCaloDigi.cc
# src/DDCaloHitCreator.cc
# src/DDExternalClusteringAlgorithm.cc
# src/DDGeometryCreator.cc
src/DDMCParticleCreator.cc
# src/DDPandoraPFANewProcessor.cc
# src/DDPfoCreator.cc
# src/DDScintillatorPpdDigi.cc
# src/DDSimpleMuonDigi.cc
# src/DDTrackCreatorBase.cc
# src/DDTrackCreatorCLIC.cc
# src/DDTrackCreatorILD.cc
)

set(_plugin_sources ${CMAKE_CURRENT_LIST_DIR}/
# src/components/*.cpp
src/CalorimeterHitType.cc
# src/DDBFieldPlugin.cc
# src/DDCaloDigi.cc
# src/DDCaloHitCreator.cc
# src/DDExternalClusteringAlgorithm.cc
# src/DDGeometryCreator.cc
# src/DDMCParticleCreator.cc
# src/DDPandoraPFANewProcessor.cc
# src/DDPfoCreator.cc
# src/DDScintillatorPpdDigi.cc
src/DDSimpleMuonDigi.cc
# src/DDTrackCreatorBase.cc
# src/DDTrackCreatorCLIC.cc
# src/DDTrackCreatorILD.cc
)

gaudi_add_module(k4GaudiPandoraPlugins
SOURCES ${_plugin_sources}
LINK Gaudi::GaudiKernel
k4FWCore::k4FWCore
EDM4HEP::edm4hep
DD4hep::DDRec
DD4hep::DDCore
)
target_include_directories(k4GaudiPandoraPlugins PRIVATE include)
install(TARGETS k4GaudiPandoraPlugins
Expand Down
211 changes: 72 additions & 139 deletions k4GaudiPandora/include/CalorimeterHitType.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
#ifndef CalorimeterHitType_h
/*
* Copyright (c) 2020-2024 Key4hep-Project.
*
* This file is part of Key4hep.
* See https://key4hep.github.io/key4hep-doc/ for further info.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CalorimeterHitType_h
#define CalorimeterHitType_h 1

#include <iostream>
Expand All @@ -9,188 +27,103 @@
* Example usage: <br>
* <pre>
* lcio::CalorimeterHit* cHit = .... ;
*
* // set the type (e.g. in digitization )
*
* // set the type (e.g. in digitization )
* cHit->setType( CHT( CHT::em , CHT::ecal , CHT::plug , 12 ) ) ;
*
* ...
*
* CHT cht = cHit->getType() ;
*
*
* // sum energies for electromagentic, hadronic and tailcatcher:
* if( cht.is( CHT::em ) )
* if( cht.is( CHT::em ) )
* e_em += cHit->getEnergy() ;
* else
* if ( cht.is(CHT::had ) )
* else
* if ( cht.is(CHT::had ) )
* e_had += cHit->getEnergy() ;
* else
* e_muon += cHit->getEnergy() ;
*
*
* // use only EcalPlug hits:
* if( cht.is( CHT::ecal) && cht.is( CHT::plug) )
*
* // get the layer number (e.g. for calibration or clustering)
* unsigned l = cht.layer() ;
* if( cht.is( CHT::ecal) && cht.is( CHT::plug) )
*
* // get the layer number (e.g. for calibration or clustering)
* unsigned l = cht.layer() ;
* // or directly :
* unsigned l = CHT( cHit->getType() ).layer() ;
*
* // detailed print:
* std::cout << CHT( cHit->getType() ) << std::endl ;
*
* </pre>
*
*
* F.Gaede, DESY, 12/2008
*/

class CHT{

class CHT {
public:

/** calorimeter types */
typedef enum {
em = 0 ,
had = 1,
muon = 2
} CaloType ;

enum CaloType { em = 0, had = 1, muon = 2 };

/** calo ids - specific to ILD */
typedef enum {
unknown = 0 ,
ecal = 1 ,
hcal = 2 ,
yoke = 3 ,
lcal = 4 ,
lhcal = 5 ,
bcal = 6
} CaloID ;

/** calo layout / subdetector */
typedef enum {
any = 0 ,
barrel = 1 ,
endcap = 2 ,
plug = 3 ,
ring = 4
} Layout ;


enum CaloID { unknown = 0, ecal = 1, hcal = 2, yoke = 3, lcal = 4, lhcal = 5, bcal = 6 };

/** calo layout / subdetector */
enum Layout { any = 0, barrel = 1, endcap = 2, plug = 3, ring = 4 };

/** C'tor for initialization from CalorimeterHit::getType() */
CHT(int type) :_type(type) {
}

CHT(int type) : m_type(type) {}

/** C'tor for encoding the calo type inforamtion */
CHT(CaloType c, CaloID n, Layout l , unsigned lay):
_type(c * fCaloType + n * fCaloID + l * fLayout + lay * fLayer)
{}

CHT(CaloType c, CaloID n, Layout l, unsigned lay)
: m_type(c * fCaloType + n * fCaloID + l * fLayout + lay * fLayer) {}

/** calorimeter type: CHT::em , CHT::had, CHT::muon */
CaloType caloType() const {
return (CaloType) (_type % fCaloID ) ;
}
CaloType caloType() const { return (CaloType)(m_type % fCaloID); }

/** calo ID - see enum CaloID for allowed values */
CaloID caloID() const {
return (CaloID) ( (_type % fLayout ) / fCaloID ) ;
}

CaloID caloID() const { return (CaloID)((m_type % fLayout) / fCaloID); }

/** calo layout - see enum layout for allowed values */
Layout layout() const {
return (Layout) ( (_type % fLayer ) / fLayout ) ;
}

Layout layout() const { return (Layout)((m_type % fLayer) / fLayout); }

/** calo layer of hit */
unsigned layer() const {
return unsigned ( _type ) / fLayer ;
}

bool is(CaloType t) const {
return caloType() == t ;
}

bool is(CaloID n) const {
return caloID() == n ;
}

bool is(Layout l) const {
return layout() == l ;
}

unsigned layer() const { return unsigned(m_type) / fLayer; }

bool is(CaloType t) const { return caloType() == t; }

bool is(CaloID n) const { return caloID() == n; }

bool is(Layout l) const { return layout() == l; }

/** automatic conversion to int */
operator int() const { return _type ;}
operator int() const { return m_type; }

/** explicit conversion to int */
int toInt() const { return _type ;}
int toInt() const { return m_type; }

protected:

int _type ;

static const int fCaloType = 1 ;
static const int fCaloID = 10 ;
static const int fLayout = 1000 ;
static const int fLayer = 10000 ;

} ;
int m_type;

/** detailed string for calo type */
std::ostream& operator<<(std::ostream& os, const CHT& cht) ;
static const int fCaloType = 1;
static const int fCaloID = 10;
static const int fLayout = 1000;
static const int fLayer = 10000;
};

/** detailed string for calo type */
std::ostream& operator<<(std::ostream& os, const CHT& cht);

/** Return Layout based on the collection name, e.g. if name contains tolower("endcap") CHT::endcap is returned. In case no known layout
is found, CHT::any is returned.*/
CHT::Layout layoutFromString(const std::string& name) ;
CHT::Layout layoutFromString(const std::string& name);

/** Return caloID based on the collection name, e.g. if name contains tolower("HCal") CHT::hcal is returned. In case no known type
is found, CHT::unknown is returned.*/
CHT::CaloID caloIDFromString(const std::string& name) ;
CHT::CaloID caloIDFromString(const std::string& name);

/** Return caloType from string, e.g. if name contains tolower("Had") CHT::had is returned. In case no known type
is found, CHT::em is returned.*/
CHT::CaloType caloTypeFromString(const std::string& name) ;



#endif


// int main(){

// CHT ct( CHT::em , CHT::ecal , CHT::plug , 12 ) ;

// std::cout << ct << std::endl ;

// std::cout << " caloType : " << ct.toInt() << std::endl ;

// std::cout << " caloID " << ct.caloID()
// << " is bcal " << ct.is( CHT::bcal )
// << " is muon " << ct.is( CHT::muon )
// << " layer " << ct.layer()
// << std::endl ;

// int i = CHT( CHT::muon , CHT::ecal , CHT::endcap , 123 ) ;

// std::cout << " type i : " << i << std::endl ;


// std::cout << " layer from int : " << CHT(i).layer() << std::endl ;

// CHT it(i) ;

// std::cout << " caloID " << it.caloID()
// << " is bcal " << it.is( CHT::bcal )
// << " is muon " << it.is( CHT::muon )
// << " is endcap " << it.is( CHT::endcap )
// << " layer " << it.layer()
// << " layout " << it.layout()
// << std::endl ;


// std::cout << it << std::endl ;

// CHT ct2 = 12345678 ;

// std::cout << ct2 << std::endl ;

// std::cout << " sizeof( CHT ) : " << sizeof( it ) << std::endl ;
CHT::CaloType caloTypeFromString(const std::string& name);

// }
#endif
Loading

0 comments on commit 3d1af12

Please sign in to comment.