Changeset 7188 for trunk/MagicSoft


Ignore:
Timestamp:
07/13/05 19:06:26 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7183 r7188  
    1919While an underscore is a placeholder for a white-space or an empty line.
    2020
    21 
    2221                                                 -*-*- END OF LINE -*-*-
     22
     23 2005/07/13 Abelardo Moralejo (2005/07/12)
     24
     25   * manalysis/MGeomApply.cc
     26     - Now, if the MGeomApply task has a serial number >0 (indicating
     27       most likely a specific telescope in a multi-telescope file), then
     28       apply the geometry only to objects with the same serial number.
     29       This is important for stereo setups in which the telescopes have
     30       cameras with different numbers of pixels. If the MGeomApply task
     31       has serial number 0 (default), it will apply the geometry to all
     32       found objects as it used to do.
     33
     34   * manalysis/MMcCalibrationUpdate.cc, mpedestal/MMcPedestalCopy.cc
     35     - Now the PreProcess adds the serial number also to MRawRunHeader
     36       and MMcRunHeader, since in stereo MC files produced with the
     37       current camera simulation at CVS there is one such container per
     38       telescope. There is no difference in behaviour for single
     39       telescope files. Old MC stereo files will no longer be readable.
     40
     41   * mimage/MNewImagePar.cc
     42     - Made calculation of "Inner size" valid also for camera geometries
     43       other than MAGIC standard one. The calculation of "inner leakage"
     44       is now made only for MAGIC standard geometry (there is no easy
     45       fix for that, but having fInnerSize and MHillas.fSize, the inner
     46       leakage is a completely unnecessary parameter). Added a comment on
     47       a possible fix for the calculation of fConc.
     48
     49   * mcalib/MMcCalibrationCalc.[h,cc]
     50     - Added member fMinSize and setter for it. It is the minimum
     51       (uncalibrated) size of events to be used in the calibration.
     52       Previously it was fixed at 1000 ADC counts, but the value depends
     53       on the extractor used, so it must be possible to change it.
     54     - Add the serial number to MRawRunHeader and MMcConfigRunHeader
     55       (now there is one per telescope in stereo files).
     56     - Moved the creation of histograms from the constructor to the
     57       PreProcess, otherwise the serial number is not added to the
     58       histogram name.
     59     - In PostProcess, set the average QE for area 0 (inner pixels) in
     60       MCalibrationQECam object, to be used later by MCalibrateData.
     61   
     62   * macros/starmcstereo.C
     63     - Big update. Adapted to all changes above. Now not only relative, but
     64       also absolute calibration (=SIZE in phes) is made.
     65
     66
     67
     68 2005/07/13 Raquel de los Reyes (2005/07/12)
     69
     70   * merpp.cc
     71     - Added the container MCameraActiveLoad to the rootified central
     72       control files
     73
     74   * mreport/MReportCC.[h,cc]
     75     - Changes in the InterpreteBody to write the variable UPS status and
     76       the Time difference between GPS and rubidium clock.
     77
     78  * mreport/MReportCamera.cc
     79     - Changes in the InterpreteCamera and InterpreteBody functions to allow
     80       the data merpping from 2005_06_30.
     81
     82
     83
     84 2005/07/13 Abelardo Moralejo (2005/07/12)
     85
     86   * macros/starmcstereo.C
     87     - Fixed error which made some objects to be written twice in the
     88       _test_ output file.
     89
     90
     91
     92 2005/07/13 Patricia Liebing (2005/07/06)
     93
     94   * mhcalib/MHCalibrationChargeCam.cc:
     95    - include new flag (kLoGainBlackout) into the "uncalibrated"
     96      pixel classification (see docu from 28/06/2005 Markus Gaug)
     97
     98   * mbadpixels/MBadPixelsPix.[cc.h], mcalib/MCalibrationChargeCalc.cc
     99     - included flag kLoGainBlackout for unsuitable pixels w/
     100       corresponding docu/printout (see MHCalibrationChargeCam.cc)
     101 
     102   * mhcalib/MHCalibrationPulseTimeCam.cc, MHCalibrationCam.cc
     103     - add Pixel ID to Debug printout statements
     104
     105   * mjobs/MJCalibration.cc
     106     - include new display for kLoGainBlackout unsuitable pixels
     107
     108
     109
     110 2005/07/13 Antonio Stamerra (2005/07/04)
     111
     112   * manalysis/MMcTriggerLvl2Calc.cc
     113     - the checks written on ReInit for MC have been moved to PreProcess()
     114     - kFALSE substituted with kSKIP in the check for the standard MAGIC
     115       geometry
     116
     117
     118
     119 2005/07/13 Abelardo Moralejo (2005/07/01)
     120
     121   * macros/starmc.C
     122     - Set two different cleaning tasks for the calibration loop and
     123       for the second (analysis) loop. Otherwise, some pixels were
     124       cleaned out in the first loop (we do not want this) if the
     125       absolute method was chosen.
     126
     127
     128
     129 2005/07/13 Abelardo Moralejo (2005/06/30)
     130
     131   * mmc/MTriggerDefine.h
     132     - Added TRIGGER_PIXELS_4, a provisional number of trigger pixels
     133       for the MGeomCamMagic1183 geometry.
     134
     135   * mgeom/MGeomCamMagic1183.[h,cc]
     136     - added. Possible design for a MAGIC-II camera. Preliminary
     137       version, not yet ready to use.
     138
     139
     140
     141 2005/07/13 Abelardo Moralejo (2005/06/29)
     142
     143   * mgeom/MGeomCamMagic1183.[h,cc]
     144     - added. Possible design for a MAGIC-II camera
     145
     146   * mgeom/Makefile, GeomLinkDef.h
     147     - added new class above.
     148
     149
     150
     151 2005/07/13 Markus Gaug (2005/06/28)
     152
     153   * mhcalib/MHCalibrationChargeCam.[h,cc]
     154     - set the fPickupLimit and fBlackoutLimit for the low-gain arrays
     155       to a 3.5 instead of the default used in MHCalibrationPix (5.0).
     156     - use a new criterium to exclude bad pixels: If the high-gain was
     157       saturated and the blackout-events in the low-gain exceed the
     158       fNumLoGainBlackoutLimit, the pixel is declared unsuitable.
     159       This excludes those pixels which have a saturating high-gain
     160       channel, but the low-gain switch does not switch often enough
     161       to make the distribution reliable.
     162
     163
     164
     165 2005/07/13 Markus Gaug (2005/06/23)
     166
     167   * mhcalib/MHCalibrationChargeCam.cc
     168     - fix a bug counting the number of saturated events. Up to now, the
     169       number of saturated slices was counted (which is one for a not too
     170       high number), but for some (pathological) pixels, many more slices
     171       saturated and produced wrong limits.
     172     - make the PickupLimit und BlackoutLimit for the low-gain explicitely
     173       smaller. The too large limits caused a failed fit for some channels
     174       which resulted in wrong calibration constants. (M. Gaug)
     175
     176
     177
     178 2005/07/13 Markus Gaug (2005/06/22)
     179
     180   * mjobs/MJPedestal.cc
     181     - change order of reading local environmnet variables in lines 1044
     182       to 1068. Reason: The lines:
     183            if (fExtractor==tenv.GetTask())
     184               return kTRUE;
     185       yielded sometimes a return before the rest of the env-variables
     186       could be read in. This affected ONLY the reading of the pedestal
     187       reference file and the bad pixels file name. (M. Gaug)
     188     - Added "decode" task (MTriggerPatternDecode) task to the list also
     189       for MC runs.
     190
     191   * mhcalib/MHCalibrationChargeCam.cc
     192     - fixed the setting of unreliability for saturated events where the
     193       high-gain signal was not stable over time. Now, saturation is
     194       asked for before (like in the high-gain fitted-case). (M. Gaug)
     195     - fixed a small bug in the precise setting of the histogram ranges.
     196       May have introduced a bias of typically 1 FADC cnt in the mean
     197       fitted signal (< 0.5%).
     198
     199   * mbadpixels/MBadPixelsPix.[h,cc]
     200     - took out the un-used bad pixels information in function:
     201       GetUnsuitableCalLevel().
     202     - debugged the class-documentation
     203
     204   * mcalib/MCalibrationIntensityChargeCam.cc
     205     - a very small fix in the axis title from N_phe to N_{phe}
     206     - fixed one bug in the draw-functions of this class. Not (yet) used by
     207       standard calibration.
     208     - +some undocumented changes
     209
     210  * mjobs/MJCalibration.cc
     211    - changed order in tasklist between MCalibColorSet and
     212      MPedCalcFromPedRun. Caused crashes in the intensity calibrations.
     213      Does not affect ordinary calibration since MPedCalcFromPedRun is
     214      then not in the tasklist anyhow.
     215    - changed order of MHCalibrationChargeCam and MCalibrationRelTimeCalc.
     216      This wrong order caused MCalibrationRelTimeCalc to print out
     217      unreliable pixels which were not set by the rel. time calibration.
     218      This caused some confusion in the reading of the output because of
     219      the un-logical order of flag settings and posterior output.
     220    - set the error of the hi-logain intercalibration constants
     221      as the real error on the mean instead of the sigma.
     222    - took out the those bad pixel-informations which are not used
     223      any more in the "Defect" - display. (M. Gaug)
     224
     225
     226
     227 2005/07/13 Markus Gaug (2005/06/21)
     228
     229   * mhcalib/MHCalibrationChargePix.h
     230     - take out one un-necessary 'virtual'-declaration for the Draw-
     231       function
     232
     233   * mhcalib/MHGausEvents.cc
     234     - fixed a small bug in the non-standard display with options.
     235
     236
     237
     238 2005/07/13 Markus Gaug (2005/06/19)
     239
     240   * msignal/MExtractTimeAndChargeSpline.cc
     241     - set fgOffsetLoGain from 1.7 to 1.39. This is the correct time
     242       shift between high-gain and low-gain. Affects only very detailed
     243       timing studies.
     244
     245   * msignal/MExtractTimeAndChargeDigitalFilter.cc
     246     - set fOffsetLoGain from 1.7 to 1.4 which corrects now exactly for
     247       the arrival time difference between low-gain and high-gain pulses.
     248       This wrong number could have had some effect on image cleanings
     249       using the time information. (M. Gaug)
     250 
     251   * mcalib/MCalibrationBlindCam.[h,cc]
     252     - remove obsolete Copy-function
     253
     254   * mcalib/MCalibConstPix.h, mcalib/MCalibConstCam.h
     255     - introduce Copy-functions
     256     - set class index to 1 (was 0)
     257
     258   * mcalib/MCalibrationChargePix.[h,cc]
     259     - introduce Copy() function.
     260
     261
     262
     263 2005/07/13 Markus Gaug (2005/06/18)
     264
     265   * mpedestal/MPedestalCam.cc
     266     - modify Print() function to print out also the event-by-event
     267       averaged results.
     268
     269   * mpedestal/MExtractPedestal.[h,cc]
     270     - new flag fUseSpecialPixels (set to kFALSE per default)
     271     - new data member: fNameRawEvtData which can be set from outside
     272       (e.g. to "MRawEvtData2").
     273     - with these two changes, the special pixels can be extracted.
     274       Difference to previous version: if flag fUseSpecialPixels is set,
     275       * the area and sector averages are not calculated.
     276       * the MPedestalCam will get initialized to
     277         MRawRunHeader->GetNumSpecialPixels().
     278     - fix a bug in the calculation of the event-by-event averaged
     279       pedestal RMS (one total number of areas or sectors was not taken
     280       into account).
     281     - make local variables in the calculation of rms and mean doubles
     282       instead of floats.
     283
     284   * mpedestal/MPedCalcPedRun.cc
     285     - do not calculate the area and sector averages in case flag
     286       fUseSpecialPixels is set.
     287     - check for existence of pointer fRawEvt in PostProcess.
     288
     289
     290
     291 2005/07/13 Markus Gaug (2005/06/15)
     292
     293   * mcalib/MCalibrationIntensityConstCam.[h,cc]
     294     - new class to store the actual applied conversion factors (now with
     295       averaged photo-electrons not in the MCalibrationIntensityChargeCam
     296       any more).
     297
     298   * mjobs/MJCalibration.cc
     299     - set the correct (statistical) error of the inter-calibraiton factor
     300       into MCalibrationChargePix::SetConversionHiLoErr() and the
     301       sigma of the distribution
     302       into MCalibrationChargePix::SetConversionHiLoSigma().
     303     - In MCalibrationChargePix, the mean conversion error is used for the
     304       statistical error of the conversion factor.
     305     - In CalibrateData, the sigma is used for the statistical error of the
     306       converted signal to equiv. high-gain charges.
     307
     308
     309 2005/07/13 Markus Gaug (2005/06/14)
     310
     311   * mcalib/MCalibrationHiLoPix.[h,cc]
     312     - store also results from profile fits.
     313     - increades class version
     314
     315   * mhcalib/MHCalibrationHiLoPix.[h,cc], mhcalib/MHCalibrationHiLoCam.[h,cc]
     316    - added TProfiles for every pixel filled with the high-gain signal
     317      vs. low-gain signal which can be fitted to extract gain and
     318      offset.
     319
     320   * mhcalib/Makefile, mhcalib/HCalibLinkDef.h
     321     - added MHCalibrationHiLoPix
     322
     323
     324
     325 2005/07/13 Markus Gaug (2005/06/10)
     326
     327   * mcalib/MCalibrationRelTimeCalc.cc
     328     - print out forgotten successfully calibrated pixels
     329     - small change in spacing of one output
     330
     331   * mhcalib/MHCalibrationCam.[h,cc]
     332     - introduce max. number of events, the rest gets skipped before the
     333       next ReInit() is called. Default: 4096
     334       Reason: The calibration causes too many un-reliable pixels if more
     335               than about 5000 events are treated (@500 Hz) because of the
     336               mode hopping of the VCSels. However, in the past, some
     337               calibration runs have been taken (erroneously) with more
     338               than 5000 events, especially the intensity scans where 
     339               a good precision is needed.
     340    - increased version number
     341    - introduce a Getter for the fAverageAreaNum array.
     342    - re-normalize the area-averaged sigmas to the equivalent number per
     343      pixel also for the intensity calibration.
     344
     345   * mcalib/MCalibrationChargePix.[h,cc]
     346    - divide errors in stat. and syst. errors. Both can be retrieved
     347      now, depending on the study, one wants to make.
     348
     349
     350
     351 2005/07/13 Markus Gaug (2005/06/06)
     352
     353   * mhcalib/MHGausEvents.[h,cc]
     354     - put small functions into header file to speed up calculations a bit.
     355
     356   * mcalib/MCalibrationRelTimeCalc.cc
     357     - introduce flags to steer the setting of unreliability like done
     358       in MCalibrationChargeCalc. Can be steered from the conf-file.
     359
     360
     361
     362 2005/07/13 Thomas Bretz
     363
     364   * mbase/MTaskInteractive.[h,cc]:
     365     - fixed a bug with calling ReInit... PostProcess was called instead.
     366     - added the missing initialisation of fReInit in constructor
     367
     368   * sinope.cc:
     369     - removed plotting the tasklist statistics twice
     370     - replaced DrawClone by DrawCopy (DrawClone gave problems)
     371
     372   * mhflux/MAlphaFitter.[h,cc]:
     373     - fixed the ThetaSq function. It was wrongly defined as
     374       exp(-((x-c)/s)^2) instead of exp(-1/2*((x-c)/s))
     375     - Set start value for corresponding fit back to same value
     376       as for a standard gauss-fit.
     377
     378
    23379
    24380 2005/07/12 Daniela Dorner
  • trunk/MagicSoft/Mars/NEWS

    r7180 r7188  
    3333   - callisto: MCalibrationHiLoCam can now be printed from its context
    3434     menu, eg in the TBrowser
     35
     36   - callisto: fixed logain offset (fgOffsetLoGain) from 1.7 to
     37       - 1.39 (MExtractTimeAndChargeSpline)
     38       - 1.40 (MExtractTimeAndChargeDigitalFilter)
     39     This is important mainly for timing studies.
     40
     41   - callisto: Changed limits in MHCalibrationChargeCalc from
     42       - -100.125 to -98   (fgChargeHiGainFirst)
     43       - 1899.875 to 1902. (fgChargeHiGainLast)
     44       - -100.25  to -99   (fgChargeLoGainFirst)
     45       - 899.75   to 901.  (fgChargeLoGainLast)
     46     Introduced new limits:
     47       - fgNumLoGainBlackoutLimit: 0.05
     48       - fgLoGainBlackoutLimit: 3.5
     49       - fgLoGainPickupLimit: 3.5
     50
     51   - callisto: use a new criterium to exclude bad pixels: If the high-gain
     52     was saturated and the blackout-events in the low-gain exceed the
     53     fNumLoGainBlackoutLimit, the pixel is declared unsuitable.
     54     This excludes those pixels which have a saturating high-gain
     55     channel, but the low-gain switch does not switch often enough
     56     to make the distribution reliable.
     57
     58   - callisto: fix a bug counting the number of saturated events. Up to now,
     59     the number of saturated slices was counted (which is one for a not too
     60     high number), but for some (pathological) pixels, many more slices
     61     saturated and produced wrong limits.
     62
     63   - callisto: New options in in callisto.rc for MCalibrationRelTimeCalc:
     64     + MCalibrationRelTimeCam.CheckFitResults: Yes
     65     + MCalibrationRelTimeCam.CheckDeviatingBehavior: Yes
     66     + MCalibrationRelTimeCam.CheckHistOverflow: Yes
     67     + MCalibrationRelTimeCam.CheckOscillations: Yes
     68
     69   - callisto: introduce max. number of events for intercalibration,
     70     the rest gets skipped. Default: 4096
     71     The calibration causes too many un-reliable pixels if more
     72     than about 5000 events are treated (@500 Hz) because of the
     73     mode hopping of the VCSels. However, in the past, some
     74     calibration runs have been taken (erroneously) with more
     75     than 5000 events, especially the intensity scans where 
     76     a good precision is needed.
    3577
    3678   - star: fixed a bug which caused MEffectiveOnTime containers not to
  • trunk/MagicSoft/Mars/callisto.rc

    r7130 r7188  
    237237# Use this to change the behaviour of the calibration
    238238# -------------------------------------------------------------------------
    239 # Type if you set a colour explicitely from outside (only for MC!!!)
     239# Type if you set a colour explicitely from outside (TEST purposes!!)
    240240#MJCalibration.MCalibColorSet.ExplicitColor: green,blue,uv,ct1
    241241
     
    258258#MJCalibration.MHCalibrationChargeCam.Averageing:   yes
    259259#MJCalibration.MHCalibrationChargeCam.HiGainNbins:  500
    260 #MJCalibration.MHCalibrationChargeCam.HiGainFirst:  -100.125
    261 #MJCalibration.MHCalibrationChargeCam.HiGainLast:   1899.875
     260#MJCalibration.MHCalibrationChargeCam.HiGainFirst:  -98.
     261#MJCalibration.MHCalibrationChargeCam.HiGainLast:   1902.
    262262#MJCalibration.MHCalibrationChargeCam.LoGainNbins:   500
    263 #MJCalibration.MHCalibrationChargeCam.LoGainFirst:  -100.25
    264 #MJCalibration.MHCalibrationChargeCam.LoGainLast:   899.75
     263#MJCalibration.MHCalibrationChargeCam.LoGainFirst:  -99.
     264#MJCalibration.MHCalibrationChargeCam.LoGainLast:   901.
    265265#MJCalibration.MHCalibrationChargeCam.TimeLowerLimit: 1.
    266266#MJCalibration.MHCalibrationChargeCam.TimeUpperLimit: 3.
     
    270270#MJCalibration.MHCalibrationChargeCam.OverflowLimit: 0.005
    271271#MJCalibration.MHCalibrationChargeCam.PulserFrequency: 500
     272
    272273
    273274#MJCalibration.MHCalibrationRelTimeCam.Debug:        no
     
    392393# Type of used data format: raw,root,MC
    393394#MJCalibrateSignal.DataType: Root
    394 # Type if you set a colour explicitely from outside (only for MC!!!)
     395# Type if you set a colour explicitely from outside (only TESTS!!!)
    395396#MJCalibrateSignal.MCalibColorSet.ExpicitColor: green,blue,uv,ct1
    396397#MJCalibrateSignal.MCalibrateData.PedestalFlag: Event
     
    426427#MJCalibrateSignal.MHCalibrationChargeCam.Averageing:   yes
    427428#MJCalibrateSignal.MHCalibrationChargeCam.HiGainNbins:  500
    428 #MJCalibrateSignal.MHCalibrationChargeCam.HiGainFirst:  -100.5
     429#MJCalibrateSignal.MHCalibrationChargeCam.HiGainFirst:  -98.
     430#MJCalibrateSignal.MHCalibrationChargeCam.HiGainLast:   1902.
    429431#MJCalibrateSignal.MHCalibrationChargeCam.HiGainLast:   1899.5
    430432MJCalibrateSignal.MHCalibrationChargeCam.LoGainNbins:   250
    431 #MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:  -100.5
    432 #MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:   899.5
     433#MJCalibrateSignal.MHCalibrationChargeCam.LoGainFirst:  -99.
     434#MJCalibrateSignal.MHCalibrationChargeCam.LoGainLast:   901.
    433435#MJCalibrateSignal.MHCalibrationChargeCam.TimeLowerLimit: 1.
    434436#MJCalibrateSignal.MHCalibrationChargeCam.TimeUpperLimit: 3.
  • trunk/MagicSoft/Mars/macros/starmc.C

    r7005 r7188  
    5252  // differences in gain of outer pixels)
    5353  //
    54   CalibrationFilename = new TString("/data1/magic/mc_data/root/Period025/gammas_nonoise/Gamma_zbin0_*.root");
     54  CalibrationFilename = new TString("nonoise/Gamma_zbin0_0_7_1000to1009_w0.root");
    5555  // File to be used in the calibration (must be a camera file without added noise)
    5656
    57 
    58   Char_t* AnalysisFilename = "Gamma_zbin1_0_*.root";  // File to be analyzed
    59 
     57  Char_t* AnalysisFilename = "Gamma_zbin0_0_*.root";  // File to be analyzed
    6058
    6159
     
    7674  // USER CHANGE: tail cuts for image analysis
    7775
    78   Float_t CleanLev[2] = {7., 5.};
    79   MImgCleanStd  clean(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
    80   clean.SetMethod(MImgCleanStd::kAbsolute);      // In absolute units (phot or phe- as chosen below)
    81 
     76  Float_t CleanLev[2] = {10., 5.}; // Tail cuts for the analysis loop
     77  MImgCleanStd clean2(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
     78  clean2.SetMethod(MImgCleanStd::kAbsolute);
    8279
    8380  //  USER CHANGE: signal extraction
    84   //
    85   //  MExtractFixedWindowPeakSearch sigextract;
    86   //  sigextract.SetWindows(6, 6, 4);
    8781
    8882  //  MExtractTimeAndChargeDigitalFilter sigextract;
     
    9185
    9286  MExtractTimeAndChargeSpline sigextract;
     87  sigextract.SetChargeType(MExtractTimeAndChargeSpline::kIntegral);
    9388  sigextract.SetRiseTimeHiGain(0.5);
    9489  sigextract.SetFallTimeHiGain(0.5);
     
    9691  // USER CHANGE: high to low gain ratio. DEPENDS on EXTRACTOR!!
    9792  // One should calculate somewhere else what this factor is for each extractor!
    98   Float_t hi2low = 12.; // tentative value for spline with risetime 0.5, fall time 0.5
     93
     94  //  Float_t hi2low = 10.83;
     95  // value for digital filter, HG window 4, LG window 6
     96
     97  Float_t hi2low = 11.28;
     98  // value for spline with risetime 0.5, fall time 0.5, low gain stretch 1.5
    9999
    100100
     
    108108
    109109
     110  MImgCleanStd  clean(0.,0.);
     111  // All pixels containing any photon will be accepted. This is what we want
     112  // for the calibration loop (since no noise is added)
     113  clean.SetMethod(MImgCleanStd::kAbsolute);
     114  // In absolute units (phot or phe- as chosen below)
     115
    110116  MSrcPosCam src;
    111117  //
    112   // ONLY FOR WOBBLE MODE!!
    113   //   src.SetX(120.);  // units: mm
     118  // ONLY FOR WOBBLE MODE!! : set the rigt source position on camera!
     119  //   src.SetX(120.);   // units: mm. Value for MC w+ files
     120  //   src.SetX(-120.);  // units: mm. Value for MC w- files
    114121
    115122  src.SetReadyToSave();
     
    244251  //
    245252
     253
    246254  MProgressBar bar;
    247255  bar.SetWindowName("Calibrating...");
     
    273281  tlist.RemoveFromList(&read);
    274282
     283  tlist.AddToListBefore(&clean2, &clean);
     284  tlist.RemoveFromList(&clean);
     285
    275286  //
    276287  // Analyzed only the desired fraction of events, skip the rest:
  • trunk/MagicSoft/Mars/macros/starmcstereo.C

    r3439 r7188  
    1717!
    1818!   Author(s):  Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
    19 !               Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    2019!
    2120!   Copyright: MAGIC Software Development, 2000-2004
     
    3332/////////////////////////////////////////////////////////////////////////////
    3433
    35 //
    36 // User change.
    37 //
    38 
    39 Float_t ctx[7] = {0., 0., 0., 0., 0., 0., 0.};
    40 Float_t cty[7] = {-70., -40., -30., 30., 50., 60., 70.}; // in meters
    41 //
    42 // FIXME: unfortunately present version of reflector was not prepared for
    43 // stereo configurations and keeps no track of CT position. So the positions
    44 // must be set above by the user, making sure that they correspond to the
    45 // files one is analysing.
    46 //
    47 
    48 void starmcstereo(Int_t ct1 = 2, Int_t ct2 = 5)
     34void starmcstereo(Int_t ct1 = 1, Int_t ct2 = 2)
    4935{
    50   if (ct1 > sizeof(ctx)/sizeof(ctx[0]) ||
    51       ct2 > sizeof(ctx)/sizeof(ctx[0]) )
    52     {
    53       cout << endl << "Wrong CT id number!" << endl;
     36  // ------------- user change -----------------
     37
     38  TString* CalibrationFilename = 0;
     39
     40  // Calibration file: a file with no added noise. Comment out next line if you
     41  // do not want to calibrate the data (means SIZE will be in ADC counts)
     42
     43  CalibrationFilename = new TString("nonoise/Gamma_20_0_7_200000to200009_XX_w0.root");
     44
     45  Char_t* AnalysisFilename = "Gamma_20_0_7_*_XX_w0.root";  // File to be analyzed
     46  Char_t* OutFileTag      = "gammas";           // Output file tag
     47
     48  // First open input files to check that the required telescopes
     49  // are in the file, and get telescope coordinates.
     50
     51  TChain *rh = new TChain("RunHeaders");
     52  rh->Add(AnalysisFilename);
     53  MMcCorsikaRunHeader *corsrh = new MMcCorsikaRunHeader();
     54  rh->SetBranchAddress("MMcCorsikaRunHeader.", &corsrh);
     55  rh->GetEvent(0);
     56  // We assume that all the read files will have the same telescopes inside,
     57  // so we look only into the first runheader.
     58  Int_t allcts = corsrh->GetNumCT();
     59  if (ct1 >  allcts || ct2 >  allcts)
     60    {
     61      cout << endl << "Wrong CT id number, not contained in input file!" << endl;
    5462      return;
    5563    }
     64  // Set telescope coordinates as read from first runheader:
     65  Float_t ctx[2];
     66  Float_t cty[2];
     67  ctx[0] = ((*corsrh)[ct1-1])->GetCTx();
     68  cty[0] = ((*corsrh)[ct1-1])->GetCTy();
     69  ctx[1] = ((*corsrh)[ct2-1])->GetCTx();
     70  cty[1] = ((*corsrh)[ct2-1])->GetCTy();
     71
     72  // Now find out number of pixels in each camera:
     73  MMcConfigRunHeader* confrh1 = new MMcConfigRunHeader();
     74  MMcConfigRunHeader* confrh2 = new MMcConfigRunHeader();
     75  rh->SetBranchAddress("MMcConfigRunHeader;1.", &confrh1);
     76  rh->SetBranchAddress("MMcConfigRunHeader;2.", &confrh2);
     77  rh->GetEvent(0);
     78  Int_t npix[2];
     79  npix[0] = confrh1->GetNumPMTs();
     80  npix[1] = confrh2->GetNumPMTs();
     81
     82  rh->Delete();
     83
    5684
    5785  Int_t CT[2] = {ct1, ct2};  // Only 2-telescope analysis for the moment
    58   Int_t NCTs = sizeof(CT)/sizeof(CT[0]);
     86  Int_t NCTs = 2;
    5987
    6088
    6189  // ------------- user change -----------------
    6290
    63   Char_t* AnalysisFilename = "gam-yXX-00001.root";  // File to be analyzed
    64   Char_t* OutFileTag      = "gammas";           // Output file tag
    65 
    66   Float_t CleanLev[2] = {4., 3.}; // Tail cuts for image analysis
    67 
    68   Int_t BinsHigh[2] = {5, 9}; // First and last FADC bin of the range to be integrated,
    69   Int_t BinsLow[2]  = {5, 9}; // for high and low gain respectively.
     91  Float_t BinsHigh[2] = {0, 79};
     92  Float_t BinsLow[2]  = {0, 79};  // FADC slices (2GHz sampling)
     93  Float_t CleanLev[2] = {7., 5.}; // Units: phes (absolute cleaning will be used later!)
     94  // Tail cuts for the analysis loop. In the first (calibration) loop they will not
     95  // be used; we run over a noiseless file and we want to accept all pixels with any
     96  // number of phes.
     97
     98
     99  MImgCleanStd**     clean = new MImgCleanStd*[NCTs]; 
     100
     101  MImgCleanStd* clean[0] = new MImgCleanStd(1.,1.);
     102  MImgCleanStd* clean[1] = new MImgCleanStd(1.,1.);
     103  // Just dummy levels. Since the calibration file will be a noiseless file, RMS of
     104  // pedestal will be 0, and all events will be accepted, regardless of the cleaning level.
     105  // For some reason the above lines do not work if made on a loop! (???)
     106  clean[0]->SetSerialNumber(CT[0]);
     107  clean[1]->SetSerialNumber(CT[1]);
     108
     109  MExtractTimeAndChargeSpline* sigextract = new MExtractTimeAndChargeSpline[NCTs];
     110  MMcCalibrationUpdate*  mccalibupdate = new MMcCalibrationUpdate[NCTs];
     111  MCalibrateData* calib = new MCalibrateData[NCTs];
     112  MMcCalibrationCalc* mccalibcalc = new MMcCalibrationCalc[NCTs];
    70113
    71114  // -------------------------------------------
    72 
    73   //
    74   // This is a demonstration program which calculates the image
    75   // parameters from a Magic Monte Carlo root file. Units of Size are
    76   // for the moment, FADC counts.
    77   //
    78   //
    79115  // Create a empty Parameter List and an empty Task List
    80116  // The tasklist is identified in the eventloop by its name
    81117  //
    82118  MParList  plist;
    83 
    84119  MTaskList tlist;
    85 
    86120  plist.AddToList(&tlist);
    87121
     
    89123  MBadPixelsCam badpix[NCTs];
    90124
    91   for (Int_t ict = 0; ict < NCTs; ict++)
     125  Float_t hi2lowratio = 10.0;
     126
     127  for (Int_t i = 0; i < NCTs; i++)
    92128    {
    93129      TString s = "MSrcPosCam;";
    94       s += CT[ict];
    95       src[ict].SetName(s);
    96       src[ict].SetReadyToSave();
    97       plist.AddToList(&(src[ict]));
     130      s += CT[i];
     131      src[i].SetName(s);
     132      src[i].SetReadyToSave();
     133      plist.AddToList(&(src[i]));
    98134
    99135      TString b = "MBadPixelsCam;";
    100       b += CT[ict];
    101       badpix[ict].SetName(b);
    102       badpix[ict].SetReadyToSave();
    103       plist.AddToList(&(badpix[ict]));
    104     }
     136      b += CT[i];
     137      badpix[i].SetName(b);
     138      badpix[i].InitSize(npix[i]);
     139      badpix[i].SetReadyToSave();
     140      plist.AddToList(&(badpix[i]));
     141
     142      sigextract[i].SetSerialNumber(CT[i]);
     143      sigextract[i].SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
     144      sigextract[i].SetRiseTimeHiGain(0.5);
     145      sigextract[i].SetFallTimeHiGain(0.5);
     146      sigextract[i].SetLoGainStretch(1.);
     147
     148      mccalibupdate[i].SetSerialNumber(CT[i]);
     149      mccalibupdate[i].SetUserLow2HiGainFactor(hi2lowratio);
     150      mccalibupdate[i].SetSignalType(MCalibrateData::kPhe);
     151
     152      calib[i].SetSerialNumber(CT[i]);
     153      calib[i].SetCalibConvMinLimit(0.);
     154      calib[i].SetCalibConvMaxLimit(100.); // Override limits for real data 
     155      calib[i].SetCalibrationMode(MCalibrateData::kFfactor);
     156      // Do not change CalibrationMode (just indicates where the cal. constants will be stored)
     157      calib[i].SetSignalType(mccalibupdate[i].GetSignalType());
     158
     159      mccalibcalc[i].SetSerialNumber(CT[i]);
     160      mccalibcalc[i].SetMinSize(200);
     161      // Minimum SIZE for an event to be used in the calculation of calibration constants.
     162      // Units are ADC counts, and value depends on signal extractor!
     163    }
     164
     165
    105166  //
    106167  // Now setup the tasks and tasklist:
     
    110171  read.DisableAutoScheme();
    111172
    112   read.AddFile(AnalysisFilename);
     173  if (CalibrationFilename)
     174    read.AddFile(CalibrationFilename->Data());
     175
    113176
    114177  MGeomApply*        apply = new MGeomApply[NCTs];
    115 
    116178  MMcPedestalCopy*   pcopy = new MMcPedestalCopy[NCTs];
    117 
    118   MExtractSignal*      sigextract = new MExtractSignal[NCTs];
    119 
    120   MMcCalibrationUpdate*  mccalibupdate = new MMcCalibrationUpdate[NCTs];
    121   MCalibrate* calib = new MCalibrate[NCTs];
    122 
    123   MImgCleanStd**     clean = new MImgCleanStd*[NCTs];
    124 
    125179  MHillasCalc*       hcalc = new MHillasCalc[NCTs];
    126   MHillasSrcCalc*    scalc = new MHillasSrcCalc[NCTs];
    127180
    128181  TString outfile = "star_";
    129182  outfile += CT[0];
    130   if (NCTs==2)
    131     {
    132       outfile += "_";
    133       outfile += CT[1];
    134     }
     183  outfile += "_";
     184  outfile += CT[1];
    135185
    136186  //
     
    144194  outfile = "star_";
    145195  outfile += CT[0];
    146   if (NCTs==2)
    147     {
    148       outfile += "_";
    149       outfile += CT[1];
    150     }
     196  outfile += "_";
     197  outfile += CT[1];
    151198
    152199  outfile += "_";
     
    159206    {
    160207      apply[i]->SetSerialNumber(CT[i]);
    161 
    162208      pcopy[i]->SetSerialNumber(CT[i]);
    163209
    164       sigextract[i]->SetSerialNumber(CT[i]);
    165       sigextract[i].SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
    166 
    167       mccalibupdate[i]->SetSerialNumber(CT[i]);
    168       calib[i]->SetSerialNumber(CT[i]);
    169 
    170       clean[i] = new MImgCleanStd(CleanLev[0], CleanLev[1]);
    171       clean[i]->SetSerialNumber(CT[i]);
    172 
    173210      hcalc[i]->SetSerialNumber(CT[i]);
    174       scalc[i]->SetSerialNumber(CT[i]);
     211      hcalc[i].Disable(MHillasCalc::kCalcHillasSrc);
     212      // Source-dependent parameters not needed in the first loop (calibration)
    175213
    176214      write1.SetSerialNumber(CT[i]);
    177215      write2.SetSerialNumber(CT[i]);
    178216
    179       write1.AddContainer(write1.AddSerialNumber("MMcEvt"),       "Events");
    180       write1.AddContainer(write1.AddSerialNumber("MHillas"),      "Events");
    181       write1.AddContainer(write1.AddSerialNumber("MHillasExt"),   "Events");
    182       write1.AddContainer(write1.AddSerialNumber("MHillasSrc"),   "Events");
    183       write1.AddContainer(write1.AddSerialNumber("MNewImagePar"), "Events");
    184       write1.AddContainer(write1.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
    185       write2.AddContainer(write2.AddSerialNumber("MMcEvt"),       "Events");
    186       write2.AddContainer(write2.AddSerialNumber("MHillas"),      "Events");
    187       write2.AddContainer(write2.AddSerialNumber("MHillasExt"),   "Events");
    188       write2.AddContainer(write2.AddSerialNumber("MHillasSrc"),   "Events");
    189       write2.AddContainer(write2.AddSerialNumber("MNewImagePar"), "Events");
    190       write2.AddContainer(write2.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
    191     }
    192 
    193   if (NCTs==2)
    194     {
    195       write1.AddContainer("MStereoPar", "Events");
    196       write2.AddContainer("MStereoPar", "Events");
    197     }
     217      write1.AddContainer("MMcEvt",       "Events");
     218      write1.AddContainer("MHillas",      "Events");
     219      write1.AddContainer("MHillasExt",   "Events");
     220      write1.AddContainer("MHillasSrc",   "Events");
     221      write1.AddContainer("MNewImagePar", "Events");
     222      write1.AddContainer("MSrcPosCam",   "Events");
     223      write2.AddContainer("MMcEvt",       "Events");
     224      write2.AddContainer("MHillas",      "Events");
     225      write2.AddContainer("MHillasExt",   "Events");
     226      write2.AddContainer("MHillasSrc",   "Events");
     227      write2.AddContainer("MNewImagePar", "Events");
     228      write2.AddContainer("MSrcPosCam",   "Events");
     229    }
     230
     231  MStereoPar* mstereo = new MStereoPar;
     232  plist.AddToList(mstereo);
     233
     234  write1.AddContainer(mstereo, "Events");
     235  write2.AddContainer(mstereo, "Events");
     236  // We use MWriteRootFile::AddContainer(MParContainer* ,...) instead
     237  // of using the container name as above, because in the former case the
     238  // serial number tag (indicating the telescope id) is added to the
     239  // container name, which is fine for containers of which there is one
     240  // per telescope. However, the container MStereoPar is unique, since it
     241  // is filled with information coming from both telescopes.
    198242
    199243  write1.AddContainer("MRawRunHeader", "RunHeaders");
     
    204248
    205249  tlist.AddToList(&read);
     250
     251  // Skip untriggered events (now camera simulation output contains by default all simulated events)
     252  MContinue* trigger = new MContinue("(MMcTrig;1.fNumFirstLevel<1) && (MMcTrig;2.fNumFirstLevel<1)","Events");
     253  tlist.AddToList(trigger);
    206254
    207255  for (i = 0; i < NCTs; i++)
     
    214262      tlist.AddToList(clean[i]);
    215263      tlist.AddToList(&(hcalc[i]));
    216       tlist.AddToList(&(scalc[i]));
    217     }
    218 
     264      tlist.AddToList(&(mccalibcalc[i]));
     265    }
     266
     267
     268  MF filter1("{MMcEvt;1.fEvtNumber%2}<0.5");
     269  MF filter2("{MMcEvt;1.fEvtNumber%2}>0.5");
     270  //
     271  // ^^^^ Filters to divide output in two: test and train samples.
     272  //
     273  write1.SetFilter (&filter1);
     274  write2.SetFilter (&filter2);
     275
     276  //
     277  // Create and set up the eventloop
     278  //
     279  MProgressBar bar;
     280  bar.SetWindowName("Calibrating");
     281
     282  MEvtLoop evtloop;
     283  evtloop.SetProgressBar(&bar);
     284  evtloop.SetParList(&plist);
     285
     286  //
     287  // First loop: calibration loop. Go over MC events simulated with
     288  // no noise, to correlate SIZE with the number of phes and get the
     289  // conversion factor (this is done by MMcCalibrationCalc).
     290  //
     291  if (CalibrationFilename)
     292    {
     293      if (!evtloop.Eventloop())
     294        return;
     295    }
     296
     297  tlist.PrintStatistics();
     298
     299  ///////////////////////////////////////////////////////////////////////
     300
     301
     302  // Now prepare the second loop: go over the events you want to analyze.
     303  // This time the MMcCalibrationUpdate tasks will apply the previously
     304  // calculated calibration factors.
     305
     306  // First substitute the reading task:
     307  MReadMarsFile read2("Events");
     308  read2.AddFile(AnalysisFilename); 
     309  read2.DisableAutoScheme();
     310  tlist.AddToListBefore(&read2, &read);
     311  tlist.RemoveFromList(&read);
     312
     313  // Delete cleaning tasks and create new ones with absolute cleaning method:
     314    for (Int_t i= 0; i < NCTs; i++ )
     315    {
     316      tlist.RemoveFromList(clean[i]);
     317      delete clean[i];
     318    }
     319
     320  // New cleaning tasks:
     321  clean[0] = new MImgCleanStd(CleanLev[0], CleanLev[1]);
     322  clean[1] = new MImgCleanStd(CleanLev[0], CleanLev[1]);
     323  clean[0]->SetMethod(MImgCleanStd::kAbsolute);
     324  clean[1]->SetMethod(MImgCleanStd::kAbsolute);
     325  clean[0]->SetSerialNumber(CT[0]);
     326  clean[1]->SetSerialNumber(CT[1]);
     327  tlist.AddToListBefore(clean[0],&(hcalc[0]));
     328  tlist.AddToListBefore(clean[1],&(hcalc[1]));
     329
     330  tlist.RemoveFromList(&(mccalibcalc[0]));
     331  tlist.RemoveFromList(&(mccalibcalc[1])); // Remove calibration tasks from list.
     332
     333  // Now calculate also source-dependent Hillas parameters:
     334  for (i = 0; i < NCTs; i++)
     335    hcalc[i].Enable(MHillasCalc::kCalcHillasSrc);
     336
     337  // Add task to calculate stereo parameters:
    219338  MStereoCalc stereocalc;
    220339  stereocalc.SetCTids(CT[0],CT[1]);
    221 
    222   //
    223   // FIXME: telescope coordinates must be introduced by the user, since
    224   // they are not available nor in the camera file, neither in the reflector
    225   // output.
    226   //
    227 
    228   stereocalc.SetCT1coor(ctx[CT[0]-1],cty[CT[0]-1]);
    229   stereocalc.SetCT2coor(ctx[CT[1]-1],cty[CT[1]-1]);
    230 
     340  stereocalc.SetCT1coor(ctx[0],cty[0]);
     341  stereocalc.SetCT2coor(ctx[1],cty[1]);
    231342  tlist.AddToList(&stereocalc);
    232343
    233 
    234   MF filter1("{MMcEvt;1.fEvtNumber%2}<0.5");
    235   MF filter2("{MMcEvt;1.fEvtNumber%2}>0.5");
    236   //
    237   // ^^^^ Filters to divide output in two: test and train samples.
    238   //
    239 
    240   write1.SetFilter (&filter1);
    241   write2.SetFilter (&filter2);
    242 
     344  // Add writing tasks:
    243345  tlist.AddToList(&filter1);
    244346  tlist.AddToList(&write1);
     
    246348  tlist.AddToList(&write2);
    247349
    248   //
    249   // Create and set up the eventloop
    250   //
    251   MProgressBar bar;
    252 
    253   MEvtLoop evtloop;
    254   evtloop.SetProgressBar(&bar);
    255   evtloop.SetParList(&plist);
    256 
    257   //
    258   // Execute your analysis
    259   //
     350  bar.SetWindowName("Analyzing");
     351
    260352  if (!evtloop.Eventloop())
    261353    return;
    262354
     355  tlist.PrintStatistics();
     356
    263357  for (Int_t i= 0; i < NCTs; i++ )
    264358    delete clean[i];
    265359
    266   tlist.PrintStatistics();
     360  plist.FindObject("MCalibrationChargeCam;1")->Write();
     361  plist.FindObject("MCalibrationChargeCam;2")->Write();
     362
     363  plist.FindObject("MCalibrationQECam;1")->Write();
     364  plist.FindObject("MCalibrationQECam;2")->Write();
     365
     366  return;
    267367}
  • trunk/MagicSoft/Mars/manalysis/MGeomApply.cc

    r5844 r7188  
    133133    {
    134134        MCamEvent *cam = dynamic_cast<MCamEvent*>(o);
    135         if (cam)
    136             cam->Init(geom);
     135        if (!cam)
     136            continue;
     137
     138        // If the MGeomApply task has a serial number >0 (indicating most likely
     139        // a specific telescope in a multi-telescope file), then apply the
     140        // geometry only to objects with the same serial number. This is important
     141        // for stereo setups in which the telescopes have cameras with different
     142        // numbers of pixels. If the MGeomApply task has serial number 0 (default),
     143        // it will apply the geometry to all found objects as it used to do.
     144        const TString name(o->GetName());
     145
     146        // Extract serial number from name:
     147        const Int_t serial = atoi(name.Data()+name.Last(';')+1);
     148
     149        // Compare with the serial number of this task:
     150        if (serial>0 && serial!=GetSerialNumber())
     151            continue;
     152
     153        // Initialize object according to camera geometry:
     154        cam->Init(geom);
    137155    }
    138156}
     
    186204
    187205    // FIXME, workaround: this call to CalcPixRatio is here just to allow
    188     // the use of some camera files from the 0.7 beta version in which the
     206    // the use of some MC camera files from the 0.7 beta version in which the
    189207    // array containing pixel ratios is not initialized.
    190208    geom->CalcPixRatio();
  • trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc

    r7005 r7188  
    9595Bool_t MMcCalibrationUpdate::CheckRunType(MParList *pList) const
    9696{
    97     const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     97    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
    9898    if (!run)
    9999    {
     
    176176    }
    177177
    178     MMcRunHeader* mcrunh = (MMcRunHeader*) pList->FindObject("MMcRunHeader");
     178    MMcRunHeader* mcrunh = (MMcRunHeader*) pList->FindObject(AddSerialNumber("MMcRunHeader"));
     179    if (!mcrunh)
     180    {
     181        *fLog << err << AddSerialNumber("MMcRunHeader") << " not found... aborting." << endl;
     182        return kFALSE;
     183    }
    179184
    180185    //
     
    247252    // perpendicular to the camera plane.
    248253    //
    249     // FIXME! We look for AddSerialNumber("MMcConfigRunHeader") but
    250     // for the moment the stereo version of camera does not write one such
    251     // header per telescope (it should!)
     254    // As it happens with most containers, we look for AddSerialNumber("MMcConfigRunHeader")
     255    // because in the stereo option the camera simulation writes one such header
     256    // per telescope.
    252257    //
    253258    MMcConfigRunHeader* mcconfig = (MMcConfigRunHeader*) pList->FindObject(AddSerialNumber("MMcConfigRunHeader"));
  • trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.cc

    r3795 r7188  
    1717!
    1818!   Author(s): Antonio Stamerra  1/2003 <mailto:antono.stamerra@pi.infn.it>
    19 !   Author(s): Marcos Lopez 1/2003 <mailto:marcos@gae.ucm.es>
    2019!
    2120!   Copyright: MAGIC Software Development, 2000-2003
     
    7170// run type
    7271//
    73 Bool_t MMcTriggerLvl2Calc::CheckRunType(MParList *pList) const
     72Bool_t MMcTriggerLvl2Calc::IsMCRun(MParList *pList) const
    7473{
    7574  const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     
    9089Bool_t MMcTriggerLvl2Calc::ReInit(MParList *pList)
    9190{
    92     //
    93     // If it is no MC file skip this function...
    94     //
    95     if (!CheckRunType(pList))
    96     {
    97         *fLog << inf << "This is no MC file... skipping." << endl;
    98         return kTRUE;
    99     }
    100        
    101     //
    102     // Check all necessary containers
    103     //
    104     fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
    105      if (!fMcEvt)
    106      {
    107          *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
    108          return kFALSE;
    109      }
    110 
    111     fMcTrig = (MMcTrig*)pList->FindObject("MMcTrig");
    112     if (!fMcTrig)
    113     {
    114         *fLog << err << dbginf << "MMcTrig not found... exit." << endl;
    115         return kFALSE;
    116     }
    117 
    118     fCam = (MGeomCam*)pList->FindObject("MGeomCam");
    119     if (!fCam)
    120     {
    121         *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
    122         return kFALSE;
    123     }
    124     // Check if fCam is a Magic geometry: only MGeomCamMagic geometry and
    125     // geometries with 577 pixels are now accepted by MMcTriggerLvl2
    126     if (fCam->GetNumPixels()!= 577)
    127       {
    128         *fLog << dbginf << "MGeomCam has a wrong geometry; only MAGIC geometry (577 pixels) is accepted by now... aborting" <<endl;
    129         return kFALSE;
    130       }
    131 
    13291    return kTRUE;
    13392}
     93
    13494
    13595
     
    168128      *fLog << "Compact pixel is set with at least "<<fMMcTriggerLvl2->GetCompactNN() << " NN" <<endl;
    169129
     130    //------------------------------------------------------------
     131    //
     132    // If it is no MC file skip this function...
     133    //
     134    if (!IsMCRun(pList))
     135    {
     136        *fLog << inf << "Reading a data file...skipping the rest of PreProcess()" << endl;
     137        return kTRUE;
     138    }
     139       
     140    //
     141    // Check all necessary containers in case of a MC run
     142    //
     143    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
     144     if (!fMcEvt)
     145     {
     146         *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
     147         return kFALSE;
     148     }
     149
     150    fMcTrig = (MMcTrig*)pList->FindObject("MMcTrig");
     151    if (!fMcTrig)
     152    {
     153        *fLog << err << dbginf << "MMcTrig not found... exit." << endl;
     154        return kFALSE;
     155    }
     156
     157    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
     158    if (!fCam)
     159    {
     160        *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
     161        return kFALSE;
     162    }
     163    // Check if fCam is a Magic geometry: only MGeomCamMagic geometry and
     164    // geometries with 577 pixels are now accepted by MMcTriggerLvl2
     165    if (fCam->GetNumPixels()!= 577)
     166      {
     167        *fLog << warn << "MGeomCam has a wrong geometry; only MAGIC geometry (577 pixels) is accepted by now... the Task is skipped." <<endl;
     168        return kSKIP;
     169      }
    170170
    171171    return kTRUE;
     172
    172173}
    173174
  • trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.h

    r3795 r7188  
    3333
    3434  Bool_t ReInit(MParList *pList);
    35   Bool_t CheckRunType(MParList *pList) const;
     35  Bool_t IsMCRun(MParList *pList) const;
    3636
    3737 public:
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.cc

    r5797 r7188  
    4444// are coded in the following form:
    4545//
     46//
     47// * Set bits leading to an unsuitable flag:
     48//
     49// BIT(7 ): kLoGainSaturation     :  The Low Gain signals were saturated during calibration
     50// BIT(8 ): kChargeIsPedestal     :  The calibration signal contained only pedestals - presumably dead pixel
     51// BIT(12): kMeanTimeInFirstBin   :  The signal has its mean maximum in the first used FADC slice - signal extractor bad
     52// BIT(13): kMeanTimeInLast2Bins  :  The signal has its mean maximum in the last two used FADC slice - signal extractor bad
     53// BIT(14): kDeviatingNumPhes     :  The calculated number of phes deviates by more than +6-5.5 sigma of the phes mean of the same area idx.
     54// BIT(19): kHiGainOverFlow       :  The Hi-Gain calibration histogram showed overflow in more than 0.5% of the events
     55// BIT(20): kLoGainOverFlow       :  The Lo-Gain calibration histogram showed overflow in more than 0.5% of the events
     56// BIT(23): kDeadPedestalRms      :  The pedestal RMS was 4.5 sigma below or 25 sigma above the average per area idx.
     57// BIT(24): kFluctuatingArivalTimes: The RMS of the position of the pulse maximum is larger than 3.5 FADC slices.
     58// BIT(24): kLoGainBlackout       :  A high gain saturated pixel had too many blackout events in the low gain
     59//
     60//
    4661// * Set bits leading to an unreliable flag:
    4762//
     
    5267// BIT(5 ): kLoGainOscillating   :  The Low  Gain signals fourier transform showed abnormal behavior 
    5368// BIT(6 ): kRelTimeOscillating  :  The High Gain arrival times fourier transform showed abnormal behavior 
    54 // BIT(14): kDeviatingNumPhes    :  The calculated number of photo-electrons deviates too much from the mean - inconsistency
     69// BIT(11): kChargeSigmaNotValid :  The sigma of the signal distribution is smaller than the pedestal RMS - presumably a pixel with a star in its FOV only during the pedestal taking
    5570// BIT(16): kDeviatingFFactor    :  The calculated overall F-Factor deviates too much from the mean - inconsistency
    5671// BIT(15): kDeviatingNumPhots   :  The calculated number of calibrated photons deviates too much from the mean - inconsistency
    5772//
    58 // * Set bits leading to an unsuitable flag:
    59 //
    60 // BIT(7 ): kLoGainSaturation    :  The Low  Gain signals were saturated during calibration
    61 // BIT(8 ): kChargeIsPedestal    :  The calibration signal contained only pedestals - presumably dead pixel
    62 // BIT(9 ): kChargeErrNotValid   :  The absolute error of the derived charge has given non-sense - presumably pedestal
    63 // BIT(10): kChargeRelErrNotValid:  The relative error of the derived charge was too large or too small
    64 // BIT(11): kChargeSigmaNotValid :  The sigma of the pedestal distribution smaller than the pedestal RMS - presumably a pixel with a star in its FOV only during the pedestal taking
    65 // BIT(12): kMeanTimeInFirstBin  :  The signal has its mean maximum in the first used FADC slice - signal extractor bad
    66 // BIT(13): kMeanTimeInLast2Bins :  The signal has its mean maximum in the last two used FADC slice - signal extractor bad
    67 // BIT(19): kHiGainOverFlow      :  The Hi-Gain calibration histogram showed overflow without saturating the FADC
    68 // BIT(20): kLoGainOverFlow      :  The Lo-Gain calibration histogram showed overflow
    6973//
    7074// * Set bits leading to not useable low-gain signal:
    7175//
    72 // BIT(17): kConversionHiLoNotValid: The calibrated Conversion between Hi-Gain and Low Gain gives absurd results
     76// BIT(17): kConversionHiLoNotValid: The inter-calibration constant between Hi-Gain and Low Gain does not exist.
    7377//
    7478// These bits can be called with the enum MBadPixelsPix::UncalibratedType_t in combination
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.h

    r7103 r7188  
    5555      kHiLoOscillating          = BIT(22),
    5656      kDeadPedestalRms          = BIT(23),
    57       kFluctuatingArrivalTimes  = BIT(24)
     57      kFluctuatingArrivalTimes  = BIT(24),
     58      kLoGainBlackout           = BIT(25)
    5859    };
    5960   
     
    9091                                     || IsUncalibrated(kLoGainSaturation   )
    9192                                     || IsUncalibrated(kConversionHiLoNotValid)
    92                                      || IsUncalibrated(kLoGainOscillating  ) ; }
     93                                     || IsUncalibrated(kLoGainOscillating  )
     94                                     || IsUncalibrated(kLoGainBlackout  ); }
    9395    Bool_t IsHiGainBad() const { return IsUnsuitable  (kUnsuitableRun      )
    9496                                     || IsUncalibrated(kHiGainOscillating  ) ; }
    9597
    9698    Int_t  GetUnsuitableCalLevel() const   {
    97       if (!IsUnsuitable())                        return 0;
    98       if (IsUncalibrated( kChargeIsPedestal    )) return 1;
    99       if (IsUncalibrated( kChargeRelErrNotValid)) return 2;
    100       if (IsUncalibrated( kLoGainSaturation    )) return 3;
    101       if (IsUncalibrated( kMeanTimeInFirstBin  )) return 4;
    102       if (IsUncalibrated( kMeanTimeInLast2Bins )) return 5;
    103       if (IsUncalibrated( kDeviatingNumPhots   )) return 6;
    104       if (IsUncalibrated( kHiGainOverFlow      )) return 7;
    105       if (IsUncalibrated( kLoGainOverFlow      )) return 8;
    106       if (IsUncalibrated( kDeadPedestalRms     )) return 9;
    107       if (IsUncalibrated( kFluctuatingArrivalTimes)) return 10;
    108       if (IsUncalibrated( kDeviatingNumPhes       )) return 11;
    109       if (IsUncalibrated( kPreviouslyExcluded     )) return 12;
    110       return 13;
     99      if (!IsUnsuitable())                           return 0;
     100      if (IsUncalibrated( kChargeIsPedestal    ))    return 1;
     101      if (IsUncalibrated( kLoGainSaturation    ))    return 2;
     102      if (IsUncalibrated( kMeanTimeInFirstBin  ))    return 3;
     103      if (IsUncalibrated( kMeanTimeInLast2Bins ))    return 4;
     104      if (IsUncalibrated( kHiGainOverFlow      ))    return 5;
     105      if (IsUncalibrated( kLoGainOverFlow      ))    return 6;
     106      if (IsUncalibrated( kDeadPedestalRms     ))    return 7;
     107      if (IsUncalibrated( kFluctuatingArrivalTimes)) return 8;
     108      if (IsUncalibrated( kDeviatingNumPhes    ))    return 9;
     109      if (IsUncalibrated( kLoGainBlackout      ))    return 10;
     110      if (IsUncalibrated( kPreviouslyExcluded  ))    return 11;
     111      return 12;
    111112    }
    112113
  • trunk/MagicSoft/Mars/mbase/MParameters.h

    r6915 r7188  
    5454    ClassDef(MParameterI, 1) // Container to hold a generalized parameters (integer)
    5555};
     56
    5657/*
    5758class MParameters : public MParContainer
  • trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h

    r6663 r7188  
    1919#pragma link C++ class MCalibrationIntensityCam+;
    2020#pragma link C++ class MCalibrationIntensityChargeCam+;
     21#pragma link C++ class MCalibrationIntensityConstCam+;
    2122#pragma link C++ class MCalibrationIntensityBlindCam+;
    2223#pragma link C++ class MCalibrationIntensityQECam+;
    2324#pragma link C++ class MCalibrationIntensityRelTimeCam+;
    2425#pragma link C++ class MCalibrationIntensityTestCam+;
     26
    2527#pragma link C++ class MCalibrationCam+;
    2628#pragma link C++ class MCalibrationPix+;
  • trunk/MagicSoft/Mars/mcalib/MCalibConstCam.cc

    r6457 r7188  
    8585// --------------------------------------------------------------------------
    8686//
    87 // Set the size of the camera
    88 //
    89 void MCalibConstCam::InitSize(const UInt_t i)
    90 {
    91     fArray->ExpandCreate(i);
    92 }
    93 
    94 // -------------------------------------------------------------------
    95 //
    96 // Calls TClonesArray::ExpandCreate() for:
    97 // - fAverageAreas
    98 //
    99 void MCalibConstCam::InitAverageAreas(const UInt_t i)
    100 {
    101   fAverageAreas->ExpandCreate(i);
    102 }
    103 
    104 // -------------------------------------------------------------------
    105 //
    106 // Calls TClonesArray::ExpandCreate() for:
    107 // - fAverageSectors
    108 //
    109 void MCalibConstCam::InitAverageSectors(const UInt_t i)
    110 {
    111   fAverageSectors->ExpandCreate(i);
    112 }
     87// Copy 'constructor'
     88//
     89void MCalibConstCam::Copy(TObject &obj) const
     90{
     91
     92  MParContainer::Copy(obj);
     93
     94  MCalibConstCam &cam = (MCalibConstCam&)obj;
     95 
     96  Int_t n = GetSize();
     97 
     98  if (n==0)
     99    return;
     100 
     101  cam.InitSize(n);
     102  for (int i=0; i<n; i++)
     103    (*this)[i].Copy(cam[i]);
     104
     105  n = GetNumAverageArea();
     106  cam.InitAverageAreas(n);
     107  for (int i=0; i<n; i++)
     108    GetAverageArea(i).Copy(cam.GetAverageArea(i));
     109
     110  n = GetNumAverageSector();
     111  cam.InitAverageSectors(n);
     112  for (int i=0; i<n; i++)
     113    GetAverageSector(i).Copy(cam.GetAverageSector(i));
     114}
     115
    113116
    114117// -------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mcalib/MCalibConstCam.h

    r6073 r7188  
    99#endif
    1010
    11 class TClonesArray;
     11#ifndef ROOT_TClonesArray
     12#include <TClonesArray.h>
     13#endif
     14
    1215
    1316class MGeomCam;
     
    2124  TClonesArray *fAverageSectors;  //-> Array of MCalibConstPix, one per camera sector
    2225
     26  Int_t fRunNumber;               // Run number
     27 
    2328public:
    2429
     
    2732 
    2833  void Clear(Option_t *o="");
     34  void Copy(TObject &object) const;
    2935 
    3036  // Getters
    31         MCalibConstPix &GetAverageArea   ( UInt_t i );
    32   const MCalibConstPix &GetAverageArea   ( UInt_t i )            const;
    33   const Int_t           GetNumAverageArea()                      const;
    34         MCalibConstPix &GetAverageSector ( UInt_t i );
    35   const MCalibConstPix &GetAverageSector ( UInt_t i )            const;
    36   const Int_t           GetNumAverageSector()                    const;
    37   Int_t                 GetSize          ()                      const;
     37        MCalibConstPix &GetAverageArea     ( UInt_t i );
     38  const MCalibConstPix &GetAverageArea     ( UInt_t i )  const;
     39  const Int_t           GetNumAverageArea  ()            const;
     40        MCalibConstPix &GetAverageSector   ( UInt_t i );
     41  const MCalibConstPix &GetAverageSector   ( UInt_t i )  const;
     42  const Int_t           GetNumAverageSector()            const;
     43  Int_t                 GetSize            ()            const;
    3844
    39         MCalibConstPix &operator[]     ( Int_t i             );
    40   const MCalibConstPix &operator[]     ( Int_t i             ) const;
     45        MCalibConstPix &operator[]         ( Int_t i  );
     46  const MCalibConstPix &operator[]         ( Int_t i  ) const;
    4147
    4248  void  Init                           ( const MGeomCam &geom);
    43   void  InitSize                       ( const UInt_t i      );
    44   void  InitAverageAreas               ( const UInt_t i      );
    45   void  InitAverageSectors             ( const UInt_t i      );
     49  void  InitSize                       ( const UInt_t i ) { fArray->ExpandCreate(i);          }
     50  void  InitAverageAreas               ( const UInt_t i ) { fAverageAreas->ExpandCreate(i);   }
     51  void  InitAverageSectors             ( const UInt_t i ) { fAverageSectors->ExpandCreate(i); }
    4652
    4753  void Print(Option_t *o="") const;
     54
     55  // Setters
     56  void SetRunNumber( const Int_t n )   {  fRunNumber = n; }
    4857 
    49   Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    50   void  DrawPixelContent(Int_t idx) const;
     58  Bool_t GetPixelContent (Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
     59  void   DrawPixelContent(Int_t idx) const;
    5160
    52   ClassDef(MCalibConstCam, 0)   // Temporary Storage for calibration constants
     61  ClassDef(MCalibConstCam, 1)   // Temporary Storage for calibration constants
    5362};
    5463
  • trunk/MagicSoft/Mars/mcalib/MCalibConstPix.h

    r6073 r7188  
    99{
    1010private:
    11 
    1211    Float_t fCalibConst;        // conversion factor (modified after each interlaced cal. update)
    1312    Float_t fCalibFFactor;      // global F-Factor   (modified after each interlaced cal. update)
    1413
    1514public:
    16  
    1715    MCalibConstPix();
    18    
     16
     17    // TObject
    1918    void Clear(Option_t *o="")
    20       {
    21         fCalibConst   = -1.;
    22         fCalibFFactor = -1.;
    23       }
    24    
     19    {
     20        fCalibConst   = -1.;
     21        fCalibFFactor = -1.;
     22    }
     23
     24    void Copy(TObject &object) const
     25    {
     26        MCalibConstPix &pix =  (MCalibConstPix&)object;
     27        pix.fCalibConst   = fCalibConst;
     28        pix.fCalibFFactor = fCalibFFactor;
     29    }
     30
    2531    // Getters
    2632    Float_t GetCalibConst()   const { return fCalibConst;   }
     
    3137    void SetCalibFFactor( const Float_t f )  { fCalibFFactor = f; }
    3238
    33     ClassDef(MCalibConstPix, 0) // Temporay Storage Calibraion Constant of one pixel
     39    ClassDef(MCalibConstPix, 1) // Temporay Storage Calibraion Constant of one pixel
    3440};
    3541
  • trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.cc

    r5128 r7188  
    7171
    7272}
    73 
    74 // --------------------------------------------------------------------------
    75 //
    76 // Copy 'constructor'
    77 //
    78 void MCalibrationBlindCam::Copy(TObject& object) const
    79 {
    80  
    81   MCalibrationBlindCam &calib = (MCalibrationBlindCam&)object;
    82  
    83   MCalibrationCam::Copy(calib);
    84 
    85   /* 
    86   const UInt_t n = GetSize();
    87   if (n != 0)
    88     {
    89       calib.InitSize(n);
    90       for (UInt_t i=0; i<n; i++)
    91         (*this)[i].Copy(calib[i]);
    92     }
    93   */
    94 }
    95 
    96 
    9773
    9874// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.h

    r5128 r7188  
    1313
    1414public:
    15 
    1615  MCalibrationBlindCam(Int_t nblind=1,const char *name=NULL, const char *title=NULL);
    1716 
    18   void Copy(TObject& object) const;
    19 
    2017  // Inits
    2118  void  Init ( const MGeomCam &geom ) {}
    2219
     20  // Getter
    2321  Bool_t IsFluxInsidePlexiglassAvailable () const;
    2422
     
    2725  Float_t GetFluxInsidePlexiglassRelVar() const;
    2826
     27  // Setter
    2928  void  SetPulserColor( const MCalibrationCam::PulserColor_t col );
    3029 
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc

    r7099 r7188  
    7373//  + fNumSaturated
    7474//
     75// Class Version 4:
     76//  +  Float_t fConversionHiLoSigma;             // Sigma of conversion factor betw. Hi and Lo Gain
     77//  -  Float_t fMeanConvFADC2PheVar;             // Variance conversion factor (F-factor method)
     78//  +  Float_t fMeanConvFADC2PheStatVar;         // Variance conversion factor, only stat. error
     79//  +  Float_t fMeanConvFADC2PheSystVar;         // Variance conversion factor, only syst. error
     80//  -  Float_t fMeanFFactorFADC2PhotVar;         // Variance mean F-Factor photons (F-factor method)
     81//  +  Float_t fMeanFFactorFADC2PhotVar;         // Variance mean F-Factor photons, only stat. error
     82//  -  Float_t fPheFFactorMethod;                // Number Phe's calculated (F-factor method)
     83//  -  Float_t fPheFFactorMethodVar;             // Variance number of Phe's (F-factor method)
     84//  +  Float_t fPheFFactorMethod;                // Number Phe's calculated  with F-factor method)
     85//  +  Float_t fPheFFactorMethodStatVar;         // Variance number of Phe's, only stat. error
     86//  +  Float_t fPheFFactorMethodSystVar;         // Variance number of Phe's, only syst. error
     87//
    7588/////////////////////////////////////////////////////////////////////////////
    7689#include "MCalibrationChargePix.h"
     
    90103const Float_t MCalibrationChargePix::gkFFactorErr          = 0.02;
    91104
    92 const Float_t MCalibrationChargePix::fgConversionHiLo           = 10.;
    93 const Float_t MCalibrationChargePix::fgConversionHiLoErr        = 2.5;
    94 const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit    = 1.;
    95 const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit   = 0.85;
     105const Float_t MCalibrationChargePix::fgConversionHiLo         = 10.;
     106const Float_t MCalibrationChargePix::fgConversionHiLoErr      = 0.05;
     107const Float_t MCalibrationChargePix::fgConversionHiLoSigma    = 2.5;
     108const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit  = 1.;
     109const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit = 0.85;
    96110
    97111// --------------------------------------------------------------------------
     
    157171
    158172  fPheFFactorMethod                 =  -1.;
    159   fPheFFactorMethodVar              =  -1.;
     173  fPheFFactorMethodStatVar          =  -1.;
     174  fPheFFactorMethodSystVar          =  -1.;
    160175
    161176  fMeanConvFADC2Phe                 =  -1.;
    162   fMeanConvFADC2PheVar              =  -1.;
     177  fMeanConvFADC2PheStatVar          =  -1.;
     178  fMeanConvFADC2PheSystVar          =  -1.;
    163179  fMeanFFactorFADC2Phot             =  -1.;
    164180  fMeanFFactorFADC2PhotVar          =  -1.; 
     
    168184  MCalibrationPix::Clear();
    169185}
     186
     187// -----------------------------------------------------
     188//
     189void MCalibrationChargePix::Copy(TObject& object) const
     190{
     191  MCalibrationChargePix &pix = (MCalibrationChargePix&)object;
     192 
     193  MCalibrationPix::Copy(pix);
     194
     195  //
     196  // Copy the data members
     197  //
     198  pix.fAbsTimeMean                = fAbsTimeMean              ;
     199  pix.fAbsTimeRms                 = fAbsTimeRms               ;
     200  pix.fCalibFlags                 = fCalibFlags               ;
     201  pix.fConversionHiLo             = fConversionHiLo           ;
     202  pix.fConversionHiLoVar          = fConversionHiLoVar        ;
     203  pix.fConversionHiLoSigma        = fConversionHiLoSigma      ;
     204  pix.fConvFFactorRelVarLimit     = fConvFFactorRelVarLimit   ;
     205  pix.fLoGainPedRmsSquare         = fLoGainPedRmsSquare       ;
     206  pix.fLoGainPedRmsSquareVar      = fLoGainPedRmsSquareVar    ;
     207  pix.fMeanConvFADC2Phe           = fMeanConvFADC2Phe         ;
     208  pix.fMeanConvFADC2PheStatVar    = fMeanConvFADC2PheStatVar  ;
     209  pix.fMeanConvFADC2PheSystVar    = fMeanConvFADC2PheSystVar  ;
     210  pix.fMeanFFactorFADC2Phot       = fMeanFFactorFADC2Phot     ;
     211  pix.fMeanFFactorFADC2PhotVar    = fMeanFFactorFADC2PhotVar  ;
     212  pix.fPed                        = fPed                      ;
     213  pix.fPedVar                     = fPedVar                   ;
     214  pix.fPedRms                     = fPedRms                     ;
     215  pix.fPedRmsVar                  = fPedRmsVar                  ;
     216  pix.fPheFFactorMethod           = fPheFFactorMethod           ;
     217  pix.fPheFFactorMethodStatVar    = fPheFFactorMethodStatVar    ;
     218  pix.fPheFFactorMethodSystVar    = fPheFFactorMethodSystVar    ;
     219  pix.fPheFFactorMethodLimit      = fPheFFactorMethodLimit      ;
     220  pix.fRSigmaSquare               = fRSigmaSquare               ;
     221  pix.fRSigmaSquareVar            = fRSigmaSquareVar            ;
     222  pix.fNumSaturated               = fNumSaturated               ;
     223}                                 
    170224
    171225
     
    185239void MCalibrationChargePix::SetPedestal(const Float_t ped, const Float_t pedrms, const Float_t pederr)
    186240{
    187 
    188241  fPed       = ped;   
    189242  fPedRms    = pedrms;
     
    197250void MCalibrationChargePix::SetPed(const Float_t ped, const Float_t pederr)
    198251{
    199 
    200252  fPed       = ped;   
    201253  fPedVar    = pederr*pederr;
     
    208260void MCalibrationChargePix::SetPedRMS( const Float_t pedrms, const Float_t pedrmserr)
    209261{
    210  
    211262  fPedRms    = pedrms;
    212263  fPedRmsVar = pedrmserr*pedrmserr;
    213  
    214 }
    215 
    216 
    217 // -------------------------------------------------------------------------------
    218 //
    219 // Get the conversion Error Hi-Gain to Low-Gain:
    220 // - If fConversionHiLoVar is smaller than 0 (i.e. has not yet been set), return -1.
     264}
     265
     266
     267// Inline Functions:
     268// -----------------
     269//
     270// GetConversionHiLoErr:
     271//   Get the conversion Error Hi-Gain to Low-Gain:
     272//   If fConversionHiLoVar is smaller than 0 (i.e. has not yet
     273//   been set), return -1.
    221274// 
    222 Float_t MCalibrationChargePix::GetConversionHiLoErr()  const
    223 {
    224   if (fConversionHiLoVar < 0.)
    225     return -1.;
    226 
    227   return TMath::Sqrt(fConversionHiLoVar);
    228 }
     275// GetPedRms(): Get the pedestals RMS: Test bit kHiGainSaturation:
     276//  If yes, return square root of fLoGainPedRmsSquare (if greater than 0,
     277//  otherwise -1.), If no,  return fPedRms
     278//
     279// GetConvertedMean(): Get the Low Gain Mean Charge converted to High Gain
     280//  amplification: Returns fLoGainMean multiplied with fConversionHiLo if
     281//  IsHiGainSaturation(), else return fHiGainMean
     282//
     283// GetConvertedMeanErr(): Get the Error of the converted Low Gain Mean:
     284//  Returns -1 if the variable fLoGainMean or fLoGainMeanVar are smaller than 0.
     285//  Returns the square root of the quadratic sum of the relative variances of
     286//  the fLoGainMean and fConversionHiLo, mulitplied with GetConvertedMean()
     287//  in case of HiGain Saturation,
     288//  else return GetMeanErr()
     289//
     290// GetConvertedSigma(): Get the Low Gain Sigma converted to High Gain
     291//  amplification: Returns fLoGainSigma multiplied with fConversionHiLo
     292//  if IsHiGainSaturation() else return fHiGainSigma
     293//
     294// GetConvertedSigmaErr(): Get the Error of the converted Sigma:
     295//  Returns -1 if the variable fLoGainSigma or fLoGainSigmaVar are smaller than 0.
     296//  if IsHiGainSaturatio()
     297//  returns the square root of the quadratic sum of the relative variances of
     298//  the fLoGainSigma and fConversionHiLo, mulitplied with GetConvertedSigma()
     299//  else returns GetSigmaErr()
     300//
     301// GetConvertedRSigma(): Get the converted reduced Sigma:
     302//  If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
     303//  Test bit kHiGainSaturation:
     304//  If yes, return square root of fRSigmaSquare, multiplied with fConversionHiLo,
     305//  If no , return square root of fRSigmaSquare
     306//
     307// GetRSigma(): Get the reduced Sigma:
     308//  If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
     309//
     310// GetConvertedRSigmaSquare(): Get the reduced Sigma Square:
     311//  If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
     312//  Test bit kHiGainSaturation:
     313//  If yes, return fRSigmaSquare, multiplied with fConversionHiLo^2,
     314//  If no , return fRSigmaSquare
     315//
     316// GetPheFFactorMethodErr(): Get the error on the number of photo-electrons
     317//  (F-Factor Method): If fPheFFactorMethodVar is smaller than 0 (i.e. has
     318//  not yet been set), return -1. Else returns the square root of
     319//  fPheFFactorMethodVar
     320//
     321// GetMeanFFactorFADC2PhotErr(): Get the error on the mean total F-Factor
     322//  of the signal readout (F-Factor Method): If fMeanFFactorFADC2PhotVar
     323//  is smaller than 0 (i.e. has not yet been set), return -1. Else returns
     324//  the square root of fMeanFFactorFADC2PhotVar
     325//
     326// GetPheFFactorMethodRelVar(): Get the relative variance on the number of
     327//  photo-electrons (F-Factor Method): If fPheFFactorMethodVar is smaller
     328//  than 0 (i.e. has not yet been set), return -1. If fPheFFactorMethod
     329//  is 0, return -1. Else returns fPheFFactorMethodVar / fPheFFactorMethod^2
     330//
     331// GetMeanConvFADC2PheErr(): Get the error on the mean conversion factor
     332//  (FFactor  Method): If fMeanConvFADC2PheVar is smaller than 0 (i.e. has
     333//  not yet been set), return -1. Else returns the square root of
     334//  fMeanConvFADC2PheVar
    229335
    230336// --------------------------------------------------------------------------
     
    278384 
    279385
    280 // --------------------------------------------------------------------------
    281 //
    282 // Get the pedestals RMS:
    283 // - Test bit kHiGainSaturation:
    284 //   If yes, return square root of fLoGainPedRmsSquare (if greater than 0, otherwise -1.),
    285 //   If no,  return fPedRms
    286 //
    287 Float_t  MCalibrationChargePix::GetPedRms()  const
    288 {
    289 
    290   if (IsHiGainSaturation())
    291     if (fLoGainPedRmsSquare < 0.)
    292       return -1.;
    293     else
    294       return TMath::Sqrt(fLoGainPedRmsSquare);
    295  
    296   return fPedRms;
    297 }
    298386
    299387// --------------------------------------------------------------------------
     
    321409// --------------------------------------------------------------------------
    322410//
    323 // Get the Low Gain Mean Charge converted to High Gain amplification:
    324 // Returns fLoGainMean multiplied with fConversionHiLo if IsHiGainSaturation(),
    325 //         else return fHiGainMean
    326 //
    327 Float_t MCalibrationChargePix::GetConvertedMean()  const
    328 {
    329 
    330   if (IsHiGainSaturation())
    331     return fLoGainMean * fConversionHiLo;
    332 
    333   return fHiGainMean;
    334 }
    335 
    336 // --------------------------------------------------------------------------
    337 //
    338 // Get the Error of the converted Low Gain Mean:
    339 //
    340 // Returns -1 if the variable fLoGainMean or fLoGainMeanVar are smaller than 0.
    341 //
    342 // Returns the square root of the quadratic sum of the relative variances of
    343 // the fLoGainMean and fConversionHiLo, mulitplied with GetConvertedMean()
    344 // in case of HiGain Saturation,
    345 // else return GetMeanErr()
    346 //
    347 Float_t MCalibrationChargePix::GetConvertedMeanErr()  const
    348 {
    349 
    350   if (IsHiGainSaturation())
    351     {
    352       const Float_t logainrelvar = GetLoGainMeanRelVar();
    353      
    354       if (logainrelvar < 0.)
    355         return -1.;
    356 
    357       return TMath::Sqrt(logainrelvar + GetConversionHiLoRelVar()) * GetConvertedMean();
    358     }
    359   else
    360     return GetMeanErr();
    361 
    362 }
    363 
    364 // --------------------------------------------------------------------------
    365 //
    366 // Get the Low Gain Sigma converted to High Gain amplification:
    367 // Returns fLoGainSigma multiplied with fConversionHiLo if IsHiGainSaturation()
    368 // else return fHiGainSigma
    369 //
    370 Float_t MCalibrationChargePix::GetConvertedSigma()  const
    371 {
    372  
    373   if (IsHiGainSaturation())
    374     return fLoGainSigma * fConversionHiLo;
    375   else
    376     return fHiGainSigma;
    377 }
    378 
    379 // --------------------------------------------------------------------------
    380 //
    381 // Get the Error of the converted Sigma:
    382 //
    383 // Returns -1 if the variable fLoGainSigma or fLoGainSigmaVar are smaller than 0.
    384 //
    385 // if IsHiGainSaturatio()
    386 // returns the square root of the quadratic sum of the relative variances of
    387 // the fLoGainSigma and fConversionHiLo, mulitplied with GetConvertedSigma()
    388 // else returns GetSigmaErr()
    389 //
    390 Float_t MCalibrationChargePix::GetConvertedSigmaErr()  const
    391 {
    392 
    393   if (IsHiGainSaturation())
    394     {
    395       if (fLoGainSigmaVar < 0.)
    396         return -1.;
    397      
    398       if (fLoGainSigma < 0.)
    399         return -1.;
    400      
    401       const Float_t sigmaRelVar =  fLoGainSigmaVar
    402                                 /( fLoGainSigma * fLoGainSigma );
    403 
    404       return TMath::Sqrt(sigmaRelVar+GetConversionHiLoRelVar()) * GetConvertedSigma();
    405     }
    406   else
    407     return GetSigmaErr();
    408 
    409 
    410 }
    411 
    412 // --------------------------------------------------------------------------
    413 //
    414 // Get the converted reduced Sigma:
    415 // - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
    416 // - Test bit kHiGainSaturation:
    417 //   If yes, return square root of fRSigmaSquare, multiplied with fConversionHiLo,
    418 //   If no , return square root of fRSigmaSquare
    419 //
    420 Float_t MCalibrationChargePix::GetConvertedRSigma()  const
    421 {
    422   if (fRSigmaSquare < 0)
    423     return -1;
    424 
    425   const Float_t rsigma = TMath::Sqrt(fRSigmaSquare);
    426  
    427   return IsHiGainSaturation() ? rsigma*fConversionHiLo : rsigma ;
    428 }
    429 
    430 // --------------------------------------------------------------------------
    431 //
    432411// Get the error of the converted reduced Sigma:
    433412// - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
     
    460439// --------------------------------------------------------------------------
    461440//
    462 // Get the reduced Sigma:
    463 // - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
    464 //
    465 Float_t MCalibrationChargePix::GetRSigma()  const
    466 {
    467   if (fRSigmaSquare < 0)
    468     return -1;
    469 
    470   return TMath::Sqrt(fRSigmaSquare);
    471  
    472 }
    473 
    474 // --------------------------------------------------------------------------
    475 //
    476441// Get the error of the reduced Sigma:
    477442// - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
     
    540505 
    541506  return TMath::Sqrt(rsigmarelvar + meanrelvar) * GetRSigmaPerCharge();
    542 }
    543 
    544 // --------------------------------------------------------------------------
    545 //
    546 // Get the reduced Sigma Square:
    547 // - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
    548 // - Test bit kHiGainSaturation:
    549 //   If yes, return fRSigmaSquare, multiplied with fConversionHiLo^2,
    550 //   If no , return fRSigmaSquare
    551 //
    552 Float_t MCalibrationChargePix::GetConvertedRSigmaSquare()  const
    553 {
    554   if (fRSigmaSquare < 0)
    555     return -1;
    556 
    557   return IsHiGainSaturation() ? fRSigmaSquare*fConversionHiLo*fConversionHiLo : fRSigmaSquare ;
    558507}
    559508
     
    582531}
    583532
    584 // --------------------------------------------------------------------------
    585 //
    586 // Get the error on the number of photo-electrons (F-Factor Method):
    587 // - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    588 // - Else returns the square root of fPheFFactorMethodVar
    589 //
    590 Float_t MCalibrationChargePix::GetPheFFactorMethodErr()  const
    591 {
    592   if (fPheFFactorMethodVar < 0.)
    593     return -1.;
    594   return TMath::Sqrt(fPheFFactorMethodVar);
    595 }
    596 
    597 // --------------------------------------------------------------------------
    598 //
    599 // Get the error on the mean total F-Factor of the signal readout (F-Factor Method):
    600 // - If fMeanFFactorFADC2PhotVar is smaller than 0 (i.e. has not yet been set), return -1.
    601 // - Else returns the square root of fMeanFFactorFADC2PhotVar
    602 //
    603 Float_t MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()  const
    604 {
    605   if (fMeanFFactorFADC2PhotVar < 0.)
    606     return -1.;
    607   return TMath::Sqrt(fMeanFFactorFADC2PhotVar);
    608 }
    609 
    610 // --------------------------------------------------------------------------
    611 //
    612 // Get the relative variance on the number of photo-electrons (F-Factor Method):
    613 // - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    614 // - If fPheFFactorMethod    is 0, return -1.
    615 // - Else returns fPheFFactorMethodVar / fPheFFactorMethod^2
    616 //
    617 Float_t MCalibrationChargePix::GetPheFFactorMethodRelVar()  const
    618 {
    619   if (fPheFFactorMethodVar < 0.)
    620     return -1.;
    621   if (fPheFFactorMethod  == 0.)
    622     return -1.;
    623 
    624   return fPheFFactorMethodVar / (fPheFFactorMethod * fPheFFactorMethod);
    625 }
    626 
    627 
    628 // --------------------------------------------------------------------------
    629 //
    630 // Get the error on the mean conversion factor (FFactor  Method):
    631 // - If fMeanConvFADC2PheVar is smaller than 0 (i.e. has not yet been set), return -1.
    632 // - Else returns the square root of fMeanConvFADC2PheVar
    633 //
    634 Float_t MCalibrationChargePix::GetMeanConvFADC2PheErr()  const
    635 {
    636   if (fMeanConvFADC2PheVar < 0.)
    637     return -1.;
    638   return TMath::Sqrt(fMeanConvFADC2PheVar);
    639 }
     533
    640534
    641535// --------------------------------------------------------------------------
     
    803697  // Calculate the Error of Nphe
    804698  //
    805   const Float_t pheRelVar = ffactorsquareRelVar + meanSquareRelVar + rsigmaSquareRelVar;
    806   fPheFFactorMethodVar    = pheRelVar * fPheFFactorMethod * fPheFFactorMethod;
     699  const Float_t pheRelVar  = meanSquareRelVar + rsigmaSquareRelVar;
     700  fPheFFactorMethodStatVar = pheRelVar * fPheFFactorMethod * fPheFFactorMethod;
     701  fPheFFactorMethodSystVar = ffactorsquareRelVar * fPheFFactorMethod * fPheFFactorMethod;
    807702
    808703  if (IsDebug())
     
    816711    }
    817712
    818   if (fPheFFactorMethodVar < 0. )
     713  if (fPheFFactorMethodStatVar < 0. )
    819714    return kFALSE;
    820715
     
    879774  // the errors, but have to take account of this cancellation:
    880775  //
    881   Float_t convrelvar = ffactorsquareRelVar + GetMeanRelVar() + rsigmaSquareRelVar;
     776  Float_t convrelvar = GetMeanRelVar() + rsigmaSquareRelVar;
     777  if (IsHiGainSaturation())
     778      convrelvar += GetConversionHiLoRelVar();
     779
    882780  const Float_t limit = IsHiGainSaturation() ? fConvFFactorRelVarLimit * 4. : fConvFFactorRelVarLimit;
    883781
     
    906804    }
    907805 
    908   fMeanConvFADC2PheVar =  convrelvar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
     806  fMeanConvFADC2PheStatVar = convrelvar * fMeanConvFADC2Phe  * fMeanConvFADC2Phe;
     807  fMeanConvFADC2PheSystVar = ffactorsquareRelVar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
    909808 
    910809  SetFFactorMethodValid(kTRUE);
     
    967866                              + 0.25 * nphotonsrelvar;
    968867 
    969   fMeanFFactorFADC2PhotVar    = ffactorrelvar * fMeanFFactorFADC2Phot * fMeanFFactorFADC2Phot;
     868  fMeanFFactorFADC2PhotVar = ffactorrelvar * fMeanFFactorFADC2Phot * fMeanFFactorFADC2Phot;
    970869
    971870  if (IsDebug())
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h

    r7099 r7188  
    1717  static const Float_t fgConversionHiLo;         //! Default fConversionHiLo          (now set to: 10.)
    1818  static const Float_t fgConversionHiLoErr;      //! Default fConversionHiLoVar       (now set to: 2.5)
     19  static const Float_t fgConversionHiLoSigma;    //! Default fConversionHiLoSigma     (now set to: 2.5)
    1920  static const Float_t fgPheFFactorMethodLimit;  //! Default fPheFFactorMethodLimit   (now set to: 5.)
    2021  static const Float_t fgConvFFactorRelErrLimit; //! Default fConvFFactorRelErrLimit  (now set to: 0.35) 
     
    2526  Float_t fConversionHiLo;                  // Conversion factor betw. Hi Gain and Lo Gain 
    2627  Float_t fConversionHiLoVar;               // Variance Conversion factor betw. Hi and Lo Gain
     28  Float_t fConversionHiLoSigma;             // Sigma of conversion factor betw. Hi and Lo Gain
    2729  Float_t fConvFFactorRelVarLimit;          // Limit for acceptance rel. variance Conversion FADC2Phe
    2830  Float_t fLoGainPedRmsSquare;              // Pedestal RMS square of Low Gain
    2931  Float_t fLoGainPedRmsSquareVar;           // Pedestal RMS square Variance of Low Gain
    3032  Float_t fMeanConvFADC2Phe;                // Conversion factor (F-factor method)
    31   Float_t fMeanConvFADC2PheVar;             // Variance conversion factor (F-factor method)
     33  Float_t fMeanConvFADC2PheStatVar;         // Variance conversion factor, only stat. error
     34  Float_t fMeanConvFADC2PheSystVar;         // Variance conversion factor, only syst. error
    3235  Float_t fMeanFFactorFADC2Phot;            // Total mean F-Factor to photons (F-factor method)
    33   Float_t fMeanFFactorFADC2PhotVar;         // Variance mean F-Factor photons (F-factor method) 
     36  Float_t fMeanFFactorFADC2PhotVar;         // Variance mean F-Factor photons, only stat. error
    3437  Float_t fPed;                             // Pedestal (from MPedestalPix) times number FADC slices
    3538  Float_t fPedVar;                          // Variance of pedestal
    3639  Float_t fPedRms;                          // Pedestal RMS (from MPedestalPix) times sqrt nr. FADC slices
    3740  Float_t fPedRmsVar;                       // Pedestal RMS (from MPedestalPix) times sqrt nr. FADC slices
    38   Float_t fPheFFactorMethod;                // Number Phe's calculated (F-factor method)
    39   Float_t fPheFFactorMethodVar;             // Variance number of Phe's (F-factor method)
     41  Float_t fPheFFactorMethod;                // Number Phe's calculated  with F-factor method)
     42  Float_t fPheFFactorMethodStatVar;         // Variance number of Phe's, only stat. error
     43  Float_t fPheFFactorMethodSystVar;         // Variance number of Phe's, only syst. error
    4044  Float_t fPheFFactorMethodLimit;           // Min. number Photo-electrons for pix to be accepted.
    4145  Float_t fRSigmaSquare;                    // Square of Reduced sigma
     
    5155 
    5256public:
     57  MCalibrationChargePix(const char *name=NULL, const char *title=NULL);
    5358
    54   MCalibrationChargePix(const char *name=NULL, const char *title=NULL);
    55  
     59  // TObject
    5660  void Clear(Option_t *o="");
     61  void Copy(TObject& object) const;
    5762
    5863  // Setter
    59   void SetAbsTimeMean ( const Float_t f ) { fAbsTimeMean = f; }
    60   void SetAbsTimeRms  ( const Float_t f ) { fAbsTimeRms  = f; }
    61   void SetConversionHiLo    ( const Float_t c=fgConversionHiLo    )        { fConversionHiLo    = c;       }
    62   void SetConversionHiLoErr ( const Float_t e=fgConversionHiLoErr )        { fConversionHiLoVar = e*e;     }
     64  /*
    6365  void SetConvFFactorRelErrLimit   ( const Float_t f=fgConvFFactorRelErrLimit) { fConvFFactorRelVarLimit = f*f;}
    64   void SetFFactorMethodValid   ( const Bool_t b = kTRUE );
    6566  void SetMeanConvFADC2Phe      ( const Float_t f)                          { fMeanConvFADC2Phe       = f; }
    6667  void SetMeanConvFADC2PheVar   ( const Float_t f)                          { fMeanConvFADC2PheVar    = f; }
    6768  void SetMeanFFactorFADC2Phot  ( const Float_t f)                          { fMeanFFactorFADC2Phot   = f; }
    68   void SetPedestal              ( const Float_t ped, const Float_t pedrms, const Float_t pederr);
    69   void SetPed                   ( const Float_t ped, const Float_t pederr); 
    70   void SetPedRMS              ( const Float_t pedrms, const Float_t pedrmserr); 
    7169  void SetPheFFactorMethod      ( const Float_t f)                          { fPheFFactorMethod       = f; }
    7270  void SetPheFFactorMethodVar   ( const Float_t f)                          { fPheFFactorMethodVar    = f; } 
    7371  void SetPheFFactorMethodLimit ( const Float_t f=fgPheFFactorMethodLimit ) { fPheFFactorMethodLimit  = f; }
    7472  void SetNumSaturated          ( const Int_t   i)                          { fNumSaturated           = i; }
     73  */
     74  void SetFFactorMethodValid     (const Bool_t b = kTRUE );
     75  void SetPedestal               (const Float_t ped, const Float_t pedrms, const Float_t pederr);
     76  void SetPed                   ( const Float_t ped, const Float_t pederr); 
     77  void SetPedRMS              ( const Float_t pedrms, const Float_t pedrmserr); 
     78
     79  void SetAbsTimeMean            (const Float_t f)                          { fAbsTimeMean            = f; }
     80  void SetAbsTimeRms             (const Float_t f)                          { fAbsTimeRms             = f; }
     81  void SetConversionHiLo         (const Float_t c=fgConversionHiLo        ) { fConversionHiLo         = c; }
     82  void SetConversionHiLoErr      (const Float_t e=fgConversionHiLoErr     ) { fConversionHiLoVar      = e*e;}
     83  void SetConversionHiLoSigma    (const Float_t s=fgConversionHiLoSigma   ) { fConversionHiLoSigma    = s; }
     84  void SetConvFFactorRelErrLimit (const Float_t f=fgConvFFactorRelErrLimit) { fConvFFactorRelVarLimit = f*f;}
     85  void SetMeanConvFADC2Phe       (const Float_t f)                          { fMeanConvFADC2Phe       = f; }
     86  void SetMeanConvFADC2PheVar    (const Float_t f)                          { fMeanConvFADC2PheStatVar= f; }
     87  void SetMeanConvFADC2PheSystVar(const Float_t f)                          { fMeanConvFADC2PheSystVar= f; }
     88  void SetMeanFFactorFADC2Phot   (const Float_t f)                          { fMeanFFactorFADC2Phot   = f; }
     89  void SetNumSaturated           (const Int_t   i)                          { fNumSaturated           = i; }
     90  void SetPheFFactorMethod       (const Float_t f)                          { fPheFFactorMethod       = f; }
     91  void SetPheFFactorMethodVar    (const Float_t f)                          { fPheFFactorMethodStatVar= f; }
     92  void SetPheFFactorMethodSystVar(const Float_t f)                          { fPheFFactorMethodSystVar= f; }
     93  void SetPheFFactorMethodLimit  (const Float_t f=fgPheFFactorMethodLimit ) { fPheFFactorMethodLimit  = f; }
    7594 
    7695  // Getters
    77   Float_t GetAbsTimeMean             () const { return fAbsTimeMean;             }
    78   Float_t GetAbsTimeRms              () const { return fAbsTimeRms;              }
    79   Float_t GetConversionHiLo          () const { return fConversionHiLo;          }
    80   Float_t GetConversionHiLoErr       () const;
    81   Float_t GetConvertedMean           () const;
    82   Float_t GetConvertedMeanErr        () const;
    83   Float_t GetConvertedSigma          () const;
    84   Float_t GetConvertedSigmaErr       () const;
    85   Float_t GetConvertedRSigma         () const;
    86   Float_t GetConvertedRSigmaErr      () const;
    87   Float_t GetConvertedRSigmaSquare   () const; 
    88   Float_t GetMeanConvFADC2Phe        () const { return fMeanConvFADC2Phe;        }
    89   Float_t GetMeanConvFADC2PheErr     () const;
    90   Float_t GetMeanConvFADC2PheVar     () const { return fMeanConvFADC2PheVar;     }
    91   Float_t GetMeanFFactorFADC2Phot    () const { return fMeanFFactorFADC2Phot;    }
    92   Float_t GetMeanFFactorFADC2PhotErr () const;
    93   Float_t GetMeanFFactorFADC2PhotVar () const { return fMeanFFactorFADC2PhotVar; }   
    94   Int_t   GetNumSaturated            () const { return fNumSaturated;            }
    95   Float_t GetPed                     () const { return fPed;                     }
    96   Float_t GetPedErr                  () const { return TMath::Sqrt(fPedVar);     }
    97   Float_t GetPedRms                  () const;
    98   Float_t GetPedRmsErr               () const;
    99   Float_t GetPheFFactorMethod        () const { return fPheFFactorMethod;        }   
    100   Float_t GetPheFFactorMethodErr     () const;
    101   Float_t GetPheFFactorMethodVar     () const { return fPheFFactorMethodVar;     }
    102   Float_t GetPheFFactorMethodRelVar  () const;
    103   Float_t GetRSigma                  () const;
    104   Float_t GetRSigmaErr               () const;
    105   Float_t GetRSigmaRelVar            () const;
    106   Float_t GetRSigmaPerCharge         () const;
    107   Float_t GetRSigmaPerChargeErr      () const;
     96  Float_t GetAbsTimeMean        () const { return fAbsTimeMean;    }
     97  Float_t GetAbsTimeRms         () const { return fAbsTimeRms;     }
     98  Float_t GetConversionHiLo     () const { return fConversionHiLo; }
     99  Float_t GetConversionHiLoErr  () const { return fConversionHiLoVar<0 ? -1 : TMath::Sqrt(fConversionHiLoVar);  }
     100  Float_t GetConversionHiLoSigma() const { return fConversionHiLoSigma; }
     101  Float_t GetConvertedMean      () const { return IsHiGainSaturation() ? fLoGainMean * fConversionHiLo : fHiGainMean; }
     102  Float_t GetConvertedMeanErr   () const
     103  {
     104      if (!IsHiGainSaturation())
     105          return GetMeanErr();
     106      const Float_t logainrelvar = GetLoGainMeanRelVar();
     107      return logainrelvar<0 ? -1 : TMath::Sqrt(logainrelvar + GetConversionHiLoRelVar()) * GetConvertedMean();
     108  }
     109  Float_t GetConvertedSigma() const { return IsHiGainSaturation() ? fLoGainSigma * fConversionHiLo : fHiGainSigma; }
     110  Float_t GetConvertedSigmaErr() const
     111  {
     112    if (!IsHiGainSaturation())
     113        return GetSigmaErr();
    108114
    109   Bool_t IsFFactorMethodValid        () const;
     115    if (fLoGainSigmaVar<0 || fLoGainSigma<0)
     116        return -1.;
     117
     118    const Float_t sigmaRelVar = fLoGainSigmaVar/(fLoGainSigma*fLoGainSigma);
     119    return TMath::Sqrt(sigmaRelVar+GetConversionHiLoRelVar()) * GetConvertedSigma();
     120  }
     121  Float_t GetConvertedRSigma() const
     122  {
     123      if (fRSigmaSquare < 0)
     124          return -1;
     125      const Float_t rsigma = TMath::Sqrt(fRSigmaSquare);
     126      return IsHiGainSaturation() ? rsigma*fConversionHiLo : rsigma ;
     127  }
     128  Float_t GetConvertedRSigmaErr() const;
     129  Float_t GetConvertedRSigmaSquare() const
     130  {
     131      if (fRSigmaSquare < 0)
     132          return -1;
     133      return IsHiGainSaturation() ? fRSigmaSquare*fConversionHiLo*fConversionHiLo : fRSigmaSquare ;
     134  }
     135  Float_t GetMeanConvFADC2Phe() const { return fMeanConvFADC2Phe; }
     136  Float_t GetMeanConvFADC2PheErr  () const { return fMeanConvFADC2PheStatVar<0 ? -1 : TMath::Sqrt(fMeanConvFADC2PheStatVar); }
     137  Float_t GetMeanConvFADC2PheSystErr() const { return fMeanConvFADC2PheSystVar<0 ? -1 : TMath::Sqrt(fMeanConvFADC2PheSystVar); }
     138  Float_t GetMeanConvFADC2PheTotErr() const
     139  {
     140      if (fMeanConvFADC2PheSystVar<0 || fMeanConvFADC2PheStatVar<0)
     141          return -1.;
     142      return TMath::Sqrt(fMeanConvFADC2PheSystVar+fMeanConvFADC2PheStatVar);
     143  }
     144  Float_t GetFFactorFADC2Phe        () const { return gkFFactor;   }
     145  Float_t GetMeanConvFADC2PheVar    () const { return fMeanConvFADC2PheStatVar; }
     146  Float_t GetMeanConvFADC2PheSystVar() const { return fMeanConvFADC2PheSystVar; }
     147
     148  Float_t GetMeanFFactorFADC2Phot   () const { return fMeanFFactorFADC2Phot;    }
     149  Float_t GetMeanFFactorFADC2PhotErr() const { return fMeanFFactorFADC2PhotVar<0 ? -1. : TMath::Sqrt(fMeanFFactorFADC2PhotVar); }
     150  Float_t GetMeanFFactorFADC2PhotVar() const { return fMeanFFactorFADC2PhotVar; }
     151  Int_t   GetNumSaturated           () const { return fNumSaturated;            }   
     152  Float_t GetPed                    () const { return fPed;                     }
     153  Float_t GetPedErr                 () const { return TMath::Sqrt(fPedVar);     }
     154  Float_t GetPedRms                 () const
     155  {
     156    if (!IsHiGainSaturation())
     157        return fPedRms;
     158    return fLoGainPedRmsSquare<0 ? -1 : TMath::Sqrt(fLoGainPedRmsSquare);
     159  }
     160  Float_t GetPedRmsErr              () const;
     161  Float_t GetPheFFactorMethod       () const { return fPheFFactorMethod; }
     162  Float_t GetPheFFactorMethodErr    () const { return fPheFFactorMethodStatVar<0 ? -1 : TMath::Sqrt(fPheFFactorMethodStatVar); }
     163  Float_t GetPheFFactorMethodSystErr() const { return fPheFFactorMethodSystVar<0 ? -1 : TMath::Sqrt(fPheFFactorMethodSystVar); }
     164  Float_t GetPheFFactorMethodTotErr () const
     165  {
     166      if (fPheFFactorMethodStatVar<0 || fPheFFactorMethodSystVar<0)
     167          return -1.;
     168      return TMath::Sqrt(fPheFFactorMethodStatVar+fPheFFactorMethodSystVar);
     169  }
     170  Float_t GetPheFFactorMethodVar    () const { return fPheFFactorMethodStatVar; }
     171  Float_t GetPheFFactorMethodSystVar() const { return fPheFFactorMethodSystVar; }
     172  Float_t GetPheFFactorMethodRelVar () const { return fPheFFactorMethodStatVar<=0 ? -1 : fPheFFactorMethodStatVar / (fPheFFactorMethod * fPheFFactorMethod); }
     173  Float_t GetPheFFactorMethodRelSystVar() const { return fPheFFactorMethodSystVar<=0 ? -1. : fPheFFactorMethodSystVar / (fPheFFactorMethod * fPheFFactorMethod); }
     174  Float_t GetRSigma                 () const { return fRSigmaSquare<0 ? -1 : TMath::Sqrt(fRSigmaSquare); }
     175
     176  Float_t GetRSigmaErr         () const;
     177  Float_t GetRSigmaRelVar      () const;
     178  Float_t GetRSigmaPerCharge   () const;
     179  Float_t GetRSigmaPerChargeErr() const;
     180
     181  Bool_t IsFFactorMethodValid() const;
    110182
    111183  // Calculations
  • trunk/MagicSoft/Mars/mcalib/MCalibrationHiLoPix.cc

    r5749 r7188  
    1818!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2004
     20!   Copyright: MAGIC Software Development, 2000-2005
    2121!
    2222\* ======================================================================== */
    2323/////////////////////////////////////////////////////////////////////////////
    24 //                                                                         //
    25 // MCalibrationHiLoPix                                                     //
    26 //                                                                         //
    27 // Storage container for high-gain vs. low-gain charge calibration results //
    28 // of one Pixel (PMT).                                                     //
    29 // The following "calibration" constants can be retrieved:                 //
     24//
     25// MCalibrationHiLoPix
     26//
     27// Storage container for high-gain vs. low-gain charge calibration results
     28// of one Pixel (PMT).
     29// The following "calibration" constants can be retrieved:
    3030// - GetHiLoRatio(): The mean conversion High-gain vs. Low-gain
    3131//   with which the low-gain result has to be multiplied
    32 // - GetHiLoSigma(): The Gauss sigma of histogrammed High-gain vs. Low-gain ratios
     32// - GetHiLoSigma(): The Gauss sigma of histogrammed High-gain vs.
     33//   Low-gain ratios
    3334//
    34 // See also: MHCalibrationHiLoPix, MHCalibrationHiLoCam              //
    35 //                                                                         //
     35// See also: MHCalibrationHiLoPix, MHCalibrationHiLoCam
     36//
     37// Class Version 2:
     38//  + Float_t fOffsetPerSlice;  // Offset from fit (per FADC slice)
     39//  + Float_t fGainRatio;       // Ratio of gains from fit
     40//
    3641/////////////////////////////////////////////////////////////////////////////
    3742#include "MCalibrationHiLoPix.h"
     
    4651//
    4752MCalibrationHiLoPix::MCalibrationHiLoPix(const char *name, const char *title)
     53  : fOffsetPerSlice(-9999.), fGainRatio(-1.)
    4854{
    4955
     
    5258
    5359}
    54 
  • trunk/MagicSoft/Mars/mcalib/MCalibrationHiLoPix.h

    r5946 r7188  
    99{
    1010private:
     11    Float_t fOffsetPerSlice;            // Offset from fit (per FADC slice)
     12    Float_t fGainRatio;                 // Ratio of gains from fit
    1113
    1214public:
     15  MCalibrationHiLoPix(const char *name=NULL, const char *title=NULL);
    1316
    14   MCalibrationHiLoPix(const char *name=NULL, const char *title=NULL);
    15   ~MCalibrationHiLoPix() {}
    16  
     17  // Setter
     18  void SetGainRatio     (const Float_t f) { fGainRatio      = f; }
     19  void SetOffsetPerSlice(const Float_t f) { fOffsetPerSlice = f; }
     20
     21  // Getter
    1722  Float_t GetHiLoChargeRatio()         const { return GetHiGainMean();     }
    1823  Float_t GetHiLoChargeRatioErr()      const { return GetHiGainMeanErr();  }
     
    2631  Float_t GetHiLoTimeDiffSigmaErr()    const { return GetLoGainSigmaErr(); }
    2732  Float_t GetHiLoTimeDiffProb()        const { return GetLoGainProb();     }
     33  Float_t GetGainRatio     ()          const { return fGainRatio;          }
     34  Float_t GetOffsetPerSlice()          const { return fOffsetPerSlice;     }
    2835
    29   ClassDef(MCalibrationHiLoPix, 1)      // Container HiLo conversion Calibration Results Pixel
     36  ClassDef(MCalibrationHiLoPix, 2)      // Container HiLo conversion Calibration Results Pixel
    3037};
    3138
  • trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc

    r6412 r7188  
    594594          varerr[i] = pix.GetRSigmaErr();
    595595        }
    596       if (option.Contains("abstime"))
     596      if (option.Contains("abstimemean"))
    597597        {
    598598          var   [i] = pix.GetAbsTimeMean();
    599599          varerr[i] = pix.GetAbsTimeRms();
    600600        }
     601      if (option.Contains("abstimerms"))
     602        {
     603          var   [i] = pix.GetAbsTimeRms();
     604          varerr[i] = pix.GetAbsTimeRms()/2.;
     605        }
    601606      if (option.Contains("blackout"))
    602607        {
     
    663668          var   [i] = pix.GetRSigmaPerCharge();
    664669          varerr[i] = pix.GetRSigmaPerChargeErr();
     670        }
     671      if (option.Contains("conversionfactor"))
     672        {
     673          const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(0);
     674          const Float_t mean = pix.GetConvertedMean();
     675          const Float_t phe  = apix.GetPheFFactorMethod();
     676
     677          var[i]    = phe/mean;
     678          varerr[i] = TMath::Sqrt(apix.GetPheFFactorMethodErr()*apix.GetPheFFactorMethodErr()/mean/mean
     679                                  + phe*phe/mean/mean/mean/mean*pix.GetConvertedMeanErr()*pix.GetConvertedMeanErr());
    665680        }
    666681  }
     
    735750         
    736751          if (option.Contains("rsigma"))
     752              pvar = pix.GetRSigma();
     753          if (option.Contains("abstimemean"))
     754              pvar = pix.GetAbsTimeMean();
     755          if (option.Contains("abstimerms"))
     756              pvar = pix.GetAbsTimeRms();
     757          if (option.Contains("conversionhilo"))
     758              pvar = pix.GetConversionHiLo();
     759          if (option.Contains("convertedmean"))
     760              pvar = pix.GetConvertedMean();
     761          if (option.Contains("convertedsigma"))
     762              pvar = pix.GetConvertedSigma();
     763          if (option.Contains("convertedrsigma"))
     764              pvar = pix.GetConvertedRSigma();
     765          if (option.Contains("meanconvfadc2phe"))
     766              pvar = pix.GetMeanConvFADC2Phe();
     767          if (option.Contains("meanffactorfadc2phot"))
     768              pvar = pix.GetMeanFFactorFADC2Phot();
     769          if (option.Contains("ped"))
     770              pvar = pix.GetPed();
     771          if (option.Contains("pedrms"))
     772              pvar = pix.GetPedRms();
     773          if (option.Contains("pheffactormethod"))
     774              pvar = pix.GetPheFFactorMethod();
     775          if (option.Contains("rsigmapercharge"))
     776              pvar = pix.GetRSigmaPerCharge();
     777          if (option.Contains("conversionfactor"))
     778          {
     779              const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
     780              pvar = apix.GetPheFFactorMethod()/pix.GetConvertedMean();
     781          }
     782
     783
     784          variab  += pvar;
     785          variab2 += pvar*pvar;
     786          num++;
     787         
     788          camcharge.Fill(j,pvar);
     789          camcharge.SetUsed(j);
     790        }
     791     
     792      if (num > 1)
     793        {
     794          variab  /= num;
     795          variance = (variab2 - variab*variab*num) / (num-1);
     796
     797          vararea[i]    = variab;
     798          varareaerr[i] = variance>0 ? TMath::Sqrt(variance/num) : 999999999.;
     799
     800          //
     801          // Make also a Gauss-fit to the distributions. The RMS can be determined by
     802          // outlier, thus we look at the sigma and the RMS and take the smaller one, afterwards.
     803          //
     804          h = camcharge.ProjectionS(TArrayI(),TArrayI(1,&aidx),"_py",750);
     805          h->SetDirectory(NULL);
     806          h->Fit("gaus","QL");
     807          TF1 *fit = h->GetFunction("gaus");
     808
     809          Float_t ci2   = fit->GetChisquare();
     810          Float_t sigma = fit->GetParameter(2);
     811
     812          if (ci2 > 500. || sigma > varareaerr[i])
     813            {
     814              h->Fit("gaus","QLM");
     815              fit = h->GetFunction("gaus");
     816
     817              ci2   = fit->GetChisquare();
     818              sigma = fit->GetParameter(2);
     819            }
     820         
     821          const Float_t mean  = fit->GetParameter(1);
     822          const Float_t ndf   = fit->GetNDF();
     823         
     824          *fLog << inf << "Camera Nr: " << i << endl;
     825          *fLog << inf << option.Data() << " area idx: " << aidx << " Results: " << endl;
     826          *fLog << inf << "Mean: " << Form("%4.3f",mean)
     827                << "+-" << Form("%4.3f",fit->GetParError(1))
     828                << "  Sigma: " << Form("%4.3f",sigma) << "+-" << Form("%4.3f",fit->GetParError(2))
     829                << "  Chisquare: " << Form("%4.3f",ci2) << "  NDF  : " << ndf << endl;
     830          delete h;
     831          gROOT->GetListOfFunctions()->Remove(fit);
     832
     833          if (sigma<varareaerr[i] && ndf>2 && ci2<500.)
     834            {
     835              vararea   [i] = mean;
     836              varareaerr[i] = sigma/TMath::Sqrt((Float_t)num);
     837            }
     838        }
     839      else
     840        {
     841          vararea[i]    = -1.;
     842          varareaerr[i] = 0.;
     843        }
     844
     845      nr[i] = i;
     846      nrerr[i] = 0.;
     847    }
     848 
     849  TGraphErrors *gr = new TGraphErrors(size,
     850                                     nr.GetArray(),vararea.GetArray(),
     851                                     nrerr.GetArray(),varareaerr.GetArray());
     852  gr->SetTitle(Form("%s Area %3i Average",option.Data(),aidx));
     853  gr->GetXaxis()->SetTitle("Camera Nr.");
     854  //  gr->GetYaxis()->SetTitle("<Q> [1]");     
     855  return gr;
     856}
     857
     858
     859// -------------------------------------------------------------------
     860//
     861// Returns a TGraphErrors with the mean effective number of photon
     862// vs. the calibration camera number. With the string 'method', different
     863// calibration methods can be called.
     864//
     865TGraphErrors *MCalibrationIntensityChargeCam::GetPhotVsTime( const Option_t *method )
     866{
     867 
     868  const Int_t size = GetSize();
     869 
     870  if (size == 0)
     871    return NULL;
     872
     873  TString option(method);
     874
     875  TArrayF photarr(size);
     876  TArrayF photarrerr(size);
     877  TArrayF nr(size);
     878  TArrayF nrerr(size);
     879 
     880  for (Int_t i=0;i<GetSize();i++)
     881    {
     882      //
     883      // Get the calibration cam from the intensity cam
     884      //
     885      MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
     886
     887      //
     888      // Get the calibration pix from the calibration cam
     889      //
     890      Float_t phot    = 0.;
     891      Float_t photerr = 0.;
     892
     893      if (option.Contains("BlindPixel"))
     894        {
     895          phot    = cam->GetNumPhotonsBlindPixelMethod();
     896          photerr = cam->GetNumPhotonsBlindPixelMethodErr();
     897        }
     898      if (option.Contains("FFactor"))
     899        {
     900          phot    = cam->GetNumPhotonsFFactorMethod();
     901          photerr = cam->GetNumPhotonsFFactorMethodErr();
     902        }
     903      if (option.Contains("PINDiode"))
     904        {
     905          phot    = cam->GetNumPhotonsPINDiodeMethod();
     906          photerr = cam->GetNumPhotonsPINDiodeMethodErr();
     907        }
     908
     909      photarr[i]       = phot;
     910      photarrerr[i]    = photerr;
     911
     912      nr[i] = i;
     913      nrerr[i] = 0.;
     914    }
     915 
     916  TGraphErrors *gr = new TGraphErrors(size,
     917                                     nr.GetArray(),photarr.GetArray(),
     918                                     nrerr.GetArray(),photarrerr.GetArray());
     919  gr->SetTitle("Photons Average");
     920  gr->GetXaxis()->SetTitle("Camera Nr.");
     921  gr->GetYaxis()->SetTitle("<N_{phot}> [1]");
     922  return gr;
     923}
     924
     925// -------------------------------------------------------------------
     926//
     927// Returns a TGraphErrors with the mean effective number of photo-electrons per
     928// area index 'aidx' vs. the calibration camera number
     929//
     930TGraphErrors *MCalibrationIntensityChargeCam::GetPhePerAreaVsTime( const Int_t aidx, const MGeomCam &geom)
     931{
     932 
     933  const Int_t size = GetSize();
     934 
     935  if (size == 0)
     936    return NULL;
     937 
     938  TArrayF phearea(size);
     939  TArrayF pheareaerr(size);
     940  TArrayF time(size);
     941  TArrayF timeerr(size);
     942 
     943  for (Int_t i=0;i<GetSize();i++)
     944    {
     945      //
     946      // Get the calibration cam from the intensity cam
     947      //
     948      MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
     949
     950      //
     951      // Get the calibration pix from the calibration cam
     952      //
     953      const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
     954      const Float_t phe          = apix.GetPheFFactorMethod();
     955      const Float_t pheerr       = apix.GetPheFFactorMethodErr();
     956
     957      phearea[i]       = phe;
     958      pheareaerr[i]    = pheerr;
     959
     960      time[i] = i;
     961      timeerr[i] = 0.;
     962    }
     963 
     964  TGraphErrors *gr = new TGraphErrors(size,
     965                                     time.GetArray(),phearea.GetArray(),
     966                                     timeerr.GetArray(),pheareaerr.GetArray());
     967  gr->SetTitle(Form("Phes Area %d Average",aidx));
     968  gr->GetXaxis()->SetTitle("Camera Nr.");
     969  gr->GetYaxis()->SetTitle("<N_{phe}> [1]");
     970  return gr;
     971}
     972
     973// -------------------------------------------------------------------
     974//
     975// Returns a TGraphErrors with the event-by-event averaged charge per
     976// area index 'aidx' vs. the calibration camera number
     977//
     978TGraphErrors *MCalibrationIntensityChargeCam::GetChargePerAreaVsTime( const Int_t aidx, const MGeomCam &geom)
     979{
     980 
     981  const Int_t size = GetSize();
     982 
     983  if (size == 0)
     984    return NULL;
     985 
     986  TArrayF chargearea(size);
     987  TArrayF chargeareaerr(size);
     988  TArrayF nr(size);
     989  TArrayF nrerr(size);
     990 
     991  for (Int_t i=0;i<GetSize();i++)
     992    {
     993      //
     994      // Get the calibration cam from the intensity cam
     995      //
     996      MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
     997
     998      //
     999      // Get the calibration pix from the calibration cam
     1000      //
     1001      const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
     1002      const Float_t charge          = apix.GetConvertedMean();
     1003      const Float_t chargeerr       = apix.GetConvertedSigma();
     1004
     1005      chargearea[i]       = charge;
     1006      chargeareaerr[i]    = chargeerr;
     1007
     1008      nr[i]    = i;
     1009      nrerr[i] = 0.;
     1010    }
     1011 
     1012  TGraphErrors *gr = new TGraphErrors(size,
     1013                                     nr.GetArray(),chargearea.GetArray(),
     1014                                     nrerr.GetArray(),chargeareaerr.GetArray());
     1015  gr->SetTitle(Form("Averaged Charges Area Idx %d",aidx));
     1016  gr->GetXaxis()->SetTitle("Camera Nr.");
     1017  gr->GetYaxis()->SetTitle("<Q> [FADC cnts]");     
     1018  return gr;
     1019}
     1020
     1021TH1F *MCalibrationIntensityChargeCam::GetVarFluctuations( const Int_t aidx, const MGeomCam &geom, const Option_t *varname )
     1022{
     1023 
     1024  const Int_t size = GetSize();
     1025 
     1026  if (size == 0)
     1027    return NULL;
     1028 
     1029  TString option(varname);
     1030  option.ToLower();
     1031 
     1032  TH1F *hist = new TH1F("hist",Form("%s - Rel. Fluctuations %s Pixel",option.Data(),aidx ? "Outer" : "Inner"),
     1033                        200,0.,100.);
     1034  hist->SetXTitle("Relative Fluctuation [%]");
     1035  hist->SetYTitle("Nr. channels [1]"); 
     1036  hist->SetFillColor(kRed+aidx);
     1037
     1038  MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam();
     1039
     1040  //
     1041  // Loop over pixels
     1042  //
     1043  for (Int_t npix=0;npix<cam->GetSize();npix++)
     1044    {
     1045      if (geom[npix].GetAidx() != aidx)
     1046        continue;
     1047
     1048      Double_t variab   = 0.;
     1049      Double_t variab2  = 0.;
     1050      Double_t variance = 0.;
     1051      Int_t    num      = 0;
     1052      Float_t  pvar     = 0.;
     1053      Float_t  relrms   = 99.9;
     1054      //
     1055      // Loop over the Cams for each pixel
     1056      //
     1057      for (Int_t i=0; i<GetSize(); i++)
     1058        {
     1059          MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
     1060          //
     1061          // Get the calibration pix from the calibration cam
     1062          //
     1063          MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[npix];
     1064          //
     1065          // Don't use bad pixels
     1066          //
     1067          if (!pix.IsFFactorMethodValid())
     1068            continue;
     1069
     1070          if (option.Contains("rsigma"))
    7371071            pvar = pix.GetRSigma();
    738           if (option.Contains("abstime"))
     1072          if (option.Contains("abstimemean"))
    7391073            pvar = pix.GetAbsTimeMean();
     1074          if (option.Contains("abstimerms"))
     1075            pvar = pix.GetAbsTimeRms();
    7401076          if (option.Contains("conversionhilo"))
    7411077            pvar = pix.GetConversionHiLo();
     
    7581094          if (option.Contains("rsigmapercharge"))
    7591095            pvar = pix.GetRSigmaPerCharge();
     1096          if (option.Contains("conversionfactor"))
     1097          {
     1098              const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(0);
     1099              pvar = apix.GetPheFFactorMethod()/pix.GetConvertedMean();
     1100          }
     1101
    7601102
    7611103          variab  += pvar;
    7621104          variab2 += pvar*pvar;
    7631105          num++;
    764          
    765           camcharge.Fill(j,pvar);
    766           camcharge.SetUsed(j);
    767         }
    768      
    769       if (num > 1)
    770         {
    771           variab  /= num;
    772           variance = (variab2 - variab*variab*num) / (num-1);
    773 
    774           vararea[i] = variab;
    775           if (variance > 0.)
    776             varareaerr[i] = TMath::Sqrt(variance);
    777           else
    778             varareaerr[i] = 999999999.;
    779 
    780           //
    781           // Make also a Gauss-fit to the distributions. The RMS can be determined by
    782           // outlier, thus we look at the sigma and the RMS and take the smaller one, afterwards.
    783           //
    784           h = camcharge.ProjectionS(TArrayI(),TArrayI(1,&aidx),"_py",750);
    785           h->SetDirectory(NULL);
    786           h->Fit("gaus","QL");
    787           TF1 *fit = h->GetFunction("gaus");
    788 
    789           Float_t ci2   = fit->GetChisquare();
    790           Float_t sigma = fit->GetParameter(2);
    791 
    792           if (ci2 > 500. || sigma > varareaerr[i])
    793             {
    794               h->Fit("gaus","QLM");
    795               fit = h->GetFunction("gaus");
    796 
    797               ci2   = fit->GetChisquare();
    798               sigma = fit->GetParameter(2);
    799             }
    800          
    801           const Float_t mean  = fit->GetParameter(1);
    802           const Float_t ndf   = fit->GetNDF();
    803          
    804           *fLog << inf << "Camera Nr: " << i << endl;
    805           *fLog << inf << option.Data() << " area idx: " << aidx << " Results: " << endl;
    806           *fLog << inf << "Mean: " << Form("%4.3f",mean)
    807                 << "+-" << Form("%4.3f",fit->GetParError(1))
    808                 << "  Sigma: " << Form("%4.3f",sigma) << "+-" << Form("%4.3f",fit->GetParError(2))
    809                 << "  Chisquare: " << Form("%4.3f",fit->GetChisquare()) << "  NDF  : " << ndf << endl;         
    810           delete h;
    811           gROOT->GetListOfFunctions()->Remove(fit);
    812 
    813           if (sigma < varareaerr[i] && ndf > 2)
    814             {
    815               vararea   [i] = mean;
    816               varareaerr[i] = sigma;
    817             }
    818         }
    819       else
    820         {
    821           vararea[i]    = -1.;
    822           varareaerr[i] = 0.;
    823         }
    824 
    825       nr[i] = i;
    826       nrerr[i] = 0.;
    827     }
    828  
    829   TGraphErrors *gr = new TGraphErrors(size,
    830                                      nr.GetArray(),vararea.GetArray(),
    831                                      nrerr.GetArray(),varareaerr.GetArray());
    832   gr->SetTitle(Form("%s Area %3i Average",option.Data(),aidx));
    833   gr->GetXaxis()->SetTitle("Camera Nr.");
    834   //  gr->GetYaxis()->SetTitle("<Q> [1]");     
    835   return gr;
    836 }
    837 
    838 
    839 // -------------------------------------------------------------------
    840 //
    841 // Returns a TGraphErrors with the mean effective number of photon
    842 // vs. the calibration camera number. With the string 'method', different
    843 // calibration methods can be called.
    844 //
    845 TGraphErrors *MCalibrationIntensityChargeCam::GetPhotVsTime( const Option_t *method )
    846 {
    847  
    848   const Int_t size = GetSize();
    849  
    850   if (size == 0)
    851     return NULL;
    852 
    853   TString option(method);
    854 
    855   TArrayF photarr(size);
    856   TArrayF photarrerr(size);
    857   TArrayF nr(size);
    858   TArrayF nrerr(size);
    859  
    860   for (Int_t i=0;i<GetSize();i++)
    861     {
    862       //
    863       // Get the calibration cam from the intensity cam
    864       //
    865       MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
    866 
    867       //
    868       // Get the calibration pix from the calibration cam
    869       //
    870       Float_t phot    = 0.;
    871       Float_t photerr = 0.;
    872 
    873       if (option.Contains("BlindPixel"))
    874         {
    875           phot    = cam->GetNumPhotonsBlindPixelMethod();
    876           photerr = cam->GetNumPhotonsBlindPixelMethodErr();
    877         }
    878       if (option.Contains("FFactor"))
    879         {
    880           phot    = cam->GetNumPhotonsFFactorMethod();
    881           photerr = cam->GetNumPhotonsFFactorMethodErr();
    882         }
    883       if (option.Contains("PINDiode"))
    884         {
    885           phot    = cam->GetNumPhotonsPINDiodeMethod();
    886           photerr = cam->GetNumPhotonsPINDiodeMethodErr();
    887         }
    888 
    889       photarr[i]       = phot;
    890       photarrerr[i]    = photerr;
    891 
    892       nr[i] = i;
    893       nrerr[i] = 0.;
    894     }
    895  
    896   TGraphErrors *gr = new TGraphErrors(size,
    897                                      nr.GetArray(),photarr.GetArray(),
    898                                      nrerr.GetArray(),photarrerr.GetArray());
    899   gr->SetTitle("Photons Average");
    900   gr->GetXaxis()->SetTitle("Camera Nr.");
    901   gr->GetYaxis()->SetTitle("<N_phot> [1]");     
    902   return gr;
    903 }
    904 
    905 // -------------------------------------------------------------------
    906 //
    907 // Returns a TGraphErrors with the mean effective number of photo-electrons per
    908 // area index 'aidx' vs. the calibration camera number
    909 //
    910 TGraphErrors *MCalibrationIntensityChargeCam::GetPhePerAreaVsTime( const Int_t aidx, const MGeomCam &geom)
    911 {
    912  
    913   const Int_t size = GetSize();
    914  
    915   if (size == 0)
    916     return NULL;
    917  
    918   TArrayF phearea(size);
    919   TArrayF pheareaerr(size);
    920   TArrayF time(size);
    921   TArrayF timeerr(size);
    922  
    923   for (Int_t i=0;i<GetSize();i++)
    924     {
    925       //
    926       // Get the calibration cam from the intensity cam
    927       //
    928       MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
    929 
    930       //
    931       // Get the calibration pix from the calibration cam
    932       //
    933       const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
    934       const Float_t phe          = apix.GetPheFFactorMethod();
    935       const Float_t pheerr       = apix.GetPheFFactorMethodErr();
    936 
    937       phearea[i]       = phe;
    938       pheareaerr[i]    = pheerr;
    939 
    940       time[i] = i;
    941       timeerr[i] = 0.;
    942     }
    943  
    944   TGraphErrors *gr = new TGraphErrors(size,
    945                                      time.GetArray(),phearea.GetArray(),
    946                                      timeerr.GetArray(),pheareaerr.GetArray());
    947   gr->SetTitle(Form("Phes Area %d Average",aidx));
    948   gr->GetXaxis()->SetTitle("Camera Nr.");
    949   gr->GetYaxis()->SetTitle("<N_phes> [1]");     
    950   return gr;
    951 }
    952 
    953 // -------------------------------------------------------------------
    954 //
    955 // Returns a TGraphErrors with the event-by-event averaged charge per
    956 // area index 'aidx' vs. the calibration camera number
    957 //
    958 TGraphErrors *MCalibrationIntensityChargeCam::GetChargePerAreaVsTime( const Int_t aidx, const MGeomCam &geom)
    959 {
    960  
    961   const Int_t size = GetSize();
    962  
    963   if (size == 0)
    964     return NULL;
    965  
    966   TArrayF chargearea(size);
    967   TArrayF chargeareaerr(size);
    968   TArrayF nr(size);
    969   TArrayF nrerr(size);
    970  
    971   for (Int_t i=0;i<GetSize();i++)
    972     {
    973       //
    974       // Get the calibration cam from the intensity cam
    975       //
    976       MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
    977 
    978       //
    979       // Get the calibration pix from the calibration cam
    980       //
    981       const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
    982       const Float_t charge          = apix.GetConvertedMean();
    983       const Float_t chargeerr       = apix.GetConvertedSigma();
    984 
    985       chargearea[i]       = charge;
    986       chargeareaerr[i]    = chargeerr;
    987 
    988       nr[i]    = i;
    989       nrerr[i] = 0.;
    990     }
    991  
    992   TGraphErrors *gr = new TGraphErrors(size,
    993                                      nr.GetArray(),chargearea.GetArray(),
    994                                      nrerr.GetArray(),chargeareaerr.GetArray());
    995   gr->SetTitle(Form("Averaged Charges Area Idx %d",aidx));
    996   gr->GetXaxis()->SetTitle("Camera Nr.");
    997   gr->GetYaxis()->SetTitle("<Q> [FADC cnts]");     
    998   return gr;
    999 }
    1000 
    1001 TH1F *MCalibrationIntensityChargeCam::GetVarFluctuations( const Int_t aidx, const MGeomCam &geom, const Option_t *varname )
    1002 {
    1003  
    1004   const Int_t size = GetSize();
    1005  
    1006   if (size == 0)
    1007     return NULL;
    1008  
    1009   TString option(varname);
    1010  
    1011   TH1F *hist = new TH1F("hist",Form("%s - Rel. Fluctuations %s Pixel",option.Data(),aidx ? "Outer" : "Inner"),
    1012                         200,0.,100.);
    1013   hist->SetXTitle("Relative Fluctuation [%]");
    1014   hist->SetYTitle("Nr. channels [1]"); 
    1015   hist->SetFillColor(kRed+aidx);
    1016 
    1017   MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam();
    1018 
    1019   //
    1020   // Loop over pixels
    1021   //
    1022   for (Int_t npix=0;npix<cam->GetSize();npix++)
    1023     {
    1024       if (geom[npix].GetAidx() != aidx)
    1025         continue;
    1026 
    1027       Double_t variab   = 0.;
    1028       Double_t variab2  = 0.;
    1029       Double_t variance = 0.;
    1030       Int_t    num      = 0;
    1031       Float_t  pvar     = 0.;
    1032       Float_t  relrms   = 99.9;
    1033       //
    1034       // Loop over the Cams for each pixel
    1035       //
    1036       for (Int_t i=0; i<GetSize(); i++)
    1037         {
    1038           MCalibrationChargeCam *cam = (MCalibrationChargeCam*)GetCam(i);
    1039           //
    1040           // Get the calibration pix from the calibration cam
    1041           //
    1042           MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[npix];
    1043           //
    1044           // Don't use bad pixels
    1045           //
    1046           if (!pix.IsFFactorMethodValid())
    1047             continue;
    1048 
    1049           if (option.Contains("RSigma"))
    1050             pvar = pix.GetRSigma();
    1051           if (option.Contains("AbsTime"))
    1052             pvar = pix.GetAbsTimeMean();
    1053           if (option.Contains("ConversionHiLo"))
    1054             pvar = pix.GetConversionHiLo();
    1055           if (option.Contains("ConvertedMean"))
    1056             pvar = pix.GetConvertedMean();
    1057           if (option.Contains("ConvertedSigma"))
    1058             pvar = pix.GetConvertedSigma();
    1059           if (option.Contains("ConvertedRSigma"))
    1060             pvar = pix.GetConvertedRSigma();
    1061           if (option.Contains("MeanConvFADC2Phe"))
    1062             pvar = pix.GetMeanConvFADC2Phe();
    1063           if (option.Contains("MeanFFactorFADC2Phot"))
    1064             pvar = pix.GetMeanFFactorFADC2Phot();
    1065           if (option.Contains("Ped"))
    1066             pvar = pix.GetPed();
    1067           if (option.Contains("PedRms"))
    1068             pvar = pix.GetPedRms();
    1069           if (option.Contains("PheFFactorMethod"))
    1070             pvar = pix.GetPheFFactorMethod();
    1071           if (option.Contains("RSigmaPerCharge"))
    1072             pvar = pix.GetRSigmaPerCharge();
    1073 
    1074           variab  += pvar;
    1075           variab2 += pvar*pvar;
    1076           num++;
    10771106        }
    10781107
  • trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc

    r6963 r7188  
    4040//                  - FinalizeBadPixels()
    4141//
     42// Class Version 2:
     43//  + Byte_t fCheckFlags; // Bit-field to hold the possible check flags
     44//
     45//
    4246//  Input Containers:
    4347//   MCalibrationRelTimeCam
     
    7175#include "MBadPixelsPix.h"
    7276
    73 
    7477ClassImp(MCalibrationRelTimeCalc);
    7578
     
    7780
    7881const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 1.0;
     82
    7983// --------------------------------------------------------------------------
    8084//
     
    97101  fName  = name  ? name  : "MCalibrationRelTimeCalc";
    98102  fTitle = title ? title : "Task to finalize the relative time calibration";
    99  
     103
     104  SetCheckFitResults       ( kFALSE );
     105  SetCheckDeviatingBehavior( kFALSE );
     106  SetCheckHistOverflow     ( kFALSE );
     107  SetCheckOscillations     ( kFALSE );
     108
    100109  SetRelTimeResolutionLimit();
    101110  SetOutputPath();
    102111  SetOutputFile("");
    103  
     112
    104113  Clear();
    105  
     114
    106115}
    107116
     
    268277
    269278  PrintUncalibrated(MBadPixelsPix::kDeviatingTimeResolution,   
    270                     Form("%s%2.1f%s","Time resolution less than ",fRelTimeResolutionLimit," FADC slices from Mean:   "));
     279                    Form("%s%2.1f%s","Time resol. less than ",fRelTimeResolutionLimit," FADC sl. from Mean:     "));
    271280  PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating,   
    272281                    "Pixels with changing Rel. Times over time:             ");
     
    437446      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*relcam)[i];
    438447
    439       if (bad.IsUncalibrated( MBadPixelsPix::kDeviatingTimeResolution))
    440         bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun   );
    441  
    442       if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted))
    443         bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun   );
    444  
    445       if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
    446         bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun   );
    447  
    448       if (bad.IsUnsuitable(   MBadPixelsPix::kUnsuitableRun    ))
    449         pix.SetExcluded();
    450 
    451     }
     448      if (IsCheckDeviatingBehavior())
     449          if (bad.IsUncalibrated(MBadPixelsPix::kDeviatingTimeResolution))
     450              bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
     451
     452      if (IsCheckFitResults())
     453          if (bad.IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted))
     454              bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
     455
     456      if (IsCheckOscillations())
     457          if (bad.IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
     458              bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
     459
     460      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
     461          pix.SetExcluded();
     462    }
     463
    452464}
    453465
     
    488500
    489501  if (fGeom->InheritsFrom("MGeomCamMagic"))
    490     *fLog << " " << setw(7) << "Uncalibrated Pixels:            "
    491           << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
     502    *fLog << " " << setw(7) << "Uncalibrated Pixels:            Inner: "
     503          << Form("%3i",counts[0]) << " Outer: " << Form("%3i",counts[1]) << endl;
    492504
    493505  counts.Reset();
     
    506518    relcam->SetNumUnreliable(counts[aidx], aidx);
    507519
    508   *fLog << " " << setw(7) << "Unreliable Pixels:              "
    509         << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
     520  *fLog << " " << setw(7) << "Unreliable Pixels:              Inner: "
     521        << Form("%3i",counts[0]) << " Outer: " << Form("%3i",counts[1]) << endl;
    510522
    511523}
     
    545557void MCalibrationRelTimeCalc::SetOutputPath(TString path)
    546558{
    547   fOutputPath = path;
    548   if (fOutputPath.EndsWith("/"))
    549     fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
     559    fOutputPath = path;
     560    if (fOutputPath.EndsWith("/"))
     561        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
    550562}
    551563
     
    556568const char* MCalibrationRelTimeCalc::GetOutputFile()
    557569{
    558   return Form("%s/%s", (const char*)fOutputPath, (const char*)fOutputFile);
    559 }
     570    return Form("%s/%s", (const char*)fOutputPath, (const char*)fOutputFile);
     571}
     572
     573
     574// --------------------------------------------------------------------------
     575//
     576// MCalibrationRelTimeCam.CheckFitResults: Yes
     577// MCalibrationRelTimeCam.CheckDeviatingBehavior: Yes
     578// MCalibrationRelTimeCam.CheckHistOverflow: Yes
     579// MCalibrationRelTimeCam.CheckOscillations: Yes
     580//
     581Int_t MCalibrationRelTimeCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     582{
     583    Bool_t rc = kFALSE;
     584
     585    if (IsEnvDefined(env, prefix, "CheckFitResults", print))
     586    {
     587        SetCheckFitResults(GetEnvValue(env, prefix, "CheckFitResults", IsCheckFitResults()));
     588        rc = kTRUE;
     589    }
     590    if (IsEnvDefined(env, prefix, "CheckDeviatingBehavior", print))
     591    {
     592        SetCheckDeviatingBehavior(GetEnvValue(env, prefix, "CheckDeviatingBehavior", IsCheckDeviatingBehavior()));
     593        rc = kTRUE;
     594    }
     595    if (IsEnvDefined(env, prefix, "CheckHistOverflow", print))
     596    {
     597        SetCheckHistOverflow(GetEnvValue(env, prefix, "CheckHistOverflow", IsCheckHistOverflow()));
     598        rc = kTRUE;
     599    }
     600
     601    if (IsEnvDefined(env, prefix, "CheckOscillations", print))
     602    {
     603        SetCheckOscillations(GetEnvValue(env, prefix, "CheckOscillations", IsCheckOscillations()));
     604        rc = kTRUE;
     605    }
     606
     607    return rc;
     608}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.h

    r5679 r7188  
    4343  MGeomCam                   *fGeom;             //! Camera geometry
    4444
     45  // enums
     46  enum  Check_t
     47  {
     48      kCheckHistOverflow,
     49      kCheckDeviatingBehavior,
     50      kCheckOscillations,
     51      kCheckFitResults
     52  };                                             // Possible Checks
     53
     54  Byte_t fCheckFlags;                            // Bit-field to hold the possible check flags
     55
    4556  enum  { kDebug };                              //  Possible flags
    4657
     
    5667  void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
    5768
     69  // Query checks
     70  Bool_t IsCheckDeviatingBehavior() const { return TESTBIT(fCheckFlags,kCheckDeviatingBehavior); }
     71  Bool_t IsCheckHistOverflow     () const { return TESTBIT(fCheckFlags,kCheckHistOverflow);      }
     72  Bool_t IsCheckOscillations     () const { return TESTBIT(fCheckFlags,kCheckOscillations);      }
     73  Bool_t IsCheckFitResults       () const { return TESTBIT(fCheckFlags,kCheckFitResults);        }
     74
     75  // MTask
    5876  Bool_t ReInit     (MParList *pList);
    5977  Int_t  Process    () { return kTRUE; }
    6078  Int_t  PostProcess();
    6179
     80  // MParContainer
     81  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
     82
    6283public:
    63 
    6484  MCalibrationRelTimeCalc(const char *name=NULL, const char *title=NULL);
    6585
     86  // TObject
    6687  void Clear(const Option_t *o="");
    67  
     88
     89  // MCalibrationRelTimeCalc
    6890  Int_t Finalize();
    6991 
     92  // Getter
    7093  Bool_t IsDebug() const  {  return TESTBIT(fFlags,kDebug); }
    7194
    72   void SetDebug                 ( const Bool_t  b=kTRUE ) { b ? SETBIT(fFlags,kDebug) : CLRBIT(fFlags,kDebug); }   
     95  // Setter
    7396  void SetOutputPath            ( TString path="."                         );
    7497  void SetOutputFile            ( TString file="TimeCalibStat.txt"         ) { fOutputFile          = file; }
    7598  void SetRelTimeResolutionLimit( const Float_t f=fgRelTimeResolutionLimit ) { fRelTimeResolutionLimit = f; }
    7699
    77   ClassDef(MCalibrationRelTimeCalc, 1)   // Task finalizing the relative time Calibration
     100  // Checks
     101  void SetCheckFitResults(const Bool_t b=kTRUE)        { b ? SETBIT(fCheckFlags,kCheckFitResults) : CLRBIT(fCheckFlags,kCheckFitResults); }
     102  void SetCheckDeviatingBehavior(const Bool_t b=kTRUE) { b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior) : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
     103  void SetCheckHistOverflow(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckHistOverflow) : CLRBIT(fCheckFlags,kCheckHistOverflow); }
     104  void SetCheckOscillations(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckOscillations) : CLRBIT(fCheckFlags,kCheckOscillations); }
     105  void SetDebug(const Bool_t b=kTRUE)                  { b ? SETBIT(fFlags, kDebug) : CLRBIT(fFlags, kDebug); }
     106
     107  ClassDef(MCalibrationRelTimeCalc, 2)   // Task finalizing the relative time Calibration
    78108};
    79109
  • trunk/MagicSoft/Mars/mcalib/MMcCalibrationCalc.cc

    r7005 r7188  
    7171using namespace std;
    7272
    73 MMcCalibrationCalc::MMcCalibrationCalc(const char *name, const char *title)
     73// --------------------------------------------------------------------------
     74//
     75// Constructor. Default value for fMinSize is 1000 ADC counts. This must be
     76// set in general by the user (SetMinSize), since it depends among other things
     77// on the signal extractor used.
     78//
     79MMcCalibrationCalc::MMcCalibrationCalc(const char *name, const char *title): fMinSize(1000)
    7480{
    7581    fName  = name  ? name  : "MMcCalibrationCalc";
    7682    fTitle = title ? title : "Calculate and write conversion factors into MCalibrationChargeCam and MCalibrationQECam containers";
    77 
    78     fHistADC2PhotEl = new TH1F(AddSerialNumber("ADC2PhotEl"), "log10(fPhotElfromShower/fSize)", 1500, -3., 3.);
    79     fHistADC2PhotEl->SetXTitle("log_{10}(fPhotElfromShower / fSize) [photel/ADC count]");
    80 
    81 
    82     fHistPhot2PhotEl = new TH1F(AddSerialNumber("Phot2PhotEl"), "Photon conversion efficiency", 1000, 0., 1.);
    83     fHistPhot2PhotEl->SetXTitle("Overall photon conversion efficiency [photoelectron/photon]");
    84 
    8583}
    8684
     
    9391Bool_t MMcCalibrationCalc::CheckRunType(MParList *pList) const
    9492{
    95     const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     93    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
    9694    if (!run)
    9795    {
    98         *fLog << warn << "Warning - cannot check file type, MRawRunHeader not found." << endl;
    99         return kTRUE;
     96      *fLog << warn << "Warning - cannot check file type, " << AddSerialNumber("MRawRunHeader")
     97            << " not found." << endl;
     98      return kTRUE;
    10099    }
    101100
     
    105104// --------------------------------------------------------------------------
    106105//
    107 // Make sure, that there is an MCalibrationCam Object in the Parameter List.
     106// Look for all necessary containers and create histograms
    108107//
    109108Int_t MMcCalibrationCalc::PreProcess(MParList *pList)
    110109{
    111     fHistADC2PhotEl->Reset();
    112     fHistPhot2PhotEl->Reset();
    113 
    114110    fADC2PhotEl = 0;
    115111    fPhot2PhotEl = 0;
     
    156152        return kFALSE;
    157153    }
     154
     155    //
     156    // Create histograms:
     157    //
     158
     159    fHistADC2PhotEl = new TH1F(AddSerialNumber("ADC2PhotEl"), "log10(fPhotElfromShower/fSize)", 1500, -3., 3.);
     160    fHistADC2PhotEl->SetXTitle("log_{10}(fPhotElfromShower / fSize) [photel/ADC count]");
     161
     162
     163    fHistPhot2PhotEl = new TH1F(AddSerialNumber("Phot2PhotEl"), "Photon conversion efficiency", 1000, 0., 1.);
     164    fHistPhot2PhotEl->SetXTitle("Overall photon conversion efficiency [photoelectron/photon]");
     165
    158166
    159167    return kTRUE;
     
    210218  // perpendicular to the camera plane.
    211219  //
    212   // FIXME! We should look for AddSerialNumber("MMcConfigRunHeader") but
    213   // for the moment the stereo version of camera does not write one such
    214   // header per telescope (it should!)
    215   //
    216   MMcConfigRunHeader* mcconfig = (MMcConfigRunHeader*) pList->FindObject("MMcConfigRunHeader");
     220  MMcConfigRunHeader* mcconfig = (MMcConfigRunHeader*) pList->FindObject(AddSerialNumber("MMcConfigRunHeader"));
    217221  if (!mcconfig)
    218222    {
    219       *fLog << err << "MMcConfigRunHeader" << " not found... aborting." << endl;
     223      *fLog << err << AddSerialNumber("MMcConfigRunHeader") << " not found... aborting." << endl;
    220224      return kFALSE;
    221225    }
     
    253257    //
    254258    // Exclude events with low Size (larger fluctuations)
    255     // FIXME? The present cut (1000 "inner-pixel-counts") is somehow
    256     // arbitrary. Might it be optimized?
    257259    //   
    258260
    259     if (size < 1000)
     261    if (size < fMinSize)
    260262        return kTRUE;
    261263
     
    288290    }
    289291
    290     fPhot2PhotEl = fHistPhot2PhotEl->GetMean();   // Average quantum efficiency
     292    fPhot2PhotEl = fHistPhot2PhotEl->GetMean();   
     293    // Average quantum efficiency. For now we will set this value for all pixels, although
     294    // even in MC there may be differences from pixel to pixel, if the .dat file containing
     295    // QE vs lambda, input of the camera simulation, has different QE curves for different
     296    // pixels. FIXME?
     297
     298    MCalibrationQEPix &avqepix = (MCalibrationQEPix&)(fQECam->GetAverageArea(0));
     299    avqepix.SetAverageQE(fPhot2PhotEl); // Needed by MCalibrateData!
    291300
    292301    //
     
    335344        // FIXME: we are now assuming that all inner pixels have the same gain, and all
    336345        // outer pixels have the same gain (different from inner ones though). This can
    337         // only be like this in camera 0.7, but may change in future versions of camera.
     346        // only be like this in camera 0.7, but might change in future versions of camera.
    338347        //
    339348
     
    347356    }
    348357
     358
    349359    return kTRUE;
    350360}
  • trunk/MagicSoft/Mars/mcalib/MMcCalibrationCalc.h

    r4710 r7188  
    3535                                         // outer pixels w.r.t inner ones
    3636
     37    Float_t fMinSize;
     38    // Minimum SIZE (before calibration, ADC counts) an event must have to be considered in the
     39    // calculation of the calibration constants.
     40
    3741    TH1F*   fHistADC2PhotEl;
    3842    TH1F*   fHistPhot2PhotEl; // Histograms for monitoring the calibration.
     
    5054    TH1F*   GetHistPhot2PhotEl() { return fHistPhot2PhotEl; }
    5155
     56    void SetMinSize(Float_t x) { fMinSize = x; }
     57
    5258    ClassDef(MMcCalibrationCalc, 0)   // Task which obtains, for MC files, the calibration factor from ADC counts to photons.
    5359};
  • trunk/MagicSoft/Mars/mcalib/Makefile

    r6662 r7188  
    4040           MCalibrateRelTimes.cc \
    4141           MCalibrationIntensityCam.cc \
     42           MCalibrationIntensityConstCam.cc \
    4243           MCalibrationIntensityChargeCam.cc \
    4344           MCalibrationIntensityBlindCam.cc \
  • trunk/MagicSoft/Mars/merpp.cc

    r7116 r7188  
    332332            w->AddContainer("MCameraCalibration", "Camera");
    333333            w->AddContainer("MCameraCooling",     "Camera");
     334            w->AddContainer("MCameraActiveLoad",  "Camera");
    334335            w->AddContainer("MCameraHV",          "Camera");
    335336            w->AddContainer("MCameraLV",          "Camera");
  • trunk/MagicSoft/Mars/mhcalib/HCalibLinkDef.h

    r6598 r7188  
    1515#pragma link C++ class MHCalibrationTestCam+;
    1616#pragma link C++ class MHCalibrationHiLoCam+;
     17#pragma link C++ class MHCalibrationHiLoPix+;
    1718#pragma link C++ class MHCalibrationPulseTimeCam+;
    1819#pragma link C++ class MHPedestalCam+;
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc

    r7095 r7188  
    6060//  + Bool_t   fIsLoGainFitRanges;            // Are low-gain fit ranges defined?
    6161//
     62// Class Version 5:
     63//  + Int_t   fMaxNumEvts;                    // Max Number of events
    6264//
    6365/////////////////////////////////////////////////////////////////////////////
     
    103105const Float_t MHCalibrationCam::fgProbLimit        = 0.0001;
    104106const Float_t MHCalibrationCam::fgOverflowLimit    = 0.005;
     107const Int_t   MHCalibrationCam::fgMaxNumEvts       = 4096;
    105108
    106109const TString MHCalibrationCam::gsHistName   = "Hist";
     
    141144    fHistName(gsHistName),fHistTitle(gsHistTitle),
    142145    fHistXTitle(gsHistXTitle),fHistYTitle(gsHistYTitle),
     146    fCurrentNumEvts(0),
    143147    fColor(MCalibrationCam::kNONE), fIntensBad(NULL),
    144148    fBadPixels(NULL), fIntensCam(NULL), fCam(NULL), fGeom(NULL),
     
    167171    SetProbLimit();
    168172    SetOverflowLimit();
     173    SetMaxNumEvts();
    169174
    170175    SetAverageing  (kTRUE);
     
    385390{
    386391  SetIsReset();
     392
     393  fCurrentNumEvts = 0;
    387394 
    388395  ResetHistTitles();
     
    543550  }
    544551
     552  fCurrentNumEvts = 0;
     553
    545554  return SetupHists(pList);
    546555}
     
    630639         
    631640          MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
    632           if (bad.IsBad())
     641          if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    633642            continue;
    634643         
     
    649658        SetLoGain(fRunHeader->GetNumSamplesLoGain());
    650659    }
     660
     661  fCurrentNumEvts = 0;
    651662
    652663  if (!ReInitHists(pList))
     
    874885Bool_t MHCalibrationCam::Fill(const MParContainer *par, const Stat_t w)
    875886{
     887  if (fCurrentNumEvts >= fMaxNumEvts)
     888    return kTRUE;
     889
     890  fCurrentNumEvts++;
     891
    876892  SetIsReset(kFALSE);
    877893
     
    950966  if (GetNumExecutions() < 2)
    951967    return kTRUE;
     968
     969  *fLog << inf << GetDescriptor() << ": Number of event used to fill histograms == " << fCurrentNumEvts << endl;
    952970
    953971  if (fHiGainArray->GetSize() == 0 && fLoGainArray->GetSize() == 0)
     
    11801198void MHCalibrationCam::CalcAverageSigma()
    11811199{
    1182 
    1183   if (!fCam)
    1184     return;
    1185  
    11861200  if (!IsAverageing())
    11871201    return;
    11881202 
     1203  MCalibrationCam *cam = fIntensCam ? fIntensCam->GetCam() : fCam;
     1204  if (!cam)
     1205    return;
     1206 
    11891207  for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
    11901208    {
    11911209 
    1192       MCalibrationPix &pix    = fCam->GetAverageArea(j);
     1210      MCalibrationPix &pix    = cam->GetAverageArea(j);
    11931211
    11941212      const Float_t numsqr    = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
     
    12031221      fAverageAreaRelSigmaVar[j] += pix.GetMeanRelVar();
    12041222      fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
     1223    }
     1224
     1225  for (UInt_t j=0; j<fGeom->GetNumSectors(); j++)
     1226    {
     1227      MCalibrationPix &pix    = cam->GetAverageSector(j);
     1228
     1229      const Float_t numsqr    = TMath::Sqrt((Float_t)fAverageSectorNum[j]);
     1230      pix.SetSigma   (pix.GetSigma() * numsqr);
     1231      pix.SetSigmaVar(pix.GetSigmaErr() * pix.GetSigmaErr() * numsqr);
    12051232    }
    12061233}
     
    12831310    {
    12841311      *fLog << dbginf << GetDescriptor() << ": ID " << GetName()
     1312            << " "<<pix.GetPixId()
    12851313            << " HiGainSaturation: "   << pix.IsHiGainSaturation()
    12861314            << " HiGainMean: "         << hist.GetMean    ()
     
    13741402    {
    13751403      *fLog << dbginf << GetDescriptor() << "ID: " << hist.GetName()
    1376             << " HiGainSaturation: "   << pix.IsHiGainSaturation()
     1404            << " "<<pix.GetPixId()
     1405            << " HiGainSaturation: "   << pix.IsHiGainSaturation()
    13771406            << " LoGainMean: "         << hist.GetMean    ()
    13781407            << " LoGainMeanErr: "      << hist.GetMeanErr ()
     
    15461575      rc = kTRUE;
    15471576    }
     1577
     1578  if (IsEnvDefined(env, prefix, "MaxNumEvts", print))
     1579    {
     1580      SetMaxNumEvts(GetEnvValue(env, prefix, "MaxNumEvts", fMaxNumEvts));
     1581      rc = kTRUE;
     1582    }
    15481583 
    15491584  if (IsEnvDefined(env, prefix, "OverflowLimit", print))
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h

    r7095 r7188  
    4040 
    4141private:
    42   static const Double_t fgLowerFitLimitHiGain; //! The default for fLowerFitLimitHiGain (now at: 0)
    43   static const Double_t fgUpperFitLimitHiGain; //! The default for fUpperFitLimitHiGain (now at: 0)
    44   static const Double_t fgLowerFitLimitLoGain; //! The default for fLowerFitLimitLoGain (now at: 0)
    45   static const Double_t fgUpperFitLimitLoGain; //! The default for fUpperFitLimitLoGain (now at: 0)
    46 
    47   static const Int_t   fgPulserFrequency;  //! The default for fPulserFrequency (now set to: 500)
    48   static const Float_t fgProbLimit;        //! The default for fProbLimit (now set to: 0.0001) 
    49   static const Float_t fgOverflowLimit;    //! The default for fOverflowLimit (now at: 0.005)
     42  static const Double_t fgLowerFitLimitHiGain; //! Default for fLowerFitLimitHiGain
     43  static const Double_t fgUpperFitLimitHiGain; //! Default for fUpperFitLimitHiGain
     44  static const Double_t fgLowerFitLimitLoGain; //! Default for fLowerFitLimitLoGain
     45  static const Double_t fgUpperFitLimitLoGain; //! Default for fUpperFitLimitLoGain
     46
     47  static const Int_t   fgPulserFrequency;  //! Default for fPulserFrequency
     48  static const Float_t fgProbLimit;        //! Default for fProbLimit
     49  static const Float_t fgOverflowLimit;    //! Default for fOverflowLimit
     50  static const Int_t   fgMaxNumEvts;       //! Default for fMaxNumEvts
    5051 
    5152  static const TString gsHistName;         //! Default Histogram names
     
    7879  Float_t fNumHiGainSaturationLimit;      // Rel. amount sat. higain FADC slices until pixel is called saturated
    7980  Float_t fNumLoGainSaturationLimit;      // Rel. amount sat. logain FADC slices until pixel is called saturated
     81
     82  Int_t   fMaxNumEvts;                    // Max Number of events
     83  Int_t   fCurrentNumEvts;                //! Current number of events
    8084 
    8185  MArrayI fRunNumbers;                    // Numbers of runs used
     
    191195  void   DrawPixelContent( Int_t num )  const  {}
    192196
     197  const MArrayI           &GetAverageAreaNum     ()          const { return fAverageAreaNum; }
    193198  const Int_t              GetAverageAreas       ()          const;     
    194199        MHCalibrationPix  &GetAverageHiGainArea  (UInt_t i);
     
    200205        MHCalibrationPix  &GetAverageLoGainSector(UInt_t i);
    201206  const MHCalibrationPix  &GetAverageLoGainSector(UInt_t i)  const;
    202   const Int_t              GetAverageSectors     ()          const;
     207  const MArrayI           &GetAverageSectorNum    ()         const { return fAverageSectorNum; }
     208  const Int_t              GetAverageSectors      ()         const;
    203209  const MCalibrationCam::PulserColor_t GetColor   ()     const  { return fColor;                    }
    204210  const Float_t        GetNumHiGainSaturationLimit()     const  { return fNumHiGainSaturationLimit; }
     
    234240  void SetFirst                   ( const Axis_t f )       { fFirst   = f; }
    235241  void SetLast                    ( const Axis_t f )       { fLast    = f; }
     242  void SetMaxNumEvts              ( const Int_t  i=fgMaxNumEvts ) { fMaxNumEvts  = i; }
    236243
    237244  void SetProbLimit               ( const Float_t f=fgProbLimit) { fProbLimit = f; }   
     
    242249  void SetPulserFrequency      ( const Int_t   i=fgPulserFrequency )   { fPulserFrequency  = i; }
    243250 
    244   ClassDef(MHCalibrationCam, 5) // Base Histogram class for Calibration Camera
     251  ClassDef(MHCalibrationCam, 6) // Base Histogram class for Calibration Camera
    245252};
    246253
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc

    r7126 r7188  
    6464// from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup)
    6565//
    66 // Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
     66// If more than fNumHiGainSaturationLimit (default: 15%) of the overall FADC
    6767// slices show saturation, the following flag is set:
    6868// - MCalibrationChargePix::SetHiGainSaturation();
     
    108108// sigmas in the camera.
    109109//
     110// Class Version 2:
     111//  + Float_t fNumLoGainBlackoutLimit; // Rel. amount blackout logain events until pixel is declared unsuitable
     112//
    110113/////////////////////////////////////////////////////////////////////////////
    111114#include "MHCalibrationChargeCam.h"
     
    157160
    158161const Int_t   MHCalibrationChargeCam::fgChargeHiGainNbins =  500;
    159 const Axis_t  MHCalibrationChargeCam::fgChargeHiGainFirst = -100.125;
    160 const Axis_t  MHCalibrationChargeCam::fgChargeHiGainLast  =  1899.875;
     162const Axis_t  MHCalibrationChargeCam::fgChargeHiGainFirst = -98.;
     163const Axis_t  MHCalibrationChargeCam::fgChargeHiGainLast  =  1902.;
    161164const Int_t   MHCalibrationChargeCam::fgChargeLoGainNbins =  500;
    162 const Axis_t  MHCalibrationChargeCam::fgChargeLoGainFirst = -100.25;
    163 const Axis_t  MHCalibrationChargeCam::fgChargeLoGainLast  =  899.75;
     165const Axis_t  MHCalibrationChargeCam::fgChargeLoGainFirst = -99.;
     166const Axis_t  MHCalibrationChargeCam::fgChargeLoGainLast  =  901.;
    164167const Float_t MHCalibrationChargeCam::fgProbLimit         = 0.00000001;
    165168const TString MHCalibrationChargeCam::gsHistName          = "Charge";
     
    173176const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.15;
    174177const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
     178const Float_t MHCalibrationChargeCam::fgNumLoGainBlackoutLimit   = 0.05;
     179const Float_t MHCalibrationChargeCam::fgLoGainBlackoutLimit      = 3.5;
     180const Float_t MHCalibrationChargeCam::fgLoGainPickupLimit        = 3.5;
    175181const Float_t MHCalibrationChargeCam::fgTimeLowerLimit           = 1.;
    176182const Float_t MHCalibrationChargeCam::fgTimeUpperLimit           = 3.;
     
    189195// - fTimeLowerLimit           to fgTimeLowerLimit
    190196// - fTimeUpperLimit           to fgTimeUpperLimit
     197// - fNumLoGainBlackoutLimit   to fgNumLoGainBlackoutLimit
    191198//
    192199// - fNbins to fgChargeHiGainNbins
     
    217224  SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
    218225  SetNumLoGainSaturationLimit(fgNumLoGainSaturationLimit);
     226
     227  SetNumLoGainBlackoutLimit  (fgNumLoGainBlackoutLimit);
    219228
    220229  SetTimeLowerLimit();
     
    571580          pix.SetAbsTimeFirst(-0.5);
    572581          pix.SetAbsTimeLast(logainsamples-0.5);
    573          
     582          pix.SetPickupLimit(fgLoGainPickupLimit);
     583          pix.SetBlackoutLimit(fgLoGainBlackoutLimit);
     584
    574585          InitHists(pix,(*badcam)[i],i);
    575586
     
    708719     
    709720      const Float_t sumhi = pix.GetExtractedSignalHiGain();
    710       const Int_t   sathi = (Int_t)pix.GetNumHiGainSaturated();
     721      const Bool_t  sathi = pix.GetNumHiGainSaturated()>0;
    711722
    712723      if (IsOscillations())
     
    715726        histhi.FillHist(sumhi);
    716727       
    717       histhi.AddSaturated(sathi); 
     728      histhi.AddSaturated(sathi);
    718729
    719730      const Int_t aidx   = (*fGeom)[i].GetAidx();
     
    721732
    722733      fSumhiarea[aidx]  += sumhi;
    723       fSathiarea[aidx]  += sathi;
    724 
    725734      fSumhisector[sector]  += sumhi;
    726       fSathisector[sector]  += sathi;
     735      if (sathi)
     736      {
     737          fSathiarea[aidx]++;
     738          fSathisector[sector]++;
     739      }
    727740
    728741      if (IsLoGain())
     
    939952            continue;
    940953          }
     954
     955        MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
     956        if (!pix.IsHiGainSaturation())
     957            continue;
    941958       
    942959        h = histlo.GetHGausHist();
     
    960977          }
    961978       
    962         MCalibrationChargePix  &pix    = (MCalibrationChargePix&)(*chargecam)[i] ;
    963        
    964         if (pix.IsHiGainSaturation())
    965           FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
     979        FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
    966980      }
    967981
     
    10631077                    MBadPixelsPix::kLoGainOscillating);
    10641078
     1079  //
     1080  // Check for pixels which have the high-gain saturated, but the low-gain
     1081  // switch not applied in sufficient cases. Have to exclude these pixels,
     1082  // although they not abnormal. They simply cannot be calibrated...
     1083  //
     1084  for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
     1085  {
     1086
     1087      MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
     1088      if (histlo.IsExcluded())
     1089          continue;
     1090
     1091      MCalibrationChargePix  &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
     1092      if (!pix.IsHiGainSaturation())
     1093          continue;
     1094
     1095      //
     1096      // Now,treat only low-gain calibrated pixels:
     1097      //
     1098      const Double_t lim = fNumLoGainBlackoutLimit*histlo.GetHGausHist()->GetEntries();
     1099      if (histlo.GetBlackout() <= lim)
     1100          continue;
     1101
     1102      MBadPixelsPix &bad = (*badcam)[i];
     1103      bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
     1104      bad.SetUncalibrated(MBadPixelsPix::kLoGainBlackout);
     1105  }
    10651106
    10661107  return kTRUE;
     
    11281169      MCalibrationPix  &pix    = (*chargecam)[i];
    11291170
    1130       if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
    1131         if (!pix.IsHiGainSaturation())
    1132           bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
     1171      if (bad.IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
     1172          if (!pix.IsHiGainSaturation())
     1173              bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
    11331174 
    1134       if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
    1135         if (pix.IsHiGainSaturation())
    1136           bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
    1137 
    1138       if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
    1139           bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     1175      if (bad.IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
     1176          if (pix.IsHiGainSaturation())
     1177              bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
     1178
     1179      if (bad.IsUncalibrated(MBadPixelsPix::kLoGainSaturation))
     1180          bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
    11401181
    11411182      if (IsOscillations())
    11421183        {
    1143           if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
    1144             bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
    1145          
    1146           if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
    1147             if (pix.IsHiGainSaturation())
    1148               bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
     1184            if (bad.IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
     1185                if (!pix.IsHiGainSaturation())
     1186                    bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
     1187
     1188            if (bad.IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
     1189                if (pix.IsHiGainSaturation())
     1190                    bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
    11491191        }
    11501192    }
    1151 
    1152 
    1153      
    11541193}
    11551194
     
    14371476  }
    14381477
     1478  if (IsEnvDefined(env, prefix, "NumLoGainBlackoutLimit", print))
     1479  {
     1480      SetNumLoGainBlackoutLimit(GetEnvValue(env, prefix, "NumLoGainBlackoutLimit", fNumLoGainBlackoutLimit));
     1481      rc = kTRUE;
     1482  }
     1483
     1484
    14391485  TEnv refenv(fReferenceFile);
    14401486
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h

    r7043 r7188  
    4444  static const TString gsAbsHistYTitle;              //! Default Histogram y-axis titles abs.times
    4545 
    46   static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit
    47   static const Float_t fgNumLoGainSaturationLimit;   //! The default for fNumLoGainSaturationLimit
     46  static const Float_t fgNumHiGainSaturationLimit;   //! Default for fNumHiGainSaturationLimit
     47  static const Float_t fgNumLoGainSaturationLimit;   //! Default for fNumLoGainSaturationLimit
     48  static const Float_t fgNumLoGainBlackoutLimit;     //! Default for fNumLoGainBlackoutLimit (now at: 0.05)
     49
     50  static const Float_t fgLoGainBlackoutLimit;        //! Default for low-gain blackout limit (now at: 3.5)
     51  static const Float_t fgLoGainPickupLimit;          //! Default for low-gian pickup limit   (now at: 3.5)
    4852
    4953  static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit
     
    5357  Axis_t  fLoGainFirst;                              // Lower histogram limit low gain
    5458  Axis_t  fLoGainLast;                               // Upper histogram limit low gain
     59
     60  Float_t fNumLoGainBlackoutLimit;                   // Rel. amount blackout logain events until pixel is declared unsuitable
    5561
    5662  TString fAbsHistName;                              // Histogram names abs.times
     
    124130  void SetLoGainLast    ( const Axis_t f )    { fLoGainLast    = f; } 
    125131
     132  void SetNumLoGainBlackoutLimit( const Float_t f=fgNumLoGainBlackoutLimit ) { fNumLoGainBlackoutLimit = f; }
     133
    126134  void SetReferenceFile ( const TString ref=fgReferenceFile ) { fReferenceFile  = ref; }
    127135
    128136  void SetTimeLowerLimit( const Float_t f=fgTimeLowerLimit )  { fTimeLowerLimit = f; }
    129137  void SetTimeUpperLimit( const Float_t f=fgTimeUpperLimit )  { fTimeUpperLimit = f; }
    130  
     138
     139  // MHCamEvent
    131140  Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const { return kTRUE; }
    132141  void   DrawPixelContent( Int_t num )  const;   
    133142
    134   ClassDef(MHCalibrationChargeCam, 1)   // Histogram class for Charge Camera Calibration
     143  ClassDef(MHCalibrationChargeCam, 2)   // Histogram class for Charge Camera Calibration
    135144};
    136145
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePix.h

    r5137 r7188  
    4242
    4343  // Draws
    44   virtual void Draw(Option_t *opt="");
     44  void Draw(Option_t *opt="");
    4545
    4646  ClassDef(MHCalibrationChargePix, 1)     // Base Histogram class for Charge Pixel Calibration
  • trunk/MagicSoft/Mars/mhcalib/MHGausEvents.cc

    r6800 r7188  
    483483  option.ToLower();
    484484 
    485   Int_t win = 1;
     485  Int_t win   = 1;
    486486  Int_t nofit = 0;
    487487
    488488  if (option.Contains("events"))
    489     {
    490       option.ReplaceAll("events","");     
    491       win += 1;
    492     }
     489    win += 1;
    493490  if (option.Contains("fourier"))
    494     {
    495       option.ReplaceAll("fourier","");     
    496       win += 2;
    497     }
     491    win += 2;
    498492 
    499493  if (IsEmpty())
     
    779773}
    780774
    781 
    782 const Double_t MHGausEvents::GetChiSquare()  const
    783 {
    784   return ( fFGausFit ? fFGausFit->GetChisquare() : 0.);
    785 }
    786 
    787 
    788 const Double_t MHGausEvents::GetExpChiSquare()  const
    789 {
    790   return ( fFExpFit ? fFExpFit->GetChisquare() : 0.);
    791 }
    792 
    793 
    794 const Int_t MHGausEvents::GetExpNdf()  const
    795 {
    796   return ( fFExpFit ? fFExpFit->GetNDF() : 0);
    797 }
    798 
    799 
    800 const Double_t MHGausEvents::GetExpProb()  const
    801 {
    802   return ( fFExpFit ? fFExpFit->GetProb() : 0.);
    803 }
    804 
    805 
    806 const Int_t MHGausEvents::GetNdf() const
    807 {
    808   return ( fFGausFit ? fFGausFit->GetNDF() : 0);
    809 }
    810 
    811 const Double_t MHGausEvents::GetOffset()  const
    812 {
    813   return ( fFExpFit ? fFExpFit->GetParameter(0) : 0.);
    814 }
    815 
    816 
    817 
    818 // --------------------------------------------------------------------------
    819 //
    820 // If fFExpFit exists, returns fit parameter 1 (Slope of Exponential fit),
    821 // otherwise 0.
    822 //
    823 const Double_t MHGausEvents::GetSlope()  const
    824 {
    825   return ( fFExpFit ? fFExpFit->GetParameter(1) : 0.);
    826 }
    827 
    828775// --------------------------------------------------------------------------
    829776//
     
    839786  //  att.Copy(fHGausHist.GetXaxis());
    840787}
    841 
    842 // --------------------------------------------------------------------------
    843 //
    844 // Return kFALSE if number of entries is 0
    845 //
    846 const Bool_t MHGausEvents::IsEmpty() const
    847 {
    848   return !(fHGausHist.GetEntries());
    849 }
    850 
    851 // --------------------------------------------------------------------------
    852 //
    853 // Return kTRUE  if number of entries is bin content of fNbins+1
    854 //
    855 const Bool_t MHGausEvents::IsOnlyOverflow() const
    856 {
    857   return fHGausHist.GetEntries() == fHGausHist.GetBinContent(fNbins+1);
    858 }
    859 
    860 // --------------------------------------------------------------------------
    861 //
    862 // Return kTRUE  if number of entries is bin content of 0
    863 //
    864 const Bool_t MHGausEvents::IsOnlyUnderflow() const
    865 {
    866   return fHGausHist.GetEntries() == fHGausHist.GetBinContent(0);
    867 }
    868 
    869 
    870 const Bool_t MHGausEvents::IsExcluded() const
    871 {
    872   return TESTBIT(fFlags,kExcluded);
    873 }
    874 
    875 
    876 const Bool_t MHGausEvents::IsExpFitOK() const
    877 {
    878   return TESTBIT(fFlags,kExpFitOK);
    879 }
    880 
    881 const Bool_t MHGausEvents::IsFourierSpectrumOK() const
    882 {
    883   return TESTBIT(fFlags,kFourierSpectrumOK);
    884 }
    885 
    886 
    887 const Bool_t MHGausEvents::IsGausFitOK() const
    888 {
    889   return TESTBIT(fFlags,kGausFitOK);
    890 }
    891 
    892788
    893789// -----------------------------------------------------------------------------------
     
    929825}
    930826
    931 // --------------------------------------------------------------------------
    932 //
    933 // Set Excluded bit from outside
    934 //
    935 void MHGausEvents::SetExcluded(const Bool_t b)
    936 {
    937     b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded);
    938 }
    939 
    940 
    941 // -------------------------------------------------------------------
    942 //
    943 // The flag setters are to be used ONLY for Monte-Carlo!!
    944 //
    945 void  MHGausEvents::SetExpFitOK(const Bool_t b)
    946 {
    947  
    948   b ? SETBIT(fFlags,kExpFitOK) : CLRBIT(fFlags,kExpFitOK); 
    949 }
    950 
    951 // -------------------------------------------------------------------
    952 //
    953 // The flag setters are to be used ONLY for Monte-Carlo!!
    954 //
    955 void  MHGausEvents::SetFourierSpectrumOK(const Bool_t b)
    956 {
    957 
    958   b ? SETBIT(fFlags,kFourierSpectrumOK) : CLRBIT(fFlags,kFourierSpectrumOK);   
    959 }
    960 
    961 
    962 // -------------------------------------------------------------------
    963 //
    964 // The flag setters are to be used ONLY for Monte-Carlo!!
    965 //
    966 void  MHGausEvents::SetGausFitOK(const Bool_t b)
    967 {
    968   b ? SETBIT(fFlags,kGausFitOK) : CLRBIT(fFlags,kGausFitOK);
    969 
    970 }
    971 
    972827// ----------------------------------------------------------------------------
    973828//
  • trunk/MagicSoft/Mars/mhcalib/MHGausEvents.h

    r6800 r7188  
    44#ifndef ROOT_TH1
    55#include <TH1.h>
     6#endif
     7
     8#ifndef ROOF_TF1
     9#include <TF1.h>
    610#endif
    711
     
    1620class TVirtualPad;
    1721class TGraph;
    18 class MArrayF;
    1922class TH1F;
    2023class TH1I;
    2124class TF1;
     25
    2226class MHGausEvents : public MH
    2327{
     
    2832  const static Int_t    fgPowerProbabilityBins; //! Default for fPowerProbabilityBins (now set to: 20)
    2933
    30   Float_t *CreateEventXaxis(Int_t n);  // Create an x-axis for the Event TGraphs
    31   Float_t *CreatePSDXaxis(Int_t n);    // Create an x-axis for the PSD TGraphs
     34  Float_t *CreateEventXaxis(Int_t n);           // Create an x-axis for the Event TGraphs
     35  Float_t *CreatePSDXaxis  (Int_t n);           // Create an x-axis for the PSD TGraphs
    3236 
    3337protected:
    3438
    35   Float_t  fEventFrequency;            // Event frequency in Hertz (to be set)
    36 
    3739  Int_t    fBinsAfterStripping;        // Bins for the Gauss Histogram after stripping off the zeros at both ends
    3840  UInt_t   fCurrentSize;               // Current size of the array fEvents
     41  Float_t  fEventFrequency;            // Event frequency in Hertz (to be set)
    3942  Byte_t   fFlags;                     // Bit field for the fit result bits
    4043  Int_t    fPowerProbabilityBins;      // Bins for the projected power spectrum
     
    8285
    8386  // Draws
    84   void Draw(Option_t *option="");                  // *MENU*
    85   void DrawEvents(Option_t *option="");              // *MENU*
    86   void DrawPowerSpectrum(Option_t *option="");        // *MENU*
    87   void DrawPowerProjection(Option_t *option="");      // *MENU*
     87  void Draw               ( Option_t *option="" ); // *MENU*
     88  void DrawEvents         ( Option_t *option="" ); // *MENU*
     89  void DrawPowerSpectrum  ( Option_t *option="" ); // *MENU*
     90  void DrawPowerProjection( Option_t *option="" ); // *MENU*
    8891
    8992  // Fill
    90   void   FillArray       ( const Float_t f );
    91   Bool_t FillHist        ( const Float_t f );
    92   Bool_t FillHistAndArray( const Float_t f );
     93  void   FillArray        ( const Float_t f );
     94  Bool_t FillHist         ( const Float_t f );
     95  Bool_t FillHistAndArray ( const Float_t f );
    9396 
    9497  // Fits
    95   Bool_t FitGaus( Option_t *option="RQ0",         
    96                    const Double_t xmin=0.,
    97                    const Double_t xmax=0.);          // *MENU*
     98  Bool_t FitGaus          ( Option_t *option="RQ0",         
     99                            const Double_t xmin=0.,
     100                            const Double_t xmax=0.); // *MENU*
    98101 
    99102  // Inits
     
    101104 
    102105  // Getters
    103   const Double_t GetChiSquare()          const;
    104   const Double_t GetExpChiSquare()       const;
    105   const Int_t    GetExpNdf()             const;
    106   const Double_t GetExpProb()            const;
     106  const Double_t GetChiSquare()          const { return ( fFGausFit ? fFGausFit->GetChisquare() : 0.); }
     107  const Double_t GetExpChiSquare()       const { return ( fFExpFit  ? fFExpFit->GetChisquare()  : 0.); }
     108  const Int_t    GetExpNdf()             const { return ( fFExpFit  ? fFExpFit->GetNDF()        : 0 ); }
     109  const Double_t GetExpProb()            const { return ( fFExpFit  ? fFExpFit->GetProb()       : 0.); }
    107110        MArrayF *GetEvents()                   { return &fEvents;            } 
    108111  const MArrayF *GetEvents()             const { return &fEvents;            }
    109   const Float_t  GetEventFrequency () const { return fEventFrequency; }
    110   TF1     *GetFExpFit()                  { return fFExpFit;            }
     112  const Float_t  GetEventFrequency ()    const { return fEventFrequency;    }
     113        TF1     *GetFExpFit()                  { return fFExpFit;            }
    111114  const TF1     *GetFExpFit()            const { return fFExpFit;            }
    112115        TF1     *GetFGausFit()                 { return fFGausFit;           }
     
    125128  const Double_t GetMean()               const { return fMean;               }
    126129  const Double_t GetMeanErr()            const { return fMeanErr;            }
    127   const Int_t    GetNdf()                const;
    128   const Int_t    GetNbins()               const { return fNbins;            }
    129   const Double_t GetOffset()             const;
     130  const Int_t    GetNdf()                const { return ( fFGausFit ? fFGausFit->GetNDF()       : 0);  }
     131  const Int_t    GetNbins()              const { return fNbins;              }
     132  const Double_t GetOffset()             const { return ( fFExpFit  ? fFExpFit->GetParameter(0) : 0.); }
    130133        MArrayF *GetPowerSpectrum()            { return fPowerSpectrum;      } 
    131134  const MArrayF *GetPowerSpectrum()      const { return fPowerSpectrum;      }
     
    133136  const Double_t GetSigma()              const { return fSigma;              }
    134137  const Double_t GetSigmaErr()           const { return fSigmaErr;           }
    135   const Double_t GetSlope()              const;
     138  const Double_t GetSlope()              const { return ( fFExpFit  ? fFExpFit->GetParameter(1) : 0.); }
    136139
    137   const Bool_t IsExcluded()              const;
    138   const Bool_t IsExpFitOK()              const;
    139   const Bool_t IsEmpty()                 const;
    140   const Bool_t IsFourierSpectrumOK()     const;
    141   const Bool_t IsGausFitOK()             const;
    142   const Bool_t IsOnlyOverflow()          const;
    143   const Bool_t IsOnlyUnderflow()         const; 
     140  const Bool_t   IsExcluded()            const { return TESTBIT(fFlags,kExcluded);          }
     141  const Bool_t   IsExpFitOK()            const { return TESTBIT(fFlags,kExpFitOK);          }
     142  const Bool_t   IsEmpty()               const { return !(fHGausHist.GetEntries());         }
     143  const Bool_t   IsFourierSpectrumOK()   const { return TESTBIT(fFlags,kFourierSpectrumOK); }
     144  const Bool_t   IsGausFitOK()           const { return TESTBIT(fFlags,kGausFitOK);         }
     145  const Bool_t   IsOnlyOverflow()        const { return fHGausHist.GetEntries() == fHGausHist.GetBinContent(fNbins+1); }
     146  const Bool_t   IsOnlyUnderflow()       const { return fHGausHist.GetEntries() == fHGausHist.GetBinContent(0);        }
    144147
    145148  // Prints
     
    148151  // Setters
    149152  void  SetEventFrequency   ( const Float_t  f                   ) { fEventFrequency = f;   }
    150   void  SetExcluded         ( const Bool_t   b=kTRUE             )
    151   void  SetExpFitOK         ( const Bool_t   b=kTRUE             );
    152   void  SetFourierSpectrumOK( const Bool_t   b=kTRUE             );
    153   void  SetGausFitOK        ( const Bool_t   b=kTRUE             );
     153  void  SetExcluded         ( const Bool_t   b=kTRUE             ) { b ? SETBIT(fFlags,kExcluded)  : CLRBIT(fFlags,kExcluded); }
     154  void  SetExpFitOK         ( const Bool_t   b=kTRUE             ) { b ? SETBIT(fFlags,kExpFitOK)  : CLRBIT(fFlags,kExpFitOK); }
     155  void  SetFourierSpectrumOK( const Bool_t   b=kTRUE             ) { b ? SETBIT(fFlags,kFourierSpectrumOK) : CLRBIT(fFlags,kFourierSpectrumOK); }
     156  void  SetGausFitOK        ( const Bool_t   b=kTRUE             ) { b ? SETBIT(fFlags,kGausFitOK) : CLRBIT(fFlags,kGausFitOK);}
    154157  void  SetLast             ( const Double_t d                   ) { fLast           = d;   }
    155158  void  SetFirst            ( const Double_t d                   ) { fFirst          = d;   }
  • trunk/MagicSoft/Mars/mhcalib/Makefile

    r6598 r7188  
    4141           MHCalibrationRelTimeCam.cc \
    4242           MHCalibrationHiLoCam.cc \
     43           MHCalibrationHiLoPix.cc \
    4344           MHCalibrationTestCam.cc \
    4445           MHCalibrationPulseTimeCam.cc \
  • trunk/MagicSoft/Mars/mhflux/MHFalseSource.h

    r7178 r7188  
    4747
    4848    TObject *GetCatalog();
     49    void MakeSymmetric(TH1 *h);
    4950
    5051private:
     
    5657    void ProjectOn(const TH3D &src, TH2D *h, TH2D *all);
    5758    void ProjectOnOff(TH2D *h, TH2D *all);
    58 
    59     void MakeSymmetric(TH1 *h);
    6059
    6160public:
  • trunk/MagicSoft/Mars/mimage/MNewImagePar.cc

    r7176 r7188  
    141141    Float_t maxpix2 = 0;                                 // [#phot]
    142142
    143     /*
    144     MSignalPix *pix = 0;
    145     TIter Next(evt);
    146     while ((pix=(MSignalPix*)Next()))
    147     */
     143    const Bool_t ismagiclike =
     144        geom.GetNumPixels() == 577 &&
     145        geom.GetNumAreas()  == 2   &&
     146        geom.GetPixRatio(396) > geom.GetPixRatio(397);
     147
    148148    UInt_t npix = evt.GetNumPixels();
    149149    for (UInt_t i=0; i<npix; i++)
     
    182182           edgepix2 += nphot;
    183183
    184         //
    185         // Now we are working on absolute values of nphot, which
    186         // must take pixel size into account
    187         //
    188         nphot *= geom.GetPixRatio(i/*pixid*/);
    189 
    190         // count inner pixels: To dependent on MAGIC Camera --> FIXME
    191 
    192         if (i<397){
     184        const Double_t ratio = geom.GetPixRatio(i);
     185        if (TMath::Nint(ratio)==1) // Means this is a small (= inner pixel)
     186        {
    193187            fInnerSize += nphot;
    194             if(i>270){
    195                 edgepixin2 += nphot;
    196                 if(i>330)
    197                     edgepixin1 += nphot;
     188
     189            // Do calculation of "inner leakage" only for MAGIC-like geometry,
     190            // i.e., 577 pixels, pixels of 2 different areas, inner part
     191            // from pixel 0 to 396:
     192            if (ismagiclike)
     193            {
     194                if(i > 270) // last two "rings" of inner pixels
     195                {
     196                    edgepixin2 += nphot;
     197                    if(i > 330)  // last "ring" of inner pixels
     198                        edgepixin1 += nphot;
     199                }
    198200            }
    199201        }
    200202
    201         // Compute Concentration 1-2
     203        //
     204        // Now convert nphot from absolute number of photons or phe to signal
     205        // density (divide by pixel area), to find the pixel with highest signal
     206        // density:
     207        //
     208        nphot *= ratio;
     209
     210        // Look for signal density in two highest pixels:
    202211        if (nphot>maxpix1)
    203212        {
     
    213222    fInnerLeakage1 = edgepixin1 / fInnerSize;
    214223    fInnerLeakage2 = edgepixin2 / fInnerSize;
     224
    215225    fLeakage1 = edgepix1 / hillas.GetSize();
    216226    fLeakage2 = edgepix2 / hillas.GetSize();
    217227
     228    // FIXME?: in case the pixel with highest signal density is an outer pixel,
     229    // the value of fConc (ratio of signal in two highest pixels to SIZE) should
     230    // rather be 2*fConc1, under the simplest assumption that the light density
     231    // inside the outer (large) pixel is uniform.
    218232    fConc  = (maxpix1+maxpix2)/hillas.GetSize();         // [ratio]
    219233    fConc1 = maxpix1/hillas.GetSize();                   // [ratio]
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r7126 r7188  
    760760      gPad->SetBorderMode(0);
    761761      if (geomcam.InheritsFrom("MGeomCamMagic"))
    762         DisplayDoubleProject(&disp35, "noisy", "dead");
     762        DisplayDoubleProject(&disp37, "noisy", "dead");
    763763
    764764      //
     
    842842      // for the datacheck, fix the ranges!!
    843843      //
    844       const Double_t max = 12.;
     844      const Double_t max = 10.;
    845845      obj8->SetMinimum(0.);
    846846      obj8->SetMaximum(max);
     
    863863      t1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol)));
    864864      t1->SetTextAlign(12);
    865       TText *t2 = pave->AddText(Form("%s%3i%s","Signal Rel. error too large:                          ",
    866                                        CountBadPixels(&disp24,2)," pixels"));
    867       t2->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol)));
    868       t2->SetTextAlign(12);
    869865      TText *t4 = pave->AddText(Form("Low Gain Saturation:                                   %3i pixels",
    870                                        CountBadPixels(&disp24,3)));
    871       t4->SetTextColor(gStyle->GetColorPalette(Int_t(3./max*numcol)));
     866                                       CountBadPixels(&disp24,2)));
     867      t4->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol)));
    872868      t4->SetTextAlign(12);
    873869      TText *t5 = pave->AddText(Form("Mean Arr. Time In First Extraction Bin:      %3i pixels",
    874                                        CountBadPixels(&disp24,4)));
    875       t5->SetTextColor(gStyle->GetColorPalette(Int_t(4./max*numcol)));
     870                                       CountBadPixels(&disp24,3)));
     871      t5->SetTextColor(gStyle->GetColorPalette(Int_t(3./max*numcol)));
    876872      t5->SetTextAlign(12);
    877873      TText *t6 = pave->AddText(Form("Mean Arr. Time In Last 2 Extraction Bins:  %3i pixels",
    878                                        CountBadPixels(&disp24,5)));
    879       t6->SetTextColor(gStyle->GetColorPalette(Int_t(5./max*numcol)));
     874                                       CountBadPixels(&disp24,4)));
     875      t6->SetTextColor(gStyle->GetColorPalette(Int_t(4./max*numcol)));
    880876      t6->SetTextAlign(12);
    881       TText *t9 = pave->AddText(Form("Deviating Number of Photons:                    %3i pixels",
    882                                        CountBadPixels(&disp24,6)));
    883       t9->SetTextColor(gStyle->GetColorPalette(Int_t(6./max*numcol)));
    884       t9->SetTextAlign(12);
    885877      TText *t10= pave->AddText(Form("High-Gain Histogram Overflow:                  %3i pixels",
    886                                        CountBadPixels(&disp24,7 )));
    887       t10->SetTextColor(gStyle->GetColorPalette(Int_t(7./max*numcol)));
     878                                       CountBadPixels(&disp24,5 )));
     879      t10->SetTextColor(gStyle->GetColorPalette(Int_t(5./max*numcol)));
    888880      t10->SetTextAlign(12);
    889881      TText *t11= pave->AddText(Form("Low-Gain Histogram Overflow:                   %3i pixels",
    890                                        CountBadPixels(&disp24,8 )));
    891       t11->SetTextColor(gStyle->GetColorPalette(Int_t(8./max*numcol)));
     882                                       CountBadPixels(&disp24,6 )));
     883      t11->SetTextColor(gStyle->GetColorPalette(Int_t(6./max*numcol)));
    892884      t11->SetTextAlign(12);
    893885      TText *t12= pave->AddText(Form("Presumably dead from Ped. Rms:              %3i pixels",
    894                                        CountBadPixels(&disp24,9 )));
    895       t12->SetTextColor(gStyle->GetColorPalette(Int_t(9./max*numcol)));
     886                                       CountBadPixels(&disp24,7 )));
     887      t12->SetTextColor(gStyle->GetColorPalette(Int_t(7./max*numcol)));
    896888      t12->SetTextAlign(12);
    897889      TText *t13= pave->AddText(Form("Fluctuating Pulse Arrival Times:                 %3i pixels",
    898                                        CountBadPixels(&disp24,10)));
    899       t13->SetTextColor(gStyle->GetColorPalette(Int_t(10./max*numcol)));
     890                                       CountBadPixels(&disp24,8 )));
     891      t13->SetTextColor(gStyle->GetColorPalette(Int_t(8./max*numcol)));
    900892      t13->SetTextAlign(12);
    901893      TText *t17 = pave->AddText(Form("Deviating Number of Photo-electrons:       %3i pixels",
    902                                        CountBadPixels(&disp24,11)));
    903       t17->SetTextColor(gStyle->GetColorPalette(Int_t(11./max*numcol)));
     894                                       CountBadPixels(&disp24,9 )));
     895      t17->SetTextColor(gStyle->GetColorPalette(Int_t(9./max*numcol)));
    904896      t17->SetTextAlign(12);
    905897      TText *t14= pave->AddText(Form("Previously Excluded:                                   %3i pixels",
    906                                        CountBadPixels(&disp24,12)));
    907       t14->SetTextColor(gStyle->GetColorPalette(Int_t(12./max*numcol)));
     898                                       CountBadPixels(&disp24,10)));
     899      t14->SetTextColor(gStyle->GetColorPalette(Int_t(10./max*numcol)));
    908900      t14->SetTextAlign(12);
     901      TText *t15= pave->AddText(Form("Too many Low-Gain Blackout Events              %3i pixels",
     902                                       CountBadPixels(&disp24,25 )));
     903      t15->SetTextColor(gStyle->GetColorPalette(Int_t(11./max*numcol)));
     904      t15->SetTextAlign(12);
    909905      pave->Draw();
    910906
     
    15141510      const MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)hilocam[i];
    15151511
    1516       const Float_t ratio = pix.GetHiLoChargeRatio();
    1517       const Float_t sigma = pix.GetHiLoChargeRatioSigma();
     1512      const Float_t ratio  = pix.GetHiLoChargeRatio();
     1513      const Float_t raterr = pix.GetHiLoChargeRatioErr();
     1514      const Float_t sigma  = pix.GetHiLoChargeRatioSigma();
    15181515
    15191516      if (ratio < 0.)
     
    15261523     
    15271524      cpix.SetConversionHiLo(ratio);
    1528       cpix.SetConversionHiLoErr(sigma);     
     1525      cpix.SetConversionHiLoErr(raterr);
     1526      cpix.SetConversionHiLoSigma(sigma);
    15291527    }
    15301528
     
    19431941      tlist.AddToList(&steer);
    19441942
    1945     tlist.AddToList(&fillcam);
    1946 
    19471943    if (IsRelTimes())
    19481944    {
     
    19501946        tlist.AddToList(&timecalc);
    19511947    }
     1948
     1949    tlist.AddToList(&fillcam);
    19521950
    19531951    if (IsUseBlindPixel())
     
    19991997    if (fIsPixelCheck)
    20001998    {
    2001         chargecam[fCheckedPixId].DrawClone("");
    2002         chargecam(fCheckedPixId).DrawClone("");
     1999        chargecam[fCheckedPixId].DrawClone("datacheck");
     2000        chargecam(fCheckedPixId).DrawClone("datacheck");
    20032001
    20042002        if (IsRelTimes())
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r7130 r7188  
    786786    fDeadPixelCheck = GetEnv("DeadPixelsCheck", fDeadPixelCheck);
    787787
     788    fBadPixelsFile = GetEnv("BadPixelsFile",fBadPixelsFile.Data());
     789    fReferenceFile = GetEnv("ReferenceFile",fReferenceFile.Data());
     790    ReadReferenceFile();
     791
     792    // ------------- Do not put simple resource below --------------
     793
    788794    // Setup an environment task
    789795    MTaskEnv tenv("ExtractSignal");
     
    810816    // ..and store it
    811817    SetExtractor((MExtractor*)tenv.GetTask());
    812 
    813     fBadPixelsFile = GetEnv("BadPixelsFile",fBadPixelsFile.Data());
    814     fReferenceFile = GetEnv("ReferenceFile",fReferenceFile.Data());
    815     ReadReferenceFile();
    816818
    817819    return kTRUE;
     
    11191121    fcalib.SetInverted();
    11201122
     1123    tlist.AddToList(&decode);
     1124
    11211125    if (fIsPulsePosCheck)
    11221126    {
    11231127        fillpul.SetFilter(&fcalib);
    1124         tlist.AddToList(&decode);
    11251128        tlist.AddToList(&fcalib);
    11261129        tlist.AddToList(&fillpul);
  • trunk/MagicSoft/Mars/mmain/MEventDisplay.cc

    r7176 r7188  
    594594    // Now read event...
    595595    //
     596    // FIXME: Can we safly replace ReadinEvent() by RedinEvent(1)?
    596597    ReadinEvent();
     598
    597599
    598600    MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
  • trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc

    r7070 r7188  
    175175
    176176const TString MExtractPedestal::fgNamePedestalCam = "MPedestalCam";
     177const TString MExtractPedestal::fgNameRawEvtData  = "MRawEvtData";
    177178const UInt_t  MExtractPedestal::fgNumDump = 500;
    178179
     
    191192MExtractPedestal::MExtractPedestal(const char *name, const char *title)
    192193    : fGeom(NULL), fPedestalsIn(NULL), fPedestalsInter(NULL), fPedestalsOut(NULL),
    193       fExtractor(NULL), fExtractWinFirst(0), fExtractWinSize(0)
     194      fExtractor(NULL), fExtractWinFirst(0), fExtractWinSize(0), fUseSpecialPixels(kFALSE)
    194195{
    195196    fName  = name  ? name  : "MExtractPedestal";
     
    207208    SetNamePedestalCamIn();
    208209    SetNamePedestalCamOut();
     210    SetNamePedestalCamInter();
     211    SetNameRawEvtData();
    209212    SetNumDump();
    210213
     
    311314
    312315  Clear();
    313  
     316
     317  fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber(fNameRawEvtData));
     318  if (!fRawEvt)
     319      if (!fUseSpecialPixels)
     320      {
     321          *fLog << err << AddSerialNumber(fNameRawEvtData) << " not found... aborting." << endl;
     322          return kFALSE;
     323      }
     324
     325
    314326  fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
    315327  if (!fRawEvt)
     
    372384Int_t MExtractPedestal::Process()
    373385{
     386    //
     387    // Necessary check for extraction of special pixels
     388    // together with data which does not yet have them
     389    //
     390    if (fSumx.GetSize()==0)
     391        return kTRUE;
     392
    374393    if (fExtractor)
    375394        fExtractor->SetNoiseCalculation(fRandomCalculation);
     
    405424Bool_t MExtractPedestal::ReInit(MParList *pList)
    406425{
    407   // If the size is not yet set, set the size
    408   if (fSumx.GetSize()==0)
    409   {
    410       const Int_t npixels  = fPedestalsOut->GetSize();
    411       const Int_t areas    = fPedestalsOut->GetNumAverageArea();
    412       const Int_t sectors  = fPedestalsOut->GetNumAverageSector();
    413 
    414       fSumx.  Set(npixels);
    415       fSumx2. Set(npixels);
    416       fSumAB0.Set(npixels);
    417       fSumAB1.Set(npixels);
    418 
    419       fAreaSumx.  Set(areas);
    420       fAreaSumx2. Set(areas);
    421       fAreaSumAB0.Set(areas);
    422       fAreaSumAB1.Set(areas);
    423       fAreaFilled.Set(areas);
    424       fAreaValid .Set(areas);
    425 
    426       fSectorSumx.  Set(sectors);
    427       fSectorSumx2. Set(sectors);
    428       fSectorSumAB0.Set(sectors);
    429       fSectorSumAB1.Set(sectors);
    430       fSectorFilled.Set(sectors);
    431       fSectorValid .Set(sectors);
    432 
    433       for (Int_t i=0; i<npixels; i++)
    434       {
    435           const UInt_t aidx   = (*fGeom)[i].GetAidx();
    436           const UInt_t sector = (*fGeom)[i].GetSector();
    437 
    438           fAreaValid  [aidx]  ++;
    439           fSectorValid[sector]++;
    440       }
    441   }
    442 
    443   if (fExtractor)
    444   {
    445       if (!((MTask*)fExtractor)->ReInit(pList))
    446           return kFALSE;
    447 
    448       SetExtractWindow(fExtractor->GetHiGainFirst(), (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
    449   }
    450 
    451   return kTRUE;
     426    // Necessary check for special pixels which might not yet have existed
     427    if (!fRawEvt)
     428    {
     429        if (fRunHeader->GetFormatVersion() > 3)
     430            return kTRUE;
     431
     432        *fLog << err << "ERROR - " << fNameRawEvtData << " [MRawEvtData] has not ";
     433        *fLog << "been found and format version > 3... abort." << endl;
     434        return kFALSE;
     435    }
     436
     437    // If the size is not yet set, set the size
     438    if (fSumx.GetSize()==0)
     439    {
     440        // Initialize the normal pixels (size of MPedestalCam already set by MGeomApply)
     441        const Int_t npixels  = fPedestalsOut->GetSize();
     442
     443        fSumx.  Set(npixels);
     444        fSumx2. Set(npixels);
     445        fSumAB0.Set(npixels);
     446        fSumAB1.Set(npixels);
     447
     448        if (fUseSpecialPixels)
     449        {
     450            // Initialize size of MPedestalCam in case of special pixels (not done by MGeomApply)
     451            const UShort_t nspecial = fRunHeader->GetNumSpecialPixels();
     452            if (nspecial == 0)
     453            {
     454                *fLog << warn << "WARNING - Number of special pixels is 0." << endl;
     455                return kTRUE;
     456            }
     457
     458            fPedestalsOut->InitSize((UInt_t)nspecial);
     459        }
     460        else
     461        {
     462            // Initialize the averaged areas and sectors (do not exist for special pixels)
     463            const Int_t areas    = fPedestalsOut->GetNumAverageArea();
     464            const Int_t sectors  = fPedestalsOut->GetNumAverageSector();
     465
     466            fAreaSumx.  Set(areas);
     467            fAreaSumx2. Set(areas);
     468            fAreaSumAB0.Set(areas);
     469            fAreaSumAB1.Set(areas);
     470            fAreaFilled.Set(areas);
     471            fAreaValid .Set(areas);
     472
     473            fSectorSumx.  Set(sectors);
     474            fSectorSumx2. Set(sectors);
     475            fSectorSumAB0.Set(sectors);
     476            fSectorSumAB1.Set(sectors);
     477            fSectorFilled.Set(sectors);
     478            fSectorValid .Set(sectors);
     479
     480            for (Int_t i=0; i<npixels; i++)
     481            {
     482                const UInt_t aidx   = (*fGeom)[i].GetAidx();
     483                const UInt_t sector = (*fGeom)[i].GetSector();
     484
     485                fAreaValid  [aidx]  ++;
     486                fSectorValid[sector]++;
     487            }
     488        }
     489    }
     490
     491    if (fExtractor)
     492    {
     493        if (!((MTask*)fExtractor)->ReInit(pList))
     494            return kFALSE;
     495
     496        SetExtractWindow(fExtractor->GetHiGainFirst(), (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
     497    }
     498
     499    return kTRUE;
    452500}
    453501
    454502Int_t MExtractPedestal::PostProcess()
    455503{
    456   fPedestalsIn = NULL;
    457   return fExtractor ? fExtractor->CallPostProcess() : kTRUE;
     504    fPedestalsIn = NULL;
     505    return fExtractor ? fExtractor->CallPostProcess() : kTRUE;
    458506}
    459507
     
    486534    }
    487535
     536    // find resource for fUseSpecialPixels
     537    if (IsEnvDefined(env, prefix, "UseSpecialPixels", print))
     538    {
     539        SetUseSpecialPixels(GetEnvValue(env, prefix, "UseSpecialPixels", fUseSpecialPixels));
     540        rc = kTRUE;
     541    }
     542
    488543    // find resource for numeventsdump
    489544    if (IsEnvDefined(env, prefix, "NumEventsDump", print))
     
    577632void MExtractPedestal::CalcPixResults(const UInt_t nevts, const UInt_t pixid)
    578633{
    579     const Float_t sum  = fSumx[pixid];
    580     const Float_t sum2 = fSumx2[pixid];
     634    const Double_t sum  = fSumx[pixid];
     635    const Double_t sum2 = fSumx2[pixid];
    581636
    582637    // 1. Calculate the mean of the sums:
    583     Float_t ped        = sum/nevts;
     638    Double_t ped = sum/nevts;
    584639
    585640    // 2. Calculate the Variance of the sums:
    586     Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);
     641    Double_t var = (sum2-sum*sum/nevts)/(nevts-1.);
    587642
    588643    // 3. Calculate the amplitude of the 150MHz "AB" noise
    589     Float_t abOffs = (fSumAB0[pixid] - fSumAB1[pixid]) / nevts;
     644    Double_t abOffs = (fSumAB0[pixid] - fSumAB1[pixid]) / nevts;
    590645
    591646    // 4. Scale the mean, variance and AB-noise to the number of slices:
     
    595650
    596651    // 5. Calculate the RMS from the Variance:
    597     const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);
     652    const Double_t rms = var<0 ? 0 : TMath::Sqrt(var);
    598653
    599654    (*fPedestalsOut)[pixid].Set(ped, rms, abOffs, nevts);
     
    612667void MExtractPedestal::CalcAreaResults(const UInt_t nevts, const UInt_t napix, const UInt_t aidx)
    613668{
    614     const Float_t sum  = fAreaSumx[aidx];
    615     const Float_t sum2 = fAreaSumx2[aidx];
     669    const Double_t sum  = fAreaSumx[aidx];
     670    const Double_t sum2 = fAreaSumx2[aidx];
    616671
    617672    // 1. Calculate the mean of the sums:
    618     Float_t ped        = sum/nevts;
     673    Double_t ped = sum/nevts;
    619674
    620675    // 2. Calculate the Variance of the sums:
    621     Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);
     676    Double_t var = (sum2/napix-sum*sum/nevts)/(nevts-1.);
    622677
    623678    // 3. Calculate the amplitude of the 150MHz "AB" noise
    624     Float_t abOffs = (fAreaSumAB0[aidx] - fAreaSumAB1[aidx]) / nevts;
     679    Double_t abOffs = (fAreaSumAB0[aidx] - fAreaSumAB1[aidx]) / nevts;
    625680
    626681    // 4. Scale the mean, variance and AB-noise to the number of slices:
     
    635690
    636691    // 6. Calculate the RMS from the Variance:
    637     const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);
     692    const Double_t rms = var<0 ? 0 : TMath::Sqrt(var);
    638693
    639694    fPedestalsOut->GetAverageArea(aidx).Set(ped, rms, abOffs, nevts);
     
    652707void MExtractPedestal::CalcSectorResults(const UInt_t nevts, const UInt_t nspix, const UInt_t sector)
    653708{
    654     const Float_t sum  = fSectorSumx[sector];
    655     const Float_t sum2 = fSectorSumx2[sector];
     709    const Double_t sum  = fSectorSumx[sector];
     710    const Double_t sum2 = fSectorSumx2[sector];
    656711
    657712    // 1. Calculate the mean of the sums:
    658     Float_t ped        = sum/nevts;
     713    Double_t ped        = sum/nevts;
    659714
    660715    // 2. Calculate the Variance of the sums:
    661     Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);
     716    Double_t var = (sum2/nspix-sum*sum/nevts)/(nevts-1.);
    662717
    663718    // 3. Calculate the amplitude of the 150MHz "AB" noise
    664     Float_t abOffs = (fSectorSumAB0[sector] - fSectorSumAB1[sector]) / nevts;
     719    Double_t abOffs = (fSectorSumAB0[sector] - fSectorSumAB1[sector]) / nevts;
    665720
    666721    // 4. Scale the mean, variance and AB-noise to the number of slices:
     
    675730
    676731    // 6. Calculate the RMS from the Variance:
    677     const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);
     732    const Double_t rms = var<0 ? 0 : TMath::Sqrt(var);
    678733
    679734    fPedestalsOut->GetAverageSector(sector).Set(ped, rms, abOffs, nevts);
     
    688743    *fLog << "Intermediate Storage is       " << (fIntermediateStorage?"on":"off") << endl;
    689744    *fLog << "Pedestal Update is            " << (fPedestalUpdate?"on":"off") << endl;
     745    *fLog << "Special pixel mode            " << (fUseSpecialPixels?"on":"off") << endl;
    690746    if (fPedestalUpdate)
    691747    {
  • trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h

    r6913 r7188  
    2525private:
    2626  static const TString  fgNamePedestalCam;  //! "MPedestalCam"
     27  static const TString  fgNameRawEvtData;   //! "MRawEvtData"
    2728  static const UInt_t   fgNumDump;          //!
    2829
    2930  TString fNamePedestalCamIn;        // Name of the incoming 'MPedestalCam' container
    3031  TString fNamePedestalCamOut;       // Name of the outgoing 'MPedestalCam' container
    31   TString fNamePedestalCamInter;     // Name of the intermediate 'MPedestalCam' container 
     32  TString fNamePedestalCamInter;     // Name of the intermediate 'MPedestalCam' container
     33  TString fNameRawEvtData;           // Name of MRawEvtData
    3234
    3335  Bool_t  fRandomCalculation;        // Is pedestalextraction by extractor random?
     
    5557 
    5658  Bool_t  fPedestalUpdate;           // Flag if the pedestal shall be updated after every fNumEventsDump
     59  Bool_t  fUseSpecialPixels;         // Flag if the special pixels shall be treated
    5760
    5861  MArrayD fSumx;                     // sum of values
     
    103106
    104107  // names
    105   void SetNamePedestalCamIn   (const char *name=fgNamePedestalCam.Data()) { fNamePedestalCamIn    = name; }
    106   void SetNamePedestalCamInter(const char *name=fgNamePedestalCam.Data()) { fNamePedestalCamInter = name; } 
    107   void SetNamePedestalCamOut  (const char *name=fgNamePedestalCam.Data()) { fNamePedestalCamOut   = name; }
     108  void SetNamePedestalCamIn   (const char *name=fgNamePedestalCam) { fNamePedestalCamIn    = name; }
     109  void SetNamePedestalCamInter(const char *name=fgNamePedestalCam) { fNamePedestalCamInter = name; }
     110  void SetNamePedestalCamOut  (const char *name=fgNamePedestalCam) { fNamePedestalCamOut   = name; }
     111  void SetNameRawEvtData      (const char *name=fgNameRawEvtData)  { fNameRawEvtData       = name; }
    108112
    109113  // pointers
     
    115119  // flags
    116120  void SetIntermediateStorage (Bool_t b=kTRUE) { fIntermediateStorage = b; }
     121  void SetUseSpecialPixels    (Bool_t b=kTRUE) { fUseSpecialPixels    = b; }
    117122  void SetPedestalUpdate      (Bool_t b=kTRUE) { fPedestalUpdate      = b; }
    118123  void SetRandomCalculation   (Bool_t b=kTRUE) { fRandomCalculation   = b; }
  • trunk/MagicSoft/Mars/mpedestal/MMcPedestalCopy.cc

    r3803 r7188  
    7979Bool_t MMcPedestalCopy::CheckRunType(MParList *pList) const
    8080{
    81     const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     81    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
    8282    if (!run)
    8383    {
    84         *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
     84      *fLog << warn << dbginf << "Warning - cannot check file type, "
     85            << AddSerialNumber("MRawRunHeader") << " not found." << endl;
    8586        return kTRUE;
    8687    }
     
    138139      }
    139140
    140     MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
     141    MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject(AddSerialNumber("MMcRunHeader"));
    141142    if (!mcrun)
    142         *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
     143      *fLog << warn << dbginf << AddSerialNumber("MMcRunHeader")
     144            << " not found... assuming camera<0.7" << endl;
    143145
    144146    const int num = pedcam->GetSize();
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc

    r7130 r7188  
    276276 
    277277  //
    278   // In the other case, produce the MPedestalCam to be use the subsequent (non-pedestal) events
     278  // In the other case, produce the MPedestalCam to be use the subsequent
     279  // (non-pedestal) events
    279280  //
    280281  *fLog << inf << "Finalizing pedestal calculations..." << flush;
     
    299300Int_t MPedCalcPedRun::Calc()
    300301{
    301 
    302302  if (fIsNotPedRun && !IsPedBitSet())
    303303    return kTRUE;
     
    317317  while (pixel.Next())
    318318  {
    319       const UInt_t idx    = pixel.GetPixelId();
    320       const UInt_t aidx   = (*fGeom)[idx].GetAidx();
    321       const UInt_t sector = (*fGeom)[idx].GetSector();     
     319      const UInt_t idx = pixel.GetPixelId();
    322320
    323321      Float_t sum = 0.;
     
    330328        CalcSums(pixel, sum, ab0, ab1);
    331329
    332       fSumx[idx]           += sum;
     330      fSumx[idx] += sum;
     331
     332      if (fIntermediateStorage)
     333        (*fPedestalsInter)[idx].Set(sum,0.,0.,fUsedEvents);
     334
     335      const Float_t sqrsum = sum*sum;
     336
     337      fSumx2[idx]  += sqrsum;
     338      fSumAB0[idx] += ab0;
     339      fSumAB1[idx] += ab1;
     340
     341      if (fUseSpecialPixels)
     342        continue;
     343
     344      const UInt_t aidx   = (*fGeom)[idx].GetAidx();
     345      const UInt_t sector = (*fGeom)[idx].GetSector();     
     346
    333347      fAreaSumx[aidx]      += sum;
    334348      fSectorSumx[sector]  += sum;
    335349
    336       if (fIntermediateStorage)
    337         (*fPedestalsInter)[idx].Set(sum,0.,0.,fUsedEvents);
    338 
    339       const Float_t sqrsum   = sum*sum;
    340       fSumx2[idx]           += sqrsum;
    341       fAreaSumx2[aidx]      += sqrsum;
    342       fSectorSumx2[sector]  += sqrsum;
    343 
    344       fSumAB0[idx]         += ab0;
    345       fSumAB1[idx]         += ab1;
     350      fAreaSumx2[aidx]     += sqrsum;
     351      fSectorSumx2[sector] += sqrsum;
    346352
    347353      fAreaSumAB0[aidx]    += ab0;
     
    422428}
    423429
    424 
    425430// --------------------------------------------------------------------------
    426431//
     
    429434Int_t MPedCalcPedRun::Finalize()
    430435{
    431 
    432   if (fUsedEvents == 0)
     436    if (fUsedEvents == 0)
     437        return kTRUE;
     438
     439    //
     440    // Necessary check for extraction of special pixels
     441    // together with data which does not yet have them
     442    //
     443    if (fSumx.GetSize()==0)
     444        return kTRUE;
     445
     446    MRawEvtPixelIter pixel(fRawEvt);
     447    while (pixel.Next())
     448        CalcPixResults(fUsedEvents, pixel.GetPixelId());
     449
     450    if (!fUseSpecialPixels)
     451    {
     452
     453        //
     454        // Loop over the (two) area indices to get the averaged pedestal per aidx
     455        //
     456        for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)
     457            if (fAreaValid[aidx]>0)
     458                CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx);
     459
     460        //
     461        // Loop over the (six) sector indices to get the averaged pedestal per sector
     462        //
     463        for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++)
     464            if (fSectorValid[sector]>0)
     465                CalcSectorResults(fUsedEvents, fSectorValid[sector], sector);
     466    }
     467
     468    fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize);
     469    fPedestalsOut->SetReadyToSave();
     470
    433471    return kTRUE;
    434  
    435   MRawEvtPixelIter pixel(fRawEvt);
    436   while (pixel.Next())
    437     CalcPixResults(fUsedEvents, pixel.GetPixelId());
    438  
    439   //
    440   // Loop over the (two) area indices to get the averaged pedestal per aidx
    441   //
    442   for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)
    443     if (fAreaValid[aidx]>0)
    444       CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx);
    445  
    446   //
    447   // Loop over the (six) sector indices to get the averaged pedestal per sector
    448   //
    449   for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++)
    450     if (fSectorValid[sector]>0)
    451       CalcSectorResults(fUsedEvents, fSectorValid[sector], sector);
    452  
    453   fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize);
    454   fPedestalsOut->SetReadyToSave();
    455  
    456   return kTRUE;
    457472}
    458473
    459474Int_t MPedCalcPedRun::PostProcess()
    460475{
    461   if (!Finalize())
    462     return kFALSE;
    463  
    464   return MExtractPedestal::PostProcess();
     476    if (!fRawEvt)
     477        return kTRUE;
     478
     479    if (!Finalize())
     480        return kFALSE;
     481
     482    return MExtractPedestal::PostProcess();
    465483}
    466484
     
    485503void MPedCalcPedRun::Print(Option_t *o) const
    486504{
    487 
    488505    MExtractPedestal::Print(o);
    489506
  • trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc

    r5558 r7188  
    276276}
    277277
     278void MPedestalCam::PrintArr(const TCollection &list) const
     279{
     280    Int_t id = 0;
     281
     282    TIter Next(&list);
     283    MPedestalPix *pix = 0;
     284
     285    while ((pix=(MPedestalPix*)Next()))
     286        *fLog << Form("Nr.: %4i  Pedestal: %5.2f    RMS: %5.2f    ABOffset: %5.2f ",
     287                      id++, pix->GetPedestal(), pix->GetPedestalRms(), pix->GetPedestalABoffset()) << endl;
     288}
     289
    278290void MPedestalCam::Print(Option_t *o) const
    279291{
    280292    *fLog << all << GetDescriptor() << ":" << endl;
    281     int id = 0;
    282 
    283     TIter Next(fArray);
    284     MPedestalPix *pix;
    285     while ((pix=(MPedestalPix*)Next()))
    286     {
    287         id++;
    288 
    289         if (!pix->IsValid())
    290             continue;
    291 
    292         *fLog << id-1 << ": ";
    293         *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
    294     }
     293    *fLog << "Pixels:" << endl;   
     294    *fLog << endl;
     295
     296    PrintArr(*fArray);
     297
     298    *fLog << endl;
     299    *fLog << "Event-by-event averaged areas:" << endl;   
     300    *fLog << endl;
     301
     302    PrintArr(*fAverageAreas);
     303
     304    *fLog << endl;
     305    *fLog << "Event-by-event averaged sectors:" << endl;
     306    *fLog << endl;
     307
     308    PrintArr(*fAverageSectors);
    295309}
    296310
  • trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h

    r5558 r7188  
    2424
    2525  UInt_t fTotalEntries;  // Total number of times, the Process was executed (to estimate the error of pedestal)
     26
     27  void PrintArr(const TCollection &list) const;
    2628
    2729public:
  • trunk/MagicSoft/Mars/mreport/MReportCC.cc

    r7026 r7188  
    3131// From here maily weather station data is decoded such as
    3232// temperature, humidity, wind-speed and solar radiation
     33//
     34// Class Version 2:
     35// ----------------
     36//  +  Float_t fUPSStatus; // arbitrary units (still not properly defined)
     37//  +  Float_t fDifRubGPS; // [us] Difference between the Rubidium clock time and the time provided by the GPS receiver
     38//
    3339//
    3440//////////////////////////////////////////////////////////////////////////////
     
    7480    Int_t len;
    7581    const Int_t n=sscanf(str.Data(),
    76                          "%*f %*f %*f %*f %f %f %f %f %*f %*f %n",
     82                         "%*f %*f %*f %*f %f %f %f %f %f %f %n",
    7783                         &fTemperature, &fSolarRadiation, &fWindSpeed,
    78                          &fHumidity, &len);
    79     if (n!=4)
     84                         &fHumidity, &fUPSStatus, &fDifRubGPS, &len);
     85    if (n!=6)
    8086    {
    8187        *fLog << warn << "WARNING - Wrong number of arguments." << endl;
  • trunk/MagicSoft/Mars/mreport/MReportCC.h

    r7027 r7188  
    1414    Float_t fSolarRadiation; // [W/m^2] IR-Radiation
    1515
     16    Float_t fUPSStatus;      // arbitrary units (still not properly defined)
     17    Float_t fDifRubGPS;      // [us] Difference between the Rubidium clock time and the time provided by the GPS receiver
     18
    1619    Int_t InterpreteBody(TString &str, Int_t ver);
    1720
     
    2629    void Print(Option_t *opt) const;
    2730
    28     ClassDef(MReportCC, 1) // Class for CC-REPORT information
     31    ClassDef(MReportCC, 2) // Class for CC-REPORT information
    2932};
    3033
  • trunk/MagicSoft/Mars/mreport/MReportCamera.cc

    r6962 r7188  
    568568        return kCONTINUE;
    569569
    570     if (ver > gkActiveLoadControlVersNum)
     570    if (ver >= gkActiveLoadControlVersNum)
    571571    {
    572572         if (!InterpreteActiveLoad(str))
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc

    r7099 r7188  
    159159const Float_t MExtractTimeAndChargeSpline::fgFallTimeHiGain   = 0.5;
    160160const Float_t MExtractTimeAndChargeSpline::fgLoGainStretch    = 1.5;
    161 const Float_t MExtractTimeAndChargeSpline::fgOffsetLoGain     = 1.7;  // 5 ns
     161const Float_t MExtractTimeAndChargeSpline::fgOffsetLoGain     = 1.39;  // 5 ns
    162162const Float_t MExtractTimeAndChargeSpline::fgLoGainStartShift = -1.8; 
    163163
  • trunk/MagicSoft/include-Classes/MMcFormat/MTriggerDefine.h

    r5253 r7188  
    33//      In this file are the fundamental definitions for the class MCTrigger
    44//
     5// Number of pixels in the trigger region (used by camera simulation,
     6// see camera.cxx.
    57//
    68#define TRIGGER_PIXELS_1      397
    79#define TRIGGER_PIXELS_2      397
    810#define TRIGGER_PIXELS_3      1657
     11#define TRIGGER_PIXELS_4      547  // For MGeomCamMagic1183, PRELIMINARY!
    912#define TRIGGER_PIXELS_5      397
    1013#define TRIGGER_PIXELS_6      1657
Note: See TracChangeset for help on using the changeset viewer.