Changeset 1891 for trunk/MagicSoft/Mars/mfileio
- Timestamp:
- 04/03/03 10:28:31 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mfileio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
r1888 r1891 784 784 return kFALSE; 785 785 786 fBinningT = (MBinning*)pList->FindObject("BinningTheta"); 787 if (!fBinningT) 788 { 789 *fLog << err << dbginf << "BinningTheta not found ... aborting." << endl; 790 return kFALSE; 791 } 792 786 793 fNumFilterEvts = 0; 787 794 fNumEvents = 0; … … 796 803 // -------------------------------------------------------------------------- 797 804 // 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 // 807 Float_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; 854 820 } 855 821 … … 942 908 943 909 // 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); 948 912 949 913 // store hour angle 950 914 fHourAngle->SetVal(event.fhourangle); 951 952 //*fLog << "MCt1ReadPreProc::ProcessEvent; fhourangle = "953 // << event.fhourangle << endl;954 915 955 916 fMcEvt->Fill(event.isecs_since_midday, //0, /*fEvtNum*/ … … 969 930 fIsMcFile ? event.imcimpact_m*100 : 0, 970 931 TMath::Pi()/180*event.iaz_arcs/3600, // azimuth (arcseconds) 971 ThetaSmeared,972 932 SmearTheta(theta), 933 0, /* fTFirst */ 973 934 0, /* fTLast */ 974 935 0, /* fL_Nmax */ -
trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
r1888 r1891 9 9 #include "MRead.h" 10 10 #endif 11 12 #include <TRandom3.h>13 11 14 12 class TList; … … 25 23 class MParList; 26 24 class MParameterD; 25 class MBinning; 27 26 28 27 struct outputpars; … … 47 46 MParameterD *fHourAngle; // hour angle [deg] 48 47 MParameterD *fThetaOrig; // original zenith angle [rad] 48 MBinning *fBinningT; // Theta binning for the smearing 49 49 50 50 Bool_t fIsMcFile; // Flag whether current run is a MC run … … 57 57 58 58 TArrayF fPedRMS; 59 60 TRandom3 ran3;61 59 62 60 Bool_t OpenNextFile(); … … 71 69 void ProcessRunHeader(const struct outputpars &outpars); 72 70 void ProcessEvent(const struct eventrecord &event); 71 72 Float_t SmearTheta(Float_t theta); 73 73 74 74 Bool_t PreProcess(MParList *pList); … … 87 87 UInt_t GetEntries() { return fEntries; } 88 88 89 Bool_t SmearTheta(MParList *plist, Float_t *theta, Float_t *thetasmeared);90 91 89 ClassDef(MCT1ReadPreProc, 0) // Reads the CT1 preproc data file 92 90 };
Note:
See TracChangeset
for help on using the changeset viewer.