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

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.