| 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): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de> | 
|---|
| 19 | !   Author(s): Markus Gaug, 02/2004 <mailto:markus@ifae.es> | 
|---|
| 20 | ! | 
|---|
| 21 | !   Copyright: MAGIC Software Development, 2000-2005 | 
|---|
| 22 | ! | 
|---|
| 23 | ! | 
|---|
| 24 | \* ======================================================================== */ | 
|---|
| 25 |  | 
|---|
| 26 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 27 | // | 
|---|
| 28 | //  MJCalibration | 
|---|
| 29 | // | 
|---|
| 30 | //  Do one calibration loop over serious of runs with the same pulser | 
|---|
| 31 | //  colour and the same intensity. The following containers (rectangular) and | 
|---|
| 32 | //  tasks (ellipses) are called to produce an MCalibrationChargeCam and to | 
|---|
| 33 | //  update the MCalibrationQECam: (MCalibrate is not called from this class) | 
|---|
| 34 | // | 
|---|
| 35 | //Begin_Html | 
|---|
| 36 | /* | 
|---|
| 37 | <img src="images/CalibClasses.gif"> | 
|---|
| 38 | */ | 
|---|
| 39 | //End_Html | 
|---|
| 40 | // | 
|---|
| 41 | // Different signal extractors can be set with the command SetExtractor() | 
|---|
| 42 | // Only extractors deriving from MExtractor can be set, default is MExtractSlidingWindow | 
|---|
| 43 | // | 
|---|
| 44 | // Different arrival time extractors can be set with the command SetTimeExtractor() | 
|---|
| 45 | // Only extractors deriving from MExtractTime can be set, default is MExtractTimeHighestIntegral | 
|---|
| 46 | // | 
|---|
| 47 | // At the end of the eventloop, plots and results are displayed, depending on | 
|---|
| 48 | // the flags set (see DisplayResult()) | 
|---|
| 49 | // | 
|---|
| 50 | // If the flag SetFullDisplay() is set, all MHCameras will be displayed. | 
|---|
| 51 | // if the flag SetDataCheckDisplay() is set, only the most important ones are displayed | 
|---|
| 52 | // Otherwise, (default: SetNormalDisplay()), a good selection of plots is given | 
|---|
| 53 | // | 
|---|
| 54 | // The absolute light calibration devices Blind Pixel and PIN Diode can be switched on | 
|---|
| 55 | // and off with the commands: | 
|---|
| 56 | // | 
|---|
| 57 | // - SetUseBlindPixel(Bool_t ) | 
|---|
| 58 | // - SetUsePINDiode(Bool_t ) | 
|---|
| 59 | // | 
|---|
| 60 | // See also: MHCalibrationChargePix, MHCalibrationChargeCam, MHGausEvents | 
|---|
| 61 | //           MHCalibrationChargeBlindPix, MHCalibrationChargePINDiode | 
|---|
| 62 | //           MCalibrationChargePix, MCalibrationChargeCam, MCalibrationChargeCalc | 
|---|
| 63 | //           MCalibrationBlindPix, MCalibrationChargePINDiode, | 
|---|
| 64 | //           MCalibrationQECam, MBadPixelsPix, MBadPixelsCam | 
|---|
| 65 | // | 
|---|
| 66 | // If the flag RelTimeCalibration() is set, a calibration of the relative arrival | 
|---|
| 67 | // times is also performed. The following containers (rectangular) and | 
|---|
| 68 | // tasks (ellipses) are called to produce an MCalibrationRelTimeCam used by | 
|---|
| 69 | // MCalibrateTime to correct timing offset between pixels: (MCalibrateTime is not | 
|---|
| 70 | // called from this class) | 
|---|
| 71 | // | 
|---|
| 72 | //Begin_Html | 
|---|
| 73 | /* | 
|---|
| 74 | <img src="images/RelTimeClasses.gif"> | 
|---|
| 75 | */ | 
|---|
| 76 | //End_Html | 
|---|
| 77 | // | 
|---|
| 78 | // Different arrival time extractors can be set directly with the command | 
|---|
| 79 | // SetTimeExtractor(MExtractor *) | 
|---|
| 80 | // | 
|---|
| 81 | // Resource file entries are case sensitive! | 
|---|
| 82 | // | 
|---|
| 83 | // See also: MHCalibrationRelTimePix, MHCalibrationRelTimeCam, MHGausEvents | 
|---|
| 84 | //           MCalibrationRelTimePix, MCalibrationRelTimeCam | 
|---|
| 85 | //           MBadPixelsPix, MBadPixelsCam | 
|---|
| 86 | // | 
|---|
| 87 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 88 | #include "MJCalibration.h" | 
|---|
| 89 |  | 
|---|
| 90 | #include <TFile.h> | 
|---|
| 91 | #include <TF1.h> | 
|---|
| 92 | #include <TStyle.h> | 
|---|
| 93 | #include <TCanvas.h> | 
|---|
| 94 | #include <TSystem.h> | 
|---|
| 95 | #include <TLine.h> | 
|---|
| 96 | #include <TLatex.h> | 
|---|
| 97 | #include <TLegend.h> | 
|---|
| 98 | #include <TRegexp.h> | 
|---|
| 99 | #include <TPaveText.h> | 
|---|
| 100 | #include <TPaveStats.h> | 
|---|
| 101 | #include <TEnv.h> | 
|---|
| 102 |  | 
|---|
| 103 | #include "MLog.h" | 
|---|
| 104 | #include "MLogManip.h" | 
|---|
| 105 |  | 
|---|
| 106 | #include "MEnv.h" | 
|---|
| 107 | #include "MRunIter.h" | 
|---|
| 108 | #include "MSequence.h" | 
|---|
| 109 | #include "MParList.h" | 
|---|
| 110 | #include "MTaskList.h" | 
|---|
| 111 | #include "MEvtLoop.h" | 
|---|
| 112 |  | 
|---|
| 113 | #include "MHCamera.h" | 
|---|
| 114 | #include "MGeomCam.h" | 
|---|
| 115 |  | 
|---|
| 116 | #include "MCalibrationPatternDecode.h" | 
|---|
| 117 | #include "MCalibrationCam.h" | 
|---|
| 118 | #include "MCalibrationQECam.h" | 
|---|
| 119 | #include "MCalibrationQEPix.h" | 
|---|
| 120 | #include "MCalibrationChargeCam.h" | 
|---|
| 121 | #include "MCalibrationChargePix.h" | 
|---|
| 122 | #include "MCalibrationChargePINDiode.h" | 
|---|
| 123 | #include "MCalibrationBlindPix.h" | 
|---|
| 124 | #include "MCalibrationBlindCam.h" | 
|---|
| 125 | #include "MCalibrationBlindCamOneOldStyle.h" | 
|---|
| 126 | #include "MCalibrationBlindCamTwoNewStyle.h" | 
|---|
| 127 | #include "MCalibrationBlindCamThreeNewStyle.h" | 
|---|
| 128 | #include "MCalibrationChargeCalc.h" | 
|---|
| 129 | #include "MCalibColorSet.h" | 
|---|
| 130 | #include "MCalibrationRelTimeCam.h" | 
|---|
| 131 | #include "MCalibrationRelTimeCalc.h" | 
|---|
| 132 |  | 
|---|
| 133 | #include "MHGausEvents.h" | 
|---|
| 134 | #include "MHCalibrationCam.h" | 
|---|
| 135 | #include "MHCalibrationChargeCam.h" | 
|---|
| 136 | #include "MHCalibrationChargeBlindCam.h" | 
|---|
| 137 | #include "MHCalibrationChargePINDiode.h" | 
|---|
| 138 | #include "MHCalibrationRelTimeCam.h" | 
|---|
| 139 | #include "MHCalibrationPix.h" | 
|---|
| 140 |  | 
|---|
| 141 | #include "MHCamEvent.h" | 
|---|
| 142 |  | 
|---|
| 143 | #include "MReadMarsFile.h" | 
|---|
| 144 | #include "MPedCalcPedRun.h" | 
|---|
| 145 | #include "MRawFileRead.h" | 
|---|
| 146 | #include "MGeomApply.h" | 
|---|
| 147 | #include "MPedestalSubtract.h" | 
|---|
| 148 | #include "MTaskEnv.h" | 
|---|
| 149 | #include "MBadPixelsMerge.h" | 
|---|
| 150 | #include "MBadPixelsCam.h" | 
|---|
| 151 | #include "MExtractTime.h" | 
|---|
| 152 | #include "MExtractor.h" | 
|---|
| 153 | #include "MExtractPINDiode.h" | 
|---|
| 154 | #include "MExtractBlindPixel.h" | 
|---|
| 155 | #include "MExtractTimeAndChargeSpline.h" | 
|---|
| 156 | #include "MFCosmics.h" | 
|---|
| 157 | #include "MFTriggerPattern.h" | 
|---|
| 158 | #include "MContinue.h" | 
|---|
| 159 | #include "MFillH.h" | 
|---|
| 160 |  | 
|---|
| 161 | #include "MTriggerPatternDecode.h" | 
|---|
| 162 |  | 
|---|
| 163 | #include "MArrivalTimeCam.h" | 
|---|
| 164 |  | 
|---|
| 165 | #include "MStatusDisplay.h" | 
|---|
| 166 |  | 
|---|
| 167 | ClassImp(MJCalibration); | 
|---|
| 168 |  | 
|---|
| 169 | using namespace std; | 
|---|
| 170 |  | 
|---|
| 171 | const Int_t MJCalibration::gkIFAEBoxInaugurationRun        = 20113; | 
|---|
| 172 | const Int_t MJCalibration::gkSecondBlindPixelInstallation  = 31693; | 
|---|
| 173 | const Int_t MJCalibration::gkSpecialPixelsContInstallation = 34057; | 
|---|
| 174 | const Int_t MJCalibration::gkThirdBlindPixelInstallation   = 43308; | 
|---|
| 175 | const TString MJCalibration::fgReferenceFile = "mjobs/calibrationref.rc"; | 
|---|
| 176 | const TString MJCalibration::fgHiLoCalibFile = "resources/hilocalib.rc"; | 
|---|
| 177 |  | 
|---|
| 178 | // -------------------------------------------------------------------------- | 
|---|
| 179 | // | 
|---|
| 180 | // Default constructor. | 
|---|
| 181 | // | 
|---|
| 182 | // - fExtractor to NULL, fTimeExtractor to NULL, fColor to kNONE, | 
|---|
| 183 | //   fDisplay to kNormalDisplay, kRelTimes to kFALSE, kataCheck to kFALSE, kDebug to kFALSE | 
|---|
| 184 | // - SetUseBlindPixel() | 
|---|
| 185 | // - SetUsePINDiode() | 
|---|
| 186 | // | 
|---|
| 187 | MJCalibration::MJCalibration(const char *name, const char *title) | 
|---|
| 188 | : fExtractor(NULL), fTimeExtractor(NULL), | 
|---|
| 189 | fColor(MCalibrationCam::kNONE), fDisplayType(kDataCheckDisplay), | 
|---|
| 190 | fGeometry("MGeomCamMagic") | 
|---|
| 191 | { | 
|---|
| 192 |  | 
|---|
| 193 | fName  = name  ? name  : "MJCalibration"; | 
|---|
| 194 | fTitle = title ? title : "Tool to create the calibration constants for one calibration run"; | 
|---|
| 195 |  | 
|---|
| 196 | //SetHiLoCalibration(); | 
|---|
| 197 | SetRelTimeCalibration(); | 
|---|
| 198 | SetDebug(kFALSE); | 
|---|
| 199 |  | 
|---|
| 200 | SetReferenceFile(); | 
|---|
| 201 | SetHiLoCalibFile(); | 
|---|
| 202 |  | 
|---|
| 203 | fConvFADC2PheMin           = 0.; | 
|---|
| 204 | fConvFADC2PheMax           = 1.5; | 
|---|
| 205 | fConvFADC2PhotMin          = 0.; | 
|---|
| 206 | fConvFADC2PhotMax          = 10.; | 
|---|
| 207 | fQEMin                     = 0.; | 
|---|
| 208 | fQEMax                     = 0.3; | 
|---|
| 209 | fArrivalTimeMin            = 1.; | 
|---|
| 210 | fArrivalTimeMax            = 10.; | 
|---|
| 211 | fTimeOffsetMin             = -3.; | 
|---|
| 212 | fTimeOffsetMax             =  3.; | 
|---|
| 213 | fTimeResolutionMin         =  0.; | 
|---|
| 214 | fTimeResolutionMax         =  1.; | 
|---|
| 215 |  | 
|---|
| 216 | fRefFADC2PheInner          = 0.14; | 
|---|
| 217 | fRefFADC2PheOuter          = 0.4; | 
|---|
| 218 | fRefConvFADC2PheInner      = 0.14; | 
|---|
| 219 | fRefConvFADC2PheOuter      = 0.52; | 
|---|
| 220 | fRefQEInner                = 0.18; | 
|---|
| 221 | fRefQEOuter                = 0.12; | 
|---|
| 222 | fRefArrivalTimeInner       = 4.5; | 
|---|
| 223 | fRefArrivalTimeOuter       = 5.0; | 
|---|
| 224 | fRefArrivalTimeRmsInner    = 0.5; | 
|---|
| 225 | fRefArrivalTimeRmsOuter    = 0.5; | 
|---|
| 226 | fRefTimeOffsetInner        = -0.23; | 
|---|
| 227 | fRefTimeOffsetOuter        = 0.39; | 
|---|
| 228 | fRefTimeResolutionInner    = 0.153; | 
|---|
| 229 | fRefTimeResolutionOuter    = 0.128; | 
|---|
| 230 |  | 
|---|
| 231 | } | 
|---|
| 232 |  | 
|---|
| 233 | void MJCalibration::DrawTab(MParList &plist, const char *cont, const char *name, Option_t *opt) | 
|---|
| 234 | { | 
|---|
| 235 | TObject *obj = plist.FindObject(cont); | 
|---|
| 236 | if (!obj) | 
|---|
| 237 | return; | 
|---|
| 238 |  | 
|---|
| 239 | fDisplay->AddTab(name); | 
|---|
| 240 | obj->DrawClone(opt); | 
|---|
| 241 | } | 
|---|
| 242 |  | 
|---|
| 243 | // -------------------------------------------------------------------------- | 
|---|
| 244 | // | 
|---|
| 245 | // Display the results in MStatusDisplay: | 
|---|
| 246 | // | 
|---|
| 247 | // - Add "Calibration" to the MStatusDisplay title | 
|---|
| 248 | // - Retrieve the MGeomCam from MParList | 
|---|
| 249 | // - Initialize the following MHCamera's: | 
|---|
| 250 | //   1)  MCalibrationPix::GetMean() | 
|---|
| 251 | //   2)  MCalibrationPix::Sigma() | 
|---|
| 252 | //   3)  MCalibrationChargePix::GetRSigma() | 
|---|
| 253 | //   4)  MCalibrationChargePix::GetRSigmaPerCharge() | 
|---|
| 254 | //   5)  MCalibrationChargePix::GetPheFFactorMethod() | 
|---|
| 255 | //   6)  MCalibrationChargePix::GetMeanConvFADC2Phe() | 
|---|
| 256 | //   7)  MCalibrationChargePix::GetMeanFFactorFADC2Phot() | 
|---|
| 257 | //   8)  MCalibrationQEPix::GetQECascadesFFactor() | 
|---|
| 258 | //   9)  MCalibrationQEPix::GetQECascadesBlindPixel() | 
|---|
| 259 | //   10) MCalibrationQEPix::GetQECascadesPINDiode() | 
|---|
| 260 | //   11) MCalibrationQEPix::GetQECascadesCombined() | 
|---|
| 261 | //   12) MCalibrationQEPix::IsAverageQEFFactorAvailable() | 
|---|
| 262 | //   13) MCalibrationQEPix::IsAverageQEBlindPixelAvailable() | 
|---|
| 263 | //   14) MCalibrationQEPix::IsAverageQEPINDiodeAvailable() | 
|---|
| 264 | //   15) MCalibrationQEPix::IsAverageQECombinedAvailable() | 
|---|
| 265 | //   16) MCalibrationChargePix::IsHiGainSaturation() | 
|---|
| 266 | //   17) MCalibrationPix::GetHiLoMeansDivided() | 
|---|
| 267 | //   18) MCalibrationPix::GetHiLoSigmasDivided() | 
|---|
| 268 | //   19) MCalibrationChargePix::GetHiGainPickup() | 
|---|
| 269 | //   20) MCalibrationChargePix::GetLoGainPickup() | 
|---|
| 270 | //   21) MCalibrationChargePix::GetHiGainBlackout() | 
|---|
| 271 | //   22) MCalibrationChargePix::GetLoGainBlackout() | 
|---|
| 272 | //   23) MCalibrationPix::IsExcluded() | 
|---|
| 273 | //   24) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun) | 
|---|
| 274 | //   25) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun) | 
|---|
| 275 | //   26) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating) | 
|---|
| 276 | //   27) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating) | 
|---|
| 277 | //   28) MCalibrationChargePix::GetAbsTimeMean() | 
|---|
| 278 | //   29) MCalibrationChargePix::GetAbsTimeRms() | 
|---|
| 279 | // | 
|---|
| 280 | // If the flag SetFullDisplay() is set, all MHCameras will be displayed. | 
|---|
| 281 | // if the flag SetDataCheckDisplay() is set, only the most important ones are displayed | 
|---|
| 282 | // and otherwise, (default: SetNormalDisplay()), a good selection of plots is given | 
|---|
| 283 | // | 
|---|
| 284 | void MJCalibration::DisplayResult(MParList &plist) | 
|---|
| 285 | { | 
|---|
| 286 | if (!fDisplay) | 
|---|
| 287 | return; | 
|---|
| 288 |  | 
|---|
| 289 | TString drawoption = "nonew "; | 
|---|
| 290 | if (fDisplayType == kDataCheckDisplay) | 
|---|
| 291 | drawoption += "datacheck"; | 
|---|
| 292 | if (fDisplayType == kFullDisplay) | 
|---|
| 293 | drawoption += "all"; | 
|---|
| 294 |  | 
|---|
| 295 | if (IsUsePINDiode()) | 
|---|
| 296 | DrawTab(plist, "MHCalibrationChargePINDiode", "PINDiode",  drawoption); | 
|---|
| 297 | if (IsUseBlindPixel()) | 
|---|
| 298 | DrawTab(plist, "MHCalibrationChargeBlindCam", "BlindPix",  drawoption); | 
|---|
| 299 | if (IsRelTimes()) | 
|---|
| 300 | DrawTab(plist, "MHCalibrationRelTimeCam",     "Time",      drawoption); | 
|---|
| 301 | DrawTab(plist, "MHCalibrationChargeCam",          "Charge",    drawoption); | 
|---|
| 302 |  | 
|---|
| 303 | // | 
|---|
| 304 | // Update display | 
|---|
| 305 | // | 
|---|
| 306 | TString title = fDisplay->GetTitle(); | 
|---|
| 307 | title += "--  Calibration "; | 
|---|
| 308 | title += Form("calib%08d", fSequence.GetSequence()); | 
|---|
| 309 | title += "  --"; | 
|---|
| 310 | fDisplay->SetTitle(title); | 
|---|
| 311 |  | 
|---|
| 312 | // | 
|---|
| 313 | // Get container from list | 
|---|
| 314 | // | 
|---|
| 315 | MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam"); | 
|---|
| 316 |  | 
|---|
| 317 | // Create histograms to display | 
|---|
| 318 | MHCamera disp1 (geomcam, "Charge",            "Fitted Mean Signal (Charges)"); | 
|---|
| 319 | MHCamera disp2 (geomcam, "SigmaCharge",       "Sigma of Fitted Signal"); | 
|---|
| 320 | MHCamera disp3 (geomcam, "RSigma",            "Reduced Sigmas"); | 
|---|
| 321 | MHCamera disp4 (geomcam, "RSigmaPerCharge",   "Reduced Sigma per Charge"); | 
|---|
| 322 | MHCamera disp5 (geomcam, "NumPhes",           "Number Photo-electrons"); | 
|---|
| 323 | MHCamera disp6 (geomcam, "ConvFADC2Phes",     "Phes per Charge (Before Flat-Field)"); | 
|---|
| 324 | MHCamera disp7 (geomcam, "TotalFFactor",      "Total F-Factor(F-Factor Method)"); | 
|---|
| 325 | MHCamera disp8 (geomcam, "CascadesQEFFactor", "Cascades QE (F-Factor Method)"); | 
|---|
| 326 | MHCamera disp9 (geomcam, "CascadesQEBlindPix","Cascades QE (Blind Pixel Method)"); | 
|---|
| 327 | MHCamera disp10(geomcam, "CascadesQEPINDiode","Cascades QE (PIN Diode Method)"); | 
|---|
| 328 | MHCamera disp11(geomcam, "CascadesQECombined","Cascades QE (Combined Method)"); | 
|---|
| 329 | MHCamera disp12(geomcam, "FFactorValid",      "Pixels with Valid F-Factor Calibration"); | 
|---|
| 330 | MHCamera disp13(geomcam, "BlindPixelValid",   "Pixels with valid BlindPixel Calibration"); | 
|---|
| 331 | MHCamera disp14(geomcam, "PINdiodeValid",     "Pixels with Valid PINDiode Calibration"); | 
|---|
| 332 | MHCamera disp15(geomcam, "CombinedValid",     "Pixels with Valid Combined Calibration"); | 
|---|
| 333 | MHCamera disp16(geomcam, "Saturation",        "Pixels with Saturated Hi Gain"); | 
|---|
| 334 | MHCamera disp17(geomcam, "ConversionMeans",   "Conversion HiGain.vs.LoGain Means"); | 
|---|
| 335 | MHCamera disp18(geomcam, "ConversionSigmas",  "Conversion HiGain.vs.LoGain Sigmas"); | 
|---|
| 336 | MHCamera disp19(geomcam, "HiGainPickup",      "Number Pickup Events Hi Gain"); | 
|---|
| 337 | MHCamera disp20(geomcam, "LoGainPickup",      "Number Pickup Events Lo Gain"); | 
|---|
| 338 | MHCamera disp21(geomcam, "HiGainBlackout",    "Number Blackout Events Hi Gain"); | 
|---|
| 339 | MHCamera disp22(geomcam, "LoGainBlackout",    "Number Blackout Events Lo Gain"); | 
|---|
| 340 | MHCamera disp23(geomcam, "Excluded",          "Pixels Previously Excluded"); | 
|---|
| 341 | MHCamera disp24(geomcam, "UnSuitable",        "Pixels NOT Suited for Further Analysis"); | 
|---|
| 342 | MHCamera disp25(geomcam, "UnReliable",        "Pixels Suitable, but NOT Reliable for Further Analysis"); | 
|---|
| 343 | MHCamera disp26(geomcam, "HiGainOscillating", "Oscillating Pixels High Gain"); | 
|---|
| 344 | MHCamera disp27(geomcam, "LoGainOscillating", "Oscillating Pixels Low Gain"); | 
|---|
| 345 | MHCamera disp28(geomcam, "AbsTimeMean",       "Abs. Arrival Times"); | 
|---|
| 346 | MHCamera disp29(geomcam, "AbsTimeRms",        "RMS of Arrival Times"); | 
|---|
| 347 | MHCamera disp30(geomcam, "MeanTime",          "Mean Rel. Arrival Times"); | 
|---|
| 348 | MHCamera disp31(geomcam, "SigmaTime",         "Sigma Rel. Arrival Times"); | 
|---|
| 349 | MHCamera disp32(geomcam, "TimeProb",          "Probability of Time Fit"); | 
|---|
| 350 | MHCamera disp33(geomcam, "TimeNotFitValid",   "Pixels with not valid Fit Results"); | 
|---|
| 351 | MHCamera disp34(geomcam, "TimeOscillating",   "Oscillating Pixels"); | 
|---|
| 352 | MHCamera disp35(geomcam, "TotalConv",         "Conversion Factor to Photons"); | 
|---|
| 353 | MHCamera disp36(geomcam, "RMSperMean",        "Charge histogram RMS per Mean"); | 
|---|
| 354 | MHCamera disp37(geomcam, "TotalConvPhe",      "Conversion Factor to equiv. Phe's"); | 
|---|
| 355 |  | 
|---|
| 356 | // Fitted charge means and sigmas | 
|---|
| 357 | disp1.SetCamContent(fCalibrationCam,  0); | 
|---|
| 358 | disp1.SetCamError(  fCalibrationCam,  1); | 
|---|
| 359 | disp2.SetCamContent(fCalibrationCam,  2); | 
|---|
| 360 | disp2.SetCamError(  fCalibrationCam,  3); | 
|---|
| 361 |  | 
|---|
| 362 | // Reduced Sigmas and reduced sigmas per charge | 
|---|
| 363 | disp3.SetCamContent(fCalibrationCam,  5); | 
|---|
| 364 | disp3.SetCamError(  fCalibrationCam,  6); | 
|---|
| 365 | disp4.SetCamContent(fCalibrationCam,  7); | 
|---|
| 366 | disp4.SetCamError(  fCalibrationCam,  8); | 
|---|
| 367 |  | 
|---|
| 368 | // F-Factor Method | 
|---|
| 369 | disp5.SetCamContent(fCalibrationCam,  9); | 
|---|
| 370 | disp5.SetCamError(  fCalibrationCam, 10); | 
|---|
| 371 | disp6.SetCamContent(fCalibrationCam, 11); | 
|---|
| 372 | disp6.SetCamError(  fCalibrationCam, 12); | 
|---|
| 373 | disp7.SetCamContent(fCalibrationCam, 13); | 
|---|
| 374 | disp7.SetCamError(  fCalibrationCam, 14); | 
|---|
| 375 |  | 
|---|
| 376 | // Quantum Efficiencies | 
|---|
| 377 | disp8.SetCamContent (fQECam, 0 ); | 
|---|
| 378 | disp8.SetCamError   (fQECam, 1 ); | 
|---|
| 379 | disp9.SetCamContent (fQECam, 2 ); | 
|---|
| 380 | disp9.SetCamError   (fQECam, 3 ); | 
|---|
| 381 | disp10.SetCamContent(fQECam, 4 ); | 
|---|
| 382 | disp10.SetCamError  (fQECam, 5 ); | 
|---|
| 383 | disp11.SetCamContent(fQECam, 6 ); | 
|---|
| 384 | disp11.SetCamError  (fQECam, 7 ); | 
|---|
| 385 |  | 
|---|
| 386 | // Valid flags | 
|---|
| 387 | disp12.SetCamContent(fQECam, 8 ); | 
|---|
| 388 | disp13.SetCamContent(fQECam, 9 ); | 
|---|
| 389 | disp14.SetCamContent(fQECam, 10); | 
|---|
| 390 | disp15.SetCamContent(fQECam, 11); | 
|---|
| 391 |  | 
|---|
| 392 | // Conversion Hi-Lo | 
|---|
| 393 | disp16.SetCamContent(fCalibrationCam, 25); | 
|---|
| 394 | disp17.SetCamContent(fCalibrationCam, 16); | 
|---|
| 395 | disp17.SetCamError  (fCalibrationCam, 17); | 
|---|
| 396 | disp18.SetCamContent(fCalibrationCam, 18); | 
|---|
| 397 | disp18.SetCamError  (fCalibrationCam, 19); | 
|---|
| 398 |  | 
|---|
| 399 | // Pickup and Blackout | 
|---|
| 400 | disp19.SetCamContent(fCalibrationCam, 21); | 
|---|
| 401 | disp20.SetCamContent(fCalibrationCam, 22); | 
|---|
| 402 | disp21.SetCamContent(fCalibrationCam, 23); | 
|---|
| 403 | disp22.SetCamContent(fCalibrationCam, 24); | 
|---|
| 404 |  | 
|---|
| 405 | // Pixels with defects | 
|---|
| 406 | disp23.SetCamContent(fCalibrationCam, 20); | 
|---|
| 407 | disp24.SetCamContent(fBadPixels, 6); | 
|---|
| 408 | disp25.SetCamContent(fBadPixels, 7); | 
|---|
| 409 |  | 
|---|
| 410 | // Oscillations | 
|---|
| 411 | disp26.SetCamContent(fBadPixels, 10); | 
|---|
| 412 | disp27.SetCamContent(fBadPixels, 11); | 
|---|
| 413 |  | 
|---|
| 414 | // Arrival Times | 
|---|
| 415 | disp28.SetCamContent(fCalibrationCam, 26); | 
|---|
| 416 | disp28.SetCamError(  fCalibrationCam, 27); | 
|---|
| 417 | disp29.SetCamContent(fCalibrationCam, 27); | 
|---|
| 418 |  | 
|---|
| 419 | // RMS and Mean | 
|---|
| 420 | disp36.SetCamContent(fCalibrationCam,32); | 
|---|
| 421 | disp36.SetCamError(fCalibrationCam,33); | 
|---|
| 422 |  | 
|---|
| 423 | disp1.SetYTitle("Q [FADC cnts]"); | 
|---|
| 424 | disp2.SetYTitle("\\sigma_{Q} [FADC cnts]"); | 
|---|
| 425 |  | 
|---|
| 426 | disp3.SetYTitle("\\sqrt{\\sigma^{2}_{Q} - RMS^{2}_{Ped}} [FADC cnts]"); | 
|---|
| 427 | disp4.SetYTitle("Red.Sigma/<Q> [1]"); | 
|---|
| 428 |  | 
|---|
| 429 | disp5.SetYTitle("Photo-electons [1]"); | 
|---|
| 430 | disp6.SetYTitle("Phes/<Q> [FADC cnts^{-1}]"); | 
|---|
| 431 | disp7.SetYTitle("Total F-Factor [1]"); | 
|---|
| 432 |  | 
|---|
| 433 | disp8.SetYTitle("QE [1]"); | 
|---|
| 434 | disp9.SetYTitle("QE [1]"); | 
|---|
| 435 | disp10.SetYTitle("QE [1]"); | 
|---|
| 436 | disp11.SetYTitle("QE [1]"); | 
|---|
| 437 |  | 
|---|
| 438 | disp12.SetYTitle("[1]"); | 
|---|
| 439 | disp13.SetYTitle("[1]"); | 
|---|
| 440 | disp14.SetYTitle("[1]"); | 
|---|
| 441 | disp15.SetYTitle("[1]"); | 
|---|
| 442 | disp16.SetYTitle("[1]"); | 
|---|
| 443 |  | 
|---|
| 444 | disp17.SetYTitle("<Q>(High)/<Q>(Low) [1]"); | 
|---|
| 445 | disp18.SetYTitle("\\sigma_{Q}(High)/\\sigma_{Q}(Low) [1]"); | 
|---|
| 446 |  | 
|---|
| 447 | disp19.SetYTitle("[1]"); | 
|---|
| 448 | disp20.SetYTitle("[1]"); | 
|---|
| 449 | disp21.SetYTitle("[1]"); | 
|---|
| 450 | disp22.SetYTitle("[1]"); | 
|---|
| 451 | //    disp23.SetYTitle("[1]"); | 
|---|
| 452 | //    disp24.SetYTitle("[1]"); | 
|---|
| 453 | //    disp25.SetYTitle("[1]"); | 
|---|
| 454 | disp26.SetYTitle("[1]"); | 
|---|
| 455 | disp27.SetYTitle("[1]"); | 
|---|
| 456 |  | 
|---|
| 457 | disp28.SetYTitle("Mean Abs. Time [FADC sl.]"); | 
|---|
| 458 | disp29.SetYTitle("RMS Abs. Time [FADC sl.]"); | 
|---|
| 459 | disp35.SetYTitle("Conv.Factor [Ph/FADC cnts]"); | 
|---|
| 460 | disp36.SetYTitle("Charge RMS/<Q> [1]"); | 
|---|
| 461 | disp37.SetYTitle("Conv.Factor [Phe/FADC cnts]"); | 
|---|
| 462 |  | 
|---|
| 463 | for (UInt_t i=0;i<geomcam.GetNumPixels();i++) | 
|---|
| 464 | { | 
|---|
| 465 |  | 
|---|
| 466 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCalibrationCam[i]; | 
|---|
| 467 | MCalibrationQEPix     &qe  = (MCalibrationQEPix&)fQECam[i]; | 
|---|
| 468 |  | 
|---|
| 469 | if (!pix.IsFFactorMethodValid()) | 
|---|
| 470 | continue; | 
|---|
| 471 |  | 
|---|
| 472 | const Float_t convphe  = pix.GetMeanConvFADC2Phe(); | 
|---|
| 473 | const Float_t quaeff   = qe.GetQECascadesFFactor(); | 
|---|
| 474 |  | 
|---|
| 475 | disp35.Fill(i,convphe/quaeff); | 
|---|
| 476 | disp35.SetUsed(i); | 
|---|
| 477 |  | 
|---|
| 478 | disp37.Fill(i,convphe/quaeff*MCalibrationQEPix::gkDefaultAverageQE); | 
|---|
| 479 | disp37.SetUsed(i); | 
|---|
| 480 | } | 
|---|
| 481 |  | 
|---|
| 482 |  | 
|---|
| 483 | if (IsRelTimes()) | 
|---|
| 484 | { | 
|---|
| 485 | disp30.SetCamContent(fRelTimeCam, 0); | 
|---|
| 486 | disp30.SetCamError(  fRelTimeCam, 1); | 
|---|
| 487 | disp31.SetCamContent(fRelTimeCam, 2); | 
|---|
| 488 | disp31.SetCamError(  fRelTimeCam, 3); | 
|---|
| 489 | disp32.SetCamContent(fRelTimeCam, 4); | 
|---|
| 490 | disp33.SetCamContent(fBadPixels, 20); | 
|---|
| 491 | disp34.SetCamContent(fBadPixels, 21); | 
|---|
| 492 |  | 
|---|
| 493 | disp30.SetYTitle("Time Offset [FADC units]"); | 
|---|
| 494 | disp31.SetYTitle("Timing resolution [FADC units]"); | 
|---|
| 495 | disp32.SetYTitle("P_{Time} [1]"); | 
|---|
| 496 | disp33.SetYTitle("[1]"); | 
|---|
| 497 | disp34.SetYTitle("[1]"); | 
|---|
| 498 | } | 
|---|
| 499 |  | 
|---|
| 500 | if (fDisplayType == kDataCheckDisplay) | 
|---|
| 501 | { | 
|---|
| 502 |  | 
|---|
| 503 | TCanvas &c1 = fDisplay->AddTab("FitCharge"); | 
|---|
| 504 | c1.Divide(3, 3); | 
|---|
| 505 |  | 
|---|
| 506 | // | 
|---|
| 507 | // MEAN CHARGES | 
|---|
| 508 | // | 
|---|
| 509 |  | 
|---|
| 510 | c1.cd(1); | 
|---|
| 511 | gPad->SetBorderMode(0); | 
|---|
| 512 | gPad->SetTicks(); | 
|---|
| 513 | MHCamera *obj1=(MHCamera*)disp1.DrawCopy("hist"); | 
|---|
| 514 | // | 
|---|
| 515 | // for the datacheck, fix the ranges!! | 
|---|
| 516 | // | 
|---|
| 517 | // obj1->SetMinimum(fChargeMin); | 
|---|
| 518 | // obj1->SetMaximum(fChargeMax); | 
|---|
| 519 | // | 
|---|
| 520 | // Set the datacheck sizes: | 
|---|
| 521 | // | 
|---|
| 522 | FixDataCheckHist((TH1D*)obj1); | 
|---|
| 523 | obj1->SetStats(kFALSE); | 
|---|
| 524 | // | 
|---|
| 525 | // set reference lines | 
|---|
| 526 | // | 
|---|
| 527 | //        DisplayReferenceLines(obj1,0); | 
|---|
| 528 |  | 
|---|
| 529 | c1.cd(4); | 
|---|
| 530 | gPad->SetBorderMode(0); | 
|---|
| 531 | obj1->SetPrettyPalette(); | 
|---|
| 532 | obj1->Draw(); | 
|---|
| 533 |  | 
|---|
| 534 | c1.cd(7); | 
|---|
| 535 | gPad->SetBorderMode(0); | 
|---|
| 536 | gPad->SetTicks(); | 
|---|
| 537 | TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName()); | 
|---|
| 538 | obj2->Draw(); | 
|---|
| 539 | obj2->SetBit(kCanDelete); | 
|---|
| 540 | obj2->Fit("gaus","Q"); | 
|---|
| 541 | TF1 *fun2 = obj2->GetFunction("gaus"); | 
|---|
| 542 | fun2->SetLineColor(kYellow); | 
|---|
| 543 | gPad->Modified(); | 
|---|
| 544 | gPad->Update(); | 
|---|
| 545 | TPaveStats *st = (TPaveStats*)obj2->GetListOfFunctions()->FindObject("stats"); | 
|---|
| 546 | st->SetY1NDC(0.55); | 
|---|
| 547 | st->SetY2NDC(0.89); | 
|---|
| 548 | st->SetX1NDC(0.65); | 
|---|
| 549 | st->SetX2NDC(0.99); | 
|---|
| 550 | gPad->Modified(); | 
|---|
| 551 | gPad->Update(); | 
|---|
| 552 | // | 
|---|
| 553 | // Set the datacheck sizes: | 
|---|
| 554 | // | 
|---|
| 555 | FixDataCheckHist(obj2); | 
|---|
| 556 | obj2->SetStats(1); | 
|---|
| 557 |  | 
|---|
| 558 | // | 
|---|
| 559 | // Display the outliers as dead and noisy pixels | 
|---|
| 560 | // | 
|---|
| 561 | DisplayOutliers(obj2,"low-ampl.","high-ampl."); | 
|---|
| 562 | TLatex flattex; | 
|---|
| 563 | flattex.SetTextSize(0.07); | 
|---|
| 564 | const Double_t minl = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst()); | 
|---|
| 565 | const Double_t maxl = obj2->GetBinCenter(obj2->GetXaxis()->GetLast()); | 
|---|
| 566 | flattex.DrawLatex(minl+0.015*(maxl-minl),obj2->GetBinContent(obj2->GetMaximumBin())/1.35, | 
|---|
| 567 | Form("Flatfield precision: %4.2f%%", | 
|---|
| 568 | fun2->GetParameter(2)/fun2->GetParameter(1)*100.)); | 
|---|
| 569 |  | 
|---|
| 570 | // | 
|---|
| 571 | // RMS per Charge | 
|---|
| 572 | // | 
|---|
| 573 |  | 
|---|
| 574 | c1.cd(2); | 
|---|
| 575 | gPad->SetBorderMode(0); | 
|---|
| 576 | gPad->SetTicks(); | 
|---|
| 577 | MHCamera *obj3=(MHCamera*)disp36.DrawCopy("hist"); | 
|---|
| 578 | // | 
|---|
| 579 | // for the datacheck, fix the ranges!! | 
|---|
| 580 | // | 
|---|
| 581 | //      obj3->SetMinimum(0.); | 
|---|
| 582 | // obj3->SetMaximum(fChargeMax); | 
|---|
| 583 | // | 
|---|
| 584 | // Set the datacheck sizes: | 
|---|
| 585 | // | 
|---|
| 586 | FixDataCheckHist((TH1D*)obj3); | 
|---|
| 587 | obj3->SetStats(kFALSE); | 
|---|
| 588 | // | 
|---|
| 589 | // set reference lines | 
|---|
| 590 | // | 
|---|
| 591 | //        DisplayReferenceLines(obj3,0); | 
|---|
| 592 |  | 
|---|
| 593 | c1.cd(5); | 
|---|
| 594 | gPad->SetBorderMode(0); | 
|---|
| 595 | obj3->SetPrettyPalette(); | 
|---|
| 596 | obj3->Draw(); | 
|---|
| 597 |  | 
|---|
| 598 | c1.cd(8); | 
|---|
| 599 | gPad->SetBorderMode(0); | 
|---|
| 600 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 601 | DisplayDoubleProject(&disp36, "dead", "noisy"); | 
|---|
| 602 |  | 
|---|
| 603 | // | 
|---|
| 604 | // PHOTO ELECTRONS | 
|---|
| 605 | // | 
|---|
| 606 |  | 
|---|
| 607 | c1.cd(3); | 
|---|
| 608 | gPad->SetBorderMode(0); | 
|---|
| 609 | gPad->SetTicks(); | 
|---|
| 610 | MHCamera *obj4=(MHCamera*)disp5.DrawCopy("hist"); | 
|---|
| 611 | // | 
|---|
| 612 | // for the datacheck, fix the ranges!! | 
|---|
| 613 | // | 
|---|
| 614 | // obj3->SetMinimum(fChargeMin); | 
|---|
| 615 | // obj3->SetMaximum(fChargeMax); | 
|---|
| 616 | // | 
|---|
| 617 | // Set the datacheck sizes: | 
|---|
| 618 | // | 
|---|
| 619 | FixDataCheckHist((TH1D*)obj4); | 
|---|
| 620 | obj4->SetStats(kFALSE); | 
|---|
| 621 | // | 
|---|
| 622 | // set reference lines | 
|---|
| 623 | // | 
|---|
| 624 | //        DisplayReferenceLines(obj3,0); | 
|---|
| 625 |  | 
|---|
| 626 | c1.cd(6); | 
|---|
| 627 | gPad->SetBorderMode(0); | 
|---|
| 628 | obj4->SetPrettyPalette(); | 
|---|
| 629 | obj4->Draw(); | 
|---|
| 630 |  | 
|---|
| 631 | c1.cd(9); | 
|---|
| 632 | gPad->SetBorderMode(0); | 
|---|
| 633 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 634 | DisplayDoubleProject(&disp5, "dead", "noisy"); | 
|---|
| 635 |  | 
|---|
| 636 | // | 
|---|
| 637 | // CONVERSION FACTORS | 
|---|
| 638 | // | 
|---|
| 639 | TCanvas &c2 = fDisplay->AddTab("Conversion"); | 
|---|
| 640 | c2.Divide(3,3); | 
|---|
| 641 |  | 
|---|
| 642 | c2.cd(1); | 
|---|
| 643 | gPad->SetBorderMode(0); | 
|---|
| 644 | gPad->SetTicks(); | 
|---|
| 645 | MHCamera *obj5=(MHCamera*)disp6.DrawCopy("hist"); | 
|---|
| 646 | // | 
|---|
| 647 | // for the datacheck, fix the ranges!! | 
|---|
| 648 | // | 
|---|
| 649 | obj5->SetMinimum(fConvFADC2PheMin); | 
|---|
| 650 | obj5->SetMaximum(fConvFADC2PheMax); | 
|---|
| 651 | // | 
|---|
| 652 | // Set the datacheck sizes: | 
|---|
| 653 | // | 
|---|
| 654 | FixDataCheckHist((TH1D*)obj5); | 
|---|
| 655 | obj5->SetStats(kFALSE); | 
|---|
| 656 | // | 
|---|
| 657 | // set reference lines | 
|---|
| 658 | // | 
|---|
| 659 | DisplayReferenceLines(obj5,2); | 
|---|
| 660 |  | 
|---|
| 661 | c2.cd(4); | 
|---|
| 662 | gPad->SetBorderMode(0); | 
|---|
| 663 | obj5->SetPrettyPalette(); | 
|---|
| 664 | obj5->Draw(); | 
|---|
| 665 |  | 
|---|
| 666 | c2.cd(7); | 
|---|
| 667 | gPad->SetBorderMode(0); | 
|---|
| 668 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 669 | DisplayDoubleProject(&disp6, "noisy", "dead"); | 
|---|
| 670 |  | 
|---|
| 671 | // | 
|---|
| 672 | // QUANTUM EFFICIENCY | 
|---|
| 673 | // | 
|---|
| 674 | c2.cd(2); | 
|---|
| 675 | gPad->SetBorderMode(0); | 
|---|
| 676 | gPad->SetTicks(); | 
|---|
| 677 | MHCamera *obj6=(MHCamera*)disp8.DrawCopy("hist"); | 
|---|
| 678 | // | 
|---|
| 679 | // for the datacheck, fix the ranges!! | 
|---|
| 680 | // | 
|---|
| 681 | obj6->SetMinimum(fQEMin); | 
|---|
| 682 | obj6->SetMaximum(fQEMax); | 
|---|
| 683 | // | 
|---|
| 684 | // Set the datacheck sizes: | 
|---|
| 685 | // | 
|---|
| 686 | FixDataCheckHist((TH1D*)obj6); | 
|---|
| 687 | obj6->SetStats(kFALSE); | 
|---|
| 688 | // | 
|---|
| 689 | // set reference lines | 
|---|
| 690 | // | 
|---|
| 691 | DisplayReferenceLines(obj6,0); | 
|---|
| 692 |  | 
|---|
| 693 | c2.cd(5); | 
|---|
| 694 | gPad->SetBorderMode(0); | 
|---|
| 695 | obj6->SetPrettyPalette(); | 
|---|
| 696 | obj6->Draw(); | 
|---|
| 697 |  | 
|---|
| 698 | c2.cd(8); | 
|---|
| 699 | gPad->SetBorderMode(0); | 
|---|
| 700 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 701 | DisplayDoubleProject(&disp8, "noisy", "dead"); | 
|---|
| 702 |  | 
|---|
| 703 | // | 
|---|
| 704 | // CONVERSION FADC TO PHOTONS | 
|---|
| 705 | // | 
|---|
| 706 |  | 
|---|
| 707 | c2.cd(3); | 
|---|
| 708 | gPad->SetBorderMode(0); | 
|---|
| 709 | gPad->SetTicks(); | 
|---|
| 710 | MHCamera *obj7=(MHCamera*)disp37.DrawCopy("hist"); | 
|---|
| 711 | // | 
|---|
| 712 | // for the datacheck, fix the ranges!! | 
|---|
| 713 | // | 
|---|
| 714 | obj7->SetMinimum(fConvFADC2PheMin); | 
|---|
| 715 | obj7->SetMaximum(fConvFADC2PheMax); | 
|---|
| 716 | // | 
|---|
| 717 | // Set the datacheck sizes: | 
|---|
| 718 | // | 
|---|
| 719 | FixDataCheckHist((TH1D*)obj7); | 
|---|
| 720 | obj7->SetStats(kFALSE); | 
|---|
| 721 | // | 
|---|
| 722 | // set reference lines | 
|---|
| 723 | // | 
|---|
| 724 | DisplayReferenceLines(obj7,1); | 
|---|
| 725 |  | 
|---|
| 726 | c2.cd(6); | 
|---|
| 727 | gPad->SetBorderMode(0); | 
|---|
| 728 | obj7->SetPrettyPalette(); | 
|---|
| 729 | obj7->Draw(); | 
|---|
| 730 | c2.cd(9); | 
|---|
| 731 | gPad->SetBorderMode(0); | 
|---|
| 732 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 733 | DisplayDoubleProject(&disp37, "noisy", "dead"); | 
|---|
| 734 |  | 
|---|
| 735 | // | 
|---|
| 736 | // ARRIVAL TIMES | 
|---|
| 737 | // | 
|---|
| 738 | TCanvas &c3 = fDisplay->AddTab("AbsTimes"); | 
|---|
| 739 | c3.Divide(2,3); | 
|---|
| 740 |  | 
|---|
| 741 | c3.cd(1); | 
|---|
| 742 | gPad->SetBorderMode(0); | 
|---|
| 743 | gPad->SetTicks(); | 
|---|
| 744 | MHCamera *obj10=(MHCamera*)disp28.DrawCopy("hist"); | 
|---|
| 745 | // | 
|---|
| 746 | // for the datacheck, fix the ranges!! | 
|---|
| 747 | // | 
|---|
| 748 | obj10->SetMinimum(fArrivalTimeMin); | 
|---|
| 749 | obj10->SetMaximum(fArrivalTimeMax); | 
|---|
| 750 | // | 
|---|
| 751 | // Set the datacheck sizes: | 
|---|
| 752 | // | 
|---|
| 753 | FixDataCheckHist((TH1D*)obj10); | 
|---|
| 754 | obj10->SetStats(kFALSE); | 
|---|
| 755 | // | 
|---|
| 756 | // set reference lines | 
|---|
| 757 | // | 
|---|
| 758 | DisplayReferenceLines(obj10,3); | 
|---|
| 759 |  | 
|---|
| 760 | c3.cd(3); | 
|---|
| 761 | gPad->SetBorderMode(0); | 
|---|
| 762 | obj10->SetPrettyPalette(); | 
|---|
| 763 | obj10->Draw(); | 
|---|
| 764 |  | 
|---|
| 765 | c3.cd(5); | 
|---|
| 766 | gPad->SetBorderMode(0); | 
|---|
| 767 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 768 | DisplayDoubleProject(&disp28, "early", "late"); | 
|---|
| 769 |  | 
|---|
| 770 | // | 
|---|
| 771 | // ARRIVAL TIMES JITTER | 
|---|
| 772 | // | 
|---|
| 773 | c3.cd(2); | 
|---|
| 774 | gPad->SetBorderMode(0); | 
|---|
| 775 | gPad->SetTicks(); | 
|---|
| 776 | MHCamera *obj11=(MHCamera*)disp29.DrawCopy("hist"); | 
|---|
| 777 | // | 
|---|
| 778 | // for the datacheck, fix the ranges!! | 
|---|
| 779 | // | 
|---|
| 780 | //      obj11->SetMinimum(fArrivalTimeMin); | 
|---|
| 781 | //      obj11->SetMaximum(fArrivalTimeMax); | 
|---|
| 782 | // | 
|---|
| 783 | // Set the datacheck sizes: | 
|---|
| 784 | // | 
|---|
| 785 | FixDataCheckHist((TH1D*)obj11); | 
|---|
| 786 | obj11->SetStats(kFALSE); | 
|---|
| 787 | // | 
|---|
| 788 | // set reference lines | 
|---|
| 789 | // | 
|---|
| 790 | DisplayReferenceLines(obj11,4); | 
|---|
| 791 |  | 
|---|
| 792 | c3.cd(4); | 
|---|
| 793 | gPad->SetBorderMode(0); | 
|---|
| 794 | obj11->SetPrettyPalette(); | 
|---|
| 795 | obj11->Draw(); | 
|---|
| 796 |  | 
|---|
| 797 | c3.cd(6); | 
|---|
| 798 | gPad->SetBorderMode(0); | 
|---|
| 799 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 800 | DisplayDoubleProject(&disp29, "", "jittering"); | 
|---|
| 801 |  | 
|---|
| 802 | // | 
|---|
| 803 | // UNSUITABLE PIXELS | 
|---|
| 804 | // | 
|---|
| 805 | TCanvas &c4 = fDisplay->AddTab("Defect"); | 
|---|
| 806 | c4.Divide(2,2, 0.005, 0.005); | 
|---|
| 807 |  | 
|---|
| 808 | c4.cd(1); | 
|---|
| 809 | gPad->SetBorderMode(0); | 
|---|
| 810 | gPad->SetTicks(); | 
|---|
| 811 | MHCamera *obj8=(MHCamera*)disp24.DrawCopy("hist"); | 
|---|
| 812 | // | 
|---|
| 813 | // for the datacheck, fix the ranges!! | 
|---|
| 814 | // | 
|---|
| 815 | const Double_t max = 11.; | 
|---|
| 816 | obj8->SetMinimum(0.); | 
|---|
| 817 | obj8->SetMaximum(max); | 
|---|
| 818 | // | 
|---|
| 819 | // Set the datacheck sizes: | 
|---|
| 820 | // | 
|---|
| 821 | FixDataCheckHist((TH1D*)obj8); | 
|---|
| 822 | obj8->SetStats(kFALSE); | 
|---|
| 823 |  | 
|---|
| 824 | gStyle->SetPalette(1); | 
|---|
| 825 | const Int_t numcol = gStyle->GetNumberOfColors()-3; | 
|---|
| 826 |  | 
|---|
| 827 | TPaveText *pave = new TPaveText(0.05,0.02,0.975,0.99); | 
|---|
| 828 | pave->SetBit(kCanDelete); | 
|---|
| 829 | pave->ConvertNDCtoPad(); | 
|---|
| 830 | pave->SetTextSize(0.045); | 
|---|
| 831 | pave->AddText("  "); | 
|---|
| 832 | TText *t1 = pave->AddText(Form("Signal smaller 4.5 Pedestal RMS:               %3i pixels", | 
|---|
| 833 | CountBadPixels(&disp24,1))); | 
|---|
| 834 | t1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol))); | 
|---|
| 835 | t1->SetTextAlign(12); | 
|---|
| 836 | TText *t4 = pave->AddText(Form("Low Gain Saturation:                                   %3i pixels", | 
|---|
| 837 | CountBadPixels(&disp24,2))); | 
|---|
| 838 | t4->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol))); | 
|---|
| 839 | t4->SetTextAlign(12); | 
|---|
| 840 | TText *t5 = pave->AddText(Form("Mean Arr. Time In First Extraction Bin:      %3i pixels", | 
|---|
| 841 | CountBadPixels(&disp24,3))); | 
|---|
| 842 | t5->SetTextColor(gStyle->GetColorPalette(Int_t(3./max*numcol))); | 
|---|
| 843 | t5->SetTextAlign(12); | 
|---|
| 844 | TText *t6 = pave->AddText(Form("Mean Arr. Time In Last 2 Extraction Bins:  %3i pixels", | 
|---|
| 845 | CountBadPixels(&disp24,4))); | 
|---|
| 846 | t6->SetTextColor(gStyle->GetColorPalette(Int_t(4./max*numcol))); | 
|---|
| 847 | t6->SetTextAlign(12); | 
|---|
| 848 | TText *t10= pave->AddText(Form("High-Gain Histogram Overflow:                  %3i pixels", | 
|---|
| 849 | CountBadPixels(&disp24,5 ))); | 
|---|
| 850 | t10->SetTextColor(gStyle->GetColorPalette(Int_t(5./max*numcol))); | 
|---|
| 851 | t10->SetTextAlign(12); | 
|---|
| 852 | TText *t11= pave->AddText(Form("Low-Gain Histogram Overflow:                   %3i pixels", | 
|---|
| 853 | CountBadPixels(&disp24,6 ))); | 
|---|
| 854 | t11->SetTextColor(gStyle->GetColorPalette(Int_t(6./max*numcol))); | 
|---|
| 855 | t11->SetTextAlign(12); | 
|---|
| 856 | TText *t12= pave->AddText(Form("Presumably dead from Ped. Rms:              %3i pixels", | 
|---|
| 857 | CountBadPixels(&disp24,7 ))); | 
|---|
| 858 | t12->SetTextColor(gStyle->GetColorPalette(Int_t(7./max*numcol))); | 
|---|
| 859 | t12->SetTextAlign(12); | 
|---|
| 860 | TText *t13= pave->AddText(Form("Fluctuating Pulse Arrival Times:                 %3i pixels", | 
|---|
| 861 | CountBadPixels(&disp24,8 ))); | 
|---|
| 862 | t13->SetTextColor(gStyle->GetColorPalette(Int_t(8./max*numcol))); | 
|---|
| 863 | t13->SetTextAlign(12); | 
|---|
| 864 | TText *t17 = pave->AddText(Form("Deviating Number of Photo-electrons:       %3i pixels", | 
|---|
| 865 | CountBadPixels(&disp24,9 ))); | 
|---|
| 866 | t17->SetTextColor(gStyle->GetColorPalette(Int_t(9./max*numcol))); | 
|---|
| 867 | t17->SetTextAlign(12); | 
|---|
| 868 | TText *t15= pave->AddText(Form("Too many Low-Gain Blackout Events:       %3i pixels", | 
|---|
| 869 | CountBadPixels(&disp24,10 ))); | 
|---|
| 870 | t15->SetTextColor(gStyle->GetColorPalette(Int_t(10./max*numcol))); | 
|---|
| 871 | t15->SetTextAlign(12); | 
|---|
| 872 | TText *t14= pave->AddText(Form("Previously Excluded:                                   %3i pixels", | 
|---|
| 873 | CountBadPixels(&disp24,11))); | 
|---|
| 874 | t14->SetTextColor(gStyle->GetColorPalette(Int_t(11./max*numcol))); | 
|---|
| 875 | t14->SetTextAlign(12); | 
|---|
| 876 | pave->Draw(); | 
|---|
| 877 |  | 
|---|
| 878 | c4.cd(3); | 
|---|
| 879 | gPad->SetBorderMode(0); | 
|---|
| 880 | obj8->Draw(); | 
|---|
| 881 | obj8->SetPrettyPalette(); | 
|---|
| 882 |  | 
|---|
| 883 | // | 
|---|
| 884 | // UNRELIABLE PIXELS | 
|---|
| 885 | // | 
|---|
| 886 |  | 
|---|
| 887 | c4.cd(2); | 
|---|
| 888 | gPad->SetBorderMode(0); | 
|---|
| 889 | gPad->SetTicks(); | 
|---|
| 890 | MHCamera *obj9=(MHCamera*)disp25.DrawCopy("hist"); | 
|---|
| 891 | // | 
|---|
| 892 | // for the datacheck, fix the ranges!! | 
|---|
| 893 | // | 
|---|
| 894 | const Double_t max2 = 9.; | 
|---|
| 895 | obj9->SetMinimum(0.); | 
|---|
| 896 | obj9->SetMaximum(max2); | 
|---|
| 897 | // | 
|---|
| 898 | // Set the datacheck sizes: | 
|---|
| 899 | // | 
|---|
| 900 | FixDataCheckHist((TH1D*)obj9); | 
|---|
| 901 | obj9->SetStats(kFALSE); | 
|---|
| 902 |  | 
|---|
| 903 | gStyle->SetPalette(1); | 
|---|
| 904 |  | 
|---|
| 905 | TPaveText *pave2 = new TPaveText(0.025,0.02,0.95,0.99); | 
|---|
| 906 | pave2->SetBit(kCanDelete); | 
|---|
| 907 | pave2->ConvertNDCtoPad(); | 
|---|
| 908 | pave2->SetTextSize(0.05); | 
|---|
| 909 | pave2->AddText("  "); | 
|---|
| 910 | TText *t3 = pave2->AddText(Form("Signal Sigma smaller Pedestal RMS:      %3i pixels", | 
|---|
| 911 | CountBadPixels(&disp25,1))); | 
|---|
| 912 | t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol))); | 
|---|
| 913 | t3->SetTextAlign(12); | 
|---|
| 914 | TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted:    %3i pixels", | 
|---|
| 915 | CountBadPixels(&disp25,3))); | 
|---|
| 916 | tt1->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol))); | 
|---|
| 917 | tt1->SetTextAlign(12); | 
|---|
| 918 | TText *tt2 = pave2->AddText(Form("Low  Gain Signals could not be fitted:    %3i pixels", | 
|---|
| 919 | CountBadPixels(&disp25,4))); | 
|---|
| 920 | tt2->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol))); | 
|---|
| 921 | tt2->SetTextAlign(12); | 
|---|
| 922 | TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted:   %3i pixels", | 
|---|
| 923 | CountBadPixels(&disp25,5))); | 
|---|
| 924 | tt3->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol))); | 
|---|
| 925 | tt3->SetTextAlign(12); | 
|---|
| 926 | TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation:                 %3i pixels", | 
|---|
| 927 | CountBadPixels(&disp25,6))); | 
|---|
| 928 | tt4->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol))); | 
|---|
| 929 | tt4->SetTextAlign(12); | 
|---|
| 930 | TText *tt5 = pave2->AddText(Form("Low  Gain Signals Oscillation:                %3i pixels", | 
|---|
| 931 | CountBadPixels(&disp25,7))); | 
|---|
| 932 | tt5->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol))); | 
|---|
| 933 | tt5->SetTextAlign(12); | 
|---|
| 934 | TText *tt6 = pave2->AddText(Form("Relative Arr. Times Oscillation:               %3i pixels", | 
|---|
| 935 | CountBadPixels(&disp25,8))); | 
|---|
| 936 | tt6->SetTextColor(gStyle->GetColorPalette(Int_t(8./max2*numcol))); | 
|---|
| 937 | tt6->SetTextAlign(12); | 
|---|
| 938 | TText *tt8 = pave2->AddText(Form("Deviating global F-Factor:                       %3i pixels", | 
|---|
| 939 | CountBadPixels(&disp25,9))); | 
|---|
| 940 | tt8->SetTextColor(gStyle->GetColorPalette(Int_t(9./max2*numcol))); | 
|---|
| 941 | tt8->SetTextAlign(12); | 
|---|
| 942 | pave2->Draw(); | 
|---|
| 943 |  | 
|---|
| 944 | c4.cd(4); | 
|---|
| 945 | gPad->SetBorderMode(0); | 
|---|
| 946 | obj9->SetPrettyPalette(); | 
|---|
| 947 | obj9->Draw(); | 
|---|
| 948 |  | 
|---|
| 949 | if (IsRelTimes()) | 
|---|
| 950 | { | 
|---|
| 951 | TCanvas &c5 = fDisplay->AddTab("RelTimes"); | 
|---|
| 952 | c5.Divide(2,3); | 
|---|
| 953 |  | 
|---|
| 954 | // | 
|---|
| 955 | // MEAN REL. ARR. TIMES | 
|---|
| 956 | // | 
|---|
| 957 | c5.cd(1); | 
|---|
| 958 | gPad->SetBorderMode(0); | 
|---|
| 959 | gPad->SetTicks(); | 
|---|
| 960 | MHCamera *obj10=(MHCamera*)disp30.DrawCopy("hist"); | 
|---|
| 961 | // | 
|---|
| 962 | // for the datacheck, fix the ranges!! | 
|---|
| 963 | // | 
|---|
| 964 | obj10->SetMinimum(fTimeOffsetMin); | 
|---|
| 965 | obj10->SetMaximum(fTimeOffsetMax); | 
|---|
| 966 | // | 
|---|
| 967 | // Set the datacheck sizes: | 
|---|
| 968 | // | 
|---|
| 969 | FixDataCheckHist((TH1D*)obj10); | 
|---|
| 970 | obj10->SetStats(kFALSE); | 
|---|
| 971 | // | 
|---|
| 972 | // set reference lines | 
|---|
| 973 | // | 
|---|
| 974 | DisplayReferenceLines(obj10,5); | 
|---|
| 975 |  | 
|---|
| 976 | c5.cd(3); | 
|---|
| 977 | gPad->SetBorderMode(0); | 
|---|
| 978 | obj10->SetPrettyPalette(); | 
|---|
| 979 | obj10->Draw(); | 
|---|
| 980 |  | 
|---|
| 981 | c5.cd(5); | 
|---|
| 982 | gPad->SetBorderMode(0); | 
|---|
| 983 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 984 | DisplayDoubleProject(&disp30, "early", "late"); | 
|---|
| 985 |  | 
|---|
| 986 | // | 
|---|
| 987 | // JITTER Rel. Arr. Times | 
|---|
| 988 | // | 
|---|
| 989 | c5.cd(2); | 
|---|
| 990 | gPad->SetBorderMode(0); | 
|---|
| 991 | gPad->SetTicks(); | 
|---|
| 992 | MHCamera *obj11=(MHCamera*)disp31.DrawCopy("hist"); | 
|---|
| 993 | // | 
|---|
| 994 | // for the datacheck, fix the ranges!! | 
|---|
| 995 | // | 
|---|
| 996 | obj11->SetMinimum(fTimeResolutionMin); | 
|---|
| 997 | obj11->SetMaximum(fTimeResolutionMax); | 
|---|
| 998 | // | 
|---|
| 999 | // Set the datacheck sizes: | 
|---|
| 1000 | // | 
|---|
| 1001 | FixDataCheckHist((TH1D*)obj11); | 
|---|
| 1002 | obj11->SetStats(kFALSE); | 
|---|
| 1003 | // | 
|---|
| 1004 | // set reference lines | 
|---|
| 1005 | // | 
|---|
| 1006 | DisplayReferenceLines(obj11,6); | 
|---|
| 1007 |  | 
|---|
| 1008 | c5.cd(4); | 
|---|
| 1009 | gPad->SetBorderMode(0); | 
|---|
| 1010 | obj11->SetPrettyPalette(); | 
|---|
| 1011 | obj11->Draw(); | 
|---|
| 1012 |  | 
|---|
| 1013 | c5.cd(6); | 
|---|
| 1014 | gPad->SetBorderMode(0); | 
|---|
| 1015 | if (geomcam.InheritsFrom("MGeomCamMagic")) | 
|---|
| 1016 | DisplayDoubleProject(&disp31, "too stable", "jittering"); | 
|---|
| 1017 |  | 
|---|
| 1018 | } | 
|---|
| 1019 | return; | 
|---|
| 1020 | } | 
|---|
| 1021 |  | 
|---|
| 1022 | if (fDisplayType == kNormalDisplay) | 
|---|
| 1023 | { | 
|---|
| 1024 |  | 
|---|
| 1025 | // Charges | 
|---|
| 1026 | TCanvas &c11 = fDisplay->AddTab("FitCharge"); | 
|---|
| 1027 | c11.Divide(2, 4); | 
|---|
| 1028 |  | 
|---|
| 1029 | disp1.CamDraw(c11, 1, 2, 5, 1); | 
|---|
| 1030 | disp2.CamDraw(c11, 2, 2, 5, 1); | 
|---|
| 1031 |  | 
|---|
| 1032 | // Reduced Sigmas | 
|---|
| 1033 | TCanvas &c12 = fDisplay->AddTab("RedSigma"); | 
|---|
| 1034 | c12.Divide(2,4); | 
|---|
| 1035 |  | 
|---|
| 1036 | disp3.CamDraw(c12, 1, 2, 5, 1); | 
|---|
| 1037 | disp4.CamDraw(c12, 2, 2, 5, 1); | 
|---|
| 1038 |  | 
|---|
| 1039 | //  F-Factor | 
|---|
| 1040 | TCanvas &c13 = fDisplay->AddTab("Phe's"); | 
|---|
| 1041 | c13.Divide(3,4); | 
|---|
| 1042 |  | 
|---|
| 1043 | disp5.CamDraw(c13, 1, 3, 5, 1); | 
|---|
| 1044 | disp6.CamDraw(c13, 2, 3, 5, 1); | 
|---|
| 1045 | disp7.CamDraw(c13, 3, 3, 5, 1); | 
|---|
| 1046 |  | 
|---|
| 1047 | // QE's | 
|---|
| 1048 | TCanvas &c14 = fDisplay->AddTab("QE's"); | 
|---|
| 1049 | c14.Divide(4,4); | 
|---|
| 1050 |  | 
|---|
| 1051 | disp8.CamDraw(c14, 1, 4, 5, 1); | 
|---|
| 1052 | disp9.CamDraw(c14, 2, 4, 5, 1); | 
|---|
| 1053 | disp10.CamDraw(c14, 3, 4, 5, 1); | 
|---|
| 1054 | disp11.CamDraw(c14, 4, 4, 5, 1); | 
|---|
| 1055 |  | 
|---|
| 1056 | // Defects | 
|---|
| 1057 | TCanvas &c15 = fDisplay->AddTab("Defect"); | 
|---|
| 1058 | //      c15.Divide(5,2); | 
|---|
| 1059 | c15.Divide(4,2); | 
|---|
| 1060 |  | 
|---|
| 1061 | /* | 
|---|
| 1062 | disp23.CamDraw(c15, 1, 5, 0); | 
|---|
| 1063 | disp24.CamDraw(c15, 2, 5, 0); | 
|---|
| 1064 | disp25.CamDraw(c15, 3, 5, 0); | 
|---|
| 1065 | disp26.CamDraw(c15, 4, 5, 0); | 
|---|
| 1066 | disp27.CamDraw(c15, 5, 5, 0); | 
|---|
| 1067 | */ | 
|---|
| 1068 | disp24.CamDraw(c15, 1, 4, 0); | 
|---|
| 1069 | disp25.CamDraw(c15, 2, 4, 0); | 
|---|
| 1070 | disp26.CamDraw(c15, 3, 4, 0); | 
|---|
| 1071 | disp27.CamDraw(c15, 4, 4, 0); | 
|---|
| 1072 |  | 
|---|
| 1073 | // Abs. Times | 
|---|
| 1074 | TCanvas &c16 = fDisplay->AddTab("AbsTimes"); | 
|---|
| 1075 | c16.Divide(2,3); | 
|---|
| 1076 |  | 
|---|
| 1077 | disp28.CamDraw(c16, 1, 2, 5); | 
|---|
| 1078 | disp29.CamDraw(c16, 2, 2, 5); | 
|---|
| 1079 |  | 
|---|
| 1080 | if (IsRelTimes()) | 
|---|
| 1081 | { | 
|---|
| 1082 | // Rel. Times | 
|---|
| 1083 | TCanvas &c17 = fDisplay->AddTab("RelTimes"); | 
|---|
| 1084 | c17.Divide(2,4); | 
|---|
| 1085 |  | 
|---|
| 1086 | disp30.CamDraw(c17, 1, 2, 5, 1); | 
|---|
| 1087 | disp31.CamDraw(c17, 2, 2, 5, 1); | 
|---|
| 1088 | } | 
|---|
| 1089 |  | 
|---|
| 1090 | return; | 
|---|
| 1091 | } | 
|---|
| 1092 |  | 
|---|
| 1093 | if (fDisplayType == kFullDisplay) | 
|---|
| 1094 | { | 
|---|
| 1095 | MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationChargeCam"); | 
|---|
| 1096 |  | 
|---|
| 1097 | for (Int_t sector=1;sector<cam->GetAverageSectors();sector++) | 
|---|
| 1098 | { | 
|---|
| 1099 | cam->GetAverageHiGainSector(sector).DrawClone("all"); | 
|---|
| 1100 | cam->GetAverageLoGainSector(sector).DrawClone("all"); | 
|---|
| 1101 | } | 
|---|
| 1102 |  | 
|---|
| 1103 | // Charges | 
|---|
| 1104 | TCanvas &c21 = fDisplay->AddTab("FitCharge"); | 
|---|
| 1105 | c21.Divide(2, 4); | 
|---|
| 1106 |  | 
|---|
| 1107 | disp1.CamDraw(c21, 1, 2, 2, 1); | 
|---|
| 1108 | disp2.CamDraw(c21, 2, 2, 2, 1); | 
|---|
| 1109 |  | 
|---|
| 1110 | // Reduced Sigmas | 
|---|
| 1111 | TCanvas &c23 = fDisplay->AddTab("RedSigma"); | 
|---|
| 1112 | c23.Divide(2,4); | 
|---|
| 1113 |  | 
|---|
| 1114 | disp3.CamDraw(c23, 1, 2, 2, 1); | 
|---|
| 1115 | disp4.CamDraw(c23, 2, 2, 2, 1); | 
|---|
| 1116 |  | 
|---|
| 1117 | //  F-Factor | 
|---|
| 1118 | TCanvas &c24 = fDisplay->AddTab("Phe's"); | 
|---|
| 1119 | c24.Divide(3,5); | 
|---|
| 1120 |  | 
|---|
| 1121 | disp5.CamDraw(c24, 1, 3, 2, 1, 1); | 
|---|
| 1122 | disp6.CamDraw(c24, 2, 3, 2, 1, 1); | 
|---|
| 1123 | disp7.CamDraw(c24, 3, 3, 2, 1, 1); | 
|---|
| 1124 |  | 
|---|
| 1125 | // QE's | 
|---|
| 1126 | TCanvas &c25 = fDisplay->AddTab("QE's"); | 
|---|
| 1127 | c25.Divide(4,5); | 
|---|
| 1128 |  | 
|---|
| 1129 | disp8.CamDraw(c25, 1, 4, 2, 1, 1); | 
|---|
| 1130 | disp9.CamDraw(c25, 2, 4, 2, 1, 1); | 
|---|
| 1131 | disp10.CamDraw(c25, 3, 4, 2, 1, 1); | 
|---|
| 1132 | disp11.CamDraw(c25, 4, 4, 2, 1, 1); | 
|---|
| 1133 |  | 
|---|
| 1134 | // Validity | 
|---|
| 1135 | TCanvas &c26 = fDisplay->AddTab("Valid"); | 
|---|
| 1136 | c26.Divide(4,2); | 
|---|
| 1137 |  | 
|---|
| 1138 | disp12.CamDraw(c26, 1, 4, 0); | 
|---|
| 1139 | disp13.CamDraw(c26, 2, 4, 0); | 
|---|
| 1140 | disp14.CamDraw(c26, 3, 4, 0); | 
|---|
| 1141 | disp15.CamDraw(c26, 4, 4, 0); | 
|---|
| 1142 |  | 
|---|
| 1143 | // Other info | 
|---|
| 1144 | TCanvas &c27 = fDisplay->AddTab("HiLoGain"); | 
|---|
| 1145 | c27.Divide(3,3); | 
|---|
| 1146 |  | 
|---|
| 1147 | disp16.CamDraw(c27, 1, 3, 0); | 
|---|
| 1148 | disp17.CamDraw(c27, 2, 3, 1); | 
|---|
| 1149 | disp18.CamDraw(c27, 3, 3, 1); | 
|---|
| 1150 |  | 
|---|
| 1151 | // Pickup | 
|---|
| 1152 | TCanvas &c28 = fDisplay->AddTab("Pickup"); | 
|---|
| 1153 | c28.Divide(4,2); | 
|---|
| 1154 |  | 
|---|
| 1155 | disp19.CamDraw(c28, 1, 4, 0); | 
|---|
| 1156 | disp20.CamDraw(c28, 2, 4, 0); | 
|---|
| 1157 | disp21.CamDraw(c28, 3, 4, 0); | 
|---|
| 1158 | disp22.CamDraw(c28, 4, 4, 0); | 
|---|
| 1159 |  | 
|---|
| 1160 | // Defects | 
|---|
| 1161 | TCanvas &c29 = fDisplay->AddTab("Defect"); | 
|---|
| 1162 | //      c29.Divide(5,2); | 
|---|
| 1163 | c29.Divide(4,2); | 
|---|
| 1164 |  | 
|---|
| 1165 | disp24.CamDraw(c29, 1, 4, 0); | 
|---|
| 1166 | disp25.CamDraw(c29, 2, 4, 0); | 
|---|
| 1167 | disp26.CamDraw(c29, 3, 4, 0); | 
|---|
| 1168 | disp27.CamDraw(c29, 4, 4, 0); | 
|---|
| 1169 |  | 
|---|
| 1170 | // Abs. Times | 
|---|
| 1171 | TCanvas &c30 = fDisplay->AddTab("AbsTimes"); | 
|---|
| 1172 | c30.Divide(2,3); | 
|---|
| 1173 |  | 
|---|
| 1174 | disp28.CamDraw(c30, 1, 2, 2); | 
|---|
| 1175 | disp29.CamDraw(c30, 2, 2, 1); | 
|---|
| 1176 |  | 
|---|
| 1177 | if (IsRelTimes()) | 
|---|
| 1178 | { | 
|---|
| 1179 | // Rel. Times | 
|---|
| 1180 | TCanvas &c31 = fDisplay->AddTab("RelTimes"); | 
|---|
| 1181 | c31.Divide(3,5); | 
|---|
| 1182 |  | 
|---|
| 1183 | disp30.CamDraw(c31, 1, 3, 2, 1, 1); | 
|---|
| 1184 | disp31.CamDraw(c31, 2, 3, 2, 1, 1); | 
|---|
| 1185 | disp32.CamDraw(c31, 3, 3, 4, 1, 1); | 
|---|
| 1186 |  | 
|---|
| 1187 | // Time Defects | 
|---|
| 1188 | TCanvas &c32 = fDisplay->AddTab("DefTime"); | 
|---|
| 1189 | c32.Divide(2,2); | 
|---|
| 1190 |  | 
|---|
| 1191 | disp33.CamDraw(c32, 1, 2, 0); | 
|---|
| 1192 | disp34.CamDraw(c32, 2, 2, 0); | 
|---|
| 1193 |  | 
|---|
| 1194 | MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationRelTimeCam"); | 
|---|
| 1195 |  | 
|---|
| 1196 | for (Int_t sector=1;sector<cam->GetAverageSectors();sector++) | 
|---|
| 1197 | { | 
|---|
| 1198 | cam->GetAverageHiGainSector(sector).DrawClone("fourierevents"); | 
|---|
| 1199 | cam->GetAverageLoGainSector(sector).DrawClone("fourierevents"); | 
|---|
| 1200 | } | 
|---|
| 1201 |  | 
|---|
| 1202 | } | 
|---|
| 1203 |  | 
|---|
| 1204 | return; | 
|---|
| 1205 | } | 
|---|
| 1206 | } | 
|---|
| 1207 |  | 
|---|
| 1208 |  | 
|---|
| 1209 | void  MJCalibration::DisplayReferenceLines(MHCamera *cam, const Int_t what) const | 
|---|
| 1210 | { | 
|---|
| 1211 |  | 
|---|
| 1212 | const MGeomCam *geom = cam->GetGeometry(); | 
|---|
| 1213 |  | 
|---|
| 1214 | Double_t x = geom->InheritsFrom("MGeomCamMagic") ? 397 : cam->GetNbinsX() ; | 
|---|
| 1215 |  | 
|---|
| 1216 | TLine line; | 
|---|
| 1217 | line.SetLineStyle(kDashed); | 
|---|
| 1218 | line.SetLineWidth(3); | 
|---|
| 1219 | line.SetLineColor(kBlue); | 
|---|
| 1220 |  | 
|---|
| 1221 | TLine *l1 = NULL; | 
|---|
| 1222 |  | 
|---|
| 1223 | switch (what) | 
|---|
| 1224 | { | 
|---|
| 1225 | case 0: | 
|---|
| 1226 | l1 = line.DrawLine(0, fRefQEInner, x, fRefQEInner); | 
|---|
| 1227 | break; | 
|---|
| 1228 | case  1: | 
|---|
| 1229 | l1 = line.DrawLine(0, fRefConvFADC2PheInner, x, fRefConvFADC2PheInner); | 
|---|
| 1230 | break; | 
|---|
| 1231 | case  2: | 
|---|
| 1232 | l1 = line.DrawLine(0, fRefFADC2PheInner, x, fRefFADC2PheInner ); | 
|---|
| 1233 | break; | 
|---|
| 1234 | case  3: | 
|---|
| 1235 | l1 = line.DrawLine(0, fRefArrivalTimeInner, x, fRefArrivalTimeInner ); | 
|---|
| 1236 | break; | 
|---|
| 1237 | case  4: | 
|---|
| 1238 | l1 = line.DrawLine(0, fRefArrivalTimeRmsInner, x, fRefArrivalTimeRmsInner ); | 
|---|
| 1239 | break; | 
|---|
| 1240 | case 5: | 
|---|
| 1241 | l1 = line.DrawLine(0, fRefTimeOffsetInner, x, fRefTimeOffsetInner ); | 
|---|
| 1242 | break; | 
|---|
| 1243 | case 6: | 
|---|
| 1244 | l1 = line.DrawLine(0, fRefTimeResolutionInner, x, fRefTimeResolutionInner ); | 
|---|
| 1245 | break; | 
|---|
| 1246 | default: | 
|---|
| 1247 | break; | 
|---|
| 1248 | } | 
|---|
| 1249 |  | 
|---|
| 1250 | if (geom->InheritsFrom("MGeomCamMagic")) | 
|---|
| 1251 | { | 
|---|
| 1252 | const Double_t x2 = cam->GetNbinsX(); | 
|---|
| 1253 |  | 
|---|
| 1254 | switch (what) | 
|---|
| 1255 | { | 
|---|
| 1256 | case 0: | 
|---|
| 1257 | line.DrawLine(x2, fRefQEOuter, 398, fRefQEOuter); | 
|---|
| 1258 | break; | 
|---|
| 1259 | case 1: | 
|---|
| 1260 | line.DrawLine(x2, fRefConvFADC2PheOuter, 398, fRefConvFADC2PheOuter ); | 
|---|
| 1261 | break; | 
|---|
| 1262 | case 2: | 
|---|
| 1263 | line.DrawLine(x2, fRefFADC2PheOuter, 398, fRefFADC2PheOuter); | 
|---|
| 1264 | break; | 
|---|
| 1265 | case 3: | 
|---|
| 1266 | line.DrawLine(x2, fRefArrivalTimeOuter, 398, fRefArrivalTimeOuter); | 
|---|
| 1267 | break; | 
|---|
| 1268 | case 4: | 
|---|
| 1269 | line.DrawLine(x2, fRefArrivalTimeRmsOuter, 398, fRefArrivalTimeRmsOuter); | 
|---|
| 1270 | break; | 
|---|
| 1271 | case 5: | 
|---|
| 1272 | line.DrawLine(x2, fRefTimeOffsetOuter, 398, fRefTimeOffsetOuter); | 
|---|
| 1273 | break; | 
|---|
| 1274 | case 6: | 
|---|
| 1275 | line.DrawLine(x2, fRefTimeResolutionOuter, 398, fRefTimeResolutionOuter); | 
|---|
| 1276 | break; | 
|---|
| 1277 | default: | 
|---|
| 1278 | break; | 
|---|
| 1279 | } | 
|---|
| 1280 | } | 
|---|
| 1281 |  | 
|---|
| 1282 | TLegend *leg = new TLegend(0.6,0.85,0.9 ,0.95); | 
|---|
| 1283 | leg->SetBit(kCanDelete); | 
|---|
| 1284 | leg->AddEntry(l1, "Reference","l"); | 
|---|
| 1285 | leg->Draw(); | 
|---|
| 1286 | } | 
|---|
| 1287 |  | 
|---|
| 1288 | void  MJCalibration::DisplayOutliers(TH1D *hist, const char* whatsmall, const char* whatbig) const | 
|---|
| 1289 | { | 
|---|
| 1290 |  | 
|---|
| 1291 | const Int_t kNotDraw = 1<<9; | 
|---|
| 1292 | TF1 *f = hist->GetFunction("gaus"); | 
|---|
| 1293 | f->ResetBit(kNotDraw); | 
|---|
| 1294 |  | 
|---|
| 1295 | const Float_t mean  = f->GetParameter(1); | 
|---|
| 1296 | const Float_t lolim = mean - 4.0*f->GetParameter(2); | 
|---|
| 1297 | const Float_t uplim = mean + 4.0*f->GetParameter(2); | 
|---|
| 1298 | const Stat_t  dead  = hist->Integral(0,hist->FindBin(lolim)-1); | 
|---|
| 1299 | const Stat_t  noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1); | 
|---|
| 1300 |  | 
|---|
| 1301 | const Double_t max = hist->GetBinContent(hist->GetMaximumBin()); | 
|---|
| 1302 |  | 
|---|
| 1303 | const Double_t minl = hist->GetBinCenter(hist->GetXaxis()->GetFirst()); | 
|---|
| 1304 | const Double_t maxl = hist->GetBinCenter(hist->GetXaxis()->GetLast()); | 
|---|
| 1305 |  | 
|---|
| 1306 | TLatex deadtex; | 
|---|
| 1307 | deadtex.SetTextSize(0.07); | 
|---|
| 1308 | deadtex.DrawLatex(minl+0.015*(maxl-minl),max/1.1, | 
|---|
| 1309 | Form("%3i %s pixels",(Int_t)dead,whatsmall)); | 
|---|
| 1310 |  | 
|---|
| 1311 | TLatex noisytex; | 
|---|
| 1312 | noisytex.SetTextSize(0.07); | 
|---|
| 1313 | noisytex.DrawLatex(minl+0.015*(maxl-minl),max/1.2, | 
|---|
| 1314 | Form("%3i %s pixels",(Int_t)noisy,whatbig)); | 
|---|
| 1315 |  | 
|---|
| 1316 | } | 
|---|
| 1317 |  | 
|---|
| 1318 | void MJCalibration::FixDataCheckHist(TH1D *hist) const | 
|---|
| 1319 | { | 
|---|
| 1320 |  | 
|---|
| 1321 | hist->SetDirectory(NULL); | 
|---|
| 1322 |  | 
|---|
| 1323 | // | 
|---|
| 1324 | // set the labels bigger | 
|---|
| 1325 | // | 
|---|
| 1326 | TAxis *xaxe = hist->GetXaxis(); | 
|---|
| 1327 | TAxis *yaxe = hist->GetYaxis(); | 
|---|
| 1328 |  | 
|---|
| 1329 | xaxe->CenterTitle(); | 
|---|
| 1330 | yaxe->CenterTitle(); | 
|---|
| 1331 | xaxe->SetTitleSize(0.06); | 
|---|
| 1332 | yaxe->SetTitleSize(0.06); | 
|---|
| 1333 | xaxe->SetTitleOffset(0.8); | 
|---|
| 1334 | yaxe->SetTitleOffset(0.85); | 
|---|
| 1335 | xaxe->SetLabelSize(0.05); | 
|---|
| 1336 | yaxe->SetLabelSize(0.05); | 
|---|
| 1337 |  | 
|---|
| 1338 | } | 
|---|
| 1339 |  | 
|---|
| 1340 | const Int_t MJCalibration::CountBadPixels(MHCamera *cam, const Int_t what) const | 
|---|
| 1341 | { | 
|---|
| 1342 | Int_t cnt = 0; | 
|---|
| 1343 |  | 
|---|
| 1344 | for (UInt_t pix=0; pix<cam->GetNumPixels(); pix++) | 
|---|
| 1345 | if (TMath::Nint(cam->GetPixContent(pix)) == what) | 
|---|
| 1346 | cnt++; | 
|---|
| 1347 |  | 
|---|
| 1348 | return cnt; | 
|---|
| 1349 | } | 
|---|
| 1350 |  | 
|---|
| 1351 | // -------------------------------------------------------------------------- | 
|---|
| 1352 | // | 
|---|
| 1353 | // Retrieve the output file written by WriteResult() | 
|---|
| 1354 | // | 
|---|
| 1355 | const char* MJCalibration::GetOutputFileName() const | 
|---|
| 1356 | { | 
|---|
| 1357 | return Form("calib%08d.root", fSequence.GetSequence()); | 
|---|
| 1358 | } | 
|---|
| 1359 |  | 
|---|
| 1360 | // -------------------------------------------------------------------------- | 
|---|
| 1361 | // | 
|---|
| 1362 | // Read the following values from resource file: | 
|---|
| 1363 | // | 
|---|
| 1364 | //   ConvFADC2PheMin | 
|---|
| 1365 | //   ConvFADC2PheMax | 
|---|
| 1366 | //   ConvFADC2PhotMin | 
|---|
| 1367 | //   ConvFADC2PhotMax | 
|---|
| 1368 | // | 
|---|
| 1369 | //   QEMin | 
|---|
| 1370 | //   QEMax | 
|---|
| 1371 | // | 
|---|
| 1372 | //   ArrivalTimeMin | 
|---|
| 1373 | //   ArrivalTimeMax | 
|---|
| 1374 | // | 
|---|
| 1375 | //   TimeOffsetMin | 
|---|
| 1376 | //   TimeOffsetMax | 
|---|
| 1377 | //   TimeResolutionMin | 
|---|
| 1378 | //   TimeResolutionMax | 
|---|
| 1379 | // | 
|---|
| 1380 | //   RefConvFADC2PheInner | 
|---|
| 1381 | //   RefConvFADC2PheOuter | 
|---|
| 1382 | //   RefConvFADC2PhotInner | 
|---|
| 1383 | //   RefConvFADC2PhotOuter | 
|---|
| 1384 | // | 
|---|
| 1385 | //   RefQEInner | 
|---|
| 1386 | //   RefQEOuter | 
|---|
| 1387 | // | 
|---|
| 1388 | //   RefArrivalTimeInner | 
|---|
| 1389 | //   RefArrivalTimeOuter | 
|---|
| 1390 | //   RefArrivalTimeRmsInner | 
|---|
| 1391 | //   RefArrivalTimeRmsOuter | 
|---|
| 1392 | // | 
|---|
| 1393 | //   RefTimeOffsetInner | 
|---|
| 1394 | //   RefTimeOffsetOuter | 
|---|
| 1395 | //   RefTimeResolutionInner | 
|---|
| 1396 | //   RefTimeResolutionOuter | 
|---|
| 1397 | // | 
|---|
| 1398 | void MJCalibration::ReadReferenceFile() | 
|---|
| 1399 | { | 
|---|
| 1400 | TEnv refenv(fReferenceFile); | 
|---|
| 1401 |  | 
|---|
| 1402 | fConvFADC2PheMin        = refenv.GetValue("ConvFADC2PheMin",fConvFADC2PheMin); | 
|---|
| 1403 | fConvFADC2PheMax        = refenv.GetValue("ConvFADC2PheMax",fConvFADC2PheMax); | 
|---|
| 1404 | fConvFADC2PhotMin       = refenv.GetValue("ConvFADC2PhotMin",fConvFADC2PhotMin); | 
|---|
| 1405 | fConvFADC2PhotMax       = refenv.GetValue("ConvFADC2PhotMax",fConvFADC2PhotMax); | 
|---|
| 1406 | fQEMin                  = refenv.GetValue("QEMin",fQEMin); | 
|---|
| 1407 | fQEMax                  = refenv.GetValue("QEMax",fQEMax); | 
|---|
| 1408 | fArrivalTimeMin         = refenv.GetValue("ArrivalTimeMin",fArrivalTimeMin); | 
|---|
| 1409 | fArrivalTimeMax         = refenv.GetValue("ArrivalTimeMax",fArrivalTimeMax); | 
|---|
| 1410 | fTimeOffsetMin          = refenv.GetValue("TimeOffsetMin",fTimeOffsetMin); | 
|---|
| 1411 | fTimeOffsetMax          = refenv.GetValue("TimeOffsetMax",fTimeOffsetMax); | 
|---|
| 1412 | fTimeResolutionMin      = refenv.GetValue("TimeResolutionMin",fTimeResolutionMin); | 
|---|
| 1413 | fTimeResolutionMax      = refenv.GetValue("TimeResolutionMax",fTimeResolutionMax); | 
|---|
| 1414 |  | 
|---|
| 1415 | fRefFADC2PheInner       = refenv.GetValue("RefFADC2PheInner",fRefFADC2PheInner); | 
|---|
| 1416 | fRefFADC2PheOuter       = refenv.GetValue("RefFADC2PheOuter",fRefFADC2PheOuter); | 
|---|
| 1417 | fRefConvFADC2PhotInner  = refenv.GetValue("RefConvFADC2PhotInner",fRefConvFADC2PhotInner); | 
|---|
| 1418 | fRefConvFADC2PhotOuter  = refenv.GetValue("RefConvFADC2PhotOuter",fRefConvFADC2PhotOuter); | 
|---|
| 1419 | fRefConvFADC2PheInner   = refenv.GetValue("RefConvFADC2PheInner",fRefConvFADC2PheInner); | 
|---|
| 1420 | fRefConvFADC2PheOuter   = refenv.GetValue("RefConvFADC2PheOuter",fRefConvFADC2PheOuter); | 
|---|
| 1421 | fRefQEInner             = refenv.GetValue("RefQEInner",fRefQEInner); | 
|---|
| 1422 | fRefQEOuter             = refenv.GetValue("RefQEOuter",fRefQEOuter); | 
|---|
| 1423 | fRefArrivalTimeInner    = refenv.GetValue("RefArrivalTimeInner",fRefArrivalTimeInner); | 
|---|
| 1424 | fRefArrivalTimeOuter    = refenv.GetValue("RefArrivalTimeOuter",fRefArrivalTimeOuter); | 
|---|
| 1425 | fRefArrivalTimeRmsInner = refenv.GetValue("RefArrivalTimeRmsInner",fRefArrivalTimeRmsInner); | 
|---|
| 1426 | fRefArrivalTimeRmsOuter = refenv.GetValue("RefArrivalTimeRmsOuter",fRefArrivalTimeRmsOuter); | 
|---|
| 1427 | fRefTimeOffsetInner     = refenv.GetValue("RefTimeOffsetInner",fRefTimeOffsetInner); | 
|---|
| 1428 | fRefTimeOffsetOuter     = refenv.GetValue("RefTimeOffsetOuter",fRefTimeOffsetOuter); | 
|---|
| 1429 | fRefTimeResolutionInner = refenv.GetValue("RefTimeResolutionInner",fRefTimeResolutionInner); | 
|---|
| 1430 | fRefTimeResolutionOuter = refenv.GetValue("RefTimeResolutionOuter",fRefTimeResolutionOuter); | 
|---|
| 1431 | } | 
|---|
| 1432 |  | 
|---|
| 1433 | // -------------------------------------------------------------------------- | 
|---|
| 1434 | // | 
|---|
| 1435 | // Read the following values from resource file. | 
|---|
| 1436 | // | 
|---|
| 1437 | Bool_t MJCalibration::ReadHiLoCalibFile() | 
|---|
| 1438 | { | 
|---|
| 1439 | if (fExtractor && !fExtractor->HasLoGain()) | 
|---|
| 1440 | return kTRUE; | 
|---|
| 1441 |  | 
|---|
| 1442 | //    if (!fIsHiLoCalibration) | 
|---|
| 1443 | //        return kTRUE; | 
|---|
| 1444 |  | 
|---|
| 1445 | // We use the night time stamp to determine the period | 
|---|
| 1446 | // because the night must be in the sequence file | 
|---|
| 1447 | const MTime &night = fSequence.GetNight(); | 
|---|
| 1448 | const Int_t period = night.GetMagicPeriod(); | 
|---|
| 1449 |  | 
|---|
| 1450 | // Open resource file | 
|---|
| 1451 | MEnv env(fHiLoCalibFile); | 
|---|
| 1452 | if (!env.IsValid()) | 
|---|
| 1453 | { | 
|---|
| 1454 | *fLog << err << "ERROR - Resource file " << fHiLoCalibFile; | 
|---|
| 1455 | *fLog << " could not be opened... abort." << endl; | 
|---|
| 1456 | return kFALSE; | 
|---|
| 1457 | } | 
|---|
| 1458 |  | 
|---|
| 1459 | // Defined resource id | 
|---|
| 1460 | const TString id = IsUseMC() ? "MC" : Form("%02d", period); | 
|---|
| 1461 |  | 
|---|
| 1462 | // Check for a valid entry for the correct period | 
|---|
| 1463 | TString fname = env.GetValue(id, ""); | 
|---|
| 1464 | if (fname.IsNull()) | 
|---|
| 1465 | { | 
|---|
| 1466 | *fLog << err << "ERROR - No entry for resource id '" << id; | 
|---|
| 1467 | *fLog << "' found in " << fHiLoCalibFile << "... looking for default." << endl; | 
|---|
| 1468 | return kFALSE; | 
|---|
| 1469 | /* | 
|---|
| 1470 | *fLog << warn << "WARNING - No entry for period " << period; | 
|---|
| 1471 | *fLog << " found in " << fHiLoCalibFile << "... looking for default." << endl; | 
|---|
| 1472 |  | 
|---|
| 1473 | fname = env.GetValue("00", ""); | 
|---|
| 1474 | if (fname.IsNull()) | 
|---|
| 1475 | { | 
|---|
| 1476 | *fLog << err << "ERROR - No default entry (00) found in "; | 
|---|
| 1477 | *fLog << fHiLoCalibFile << "... abort." << endl; | 
|---|
| 1478 | return kFALSE; | 
|---|
| 1479 | }*/ | 
|---|
| 1480 | } | 
|---|
| 1481 |  | 
|---|
| 1482 | *fLog << inf << "Reading Hi-/Lo-Gain calibration constants from " << fname << endl; | 
|---|
| 1483 |  | 
|---|
| 1484 | // Open file with calibration constants | 
|---|
| 1485 | TFile file(fname, "READ"); | 
|---|
| 1486 | if (!file.IsOpen()) | 
|---|
| 1487 | { | 
|---|
| 1488 | *fLog << err << "ERROR - Couldn't open file " << fname << " for reading... abort." << endl; | 
|---|
| 1489 | return kFALSE; | 
|---|
| 1490 | } | 
|---|
| 1491 |  | 
|---|
| 1492 | // read calibration constants | 
|---|
| 1493 | MHCamEvent hilocam; | 
|---|
| 1494 | if (hilocam.Read()<=0) | 
|---|
| 1495 | { | 
|---|
| 1496 | *fLog << err << "ERROR - Unable to read MHCamEvent from " << fname << "... abort." << endl; | 
|---|
| 1497 | return kFALSE; | 
|---|
| 1498 | } | 
|---|
| 1499 |  | 
|---|
| 1500 | // Get histogram with constants | 
|---|
| 1501 | MHCamera *hist = hilocam.GetHist(); | 
|---|
| 1502 | if (!hist) | 
|---|
| 1503 | { | 
|---|
| 1504 | *fLog << err << "ERROR - MHCamEvent from " << fname << " empty... abort." << endl; | 
|---|
| 1505 | return kFALSE; | 
|---|
| 1506 | } | 
|---|
| 1507 |  | 
|---|
| 1508 | // Do some sanity stuff | 
|---|
| 1509 | if (fCalibrationCam.GetSize() < 1) | 
|---|
| 1510 | fCalibrationCam.InitSize(hist->GetNumPixels()); | 
|---|
| 1511 |  | 
|---|
| 1512 | if (fBadPixels.GetSize() < 1) | 
|---|
| 1513 | fBadPixels.InitSize(hist->GetNumPixels()); | 
|---|
| 1514 |  | 
|---|
| 1515 | if ((UInt_t)fCalibrationCam.GetSize() != hist->GetNumPixels()) | 
|---|
| 1516 | { | 
|---|
| 1517 | *fLog << err << "ERROR - Size mismatch MHCamEvent and MCalibrationChargeCam.. abort." << endl; | 
|---|
| 1518 | return kFALSE; | 
|---|
| 1519 | } | 
|---|
| 1520 |  | 
|---|
| 1521 | // Copy the constants to their final location | 
|---|
| 1522 | // FIXME: For what the hell do we need to have the constants in | 
|---|
| 1523 | //        in MCalibrationChargeCam? | 
|---|
| 1524 | for (UInt_t i=0; i<hist->GetNumPixels(); i++) | 
|---|
| 1525 | { | 
|---|
| 1526 | hist->SetBit(MHCamera::kProfile); | 
|---|
| 1527 | Double_t v = hist->GetBinContent(i); | 
|---|
| 1528 | hist->SetBit(MHCamera::kErrorMean); | 
|---|
| 1529 | Double_t e = hist->GetBinError(i); | 
|---|
| 1530 | hist->ResetBit(MHCamera::kErrorMean); | 
|---|
| 1531 | Double_t s = hist->GetBinError(i); | 
|---|
| 1532 |  | 
|---|
| 1533 | if (!hist->IsUsed(i)) | 
|---|
| 1534 | { | 
|---|
| 1535 | fBadPixels[i].SetUncalibrated(MBadPixelsPix::kConversionHiLoNotValid); | 
|---|
| 1536 | v = e = s = -1; | 
|---|
| 1537 | } | 
|---|
| 1538 |  | 
|---|
| 1539 | MCalibrationChargePix &cpix = (MCalibrationChargePix&)fCalibrationCam[i]; | 
|---|
| 1540 | cpix.SetConversionHiLo(v); | 
|---|
| 1541 | cpix.SetConversionHiLoErr(e); | 
|---|
| 1542 | cpix.SetConversionHiLoSigma(s); | 
|---|
| 1543 | } | 
|---|
| 1544 |  | 
|---|
| 1545 | return kTRUE; | 
|---|
| 1546 | } | 
|---|
| 1547 |  | 
|---|
| 1548 | // -------------------------------------------------------------------------- | 
|---|
| 1549 | // | 
|---|
| 1550 | // MJCalibration allows to setup several option by a resource file: | 
|---|
| 1551 | //   MJCalibration.Display: full, datacheck, normal | 
|---|
| 1552 | //   MJCalibration.RelTimeCalibration: yes,no | 
|---|
| 1553 | //   MJCalibration.DataCheck: yes,no | 
|---|
| 1554 | //   MJCalibration.Debug: yes,no | 
|---|
| 1555 | //   MJCalibration.UseBlindPixel: yes,no | 
|---|
| 1556 | //   MJCalibration.UsePINDiode: yes,no | 
|---|
| 1557 | //   MJCalibration.Geometry: MGeomCamMagic, MGeomCamECO1000 | 
|---|
| 1558 | // | 
|---|
| 1559 | // Name of a file containing reference values (see ReadReferenceFile) | 
|---|
| 1560 | //   Prefix.ReferenceFile:    filename | 
|---|
| 1561 | // (see ReadReferenceFile) | 
|---|
| 1562 | // | 
|---|
| 1563 | // For more details see the class description and the corresponding Getters | 
|---|
| 1564 | // | 
|---|
| 1565 | Bool_t MJCalibration::CheckEnvLocal() | 
|---|
| 1566 | { | 
|---|
| 1567 | TString dis = GetEnv("Display", ""); | 
|---|
| 1568 | if (dis.BeginsWith("Full", TString::kIgnoreCase)) | 
|---|
| 1569 | SetFullDisplay(); | 
|---|
| 1570 | if (dis.BeginsWith("DataCheck", TString::kIgnoreCase)) | 
|---|
| 1571 | SetDataCheckDisplay(); | 
|---|
| 1572 | if (dis.BeginsWith("Normal", TString::kIgnoreCase)) | 
|---|
| 1573 | SetNormalDisplay(); | 
|---|
| 1574 |  | 
|---|
| 1575 | if (!MJCalib::CheckEnvLocal()) | 
|---|
| 1576 | return kFALSE; | 
|---|
| 1577 |  | 
|---|
| 1578 | SetRelTimeCalibration(GetEnv("RelTimeCalibration", IsRelTimes())); | 
|---|
| 1579 | SetDebug(GetEnv("Debug", IsDebug())); | 
|---|
| 1580 |  | 
|---|
| 1581 | SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel())); | 
|---|
| 1582 | SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode())); | 
|---|
| 1583 | SetGeometry(GetEnv("Geometry", fGeometry)); | 
|---|
| 1584 |  | 
|---|
| 1585 | fReferenceFile = GetEnv("ReferenceFile",fReferenceFile.Data()); | 
|---|
| 1586 | ReadReferenceFile(); | 
|---|
| 1587 |  | 
|---|
| 1588 | fHiLoCalibFile = GetEnv("HiLoCalibFile",fHiLoCalibFile.Data()); | 
|---|
| 1589 |  | 
|---|
| 1590 | /* | 
|---|
| 1591 | if (IsUseMC() && !fHiLoCalibFile.EndsWith("_mc.root")) | 
|---|
| 1592 | { | 
|---|
| 1593 | if (!fHiLoCalibFile.EndsWith(".root")) | 
|---|
| 1594 | { | 
|---|
| 1595 | *fLog << warn << "WARNING - Hi-/Lo-Gain intercalibration file "; | 
|---|
| 1596 | *fLog << fHiLoCalibFile << " has not .root as extension..." << endl; | 
|---|
| 1597 | } | 
|---|
| 1598 | else | 
|---|
| 1599 | fHiLoCalibFile.Insert(fHiLoCalibFile.Length()-5, "_mc"); | 
|---|
| 1600 | } | 
|---|
| 1601 | */ | 
|---|
| 1602 |  | 
|---|
| 1603 | return ReadHiLoCalibFile(); | 
|---|
| 1604 | } | 
|---|
| 1605 |  | 
|---|
| 1606 | void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext, | 
|---|
| 1607 | MHCalibrationChargeBlindCam &blindcam) | 
|---|
| 1608 | { | 
|---|
| 1609 | const Int_t run = fSequence.GetLastRun(); | 
|---|
| 1610 |  | 
|---|
| 1611 | // | 
|---|
| 1612 | // Initialize the blind pixel. Unfortunately, there is a hardware | 
|---|
| 1613 | // difference in the first blind pixel until run | 
|---|
| 1614 | // gkSecondBlindPixelInstallation and the later setup. The first | 
|---|
| 1615 | // needs to use a filter because of the length of spurious NSB photon | 
|---|
| 1616 | // signals. The latter get better along extracting the amplitude | 
|---|
| 1617 | // from a small window. | 
|---|
| 1618 | // | 
|---|
| 1619 | const MCalibrationBlindCamOneOldStyle   one; | 
|---|
| 1620 | const MCalibrationBlindCamTwoNewStyle   two; | 
|---|
| 1621 | const MCalibrationBlindCamThreeNewStyle three; | 
|---|
| 1622 |  | 
|---|
| 1623 | const MCalibrationBlindCam &blindresults = | 
|---|
| 1624 | run<gkSecondBlindPixelInstallation ? static_cast<MCalibrationBlindCam>(one) : | 
|---|
| 1625 | (run<gkThirdBlindPixelInstallation ? static_cast<MCalibrationBlindCam>(two) : static_cast<MCalibrationBlindCam>(three)); | 
|---|
| 1626 |  | 
|---|
| 1627 | blindresults.Copy(fCalibrationBlindCam); | 
|---|
| 1628 |  | 
|---|
| 1629 | blindext.SetExtractionType(MExtractBlindPixel::kIntegral); | 
|---|
| 1630 | blindext.SetExtractionType(MExtractBlindPixel::kFilter); | 
|---|
| 1631 |  | 
|---|
| 1632 | if (run<gkSecondBlindPixelInstallation) | 
|---|
| 1633 | { | 
|---|
| 1634 | blindext.SetRange(10,19,0,6); | 
|---|
| 1635 | blindext.SetNSBFilterLimit(70); | 
|---|
| 1636 | } | 
|---|
| 1637 | else | 
|---|
| 1638 | { | 
|---|
| 1639 | blindext.SetRange(5,8,0,2); | 
|---|
| 1640 | blindext.SetNSBFilterLimit(38); | 
|---|
| 1641 | } | 
|---|
| 1642 |  | 
|---|
| 1643 | if (run>=gkThirdBlindPixelInstallation) | 
|---|
| 1644 | blindext.SetDataType(MExtractBlindPixel::kRawEvt2); | 
|---|
| 1645 | } | 
|---|
| 1646 |  | 
|---|
| 1647 | // -------------------------------------------------------------------------- | 
|---|
| 1648 | // | 
|---|
| 1649 | // Execute the task list and the eventloop: | 
|---|
| 1650 | // | 
|---|
| 1651 | // - Check the colour of the files in fRuns (FindColor()), otherwise return | 
|---|
| 1652 | // - Check for consistency between run numbers and number of files | 
|---|
| 1653 | // - Add fRuns to MReadMarsFile | 
|---|
| 1654 | // - Put into MParList: | 
|---|
| 1655 | //   1) MPedestalCam          (pedcam) | 
|---|
| 1656 | //   2) MCalibrationQECam     (fQECam) | 
|---|
| 1657 | //   3) MCalibrationChargeCam (fCalibrationCam) | 
|---|
| 1658 | //   4) MCalibrationRelTimeCam (fRelTimeCam)   (only if flag IsRelTimes() is chosen) | 
|---|
| 1659 | //   5) MBadPixelsCam         (fBadPixels) | 
|---|
| 1660 | //   6) MCalibrationChargePINDiode | 
|---|
| 1661 | //   7) MCalibrationBlindPix | 
|---|
| 1662 | // - Put into the MTaskList: | 
|---|
| 1663 | //   1)  MReadMarsFile | 
|---|
| 1664 | //   2)  MBadPixelsMerge | 
|---|
| 1665 | //   3)  MGeomApply | 
|---|
| 1666 | //   4)  MExtractor | 
|---|
| 1667 | //   5)  MExtractPINDiode | 
|---|
| 1668 | //   6)  MExtractBlindPixel | 
|---|
| 1669 | //   7)  MExtractTime (only if flag IsRelTimes() is chosen) | 
|---|
| 1670 | //   8)  MContinue(MFCosmics) | 
|---|
| 1671 | //   9)  MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode",   "FillPINDiode") | 
|---|
| 1672 | //   10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam") | 
|---|
| 1673 | //   11) MFillH("MHCalibrationChargeCam",      "MExtractedSignalCam",        "FillChargeCam") | 
|---|
| 1674 | //   12) MFillH("MHCalibrationChargeCam",      "MExtractedSignalCam",        "FillRelTime") | 
|---|
| 1675 | //   13) MCalibrationChargeCalc | 
|---|
| 1676 | //   14) MFillH("MHCalibrationRelTimeCam",     "MArrivalTimeCam") (only if flag IsRelTimes() is chosen) | 
|---|
| 1677 | //   15) MCalibrationRelTimeCalc | 
|---|
| 1678 | // - Execute MEvtLoop | 
|---|
| 1679 | // - DisplayResult() | 
|---|
| 1680 | // - WriteResult() | 
|---|
| 1681 | // | 
|---|
| 1682 | Bool_t MJCalibration::Process(MPedestalCam &pedcam) | 
|---|
| 1683 | { | 
|---|
| 1684 | if (!fSequence.IsValid()) | 
|---|
| 1685 | { | 
|---|
| 1686 | *fLog << err << "ERROR - Sequence invalid..." << endl; | 
|---|
| 1687 | return kFALSE; | 
|---|
| 1688 | } | 
|---|
| 1689 |  | 
|---|
| 1690 | *fLog << inf; | 
|---|
| 1691 | fLog->Separator(GetDescriptor()); | 
|---|
| 1692 | *fLog << "Calculate calibration constants from Sequence #"; | 
|---|
| 1693 | *fLog << fSequence.GetSequence() << endl << endl; | 
|---|
| 1694 |  | 
|---|
| 1695 | // -------------------------------------------------------------------------------- | 
|---|
| 1696 |  | 
|---|
| 1697 | if (!CheckEnv()) | 
|---|
| 1698 | return kFALSE; | 
|---|
| 1699 |  | 
|---|
| 1700 | // -------------------------------------------------------------------------------- | 
|---|
| 1701 |  | 
|---|
| 1702 | // Setup Tasklist | 
|---|
| 1703 | MParList plist; | 
|---|
| 1704 | MTaskList tlist; | 
|---|
| 1705 | plist.AddToList(&tlist); | 
|---|
| 1706 | plist.AddToList(this); // take care of fDisplay! | 
|---|
| 1707 |  | 
|---|
| 1708 | MDirIter iter; | 
|---|
| 1709 | if (fSequence.SetupCalRuns(iter, 0, IsUseRawData())<=0) | 
|---|
| 1710 | return kFALSE; | 
|---|
| 1711 |  | 
|---|
| 1712 | // | 
|---|
| 1713 | // Input containers | 
|---|
| 1714 | // | 
|---|
| 1715 | pedcam.SetName("MPedestalCam"); // MPedestalFundamental | 
|---|
| 1716 | plist.AddToList(&pedcam); | 
|---|
| 1717 | plist.AddToList(&fBadPixels); | 
|---|
| 1718 |  | 
|---|
| 1719 | // | 
|---|
| 1720 | // Calibration Results containers | 
|---|
| 1721 | // | 
|---|
| 1722 | plist.AddToList(&fQECam); | 
|---|
| 1723 | plist.AddToList(&fCalibrationCam); | 
|---|
| 1724 | plist.AddToList(&fRelTimeCam); | 
|---|
| 1725 | if (IsUseBlindPixel()) | 
|---|
| 1726 | plist.AddToList(&fCalibrationBlindCam); | 
|---|
| 1727 | if (IsUsePINDiode()) | 
|---|
| 1728 | plist.AddToList(&fCalibrationPINDiode); | 
|---|
| 1729 |  | 
|---|
| 1730 | // | 
|---|
| 1731 | // Initialize two histogram containers which could be modified in this class | 
|---|
| 1732 | // | 
|---|
| 1733 | MHCalibrationRelTimeCam     reltimecam; | 
|---|
| 1734 | MHCalibrationChargeCam      chargecam; | 
|---|
| 1735 | MHCalibrationChargeBlindCam blindcam; | 
|---|
| 1736 | plist.AddToList(&chargecam); | 
|---|
| 1737 |  | 
|---|
| 1738 | if (IsUseBlindPixel()) | 
|---|
| 1739 | plist.AddToList(&blindcam); | 
|---|
| 1740 | if (IsRelTimes()) | 
|---|
| 1741 | plist.AddToList(&reltimecam); | 
|---|
| 1742 | // | 
|---|
| 1743 | // Data Reading tasks | 
|---|
| 1744 | // | 
|---|
| 1745 | MReadMarsFile read("Events"); | 
|---|
| 1746 | MRawFileRead rawread(NULL); | 
|---|
| 1747 |  | 
|---|
| 1748 | if (IsUseRawData()) | 
|---|
| 1749 | { | 
|---|
| 1750 | rawread.AddFiles(iter); | 
|---|
| 1751 | tlist.AddToList(&rawread); | 
|---|
| 1752 | } | 
|---|
| 1753 | else | 
|---|
| 1754 | { | 
|---|
| 1755 | read.DisableAutoScheme(); | 
|---|
| 1756 | read.AddFiles(iter); | 
|---|
| 1757 | tlist.AddToList(&read); | 
|---|
| 1758 | } | 
|---|
| 1759 |  | 
|---|
| 1760 | // | 
|---|
| 1761 | // Other Tasks | 
|---|
| 1762 | // | 
|---|
| 1763 |  | 
|---|
| 1764 | // Set the default for data version earlier than 5, where no valid | 
|---|
| 1765 | // trigger pattern exists. There should not be pin diode or other | 
|---|
| 1766 | // types of events inside the calibration files which should be skipped, | 
|---|
| 1767 | // anyway. So we set the default such that the MContinue ccalib | 
|---|
| 1768 | // will never be executed. | 
|---|
| 1769 | MTriggerPatternDecode     trgpat; | 
|---|
| 1770 | MFTriggerPattern          fcalib("CalibFilter"); | 
|---|
| 1771 | fcalib.SetDefault(kFALSE); | 
|---|
| 1772 | fcalib.DenyCalibration(MFTriggerPattern::kPrescaled); | 
|---|
| 1773 |  | 
|---|
| 1774 | MContinue                 ccalib(&fcalib,"ContTrigPattern"); | 
|---|
| 1775 |  | 
|---|
| 1776 | MCalibrationPatternDecode decode; | 
|---|
| 1777 | MGeomApply                apply; | 
|---|
| 1778 | apply.SetGeometry(fGeometry); | 
|---|
| 1779 |  | 
|---|
| 1780 | MBadPixelsMerge          merge(&fBadPixels); | 
|---|
| 1781 | MExtractPINDiode         pinext; | 
|---|
| 1782 | MExtractBlindPixel       blindext; | 
|---|
| 1783 |  | 
|---|
| 1784 | if (IsUseBlindPixel()) | 
|---|
| 1785 | InitBlindPixel(blindext, blindcam); | 
|---|
| 1786 |  | 
|---|
| 1787 | //    MExtractSlidingWindow    extract2; | 
|---|
| 1788 | //    MExtractTimeHighestIntegral timehigh; | 
|---|
| 1789 | MCalibrationChargeCalc   calcalc; | 
|---|
| 1790 | MCalibrationRelTimeCalc  timecalc; | 
|---|
| 1791 | calcalc.SetExtractor(fExtractor); | 
|---|
| 1792 |  | 
|---|
| 1793 | if (IsDebug()) | 
|---|
| 1794 | { | 
|---|
| 1795 | chargecam.SetDebug(); | 
|---|
| 1796 | calcalc.SetDebug(); | 
|---|
| 1797 | } | 
|---|
| 1798 |  | 
|---|
| 1799 | // | 
|---|
| 1800 | // Calibration histogramming | 
|---|
| 1801 | // | 
|---|
| 1802 | MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode",   "FillPINDiode"); | 
|---|
| 1803 | MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam"); | 
|---|
| 1804 | MFillH fillcam("MHCalibrationChargeCam",      "MExtractedSignalCam",        "FillChargeCam"); | 
|---|
| 1805 | MFillH filltme("MHCalibrationRelTimeCam",     "MArrivalTimeCam",            "FillRelTime"); | 
|---|
| 1806 | fillpin.SetBit(MFillH::kDoNotDisplay); | 
|---|
| 1807 | fillbnd.SetBit(MFillH::kDoNotDisplay); | 
|---|
| 1808 | fillcam.SetBit(MFillH::kDoNotDisplay); | 
|---|
| 1809 | filltme.SetBit(MFillH::kDoNotDisplay); | 
|---|
| 1810 |  | 
|---|
| 1811 | // | 
|---|
| 1812 | // Set default extractors in case, none has been set... | 
|---|
| 1813 | // | 
|---|
| 1814 | /* | 
|---|
| 1815 | if (!fExtractor) | 
|---|
| 1816 | fExtractor = &extract2; | 
|---|
| 1817 | if (!fTimeExtractor) | 
|---|
| 1818 | fTimeExtractor = &timehigh; | 
|---|
| 1819 | */ | 
|---|
| 1820 | MExtractTimeAndChargeSpline spline; | 
|---|
| 1821 | if (!fExtractor) | 
|---|
| 1822 | fExtractor = &spline; | 
|---|
| 1823 | //    if (!fTimeExtractor) | 
|---|
| 1824 | //      fTimeExtractor = &timehigh; | 
|---|
| 1825 |  | 
|---|
| 1826 | const Bool_t istimecharge = fExtractor->InheritsFrom("MExtractTimeAndCharge"); | 
|---|
| 1827 |  | 
|---|
| 1828 | // | 
|---|
| 1829 | // Look if the extractor is a pure charge or also a time extractor | 
|---|
| 1830 | // | 
|---|
| 1831 | if (istimecharge) | 
|---|
| 1832 | { | 
|---|
| 1833 | if (fExtractorCam.GetSize() == pedcam.GetSize()) | 
|---|
| 1834 | calcalc.SetPedestals(&fExtractorCam); | 
|---|
| 1835 | else | 
|---|
| 1836 | { | 
|---|
| 1837 | *fLog << err << GetDescriptor() << "ERROR - "; | 
|---|
| 1838 | *fLog << "Used Extractor derives from MExtractTimeAndCharge, " << endl; | 
|---|
| 1839 | *fLog << "but MExtractorCam size " << fExtractorCam.GetSize() << " "; | 
|---|
| 1840 | *fLog << "mismatch pedcam size " << pedcam.GetSize() << "! " << endl; | 
|---|
| 1841 | return kFALSE; | 
|---|
| 1842 | } | 
|---|
| 1843 | } | 
|---|
| 1844 |  | 
|---|
| 1845 | // | 
|---|
| 1846 | // Setup more tasks and tasklist | 
|---|
| 1847 | // | 
|---|
| 1848 | MTaskEnv taskenv("ExtractSignal"); | 
|---|
| 1849 | taskenv.SetDefault(fExtractor); | 
|---|
| 1850 |  | 
|---|
| 1851 | tlist.AddToList(&trgpat); | 
|---|
| 1852 | if (fColor != MCalibrationCam::kCT1) | 
|---|
| 1853 | tlist.AddToList(&ccalib); | 
|---|
| 1854 | tlist.AddToList(&decode); | 
|---|
| 1855 | tlist.AddToList(&merge); | 
|---|
| 1856 | tlist.AddToList(&apply); | 
|---|
| 1857 |  | 
|---|
| 1858 | // Produce pedestal subtracted raw-data | 
|---|
| 1859 | MPedestalSubtract pedsub; | 
|---|
| 1860 | pedsub.SetPedestalCam(fExtractor->GetPedestals()); | 
|---|
| 1861 | tlist.AddToList(&pedsub); | 
|---|
| 1862 |  | 
|---|
| 1863 | MCalibColorSet colorset; | 
|---|
| 1864 | if (fColor != MCalibrationCam::kNONE) | 
|---|
| 1865 | colorset.SetExplicitColor(fColor); | 
|---|
| 1866 | tlist.AddToList(&colorset); | 
|---|
| 1867 |  | 
|---|
| 1868 | tlist.AddToList(&taskenv); | 
|---|
| 1869 |  | 
|---|
| 1870 | if (IsUsePINDiode()) | 
|---|
| 1871 | tlist.AddToList(&pinext); | 
|---|
| 1872 | if (IsUseBlindPixel()) | 
|---|
| 1873 | tlist.AddToList(&blindext); | 
|---|
| 1874 |  | 
|---|
| 1875 | MTaskEnv taskenv2("ExtractTime"); | 
|---|
| 1876 | if (!istimecharge) | 
|---|
| 1877 | { | 
|---|
| 1878 | taskenv2.SetDefault(fTimeExtractor); | 
|---|
| 1879 |  | 
|---|
| 1880 | if (IsRelTimes()) | 
|---|
| 1881 | tlist.AddToList(&taskenv2); | 
|---|
| 1882 | } | 
|---|
| 1883 |  | 
|---|
| 1884 | // | 
|---|
| 1885 | // Apply a filter against cosmics | 
|---|
| 1886 | // (will have to be needed in the future | 
|---|
| 1887 | // when the calibration hardware-trigger is working) | 
|---|
| 1888 | // | 
|---|
| 1889 | MFCosmics cosmics; | 
|---|
| 1890 | cosmics.SetMaxEmptyPixels(0.05); | 
|---|
| 1891 | cosmics.SetMaxAcceptedFraction(0.5); // max=0.5 cosmics | 
|---|
| 1892 |  | 
|---|
| 1893 | MContinue cont(&cosmics, "ContCosmics"); | 
|---|
| 1894 | tlist.AddToList(&cont); | 
|---|
| 1895 |  | 
|---|
| 1896 | if (IsRelTimes()) | 
|---|
| 1897 | { | 
|---|
| 1898 | tlist.AddToList(&filltme); | 
|---|
| 1899 | tlist.AddToList(&timecalc); | 
|---|
| 1900 | } | 
|---|
| 1901 |  | 
|---|
| 1902 | tlist.AddToList(&fillcam); | 
|---|
| 1903 |  | 
|---|
| 1904 | if (IsUseBlindPixel()) | 
|---|
| 1905 | tlist.AddToList(&fillbnd); | 
|---|
| 1906 | if (IsUsePINDiode()) | 
|---|
| 1907 | tlist.AddToList(&fillpin); | 
|---|
| 1908 |  | 
|---|
| 1909 | tlist.AddToList(&calcalc); | 
|---|
| 1910 |  | 
|---|
| 1911 |  | 
|---|
| 1912 | MHCamEvent evt2(0, "Extra'd", "Extracted Calibration Signal;;S [cnts/sl]"); | 
|---|
| 1913 | MHCamEvent evt9(4, "ArrTm",   "Extracted ArrivalTime;;T"); | 
|---|
| 1914 |  | 
|---|
| 1915 | MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtractedSignal"); | 
|---|
| 1916 | MFillH fill9(&evt9, "MArrivalTimeCam",     "FillArrivalTime"); | 
|---|
| 1917 |  | 
|---|
| 1918 | tlist.AddToList(&fill2); | 
|---|
| 1919 | tlist.AddToList(&fill9); | 
|---|
| 1920 |  | 
|---|
| 1921 | /* | 
|---|
| 1922 | MFillH fillP("MHPulseShape", "", "FillPulseShape"); | 
|---|
| 1923 | fillP.SetNameTab("Pulse"); | 
|---|
| 1924 | tlist.AddToList(&fillP); | 
|---|
| 1925 | */ | 
|---|
| 1926 |  | 
|---|
| 1927 | // Create and setup the eventloop | 
|---|
| 1928 | MEvtLoop evtloop(fName); | 
|---|
| 1929 | evtloop.SetParList(&plist); | 
|---|
| 1930 | evtloop.SetDisplay(fDisplay); | 
|---|
| 1931 | evtloop.SetLogStream(fLog); | 
|---|
| 1932 | if (!SetupEnv(evtloop)) | 
|---|
| 1933 | return kFALSE; | 
|---|
| 1934 |  | 
|---|
| 1935 | if (!taskenv.GetTask() && !taskenv2.GetTask()) | 
|---|
| 1936 | { | 
|---|
| 1937 | *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initialized or both '<dummy>'." << endl; | 
|---|
| 1938 | return kFALSE; | 
|---|
| 1939 | } | 
|---|
| 1940 |  | 
|---|
| 1941 | if (!WriteTasks(taskenv.GetTask(), istimecharge ? 0 : taskenv2.GetTask())) | 
|---|
| 1942 | return kFALSE; | 
|---|
| 1943 |  | 
|---|
| 1944 | // Execute first analysis | 
|---|
| 1945 | const Bool_t rc = evtloop.Eventloop(); | 
|---|
| 1946 |  | 
|---|
| 1947 | if (!fCalibrationPINDiode.IsValid()) | 
|---|
| 1948 | SetUsePINDiode(kFALSE); | 
|---|
| 1949 |  | 
|---|
| 1950 | const Int_t numexec = IsUseRawData() ? rawread.GetNumExecutions() : read.GetNumExecutions(); | 
|---|
| 1951 | if (numexec>0) | 
|---|
| 1952 | { | 
|---|
| 1953 | DisplayResult(plist); | 
|---|
| 1954 | if (!WriteResult(plist)) | 
|---|
| 1955 | return kFALSE; | 
|---|
| 1956 | } | 
|---|
| 1957 |  | 
|---|
| 1958 | if (!rc) | 
|---|
| 1959 | { | 
|---|
| 1960 | *fLog << err << GetDescriptor() << ": Failed." << endl; | 
|---|
| 1961 | return kFALSE; | 
|---|
| 1962 | } | 
|---|
| 1963 |  | 
|---|
| 1964 | // -------------------------------------------------------------------------------- | 
|---|
| 1965 |  | 
|---|
| 1966 | if (fIsPixelCheck) | 
|---|
| 1967 | { | 
|---|
| 1968 | chargecam[fCheckedPixId].DrawClone("datacheck"); | 
|---|
| 1969 | chargecam(fCheckedPixId).DrawClone("datacheck"); | 
|---|
| 1970 |  | 
|---|
| 1971 | if (IsRelTimes()) | 
|---|
| 1972 | { | 
|---|
| 1973 | reltimecam[fCheckedPixId].DrawClone(""); | 
|---|
| 1974 | reltimecam(fCheckedPixId).DrawClone(""); | 
|---|
| 1975 | } | 
|---|
| 1976 | } | 
|---|
| 1977 |  | 
|---|
| 1978 | *fLog << all << GetDescriptor() << ": Done." << endl; | 
|---|
| 1979 |  | 
|---|
| 1980 | return kTRUE; | 
|---|
| 1981 | } | 
|---|
| 1982 |  | 
|---|
| 1983 | /* | 
|---|
| 1984 | Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const | 
|---|
| 1985 | { | 
|---|
| 1986 | if (IsNoStorage()) | 
|---|
| 1987 | return kTRUE; | 
|---|
| 1988 |  | 
|---|
| 1989 | if (fPathOut.IsNull()) | 
|---|
| 1990 | return kTRUE; | 
|---|
| 1991 |  | 
|---|
| 1992 | const TString oname(GetOutputFile()); | 
|---|
| 1993 |  | 
|---|
| 1994 | *fLog << inf << "Writing to file: " << oname << endl; | 
|---|
| 1995 |  | 
|---|
| 1996 | TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9); | 
|---|
| 1997 | if (!file.IsOpen()) | 
|---|
| 1998 | { | 
|---|
| 1999 | *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl; | 
|---|
| 2000 | return kFALSE; | 
|---|
| 2001 | } | 
|---|
| 2002 |  | 
|---|
| 2003 | if (evtloop.Write(fName)<=0) | 
|---|
| 2004 | { | 
|---|
| 2005 | *fLog << err << "Unable to write MEvtloop to " << oname << endl; | 
|---|
| 2006 | return kFALSE; | 
|---|
| 2007 | } | 
|---|
| 2008 |  | 
|---|
| 2009 | return kTRUE; | 
|---|
| 2010 | } | 
|---|
| 2011 | */ | 
|---|
| 2012 |  | 
|---|
| 2013 | Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const | 
|---|
| 2014 | { | 
|---|
| 2015 | if (IsNoStorage()) | 
|---|
| 2016 | return kTRUE; | 
|---|
| 2017 |  | 
|---|
| 2018 | TObjArray cont; | 
|---|
| 2019 | if (t1) | 
|---|
| 2020 | cont.Add(t1); | 
|---|
| 2021 | if (t2) | 
|---|
| 2022 | cont.Add(t2); | 
|---|
| 2023 |  | 
|---|
| 2024 | return WriteContainer(cont, GetOutputFileName(), fOverwrite?"RECREATE":"NEW"); | 
|---|
| 2025 | } | 
|---|
| 2026 |  | 
|---|
| 2027 | // -------------------------------------------------------------------------- | 
|---|
| 2028 | // | 
|---|
| 2029 | // Write the result into the output file GetOutputFile(), if fOutputPath exists. | 
|---|
| 2030 | // | 
|---|
| 2031 | // The following containers are written: | 
|---|
| 2032 | // - MStatusDisplay | 
|---|
| 2033 | // - MCalibrationChargeCam | 
|---|
| 2034 | // - MCalibrationBlindCam | 
|---|
| 2035 | // - MCalibrationQECam | 
|---|
| 2036 | // - MCalibrationChargePINDiode | 
|---|
| 2037 | // - MBadPixelsCam | 
|---|
| 2038 | // | 
|---|
| 2039 | // If the flag kRelTimes is set, then also: | 
|---|
| 2040 | // - MCalibrationRelTimeCam or MCalibrationIntensityRelTimeCam | 
|---|
| 2041 | // | 
|---|
| 2042 | Bool_t MJCalibration::WriteResult(MParList &plist) | 
|---|
| 2043 | { | 
|---|
| 2044 | if (IsNoStorage()) | 
|---|
| 2045 | return kTRUE; | 
|---|
| 2046 |  | 
|---|
| 2047 | TObjArray cont; | 
|---|
| 2048 | cont.Add(&fBadPixels); | 
|---|
| 2049 | cont.Add(&fCalibrationCam); | 
|---|
| 2050 | cont.Add(&fQECam); | 
|---|
| 2051 | cont.Add(&fCalibrationBlindCam); | 
|---|
| 2052 | cont.Add(&fCalibrationPINDiode); | 
|---|
| 2053 |  | 
|---|
| 2054 | if (IsRelTimes()) | 
|---|
| 2055 | cont.Add(&fRelTimeCam); | 
|---|
| 2056 |  | 
|---|
| 2057 | if (fExtractorCam.GetSize() != 0) | 
|---|
| 2058 | cont.Add(&fExtractorCam); | 
|---|
| 2059 |  | 
|---|
| 2060 | TObject *pedcam = plist.FindObject("MPedestalCam"); | 
|---|
| 2061 | if (!pedcam) | 
|---|
| 2062 | *fLog << warn << " - WARNING - MPedestalCam (fundamental)... not found for writing!" << endl; | 
|---|
| 2063 | else | 
|---|
| 2064 | cont.Add(pedcam); | 
|---|
| 2065 |  | 
|---|
| 2066 | TObject *geom = plist.FindObject("MGeomCam"); | 
|---|
| 2067 | if (!geom) | 
|---|
| 2068 | *fLog << warn << " - WARNING - MGeomCam... not found for writing!" << endl; | 
|---|
| 2069 | else | 
|---|
| 2070 | cont.Add(geom); | 
|---|
| 2071 |  | 
|---|
| 2072 | if (IsHistsStorage()) | 
|---|
| 2073 | { | 
|---|
| 2074 | cont.Add(plist.FindObject("MHCalibrationChargeCam")); | 
|---|
| 2075 | cont.Add(plist.FindObject("MHCalibrationChargeBlindCam")); | 
|---|
| 2076 | cont.Add(plist.FindObject("MHCalibrationChargePINDiode")); | 
|---|
| 2077 | if (IsRelTimes()) | 
|---|
| 2078 | cont.Add(plist.FindObject("MHCalibrationRelTimeCam")); | 
|---|
| 2079 | } | 
|---|
| 2080 |  | 
|---|
| 2081 | return WriteContainer(cont, GetOutputFileName(), "UPDATE"); | 
|---|
| 2082 | } | 
|---|
| 2083 |  | 
|---|
| 2084 | void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const | 
|---|
| 2085 | { | 
|---|
| 2086 |  | 
|---|
| 2087 | TArrayI inner(1); | 
|---|
| 2088 | inner[0] = 0; | 
|---|
| 2089 |  | 
|---|
| 2090 | TArrayI outer(1); | 
|---|
| 2091 | outer[0] = 1; | 
|---|
| 2092 |  | 
|---|
| 2093 | TArrayI s1(3); | 
|---|
| 2094 | s1[0] = 6; | 
|---|
| 2095 | s1[1] = 1; | 
|---|
| 2096 | s1[2] = 2; | 
|---|
| 2097 |  | 
|---|
| 2098 | TArrayI s2(3); | 
|---|
| 2099 | s2[0] = 3; | 
|---|
| 2100 | s2[1] = 4; | 
|---|
| 2101 | s2[2] = 5; | 
|---|
| 2102 |  | 
|---|
| 2103 | TVirtualPad *pad = gPad; | 
|---|
| 2104 | pad->Divide(2,1); | 
|---|
| 2105 |  | 
|---|
| 2106 | TH1D *inout[2]; | 
|---|
| 2107 |  | 
|---|
| 2108 | for (int i=0; i<2; i++) | 
|---|
| 2109 | { | 
|---|
| 2110 | pad->cd(i+1); | 
|---|
| 2111 | gPad->SetBorderMode(0); | 
|---|
| 2112 | gPad->SetTicks(); | 
|---|
| 2113 |  | 
|---|
| 2114 | inout[i] = cam->ProjectionS(TArrayI(), TArrayI(1,&i), i==0 ? "Inner" : "Outer"); | 
|---|
| 2115 | FixDataCheckHist(inout[i]); | 
|---|
| 2116 | inout[i]->SetTitle(Form("%s %s",cam->GetTitle(),i==0 ? "Inner" : "Outer")); | 
|---|
| 2117 | inout[i]->SetDirectory(NULL); | 
|---|
| 2118 | inout[i]->SetLineColor(kRed+i); | 
|---|
| 2119 | inout[i]->SetBit(kCanDelete); | 
|---|
| 2120 | inout[i]->Draw(); | 
|---|
| 2121 | // | 
|---|
| 2122 | // Display the outliers as dead and noisy pixels | 
|---|
| 2123 | // | 
|---|
| 2124 | if (!inout[i]->Fit("gaus","0Q")) | 
|---|
| 2125 | DisplayOutliers(inout[i],whatsmall,whatbig); | 
|---|
| 2126 |  | 
|---|
| 2127 | gPad->Modified(); | 
|---|
| 2128 | gPad->Update(); | 
|---|
| 2129 | TPaveStats *st = (TPaveStats*)inout[i]->GetListOfFunctions()->FindObject("stats"); | 
|---|
| 2130 | st->SetY1NDC(0.6); | 
|---|
| 2131 | st->SetY2NDC(0.9); | 
|---|
| 2132 | st->SetX1NDC(0.55); | 
|---|
| 2133 | st->SetX2NDC(0.99); | 
|---|
| 2134 | gPad->Modified(); | 
|---|
| 2135 | gPad->Update(); | 
|---|
| 2136 |  | 
|---|
| 2137 | TLegend *leg2 = new TLegend(0.55,0.4,0.99,0.6); | 
|---|
| 2138 |  | 
|---|
| 2139 | // | 
|---|
| 2140 | // Display the two half of the camera separately | 
|---|
| 2141 | // | 
|---|
| 2142 | TH1D *half[2]; | 
|---|
| 2143 | half[0] = cam->ProjectionS(s1, TArrayI(1,&i), "Sector 6-1-2"); | 
|---|
| 2144 | half[1] = cam->ProjectionS(s2, TArrayI(1,&i), "Sector 3-4-5"); | 
|---|
| 2145 |  | 
|---|
| 2146 | for (int j=0; j<2; j++) | 
|---|
| 2147 | { | 
|---|
| 2148 | half[j]->SetLineColor(kRed+i+2*j+1); | 
|---|
| 2149 | half[j]->SetDirectory(NULL); | 
|---|
| 2150 | half[j]->SetBit(kCanDelete); | 
|---|
| 2151 | half[j]->Draw("same"); | 
|---|
| 2152 | leg2->AddEntry(half[j], half[j]->GetName(), "l"); | 
|---|
| 2153 | } | 
|---|
| 2154 | leg2->Draw(); | 
|---|
| 2155 | } | 
|---|
| 2156 | } | 
|---|