Index: /trunk/ArchTOIPipe/Kernel/flagtoidef.h
===================================================================
--- /trunk/ArchTOIPipe/Kernel/flagtoidef.h	(revision 1734)
+++ /trunk/ArchTOIPipe/Kernel/flagtoidef.h	(revision 1735)
@@ -15,4 +15,8 @@
 // Sample Value has been interpolated/Replaced ...
   FlgToiInterp  =  (unsigned long long)1 << 5,
+// Sample killed because near a "flaggued" one ...
+  FlgToiAround  =  (unsigned long long)1 << 6,
+// All bit to one ...
+  FlgToiAll     =  (unsigned long long)~0
 };
 
Index: /trunk/ArchTOIPipe/ProcWSophya/ktoibad.cc
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/ktoibad.cc	(revision 1734)
+++ /trunk/ArchTOIPipe/ProcWSophya/ktoibad.cc	(revision 1735)
@@ -104,5 +104,5 @@
 
   getData(0,sn,bolog,fgbolog);
-  if(fgbolog && flgNotLookAt) {
+  if(fgbolog & flgNotLookAt) {
     putData(0,sn,bolog,fgbolog);
     continue;
@@ -218,2 +218,106 @@
 return;                                                                            
 }
+
+
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////
+// Flag des sample autour d'un sample deja flaggue :
+// INPUT:
+// lm : longueur a flagguer de part et d'autre du mauvais sample
+//      <---lm---><bad_sample><---lm--->
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+FlagAround::FlagAround(uint_4 lm,uint_8 flgs)
+{
+ // Mise en forme des arguments
+ LSide = lm;
+
+ SetFlag();
+ SetFlagAroundFlag(flgs);
+}
+
+FlagAround::~FlagAround()
+{
+}
+
+////////////////////////////////////////////////////////////////////////
+void FlagAround::Print(ostream & os)
+{
+ os<<"FlagAround::Print"
+   <<" LSide="<<LSide
+   <<" flgSample="<<flgSample<<" flgAround="<<flgAround
+   <<endl;
+}
+
+////////////////////////////////////////////////////////////////////////
+void FlagAround::init() {
+  cout << "FlagAround::init" << endl;
+  declareInput("BoloIn");       // input index 0
+  declareOutput("BoloOut");     // output index 0
+
+  int_4 lbuff = 2*LSide +10;
+  if(neededHistory<lbuff) setNeededHistory(lbuff);
+}
+
+////////////////////////////////////////////////////////////////////////
+void FlagAround::run()
+{
+long snb = getMinIn();
+long sne = getMaxIn();
+
+if(snb>sne) {
+  cout<<"FlagAround::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
+  throw ParmError("FlagAround::run() - Bad sample interval");
+}
+if(!checkInputTOIIndex(0)) {
+  cout<<"FlagAround::run() - Input TOI (BoloIn) not connected! "<<endl;
+  throw ParmError("FlagAround::run() Input TOI (BoloIn) not connected!");
+}
+if(!checkOutputTOIIndex(0)) {
+  cout<<"FlagAround::run() - Output TOI (BoloOut) not connected! "<<endl;
+  throw ParmError("FlagAround::run() Output TOI (BoloOut) not connected!");
+}
+
+//---------------------------------------------------------
+try {
+
+cout<<"FlagAround::run(): SampleNum de "<<snb<<" a "<<sne<<endl;
+uint_4 nflag=0, nflagged=0, nflagalready=0;
+
+// Un peu boeuf! On pourrait optimiser!
+// Si on ne tue pas (LSide=0), alors juste un transfert de donnees
+for(int_4 sn=snb;sn<=sne;sn++) {
+  r_8 bolo; uint_8 fgbolo=0;
+  getData(0,sn,bolo,fgbolo);
+  if(fgbolo&flgSample) { // Pixel flaggue flgSample
+    nflag++;
+  } else if(fgbolo&flgAround) { // Pixel deja flagge around?
+    nflagalready++;
+  } else if(LSide>0) { // Pixel a flagguer?
+    int_4 ideb = sn-LSide, ifin = sn+LSide;
+    for(int_4 i=ideb;i<=ifin;i++) { // Y a t-il un "mauvais" pixel autour?
+      if(i<snb || i>sne || i==sn) continue;
+      r_8 b; uint_8 fg=0;
+      getData(0,i,b,fg);
+      if(fg&flgSample) {fgbolo |= flgAround; nflagged++; break;}
+    }
+  }
+  putData(0,sn,bolo,fgbolo);
+}
+cout<<"FlagAround::run(): Fin de boucle: nflag="<<nflag
+    <<" nflagged="<<nflagged<<" (already="<<nflagalready
+    <<") / tot="<<sne-snb+1<<endl;
+
+//---------------------------------------------------------
+} catch (PException & exc) {
+  cout<<"FlagAround: Catched Exception "<<(string)typeid(exc).name()
+      <<"\n .... Msg= "<<exc.Msg()<<endl;
+}
+
+return;                                                                            
+}
Index: /trunk/ArchTOIPipe/ProcWSophya/ktoibad.h
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/ktoibad.h	(revision 1734)
+++ /trunk/ArchTOIPipe/ProcWSophya/ktoibad.h	(revision 1735)
@@ -9,5 +9,4 @@
 //-- Pour rechercher les glitches
 //   toi BoloIn ---> |FlagGlitch | ---> toi BoloOut
-
 class FlagGlitch : public TOIProcessor {
 public:
@@ -43,3 +42,26 @@
 };
 
+//-- Pour flagguer les samples autour de samples deja flaggues
+//   toi BoloIn ---> |FlagAround | ---> toi BoloOut
+class FlagAround : public TOIProcessor {
+public:
+  FlagAround(uint_4 lm,uint_8 flgs=FlgToiAll);
+  virtual ~FlagAround();
+
+  virtual void	init(void);
+  virtual void	run(void);
+
+  //! Flagguer les samples avec la valeur flag
+  inline void SetFlag(uint_8 flag=FlgToiAround) {flgAround = flag;}
+  //! Flagguer autour des samples ayant la valeur flag
+  inline void SetFlagAroundFlag(uint_8 flag=FlgToiAll) {flgSample = flag;}
+  //! Print
+  void Print(ostream & os);
+  inline void Print(void) {Print(cout);}
+
+protected:
+  uint_8 flgSample,flgAround;
+  uint_4 LSide;
+};
+
 #endif
Index: /trunk/ArchTOIPipe/TestPipes/tstktoibad.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/tstktoibad.cc	(revision 1734)
+++ /trunk/ArchTOIPipe/TestPipes/tstktoibad.cc	(revision 1735)
@@ -16,4 +16,5 @@
  <<" -b label_bolomuv"
  <<" -g lg,lm,nsg,bupd"
+ <<" -a lmaround"
  <<" -p lp,sn1,sn2"
  <<endl;
@@ -24,9 +25,9 @@
  int_4 sdeb=0,sfin=-1;
  int_4 lp=1,sn1=-1,sn2=-1;
- uint_4 lg=3,lm=15,bupd=1000;
+ uint_4 lg=3,lm=15,bupd=1000,lmaround=10;
  r_8 nsg=5.;
  char *label_bolomuv = "boloMuV";
   int c;
- while((c = getopt(narg,arg,"hs:g:b:p:")) != -1) {
+ while((c = getopt(narg,arg,"hs:g:b:a:p:")) != -1) {
   switch (c) {
   case 's' :
@@ -35,4 +36,7 @@
   case 'g' :
    sscanf(optarg,"%d,%d,%lf,%d",&lg,&lm,&nsg,&bupd);
+   break;
+  case 'a' :
+   sscanf(optarg,"%d",&lmaround);
    break;
   case 'b' :
@@ -73,16 +77,23 @@
  deglitch.Print();
 
+ FlagAround flgaround(lm);
+ flgaround.Print();
+
  // Creation des tuyaux et des connections associees
  int taille = 8192;
- // tuyau bolo pour entree processeur
- TOISegmented * boloin = new TOISegmented("tuyau_bolo_in",taille);
- rfits.addOutput(label_bolomuv,boloin);
- deglitch.addInput("BoloIn",boloin);
+ // tuyau bolo pour entree processeur FlagGlitch
+ TOISegmented * toi1 = new TOISegmented("tuyau_bolo_in1",taille);
+ rfits.addOutput(label_bolomuv,toi1);
+ deglitch.addInput("BoloIn",toi1);
 
- // tuyau bolo pour sortie processeur
- bool writeflag=true;
- TOISegmented * boloout = new TOISegmented("tuyau_bolo_out",taille);
- deglitch.addOutput("BoloOut",boloout);
- wfits.addInput(label_bolomuv,boloout,writeflag);
+ // tuyau bolo pour entree processeur FlagAround
+ TOISegmented * toi2 = new TOISegmented("tuyau_bolo_in2",taille);
+ deglitch.addOutput("BoloOut",toi2);
+ flgaround.addInput("BoloIn",toi2);
+
+ // tuyau bolo pour entree fits writer
+ TOISegmented * toiout = new TOISegmented("tuyau_bolo_out",taille);
+ flgaround.addOutput("BoloOut",toiout);
+ wfits.addInput(label_bolomuv,toiout,true);
 
  // Print de status avant lancement des taches:
@@ -92,8 +103,11 @@
  wfits.PrintStatus(cout);  
  cout<<"----- TOISegmented::PrintStatus() : -----"<<endl;
- boloin->PrintStatus(cout);  
- boloout->PrintStatus(cout);  
+ toi1->PrintStatus(cout);  
+ toi2->PrintStatus(cout);  
+ toiout->PrintStatus(cout);  
  cout<<"-----FlagGlitch ::PrintStatus() : -----"<<endl;
  deglitch.PrintStatus(cout);  
+ cout<<"-----FlagAround ::PrintStatus() : -----"<<endl;
+ flgaround.PrintStatus(cout);  
 
  // Lancement des taches
@@ -102,4 +116,5 @@
  wfits.start();
  deglitch.start();
+ flgaround.start();  
 
  // Gestion de la re-connection des threads
