Changeset 5137


Ignore:
Timestamp:
09/25/04 14:01:50 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5136 r5137  
    2121 2004/09/23: Markus Gaug
    2222 
     23   * mhcalib/MHCalibration*Cam.[h,cc]
     24     - replaced the TObjArrays by TOrdCollections because the TObjArrays
     25       do not enter the streamer. In case, the histograms want to be
     26       stored, need to use an TOrdCollection, instead, like in the
     27       MCalibration*Cam classes.
     28     - simplified the naming of the histograms somewhat
     29
    2330   * msignal/MExtractBlindPixel.[h,cc]
    2431     - added enum DataType_t to set in which MRawEvtData container the
  • trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc

    r5047 r5137  
    7474/////////////////////////////////////////////////////////////////////////////
    7575#include "MCalibrationQECam.h"
     76#include "MCalibrationQEPix.h"
    7677
    7778#include <TOrdCollection.h>
     79#include <TGraphErrors.h>
     80#include <TH2D.h>
    7881
    7982#include "MLog.h"
    8083#include "MLogManip.h"
    8184
    82 #include "MCalibrationQEPix.h"
    83 
    8485ClassImp(MCalibrationQECam);
    8586
    8687using namespace std;
    8788
    88 const Float_t MCalibrationQECam::gkPlexiglassQE    = 0.96;
     89const Float_t MCalibrationQECam::gkPlexiglassQE    = 0.92;
    8990const Float_t MCalibrationQECam::gkPlexiglassQEErr = 0.01;
    90 
    9191// --------------------------------------------------------------------------
    9292//
     
    785785}
    786786
    787 
    788 
    789 
    790 
    791 
    792 
    793 
     787// --------------------------------------------------------------------------
     788//
     789// Returns a TGraphErrors correlating the corning blues with the
     790// calcualted quantum efficiency of each pixel, obtained with the F-Factor
     791// method.
     792//
     793TGraphErrors *MCalibrationQECam::GetGraphQEvsCorningBlues() const
     794{
     795
     796  const UInt_t size = GetSize();
     797
     798  if (fCorningBlues.GetSize() == 0)
     799    {
     800      *fLog << warn << "Size of intialized Cornings Blue is zero, please use MCalibrationQECamMagic" << endl;
     801      return NULL;
     802    }
     803 
     804  if (fCorningBlues.GetSize() != size)
     805    *fLog << warn << "Sizes mismatch, cannot create Graph!! " << endl;
     806
     807  TArrayD qes(size);
     808  TArrayD qeerrs(size);
     809  TArrayD corns(size);
     810  TArrayD cornerrs(size);
     811 
     812  Int_t cnt = 0;
     813 
     814  for (UInt_t i=0; i<size; i++)
     815    {
     816      MCalibrationQEPix &pix = (MCalibrationQEPix&)(*this)[i];
     817      if (pix.IsFFactorMethodValid() && fCorningBlues[i] > 0. && pix.GetQECascadesFFactorErr() > 0.)
     818        {
     819          qes   [i] = pix.GetQECascadesFFactor();
     820          qeerrs[i] = pix.GetQECascadesFFactorErr();
     821          corns [i] = fCorningBlues[i];
     822          cornerrs[i] = 0.05;
     823          cnt++;
     824        }
     825    }
     826 
     827  TGraphErrors *gr = new TGraphErrors(cnt,
     828                                     corns.GetArray(),qes.GetArray(),
     829                                      cornerrs.GetArray(),qeerrs.GetArray());
     830  return gr;
     831}
     832
     833// --------------------------------------------------------------------------
     834//
     835// Returns a TGraphErrors correlating the corning reds with the
     836// calcualted quantum efficiency of each pixel, obtained with the F-Factor
     837// method.
     838//
     839TGraphErrors *MCalibrationQECam::GetGraphQEvsCorningReds() const
     840{
     841
     842  const UInt_t size = GetSize();
     843
     844  if (fCorningReds.GetSize() == 0)
     845    {
     846      *fLog << warn << "Size of intialized Cornings Red is zero, please use MCalibrationQECamMagic" << endl;
     847      return NULL;
     848    }
     849 
     850  if (fCorningReds.GetSize() != size)
     851    *fLog << warn << "Sizes mismatch, cannot create Graph!! " << endl;
     852
     853  TArrayD qes(size);
     854  TArrayD qeerrs(size);
     855  TArrayD corns(size);
     856  TArrayD cornerrs(size);
     857
     858  Int_t cnt = 0;
     859
     860  for (UInt_t i=0; i<size; i++)
     861    {
     862      MCalibrationQEPix &pix = (MCalibrationQEPix&)(*this)[i];
     863      if (pix.IsFFactorMethodValid() && fCorningReds[i] > 0. && pix.GetQECascadesFFactorErr() > 0.)
     864        {
     865          qes     [i] = pix.GetQECascadesFFactor();
     866          qeerrs  [i] = pix.GetQECascadesFFactorErr();
     867          corns   [i] = fCorningReds[i];
     868          cornerrs[i] = 0.05;
     869          cnt++;
     870        }
     871     
     872    }
     873 
     874  TGraphErrors *gr = new TGraphErrors(cnt,
     875                                      corns.GetArray(),qes.GetArray(),
     876                                      cornerrs.GetArray(),qeerrs.GetArray());
     877 
     878  return gr;
     879}
     880
     881TH2D *MCalibrationQECam::GetHistQEvsCorningBlues( const Int_t nbins, const Axis_t first, const Axis_t last ) const
     882{
     883
     884  const UInt_t size = GetSize();
     885
     886  if (fCorningBlues.GetSize() == 0)
     887    return NULL;
     888 
     889  if (fCorningBlues.GetSize() != size)
     890    *fLog << warn << "Sizes mismatch, cannot create Graph!! " << endl;
     891
     892  TH2D *h = new TH2D("hist","QE vs. Corning Blue",nbins,first,last,nbins,0.,0.35);
     893 
     894  for (UInt_t i=0; i<size; i++)
     895    {
     896      MCalibrationQEPix &pix = (MCalibrationQEPix&)(*this)[i];
     897      if (pix.IsFFactorMethodValid() && fCorningBlues[i] > 0.)
     898        h->Fill(fCorningBlues[i],pix.GetQECascadesFFactor());
     899    }
     900 
     901  return h;
     902}
     903
     904TH2D *MCalibrationQECam::GetHistQEvsCorningReds( const Int_t nbins, const Axis_t first, const Axis_t last ) const
     905{
     906
     907  const UInt_t size = GetSize();
     908
     909  if (fCorningReds.GetSize() == 0)
     910    return NULL;
     911 
     912  if (fCorningReds.GetSize() != size)
     913    *fLog << warn << "Sizes mismatch, cannot create Graph!! " << endl;
     914
     915  TH2D *h = new TH2D("hist","QE vs. Corning Red",nbins,first,last,nbins,0.,0.35);
     916
     917  for (UInt_t i=0; i<size; i++)
     918    {
     919      MCalibrationQEPix &pix = (MCalibrationQEPix&)(*this)[i];
     920      if (pix.IsFFactorMethodValid() && fCorningReds[i] > 0.)
     921        h->Fill(fCorningReds[i],pix.GetQECascadesFFactor());
     922    }
     923 
     924  return h;
     925}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationQECamMagic.cc

    r4880 r5137  
    7979 
    8080  Double_t creds[577];
    81  
    82   creds[1] = 1.6;
    83   creds[2] = 8.7;
    84   creds[3] = 6.8;
    85   creds[4] = 10.3;
    86   creds[5] = 8.7;
    87   creds[6] = -1.;
    88   creds[7] = 1.3;
    89   creds[8] = 0.4;
    90   creds[9] = 7.7 ;
    91   creds[10] = 9.8;
    92   creds[11] = 5.9;
    93   creds[12] = 7.4;
    94   creds[13] = 7.4;
    95   creds[14] = 7.0;
    96   creds[15] = 7.2;
    97   creds[16] = 6.8;
    98   creds[17] = 6.9;
    99   creds[18] = 6.6;
    100   creds[19] = 1.8;
    101   creds[20] = 4.9;
    102   creds[21] = 7.1;
    103   creds[22] = 7.7;
    104   creds[23] = 8.9;
    105   creds[24] = 11.9;
    106   creds[25] = 1.6;
    107   creds[26] = 9.3;
    108   creds[27] = 5.8;
    109   creds[28] = 9.0;
    110   creds[29] = 6.5;
    111   creds[30] = 6.1;
    112   creds[31] = 8.1;
    113   creds[32] = 6.7;
    114   creds[33] = 7.0;
    115   creds[34] = 7.1;
    116   creds[35] = 7.8;
    117   creds[36] = 6.9;
    118   creds[37] = 0.9;
    119   creds[38] = 3.3;
    120   creds[39] = 7.1;
    121   creds[40] = 5.8;
    122   creds[41] = 4.4;
    123   creds[42] = 8.1;
    124   creds[43] = 6.0;
    125   creds[44] = 6.3;
    126   creds[45] = 6.0;
    127   creds[46] = 8.0;
    128   creds[47] = 0.6;
    129   creds[48] = 7.2;
    130   creds[49] = 5.6;
    131   creds[50] = 7.3;
    132   creds[51] = 8.0;
    133   creds[52] = 9.1;
    134   creds[53] = 1.4;
    135   creds[54] = 6.9;
    136   creds[55] = 9.1;
    137   creds[56] = 6.4;
    138   creds[57] = 6.1;
    139   creds[58] = 6.2;
    140   creds[59] = 7.7;
    141   creds[60] = 5.1;
    142   creds[61] = 7.9;
    143   creds[62] = 6.9;
    144   creds[63] = 3.3;
    145   creds[64] = 3.7;
    146   creds[65] = 5.8;
    147   creds[66] = 8.0;
    148   creds[67] = 7.3;
    149   creds[68] = 7.3;
    150   creds[69] = 9.1;
    151   creds[70] = 4.0;
    152   creds[71] = 8.2;
    153   creds[72] = 8.7;
    154   creds[73] = 9.1;
    155   creds[74] = 8.2;
    156   creds[75] = 9.0;
    157   creds[76] = 7.8;
    158   creds[77] = 7.5;
    159   creds[78] = 1.3;
    160   creds[79] = 6.9;
    161   creds[80] = 8.7;
    162   creds[81] = 7.6;
    163   creds[82] = 5.6;
    164   creds[83] = 10.4;
    165   creds[84] = 6.1;
    166   creds[85] = 0.9;
    167   creds[86] = 7.7;
    168   creds[87] = 7.4;
    169   creds[88] = 6.9;
    170   creds[89] = 7.0;
    171   creds[90] = 3.3;
    172   creds[91] = 7.1;
    173   creds[92] = 5.8;
    174   creds[93] = 7.2;
    175   creds[94] = 5.4;
    176   creds[95] = 7.4;
    177   creds[96] = 6.6;
    178   creds[97] = 0.0;
    179   creds[98] = 6.9;
    180   creds[99] = 7.3;
     81
     82  creds[0]   = -1.;
     83  creds[1]   = 1.6;
     84  creds[2]   = 8.7;
     85  creds[3]   = 6.8;
     86  creds[4]   = 10.3;
     87  creds[5]   = 8.7;
     88  creds[6]   = -1.;
     89  creds[7]   = 1.3;
     90  creds[8]   = 0.4;
     91  creds[9]   = 7.7 ;
     92  creds[10]  = 9.8;
     93  creds[11]  = 5.9;
     94  creds[12]  = 7.4;
     95  creds[13]  = 7.4;
     96  creds[14]  = 7.0;
     97  creds[15]  = 7.2;
     98  creds[16]  = 6.8;
     99  creds[17]  = 6.9;
     100  creds[18]  = 6.6;
     101  creds[19]  = 1.8;
     102  creds[20]  = 4.9;
     103  creds[21]  = 7.1;
     104  creds[22]  = 7.7;
     105  creds[23]  = 8.9;
     106  creds[24]  = 11.9;
     107  creds[25]  = 1.6;
     108  creds[26]  = 9.3;
     109  creds[27]  = 5.8;
     110  creds[28]  = 9.0;
     111  creds[29]  = 6.5;
     112  creds[30]  = 6.1;
     113  creds[31]  = 8.1;
     114  creds[32]  = 6.7;
     115  creds[33]  = 7.0;
     116  creds[34]  = 7.1;
     117  creds[35]  = 7.8;
     118  creds[36]  = 6.9;
     119  creds[37]  = 0.9;
     120  creds[38]  = 3.3;
     121  creds[39]  = 7.1;
     122  creds[40]  = 5.8;
     123  creds[41]  = 4.4;
     124  creds[42]  = 8.1;
     125  creds[43]  = 6.0;
     126  creds[44]  = 6.3;
     127  creds[45]  = 6.0;
     128  creds[46]  = 8.0;
     129  creds[47]  = 0.6;
     130  creds[48]  = 7.2;
     131  creds[49]  = 5.6;
     132  creds[50]  = 7.3;
     133  creds[51]  = 8.0;
     134  creds[52]  = 9.1;
     135  creds[53]  = 1.4;
     136  creds[54]  = 6.9;
     137  creds[55]  = 9.1;
     138  creds[56]  = 6.4;
     139  creds[57]  = 6.1;
     140  creds[58]  = 6.2;
     141  creds[59]  = 7.7;
     142  creds[60]  = 5.1;
     143  creds[61]  = 7.9;
     144  creds[62]  = 6.9;
     145  creds[63]  = 3.3;
     146  creds[64]  = 3.7;
     147  creds[65]  = 5.8;
     148  creds[66]  = 8.0;
     149  creds[67]  = 7.3;
     150  creds[68]  = 7.3;
     151  creds[69]  = 9.1;
     152  creds[70]  = 4.0;
     153  creds[71]  = 8.2;
     154  creds[72]  = 8.7;
     155  creds[73]  = 9.1;
     156  creds[74]  = 8.2;
     157  creds[75]  = 9.0;
     158  creds[76]  = 7.8;
     159  creds[77]  = 7.5;
     160  creds[78]  = 1.3;
     161  creds[79]  = 6.9;
     162  creds[80]  = 8.7;
     163  creds[81]  = 7.6;
     164  creds[82]  = 5.6;
     165  creds[83]  = 10.4;
     166  creds[84]  = 6.1;
     167  creds[85]  = 0.9;
     168  creds[86]  = 7.7;
     169  creds[87]  = 7.4;
     170  creds[88]  = 6.9;
     171  creds[89]  = 7.0;
     172  creds[90]  = 3.3;
     173  creds[91]  = 7.1;
     174  creds[92]  = 5.8;
     175  creds[93]  = 7.2;
     176  creds[94]  = 5.4;
     177  creds[95]  = 7.4;
     178  creds[96]  = 6.6;
     179  creds[97]  = 0.0;
     180  creds[98]  = 6.9;
     181  creds[99]  = 7.3;
    181182  creds[100] = 8.7;
    182183  creds[101] = 6.5;
     
    665666  Double_t cblues[577];
    666667
    667   cblues[1] = 12.0;
    668   cblues[2] = 12.2;
    669   cblues[3] = 12.6;
    670   cblues[4] = 12.7;
    671   cblues[5] = 12.8;
    672   cblues[6] = -1.;
    673   cblues[7] = 10.8;
    674   cblues[8] = 9.0;
    675   cblues[9] = 12.2;
    676   cblues[10] = 12.3;
    677   cblues[11] = 11.7;
    678   cblues[12] = 12.0;
    679   cblues[13] = 12.1;
    680   cblues[14] = 12.0;
    681   cblues[15] = 12.6;
    682   cblues[16] = 12.2;
    683   cblues[17] = 12.6;
    684   cblues[18] = 12.6;
    685   cblues[19] = 11.5;
    686   cblues[20] = 11.1;
    687   cblues[21] = 11.2;
    688   cblues[22] = 12.1;
    689   cblues[23] = 12.8;
    690   cblues[24] = 12.7;
    691   cblues[25] = 12.8;
    692   cblues[26] = 13.0;
    693   cblues[27] = 13.0;
    694   cblues[28] = 12.0;
    695   cblues[29] = 12.4;
    696   cblues[30] = 12.0;
    697   cblues[31] = 12.1;
    698   cblues[32] = 12.0;
    699   cblues[33] = 12.2;
    700   cblues[34] = 12.0;
    701   cblues[35] = 12.5;
    702   cblues[36] = 12.4;
    703   cblues[37] = 10.3;
    704   cblues[38] = 10.8;
    705   cblues[39] = 11.4;
    706   cblues[40] = 11.7;
    707   cblues[41] = 12.1;
    708   cblues[42] = 12.0;
    709   cblues[43] = 12.4;
    710   cblues[44] = 13.0;
    711   cblues[45] = 12.7;
    712   cblues[46] = 12.8;
    713   cblues[47] = 10.5;
    714   cblues[48] = 12.1;
    715   cblues[49] = 12.1;
    716   cblues[50] = 12.4;
    717   cblues[51] = 12.3;
    718   cblues[52] = 12.4;
    719   cblues[53] = 11.7;
    720   cblues[54] = 12.8;
    721   cblues[55] = 12.0;
    722   cblues[56] = 12.5;
    723   cblues[57] = 12.2;
    724   cblues[58] = 12.3;
    725   cblues[59] = 12.3;
    726   cblues[60] = 12.6;
    727   cblues[61] = 11.6;
    728   cblues[62] = 11.9;
    729   cblues[63] = 11.8;
    730   cblues[64] = 10.7;
    731   cblues[65] = 10.9;
    732   cblues[66] = 12.1;
    733   cblues[67] = 12.5;
    734   cblues[68] = 12.4;
    735   cblues[69] = 12.1;
    736   cblues[70] = 12.2;
    737   cblues[71] = 13.1;
    738   cblues[72] = 12.5;
    739   cblues[73] = 12.4;
    740   cblues[74] = 12.6;
    741   cblues[75] = 12.5;
    742   cblues[76] = 12.1;
    743   cblues[77] = 12.5;
    744   cblues[78] = 12.3;
    745   cblues[79] = 12.0;
    746   cblues[80] = 12.4;
    747   cblues[81] = 12.4;
    748   cblues[82] = 12.0;
    749   cblues[83] = 12.3;
    750   cblues[84] = 12.1;
    751   cblues[85] = 11.3;
    752   cblues[86] = 12.0;
    753   cblues[87] = 12.0;
    754   cblues[88] = 12.4;
    755   cblues[89] = 12.3;
    756   cblues[90] = 12.0;
    757   cblues[91] = 11.4;
    758   cblues[92] = 11.7;
    759   cblues[93] = 11.9;
    760   cblues[94] = 11.4;
    761   cblues[95] = 11.1;
    762   cblues[96] = 11.9;
    763   cblues[97] = 9.2;
    764   cblues[98] = 12.4;
    765   cblues[99] = 11.5;
     668  cblues[0]   = -1.;
     669  cblues[1]   = 12.0;
     670  cblues[2]   = 12.2;
     671  cblues[3]   = 12.6;
     672  cblues[4]   = 12.7;
     673  cblues[5]   = 12.8;
     674  cblues[6]   = -1.;
     675  cblues[7]   = 10.8;
     676  cblues[8]   = 9.0;
     677  cblues[9]   = 12.2;
     678  cblues[10]  = 12.3;
     679  cblues[11]  = 11.7;
     680  cblues[12]  = 12.0;
     681  cblues[13]  = 12.1;
     682  cblues[14]  = 12.0;
     683  cblues[15]  = 12.6;
     684  cblues[16]  = 12.2;
     685  cblues[17]  = 12.6;
     686  cblues[18]  = 12.6;
     687  cblues[19]  = 11.5;
     688  cblues[20]  = 11.1;
     689  cblues[21]  = 11.2;
     690  cblues[22]  = 12.1;
     691  cblues[23]  = 12.8;
     692  cblues[24]  = 12.7;
     693  cblues[25]  = 12.8;
     694  cblues[26]  = 13.0;
     695  cblues[27]  = 13.0;
     696  cblues[28]  = 12.0;
     697  cblues[29]  = 12.4;
     698  cblues[30]  = 12.0;
     699  cblues[31]  = 12.1;
     700  cblues[32]  = 12.0;
     701  cblues[33]  = 12.2;
     702  cblues[34]  = 12.0;
     703  cblues[35]  = 12.5;
     704  cblues[36]  = 12.4;
     705  cblues[37]  = 10.3;
     706  cblues[38]  = 10.8;
     707  cblues[39]  = 11.4;
     708  cblues[40]  = 11.7;
     709  cblues[41]  = 12.1;
     710  cblues[42]  = 12.0;
     711  cblues[43]  = 12.4;
     712  cblues[44]  = 13.0;
     713  cblues[45]  = 12.7;
     714  cblues[46]  = 12.8;
     715  cblues[47]  = 10.5;
     716  cblues[48]  = 12.1;
     717  cblues[49]  = 12.1;
     718  cblues[50]  = 12.4;
     719  cblues[51]  = 12.3;
     720  cblues[52]  = 12.4;
     721  cblues[53]  = 11.7;
     722  cblues[54]  = 12.8;
     723  cblues[55]  = 12.0;
     724  cblues[56]  = 12.5;
     725  cblues[57]  = 12.2;
     726  cblues[58]  = 12.3;
     727  cblues[59]  = 12.3;
     728  cblues[60]  = 12.6;
     729  cblues[61]  = 11.6;
     730  cblues[62]  = 11.9;
     731  cblues[63]  = 11.8;
     732  cblues[64]  = 10.7;
     733  cblues[65]  = 10.9;
     734  cblues[66]  = 12.1;
     735  cblues[67]  = 12.5;
     736  cblues[68]  = 12.4;
     737  cblues[69]  = 12.1;
     738  cblues[70]  = 12.2;
     739  cblues[71]  = 13.1;
     740  cblues[72]  = 12.5;
     741  cblues[73]  = 12.4;
     742  cblues[74]  = 12.6;
     743  cblues[75]  = 12.5;
     744  cblues[76]  = 12.1;
     745  cblues[77]  = 12.5;
     746  cblues[78]  = 12.3;
     747  cblues[79]  = 12.0;
     748  cblues[80]  = 12.4;
     749  cblues[81]  = 12.4;
     750  cblues[82]  = 12.0;
     751  cblues[83]  = 12.3;
     752  cblues[84]  = 12.1;
     753  cblues[85]  = 11.3;
     754  cblues[86]  = 12.0;
     755  cblues[87]  = 12.0;
     756  cblues[88]  = 12.4;
     757  cblues[89]  = 12.3;
     758  cblues[90]  = 12.0;
     759  cblues[91]  = 11.4;
     760  cblues[92]  = 11.7;
     761  cblues[93]  = 11.9;
     762  cblues[94]  = 11.4;
     763  cblues[95]  = 11.1;
     764  cblues[96]  = 11.9;
     765  cblues[97]  = 9.2;
     766  cblues[98]  = 12.4;
     767  cblues[99]  = 11.5;
    766768  cblues[100] = 12.3;
    767769  cblues[101] = 11.0;
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc

    r5098 r5137  
    2626// MHCalibrationCam                                               
    2727//
    28 // Base class for camera calibration classes. Incorporates the TObjArray's:
     28// Base class for camera calibration classes. Incorporates the TOrdCollection's:
    2929// - fHiGainArray (for calibrated High Gains per pixel)
    3030// - fLoGainArray (for calibrated Low Gains per pixel)
     
    3333// - fAverageHiGainSectors (for averaged High Gains events per camera sector )
    3434// - fAverageLoGainSectors (for averaged High Gains events per camera sector )
    35 // These TObjArray's are called by their default constructors, thus no objects
     35// These TOrdCollection's are called by their default constructors, thus no objects
    3636// are created, until the derived class does so.
    3737//
     
    6161#include <TText.h>
    6262#include <TPaveText.h>
     63#include <TOrdCollection.h>
     64#include <TROOT.h>
    6365
    6466#include "MLog.h"
     
    117119{
    118120
    119     fHiGainArray = new TObjArray;
     121    fHiGainArray = new TOrdCollection;
    120122    fHiGainArray->SetOwner();
    121    
    122     fLoGainArray = new TObjArray;
     123
     124    fLoGainArray = new TOrdCollection;
    123125    fLoGainArray->SetOwner();
    124126
    125     fAverageHiGainAreas = new TObjArray;
     127    fAverageHiGainAreas = new TOrdCollection;
    126128    fAverageHiGainAreas->SetOwner();
    127129
    128     fAverageLoGainAreas = new TObjArray;
     130    fAverageLoGainAreas = new TOrdCollection;
    129131    fAverageLoGainAreas->SetOwner();
    130132
    131     fAverageHiGainSectors = new TObjArray;
     133    fAverageHiGainSectors = new TOrdCollection;
    132134    fAverageHiGainSectors->SetOwner();
    133135
    134     fAverageLoGainSectors = new TObjArray;
     136    fAverageLoGainSectors = new TOrdCollection;
    135137    fAverageLoGainSectors->SetOwner();
    136138
     
    146148// --------------------------------------------------------------------------
    147149//
    148 // Returns size of fHiGainArray
    149 //
    150 const Int_t MHCalibrationCam::GetSize() const
    151 {
    152   return fHiGainArray->GetSize();
    153 }
    154 
    155 // --------------------------------------------------------------------------
    156 //
    157 // Deletes the TClonesArray of:
     150// Deletes the TOrdCollection of:
    158151// - fHiGainArray, fLoGainArray
    159152// - fAverageHiGainAreas, fAverageLoGainAreas
     
    171164  delete fAverageHiGainSectors;
    172165  delete fAverageLoGainSectors;
    173 }
    174 
    175 // --------------------------------------------------------------------------
     166  /*
     167
     168  Remove ( fHiGainArray );
     169  Remove ( fLoGainArray );
     170
     171  Remove ( fAverageHiGainAreas );
     172  Remove ( fAverageLoGainAreas );
     173
     174  Remove ( fAverageHiGainSectors );
     175  Remove ( fAverageLoGainSectors );
     176  */
     177
     178}
     179
     180void MHCalibrationCam::Remove(TOrdCollection *col)
     181{
     182
     183  if (!col)
     184    return;
     185
     186  TOrdCollectionIter Next(col);
     187 
     188  Int_t count = 0;
     189
     190  while (MHCalibrationPix *obj = (MHCalibrationPix*)Next())
     191    {
     192      *fLog << ++count << " " << obj << flush;
     193      if (obj && obj->IsOnHeap())
     194        {
     195          obj->Draw();
     196          delete obj;
     197        }
     198    }
     199 
     200  delete col;
     201}
     202
     203// --------------------------------------------------------------------------
     204//
     205// Returns size of fHiGainArray
     206//
     207const Int_t MHCalibrationCam::GetSize() const
     208{
     209  return fHiGainArray->GetSize();
     210}
     211
     212// --------------------------------------------------------------------------
     213//
     214// Get i-th High Gain pixel (pixel number)
     215//
     216MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i)
     217{
     218  return *static_cast<MHCalibrationPix*>(fHiGainArray->At(i));
     219}
     220
     221// --------------------------------------------------------------------------
     222//
     223// Get i-th High Gain pixel (pixel number)
     224//
     225const MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i) const
     226{
     227  return *static_cast<MHCalibrationPix*>(fHiGainArray->At(i));
     228}
     229
     230// --------------------------------------------------------------------------
     231//
     232// Get i-th Low Gain pixel (pixel number)
     233//
     234MHCalibrationPix  &MHCalibrationCam::operator()(UInt_t i)
     235{
     236  return *static_cast<MHCalibrationPix*>(fLoGainArray->At(i));
     237}
     238
     239// --------------------------------------------------------------------------
     240//
     241// Get i-th Low Gain pixel (pixel number)
     242//
     243const MHCalibrationPix  &MHCalibrationCam::operator()(UInt_t i) const
     244{
     245  return *static_cast<MHCalibrationPix*>(fLoGainArray->At(i));
     246}
     247
     248// --------------------------------------------------------------------------
     249//
     250// Returns the current size of the TOrdCollection fAverageHiGainAreas
     251// independently if the MHCalibrationPix is filled with values or not.
     252//
     253const Int_t MHCalibrationCam::GetAverageAreas() const
     254{
     255  return fAverageHiGainAreas->GetSize();
     256}
     257
     258// --------------------------------------------------------------------------
     259//
     260// Get i-th High Gain pixel Area (area number)
     261//
     262MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainArea(UInt_t i)
     263{
     264  return *static_cast<MHCalibrationPix*>(fAverageHiGainAreas->At(i));
     265}
     266
     267// --------------------------------------------------------------------------
     268//
     269// Get i-th High Gain pixel Area (area number)
     270//
     271const MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainArea(UInt_t i) const
     272{
     273  return *static_cast<MHCalibrationPix *>(fAverageHiGainAreas->At(i));
     274}
     275
     276// --------------------------------------------------------------------------
     277//
     278// Get i-th Low Gain pixel Area (area number)
     279//
     280MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainArea(UInt_t i)
     281{
     282  return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->At(i));
     283}
     284
     285// --------------------------------------------------------------------------
     286//
     287// Get i-th Low Gain pixel Area (area number)
     288//
     289const MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainArea(UInt_t i) const
     290{
     291  return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->At(i));
     292}
     293
     294// --------------------------------------------------------------------------
     295//
     296// Returns the current size of the TOrdCollection fAverageHiGainSectors
     297// independently if the MHCalibrationPix is filled with values or not.
     298//
     299const Int_t MHCalibrationCam::GetAverageSectors() const
     300{
     301  return fAverageHiGainSectors->GetSize();
     302}
     303
     304// --------------------------------------------------------------------------
     305//
     306// Get i-th High Gain Sector (sector number)
     307//
     308MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainSector(UInt_t i)
     309{
     310  return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->At(i));
     311}
     312
     313// --------------------------------------------------------------------------
     314//
     315// Get i-th High Gain Sector (sector number)
     316//
     317const MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainSector(UInt_t i) const
     318{
     319  return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->At(i));
     320}
     321
     322// --------------------------------------------------------------------------
     323//
     324// Get i-th Low Gain Sector (sector number)
     325//
     326MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainSector(UInt_t i)
     327{
     328  return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->At(i));
     329}
     330
     331// --------------------------------------------------------------------------
     332//
     333// Get i-th Low Gain Sector (sector number)
     334//
     335const MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainSector(UInt_t i) const
     336{
     337  return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->At(i));
     338}
     339
     340// --------------------------------------------------------------------------
     341//
     342// Calls ResetHistTitles()
    176343//
    177344// Calls Reset() for each entry in:
     
    183350{
    184351 
     352  ResetHistTitles();
     353
    185354  if (fHiGainArray)
    186355    { fHiGainArray->ForEach(MHCalibrationPix,Reset)();  }
     356
    187357  if (IsAverageing())
    188358    {
     
    209379// --------------------------------------------------------------------------
    210380//
    211 // Get i-th High Gain pixel (pixel number)
    212 //
    213 MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i)
    214 {
    215   return *static_cast<MHCalibrationPix*>(fHiGainArray->UncheckedAt(i));
    216 }
    217 
    218 // --------------------------------------------------------------------------
    219 //
    220 // Get i-th High Gain pixel (pixel number)
    221 //
    222 const MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i) const
    223 {
    224   return *static_cast<MHCalibrationPix*>(fHiGainArray->UncheckedAt(i));
    225 }
    226 
    227 // --------------------------------------------------------------------------
    228 //
    229 // Get i-th Low Gain pixel (pixel number)
    230 //
    231 MHCalibrationPix  &MHCalibrationCam::operator()(UInt_t i)
    232 {
    233   return *static_cast<MHCalibrationPix*>(fLoGainArray->UncheckedAt(i));
    234 }
    235 
    236 // --------------------------------------------------------------------------
    237 //
    238 // Get i-th Low Gain pixel (pixel number)
    239 //
    240 const MHCalibrationPix  &MHCalibrationCam::operator()(UInt_t i) const
    241 {
    242   return *static_cast<MHCalibrationPix*>(fLoGainArray->UncheckedAt(i));
    243 }
    244 
    245 // --------------------------------------------------------------------------
    246 //
    247 // Returns the current size of the TObjArray fAverageHiGainAreas
    248 // independently if the MHCalibrationPix is filled with values or not.
    249 //
    250 const Int_t MHCalibrationCam::GetAverageAreas() const
    251 {
    252   return fAverageHiGainAreas->GetEntries();
    253 }
    254 
    255 // --------------------------------------------------------------------------
    256 //
    257 // Get i-th High Gain pixel Area (area number)
    258 //
    259 MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainArea(UInt_t i)
    260 {
    261   return *static_cast<MHCalibrationPix*>(fAverageHiGainAreas->UncheckedAt(i));
    262 }
    263 
    264 // --------------------------------------------------------------------------
    265 //
    266 // Get i-th High Gain pixel Area (area number)
    267 //
    268 const MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainArea(UInt_t i) const
    269 {
    270   return *static_cast<MHCalibrationPix *>(fAverageHiGainAreas->UncheckedAt(i));
    271 }
    272 
    273 // --------------------------------------------------------------------------
    274 //
    275 // Get i-th Low Gain pixel Area (area number)
    276 //
    277 MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainArea(UInt_t i)
    278 {
    279   return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->UncheckedAt(i));
    280 }
    281 
    282 // --------------------------------------------------------------------------
    283 //
    284 // Get i-th Low Gain pixel Area (area number)
    285 //
    286 const MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainArea(UInt_t i) const
    287 {
    288   return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->UncheckedAt(i));
    289 }
    290 
    291 // --------------------------------------------------------------------------
    292 //
    293 // Returns the current size of the TObjArray fAverageHiGainSectors
    294 // independently if the MHCalibrationPix is filled with values or not.
    295 //
    296 const Int_t MHCalibrationCam::GetAverageSectors() const
    297 {
    298   return fAverageHiGainSectors->GetEntries();
    299 }
    300 
    301 // --------------------------------------------------------------------------
    302 //
    303 // Get i-th High Gain Sector (sector number)
    304 //
    305 MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainSector(UInt_t i)
    306 {
    307   return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->UncheckedAt(i));
    308 }
    309 
    310 // --------------------------------------------------------------------------
    311 //
    312 // Get i-th High Gain Sector (sector number)
    313 //
    314 const MHCalibrationPix  &MHCalibrationCam::GetAverageHiGainSector(UInt_t i) const
    315 {
    316   return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->UncheckedAt(i));
    317 }
    318 
    319 // --------------------------------------------------------------------------
    320 //
    321 // Get i-th Low Gain Sector (sector number)
    322 //
    323 MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainSector(UInt_t i)
    324 {
    325   return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->UncheckedAt(i));
    326 }
    327 
    328 // --------------------------------------------------------------------------
    329 //
    330 // Get i-th Low Gain Sector (sector number)
    331 //
    332 const MHCalibrationPix  &MHCalibrationCam::GetAverageLoGainSector(UInt_t i) const
    333 {
    334   return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->UncheckedAt(i));
     381// Resets the histogram titles for each entry in:
     382// - fHiGainArray, fLoGainArray
     383// - fAverageHiGainAreas, fAverageLoGainAreas
     384// - fAverageHiGainSectors, fAverageLoGainSectors
     385//
     386void MHCalibrationCam::ResetHistTitles()
     387{
     388 
     389  TH1F *h;
     390
     391  if (fHiGainArray)
     392    for (Int_t i=0;i<fHiGainArray->GetSize(); i++)
     393      {
     394        MHCalibrationPix &pix = (*this)[i];       
     395        h = pix.GetHGausHist();
     396        h->SetName (Form("%s%s%s%4i","H",fHistName.Data(),"HiGainPix",i));
     397        h->SetTitle(Form("%s%s%4i%s",fHistTitle.Data()," High Gain Pixel ",i," Runs: ")); 
     398        h->SetXTitle(fHistXTitle.Data());
     399        h->SetYTitle(fHistYTitle.Data());
     400      }
     401 
     402  if (IsAverageing())
     403    {
     404      if (fAverageHiGainAreas)
     405        for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
     406          {
     407            MHCalibrationPix &pix = GetAverageHiGainArea(j);       
     408            h = pix.GetHGausHist();
     409            h->SetName (Form("%s%s%s%d","H",fHistName.Data(),"HiGainArea",j));
     410            h->SetXTitle(fHistXTitle.Data());
     411            h->SetYTitle(fHistYTitle.Data());
     412            if (fGeom->InheritsFrom("MGeomCamMagic"))
     413              h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
     414                               j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
     415            else
     416              h->SetTitle(Form("%s%s%d%s",fHistTitle.Data(),
     417                               " averaged on event-by-event basis High Gain Area Idx ",j," Runs: "));
     418          }
     419     
     420      if (fAverageHiGainSectors)
     421        for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
     422          {
     423            MHCalibrationPix &pix = GetAverageHiGainSector(j);       
     424            h = pix.GetHGausHist();
     425            h->SetName (Form("%s%s%s%2i","H",fHistName.Data(),"HiGainSector",j));
     426            h->SetTitle(Form("%s%s%2i%s",fHistTitle.Data(),
     427                             " averaged on event-by-event basis High Gain Sector ",j," Runs: "));
     428            h->SetXTitle(fHistXTitle.Data());
     429            h->SetYTitle(fHistYTitle.Data());
     430          }
     431    }
     432 
     433  if (!IsLoGain())
     434    return;
     435 
     436  if (fLoGainArray)
     437    for (Int_t i=0;i<fLoGainArray->GetSize(); i++)
     438      {
     439        MHCalibrationPix &pix = (*this)(i);       
     440        h = pix.GetHGausHist();
     441        h->SetName (Form("%s%s%s%4i","H",fHistName.Data(),"LoGainPix",i));
     442        h->SetTitle(Form("%s%s%4i%s",fHistTitle.Data()," Low Gain Pixel ",i," Runs: ")); 
     443        h->SetXTitle(fHistXTitle.Data());
     444        h->SetYTitle(fHistYTitle.Data());
     445      }
     446 
     447  if (IsAverageing())
     448    {
     449      if (fAverageLoGainAreas)
     450        for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
     451          {
     452            MHCalibrationPix &pix = GetAverageLoGainArea(j);       
     453            h = pix.GetHGausHist();
     454            h->SetName (Form("%s%s%s%d","H",fHistName.Data(),"LoGainArea",j));
     455            h->SetXTitle(fHistXTitle.Data());
     456            h->SetYTitle(fHistYTitle.Data());
     457            if (fGeom->InheritsFrom("MGeomCamMagic"))
     458              h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
     459                               j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
     460            else
     461              h->SetTitle(Form("%s%s%d%s",fHistTitle.Data(),
     462                               " averaged on event-by-event basis Low Gain Area Idx ",j," Runs: "));
     463          }
     464     
     465      if (fAverageLoGainSectors)
     466        for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
     467          {
     468            MHCalibrationPix &pix = GetAverageLoGainSector(j);       
     469            h = pix.GetHGausHist();
     470            h->SetName (Form("%s%s%s%2i","H",fHistName.Data(),"LoGainSector",j));
     471            h->SetTitle(Form("%s%s%2i%s",fHistTitle.Data(),
     472                             " averaged on event-by-event basis Low Gain Sector ",j," Runs: "));
     473            h->SetXTitle(fHistXTitle.Data());
     474            h->SetYTitle(fHistYTitle.Data());
     475          }
     476    }
    335477}
    336478
     
    381523
    382524// --------------------------------------------------------------------------
     525//
     526// Searches MRawEvtHeader to find the correct pulser colour
    383527//
    384528// Gets or creates the pointers to:
     
    487631    return kFALSE;
    488632
     633  ResetHistTitles();
     634
    489635  if (!fRunHeader)
    490636    return kTRUE;
    491637 
    492   for (Int_t i=0; i<fHiGainArray->GetEntries(); i++)
     638  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
    493639    {
    494640      TH1F *h = (*this)[i].GetHGausHist();
     
    497643
    498644  if (IsLoGain())
    499     for (Int_t i=0; i<fLoGainArray->GetEntries(); i++)
     645    for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
    500646      {
    501647        TH1F *h = (*this)(i).GetHGausHist();
     
    538684//
    539685// Initializes the High Gain Arrays:
    540 //
    541 // - Expand fHiGainArrays to npixels
    542 // - Expand fAverageHiGainAreas to nareas
    543 // - Expand fAverageHiGainSectors to nsectors
    544686//
    545687// - For every entry in the expanded arrays:
     
    553695{
    554696
    555   if (fHiGainArray->GetEntries()==0)
     697  if (fHiGainArray->GetSize()==0)
    556698  {
    557       fHiGainArray->Expand(npixels);
    558699      for (Int_t i=0; i<npixels; i++)
    559700      {
    560         (*fHiGainArray)[i] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainPix"),
    561                                                   Form("%s%s",fHistTitle.Data()," High Gain Pixel"));
     701        fHiGainArray->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainPix"),
     702                                                 Form("%s%s",fHistTitle.Data()," High Gain Pixel")),i);
    562703       
    563704        MHCalibrationPix &pix = (*this)[i];         
     
    566707        pix.SetLast (fLast);
    567708       
    568         TH1F *h =  pix.GetHGausHist();
    569        
    570         h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainPix"));
    571         h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Pixel ")); 
    572         h->SetXTitle(fHistXTitle.Data());
    573         h->SetYTitle(fHistYTitle.Data());
    574        
    575709        MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
    576710        InitHists(pix,bad,i);
     
    581715    return;
    582716
    583   if (fAverageHiGainAreas->GetEntries()==0)
     717  if (fAverageHiGainAreas->GetSize()==0)
    584718  {
    585     fAverageHiGainAreas->Expand(nareas);
    586    
    587719    for (Int_t j=0; j<nareas; j++)
    588720      {
    589         (*fAverageHiGainAreas)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainArea"),
    590                                                          Form("%s%s",fHistTitle.Data()," High Gain Area Idx "));
     721        fAverageHiGainAreas->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainArea"),
     722                                                        Form("%s%s",fHistTitle.Data()," High Gain Area Idx ")),j);
    591723       
    592724        MHCalibrationPix &pix = GetAverageHiGainArea(j);
     
    595727        pix.SetFirst(fFirst);
    596728        pix.SetLast (fLast);
    597        
    598         TH1F *h =  pix.GetHGausHist();
    599 
    600         h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainArea"));
    601         h->SetXTitle(fHistXTitle.Data());
    602         h->SetYTitle(fHistYTitle.Data());
    603729
    604730        if (fGeom && fGeom->InheritsFrom("MGeomCamMagic"))
    605731          {
    606             h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
    607                              j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
    608732            pix.InitBins();
    609733            pix.SetEventFrequency(fPulserFrequency);
    610734          }
    611735        else
    612           {
    613             h->SetTitle(Form("%s%s",fHistTitle.Data()," averaged on event-by-event basis High Gain Area Idx "));
    614             InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
    615           }
     736          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
    616737      }
    617738  }
    618739
    619   if (fAverageHiGainSectors->GetEntries()==0)
    620     {
    621       fAverageHiGainSectors->Expand(nsectors);
    622 
     740  if (fAverageHiGainSectors->GetSize()==0)
     741    {
    623742      for (Int_t j=0; j<nsectors; j++)
    624743        {
    625           (*fAverageHiGainSectors)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainSector"),
    626                                                              Form("%s%s",fHistTitle.Data()," High Gain Sector "));
     744          fAverageHiGainSectors->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainSector"),
     745                                                            Form("%s%s",fHistTitle.Data()," High Gain Sector ")),j);
    627746          MHCalibrationPix &pix = GetAverageHiGainSector(j);
    628747
     
    631750          pix.SetLast (fLast);
    632751         
    633           TH1F *h =  pix.GetHGausHist();
    634 
    635           h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainSector"));
    636           h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Sector ")); 
    637           h->SetXTitle(fHistXTitle.Data());
    638           h->SetYTitle(fHistYTitle.Data());
    639 
    640752          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
    641753      }
     
    649761// Initializes the Low Gain Arrays:
    650762//
    651 // - Expand fLoGainArrays to npixels
    652 // - Expand fAverageLoGainAreas to nareas
    653 // - Expand fAverageLoGainSectors to nsectors
    654 //
    655763// - For every entry in the expanded arrays:
    656764//   * Initialize an MHCalibrationPix
     
    666774    return;
    667775
    668   if (fLoGainArray->GetEntries()==0)
     776  if (fLoGainArray->GetSize()==0)
    669777  {
    670       fLoGainArray->Expand(npixels);
    671778      for (Int_t i=0; i<npixels; i++)
    672779      {
    673         (*fLoGainArray)[i] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainPix"),
    674                                                   Form("%s%s",fHistTitle.Data()," Low Gain Pixel"));
     780        fLoGainArray->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainPix"),
     781                                                 Form("%s%s",fHistTitle.Data()," Low Gain Pixel")),i);
    675782
    676783          MHCalibrationPix &pix = (*this)[i];         
     
    679786          pix.SetLast (fLast);
    680787
    681           TH1F *h =  pix.GetHGausHist();
    682          
    683           h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainPix"));
    684           h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Pixel ")); 
    685           h->SetXTitle(fHistXTitle.Data());
    686           h->SetYTitle(fHistYTitle.Data());
    687 
    688788          MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
    689789          InitHists(pix,bad,i);
     
    694794    return;
    695795
    696   if (fAverageLoGainAreas->GetEntries()==0)
     796  if (fAverageLoGainAreas->GetSize()==0)
    697797  {
    698     fAverageLoGainAreas->Expand(nareas);
    699    
    700798    for (Int_t j=0; j<nareas; j++)
    701799      {
    702         (*fAverageLoGainAreas)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainArea"),
    703                                                          Form("%s%s",fHistTitle.Data()," Low Gain Area Idx "));
     800        fAverageLoGainAreas->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainArea"),
     801                                                        Form("%s%s",fHistTitle.Data()," Low Gain Area Idx ")),j);
    704802       
    705803        MHCalibrationPix &pix = GetAverageLoGainArea(j);
     
    709807        pix.SetLast (fLast);
    710808       
    711         TH1F *h =  pix.GetHGausHist();
    712 
    713         h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainArea"));
    714         h->SetXTitle(fHistXTitle.Data());
    715         h->SetYTitle(fHistYTitle.Data());
    716 
    717809        if (fGeom && fGeom->InheritsFrom("MGeomCamMagic"))
    718810          {
    719             h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
    720                              j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
    721811            pix.InitBins();
    722812            pix.SetEventFrequency(fPulserFrequency);
    723813          }
    724814        else
    725           {
    726             h->SetTitle(Form("%s%s",fHistTitle.Data()," averaged on event-by-event basis Low Gain Area Idx "));
    727             InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
    728           }
     815          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
    729816      }
    730817  }
    731818
    732   if (fAverageLoGainSectors->GetEntries()==0)
    733     {
    734       fAverageLoGainSectors->Expand(nsectors);
    735 
     819  if (fAverageLoGainSectors->GetSize()==0)
     820    {
    736821      for (Int_t j=0; j<nsectors; j++)
    737822        {
    738           (*fAverageLoGainSectors)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainSector"),
    739                                                              Form("%s%s",fHistTitle.Data()," Low Gain Sector "));
     823          fAverageLoGainSectors->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainSector"),
     824                                                            Form("%s%s",fHistTitle.Data()," Low Gain Sector ")),j);
    740825          MHCalibrationPix &pix = GetAverageLoGainSector(j);
    741826
     
    744829          pix.SetLast (fLast);
    745830         
    746           TH1F *h =  pix.GetHGausHist();
    747 
    748           h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainSector"));
    749           h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Sector ")); 
    750           h->SetXTitle(fHistXTitle.Data());
    751           h->SetYTitle(fHistYTitle.Data());
    752 
    753831          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
    754832      }
     
    763841// - number of sectors
    764842//
    765 // Return kFALSE, if sizes of the TObjArrays do not match npixels, nareas or nsectors
     843// Return kFALSE, if sizes of the TOrdCollections do not match npixels, nareas or nsectors
    766844//
    767845// Call FillHists()
     
    778856 
    779857  //
    780   // Hi-Gain ObjArrays
     858  // Hi-Gain OrdCollections
    781859  //
    782   if (fHiGainArray->GetEntries() != npixels)
     860  if (fHiGainArray->GetSize() != npixels)
    783861    {
    784862      *fLog << err << "ERROR - Size mismatch in number of pixels... abort." << endl;
     
    788866  if (IsLoGain())
    789867    {
    790       if (fLoGainArray->GetEntries() != npixels)
     868      if (fLoGainArray->GetSize() != npixels)
    791869        {
    792870          *fLog << err << "ERROR - Size mismatch in number of pixels... abort." << endl;
     
    798876    return FillHists(par,w);
    799877
    800   if (fAverageHiGainAreas->GetEntries() != nareas)
     878  if (fAverageHiGainAreas->GetSize() != nareas)
    801879    {
    802880      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
     
    804882    }
    805883 
    806   if (fAverageHiGainSectors->GetEntries() != nsectors)
     884  if (fAverageHiGainSectors->GetSize() != nsectors)
    807885    {
    808886      *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
     
    813891    {
    814892     
    815       if (fAverageLoGainAreas->GetEntries() != nareas)
     893      if (fAverageLoGainAreas->GetSize() != nareas)
    816894        {
    817895          *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
     
    819897        }
    820898     
    821       if (fAverageLoGainSectors->GetEntries() != nsectors)
     899      if (fAverageLoGainSectors->GetSize() != nsectors)
    822900        {
    823901          *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
     
    840918{
    841919
    842   if (fHiGainArray->GetEntries() == 0 && fLoGainArray->GetEntries() == 0)
     920  if (fHiGainArray->GetSize() == 0 && fLoGainArray->GetSize() == 0)
    843921    {
    844922      *fLog << err << GetDescriptor()
     
    847925    }
    848926 
     927  for (Int_t i=0; i<fAverageHiGainAreas->GetSize(); i++)
     928    {
     929      TH1F *h = GetAverageHiGainArea(i).GetHGausHist();
     930      switch (fColor)
     931        {
     932        case MCalibrationCam::kNONE:
     933          break;
     934        case MCalibrationCam::kBLUE:
     935          h->SetTitle( Form("%s%s", h->GetTitle(),"BLUE "));
     936          break;
     937        case MCalibrationCam::kGREEN:
     938          h->SetTitle( Form("%s%s", h->GetTitle(),"GREEN "));
     939          break;
     940        case MCalibrationCam::kUV:
     941          h->SetTitle( Form("%s%s", h->GetTitle(),"UV "));
     942          break;
     943        case MCalibrationCam::kCT1:
     944          h->SetTitle( Form("%s%s", h->GetTitle(),"CT1-Pulser "));
     945          break;
     946        }
     947    }
     948
     949  for (Int_t i=0; i<fAverageLoGainAreas->GetSize(); i++)
     950    {
     951      TH1F *h = GetAverageLoGainArea(i).GetHGausHist();
     952      switch (fColor)
     953        {
     954        case MCalibrationCam::kNONE:
     955          break;
     956        case MCalibrationCam::kBLUE:
     957          h->SetTitle( Form("%s%s", h->GetTitle(),"BLUE "));
     958          break;
     959        case MCalibrationCam::kGREEN:
     960          h->SetTitle( Form("%s%s", h->GetTitle(),"GREEN "));
     961          break;
     962        case MCalibrationCam::kUV:
     963          h->SetTitle( Form("%s%s", h->GetTitle(),"UV "));
     964          break;
     965        case MCalibrationCam::kCT1:
     966          h->SetTitle( Form("%s%s", h->GetTitle(),"CT1-Pulser "));
     967          break;
     968        }
     969    }
     970 
    849971  if (!FinalizeHists())
    850972    return kFALSE;
     973
    851974
    852975  FinalizeBadPixels();
     
    873996
    874997  hist.InitBins();
    875   hist.ChangeHistId(i);
    876998  hist.SetEventFrequency(fPulserFrequency);
    877 
    878   TH1F *h = hist.GetHGausHist();
    879   h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
    880999}
    8811000
     
    9041023     
    9051024      FitHiGainHists(hist,pix,bad,fittyp,osctyp);
    906      
    9071025    }
    9081026
     
    9131031    {
    9141032     
    915       MHCalibrationPix     &hist = GetAverageHiGainArea(j);     
     1033      MHCalibrationPix &hist = GetAverageHiGainArea(j);     
    9161034      MCalibrationPix  &pix  = calcam.GetAverageArea(j);
    9171035      MBadPixelsPix    &bad  = calcam.GetAverageBadArea(j);       
    918      
     1036
    9191037      FitHiGainHists(hist,pix,bad,fittyp,osctyp);
    9201038  }
    9211039 
    922 
    9231040  for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
    9241041    {
    925      
    926       MHCalibrationPix     &hist = GetAverageHiGainSector(j);     
     1042      MHCalibrationPix &hist = GetAverageHiGainSector(j);     
    9271043      MCalibrationPix  &pix  = calcam.GetAverageSector(j);
    9281044      MBadPixelsPix    &bad  = calcam.GetAverageBadSector(j);       
    929      
     1045
    9301046      FitHiGainHists(hist,pix,bad,fittyp,osctyp);
    9311047    }
    932 
    9331048}
    9341049
     
    9761091  }
    9771092 
    978 
    9791093  for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
    9801094    {
     
    10451159                                      MBadPixelsPix::UncalibratedType_t osctyp)
    10461160{
    1047 
    10481161
    10491162  if (hist.IsEmpty() || hist.IsOnlyOverflow() || hist.IsOnlyUnderflow())
     
    10881201  if (IsDebug())
    10891202    {
    1090       *fLog << dbginf << GetDescriptor() << ": ID " << hist.GetPixId()
     1203      *fLog << dbginf << GetDescriptor() << ": ID " << GetName()
    10911204            << " HiGainSaturation: "   << pix.IsHiGainSaturation()
    10921205            << " HiGainMean: "         << hist.GetMean    ()
     
    11701283  if (IsDebug())
    11711284    {
    1172       *fLog << dbginf << GetDescriptor() << "ID: " << hist.GetPixId()
     1285      *fLog << dbginf << GetDescriptor() << "ID: " << hist.GetName()
    11731286            << " HiGainSaturation: "   << pix.IsHiGainSaturation()
    11741287            << " LoGainMean: "         << hist.GetMean    ()
     
    12001313    return;
    12011314
    1202   const Int_t nareas = fAverageHiGainAreas->GetEntries();
     1315  const Int_t nareas = fAverageHiGainAreas->GetSize();
    12031316  if (nareas == 0)
    12041317    return;
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h

    r5098 r5137  
    2424
    2525class TText;
    26 class TObjArray;
     26class TOrdCollection;
    2727
    2828class MHCalibrationPix;
     
    5454  Axis_t  fLast;                         // Upper histogram limit
    5555
    56   TString fHistName;                     // Histogram names
    57   TString fHistTitle;                    // Histogram titles
    58   TString fHistXTitle;                   // Histogram x-axis titles
    59   TString fHistYTitle;                   // Histogram y-axis titles
     56  TString fHistName;                     //! Histogram names
     57  TString fHistTitle;                    //! Histogram titles
     58  TString fHistXTitle;                   //! Histogram x-axis titles
     59  TString fHistYTitle;                   //! Histogram y-axis titles
    6060 
    6161  Float_t fNumHiGainSaturationLimit;     // Rel. amount sat. higain FADC slices until pixel is called saturated
     
    7070  MArrayF fAverageAreaSigmaVar;          // Variance Re-normalized sigmas in average pixels per area
    7171  MArrayI fAverageAreaNum;               // Number of pixels in average pixels per area
    72   MArrayI fAverageSectorNum;             // Number of pixels in average pixels per sector 
    73 
    74   TObjArray *fAverageHiGainAreas;        // Array of calibration pixels, one per pixel area
    75   TObjArray *fAverageHiGainSectors;      // Array of calibration pixels, one per camera sector
    76   TObjArray *fAverageLoGainAreas;        // Array of calibration pixels, one per pixel area
    77   TObjArray *fAverageLoGainSectors;      // Array of calibration pixels, one per camera sector
     72  MArrayI fAverageSectorNum;             // Number of pixels in average pixels per sector
     73
     74  TOrdCollection *fAverageHiGainAreas;   // Array of calibration pixels, one per pixel area
     75  TOrdCollection *fAverageHiGainSectors; // Array of calibration pixels, one per camera sector
     76  TOrdCollection *fAverageLoGainAreas;   // Array of calibration pixels, one per pixel area
     77  TOrdCollection *fAverageLoGainSectors; // Array of calibration pixels, one per camera sector
    7878
    7979  MCalibrationCam::PulserColor_t fColor; // Colour of the pulsed LEDs
     
    8686  MRawRunHeader    *fRunHeader;          //! Run Header
    8787 
    88   TObjArray *fHiGainArray;               // Array of calibration pixels, one per pixel
    89   TObjArray *fLoGainArray;               // Array of calibration pixels, one per pixel
     88  TOrdCollection *fHiGainArray;          // Array of calibration pixels, one per pixel
     89  TOrdCollection *fLoGainArray;          // Array of calibration pixels, one per pixel
    9090
    9191  Int_t      fPulserFrequency;           // Light pulser frequency
     
    108108  virtual void   InitLoGainArrays( const Int_t npix, const Int_t nareas, const Int_t nsectors );
    109109
     110  virtual void   ResetHistTitles();
     111 
    110112  void DrawAverageSigma( Bool_t sat, Bool_t inner,
    111113                         Float_t sigma, Float_t sigmaerr,
     
    139141  Bool_t IsOscillations() const  { return TESTBIT(fFlags,kOscillations); }
    140142  Bool_t IsSizeCheck   () const  { return TESTBIT(fFlags,kSizeCheck);    }
     143 
     144  void   Remove(TOrdCollection *col);
    141145 
    142146  Int_t ReadEnv        ( const TEnv &env, TString prefix, Bool_t print);
     
    214218
    215219#endif
    216 
    217 
    218 
    219 
    220 
    221 
    222 
    223 
    224 
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.cc

    r5098 r5137  
    3535#include <TCanvas.h>
    3636#include <TPad.h>
     37#include <TOrdCollection.h>
    3738
    3839#include "MLog.h"
     
    5960const Axis_t    MHCalibrationChargeBlindCam::fgSPheCut  =  20.;
    6061const TString   MHCalibrationChargeBlindCam::gsHistName   = "ChargeBlind";
    61 const TString   MHCalibrationChargeBlindCam::gsHistTitle  = "Signals Blind ";
     62const TString   MHCalibrationChargeBlindCam::gsHistTitle  = "Signals Blind";
    6263const TString   MHCalibrationChargeBlindCam::gsHistXTitle = "Signal [FADC counts]";
    6364const TString   MHCalibrationChargeBlindCam::gsHistYTitle = "Nr. events";
     
    184185  const Int_t integ        = signal->IsExtractionType( MExtractBlindPixel::kIntegral );
    185186 
    186   TH1F *h;
    187 
    188   if (fHiGainArray->GetEntries()==0)
     187  if (fHiGainArray->GetSize()==0)
    189188  {
    190       fHiGainArray->Expand(nblindpixels);
    191189      for (Int_t i=0; i<nblindpixels; i++)
    192190      {
    193         (*fHiGainArray)[i] = new MHCalibrationChargeBlindPix(Form("%s%s",fHistName.Data(),"Pix"),
    194                                                   Form("%s%s",fHistTitle.Data()," Pixel "));
     191        fHiGainArray->AddAt(new MHCalibrationChargeBlindPix(Form("%s%s%d",fHistName.Data(),"Pix",i),
     192                                                  Form("%s%s%d",fHistTitle.Data()," Pixel ",i)),i);
    195193
    196194        MHCalibrationChargeBlindPix &pix = (MHCalibrationChargeBlindPix&)(*this)[i];
     
    202200        pix.SetFitFunc      ( integ ? MHCalibrationChargeBlindPix::kEPoisson5 : fFitFunc );
    203201
    204         h = pix.GetHGausHist();
    205 
    206         h->SetName (Form("%s%s%s","H",fHistName.Data(),"Pix"));
    207         h->SetTitle(Form("%s%s",fHistTitle.Data()," Pixel ")); 
    208         h->SetXTitle(fHistXTitle.Data());
    209         h->SetYTitle(fHistYTitle.Data());
    210 
    211         pix.ChangeHistId(i);
    212202        pix.InitBins();
    213203
    214         h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
    215204      }
    216205  }
    217206  return kTRUE;
     207}
     208
     209// --------------------------------------------------------------------------
     210//
     211// Resets the histogram titles for each entry in:
     212// - fHiGainArray
     213//
     214void MHCalibrationChargeBlindCam::ResetHistTitles()
     215{
     216 
     217  TH1F *h;
     218
     219  if (fHiGainArray)
     220    for (Int_t i=0;i<fHiGainArray->GetSize(); i++)
     221      {
     222        MHCalibrationPix &pix = (*this)[i];       
     223        h = pix.GetHGausHist();
     224        h->SetName (Form("%s%s%s%d","H",fHistName.Data(),"Pix",i));
     225        h->SetTitle(Form("%s%s%d%s",fHistTitle.Data()," Pixel ",i," Runs: ")); 
     226        h->SetXTitle(fHistXTitle.Data());
     227        h->SetYTitle(fHistYTitle.Data());
     228      }
    218229}
    219230
     
    327338  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
    328339    {
    329      
    330340      MHCalibrationChargeBlindPix &hist = (MHCalibrationChargeBlindPix&)(*this)[i];
    331341     
    332342      TH1F *h = hist.GetHGausHist();
    333343
     344      switch (fColor)
     345        {
     346        case MCalibrationCam::kNONE:
     347          break;
     348        case MCalibrationCam::kBLUE:
     349          h->SetTitle( Form("%s%s", h->GetTitle(),"BLUE "));
     350          break;
     351        case MCalibrationCam::kGREEN:
     352          h->SetTitle( Form("%s%s", h->GetTitle(),"GREEN "));
     353          break;
     354        case MCalibrationCam::kUV:
     355          h->SetTitle( Form("%s%s", h->GetTitle(),"UV "));
     356          break;
     357        case MCalibrationCam::kCT1:
     358          h->SetTitle( Form("%s%s", h->GetTitle(),"CT1-Pulser "));
     359          break;
     360        }
     361     
    334362      Stat_t overflow = h->GetBinContent(h->GetNbinsX()+1);
    335363      if (overflow > 0.1)
     
    373401  if (hist.IsEmpty())
    374402  {
    375     *fLog << err << GetDescriptor() << " ID: " << hist.GetPixId()
     403    *fLog << err << GetDescriptor() << " ID: " << hist.GetName()
    376404          << " My histogram has not been filled !! " << endl;
    377405      return;
     
    405433}
    406434
     435// --------------------------------------------------------------------------
     436//
     437// This Clone-function has to be different from the MHCalibrationCam
     438// Clone function since it does not store and display the averaged values
     439// (in fAverageAreas), but the blind pixels stored in fHiGainArray.
     440//
     441// Creates new MHCalibrationChargeBlindCam and
     442// Clones MHCalibrationChargeBlindPix's individually
     443//
     444#if 0
     445TObject *MHCalibrationChargeBlindCam::Clone(const char *name) const
     446{
     447
     448  MHCalibrationChargeBlindCam *cam = new MHCalibrationChargeBlindCam();
     449
     450  //
     451  // Copy the data members
     452  //
     453  cam->fRunNumbers             = fRunNumbers;
     454  cam->fPulserFrequency        = fPulserFrequency;
     455  cam->fFlags                  = fFlags;
     456  cam->fNbins                  = fNbins;
     457  cam->fFirst                  = fFirst;
     458  cam->fLast                   = fLast;
     459  cam->fFitFunc                = fFitFunc;
     460
     461  const Int_t nhi = fHiGainArray->GetSize();
     462 
     463  for (int i=0; i<nhi; i++)
     464    cam->fHiGainArray->AddAt((*this)[i].Clone(),i);
     465
     466  return cam;
     467}
     468#endif
    407469// -----------------------------------------------------------------------------
    408470//
     
    416478{
    417479
    418   const Int_t size = fHiGainArray->GetEntries();
     480  const Int_t size = fHiGainArray->GetSize();
    419481
    420482  if (size == 0)
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.h

    r5098 r5137  
     1
    12#ifndef MARS_MHCalibrationChargeBlindCam
    23#define MARS_MHCalibrationChargeBlindCam
     
    3940  Bool_t FinalizeHists();
    4041
     42  void   ResetHistTitles();
    4143  void   FitBlindPixel( MHCalibrationChargeBlindPix &hist, MCalibrationBlindPix &pix);
    4244
     
    4648
    4749  MHCalibrationChargeBlindCam(const char *name=NULL, const char *title=NULL);
    48 
     50  ~MHCalibrationChargeBlindCam() {}
     51 
    4952  // Draw
    5053  void  Draw(Option_t *opt="");
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.cc

    r5098 r5137  
    146146{
    147147
     148  //
     149  // The next two lines are important for the case that
     150  // the class has been stored to a file and is read again.
     151  // In this case, the next two lines prevent a segm. violation
     152  // in the destructor
     153  //
     154  gROOT->GetListOfFunctions()->Remove(fSinglePheFit);
     155
    148156  if (fSinglePheFit)
    149157      delete fSinglePheFit;
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc

    r5098 r5137  
    2929// MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
    3030//
    31 // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and
     31// - Pixel, stored in the TOrdCollection's MHCalibrationCam::fHiGainArray and
    3232//   MHCalibrationCam::fLoGainArray
    3333//
    3434// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
    35 //   stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
     35//   stored in the TOrdCollection's MHCalibrationCam::fAverageHiGainAreas and
    3636//   MHCalibrationCam::fAverageLoGainAreas
    3737//
    3838// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
    39 //   stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and
     39//   stored in the TOrdCollection's MHCalibrationCam::fAverageHiGainSectors and
    4040//   MHCalibrationCam::fAverageLoGainSectors
    4141//
     
    141141#include "MArrayD.h"
    142142
     143#include <TOrdCollection.h>
    143144#include <TPad.h>
    144145#include <TVirtualPad.h>
     
    156157const Int_t   MHCalibrationChargeCam::fgChargeHiGainNbins =  550;
    157158const Axis_t  MHCalibrationChargeCam::fgChargeHiGainFirst = -100.5;
    158 const Axis_t  MHCalibrationChargeCam::fgChargeHiGainLast  = 999.5;
    159 const Int_t   MHCalibrationChargeCam::fgChargeLoGainNbins =  325;
     159const Axis_t  MHCalibrationChargeCam::fgChargeHiGainLast  =  999.5;
     160const Int_t   MHCalibrationChargeCam::fgChargeLoGainNbins =  525;
    160161const Axis_t  MHCalibrationChargeCam::fgChargeLoGainFirst = -150.5;
    161 const Axis_t  MHCalibrationChargeCam::fgChargeLoGainLast  =  499.5;
     162const Axis_t  MHCalibrationChargeCam::fgChargeLoGainLast  =  899.5;
    162163const TString MHCalibrationChargeCam::gsHistName          = "Charge";
    163164const TString MHCalibrationChargeCam::gsHistTitle         = "Signals";
     
    241242// --------------------------------------------------------------------------
    242243//
     244// Creates new MHCalibrationChargeCam only with the averaged areas:
     245// the rest has to be retrieved directly, e.g. via:
     246//     MHCalibrationChargeCam *cam = MParList::FindObject("MHCalibrationChargeCam");
     247//  -  cam->GetAverageSector(5).DrawClone();
     248//  -  (*cam)[100].DrawClone()
     249//
     250TObject *MHCalibrationChargeCam::Clone(const char *) const
     251{
     252
     253  MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
     254
     255  //
     256  // Copy the data members
     257  //
     258  cam->fColor                  = fColor;
     259  cam->fRunNumbers             = fRunNumbers;
     260  cam->fPulserFrequency        = fPulserFrequency;
     261  cam->fFlags                  = fFlags;
     262  cam->fNbins                  = fNbins;
     263  cam->fFirst                  = fFirst;
     264  cam->fLast                   = fLast;
     265  cam->fLoGainNbins            = fLoGainNbins;
     266  cam->fLoGainFirst            = fLoGainFirst;
     267  cam->fLoGainLast             = fLoGainLast;
     268
     269  //
     270  // Copy the MArrays
     271  //
     272  cam->fAverageAreaRelSigma    = fAverageAreaRelSigma;
     273  cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
     274  cam->fAverageAreaSat         = fAverageAreaSat;
     275  cam->fAverageAreaSigma       = fAverageAreaSigma;
     276  cam->fAverageAreaSigmaVar    = fAverageAreaSigmaVar;
     277  cam->fAverageAreaNum         = fAverageAreaNum;
     278  cam->fAverageSectorNum       = fAverageSectorNum;
     279
     280  if (!IsAverageing())
     281    return cam;
     282
     283  const Int_t navhi   =  fAverageHiGainAreas->GetSize();
     284
     285  for (int i=0; i<navhi; i++)
     286    cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
     287
     288  if (IsLoGain())
     289    {
     290     
     291      const Int_t navlo = fAverageLoGainAreas->GetSize();
     292      for (int i=0; i<navlo; i++)
     293        cam->fAverageLoGainAreas->AddAt(GetAverageLoGainArea(i).Clone(),i);
     294
     295    }
     296
     297  return cam;
     298}
     299
     300// --------------------------------------------------------------------------
     301//
    243302// Gets the pointers to:
    244303// - MRawEvtData
     
    323382  const Float_t numlogain = signal->GetNumUsedLoGainFADCSlices(); 
    324383
    325 
    326384  if (fCam)
    327385    {
     
    350408  const Int_t nareas   = fGeom->GetNumAreas();
    351409
     410  //
     411  // In case of the intense blue, double the range
     412  //
     413  if (fGeom->InheritsFrom("MGeomCamMagic"))
     414    if ( fColor == MCalibrationCam::kBLUE)
     415      SetLoGainLast(2.*fLoGainLast - fLoGainFirst);
     416 
    352417  InitHiGainArrays(npixels,nareas,nsectors);
    353418  InitLoGainArrays(npixels,nareas,nsectors);
     
    377442// Initializes the High Gain Arrays:
    378443//
    379 // - Expand fHiGainArrays to npixels
    380 // - Expand fAverageHiGainAreas to nareas
    381 // - Expand fAverageHiGainSectors to nsectors
    382 //
    383444// - For every entry in the expanded arrays:
    384445//   * Initialize an MHCalibrationChargePix
     
    399460  const Int_t higainsamples = fRunHeader->GetNumSamplesHiGain();
    400461
    401   if (fHiGainArray->GetEntries()==0)
     462  if (fHiGainArray->GetSize()==0)
    402463  {
    403       fHiGainArray->Expand(npixels);
    404464      for (Int_t i=0; i<npixels; i++)
    405465      {
    406         (*fHiGainArray)[i] = new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"HiGainPix"),
    407                                                   Form("%s%s",fHistTitle.Data()," High Gain Pixel"));
     466        fHiGainArray->AddAt(new MHCalibrationChargePix(Form("%s%s%4i",fHistName.Data(),"HiGainPix",i),
     467                                                       Form("%s%s%4i",fHistTitle.Data()," High Gain Pixel",i)),i);
    408468
    409469        MHCalibrationChargePix &pix = (MHCalibrationChargePix&)(*this)[i];
     
    417477        pix.SetAbsTimeLast(higainsamples-0.5);
    418478
    419         h = pix.GetHGausHist();
    420 
    421         h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainPix"));
    422         h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Pixel ")); 
    423         h->SetXTitle(fHistXTitle.Data());
    424         h->SetYTitle(fHistYTitle.Data());
    425        
    426479        h = pix.GetHAbsTime();
    427480
    428         h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainPix"));
    429         h->SetTitle(Form("%s%s",fAbsHistTitle.Data()," High Gain Pixel "));
     481        h->SetName (Form("%s%s%s%4i","H",fAbsHistName.Data(),"HiGainPix",i));
     482        h->SetTitle(Form("%s%s%4i",fAbsHistTitle.Data()," High Gain Pixel ",i));
    430483        h->SetXTitle(fAbsHistXTitle.Data());
    431484        h->SetYTitle(fAbsHistYTitle.Data());
     
    437490
    438491
    439   if (fAverageHiGainAreas->GetEntries()==0)
     492  if (fAverageHiGainAreas->GetSize()==0)
    440493  {
    441     fAverageHiGainAreas->Expand(nareas);
    442    
    443494    for (Int_t j=0; j<nareas; j++)
    444495      {
    445         (*fAverageHiGainAreas)[j] =
    446           new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"HiGainArea"),
    447                                      Form("%s%s",fHistTitle.Data()," High Gain Area Idx "));
     496        fAverageHiGainAreas->AddAt(new MHCalibrationChargePix(Form("%s%s%d",fHistName.Data(),"HiGainArea",j),
     497                                                  Form("%s%s%d",fHistTitle.Data()," High Gain Area Idx ",j)),j);
    448498       
    449499        MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
     
    457507        pix.SetAbsTimeLast(higainsamples-0.5);
    458508
    459         h =  pix.GetHGausHist();
    460        
    461         h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainArea"));
    462         h->SetXTitle(fHistXTitle.Data());
    463         h->SetYTitle(fHistYTitle.Data());
    464        
    465         if (fGeom->InheritsFrom("MGeomCamMagic"))
    466           {
    467             h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
    468                              j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
    469             pix.InitBins();
    470             pix.SetEventFrequency(fPulserFrequency);
    471           }
    472         else
    473           {
    474             h->SetTitle(Form("%s%s",fHistTitle.Data(),
    475                              " averaged on event-by-event basis High Gain Area Idx "));
    476             InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
    477           }
     509        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
    478510
    479511        h =  pix.GetHAbsTime();
    480512       
    481         h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainArea"));
    482         h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
    483                          " averaged on event-by-event basis High Gain Area Idx "));
     513        h->SetName (Form("%s%s%s%d","H",fAbsHistName.Data(),"HiGainArea",j));
     514        h->SetTitle(Form("%s%s%d",fAbsHistTitle.Data(),
     515                         " averaged on event-by-event basis High Gain Area Idx ",j));
    484516        h->SetXTitle(fAbsHistXTitle.Data());
    485517        h->SetYTitle(fAbsHistYTitle.Data());
     
    487519  }
    488520 
    489   if (fAverageHiGainSectors->GetEntries()==0)
     521  if (fAverageHiGainSectors->GetSize()==0)
    490522  {
    491       fAverageHiGainSectors->Expand(nsectors);
    492 
    493523      for (Int_t j=0; j<nsectors; j++)
    494       {
    495           (*fAverageHiGainSectors)[j] =
    496             new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"HiGainSector"),
    497                                        Form("%s%s",fHistTitle.Data()," High Gain Sector "));
     524        {
     525          fAverageHiGainSectors->AddAt(new MHCalibrationChargePix(Form("%s%s%2i",fHistName.Data(),"HiGainSector",j),
     526                                                      Form("%s%s%2i",fHistTitle.Data()," High Gain Sector ",j)),j);
    498527
    499528          MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
     
    507536          pix.SetAbsTimeLast(higainsamples-0.5);
    508537         
    509           h =  pix.GetHGausHist();
    510          
    511           h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainSector"));
    512           h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Sector ")); 
    513           h->SetXTitle(fHistXTitle.Data());
    514           h->SetYTitle(fHistYTitle.Data());
    515 
    516538          h =  pix.GetHAbsTime();
    517539         
    518           h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainSector"));
    519           h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
    520                            " averaged on event-by-event basis High Gain Area Sector "));
     540          h->SetName (Form("%s%s%s%2i","H",fAbsHistName.Data(),"HiGainSector",j));
     541          h->SetTitle(Form("%s%s%2i",fAbsHistTitle.Data(),
     542                           " averaged on event-by-event basis High Gain Area Sector ",j));
    521543          h->SetXTitle(fAbsHistXTitle.Data());
    522544          h->SetYTitle(fAbsHistYTitle.Data());
     
    536558// Initializes the Low Gain Arrays:
    537559//
    538 // - Expand fLoGainArrays to npixels
    539 // - Expand fAverageLoGainAreas to nareas
    540 // - Expand fAverageLoGainSectors to nsectors
    541 //
    542560// - For every entry in the expanded arrays:
    543561//   * Initialize an MHCalibrationChargePix
     
    560578  TH1F *h;
    561579
    562   if (fLoGainArray->GetEntries()==0 )
    563     {
    564       fLoGainArray->Expand(npixels);
    565      
     580  if (fLoGainArray->GetSize()==0 )
     581    {
    566582      for (Int_t i=0; i<npixels; i++)
    567583        {
    568           (*fLoGainArray)[i] =
    569             new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"LoGainPix"),
    570                                        Form("%s%s",fHistTitle.Data()," Low Gain Pixel"));
     584          fLoGainArray->AddAt(new MHCalibrationChargePix(Form("%s%s%4i",fHistName.Data(),"LoGainPix",i),
     585                                       Form("%s%s%4i",fHistTitle.Data()," Low Gain Pixel",i)),i);
    571586
    572587          MHCalibrationChargePix &pix = (MHCalibrationChargePix&)(*this)(i);
     
    580595          pix.SetAbsTimeLast(logainsamples-0.5);
    581596         
    582           h =  pix.GetHGausHist();
    583          
    584           h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainPix"));
    585           h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Pixel ")); 
    586           h->SetXTitle(fHistXTitle.Data());
    587           h->SetYTitle(fHistYTitle.Data());
    588          
    589597          h = pix.GetHAbsTime();
    590598         
    591           h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainPix"));
    592           h->SetTitle(Form("%s%s",fAbsHistTitle.Data()," High Gain Pixel "));
     599          h->SetName (Form("%s%s%s%4i","H",fAbsHistName.Data(),"HiGainPix",i));
     600          h->SetTitle(Form("%s%s%4i",fAbsHistTitle.Data()," High Gain Pixel ",i));
    593601          h->SetXTitle(fAbsHistXTitle.Data());
    594602          h->SetYTitle(fAbsHistYTitle.Data());
     
    599607  }
    600608
    601   if (fAverageLoGainAreas->GetEntries()==0)
    602     {
    603       fAverageLoGainAreas->Expand(nareas);
    604      
     609  if (fAverageLoGainAreas->GetSize()==0)
     610    {
    605611      for (Int_t j=0; j<nareas; j++)
    606612        {
    607           (*fAverageLoGainAreas)[j] =
    608             new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"LoGainArea"),
    609                                        Form("%s%s",fHistTitle.Data()," Low Gain Area Idx "));
    610        
    611         MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
    612 
    613         pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
    614         pix.SetFirst(fLoGainFirst);
    615         pix.SetLast (fLoGainLast);
    616 
    617         pix.SetAbsTimeNbins(logainsamples);
    618         pix.SetAbsTimeFirst(-0.5);
    619         pix.SetAbsTimeLast(logainsamples-0.5);
    620 
    621         h =  pix.GetHGausHist();
    622        
    623         h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainArea"));
    624         h->SetXTitle(fHistXTitle.Data());
    625         h->SetYTitle(fHistYTitle.Data());
    626 
    627 
    628         if (fGeom->InheritsFrom("MGeomCamMagic"))
    629           {
    630             h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
    631                              j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
    632             pix.InitBins();
    633             pix.SetEventFrequency(fPulserFrequency);
    634           }
    635         else
    636           {
    637             h->SetTitle(Form("%s%s",fHistTitle.Data()," averaged on event-by-event basis Low Gain Area Idx "));
    638             InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
    639           }
    640 
    641         h =  pix.GetHAbsTime();
    642        
    643         h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"LoGainArea"));
    644         h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
    645                          " averaged on event-by-event basis Low Gain Area Idx "));
    646         h->SetXTitle(fAbsHistXTitle.Data());
    647         h->SetYTitle(fAbsHistYTitle.Data());
    648 
    649         }
    650     }
    651  
    652 
    653   if (fAverageLoGainSectors->GetEntries()==0 && IsLoGain())
    654   {
    655       fAverageLoGainSectors->Expand(nsectors);
    656  
    657       for (Int_t j=0; j<nsectors; j++)
    658       {
    659           (*fAverageLoGainSectors)[j] =
    660             new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"LoGainSector"),
    661                                        Form("%s%s",fHistTitle.Data()," Low Gain Sector "));
    662 
    663           MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
    664 
     613          fAverageLoGainAreas->AddAt(new MHCalibrationChargePix(Form("%s%s%d",fHistName.Data(),"LoGainArea",j),
     614                                       Form("%s%s%d",fHistTitle.Data()," Low Gain Area Idx ",j)),j);
     615       
     616          MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
     617         
    665618          pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
    666619          pix.SetFirst(fLoGainFirst);
    667620          pix.SetLast (fLoGainLast);
    668 
     621         
    669622          pix.SetAbsTimeNbins(logainsamples);
    670623          pix.SetAbsTimeFirst(-0.5);
    671624          pix.SetAbsTimeLast(logainsamples-0.5);
    672625         
    673           h =  pix.GetHGausHist();
    674          
    675           h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainSector"));
    676           h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Sector ")); 
    677           h->SetXTitle(fHistXTitle.Data());
    678           h->SetYTitle(fHistYTitle.Data());
    679 
    680626          h =  pix.GetHAbsTime();
    681627         
    682           h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"LoGainSector"));
    683           h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
    684                            " averaged on event-by-event basis Low Gain Area Sector "));
     628          h->SetName (Form("%s%s%s%2i","H",fAbsHistName.Data(),"LoGainArea",j));
     629          h->SetTitle(Form("%s%s%2i",fAbsHistTitle.Data(),
     630                           " averaged on event-by-event basis Low Gain Area Idx ",j));
    685631          h->SetXTitle(fAbsHistXTitle.Data());
    686632          h->SetYTitle(fAbsHistYTitle.Data());
    687633         
    688           //
    689           // Adapt the range for the case, the intense blue is used:
    690           // FIXME: this is a nasty workaround, but for the moment necessary
    691           // in order to avoid default memory space.
    692           //
    693           if (fGeom->InheritsFrom("MGeomCamMagic"))
    694             {
    695               if ( fColor == MCalibrationCam::kBLUE)
    696                 {
    697                   pix.SetFirst(-10.5);
    698                   pix.SetLast(999.5);
    699                   pix.SetNbins(3030);
    700                 }
    701             }
    702          
    703           InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
     634          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
     635        }
     636    }
     637 
     638
     639  if (fAverageLoGainSectors->GetSize()==0 && IsLoGain())
     640  {
     641    for (Int_t j=0; j<nsectors; j++)
     642      {
     643        fAverageLoGainSectors->AddAt(new MHCalibrationChargePix(Form("%s%s%2i",fHistName.Data(),"LoGainSector",j),
     644                                                        Form("%s%s%2i",fHistTitle.Data()," Low Gain Sector ",j)),j);
     645       
     646        MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
     647       
     648        pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
     649        pix.SetFirst(fLoGainFirst);
     650        pix.SetLast (fLoGainLast);
     651       
     652        pix.SetAbsTimeNbins(logainsamples);
     653        pix.SetAbsTimeFirst(-0.5);
     654        pix.SetAbsTimeLast(logainsamples-0.5);
     655       
     656        h =  pix.GetHAbsTime();
     657       
     658        h->SetName (Form("%s%s%s%2i","H",fAbsHistName.Data(),"LoGainSector",j));
     659        h->SetTitle(Form("%s%s%2i",fAbsHistTitle.Data(),
     660                           " averaged on event-by-event basis Low Gain Area Sector ",j));
     661        h->SetXTitle(fAbsHistXTitle.Data());
     662        h->SetYTitle(fAbsHistYTitle.Data());
     663
     664        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
    704665      }
    705666  }
    706667}
    707668
    708  
     669
    709670// --------------------------------------------------------------------------
    710671//
     
    717678// - number of sectors
    718679//
    719 // For all TObjArray's (including the averaged ones), the following steps are performed:
     680// For all TOrdCollection's (including the averaged ones), the following steps are performed:
    720681//
    721682// 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
     
    852813
    853814      MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
     815     
    854816
    855817      if (IsOscillations())
     
    910872// --------------------------------------------------------------------------
    911873//
    912 // For all TObjArray's (including the averaged ones), the following steps are performed:
     874// For all TOrdCollection's (including the averaged ones), the following steps are performed:
    913875//
    914876// 1) Returns if the pixel is excluded.
     
    934896  MCalibrationCam *chargecam = fIntensCam ? fIntensCam->GetCam() : fCam;
    935897  MBadPixelsCam   *badcam    = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
    936      
     898
     899
    937900  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
    938901    {
     
    1022985          FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
    1023986      }
    1024  
     987
    1025988  for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
    1026989    {
     
    10401003      FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
    10411004   }
    1042  
     1005
    10431006  if (IsLoGain())
    10441007    for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
     
    11471110      *fLog << warn << GetDescriptor()
    11481111            << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," smaller than ",fTimeLowerLimit,
    1149                     " FADC slices from lower edge in pixel ",hist.GetPixId()) << endl;
     1112                    " FADC slices from lower edge in pixel ",hist.GetName()) << endl;
    11501113      bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
    11511114    }
     
    11551118      *fLog << warn << GetDescriptor()
    11561119            << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," greater than ",fTimeUpperLimit,
    1157                     " FADC slices from upper edge in pixel ",hist.GetPixId()) << endl;
     1120                    " FADC slices from upper edge in pixel ",hist.GetName()) << endl;
    11581121      bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
    11591122    }
     
    12301193{
    12311194
    1232   const Int_t nareas = fAverageHiGainAreas->GetEntries();
     1195  const Int_t nareas = fAverageHiGainAreas->GetSize();
    12331196  if (nareas == 0)
    12341197    return;
     
    12621225       // Ask for Hi-Gain saturation
    12631226       //
     1227       *fLog << err << hipix.GetSaturated() << "   " << fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries() <<  endl;
    12641228       if (hipix.GetSaturated() > fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries() && IsLoGain())
    12651229         {
     
    12691233       else
    12701234         DrawDataCheckPixel(hipix,i ? gkHiGainOuterRefLines : gkHiGainInnerRefLines);
     1235
    12711236    }     
    12721237}
     
    12961261                        pix.GetFirst() > 0. ? pix.GetFirst() : 0.,
    12971262                        pix.GetLast() > pix.GetFirst()
    1298                         ? ( pix.GetLast() > 450. ? 450. : pix.GetLast() )
     1263                        ? ( pix.GetLast() > 450.
     1264                            ? ( fColor == MCalibrationCam::kBLUE ? 800. : 450. )
     1265                            : pix.GetLast() )
    12991266                        : pix.GetFirst()*2.);
    13001267
     
    13831350
    13841351  pix.DrawEvents("same");
     1352
     1353  //  newpad->cd(3);
     1354  //  pix.DrawPowerSpectrum(*newpad,4);
     1355
    13851356  return;
    13861357 
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h

    r5098 r5137  
    105105  ~MHCalibrationChargeCam() {}
    106106 
     107  // Clone
     108  TObject *Clone(const char *name="") const;
     109
    107110  void SetLoGainNbins       ( const Int_t  i )       { fLoGainNbins   = i; }
    108111  void SetLoGainFirst       ( const Axis_t f )       { fLoGainFirst   = f; }
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePix.cc

    r5098 r5137  
    101101  MHGausEvents::Reset();
    102102  fHAbsTime.Reset();
    103 }
    104 
    105 // --------------------------------------------------------------------------
    106 //
    107 // Calls MHCalibrationPix::ChangeHistId()
    108 //
    109 // Add id to names and titles of:
    110 // - fHAbsTime
    111 //
    112 void MHCalibrationChargePix::ChangeHistId(Int_t id)
    113 {
    114 
    115   MHCalibrationPix::ChangeHistId(id);
    116 
    117   fHAbsTime.SetName (Form("%s%d", fHAbsTime.GetName(),  id));
    118   fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
    119 
    120103}
    121104
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePix.h

    r5098 r5137  
    4444  virtual void Draw(Option_t *opt="");
    4545
    46   // Miscelleaneous
    47   void ChangeHistId(Int_t id);
    48  
    4946  ClassDef(MHCalibrationChargePix, 1)     // Base Histogram class for Charge Pixel Calibration
    5047};
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationPix.cc

    r5098 r5137  
    6262//
    6363MHCalibrationPix::MHCalibrationPix(const char *name, const char *title)
    64     : fPixId(-1)
    6564{
    6665
     
    108107    {
    109108      *fLog << warn << GetDescriptor()
    110             << ": Cannot bypass fit. Number of entries smaller or equal 0 in pixel: " << fPixId << endl;
     109            << ": Cannot bypass fit. Number of entries smaller or equal 0 in pixel: " << GetName() << endl;
    111110      return;
    112111    }
     
    116115  fSigma    = fHGausHist.GetRMS() ;
    117116  fSigmaErr = fHGausHist.GetRMS() / TMath::Sqrt(entries) / 2.;
    118 }
    119 
    120 // --------------------------------------------------------------------------
    121 //
    122 // - Set fPixId to id
    123 //
    124 // Add id to names and titles of:
    125 // - fHGausHist
    126 //
    127 void MHCalibrationPix::ChangeHistId(const Int_t id)
    128 {
    129 
    130   fPixId = id;
    131 
    132   fHGausHist.SetName(  Form("%s%d", fHGausHist.GetName(),  id));
    133   fHGausHist.SetTitle( Form("%s%d", fHGausHist.GetTitle(), id));
    134 
    135   fName  = Form("%s%d", fName.Data(),  id);
    136   fTitle = Form("%s%d", fTitle.Data(), id);
    137 
    138117}
    139118
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationPix.h

    r5098 r5137  
    1818  Int_t    fSaturated;                   // Number of events classified as saturated
    1919  Float_t  fPickupLimit;                 // Upper nr sigmas from mean until event is considered pickup
    20   Int_t    fPixId;                       // Pixel ID
    2120
    2221public:
    2322
    2423  MHCalibrationPix(const char* name=NULL, const char* title=NULL);
    25   ~MHCalibrationPix() {}
    2624
    2725  void  Clear(Option_t *o="");
     
    3028  const Double_t GetBlackout       () const; 
    3129  const Double_t GetPickup         () const;
    32   const Int_t    GetPixId          () const { return fPixId;          }
    3330  const Float_t  GetSaturated      () const { return fSaturated;      }
    3431
     
    4138  void  SetBlackoutLimit    ( const Float_t  lim=fgBlackoutLimit ) { fBlackoutLimit  = lim; }
    4239  void  SetPickupLimit      ( const Float_t  lim=fgPickupLimit   ) { fPickupLimit    = lim; }
    43   void  SetPixId            ( const Int_t    i                   ) { fPixId          = i;   }
    4440
    4541  // Miscelleaneous
    46   virtual void ChangeHistId(const Int_t id);      // Changes names and titles of the histogram
    4742  virtual void Renorm();                          // Re-normalize the results
    4843 
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.cc

    r5098 r5137  
    109109#include "MBadPixelsPix.h"
    110110
     111#include <TOrdCollection.h>
    111112#include <TPad.h>
    112113#include <TVirtualPad.h>
     
    167168
    168169}
     170
     171// --------------------------------------------------------------------------
     172//
     173// Creates new MHCalibrationRelTimeCam only with the averaged areas:
     174// the rest has to be retrieved directly, e.g. via:
     175//     MHCalibrationRelTimeCam *cam = MParList::FindObject("MHCalibrationRelTimeCam");
     176//  -  cam->GetAverageSector(5).DrawClone();
     177//  -  (*cam)[100].DrawClone()
     178//
     179#if 0
     180TObject *MHCalibrationRelTimeCam::Clone(const char *) const
     181{
     182
     183  MHCalibrationRelTimeCam *cam = new MHCalibrationRelTimeCam();
     184
     185  //
     186  // Copy the data members
     187  //
     188  cam->fRunNumbers             = fRunNumbers;
     189  cam->fPulserFrequency        = fPulserFrequency;
     190  cam->fFlags                  = fFlags;
     191  cam->fNbins                  = fNbins;
     192  cam->fFirst                  = fFirst;
     193  cam->fLast                   = fLast;
     194
     195  //
     196  // Copy the MArrays
     197  //
     198  cam->fAverageAreaRelSigma    = fAverageAreaRelSigma;
     199  cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
     200  cam->fAverageAreaSat         = fAverageAreaSat;
     201  cam->fAverageAreaSigma       = fAverageAreaSigma;
     202  cam->fAverageAreaSigmaVar    = fAverageAreaSigmaVar;
     203  cam->fAverageAreaNum         = fAverageAreaNum;
     204  cam->fAverageSectorNum       = fAverageSectorNum;
     205
     206  if (!IsAverageing())
     207    return cam;
     208
     209  const Int_t navhi   =  fAverageHiGainAreas->GetSize();
     210
     211  for (int i=0; i<navhi; i++)
     212    cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
     213
     214  if (IsLoGain())
     215    {
     216     
     217      const Int_t navlo = fAverageLoGainAreas->GetSize();
     218      for (int i=0; i<navlo; i++)
     219        cam->fAverageLoGainAreas->AddAt(GetAverageLoGainArea(i).Clone(),i);
     220
     221    }
     222
     223  return cam;
     224}
     225#endif
    169226
    170227// --------------------------------------------------------------------------
     
    351408Bool_t MHCalibrationRelTimeCam::FinalizeHists()
    352409{
     410
     411  *fLog << endl;
     412
     413  MCalibrationCam *relcam = fIntensCam ? fIntensCam->GetCam() : fCam;
     414  MBadPixelsCam   *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
     415
    353416  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
    354417    {
     
    359422        continue;
    360423     
    361       MCalibrationRelTimePix &pix = fIntensCam
    362         ? (MCalibrationRelTimePix&)(*fIntensCam)[i]
    363         : (MCalibrationRelTimePix&)(*fCam)[i];
     424      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*relcam)[i] ;
    364425
    365426      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
     
    398459      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
    399460        {
    400           MCalibrationRelTimePix  &pix    = fIntensCam
    401             ? (MCalibrationRelTimePix&)fIntensCam->GetAverageArea(j)
    402             : (MCalibrationRelTimePix&)fCam->GetAverageArea(j);
     461          MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)relcam->GetAverageArea(j);
    403462          pix.SetHiGainSaturation();
    404463          histhi.SetExcluded();
     
    414473     
    415474      MHCalibrationPix &histhi = GetAverageHiGainSector(j);     
    416       MCalibrationRelTimePix  &pix = fIntensCam
    417         ? (MCalibrationRelTimePix&)fIntensCam->GetAverageSector(j) 
    418         : (MCalibrationRelTimePix&)fCam->GetAverageSector(j);
     475      MCalibrationRelTimePix  &pix = (MCalibrationRelTimePix&)relcam->GetAverageSector(j) ;
    419476
    420477      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
     
    428485    }
    429486
    430   FitHiGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
    431                   fIntensBad ?                   (*fIntensBad->GetCam()) : *fBadPixels,
     487  FitHiGainArrays(*relcam,*badcam,
    432488                  MBadPixelsPix::kRelTimeNotFitted,
    433489                  MBadPixelsPix::kRelTimeOscillating);
    434490 
    435491  if (IsLoGain())       
    436     FitLoGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
    437                     fIntensBad ?                   (*fIntensBad->GetCam()) : *fBadPixels,
     492    FitLoGainArrays(*relcam,*badcam,
    438493                    MBadPixelsPix::kRelTimeNotFitted,
    439494                    MBadPixelsPix::kRelTimeOscillating);
     
    548603{
    549604
    550   const Int_t nareas = fAverageHiGainAreas->GetEntries();
     605  const Int_t nareas = fAverageHiGainAreas->GetSize();
    551606  if (nareas == 0)
    552607    return;
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.h

    r5102 r5137  
    3232  static const TString gsHistYTitle;                 //! Default Histogram y-axis titles
    3333 
    34   MArrayD fSumareahi  ;                             //!
    35   MArrayD fSumarealo  ;                             //!
    36   MArrayD fSumsectorhi;                             //!
    37   MArrayD fSumsectorlo;                             //!
    38   MArrayI fNumareahi  ;                             //!
    39   MArrayI fNumarealo  ;                             //!
    40   MArrayI fNumsectorhi;                             //!
    41   MArrayI fNumsectorlo;                             //!
     34  MArrayD fSumareahi  ;                             //
     35  MArrayD fSumarealo  ;                             //
     36  MArrayD fSumsectorhi;                             //
     37  MArrayD fSumsectorlo;                             //
     38  MArrayI fNumareahi  ;                             //
     39  MArrayI fNumarealo  ;                             //
     40  MArrayI fNumsectorhi;                             //
     41  MArrayI fNumsectorlo;                             //
    4242
    4343  UInt_t fReferencePixel;                           // The reference pixel for rel. times
     
    5757  UInt_t GetReferencePixel() const { return fReferencePixel; }
    5858
     59  // Clone
     60  //  TObject *Clone(const char *name="") const;
     61
    5962  // Setters
    6063  void  SetReferencePixel( const UInt_t i=fgReferencePixel) { fReferencePixel = i; }
     
    7073
    7174#endif
    72 
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationTestCam.cc

    r4950 r5137  
    103103#include "MBadPixelsPix.h"
    104104
     105#include <TOrdCollection.h>
     106
    105107ClassImp(MHCalibrationTestCam);
    106108
    107109using namespace std;
    108110
    109 const Int_t   MHCalibrationTestCam::fgNbins    = 900;
    110 const Axis_t  MHCalibrationTestCam::fgFirst    = -5.;
    111 const Axis_t  MHCalibrationTestCam::fgLast     =  5.;
     111const Int_t   MHCalibrationTestCam::fgNbins    = 1000;
     112const Axis_t  MHCalibrationTestCam::fgFirst    = -0.5;
     113const Axis_t  MHCalibrationTestCam::fgLast     = 39999.5;
    112114const TString MHCalibrationTestCam::gsHistName   = "Test";
    113115const TString MHCalibrationTestCam::gsHistTitle  = "Calibrated Calibration Signals"; 
     
    188190
    189191
     192//--------------------------------------------------------------------------------------
     193//
     194// Initializes the High Gain Arrays:
     195//
     196// - For every entry in the expanded arrays:
     197//   * Initialize an MHCalibrationPix
     198//   * Set Binning from  fNbins, fFirst and fLast
     199//   * Set Histgram names and titles from fHistName and fHistTitle
     200//   * Set X-axis and Y-axis titles with fHistXTitle and fHistYTitle
     201//   * Call InitHists
     202//
     203void MHCalibrationTestCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
     204{
     205
     206  if (fHiGainArray->GetSize()==0)
     207  {
     208      for (Int_t i=0; i<npixels; i++)
     209      {
     210        fHiGainArray->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainPix"),
     211                                                 Form("%s%s",fHistTitle.Data()," High Gain Pixel")),i);
     212       
     213        MHCalibrationPix &pix = (*this)[i];         
     214        pix.SetNbins(fNbins);
     215        pix.SetFirst(fFirst);
     216        pix.SetLast (fLast);
     217       
     218        MBadPixelsPix &bad = (*fBadPixels)[i];
     219        InitHists(pix,bad,i);
     220      }
     221  }
     222
     223  if (!IsAverageing())
     224    return;
     225
     226  if (fAverageHiGainAreas->GetSize()==0)
     227  {
     228    for (Int_t j=0; j<nareas; j++)
     229      {
     230        fAverageHiGainAreas->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainArea"),
     231                                                        Form("%s%s",fHistTitle.Data()," High Gain Area Idx ")),j);
     232       
     233        MHCalibrationPix &pix = GetAverageHiGainArea(j);
     234       
     235        pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
     236        pix.SetFirst(fFirst);
     237        pix.SetLast (fLast);
     238
     239        pix.InitBins();
     240        pix.SetEventFrequency(fPulserFrequency);
     241      }
     242  }
     243
     244  if (fAverageHiGainSectors->GetSize()==0)
     245    {
     246      for (Int_t j=0; j<nsectors; j++)
     247        {
     248          fAverageHiGainSectors->AddAt(new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainSector"),
     249                                                            Form("%s%s",fHistTitle.Data()," High Gain Sector ")),j);
     250          MHCalibrationPix &pix = GetAverageHiGainSector(j);
     251
     252          pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors));
     253          pix.SetFirst(fFirst);
     254          pix.SetLast (fLast);
     255         
     256          pix.InitBins();
     257          pix.SetEventFrequency(fPulserFrequency);
     258      }
     259  }
     260}
     261
    190262// -------------------------------------------------------------------------------
    191263//
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationTestCam.h

    r4950 r5137  
    3535  Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
    3636  Bool_t FinalizeHists();
     37
     38  void InitHiGainArrays(const Int_t npix, const Int_t nareas, const Int_t nsectors);
    3739 
    3840public:
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationTestTimeCam.cc

    r4950 r5137  
    102102#include "MBadPixelsPix.h"
    103103
     104#include <TOrdCollection.h>
     105
    104106ClassImp(MHCalibrationTestTimeCam);
    105107
  • trunk/MagicSoft/Mars/mpedestal/MHPedestalCam.cc

    r4996 r5137  
    113113#include "TH1.h"
    114114
     115#include <TOrdCollection.h>
     116
    115117ClassImp(MHPedestalCam);
    116118
     
    231233  fExtractLoGainSlices = sliceslo;
    232234
    233   if (fHiGainArray->GetEntries()==0)
    234   {
    235       fHiGainArray->Expand(npixels);
     235  if (fHiGainArray->GetSize()==0)
     236  {
    236237      for (Int_t i=0; i<npixels; i++)
    237238      {
    238           (*fHiGainArray)[i] = new MHPedestalPix;
    239           InitPedHists((MHPedestalPix&)(*this)[i],i,fExtractHiGainSlices);
     239        fHiGainArray->AddAt(new MHPedestalPix(Form("%s%4i","MHPedestalHiGainPix",i),
     240                                              Form("%s%4i","Pedestals High Gain Pixel",i)),i);
     241        InitPedHists((MHPedestalPix&)(*this)[i],i,fExtractHiGainSlices);
    240242         
    241           if ((*fBadPixels)[i].IsBad())
     243      if ((*fBadPixels)[i].IsBad())
    242244            (*this)[i].SetExcluded();
    243245
     
    247249  }
    248250
    249   if (fLoGainArray->GetEntries()==0)
    250   {
    251       fLoGainArray->Expand(npixels);
     251  if (fLoGainArray->GetSize()==0)
     252  {
    252253      for (Int_t i=0; i<npixels; i++)
    253254      {
    254           (*fLoGainArray)[i] = new MHPedestalPix;
    255           InitPedHists((MHPedestalPix&)(*this)(i),i,fExtractLoGainSlices);
    256 
    257           if ((*fBadPixels)[i].IsBad())
    258             (*this)(i).SetExcluded();
     255        fLoGainArray->AddAt(new MHPedestalPix(Form("%s%4i","MHPedestalLoGainPix",i),
     256                                              Form("%s%4i","Pedestals Low Gain Pixel",i)),i);
     257        InitPedHists((MHPedestalPix&)(*this)(i),i,fExtractLoGainSlices);
     258
     259        if ((*fBadPixels)[i].IsBad())
     260          (*this)(i).SetExcluded();
    259261      }
    260262  }
    261263
    262   if (fAverageHiGainAreas->GetEntries()==0)
    263   {
    264     fAverageHiGainAreas->Expand(nareas);
     264  if (fAverageHiGainAreas->GetSize()==0)
     265  {
    265266   
    266267    for (Int_t j=0; j<nareas; j++)
    267268      {
    268         (*fAverageHiGainAreas)[j] =
    269           new MHPedestalPix("AverageHiGainArea",
    270                                       "Average Pedestals area idx ");
    271 
    272         GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Pedestals average Area Idx ");
     269        fAverageHiGainAreas->AddAt(new MHPedestalPix(Form("%s%d","AverageHiGainArea",j),
     270                                                     Form("%s%d","Average Pedestals area idx ",j)),j);
    273271
    274272        InitPedHists((MHPedestalPix&)GetAverageHiGainArea(j),j,fExtractHiGainSlices);
     
    277275  }
    278276
    279   if (fAverageLoGainAreas->GetEntries()==0)
    280   {
    281     fAverageLoGainAreas->Expand(nareas);
     277  if (fAverageLoGainAreas->GetSize()==0)
     278  {
    282279   
    283280    for (Int_t j=0; j<nareas; j++)
    284281      {
    285         (*fAverageLoGainAreas)[j] =
    286           new MHPedestalPix("AverageLoGainArea",
    287                                       "Pedestals average Area idx ");
    288 
    289         GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Pedestals average Area Idx ");
     282        fAverageLoGainAreas->AddAt(new MHPedestalPix(Form("%s%d","AverageLoGainArea",j),
     283                                                     Form("%s%d","Pedestals average Area idx ",j)),j);
    290284
    291285        InitPedHists((MHPedestalPix&)GetAverageLoGainArea(j),j,fExtractLoGainSlices);
     
    294288  }
    295289
    296   if (fAverageHiGainSectors->GetEntries()==0)
    297   {
    298       fAverageHiGainSectors->Expand(nsectors);
     290  if (fAverageHiGainSectors->GetSize()==0)
     291  {
    299292
    300293      for (Int_t j=0; j<nsectors; j++)
    301294      {
    302           (*fAverageHiGainSectors)[j] =
    303             new MHPedestalPix("AverageHiGainSector",
    304                                         "Pedestals average sector ");
    305 
    306           GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Pedestals average Sector ");
     295          fAverageHiGainSectors->AddAt(new MHPedestalPix(Form("%s%2i","AverageHiGainSector",j),
     296                                                         Form("%s%2i","Pedestals average sector ",j)),j);
    307297
    308298          InitPedHists((MHPedestalPix&)GetAverageHiGainSector(j),j,fExtractHiGainSlices);
    309 
    310299      }
    311300  }
    312301
    313   if (fAverageLoGainSectors->GetEntries()==0)
    314   {
    315       fAverageLoGainSectors->Expand(nsectors);
    316 
     302  if (fAverageLoGainSectors->GetSize()==0)
     303  {
    317304      for (Int_t j=0; j<nsectors; j++)
    318305      {
    319           (*fAverageLoGainSectors)[j] =
    320             new MHPedestalPix("AverageLoGainSector",
    321                                         "Pedestals average sector ");
    322 
    323           GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Pedestals average Sector ");
     306          fAverageLoGainSectors->AddAt(new MHPedestalPix(Form("%s%2i","AverageLoGainSector",j),
     307                                                         Form("%s%2i","Pedestals average sector ",j)),j);
    324308
    325309          InitPedHists((MHPedestalPix&)GetAverageLoGainSector(j),j,fExtractLoGainSlices);
    326          
    327310      }
    328311  }
     
    347330
    348331  hist.InitBins();
    349   hist.ChangeHistId(i);
    350332  hist.SetEventFrequency(fPulserFrequency);
    351333
     
    355337  hist.SetProbLimit(0.);
    356338
    357   TH1F *h = hist.GetHGausHist();
    358   h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
    359339}
    360340// -------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.