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>
14 #include "CalorimeterHitType.h"
18 using namespace lcio ;
19 using namespace marlin ;
28 _description =
"Performs simple digitization of sim calo hits..." ;
30 std::vector<std::string> ecalCollections;
32 ecalCollections.push_back(std::string(
"ecal02_EcalBarrel"));
33 ecalCollections.push_back(std::string(
"ecal02_EcalEndcap"));
35 registerInputCollections( LCIO::SIMCALORIMETERHIT,
37 "ECAL Collection Names" ,
41 std::vector<std::string> hcalCollections;
43 hcalCollections.push_back(std::string(
"hcalFeScintillator_HcalBarrelEnd"));
44 hcalCollections.push_back(std::string(
"hcalFeScintillator_HcalBarrelReg"));
45 hcalCollections.push_back(std::string(
"hcalFeScintillator_HcalEndCaps"));
47 registerInputCollections( LCIO::SIMCALORIMETERHIT,
49 "HCAL Collection Names" ,
53 registerOutputCollection( LCIO::CALORIMETERHIT,
54 "ECALOutputCollection" ,
55 "ECAL Collection of real Hits" ,
57 std::string(
"ECAL")) ;
59 registerOutputCollection( LCIO::CALORIMETERHIT,
60 "HCALOutputCollection" ,
61 "HCAL Collection of real Hits" ,
63 std::string(
"HCAL")) ;
66 registerOutputCollection( LCIO::LCRELATION,
67 "RelationOutputCollection" ,
68 "CaloHit Relation Collection" ,
70 std::string(
"RelationCaloHit")) ;
72 registerProcessorParameter(
"ECALThreshold" ,
73 "Threshold for ECAL Hits in GeV" ,
77 registerProcessorParameter(
"HCALThreshold" ,
78 "Threshold for HCAL Hits in GeV" ,
83 std::vector<int> ecalLayers;
84 ecalLayers.push_back(30);
85 ecalLayers.push_back(100);
88 registerProcessorParameter(
"ECALLayers" ,
89 "Index of ECal Layers" ,
95 std::vector<int> hcalLayers;
96 hcalLayers.push_back(100);
98 registerProcessorParameter(
"HCALLayers" ,
99 "Index of HCal Layers" ,
104 std::vector<float> calibrEcal;
105 calibrEcal.push_back(31.3);
106 calibrEcal.push_back(83.0);
109 registerProcessorParameter(
"CalibrECAL" ,
110 "Calibration coefficients for ECAL" ,
115 std::vector<float> calibrHcal;
116 calibrHcal.push_back(27.3);
118 registerProcessorParameter(
"CalibrHCAL" ,
119 "Calibration coefficients for HCAL" ,
124 registerProcessorParameter(
"IfDigitalEcal" ,
130 registerProcessorParameter(
"IfDigitalHcal" ,
144 CellIDDecoder<SimCalorimeterHit>::setDefaultEncoding(
"M:3,S-1:3,I:9,J:9,K-1:6") ;
164 flag.setBit(LCIO::CHBIT_LONG);
166 ecalcol->setFlag(flag.getFlag());
167 hcalcol->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();
192 CalorimeterHitImpl * calhit =
new CalorimeterHitImpl();
193 int cellid = hit->getCellID0();
194 int cellid1 = hit->getCellID1();
195 float calibr_coeff(1.);
196 int layer = idDecoder(hit)[
"K-1"];
204 if (layer >= min && layer < max) {
209 calhit->setCellID0(cellid);
210 calhit->setCellID1(cellid1);
212 calhit->setEnergy(calibr_coeff);
215 calhit->setEnergy(calibr_coeff*energy);
217 calhit->setPosition(hit->getPosition());
219 calhit->setType( CHT( CHT::em, CHT::ecal, caloLayout , layer ) );
221 calhit->setRawHit(hit);
222 ecalcol->addElement(calhit);
223 LCRelationImpl *rel =
new LCRelationImpl(calhit,hit,1.);
224 relcol->addElement( rel );
229 catch(DataNotAvailableException &
e){
232 ecalcol->parameters().setValue(LCIO::CellIDEncoding,initString);
246 CHT::Layout caloLayout = layoutFromString( colName ) ;
251 initString = col->getParameters().getStringVal(LCIO::CellIDEncoding);
252 int numElements = col->getNumberOfElements();
253 CellIDDecoder<SimCalorimeterHit> idDecoder(col);
254 for (
int j(0); j < numElements; ++j) {
255 SimCalorimeterHit * hit =
dynamic_cast<SimCalorimeterHit*
>( col->getElementAt( j ) ) ;
256 float energy = hit->getEnergy();
260 CalorimeterHitImpl * calhit =
new CalorimeterHitImpl();
261 int cellid = hit->getCellID0();
262 int cellid1 = hit->getCellID1();
263 float calibr_coeff(1.);
264 int layer =idDecoder(hit)[
"K-1"];
272 if (layer >= min && layer < max) {
277 calhit->setCellID0(cellid);
278 calhit->setCellID1(cellid1);
280 calhit->setEnergy(calibr_coeff);
283 calhit->setEnergy(calibr_coeff*energy);
285 calhit->setPosition(hit->getPosition());
287 calhit->setType( CHT( CHT::had, CHT::hcal , caloLayout , layer ) );
289 calhit->setRawHit(hit);
290 hcalcol->addElement(calhit);
291 LCRelationImpl *rel =
new LCRelationImpl(calhit,hit,1.0);
292 relcol->addElement( rel );
297 catch(DataNotAvailableException &
e){
300 hcalcol->parameters().setValue(LCIO::CellIDEncoding,initString);
std::string _outputEcalCollection
virtual void check(LCEvent *evt)
std::vector< std::string > _ecalCollections
virtual void processEvent(LCEvent *evt)
std::vector< int > _hcalLayers
SimpleCaloDigi aSimpleCaloDigi
std::vector< int > _ecalLayers
std::string _outputRelCollection
std::string _outputHcalCollection
std::vector< std::string > _hcalCollections
virtual void processRunHeader(LCRunHeader *run)
std::vector< LCCollection * > LCCollectionVec
std::vector< float > _calibrCoeffHcal
std::vector< float > _calibrCoeffEcal