| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 25 | //
|
|---|
| 26 | // MHCalibrationChargeCam
|
|---|
| 27 | //
|
|---|
| 28 | // Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes
|
|---|
| 29 | // MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
|
|---|
| 30 | //
|
|---|
| 31 | // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and
|
|---|
| 32 | // MHCalibrationCam::fLoGainArray
|
|---|
| 33 | //
|
|---|
| 34 | // - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
|
|---|
| 35 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
|
|---|
| 36 | // MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 37 | //
|
|---|
| 38 | // - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
|
|---|
| 39 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and
|
|---|
| 40 | // MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 41 | //
|
|---|
| 42 | // Every signal is taken from MExtractedSignalCam and filled into a histogram and
|
|---|
| 43 | // an array, in order to perform a Fourier analysis (see MHGausEvents).
|
|---|
| 44 | // The signals are moreover averaged on an event-by-event basis and written into
|
|---|
| 45 | // the corresponding average pixels.
|
|---|
| 46 | //
|
|---|
| 47 | // Additionally, the (FADC slice) position of the maximum is stored in an Absolute
|
|---|
| 48 | // Arrival Time histogram. This histogram serves for a rough cross-check if the
|
|---|
| 49 | // signal does not lie at or outside the edges of the extraction window.
|
|---|
| 50 | //
|
|---|
| 51 | // The Charge histograms are fitted to a Gaussian, mean and sigma with its errors
|
|---|
| 52 | // and the fit probability are extracted. If none of these values are NaN's and
|
|---|
| 53 | // if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
|
|---|
| 54 | // the fit is declared valid.
|
|---|
| 55 | // Otherwise, the fit is repeated within ranges of the previous mean
|
|---|
| 56 | // +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
|
|---|
| 57 | // In case this does not make the fit valid, the histogram means and RMS's are
|
|---|
| 58 | // taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
|
|---|
| 59 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or
|
|---|
| 60 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
|
|---|
| 61 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 62 | //
|
|---|
| 63 | // Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas
|
|---|
| 64 | // from the mean are counted as Pickup events (stored in MHGausEvents::fPickup)
|
|---|
| 65 | //
|
|---|
| 66 | // Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
|
|---|
| 67 | // slices show saturation, the following flag is set:
|
|---|
| 68 | // - MCalibrationChargePix::SetHiGainSaturation();
|
|---|
| 69 | // In that case, the calibration constants are derived from the low-gain results.
|
|---|
| 70 | //
|
|---|
| 71 | // If more than fNumLoGainSaturationLimit (default: 1%) of the overall
|
|---|
| 72 | // low-gain FADC slices saturate, the following flags are set:
|
|---|
| 73 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
|
|---|
| 74 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun )
|
|---|
| 75 | //
|
|---|
| 76 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
|---|
| 77 | // spectrum and investigates if the projected fourier components follow an exponential
|
|---|
| 78 | // distribution. In case that the probability of the exponential fit is less than
|
|---|
| 79 | // MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
|
|---|
| 80 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
|
|---|
| 81 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
|
|---|
| 82 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 83 | //
|
|---|
| 84 | // This same procedure is performed for the average pixels.
|
|---|
| 85 | //
|
|---|
| 86 | // The following results are written into MCalibrationChargeCam:
|
|---|
| 87 | //
|
|---|
| 88 | // - MCalibrationPix::SetHiGainSaturation()
|
|---|
| 89 | // - MCalibrationPix::SetHiGainMean()
|
|---|
| 90 | // - MCalibrationPix::SetHiGainMeanErr()
|
|---|
| 91 | // - MCalibrationPix::SetHiGainSigma()
|
|---|
| 92 | // - MCalibrationPix::SetHiGainSigmaErr()
|
|---|
| 93 | // - MCalibrationPix::SetHiGainProb()
|
|---|
| 94 | // - MCalibrationPix::SetHiGainNumPickup()
|
|---|
| 95 | //
|
|---|
| 96 | // - MCalibrationPix::SetLoGainMean()
|
|---|
| 97 | // - MCalibrationPix::SetLoGainMeanErr()
|
|---|
| 98 | // - MCalibrationPix::SetLoGainSigma()
|
|---|
| 99 | // - MCalibrationPix::SetLoGainSigmaErr()
|
|---|
| 100 | // - MCalibrationPix::SetLoGainProb()
|
|---|
| 101 | // - MCalibrationPix::SetLoGainNumPickup()
|
|---|
| 102 | //
|
|---|
| 103 | // - MCalibrationChargePix::SetAbsTimeMean()
|
|---|
| 104 | // - MCalibrationChargePix::SetAbsTimeRms()
|
|---|
| 105 | //
|
|---|
| 106 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
|---|
| 107 | // the number involved pixels in order to be able to compare it to the average of
|
|---|
| 108 | // sigmas in the camera.
|
|---|
| 109 | //
|
|---|
| 110 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 111 | #include "MHCalibrationChargeCam.h"
|
|---|
| 112 | #include "MHCalibrationCam.h"
|
|---|
| 113 |
|
|---|
| 114 | #include "MLog.h"
|
|---|
| 115 | #include "MLogManip.h"
|
|---|
| 116 |
|
|---|
| 117 | #include "MParList.h"
|
|---|
| 118 |
|
|---|
| 119 | #include "MHCalibrationChargeHiGainPix.h"
|
|---|
| 120 | #include "MHCalibrationChargeLoGainPix.h"
|
|---|
| 121 | #include "MHCalibrationChargePix.h"
|
|---|
| 122 |
|
|---|
| 123 | #include "MCalibrationChargeCam.h"
|
|---|
| 124 | #include "MCalibrationChargePix.h"
|
|---|
| 125 |
|
|---|
| 126 | #include "MGeomCam.h"
|
|---|
| 127 | #include "MGeomPix.h"
|
|---|
| 128 |
|
|---|
| 129 | #include "MHGausEvents.h"
|
|---|
| 130 |
|
|---|
| 131 | #include "MBadPixelsCam.h"
|
|---|
| 132 | #include "MBadPixelsPix.h"
|
|---|
| 133 |
|
|---|
| 134 | #include "MRawEvtData.h"
|
|---|
| 135 | #include "MRawEvtPixelIter.h"
|
|---|
| 136 |
|
|---|
| 137 | #include "MExtractedSignalCam.h"
|
|---|
| 138 | #include "MExtractedSignalPix.h"
|
|---|
| 139 |
|
|---|
| 140 | #include <TPad.h>
|
|---|
| 141 | #include <TVirtualPad.h>
|
|---|
| 142 | #include <TCanvas.h>
|
|---|
| 143 | #include <TStyle.h>
|
|---|
| 144 | #include <TF1.h>
|
|---|
| 145 | #include <TH2D.h>
|
|---|
| 146 | #include <TLine.h>
|
|---|
| 147 | #include <TLatex.h>
|
|---|
| 148 | #include <TLegend.h>
|
|---|
| 149 |
|
|---|
| 150 | ClassImp(MHCalibrationChargeCam);
|
|---|
| 151 |
|
|---|
| 152 | using namespace std;
|
|---|
| 153 |
|
|---|
| 154 | const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
|
|---|
| 155 | const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
|
|---|
| 156 | const Float_t MHCalibrationChargeCam::fgTimeLowerLimit = 1.;
|
|---|
| 157 | const Float_t MHCalibrationChargeCam::fgTimeUpperLimit = 2.;
|
|---|
| 158 | // 1Led Green, 1 LED blue, 5 LEDs blue, 10 LEDs blue, 10 LEDs UV, CT1, 5Leds Green
|
|---|
| 159 | const Float_t MHCalibrationChargeCam::gkHiGainInnerRefLines[7] = { 245., 323. , 1065., 1467., 180., 211. , 533.5};
|
|---|
| 160 | const Float_t MHCalibrationChargeCam::gkHiGainOuterRefLines[7] = { 217., 307.5, 932. , 1405., 167., 183.5, 405.5};
|
|---|
| 161 | const Float_t MHCalibrationChargeCam::gkLoGainInnerRefLines[7] = { 20.8, 28.0 , 121. , 200.2, 16.5, 13.5 , 41.7 };
|
|---|
| 162 | const Float_t MHCalibrationChargeCam::gkLoGainOuterRefLines[7] = { 18.9, 26.0 , 108.3, 198. , 14.0, 11. , 42. };
|
|---|
| 163 | // --------------------------------------------------------------------------
|
|---|
| 164 | //
|
|---|
| 165 | // Default Constructor.
|
|---|
| 166 | //
|
|---|
| 167 | // Sets:
|
|---|
| 168 | // - all pointers to NULL
|
|---|
| 169 | //
|
|---|
| 170 | // Initializes:
|
|---|
| 171 | // - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
|
|---|
| 172 | // - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
|
|---|
| 173 | // - fTimeLowerLimit to fgTimeLowerLimit
|
|---|
| 174 | // - fTimeUpperLimit to fgTimeUpperLimit
|
|---|
| 175 | //
|
|---|
| 176 | MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
|
|---|
| 177 | : fRawEvt(NULL)
|
|---|
| 178 | {
|
|---|
| 179 | fName = name ? name : "MHCalibrationChargeCam";
|
|---|
| 180 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
|---|
| 181 |
|
|---|
| 182 | SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
|
|---|
| 183 | SetNumLoGainSaturationLimit(fgNumLoGainSaturationLimit);
|
|---|
| 184 | SetTimeLowerLimit();
|
|---|
| 185 | SetTimeUpperLimit();
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | // --------------------------------------------------------------------------
|
|---|
| 191 | //
|
|---|
| 192 | // Gets the pointers to:
|
|---|
| 193 | // - MRawEvtData
|
|---|
| 194 | //
|
|---|
| 195 | Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
|
|---|
| 196 | {
|
|---|
| 197 |
|
|---|
| 198 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
|---|
| 199 | if (!fRawEvt)
|
|---|
| 200 | {
|
|---|
| 201 | *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
|---|
| 202 | return kFALSE;
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | return kTRUE;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | // --------------------------------------------------------------------------
|
|---|
| 209 | //
|
|---|
| 210 | // Gets or creates the pointers to:
|
|---|
| 211 | // - MExtractedSignalCam
|
|---|
| 212 | // - MCalibrationChargeCam
|
|---|
| 213 | // - MBadPixelsCam
|
|---|
| 214 | //
|
|---|
| 215 | // Initializes the number of used FADC slices from MExtractedSignalCam
|
|---|
| 216 | // into MCalibrationChargeCam and test for changes in that variable
|
|---|
| 217 | //
|
|---|
| 218 | // Initializes, if empty to MGeomCam::GetNumPixels():
|
|---|
| 219 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
|---|
| 220 | //
|
|---|
| 221 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
|---|
| 222 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 223 | //
|
|---|
| 224 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
|---|
| 225 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 226 | //
|
|---|
| 227 | // Calls MHCalibrationCam::InitHists() for every entry in:
|
|---|
| 228 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
|---|
| 229 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 230 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 231 | //
|
|---|
| 232 | // Sets Titles and Names for the Charge Histograms:
|
|---|
| 233 | // - MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 234 | // - MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 235 | //
|
|---|
| 236 | // Sets number of bins to MHCalibrationCam::fAverageNbins for:
|
|---|
| 237 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 238 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 239 | //
|
|---|
| 240 | Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
|
|---|
| 241 | {
|
|---|
| 242 |
|
|---|
| 243 | MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
|---|
| 244 | if (!signal)
|
|---|
| 245 | {
|
|---|
| 246 | *fLog << err << "MExtractedSignalCam not found... abort." << endl;
|
|---|
| 247 | return kFALSE;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | fCam = (MCalibrationCam*)pList->FindObject("MCalibrationChargeCam");
|
|---|
| 251 | if (!fCam)
|
|---|
| 252 | {
|
|---|
| 253 | fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
|
|---|
| 254 | if (!fCam)
|
|---|
| 255 | {
|
|---|
| 256 | gLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
|
|---|
| 257 | return kFALSE;
|
|---|
| 258 | }
|
|---|
| 259 | else
|
|---|
| 260 | fCam->Init(*fGeom);
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | fFirstHiGain = signal->GetFirstUsedSliceHiGain();
|
|---|
| 264 | fLastHiGain = signal->GetLastUsedSliceHiGain();
|
|---|
| 265 | fFirstLoGain = signal->GetFirstUsedSliceLoGain();
|
|---|
| 266 | fLastLoGain = signal->GetLastUsedSliceLoGain();
|
|---|
| 267 |
|
|---|
| 268 | const Float_t numhigain = signal->GetNumUsedHiGainFADCSlices();
|
|---|
| 269 | const Float_t numlogain = signal->GetNumUsedLoGainFADCSlices();
|
|---|
| 270 |
|
|---|
| 271 | if (fCam->GetNumHiGainFADCSlices() == 0.)
|
|---|
| 272 | fCam->SetNumHiGainFADCSlices ( numhigain );
|
|---|
| 273 | else if (fCam->GetNumHiGainFADCSlices() != numhigain)
|
|---|
| 274 | {
|
|---|
| 275 | *fLog << err << GetDescriptor()
|
|---|
| 276 | << ": Number of High Gain FADC extraction slices has changed, abort..." << endl;
|
|---|
| 277 | return kFALSE;
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | if (fCam->GetNumLoGainFADCSlices() == 0.)
|
|---|
| 281 | fCam->SetNumLoGainFADCSlices ( numlogain );
|
|---|
| 282 | else if (fCam->GetNumLoGainFADCSlices() != numlogain)
|
|---|
| 283 | {
|
|---|
| 284 | *fLog << err << GetDescriptor()
|
|---|
| 285 | << ": Number of Low Gain FADC extraction slices has changes, abort..." << endl;
|
|---|
| 286 | return kFALSE;
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | const Int_t npixels = fGeom->GetNumPixels();
|
|---|
| 290 | const Int_t nsectors = fGeom->GetNumSectors();
|
|---|
| 291 | const Int_t nareas = fGeom->GetNumAreas();
|
|---|
| 292 |
|
|---|
| 293 | if (fHiGainArray->GetEntries()==0)
|
|---|
| 294 | {
|
|---|
| 295 | fHiGainArray->Expand(npixels);
|
|---|
| 296 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 297 | {
|
|---|
| 298 | (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
|
|---|
| 299 | InitHists((*this)[i],(*fBadPixels)[i],i);
|
|---|
| 300 | }
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | if (fLoGainArray->GetEntries()==0)
|
|---|
| 304 | {
|
|---|
| 305 | fLoGainArray->Expand(npixels);
|
|---|
| 306 |
|
|---|
| 307 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 308 | {
|
|---|
| 309 | (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
|
|---|
| 310 | InitHists((*this)(i),(*fBadPixels)[i],i);
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | if (fAverageHiGainAreas->GetEntries()==0)
|
|---|
| 316 | {
|
|---|
| 317 | fAverageHiGainAreas->Expand(nareas);
|
|---|
| 318 |
|
|---|
| 319 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 320 | {
|
|---|
| 321 | (*fAverageHiGainAreas)[j] =
|
|---|
| 322 | new MHCalibrationChargeHiGainPix("AverageHiGainArea",
|
|---|
| 323 | "Average HiGain FADC sums area idx ");
|
|---|
| 324 |
|
|---|
| 325 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
|---|
| 326 |
|
|---|
| 327 | hist.SetNbins(fAverageNbins);
|
|---|
| 328 | hist.SetLast(2.*hist.GetLast());
|
|---|
| 329 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
|
|---|
| 330 |
|
|---|
| 331 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
|---|
| 332 | {
|
|---|
| 333 | hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
|
|---|
| 334 | j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
|
|---|
| 335 | hist.InitBins();
|
|---|
| 336 | hist.SetEventFrequency(fPulserFrequency);
|
|---|
| 337 | }
|
|---|
| 338 | else
|
|---|
| 339 | {
|
|---|
| 340 | hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
|
|---|
| 341 | InitHists(hist,fCam->GetAverageBadArea(j),j);
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 | if (fAverageLoGainAreas->GetEntries()==0)
|
|---|
| 348 | {
|
|---|
| 349 | fAverageLoGainAreas->Expand(nareas);
|
|---|
| 350 |
|
|---|
| 351 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 352 | {
|
|---|
| 353 | (*fAverageLoGainAreas)[j] =
|
|---|
| 354 | new MHCalibrationChargeLoGainPix("AverageLoGainArea",
|
|---|
| 355 | "Average LoGain FADC sums of pixel area idx ");
|
|---|
| 356 |
|
|---|
| 357 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
|---|
| 358 |
|
|---|
| 359 | hist.SetNbins(fAverageNbins);
|
|---|
| 360 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
|
|---|
| 361 |
|
|---|
| 362 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
|---|
| 363 | {
|
|---|
| 364 | hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
|
|---|
| 365 | j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
|
|---|
| 366 | hist.InitBins();
|
|---|
| 367 | hist.SetEventFrequency(fPulserFrequency);
|
|---|
| 368 | }
|
|---|
| 369 | else
|
|---|
| 370 | {
|
|---|
| 371 | hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
|
|---|
| 372 | InitHists(hist,fCam->GetAverageBadArea(j),j);
|
|---|
| 373 | }
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | if (fAverageHiGainSectors->GetEntries()==0)
|
|---|
| 378 | {
|
|---|
| 379 | fAverageHiGainSectors->Expand(nsectors);
|
|---|
| 380 |
|
|---|
| 381 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 382 | {
|
|---|
| 383 | (*fAverageHiGainSectors)[j] =
|
|---|
| 384 | new MHCalibrationChargeHiGainPix("AverageHiGainSector",
|
|---|
| 385 | "Average HiGain FADC sums of pixel sector ");
|
|---|
| 386 |
|
|---|
| 387 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
|---|
| 388 |
|
|---|
| 389 | hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
|
|---|
| 390 | hist.SetNbins(fAverageNbins);
|
|---|
| 391 | hist.SetLast (2.*hist.GetLast());
|
|---|
| 392 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
|
|---|
| 393 |
|
|---|
| 394 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
|---|
| 395 |
|
|---|
| 396 | }
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | if (fAverageLoGainSectors->GetEntries()==0)
|
|---|
| 400 | {
|
|---|
| 401 | fAverageLoGainSectors->Expand(nsectors);
|
|---|
| 402 |
|
|---|
| 403 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 404 | {
|
|---|
| 405 | (*fAverageLoGainSectors)[j] =
|
|---|
| 406 | new MHCalibrationChargeLoGainPix("AverageLoGainSector",
|
|---|
| 407 | "Average LoGain FADC sums of pixel sector ");
|
|---|
| 408 |
|
|---|
| 409 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
|---|
| 410 |
|
|---|
| 411 | hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
|
|---|
| 412 | hist.SetNbins(fAverageNbins);
|
|---|
| 413 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
|
|---|
| 414 |
|
|---|
| 415 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
|---|
| 416 |
|
|---|
| 417 | }
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | return kTRUE;
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 | // --------------------------------------------------------------------------
|
|---|
| 425 | //
|
|---|
| 426 | // Retrieves from MExtractedSignalCam:
|
|---|
| 427 | // - first used LoGain FADC slice
|
|---|
| 428 | //
|
|---|
| 429 | // Retrieves from MGeomCam:
|
|---|
| 430 | // - number of pixels
|
|---|
| 431 | // - number of pixel areas
|
|---|
| 432 | // - number of sectors
|
|---|
| 433 | //
|
|---|
| 434 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
|---|
| 435 | //
|
|---|
| 436 | // 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
|
|---|
| 437 | // - MExtractedSignalPix::GetExtractedSignalHiGain();
|
|---|
| 438 | // - MExtractedSignalPix::GetExtractedSignalLoGain();
|
|---|
| 439 | //
|
|---|
| 440 | // 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
|
|---|
| 441 | // - MExtractedSignalPix::GetNumHiGainSaturated();
|
|---|
| 442 | // - MExtractedSignalPix::GetNumLoGainSaturated();
|
|---|
| 443 | //
|
|---|
| 444 | // 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
|
|---|
| 445 | // - MRawEvtPixelIter::GetIdxMaxHiGainSample();
|
|---|
| 446 | // - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
|
|---|
| 447 | //
|
|---|
| 448 | Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
|
|---|
| 449 | {
|
|---|
| 450 |
|
|---|
| 451 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
|---|
| 452 | if (!signal)
|
|---|
| 453 | {
|
|---|
| 454 | *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
|
|---|
| 455 | return kFALSE;
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | const UInt_t npixels = fGeom->GetNumPixels();
|
|---|
| 459 | const UInt_t nareas = fGeom->GetNumAreas();
|
|---|
| 460 | const UInt_t nsectors = fGeom->GetNumSectors();
|
|---|
| 461 | const UInt_t lofirst = signal->GetFirstUsedSliceLoGain();
|
|---|
| 462 |
|
|---|
| 463 | Float_t sumhiarea [nareas], sumloarea [nareas], timehiarea [nareas], timeloarea [nareas];
|
|---|
| 464 | Float_t sumhisector[nsectors], sumlosector[nsectors], timehisector[nsectors], timelosector[nsectors];
|
|---|
| 465 | Int_t sathiarea [nareas], satloarea [nareas];
|
|---|
| 466 | Int_t sathisector[nsectors], satlosector[nsectors];
|
|---|
| 467 |
|
|---|
| 468 | memset(sumhiarea, 0, nareas * sizeof(Float_t));
|
|---|
| 469 | memset(sumloarea, 0, nareas * sizeof(Float_t));
|
|---|
| 470 | memset(timehiarea, 0, nareas * sizeof(Float_t));
|
|---|
| 471 | memset(timeloarea, 0, nareas * sizeof(Float_t));
|
|---|
| 472 | memset(sathiarea, 0, nareas * sizeof(Int_t ));
|
|---|
| 473 | memset(satloarea, 0, nareas * sizeof(Int_t ));
|
|---|
| 474 | memset(sumhisector, 0, nsectors*sizeof(Float_t));
|
|---|
| 475 | memset(sumlosector, 0, nsectors*sizeof(Float_t));
|
|---|
| 476 | memset(timehisector,0, nsectors*sizeof(Float_t));
|
|---|
| 477 | memset(timelosector,0, nsectors*sizeof(Float_t));
|
|---|
| 478 | memset(sathisector, 0, nsectors*sizeof(Int_t ));
|
|---|
| 479 | memset(satlosector, 0, nsectors*sizeof(Int_t ));
|
|---|
| 480 |
|
|---|
| 481 | for (UInt_t i=0; i<npixels; i++)
|
|---|
| 482 | {
|
|---|
| 483 |
|
|---|
| 484 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
|---|
| 485 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
|---|
| 486 |
|
|---|
| 487 | if (histhi.IsExcluded())
|
|---|
| 488 | continue;
|
|---|
| 489 |
|
|---|
| 490 | const MExtractedSignalPix &pix = (*signal)[i];
|
|---|
| 491 |
|
|---|
| 492 | const Float_t sumhi = pix.GetExtractedSignalHiGain();
|
|---|
| 493 | const Float_t sumlo = pix.GetExtractedSignalLoGain();
|
|---|
| 494 |
|
|---|
| 495 | if (!histhi.FillHistAndArray(sumhi))
|
|---|
| 496 | fHiGainOverFlow++;
|
|---|
| 497 | if (!histlo.FillHistAndArray(sumlo))
|
|---|
| 498 | fLoGainOverFlow++;
|
|---|
| 499 |
|
|---|
| 500 | const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
|
|---|
| 501 | const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
|
|---|
| 502 |
|
|---|
| 503 | histhi.SetSaturated(sathi);
|
|---|
| 504 | histlo.SetSaturated(satlo);
|
|---|
| 505 |
|
|---|
| 506 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
|---|
| 507 | const Int_t sector = (*fGeom)[i].GetSector();
|
|---|
| 508 |
|
|---|
| 509 | sumhiarea[aidx] += sumhi;
|
|---|
| 510 | sumloarea[aidx] += sumlo;
|
|---|
| 511 | sathiarea[aidx] += sathi;
|
|---|
| 512 | satloarea[aidx] += satlo;
|
|---|
| 513 |
|
|---|
| 514 | sumhisector[sector] += sumhi;
|
|---|
| 515 | sumlosector[sector] += sumlo;
|
|---|
| 516 | sathisector[sector] += sathi;
|
|---|
| 517 | satlosector[sector] += satlo;
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | MRawEvtPixelIter pixel(fRawEvt);
|
|---|
| 521 | while (pixel.Next())
|
|---|
| 522 | {
|
|---|
| 523 |
|
|---|
| 524 | const UInt_t pixid = pixel.GetPixelId();
|
|---|
| 525 |
|
|---|
| 526 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
|
|---|
| 527 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
|
|---|
| 528 |
|
|---|
| 529 | if (histhi.IsExcluded())
|
|---|
| 530 | continue;
|
|---|
| 531 |
|
|---|
| 532 | const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
|
|---|
| 533 | const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
|
|---|
| 534 |
|
|---|
| 535 | histhi.FillAbsTime(timehi);
|
|---|
| 536 | histlo.FillAbsTime(timelo);
|
|---|
| 537 |
|
|---|
| 538 | const Int_t aidx = (*fGeom)[pixid].GetAidx();
|
|---|
| 539 | const Int_t sector = (*fGeom)[pixid].GetSector();
|
|---|
| 540 |
|
|---|
| 541 | timehiarea[aidx] += timehi;
|
|---|
| 542 | timeloarea[aidx] += timelo;
|
|---|
| 543 |
|
|---|
| 544 | timehisector[sector] += timehi;
|
|---|
| 545 | timelosector[sector] += timelo;
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | for (UInt_t j=0; j<nareas; j++)
|
|---|
| 549 | {
|
|---|
| 550 |
|
|---|
| 551 | const Int_t npix = fAverageAreaNum[j];
|
|---|
| 552 |
|
|---|
| 553 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
|---|
| 554 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
|---|
| 555 |
|
|---|
| 556 | hipix.FillHistAndArray(sumhiarea[j]/npix);
|
|---|
| 557 | lopix.FillHistAndArray(sumloarea[j]/npix);
|
|---|
| 558 |
|
|---|
| 559 | hipix.SetSaturated((Float_t)sathiarea[j]/npix);
|
|---|
| 560 | lopix.SetSaturated((Float_t)satloarea[j]/npix);
|
|---|
| 561 |
|
|---|
| 562 | hipix.FillAbsTime(timehiarea[j]/npix);
|
|---|
| 563 | lopix.FillAbsTime(timeloarea[j]/npix);
|
|---|
| 564 |
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 | for (UInt_t j=0; j<nsectors; j++)
|
|---|
| 568 | {
|
|---|
| 569 |
|
|---|
| 570 | const Int_t npix = fAverageSectorNum[j];
|
|---|
| 571 |
|
|---|
| 572 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
|---|
| 573 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
|---|
| 574 |
|
|---|
| 575 | hipix.FillHistAndArray(sumhisector[j]/npix);
|
|---|
| 576 | lopix.FillHistAndArray(sumlosector[j]/npix);
|
|---|
| 577 |
|
|---|
| 578 | hipix.SetSaturated((Float_t)sathisector[j]/npix);
|
|---|
| 579 | lopix.SetSaturated((Float_t)satlosector[j]/npix);
|
|---|
| 580 |
|
|---|
| 581 | hipix.FillAbsTime(timehisector[j]/npix);
|
|---|
| 582 | lopix.FillAbsTime(timelosector[j]/npix);
|
|---|
| 583 |
|
|---|
| 584 | }
|
|---|
| 585 |
|
|---|
| 586 | return kTRUE;
|
|---|
| 587 | }
|
|---|
| 588 |
|
|---|
| 589 | // --------------------------------------------------------------------------
|
|---|
| 590 | //
|
|---|
| 591 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
|---|
| 592 | //
|
|---|
| 593 | // 1) Returns if the pixel is excluded.
|
|---|
| 594 | // 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
|
|---|
| 595 | // or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
|
|---|
| 596 | // 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
|
|---|
| 597 | // MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
|
|---|
| 598 | // otherwise the Hi-Gain ones.
|
|---|
| 599 | // 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
|
|---|
| 600 | // with the flags:
|
|---|
| 601 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
|
|---|
| 602 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
|
|---|
| 603 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
|
|---|
| 604 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
|
|---|
| 605 | //
|
|---|
| 606 | Bool_t MHCalibrationChargeCam::FinalizeHists()
|
|---|
| 607 | {
|
|---|
| 608 |
|
|---|
| 609 | if (fHiGainOverFlow)
|
|---|
| 610 | *fLog << warn << GetDescriptor()
|
|---|
| 611 | << ": WARNING: Histogram Overflow has occurred " << fHiGainOverFlow << " in the High-Gain! " << endl;
|
|---|
| 612 | if (fLoGainOverFlow)
|
|---|
| 613 | *fLog << warn << GetDescriptor()
|
|---|
| 614 | << ": WARNING: Histogram Overflow has occurred " << fLoGainOverFlow << " in the Low-Gain! " << endl;
|
|---|
| 615 |
|
|---|
| 616 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
|---|
| 617 | {
|
|---|
| 618 |
|
|---|
| 619 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
|---|
| 620 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
|---|
| 621 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 622 |
|
|---|
| 623 | if (histhi.IsExcluded())
|
|---|
| 624 | continue;
|
|---|
| 625 |
|
|---|
| 626 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 627 | {
|
|---|
| 628 | pix.SetHiGainSaturation();
|
|---|
| 629 | histhi.CreateFourierSpectrum();
|
|---|
| 630 | continue;
|
|---|
| 631 | }
|
|---|
| 632 |
|
|---|
| 633 | FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
|
|---|
| 634 | }
|
|---|
| 635 |
|
|---|
| 636 | for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
|
|---|
| 637 | {
|
|---|
| 638 |
|
|---|
| 639 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
|---|
| 640 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 641 |
|
|---|
| 642 | if (histlo.IsExcluded())
|
|---|
| 643 | continue;
|
|---|
| 644 |
|
|---|
| 645 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
|---|
| 646 | {
|
|---|
| 647 | *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
|
|---|
| 648 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
|---|
| 649 | histlo.CreateFourierSpectrum();
|
|---|
| 650 | continue;
|
|---|
| 651 | }
|
|---|
| 652 |
|
|---|
| 653 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
|---|
| 654 |
|
|---|
| 655 | if (pix.IsHiGainSaturation())
|
|---|
| 656 | FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
|
|---|
| 657 | }
|
|---|
| 658 |
|
|---|
| 659 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
|---|
| 660 | {
|
|---|
| 661 |
|
|---|
| 662 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
|---|
| 663 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
|---|
| 664 | MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
|
|---|
| 665 |
|
|---|
| 666 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 667 | {
|
|---|
| 668 | pix.SetHiGainSaturation();
|
|---|
| 669 | histhi.CreateFourierSpectrum();
|
|---|
| 670 | continue;
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
|
|---|
| 674 | }
|
|---|
| 675 |
|
|---|
| 676 | for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
|
|---|
| 677 | {
|
|---|
| 678 |
|
|---|
| 679 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
|---|
| 680 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
|---|
| 681 | MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
|
|---|
| 682 |
|
|---|
| 683 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
|---|
| 684 | {
|
|---|
| 685 | *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
|
|---|
| 686 | histlo.CreateFourierSpectrum();
|
|---|
| 687 | continue;
|
|---|
| 688 | }
|
|---|
| 689 |
|
|---|
| 690 | if (pix.IsHiGainSaturation())
|
|---|
| 691 | FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
|---|
| 695 | {
|
|---|
| 696 |
|
|---|
| 697 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
|---|
| 698 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
|---|
| 699 | MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
|
|---|
| 700 |
|
|---|
| 701 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 702 | {
|
|---|
| 703 | pix.SetHiGainSaturation();
|
|---|
| 704 | histhi.CreateFourierSpectrum();
|
|---|
| 705 | continue;
|
|---|
| 706 | }
|
|---|
| 707 |
|
|---|
| 708 | FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 | for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
|
|---|
| 712 | {
|
|---|
| 713 |
|
|---|
| 714 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
|---|
| 715 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
|---|
| 716 | MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
|
|---|
| 717 |
|
|---|
| 718 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
|---|
| 719 | {
|
|---|
| 720 | *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
|
|---|
| 721 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
|---|
| 722 | histlo.CreateFourierSpectrum();
|
|---|
| 723 | continue;
|
|---|
| 724 | }
|
|---|
| 725 |
|
|---|
| 726 | if (pix.IsHiGainSaturation())
|
|---|
| 727 | FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
|
|---|
| 728 | }
|
|---|
| 729 |
|
|---|
| 730 | //
|
|---|
| 731 | // Perform the fitting for the High Gain (done in MHCalibrationCam)
|
|---|
| 732 | //
|
|---|
| 733 | FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
|---|
| 734 | MBadPixelsPix::kHiGainNotFitted,
|
|---|
| 735 | MBadPixelsPix::kHiGainOscillating);
|
|---|
| 736 | //
|
|---|
| 737 | // Perform the fitting for the Low Gain (done in MHCalibrationCam)
|
|---|
| 738 | //
|
|---|
| 739 | FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
|---|
| 740 | MBadPixelsPix::kLoGainNotFitted,
|
|---|
| 741 | MBadPixelsPix::kLoGainOscillating);
|
|---|
| 742 |
|
|---|
| 743 | return kTRUE;
|
|---|
| 744 | }
|
|---|
| 745 |
|
|---|
| 746 | // --------------------------------------------------------------------------------
|
|---|
| 747 | //
|
|---|
| 748 | // Fill the absolute time results into MCalibrationChargePix
|
|---|
| 749 | //
|
|---|
| 750 | // Check absolute time validity:
|
|---|
| 751 | // - Mean arrival time is at least fTimeLowerLimit slices from the lower edge
|
|---|
| 752 | // - Mean arrival time is at least fUpperLimit slices from the upper edge
|
|---|
| 753 | //
|
|---|
| 754 | void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
|
|---|
| 755 | Byte_t first, Byte_t last)
|
|---|
| 756 | {
|
|---|
| 757 |
|
|---|
| 758 | const Float_t mean = hist.GetAbsTimeMean();
|
|---|
| 759 | const Float_t rms = hist.GetAbsTimeRms();
|
|---|
| 760 |
|
|---|
| 761 | pix.SetAbsTimeMean ( mean );
|
|---|
| 762 | pix.SetAbsTimeRms ( rms );
|
|---|
| 763 |
|
|---|
| 764 | const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
|
|---|
| 765 | const Float_t upperlimit = (Float_t)last + fTimeUpperLimit;
|
|---|
| 766 |
|
|---|
| 767 | if ( mean < lowerlimit)
|
|---|
| 768 | {
|
|---|
| 769 | *fLog << warn << GetDescriptor()
|
|---|
| 770 | << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," smaller than ",fTimeLowerLimit,
|
|---|
| 771 | " FADC slices from lower edge in pixel ",hist.GetPixId()) << endl;
|
|---|
| 772 | bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
|
|---|
| 773 | }
|
|---|
| 774 |
|
|---|
| 775 | if ( mean > upperlimit )
|
|---|
| 776 | {
|
|---|
| 777 | *fLog << warn << GetDescriptor()
|
|---|
| 778 | << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," greater than ",fTimeUpperLimit,
|
|---|
| 779 | " FADC slices from upper edge in pixel ",hist.GetPixId()) << endl;
|
|---|
| 780 | bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
|
|---|
| 781 | }
|
|---|
| 782 | }
|
|---|
| 783 |
|
|---|
| 784 | // --------------------------------------------------------------------------
|
|---|
| 785 | //
|
|---|
| 786 | // Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
|
|---|
| 787 | // - MBadPixelsPix::kLoGainSaturation
|
|---|
| 788 | //
|
|---|
| 789 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
|---|
| 790 | // - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
|
|---|
| 791 | // - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
|
|---|
| 792 | // - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
|
|---|
| 793 | // - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
|
|---|
| 794 | //
|
|---|
| 795 | void MHCalibrationChargeCam::FinalizeBadPixels()
|
|---|
| 796 | {
|
|---|
| 797 |
|
|---|
| 798 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
|---|
| 799 | {
|
|---|
| 800 |
|
|---|
| 801 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 802 | MCalibrationPix &pix = (*fCam)[i];
|
|---|
| 803 |
|
|---|
| 804 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
|
|---|
| 805 | if (!pix.IsHiGainSaturation())
|
|---|
| 806 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 807 |
|
|---|
| 808 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
|
|---|
| 809 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 810 |
|
|---|
| 811 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
|
|---|
| 812 | if (pix.IsHiGainSaturation())
|
|---|
| 813 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 814 |
|
|---|
| 815 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
|
|---|
| 816 | if (pix.IsHiGainSaturation())
|
|---|
| 817 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 818 |
|
|---|
| 819 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
|
|---|
| 820 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
|---|
| 821 | }
|
|---|
| 822 | }
|
|---|
| 823 |
|
|---|
| 824 | // --------------------------------------------------------------------------
|
|---|
| 825 | //
|
|---|
| 826 | // Dummy, needed by MCamEvent
|
|---|
| 827 | //
|
|---|
| 828 | Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 829 | {
|
|---|
| 830 | return kTRUE;
|
|---|
| 831 | }
|
|---|
| 832 |
|
|---|
| 833 | // --------------------------------------------------------------------------
|
|---|
| 834 | //
|
|---|
| 835 | // Calls MHGausEvents::DrawClone() for pixel idx
|
|---|
| 836 | //
|
|---|
| 837 | void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
|
|---|
| 838 | {
|
|---|
| 839 | (*this)[idx].DrawClone();
|
|---|
| 840 | }
|
|---|
| 841 |
|
|---|
| 842 |
|
|---|
| 843 | // -----------------------------------------------------------------------------
|
|---|
| 844 | //
|
|---|
| 845 | // Default draw:
|
|---|
| 846 | //
|
|---|
| 847 | // Displays the averaged areas, both High Gain and Low Gain
|
|---|
| 848 | //
|
|---|
| 849 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
|---|
| 850 | //
|
|---|
| 851 | void MHCalibrationChargeCam::Draw(const Option_t *opt)
|
|---|
| 852 | {
|
|---|
| 853 |
|
|---|
| 854 | const Int_t nareas = fAverageHiGainAreas->GetEntries();
|
|---|
| 855 | if (nareas == 0)
|
|---|
| 856 | return;
|
|---|
| 857 |
|
|---|
| 858 | TString option(opt);
|
|---|
| 859 | option.ToLower();
|
|---|
| 860 |
|
|---|
| 861 | if (!option.Contains("datacheck"))
|
|---|
| 862 | {
|
|---|
| 863 | MHCalibrationCam::Draw(opt);
|
|---|
| 864 | return;
|
|---|
| 865 | }
|
|---|
| 866 |
|
|---|
| 867 | //
|
|---|
| 868 | // From here on , the datacheck - Draw
|
|---|
| 869 | //
|
|---|
| 870 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
|---|
| 871 | pad->SetBorderMode(0);
|
|---|
| 872 |
|
|---|
| 873 | pad->Divide(2,nareas);
|
|---|
| 874 |
|
|---|
| 875 | for (Int_t i=0; i<nareas;i++)
|
|---|
| 876 | {
|
|---|
| 877 | pad->cd(2*(i+1)-1);
|
|---|
| 878 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
|
|---|
| 879 |
|
|---|
| 880 | if (i==0)
|
|---|
| 881 | DrawDataCheckPixel(hipix,gkHiGainInnerRefLines);
|
|---|
| 882 | else
|
|---|
| 883 | DrawDataCheckPixel(hipix,gkHiGainOuterRefLines);
|
|---|
| 884 |
|
|---|
| 885 | pad->cd(2*(i+1));
|
|---|
| 886 |
|
|---|
| 887 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
|
|---|
| 888 |
|
|---|
| 889 | if (i==0)
|
|---|
| 890 | DrawDataCheckPixel(lopix,gkLoGainInnerRefLines);
|
|---|
| 891 | else
|
|---|
| 892 | DrawDataCheckPixel(lopix,gkLoGainOuterRefLines);
|
|---|
| 893 |
|
|---|
| 894 | }
|
|---|
| 895 | }
|
|---|
| 896 |
|
|---|
| 897 |
|
|---|
| 898 | // --------------------------------------------------------------------------
|
|---|
| 899 | //
|
|---|
| 900 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
|---|
| 901 | // I don't know the reason.
|
|---|
| 902 | //
|
|---|
| 903 | // Creates new MHCalibrationCam
|
|---|
| 904 | //
|
|---|
| 905 | TObject *MHCalibrationChargeCam::Clone(const char *) const
|
|---|
| 906 | {
|
|---|
| 907 |
|
|---|
| 908 | const Int_t navhi = fAverageHiGainAreas->GetEntries();
|
|---|
| 909 | const Int_t navlo = fAverageLoGainAreas->GetEntries();
|
|---|
| 910 | const Int_t nsehi = fAverageHiGainSectors->GetEntries();
|
|---|
| 911 | const Int_t nselo = fAverageLoGainSectors->GetEntries();
|
|---|
| 912 |
|
|---|
| 913 | //
|
|---|
| 914 | // FIXME, this might be done faster and more elegant, by direct copy.
|
|---|
| 915 | //
|
|---|
| 916 | MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
|
|---|
| 917 |
|
|---|
| 918 | cam->fAverageHiGainAreas->Expand(navhi);
|
|---|
| 919 | cam->fAverageLoGainAreas->Expand(navlo);
|
|---|
| 920 | cam->fAverageHiGainSectors->Expand(nsehi);
|
|---|
| 921 | cam->fAverageLoGainSectors->Expand(nselo);
|
|---|
| 922 |
|
|---|
| 923 | cam->fAverageHiGainAreas->Expand(navhi);
|
|---|
| 924 | cam->fAverageLoGainAreas->Expand(navlo);
|
|---|
| 925 | cam->fAverageHiGainSectors->Expand(nsehi);
|
|---|
| 926 | cam->fAverageLoGainSectors->Expand(nselo);
|
|---|
| 927 |
|
|---|
| 928 | for (int i=0; i<navhi; i++)
|
|---|
| 929 | (*cam->fAverageHiGainAreas)[i] = (*fAverageHiGainAreas)[i]->Clone();
|
|---|
| 930 | for (int i=0; i<navlo; i++)
|
|---|
| 931 | (*cam->fAverageLoGainAreas)[i] = (*fAverageLoGainAreas)[i]->Clone();
|
|---|
| 932 | for (int i=0; i<nsehi; i++)
|
|---|
| 933 | (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
|
|---|
| 934 | for (int i=0; i<nselo; i++)
|
|---|
| 935 | (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
|
|---|
| 936 |
|
|---|
| 937 | cam->fAverageAreaNum = fAverageAreaNum;
|
|---|
| 938 | cam->fAverageAreaSat = fAverageAreaSat;
|
|---|
| 939 | cam->fAverageAreaSigma = fAverageAreaSigma;
|
|---|
| 940 | cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
|
|---|
| 941 | cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
|
|---|
| 942 | cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
|
|---|
| 943 | cam->fAverageSectorNum = fAverageSectorNum;
|
|---|
| 944 | cam->fRunNumbers = fRunNumbers;
|
|---|
| 945 |
|
|---|
| 946 | cam->fPulserFrequency = fPulserFrequency;
|
|---|
| 947 | cam->fAverageNbins = fAverageNbins;
|
|---|
| 948 |
|
|---|
| 949 | return cam;
|
|---|
| 950 |
|
|---|
| 951 | }
|
|---|
| 952 |
|
|---|
| 953 | void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[])
|
|---|
| 954 | {
|
|---|
| 955 |
|
|---|
| 956 | TVirtualPad *newpad = gPad;
|
|---|
| 957 | newpad->Divide(1,2);
|
|---|
| 958 | newpad->cd(1);
|
|---|
| 959 |
|
|---|
| 960 | gPad->SetTicks();
|
|---|
| 961 | if (!pix.IsEmpty())
|
|---|
| 962 | gPad->SetLogy();
|
|---|
| 963 |
|
|---|
| 964 | gStyle->SetOptStat(0);
|
|---|
| 965 |
|
|---|
| 966 | TH1F *hist = pix.GetHGausHist();
|
|---|
| 967 |
|
|---|
| 968 |
|
|---|
| 969 | TH2D *null = new TH2D("Null",hist->GetTitle(),100,pix.GetFirst(),pix.GetLast(),
|
|---|
| 970 | 100,0.,hist->GetEntries()/10.);
|
|---|
| 971 |
|
|---|
| 972 | null->SetDirectory(NULL);
|
|---|
| 973 | null->SetBit(kCanDelete);
|
|---|
| 974 | null->GetXaxis()->SetTitle(hist->GetXaxis()->GetTitle());
|
|---|
| 975 | null->GetYaxis()->SetTitle(hist->GetYaxis()->GetTitle());
|
|---|
| 976 | null->GetXaxis()->CenterTitle();
|
|---|
| 977 | null->GetYaxis()->CenterTitle();
|
|---|
| 978 | null->Draw();
|
|---|
| 979 | hist->Draw("same");
|
|---|
| 980 |
|
|---|
| 981 | gStyle->SetOptFit();
|
|---|
| 982 |
|
|---|
| 983 | if (pix.GetFGausFit())
|
|---|
| 984 | {
|
|---|
| 985 | pix.GetFGausFit()->SetLineColor(pix.IsGausFitOK() ? kGreen : kRed);
|
|---|
| 986 | pix.GetFGausFit()->Draw("same");
|
|---|
| 987 | }
|
|---|
| 988 |
|
|---|
| 989 | DisplayRefLines(null,refline);
|
|---|
| 990 |
|
|---|
| 991 |
|
|---|
| 992 | newpad->cd(2);
|
|---|
| 993 | gPad->SetTicks();
|
|---|
| 994 |
|
|---|
| 995 | pix.DrawEvents();
|
|---|
| 996 | return;
|
|---|
| 997 |
|
|---|
| 998 | }
|
|---|
| 999 |
|
|---|
| 1000 |
|
|---|
| 1001 | void MHCalibrationChargeCam::DisplayRefLines(const TH2D *hist, const Float_t refline[]) const
|
|---|
| 1002 | {
|
|---|
| 1003 |
|
|---|
| 1004 | TLine *green1 = new TLine(refline[0],0.,refline[0],hist->GetYaxis()->GetXmax());
|
|---|
| 1005 | green1->SetBit(kCanDelete);
|
|---|
| 1006 | green1->SetLineColor(kGreen);
|
|---|
| 1007 | green1->SetLineStyle(2);
|
|---|
| 1008 | green1->SetLineWidth(3);
|
|---|
| 1009 | green1->Draw();
|
|---|
| 1010 |
|
|---|
| 1011 | TLine *green5 = new TLine(refline[6],0.,refline[6],hist->GetYaxis()->GetXmax());
|
|---|
| 1012 | green5->SetBit(kCanDelete);
|
|---|
| 1013 | green5->SetLineColor(8);
|
|---|
| 1014 | green5->SetLineStyle(2);
|
|---|
| 1015 | green5->SetLineWidth(3);
|
|---|
| 1016 | green5->Draw();
|
|---|
| 1017 |
|
|---|
| 1018 | TLine *blue1 = new TLine(refline[1],0.,refline[1],hist->GetYaxis()->GetXmax());
|
|---|
| 1019 | blue1->SetBit(kCanDelete);
|
|---|
| 1020 | blue1->SetLineColor(007);
|
|---|
| 1021 | blue1->SetLineStyle(2);
|
|---|
| 1022 | blue1->SetLineWidth(3);
|
|---|
| 1023 | blue1->Draw();
|
|---|
| 1024 |
|
|---|
| 1025 | TLine *blue5 = new TLine(refline[2],0.,refline[2],hist->GetYaxis()->GetXmax());
|
|---|
| 1026 | blue5->SetBit(kCanDelete);
|
|---|
| 1027 | blue5->SetLineColor(062);
|
|---|
| 1028 | blue5->SetLineStyle(2);
|
|---|
| 1029 | blue5->SetLineWidth(3);
|
|---|
| 1030 | blue5->Draw();
|
|---|
| 1031 |
|
|---|
| 1032 | TLine *blue10 = new TLine(refline[3],0.,refline[3],hist->GetYaxis()->GetXmax());
|
|---|
| 1033 | blue10->SetBit(kCanDelete);
|
|---|
| 1034 | blue10->SetLineColor(004);
|
|---|
| 1035 | blue10->SetLineStyle(2);
|
|---|
| 1036 | blue10->SetLineWidth(3);
|
|---|
| 1037 | blue10->Draw();
|
|---|
| 1038 |
|
|---|
| 1039 | TLine *uv10 = new TLine(refline[4],0.,refline[4],hist->GetYaxis()->GetXmax());
|
|---|
| 1040 | uv10->SetBit(kCanDelete);
|
|---|
| 1041 | uv10->SetLineColor(106);
|
|---|
| 1042 | uv10->SetLineStyle(2);
|
|---|
| 1043 | uv10->SetLineWidth(3);
|
|---|
| 1044 | uv10->Draw();
|
|---|
| 1045 |
|
|---|
| 1046 | TLine *ct1 = new TLine(refline[5],0.,refline[5],hist->GetYaxis()->GetXmax());
|
|---|
| 1047 | ct1->SetBit(kCanDelete);
|
|---|
| 1048 | ct1->SetLineColor(006);
|
|---|
| 1049 | ct1->SetLineStyle(2);
|
|---|
| 1050 | ct1->SetLineWidth(3);
|
|---|
| 1051 | ct1->Draw();
|
|---|
| 1052 |
|
|---|
| 1053 | TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
|
|---|
| 1054 | leg->SetBit(kCanDelete);
|
|---|
| 1055 | leg->AddEntry(green1,"1 Led GREEN","l");
|
|---|
| 1056 | leg->AddEntry(green5,"5 Leds GREEN","l");
|
|---|
| 1057 | leg->AddEntry(blue1,"1 Led BLUE","l");
|
|---|
| 1058 | leg->AddEntry(blue5,"5 Leds BLUE","l");
|
|---|
| 1059 | leg->AddEntry(blue10,"10 Leds BLUE","l");
|
|---|
| 1060 | leg->AddEntry(uv10,"10 Leds UV","l");
|
|---|
| 1061 | leg->AddEntry(ct1,"CT1-Pulser","l");
|
|---|
| 1062 |
|
|---|
| 1063 | leg->Draw();
|
|---|
| 1064 | }
|
|---|