Changeset 1057 in Sophya


Ignore:
Timestamp:
Jul 7, 2000, 10:50:03 AM (25 years ago)
Author:
ercodmgr
Message:

cmv 7/7/2000

nomhistadapter.cc :

GetCopyObj() on fait un UpdateHisto() si c'est un HProf

servnobjm.cc :

ProjectHProf() on fait un UpdateHisto()

pihisto.cc :

Draw() on fait un UpdateHisto() si c'est un HProf

pawexecut.cc :

h/integ, h/deriv, h/rebin, h/cadd, h/cmult NON valable pour un HProf
h/oper teste et h3->Zero() ENLEVE pour permettre

h/oper @ h1 h3 h3
h/oper @ h3 h3 h3 ... etc...

cmv 7/7/2000

Location:
trunk/SophyaPI/PIext
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r719 r1057  
    3939{
    4040HProf * hp = dynamic_cast<HProf *>(mHis);
    41 if (hp == NULL)   return( new Histo(*mHis) );
    42 else return( new HProf(*hp) );
     41if (hp == NULL) return( new Histo(*mHis) );
     42// C'est un HProf, il faut l'updater si on le copie
     43//   car seule la partie "Histo" est copiee!
     44if( !(hp->IsOk()) ) hp->UpdateHisto();
     45return( new HProf(*hp) );
    4346}
    4447
  • trunk/SophyaPI/PIext/pawexecut.cc

    r1054 r1057  
    5858
    5959kw = "h/integ";
    60 usage = "Integrate a 1D histogram or profile";
     60usage = "Integrate a 1D histogram";
    6161usage += "\n h/integ nameh1d [norm]";
    62 usage += "\n  Related commands: h/deriv"; 
     62usage += "\n  Related commands: h/deriv";
    6363piac->RegisterCommand(kw,usage,this,hgrp);
    6464
    6565kw = "h/deriv";
    66 usage = "Derivate a 1D histogram or profile";
     66usage = "Derivate a 1D histogram";
    6767usage += "\n h/deriv nameh1d";
    68 usage += "\n  Related commands: h/integ"; 
     68usage += "\n  Related commands: h/integ";
    6969piac->RegisterCommand(kw,usage,this,hgrp);
    7070
    7171kw = "h/rebin";
    7272usage = "Rebin a 1D histogram or profile";
    73 usage += "\n h/rebin nbin";
     73usage += "\n h/rebin nameh1d nbin";
    7474piac->RegisterCommand(kw,usage,this,hgrp);
    7575
    7676kw = "h/cadd";
    7777usage = "Add a constant to an histogram";
    78 usage += "\n h/cadd val";
     78usage += "\n h/cadd namehisto val";
    7979usage += "\n  Related commands: h/cmult h/oper"; 
    8080piac->RegisterCommand(kw,usage,this,hgrp);
     
    8282kw = "h/cmult";
    8383usage = "Multiply an histogram by a constant";
    84 usage += "\n h/cmult val";
     84usage += "\n h/cmult namehisto val";
    8585usage += "\n  Related commands: h/cadd h/oper"; 
    8686piac->RegisterCommand(kw,usage,this,hgrp);
     
    285285double norm = 1.;
    286286if(tokens.size()>=2) norm = atof(tokens[1].c_str());
     287// attention: dynamic_cast<Histo*>(HProf)=Vrai!
    287288Histo* 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;
     289HProf* hp = dynamic_cast<HProf*>(mobj);
     290if(hp || !h1)
     291  {cout<<"PAWExecutor::h_integ Error: "<<tokens[0]<<" not an Histo"<<endl;
     292  return;}
     293h1->HInteg(norm);
    293294}
    294295
     
    304305  {cout<<"PAWExecutor::h_deriv Error: unknow object"<<tokens[0]<<endl;
    305306  return;}
     307// attention: dynamic_cast<Histo*>(HProf)=Vrai!
    306308Histo* 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;
     309HProf* hp = dynamic_cast<HProf*>(mobj);
     310if(hp || !h1)
     311  {cout<<"PAWExecutor::h_deriv Error: "<<tokens[0]<<" not an Histo"<<endl;
     312  return;}
     313h1->HDeriv();
    311314}
    312315
     
    324327int nbin = atoi(tokens[1].c_str());
    325328Histo* 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;
     329HProf* hp = dynamic_cast<HProf*>(mobj);
     330if(hp || !h1)
     331  {cout<<"PAWExecutor::h_rebin Error: "<<tokens[0]<<" not an Histo"<<endl;
     332  return;}
     333h1->HRebin(nbin);
    330334}
    331335
     
    343347double val = atof(tokens[1].c_str());
    344348Histo*   h1 = dynamic_cast<Histo*>(mobj);
     349HProf*   hp = dynamic_cast<HProf*>(mobj);
    345350Histo2D* 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/HProf/Histo2D"<<endl;
     351if(h1 && !hp) *h1 += val;
     352else if(h2)   *h2 += val;
     353else cout<<"PAWExecutor::h_cadd Error: "<<tokens[0]<<" not an Histo/Histo2D"<<endl;
    349354}
    350355
     
    362367double val = atof(tokens[1].c_str());
    363368Histo*   h1 = dynamic_cast<Histo*>(mobj);
     369HProf*   hp = dynamic_cast<HProf*>(mobj);
    364370Histo2D* h2 = dynamic_cast<Histo2D*>(mobj);
    365 if(h1)      *h1 *= val;
    366 else if(h2) *h2 *= val;
     371if(h1 && !hp) *h1 *= val;
     372else if(h2)   *h2 *= val;
    367373else cout<<"PAWExecutor::h_cmult Error: "<<tokens[0]
    368          <<" not an Histo/HProf/Histo2D"<<endl;
     374         <<" not an Histo/Histo2D"<<endl;
    369375}
    370376
     
    376382// hres = h1 @ h2    with @ = (+,-,*,/)
    377383{
    378 cout<<"*** WARNING *** Not Tested, Do Not Use (cmv) !"<<endl;
    379 cerr<<"*** WARNING *** Not Tested, Do Not Use (cmv) !"<<endl;
    380384if(tokens.size()<4)
    381385  {cout<<"Usage: n/oper @ h1 h2 hres with @=(+,-,*,/)"<<endl;
     
    406410          <<" not implemented for HProf"<<endl; return;}
    407411  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"
    409413         <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl;
    410414    return;}
     
    420424    h3 = dynamic_cast<HProf*>(mobjh3);
    421425    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"
    423427           <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl;
    424428      return;}
     
    426430      {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 "
    427431           <<h1->NBins()<<" "<<h3->NBins()<<endl; return;}
    428     h3->Zero();
    429432    *h3 = *h1 + *h2;
    430433    h3->UpdateHisto();
     
    434437} else if( dynamic_cast<Histo*>(mobjh1) != NULL ) {
    435438  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"
    437440         <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl;
    438441    return;}
     
    448451    h3 = dynamic_cast<Histo*>(mobjh3);
    449452    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"
    451454           <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl;
    452455      return;}
     
    454457      {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 "
    455458           <<h1->NBins()<<" "<<h3->NBins()<<endl; return;}
    456     h3->Zero();
    457459    if( oper[0]=='+')      *h3 = *h1 + *h2;
    458460    else if( oper[0]=='-') *h3 = *h1 - *h2;
     
    464466} else if( dynamic_cast<Histo2D*>(mobjh1) != NULL ) {
    465467  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"
    467469         <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl;
    468470    return;}
     
    479481    h3 = dynamic_cast<Histo2D*>(mobjh3);
    480482    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"
    482484           <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl;
    483485      return;}
     
    486488           <<h1->NBinX()<<","<<h1->NBinY()<<"   "
    487489           <<h3->NBinX()<<","<<h3->NBinY()<<endl; return;}
    488     h3->Zero();
    489490    if( oper[0]=='+')      *h3 = *h1 + *h2;
    490491    else if( oper[0]=='-') *h3 = *h1 - *h2;
     
    495496// Doesn't work for other objects
    496497} 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;
    498500  return;
    499501}
  • trunk/SophyaPI/PIext/pihisto.cc

    r548 r1057  
    7676  if (!mHisto)  return; 
    7777
    78   if (mMrk != PI_NotDefMarker ||  ( typeid(*mHisto) == typeid(HProf) ) )  {
    79     // Marqeurs definis OU HBProf => marqueurs+Erreurs si il y en a
    80     if (mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
     78  if(mMrk != PI_NotDefMarker ||  (typeid(*mHisto) == typeid(HProf)) ) {
     79    // Marqeurs definis OU HProf => marqueurs+Erreurs si il y en a
     80    if(typeid(*mHisto) == typeid(HProf))
     81      { HProf* hp = (HProf*) mHisto; if(!(hp->IsOk())) hp->UpdateHisto();}
     82    if(mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
    8183    double x1,y1, x2,y2;
    8284    double bw = mHisto->BinWidth();
    83     for (int i=0; i<mHisto->NBins(); i++) {
     85    for(int i=0; i<mHisto->NBins(); i++) {
    8486      if(mHisto->Error(i)>0.) {
    8587        // barres d'erreur verticales
     
    100102    oktrace = true;
    101103  }
    102   if (mLAtt != PI_NotDefLineAtt) {
     104  if(mLAtt != PI_NotDefLineAtt) {
    103105    double x1,y1, x2, y2;
    104106    x1 = mHisto->BinLowEdge(0);
    105107    y1 = 0;
    106     for (int i=0; i<mHisto->NBins(); i++) {
     108    for(int i=0; i<mHisto->NBins(); i++) {
    107109      x2 = x1;
    108110      y2 = (*mHisto)(i);
     
    127129  }
    128130  // A faire a la fin - DrawStats change l'attribut de ligne
    129   if (stats) DrawStats(g);
     131  if(stats) DrawStats(g);
    130132}
    131133
  • trunk/SophyaPI/PIext/servnobjm.cc

    r584 r1057  
    591591  mOmg->AddObj(hprof, nomprof);
    592592  }
    593 hprof->UpdateHisto();
     593if(!(hprof->IsOk())) hprof->UpdateHisto();
    594594
    595595mOmg->DisplayObj(nomprof, dopt);
Note: See TracChangeset for help on using the changeset viewer.