2 #include <EVENT/LCCollection.h>
3 #include <EVENT/SimCalorimeterHit.h>
4 #include <IMPL/CalorimeterHitImpl.h>
5 #include <IMPL/LCCollectionVec.h>
6 #include <IMPL/LCFlagImpl.h>
7 #include <IMPL/LCRelationImpl.h>
8 #include <EVENT/LCParameters.h>
9 #include <UTIL/CellIDDecoder.h>
17 #include <marlin/Global.h>
18 #include <gear/GEAR.h>
19 #include <gear/CalorimeterParameters.h>
20 #include <gear/LayerLayout.h>
24 using namespace lcio ;
25 using namespace marlin ;
33 _description =
"Performs simple digitization of sim muon hits..." ;
35 std::vector<std::string> muonCollections;
37 muonCollections.push_back(std::string(
"yoke03_MuonBarrel"));
38 muonCollections.push_back(std::string(
"yoke03_MuonEndCap"));
39 muonCollections.push_back(std::string(
"yoke03_MuonPlug"));
42 registerInputCollections( LCIO::SIMCALORIMETERHIT,
44 "Muon Collection Names" ,
48 registerOutputCollection( LCIO::CALORIMETERHIT,
49 "MUONOutputCollection" ,
50 "Muon Collection of real Hits" ,
52 std::string(
"MUON")) ;
54 registerOutputCollection( LCIO::LCRELATION,
55 "RelationOutputCollection" ,
56 "CaloHit Relation Collection" ,
58 std::string(
"RelationMuonHit")) ;
60 registerProcessorParameter(
"MuonThreshold" ,
61 "Threshold for Muon Hits in GeV" ,
65 registerProcessorParameter(
"CalibrMUON" ,
66 "Calibration coefficients for MUON" ,
70 registerProcessorParameter(
"MaxHitEnergyMUON",
71 "maximum hit energy for a MUON hit" ,
75 IntVec keepBarrelLayersVec, keepEndcapLayersVec;
77 registerProcessorParameter(
"KeepBarrelLayersVec" ,
78 "Vector of Barrel layers to be kept. Layers start at 1!",
82 registerProcessorParameter(
"KeepEndcapLayersVec" ,
83 "Vector of Endcap layers to be kept. Layers start at 1!",
88 registerProcessorParameter(
"CellIDLayerString" ,
89 "name of the part of the cellID that holds the layer" ,
102 CellIDDecoder<SimCalorimeterHit>::setDefaultEncoding(
"M:3,S-1:3,I:9,J:9,K-1:6") ;
106 int layersEndcap=0, layersBarrel=0;
109 layersBarrel = Global::GEAR->getYokeBarrelParameters().getLayerLayout().getNLayers();
110 }
catch( gear::UnknownParameterException&
e ){
111 streamlog_out(WARNING) <<
" oops - no Yoke Barrel available " << std::endl ;
114 layersEndcap = Global::GEAR->getYokeEndcapParameters().getLayerLayout().getNLayers();
115 }
catch( gear::UnknownParameterException& e ){
116 streamlog_out(WARNING) <<
" oops - no Yoke Endcap available " << std::endl ;
122 for(
int i = 0; i < layersBarrel; ++i) {
134 for(
int i = 0; i < layersEndcap; ++i) {
157 streamlog_out( DEBUG ) <<
" process event : " << evt->getEventNumber()
158 <<
" - run " << evt->getRunNumber() << std::endl ;
166 flag.setBit(LCIO::CHBIT_LONG);
168 muoncol->setFlag(flag.getFlag());
180 CHT::Layout caloLayout = layoutFromString( colName ) ;
184 initString = col->getParameters().getStringVal(LCIO::CellIDEncoding);
185 int numElements = col->getNumberOfElements();
186 CellIDDecoder<SimCalorimeterHit> idDecoder( col );
187 for (
int j(0); j < numElements; ++j) {
188 SimCalorimeterHit * hit =
dynamic_cast<SimCalorimeterHit*
>( col->getElementAt( j ) ) ;
189 float energy = hit->getEnergy();
190 int cellid = hit->getCellID0();
191 int cellid1 = hit->getCellID1();
195 if( !
useLayer(caloLayout, layer) )
continue;
196 float calibr_coeff(1.);
198 float hitEnergy = calibr_coeff*energy;
201 CalorimeterHitImpl * calhit =
new CalorimeterHitImpl();
202 calhit->setCellID0(cellid);
203 calhit->setCellID1(cellid1);
204 calhit->setEnergy(hitEnergy);
205 calhit->setPosition(hit->getPosition());
206 calhit->setType( CHT(
CHT::muon, CHT::yoke, caloLayout , idDecoder(hit)[ _cellIDLayerString ] ) );
207 calhit->setRawHit(hit);
208 muoncol->addElement(calhit);
209 LCRelationImpl *rel =
new LCRelationImpl(calhit,hit,1.);
210 relcol->addElement( rel );
215 catch(DataNotAvailableException &
e){
218 muoncol->parameters().setValue(LCIO::CellIDEncoding,initString);
bool useLayer(CHT::Layout caloLayout, unsigned int layer)
virtual void processRunHeader(LCRunHeader *run)
std::string _outputMuonCollection
virtual void check(LCEvent *evt)
std::vector< bool > _useLayersEndcapVec
virtual void processEvent(LCEvent *evt)
IntVec _layersToKeepEndcapVec
IntVec _layersToKeepBarrelVec
SimpleMuonDigi aSimpleMuonDigi
std::string _outputRelCollection
std::string _cellIDLayerString
std::vector< LCCollection * > LCCollectionVec
std::vector< std::string > _muonCollections
std::vector< bool > _useLayersBarrelVec