#ifndef __TCESCLUSTERFITTER__ #define __TCESCLUSTERFITTER__ /* Compute a CES chi2 and position from a list of ADC's. A standard pedestal, gain, and threshold for ADC's is applied. Use: TCesClusterFitter calc; // fill raw ADC's into int adc[11]; // bool wires is true for wire view // first strip is the detector channel number of the adc[0], // nstrips is the number of valid ADC values in adc[0:nstrips-1] // only 11 strip clusters allowed int failed = calc.Fit(int* adc, bool wires=true, int firststrip, int nstrips); if(failed) cout << "failed" << endl; float rawE = calc.RawEnergy(); float fitE = calc.FitEnergy(); // the x or z reflects readout order // x direction = +phi for west, -phi for east, z = |CDF x| double cesXorZ = calc.Position(); double cesXorZ = calc.Position(); double chi2 = calc.Chi2(); */ #include #include class TCesClusterFitter { public : // constants double CESRADIUS; int N_PHI_STRIP; double PHI_STRIP_OFFSET; double PHI_STRIP_PITCH; int N_Z_STRIP1; int N_Z_STRIP2; double Z_STRIP_OFFSET1; double Z_STRIP_OFFSET2; double Z_STRIP_PITCH1; double Z_STRIP_PITCH2; double GEV_TO_ADC_WIRE; // GeV to Adc for strips double GEV_TO_ADC_STRIP; // GeV to Adc for strips double CONST1; // two factors determining one-channel E sigma double CONST2; // double DXMIN; // tolerance to stop iteration private : // frozen electron shower profile (1985 test beam) double _pos1[300]; double _corrections[6][300]; double _posMax; // position of the strip with highest pulse height double _fittedPosition; double _strippos[129]; // strip boundaries double _wirepos[33]; // strip boundaries double _offset; double _sinth; // sinTheta determined by the channel with highest ADC double _pos[12]; /* strip boundaries of channels in the cluster * in mm * projected with sinTheta to correct the widening effect */ double _rawPosition; // cluster centroid double _rawEnergy; // cluster sum energy double _fitPosition; double _e[11]; double _fitEnergy; double _chi2; int ADCs[11]; // stores the ADC's of the 11 channels. int firstChan; // first strip number int nChan; // number of strips double qdiff[11]; // differences between measured and expected void initArrays(); int fitt2_strip(double x1, double delta, double R[2]); int fitt2_wire (double x1, double delta, double R[2]); int _verbose; bool _wires; public: TCesClusterFitter(); ~TCesClusterFitter(); int Fit(int* adc, bool wires=true, int firststrip=0, int nstrips=11); double RawEnergy(){ return _rawEnergy;} double FitEnergy() { return _fitEnergy;} // position in readout direction double Position() {return _fitPosition;} // provide side (0=east) and get stntuple sign (x in -phi sense, z in CDFz) double Position(int side) { return (side==0? -_fitPosition : _fitPosition ); } double Chi2() {return _chi2;} void SetVerbose(int i) { _verbose = i;} }; #endif