Changeset 2802 for trunk/MagicSoft
- Timestamp:
- 01/14/04 16:18:50 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2801 r2802 12 12 rms = 0 later resulted in the pixel being eliminated in the 13 13 image cleaning. 14 15 16 14 17 15 18 2004/01/14: Thomas Bretz … … 41 44 * mreport/MReportFileRead.cc: 42 45 - moved code from MReportHelp to new file 43 - removed usage of MRepoort class completely 46 - removed usage of MReport class completely 47 48 * mfilter/MFGeomag.[h,cc]: 49 - fixed a bug which causes MFGeomag to fail if MARSSYS is not set 50 - changed the second loop from 0->1151 to 1152->2304 51 - removed dummy arrays used for reading 52 - output filename in case of 'file not found' 53 - removed obsolete data members 54 - removed obsolete Init function 55 - removed forbidden underscore from member variable 56 - changed wrong 0/1 in allocation of fResult into kFALSE/TRUE 44 57 45 58 -
trunk/MagicSoft/Mars/mfilter/MFGeomag.cc
r2779 r2802 16 16 ! 17 17 ! 18 ! Author(s): R.K.Bock 11/2003 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 118 ! Author(s): R.K.Bock 11/2003 <mailto:rkb@mppmu.mpg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2004 21 21 ! 22 22 ! … … 39 39 #include "MFGeomag.h" 40 40 41 #include "fstream" //for ifstream 42 #include "TRandom.h" //for gRandom 41 #include <fstream> //for ifstream 42 43 #include <TRandom.h> //for gRandom 44 #include <TSystem.h> 43 45 44 46 #include "MLog.h" … … 49 51 #include "MMcEvt.hxx" 50 52 51 #include <TSystem.h>52 53 53 ClassImp(MFGeomag); 54 54 … … 57 57 // -------------------------------------------------------------------------- 58 58 // 59 MFGeomag::MFGeomag(const char *cname, const char type, const Int_t val, 60 const char *name, const char *title) : fMcEvt(NULL) 61 { 62 fContName = cname; 63 Init(type, val, name, title); 64 } 65 66 // -------------------------------------------------------------------------- 67 // 68 void MFGeomag::Init(const char type, const Int_t val, 69 const char *name, const char *title) 70 59 MFGeomag::MFGeomag(const char *name, const char *title) : fMcEvt(NULL) 71 60 { 72 61 fName = name ? name : "MFGeomag"; 73 62 fTitle = title ? title : "Filter using geomagnetic field"; 74 63 75 fGamm _elec= kFALSE; // logical variable, will not take gammas as electrons (default)76 77 AddToBranchList( Form("%s.fPartId", (const char*)fContName));64 fGammaElectron = kFALSE; // logical variable, will not take gammas as electrons (default) 65 66 AddToBranchList("MMcEvt.fPartId"); 78 67 } 68 79 69 // -------------------------------------------------------------------------- 80 70 // … … 82 72 { 83 73 // reading of tables (variables defined as 'private') 84 85 Float_t azim [2*1152]; // (these variables not used) 86 Float_t thet [2*1152]; 87 88 TString filename = gSystem->Getenv("MARSSYS"); 89 filename += "/mfilter/gcplus.txt"; 74 TString marssys(gSystem->Getenv("MARSSYS")); 75 if (!marssys.IsNull() && !marssys.EndsWith("/")) 76 marssys += "/"; 77 78 // 79 // Read gcminus.txt 80 // 81 TString filename(marssys); 82 filename += "mfilter/gcplus.txt"; 90 83 91 84 ifstream geomagp(filename); 92 85 93 if (!geomagp) { 94 *fLog << err <<" ERROR gcplus.txt file not found by Geomag"<<endl; 86 if (!geomagp) 87 { 88 *fLog << err << "ERROR - file " << filename << " not found." << endl; 95 89 return kFALSE; 96 90 } 97 91 for (int i=0; i<1152; i++) 98 92 { 99 geomagp >>azim[i]>>thet[i];100 geomagp >> fRigMin[i]>>fRigMax[i]>>fProb[i];93 Float_t dummy; 94 geomagp >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i]; 101 95 } 102 96 *fLog << inf << endl; 103 *fLog << "gcplus.txt read,first line: ";97 *fLog << "gcplus.txt - first line: "; 104 98 *fLog << Form ("FRigMin=%8f fRigMax=%8f fProb=%8f", 105 99 fRigMin[0], fRigMax[0], fProb[0]) << endl; 106 100 107 filename = gSystem->Getenv("MARSSYS"); 108 filename += "/mfilter/gcminus.txt"; 101 // 102 // Read gcminus.txt 103 // 104 filename = marssys; 105 filename += "mfilter/gcminus.txt"; 109 106 110 107 ifstream geomagm(filename); 111 if (!geomagm) { 112 *fLog << err <<" ERROR gcminus.txt file not found by Geomag"<<endl; 113 return kFALSE; 114 } 115 for (int i=0; i<1152; i++) 116 { 117 geomagm >>azim[i+1152]>>thet[i+1152]; 118 geomagm >>fRigMin[i+1152]>>fRigMax[i+1152]>>fProb[i+1152]; 119 } 120 *fLog << "gcminus.txt read, first line: "; 108 if (!geomagm) 109 { 110 *fLog << err << "ERROR - file " << filename << " not found." << endl; 111 return kFALSE; 112 } 113 for (int i=1152; i<2304; i++) 114 { 115 Float_t dummy; 116 geomagm >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i]; 117 } 118 *fLog << "gcminus.txt - first line: "; 121 119 *fLog << Form ("fRigMin=%8f fRigMax=%8f fProb=%8f", 122 120 fRigMin[1152], fRigMax[1152], fProb[1152]) << endl; … … 129 127 if (!fMcEvt) 130 128 { 131 *fLog << err << dbginf << " [MMcEvt]not found... aborting." << endl;129 *fLog << err << "MMcEvt not found... aborting." << endl; 132 130 return kFALSE; 133 131 } … … 139 137 void MFGeomag::SetGammElec() 140 138 { 141 fGamm _elec= kTRUE; // logical variable, will take gammas as electrons139 fGammaElectron = kTRUE; // logical variable, will take gammas as electrons 142 140 *fLog <<" MFGeomag called to treat gammas as electrons" << endl; 143 141 return; … … 157 155 { 158 156 case kGAMMA: 159 if (!fGamm _elec) //accept gammas if not set to electrons157 if (!fGammaElectron) //accept gammas if not set to electrons 160 158 { 161 fResult = 0;159 fResult = kFALSE; 162 160 return kTRUE; 163 161 } … … 180 178 181 179 default: 182 Int_t id = fMcEvt->GetPartId(); 183 *fLog << err <<" Unknown Monte Carlo Particle Id#: "<< id << endl; 180 *fLog << err << " Unknown Monte Carlo Particle Id#: "<< fMcEvt->GetPartId() << endl; 184 181 return kFALSE; 185 182 } … … 188 185 int ia=(int)(az*11.459156); 189 186 ia = (ia+36) % 72; // azimuth definitions differ by 180 deg 187 190 188 float r1=fRigMin[72*it+ia+indadd]; 191 189 if (rig<=r1) { 192 fResult= 1;// reject190 fResult=kTRUE; // reject 193 191 return kTRUE; 194 192 } 193 195 194 float r2=fRigMax[72*it+ia+indadd]; 196 195 if (rig>=r2) { 197 fResult= 0;// accept196 fResult=kFALSE; // accept 198 197 return kTRUE; 199 198 } 200 float R = gRandom->Rndm(0); //accept if above intermediate threshold 201 float pr=fProb [72*it+ia+indadd]; 202 fResult = 0; 203 if (rig < 0.5/pr*R*(r2-r1) + r1) fResult = 1; // pretty good approximation 199 200 float R = gRandom->Rndm(0); // accept if above intermediate threshold 201 float pr=fProb[72*it+ia+indadd]; 202 fResult = kFALSE; 203 204 if (rig < 0.5/pr*R*(r2-r1) + r1) 205 fResult = kTRUE; // pretty good approximation 206 204 207 return kTRUE; 205 208 } -
trunk/MagicSoft/Mars/mfilter/MFGeomag.h
r2510 r2802 1 1 #ifndef MARS_MFGeomag 2 2 #define MARS_MFGeomag 3 4 /////////////////////////////////////////////////////////////////////////////5 // //6 // MFGeomag //7 // //8 /////////////////////////////////////////////////////////////////////////////9 3 10 4 #ifndef MARS_MFilter … … 19 13 private: 20 14 MMcEvt *fMcEvt; 21 TString fContName;22 23 typedef enum { kEEqual, kENotEqual } FilterType_t;24 FilterType_t fFilterType;25 15 26 16 Bool_t fResult; //! 27 Bool_t fGamm _elec; // switches gammas to electrons28 // 17 Bool_t fGammaElectron; // switches gammas to electrons 18 29 19 Float_t fRigMin[2*1152]; //tables to contain cut limits 30 20 Float_t fRigMax[2*1152]; 31 21 Float_t fProb [2*1152]; 32 33 void Init(const char type, const Int_t val,34 const char *name, const char *title);35 36 22 37 23 Int_t PreProcess(MParList *pList); … … 39 25 40 26 public: 41 MFGeomag(const char *cname="MMcEvt", const char type='=', const Int_t val=0, 42 const char *name=NULL, const char *title=NULL); 27 MFGeomag(const char *name=NULL, const char *title=NULL); 43 28 44 29 void SetGammElec(); // allows to use gammas like electrons 45 Bool_t IsExpressionTrue() const { return fResult;};30 Bool_t IsExpressionTrue() const { return fResult; } 46 31 47 32 ClassDef(MFGeomag,0) // Filter for MC particles, by geomagnetic field
Note:
See TracChangeset
for help on using the changeset viewer.