Changeset 4956 for trunk/MagicSoft
- Timestamp:
- 09/12/04 20:47:28 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r4955 r4956 33 33 * mbase/BaseLinkDef.h 34 34 - new class analogously to MArrayD 35 36 * mhbase/MH.[h,cc] 37 - added functions ProjectArray(MArrayD,...) 38 and ProjectArray(MArrayF,...) 35 39 36 40 -
trunk/MagicSoft/Mars/mhbase/MH.cc
r4895 r4956 73 73 #include "MBinning.h" 74 74 75 #include "MArrayD.h" 76 #include "MArrayF.h" 77 75 78 ClassImp(MH); 76 79 … … 1142 1145 // M.Gaug added this withouz Documentation 1143 1146 // 1144 TH1I* MH::ProjectArray(const TArrayF &array, Int_t nbins, const char* name, const char* title) 1147 TH1I* MH::ProjectArray(const TArrayF &array, Int_t nbins, 1148 const char* name, const char* title) 1145 1149 { 1146 1150 const Int_t size = array.GetSize(); … … 1229 1233 } 1230 1234 1235 // -------------------------------------------------------------------------- 1236 // 1237 // M.Gaug added this withouz Documentation 1238 // 1239 TH1I* MH::ProjectArray(const MArrayF &array, Int_t nbins, 1240 const char* name, const char* title) 1241 { 1242 const Int_t size = array.GetSize(); 1243 1244 TH1I *h1=0; 1245 1246 //check if histogram with identical name exist 1247 TObject *h1obj = gROOT->FindObject(name); 1248 if (h1obj && h1obj->InheritsFrom("TH1I")) 1249 { 1250 h1 = (TH1I*)h1obj; 1251 h1->Reset(); 1252 } 1253 1254 Double_t min = size>0 ? array[0] : 0; 1255 Double_t max = size>0 ? array[0] : 1; 1256 1257 // first loop over array to find the min and max 1258 for (Int_t i=1; i<size;i++) 1259 { 1260 max = TMath::Max((Double_t)array[i], max); 1261 min = TMath::Min((Double_t)array[i], min); 1262 } 1263 1264 Int_t newbins = 0; 1265 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1266 1267 if (!h1) 1268 { 1269 h1 = new TH1I(name, title, nbins, min, max); 1270 h1->SetXTitle(""); 1271 h1->SetYTitle("Counts"); 1272 h1->SetDirectory(gROOT); 1273 } 1274 1275 // Second loop to fill the histogram 1276 for (Int_t i=0;i<size;i++) 1277 h1->Fill(array[i]); 1278 1279 return h1; 1280 } 1281 1282 // -------------------------------------------------------------------------- 1283 // 1284 // M.Gaug added this withouz Documentation 1285 // 1286 TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title) 1287 { 1288 const Int_t size = array.GetSize(); 1289 TH1I *h1=0; 1290 1291 //check if histogram with identical name exist 1292 TObject *h1obj = gROOT->FindObject(name); 1293 if (h1obj && h1obj->InheritsFrom("TH1I")) 1294 { 1295 h1 = (TH1I*)h1obj; 1296 h1->Reset(); 1297 } 1298 1299 Double_t min = size>0 ? array[0] : 0; 1300 Double_t max = size>0 ? array[0] : 1; 1301 1302 // first loop over array to find the min and max 1303 for (Int_t i=1; i<size;i++) 1304 { 1305 max = TMath::Max(array[i], max); 1306 min = TMath::Min(array[i], min); 1307 } 1308 1309 Int_t newbins = 0; 1310 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1311 1312 if (!h1) 1313 { 1314 h1 = new TH1I(name, title, newbins, min, max); 1315 h1->SetXTitle(""); 1316 h1->SetYTitle("Counts"); 1317 h1->SetDirectory(gROOT); 1318 } 1319 1320 // Second loop to fill the histogram 1321 for (Int_t i=0;i<size;i++) 1322 h1->Fill(array[i]); 1323 1324 return h1; 1325 } 1326 -
trunk/MagicSoft/Mars/mhbase/MH.h
r3156 r4956 14 14 class TArrayF; 15 15 class TArrayD; 16 class MArrayF; 17 class MArrayD; 16 18 class TCanvas; 17 19 … … 96 98 static TH1I* ProjectArray(const TArrayD &array, Int_t nbins=30, 97 99 const char* name="ProjectArray", const char* title="Projected Array"); 100 static TH1I* ProjectArray(const MArrayF &array, Int_t nbins=30, 101 const char* name="ProjectArray", const char* title="Projected Array"); 102 static TH1I* ProjectArray(const MArrayD &array, Int_t nbins=30, 103 const char* name="ProjectArray", const char* title="Projected Array"); 98 104 99 105 static void ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin=-1, Int_t lastybin=9999);
Note:
See TracChangeset
for help on using the changeset viewer.