Improving Tower Gain Fits

Update 21 July

I changed the fit range and min and max values for the parameters and got rid of the weird oscillations in the fits.  The code is now:

 //parameter starting values
      sv[0]=hTowerMip[itow]->GetRMS();
      pllo[0] = 0.1*sv[0]; plhi[0] = 20.0*sv[0];
      sv[1]=hTowerMip[itow]->GetMean();
      pllo[1] = 0.1*sv[1]; plhi[1] = 3.0*sv[1];
      sv[2]=hTowerMip[itow]->Integral();
      pllo[2] = 0.1*sv[2]; plhi[2] = 10*sv[2];
      sv[3]=hTowerMip[itow]->GetRMS();
      pllo[3] = 0.1*sv[3]; plhi[3] = 3.0*sv[3];
 

New plots are attached.  Note: the green line on the plots has nothing to do with the fit range.  The function is drawn over the entire range used in the fit.  Now it looks like the only bad fit is 09TC09.  09TE03 suggests that upper fit range might need a tweak.

 

Currently the tower ADC spectra are fit with a Landau + Gaussian.  This fit is occasionally going horribly wrong and we end up with huge fit parameter uncertainties.  Instead of using this fit, I took the root convoluted Landau+Gaussian fit - see here, modifying the code in the macro to read in our histogram files and do fits to the histograms - see newFitTower near the end of my file, newFitTower.C, attached below.  This code includes a function that finds the peak and full width at half maximum of the fit function.  What I am unsure of is what the precise error on the peak is using this function, but the peak is close enough to the Landau MPV it's probably OK to use the MPV fit error. 

I fit Zach's histograms in sector 9 that he used to fit the towers.  These have the SMD MIP signal but do not appear to have the pre and post shower MIP requirements as well.  I am attaching a pdf of all of the tower fits for this sector, a text file with the gains I fit compared to the ideal gains, and the code I used to do the fit.  I do see the gains are systematically lower than ideal, but hopefully this will go away when the pre and post shower requirements are put back in.  For each tower fit, the inclusive distribution is shown in blue, the MIP distribution is in black, the fit is in red and the arrow points to the peak of the fit.  The green lines are (I think) the MIP gate used elsewhere in the code and the red dotted line is the mean - they have nothing to do with my fit.

If this code were going to be used, my text file would need to be changed to be more like the one already in use.  After putting back in the pre and post shower requirements, a simple Gaussian might do the trick.  It might also we worthwhile to see if a fit more like this one would work better for the other layers as well.  There are still some crazy fits in here - see for example pgs 31 or 14.  This can probably be fixed by changing the fit range and min/max fit parameters to depend on starting values (which come from the histo mean and rms).