53 #ifndef STROOT_STFMSPOINTMAKER_STFMSCLUSTERFITTER_H_
54 #define STROOT_STFMSPOINTMAKER_STFMSCLUSTERFITTER_H_
56 #ifndef __CINT__ // Hide std::array from CINT, as CINT cannot parse C++11
71 namespace FMSCluster {
72 typedef std::list<StFmsFittedPhoton> PhotonList;
99 Float_t scaleShowerShapeLarge , Float_t scaleShowerShapeSmall,
100 Int_t ShowerShapeWithAngle , Int_t MergeSmallToLarge,
double vertexZ);
135 Double_t
fitNPhoton(
const std::vector<double>& parameteres,
136 const std::vector<double>& steps,
137 const std::vector<double>& lower,
138 const std::vector<double>& up,
139 PhotonList* photons);
141 Double_t
fitNPhoton(
const std::vector<double>& parameters,
142 const std::vector<double>& lower,
143 const std::vector<double>& up,
144 PhotonList* photons);
162 #ifndef __CINT__ // Hide std::array from CINT, as CINT cannot parse C++11
163 Int_t
fit2Photon(
const std::array<double, 7>& parameters,
164 const std::array<double, 7>& steps,
165 const std::array<double, 7>& lower,
166 const std::array<double, 7>& upper,
167 PhotonList* photons);
189 static inline Double_t
energyDepositionInTower(Double_t x, Double_t y,Double_t xun, Double_t yun, Double_t* parmeters,Int_t MergeSmallToLarge,
double vertexz);
190 static inline Double_t energyDepositionInTowerSingleLayer(Double_t x, Double_t y, Double_t* parameters);
208 int runMinuitMinimization();
219 static inline Double_t energyDepositionDistribution(Double_t x, Double_t y, Double_t* par);
220 static Double_t energyDepositionDistribution(Double_t* x, Double_t* par);
230 static void minimizationFunctionNPhoton(Int_t& npar, Double_t* grad,
231 Double_t& fval, Double_t* par,
238 static void minimizationFunction2Photon(Int_t& nparam, Double_t* grad,
239 Double_t& fval, Double_t* param,
249 template<
class Container>
250 int setMinuitParameter(
int index,
const TString& name,
251 const Container& parameters,
252 const Container& steps,
253 const Container& lower,
254 const Container& upper);
263 int readMinuitParameters(std::vector<double>& parameters,
264 std::vector<double>& errors);
267 static Double_t mEnergySum;
268 Float_t mScaleShowerShapeLarge=1.0;
269 Float_t mScaleShowerShapeSmall=1.0;
270 Int_t mShowerShapeWithAngle;
271 Int_t mMergeSmallToLarge;
277 inline double asmsqrt(
double x) {
278 __asm__ (
"fsqrt" :
"+t" (x));
284 inline double showerShapeComponent(
double x,
double y,
double a,
double b) {
285 if (a == 0.0 || b == 0.0)
return 0.0;
286 return a * atan(x * y / (b * sqrt(b * b + x * x + y * y)));
289 inline Double_t StFmsClusterFitter::energyDepositionDistribution(
double x,
double y,
double* parameters){
290 constexpr
double ootwopi = 1.0/2.0/3.14159265358979323846;
291 return ( showerShapeComponent(x, y, parameters[1], parameters[4])
292 + showerShapeComponent(x, y, parameters[2], parameters[5])
293 + showerShapeComponent(x, y, parameters[3], parameters[6]) ) * ootwopi;
298 const double w = parameters[0]/2.0;
299 return energyDepositionDistribution(x-w,y-w,parameters)
300 - energyDepositionDistribution(x-w,y+w,parameters)
301 - energyDepositionDistribution(x+w,y-w,parameters)
302 + energyDepositionDistribution(x+w,y+w,parameters);
307 Double_t* parameters,Int_t mMerge ,
double vertexz){
310 Double_t ZcS[6] = {720.45,727.95,735.45,742.95,750.45,757.95};
311 Double_t ZcL[6] = {722.98,733.01,743.04,753.07,763.10,773.13};
314 Double_t Zmax,yoff,xoff;
315 if (parameters[0] > 4) {
316 yoff=98.8; Zmax=735.45; xoff=0.3; Zc=ZcL;
318 yoff=46.5; Zmax=735.45; xoff=0.93; Zc=ZcS;
320 if (mMerge>0) yoff=98.8;
322 Double_t tanx = ( xun + xoff) / (Zmax-vertexz);
323 Double_t tany = ( yoff - yun) / (Zmax-vertexz);
326 for(Int_t i = 0; i < 6; i++){
327 Double_t xc = xun + tanx*(Zc[i] - Zmax);
328 Double_t yc = yun - tany*(Zc[i] - Zmax);
330 sum += ( energyDepositionInTowerSingleLayer(x-xc,y-yc,¶meters[istart]) * parameters[istart+7]) ;
335 inline Double_t StFmsClusterFitter::energyDepositionInTowerSingleLayer(Double_t x, Double_t y, Double_t* parameters){
336 const double w = parameters[0];
339 if (w < 4) {ww1=3.822/2; ww2=3.875/2; }
340 else {ww1=5.812/2; ww2=5.812/2; }
342 return energyDepositionDistribution(x-ww1,y-ww2,parameters)
343 - energyDepositionDistribution(x-ww1,y+ww2,parameters)
344 - energyDepositionDistribution(x+ww1,y-ww2,parameters)
345 + energyDepositionDistribution(x+ww1,y+ww2,parameters);
350 #endif // STROOT_STFMSPOINTMAKER_STFMSCLUSTERFITTER_H_
Int_t fit2Photon(const std::array< double, 7 > ¶meters, const std::array< double, 7 > &steps, const std::array< double, 7 > &lower, const std::array< double, 7 > &upper, PhotonList *photons)
static Double_t energyDepositionInTowerOLD(Double_t x, Double_t y, Double_t *par)
std::list< StFmsTower * > Towers
Shorthand for tower collection.
static Double_t energyDepositionInTower(Double_t *x, Double_t *par)
Declaration of StFmsTowerCluster, a cluster of FMS towers.
static int maxNFittedPhotons()
Double_t fitNPhoton(const std::vector< double > ¶meteres, const std::vector< double > &steps, const std::vector< double > &lower, const std::vector< double > &up, PhotonList *photons)
void setTowers(StFmsTowerCluster::Towers *towers)
virtual ~StFmsClusterFitter()
Declaration of StFmsFittedPhoton, a photon fitted to an FMS cluster.
TF2 * showerShapeFunction()