Changeset 5729 for trunk/MagicSoft


Ignore:
Timestamp:
01/07/05 19:56:06 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MEnergyEstParam.h

    r2225 r5729  
    5858    void SetCoeffB(const TArrayD &arr);
    5959
     60    void SetVariables(const TArrayD &arr) { SetCoeff(arr); }
     61
    6062    Double_t GetCoeff(Int_t i) { return i<fA.GetSize()? fA[i] : fB[i-fA.GetSize()]; }
    6163
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc

    r5570 r5729  
    6666//     SetPedestalFlag(MCalibrateData::kEvent)  (calibration is done for each event)
    6767//
    68 //   By calling SetNamePedestalCam() and/or SetNamePedPhotCam() you
    69 //   can control the name of the MPedestalCam and/or MPedPhotCam container which is used.
     68//   By calling AddPedestal() you can control the name of the
     69//   MPedestalCam and/or MPedPhotCam container which is used.
    7070//
    7171//   Assume you want to calibrate "MPedestalCam" once and "MPedestalFromLoGain" [MPedestalCam]
     
    7676//     MCalibrateData cal2;
    7777//     cal2.SetCalibrationMode(MCalibrateData::kSkip);
    78 //     cal2.SetNamePedestalCam("MPedestalFromLoGain");
    79 //     cal2.SetNamePedPhotCam("MPedPhotFromLoGain")
     78//     cal2.AddPedestal("FromLoGain");
    8079//     cal2.SetPedestalFlag(MCalibrateData::kEvent);
    8180//
     
    133132using namespace std;
    134133
    135 const TString MCalibrateData::fgNamePedestalCam  = "MPedestalCam";
    136 const TString MCalibrateData::fgNamePedPhotCam = "MPedPhotCam";
    137 
    138134// --------------------------------------------------------------------------
    139135//
     
    145141// - fCalibrationMode to kDefault
    146142// - fPedestalFlag to kNo
    147 // - fNamePedADCRunContainer    to "MPedestalCam" 
    148 // - fNamePedPhotRunContainer   to "MPedPhotCam"   
    149143//
    150144MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title)
    151     : fGeomCam(NULL),   fPedestalMean(NULL), fPedestalRms(NULL),
    152       fBadPixels(NULL), fCalibrations(NULL), fQEs(NULL), fSignals(NULL),
    153       fPedPhot(NULL),   fCerPhotEvt(NULL), fPedestalFlag(kNo)
     145    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL),
     146    fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fPedestalFlag(kNo)
    154147{
    155148
     
    159152  SetCalibrationMode(calmode);
    160153
    161   SetNamePedestalCam();
    162   SetNamePedPhotCam();
     154  fNamesPedestal.SetOwner();
     155}
     156
     157void MCalibrateData::AddPedestal(const char *name)
     158{
     159    TString ped(name);
     160    TString pho(name);
     161    ped.Prepend("MPedestal");
     162    pho.Prepend("MPedPhot");
     163
     164    fNamesPedestal.Add(new TNamed(ped, pho));
     165}
     166
     167void MCalibrateData::AddPedestal(const char *pedestal, const char *pedphot)
     168{
     169    fNamesPedestal.Add(new TNamed(pedestal, pedphot));
    163170}
    164171
     
    226233    }
    227234
    228     //fPedestalMean = 0;
    229     //fPedestalRms  = 0;
    230     fPedPhot  = 0;
     235    if (fNamesPedestal.GetSize()>0 && fPedestalFlag==kNo)
     236    {
     237        *fLog << warn << "Pedestal list contains entries, but mode is set to kNo... setting to kEvent." << endl;
     238        fPedestalFlag = kEvent;
     239    }
     240
    231241    if (fPedestalFlag)
    232242    {
    233         if (!fPedestalMean)
    234         {
    235             fPedestalMean = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedestalCam), "MPedestalCam");
    236             if (!fPedestalMean)
     243        if (fNamesPedestal.GetSize()==0)
     244        {
     245            *fLog << inf << "No container names specified... using default: MPedestalCam and MPedPhotCam." << endl;
     246            AddPedestal();
     247        }
     248
     249        fPedestalCams.Clear();
     250        fPedPhotCams.Clear();
     251
     252        TIter Next(&fNamesPedestal);
     253        TObject *o=0;
     254        while ((o=Next()))
     255        {
     256            TObject *pedcam = pList->FindObject(AddSerialNumber(o->GetName()), "MPedestalCam");
     257            if (!pedcam)
    237258            {
    238                 *fLog << err << AddSerialNumber(fNamePedestalCam) << " [MPedestalCam] not found ... aborting" << endl;
     259                *fLog << err << AddSerialNumber(o->GetName()) << " [MPedestalCam] not found ... aborting" << endl;
    239260                return kFALSE;
    240261            }
    241         }
    242 
    243         if (!fPedestalRms)
    244         {
    245             fPedestalRms = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedestalCam), "MPedestalCam");
    246             if (!fPedestalRms)
    247             {
    248                 *fLog << err << AddSerialNumber(fNamePedestalCam) << " [MPedestalCam] not found ... aborting" << endl;
     262            TObject *pedphot = pList->FindCreateObj("MPedPhotCam", AddSerialNumber(o->GetTitle()));
     263            if (!pedphot)
    249264                return kFALSE;
    250             }
    251         }
    252 
    253         fPedPhot = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam", AddSerialNumber(fNamePedPhotCam));
    254         if (!fPedPhot)
    255             return kFALSE;
     265
     266            fPedestalCams.Add(pedcam);
     267            fPedPhotCams.Add(pedphot);
     268        }
    256269    }
    257270
     
    281294
    282295    // Sizes might have changed
    283     if (fPedestalFlag && (Int_t)fPedestalMean->GetSize() != fSignals->GetSize())
    284     {
    285         *fLog << err << "Size mismatch of MPedestalCam for Mean and MCalibrationCam... abort." << endl;
    286         return kFALSE;
    287     }
    288 
    289     if (fPedestalFlag && (Int_t)fPedestalRms->GetSize() != fSignals->GetSize())
    290     {
    291         *fLog << err << "Size mismatch of MPedestalCam for RMS and MCalibrationCam... abort." << endl;
    292         return kFALSE;
     296    if (fPedestalFlag)
     297    {
     298        TIter Next(&fPedestalCams);
     299        MPedestalCam *cam=0;
     300        while ((cam=(MPedestalCam*)Next()))
     301        if ((Int_t)cam->GetSize() != fSignals->GetSize())
     302        {
     303            *fLog << err << "Size mismatch of " << cam->GetDescriptor() << " and MCalibrationCam... abort." << endl;
     304            return kFALSE;
     305        }
    293306    }
    294307
     
    523536        if (pedestal)
    524537        {
     538            /*
    525539            // pedestals/(used FADC slices)   in [ADC] counts
    526540            const Float_t pedes  = (*fPedestalMean)[pixidx].GetPedestal()   * slices;
     
    534548
    535549            (*fPedPhot)[pixidx].Set(pedphot, pedphotrms);
     550            */
     551            TIter NextPed(&fPedestalCams);
     552            TIter NextPhot(&fPedPhotCams);
     553
     554            MPedestalCam *pedestal = 0;
     555            MPedPhotCam  *pedphot  = 0;
     556
     557            while ((pedestal=(MPedestalCam*)NextPed()) &&
     558                   (pedphot =(MPedPhotCam*)NextPhot()))
     559            {
     560                // pedestals/(used FADC slices)   in [ADC] counts
     561                const Float_t pedes  = (*pedestal)[pixidx].GetPedestal()    * slices;
     562                const Float_t pedrms = (*pedestal)[pixidx].GetPedestalRms() * sqrtslices;
     563
     564                // pedestals/(used FADC slices)   in [number of photons]
     565                const Float_t mean = pedes  * calibConv;
     566                const Float_t rms  = pedrms * calibConv;
     567
     568                (*pedphot)[pixidx].Set(mean, rms);
     569                pedphot->SetReadyToSave();
     570            }
    536571        }
    537572    }
     
    542577        return kCONTINUE;
    543578    }
    544 
    545     if (pedestal)
    546         fPedPhot->SetReadyToSave();
    547579
    548580    if (data)
     
    610642    }
    611643
    612     if (fNamePedestalCam != fgNamePedestalCam)
    613     {
    614         out << "   " << GetUniqueName() << ".SetNamePedestalCam(";
    615         out << fNamePedestalCam << ");" << endl;
    616     }
    617 
    618     if (fNamePedPhotCam  != fgNamePedPhotCam)
    619     {
    620         out << "   " << GetUniqueName() << ".SetNamePedPhotCam(";
    621         out << fNamePedPhotCam << ");" << endl;
     644    TIter Next(&fNamesPedestal);
     645    TObject *o=0;
     646    while ((o=Next()))
     647    {
     648        out << "   " << GetUniqueName() << ".AddPedestal(\"";
     649        out << o->GetName() << "\", \"" << o->GetTitle() << "\");" << endl;
    622650    }
    623651}
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.h

    r5570 r5729  
    3434{
    3535private:
    36   static const TString fgNamePedestalCam;    //! "MPedestalCam"
    37   static const TString fgNamePedPhotCam;     //! "MPedPhotCam"
     36  MGeomCam              *fGeomCam;       //! Camera geometry container
     37  MBadPixelsCam         *fBadPixels;     //! Bad Pixels information
     38  MCalibrationChargeCam *fCalibrations;  //! Calibration constants
     39  MCalibrationQECam     *fQEs;           //! Quantum efficiencies
     40  MExtractedSignalCam   *fSignals;       //! Integrated charge in FADCs counts
     41  MCerPhotEvt           *fCerPhotEvt;    //! Cerenkov Photon Event used for calculation
    3842 
    39   MGeomCam              *fGeomCam;          //! Camera geometry container
    40   MPedestalCam          *fPedestalMean;     //! Pedestals/slice [ADC counts]
    41   MPedestalCam          *fPedestalRms;      //! Pedestals/slice [ADC counts]
    42   MBadPixelsCam         *fBadPixels;        //! Bad Pixels information
    43   MCalibrationChargeCam *fCalibrations;     //! Calibration constants
    44   MCalibrationQECam     *fQEs;              //! Quantum efficiencies
    45   MExtractedSignalCam   *fSignals;          //! Integrated charge in FADCs counts
     43  UShort_t fCalibrationMode;             // Flag defining the calibration mode (CalibrationMode_t)
     44  Byte_t   fPedestalFlag;                // Flags defining to calibrate the pedestal each event or each run
    4645 
    47   MPedPhotCam           *fPedPhot;          //! Pedestals/(used slices) [photons]
    48   MCerPhotEvt           *fCerPhotEvt;       //! Cerenkov Photon Event used for calculation
    49  
    50   UShort_t fCalibrationMode;                // Flag defining the calibration mode (CalibrationMode_t)
    51   Byte_t   fPedestalFlag;                   // Flags defining to calibrate the pedestal each event or each run
    52  
    53   TString  fNamePedestalCam;            // name of fPedestal
    54   TString  fNamePedPhotCam;           // name of fPedPhot
     46  TList fNamesPedestal;                  // Names of input and output pedestal conatainer
     47  TList fPedestalCams;                   //! List of pointers to input MPedestalCam
     48  TList fPedPhotCams;                    //! List of pointers to corresponding output MPedPhotCam
    5549
    5650  Int_t Calibrate(Bool_t data, Bool_t pedestal) const;
     
    9589 
    9690  void   SetCalibrationMode ( CalibrationMode_t calmode=kDefault ) { fCalibrationMode=calmode; }
    97  
    98   void   SetNamePedestalCam(const char *name=fgNamePedestalCam.Data())
    99   {
    100       fNamePedestalCam  = name;
    101   }
    102   void SetPedestalCamMean(MPedestalCam *cam) { fPedestalMean = cam; }
    103   void SetPedestalCamRms(MPedestalCam *cam)  { fPedestalRms  = cam; }
    10491
    105   void   SetNamePedPhotCam(const char *name=fgNamePedPhotCam.Data())
    106   {
    107       fNamePedPhotCam   = name;
    108   }
    109  
     92  void   AddPedestal(const char *name="Cam");
     93  void   AddPedestal(const char *pedestal, const char *pedphot);
     94
    11095  ClassDef(MCalibrateData, 0)   // Task to calibrate FADC counts into Cherenkov photons
    11196};
Note: See TracChangeset for help on using the changeset viewer.