Changeset 5007 for trunk/MagicSoft/Mars/mhbase
- Timestamp:
- 09/14/04 17:00:14 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MH.cc
r5003 r5007 1181 1181 const Int_t size = array.GetSize(); 1182 1182 1183 TH1I *h1=0; 1184 1185 //check if histogram with identical name exist 1186 TObject *h1obj = gROOT->FindObject(name); 1187 if (h1obj && h1obj->InheritsFrom("TH1I")) 1188 { 1189 h1 = (TH1I*)h1obj; 1190 h1->Reset(); 1191 } 1192 1183 1193 Double_t min = size>0 ? array[0] : 0; 1184 1194 Double_t max = size>0 ? array[0] : 1; … … 1193 1203 Int_t newbins = 0; 1194 1204 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1195 1196 TH1I *h1 = new TH1I(name, title, nbins, min, max); 1197 h1->SetXTitle(""); 1198 h1->SetYTitle("Counts"); 1199 h1->SetDirectory(NULL); 1205 1206 if (!h1) 1207 { 1208 h1 = new TH1I(name, title, nbins, min, max); 1209 h1->SetXTitle(""); 1210 h1->SetYTitle("Counts"); 1211 h1->SetDirectory(gROOT); 1212 } 1200 1213 1201 1214 // Second loop to fill the histogram … … 1217 1230 Double_t max = size>0 ? array[0] : 1; 1218 1231 1232 TH1I *h1=0; 1233 1234 //check if histogram with identical name exist 1235 TObject *h1obj = gROOT->FindObject(name); 1236 if (h1obj && h1obj->InheritsFrom("TH1I")) 1237 { 1238 h1 = (TH1I*)h1obj; 1239 h1->Reset(); 1240 } 1241 1219 1242 // first loop over array to find the min and max 1220 1243 for (Int_t i=1; i<size;i++) … … 1227 1250 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1228 1251 1229 TH1I *h1 = new TH1I(name, title, newbins, min, max); 1230 h1->SetXTitle(""); 1231 h1->SetYTitle("Counts"); 1232 h1->SetDirectory(NULL); 1233 1252 if (!h1) 1253 { 1254 h1 = new TH1I(name, title, newbins, min, max); 1255 h1->SetXTitle(""); 1256 h1->SetYTitle("Counts"); 1257 h1->SetDirectory(gROOT); 1258 } 1259 1234 1260 // Second loop to fill the histogram 1235 1261 for (Int_t i=0;i<size;i++) … … 1246 1272 const char* name, const char* title) 1247 1273 { 1248 const TArrayF arr(array.GetSize(), array.GetArray()); 1249 return ProjectArray(arr, nbins, name, title); 1274 return ProjectArray(TArrayF(array.GetSize(),array.GetArray()), nbins, name, title); 1250 1275 } 1251 1276 … … 1256 1281 TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title) 1257 1282 { 1258 const TArrayD arr(array.GetSize(), array.GetArray()); 1259 return ProjectArray(arr, nbins, name, title); 1283 return ProjectArray(TArrayD(array.GetSize(),array.GetArray()), nbins, name, title); 1260 1284 } 1261 1285
Note:
See TracChangeset
for help on using the changeset viewer.