Changeset 1891 for trunk/MagicSoft/Mars
- Timestamp:
- 04/03/03 10:28:31 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1890 r1891 1 1 -*-*- END OF LINE -*-*- 2 3 2003/04/02: Thomas Bretz 4 5 * mhist/MHMatrix.[h,cc]: 6 - added ReadEnv 7 8 * mfileio/MCT1ReadPreProc.[h,cc]: 9 - base SmearTheta on new FindLoEndge 10 - simplified 11 12 * mhist/MBinning.h: 13 - added FindBinLoEdge 14 - added FindBinHiEdge 15 16 * mdata/MDataArray.[h,cc]: 17 - added Clear 18 - added Delete 19 20 2 21 3 22 2003/04/02: Abelardo Moralejo … … 26 45 separation) 27 46 47 48 28 49 2003/04/02: Wolfgang Wittek 29 50 … … 46 67 47 68 69 48 70 2003/04/01: Abelardo Moralejo 49 71 … … 57 79 58 80 81 59 82 2003/03/31: Thomas Bretz 83 84 * manalysis/MParameters.[h,cc]: 85 - added 86 87 * manalysis/AnalysisLinkDef.h, manalysis/Makefile: 88 - added MParameters, MParameterD, MParameterI 89 90 * mhist/MHArray.[h,cc]: 91 - added default constructor 92 - added Set-function 93 - added Init function 94 - moved code from constructors to Set and Init 60 95 61 96 * Makefile.conf.linux: -
trunk/MagicSoft/Mars/mdata/MDataArray.h
r1574 r1891 42 42 Int_t GetNumEntries() const { return fList.GetEntries(); } 43 43 44 void Clear(Option_t *option="") { fList.Clear(option); } 45 void Delete(Option_t *option="") { fList.Delete(option); } 46 44 47 ClassDef(MDataArray, 1) // An array of MData containers 45 48 }; -
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 }; -
trunk/MagicSoft/Mars/mhist/MBinning.h
r1668 r1891 42 42 void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up); 43 43 44 Int_t FindLoEdge(Double_t val) const 45 { 46 for (int i=0; i<fEdges.GetSize(); i++) 47 { 48 if (val >= ((TArrayD)fEdges)[i]) 49 return i; 50 } 51 return -1; 52 } 53 Int_t FindHiEdge(Double_t val) const 54 { 55 for (int i=0; i<fEdges.GetSize(); i++) 56 { 57 if (val < ((TArrayD)fEdges)[i]) 58 return i; 59 } 60 return -1; 61 } 62 44 63 // FIXME: ROOT workaround: "operator[] const" missing 45 64 Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; } -
trunk/MagicSoft/Mars/mhist/MHMatrix.cc
r1887 r1891 1002 1002 1003 1003 // -------------------------------------------------------------------------- 1004 // 1005 // Read the setup from a TEnv: 1006 // Column0, Column1, Column2, ..., Column10, ..., Column100, ... 1007 // 1008 // Searching stops if the first key isn't found in the TEnv. Empty 1009 // columns are not allowed 1010 // 1011 // eg. 1012 // MHMatrix.Column0: cos(MMcEvt.fTelescopeTheta) 1013 // MHMatrix.Column1: MHillasSrc.fAlpha 1014 // 1015 Bool_t MHMatrix::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 1016 { 1017 if (fM.IsValid()) 1018 { 1019 *fLog << err << "ERROR - matrix is already in use. Can't add a new column from TEnv... skipped." << endl; 1020 return kERROR; 1021 } 1022 1023 if (TestBit(kIsLocked)) 1024 { 1025 *fLog << err << "ERROR - matrix is locked. Can't add new column from TEnv... skipped." << endl; 1026 return kERROR; 1027 } 1028 1029 if (fData) 1030 { 1031 *fLog << inf << "Removing all existing columns in " << GetDescriptor() << endl; 1032 fData->Delete(); 1033 } 1034 else 1035 { 1036 fData = new MDataArray; 1037 SetBit(kIsOwner); 1038 } 1039 1040 // 1041 // Search (beginning with 0) all keys 1042 // 1043 for (int i=0;; i++) 1044 { 1045 TString idx = "Column"; 1046 idx += i; 1047 1048 // Output if print set to kTRUE 1049 IsEnvDefined(env, prefix, idx, print); 1050 1051 // Try to get the file name 1052 TString name = GetEnvValue(env, prefix, idx, ""); 1053 if (name.IsNull()) 1054 return kTRUE; 1055 1056 /* 1057 if (name.BeginsWith("\"") && name.EndsWith("\"")) 1058 { 1059 name.Remove(name.Last('\"'), 1); 1060 name.Remove(name.First('\"'), 1); 1061 } 1062 */ 1063 1064 if (print) 1065 *fLog << all << "Add Column: " << name << endl; 1066 fData->AddEntry(name); 1067 } 1068 1069 return kTRUE; 1070 } -
trunk/MagicSoft/Mars/mhist/MHMatrix.h
r1879 r1891 110 110 Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL); 111 111 112 Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); 113 112 114 ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events 113 115 };
Note:
See TracChangeset
for help on using the changeset viewer.