Changeset 9312 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 02/10/09 20:00:10 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
r9308 r9312 91 91 // 92 92 MHCamEvent::MHCamEvent(const char *name, const char *title) 93 : fSum(NULL), fE vt(NULL), fType(0), fErrorSpread(kTRUE), fErrorRelative(kFALSE),93 : fSum(NULL), fErr(NULL), fEvt(NULL), fType(0), fErrorSpread(kTRUE), fErrorRelative(kFALSE), 94 94 fThreshold(0), fUseThreshold(0) 95 95 { … … 104 104 // 105 105 MHCamEvent::MHCamEvent(Int_t type, const char *name, const char *title) 106 : fSum(NULL), fE vt(NULL), fType(type), fErrorSpread(kTRUE), fErrorRelative(kFALSE),106 : fSum(NULL), fErr(NULL), fEvt(NULL), fType(type), fErrorSpread(kTRUE), fErrorRelative(kFALSE), 107 107 fThreshold(0), fUseThreshold(0) 108 108 { … … 120 120 if (fSum) 121 121 delete fSum; 122 } 123 124 Bool_t MHCamEvent::InitGeom(const MParList &plist) 125 { 126 MGeomCam *cam = (MGeomCam*)plist.FindObject(fNameGeom, "MGeomCam"); 127 if (!cam) 128 { 129 *fLog << err << fNameGeom << " [MGeomCam] not found... abort." << endl; 130 return kFALSE; 131 } 132 133 // combine name 134 const TString name = fNameEvt.IsNull() ? fName : fNameEvt; 135 136 fSum->SetGeometry(*cam, name+";avg"); 137 if (fTitle!=gsDefTitle) 138 fSum->SetTitle(fTitle); 139 if (!fTitle.Contains(";")) 140 fSum->SetYTitle("a.u."); 141 142 if (fErr) 143 fErr->SetGeometry(*fSum->GetGeometry(), fErr->GetName(), fErr->GetTitle()); 144 145 return kTRUE; 122 146 } 123 147 … … 142 166 } 143 167 144 MGeomCam *cam = (MGeomCam*)plist->FindObject(fNameGeom, "MGeomCam"); 145 if (!cam) 146 { 147 *fLog << err << fNameGeom << " [MGeomCam] not found... abort." << endl; 168 fSum->Reset(); 169 170 fNumReInit = 0; 171 172 if (!InitGeom(*plist)) 148 173 return kFALSE; 149 } 150 151 // combine name 152 const TString name = fNameEvt.IsNull() ? fName : fNameEvt; 153 154 fSum->Reset(); 155 fSum->SetGeometry(*cam, name+";avg"); 156 157 if (fTitle!=gsDefTitle) 158 fSum->SetTitle(fTitle); 159 if (!fTitle.Contains(";")) 160 fSum->SetYTitle("a.u."); 174 161 175 if (fUseThreshold!=kCollectMin && fUseThreshold!=kCollectMax) 162 176 fSum->SetBit(MHCamera::kProfile); … … 169 183 // -------------------------------------------------------------------------- 170 184 // 185 // The geometry read from the RunHeaders might have changed. This does not 186 // effect anything in PreProcess. So we set a new geometry. We don't move 187 // this away from PreProcess to support also loops without calling ReInit. 188 // 189 Bool_t MHCamEvent::ReInit(MParList *plist) 190 { 191 return fNumReInit++==0 ? InitGeom(*plist) : kTRUE; 192 } 193 194 195 // -------------------------------------------------------------------------- 196 // 171 197 // Fill the histograms with data from a MCamEvent-Container. 172 198 // … … 250 276 } 251 277 278 TString MHCamEvent::Format(const char *ext) const 279 { 280 TString n = fSum->GetName(); 281 282 const Ssiz_t pos = n.Last(';'); 283 if (pos<0) 284 return ""; 285 286 n = n(0, pos); 287 n += ";"; 288 n += ext; 289 return n; 290 } 291 252 292 void MHCamEvent::Paint(Option_t *) 253 293 { … … 255 295 256 296 pad->cd(2); 257 if (gPad->FindObject( MString::Format("%s;proj", fName.Data())))258 { 259 TH1 *h=fSum->Projection( MString::Format("%s;proj", fName.Data()));297 if (gPad->FindObject(Format("proj"))) 298 { 299 TH1 *h=fSum->Projection(Format("proj")); 260 300 if (h->GetMaximum()>0) 261 301 gPad->SetLogy(); … … 263 303 264 304 pad->cd(5); 265 if (gPad->FindObject( MString::Format("%s;rad", fName.Data())))266 fSum->RadialProfile( MString::Format("%s;rad", fName.Data()));305 if (gPad->FindObject(Format("rad"))) 306 fSum->RadialProfile(Format("rad")); 267 307 268 308 pad->cd(6); 269 if (gPad->FindObject( MString::Format("%s;az", fName.Data())))270 fSum->AzimuthProfile( MString::Format("%s;az", fName.Data()));309 if (gPad->FindObject(Format("az"))) 310 fSum->AzimuthProfile(Format("az")); 271 311 272 312 pad->cd(4); 273 313 gPad->cd(1); 274 MHCamera *cam = (MHCamera*)gPad->FindObject( MString::Format("%s;err", fName.Data()));314 MHCamera *cam = (MHCamera*)gPad->FindObject(Format("err")); 275 315 if (cam) 276 316 cam->SetCamContent(*fSum, fErrorRelative ? 1 : 2); … … 300 340 p->Draw(); 301 341 p->cd(); 302 TH1 *h = fSum->Projection( MString::Format("%s;proj", fName.Data()), 50);342 TH1 *h = fSum->Projection(Format("proj"), 50); 303 343 h->SetTitle("Projection"); 304 344 h->SetBit(kCanDelete); … … 328 368 e += "/v_{i}"; 329 369 330 MHCamera *cam = new MHCamera(*fSum->GetGeometry()); 331 cam->SetName(MString::Format("%s;err", fName.Data())); 332 cam->SetTitle(e); 333 cam->SetYTitle(fSum->GetYaxis()->GetTitle()); 334 cam->SetCamContent(*fSum, fErrorRelative ? 1 : 2); 335 cam->SetBit(kCanDelete); 336 cam->Draw(); 370 fErr = new MHCamera(*fSum->GetGeometry()); 371 fErr->SetName(Format("err")); 372 fErr->SetTitle(e); 373 fErr->SetYTitle(fSum->GetYaxis()->GetTitle()); 374 fErr->SetCamContent(*fSum, fErrorRelative ? 1 : 2); 375 fErr->SetBit(kMustCleanup); 376 fErr->SetBit(kCanDelete); 377 fErr->Draw(); 337 378 338 379 pad->cd(); … … 343 384 p->Draw(); 344 385 p->cd(); 345 h = (TH1*)fSum->RadialProfile( MString::Format("%s;rad", fName.Data()), 20);386 h = (TH1*)fSum->RadialProfile(Format("rad"), 20); 346 387 h->SetTitle("Radial Profile"); 347 388 h->SetBit(kCanDelete|TH1::kNoStats); … … 355 396 p->Draw(); 356 397 p->cd(); 357 h = (TH1*)fSum->AzimuthProfile( MString::Format("%s;az", fName.Data()), 30);398 h = (TH1*)fSum->AzimuthProfile(Format("az"), 30); 358 399 h->SetTitle("Azimuth Profile"); 359 400 h->SetBit(kCanDelete|TH1::kNoStats); … … 361 402 } 362 403 404 405 void MHCamEvent::RecursiveRemove(TObject *obj) 406 { 407 if (obj==fErr) 408 fErr = 0; 409 } -
trunk/MagicSoft/Mars/mhist/MHCamEvent.h
r9308 r9312 17 17 protected: 18 18 MHCamera *fSum; // storing the sum 19 MHCamera *fErr; //! storing the err 19 20 MCamEvent *fEvt; //! the current event 20 21 … … 29 30 Char_t fUseThreshold; // Use a threshold? Which direction has it? 30 31 31 void Init(const char *name, const char *title); 32 Int_t fNumReInit; //! 33 34 TString Format(const char *ext) const; 35 36 void Init(const char *name, const char *title); 37 Bool_t InitGeom(const MParList &plist); 32 38 33 39 Bool_t SetupFill(const MParList *pList); 40 Bool_t ReInit(MParList *plist); 34 41 Int_t Fill(const MParContainer *par, const Stat_t w=1); 35 42 … … 62 69 void SetErrorRelative(Bool_t b=kTRUE) { fErrorRelative = b; } 63 70 71 void RecursiveRemove(TObject *obj); 72 64 73 ClassDef(MHCamEvent, 2) // Histogram to sum camera events 65 74 };
Note:
See TracChangeset
for help on using the changeset viewer.