3 #include <marlin/Global.h>
5 #include <EVENT/LCCollection.h>
7 #include <IMPL/LCCollectionVec.h>
8 #include <IMPL/CalorimeterHitImpl.h>
9 #include <IMPL/LCRelationImpl.h>
11 #include <UTIL/LCRelationNavigator.h>
13 #include "CalorimeterHitType.h"
15 #include <EVENT/LCParameters.h>
16 #include <EVENT/SimCalorimeterHit.h>
24 #define RELATIONFROMTYPESTR "FromType"
25 #define RELATIONTOTYPESTR "ToType"
28 using namespace lcio ;
29 using namespace marlin ;
33 _description =
"Performs simple reconstruction of calo hits..." ;
35 std::vector < std::string > inputHitCollections;
36 registerInputCollections( LCIO::CALORIMETERHIT,
37 "inputHitCollections",
38 "input hit collection names",
42 std::vector < std::string > inputRelCollections;
43 registerInputCollections( LCIO::LCRELATION,
44 "inputRelationCollections",
45 "input relation collection names (digi<->sim), one per inputHitCollection",
50 std::vector < std::string > outputHitCollections;
51 registerProcessorParameter(
"outputHitCollections",
52 "output hit collection names",
54 outputHitCollections);
56 std::vector < std::string > outputRelCollections;
57 registerProcessorParameter(
"outputRelationCollections",
58 "output hit collection names",
60 outputRelCollections);
62 std::vector<int> calLayers;
63 registerProcessorParameter(
"calibration_layergroups" ,
64 "grouping of calo layers" ,
68 std::vector<float> calibrCoeff;
69 registerProcessorParameter(
"calibration_factorsMipGev" ,
70 "Calibration coefficients (MIP->shower GeV) of layers groups" ,
74 registerProcessorParameter(
"CellIDLayerString" ,
75 "name of the part of the cellID that holds the layer" ,
109 _flag.setBit(LCIO::CHBIT_LONG);
110 _flag.setBit(LCIO::RCHBIT_TIME);
127 streamlog_out ( DEBUG ) <<
"looking for hit, relation collection: " << colName <<
" " << relName << endl;
130 LCCollection * col = evt->getCollection( colName.c_str() ) ;
131 string initString = col->getParameters().getStringVal(LCIO::CellIDEncoding);
133 LCCollection * inrelcol = evt->getCollection( relName.c_str() ) ;
134 LCRelationNavigator navi(inrelcol);
137 _idDecoder =
new CellIDDecoder<CalorimeterHit> ( col );
141 newcol->setFlag(
_flag.getFlag());
149 int numElements = col->getNumberOfElements();
150 streamlog_out ( DEBUG ) << colName <<
" number of elements = " << numElements << endl;
152 for (
int j(0); j < numElements; ++j) {
153 CalorimeterHit * hit =
dynamic_cast<CalorimeterHit*
>( col->getElementAt( j ) ) ;
155 int cellid0 = hit->getCellID0();
156 int cellid1 = hit->getCellID1();
158 CalorimeterHitImpl * calhit =
new CalorimeterHitImpl();
162 calhit->setCellID0(cellid0);
163 calhit->setCellID1(cellid1);
164 calhit->setEnergy(energy);
165 calhit->setRawHit( hit->getRawHit() );
166 calhit->setTime( hit->getTime() );
167 calhit->setPosition( hit->getPosition() );
168 calhit->setType( hit->getType() );
170 newcol->addElement( calhit );
173 if ( navi.getRelatedToObjects( hit ) .size() > 0 ) {
174 SimCalorimeterHit* simhit = (SimCalorimeterHit*) navi.getRelatedToObjects(hit)[0];
176 relcol->addElement(
new LCRelationImpl(calhit,simhit,1.0) );
178 streamlog_out ( WARNING ) <<
"could not find relation to sim calo hit!" << endl;
184 newcol->parameters().setValue(LCIO::CellIDEncoding,initString);
189 catch(DataNotAvailableException &
e){
190 streamlog_out(DEBUG) <<
"could not find input ECAL collection " << colName << std::endl;
197 float calib_coeff = 0;
204 if (ilayer >= min && ilayer < max) {
209 assert( calib_coeff>0 );
virtual float reconstructEnergy(const CalorimeterHit *hit)=0
virtual void check(LCEvent *evt)
virtual void processEvent(LCEvent *evt)
std::vector< float > _calibrCoeff
std::vector< std::string > _outputHitCollections
std::vector< std::string > _outputRelCollections
std::vector< std::string > _inputHitCollections
float getLayerCalib(int ilayer)
#define RELATIONFROMTYPESTR
#define RELATIONTOTYPESTR
std::string _cellIDLayerString
std::vector< LCCollection * > LCCollectionVec
std::vector< std::string > _inputRelCollections
virtual void processRunHeader(LCRunHeader *run)
CellIDDecoder< CalorimeterHit > * _idDecoder
std::vector< int > _calLayers