Ignore:
Timestamp:
12/19/01 15:44:07 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r1130 r1132  
    7171//
    7272MMcPedestalNSBAdd::MMcPedestalNSBAdd(const Float_t difnsb,
    73                                const char *name, const char *title)
     73                                     const char *name, const char *title)
     74    : fDnsbPixel(difnsb)
    7475{
    7576    fName  = name  ? name  : "MMcPedestalNSBAdd";
     
    8283    AddToBranchList("fPedesMean");
    8384    AddToBranchList("fElecNoise");
    84 
    85     fDnsbPixel=difnsb;
     85}
     86
     87Bool_t MMcPedestalNSBAdd::CheckRunType(MParList *pList) const
     88{
     89    MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     90    if (!runheader)
     91    {
     92        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
     93        return kTRUE;
     94    }
     95
     96    return runheader->GetRunType() == kRTMonteCarlo;
    8697}
    8798
     
    97108   // implemented then this line should be removed.
    98109
    99     ReInit(pList);   
     110    if (!CheckRunType(pList))
     111    {
     112        *fLog << warn << dbginf << "Warning - MMcPedestalNSB is for Monte Carlo files only... removing this task from list." << endl;
     113        return kSKIP;
     114    }
     115
     116    fFadc = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
     117    if (!fFadc)
     118    {
     119        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
     120        return kFALSE;
     121    }
     122
     123    fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
     124    if (!fGeom)
     125    {
     126        *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
     127        return kFALSE;
     128    }
     129
     130    fPedCam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
     131    if (!fPedCam)
     132        return kFALSE;
     133
     134    MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
     135    if (!mcrunheader && fDnsbPixel < 0 )
     136    {
     137        *fLog << err << dbginf << "Using the default argument of MMcPedestalNSB::MMcPedestalNSB() ";
     138        *fLog << "only allowed if MMcRunHeader is available... aborting." << endl;
     139        return kFALSE;
     140    }
    100141
    101142    return kTRUE;
     
    117158//   - MPedestalCam
    118159//
    119 Bool_t MMcPedestalNSBAdd::ReInit(MParList *pList)
    120 {
    121 
    122     MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
    123     if (runheader)
    124     {
    125         if (runheader->GetRunType() != kRTMonteCarlo)
    126         {
    127             *fLog << warn << dbginf << "Warning - MMcPedestalNSB is for Monte Carlo files only... removing this task from list." << endl;
    128             return kSKIP;
    129         }
    130     }   
    131     else
    132         *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
    133 
    134 
    135     MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
    136     if (!fadc)
    137     {
    138         *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
    139         return kFALSE;
    140     }
    141 
    142 
     160Float_t MMcPedestalNSBAdd::GetDnsb(MParList *pList) const
     161{
    143162    MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
    144163    if (!mcrunheader && fDnsbPixel < 0 )
     
    146165        *fLog << err << dbginf << "Using the default argument of MMcPedestalNSB::MMcPedestalNSB() ";
    147166        *fLog << "only allowed if MMcRunHeader is available... aborting." << endl;
     167        return -1;
     168    }
     169
     170    if (!mcrunheader)
     171        return fDnsbPixel;
     172
     173    if (fDnsbPixel >= 0 && fDnsbPixel != mcrunheader->GetNumPheFromDNSB())
     174    {
     175        *fLog << warn << dbginf << "The MC file has been generated with diffuse nsb " << mcrunheader->GetNumPheFromDNSB();
     176        *fLog <<" but you set up the diffuse NSB to " << fDnsbPixel << endl;
     177
     178        return fDnsbPixel;
     179    }
     180
     181    return mcrunheader->GetNumPheFromDNSB();
     182}
     183
     184Bool_t MMcPedestalNSBAdd::ReInit(MParList *pList)
     185{
     186    if (!CheckRunType(pList))
    148187        return kFALSE;
    149     }
    150 
    151     if (mcrunheader)
    152     {
    153         if (fDnsbPixel >= 0 && fDnsbPixel != mcrunheader->GetNumPheFromDNSB())
    154         {
    155             *fLog << warn << dbginf << "The MC file has been generated with diffuse nsb " << mcrunheader->GetNumPheFromDNSB();
    156             *fLog <<" but you set up the diffuse NSB to " << fDnsbPixel << endl;
    157         }
    158         else
    159             fDnsbPixel = mcrunheader->GetNumPheFromDNSB();
    160     }
    161 
    162     fDnsbPixel *= 50.0/15.0;
    163 
    164 
    165     MGeomCam *geometry = (MGeomCam*)pList->FindObject("MGeomCam");
    166     if (!geometry)
    167     {
    168         *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
    169         return kFALSE;
    170     }
    171 
    172 
    173     MPedestalCam *pedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
    174     if (!pedestals)
    175         return kFALSE;
    176 
    177 
    178     const int num = fadc->GetNumPixel();
     188
     189    Float_t dnsbpix = GetDnsb(pList) * 50.0/15.0;
     190
     191    if (dnsbpix < 0)
     192        return kFALSE;
     193
     194    const int num = fFadc->GetNumPixel();
    179195   
    180     pedestals->InitSize(num);
    181 
    182     const Float_t size0 = (*geometry)[0].GetR()*(*geometry)[0].GetR();
     196    fPedCam->InitSize(num);
     197
     198    const Float_t size0 = (*fGeom)[0].GetR() * (*fGeom)[0].GetR();
    183199
    184200    for (int i=0; i<num; i++)
    185201    {
    186         MPedestalPix &pix     = (*pedestals)[i];
    187         MGeomPix     &pixgeom = (*geometry)[i];
     202        MPedestalPix &pix     = (*fPedCam)[i];
     203        MGeomPix     &pixgeom = (*fGeom)[i];
    188204
    189205        const Float_t pedrms  = pix.GetSigma();
    190206        const Float_t size    = pixgeom.GetR()*pixgeom.GetR()/size0;
    191207
    192         const Float_t ampl    = fadc->GetAmplitud();
    193 
    194         pix.SetSigma(sqrt(pedrms*pedrms + fDnsbPixel*ampl*ampl*size));
     208        const Float_t ampl    = fFadc->GetAmplitud();
     209
     210        pix.SetSigma(sqrt(pedrms*pedrms + dnsbpix*ampl*ampl*size));
    195211    }
    196212
Note: See TracChangeset for help on using the changeset viewer.