Ignore:
Timestamp:
01/19/03 14:52:29 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/manalysis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc

    r1552 r1715  
    1616!
    1717!
    18 !   Author(s): Abelardo Moralejo 7/2002  (moralejo@pd.infn.it)
    19 !
    20 !   Copyright: MAGIC Software Development, 2002
     18!   Author(s): Abelardo Moralejo 7/2002  <mailto:moralejo@pd.infn.it>
     19!   Author(s): Thomas Bretz 2002  <mailto:tbretz@astro.uni-wuerzburg.de>
     20!
     21!   Copyright: MAGIC Software Development, 2002-2003
    2122!
    2223!
     
    2425
    2526//////////////////////////////////////////////////////////////////////////////
    26 //                                                                          //
    27 //   MCerPhotCalc                                                          //
    28 //                                                                          //
    29 //   This is a task which calculates the number of photons from the FADC    //
    30 //   time slices. It weights the each slice according to the numbers in     //
    31 //   the array fWeight (default: all slices added up with weight 1). 
    32 //                                                                          //
    33 //  Input Containers:                                                       //
    34 //   MRawRunHeader, MRawEvtData, MPedestalCam                               //
    35 //                                                                          //
    36 //  Output Containers:                                                      //
    37 //   MCerPhotEvt                                                            //
    38 //                                                                          //
     27//
     28//   MCerPhotCalc
     29//
     30//   This is a task which calculates the number of photons from the FADC
     31//   time slices. It weights the each slice according to the numbers in
     32//   the array fWeight (default: all slices added up with weight 1).
     33//
     34//  Input Containers:
     35//   MRawRunHeader, MRawEvtData, MPedestalCam
     36//
     37//  Output Containers:
     38//   MCerPhotEvt
     39//
    3940//////////////////////////////////////////////////////////////////////////////
    40 
    4141#include "MCerPhotCalc.h"
    4242
     
    103103    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
    104104    if (!fPedestals)
    105     {
    106         *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
    107         return kFALSE;
    108     }
     105        return kFALSE;
    109106
    110107    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
     
    115112    fSumQuadWeights = 0.;
    116113    for (Int_t i = 0; i < fWeight.GetSize(); i++)
    117       fSumQuadWeights += fWeight[i]*fWeight[i];
     114        fSumQuadWeights += fWeight[i]*fWeight[i];
    118115
    119116    fSumQuadWeights = sqrt(fSumQuadWeights);
     
    171168    MRawEvtPixelIter pixel(fRawEvt);
    172169
    173     TArrayF BinSignal(fWeight.GetSize());
     170    TArrayF binsignal(fWeight.GetSize());
    174171
    175172    while (pixel.Next())
    176       {
    177         const UInt_t pixid = pixel.GetPixelId();
     173    {
     174        const UInt_t pixid = pixel.GetPixelId();
    178175        const MPedestalPix &ped = (*fPedestals)[pixid];
    179176
     
    187184        }
    188185
    189         // Mean pedestal:
    190         Double_t mean = fEnableFix ? ped.GetMean()-0.5 : ped.GetMean();
    191 
    192         Byte_t *ptr = pixel.GetHiGainSamples();
    193 
    194         Float_t nphot = 0.;
    195         Float_t nphoterr = 0.;
    196 
    197         // Calculate pixel signal unless it has all FADC slices empty:
    198 
    199         if (pixel.GetSumHiGainSamples()>0)
    200           {
    201             for(Int_t i = 0; i<fWeight.GetSize(); i++)
    202               {
    203                 BinSignal[i] =  (Float_t) ptr[i] - mean;
    204                 nphot       +=  BinSignal[i] * fWeight[i];
    205               }
    206             nphoterr = ped.GetSigma()* fSumQuadWeights;
    207           }
     186        //
     187        // Mean pedestal:
     188        //
     189        const Double_t mean = fEnableFix ? ped.GetMean()-0.5 : ped.GetMean();
     190
     191        //
     192        // Calculate pixel signal unless it has all FADC slices empty:
     193        //
     194        const Byte_t *ptr = pixel.GetHiGainSamples();
     195
     196        Float_t nphot = 0;
     197        Float_t nphoterr = 0;
     198
     199        if (pixel.GetSumHiGainSamples()>0)
     200        {
     201            for (Int_t i=0; i<fWeight.GetSize(); i++)
     202            {
     203                binsignal[i] =  ptr[i] - mean;
     204                nphot       +=  binsignal[i] * fWeight[i];
     205            }
     206            nphoterr = ped.GetSigma() * fSumQuadWeights;
     207        }
    208208
    209209        fCerPhotEvt->AddPixel(pixid, nphot, nphoterr);
    210210
    211211        // FIXME! Handling of Lo Gains is missing!
    212       }
     212    }
    213213
    214214    fCerPhotEvt->SetReadyToSave();
     
    217217}
    218218
     219// --------------------------------------------------------------------------
    219220//
    220221// Set default values for the number of slices and weights:
    221222//
    222 
    223223void MCerPhotCalc::SetDefaultWeights()
    224224{
    225   const Float_t dummy[15] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,};
    226 
    227   fWeight.Set(15,dummy);
    228   return;
    229 }
    230 
    231 
    232 
    233 
     225    const Float_t dummy[15] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
     226    fWeight.Set(15, dummy);
     227}
  • trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h

    r1546 r1715  
    1010//                                                                         //
    1111/////////////////////////////////////////////////////////////////////////////
     12#ifndef ROOT_TArrayF
     13#include <TArrayF.h>
     14#endif
    1215
    1316#ifndef MARS_MTask
     
    1518#endif
    1619
    17 #include <TArrayF.h>
    18 
    1920class MRawEvtData;
    2021class MPedestalCam;
    2122class MCerPhotEvt;
    2223class MRawRunHeader;
    23 class TArrayF;
    2424
    2525class MCerPhotCalc : public MTask
     
    4444    Bool_t ReInit(MParList *pList);
    4545
    46     void   SetWeights(TArrayF w) {fWeight.Set(w.GetSize(),w.GetArray());}
     46    // FIXME: The array size should be checked!
     47    void   SetWeights(const TArrayF &w) { fWeight = w; }
    4748
    4849    ClassDef(MCerPhotCalc, 0)   // Task to calculate cerenkov photons from raw data
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc

    r1574 r1715  
    158158        return -5.;
    159159
     160    const UInt_t n = geom->GetNumPixels();
     161
    160162    Float_t minval = (*this)[0].GetNumPhotons();
    161163
     
    164166        const MCerPhotPix &pix = (*this)[i];
    165167
     168        const UInt_t id = pix.GetPixId();
     169        if (id>=n)
     170            continue;
     171
    166172        Float_t testval = pix.GetNumPhotons();
    167173
    168174        if (geom)
    169             testval *= geom->GetPixRatio(pix.GetPixId());
     175            testval *= geom->GetPixRatio(id);
    170176
    171177        if (testval < minval)
     
    187193        return 50.;
    188194
     195    const UInt_t n = geom->GetNumPixels();
     196
    189197    Float_t maxval = (*this)[0].GetNumPhotons();
    190198
     
    193201        const MCerPhotPix &pix = (*this)[i];
    194202
     203        const UInt_t id = pix.GetPixId();
     204        if (id>=n)
     205            continue;
     206
    195207        Float_t testval = pix.GetNumPhotons();
    196 
    197208        if (geom)
    198             testval *= geom->GetPixRatio(pix.GetPixId());
     209            testval *= geom->GetPixRatio(id);
    199210
    200211        if (testval > maxval)
     
    322333    return NULL;
    323334}
     335
     336/*
     337// --------------------------------------------------------------------------
     338//
     339// Use this function to sum photons in events together.
     340//
     341Bool_t MCerPhotEvt::AddEvent(const MCerPhotEvt &evt)
     342{
     343    if (evt.fNumPixels<=0)
     344    {
     345        *fLog << "Warning - Event to be added has no pixels." << endl;
     346        return kFALSE;
     347    }
     348    if (fNumPixels<=0)
     349    {
     350        *fLog << "Warning - Event to add pixels to has no pixels." << endl;
     351        return kFALSE;
     352    }
     353
     354    for (UInt_t i=0; i<evt.fNumPixels; i++)
     355    {
     356        const UInt_t id = evt[i].GetPixId();
     357
     358        MCerPhotPix *pix2 = GetPixById(id);
     359        if (!pix2)
     360        {
     361            *fLog << "Error - Pixel#" << dec << id << " does not exist in this event!" << endl;
     362            return kFALSE;
     363        }
     364
     365        pix2->AddNumPhotons(evt[i].GetNumPhotons());
     366    }
     367    return kTRUE;
     368}
     369*/
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h

    r1574 r1715  
    3030    }
    3131
     32    //Bool_t  AddEvent(const MCerPhotEvt &evt);
    3233
    3334    Bool_t  IsPixelExisting(Int_t id) const;
  • trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h

    r1503 r1715  
    4141    void    Set(Float_t np, Float_t ep) { fPhot = np; fErrPhot = ep; }
    4242
     43    void    AddNumPhotons(Float_t f)    { fPhot += f; }
     44
    4345    void    Print(Option_t *opt = NULL) const;
    4446
Note: See TracChangeset for help on using the changeset viewer.