[mugen] fix front/back bodydist

[mugen] fix front/back bodydist

git-svn-id: 39e099a8ed5324aded674b764a67f7a08796d9a7@7027 662fdd30-d327-0410-a531-f549c87e1e9e

--- src/mugen/compiler.cpp
+++ src/mugen/compiler.cpp
@@ -952,14 +952,15 @@
             return new Facing();
         }

-        if (identifier == "backedgebodydist" ||
-            identifier == "backedgedist"){
+        if (identifier == "backedgebodydist"){
             class BackEdgeBodyDist: public Value {
             public:
                 RuntimeValue evaluate(const Environment & environment) const {
                     int x = environment.getCharacter().getBackX();
-                    return RuntimeValue(PaintownUtil::min(x - environment.getStage().maximumLeft(),
-                                                          environment.getStage().maximumRight() - x));
+                    switch (environment.getCharacter().getFacing()){
+                        case FacingRight: return x - environment.getStage().maximumLeft();
+                        case FacingLeft: return environment.getStage().maximumRight() - x;
+                    }
                 }

                 Value * copy() const {
@@ -970,24 +971,36 @@
             return new BackEdgeBodyDist();
         }

-        /*
         if (identifier == "backedgedist"){
             class BackEdgeDist: public Value {
             public:
                 RuntimeValue evaluate(const Environment & environment) const {
-                }
-            };
-        }
-        */
-
-        if (identifier == "frontedgebodydist" ||
-            identifier == "frontedgedist"){
+                    int x = environment.getCharacter().getX();
+                    /* FIXME: handle screenbound in case maximumLeft/Right don't */
+                    switch (environment.getCharacter().getFacing()){
+                        case FacingRight: return x - environment.getStage().maximumLeft();
+                        case FacingLeft: return environment.getStage().maximumRight() - x;
+
+                    }
+                }
+
+                Value * copy() const {
+                    return new BackEdgeDist();
+                }
+            };
+
+            return new BackEdgeDist();
+        }
+
+        if (identifier == "frontedgebodydist"){
             class FrontEdgeBodyDist: public Value {
             public:
                 RuntimeValue evaluate(const Environment & environment) const {
                     int x = environment.getCharacter().getFrontX();
-                    return RuntimeValue(PaintownUtil::min(x - environment.getStage().maximumLeft(),
-                                                          environment.getStage().maximumRight() - x));
+                    switch (environment.getCharacter().getFacing()){
+                        case FacingLeft: return x - environment.getStage().maximumLeft();
+                        case FacingRight: return environment.getStage().maximumRight() - x;
+                    }
                 }

                 Value * copy() const {
@@ -996,6 +1009,25 @@
             };

             return new FrontEdgeBodyDist();
+        }
+
+        if (identifier == "frontedgedist"){
+            class FrontEdgeDist: public Value {
+            public:
+                RuntimeValue evaluate(const Environment & environment) const {
+                    int x = environment.getCharacter().getX();
+                    switch (environment.getCharacter().getFacing()){
+                        case FacingLeft: return x - environment.getStage().maximumLeft();
+                        case FacingRight: return environment.getStage().maximumRight() - x;
+                    }
+                }
+
+                Value * copy() const {
+                    return new FrontEdgeDist();
+                }
+            };
+
+            return new FrontEdgeDist();
         }

         if (identifier == "hitdefattr:state"){


check if locationId is 0

check if locationId is 0

--- src/node_ftdi.cc
+++ src/node_ftdi.cc
@@ -148,8 +148,7 @@
     if(args[0]->IsObject())
     {
         Local<Object> obj = args[0]->ToObject();
-
-        if(obj->Has(locationId))
+        if(obj->Has(locationId) && obj->Get(locationId)->Int32Value() != 0)
         {
             object->connectParams.connectId = obj->Get(locationId)->Int32Value();
             object->connectParams.connectType = ConnectType_ByLocationId;


control plots went to AliRICH

control plots went to AliRICH

--- RICH/menu.C
+++ RICH/menu.C
@@ -1,157 +1,11 @@
-AliRICH * R() {return r;}
-
-void ControlPlots()
-{
-  TH1F *pHxD,*pHyD,*pCqH1,*pCsH1,*pCqMipH1,*pCsMipH1,*pCqCerH1,*pCsCerH1,*pCqFeeH1,*pCsFeeH1,*pNumClusH1;
-  TH2F *pCmH2,*pCmMipH2,*pCmCerH2,*pCmFeeH2;
-
-  Bool_t isDig =!R()->GetLoader()->LoadDigits();
-  Bool_t isClus=!R()->GetLoader()->LoadRecPoints();
-
-  if(!isDig && !isClus){ Info("ControlPlots","No digits and clusters! Nothing to do.");return;}
-
-  TFile *pFile = new TFile("$(HOME)/ControlPlots.root","RECREATE");
-
-  if(isDig){
-    cout<<"Digits available\n";
-    pHxD=new TH1F("HitDigitDiffX","Hit-Digits diff X all chambers;diff [cm]",100,-10,10);
-    pHyD=new TH1F("HitDigitDiffY","Hit-Digits diff Y all chambers;diff [cm]",100,-10,10);
-  }//isDig
-
-  if(isClus){
-    cout<<"Clusters available\n";
-    pNumClusH1=new TH1F("NumClusPerEvent","Number of clusters per event;number",50,0,49);
-    pCqH1=new TH1F("ClusQ",   "Cluster Charge all chambers;q [QDC]",R()->P()->MaxQdc(),0,R()->P()->MaxQdc());
-    pCsH1=new TH1F("ClusSize","Cluster size all chambers;size [number of pads in cluster]",100,0,100);
-    pCmH2=new TH2F("ClusMap", "Cluster map;x [cm];y [cm]",1000,-R()->P()->PcSizeX()/2,R()->P()->PcSizeX()/2,
-                                                          1000,-R()->P()->PcSizeY()/2,R()->P()->PcSizeY()/2);
-
-    pCqMipH1=new TH1F("MipClusQ",   "MIP Cluster Charge all chambers;q [QDC]",R()->P()->MaxQdc(),0,R()->P()->MaxQdc());
-    pCsMipH1=new TH1F("MipClusSize","MIP Cluster size all chambers;size [number of pads in cluster]",100,0,100);
-    pCmMipH2=new TH2F("MipClusMap", "MIP Cluster map;x [cm];y [cm]",1000,-R()->P()->PcSizeX()/2,R()->P()->PcSizeX()/2,
-                                                                    1000,-R()->P()->PcSizeY()/2,R()->P()->PcSizeY()/2);
-
-    pCqCerH1=new TH1F("CerClusQ",   "Cerenkov Cluster Charge all chambers;q [QDC]",R()->P()->MaxQdc(),0,R()->P()->MaxQdc());
-    pCsCerH1=new TH1F("CerClusSize","Cernekov Cluster size all chambers;size [number of pads in cluster]",100,0,100);
-    pCmCerH2=new TH2F("CerClusMap", "Cerenkov Cluster map;x [cm];y [cm]",1000,-R()->P()->PcSizeX()/2,R()->P()->PcSizeX()/2,
-                                                                         1000,-R()->P()->PcSizeY()/2,R()->P()->PcSizeY()/2);
-
-    pCqFeeH1=new TH1F("FeeClusQ",   "Feedback Cluster Charge all chambers;q [QDC]",R()->P()->MaxQdc(),0,R()->P()->MaxQdc());
-    pCsFeeH1=new TH1F("FeeClusSize","Feedback Cluster size all chambers;size [number of pads in cluster]",100,0,100);
-    pCmFeeH2=new TH2F("FeeClusMap", "Feedback Cluster map;x [cm];y [cm]",1000,-R()->P()->PcSizeX()/2,R()->P()->PcSizeX()/2,
-                                                                         1000,-R()->P()->PcSizeY()/2,R()->P()->PcSizeY()/2);
-  }//isClus
-
-  for(Int_t iEvtN=0;iEvtN<R()->GetLoader()->GetRunLoader()->GetAliRun()->GetEventsPerRun();iEvtN++){//events loop
-    R()->GetLoader()->GetRunLoader()->GetEvent(iEvtN);
-    if(isClus) R()->GetLoader()->TreeR()->GetEntry(0);
-    if(isDig)  R()->GetLoader()->TreeD()->GetEntry(0);
-
-    for(Int_t iChamN=1;iChamN<=7;iChamN++){//chambers loop
-      if(isClus){
-        Int_t iNclusCham=R()->Clusters(iChamN)->GetEntries();
-        if(iNclusCham) pNumClusH1->Fill(iNclusCham);//fill total number of clusters for a given event
-        for(Int_t iClusN=0;iClusN<iNclusCham;iClusN++){//clusters loop
-          AliRICHcluster *pClus=(AliRICHcluster*)R()->Clusters(iChamN)->At(iClusN);
-                                      pCqH1->Fill(pClus->Q());   pCsH1->Fill(pClus->Size());   pCmH2->Fill(pClus->X(),pClus->Y());    //common
-           if(pClus->IsPureMip())     {pCqMipH1->Fill(pClus->Q());pCsMipH1->Fill(pClus->Size());pCmMipH2->Fill(pClus->X(),pClus->Y());}//Pure Mips
-           if(pClus->IsPureCerenkov()){pCqCerH1->Fill(pClus->Q());pCsCerH1->Fill(pClus->Size());pCmCerH2->Fill(pClus->X(),pClus->Y());}//Pure Photons
-           if(pClus->IsPureFeedback()){pCqFeeH1->Fill(pClus->Q());pCsFeeH1->Fill(pClus->Size());pCmFeeH2->Fill(pClus->X(),pClus->Y());}//Pure Feedbacks
-        }//clusters loop
-      }//isClus
-      if(isDig){
-        for(Int_t iDigN=0;iDigN<r->Digits(iChamN)->GetEntries();iDigN++){//digits loop
-          AliRICHdigit *pDig=(AliRICHdigit*)r->Digits(iChamN)->At(iDigN);
-          AliRICHhit   *pHit=hit(pDig->Tid(0));
-          TVector2 hitV2=R()->C(iChamN)->Glob2Loc(pHit->OutX3()); TVector2 digV2=R()->P()->Pad2Loc(pDig->X(),pDig->Y());
-          pHxD->Fill(hitV2.X()-digV2.X()); pHyD->Fill(hitV2.Y()-digV2.Y());
-        }//digits loop
-      }//isDig
-    }//chambers loop
-    Info("ControlPlots","Event %i processed.",iEvtN);
-  }//events loop
-
-  if(isDig)  R()->GetLoader()->UnloadDigits();
-  if(isClus) R()->GetLoader()->UnloadRecPoints();
-
-  pFile->Write(); delete pFile;
-}//void ControlPlots()
-//__________________________________________________________________________________________________
-void MainTrank()
-{
-  TStopwatch sw;TDatime time;
-  H_SD(); SD_D();   AliRICHClusterFinder *z=new AliRICHClusterFinder(r); z->Exec();//delete z;
-  cout<<"\nInfo in <MainTrank>: Start time: ";time.Print();
-    cout<<"Info in <MainTrank>: Stop  time: ";time.Set();  time.Print();
-    cout<<"Info in <MainTrank>: Time  used: ";sw.Print();
-}
-//__________________________________________________________________________________________________
-void sh()
-{//prints list of hits for a given event
-  R()->GetLoader()->LoadHits();
-
-  Int_t iTotalHits=0;
-  for(Int_t iPrimN=0;iPrimN<rl->TreeH()->GetEntries();iPrimN++){//prims loop
-    R()->GetLoader()->TreeH()->GetEntry(iPrimN);
-    R()->Hits()->Print();
-    iTotalHits+=R()->Hits()->GetEntries();
-  }
-  Info("sh","totally %i hits",iTotalHits);
-  R()->GetLoader()->UnloadHits();
-}
-//__________________________________________________________________________________________________
-AliRICHhit* hit(Int_t tid)
-{//print hits for given tid
-  R()->GetLoader()->LoadHits();
-  for(Int_t iPrimN=0;iPrimN<R()->GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
-    R()->GetLoader()->TreeH()->GetEntry(iPrimN);
-    for(Int_t iHitN=0;iHitN<R()->Hits()->GetEntries();iHitN++){
-      AliRICHhit *pHit=(AliRICHhit*)R()->Hits()->At(iHitN);
-      if(tid==pHit->Track()) {R()->GetLoader()->UnloadHits();return pHit;}
-    }//hits
-  }//prims loop
-  R()->GetLoader()->UnloadHits();
-}
-//__________________________________________________________________________________________________
-void ss()
-{
-  if(rl->LoadSDigits()) return;
-  rl->TreeS()->GetEntry(0);
-  r->SDigits()->Print();
-  Info("ss","totally %i sdigits",r->SDigits()->GetEntries());
-  rl->UnloadSDigits();
-}
-//__________________________________________________________________________________________________
-void sd()
-{
-  if(rl->LoadDigits()) return;
-  rl->TreeD()->GetEntry(0);
-  Int_t iTotalDigits=0;
-  for(int i=1;i<=7;i++){
-    r->Digits(i)->Print();
-    iTotalDigits+=r->Digits(i)->GetEntries();
-  }
-  Info("sd","totally %i digits",iTotalDigits);
-  rl->UnloadDigits();
-}
-//__________________________________________________________________________________________________
-void sc(Int_t iEvtN=0)
-{
-  Info("sc","List of clusters for event %i",iEvtN);
-  R()->GetLoader()->GetRunLoader()->GetEvent(iEvtN);
-  if(R()->GetLoader()->LoadRecPoints()) return;
-//  r->SetTreeAddress();
-  R()->GetLoader()->TreeR()->GetEntry(0);
-  Int_t iTotalClusters=0;
-  for(Int_t iChamber=1;iChamber<=7;iChamber++){
-    R()->Clusters(iChamber)->Print();
-    iTotalClusters+=R()->Clusters(iChamber)->GetEntries();
-  }
-  R()->GetLoader()->UnloadRecPoints();
-  Info("sc","totally %i clusters",iTotalClusters);
-}
-//__________________________________________________________________________________________________
-void sp(int tid)
+AliRICH * R()    {return r;}
+void ph(Int_t event=0) {R()->PrintHits(event);}    //utility print hits for 'event' event
+void ps(Int_t event=0) {R()->PrintSDigits(event);} //utility print sdigits
+void pd(Int_t event=0) {R()->PrintDigits(event);}  //utility print digits
+void pc(Int_t event=0) {R()->PrintClusters(event);}//utility print clusters
+
+//__________________________________________________________________________________________________
+void pp(int tid)
 {
   R()->GetLoader()->GetRunLoader()->LoadHeader();  R()->GetLoader()->GetRunLoader()->LoadKinematics();

@@ -223,54 +77,6 @@
 }
 //__________________________________________________________________________________________________

-void SD_D()
-{
-  Info("SD_D","Start.");
-  extern Int_t kBad;
-  R()->P()->GenSigmaThMap();
-  rl->LoadSDigits();
-
-  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
-    al->GetEvent(iEventN);    cout<<"Event "<<iEventN<<endl;
-    rl->MakeTree("D");      R()->MakeBranch("D"); //create TreeD with RICH branches
-    R()->ResetSDigits();    R()->ResetDigits();   //reset lists of sdigits and digits
-    rl->TreeS()->GetEntry(0);                        //get sdigits to memory container
-    R()->SDigits()->Sort();
-
-    Int_t combiPid=0,chamber=0,x=0,y=0,tid[3],id=0; Double_t q=0;
-    Int_t iNdigitsPerPad;//how many sdigits for a given pad
-    const int kBad=-101;//??? to be removed in code
-    for(Int_t i=0;i<R()->SDigits()->GetEntries();i++){//sdigits loop (sorted)
-      AliRICHdigit *pSdig=(AliRICHdigit*)R()->SDigits()->At(i);
-      if(pSdig->Id()==id){//still the same pad
-        iNdigitsPerPad++; q+=pSdig->Q();  combiPid+=pSdig->CombiPid();
-        if(iNdigitsPerPad<=3)
-          tid[iNdigitsPerPad-1]=pSdig->Tid(0);
-        else
-          Warning("SDigits2Digits","More then 3 sdigits for the given pad");
-      }else{//new pad, add the pevious one
-        if(id!=kBad&&R()->P()->IsOverTh(chamber,x,y,q)) {
-           R()->AddDigit(chamber,x,y,q,combiPid,tid);
-         }
-        combiPid=pSdig->CombiPid();chamber=pSdig->C();id=pSdig->Id();
-        x=pSdig->X();y=pSdig->Y();
-        q=pSdig->Q();
-        tid[0]=pSdig->Tid(0);
-        iNdigitsPerPad=1;tid[1]=tid[2]=kBad;
-      }
-    }//sdigits loop (sorted)
-
-    if(R()->SDigits()->GetEntries() && R()->P()->IsOverTh(chamber,x,y,q))
-      R()->AddDigit(chamber,x,y,q,combiPid,tid);//add the last digit
-
-    rl->TreeD()->Fill();
-    rl->WriteDigits("OVERWRITE");
-  }//events loop
-  rl->UnloadSDigits();     rl->UnloadDigits();
-  R()->ResetSDigits(); R()->ResetDigits();//reset lists of sdigits and digits
-  Info("SD_D","Stop.");
-}//SD_D()
-//__________________________________________________________________________________________________
 void Show()
 {
   cout<<endl;
@@ -315,12 +121,18 @@
     }
     cout<<endl;
   }//events loop
+
   rl->UnloadHits();
     if(isSdigits) rl->UnloadSDigits();
       if(isDigits) rl->UnloadDigits();
         if(isClusters) rl->UnloadRecPoints();
   al->UnloadHeader();
   al->UnloadKinematics();
+
+  TVector counters=r->Counters();
+
+  counters(9)=counters(0); for(Int_t i=1;i<=8;i++) counters(9)-=counters(i);
+  counters.Print();
   cout<<endl;
 }//void Show()
 //__________________________________________________________________________________________________
@@ -339,7 +151,7 @@
   if(gAlice) delete gAlice;
   if(!(al=AliRunLoader::Open("galice.root","AlicE","update"))){
     gSystem->Exec("rm -rf *.root *.dat");
-    Error("ReadAlice","galice.root broken, removing all this garbage then init new one");
+    Error("menu.C::ReadAlice","galice.root broken, removing all this garbage then init new one");
     new AliRun("gAlice","Alice experiment system");
     gAlice->SetDebug(-1);
     gAlice->Init("Config.C");
@@ -347,7 +159,7 @@
     return kFALSE;
   }
   al->LoadgAlice();
-  if(!gAlice) Fatal("ReadAlice","No gAlice in file");
+  if(!gAlice) Fatal("menu.C::ReadAlice","No gAlice in file");
   a=al->GetAliRun();
   a->SetDebug(0);
 //RICH
@@ -363,25 +175,23 @@
 {
   TCanvas *pC=new TCanvas("c","Amplification test",900,800);
   pC->Divide(1,2);
-  pC->cd(1);
-  TF1 *pF1=new TF1("f1",Gain,-70,70,1);  pF1->SetParameters(1,1);pF1->SetParNames("Sector");
-  TF1 *pF2=new TF1("f2",Gain,-70,70,1);  pF2->SetParameters(2,1);pF2->SetParNames("Sector");
-  pF1->Draw();pF2->Draw("same");
-
-  pC->cd(2);
+

   const Int_t nPoints=8;
-  THStack *pStack=new THStack("stack","photons");
+  THStack *pStackPhot=new THStack("StackPhot","photons");
+  THStack *pStackMip =new THStack("StackMip","mips");
   TLegend *pLeg=new TLegend(0.6,0.2,0.9,0.5,"legend");
-  TH1F *apH[nPoints];
-
-  Double_t starty=AliRICHParam::DeadZone()/2;
+  TH1F *apHphot[nPoints];
+  TH1F *apHmip[nPoints];
+
+  Double_t starty=0;
   Double_t deltay=AliRICHParam::SectorSizeY()/nPoints;

   for(int i=0;i<nPoints;i++){
-    apH[i]=new TH1F(Form("h%i",i),"Qdc for Photon;QDC;Counts",500,0,500); apH[i]->SetLineColor(i);
-    pStack->Add(apH[i]);
-    pLeg->AddEntry(apH[i],Form("@(0,%5.2f->%5.2f)",starty+i*deltay,starty+i*deltay-AliRICHParam::SectorSizeY()/2));
+    apHphot[i]=new TH1F(Form("hphot%i",i),"Qdc for Photon;QDC;Counts",500,0,500); apHphot[i]->SetLineColor(i);pStackPhot->Add(apHphot[i]);
+    apHmip[i] =new TH1F(Form("hmip%i",i),"Qdc for Mip;QDC;Counts",4000,0,4000);   apHmip[i]->SetLineColor(i);pStackMip->Add(apHmip[i]);
+
+    pLeg->AddEntry(apHphot[i],Form("@(10,%5.2f->%5.2f)",starty+i*deltay,starty+i*deltay-AliRICHParam::SectorSizeY()/2));
   }

@@ -389,12 +199,14 @@
 //  AliRICHParam::ResetWireSag();
   for(Int_t i=0;i<10000;i++){//events loop
     for(int j=0;j<nPoints;j++){
-      x2.Set(0,starty-j*deltay);
-      apH[j]->Fill(AliRICHParam::TotQdc(x2,0));
+      x2.Set(10,starty+j*deltay);
+      apHphot[j]->Fill(AliRICHParam::TotQdc(x2,0));
+      apHmip[j]->Fill(AliRICHParam::TotQdc(x2,gRandom->Landau(600,150)*1e-9));
     }
   }
-  pStack->Draw("nostack");
-  pLeg->Draw();
+
+  pC->cd(1);  pStackMip->Draw("nostack");
+  pC->cd(2);  pStackPhot->Draw("nostack"); pLeg->Draw();
 }//TestResponse()
 //__________________________________________________________________________________________________
 void TestSD()
@@ -420,103 +232,141 @@
 void TestC()
 {
   Info("TestC","Creating test clusters.");
-  rl->MakeTree("R");r->MakeBranch("R");
+  R()->GetLoader()->MakeTree("R");R()->MakeBranch("R");

   AliRICHcluster c;
   c.AddDigit(new AliRICHdigit(1,20,21,200,1,2,3));
   c.AddDigit(new AliRICHdigit(1,22,21,250,1,2,3));
   c.CoG();

-  r->AddCluster(c);
-
-  rl->TreeR()->Fill();
-  rl->WriteRecPoints("OVERWRITE");
-  rl->UnloadRecPoints();
-  r->ResetClusters();
+  R()->AddCluster(c);
+
+  R()->GetLoader()->TreeR()->Fill();  R()->GetLoader()->WriteRecPoints("OVERWRITE");
+  R()->GetLoader()->UnloadRecPoints();
+  R()->ResetClusters();

   Info("TestC","Stop.");
 }//TestC()
 //__________________________________________________________________________________________________
 void TestSeg()
 {
-  AliRICHParam *p=R()->P();
+  AliRICHParam p;
+
+  new TCanvas("name","PC segmentation");
+  gPad->Range(-20,-20,200,150);
+  AliRICHDisplFast::DrawSectors();
+
+  TLatex t; t.SetTextSize(0.02);
+  t.DrawLatex(p.PcSizeX()+10,120,Form("Pc  %6.2fx%6.2fcm %3ix%3ipads",p.PcSizeX()    ,p.PcSizeY(),    p.NpadsX()   ,p.NpadsY()));
+  t.DrawLatex(p.PcSizeX()+10,115,Form("Sec %6.2fx%5.2fcm %3ix%2ipads",p.SectorSizeX(),p.SectorSizeY(),p.NpadsXsec(),p.NpadsYsec()));
+  t.DrawLatex(p.PcSizeX()+10,110,Form("Pad %6.2fx%4.2fcm DeadZone %6.2fcm",p.PadSizeX()   ,p.PadSizeY(),p.DeadZone()));
+
+  TVector2 v2;
+  t.SetTextAlign(12);
+  v2=AliRICHParam::Pad2Loc( 1,24);  t.DrawText(v2.X(),v2.Y(),"sec 1");
+  v2=AliRICHParam::Pad2Loc(81,24);  t.DrawText(v2.X(),v2.Y(),"sec 2");
+  v2=AliRICHParam::Pad2Loc( 1,70);  t.DrawText(v2.X(),v2.Y(),"sec 3");
+  v2=AliRICHParam::Pad2Loc(81,70);  t.DrawText(v2.X(),v2.Y(),"sec 4");
+  v2=AliRICHParam::Pad2Loc( 1,120); t.DrawText(v2.X(),v2.Y(),"sec 5");
+  v2=AliRICHParam::Pad2Loc(81,120); t.DrawText(v2.X(),v2.Y(),"sec 6");
+
+//  TGaxis *pAx=new TGaxis(0,0,140,  0,0,140,510,"-="); pAx->SetTitle("x, cm"); pAx->SetTextSize(0.05); pAx->Draw();
+//  TGaxis *pAy=new TGaxis(0,0,  0,140,0,140,510,"-="); pAy->SetTitle("y, cm"); pAy->SetTextSize(0.05); pAy->Draw();
+
+
+  t.SetTextColor(kBlue);
+
   Int_t padx,pady,sec;
-  Double_t x,y;
-  Double_t eps=0.0000001;
-  Double_t x1=-0.5*p->PcSizeX()+eps; Double_t x2=-0.5*p->SectorSizeX()-p->DeadZone()-eps; Double_t x3=-0.5*p->SectorSizeX()+eps;
-  Double_t x6= 0.5*p->PcSizeX()-eps; Double_t x5= 0.5*p->SectorSizeX()+p->DeadZone()+eps; Double_t x4= 0.5*p->SectorSizeX()-eps;
-  Double_t y1=-0.5*p->PcSizeY()+eps; Double_t y2=-0.5*p->DeadZone()-eps;
-  Double_t y4= 0.5*p->PcSizeY()-eps; Double_t y3= 0.5*p->DeadZone()+eps;
-  TVector2 v2;
-
-  AliRICHParam::Print();
-
-  sec=p->Loc2Pad(TVector2(x= 0,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x= 0,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x= 0,y= 0),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" dead  ","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x= 0,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x= 0,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
-
-  sec=p->Loc2Pad(TVector2(x=x1,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x2,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x3,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x4,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x5,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x6,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
-
-  sec=p->Loc2Pad(TVector2(x=x1,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x2,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x3,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x4,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x5,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x6,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
-
-  sec=p->Loc2Pad(TVector2(x=x1,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x2,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x3,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x4,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x5,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x6,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
-
-  sec=p->Loc2Pad(TVector2(x=x1,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x2,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x3,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x4,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x5,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
-  sec=p->Loc2Pad(TVector2(x=x6,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
+  Double_t margin=5;
+  Double_t x0=0; Double_t x1=p.SectorSizeX(); Double_t x2=p.SectorSizeX()+p.DeadZone(); Double_t x3=p.PcSizeX();
+  Double_t y0=0; Double_t y1=p.SectorSizeY(); Double_t y2=p.SectorSizeY()+p.DeadZone();
+  Double_t y3=2*p.SectorSizeY()+p.DeadZone(); Double_t y4=p.PcSizeY()-p.SectorSizeY();
+  Double_t y5=p.PcSizeY();

-  new TCanvas("name","title");
-  gPad->Range(-80,-80,80,80);
-  AliRICHDisplFast::DrawSectors();
-  AliRICHParam *p=new AliRICHParam;
-
-  Double_t eps=0.0001;
-  Double_t x1=-0.5*p->PcSizeX()+eps; Double_t x2=-0.5*p->SectorSizeX()-p->DeadZone()-eps; Double_t x3=-0.5*p->SectorSizeX()+eps;
-  Double_t x6= 0.5*p->PcSizeX()-eps; Double_t x5= 0.5*p->SectorSizeX()+p->DeadZone()+eps; Double_t x4= 0.5*p->SectorSizeX()-eps;
-  Double_t y1=-0.5*p->PcSizeY()+eps; Double_t y2=-0.5*p->DeadZone()-eps;
-  Double_t y4= 0.5*p->PcSizeY()-eps; Double_t y3= 0.5*p->DeadZone()+eps;
-
-  TLatex t; t.SetTextSize(0.02);
-
-  TVector2 v2;
-  v2=AliRICHParam::Pad2Loc( 1,140); t.DrawLatex(v2.X(),v2.Y(),"Sector 1");
-  v2=AliRICHParam::Pad2Loc(49,140); t.DrawLatex(v2.X(),v2.Y(),"Sector 2");
-  v2=AliRICHParam::Pad2Loc(97,140); t.DrawLatex(v2.X(),v2.Y(),"Sector 3");
-  v2=AliRICHParam::Pad2Loc( 1, 60); t.DrawLatex(v2.X(),v2.Y(),"Sector 4");
-  v2=AliRICHParam::Pad2Loc(49, 60); t.DrawLatex(v2.X(),v2.Y(),"Sector 5");
-  v2=AliRICHParam::Pad2Loc(97, 60); t.DrawLatex(v2.X(),v2.Y(),"Sector 6");
+//pads along x
+  t.SetTextAlign(11); t.DrawText(x0,y5+margin,"1");
+  t.SetTextAlign(31); t.DrawText(x1,y5+margin,"80");
+  t.SetTextAlign(11); t.DrawText(x2,y5+margin,"81");
+  t.SetTextAlign(31); t.DrawText(x3,y5+margin,"160");
+//pads along y
+  t.SetTextAlign(11); t.DrawText(x3+margin,y0,"1");
+  t.SetTextAlign(13); t.DrawText(x3+margin,y1,"48");
+  t.SetTextAlign(11); t.DrawText(x3+margin,y2,"49");
+  t.SetTextAlign(13); t.DrawText(x3+margin,y3,"96");
+  t.SetTextAlign(11); t.DrawText(x3+margin,y4,"97");
+  t.SetTextAlign(13); t.DrawText(x3+margin,y5,"144");

   t.SetTextColor(kRed);
-  t.DrawLatex(-63.08,-70,"-63.08"); t.DrawLatex(-28.00,-70,"-22.76"); t.DrawLatex(-20.16,-70,"-20.16"); //x position
-  t.DrawLatex( 58.00,-70," 63.08"); t.DrawLatex( 22.76,-70," 22.76"); t.DrawLatex( 15.00,-70," 20.16");
-  t.DrawLatex(-70,-64,"-65.30"); t.DrawLatex(-70,-5,"-1.30"); //y position
-  t.DrawLatex(-70, 63," 65.30"); t.DrawLatex(-70, 2," 1.30");
-
-  t.SetTextColor(kBlue);
-  t.DrawLatex(-63.08,-75,"1");  t.DrawLatex(-25.00,-75,"48");  t.DrawLatex(-20.00,-75,"49");       //x pads
-  t.DrawLatex( 18.00,-75,"96"); t.DrawLatex( 23.00,-75,"97");  t.DrawLatex( 60.00,-75,"144");
-  t.DrawLatex(-75,-64,"1");   t.DrawLatex(-75,-5,"80"); //y pads
-  t.DrawLatex(-75, 63,"160"); t.DrawLatex(-75, 2,"81");
+
+//positions along x
+  t.SetTextAlign(13);t.DrawText(x0,y0-margin,Form("%5.2f",x0));
+  t.SetTextAlign(33);t.DrawText(x1,y0-margin,Form("%5.2f",x1));
+  t.SetTextAlign(13);t.DrawText(x2,y0-margin,Form("%5.2f",x2));
+  t.SetTextAlign(33);t.DrawText(x3,y0-margin,Form("%5.2f",x3));
+//positions along y
+  t.SetTextAlign(31);t.DrawText(x0-margin,y0,Form("%5.2f",y0));
+  t.SetTextAlign(33);t.DrawText(x0-margin,y1,Form("%5.2f",y1));
+  t.SetTextAlign(31);t.DrawText(x0-margin,y2,Form("%5.2f",y2));
+  t.SetTextAlign(33);t.DrawText(x0-margin,y3,Form("%5.2f",y3));
+  t.SetTextAlign(31);t.DrawText(x0-margin,y4,Form("%5.2f",y4));
+  t.SetTextAlign(33);t.DrawText(x0-margin,y5,Form("%5.2f",y5));
+//coners
+  t.SetTextSize(0.02);
+  TVector pad(2);
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x0,y0)));t.SetTextAlign(11);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x0,y1)));t.SetTextAlign(13);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x1,y1)));t.SetTextAlign(33);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x1,y0)));t.SetTextAlign(31);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x0,y2)));t.SetTextAlign(11);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x0,y3)));t.SetTextAlign(13);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x1,y3)));t.SetTextAlign(33);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x1,y2)));t.SetTextAlign(31);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x0,y4)));t.SetTextAlign(11);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x0,y5)));t.SetTextAlign(13);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x1,y5)));t.SetTextAlign(33);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x1,y4)));t.SetTextAlign(31);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x2,y4)));t.SetTextAlign(11);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x2,y5)));t.SetTextAlign(13);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x3,y5)));t.SetTextAlign(33);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x3,y4)));t.SetTextAlign(31);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x2,y2)));t.SetTextAlign(11);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x2,y3)));t.SetTextAlign(13);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x3,y3)));t.SetTextAlign(33);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x3,y2)));t.SetTextAlign(31);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x2,y0)));t.SetTextAlign(11);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x2,y1)));t.SetTextAlign(13);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x3,y1)));t.SetTextAlign(33);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+  v2=p.Pad2Loc(p.Loc2Pad(TVector2(x3,y0)));t.SetTextAlign(31);t.DrawText(v2.X(),v2.Y(),Form("%5.2f,%5.2f",v2.X(),v2.Y()));
+//new canvas
+  new TCanvas("trasform","Test LRS-MRS transform");
+
+  TView *pView=new TView(1);
+  pView->SetRange(-600,-600,-600,600,600,600);
+//axis
+  Double_t X[6]={0,0,0,300,0,0};  Double_t Y[6]={0,0,0,0,300,0};  Double_t Z[6]={0,0,0,0,0,300};
+  TPolyLine3D *pXaxis=new TPolyLine3D(2,X);pXaxis->SetLineColor(kRed);   pXaxis->Draw();
+  TPolyLine3D *pYaxis=new TPolyLine3D(2,Y);pYaxis->SetLineColor(kGreen); pYaxis->Draw();
+  TPolyLine3D *pZaxis=new TPolyLine3D(2,Z);pZaxis->SetLineColor(kBlue);  pZaxis->Draw();
+//chambers
+  Int_t iNpointsX=50,iNpointsY=50;
+  for(Int_t iChamberN=1;iChamberN<=7;iChamberN++){//chamber loop
+    TPolyMarker3D *pChamber=new TPolyMarker3D(iNpointsX*iNpointsY);
+    Int_t i=0;
+    for(Double_t x=0;x<p.PcSizeX();x+=p.PcSizeX()/iNpointsX)
+      for(Double_t y=0;y<p.PcSizeY();y+=p.PcSizeY()/iNpointsY){//step loop
+        TVector3 v3=p.C(iChamberN)->Loc2Glob(TVector2(x,y));
+        pChamber->SetPoint(i++,v3.X(),v3.Y(),v3.Z());
+        pChamber->SetMarkerSize(1);
+        pChamber->SetMarkerColor(iChamberN);
+      }//step loop
+    pChamber->Draw();
+  }//chamber loop
+  gPad->GetView()->RotateView(270,30);
 }//void TestSeg()
 //__________________________________________________________________________________________________
 void TestMenu()
