Ignore:
Timestamp:
04/03/03 10:28:31 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfileio
Files:
2 edited

Legend:

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

    r1888 r1891  
    784784        return kFALSE;
    785785
     786    fBinningT = (MBinning*)pList->FindObject("BinningTheta");
     787    if (!fBinningT)
     788    {
     789        *fLog << err << dbginf << "BinningTheta not found ... aborting." << endl;
     790        return kFALSE;
     791    }
     792
    786793    fNumFilterEvts = 0;
    787794    fNumEvents     = 0;
     
    796803// --------------------------------------------------------------------------
    797804//
    798 // Smear Theta uniformly in a bin of Theta; result is stored in ThetaSmeared
    799 //
    800 //
    801 Bool_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;
     805// Smear Theta uniformly in a bin of Theta
     806//
     807Float_t MCT1ReadPreProc::SmearTheta(Float_t theta)
     808{
     809    // both Theta and ThetaSmeared are in [radians]
     810    // the edges are in [degrees]
     811    const Int_t bin = fBinningT->FindLoEdge(theta * 180.0/TMath::Pi());
     812    if (bin == -1)
     813        return theta;
     814
     815    // smear Theta within the Theta bin
     816    const Double_t low = fBinningT->GetEdges()[bin];
     817    const Double_t up  = fBinningT->GetEdges()[bin+1];
     818
     819    return (low + gRandom->Rndm(1) * (up-low)) * TMath::Pi()/180;
    854820}
    855821
     
    942908
    943909    // 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);
     910    Float_t theta = TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600);
     911    fThetaOrig->SetVal(theta);
    948912
    949913    // store hour angle
    950914    fHourAngle->SetVal(event.fhourangle);
    951 
    952     //*fLog << "MCt1ReadPreProc::ProcessEvent; fhourangle = "
    953     //      << event.fhourangle << endl;
    954915
    955916    fMcEvt->Fill(event.isecs_since_midday,     //0, /*fEvtNum*/
     
    969930                 fIsMcFile ? event.imcimpact_m*100 : 0,
    970931                 TMath::Pi()/180*event.iaz_arcs/3600, // azimuth (arcseconds)
    971                  ThetaSmeared,
    972                 0, /* fTFirst */
     932                 SmearTheta(theta),
     933                0, /* fTFirst */
    973934                 0, /* fTLast */
    974935                 0, /* fL_Nmax */
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h

    r1888 r1891  
    99#include "MRead.h"
    1010#endif
    11 
    12 #include <TRandom3.h>
    1311
    1412class TList;
     
    2523class MParList;
    2624class MParameterD;
     25class MBinning;
    2726
    2827struct outputpars;
     
    4746    MParameterD   *fHourAngle;    // hour angle [deg]
    4847    MParameterD   *fThetaOrig;    // original zenith angle [rad]
     48    MBinning      *fBinningT;     // Theta binning for the smearing
    4949
    5050    Bool_t fIsMcFile;       // Flag whether current run is a MC run
     
    5757
    5858    TArrayF fPedRMS;
    59 
    60     TRandom3 ran3;
    6159
    6260    Bool_t OpenNextFile();
     
    7169    void   ProcessRunHeader(const struct outputpars &outpars);
    7270    void   ProcessEvent(const struct eventrecord &event);
     71
     72    Float_t SmearTheta(Float_t theta);
    7373
    7474    Bool_t PreProcess(MParList *pList);
     
    8787    UInt_t GetEntries() { return fEntries; }
    8888
    89     Bool_t SmearTheta(MParList *plist, Float_t *theta, Float_t *thetasmeared);
    90 
    9189    ClassDef(MCT1ReadPreProc, 0) // Reads the CT1 preproc data file
    9290};
Note: See TracChangeset for help on using the changeset viewer.