Ignore:
Timestamp:
04/02/03 09:03:22 (22 years ago)
Author:
wittek
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfileio
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc

    r1880 r1888  
    7979#include "MMcEvt.hxx"
    8080#include "MMcTrig.hxx"
     81#include "MBinning.h"
     82
     83#include "TRandom3.h"
     84#include "MParameters.h"
    8185
    8286ClassImp(MCT1ReadPreProc);
     
    119123// Add this file as the last entry in the chain
    120124//
    121 Int_t MCT1ReadPreProc::AddFile(const char *txt, Int_t)
     125void MCT1ReadPreProc::AddFile(const char *txt)
    122126{
    123127    const char *name = gSystem->ExpandPathName(txt);
     
    129133    {
    130134        *fLog << warn << "WARNING - Problem reading header... ignored." << endl;
    131         return 0;
     135        return;
    132136    }
    133137
     
    136140    {
    137141        *fLog << warn << "WARNING - File contains no data... ignored." << endl;
    138         return 0;
     142        return;
    139143    }
    140144
     
    144148
    145149    fFileNames->AddLast(new TNamed(txt, ""));
    146     return 1;
    147150}
    148151
     
    703706
    704707    //
     708    //  look for the HourAngle container in the plist
     709    //
     710    fHourAngle = (MParameterD*)pList->FindCreateObj("MParameterD","HourAngle");
     711    if (!fHourAngle)
     712        return kFALSE;
     713    fHourAngle->SetTitle("Store the CT1 hour angle [deg]");
     714
     715    //
     716    //  look for the ThetaOrig container in the plist
     717    //
     718    fThetaOrig = (MParameterD*)pList->FindCreateObj("MParameterD","ThetaOrig");
     719    if (!fThetaOrig)
     720        return kFALSE;
     721    fThetaOrig->SetTitle("Store the original CT1 zenith angle [rad]");
     722
     723    //
    705724    //  look for the MCerPhotEvt class in the plist
    706725    //
     
    772791
    773792    return GetSelector() ? GetSelector()->CallPreProcess(pList) : kTRUE;
     793}
     794
     795
     796// --------------------------------------------------------------------------
     797//
     798// Smear Theta uniformly in a bin of Theta; result is stored in ThetaSmeared
     799//
     800//
     801Bool_t MCT1ReadPreProc::SmearTheta(MParList *plist, Float_t *Theta,
     802                             Float_t *ThetaSmeared)
     803{
     804  // both Theta and ThetaSmeared are in [radians]
     805  // the edges are in [degrees]
     806
     807  const MBinning *binstheta = (MBinning*)plist->FindObject("BinningTheta");
     808  if (!binstheta)
     809  {
     810    *fLog << err << dbginf << "BinningTheta not found ... aborting." << endl;
     811    return kFALSE;
     812  }
     813
     814  Int_t nedges = binstheta->GetNumEdges();
     815  Double_t *edges  = (Double_t*)binstheta->GetEdges();
     816
     817  Int_t bin = -1;
     818  *ThetaSmeared = *Theta;
     819
     820  Float_t Thetadeg = (*Theta) * 180.0/TMath::Pi();
     821  Float_t ThetaSmeareddeg;
     822 
     823  // search Theta bin
     824  Int_t i;
     825  for (i=1; i<nedges; i++)
     826  {
     827    if (Thetadeg >= *(edges+i)  ) continue;
     828    if (Thetadeg  < *(edges+i-1)) break;
     829    bin = i;
     830    break;
     831  }
     832
     833  Float_t low=0.0;
     834  Float_t up =0.0;
     835
     836  // smear Theta within the Theta bin
     837  ThetaSmeareddeg = -1.0;
     838  if (bin != -1)
     839  {
     840    low = *(edges+bin-1);
     841    up  = *(edges+bin);
     842
     843    Double_t ran = ran3.Rndm(1);
     844    ThetaSmeareddeg = (low + ran * (up-low));
     845  }
     846  *ThetaSmeared = ThetaSmeareddeg * TMath::Pi()/180.0;
     847
     848  //*fLog << "SmearTheta : Thetadeg, ThetaSmeareddeg, low, up, bin = "
     849  //      << Thetadeg
     850  //      << ",  " << ThetaSmeareddeg << ",  " << low << ",  " << up << ",  "
     851  //      << bin << endl;   
     852
     853  return kTRUE;
    774854}
    775855
     
    860940    // int ipreproc_alt_arcs; // "should be" alt according to preproc (arcseconds)
    861941    // int ipreproc_az_arcs;  // "should be" az according to preproc (arcseconds)
     942
     943    // smear Theta in its Theta bin
     944    Float_t ThetaOrig =  TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600); // [radians]
     945    Float_t ThetaSmeared;                                               // [radians]
     946    SmearTheta(fParList, &ThetaOrig, &ThetaSmeared);
     947    fThetaOrig->SetVal(ThetaOrig);
     948
     949    // store hour angle
     950    fHourAngle->SetVal(event.fhourangle);
     951
     952    //*fLog << "MCt1ReadPreProc::ProcessEvent; fhourangle = "
     953    //      << event.fhourangle << endl;
    862954
    863955    fMcEvt->Fill(event.isecs_since_midday,     //0, /*fEvtNum*/
     
    877969                 fIsMcFile ? event.imcimpact_m*100 : 0,
    878970                 TMath::Pi()/180*event.iaz_arcs/3600, // azimuth (arcseconds)
    879                  TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600), // altitude (arcseconds)
     971                 ThetaSmeared,
    880972                 0, /* fTFirst */
    881973                 0, /* fTLast */
     
    895987                 0, /* elec */
    896988                 0, /* muon */
    897                  event.fhourangle  /* other */
     989                 0  /* other */
    898990                 );
    899991
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h

    r1880 r1888  
    99#include "MRead.h"
    1010#endif
     11
     12#include <TRandom3.h>
    1113
    1214class TList;
     
    2224class MTaskList;
    2325class MParList;
     26class MParameterD;
    2427
    2528struct outputpars;
     
    4245    MRawRunHeader *fRawRunHeader; // raw run header
    4346    MParList      *fParList;      // parameter list
     47    MParameterD   *fHourAngle;    // hour angle [deg]
     48    MParameterD   *fThetaOrig;    // original zenith angle [rad]
    4449
    4550    Bool_t fIsMcFile;       // Flag whether current run is a MC run
     
    5358    TArrayF fPedRMS;
    5459
     60    TRandom3 ran3;
    5561
    5662    Bool_t OpenNextFile();
     
    7783    ~MCT1ReadPreProc();
    7884
    79     Int_t AddFile(const char *fname, Int_t dummy=-1);
     85    void AddFile(const char *fname);
    8086
    8187    UInt_t GetEntries() { return fEntries; }
     88
     89    Bool_t SmearTheta(MParList *plist, Float_t *theta, Float_t *thetasmeared);
    8290
    8391    ClassDef(MCT1ReadPreProc, 0) // Reads the CT1 preproc data file
     
    8694#endif
    8795
     96
     97
  • trunk/MagicSoft/Mars/mfileio/Makefile

    r1600 r1888  
    2020# @endcode
    2121
    22 INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mdata -I../manalysis -I../mgeom
     22INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mdata -I../manalysis -I../mgeom -I../mhist
    2323
    2424# @code
Note: See TracChangeset for help on using the changeset viewer.