Changeset 3081
- Timestamp:
- 02/10/04 16:10:52 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3080 r3081 8 8 * mcalib/MCalibrationCam.cc 9 9 - fixed documentation 10 11 * mhbase/MH.[h,cc] 12 - new function ProjectArray 13 14 * mcalib/MHCalibrationPixel.[h,cc] 15 * mcalib/MHCalibrationBlindPixel.[h,cc] 16 - use ProjectArray from MH to plot the projection of the fourier 17 spectrum 10 18 11 19 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc
r3075 r3081 88 88 const Double_t MHCalibrationBlindPixel::fgBlindPixelElectronicAmpError = 0.002; 89 89 90 const Axis_t MHCalibrationBlindPixel::fNyquistFreq = 1.0;91 const Axis_t MHCalibrationBlindPixel::fMinFreq = 0.;92 90 const Int_t MHCalibrationBlindPixel::fPSDNbins = 30; 93 91 … … 266 264 fPSDHiGain = fourier.PowerSpectrumDensity(fHiGains); 267 265 268 Int_t entries; 269 TArrayF *array; 270 271 fHPSD = new TH1F("HBlindPixelPSD", 272 "Power Spectrum Density Projection Blind Pixel", 273 fPSDNbins,fMinFreq,fNyquistFreq); 274 275 array = fPSDHiGain; 276 entries = array->GetSize(); 277 278 for (Int_t i=0;i<entries;i++) 279 fHPSD->Fill(array->At(i)); 280 266 fHPSD = MH::ProjectArray(fPSDHiGain, fPSDNbins, 267 "PSDProjectionBlindPixel", 268 "Power Spectrum Density Projection HiGain Blind Pixel"); 281 269 // 282 270 // First guesses for the fit (should be as close to reality as possible, 283 271 // 284 const Double_t area_guess = entries*10.; 285 286 fPSDExpFit = new TF1("PSDExpFit","[0]*exp(-[1]*x)",0.,1.); 287 288 fPSDExpFit->SetParameters(entries,10.); 289 fPSDExpFit->SetParNames("Area","slope"); 290 fPSDExpFit->SetParLimits(0,0.,3.*area_guess); 291 fPSDExpFit->SetParLimits(1,0.,20.); 292 fPSDExpFit->SetRange(fMinFreq,fNyquistFreq); 272 const Double_t xmax = fHPSD->GetXaxis()->GetXmax(); 273 274 fPSDExpFit = new TF1("PSDExpFit","exp([0]-[1]*x)",0.,xmax); 275 276 const Double_t slope_guess = (TMath::Log(fHPSD->GetEntries())+1.)/xmax; 277 const Double_t offset_guess = slope_guess*xmax; 278 279 fPSDExpFit->SetParameters(offset_guess, slope_guess); 280 fPSDExpFit->SetParNames("Offset","Slope"); 281 fPSDExpFit->SetParLimits(0,offset_guess/2.,2.*offset_guess); 282 fPSDExpFit->SetParLimits(1,slope_guess/2.,2.*slope_guess); 283 fPSDExpFit->SetRange(0.,xmax); 293 284 294 285 fHPSD->Fit(fPSDExpFit,"RQL0"); -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h
r3061 r3081 25 25 static const Double_t fgBlindPixelElectronicAmpError; 26 26 27 static const Axis_t fNyquistFreq;28 static const Axis_t fMinFreq;29 27 static const Int_t fPSDNbins; 30 28 … … 40 38 TArrayF* fPSDLoGain; //-> Power spectrum density of fLoGains 41 39 42 TH1 F* fHPSD; //->40 TH1I* fHPSD; //-> 43 41 TF1* fPSDExpFit; //-> 44 42 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
r3075 r3081 61 61 const Int_t MHCalibrationPixel::fNDFLimit = 5; 62 62 63 const Axis_t MHCalibrationPixel::fMinFreq = 0.; 64 const Int_t MHCalibrationPixel::fPSDNbins = 50; 63 const Int_t MHCalibrationPixel::fPSDNbins = 30; 65 64 66 65 // -------------------------------------------------------------------------- … … 268 267 fPSDHiGain = fourier.PowerSpectrumDensity(fHiGains); 269 268 270 Int_t entries;271 TArrayF *array;272 273 const Double_t max_freq = (fChargeSigma > 0.) ? fChargeSigma*0.2 : 2.;274 const Double_t min_freq = 0.;275 276 269 if (IsUseLoGain()) 277 { 278 fHPSD = new TH1F(Form("%s%d","HPSD",fPixId), 279 Form("%s%s","Power Spectrum Density Projection ","LoGain"), 280 fPSDNbins,min_freq,max_freq); 281 282 array = fPSDLoGain; 283 } 270 fHPSD = MH::ProjectArray(fPSDLoGain, fPSDNbins, 271 Form("%s%d","PSDProjection",fPixId), 272 Form("%s%d","Power Spectrum Density Projection LoGain ",fPixId)); 284 273 else 285 { 286 287 fHPSD = new TH1F(Form("%s%d","HPSD",fPixId), 288 Form("%s%s","Power Spectrum Density Projection ","HiGain"), 289 fPSDNbins,min_freq,max_freq); 290 291 array = fPSDHiGain; 292 } 293 294 entries = array->GetSize(); 295 296 for (Int_t i=0;i<entries;i++) 297 fHPSD->Fill(array->At(i)); 274 fHPSD = MH::ProjectArray(fPSDHiGain, fPSDNbins, 275 Form("%s%d","PSDProjection",fPixId), 276 Form("%s%d","Power Spectrum Density Projection HiGain ",fPixId)); 298 277 299 278 // 300 279 // First guesses for the fit (should be as close to reality as possible, 301 280 // 302 const Double_t area_guess = entries*10.; 303 304 fPSDExpFit = new TF1(Form("%s%d","PSDExpFit",fPixId),"[0]*exp(-[1]*x)",0.,1.); 305 306 fPSDExpFit->SetParameters(area_guess,10.); 307 fPSDExpFit->SetParNames("Area","slope"); 308 fPSDExpFit->SetParLimits(0,0.,20.*area_guess); 309 fPSDExpFit->SetParLimits(1,0.,30.); 310 fPSDExpFit->SetRange(min_freq,max_freq); 281 const Double_t xmax = fHPSD->GetXaxis()->GetXmax(); 282 283 fPSDExpFit = new TF1(Form("%s%d","PSDExpFit",fPixId),"exp([0]-[1]*x)",0.,xmax); 284 285 const Double_t slope_guess = (TMath::Log(fHPSD->GetEntries())+1.)/xmax; 286 const Double_t offset_guess = slope_guess*xmax; 287 288 fPSDExpFit->SetParameters(offset_guess, slope_guess); 289 fPSDExpFit->SetParNames("Offset","Slope"); 290 fPSDExpFit->SetParLimits(0,offset_guess/2.,2.*offset_guess); 291 fPSDExpFit->SetParLimits(1,slope_guess/2.,2.*slope_guess); 292 fPSDExpFit->SetRange(0.,xmax); 311 293 312 294 fHPSD->Fit(fPSDExpFit,"RQL0"); -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h
r3075 r3081 26 26 static const Int_t fNDFLimit; 27 27 28 static const Axis_t fMinFreq;29 28 static const Int_t fPSDNbins; 30 29 … … 49 48 TF1* fChargeGausFit; //-> 50 49 51 TH1 F* fHPSD; //->50 TH1I* fHPSD; //-> 52 51 TF1* fPSDExpFit; //-> 53 52 -
trunk/MagicSoft/Mars/mhbase/MH.cc
r2858 r3081 1081 1081 return NULL; 1082 1082 } 1083 1084 TH1I* MH::ProjectArray(const TArrayF *array, Int_t nbins, const char* name, const char* title) 1085 { 1086 1087 const Int_t size = array->GetSize(); 1088 TH1I *h1=0; 1089 1090 //check if histogram with identical name exist 1091 TObject *h1obj = gROOT->FindObject(name); 1092 if (h1obj && h1obj->InheritsFrom("TH1I")) { 1093 h1 = (TH1I*)h1obj; 1094 h1->Reset(); 1095 } 1096 1097 Double_t max = 0.; 1098 Double_t min = 0.; 1099 Int_t newbins = 0; 1100 1101 // first loop over array to find the maximum: 1102 for (Int_t i=0; i<size;i++) 1103 if (array->At(i) > max) 1104 max = array->At(i); 1105 1106 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1107 1108 if (!h1) 1109 { 1110 h1 = new TH1I(name, title, newbins, min, max); 1111 h1->SetXTitle(""); 1112 h1->SetYTitle("Counts"); 1113 h1->SetDirectory(NULL); 1114 } 1115 1116 // Second loop to fill the histogram 1117 for (Int_t i=0;i<size;i++) 1118 h1->Fill(array->At(i)); 1119 1120 h1->SetEntries(size); 1121 1122 return h1; 1123 } 1124 1125 TH1I* MH::ProjectArray(const TArrayD *array, Int_t nbins, const char* name, const char* title) 1126 { 1127 1128 const Int_t size = array->GetSize(); 1129 1130 TH1I *h1=0; 1131 1132 //check if histogram with identical name exist 1133 TObject *h1obj = gROOT->FindObject(name); 1134 if (h1obj && h1obj->InheritsFrom("TH1I")) { 1135 h1 = (TH1I*)h1obj; 1136 h1->Reset(); 1137 } 1138 1139 Double_t max = 0.; 1140 Double_t min = 0.; 1141 Int_t newbins = 0; 1142 1143 // first loop over array to find the maximum: 1144 for (Int_t i=0; i<size;i++) 1145 if (array->At(i) > max) 1146 max = array->At(i); 1147 1148 FindGoodLimits( nbins, newbins, min, max, kFALSE); 1149 1150 if (!h1) 1151 { 1152 h1 = new TH1I(name, title, newbins, min, max); 1153 h1->SetXTitle(""); 1154 h1->SetYTitle("Counts"); 1155 h1->SetDirectory(NULL); 1156 } 1157 1158 // Second loop to fill the histogram 1159 for (Int_t i=0;i<size;i++) 1160 h1->Fill(array->At(i)); 1161 1162 h1->SetEntries(size); 1163 1164 return h1; 1165 } 1166 -
trunk/MagicSoft/Mars/mhbase/MH.h
r2735 r3081 7 7 8 8 class TH1; 9 class TH1I; 9 10 class TH1D; 10 11 class TH2; 11 12 class TH3; 12 13 class TAxis; 14 class TArrayF; 13 15 class TArrayD; 14 16 class TCanvas; … … 89 91 static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0); 90 92 static Int_t CutEdges(TH1 *h, Int_t nbins); 93 94 static TH1I* ProjectArray(const TArrayF *array, Int_t nbins=30, const char* name="ProjectArray", 95 const char* title="Projected Array"); 96 static TH1I* ProjectArray(const TArrayD *array, Int_t nbins=30, const char* name="ProjectArray", 97 const char* title="Projected Array"); 91 98 92 99 static void ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin=-1, Int_t lastybin=9999);
Note:
See TracChangeset
for help on using the changeset viewer.