Changeset 1057 in Sophya for trunk/SophyaPI/PIext/pawexecut.cc
- Timestamp:
- Jul 7, 2000, 10:50:03 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/pawexecut.cc
r1054 r1057 58 58 59 59 kw = "h/integ"; 60 usage = "Integrate a 1D histogram or profile";60 usage = "Integrate a 1D histogram"; 61 61 usage += "\n h/integ nameh1d [norm]"; 62 usage += "\n Related commands: h/deriv"; 62 usage += "\n Related commands: h/deriv"; 63 63 piac->RegisterCommand(kw,usage,this,hgrp); 64 64 65 65 kw = "h/deriv"; 66 usage = "Derivate a 1D histogram or profile";66 usage = "Derivate a 1D histogram"; 67 67 usage += "\n h/deriv nameh1d"; 68 usage += "\n Related commands: h/integ"; 68 usage += "\n Related commands: h/integ"; 69 69 piac->RegisterCommand(kw,usage,this,hgrp); 70 70 71 71 kw = "h/rebin"; 72 72 usage = "Rebin a 1D histogram or profile"; 73 usage += "\n h/rebin n bin";73 usage += "\n h/rebin nameh1d nbin"; 74 74 piac->RegisterCommand(kw,usage,this,hgrp); 75 75 76 76 kw = "h/cadd"; 77 77 usage = "Add a constant to an histogram"; 78 usage += "\n h/cadd val";78 usage += "\n h/cadd namehisto val"; 79 79 usage += "\n Related commands: h/cmult h/oper"; 80 80 piac->RegisterCommand(kw,usage,this,hgrp); … … 82 82 kw = "h/cmult"; 83 83 usage = "Multiply an histogram by a constant"; 84 usage += "\n h/cmult val";84 usage += "\n h/cmult namehisto val"; 85 85 usage += "\n Related commands: h/cadd h/oper"; 86 86 piac->RegisterCommand(kw,usage,this,hgrp); … … 285 285 double norm = 1.; 286 286 if(tokens.size()>=2) norm = atof(tokens[1].c_str()); 287 // attention: dynamic_cast<Histo*>(HProf)=Vrai! 287 288 Histo* h1 = dynamic_cast<Histo*>(mobj); 288 // Le HProf se fait tout seul avec Histo: dynamic_cast<Histo*>(HProf)=Vrai! 289 //HProf* hp = dynamic_cast<HProf*>(mobj); 290 if(h1) h1->HInteg(norm);291 //else if(hp) hp->HInteg(norm); 292 else cout<<"PAWExecutor::h_integ Error: "<<tokens[0]<<" not an Histo/HProf"<<endl;289 HProf* hp = dynamic_cast<HProf*>(mobj); 290 if(hp || !h1) 291 {cout<<"PAWExecutor::h_integ Error: "<<tokens[0]<<" not an Histo"<<endl; 292 return;} 293 h1->HInteg(norm); 293 294 } 294 295 … … 304 305 {cout<<"PAWExecutor::h_deriv Error: unknow object"<<tokens[0]<<endl; 305 306 return;} 307 // attention: dynamic_cast<Histo*>(HProf)=Vrai! 306 308 Histo* h1 = dynamic_cast<Histo*>(mobj); 307 //HProf* hp = dynamic_cast<HProf*>(mobj); 308 if(h1) h1->HDeriv(); 309 //else if(hp) hp->HDeriv(); 310 else cout<<"PAWExecutor::h_deriv Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; 309 HProf* hp = dynamic_cast<HProf*>(mobj); 310 if(hp || !h1) 311 {cout<<"PAWExecutor::h_deriv Error: "<<tokens[0]<<" not an Histo"<<endl; 312 return;} 313 h1->HDeriv(); 311 314 } 312 315 … … 324 327 int nbin = atoi(tokens[1].c_str()); 325 328 Histo* h1 = dynamic_cast<Histo*>(mobj); 326 //HProf* hp = dynamic_cast<HProf*>(mobj); 327 if(h1) h1->HRebin(nbin); 328 //else if(hp) hp->HRebin(nbin); 329 else cout<<"PAWExecutor::h_rebin Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; 329 HProf* hp = dynamic_cast<HProf*>(mobj); 330 if(hp || !h1) 331 {cout<<"PAWExecutor::h_rebin Error: "<<tokens[0]<<" not an Histo"<<endl; 332 return;} 333 h1->HRebin(nbin); 330 334 } 331 335 … … 343 347 double val = atof(tokens[1].c_str()); 344 348 Histo* h1 = dynamic_cast<Histo*>(mobj); 349 HProf* hp = dynamic_cast<HProf*>(mobj); 345 350 Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); 346 if(h1 )*h1 += val;347 else if(h2) *h2 += val;348 else cout<<"PAWExecutor::h_cadd Error: "<<tokens[0]<<" not an Histo/H Prof/Histo2D"<<endl;351 if(h1 && !hp) *h1 += val; 352 else if(h2) *h2 += val; 353 else cout<<"PAWExecutor::h_cadd Error: "<<tokens[0]<<" not an Histo/Histo2D"<<endl; 349 354 } 350 355 … … 362 367 double val = atof(tokens[1].c_str()); 363 368 Histo* h1 = dynamic_cast<Histo*>(mobj); 369 HProf* hp = dynamic_cast<HProf*>(mobj); 364 370 Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); 365 if(h1 )*h1 *= val;366 else if(h2) *h2 *= val;371 if(h1 && !hp) *h1 *= val; 372 else if(h2) *h2 *= val; 367 373 else cout<<"PAWExecutor::h_cmult Error: "<<tokens[0] 368 <<" not an Histo/H Prof/Histo2D"<<endl;374 <<" not an Histo/Histo2D"<<endl; 369 375 } 370 376 … … 376 382 // hres = h1 @ h2 with @ = (+,-,*,/) 377 383 { 378 cout<<"*** WARNING *** Not Tested, Do Not Use (cmv) !"<<endl;379 cerr<<"*** WARNING *** Not Tested, Do Not Use (cmv) !"<<endl;380 384 if(tokens.size()<4) 381 385 {cout<<"Usage: n/oper @ h1 h2 hres with @=(+,-,*,/)"<<endl; … … 406 410 <<" not implemented for HProf"<<endl; return;} 407 411 if( dynamic_cast<HProf*>(mobjh2) == NULL ) 408 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2 412 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" 409 413 <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; 410 414 return;} … … 420 424 h3 = dynamic_cast<HProf*>(mobjh3); 421 425 if(h3 == NULL) // ce n'est pas un HProf 422 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3 426 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" 423 427 <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; 424 428 return;} … … 426 430 {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 " 427 431 <<h1->NBins()<<" "<<h3->NBins()<<endl; return;} 428 h3->Zero();429 432 *h3 = *h1 + *h2; 430 433 h3->UpdateHisto(); … … 434 437 } else if( dynamic_cast<Histo*>(mobjh1) != NULL ) { 435 438 if( dynamic_cast<Histo*>(mobjh2) == NULL ) 436 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2 439 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" 437 440 <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; 438 441 return;} … … 448 451 h3 = dynamic_cast<Histo*>(mobjh3); 449 452 if(h3 == NULL) // ce n'est pas un Histo 450 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3 453 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" 451 454 <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; 452 455 return;} … … 454 457 {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 " 455 458 <<h1->NBins()<<" "<<h3->NBins()<<endl; return;} 456 h3->Zero();457 459 if( oper[0]=='+') *h3 = *h1 + *h2; 458 460 else if( oper[0]=='-') *h3 = *h1 - *h2; … … 464 466 } else if( dynamic_cast<Histo2D*>(mobjh1) != NULL ) { 465 467 if( dynamic_cast<Histo2D*>(mobjh2) == NULL ) 466 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2 468 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" 467 469 <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; 468 470 return;} … … 479 481 h3 = dynamic_cast<Histo2D*>(mobjh3); 480 482 if(h3 == NULL) // ce n'est pas un Histo2D 481 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3 483 {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" 482 484 <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; 483 485 return;} … … 486 488 <<h1->NBinX()<<","<<h1->NBinY()<<" " 487 489 <<h3->NBinX()<<","<<h3->NBinY()<<endl; return;} 488 h3->Zero();489 490 if( oper[0]=='+') *h3 = *h1 + *h2; 490 491 else if( oper[0]=='-') *h3 = *h1 - *h2; … … 495 496 // Doesn't work for other objects 496 497 } else { 497 cout<<"PAWExecutor::h_oper Error: not implemented for "<<typeid(*mobjh1).name()<<endl; 498 cout<<"PAWExecutor::h_oper Error: not implemented for " 499 <<typeid(*mobjh1).name()<<endl; 498 500 return; 499 501 }
Note:
See TracChangeset
for help on using the changeset viewer.