@@ -526,7 +376,6 @@
   pMenu->AddButton("Test response",      "TestResponse()",    "Test AliRICHParam response methods");
   pMenu->AddButton("Test sdigits",       "TestSD()",          "Create test set of sdigits");
   pMenu->AddButton("Test clusters",      "TestC()",           "Create test set of clusters");
-  pMenu->AddButton("Test digits OLD",    "TestDigitsOLD()",   "Create test set of OLD digits");
   pMenu->Show();
 }//TestMenu()
 //__________________________________________________________________________________________________
@@ -535,16 +384,9 @@
   TControlBar *pMenu = new TControlBar("vertical","RICH main");

   if(ReadAlice()){//it's from file, reconstruct
-    pMenu->AddButton("hits->sdigits->digits->clusters","MainTrank()","Convert");
-
-    pMenu->AddButton("sdigits->digits"  ,"SD_D()" ,"AliRICHDigitizer");
-    pMenu->AddButton("digits->resolved clusters" ,"cf=new AliRICHClusterFinder(r);cf->Exec();delete cf;","AliRICHClusterFinder");
-    pMenu->AddButton("digits->raw clusters" ,     "AliRICHParam::SetDeclustering(kFALSE);cf=new AliRICHClusterFinder(r);cf->Exec();delete cf;","AliRICHClusterFinder");
-    pMenu->AddButton("clusters->recos"  ,"C_R()"  ,"AliRICHRecon");
-
-    pMenu->AddButton("Show",            "Show()","Shows the structure of events in files");
-    pMenu->AddButton("Display Fast",    "DisplFast()",           "Display Fast");
-    pMenu->AddButton("Control Plots",   "ControlPlots()",        "Display some control histograms");
+    pMenu->AddButton("Show",            "Show()",             "Shows the structure of events in files");
+    pMenu->AddButton("Display Fast",    "DisplFast()",        "Display Fast");
+    pMenu->AddButton("Control Plots",   "R()->ControlPlots()","Create some control histograms");

   }else{//it's aliroot, simulate
     pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
@@ -565,6 +407,7 @@

 void ReadRaw()
 {
+// First interation for TB raw data reader
   char *sRawFileName="beam/run1822_4sigma.dat";
   FILE *pRawFile=fopen(sRawFileName,"r");
   if(!pRawFile){Error("ReadRaw","Something wrong with raw data file %s",sRawFileName); return;}


take out log msg

take out log msg

--- RdbDump.cpp
+++ RdbDump.cpp
@@ -576,7 +576,7 @@
 	//m_bytesWritten = 0;

 	// sanity check
-	log("dump: writing %li bytes at offset %lli",m_bytesToWrite,offset);
+	//log("dump: writing %li bytes at offset %lli",m_bytesToWrite,offset);

 	// . if we're called by RdbMerge directly use m_callback/m_state
 	// . otherwise, use doneWritingWrapper() which will call dumpTree()


fix graph window some

fix graph window some

--- Statsdb.cpp
+++ Statsdb.cpp
@@ -632,7 +632,7 @@
 		      "background-color:#c0c0c0;"
 		      //"overflow-y:hidden;"
 		      "overflow-x:hidden;"
-		      "z-index:-10;"
+			"z-index:0;"
 		      // the tick marks we print below are based on it
 		      // being a window of the last 20 seconds... and using
 		      // DX2 pixels
@@ -658,8 +658,8 @@
 		m_gw.safePrintf("

\n"
 			      , m_bx + (long)x-1
@@ -668,12 +668,16 @@
 		// LABEL
 		m_gw.safePrintf("
%lis
\n"
-				, (long)x-10 + m_bx
+				, (long)x-15 + m_bx
 				// the label:
 				, xv
 				);


Fix wrong order in RGBA texel fetch

Fix wrong order in RGBA texel fetch

--- Texture.cpp
+++ Texture.cpp
@@ -39,9 +39,9 @@
 		uint32_t idxT = (uint32_t)glm::floor(uv.t * m_image.m_height);
 		uint32_t idx = (idxT * m_image.m_width + idxS) * m_image.m_numChannels;

+		float r = (float)(m_image.m_data[idx++]);
 		float g = (float)(m_image.m_data[idx++]);
 		float b = (float)(m_image.m_data[idx++]);
-		float r = (float)(m_image.m_data[idx++]);
 		float a = (float)(m_image.m_data[idx++]);

 		return glm::vec4(r, g, b, a) * g_texColDiv;


Final

Final

--- Verklegt1/consoleui.cpp
+++ Verklegt1/consoleui.cpp
@@ -115,58 +115,70 @@
         }
      }while(tempDateOfBirth > 2016 || tempDateOfBirth < 0);

-     do
-     {
-        if(!cin)
-        {
-            while((!cin))
-            {
+    do
+        {
+            if(tempDateOfBirth > 2016)
+            {
+                cout << TAB << "Invalid date. Please try again: ";
+                cin >> tempDateOfBirth;
+            }
+            else if(tempDateOfBirth < 0)
+            {
+                cout << TAB << "A person cannot have a negative date of birth. Please try again: ";
+                cin >> tempDateOfBirth;
+            }
+         }while(tempDateOfBirth > 2016 || tempDateOfBirth < 0);
+
+         do
+         {
+            if(!cin)
+            {
+                while((!cin))
+                {
+                    cin.clear();
+                    cin.ignore(numeric_limits<streamsize>::max(),'\n');
+                    cout << TAB << "That is not a date, please try again: ";
+                    cin >> tempDateOfBirth;
+                }
+            }
+        }while(tempDateOfBirth > 2016 && tempDateOfBirth < 0);
+
+        temp.setDateOfBirth(tempDateOfBirth);
+
+        cout << TAB << "Please enter a year of death(Enter 0 if the scientist is still alive): ";
+        cin >> tempDateOfDeath;
+
+        do
+        {
+
+            if(!cin)
+            {
+                while((!cin))
+                {
+                    cin.clear();
+                    cin.ignore(numeric_limits<streamsize>::max(),'\n');
+                    cout << TAB << "Invalid date, that is not a year, try again: ";
+                    cin >> tempDateOfDeath;
+                }
+            }
+            else if((tempDateOfDeath < tempDateOfBirth)&&(tempDateOfDeath != 0) && (tempDateOfDeath < 2017))
+            {
+                cout << TAB << "Not possible. A person cannot die before it is born, try again: ";
+                cin >> tempDateOfDeath;
                 cin.clear();
-                cin.ignore(numeric_limits<streamsize>::max(),'\n');
-                cout << TAB << "That is not a date, please try again: ";
-                cin >> tempDateOfBirth;
-            }
-        }
-    }while(tempDateOfBirth > 2016 && tempDateOfBirth < 0);
-
-    temp.setDateOfBirth(tempDateOfBirth);
-
-    cout << TAB << "Please enter a year of death(Enter 0 if the scientist is still alive): ";
-    cin >> tempDateOfDeath;
-
-    do
-    {
-        if(!cin)
-        {
-            while((!cin))
-            {
-                cin.clear();
-                cin.ignore(numeric_limits<streamsize>::max(),'\n');
-                cout << TAB << "Invalid date, that is not a year, try again: " << endl;
-                cout << TAB << "Please enter a year of death(Enter 0 if the scientist is still alive): ";
+            }
+        }
+        while((tempDateOfDeath < tempDateOfBirth)&&(tempDateOfDeath != 0));
+
+        do
+        {
+            if(tempDateOfDeath > 2016)
+            {
+                cout << TAB << "Not possible. A person cannot die beyond the current year, try again: ";
                 cin >> tempDateOfDeath;
             }
-        }
-        else if(((tempDateOfDeath < tempDateOfBirth)&&(tempDateOfDeath != 0)) || (tempDateOfDeath > 2017))
-        {
-            cout << TAB << "Not possible. A person cannot die before it is born, try again: ";
-            cin >> tempDateOfDeath;
-            cout << TAB << "Please enter a year of death(Enter 0 if the scientist is still alive): ";
-            cin.clear();
-            cin >> tempDateOfDeath;
-        }
-    }
-    while((tempDateOfDeath < tempDateOfBirth)&&(tempDateOfDeath != 0));
-
-    do
-    {
-        if(tempDateOfDeath > 2016)
-        {
-            cout << TAB << "Not possible. A person cannot die beyond the current year, try again: ";
-            cin >> tempDateOfDeath;
-        }
-
-    }while((tempDateOfDeath < tempDateOfBirth)&&(tempDateOfDeath != 0));
+
+        }while((tempDateOfDeath < tempDateOfBirth)&&(tempDateOfDeath != 0));

     temp.setDateOfDeath(tempDateOfDeath);
     cout << endl;


Minor fix in setting of default camera profile

--- Voxel/Configuration.cpp
+++ Voxel/Configuration.cpp
@@ -999,17 +999,38 @@

   ConfigurationFile *c = &_cameraProfiles.at(id);

-  if(!c->removeFile())
-    return false;
+  bool refreshHardware = false;
+
+  if(c->getLocation() == IN_HOST)
+  {
+    if(!c->removeFile())
+      return false;
+  }
+  else
+    refreshHardware = true;

   _cameraProfiles.erase(_cameraProfiles.find(id));

   if(_cameraProfileNames.find(id) != _cameraProfileNames.end())
     _cameraProfileNames.erase(_cameraProfileNames.find(id));

+  if(refreshHardware && !writeToHardware())
+  {
+    logger(LOG_ERROR) << "MainConfigurationFile: Failed to update hardware data after removing profile with id = " << id << std::endl;
+    return false;
+  }
+
   if(!_updateCameraProfileList())
   {
     logger(LOG_WARNING) << "MainConfigurationFile: Could not update profile list in main configuration file '" << _fileName << "'." << std::endl;
+  }
+
+  if(id == _currentCameraProfileID)
+  {
+    if(id != _defaultCameraProfileID)
+      return setCurrentCameraProfile(_defaultCameraProfileID);
+    else if(_cameraProfiles.size() > 0)
+      return setCurrentCameraProfile(_cameraProfiles.begin()->first);
   }

   return true;
@@ -1372,6 +1393,8 @@
   if(!config)
     return false;

+  logger(LOG_INFO) << "MainConfigurationFile: Setting id = " << id << ", as default camera profile." << std::endl;
+
   if(config->getLocation() == ConfigurationFile::IN_CAMERA)
   {
     _defaultCameraProfileIDInHardware = id;
@@ -1380,6 +1403,10 @@
   else
   {
     _defaultCameraProfileID = id;
+
+    if(!setInteger("core", "default_profile", id))
+      return false;
+
     return write();
   }
 }


switch to debug msg

switch to debug msg

--- moveit_core/robot_state/src/conversions.cpp
+++ moveit_core/robot_state/src/conversions.cpp
@@ -313,7 +313,7 @@
         else
         {
           if (state.clearAttachedBody(aco.object.id))
-            logInform("The robot state already had an object named '%s' attached to link '%s'. The object was replaced.",
+            logDebug("The robot state already had an object named '%s' attached to link '%s'. The object was replaced.",
                       aco.object.id.c_str(), aco.link_name.c_str());
           state.attachBody(aco.object.id, shapes, poses, aco.touch_links, aco.link_name, aco.detach_posture);
           logDebug("Attached object '%s' to link '%s'", aco.object.id.c_str(), aco.link_name.c_str());


Add unit test to check for zero length dir in FTP PWD response.

BUG=38845
TEST=FtpNetworkTransactionTest.ZeroLengthDirInPWD
Review URL: http://codereview.chromium.org/1166001

git-svn-id: http://src.chromium.org/svn/trunk/src@42238 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: 064aba337641460f2dd9ff2660320e8d9741df8b


Support encryption of streams!

Support encryption of streams!

--- package/source/zippackage/ZipPackageFolder.cxx
+++ package/source/zippackage/ZipPackageFolder.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: ZipPackageFolder.cxx,v $
  *
- *  $Revision: 1.39 $
- *
- *  last change: $Author: mtg $ $Date: 2001-05-02 18:11:15 $
+ *  $Revision: 1.40 $
+ *
+ *  last change: $Author: mtg $ $Date: 2001-05-08 14:04:49 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -84,6 +84,9 @@
 #endif
 #ifndef _OSL_TIME_H_
 #include <osl/time.h>
+#endif
+#ifndef _RTL_DIGEST_H_
+#include <rtl/digest.h>
 #endif

 using namespace com::sun::star::packages::ZipConstants;
@@ -274,18 +277,21 @@
         throw NoSuchElementException();
     insertByName(aName, aElement);
 }
-void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut)
+void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, Sequence < sal_Int8 > &rEncryptionKey)
     throw(RuntimeException)
 {
     Reference < XUnoTunnel > xTunnel;
     ZipPackageFolder *pFolder = NULL;
     ZipPackageStream *pStream = NULL;
     TunnelHash::const_iterator aCI = aContents.begin(), aEnd = aContents.end();
-    const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
-    const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
-    const OUString sInitialisationVector ( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
-    const OUString sSalt ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
-    const OUString sIterationCount ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
+    const OUString sMediaTypeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
+    const OUString sFullPathProperty ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
+    const OUString sInitialisationVectorProperty ( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
+    const OUString sSaltProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
+    const OUString sIterationCountProperty ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
+    const OUString sSizeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Size" ) );
+
+    sal_Bool bHaveEncryptionKey = rEncryptionKey.getLength() == 16 ? sal_True : sal_False;

     // Get a random number generator and seed it with current timestamp
     TimeValue aTime;
@@ -342,16 +348,16 @@
                 VOS_ENSURE( 0, "Error writing ZipOutputStream" );
             }

-            aPropSet[0].Name = sMediaType;
+            aPropSet[0].Name = sMediaTypeProperty;
             aPropSet[0].Value <<= pFolder->GetMediaType();
-            aPropSet[1].Name = sFullPath;
+            aPropSet[1].Name = sFullPathProperty;
             aPropSet[1].Value <<= pTempEntry->sName;

             // Copy back the zip entry and make the offset negative so that we
             // know it's point at the beginning of the LOC
             ZipPackageFolder::copyZipEntry ( pFolder->aEntry, *pTempEntry );
             pFolder->aEntry.nOffset *= -1;
-            pFolder->saveContents(pTempEntry->sName, rManList, rZipOut);
+            pFolder->saveContents(pTempEntry->sName, rManList, rZipOut, rEncryptionKey);
             pFolder->aEntry.sName = (*aCI).first;
         }
         else
@@ -363,36 +369,42 @@
             pTempEntry->sName = rPath + (*aCI).first;

             sal_Bool bToBeCompressed = pStream->IsToBeCompressed();
-            sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted();
-
-            aPropSet[0].Name = sMediaType;
+            sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted() && bHaveEncryptionKey;
+
+            aPropSet[0].Name = sMediaTypeProperty;
             aPropSet[0].Value <<= pStream->GetMediaType( );
-            aPropSet[1].Name = sFullPath;
+            aPropSet[1].Name = sFullPathProperty;
             aPropSet[1].Value <<= pTempEntry->sName;

-            if ( bToBeEncrypted)
+            if ( bToBeEncrypted )
             {
-                Sequence < sal_Int8 > aSalt ( 16 ), aVector ( 8 );
+                Sequence < sal_uInt8 > aSalt ( 16 ), aVector ( 8 );
+                Sequence < sal_Int8 > aKey ( 16 );
                 rtl_random_getBytes ( aRandomPool, aSalt.getArray(), 16 );
                 rtl_random_getBytes ( aRandomPool, aVector.getArray(), 8 );
-                sal_Int64 nIterationCount = 1024;
-
+                sal_Int32 nIterationCount = 1024;
+
+                rtl_digest_PBKDF2 ( reinterpret_cast < sal_uInt8 * > (aKey.getArray()), 16,
+                                    reinterpret_cast < sal_uInt8 * > (rEncryptionKey.getArray()), rEncryptionKey.getLength(),
+                                    aSalt.getConstArray(), 16,
+                                    nIterationCount );
                 pStream->setInitialisationVector ( aVector );
                 pStream->setSalt ( aSalt );
                 pStream->setIterationCount ( nIterationCount );
-
-                aPropSet.realloc(5);
-                aPropSet[2].Name = sInitialisationVector;
+                pStream->setKey ( aKey );
+
+                aPropSet.realloc(6); // 6th component is size, below
+                aPropSet[2].Name = sInitialisationVectorProperty;
                 aPropSet[2].Value <<= aVector;
-                aPropSet[3].Name = sSalt;
+                aPropSet[3].Name = sSaltProperty;
                 aPropSet[3].Value <<= aSalt;
-                aPropSet[4].Name = sIterationCount;
+                aPropSet[4].Name = sIterationCountProperty;
                 aPropSet[4].Value <<= nIterationCount;
             }

             // If the entry is already stored in the zip file in the format we
             // want for this write...copy it raw
-            if (pStream->IsPackageMember() &&
+            if (pStream->IsPackageMember() && !bToBeEncrypted &&
                 ( (pStream->aEntry.nMethod == DEFLATED && bToBeCompressed) ||
                   (pStream->aEntry.nMethod == STORED && !bToBeCompressed) ) )
             {
@@ -401,7 +413,7 @@
                     Reference < XInputStream > xStream = pStream->getRawStream( pStream->aEntry );
                     try
                     {
-                        rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted );
+                        rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted);
                         while (1)
                         {
                             Sequence < sal_Int8 > aSeq (65535);
@@ -427,30 +439,23 @@
             else
             {
                 Reference < XInputStream > xStream = pStream->getInputStream();
-                Reference < XSeekable > xSeek (xStream, UNO_QUERY);
-                sal_Bool bTrackLength = sal_True;

                 pTempEntry->nCrc = -1;
                 pTempEntry->nSize = -1;
                 pTempEntry->nCompressedSize = -1;
                 pTempEntry->nMethod = bToBeCompressed ? DEFLATED : STORED;

-                if (xSeek.is())
+                if (bToBeEncrypted)
                 {
-                    xSeek->seek(0);
-                    if (pTempEntry->nMethod == STORED)
-                    {
-                        pTempEntry->nSize = pTempEntry->nCompressedSize = static_cast < sal_Int32 > (xSeek->getLength());
-                        bTrackLength = sal_False;
-                    }
-                    // Some implementations of XInputStream/XSeekable change the current position
-                    // in the stream! Evil evil bad bad!
-                    xSeek->seek(0);
+                    // Need to store the uncompressed size in the manifest
+                    Reference < XSeekable > xSeek (xStream, UNO_QUERY);
+                    aPropSet[5].Name = sSizeProperty;
+                    aPropSet[5].Value <<= static_cast < sal_Int32 > (xSeek->getLength());
                 }

                 try
                 {
-                    rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted );
+                    rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted);
                     while (1)
                     {
                         Sequence < sal_Int8 > aSeq (65535);
@@ -459,15 +464,12 @@
                         if (nLength < 65535)
                             aSeq.realloc(nLength);
                         rZipOut.write(aSeq, 0, nLength);
-                        if (bTrackLength)
-                            pTempEntry->nSize+=nLength;
                         if (nLength < 65535) // EOF
                             break;
                     }
-                    if (bTrackLength)
-                        pTempEntry->nCompressedSize = pStream->aEntry.nSize;
                     pStream->SetPackageMember ( sal_True );
                     rZipOut.closeEntry();
+
                 }
                 catch (IOException & )
                 {


checked out from PX4 master to avoid eclipse formatting which happened in the past

--- src/modules/fw_att_control/fw_att_control_main.cpp
+++ src/modules/fw_att_control/fw_att_control_main.cpp
@@ -83,7 +83,8 @@
  */
 extern "C" __EXPORT int fw_att_control_main(int argc, char *argv[]);

-class FixedwingAttitudeControl {
+class FixedwingAttitudeControl
+{
 public:
 	/**
 	 * Constructor
@@ -100,56 +101,54 @@
 	 *
 	 * @return	OK on success.
 	 */
-	int start();
+	int		start();

 	/**
 	 * Task status
 	 *
 	 * @return	true if the mainloop is running
 	 */
-	bool task_running() {
-		return _task_running;
-	}
+	bool		task_running() { return _task_running; }

 private:

-	bool _task_should_exit; /**< if true, sensor task should exit */
-	bool _task_running; /**< if true, task is running in its mainloop */
-	int _control_task; /**< task handle for sensor task */
-
-	int _att_sub; /**< vehicle attitude subscription */
-	int _accel_sub; /**< accelerometer subscription */
-	int _att_sp_sub; /**< vehicle attitude setpoint */
-	int _attitude_sub; /**< raw rc channels data subscription */
-	int _airspeed_sub; /**< airspeed subscription */
-	int _vcontrol_mode_sub; /**< vehicle status subscription */
-	int _params_sub; /**< notification of parameter updates */
-	int _manual_sub; /**< notification of manual control updates */
-	int _global_pos_sub; /**< global position subscription */
-	int _vehicle_status_sub; /**< vehicle status subscription */
-
-	orb_advert_t _rate_sp_pub; /**< rate setpoint publication */
-	orb_advert_t _attitude_sp_pub; /**< attitude setpoint point */
-	orb_advert_t _actuators_0_pub; /**< actuator control group 0 setpoint */
-	orb_advert_t _actuators_1_pub; /**< actuator control group 1 setpoint (Airframe) */
-
-	struct vehicle_attitude_s _att; /**< vehicle attitude */
-	struct accel_report _accel; /**< body frame accelerations */
-	struct vehicle_attitude_setpoint_s _att_sp; /**< vehicle attitude setpoint */
-	struct manual_control_setpoint_s _manual; /**< r/c channel data */
-	struct airspeed_s _airspeed; /**< airspeed */
-	struct vehicle_control_mode_s _vcontrol_mode; /**< vehicle control mode */
-	struct actuator_controls_s _actuators; /**< actuator control inputs */
-	struct actuator_controls_s _actuators_airframe; /**< actuator control inputs */
-	struct vehicle_global_position_s _global_pos; /**< global position */
-	struct vehicle_status_s _vehicle_status; /**< vehicle status */
-
-	perf_counter_t _loop_perf; /**< loop performance counter */
-	perf_counter_t _nonfinite_input_perf; /**< performance counter for non finite input */
-	perf_counter_t _nonfinite_output_perf; /**< performance counter for non finite output */
-
-	bool _setpoint_valid; /**< flag if the position control setpoint is valid */
-	bool _debug; /**< if set to true, print debug output */
+	bool		_task_should_exit;		/**< if true, sensor task should exit */
+	bool		_task_running;			/**< if true, task is running in its mainloop */
+	int		_control_task;			/**< task handle for sensor task */
+
+	int		_att_sub;			/**< vehicle attitude subscription */
+	int		_accel_sub;			/**< accelerometer subscription */
+	int		_att_sp_sub;			/**< vehicle attitude setpoint */
+	int		_attitude_sub;			/**< raw rc channels data subscription */
+	int		_airspeed_sub;			/**< airspeed subscription */
+	int		_vcontrol_mode_sub;		/**< vehicle status subscription */
+	int 		_params_sub;			/**< notification of parameter updates */
+	int 		_manual_sub;			/**< notification of manual control updates */
+	int		_global_pos_sub;		/**< global position subscription */
+	int		_vehicle_status_sub;		/**< vehicle status subscription */
+
+	orb_advert_t	_rate_sp_pub;			/**< rate setpoint publication */
+	orb_advert_t	_attitude_sp_pub;		/**< attitude setpoint point */
+	orb_advert_t	_actuators_0_pub;		/**< actuator control group 0 setpoint */
+	orb_advert_t	_actuators_1_pub;		/**< actuator control group 1 setpoint (Airframe) */
+
+	struct vehicle_attitude_s			_att;			/**< vehicle attitude */
+	struct accel_report				_accel;			/**< body frame accelerations */
+	struct vehicle_attitude_setpoint_s		_att_sp;		/**< vehicle attitude setpoint */
+	struct manual_control_setpoint_s		_manual;		/**< r/c channel data */
+	struct airspeed_s				_airspeed;		/**< airspeed */
+	struct vehicle_control_mode_s			_vcontrol_mode;		/**< vehicle control mode */
+	struct actuator_controls_s			_actuators;		/**< actuator control inputs */
+	struct actuator_controls_s			_actuators_airframe;	/**< actuator control inputs */
+	struct vehicle_global_position_s		_global_pos;		/**< global position */
+	struct vehicle_status_s				_vehicle_status;	/**< vehicle status */
+
+	perf_counter_t	_loop_perf;			/**< loop performance counter */
+	perf_counter_t	_nonfinite_input_perf;		/**< performance counter for non finite input */
+	perf_counter_t	_nonfinite_output_perf;		/**< performance counter for non finite output */
+
+	bool		_setpoint_valid;		/**< flag if the position control setpoint is valid */
+	bool		_debug;				/**< if set to true, print debug output */

 	struct {
 		float tconst;
@@ -183,14 +182,14 @@
 		float trim_roll;
 		float trim_pitch;
 		float trim_yaw;
-		float rollsp_offset_deg; /**< Roll Setpoint Offset in deg */
-		float pitchsp_offset_deg; /**< Pitch Setpoint Offset in deg */
-		float rollsp_offset_rad; /**< Roll Setpoint Offset in rad */
-		float pitchsp_offset_rad; /**< Pitch Setpoint Offset in rad */
-		float man_roll_max; /**< Max Roll in rad */
-		float man_pitch_max; /**< Max Pitch in rad */
-
-	} _parameters; /**< local copies of interesting parameters */
+		float rollsp_offset_deg;			/**< Roll Setpoint Offset in deg */
+		float pitchsp_offset_deg;			/**< Pitch Setpoint Offset in deg */
+		float rollsp_offset_rad;			/**< Roll Setpoint Offset in rad */
+		float pitchsp_offset_rad;			/**< Pitch Setpoint Offset in rad */
+		float man_roll_max;						/**< Max Roll in rad */
+		float man_pitch_max;					/**< Max Pitch in rad */
+
+	}		_parameters;			/**< local copies of interesting parameters */

 	struct {

@@ -229,71 +228,75 @@
 		param_t pitchsp_offset_deg;
 		param_t man_roll_max;
 		param_t man_pitch_max;
-	} _parameter_handles; /**< handles for interesting parameters */
-
-	ECL_RollController _roll_ctrl;
-	ECL_PitchController _pitch_ctrl;
-	ECL_YawController _yaw_ctrl;
+	}		_parameter_handles;		/**< handles for interesting parameters */
+
+
+	ECL_RollController				_roll_ctrl;
+	ECL_PitchController				_pitch_ctrl;
+	ECL_YawController				_yaw_ctrl;
+

 	/**
 	 * Update our local parameter cache.
 	 */
-	int parameters_update();
+	int		parameters_update();

 	/**
 	 * Update control outputs
 	 *
 	 */
-	void control_update();
+	void		control_update();

 	/**
 	 * Check for changes in vehicle control mode.
 	 */
-	void vehicle_control_mode_poll();
+	void		vehicle_control_mode_poll();

 	/**
 	 * Check for changes in manual inputs.
 	 */
-	void vehicle_manual_poll();
+	void		vehicle_manual_poll();
+

 	/**
 	 * Check for airspeed updates.
 	 */
-	void vehicle_airspeed_poll();
+	void		vehicle_airspeed_poll();

 	/**
 	 * Check for accel updates.
 	 */
-	void vehicle_accel_poll();
+	void		vehicle_accel_poll();

 	/**
 	 * Check for set triplet updates.
 	 */
-	void vehicle_setpoint_poll();
+	void		vehicle_setpoint_poll();

 	/**
 	 * Check for global position updates.
 	 */
-	void global_pos_poll();
+	void		global_pos_poll();

 	/**
 	 * Check for vehicle status updates.
 	 */
-	void vehicle_status_poll();
+	void		vehicle_status_poll();

 	/**
 	 * Shim for calling task_main from task_create.
 	 */
-	static void task_main_trampoline(int argc, char *argv[]);
+	static void	task_main_trampoline(int argc, char *argv[]);

 	/**
 	 * Main sensor collection task.
 	 */
-	void task_main();
+	void		task_main();

 };

-namespace att_control {
+namespace att_control
+{

 /* oddly, ERROR is not defined for c++ */
 #ifdef ERROR
@@ -301,28 +304,39 @@
 #endif
 static const int ERROR = -1;

-FixedwingAttitudeControl *g_control = nullptr;
+FixedwingAttitudeControl	*g_control = nullptr;
 }

 FixedwingAttitudeControl::FixedwingAttitudeControl() :

-		_task_should_exit(false), _task_running(false), _control_task(-1),
-
-		/* subscriptions */
-		_att_sub(-1), _accel_sub(-1), _airspeed_sub(-1), _vcontrol_mode_sub(-1), _params_sub(
-				-1), _manual_sub(-1), _global_pos_sub(-1), _vehicle_status_sub(
-				-1),
-
-		/* publications */
-		_rate_sp_pub(-1), _attitude_sp_pub(-1), _actuators_0_pub(-1), _actuators_1_pub(
-				-1),
-
-		/* performance counters */
-		_loop_perf(perf_alloc(PC_ELAPSED, "fw att control")), _nonfinite_input_perf(
-				perf_alloc(PC_COUNT, "fw att control nonfinite input")), _nonfinite_output_perf(
-				perf_alloc(PC_COUNT, "fw att control nonfinite output")),
-		/* states */
-		_setpoint_valid(false), _debug(false) {
+	_task_should_exit(false),
+	_task_running(false),
+	_control_task(-1),
+
+/* subscriptions */
+	_att_sub(-1),
+	_accel_sub(-1),
+	_airspeed_sub(-1),
+	_vcontrol_mode_sub(-1),
+	_params_sub(-1),
+	_manual_sub(-1),
+	_global_pos_sub(-1),
+	_vehicle_status_sub(-1),
+
+/* publications */
+	_rate_sp_pub(-1),
+	_attitude_sp_pub(-1),
+	_actuators_0_pub(-1),
+	_actuators_1_pub(-1),
+
+/* performance counters */
+	_loop_perf(perf_alloc(PC_ELAPSED, "fw att control")),
+	_nonfinite_input_perf(perf_alloc(PC_COUNT, "fw att control nonfinite input")),
+	_nonfinite_output_perf(perf_alloc(PC_COUNT, "fw att control nonfinite output")),
+/* states */
+	_setpoint_valid(false),
+	_debug(false)
+{
 	/* safely initialize structs */
 	_att = {};
 	_accel = {};
@@ -335,6 +349,7 @@
 	_global_pos = {};
 	_vehicle_status = {};

+
 	_parameter_handles.tconst = param_find("FW_ATT_TC");
 	_parameter_handles.p_p = param_find("FW_PR_P");
 	_parameter_handles.p_i = param_find("FW_PR_I");
@@ -375,7 +390,8 @@
 	parameters_update();
 }

-FixedwingAttitudeControl::~FixedwingAttitudeControl() {
+FixedwingAttitudeControl::~FixedwingAttitudeControl()
+{
 	if (_control_task != -1) {

 		/* task wakes up every 100ms or so at the longest */
@@ -403,7 +419,9 @@
 	att_control::g_control = nullptr;
 }

-int FixedwingAttitudeControl::parameters_update() {
+int
+FixedwingAttitudeControl::parameters_update()
+{

 	param_get(_parameter_handles.tconst, &(_parameters.tconst));
 	param_get(_parameter_handles.p_p, &(_parameters.p_p));
@@ -411,26 +429,21 @@
 	param_get(_parameter_handles.p_ff, &(_parameters.p_ff));
 	param_get(_parameter_handles.p_rmax_pos, &(_parameters.p_rmax_pos));
 	param_get(_parameter_handles.p_rmax_neg, &(_parameters.p_rmax_neg));
-	param_get(_parameter_handles.p_integrator_max,
-			&(_parameters.p_integrator_max));
-	param_get(_parameter_handles.p_roll_feedforward,
-			&(_parameters.p_roll_feedforward));
+	param_get(_parameter_handles.p_integrator_max, &(_parameters.p_integrator_max));
+	param_get(_parameter_handles.p_roll_feedforward, &(_parameters.p_roll_feedforward));

 	param_get(_parameter_handles.r_p, &(_parameters.r_p));
 	param_get(_parameter_handles.r_i, &(_parameters.r_i));
 	param_get(_parameter_handles.r_ff, &(_parameters.r_ff));

-	param_get(_parameter_handles.r_integrator_max,
-			&(_parameters.r_integrator_max));
+	param_get(_parameter_handles.r_integrator_max, &(_parameters.r_integrator_max));
 	param_get(_parameter_handles.r_rmax, &(_parameters.r_rmax));

 	param_get(_parameter_handles.y_p, &(_parameters.y_p));
 	param_get(_parameter_handles.y_i, &(_parameters.y_i));
 	param_get(_parameter_handles.y_ff, &(_parameters.y_ff));
-	param_get(_parameter_handles.y_integrator_max,
-			&(_parameters.y_integrator_max));
-	param_get(_parameter_handles.y_coordinated_min_speed,
-			&(_parameters.y_coordinated_min_speed));
+	param_get(_parameter_handles.y_integrator_max, &(_parameters.y_integrator_max));
+	param_get(_parameter_handles.y_coordinated_min_speed, &(_parameters.y_coordinated_min_speed));
 	param_get(_parameter_handles.y_rmax, &(_parameters.y_rmax));

 	param_get(_parameter_handles.airspeed_min, &(_parameters.airspeed_min));
@@ -440,18 +453,15 @@
 	param_get(_parameter_handles.trim_roll, &(_parameters.trim_roll));
 	param_get(_parameter_handles.trim_pitch, &(_parameters.trim_pitch));
 	param_get(_parameter_handles.trim_yaw, &(_parameters.trim_yaw));
-	param_get(_parameter_handles.rollsp_offset_deg,
-			&(_parameters.rollsp_offset_deg));
-	param_get(_parameter_handles.pitchsp_offset_deg,
-			&(_parameters.pitchsp_offset_deg));
-	_parameters.rollsp_offset_rad = math::radians(
-			_parameters.rollsp_offset_deg);
-	_parameters.pitchsp_offset_rad = math::radians(
-			_parameters.pitchsp_offset_deg);
+	param_get(_parameter_handles.rollsp_offset_deg, &(_parameters.rollsp_offset_deg));
+	param_get(_parameter_handles.pitchsp_offset_deg, &(_parameters.pitchsp_offset_deg));
+	_parameters.rollsp_offset_rad = math::radians(_parameters.rollsp_offset_deg);
+	_parameters.pitchsp_offset_rad = math::radians(_parameters.pitchsp_offset_deg);
 	param_get(_parameter_handles.man_roll_max, &(_parameters.man_roll_max));
 	param_get(_parameter_handles.man_pitch_max, &(_parameters.man_pitch_max));
 	_parameters.man_roll_max = math::radians(_parameters.man_roll_max);
 	_parameters.man_pitch_max = math::radians(_parameters.man_pitch_max);
+

 	/* pitch control parameters */
 	_pitch_ctrl.set_time_constant(_parameters.tconst);
@@ -482,7 +492,9 @@
 	return OK;
 }

-void FixedwingAttitudeControl::vehicle_control_mode_poll() {
+void
+FixedwingAttitudeControl::vehicle_control_mode_poll()
+{
 	bool vcontrol_mode_updated;

 	/* Check HIL state if vehicle status has changed */
@@ -490,12 +502,13 @@

 	if (vcontrol_mode_updated) {

-		orb_copy(ORB_ID(vehicle_control_mode), _vcontrol_mode_sub,
-				&_vcontrol_mode);
-	}
-}
-
-void FixedwingAttitudeControl::vehicle_manual_poll() {
+		orb_copy(ORB_ID(vehicle_control_mode), _vcontrol_mode_sub, &_vcontrol_mode);
+	}
+}
+
+void
+FixedwingAttitudeControl::vehicle_manual_poll()
+{
 	bool manual_updated;

 	/* get pilots inputs */
@@ -507,7 +520,9 @@
 	}
 }

-void FixedwingAttitudeControl::vehicle_airspeed_poll() {
+void
+FixedwingAttitudeControl::vehicle_airspeed_poll()
+{
 	/* check if there is a new position */
 	bool airspeed_updated;
 	orb_check(_airspeed_sub, &airspeed_updated);
@@ -518,7 +533,9 @@
 	}
 }

-void FixedwingAttitudeControl::vehicle_accel_poll() {
+void
+FixedwingAttitudeControl::vehicle_accel_poll()
+{
 	/* check if there is a new position */
 	bool accel_updated;
 	orb_check(_accel_sub, &accel_updated);
@@ -528,7 +545,9 @@
 	}
 }

-void FixedwingAttitudeControl::vehicle_setpoint_poll() {
+void
+FixedwingAttitudeControl::vehicle_setpoint_poll()
+{
 	/* check if there is a new setpoint */
 	bool att_sp_updated;
 	orb_check(_att_sp_sub, &att_sp_updated);
@@ -539,18 +558,21 @@
 	}
 }

-void FixedwingAttitudeControl::global_pos_poll() {
+void
+FixedwingAttitudeControl::global_pos_poll()
+{
 	/* check if there is a new global position */
 	bool global_pos_updated;
 	orb_check(_global_pos_sub, &global_pos_updated);

 	if (global_pos_updated) {
-		orb_copy(ORB_ID(vehicle_global_position), _global_pos_sub,
-				&_global_pos);
-	}
-}
-
-void FixedwingAttitudeControl::vehicle_status_poll() {
+		orb_copy(ORB_ID(vehicle_global_position), _global_pos_sub, &_global_pos);
+	}
+}
+
+void
+FixedwingAttitudeControl::vehicle_status_poll()
+{
 	/* check if there is new status information */
 	bool vehicle_status_updated;
 	orb_check(_vehicle_status_sub, &vehicle_status_updated);
@@ -560,11 +582,15 @@
 	}
 }

-void FixedwingAttitudeControl::task_main_trampoline(int argc, char *argv[]) {
+void
+FixedwingAttitudeControl::task_main_trampoline(int argc, char *argv[])
+{
 	att_control::g_control->task_main();
 }

-void FixedwingAttitudeControl::task_main() {
+void
+FixedwingAttitudeControl::task_main()
+{

 	/* inform about start */
 	warnx("Initializing..");
@@ -641,6 +667,7 @@
 		/* only run controller if attitude changed */
 		if (fds[1].revents & POLLIN) {

+
 			static uint64_t last_run = 0;
 			float deltaT = (hrt_absolute_time() - last_run) / 1000000.0f;
 			last_run = hrt_absolute_time();
@@ -694,8 +721,8 @@
 				float airspeed;

 				/* if airspeed is not updating, we assume the normal average speed */
-				if (bool nonfinite = !isfinite(_airspeed.true_airspeed_m_s)
-						|| hrt_elapsed_time(&_airspeed.timestamp) > 1e6) {
+				if (bool nonfinite = !isfinite(_airspeed.true_airspeed_m_s) ||
+				    hrt_elapsed_time(&_airspeed.timestamp) > 1e6) {
 					airspeed = _parameters.airspeed_trim;
 					if (nonfinite) {
 						perf_count(_nonfinite_input_perf);
@@ -713,9 +740,7 @@
 				 * Forcing the scaling to this value allows reasonable handheld tests.
 				 */

-				float airspeed_scaling = _parameters.airspeed_trim
-						/ ((airspeed < _parameters.airspeed_min) ?
-								_parameters.airspeed_min : airspeed);
+				float airspeed_scaling = _parameters.airspeed_trim / ((airspeed < _parameters.airspeed_min) ? _parameters.airspeed_min : airspeed);

 				float roll_sp = _parameters.rollsp_offset_rad;
 				float pitch_sp = _parameters.pitchsp_offset_rad;
@@ -731,8 +756,7 @@
 						!_vcontrol_mode.flag_control_manual_enabled) {
 					/* read in attitude setpoint from attitude setpoint uorb topic */
 					roll_sp = _att_sp.roll_body + _parameters.rollsp_offset_rad;
-					pitch_sp = _att_sp.pitch_body
-							+ _parameters.pitchsp_offset_rad;
+					pitch_sp = _att_sp.pitch_body + _parameters.pitchsp_offset_rad;
 					throttle_sp = _att_sp.thrust;

 					/* reset integrals where needed */
@@ -758,12 +782,10 @@
 					 * the intended attitude setpoint. Later, after the rate control step the
 					 * trim is added again to the control signal.
 					 */
-					roll_sp = (_manual.y * _parameters.man_roll_max
-							- _parameters.trim_roll)
-							+ _parameters.rollsp_offset_rad;
-					pitch_sp = -(_manual.x * _parameters.man_pitch_max
-							- _parameters.trim_pitch)
-							+ _parameters.pitchsp_offset_rad;
+					roll_sp = (_manual.y * _parameters.man_roll_max - _parameters.trim_roll)
+						+ _parameters.rollsp_offset_rad;
+					pitch_sp = -(_manual.x * _parameters.man_pitch_max - _parameters.trim_pitch)
+						+ _parameters.pitchsp_offset_rad;
 					throttle_sp = _manual.z;
 					_actuators.control[4] = _manual.flaps;

@@ -782,13 +804,11 @@
 					/* lazily publish the setpoint only once available */
 					if (_attitude_sp_pub > 0) {
 						/* publish the attitude setpoint */
-						orb_publish(ORB_ID(vehicle_attitude_setpoint),
-								_attitude_sp_pub, &att_sp);
+						orb_publish(ORB_ID(vehicle_attitude_setpoint), _attitude_sp_pub, &att_sp);

 					} else {
 						/* advertise and publish */
-						_attitude_sp_pub = orb_advertise(
-								ORB_ID(vehicle_attitude_setpoint), &att_sp);
+						_attitude_sp_pub = orb_advertise(ORB_ID(vehicle_attitude_setpoint), &att_sp);
 					}
 				}

@@ -803,17 +823,11 @@
 				float speed_body_u = 0.0f;
 				float speed_body_v = 0.0f;
 				float speed_body_w = 0.0f;
-				if (_att.R_valid) {
-					speed_body_u = _att.R[0][0] * _global_pos.vel_n
-							+ _att.R[1][0] * _global_pos.vel_e
-							+ _att.R[2][0] * _global_pos.vel_d;
-					speed_body_v = _att.R[0][1] * _global_pos.vel_n
-							+ _att.R[1][1] * _global_pos.vel_e
-							+ _att.R[2][1] * _global_pos.vel_d;
-					speed_body_w = _att.R[0][2] * _global_pos.vel_n
-							+ _att.R[1][2] * _global_pos.vel_e
-							+ _att.R[2][2] * _global_pos.vel_d;
-				} else {
+				if(_att.R_valid) 	{
+					speed_body_u = _att.R[0][0] * _global_pos.vel_n + _att.R[1][0] * _global_pos.vel_e + _att.R[2][0] * _global_pos.vel_d;
+					speed_body_v = _att.R[0][1] * _global_pos.vel_n + _att.R[1][1] * _global_pos.vel_e + _att.R[2][1] * _global_pos.vel_d;
+					speed_body_w = _att.R[0][2] * _global_pos.vel_n + _att.R[1][2] * _global_pos.vel_e + _att.R[2][2] * _global_pos.vel_d;
+				} else	{
 					if (_debug && loop_counter % 10 == 0) {
 						warnx("Did not get a valid R\n");
 					}
@@ -822,80 +836,62 @@
 				/* Run attitude controllers */
 				if (isfinite(roll_sp) && isfinite(pitch_sp)) {
 					_roll_ctrl.control_attitude(roll_sp, _att.roll);
-					_pitch_ctrl.control_attitude(pitch_sp, _att.roll,
-							_att.pitch, airspeed);
+					_pitch_ctrl.control_attitude(pitch_sp, _att.roll, _att.pitch, airspeed);
 					_yaw_ctrl.control_attitude(_att.roll, _att.pitch,
 							speed_body_u, speed_body_v, speed_body_w,
-							_roll_ctrl.get_desired_rate(),
-							_pitch_ctrl.get_desired_rate()); //runs last, because is depending on output of roll and pitch attitude
+							_roll_ctrl.get_desired_rate(), _pitch_ctrl.get_desired_rate()); //runs last, because is depending on output of roll and pitch attitude

 					/* Run attitude RATE controllers which need the desired attitudes from above, add trim */
 					float roll_u = _roll_ctrl.control_bodyrate(_att.pitch,
 							_att.rollspeed, _att.yawspeed,
 							_yaw_ctrl.get_desired_rate(),
-							_parameters.airspeed_min, _parameters.airspeed_max,
-							airspeed, airspeed_scaling, lock_integrator);
-					_actuators.control[0] =
-							(isfinite(roll_u)) ?
-									roll_u + _parameters.trim_roll :
-									_parameters.trim_roll;
+							_parameters.airspeed_min, _parameters.airspeed_max, airspeed, airspeed_scaling, lock_integrator);
+					_actuators.control[0] = (isfinite(roll_u)) ? roll_u + _parameters.trim_roll : _parameters.trim_roll;
 					if (!isfinite(roll_u)) {
 						_roll_ctrl.reset_integrator();
 						perf_count(_nonfinite_output_perf);

 						if (_debug && loop_counter % 10 == 0) {
-							warnx("roll_u %.4f", (double) roll_u);
+							warnx("roll_u %.4f", (double)roll_u);
 						}
 					}

-					float pitch_u = _pitch_ctrl.control_bodyrate(_att.roll,
-							_att.pitch, _att.pitchspeed, _att.yawspeed,
+					float pitch_u = _pitch_ctrl.control_bodyrate(_att.roll, _att.pitch,
+							_att.pitchspeed, _att.yawspeed,
 							_yaw_ctrl.get_desired_rate(),
-							_parameters.airspeed_min, _parameters.airspeed_max,
-							airspeed, airspeed_scaling, lock_integrator);
-					_actuators.control[1] =
-							(isfinite(pitch_u)) ?
-									pitch_u + _parameters.trim_pitch :
-									_parameters.trim_pitch;
+							_parameters.airspeed_min, _parameters.airspeed_max, airspeed, airspeed_scaling, lock_integrator);
+					_actuators.control[1] = (isfinite(pitch_u)) ? pitch_u + _parameters.trim_pitch : _parameters.trim_pitch;
 					if (!isfinite(pitch_u)) {
 						_pitch_ctrl.reset_integrator();
 						perf_count(_nonfinite_output_perf);
 						if (_debug && loop_counter % 10 == 0) {
-							warnx(
-									"pitch_u %.4f, _yaw_ctrl.get_desired_rate() %.4f,"
-											" airspeed %.4f, airspeed_scaling %.4f,"
-											" roll_sp %.4f, pitch_sp %.4f,"
-											" _roll_ctrl.get_desired_rate() %.4f,"
-											" _pitch_ctrl.get_desired_rate() %.4f"
-											" att_sp.roll_body %.4f",
-									(double) pitch_u,
-									(double) _yaw_ctrl.get_desired_rate(),
-									(double) airspeed,
-									(double) airspeed_scaling, (double) roll_sp,
-									(double) pitch_sp,
-									(double) _roll_ctrl.get_desired_rate(),
-									(double) _pitch_ctrl.get_desired_rate(),
-									(double) _att_sp.roll_body);
+							warnx("pitch_u %.4f, _yaw_ctrl.get_desired_rate() %.4f,"
+								" airspeed %.4f, airspeed_scaling %.4f,"
+								" roll_sp %.4f, pitch_sp %.4f,"
+								" _roll_ctrl.get_desired_rate() %.4f,"
+								" _pitch_ctrl.get_desired_rate() %.4f"
+								" att_sp.roll_body %.4f",
+								(double)pitch_u, (double)_yaw_ctrl.get_desired_rate(),
+								(double)airspeed, (double)airspeed_scaling,
+								(double)roll_sp, (double)pitch_sp,
+								(double)_roll_ctrl.get_desired_rate(),
+								(double)_pitch_ctrl.get_desired_rate(),
+								(double)_att_sp.roll_body);
 						}
 					}

-					float yaw_u = _yaw_ctrl.control_bodyrate(_att.roll,
-							_att.pitch, _att.pitchspeed, _att.yawspeed,
+					float yaw_u = _yaw_ctrl.control_bodyrate(_att.roll, _att.pitch,
+							_att.pitchspeed, _att.yawspeed,
 							_pitch_ctrl.get_desired_rate(),
-							_parameters.airspeed_min, _parameters.airspeed_max,
-							airspeed, airspeed_scaling, lock_integrator);
-					_actuators.control[2] =
-							(isfinite(yaw_u)) ?
-									yaw_u + _parameters.trim_yaw :
-									_parameters.trim_yaw;
+							_parameters.airspeed_min, _parameters.airspeed_max, airspeed, airspeed_scaling, lock_integrator);
+					_actuators.control[2] = (isfinite(yaw_u)) ? yaw_u + _parameters.trim_yaw : _parameters.trim_yaw;
 					if (!isfinite(yaw_u)) {
 						_yaw_ctrl.reset_integrator();
 						perf_count(_nonfinite_output_perf);
 						if (_debug && loop_counter % 10 == 0) {
-							warnx("yaw_u %.4f", (double) yaw_u);
+							warnx("yaw_u %.4f", (double)yaw_u);
 						}
 					}
-

 					/* throttle passed through if it is finite and if no engine failure was
 					 * detected */
@@ -905,15 +901,13 @@
 						throttle_sp : 0.0f;
 					if (!isfinite(throttle_sp)) {
 						if (_debug && loop_counter % 10 == 0) {
-							warnx("throttle_sp %.4f", (double) throttle_sp);
+							warnx("throttle_sp %.4f", (double)throttle_sp);
 						}
 					}
 				} else {
 					perf_count(_nonfinite_input_perf);
 					if (_debug && loop_counter % 10 == 0) {
-						warnx(
-								"Non-finite setpoint roll_sp: %.4f, pitch_sp %.4f",
-								(double) roll_sp, (double) pitch_sp);
+						warnx("Non-finite setpoint roll_sp: %.4f, pitch_sp %.4f", (double)roll_sp, (double)pitch_sp);
 					}
 				}

@@ -930,13 +924,11 @@

 				if (_rate_sp_pub > 0) {
 					/* publish the attitude setpoint */
-					orb_publish(ORB_ID(vehicle_rates_setpoint), _rate_sp_pub,
-							&rates_sp);
+					orb_publish(ORB_ID(vehicle_rates_setpoint), _rate_sp_pub, &rates_sp);

 				} else {
 					/* advertise and publish */
-					_rate_sp_pub = orb_advertise(ORB_ID(vehicle_rates_setpoint),
-							&rates_sp);
+					_rate_sp_pub = orb_advertise(ORB_ID(vehicle_rates_setpoint), &rates_sp);
 				}

 			} else {
@@ -958,19 +950,16 @@

 			if (_actuators_0_pub > 0) {
 				/* publish the attitude setpoint */
-				orb_publish(ORB_ID(actuator_controls_0), _actuators_0_pub,
-						&_actuators);
+				orb_publish(ORB_ID(actuator_controls_0), _actuators_0_pub, &_actuators);

 			} else {
 				/* advertise and publish */
-				_actuators_0_pub = orb_advertise(ORB_ID(actuator_controls_0),
-						&_actuators);
+				_actuators_0_pub = orb_advertise(ORB_ID(actuator_controls_0), &_actuators);
 			}

 			if (_actuators_1_pub > 0) {
 				/* publish the attitude setpoint */
-				orb_publish(ORB_ID(actuator_controls_1), _actuators_1_pub,
-						&_actuators_airframe);
+				orb_publish(ORB_ID(actuator_controls_1), _actuators_1_pub, &_actuators_airframe);
 //				warnx("%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f",
 //						(double)_actuators_airframe.control[0], (double)_actuators_airframe.control[1], (double)_actuators_airframe.control[2],
 //						(double)_actuators_airframe.control[3], (double)_actuators_airframe.control[4], (double)_actuators_airframe.control[5],
@@ -978,8 +967,7 @@

 			} else {
 				/* advertise and publish */
-				_actuators_1_pub = orb_advertise(ORB_ID(actuator_controls_1),
-						&_actuators_airframe);
+				_actuators_1_pub = orb_advertise(ORB_ID(actuator_controls_1), &_actuators_airframe);
 			}

 		}
@@ -995,14 +983,18 @@
 	_exit(0);
 }

-int FixedwingAttitudeControl::start() {
+int
+FixedwingAttitudeControl::start()
+{
 	ASSERT(_control_task == -1);

 	/* start the task */
 	_control_task = task_spawn_cmd("fw_att_control",
-	SCHED_DEFAULT,
-	SCHED_PRIORITY_MAX - 5, 2048,
-			(main_t) &FixedwingAttitudeControl::task_main_trampoline, nullptr);
+				       SCHED_DEFAULT,
+				       SCHED_PRIORITY_MAX - 5,
+				       2048,
+				       (main_t)&FixedwingAttitudeControl::task_main_trampoline,
+				       nullptr);

 	if (_control_task < 0) {
 		warn("task start failed");
@@ -1012,7 +1004,8 @@
 	return OK;
 }

-int fw_att_control_main(int argc, char *argv[]) {
+int fw_att_control_main(int argc, char *argv[])
+{
 	if (argc < 1)
 		errx(1, "usage: fw_att_control {start|stop|status}");

@@ -1033,8 +1026,7 @@
 		}

 		/* avoid memory fragmentation by not exiting start handler until the task has fully started */
-		while (att_control::g_control == nullptr
-				|| !att_control::g_control->task_running()) {
+		while (att_control::g_control == nullptr || !att_control::g_control->task_running()) {
 			usleep(50000);
 			printf(".");
 			fflush(stdout);


segfault fixed when no ros connection

segfault fixed when no ros connection

--- csapex_transform/src/dynamic_transform.cpp
+++ csapex_transform/src/dynamic_transform.cpp
@@ -161,6 +161,9 @@

     LockedListener l = Listener::getLocked();
+    if(!l.l) {
+        return;
+    }
     l.l->tfl->waitForTransform(from, to, ros::Time(0), ros::Duration(1.0));
     if(l.l) {
         std::vector<std::string> f;


mc_pos_control: add vel_sp_desired to send desired velocity to the obstacle avoidance

--- src/modules/mc_pos_control/mc_pos_control_main.cpp
+++ src/modules/mc_pos_control/mc_pos_control_main.cpp
@@ -285,6 +285,7 @@
 	matrix::Vector3f _vel_prev;			/**< velocity on previous step */
 	matrix::Vector3f _vel_sp_prev;
 	matrix::Vector3f _vel_err_d;		/**< derivative of current velocity */
+	matrix::Vector3f _vel_sp_desired; /**< the desired velocity can be overwritten by obstacle avoidance */
 	matrix::Vector3f _curr_pos_sp;  /**< current setpoint of the triplets */
 	matrix::Vector3f _prev_pos_sp; /**< previous setpoint of the triples */
 	matrix::Vector2f _stick_input_xy_prev; /**< for manual controlled mode to detect direction change */
@@ -519,6 +520,7 @@
 	_vel_prev.zero();
 	_vel_sp_prev.zero();
 	_vel_err_d.zero();
+	_vel_sp_desired.zero();
 	_curr_pos_sp.zero();
 	_prev_pos_sp.zero();
 	_stick_input_xy_prev.zero();
@@ -2529,11 +2531,20 @@
 		set_takeoff_velocity(_vel_sp(2));
 	}

+	/* constrain velocity: this is desired velocity before any obstacle avoidance */
 	constrain_velocity_setpoint();
+	_vel_sp_desired = matrix::Vector3f(_vel_sp(0), _vel_sp(1), _vel_sp(2));
+
 	/* check obstacle avoidance */
 	if (use_vel_wp_avoidance() && !_in_smooth_takeoff) {

 		execute_avoidance_velocity_waypoint();
+
+		/* If obstacle avoidanc is active, the previous velocity
+		 * setpoint will be set to desired setpoint to ensure that setpoint
+		 * increases linearly with acceleration.
+		 */
+		_vel_sp_prev = _vel_sp_desired;

 	} else {
 		_vel_sp_prev = _vel_sp;


mc_pos_control limit to 50 Hz

mc_pos_control limit to 50 Hz

--- src/modules/mc_pos_control/mc_pos_control_main.cpp
+++ src/modules/mc_pos_control/mc_pos_control_main.cpp
@@ -582,10 +582,12 @@
 	_vehicle_land_detected_sub = orb_subscribe(ORB_ID(vehicle_land_detected));
 	_control_mode_sub = orb_subscribe(ORB_ID(vehicle_control_mode));
 	_params_sub = orb_subscribe(ORB_ID(parameter_update));
-	_local_pos_sub = orb_subscribe(ORB_ID(vehicle_local_position));
 	_att_sub = orb_subscribe(ORB_ID(vehicle_attitude));
 	_home_pos_sub = orb_subscribe(ORB_ID(home_position));
 	_traj_wp_avoidance_sub = orb_subscribe(ORB_ID(vehicle_trajectory_waypoint));
+
+	_local_pos_sub = orb_subscribe(ORB_ID(vehicle_local_position));
+	orb_set_interval(_local_pos_sub, 20); // 50 Hz updates

 	// get initial values for all parameters and subscribtions
 	parameters_update(true);


mc_pos_control: remove _limit_vel_xy

mc_pos_control: remove _limit_vel_xy

--- src/modules/mc_pos_control/mc_pos_control_main.cpp
+++ src/modules/mc_pos_control/mc_pos_control_main.cpp
@@ -238,7 +238,6 @@

 	bool _hold_offboard_xy = false;
 	bool _hold_offboard_z = false;
-	bool _limit_vel_xy = false;

 	math::Vector<3> _thrust_int;
 	math::Vector<3> _pos;


CDrone: Fix UpdateTouchBounds

CDrone: Fix UpdateTouchBounds

--- Runtime/MP1/World/CDrone.cpp
+++ Runtime/MP1/World/CDrone.cpp
@@ -835,6 +835,8 @@
 void CDrone::UpdateTouchBounds(float radius) {
   const zeus::CTransform xf = GetLctrTransform("Skeleton_Root"sv);
   const zeus::CVector3f diff = xf.origin - GetTranslation();
+  x690_colSphere.SetSphereCenter(diff);
+  x690_colSphere.SetSphereRadius(radius);
   SetBoundingBox(zeus::CAABox{diff - radius, diff + radius});
   x6b0_pathFind.SetCharacterRadius(0.25f + radius);
 }


Bug fix. Missing {} that was causing a false information message that the trigger input will be running in a stand-alone mode. Thanks to Philippe for noticing the problem

--- STEER/AliTriggerDetector.cxx
+++ STEER/AliTriggerDetector.cxx
@@ -117,10 +117,11 @@
    for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
      AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
      if (inp->GetSignature() == -1 &&
-	 inp->GetMask() == 0)
+	 inp->GetMask() == 0) {
        inp->Enable();
        AliInfo(Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode",
 		    inp->GetInputName().Data()));
+     }
    }

    fInputs.SetOwner(kFALSE);


FIX (#4120): Fixed check for masking

FIX (#4120): Fixed check for masking

--- Modules/Bundles/org.mitk.gui.qt.imagestatistics/src/internal/QmitkImageStatisticsView.cpp
+++ Modules/Bundles/org.mitk.gui.qt.imagestatistics/src/internal/QmitkImageStatisticsView.cpp
@@ -305,16 +305,21 @@
   m_SelectedImageMask = NULL;
   m_SelectedPlanarFigure = NULL;

-  do
-  {
+  {
+    unsigned int parentObjectIndex = 0;
     parentObjects = this->GetDefaultDataStorage()->GetSources( selectedNode );
-    if ( parentObjects->Size() > 0 )
+    while( parentObjectIndex < parentObjects->Size() )
     {
       // Use first parent object (if multiple parents are present)
-      parentNode = parentObjects->ElementAt( 0 );
+      parentNode = parentObjects->ElementAt( parentObjectIndex );
       parentImage = dynamic_cast< mitk::Image * >( parentNode->GetData() );
-    }
-  } while ( (parentImage == NULL) && (parentObjects->Size() != 0) );
+      if( parentImage != NULL )
+      {
+        break;
+      }
+      parentObjectIndex++;
+    }
+  }

   if ( parentImage != NULL )
   {
@@ -325,11 +330,27 @@
     m_SelectedImageMask = dynamic_cast< mitk::Image * >( selectedNode->GetData() );
     m_SelectedPlanarFigure = dynamic_cast< mitk::PlanarFigure * >( selectedNode->GetData() );

-    if ( (m_SelectedImageMask != NULL) || (m_SelectedPlanarFigure != NULL) )
+    // Check whether ImageMask is a binary segmentation
+
+    if ( (m_SelectedImageMask != NULL) )
+    {
+      bool isMask( false );
+      selectedNode->GetPropertyValue("binary", isMask);
+      if ( !isMask )
+      {
+        m_SelectedImageNode = selectedNode;
+        m_SelectedImage = selectedImage;
+        m_SelectedImageMask = NULL;
+      }
+      else
+      {
+        m_SelectedMaskNode = selectedNode;
+      }
+    }
+    else if ( (m_SelectedPlanarFigure != NULL) )
     {
       m_SelectedMaskNode = selectedNode;
     }
-
   }
   else if ( selectedImage != NULL )
   {


[NPU] remove duplicated stream sync in fetch op (#33819)

--- paddle/fluid/operators/controlflow/fetch_op.cc
+++ paddle/fluid/operators/controlflow/fetch_op.cc
@@ -44,11 +44,6 @@
       TensorCopySync(src_item, platform::CPUPlace(), dst_item);
     }
 #else
-#ifdef PADDLE_WITH_ASCEND_CL
-    if (platform::is_npu_place(src_item.place())) {
-      platform::DeviceContextPool::Instance().Get(src_item.place())->Wait();
-    }
-#endif
     TensorCopySync(src_item, platform::CPUPlace(), dst_item);
 #endif
   } else {


INTEGRATION: CWS adc12p (1.3.6); FILE MERGED 2005/07/27 11:21:25 np 1.3.6.1: #i52495#

--- autodoc/source/display/toolkit/htmlfile.cxx
+++ autodoc/source/display/toolkit/htmlfile.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: htmlfile.cxx,v $
  *
- *  $Revision: 1.3 $
- *
- *  last change: $Author: vg $ $Date: 2005-03-23 09:05:00 $
+ *  $Revision: 1.4 $
+ *
+ *  last change: $Author: hr $ $Date: 2005-08-05 14:26:23 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -77,7 +77,8 @@
         sStyle(),
         sCssFile(),
         sCopyright(),
-        aBodyData()
+        aBodyData(),
+        aBuffer(60000) // Grows dynamically, when necessary.
 {
 }

@@ -149,15 +150,17 @@
 void
 DocuFile_Html::WriteHeader( csv::File & io_aFile )
 {
+    aBuffer.reset();
+
     static const char s1[] =
         "<html>\n<head>\n<title>";
     static const char s2[] =
         "</title>\n"
         "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";

-    io_aFile.write( s1 );
-    io_aFile.write( sTitle );
-    io_aFile.write( s2 );
+    aBuffer.write( s1 );
+    aBuffer.write( sTitle );
+    aBuffer.write( s2 );

     if (NOT sCssFile.empty())
@@ -167,9 +170,9 @@
         static const char s4[] =
             "\">\n";

-        io_aFile.write(s3);
-        io_aFile.write(sCssFile);
-        io_aFile.write(s4);
+        aBuffer.write(s3);
+        aBuffer.write(sCssFile);
+        aBuffer.write(s4);
     }

     if (NOT sStyle.empty())
@@ -179,19 +182,23 @@
         static const char s6[] =
             "</style>\n";

-        io_aFile.write(s5);
-        io_aFile.write(sStyle);
-        io_aFile.write(s6);
+        aBuffer.write(s5);
+        aBuffer.write(sStyle);
+        aBuffer.write(s6);
     }

     static const char s7[] =
         "</head>\n";
-    io_aFile.write(s7);
+    aBuffer.write(s7);
+
+    io_aFile.write(aBuffer.c_str(), aBuffer.size());
 }

 void
 DocuFile_Html::WriteBody( csv::File & io_aFile )
 {
+    aBuffer.reset();
+
     aBodyData
         >> *new html::Link( "#_top_" )
                 << "Top of Page";
@@ -207,12 +214,14 @@
                     << new xml::AnAttribute( "align", "center" )
                     << new xml::XmlCode(sCopyright);
     }
-    aBodyData.WriteOut(io_aFile);
-}
-
-
-
-
-
-
-
+    aBodyData.WriteOut(aBuffer);
+
+    io_aFile.write(aBuffer.c_str(), aBuffer.size());
+}
+
+
+
+
+
+
+


Turn off request for QTAIM rendering option

Signed-off-by: Geoff Hutchison <9cf35bacc9f8512ca007341c9e919cf5dc03e0c7@gmail.com>

--- avogadro/qtplugins/qtaim/qtaimextension.cpp
+++ avogadro/qtplugins/qtaim/qtaimextension.cpp
@@ -740,7 +740,7 @@
   }

   emit requestActiveTool("Navigator");
-  emit requestActiveDisplayTypes(QStringList() << "QTAIMScenePlugin");
+//  emit requestActiveDisplayTypes(QStringList() << "QTAIMScenePlugin");

   return;
 }


INTEGRATION: CWS changefileheader (1.8.4); FILE MERGED 2008/03/31 16:08:01 rt 1.8.4.1: #i87441# Change license header to LPGL v3.

--- setup_native/source/win32/customactions/shellextensions/postuninstall.cxx
+++ setup_native/source/win32/customactions/shellextensions/postuninstall.cxx
@@ -1,35 +1,30 @@
 /*************************************************************************
  *
- *  OpenOffice.org - a multi-platform office productivity suite
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *  $RCSfile: postuninstall.cxx,v $
+ * Copyright 2008 by Sun Microsystems, Inc.
  *
- *  $Revision: 1.8 $
+ * OpenOffice.org - a multi-platform office productivity suite
  *
- *  last change: $Author: vg $ $Date: 2008-03-18 12:54:23 $
+ * $RCSfile: postuninstall.cxx,v $
+ * $Revision: 1.9 $
  *
- *  The Contents of this file are made available subject to
- *  the terms of GNU Lesser General Public License Version 2.1.
+ * This file is part of OpenOffice.org.
  *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
  *
- *    GNU Lesser General Public License Version 2.1
- *    =============================================
- *    Copyright 2005 by Sun Microsystems, Inc.
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
  *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License version 2.1, as published by the Free Software Foundation.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU Lesser General Public
- *    License along with this library; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *    MA  02111-1307  USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
  *
  ************************************************************************/