2 #include <gsl/gsl_sf_gamma.h>
5 #include <marlin/Global.h>
6 #include <GeometryUtil.h>
8 #include <DD4hep/DD4hepUnits.h>
9 #include <DD4hep/DetType.h>
10 #include <DD4hep/DetectorSelector.h>
11 #include <DD4hep/Detector.h>
12 #include <DDRec/DetectorData.h>
14 #include "EVENT/ReconstructedParticle.h"
15 #include "IMPL/ClusterImpl.h"
18 #include "CalorimeterHitType.h"
29 : Processor(
"ComputeShowerShapesProcessor") {
32 _description =
"Cluster Shower Profile extraction using Fitting" ;
33 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
35 "PFO collection name",
37 std::string(
"PandoraPFOs"));
39 registerProcessorParameter(
"ClusterCollectionName",
40 "Cluster collection name",
42 std::string(
"PandoraClusters"));
44 registerProcessorParameter(
"RadiationLength_Ecal",
45 "RadiationLength of Absorbers",
49 registerProcessorParameter(
"RadiationLength_Hcal",
50 "RadiationLength of Absorbers",
54 registerProcessorParameter(
"MoliereRadius_Ecal",
55 "Moliere radius of Absorbers",
59 registerProcessorParameter(
"MoliereRadius_Hcal",
60 "Moliere radius of Absorbers",
67 streamlog_out(DEBUG) <<
" init called " << std::endl ;
72 std::vector<std::string> ClusterShapeNames;
73 ClusterShapeNames.push_back(
"chi2");
74 ClusterShapeNames.push_back(
"max_Ed");
75 ClusterShapeNames.push_back(
"showerMax");
76 ClusterShapeNames.push_back(
"absorption_Length");
77 ClusterShapeNames.push_back(
"showerMax_photon");
78 ClusterShapeNames.push_back(
"showerMax_ratio");
79 ClusterShapeNames.push_back(
"Rm");
80 ClusterShapeNames.push_back(
"showerstart");
81 ClusterShapeNames.push_back(
"functionstart");
82 ClusterShapeNames.push_back(
"a");
83 ClusterShapeNames.push_back(
"b");
84 ClusterShapeNames.push_back(
"c");
85 ClusterShapeNames.push_back(
"d");
86 ClusterShapeNames.push_back(
"max_Ed_hit");
87 ClusterShapeNames.push_back(
"showerMax_hit");
88 ClusterShapeNames.push_back(
"xt90");
89 ClusterShapeNames.push_back(
"xl20");
90 ClusterShapeNames.push_back(
"depth_of_cluster");
91 ClusterShapeNames.push_back(
"meanOf_hitradius");
92 ClusterShapeNames.push_back(
"rmsOf_hitradius");
95 _PFOCol->parameters().setValues(
"ClusterShapeParameters",ClusterShapeNames);
106 int nClusters =
_PFOCol->getNumberOfElements();
108 const unsigned int ecal_Index(0) ;
109 const unsigned int hcal_Index(1) ;
110 const unsigned int yoke_Index(2) ;
111 const unsigned int lcal_Index(3) ;
112 const unsigned int lhcal_Index(4);
113 const unsigned int bcal_Index(5) ;
115 for (
int iClu=0;iClu<nClusters;++iClu) {
116 ReconstructedParticle* part=(ReconstructedParticle*)
_PFOCol->getElementAt( iClu );
118 for(
unsigned int jClu=0;jClu<part->getClusters().size();jClu++){
119 ClusterImpl* pCluster = (ClusterImpl*) part->getClusters()[jClu];
121 const unsigned int nHitsInCluster(pCluster->getCalorimeterHits().size());
123 float clusterEnergy(0.);
124 float *pHitE =
new float[nHitsInCluster];
125 float *pHitX =
new float[nHitsInCluster];
126 float *pHitY =
new float[nHitsInCluster];
127 float *pHitZ =
new float[nHitsInCluster];
128 int *typ =
new int[nHitsInCluster];
130 for (
unsigned int iHit = 0; iHit < nHitsInCluster; ++iHit)
132 EVENT::CalorimeterHit *pCalorimeterHit = (CalorimeterHit*)(pCluster->getCalorimeterHits()[iHit]);
134 const float caloHitEnergy(pCalorimeterHit->getEnergy());
136 pHitE[iHit] = caloHitEnergy;
137 pHitX[iHit] = pCalorimeterHit->getPosition()[0];
138 pHitY[iHit] = pCalorimeterHit->getPosition()[1];
139 pHitZ[iHit] = pCalorimeterHit->getPosition()[2];
140 clusterEnergy += caloHitEnergy;
142 switch (CHT(pCalorimeterHit->getType()).caloID())
144 case CHT::ecal: typ[iHit]=ecal_Index;
break;
145 case CHT::hcal: typ[iHit]=hcal_Index;
break;
146 case CHT::yoke: typ[iHit]=yoke_Index;
break;
147 case CHT::lcal: typ[iHit]=lcal_Index;
break;
148 case CHT::lhcal: typ[iHit]=lhcal_Index;
break;
149 case CHT::bcal: typ[iHit]=bcal_Index;
break;
150 default: streamlog_out(DEBUG) <<
" no subdetector found for hit with type: " << pCalorimeterHit->getType() << std::endl;
154 pClusterShapes =
new ClusterShapes(nHitsInCluster, pHitE, pHitX, pHitY, pHitZ);
159 float chi2,a,b,c,d,xl0,CoG[3],xStart[3];
169 const dd4hep::rec::LayeredCalorimeterData * eCalBarrelExtension= MarlinUtil::getLayeredCalorimeterData( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::BARREL),
170 ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) );
171 float ecalrad = eCalBarrelExtension->extent[0]/
dd4hep::mm;
175 const dd4hep::rec::LayeredCalorimeterData * eCalEndcapExtension= MarlinUtil::getLayeredCalorimeterData( ( dd4hep::DetType::CALORIMETER | dd4hep::DetType::ELECTROMAGNETIC | dd4hep::DetType::ENDCAP),
176 ( dd4hep::DetType::AUXILIARY | dd4hep::DetType::FORWARD ) );
177 float plugz = eCalEndcapExtension->extent[2]/
dd4hep::mm;
181 float lCoG=0.0,tmpcos=0.0,tmpsin=0.0,detsurface=0.0;
189 lCoG=sqrt(CoG[0]*CoG[0]+CoG[1]*CoG[1]+CoG[2]*CoG[2]);
191 tmpsin=sqrt(CoG[0]*CoG[0]+CoG[1]*CoG[1])/lCoG;
192 pClusterShapes->fit3DProfile(chi2,a,b,c,d,xl0,xStart,index_xStart,X0,Rm);
193 float lxstart=sqrt(xStart[0]*xStart[0]+xStart[1]*xStart[1]);
195 if(fabs(xStart[2])<plugz){
196 detsurface=(lxstart-ecalrad)/tmpsin;
198 detsurface=(fabs(xStart[2])-plugz)/fabs(tmpcos);
202 float maxed = a*c*gsl_sf_gammainv(b)*pow(b-1,b-1)*exp(-b+1);
203 float maxlength_pho=(1.0*std::log(clusterEnergy/(X0[0] * 0.021/Rm[0]))-0.5);
205 TVector3 clusdirection(CoG[0]-xStart[0],CoG[1]-xStart[1],CoG[2]-xStart[2]);
208 EVENT::FloatVec shapes;
210 shapes.push_back(chi2);
211 shapes.push_back(maxed);
212 shapes.push_back(((b-1.0)*X0[0]/c+xl0+detsurface)/(2.0*X0[0]));
213 shapes.push_back(1/fabs(d));
214 shapes.push_back(maxlength_pho);
215 shapes.push_back(((b-1.0)/c)/maxlength_pho);
216 shapes.push_back(Rm[0]*2.0);
217 shapes.push_back(detsurface);
218 shapes.push_back(xl0);
224 shapes.push_back(
pClusterShapes->getEmax(xStart,index_xStart,X0,Rm));
225 shapes.push_back(
pClusterShapes->getsmax(xStart,index_xStart,X0,Rm));
226 shapes.push_back(
pClusterShapes->getxt90(xStart,index_xStart,X0,Rm));
227 shapes.push_back(
pClusterShapes->getxl20(xStart,index_xStart,X0,Rm));
230 shapes.push_back(clusdirection.Mag());
231 shapes.push_back(
pClusterShapes->getRhitMean(xStart,index_xStart,X0,Rm));
232 shapes.push_back(
pClusterShapes->getRhitRMS(xStart,index_xStart,X0,Rm));
235 pCluster->setShape(shapes);
238 delete[] pHitE;
delete[] pHitX;
delete[] pHitY;
delete[] pHitZ;
virtual void processRunHeader(LCRunHeader *run)
std::string _PfoCollection
ComputeShowerShapesProcessor aComputeShowerShapesProcessor
virtual void processEvent(LCEvent *evt)
virtual void init(LCEvent *evt)
std::string _ClusterCollection
ComputeShowerShapesProcessor()
virtual void check(LCEvent *evt)
ClusterShapes * pClusterShapes