← Back to team overview

kaliveda-dev team mailing list archive

[Merge] lp:~kaliveda-dev/kaliveda/1.8.1-bugfixes into lp:kaliveda

 

John Frankland has proposed merging lp:~kaliveda-dev/kaliveda/1.8.1-bugfixes into lp:kaliveda.

Requested reviews:
  KaliVeda Development Team (kaliveda-dev)
Related bugs:
  Bug #807444 in KaliVeda: "Event counters are wrong for analysis of INDRA-VAMOS raw data"
  https://bugs.launchpad.net/kaliveda/+bug/807444

For more details, see:
https://code.launchpad.net/~kaliveda-dev/kaliveda/1.8.1-bugfixes/+merge/81592

it's time to move on to v1.8.2 (or even 1.8.3)
-- 
https://code.launchpad.net/~kaliveda-dev/kaliveda/1.8.1-bugfixes/+merge/81592
Your team KaliVeda Development Team is requested to review the proposed merge of lp:~kaliveda-dev/kaliveda/1.8.1-bugfixes into lp:kaliveda.
=== removed file 'KVIndra/INDRA2ROOT/Analysis.C'
--- KVIndra/INDRA2ROOT/Analysis.C	2009-01-22 16:16:03 +0000
+++ KVIndra/INDRA2ROOT/Analysis.C	1970-01-01 00:00:00 +0000
@@ -1,141 +0,0 @@
-#define Analysis_cxx
-//$Id: Analysis.C,v 1.2 2003/10/08 16:25:24 franklan Exp $
-// The class definition in Analysis.h has been generated automatically
-// by the ROOT utility TTree::MakeSelector().
-//
-// This class is derived from the ROOT class TSelector.
-// The following members functions are called by the TTree::Process() functions:
-//    Begin():       called everytime a loop on the tree starts,
-//                   a convenient place to create your histograms.
-//    Notify():      this function is called at the first entry of a new Tree
-//                   in a chain.
-//    Process():     called for each event. In this function you decide what 
-//                   to read and you fill your histograms.
-//    Terminate():   called at the end of a loop on the tree,
-//                   a convenient place to draw/fit your histograms.
-//
-//   To use this file, try the following session on your Tree T
-//
-// Root > T->Process("Analysis.C")
-// Root > T->Process("Analysis.C","some options")
-// Root > T->Process("Analysis.C+")
-//
-#include "Analysis.h"
-#include "TH2.h"
-#include "TH1.h"
-#include "TStyle.h"
-#include "TCanvas.h"
-#include "KVINDRAReconNuc.h"
-#include "KVINDRA.h"
-#include "TStopwatch.h"
-
-TStopwatch *timer;
-
-void Analysis::Begin(TTree *tree)
-{
-   // Function called before starting the event loop.
-   // Initialize the tree branches.
-
-	timer = new TStopwatch();
-	
-   Init(tree);
-
-   TString option = GetOption();
-   
-   data->GetCodeMask()->SetIDMask(kIDCode2 | kIDCode3 | kIDCode4 | kIDCode6);
-   data->GetCodeMask()->SetEMask(kECode1 | kIDCode2);
-   
-   gIndra->SetTrigger(4);
-   
-   new TH2F("hmult","Mult all vs OK",61,-.5,60.5,61,-.5,60.5);
-   new TH1F("hz","Z all",61,-.5,60.5);
-   new TH1F("hzok","Z OK",61,-.5,60.5);
-   new TH1F("hmtok","MT OK",4096,-.5,4095.5);
-   new TH2F("hzmax","Zmax all vs OK",61,-.5,60.5,61,-.5,60.5);
-   new TH2F("hcomp","Ztot-Ptot all",100,0.,50000.,110,-.5,109.5);
-   new TH2F("hcompok","Ztot-Ptot OK",100,0.,50000.,110,-.5,109.5);
-}
-
-Bool_t Analysis::Process(Int_t entry)
-{
-   // Processing function. This function is called
-   // to process an event. It is the user's responsability to read
-   // the corresponding entry in memory (may be just a partial read).
-   // Once the entry is in memory one can apply a selection and if the
-   // event is selected histograms can be filled. Processing stops
-   // when this function returns kFALSE. This function combines the
-   // next two functions in one, avoiding to have to maintain state
-   // in the class to communicate between these two funtions.
-   // You should not implement ProcessCut and ProcessFill if you write
-   // this function. This method is used by PROOF.
-
-   return kTRUE;
-}
-
-Bool_t Analysis::ProcessCut(Int_t entry)
-{
-   // Selection function.
-   // Entry is the entry number in the current tree.
-   // Read only the necessary branches to select entries.
-   // Return kFALSE as soon as a bad entry is detected.
-   // To read complete event, call fChain->GetTree()->GetEntry(entry).
-
-   fChain->GetTree()->GetEntry(entry);
-   
-   KVINDRAReconNuc *frag = 0;
-   
-   while( (frag = data->GetNextParticle("ok")) ){
-	   if(frag->GetTimeMarker()<50 || frag->GetTimeMarker()>150) frag->SetIsOK(kFALSE);
-   }
-  
-   return data->IsOK();
-}
-
-void Analysis::ProcessFill(Int_t entry)
-{
-   // Function called for selected entries only.
-   // Entry is the entry number in the current tree.
-   // Read branches not processed in ProcessCut() and fill histograms.
-   // To read complete event, call fChain->GetTree()->GetEntry(entry).
-
-   
-   KVINDRAReconNuc *frag = 0;
-   
-   TH2F* h=0;
-   
-   h=(TH2F*)gROOT->FindObject("hmult");
-   if(h) h->Fill(data->GetMult("ok"), data->GetMult());
-   
-   h=(TH2F*)gROOT->FindObject("hzmax");
-   if(h) h->Fill(data->GetZmax("ok")->GetZ(), data->GetZmax()->GetZ());
-   
-   h=(TH2F*)gROOT->FindObject("hcomp");
-   if(h) h->Fill(data->GetPtot().Mag(), data->GetZtot());
-   
-   h=(TH2F*)gROOT->FindObject("hcompok");
-   if(h) h->Fill(data->GetPtot("ok").Mag(), data->GetZtot("ok"));
-   
-   TH1F *h1=0;
-   h1=(TH1F*)gROOT->FindObject("hz");
-   
-   while( (frag = data->GetNextParticle()) ){
-	   if(h1) h1->Fill(frag->GetZ());
-   }
-   
-   h1=(TH1F*)gROOT->FindObject("hzok");
-   TH1F *h2=(TH1F*)gROOT->FindObject("hmtok");
-   
-   while( (frag = data->GetNextParticle("ok")) ){
-	   if(h1) h1->Fill(frag->GetZ());
-	   if(h2) h2->Fill(frag->GetTimeMarker());
-   }
-   
-}
-
-void Analysis::Terminate()
-{
-   // Function called at the end of the event loop.
-
-	timer->Print("m");
-	delete timer;
-}

=== removed file 'KVIndra/INDRA2ROOT/Analysis.h'
--- KVIndra/INDRA2ROOT/Analysis.h	2009-01-22 16:16:03 +0000
+++ KVIndra/INDRA2ROOT/Analysis.h	1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-//////////////////////////////////////////////////////////
-//$Id: Analysis.h,v 1.1 2003/10/08 06:42:46 franklan Exp $
-//   This class has been automatically generated 
-//     (Mon Oct  6 23:44:17 2003 by ROOT version3.10/00)
-//   from TTree Arbre/Arbre d'Event
-//   found on file: test_evt.root
-//////////////////////////////////////////////////////////
-
-
-#ifndef Analysis_h
-#define Analysis_h
-
-#include <TROOT.h>
-#include <TChain.h>
-#include <TFile.h>
-#include <TSelector.h>
-
-#include "KVINDRAReconEvent.h"
-
-class Analysis : public TSelector {
-   public :
-   TTree          *fChain;   //!pointer to the analyzed TTree or TChain
-//Declaration of leaves types
-   KVINDRAReconEvent *data;
-
-//List of branches
-   TBranch        *b_data;   //!
-
-   Analysis(TTree *tree=0) { }
-   ~Analysis() { }
-   void    Begin(TTree *tree);
-   void    Init(TTree *tree);
-   Bool_t  Notify();
-   Bool_t  Process(Int_t entry);
-   Bool_t  ProcessCut(Int_t entry);
-   void    ProcessFill(Int_t entry);
-   void    SetOption(const char *option) { fOption = option; }
-   void    SetObject(TObject *obj) { fObject = obj; }
-   void    SetInputList(TList *input) {fInput = input;}
-   TList  *GetOutputList() const { return fOutput; }
-   void    Terminate();
-   ClassDef(Analysis,0);
-};
-
-#endif
-
-#ifdef Analysis_cxx
-void Analysis::Init(TTree *tree)
-{
-//   Set object pointer
-   data = 0;
-//   Set branch addresses
-   if (tree == 0) return;
-   fChain    = tree;
-   fChain->SetMakeClass(1);
-
-   fChain->SetBranchAddress("data",&data);
-}
-
-Bool_t Analysis::Notify()
-{
-   // Called when loading a new file.
-   // Get branch pointers.
-   b_data = fChain->GetBranch("data");
-   return kTRUE;
-}
-
-#endif // #ifdef Analysis_cxx
-

=== modified file 'KVIndra/INDRA_e494s/Systems.dat'
--- KVIndra/INDRA_e494s/Systems.dat	2009-01-22 16:16:03 +0000
+++ KVIndra/INDRA_e494s/Systems.dat	2011-11-08 15:13:29 +0000
@@ -69,7 +69,7 @@
 Runs: 2 4-17 577-579 602-603 605-612
 
 +Alpha source
-Runs: 21-31 234-254 533-540 548-560
+Runs: 21-36 234-254 533-540 548-560
 
 +Pedestal
 Runs: 37-40 290-291 335-336 541-542

=== modified file 'KVIndra/KVIndraLinkDef.h'
--- KVIndra/KVIndraLinkDef.h	2011-10-25 14:30:21 +0000
+++ KVIndra/KVIndraLinkDef.h	2011-11-08 15:13:29 +0000
@@ -28,6 +28,7 @@
 #pragma link C++ class KVINDRARawIdent;
 #endif
 #pragma link C++ class KVRunListLine;
+#pragma link C++ class KVINDRAReconRoot;
 #pragma link C++ class KVINDRARunListReader;
 #pragma link C++ class KVINDRARunSheetReader;
 #pragma link C++ class KVINDRARunSheetGUI;

=== modified file 'KVIndra/analysis/KVINDRADstToRootTransfert.cpp'
--- KVIndra/analysis/KVINDRADstToRootTransfert.cpp	2011-06-09 10:41:53 +0000
+++ KVIndra/analysis/KVINDRADstToRootTransfert.cpp	2011-11-08 15:13:29 +0000
@@ -25,6 +25,7 @@
 #include "KVDataSetManager.h"
 #include "KVDataRepository.h"
 #include "KVBatchSystem.h"
+#include "KVGANILDataReader.h"
 
 typedef KVDetector* (KVINDRADstToRootTransfert::*FNMETHOD) ( int,int );
 
@@ -177,6 +178,25 @@
       //leaves for reconstructed events
 		data_tree->Branch("INDRAReconEvent", "KVINDRAReconEvent", &evt, 10000000, 0)->SetAutoDelete(kFALSE);
 
+      //tree for raw data
+		rawtree = new TTree("RawData", Form("%s : %s : raw data",
+			 	gIndraDB->GetRun(fRunNumber)->GetName(), gIndraDB->GetRun(fRunNumber)->GetTitle()));
+      rawtree->Branch("RunNumber", &fRunNumber, "RunNumber/I");
+		Int_t fEventNumber=1;
+      rawtree->Branch( "EventNumber", &fEventNumber, "EventNumber/I");
+      
+      // the format of the raw data tree must be "arrays" : we depend on it in KVINDRAReconDataAnalyser
+      // in order to read the raw data and set the detector acquisition parameters
+      TString raw_opt = "arrays";
+		KVGANILDataReader* raw_data = (KVGANILDataReader*)gDataSet->OpenRunfile("raw", fRunNumber);
+      raw_data->SetUserTree(rawtree,raw_opt.Data());
+      Info("InitRun", "Created raw data tree (%s : %s). Format: %s",
+            rawtree->GetName(), rawtree->GetTitle(), raw_opt.Data());
+		
+	// fill the raw data tree
+	while( raw_data->GetNextEvent() ) fEventNumber++;
+   Info("InitRun", "Raw data tree containes %d events", fEventNumber-1);
+		
 	events_good=events_read=0;
 
 	if(camp2){
@@ -240,6 +260,7 @@
 
 	gDataAnalyser->WriteBatchInfo(data_tree);
 	data_tree->Write();		//write tree to file
+	rawtree->Write();
 
 		//add new file to repository
 		OutputDataset->CommitRunfile("root", fRunNumber, fi);

=== modified file 'KVIndra/analysis/KVINDRADstToRootTransfert.h'
--- KVIndra/analysis/KVINDRADstToRootTransfert.h	2010-12-22 15:38:50 +0000
+++ KVIndra/analysis/KVINDRADstToRootTransfert.h	2011-11-08 15:13:29 +0000
@@ -45,6 +45,7 @@
 	Int_t events_good, events_read;//totals of events read and trees filled
 	
 	TTree* data_tree;//tree for writing events
+   TTree* rawtree;//raw data tree
 
 	Int_t fRunNumber;//run number of current file
    Int_t fCampNumber;

=== modified file 'KVIndra/analysis/KVINDRARawDataReconstructor.cpp'
--- KVIndra/analysis/KVINDRARawDataReconstructor.cpp	2010-05-07 12:38:57 +0000
+++ KVIndra/analysis/KVINDRARawDataReconstructor.cpp	2011-11-08 15:13:29 +0000
@@ -89,7 +89,9 @@
       rawtree->Branch("RunNumber", &fRunNumber, "RunNumber/I");
       rawtree->Branch( "EventNumber", &fEventNumber, "EventNumber/I");
       
-      TString raw_opt = gDataSet->GetDataSetEnv("KVINDRARawDataReconstructor.RawDataTreeFormat", "arrays");
+      // the format of the raw data tree must be "arrays" : we depend on it in KVINDRAReconDataAnalyser
+      // in order to read the raw data and set the detector acquisition parameters
+      TString raw_opt = "arrays";
       GetRawDataReader()->SetUserTree(rawtree,raw_opt.Data());
       Info("InitRun", "Created raw data tree (%s : %s). Format: %s",
             rawtree->GetName(), rawtree->GetTitle(), raw_opt.Data());

=== modified file 'KVIndra/analysis/KVINDRAReconDataAnalyser.cpp'
--- KVIndra/analysis/KVINDRAReconDataAnalyser.cpp	2010-05-26 13:04:54 +0000
+++ KVIndra/analysis/KVINDRAReconDataAnalyser.cpp	2011-11-08 15:13:29 +0000
@@ -15,7 +15,6 @@
 #include "TChain.h"
 #include "TObjString.h"
 #include "TChain.h"
-#include "KVSelector.h"
 #include "KVAvailableRunsFile.h"
 
 ClassImp(KVINDRAReconDataAnalyser)
@@ -28,6 +27,10 @@
    //Default constructor
    fDataSelector="none";
    theChain=0;
+   theRawData=0;
+   ParVal=0;
+   ParNum=0;
+	fSelector=0;
 }
 
 void KVINDRAReconDataAnalyser::Reset()
@@ -36,11 +39,18 @@
    KVDataAnalyser::Reset();
    fDataSelector="none";
    theChain=0;
+   theRawData=0;
+   ParVal=0;
+   ParNum=0;
+	fSelector=0;
 }
 
 KVINDRAReconDataAnalyser::~KVINDRAReconDataAnalyser()
 {
    //Destructor
+   if(ParVal) delete [] ParVal;
+   if(ParNum) delete [] ParNum;
+	SafeDelete(fSelector);
 }
 
 //_________________________________________________________________
@@ -96,27 +106,25 @@
       cout << "Data Selector : " << fDataSelector.Data() << endl;
    }
    
-   TSelector *selector = (TSelector*)GetInstanceOfUserClass();
+   fSelector = (KVSelector*)GetInstanceOfUserClass();
    
-   if(!selector || !selector->InheritsFrom("TSelector"))
+   if(!fSelector || !fSelector->InheritsFrom("TSelector"))
     {
     	cout << "The selector \"" << GetUserClass() << "\" is not valid." << endl;
     	cout << "Process aborted." << endl;
-    	if(selector) {
-    		delete selector;
-    		selector=0;
-    	}
     }
    else
     {
+   	SafeDelete(fSelector);
+		 Info("SubmitTask", "Beginning TChain::Process...");
       if (nbEventToRead) {
          theChain->Process(GetUserClass(), option.Data(),nbEventToRead);
       } else {
          theChain->Process(GetUserClass(), option.Data());
       }
     }
-   if(selector) delete selector;
    delete theChain;
+   fSelector=0;//deleted by TChain/TTreePlayer
 }
 
 //_________________________________________________________________
@@ -274,17 +282,51 @@
 void KVINDRAReconDataAnalyser::preInitRun()
 {
 	// Called by currently-processed KVSelector when a new file in the TChain is opened.
-	// If gIndra=0x0 we build the multidetector for the current dataset.
 	// We call gIndra->SetParameters for the current run.
 	
 	Int_t run = GetRunNumberFromFileName( theChain->GetCurrentFile()->GetName() );
 	gIndra->SetParameters(run);
-}
-
-void KVINDRAReconDataAnalyser::postEndAnalysis()
-{
-	// Called by currently-processed KVSelector after user's EndAnalysis() method.
-	// We clean up by deleting gIndra
-	
-	if(gIndra) delete gIndra;
+	ConnectRawDataTree();
+}
+
+void KVINDRAReconDataAnalyser::preAnalysis()
+{
+	// Read and set raw data for the current reconstructed event
+	
+	if(!theRawData) return;
+	// all recon events are numbered 1, 2, ... : therefore entry number is N-1
+	Long64_t rawEntry = fSelector->GetEventNumber() - 1;
+	theRawData->GetEntry(rawEntry);
+	for(int i=0; i<NbParFired; i++){
+		KVACQParam* par = gIndra->GetACQParam((*parList)[ParNum[i]]->GetName());
+		if(par) par->SetData(ParVal[i]);
+	}
+}
+
+void KVINDRAReconDataAnalyser::ConnectRawDataTree()
+{
+	// Called by preInitRun().
+	// When starting to read a new run (=new file), we look for the TTree "RawData" in the
+	// current file (it should have been created by KVINDRARawDataReconstructor).
+	// If found, it will be used by ReadRawData() to set the values of all acquisition parameters
+	// for each event.
+	
+	theRawData=(TTree*)theChain->GetCurrentFile()->Get("RawData");
+	if(!theRawData){
+		Warning("ConnectRawDataTree", "RawData tree not found in file; raw data parameters of detectors will not be available in analysis");
+		return;
+	}
+	else
+		Info("ConnectRawDataTree", "Found RawData tree in file");
+	Int_t maxNopar = theRawData->GetMaximum("NbParFired");
+   if(ParVal) delete [] ParVal;
+   if(ParNum) delete [] ParNum;
+	ParVal = new UShort_t[maxNopar];	
+	ParNum = new UInt_t[maxNopar];	
+	parList = (TObjArray*)theRawData->GetUserInfo()->FindObject("ParameterList");
+	theRawData->SetBranchAddress("NbParFired", &NbParFired);
+	theRawData->SetBranchAddress("ParNum", ParNum);
+	theRawData->SetBranchAddress("ParVal", ParVal);
+	Info("ConnectRawDataTree", "Connected raw data parameters");
+	Entry=0;
 }

=== modified file 'KVIndra/analysis/KVINDRAReconDataAnalyser.h'
--- KVIndra/analysis/KVINDRAReconDataAnalyser.h	2010-05-26 13:04:54 +0000
+++ KVIndra/analysis/KVINDRAReconDataAnalyser.h	2011-11-08 15:13:29 +0000
@@ -11,6 +11,7 @@
 #define __KVINDRAReconDataAnalyser_H
 
 #include "KVDataAnalyser.h"
+#include "KVSelector.h"
 class TChain;
 
 class KVINDRAReconDataAnalyser:public KVDataAnalyser {
@@ -21,8 +22,15 @@
    KVString fDataSelectorDec;//name of KVDataSelector header file (if it exists)
 
    virtual KVNumberList PrintAvailableRuns(KVString & datatype);
-   
+   KVSelector* fSelector;// the data analysis class
    TChain* theChain;//chain of TTrees to be analysed
+	TTree* theRawData;//raw data TTree in recon file
+   Int_t NbParFired;
+   UShort_t* ParVal;
+   UInt_t* ParNum;
+   TObjArray* parList;
+   Long64_t Entry;
+	void ConnectRawDataTree();
 	
  public:
 
@@ -46,8 +54,9 @@
    virtual const Char_t* ExpandAutoBatchName(const Char_t* format);
    
    void preInitAnalysis();
+   void preAnalysis();
    void preInitRun();
-   void postEndAnalysis();
+	virtual void RegisterUserClass(TObject*obj) {fSelector=(KVSelector*)obj;};
    
    ClassDef(KVINDRAReconDataAnalyser, 0) //For analysing reconstructed INDRA data
 };

=== added file 'KVIndra/analysis/KVINDRAReconRoot.cpp'
--- KVIndra/analysis/KVINDRAReconRoot.cpp	1970-01-01 00:00:00 +0000
+++ KVIndra/analysis/KVINDRAReconRoot.cpp	2011-11-08 15:13:29 +0000
@@ -0,0 +1,175 @@
+#define KVINDRAReconRoot_cxx
+
+#include "KVINDRAReconRoot.h"
+#include "TFile.h"
+#include "TTree.h"
+#include "KVDataRepository.h"
+#include "KVDataSet.h"
+#include "KVDataRepositoryManager.h"
+#include "KVDataAnalyser.h"
+#include "KVINDRAReconNuc.h"
+
+ClassImp(KVINDRAReconRoot)
+
+////////////////////////////////////////////////////////////////////////////////
+// BEGIN_HTML <!--
+/* -->
+<h2>KVINDRAReconRoot</h2>
+<h4>Generation of fully-identified and calibrated INDRA data files</h4>
+<!-- */
+// --> END_HTML
+////////////////////////////////////////////////////////////////////////////////
+
+void KVINDRAReconRoot::InitAnalysis(void)
+{
+}
+
+//_____________________________________
+void KVINDRAReconRoot::InitRun(void)
+{
+   //When each run is opened, we create a new ROOT file for the identified events we
+   //are going to generate from the reconstructed events we are reading.
+   // By default this file will be written in the same data repository as the recon data file we are reading.
+   // This can be changed by setting the environment variable(s):
+   //
+   //     ReconRoot.DataAnalysisTask.OutputRepository:     [name of repository]
+   //     [name of dataset].ReconRoot.DataAnalysisTask.OutputRepository:         [name of repository]
+   //
+   // If no value is set for the current dataset (second variable), the value of the
+   // first variable will be used. If neither is defined, the new file will be written in the same repository as
+   // the recon file (if possible, i.e. if repository is not remote).
+
+   // get dataset to which we must associate new run
+   KVDataSet* OutputDataset =
+      gDataRepositoryManager->GetDataSet(
+         gDataSet->GetDataSetEnv("ReconRoot.DataAnalysisTask.OutputRepository", gDataRepository->GetName()),
+         gDataSet->GetName() );
+
+   //create new ROOT file for identified events
+   fRunNumber = gIndra->GetCurrentRunNumber();
+   fIdentFile = OutputDataset->NewRunfile("root", fRunNumber);
+
+
+		fIdentTree = new TTree("ReconstructedEvents", Form("%s : %s : fully-identified & calibrated events created from recon data",
+			 	gIndraDB->GetRun(fRunNumber)->GetName(),
+            gIndraDB->GetRun(fRunNumber)->GetTitle())
+            );
+#if ROOT_VERSION_CODE > ROOT_VERSION(5,25,4)
+#if ROOT_VERSION_CODE < ROOT_VERSION(5,26,1)
+   // The TTree::OptimizeBaskets mechanism is disabled, as for ROOT versions < 5.26/00b
+   // this lead to a memory leak
+   fIdentTree->SetAutoFlush(0);
+#endif
+#endif
+      //leaves for reconstructed events
+		fIdentTree->Branch("INDRAReconEvent", "KVINDRAReconEvent", GetEventReference(), 10000000, 0)->SetAutoDelete(kFALSE);
+
+      Info("InitRun", "Created identified/calibrated data tree %s : %s", fIdentTree->GetName(), fIdentTree->GetTitle());
+
+   // initialise identifications
+   gIndra->InitializeIDTelescopes();
+
+   // print status of identifications
+   gIndra->PrintStatusOfIDTelescopes();
+   // print status of calibrations
+   gIndra->PrintCalibStatusOfDetectors();
+   
+		for(register int i=0; i<15; i++) Acodes[i]=0;
+		for(register int i=0; i<4; i++) Astatus[i]=0;
+}
+
+//_____________________________________
+Bool_t KVINDRAReconRoot::Analysis(void)
+{
+   //For each event we:
+   //     perform primary & secondary event identification and calibration and fill tree
+   fEventNumber = GetEvent()->GetNumber();
+	 CountStatus();
+   if (GetEvent()->GetMult() > 0) {
+      GetEvent()->IdentifyEvent();
+      GetEvent()->CalibrateEvent();
+      GetEvent()->SecondaryIdentCalib();
+	 CountCodes();
+   }
+   fIdentTree->Fill();
+   return kTRUE;
+}
+void KVINDRAReconRoot::CountCodes()
+{
+	KVINDRAReconNuc* particle;
+		for(register int i=0; i<15; i++) codes[i]=0;
+		while ( (particle = GetEvent()->GetNextParticle()) ){
+			int code = particle->GetCodes().GetVedaIDCode();
+			if((code==0&&particle->IsIdentified())||(code>0&&code<15)) codes[code]+=1;
+    	}
+		int ntot=0;
+		for(register int i=0; i<15; i++){
+				ntot+=codes[i];
+				Acodes[i]+=codes[i];
+		}
+}
+void KVINDRAReconRoot::CountStatus()
+{
+	KVINDRAReconNuc* particle;
+		for(register int i=0; i<4; i++) status[i]=0;
+		while ( (particle = GetEvent()->GetNextParticle()) ){
+			status[particle->GetStatus()]+=1;
+    	}
+		int ntot=0;
+		for(register int i=0; i<4; i++){
+				ntot+=status[i];
+				Astatus[i]+=status[i];
+		}
+}
+
+//_____________________________________
+void KVINDRAReconRoot::EndRun(void)
+{
+   //At the end of each run we:
+   //      write the tree into the new file
+   //      close the file
+   //      copy the file into the required repository (see InitRun)
+   //      update the available runlist
+
+   fIdentFile->cd();
+
+	gDataAnalyser->WriteBatchInfo(fIdentTree);
+
+    GetRawData()->CloneTree(-1,"fast"); //copy raw data tree to file
+    GetGeneData()->CloneTree(-1,"fast"); //copy pulser & laser (gene) tree to file
+
+    fIdentFile->Write();
+
+   //add file to repository
+   // get dataset to which we must associate new run
+   KVDataSet* OutputDataset =
+      gDataRepositoryManager->GetDataSet(
+         gDataSet->GetDataSetEnv("ReconRoot.DataAnalysisTask.OutputRepository", gDataRepository->GetName()),
+         gDataSet->GetName() );
+
+   OutputDataset->CommitRunfile("root", gIndra->GetCurrentRunNumber(),
+                           fIdentFile);
+   fIdentFile = 0;
+   fIdentTree = 0;
+   
+   cout << endl << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+   cout << endl << "         BILAN  DES  COURSES " << endl << endl;;
+int ntot=0;		for(register int i=0; i<4; i++)ntot+=Astatus[i];
+
+		for(register int i=0; i<4; i++){
+				cout << "   Status" <<i<< "\t" << Astatus[i] <<"\t"<<setprecision(2)<<100.*Astatus[i]/(1.*ntot)<<" %"<< endl;
+		}
+		cout << endl << "  Total all status : " << ntot <<endl<<endl;
+ntot=0;
+		for(register int i=0; i<15; i++)ntot+=Acodes[i];
+		for(register int i=0; i<15; i++){
+				cout << "   Code" <<i<< "\t" << Acodes[i] <<"\t"<<setprecision(2)<<100.*Acodes[i]/(1.*ntot)<<" %"<< endl;
+		}
+		cout << endl << "  Total all codes : " << ntot <<endl;
+   cout << endl << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+}
+
+//_____________________________________
+void KVINDRAReconRoot::EndAnalysis(void)
+{
+}

=== added file 'KVIndra/analysis/KVINDRAReconRoot.h'
--- KVIndra/analysis/KVINDRAReconRoot.h	1970-01-01 00:00:00 +0000
+++ KVIndra/analysis/KVINDRAReconRoot.h	2011-11-08 15:13:29 +0000
@@ -0,0 +1,41 @@
+#ifndef KVINDRAReconRoot_h
+#define KVINDRAReconRoot_h
+
+#include "KVSelector.h"
+
+class TFile;
+class TTree;
+
+class KVINDRAReconRoot:public KVSelector {
+	int codes[15];
+	int status[4];
+	int Acodes[15];
+	int Astatus[4];
+
+   protected:
+   TFile *fIdentFile;           //new file
+   TTree *fIdentTree;           //new tree
+   Int_t fRunNumber;
+   Int_t fEventNumber;
+
+ public:
+    KVINDRAReconRoot() {
+      fIdentFile = 0;
+      fIdentTree = 0;
+   };
+   virtual ~ KVINDRAReconRoot() {
+   };
+
+   virtual void InitRun();
+   virtual void EndRun();
+   virtual void InitAnalysis();
+   virtual Bool_t Analysis();
+   virtual void EndAnalysis();
+   
+   void CountStatus();
+   void CountCodes();
+
+   ClassDef(KVINDRAReconRoot, 0) //Generation of fully-identified and calibrated INDRA data files
+};
+
+#endif

=== modified file 'KVIndra/analysis/KVSelector.cpp'
--- KVIndra/analysis/KVSelector.cpp	2011-04-06 13:10:17 +0000
+++ KVIndra/analysis/KVSelector.cpp	2011-11-08 15:13:29 +0000
@@ -176,7 +176,6 @@
    SafeDelete(fPartCond);
 	delete lhisto;
 	delete ltree;
-
 }
 
 void KVSelector::Init(TTree * tree)
@@ -194,7 +193,7 @@
    else
       fTreeOffset = 0;
 
-	data=0;
+	data=0;b_data=0;
    fChain->SetBranchAddress( fBranchName.Data() , &data, &b_data);
    b_data->SetAutoDelete(kFALSE);
 
@@ -206,6 +205,8 @@
    {
       fKVDataSelector->Init();
    }
+	// tell the data analyser who we are
+	gDataAnalyser->RegisterUserClass(this);
 	gDataAnalyser->preInitAnalysis();
    InitAnalysis();              //user initialisations for analysis
 	gDataAnalyser->postInitAnalysis();
@@ -306,10 +307,10 @@
    // When running with PROOF SlaveBegin() is called in each slave
    // Initialize the tree branches.
 
-   Init(tree);
+/*    Init(tree);
 
    TString option = GetOption();
-
+ */
 }
 
 #ifdef __WITHOUT_TSELECTOR_LONG64_T
@@ -336,6 +337,7 @@
       cout << " +++ " << totentry << " events processed +++ " << endl;
 
    fChain->GetTree()->GetEntry(fTreeEntry);
+	gDataAnalyser->preAnalysis();
 
    //additional selection criteria ?
    if(fPartCond){
@@ -365,7 +367,6 @@
 
    Bool_t ok_anal = kTRUE;
 
-	gDataAnalyser->preAnalysis();
    if (needToSelect) {
       ok_anal = fKVDataSelector->ProcessCurrentEntry(); //Data Selection and user analysis
    } else

=== modified file 'KVIndra/analysis/KVSelector.h'
--- KVIndra/analysis/KVSelector.h	2011-01-12 09:54:17 +0000
+++ KVIndra/analysis/KVSelector.h	2011-11-08 15:13:29 +0000
@@ -117,6 +117,11 @@
    KVINDRAReconEvent *GetEvent() {
       return data;
    };
+   Int_t GetEventNumber() {
+		// returns number of currently analysed event
+		// N.B. this may be different to the TTree/TChain entry number etc.
+      return data->GetNumber();
+   };
 
    Int_t Version() const {
       return 2;

=== modified file 'KVIndra/detectors/KVChIo.cpp'
--- KVIndra/detectors/KVChIo.cpp	2011-05-19 08:11:09 +0000
+++ KVIndra/detectors/KVChIo.cpp	2011-11-08 15:13:29 +0000
@@ -113,10 +113,11 @@
    //Any change in the coder pedestal between the current run and the effective pedestal
    //of the channel-volt calibration (GetCanal(V=0)) is automatically corrected for.
    //
-   //Returns -1 if PG <-> Volts calibration is not available
+   //Returns GG calculated from PG if GG <-> Volts calibration is not available
 
-      if (!fChVoltGG || !fChVoltGG->GetStatus())
-         return -1;
+      if (!fChVoltGG || !fChVoltGG->GetStatus()){
+         return GetGGfromPG(GetCanalPGFromVolts(volts));
+      }
       Int_t chan = TMath::Nint(fChVoltGG->Invert(volts) + GetPedestal("GG") - fChVoltGG->Invert(0));
       return chan;
 }

=== modified file 'KVIndra/detectors/KVSilicon.cpp'
--- KVIndra/detectors/KVSilicon.cpp	2011-05-19 08:11:09 +0000
+++ KVIndra/detectors/KVSilicon.cpp	2011-11-08 15:13:29 +0000
@@ -108,10 +108,11 @@
    //Any change in the coder pedestal between the current run and the effective pedestal
    //of the channel-volt calibration (GetCanal(V=0)) is automatically corrected for.
    //
-   //Returns -1 if PG <-> Volts calibration is not available
+   //Returns GG calculated from PG if GG <-> Volts calibration is not available
 
-      if (!fChVoltGG || !fChVoltGG->GetStatus())
-         return -1;
+      if (!fChVoltGG || !fChVoltGG->GetStatus()){
+         return GetGGfromPG(GetCanalPGFromVolts(volts));
+      }
       Int_t chan = TMath::Nint(fChVoltGG->Invert(volts) + GetPedestal("GG") - fChVoltGG->Invert(0));
       return chan;
 }

=== modified file 'KVIndra/events/KVINDRAReconEvent.cpp'
--- KVIndra/events/KVINDRAReconEvent.cpp	2010-05-06 10:05:28 +0000
+++ KVIndra/events/KVINDRAReconEvent.cpp	2011-11-08 15:13:29 +0000
@@ -23,6 +23,7 @@
 #include "KVTelescope.h"
 #include "KVDetector.h"
 #include "KVCsI.h"
+#include "KVSilicon.h"
 #include "KVDetectorEvent.h"
 #include "KVINDRAReconNuc.h"
 #include "KVINDRA.h"
@@ -30,6 +31,7 @@
 #include "KVIDCsI.h"
 #include "KVIDGCsI.h"
 #include "KVDataSet.h"
+#include "KVChIo.h"
 
 ClassImp(KVINDRAReconEvent);
 
@@ -59,6 +61,7 @@
 {
    //default initialisations
    fCodeMask = 0;
+   fHitGroups=0;
 }
 
 
@@ -74,6 +77,7 @@
       delete fCodeMask;
       fCodeMask = 0;
    }
+   SafeDelete(fHitGroups);
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -137,77 +141,6 @@
    }
 }
 
-//_____________________________________________________________________________
-
-//void KVINDRAReconEvent::GeometricFilter()
-//{
-//      //Private method, called during event reconstruction if SetGeometricFilter(kTRUE)
-//      //was previously called.
-//      //From the "coherence" analysis (see AnalyseGroup) we only keep particles which
-//      //can be correctly reconstructed either with or without subtraction of other
-//      //particles' calculated energy losses, and we make sure that particles actually
-//      //get stopped by the detectors.
-//      //
-//      //An additional energy threshold can be given (SetThreshold) which defines the
-//      //minimum energy in MeV/nucleon for a particle to be accepted (i.e. identification
-//      //threshold).
-//      //
-//      //Accepted particles have IsOK = kTRUE, rejected particles have IsOK = kFALSE
-//
-//      for(Int_t i=1; i<=GetMult(); i++)
-//      {
-//              KVINDRAReconNuc *nuc = GetParticle(i);
-//              nuc->SetIsOK();
-//              //from the "coherence" analysis (see AnalyseGroup) we only keep particles which
-//              //can be correctly reconstructed either with or without subtraction of other
-//              //particles' calculated energy losses
-//              if(nuc->GetAnalStatus() > 1) {
-//                      nuc->SetIsOK(kFALSE);
-//              }
-//              //make sure only one particle stopped in "stopping" detector
-//              if( nuc->GetStoppingDetector()->GetHits()->GetSize() > 1){
-//                      nuc->SetIsOK(kFALSE);
-//              }
-//              //make sure particle actually stopped in detector
-//              if(((KVNucleus*)nuc->GetStoppingDetector()->GetHits()->At(0))->GetEnergy()>0.0) {
-//                      nuc->SetIsOK(kFALSE);
-//              }
-//              if(nuc->IsOK())
-//              {
-//                      //particle accepted so far - get A, Z and energy from simulated particle
-//                      //and detector energy losses.
-//                      //Particle may still be rejected by identification threshold - see below !!!
-//                              KVNucleus* simpart = (KVNucleus*)nuc->GetStoppingDetector()->GetHits()->At(0);
-//                              if(!simpart)cout<<"No simpart"<<endl;
-//                              nuc->SetSimPart(simpart);
-//                              nuc->SetZ(simpart->GetZ());
-//                              if(nuc->GetZ()<3)
-//                              {
-//                                      //for LCP reaching CsI, use true isotope mass
-//                                      if(nuc->StoppedInCsI())
-//                                      {
-//                                              nuc->SetA(simpart->GetA());
-//                                      }
-//                              }
-//                              //add up corrected energy losses in detectors
-//                              Float_t fEnew=0.0;
-//                              for(UInt_t d=0; d<nuc->GetNumDet(); d++)
-//                              {
-//                                      fEnew += nuc->GetDetector(d)->GetCorrectedEnergy(nuc->GetZ(),nuc->GetA());
-//                              }
-//                              nuc->SetEnergy(fEnew);
-//                              nuc->GetAnglesFromTelescope();
-//                              nuc->SetEnergy(fEnew);
-//                              //identification threshold in mev/nuc - is 0.0 if not set
-//                              if((nuc->GetEnergy()/nuc->GetA())<fThreshold){
-//                                      nuc->SetIsOK(kFALSE);
-//                              }
-//              }
-//      }
-//}
-
-////////////////////////////////////////////////////////////////////////////////////////
-
 KVINDRAReconNuc *KVINDRAReconEvent::GetNextParticle(Option_t * opt)
 {
    //Use this method to iterate over the list of particles in the event.
@@ -342,20 +275,254 @@
 
 void KVINDRAReconEvent::IdentifyEvent()
 {
-   //Performs event identification (see KVReconstructedEvent::IdentifyEvent), and then
-   //particles stopping in first member of a telescope (KVReconstructedNucleus::GetStatus=3) are
-   //labelled with VEDA ID code kIDCode5 (Zmin)
-  //Unidentified particles receive the general ID code for non-identified particles (kIDCode14)
+   // Performs event identification (see KVReconstructedEvent::IdentifyEvent), and then
+   // particles stopping in first member of a telescope (GetStatus() == KVReconstructedNucleus::kStatusStopFirstStage) are
+   // labelled with VEDA ID code kIDCode5 (Zmin)
+	// 
+	//   When CsI identification gives a gamma, we unset the 'analysed' state of all detectors
+	// in front of the CsI and reanalyse the group in order to reconstruct and identify charged particles
+	// stopping in them.
+	//
+   // Unidentified particles receive the general ID code for non-identified particles (kIDCode14)
 
    KVReconstructedEvent::IdentifyEvent();
    KVINDRAReconNuc *d=0;
-   while ((d = GetNextParticle())) {
-      if (d->IsIdentified() && d->GetStatus() == 3) {
-         d->SetIDCode( kIDCode5 ); // Zmin
-      }
-      else if(!d->IsIdentified()){
+	int mult = GetMult();
+	KVUniqueNameList gammaGroups;//list of groups with gammas identified in CsI
+	ResetGetNextParticle();
+	
+   while((d = GetNextParticle())){
+      if (d->IsIdentified()&&d->GetStatus() == KVReconstructedNucleus::kStatusStopFirstStage) {
+         	d->SetIDCode( kIDCode5 ); // Zmin
+		}
+      else if (d->IsIdentified()&&d->GetCodes().TestIDCode(kIDCode0)){
+				// gamma identified in CsI
+				// reset analysed state of all detectors in front of CsI
+			if(d->GetCsI()){
+				if(d->GetCsI()->GetAlignedDetectors()){
+					TIter next(d->GetCsI()->GetAlignedDetectors());
+					KVDetector*det=(KVDetector*)next();//first detector = CsI
+					while( (det = (KVDetector*)next()) ) det->SetAnalysed(kFALSE);
+					gammaGroups.Add(d->GetGroup());
+				}
+				else
+				{
+					Error("IdentifyEvent", "particule id gamma, no aligned detectors???");
+					d->Print();
+				}	
+			}
+			else
+			{
+				Error("IdentifyEvent", "particule identified as gamma, has no CsI!!");
+				d->Print();
+			}
+		}
+   }
+	
+	// perform secondary reconstruction in groups with detected gammas
+	int ngamG = gammaGroups.GetEntries();
+	if(ngamG){
+		for(int i=0; i<ngamG; i++){
+			AnalyseGroup( (KVGroup*)gammaGroups.At(i) );
+		}
+	}
+	if(GetMult()>mult) {
+		/*Info("IdentifyEvent", "Event#%d: Secondary reconstruction (gammas) -> %d new particles",
+			GetNumber(), GetMult()-mult);*/
+
+		// identify new particles generated in secondary reconstruction 
+   	KVReconstructedEvent::IdentifyEvent();
+		ResetGetNextParticle();
+	
+   	while((d = GetNextParticle())){
+      	if (d->IsIdentified()&&d->GetStatus() == KVReconstructedNucleus::kStatusStopFirstStage) {
+         	d->SetIDCode( kIDCode5 ); // Zmin
+			}
+      	else if(!d->IsIdentified()){
+         	d->SetIDCode( kIDCode14 );
+      	}
+		}
+		/*
+		for(int i=mult+1; i<=GetMult(); i++){
+			d = GetParticle(i);
+			if(d->IsIdentified())
+				printf("\t%2d: Ring %2d Module %2d Z=%2d  A=%3d  code=%d\n",i,d->GetRingNumber(),
+						d->GetModuleNumber(),d->GetZ(),d->GetA(),d->GetCodes().GetVedaIDCode());
+			else
+				printf("\t%2d: Ring %2d Module %2d UNIDENTIFIED status=%d\n", i,d->GetRingNumber(),
+						d->GetModuleNumber(), d->GetStatus());
+		}
+		*/
+	}
+}
+
+void KVINDRAReconEvent::SecondaryIdentCalib()
+{
+	// Perform identifications and calibrations of particles not included
+   // in first round (methods IdentifyEvent() and CalibrateEvent()).
+   //
+   // Here we treat particles with GetStatus()==KVReconstructedNucleus::kStatusOKafterSub
+   // after subtracting the energy losses of all previously calibrated particles in group from the
+   // measured energy losses in the detectors they crossed.
+   
+   if(!fHitGroups)
+   	fHitGroups = new KVUniqueNameList;
+   else
+   	fHitGroups->Clear();
+   // build list of hit groups
+   KVINDRAReconNuc*d;
+   while((d = GetNextParticle())) fHitGroups->Add(d->GetGroup());
+   
+   //loop over hit groups
+   TIter next_grp(fHitGroups);
+   KVGroup* grp;
+   while( (grp = (KVGroup*)next_grp()) ){
+   	SecondaryAnalyseGroup(grp);
+   }
+
+	// set "unidentified" code for any remaining unidentified particle	
+	ResetGetNextParticle();
+   while((d = GetNextParticle())){
+   	if(!d->IsIdentified()){
          d->SetIDCode( kIDCode14 );
       }
+	}
+}
+
+void KVINDRAReconEvent::SecondaryAnalyseGroup(KVGroup* grp)
+{
+	// Perform identifications and calibrations of particles not included
+   // in first round (methods IdentifyEvent() and CalibrateEvent()).
+   //
+   // Here we treat particles with GetStatus()==KVReconstructedNucleus::kStatusOKafterSub
+   // after subtracting the energy losses of all previously calibrated particles in group from the
+   // measured energy losses in the detectors they crossed.
+   
+   // loop over al identified & calibrated particles in group and subtract calculated
+   // energy losses from all detectors
+   KVINDRAReconNuc* nuc;
+   TList sixparts;
+   TIter parts(grp->GetParticles());
+   while( (nuc = (KVINDRAReconNuc*)parts()) ){
+   	if(nuc->IsIdentified() && nuc->IsCalibrated()){
+   		nuc->SubtractEnergyFromAllDetectors();
+   		// reconstruct particles from pile-up in silicon detectors revealed by coherency CsIR/L - SiCsI
+   		if(nuc->IsSiPileup() && nuc->GetSi()->GetEnergy()>0.1){
+   			KVINDRAReconNuc* SIX = AddParticle();
+   			SIX->Reconstruct(nuc->GetSi());
+   			sixparts.Add(SIX);
+   		}
+   	}
+   }
+   // reanalyse group
+   grp->AnalyseParticles();
+   
+   Int_t nident=0;//number of particles identified in each step
+   if(sixparts.GetEntries()){   // identify any particles added by coherency CsIR/L - SiCsI
+   	KVINDRAReconNuc* SIX;
+   	TIter nextsix(&sixparts);
+   	while( (SIX = (KVINDRAReconNuc*)nextsix()) ){
+   		if( SIX->GetStatus() == KVReconstructedNucleus::kStatusOK ){
+   			SIX->Identify();
+   			if(SIX->IsIdentified()) {
+   				nident++;
+   				if(SIX->GetCodes().TestIDCode( kIDCode5 )) SIX->SetIDCode( kIDCode7 );
+   				else SIX->SetIDCode( kIDCode6 );
+   				SIX->Calibrate();
+   				if(SIX->IsCalibrated()) SIX->SubtractEnergyFromAllDetectors();
+   			}
+   			else {
+   				// failure of ChIo-Si identification: particle stopped in ChIo ?
+            	// estimation of Z (minimum) from energy loss (if detector is calibrated)
+            	UInt_t zmin = ((KVDetector*)SIX->GetDetectorList()->Last())->FindZmin(-1., SIX->GetMassFormula());
+            	if( zmin ){
+               	SIX->SetZ( zmin );
+               	SIX->SetIsIdentified();
+               	// "Identifying" telescope is taken from list of ID telescopes
+               	// to which stopping detector belongs
+               	SIX->SetIdentifyingTelescope( (KVIDTelescope*)SIX->GetStoppingDetector()->GetIDTelescopes()->Last() );
+   					SIX->Calibrate();
+           		}
+           		SIX->SetIDCode( kIDCode7 );
+   			}
+   		}
+   	}
+   }
+   if(nident){ // newly-identified particles may change status of others in group
+   	// reanalyse group
+   	grp->AnalyseParticles();
+   	nident=0;
+   }
+   
+   TIter parts2(grp->GetParticles()); // list may have changed if we have added particles
+   // identify & calibrate any remaining particles with status=KVReconstructedNucleus::kStatusOK
+   while( (nuc = (KVINDRAReconNuc*)parts2()) ){
+   	if(!nuc->IsIdentified() && nuc->GetStatus()==KVReconstructedNucleus::kStatusOK && !nuc->IsIdentified()){
+   		nuc->ResetNSegDet();
+   		nuc->Identify();
+   		if(nuc->IsIdentified()) {
+   			nident++;
+   			nuc->Calibrate();
+   			if(nuc->IsCalibrated()) nuc->SubtractEnergyFromAllDetectors();
+   		}
+   	}
+   }
+   if(nident){ // newly-identified particles may change status of others in group
+   	// reanalyse group
+   	grp->AnalyseParticles();
+   	nident=0;
+   }
+   
+   // any kStatusOKafterShare particles ?
+   TList shareChIo;
+   parts2.Reset();
+   while( (nuc = (KVINDRAReconNuc*)parts2()) ){
+   	if(!nuc->IsIdentified() && nuc->GetStatus()==KVReconstructedNucleus::kStatusOKafterShare){
+   		shareChIo.Add(nuc);
+   	}
+   }
+   Int_t nshares = shareChIo.GetEntries();
+   if(nshares){
+   	KVChIo* theChIo = ((KVINDRAReconNuc*)shareChIo.At(0))->GetChIo();
+   	if(theChIo && nshares>1){
+   		// divide chio energy equally
+   		Double_t Eshare = theChIo->GetEnergyLoss()/nshares;
+   		theChIo->SetEnergyLoss(Eshare);
+   		// modify PG and GG of ChIo according to new energy loss
+   		Double_t volts = theChIo->GetVoltsFromEnergy(Eshare);
+   		Double_t GG = theChIo->GetCanalGGFromVolts(volts);	
+   		Double_t PG = theChIo->GetCanalPGFromVolts(volts);
+			theChIo->GetACQParam("PG")->SetData(TMath::Min(4095,(Int_t)PG));
+			theChIo->GetACQParam("GG")->SetData(TMath::Min(4095,(Int_t)GG));
+		}
+   	// now try to identify
+   	TIter nextSh(&shareChIo);
+   	while( (nuc = (KVINDRAReconNuc*)nextSh()) ){
+   		nuc->SetNSegDet(10);
+   		nuc->Identify();
+   		if(nuc->IsIdentified()) {
+   			nuc->SetIDCode( kIDCode8 );
+   			nuc->Calibrate();
+   		}
+   	}
+   }
+   
+   // any remaining stopped in first stage particles ?
+   parts2.Reset();
+   while( (nuc = (KVINDRAReconNuc*)parts2()) ){
+   	if(!nuc->IsIdentified() && nuc->GetStatus()==KVReconstructedNucleus::kStatusStopFirstStage){
+            	// estimation of Z (minimum) from energy loss (if detector is calibrated)
+            	UInt_t zmin = ((KVDetector*)nuc->GetDetectorList()->Last())->FindZmin(-1., nuc->GetMassFormula());
+            	if( zmin ){
+               	nuc->SetZ( zmin );
+               	nuc->SetIsIdentified();
+               	// "Identifying" telescope is taken from list of ID telescopes
+               	// to which stopping detector belongs
+               	nuc->SetIdentifyingTelescope( (KVIDTelescope*)nuc->GetStoppingDetector()->GetIDTelescopes()->Last() );
+   					nuc->Calibrate();
+           		}
+           		nuc->SetIDCode( kIDCode5 );	 
+   	}
    }
 }
 

=== modified file 'KVIndra/events/KVINDRAReconEvent.h'
--- KVIndra/events/KVINDRAReconEvent.h	2009-12-11 10:05:59 +0000
+++ KVIndra/events/KVINDRAReconEvent.h	2011-11-08 15:13:29 +0000
@@ -38,6 +38,7 @@
          fCodeMask = new KVINDRACodeMask;
       return fCodeMask;
    };
+   KVUniqueNameList* fHitGroups;//! non-persistent pointer to list of hit groups used in SecondaryIdentAndCalib()
 
  public:
 
@@ -70,6 +71,10 @@
    void IdentifyEvent();
    void ChangeFragmentMasses(UChar_t mass_formula);
    
+      virtual void SecondaryIdentCalib();
+void SecondaryAnalyseGroup(KVGroup* grp);
+
+   
    ClassDef(KVINDRAReconEvent, 6)       //Event reconstructed from energy losses in INDRA array
 };
 

=== modified file 'KVIndra/idmaps/KVIDGChIoSi.cpp'
--- KVIndra/idmaps/KVIDGChIoSi.cpp	2010-06-16 12:49:46 +0000
+++ KVIndra/idmaps/KVIDGChIoSi.cpp	2011-11-08 15:13:29 +0000
@@ -247,13 +247,13 @@
 	 {
 		 //identified particles below (left of) Bragg line : Z is a Zmin
     	 if (fBragg && fBragg->WhereAmI(x, y, "left")){
-			  const_cast<KVIDGChIoSi*>(this)->fICode = k_LeftOfBragg;
+			  const_cast<KVIDGChIoSi*>(this)->fICode = k_LeftOfBragg;idr->SetComment("Point to identify below Bragg curve. Z given is a Zmin");
 			  }
     	 //if a particle is well-identified (i.e. not too far from the identification lines)
 	 	 //but it lies below the 'Punch_through' line, we give it a warning code
     	 if (fPunch && fPunch->WhereAmI(x, y, "below")){
 			  const_cast<KVIDGChIoSi*>(this)->fICode = k_BelowPunchThrough;
-			  idr->SetComment("WARNING: Point to identify falls below punch-through line drawn for grid");
+			  idr->SetComment("warning: point below punch-through line");
 			  }
 		 idr->IDquality = fICode;
 	 }

=== modified file 'KVIndra/idtelescopes/KVIDChIoCsI_camp5.cpp'
--- KVIndra/idtelescopes/KVIDChIoCsI_camp5.cpp	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDChIoCsI_camp5.cpp	2011-11-08 15:13:29 +0000
@@ -95,7 +95,7 @@
 
 //________________________________________________________________________________________//
 
-Bool_t KVIDChIoCsI_camp5::Identify(KVIdentificationResult* idr)
+Bool_t KVIDChIoCsI_camp5::Identify(KVIdentificationResult* idr, Double_t x, Double_t y)
 {
    //Particle identification and code setting using identification grids.
 
@@ -104,8 +104,8 @@
 		idr->SetIDType( GetType() );
 		idr->IDattempted = kTRUE;
 	
-      Double_t cigg = GetIDMapY("GG");
-      Double_t lumtot = GetIDMapX();
+      Double_t cigg = (y<0. ? GetIDMapY("GG") : y);
+      Double_t lumtot = (x<0. ? GetIDMapX() : x);
 
       KVIDGrid* theIdentifyingGrid = 0;
 
@@ -115,7 +115,7 @@
       if( fGGgrid->GetQualityCode() > KVIDZAGrid::kICODE6 && fPGgrid ){ //we have to try PG grid (if there is one)
 
          // try Z & A identification in ChIo(PG)-CsI(H) map
-         Double_t cipg = GetIDMapY("PG");
+         Double_t cipg = (y<0. ? GetIDMapY("PG") : y);
          fPGgrid->Identify(lumtot, cipg, idr);
          theIdentifyingGrid = (KVIDGrid*)fPGgrid;
 		}

=== modified file 'KVIndra/idtelescopes/KVIDChIoCsI_camp5.h'
--- KVIndra/idtelescopes/KVIDChIoCsI_camp5.h	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDChIoCsI_camp5.h	2011-11-08 15:13:29 +0000
@@ -32,7 +32,7 @@
    virtual void Initialize(void);
    virtual Double_t GetIDMapX(Option_t * opt = "");
    virtual Double_t GetIDMapY(Option_t * opt = "");
-   Bool_t Identify(KVIdentificationResult*);
+   Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    ClassDef(KVIDChIoCsI_camp5,1)//ChIo-CsI id with grids for INDRA_camp5
 };

=== modified file 'KVIndra/idtelescopes/KVIDChIoCsI_e475s.cpp'
--- KVIndra/idtelescopes/KVIDChIoCsI_e475s.cpp	2011-05-13 15:16:08 +0000
+++ KVIndra/idtelescopes/KVIDChIoCsI_e475s.cpp	2011-11-08 15:13:29 +0000
@@ -77,15 +77,15 @@
 }
 //________________________________________________________________________________________//
 
-Bool_t KVIDChIoCsI_e475s::Identify(KVIdentificationResult* IDR)
+Bool_t KVIDChIoCsI_e475s::Identify(KVIdentificationResult* IDR, Double_t x, Double_t y)
 {
     //Particle identification and code setting using identification grid KVIDGChIoSi
 
 		IDR->SetIDType( GetType() );
 		IDR->IDattempted = kTRUE;
     //identification
-    Double_t varX = GetIDMapX();
-    Double_t varY = GetIDMapY();
+    Double_t varX = (x<0. ? GetIDMapX() : x);
+    Double_t varY = (y<0. ? GetIDMapY() : y);
 
     if (fidgrid->IsIdentifiable(varX,varY))
         fidgrid->Identify(varX,varY,IDR);

=== modified file 'KVIndra/idtelescopes/KVIDChIoCsI_e475s.h'
--- KVIndra/idtelescopes/KVIDChIoCsI_e475s.h	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDChIoCsI_e475s.h	2011-11-08 15:13:29 +0000
@@ -29,7 +29,7 @@
 
 	virtual Double_t GetIDMapX(Option_t * opt = "");
    virtual Double_t GetIDMapY(Option_t * opt = "");
-	virtual Bool_t Identify(KVIdentificationResult*);
+	virtual Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
 	virtual void CalculateParticleEnergy(KVReconstructedNucleus * nuc);
 

=== modified file 'KVIndra/idtelescopes/KVIDChIoSi.cpp'
--- KVIndra/idtelescopes/KVIDChIoSi.cpp	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDChIoSi.cpp	2011-11-08 15:13:29 +0000
@@ -49,15 +49,15 @@
 
 //________________________________________________________________________________________//
 
-Bool_t KVIDChIoSi::Identify(KVIdentificationResult * IDR)
+Bool_t KVIDChIoSi::Identify(KVIdentificationResult * IDR, Double_t x, Double_t y)
 {
     //Particle identification and code setting using identification grid KVIDGChIoSi
 
 		IDR->SetIDType( GetType() );
 		IDR->IDattempted = kTRUE;
     //identification
-    Double_t chio = GetIDMapY();
-    Double_t si = GetIDMapX();
+    Double_t chio = (y<0. ? GetIDMapY() : y);
+    Double_t si = (x<0. ? GetIDMapX() : x);
 
     if (ChIoSiGrid->IsIdentifiable(si,chio))
         ChIoSiGrid->Identify(si,chio,IDR);
@@ -85,7 +85,9 @@
     {
         IDR->IDcode = kIDCode5;
         IDR->Z = fchio->FindZmin();
+        IDR->SetComment("point to identify left of Si threshold line (bruit/arret ChIo?)");
     }
+    if(quality==KVIDGChIoSi::k_RightOfEmaxSi) IDR->SetComment("point to identify has E_Si > Emax_Si i.e. codeur is saturated. Unidentifiable");
 
     return kTRUE;
 }

=== modified file 'KVIndra/idtelescopes/KVIDChIoSi.h'
--- KVIndra/idtelescopes/KVIDChIoSi.h	2011-05-26 12:14:32 +0000
+++ KVIndra/idtelescopes/KVIDChIoSi.h	2011-11-08 15:13:29 +0000
@@ -37,7 +37,7 @@
     KVIDChIoSi();
     virtual ~ KVIDChIoSi();
 
-   virtual Bool_t Identify(KVIdentificationResult *);
+   virtual Bool_t Identify(KVIdentificationResult *, Double_t x=-1., Double_t y=-1.);
 
    Double_t GetIDMapX(Option_t * opt = "");
    Double_t GetIDMapY(Option_t * opt = "");

=== modified file 'KVIndra/idtelescopes/KVIDChIoSi75_camp5.cpp'
--- KVIndra/idtelescopes/KVIDChIoSi75_camp5.cpp	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDChIoSi75_camp5.cpp	2011-11-08 15:13:29 +0000
@@ -80,7 +80,7 @@
 
 //________________________________________________________________________________________//
 
-Bool_t KVIDChIoSi75_camp5::Identify(KVIdentificationResult* IDR)
+Bool_t KVIDChIoSi75_camp5::Identify(KVIdentificationResult* IDR, Double_t x, Double_t y)
 {
     //Particle identification and code setting using identification grids.
 
@@ -90,8 +90,9 @@
 
     if ( fGGgrid )
     {
-
-        fGGgrid->Identify(GetIDMapX("GG"), GetIDMapY("GG"), IDR);
+			Double_t cigg = (y<0. ? 		GetIDMapY("GG")	: y);
+			Double_t sigg = (x<0. ? 		GetIDMapX("GG")	: x);
+        fGGgrid->Identify(sigg, cigg, IDR);
         theIdentifyingGrid =(KVIDGrid*)fGGgrid;
 
     }
@@ -100,7 +101,9 @@
 
         if ( fPGgrid )
         {
-            fPGgrid->Identify(GetIDMapX("PG"), GetIDMapY("PG"), IDR);
+			Double_t cipg = (y<0. ? 		GetIDMapY("PG")	: y);
+			Double_t sipg = (x<0. ? 		GetIDMapX("PG")	: x);
+            fPGgrid->Identify(sipg, cipg, IDR);
             theIdentifyingGrid = (KVIDGrid*)fPGgrid;
         }
     }

=== modified file 'KVIndra/idtelescopes/KVIDChIoSi75_camp5.h'
--- KVIndra/idtelescopes/KVIDChIoSi75_camp5.h	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDChIoSi75_camp5.h	2011-11-08 15:13:29 +0000
@@ -18,7 +18,7 @@
    virtual ~KVIDChIoSi75_camp5();
 
    virtual void Initialize(void);
-   Bool_t Identify(KVIdentificationResult*);
+   Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    virtual Double_t GetIDMapX(Option_t * opt = "");
    virtual Double_t GetIDMapY(Option_t * opt = "");

=== modified file 'KVIndra/idtelescopes/KVIDCsI.cpp'
--- KVIndra/idtelescopes/KVIDCsI.cpp	2010-06-22 13:34:19 +0000
+++ KVIndra/idtelescopes/KVIDCsI.cpp	2011-11-08 15:13:29 +0000
@@ -74,7 +74,7 @@
 
 //________________________________________________________________________________________//
 
-Bool_t KVIDCsI::Identify(KVIdentificationResult* IDR)
+Bool_t KVIDCsI::Identify(KVIdentificationResult* IDR, Double_t x, Double_t y)
 {
    //Particle identification and code setting using identification grid KVIDGCsI* fGrid.
 
@@ -82,8 +82,8 @@
 		IDR->IDattempted = kTRUE;
 	
       //perform identification
-      Double_t csir = GetIDMapY();
-      Double_t csil = GetIDMapX();
+      Double_t csir = (y<0. ? GetIDMapY() : y);
+      Double_t csil = (x<0. ? GetIDMapX() : x);
       CsIGrid->Identify(csil, csir, IDR);
 
       // set general ID code

=== modified file 'KVIndra/idtelescopes/KVIDCsI.h'
--- KVIndra/idtelescopes/KVIDCsI.h	2011-05-26 12:14:32 +0000
+++ KVIndra/idtelescopes/KVIDCsI.h	2011-11-08 15:13:29 +0000
@@ -33,7 +33,7 @@
 
    const Char_t *GetArrayName();
 
-   virtual Bool_t Identify(KVIdentificationResult*);
+   virtual Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    Double_t GetIDMapX(Option_t * opt = "");
    Double_t GetIDMapY(Option_t * opt = "");

=== modified file 'KVIndra/idtelescopes/KVIDSi150CsI_camp5.cpp'
--- KVIndra/idtelescopes/KVIDSi150CsI_camp5.cpp	2011-01-18 10:22:16 +0000
+++ KVIndra/idtelescopes/KVIDSi150CsI_camp5.cpp	2011-11-08 15:13:29 +0000
@@ -84,7 +84,7 @@
 
 //________________________________________________________________________________________//
 
-Bool_t KVIDSi150CsI_camp5::Identify(KVIdentificationResult* IDR)
+Bool_t KVIDSi150CsI_camp5::Identify(KVIdentificationResult* IDR, Double_t x, Double_t y)
 {
     //Particle identification and code setting using identification grids
 
@@ -93,14 +93,16 @@
     KVIDGrid* theIdentifyingGrid = 0;
 
     // try full isotopic identification
-    fZAGrid->Identify(GetIDMapX(), GetIDMapY(), IDR);
+    Double_t sili= (y<0. ? GetIDMapY() : y);
+    Double_t csi = (x<0. ? GetIDMapX() : x);
+    fZAGrid->Identify(csi,sili, IDR);
     theIdentifyingGrid = fZAGrid;
 
     if (fZAGrid->GetQualityCode() > KVIDZAGrid::kICODE6 && fZGrid)
     {
 
         // particle is above Z&A grid: try Z only ID
-        fZGrid->Identify(GetIDMapX(), GetIDMapY(), IDR);
+        fZGrid->Identify(csi,sili, IDR);
         theIdentifyingGrid = fZGrid;
     }
 

=== modified file 'KVIndra/idtelescopes/KVIDSi150CsI_camp5.h'
--- KVIndra/idtelescopes/KVIDSi150CsI_camp5.h	2011-01-18 10:22:16 +0000
+++ KVIndra/idtelescopes/KVIDSi150CsI_camp5.h	2011-11-08 15:13:29 +0000
@@ -22,7 +22,7 @@
    virtual ~KVIDSi150CsI_camp5();
 
    virtual void Initialize(void);
-   Bool_t Identify(KVIdentificationResult*);
+   Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    virtual Double_t GetIDMapX(Option_t * opt = "");
    virtual Double_t GetIDMapY(Option_t * opt = "");

=== modified file 'KVIndra/idtelescopes/KVIDSi75SiLi_camp5.cpp'
--- KVIndra/idtelescopes/KVIDSi75SiLi_camp5.cpp	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDSi75SiLi_camp5.cpp	2011-11-08 15:13:29 +0000
@@ -91,7 +91,7 @@
 
 //________________________________________________________________________________________//
 
-Bool_t KVIDSi75SiLi_camp5::Identify(KVIdentificationResult *IDR)
+Bool_t KVIDSi75SiLi_camp5::Identify(KVIdentificationResult *IDR, Double_t x, Double_t y)
 {
     //Particle identification and code setting using identification grids.
 
@@ -99,8 +99,8 @@
 		IDR->SetIDType( GetType() );
 		IDR->IDattempted = kTRUE;
 
-    Double_t si75 = GetIDMapY("GG");
-    Double_t sili = GetIDMapX();
+    Double_t si75 = (y<0. ? GetIDMapY("GG") : y);
+    Double_t sili = (x<0. ? GetIDMapX() : x);
 
     KVIDGrid* theIdentifyingGrid = 0;
 
@@ -111,7 +111,7 @@
     {
 
         // try Z & A identification in Si75(PG)-SiLi(PG) map
-        si75 = GetIDMapY("PG");
+        si75 = (y<0. ? GetIDMapY("PG") : y);
         fPGgrid->Identify(sili, si75, IDR);
         theIdentifyingGrid = (KVIDGrid*)fPGgrid;
 

=== modified file 'KVIndra/idtelescopes/KVIDSi75SiLi_camp5.h'
--- KVIndra/idtelescopes/KVIDSi75SiLi_camp5.h	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDSi75SiLi_camp5.h	2011-11-08 15:13:29 +0000
@@ -27,7 +27,7 @@
    virtual ~KVIDSi75SiLi_camp5();
 
    virtual void Initialize(void);
-   Bool_t Identify(KVIdentificationResult*);
+   Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    virtual Double_t GetIDMapX(Option_t * opt = "");
    virtual Double_t GetIDMapY(Option_t * opt = "");

=== modified file 'KVIndra/idtelescopes/KVIDSiCsI5.cpp'
--- KVIndra/idtelescopes/KVIDSiCsI5.cpp	2011-01-18 10:22:16 +0000
+++ KVIndra/idtelescopes/KVIDSiCsI5.cpp	2011-11-08 15:13:29 +0000
@@ -115,7 +115,7 @@
 }
 
 //______________________________________________________________________________
-Bool_t KVIDSiCsI5::Identify(KVIdentificationResult* IDR)
+Bool_t KVIDSiCsI5::Identify(KVIdentificationResult* IDR, Double_t x, Double_t y)
 {
    //Identification of particles using Si(300)-CsI matrices for 5th campaign.
    //First of all, Z identification is attempted with KVIDSiCsI5::IdentZ.
@@ -126,6 +126,8 @@
    //too bizarre, i.e. it must be in the KVNucleus mass table (KVNucleus::IsKnown = kTRUE).
    //If not, or if mass identification is not possible, the mass of the nucleus
    //is deduced from Z using the default mass formula of class KVNucleus.
+   //
+   // Note that optional arguments (x,y) for testing identification are not used.
 
    Double_t funLTG_Z = -1;
    Double_t funLTG_A = -1;
@@ -490,10 +492,10 @@
    SetHasPG2(kFALSE);
 }
 
-Double_t KVIDSiCsI5::GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A)
+Double_t KVIDSiCsI5::GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A, Double_t Eres)
 {
 	// Returns the Y-axis value in the 2D identification map containing isotope (Z,A)
-	// corresponding to the current X-axis value given by GetIDMapX.
+	// corresponding to either the given X-axis/Eres value or the current X-axis value given by GetIDMapX.
 	// If no mass information is available, just give Z.
 	//
 	// This method overrides KVIDTelescope::GetMeanDEFromID, as here we have
@@ -508,6 +510,7 @@
         // mass identification not possible for telescope - ignore A
         A=-1;
     }
+	Double_t x = (Eres < 0 ? GetIDMapX() : Eres);
     // loop over TGID objects
     TIter next( &GetListOfIDFunctions() );
     KVTGID* tgid;
@@ -521,7 +524,7 @@
                 // get position on isotopic line (Z,A)
                 Double_t y=0;
                 tgid->SetParameter("Z", Z);
-                y = tgid->GetDistanceToLine( GetIDMapX(), y, A );
+                y = tgid->GetDistanceToLine( x, y, A );
                 return y;
             }
             if(A==-1 && !tgid->GetZorA()){
@@ -531,7 +534,7 @@
             if(A<0 && tgid->GetZorA()){
                 // get position on Z line
                 Double_t y=0;
-                y = tgid->GetDistanceToLine( GetIDMapX(), y, Z );
+                y = tgid->GetDistanceToLine( x, y, Z );
                 return y;
             }
         }

=== modified file 'KVIndra/idtelescopes/KVIDSiCsI5.h'
--- KVIndra/idtelescopes/KVIDSiCsI5.h	2011-01-18 10:22:16 +0000
+++ KVIndra/idtelescopes/KVIDSiCsI5.h	2011-11-08 15:13:29 +0000
@@ -71,7 +71,7 @@
 
    virtual Double_t IdentifyZ(Double_t & funLTG);
 
-   virtual Bool_t Identify(KVIdentificationResult*);
+   virtual Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    void SetHasPG2(Bool_t yes=kTRUE) {
       SetBit(kHasPG2, yes);
@@ -92,7 +92,7 @@
    virtual void RemoveIdentificationParameters();
 
    virtual void Initialize();
-   virtual Double_t GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A=-1);
+   virtual Double_t GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A=-1, Double_t Eres = -1.);
 
    ClassDef(KVIDSiCsI5, 2)      //5th campaign INDRA identification using Si-CsI matrices
 };

=== modified file 'KVIndra/idtelescopes/KVIDSiCsI_e475s.cpp'
--- KVIndra/idtelescopes/KVIDSiCsI_e475s.cpp	2011-05-13 15:16:08 +0000
+++ KVIndra/idtelescopes/KVIDSiCsI_e475s.cpp	2011-11-08 15:13:29 +0000
@@ -74,15 +74,15 @@
 }
 //________________________________________________________________________________________//
 
-Bool_t KVIDSiCsI_e475s::Identify(KVIdentificationResult* IDR)
+Bool_t KVIDSiCsI_e475s::Identify(KVIdentificationResult* IDR, Double_t x, Double_t y)
 {
     //Particle identification and code setting using identification grid KVIDGChIoSi
 		IDR->SetIDType( GetType() );
 		IDR->IDattempted = kTRUE;
 
     //identification
-    Double_t varX = GetIDMapX();
-    Double_t varY = GetIDMapY();
+    Double_t varX = (x<0. ? GetIDMapX() : x);
+    Double_t varY = (y<0. ? GetIDMapY() : y);
 
     if (fidgrid->IsIdentifiable(varX,varY))
         fidgrid->Identify(varX,varY,IDR);

=== modified file 'KVIndra/idtelescopes/KVIDSiCsI_e475s.h'
--- KVIndra/idtelescopes/KVIDSiCsI_e475s.h	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDSiCsI_e475s.h	2011-11-08 15:13:29 +0000
@@ -30,7 +30,7 @@
 
 	virtual Double_t GetIDMapX(Option_t * opt = "");
    virtual Double_t GetIDMapY(Option_t * opt = "");
-	virtual Bool_t Identify(KVIdentificationResult*);
+	virtual Bool_t Identify(KVIdentificationResult*, Double_t x =-1., Double_t y=-1.);
 
 	virtual void CalculateParticleEnergy(KVReconstructedNucleus * nuc);
 

=== modified file 'KVIndra/idtelescopes/KVIDSiLiCsI_camp5.cpp'
--- KVIndra/idtelescopes/KVIDSiLiCsI_camp5.cpp	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDSiLiCsI_camp5.cpp	2011-11-08 15:13:29 +0000
@@ -81,7 +81,7 @@
 
 //________________________________________________________________________________________//
 
-Bool_t KVIDSiLiCsI_camp5::Identify(KVIdentificationResult* IDR)
+Bool_t KVIDSiLiCsI_camp5::Identify(KVIdentificationResult* IDR, Double_t x, Double_t y)
 {
    //Particle identification and code setting using identification grids.
 
@@ -89,8 +89,8 @@
 		IDR->SetIDType( GetType() );
 		IDR->IDattempted = kTRUE;
 
-      Double_t sili = GetIDMapY("GG");
-      Double_t csir = GetIDMapX();
+      Double_t sili = (y<0. ? GetIDMapY("GG") : y);
+      Double_t csir = (x<0. ? GetIDMapX() : x);
 
       KVIDGrid* theIdentifyingGrid = 0;
 
@@ -100,7 +100,7 @@
       if( fGGgrid->GetQualityCode() > KVIDZAGrid::kICODE6 && fPGgrid ){ //we have to try PG grid (if there is one)
 
          // try Z & A identification in SiLi(PG)-CsI(R) map
-         sili = GetIDMapY("PG");
+         sili = (y<0. ? GetIDMapY("PG") : y);
          fPGgrid->Identify(csir, sili, IDR);
          theIdentifyingGrid = (KVIDGrid*)fPGgrid;
 		}

=== modified file 'KVIndra/idtelescopes/KVIDSiLiCsI_camp5.h'
--- KVIndra/idtelescopes/KVIDSiLiCsI_camp5.h	2010-06-16 12:49:46 +0000
+++ KVIndra/idtelescopes/KVIDSiLiCsI_camp5.h	2011-11-08 15:13:29 +0000
@@ -26,7 +26,7 @@
    virtual ~KVIDSiLiCsI_camp5();
 
    virtual void Initialize(void);
-   Bool_t Identify(KVIdentificationResult*);
+   Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    virtual Double_t GetIDMapX(Option_t * opt = "");
    virtual Double_t GetIDMapY(Option_t * opt = "");

=== modified file 'KVIndra/particles/KVINDRAReconNuc.cpp'
--- KVIndra/particles/KVINDRAReconNuc.cpp	2011-06-08 13:34:05 +0000
+++ KVIndra/particles/KVINDRAReconNuc.cpp	2011-11-08 15:13:29 +0000
@@ -180,16 +180,6 @@
    } else {
       cout << "(unidentified)" << endl;
    }
-   if (GetIDTelescopes() && GetIDTelescopes()->GetSize()) {
-      cout << " ID Sub-codes: " << endl;
-      TIter next(GetIDTelescopes());
-      KVIDTelescope *idt;
-      while ((idt = (KVIDTelescope *) next())) {
-         cout << idt->GetName() << " : " << GetIDSubCodeString(idt->
-                                                               GetType())
-             << endl;
-      }
-   }
    if (IsCalibrated()) {
       cout << " Total Energy = " << GetEnergy() << " MeV,  Theta=" << GetTheta() << " Phi=" << GetPhi() << endl;
 		if(GetRingNumber()<10){
@@ -368,12 +358,14 @@
    		// we check that the ChIo contribution is sane:
    		// if no other particles hit this group, the Z given by the ChIoSi
    		// must be <= the Z found from Si-CsI or CsI-RL identification
-   		// (we cannot trust the punch-through lines in the grids).
+   		//
    		// in this case the measured energy loss of the ChIo can be solely attributed to this particle
    		// and we return kTRUE;
 
    		// ChIo was hit by more than one particle in group
-   		if(GetChIo() && GetChIo()->GetNHits()>1) return kFALSE;
+   		if(GetChIo() && GetChIo()->GetNHits()>1) {
+   			return kFALSE;
+   		}
 
    		KVIdentificationResult *IDchiosi = GetIdentificationResult(3);
    		if(!IDchiosi){
@@ -384,7 +376,8 @@
    		// if we have a successful ChIo-Si id with a Z > Z given by CsI or Si-CsI id,
    		// then we consider that there is a pile-up in the ChIo
    		// note that we consider Z_ChIoSi = 1 to mean the ChIo is in the pedestal i.e. nothing seen
-   		if(IDchiosi->IDOK && IDchiosi->Z>1 && IDchiosi->Z>theID.Z){
+   		// we also require the chio-si identification to be above the punch-through line
+   		if(IDchiosi->IDOK && IDchiosi->Z>1 && IDchiosi->IDquality!=KVIDGChIoSi::k_BelowPunchThrough && IDchiosi->Z>theID.Z){
    		    return kFALSE;
    		}
 
@@ -622,12 +615,12 @@
    		// particles stopping in CsI detectors on rings 1-9
    		// check coherency of CsI-R/L and Si-CsI identifications
    		ok = CoherencySiCsI(partID);
-   		// if Si-CsI and CsI-RL are coherent and no pileup is apparent,
    		// we check that the ChIo contribution is sane:
    		// if no other particles hit this group, the Z given by the ChIoSi
    		// must be <= the Z found from Si-CsI or CsI-RL identification
-   		// (we cannot trust the punch-through lines in the grids).
-   		if(fCoherent && !fPileup) fUseFullChIoEnergyForCalib = CoherencyChIoSiCsI(partID);
+
+   		//if(fCoherent && !fPileup)
+   		fUseFullChIoEnergyForCalib = CoherencyChIoSiCsI(partID);
 		}
 		else
 		{
@@ -643,7 +636,7 @@
    			++id_no;
    			pid = GetIdentificationResult(id_no);
    		}
-			
+			fUseFullChIoEnergyForCalib = !(GetChIo() && GetChIo()->GetNHits()>1);
 		}
     }
    else
@@ -738,11 +731,6 @@
         SetEnergy( E_tot );
         // set particle momentum from telescope dimensions (random)
         GetAnglesFromTelescope();        
-		TIter nxt(GetDetectorList()); KVDetector* det; register int ndet = 0;
-        while( (det = (KVDetector*)nxt()) ){
-          fEloss[ndet] = det->GetEnergy();
-          ++ndet;
-        }
         CheckCsIEnergy();
         return;
     }

=== modified file 'KVIndra/particles/KVINDRAReconNuc.h'
--- KVIndra/particles/KVINDRAReconNuc.h	2011-05-26 12:14:32 +0000
+++ KVIndra/particles/KVINDRAReconNuc.h	2011-11-08 15:13:29 +0000
@@ -83,11 +83,11 @@
 #endif
    virtual void Clear(Option_t * t = "");
    void Print(Option_t * option = "") const;
-   inline UShort_t GetTimeMarker() const {
-      return (GetStoppingDetector()?
-              (GetStoppingDetector()->
-               GetACQParam("T") ? GetStoppingDetector()->GetACQParam("T")->
-               GetCoderData() : 0) : 0);
+   inline Short_t GetTimeMarker() const {
+		if(!GetStoppingDetector()) return -1;
+		KVACQParam* mqrt = GetStoppingDetector()->GetACQParam("T");
+		if(!mqrt || !mqrt->IsWorking()) return -1;
+      return (Short_t)mqrt->GetCoderData();
    };
    UInt_t GetRingNumber(void) const {
       if (GetTelescope()) {

=== modified file 'KVMultiDet/analysis/KVDataAnalyser.h'
--- KVMultiDet/analysis/KVDataAnalyser.h	2011-09-19 10:01:52 +0000
+++ KVMultiDet/analysis/KVDataAnalyser.h	2011-11-08 15:13:29 +0000
@@ -173,6 +173,8 @@
 	virtual void WriteBatchInfo(TTree*);
 	virtual Int_t GetRunNumberFromFileName(const Char_t*);
 	
+	virtual void RegisterUserClass(TObject*) {};
+	
    ClassDef(KVDataAnalyser, 0)  //For submitting & performing data analysis tasks
 };
 

=== modified file 'KVMultiDet/analysis/KVRawDataAnalyser.cpp'
--- KVMultiDet/analysis/KVRawDataAnalyser.cpp	2011-10-06 01:49:16 +0000
+++ KVMultiDet/analysis/KVRawDataAnalyser.cpp	2011-11-08 15:13:29 +0000
@@ -55,7 +55,7 @@
 		fRunNumber = newrun;
 	}
 
-	fEventNumber=0;//event number
+	fEventNumber=1;//event number
 
    Long64_t nevents = GetNbEventToRead();
 	if(nevents<=0){
@@ -79,8 +79,6 @@
    //loop over events in file
 	while( fRunFile->GetNextEvent() && nevents--)
 	{
-      fEventNumber++;
-
       //reconstruct hit groups
       KVSeqCollection* fired = fRunFile->GetFiredDataParameters();
       gMultiDetArray->GetDetectorEvent(fDetEv, fired);
@@ -93,6 +91,7 @@
        fDetEv->Clear();
 
 		if(!((fEventNumber)%10000)) cout<< " ++++ " << fEventNumber << " events read ++++ " << endl;
+		fEventNumber+=1;
    }
 
     delete fDetEv;
@@ -100,7 +99,7 @@
 	cout << "Ending analysis of run " << fRunNumber << " on : ";
 	TDatime now2;
 	cout <<  now2.AsString() << endl << endl;
-	cout << endl << "Finished reading " << fEventNumber << " events from file " << raw_file.Data() << endl << endl;
+	cout << endl << "Finished reading " << fEventNumber-1 << " events from file " << raw_file.Data() << endl << endl;
 
 	preEndRun();
 	//call user's end of run function

=== modified file 'KVMultiDet/data_management/KVDataSet.cpp'
--- KVMultiDet/data_management/KVDataSet.cpp	2011-09-08 10:19:48 +0000
+++ KVMultiDet/data_management/KVDataSet.cpp	2011-11-08 15:13:29 +0000
@@ -999,21 +999,13 @@
 KVNumberList KVDataSet::GetRunList_StageSelection(const Char_t * type, const Char_t* ref_type)
 {
    // Returns list of runs which are present for data type "base_type" but not for "other_type"
-	//On travaille que sur des systemes deja au moins en partie convertis
-	// de ref_type en type
 	// if type is NULL or ="" returns empty KVNumberList
 
 	KVNumberList manquant;
-	//if (!type || !strlen(type)) return numb;
-	//KVString in_type = base_type;
-	
-	//numb = GetRunList(ref_type);
-	//KVNumberList lout = GetRunList(type);
-	
-	//numb.Remove(lout);
-	TList* ll = GetListOfAvailableSystems(type);
+	TList* ll = GetListOfAvailableSystems(ref_type);
 	if(!ll || !ll->GetEntries()){
 	   //numb.Clear();
+		Info("GetRunList_StageSelection","No data available of type \"%s\"", ref_type);
 	   return manquant;
 	}
 	

=== modified file 'KVMultiDet/detectors/KVDetector.cpp'
--- KVMultiDet/detectors/KVDetector.cpp	2011-06-30 13:45:02 +0000
+++ KVMultiDet/detectors/KVDetector.cpp	2011-11-08 15:13:29 +0000
@@ -253,12 +253,18 @@
       delete [] thickness;
 	}
    Double_t epart = kvp->GetEnergy() - eloss;
+<<<<<<< TREE
    if (epart<1e-3) {
 		//printf("%s, pb d arrondi on met l energie de la particule a 0\n",GetName());
 		epart = 0.0;
 	}
 	kvp->SetEnergy(epart);
    SetEnergyLoss(dE);
+=======
+   kvp->SetEnergy(epart);
+   Double_t eloss_old = GetEnergyLoss();
+   SetEnergyLoss(eloss_old+dE);
+>>>>>>> MERGE-SOURCE
 }
 
 //_______________________________________________________________________________
@@ -557,9 +563,7 @@
          par->Clear();
       }
    }
-   if ((fParticles)) {
-      fParticles->Clear();
-   }
+   ClearHits();
    //reset all layers in detector
    KVMaterial *mat;
    TIter next(fAbsorbers);

=== modified file 'KVMultiDet/detectors/KVDetector.h'
--- KVMultiDet/detectors/KVDetector.h	2011-06-01 13:40:54 +0000
+++ KVMultiDet/detectors/KVDetector.h	2011-11-08 15:13:29 +0000
@@ -227,7 +227,8 @@
 
    void AddHit(KVNucleus * part)
    {
-   // Add to the list of particles hitting this detector in an event
+   	// Add to the list of particles hitting this detector in an event
+   	
       if (!fParticles) {
       	fParticles = new KVList(kFALSE);
       	fParticles->SetCleanup();
@@ -240,7 +241,11 @@
    {
       return fParticles;
    };
-
+	void ClearHits()
+	{
+		// clear the list of particles hitting this detector in an event
+		if(fParticles) fParticles->Clear();
+	};
    // Return the number of particles hitting this detector in an event
    Int_t GetNHits() const
    {

=== modified file 'KVMultiDet/events/KVReconstructedEvent.cpp'
--- KVMultiDet/events/KVReconstructedEvent.cpp	2011-06-08 13:34:05 +0000
+++ KVMultiDet/events/KVReconstructedEvent.cpp	2011-11-08 15:13:29 +0000
@@ -118,7 +118,6 @@
 // - loop over next to last stage...if any detector hit NOT ALREADY IN A "PARTICLE"
 //   construct "particle" etc. etc.
 //
-
    KVGroup *grp_tch;
 
 #ifdef KV_DEBUG
@@ -273,14 +272,14 @@
    KVReconstructedNucleus *d;
    while ((d = GetNextParticle())) {
       if (!d->IsIdentified()){
-         if(d->GetStatus() < 3) { // if(d->GetStatus() == 0)
+         if(d->GetStatus() == KVReconstructedNucleus::kStatusOK){
             // identifiable particles
             d->Identify();
          }
-         else if(d->GetStatus() == 3) {
+         else if(d->GetStatus() == KVReconstructedNucleus::kStatusStopFirstStage) {
             // particles stopped in first member of a telescope
             // estimation of Z (minimum) from energy loss (if detector is calibrated)
-            UInt_t zmin = d->GetStoppingDetector()->FindZmin();
+            UInt_t zmin = d->GetStoppingDetector()->FindZmin(-1., d->GetMassFormula());
             if( zmin ){
                d->SetZ( zmin );
                d->SetIsIdentified();

=== modified file 'KVMultiDet/events/KVReconstructedEvent.h'
--- KVMultiDet/events/KVReconstructedEvent.h	2011-04-21 14:30:39 +0000
+++ KVMultiDet/events/KVReconstructedEvent.h	2011-11-08 15:13:29 +0000
@@ -69,6 +69,12 @@
    inline Bool_t HasRandomAngles() {
       return !fMeanAngles;
    };
+   
+   virtual void SecondaryIdentCalib()
+   {
+   	// Perform identifications and calibrations of particles not included
+   	// in first round (methods IdentifyEvent() and CalibrateEvent()).
+   };
 
    ClassDef(KVReconstructedEvent, 2)    //Base class for reconstructed experimental multiparticle events
 };

=== modified file 'KVMultiDet/events/KVSimEvent.h'
--- KVMultiDet/events/KVSimEvent.h	2011-08-23 09:07:16 +0000
+++ KVMultiDet/events/KVSimEvent.h	2011-11-08 15:13:29 +0000
@@ -15,6 +15,7 @@
 	public:
    
 	KVSimEvent(Int_t mult = 50, const char *classname = "KVSimNucleus");
+<<<<<<< TREE
 	virtual ~KVSimEvent();
 	
 	void Copy(TObject& obj) const;
@@ -22,6 +23,25 @@
 	void Print(Option_t* opt = "") const;
 	
    ClassDef(KVSimEvent,2)//Events from simulation
+=======
+	virtual ~KVSimEvent(){
+		delete add_variables; add_variables=0;
+	}
+
+	void init(){
+		add_variables = new KVNameValueList();
+	}
+	
+	void Clear(Option_t * /* opt */ = ""){
+		KVEvent::Clear();
+		add_variables->Clear();
+	
+	}
+	
+	KVNameValueList* GetParameters() { return add_variables; }
+
+   ClassDef(KVSimEvent,1)//Events from simulation
+>>>>>>> MERGE-SOURCE
 };
 
 #endif

=== modified file 'KVMultiDet/geometry/KVGroup.cpp'
--- KVMultiDet/geometry/KVGroup.cpp	2011-05-19 09:37:53 +0000
+++ KVMultiDet/geometry/KVGroup.cpp	2011-11-08 15:13:29 +0000
@@ -333,10 +333,7 @@
    }
    //reset energy loss and KVDetector::IsAnalysed() state
    //plus ACQParams set to zero
-   //GetDetectors()->Execute("Clear", "");
-   if(GetDetectors()){
-   	  GetDetectors()->R__FOR_EACH(KVDetector, Clear)();
-   }
+   GetDetectors()->R__FOR_EACH(KVDetector, Clear)();
 }
 
 //_________________________________________________________________________________
@@ -779,7 +776,7 @@
 
          if (nuc->GetNSegDet() >= 2) {
             //all part.s crossing 2 or more independent detectors are fine
-            nuc->SetStatus(0);
+            nuc->SetStatus( KVReconstructedNucleus::kStatusOK );
          } else if (nuc->GetNSegDet() == 1) {
             //only 1 independent detector hit => depends on what's in the rest
             //of the group
@@ -787,7 +784,7 @@
          } else {
             //part.s crossing 0 independent detectors (i.E. arret ChIo)
             //can not be reconstructed
-            nuc->SetStatus(3);
+            nuc->SetStatus( KVReconstructedNucleus::kStatusStopFirstStage );
          }
       }
       next.Reset();
@@ -802,18 +799,18 @@
                //after identifying the others and subtracting their calculated
                //energy losses from the "dependent"/"non-segmented" detector
                //(i.E. the ChIo)
-               nuc->SetStatus(1);
+               nuc->SetStatus( KVReconstructedNucleus::kStatusOKafterSub );
             } else {
                //more than one ? then we can make some wild guess by sharing the
                //"non-segmented" (i.e. ChIo) contribution between them, but
                //I wouldn't trust it as far as I can spit
-               nuc->SetStatus(2);
+               nuc->SetStatus( KVReconstructedNucleus::kStatusOKafterShare );
             }
             //one possibility remains: the particle may actually have stopped e.g. in the Si member
             //of a Ring 1 Si-CsI telescope, in which case AnalStatus = 3
             if (nuc->GetIDTelescopes()->GetSize() == 0) {
                //no ID telescopes with which to identify particle
-               nuc->SetStatus(3);
+               nuc->SetStatus( KVReconstructedNucleus::kStatusStopFirstStage );
             }
          }
       }
@@ -829,16 +826,16 @@
 
       if (nuc->GetNSegDet() > 0) {
          //OK no problem
-         nuc->SetStatus(0);
+         nuc->SetStatus(KVReconstructedNucleus::kStatusOK);
       } else {
          //dead in the water
-         nuc->SetStatus(3);
+         nuc->SetStatus(KVReconstructedNucleus::kStatusStopFirstStage);
       }
       //one possibility remains: the particle may actually have stopped e.g. in the 1st member
       //of a telescope, in which case AnalStatus = 3
       if (nuc->GetIDTelescopes()->GetSize() == 0) {
          //no ID telescopes with which to identify particle
-         nuc->SetStatus(3);
+         nuc->SetStatus(KVReconstructedNucleus::kStatusStopFirstStage);
       }
    }
 #ifdef KV_DEBUG
@@ -866,3 +863,10 @@
    return (GetHits() - GetNIdentified());
 };
 #endif
+
+void KVGroup::ClearHitDetectors()
+{
+	// Loop over all detectors in group and clear their list of 'hits'
+	// i.e. the lists of particles which hit each detector
+	GetDetectors()->R__FOR_EACH(KVDetector, ClearHits)();
+}

=== modified file 'KVMultiDet/geometry/KVGroup.h'
--- KVMultiDet/geometry/KVGroup.h	2011-04-11 09:16:50 +0000
+++ KVMultiDet/geometry/KVGroup.h	2011-11-08 15:13:29 +0000
@@ -98,6 +98,7 @@
       else
          return 0;
    };
+   void ClearHitDetectors();
 #if !defined(R__MACOSX)
    inline UInt_t GetNIdentified();
    inline UInt_t GetNUnidentified();

=== modified file 'KVMultiDet/geometry/KVMultiDetArray.cpp'
--- KVMultiDet/geometry/KVMultiDetArray.cpp	2011-08-23 09:07:16 +0000
+++ KVMultiDet/geometry/KVMultiDetArray.cpp	2011-11-08 15:13:29 +0000
@@ -778,7 +778,7 @@
 }
 
 //__________________________________________________________________________________
-
+//#define KV_DEBUG 1
 void KVMultiDetArray::DetectEvent(KVEvent * event,KVReconstructedEvent* rec_event)
 {
     //Simulate detection of event by multidetector array.
@@ -833,12 +833,11 @@
 	if (!fHitGroups){
 		//Create the list where fired groups will be stored
 		//for reconstruction
-		fHitGroups = new KVUniqueNameList();
-   	fHitGroups->SetOwner(kFALSE); // owns its objects
+		fHitGroups = new KVDetectorEvent;//KVUniqueNameList();
 	}
 	else {
 		//Clear the multidetector before a new filter process
-		fHitGroups->R__FOR_EACH(KVGroup,Reset) ();
+		//fHitGroups->R__FOR_EACH(KVGroup,Reset) ();
     	fHitGroups->Clear();
 	}
 	
@@ -864,6 +863,7 @@
 			
 		}
 		else {
+<<<<<<< TREE
 		
 			//Double_t eLostInTarget=0;
 			if (fTarget){
@@ -878,12 +878,28 @@
 					part->AddGroup("STOPPED IN TARGET"); 
 					
 				}	
+=======
+			KVNameValueList* nvl = 0;
+			if ( !(nvl = DetectParticle(part)) ) {
+						Info("DetEv","nvl=0");
+				part->AddGroup("DEAD ZONE"); 
+				part->AddGroup("UNDETECTED"); 
+>>>>>>> MERGE-SOURCE
 			}
+<<<<<<< TREE
 		
 			if (part->GetKE()==0) { 
 			
+=======
+			else if ( nvl->GetNpar()==0 ) {
+						Info("DetEv","no params in nvl");
+				part->AddGroup("DEAD ZONE"); 
+				part->AddGroup("UNDETECTED");
+				delete nvl;
+>>>>>>> MERGE-SOURCE
 			}
 			else {
+<<<<<<< TREE
 				//KVNameValueList* nvl = 0;
 				if ( !(nvl = DetectParticle(part)) ) {
 					det_stat->SetValue("UNDETECTED","DEAD ZONE"); 
@@ -906,7 +922,18 @@
 					KVDetector* last_det = GetDetector(LastDet.Data());
 					TList* ldet = last_det->GetAlignedDetectors();
 					TIter it1(ldet);
+=======
+#ifdef KV_DEBUG
+						Info("DetEv","OK for now");
+#endif
+				Int_t nbre_nvl = nvl->GetEntries();
+				KVString LastDet(nvl->GetNameAt(nbre_nvl-1));
+				KVDetector* last_det = GetDetector(LastDet.Data());
+				TList* ldet = last_det->GetAlignedDetectors();
+				TIter it1(ldet);
+>>>>>>> MERGE-SOURCE
 				
+<<<<<<< TREE
 					Int_t ntrav=0;
 					KVDetector*dd = 0;
 					//Test de la trajectoire coherente
@@ -917,10 +944,44 @@
 								if (dd->GetTelescope()->IsSmallerThan(last_det->GetTelescope())) ntrav+=1;
 						}
 						else {
+=======
+				Int_t ntrav=0;
+				KVDetector*dd = 0;
+				//Test de la trajectoire coherente
+				while ( ( dd = (KVDetector* )it1.Next() ) ){
+					if (dd->GetNHits()){
+#ifdef KV_DEBUG
+						Info("DetEv", "detector %s has hits",dd->GetName());
+#endif
+						if (dd->GetHits()->FindObject(part)){
+#ifdef KV_DEBUG
+							Info("DetEv", "particle found in hits list");
+#endif
+							ntrav+=1;
+						}	
+						else {
+#ifdef KV_DEBUG
+							Info("DetEv", "particle not found in hit list");
+#endif
+							dd->GetHits()->ls();
+>>>>>>> MERGE-SOURCE
 							if (dd->GetTelescope()->IsSmallerThan(last_det->GetTelescope())) ntrav+=1;
-						}
-					}
+<<<<<<< TREE
+						}
+					}
+=======
+						}
+					}
+					else {
+#ifdef KV_DEBUG
+					Info("DetEv", "detector %s NO HITS",dd->GetName());
+#endif
+						if (dd->GetTelescope()->IsSmallerThan(last_det->GetTelescope())) ntrav+=1;
+					}
+				}
+>>>>>>> MERGE-SOURCE
 				
+<<<<<<< TREE
 					if (ntrav != ldet->GetEntries()){
 						// la particule a une trajectoire
 						// incoherente, elle a loupe un detecteur avec une ouverture 
@@ -946,14 +1007,62 @@
 										dd->SetEnergyLoss(0);
 								}
 								dd->GetHits()->Remove(part);
+=======
+				if (ntrav != ldet->GetEntries()){
+					// la particule a une trajectoire
+					// incoherente, elle a loupe un detecteur avec une ouverture 
+					// plus large que ceux a la suite ou la particule est passe
+					// (ceci peut etre du a un pb de definition de zone morte autour de certains detecteur)
+					// 
+					// on retire la particule sur tout les detecteurs
+					// ou elle est enregistree et on retire egalement
+					// sa contribution en energie
+					//
+					// on assimile en fait ces particules a 
+					// des particules arretes dans les zones mortes
+					// non detectees
+					it1.Reset();
+#ifdef KV_DEBUG
+					Warning("DetectEvent","trajectoire incoherente ...");
+#endif
+					while ( ( dd = (KVDetector* )it1.Next() ) )
+						if (dd->GetHits() && dd->GetHits()->FindObject(part)){
+							if ( nvl->HasParameter(dd->GetName()) ){
+								Double_t el = dd->GetEnergy();
+								el -= nvl->GetDoubleValue(dd->GetName());
+								dd->SetEnergyLoss(el);
+								if (dd->GetNHits()==1)
+									dd->SetEnergyLoss(0);
+>>>>>>> MERGE-SOURCE
 							}
+<<<<<<< TREE
 						det_stat->SetValue("UNDETECTED","GEOMETRY INCOHERENCY");
 						
+=======
+							dd->GetHits()->Remove(part);
+						}
+					
+					part->AddGroup("DEAD ZONE");
+					part->AddGroup("UNDETECTED");
+				}
+				else {
+#ifdef KV_DEBUG
+						Info("DetEv","trajectoire OK");
+#endif
+					
+					TList* lidtel = last_det->GetTelescopesForIdentification();
+					if (lidtel->GetEntries()==0 && last_det->GetEnergy()==0){
+#ifdef KV_DEBUG
+						Info("DetEv","Arret dans un absorbeur");
+#endif
+						//Arret dans un absorbeur (unactive layer, mylar pour les ChIo par ex)
+>>>>>>> MERGE-SOURCE
 						part->AddGroup("UNDETECTED");
 						part->AddGroup("GEOMETRY INCOHERENCY");
 						
 					}
 					else {
+<<<<<<< TREE
 						
 						TList* lidtel = last_det->GetTelescopesForIdentification();
 						if (lidtel->GetEntries()==0 && last_det->GetEnergy()==0){
@@ -967,6 +1076,23 @@
 							//
 							last_det->GetHits()->Remove(part);
 							//Warning("DetectEvent","threshold ...");
+=======
+#ifdef KV_DEBUG
+						Info("DetEv","adding to hit groups");
+#endif
+						part->AddGroup("DETECTED");
+						
+						fHitGroups->AddGroup( last_det->GetGroup() );
+						
+						if (lidtel->GetEntries()>0){
+							//Il y a possibilite d identification
+						}
+						else if (last_det->GetEnergy()>0){
+							//Il n'y a pas de possibilite d'identification
+							//arret dans une ChIo ou  un Si qui sont le
+							//premier etage de detection 
+							part->AddGroup("INCOMPLETE");
+>>>>>>> MERGE-SOURCE
 						}
 						else {
 							part->AddGroup("DETECTED");
@@ -1045,17 +1171,28 @@
 			}
 		}
 		part->SetMomentum(*part->GetPInitial());
+<<<<<<< TREE
 
 	} 	//fin de loop over particles
 	
 	delete det_stat;
 	
+=======
+	}
+    // before reconstruction we have to clear the list of 'hits' of each detector
+    // (they currently hold the addresses of the simulated particles which were detected)
+    // which will be filled with the reconstructed particles, otherwise the number of hits
+    // in each detector will be 2x the real value, and coherency analysis of the reconstructed
+    // events will not work
+>>>>>>> MERGE-SOURCE
 	KVGroup *grp_tch;
-	TIter nxt_grp(fHitGroups);
+	TIter nxt_grp(fHitGroups->GetGroups());
    while ((grp_tch = (KVGroup *) nxt_grp())) {
-  		rec_event->AnalyseGroup(grp_tch);
+   	grp_tch->ClearHitDetectors();
+  		//rec_event->AnalyseGroup(grp_tch);
    }
-
+    // reconstruct the event
+    rec_event->ReconstructEvent(fHitGroups);
 }
 
 //__________________________________________________________________________________
@@ -1082,7 +1219,11 @@
         grp_tch->Print("angles");
 #endif
         //simulate detection of particle by this group
-        return grp_tch->DetectParticle(part);
+        KVNameValueList*nvl= grp_tch->DetectParticle(part);
+#ifdef KV_DEBUG
+        nvl->Print();
+ #endif
+       return nvl;
     }
     return 0;
 }

=== modified file 'KVMultiDet/geometry/KVMultiDetArray.h'
--- KVMultiDet/geometry/KVMultiDetArray.h	2011-06-01 13:40:54 +0000
+++ KVMultiDet/geometry/KVMultiDetArray.h	2011-11-08 15:13:29 +0000
@@ -78,7 +78,7 @@
    KVSeqCollection *fDetectorTypes;      //-> list of detector types used to construct telescopes of array
    KVSeqCollection *fTelescopes;         //-> list of telescope prototypes used to construct array
    KVSeqCollection *fGroups;             //->list of groups of telescopes in array
-   KVUniqueNameList *fHitGroups;          //list of hitted groups
+   KVDetectorEvent *fHitGroups;          //list of hit groups in simulation
    KVSeqCollection *fIDTelescopes;       //->deltaE-E telescopes in groups
    KVSeqCollection *fDetectors;          //->list of references to all detectors in array
    KVSeqCollection *fACQParams;          //references to data acquisition parameters associated to detectors

=== modified file 'KVMultiDet/idmaps/KVIDCutLine.h'
--- KVMultiDet/idmaps/KVIDCutLine.h	2011-03-23 16:33:39 +0000
+++ KVMultiDet/idmaps/KVIDCutLine.h	2011-11-08 15:13:29 +0000
@@ -19,10 +19,10 @@
    KVString fAcceptedDirection;         //direction relative to cut line corresponding to acceptable region
    virtual void WriteAsciiFile_extras(ofstream &, const Char_t * name_prefix ="");
    virtual void ReadAsciiFile_extras(ifstream &);
-   virtual void SetZ(Int_t atnum){ ; };
-   virtual void SetA(Int_t atnum){ ; };
-   virtual void SetAandZ(Int_t atnum,Int_t ztnum){;};
-   virtual void SetMassFormula(Int_t mf){ ; };
+   virtual void SetZ(Int_t /*atnum*/){ ; };
+   virtual void SetA(Int_t /*atnum*/){ ; };
+   virtual void SetAandZ(Int_t /*atnum*/,Int_t /*ztnum*/){;};
+   virtual void SetMassFormula(Int_t /*mf*/){ ; };
    
    public:
    KVIDCutLine();

=== modified file 'KVMultiDet/idmaps/KVIDGraph.h'
--- KVMultiDet/idmaps/KVIDGraph.h	2011-10-13 15:14:05 +0000
+++ KVMultiDet/idmaps/KVIDGraph.h	2011-11-08 15:13:29 +0000
@@ -339,6 +339,7 @@
    virtual void 			SetVarY(const char* v){TCutG::SetVarY(v); };
    virtual Int_t         InsertPoint(){return TCutG::InsertPoint();};
    virtual Int_t         RemovePoint(){return TCutG::RemovePoint();};
+   virtual Int_t         RemovePoint(Int_t i){return TCutG::RemovePoint(i);};
 	
    ClassDef(KVIDGraph,1)//Base class for particle identification in a 2D map
 };

=== modified file 'KVMultiDet/idmaps/KVIDZAGrid.cpp'
--- KVMultiDet/idmaps/KVIDZAGrid.cpp	2011-10-25 13:08:20 +0000
+++ KVMultiDet/idmaps/KVIDZAGrid.cpp	2011-11-08 15:13:29 +0000
@@ -1325,6 +1325,7 @@
         //no lines corresponding to point were found
         const_cast < KVIDZAGrid * >(this)->fICode = kICODE8;        // Z indetermine ou (x,y) hors limites
         idr->IDquality = kICODE8;
+        idr->SetComment("no identification: (x,y) out of range covered by grid");
         return;
     }
     if ( OnlyZId() )
@@ -1343,6 +1344,18 @@
         idr->Z = Zint;
         idr->PID = Z;
 		idr->A= Aint;
+		switch(fICode){
+     case kICODE0:                   idr->SetComment("ok"); break;
+  case kICODE1:                   idr->SetComment("slight ambiguity of Z, which could be larger"); break;
+  case kICODE2:                   idr->SetComment("slight ambiguity of Z, which could be smaller"); break;
+    case kICODE3:                  idr->SetComment("slight ambiguity of Z, which could be larger or smaller"); break;
+   case kICODE4:                   idr->SetComment("point is in between two lines of different Z, too far from either to be considered well-identified"); break;
+  case kICODE5:                   idr->SetComment("point is in between two lines of different Z, too far from either to be considered well-identified"); break;
+   case kICODE6:                   idr->SetComment("(x,y) is below first line in grid"); break;
+   case kICODE7:                   idr->SetComment("(x,y) is above last line in grid"); break;
+  default:
+                      idr->SetComment("no identification: (x,y) out of range covered by grid");
+		}
     }
     else
     {
@@ -1362,6 +1375,18 @@
             idr->Aident = kTRUE;
             idr->IDOK = kTRUE;
         }
+		switch(fICode){
+     case kICODE0:                   idr->SetComment("ok"); break;
+  case kICODE1:                   idr->SetComment("slight ambiguity of A, which could be larger"); break;
+  case kICODE2:                   idr->SetComment("slight ambiguity of A, which could be smaller"); break;
+    case kICODE3:                  idr->SetComment("slight ambiguity of A, which could be larger or smaller"); break;
+   case kICODE4:                   idr->SetComment("point is in between two isotopes of different Z, too far from either to be considered well-identified"); break;
+  case kICODE5:                   idr->SetComment("point is in between two isotopes of different Z, too far from either to be considered well-identified"); break;
+   case kICODE6:                   idr->SetComment("(x,y) is below first line in grid"); break;
+   case kICODE7:                   idr->SetComment("(x,y) is above last line in grid"); break;
+  default:
+                      idr->SetComment("no identification: (x,y) out of range covered by grid");
+		}
     }
 }
 

=== modified file 'KVMultiDet/idmaps/KVIDentifier.h'
--- KVMultiDet/idmaps/KVIDentifier.h	2011-04-01 13:28:10 +0000
+++ KVMultiDet/idmaps/KVIDentifier.h	2011-11-08 15:13:29 +0000
@@ -33,7 +33,7 @@
 
 	// Does nothing. Can be overridden in child classes in order to write any
 	// extra information in between the name of the object and the number of points.
-   virtual void WriteAsciiFile_extras(ofstream &, const Char_t * name_prefix =""){};
+   virtual void WriteAsciiFile_extras(ofstream &, const Char_t * /*name_prefix*/ =""){};
 
 	// Does nothing. Can be overridden in child classes in order to read any
 	// extra information in between the name of the object and the number of points.
@@ -70,7 +70,7 @@
    virtual void SetMassFormula(Int_t mf){ if(OnlyZId()) {fIon.SetMassFormula(mf); fMassFormula=mf; SetNameFromNucleus();} };   // *SUBMENU={Hierarchy="SetNucleus.../Mass Formula"}*
    virtual Int_t GetMassFormula()const { return fIon.GetMassFormula(); }
 
-   virtual Bool_t TestPoint(Double_t x, Double_t y)
+   virtual Bool_t TestPoint(Double_t /*x*/, Double_t /*y*/)
 	{
 		// Abstract method, should be overridden in child classes.
 		// Used to test whether a point (x,y) in the ID map is identifiable.
@@ -131,6 +131,7 @@
 	virtual Int_t 			 ContinueDrawing(); // *MENU={Hierarchy="Modify Line.../ContinueDrawing"}*
 	virtual void 			ChechHierarchy(KVIDentifier* gr);
 	virtual Int_t         RemovePoint(){ if(GetEditable()){ return TCutG::RemovePoint(); } else {return -1;} }; // *MENU={Hierarchy="Modify Line.../RemovePoint"}*
+	virtual Int_t         RemovePoint(Int_t i){ return TCutG::RemovePoint(i); };
 	
 	virtual Double_t GetPID() const;
 

=== modified file 'KVMultiDet/idtelescopes/KVIDTelescope.cpp'
--- KVMultiDet/idtelescopes/KVIDTelescope.cpp	2011-06-08 13:34:05 +0000
+++ KVMultiDet/idtelescopes/KVIDTelescope.cpp	2011-11-08 15:13:29 +0000
@@ -293,7 +293,7 @@
 
 //____________________________________________________________________________________
 
-Bool_t KVIDTelescope::Identify(KVIdentificationResult*)
+Bool_t KVIDTelescope::Identify(KVIdentificationResult*, Double_t, Double_t)
 {
    //Default identification method.
    //Identification of experimental data needs to be implemented in specific
@@ -1056,14 +1056,14 @@
 }
 //_________________________________________________________________________________________
 
-Double_t KVIDTelescope::GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A)
+Double_t KVIDTelescope::GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A, Double_t Eres)
 {
 	// Returns the Y-axis value in the 2D identification map containing isotope (Z,A)
-	// corresponding to the current X-axis value given by GetIDMapX.
+	// corresponding to either the given X-axis/Eres value or the current X-axis value given by GetIDMapX.
 	// If no mass information is available, just give Z.
 	//
 	// In this (default) implementation this means scanning the ID grids associated with
-	// this telescope until we find and identification line Z or (Z,A), and then interpolating
+	// this telescope until we find an identification line Z or (Z,A), and then interpolating
 	// the Y-coordinate for the current X-coordinate value.
 	//
 	// Status variable can take one of following values:
@@ -1088,7 +1088,7 @@
 	    return -1.;
 	}
 	Double_t x,x1,y1,x2,y2;
-	x = GetIDMapX();
+	x = (Eres < 0 ? GetIDMapX() : Eres);
 	idline->GetEndPoint(x2,y2);
 	if(x>x2){
         status = kMeanDE_XtooLarge;

=== modified file 'KVMultiDet/idtelescopes/KVIDTelescope.h'
--- KVMultiDet/idtelescopes/KVIDTelescope.h	2011-05-26 12:14:32 +0000
+++ KVMultiDet/idtelescopes/KVIDTelescope.h	2011-11-08 15:13:29 +0000
@@ -95,7 +95,7 @@
       ResetBit(kReadyForID);
    };
 
-   virtual Bool_t Identify(KVIdentificationResult*);
+   virtual Bool_t Identify(KVIdentificationResult*, Double_t x=-1., Double_t y=-1.);
 
    virtual void CalculateParticleEnergy(KVReconstructedNucleus * nuc);
    virtual Int_t GetCalibStatus() const
@@ -155,7 +155,7 @@
         kMeanDE_XtooLarge,   // X-coordinate is larger than largest X-coordinate of ID line
         kMeanDE_NoIdentifier   // No identifier found for Z or (Z,A)
     };
-	virtual Double_t GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A=-1);
+	virtual Double_t GetMeanDEFromID(Int_t &status, Int_t Z, Int_t A=-1, Double_t Eres = -1.0);
 
 	ClassDef(KVIDTelescope, 5)   //A delta-E - E identification telescope
 };

=== modified file 'KVMultiDet/particles/KVReconstructedNucleus.cpp'
--- KVMultiDet/particles/KVReconstructedNucleus.cpp	2011-06-08 13:34:05 +0000
+++ KVMultiDet/particles/KVReconstructedNucleus.cpp	2011-11-08 15:13:29 +0000
@@ -1,22 +1,3 @@
-/***************************************************************************
-                          kvreconstructednucleus.cpp  -  description
-                             -------------------
-    begin                : Fri Oct 18 2002
-    copyright            : (C) 2002 by Alexis Mignon
-    email                : mignon@xxxxxxxx
-
-$Id: KVReconstructedNucleus.cpp,v 1.60 2009/03/03 13:36:00 franklan Exp $
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
 #include "Riostream.h"
 #include "KVReconstructedNucleus.h"
 #include "KVTelescope.h"
@@ -68,14 +49,6 @@
     ResetBit(kIsIdentified);
     ResetBit(kIsCalibrated);
     ResetBit(kCoherency);
-   fNumDet = 0;
-   fNumPar = 0;
-   for (register int i = 0; i < MAX_NUM_DET; i++) {
-      fEloss[i] = 0.0;
-   }
-   for (register int i = 0; i < MAX_NUM_PAR; i++) {
-      fACQData[i] = 0;
-   }
    for (register int i = 0; i < IDRESULTS_DIM; i++) {
       fIDresults[i].Reset();
    }
@@ -109,7 +82,6 @@
         GetGroup()->Reset();
     }
     if (fDetList){
-        //fDetList->Clear();
         delete fDetList;
         fDetList=0;
     }
@@ -131,7 +103,7 @@
     UInt_t R__s, R__c;
     if (R__b.IsReading()) {
         Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
-        //if( R__v < 12 ) { }
+        //if( R__v < 15 ) { }
         R__b.ReadClassBuffer(KVReconstructedNucleus::Class(),this,R__v,R__s,R__c);
         // if the multidetector object exists, update some informations
         // concerning the detectors etc. hit by this particle
@@ -142,19 +114,11 @@
             fIDTelescope = 0;
 			if(fIDTelName!="") fIDTelescope = gMultiDetArray->GetIDTelescope( fIDTelName.Data() );
             TIter next_det(fDetList);
-            KVDetector *det;register int ndet = 0;UInt_t npar=0;
+            KVDetector *det;
             while ( (det = (KVDetector*)next_det()) ){
                 fNSegDet += det->GetSegment();
                 det->AddHit(this);
-               det->SetEnergy(fEloss[ndet]);
-               ndet++;
-               if (det->GetACQParamList()) {
-                  TIter next_par(det->GetACQParamList());
-                  KVACQParam *par;
-                  while ((par = (KVACQParam *) next_par())) {
-                     par->SetData(fACQData[npar++]);
-                  }
-               }
+					 det->SetAnalysed();
                 //modify detector's counters depending on particle's identification state
                 if (IsIdentified())
                     det->IncrementIdentifiedParticles();
@@ -173,10 +137,10 @@
 {
 
     cout << "KVReconstructedNucleus:" << endl;
-
-    if (GetNumDet()) {
-
-        for (int i = GetNumDet() - 1; i >= 0; i--) {
+	int ndets=GetNumDet();
+    if (ndets) {
+
+        for (int i = ndets - 1; i >= 0; i--) {
             KVDetector *det = GetDetector(i);
             if(det) det->Print("data");
         }
@@ -203,10 +167,6 @@
 	 ((KVReconstructedNucleus &) obj).fDetNames = fDetNames;
     ((KVReconstructedNucleus &) obj).SetRealZ(GetRealZ());
     ((KVReconstructedNucleus &) obj).SetRealA(GetRealA());
-   ((KVReconstructedNucleus &) obj).SetNumDet(GetNumDet());
-   ((KVReconstructedNucleus &) obj).SetNumPar(GetNumPar());
-   ((KVReconstructedNucleus &) obj).SetElossTable(GetElossTable());
-   ((KVReconstructedNucleus &) obj).SetACQData(GetACQData());
 }
 
 
@@ -220,7 +180,6 @@
     if (GetGroup())
         GetGroup()->Reset();
     if (fDetList){
-        //fDetList->Clear();
         delete fDetList;
         fDetList=0;
     };
@@ -230,8 +189,7 @@
 void KVReconstructedNucleus::AddDetector(KVDetector * det)
 {
     //Add a detector to the list of those through which the particle passed.
-    //Put reference to detector into fDetectors array, store detector's energy loss value in
-    //fEloss array, increase number of detectors by one.
+    //Put reference to detector into fDetectors array, increase number of detectors by one.
     //As this is only used in initial particle reconstruction, we add 1 unidentified particle to the detector.
     // Creates KVHashList fDetList in case it does not exist.
 
@@ -241,28 +199,6 @@
     // store pointer to detector
     if (!fDetList) fDetList = new KVHashList;
     fDetList->Add(det);
-   if (fNumDet == MAX_NUM_DET) {
-      Warning("AddDetector",
-              "Cannot store informations for more than %d detectors for reconstructed nucleus. Detector infos not taken into account",
-              fNumDet);
-   }
-   else {
-   		fEloss[fNumDet++] = det->GetEnergy();
-   		if (det->GetACQParamList()) {
-      		if ((fNumPar + det->GetACQParamList()->GetSize()) > MAX_NUM_PAR) {
-         		Warning("AddDetector",
-                 "Cannot add more than %d DAQ parameters to reconstructed nucleus. Parameters not taken into account",
-                 MAX_NUM_PAR);
-      		}
-      		else{
-      			TIter next_par(det->GetACQParamList());
-      			KVACQParam *par;
-      			while ((par = (KVACQParam *) next_par())) {
-         			fACQData[fNumPar++] = par->GetCoderData();
-      			}
-   			}
-   		}
-   	}
     //add segmentation index of detector to total segmentation index of particle
     fNSegDet += det->GetSegment();
     //add 1 unidentified particle to the detector
@@ -317,39 +253,40 @@
     // The identification code corresponding to the identifying telescope is set as the identification code of the particle.
 
     KVList *idt_list = GetStoppingDetector()->GetAlignedIDTelescopes();
-
     if (idt_list && idt_list->GetSize() > 0) {
 
         KVIDTelescope *idt;
         TIter next(idt_list);
         Int_t idnumber = 1;
-
         while ((idt = (KVIDTelescope *) next())) {
-
 			KVIdentificationResult *IDR=GetIdentificationResult(idnumber++);
 			
-            if ( IDR && idt->IsReadyForID() ) { // is telescope able to identify for this run ?
-				
-				idt->Identify( IDR );
-				
-                    //We reduce the "segmentation" index by 1.
-                    //If this remains >=2, we carry on trying to identify
-                    //However, if it falls to 1, then the particle's identifiability depends
-                    //on the rest of the KVGroup where it was detected.
-                    //If there are no other _unidentified_ particles in the group, it's fine.
-                    //If there _are_ other unidentified particles in the group, then we should wait until
-                    //the next ID round (equivalent of particles with GetAnalStatus=1).
-                    SetNSegDet(TMath::Max(GetNSegDet() - 1, 0));
-                    //if there are other unidentified particles in the group and NSegDet is < 2
-                    //then exact status depends on segmentation of the other particles : reanalyse
-                    //cout << "...........NSegDet now = " << GetNSegDet() << " && number unidentified in group="
-                    //              << (int)GetGroup()->GetNUnidentified() << endl;
-                    //if (GetNSegDet() < 2 && GetGroup()->GetNUnidentified() > 1)
-                        //break;
-                    //if NSegDet = 0 it's hopeless
-                    //if (!GetNSegDet())
-                        //break;
-
+            if ( IDR ){
+					if(idt->IsReadyForID() ) { // is telescope able to identify for this run ?
+				
+						IDR->IDattempted = kTRUE;
+						idt->Identify( IDR );
+					}
+					else
+						IDR->IDattempted = kFALSE;
+					
+					if((!IDR->IDattempted) || (IDR->IDattempted && !IDR->IDOK)){
+						// the particle is less identifiable than initially thought
+						// we may have to wait for secondary identification
+						Int_t nseg = GetNSegDet();
+						SetNSegDet(TMath::Max(nseg - 1, 0));
+						//if there are other unidentified particles in the group and NSegDet is < 2
+               	//then exact status depends on segmentation of the other particles : reanalyse
+               	if (GetNSegDet() < 2 && GetGroup()->GetNUnidentified() > 1){
+							GetGroup()->AnalyseParticles();
+                  	return;
+                  }
+               	//if NSegDet = 0 it's hopeless
+               	if (!GetNSegDet()){
+							GetGroup()->AnalyseParticles();
+                     return;
+                  }
+					}
             }
 
         }
@@ -389,67 +326,6 @@
     }
 }
 
-//______________________________________________________________________________________________//
-/*
-Int_t KVReconstructedNucleus::GetIDSubCode(const Char_t * id_tel_type,
-        KVIDSubCode & code) const
-{
-    //If the identification of the particle was attempted using a KVIDTelescope of type "id_tel_type",
-    //and 'code' holds all the subcodes from the different identification routines tried for this particle,
-    //then this method returns the subcode for this particle from telescope type "id_tel_type".
-    //
-    //In case of problems (no ID telescope of type 'id_tel_type'), the returned value is -65535.
-    //
-    //If no type is given (first argument = ""), we use the identifying telescope (obviously if the
-    //particle has remained unidentified - IsIdentified()==kFALSE - and the GetIdentifyingTelescope()
-    //pointer is not set, we return -65535).
-
-    KVIDTelescope *idtel;
-    if (strcmp(id_tel_type, ""))
-        idtel =
-            (KVIDTelescope *) GetIDTelescopes()->
-            FindObjectByType(id_tel_type);
-    else
-        idtel = GetIdentifyingTelescope();
-    if (!idtel)
-        return -65535;
-    return idtel->GetIDSubCode(code);
-}
-
-//______________________________________________________________________________________________//
-
-const Char_t *KVReconstructedNucleus::GetIDSubCodeString(const Char_t *
-        id_tel_type,
-        KVIDSubCode &
-        code) const
-{
-    //If the identification of the particle was attempted using a KVIDTelescope of type "id_tel_type",
-    //and 'code' holds all the subcodes from the different identification routines tried for this particle,
-    //then this method returns an explanation for the subcode for this particle from telescope type "id_tel_type".
-    //
-    //If no type is given (first argument = ""), we use the identifying telescope.
-    //
-    //In case of problems :
-    //       no ID telescope of type 'id_tel_type' :  "No identification attempted in id_tel_type"
-    //       particle not identified               :  "Particle unidentified. Identifying telescope not set."
-
-    KVIDTelescope *idtel;
-    if (strcmp(id_tel_type, ""))
-        idtel =
-            (KVIDTelescope *) GetIDTelescopes()->
-            FindObjectByType(id_tel_type);
-    else
-        idtel = GetIdentifyingTelescope();
-    if (!idtel) {
-        if (strcmp(id_tel_type, ""))
-            return Form("No identification attempted in %s", id_tel_type);
-        else
-            return
-                Form("Particle unidentified. Identifying telescope not set.");
-    }
-    return idtel->GetIDSubCodeString(code);
-}
-*/
 //_________________________________________________________________________________
 
 void KVReconstructedNucleus::Calibrate()
@@ -470,13 +346,6 @@
 
     KVIDTelescope* idt = GetIdentifyingTelescope();
     idt->CalculateParticleEnergy(this);
-    //if calibration was successful, we now read the energy losses from the detectors
-    //this is because detectors whose calibration
-    //depends on the identity (Z & A) of the particle will only have their energy loss
-    //member set when this method is called; otherwise it remains 0.
-    //Also, whenever possible, we calculate the energy loss for any uncalibrated or
-    //non-functioning detectors during this procedure, so this calculated energy loss
-    //will also be stored.
     if ( idt->GetCalibStatus() != KVIDTelescope::kCalibStatus_NoCalibrations ){
         SetIsCalibrated();
         //add correction for target energy loss - charged particles only
@@ -487,11 +356,6 @@
         }
         Double_t E_tot = GetEnergy() + E_targ;
         SetEnergy( E_tot );
-		TIter nxt(GetDetectorList()); KVDetector* det; register int ndet = 0;
-        while( (det = (KVDetector*)nxt()) ){
-          fEloss[ndet] = det->GetEnergy();
-          ++ndet;
-        }
         // set particle momentum from telescope dimensions (random)
         GetAnglesFromTelescope();
     }
@@ -527,3 +391,24 @@
                	  if(idr->Aident) {SetA( idr->A );SetRealA( idr->PID );}
                	  else SetRealZ( idr->PID );
 }
+
+void KVReconstructedNucleus::SubtractEnergyFromAllDetectors()
+{
+	// Subtract the calculated energy loss of this particle from the measured energy
+	// loss of all detectors it passed through.
+		
+	TIter nxt(GetDetectorList(), kIterBackward);
+	KVDetector* det;
+   Double_t Einc = GetEnergy() - GetTargetEnergyLoss(); // energy before first detector
+   while( (det = (KVDetector*)nxt()) ){
+   	Double_t Edet = det->GetEnergy();
+   	Double_t dE = det->GetDeltaE(GetZ(), GetA(), Einc); // calculate apparent energy loss in active layer
+   	Double_t Eres = det->GetERes(GetZ(), GetA(), Einc); // calculate energy after detector
+   	Edet-=dE;
+   	if(Edet<0.1) Edet=0.;
+   	det->SetEnergyLoss(Edet);
+   	Einc = Eres;
+   	if(Einc<0.1) break;
+	}
+}
+

=== modified file 'KVMultiDet/particles/KVReconstructedNucleus.h'
--- KVMultiDet/particles/KVReconstructedNucleus.h	2011-05-26 12:14:32 +0000
+++ KVMultiDet/particles/KVReconstructedNucleus.h	2011-11-08 15:13:29 +0000
@@ -1,21 +1,3 @@
-/***************************************************************************
-                          kvreconstructednucleus.h  -  description
-                             -------------------
-    begin                : Fri Oct 18 2002
-    copyright            : (C) 2002 by Alexis Mignon
-    email                : mignon@xxxxxxxx
-
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
 #ifndef KVRECONSTRUCTEDNUCLEUS_H
 #define KVRECONSTRUCTEDNUCLEUS_H
 
@@ -32,13 +14,6 @@
 class KVReconstructedNucleus:public KVNucleus {
 
 protected:
-#define MAX_NUM_DET 5
-#define MAX_NUM_PAR 15
-   Int_t fNumDet;               //number of detectors particle passed through - Int_t imposed by TStreamerInfo
-   Double_t fEloss[MAX_NUM_DET]; //[5] measured energy losses in each successive detector
-   Int_t fNumPar;               //number of associated acquisition parameters - Int_t imposed by TStreamerInfo
-   UShort_t fACQData[MAX_NUM_PAR];//[15] values of acquisition parameters
-
     KVString fDetNames; // list of names of detectors through which particle passed
     KVHashList* fDetList; //! non-persistent list of pointers to detectors
     KVString fIDTelName;   // name of identification telescope which identified this particle (if any)
@@ -65,6 +40,17 @@
 
 public:
 
+	// status codes given to reconstructed particles by KVGroup::AnalyseParticles
+	enum {
+		kStatusOK,      // = 0 :   identification is, in principle at least, possible straight away
+		kStatusOKafterSub,   //= 1 :   identification is, in principle, possible after identification and subtraction
+		                                   //         of energy losses of other particles in the same group which have Status=0
+		kStatusOKafterShare,  // = 2 : the energy loss in the shared detector of the group must be shared
+                                           // (arbitrarily) between this and the other particle(s) with Status=2
+		kStatusStopFirstStage  // = 3 :   the particle has stopped in the first member of an identification
+                                           // telescope; a minimum Z could be estimated from the measured energy loss.
+	};
+
     KVReconstructedNucleus();
     KVReconstructedNucleus(const KVReconstructedNucleus &);
     void init();
@@ -102,51 +88,27 @@
         // Return pointer to the detector in which this particle stopped
         return GetDetector(0);
     };
-   void SetNumDet(UChar_t num) {
-      if (num > MAX_NUM_DET) {
-         Warning("SetNumDet(num)", "num is greater than max allowed (%d)",
-                 MAX_NUM_DET);
-         num = MAX_NUM_DET;
-      }
-      fNumDet = num;
-   };
-   UChar_t GetNumDet() const {
-      return fNumDet;
-   };
-   void SetNumPar(UChar_t num) {
-      if (num > MAX_NUM_PAR) {
-         Warning("SetNumPar(num)", "num is greater than max allowed (%d)",
-                 MAX_NUM_PAR);
-         num = MAX_NUM_PAR;
-      }
-      fNumPar = num;
-   };
-   UChar_t GetNumPar() const {
-      return fNumPar;
-   };
-   void SetACQData(const UShort_t * acqtab) {
-      for (UChar_t i = 0; i < fNumPar; i++) {
-         fACQData[i] = acqtab[i];
-      }
-   };
-   const UShort_t *GetACQData() const {
-      return fACQData;
-   }
-   void SetElossTable(const Double_t * etab) {
-      for (UChar_t i = 0; i < fNumDet; i++) {
-         fEloss[i] = etab[i];
-      }
-   }
-   const Double_t *GetElossTable() const {
-      return fEloss;
-   }
-
+   Int_t GetNumDet() const {
+      return GetDetectorList()->GetEntries();
+   };
     Int_t GetNSegDet() const {
+    	// return segmentation index of particle used by Identify() and
+    	// KVGroup::AnalyseParticles
         return fNSegDet;
     };
     void SetNSegDet(Int_t seg) {
+    	// set segmentation index of particle used by Identify() and
+    	// KVGroup::AnalyseParticles
         fNSegDet = seg;
     };
+    void ResetNSegDet()
+    {
+    	// recalculate segmentation index of particle used by Identify() and
+    	// KVGroup::AnalyseParticles
+    	fNSegDet=0;
+    	KVDetector* det; TIter nxt(fDetList);
+    	while( (det=(KVDetector*)nxt()) ) fNSegDet += det->GetSegment();
+    };
     inline Int_t GetStatus() const
     {
         // Returns status of reconstructed particle as decided by analysis of the group (KVGroup) in
@@ -155,12 +117,12 @@
         // straight away or if we need to wait until other particles in the same group have been
         // identified and calibrated (case of >1 particle crossing shared detector in a group).
         //
-        //  Status = 0 :   identification is, in principle at least, possible straight away
-        //  Status = 1 :   identification is, in principle, possible after identification of other particles
-        //                         in the same group which have Status=0
-        //  Status = 2 :   the energy loss in the shared detector of the group must be shared
-        //                         (arbitrarily) between this and the other particle(s) with Status=2
-        //  Status = 3 :   the particle has stopped in the first member of an identification
+        //  kStatusOK (0) :   identification is, in principle at least, possible straight away
+        //  kStatusOKafterSub (1) :   identification is, in principle, possible after identification and subtraction
+		  //                                           of energy losses of other particles in the same group which have Status=0
+        //  kStatusOKafterShare (2)  :   the energy loss in the shared detector of the group must be shared
+        //                                                (arbitrarily) between this and the other particle(s) with Status=2
+        //  kStatusStopFirstStage (3) :   the particle has stopped in the first member of an identification
         //                         telescope; a minimum Z could be estimated from the measured energy loss.
         //                         (see KVDetector::FindZmin)
         return fAnalStatus;
@@ -247,12 +209,6 @@
         return TestBit(kIsCalibrated);
     };
 
-/* 
-   Int_t GetIDSubCode(const Char_t * id_tel_type,
-                       KVIDSubCode & code) const;
-    const Char_t *GetIDSubCodeString(const Char_t * id_tel_type,
-                                     KVIDSubCode & code) const;
-*/
     void SetRealZ(Float_t zz) {
         fRealZ = zz;
     }
@@ -349,8 +305,10 @@
 	// Returns NULL if no identification of given type found.
 	return GetIdentificationResult(idt->GetType());
 };
+
+	virtual void SubtractEnergyFromAllDetectors();
 	
-    ClassDef(KVReconstructedNucleus, 14)  //Nucleus detected by multidetector array
+    ClassDef(KVReconstructedNucleus, 15)  //Nucleus detected by multidetector array
 };
 
 #endif

=== modified file 'KVMultiDet/vg_base/KVVGSum.cpp'
--- KVMultiDet/vg_base/KVVGSum.cpp	2009-01-23 15:25:52 +0000
+++ KVMultiDet/vg_base/KVVGSum.cpp	2011-11-08 15:13:29 +0000
@@ -78,6 +78,7 @@
 
 void KVVGSum::init_KVVGSum(void)
 {
+	ClearNameIndex();
    fClass = 0;
    fMethod = 0;
    fVal = 0;

=== modified file 'KVMultiDet/vg_base/KVVarGlob.h'
--- KVMultiDet/vg_base/KVVarGlob.h	2011-04-05 23:44:40 +0000
+++ KVMultiDet/vg_base/KVVarGlob.h	2011-11-08 15:13:29 +0000
@@ -40,6 +40,11 @@
  protected:
    void init(void);
    void SetNameIndex(const Char_t * name, Int_t index); // associe un nom et un index
+   void ClearNameIndex()
+   {
+   	// Delete previously defined associations between variable name and index
+   	nameList.Clear();
+   };
 
    KVString fFrame;//(optional) name of reference frame used for kinematics
    KVParameterList<KVString> fOptions;//list of options

=== modified file 'KVMultiDet/vg_shape/KVTensP.cpp'
--- KVMultiDet/vg_shape/KVTensP.cpp	2011-03-31 08:16:39 +0000
+++ KVMultiDet/vg_shape/KVTensP.cpp	2011-11-08 15:13:29 +0000
@@ -17,10 +17,11 @@
 //By default, only particles with Z >=  Zmin (default value=3) are included in
 //the calculation. Use SetZmin(0) or SetZmin(1) to include all particles.
 //
-//Use SetPartLabel() in order to use only particles with a given label.
+//Use SetPartGroup() in order to use only particles belonging to a given group
+//(see KVParticle::AddGroup and KVParticle::BelongsToGroup).
 //Note that the condition on the particle's Z is still used, thus
-//if e.g., SetZmin(10) and  SetPartLabel("alpha") are used, only
-//particles with the name/label "alpha" and Z>=10 will be included. 
+//if e.g., SetZmin(10) and  SetPartGroup("alpha") are used, only
+//particles belonging to group "alpha" and Z>=10 will be included. 
 //
 //By default the tensor is calculated from particle momenta
 //in the default (laboratory) frame.
@@ -34,14 +35,13 @@
 //
 //      Name            Index                   Meaning
 //----------------------------------------------------------------------------
-//      ThetaFlot       0       (default)       Theta flow (in degrees between -90 and +90)
+//      ThetaFlot       0       (default)       Theta flow (in degrees between 0 and +90)
 //      PhiPlan         1                       Phi of the reaction plane (in degrees between 0 and 360)
 //      Vap1            2                       Value of the 1st eigenvalue
 //      Vap2            3                       Value of the 2nd eigenvalue
 //      Vap3            4                       Value of the 3rd eigenvalue
 //      Sphericite      5                       Sphericity
 //      Coplanarite     6                       Coplanarity
-//      Directivite     7       (not computed)  Directivity
 //
 // All these values can be obtained by calling the GetValuePtr() method which
 // returns an array of Double_t containing the values.
@@ -88,7 +88,6 @@
    SetNameIndex("Vap3", 4);
    SetNameIndex("Sphericite", 5);
    SetNameIndex("Coplanarite", 6);
-   SetNameIndex("Directivite", 7);
 }
 
 
@@ -227,9 +226,9 @@
    //
    //This particle will be rejected if:
    //(1) it has Z < Zmin
-   //(2) it does not have the name/label defined with SetPartLabel**
+   //(2) it does not belong to the group defined with SetPartGroup**
    //
-   // **if no label defined, only Z>=Zmin condition is used.
+   // **if no group defined, only Z>=Zmin condition is used.
    //
    //This uses the 3 cartesian components of the particle's velocity vector
    //with a weight equal to the particle's A.
@@ -238,9 +237,7 @@
    //To calculate in another frame, use KVVarGlob::SetFrame() before
    //calculation begins
 
-   //if particle label has been set, check name of particle
-   //if not, accept all
-   Bool_t ok = ((fLabel != "") ? (fLabel == c->GetName()) : kTRUE);
+   Bool_t ok = ((fLabel != "") ? (c->BelongsToGroup(fLabel.Data())) : kTRUE);
 
    //check Z of particle
    if ((c->GetZ() >= GetZmin()) && ok) {
@@ -270,17 +267,15 @@
 // 4      Value of the 3rd eigenvalue
 // 5      Sphericity
 // 6      Coplanarity
-// 7      Directivity
 //
 
-   fVal[0] = tenseurP->GetThetaFlot();
+   fVal[0] = TMath::Abs(tenseurP->GetThetaFlot());
    fVal[1] = tenseurP->GetPhiPlan();
    fVal[2] = tenseurP->GetVap(1);
    fVal[3] = tenseurP->GetVap(2);
    fVal[4] = tenseurP->GetVap(3);
    fVal[5] = tenseurP->GetSphericite();
    fVal[6] = tenseurP->GetCoplanarite();
-   fVal[7] = tenseurP->GetDirectivite();
    return fVal;
 }
 
@@ -298,13 +293,12 @@
 // 4       Value of the 3rd eigenvalue
 // 5       Sphericity
 // 6       Coplanarity
-// 7       Directivity
 //
 //
    Double_t rval = 0;
    switch (i) {
    case 0:
-      rval = tenseurP->GetThetaFlot();
+      rval = TMath::Abs(tenseurP->GetThetaFlot());
       break;
 
    case 1:
@@ -331,10 +325,6 @@
       rval = tenseurP->GetCoplanarite();
       break;
 
-   case 7:
-      rval = tenseurP->GetDirectivite();
-      break;
-
    default:
       rval = 0.;
       break;

=== modified file 'KVMultiDet/vg_shape/KVTensP.h'
--- KVMultiDet/vg_shape/KVTensP.h	2011-03-31 08:16:39 +0000
+++ KVMultiDet/vg_shape/KVTensP.h	2011-11-08 15:13:29 +0000
@@ -52,10 +52,10 @@
 
    virtual Double_t *GetValuePtr(void); // On retourne un tableau de 
 
-   virtual void SetPartLabel(const Char_t * lab) {
+   virtual void SetPartGroup(const Char_t * lab) {
       fLabel = lab;
    };
-   virtual const Char_t *GetPartLabel() const {
+   virtual const Char_t *GetPartGroup() const {
       return fLabel.Data();
    };
 

=== modified file 'VAMOS/analysis/KVIVRawDataAnalyser.cpp'
--- VAMOS/analysis/KVIVRawDataAnalyser.cpp	2009-12-11 10:05:59 +0000
+++ VAMOS/analysis/KVIVRawDataAnalyser.cpp	2011-11-08 15:13:29 +0000
@@ -40,7 +40,8 @@
 
 void KVIVRawDataAnalyser::postInitRun()	
 {
-   	((KVGANILDataReader*)fRunFile)->GetGanTapeInterface()->SetUserTree( fBidonTree );
+	KVINDRARawDataAnalyser::postInitRun(); // initialise event counters
+   ((KVGANILDataReader*)fRunFile)->GetGanTapeInterface()->SetUserTree( fBidonTree );
 }
 
 //_______________________________________________________________________//

=== modified file 'VERSION'
--- VERSION	2011-06-10 10:49:54 +0000
+++ VERSION	2011-11-08 15:13:29 +0000
@@ -1,1 +1,5 @@
+<<<<<<< TREE
 1.8.2
+=======
+1.8.1a
+>>>>>>> MERGE-SOURCE

=== modified file 'etc/KaliVeda.rootrc'
--- etc/KaliVeda.rootrc	2011-10-25 14:30:21 +0000
+++ etc/KaliVeda.rootrc	2011-11-08 15:13:29 +0000
@@ -203,10 +203,6 @@
 Reconstruction.DataAnalysisTask.Prereq:     raw
 Reconstruction.DataAnalysisTask.Analyser:     INDRARawDataRecon
 
-# The following variable can be used to change the format of the "RawData" tree which is created and filled
-# in 'recon' data files. The value is the option given to KVGANILDataReader::SetUserTree.
-KVINDRARawDataReconstructor.RawDataTreeFormat:     arrays
-
 # The following variable controls the way that particles are reconstructed from raw data
 # In the detector in which the particle stops, we require KVDetector::Fired( "option" )
 # with "option" = "all" or "any".
@@ -347,6 +343,13 @@
 Identification2.DataAnalysisTask.UserClass:     no
 Identification2.DataAnalysisTask.UserClass.Base:     INDRAIdentRoot/TSelector
 
++DataAnalysisTask:     ReconRoot
+ReconRoot.DataAnalysisTask.Title:     Generation of fully-identified and calibrated data (recon->root)
+ReconRoot.DataAnalysisTask.Prereq:     recon
+ReconRoot.DataAnalysisTask.Analyser:     INDRAReconData
+ReconRoot.DataAnalysisTask.UserClass:     no
+ReconRoot.DataAnalysisTask.UserClass.Base:     INDRAReconRoot/TSelector
+
 +DataAnalysisTask:     RawAnalysis
 RawAnalysis.DataAnalysisTask.Title:     Analysis of raw data
 RawAnalysis.DataAnalysisTask.Prereq:     raw
@@ -445,6 +448,7 @@
 +Plugin.TSelector:   INDRAGeneDataSelector  KVINDRAGeneDataSelector      KVIndra   "KVINDRAGeneDataSelector()"
 +Plugin.TSelector:   INDRAReconIdent        KVReconIdent                 KVIndra   "KVReconIdent()"
 +Plugin.TSelector:   INDRAIdentRoot         KVIdentRoot                  KVIndra   "KVIdentRoot()"
++Plugin.TSelector:   INDRAReconRoot           KVINDRAReconRoot               KVIndra     "KVINDRAReconRoot()"
 +Plugin.TSelector:   IVReconIdent           KVIVReconIdent               VAMOS     "KVIVReconIdent()"
 #+Plugin.TSelector:   ReconIdent_e475s       KVReconIdent_e475s           KVIndra   "KVReconIdent_e475s()"
 +Plugin.TSelector:   IVSelector           KVIVSelector               VAMOS     "KVIVSelector()"

=== modified file 'html/ReleaseNotes_1.8.1.html'
--- html/ReleaseNotes_1.8.1.html	2011-06-09 15:52:05 +0000
+++ html/ReleaseNotes_1.8.1.html	2011-11-08 15:13:29 +0000
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="css/site.css" type="text/css">
 </head>
 <body>
-<h1>KaliVeda v1.8.1 Release Notes</h1>
+<h1>KaliVeda v1.8.1a Release Notes</h1>
 <div class="leftSide">
 <div class="KaliVeda">KaliVeda</div>
 <img
@@ -27,7 +27,7 @@
 <div class="page">
 <h2><br>
 </h2>
-Here is a (far-from-complete) list of what's new in KaliVeda v1.8.1.<br>
+Here is a (far-from-complete) list of what's new in KaliVeda v1.8.1a.<br>
 For more details, see <a
  href="https://launchpad.net/kaliveda/1.8/1.8.1";>here</a>.<br>
 <br>
@@ -61,7 +61,13 @@
   <li>all particles whose mass is not measured have A calculated from Z
 using Charity EAL formula (KVNucleus::kEALMass formula).</li>
   <li>discrimination of neutrons is performed for all forward rings
-(1-9) by comparison of CsI and Si-CsI identifications.<br>
+(1-9) by comparison of CsI and Si-CsI identifications.</li>
+  <li>energy calibration codes now have the same meaning (and values)
+as for previous campaigns of data. The "standard" codes to accept for
+analysis are therefore kECode1 and kECode2 (<span
+ style="font-family: monospace;">GetEvent()-&gt;AcceptECodes(kECode1 |
+kECode2)</span> in <span style="font-family: monospace;">InitRun() </span>of
+analysis classes).<br>
   </li>
 </ul>
 <br>
@@ -78,7 +84,8 @@
 <br>
 New "simulation mode" for detectors (<a
  href="1.8.1/KVDetector.html#KVDetector:SetSimMode">KVDetector::SetSimMode</a>)
-and multidetector arrays (<a
+and
+multidetector arrays (<a
  href="1.8.1/KVMultiDetArray.html#KVMultiDetArray:SetSimMode">KVMultiDetArray::SetSimMode</a>
 - this just turns on the "simulation mode" for all detectors of the
 array). In "simulation mode" a detector is "fired" (<a
@@ -122,7 +129,8 @@
 Several improvements have been made to the ROOT geometry generated from
 a KVMultiDetArray (method <a
  href="1.8.1/KVMultiDetArray.html#KVMultiDetArray:CreateGeoManager">KVMultiDetArray::CreateGeoManager</a>),
-with a view to using it with the Virtual Monte Carlo (VMC) package
+with
+a view to using it with the Virtual Monte Carlo (VMC) package
 provided by ROOT in order to interface with packages such as GEANT3 and
 GEANT4.<br>
 All TGeoMaterials used in the geometry for composite materials in the
@@ -156,7 +164,8 @@
 The
 specific
 implementation
-to be used is determined by an environment
+to
+be used is determined by an environment
 variable:<br>
 <pre>KVMaterial.IonRangeTable:     VEDALOSS</pre>
 and all implementations are plugin classes derived from KVIonRangeTable:<br>
@@ -193,7 +202,8 @@
 are
 still
 in
-centimetres. Note that these classes now inherit the new <a
+centimetres.
+Note that these classes now inherit the new <a
  href="1.8.1/KVINDRADetector.html">KVINDRADetector</a> base class.<br>
 <br>
 <h3>Changes to existing classes</h3>
@@ -206,7 +216,7 @@
 now have the same meaning for all materials: they concern the linear
 dimensions of the absorber (standard units: centimetres). New methods <span
  style="font-family: monospace;">Get/SetAreaDensity</span> apply in the
-same way to all, with standard units of g/cm**3.<br>
+same way to all, with standard units of g/cm**2.<br>
 The methods<br>
 <pre>Double_t GetBraggDE(Int_t Z, Int_t A)<br>Double_t GetBraggE(Int_t Z, Int_t A)<br></pre>
 have been renamed:<br>
@@ -273,7 +283,8 @@
 creates a TGraph which gives the punch-through energy as a function of
 Z for Z=1 to Z=92. <a
  href="1.8.1/KVMultiDetArray.html#KVMultiDetArray:DrawPunchThroughEnergyVsZ">KVMultiDetArray::DrawPunchThroughEnergyvsZ(const
-Char_t* detector)</a> does the same but takes into account any
+Char_t*
+detector)</a> does the same but takes into account any
 detectors which are placed in front of the detector in question in the
 array geometry; the punch-through energy in this case corresponds to
 the incident energy required to punch through all previous detectors
@@ -307,7 +318,8 @@
 It
 manages
 a
-list of KVedaLossMaterial objects which use the same
+list
+of KVedaLossMaterial objects which use the same
 tabulation of ranges of heavy ions as before:<br>
 <pre>	*************************************************************************<br>	*                VEDALOSS STOPPING POWER &amp; RANGE TABLES                 *<br>	*                                                                       *<br>	*   1.  Si      Silicon             Z=14 A= 28.1  rho= 2.330 g/cm**3    *<br>	*   2.  Myl     Mylar               Z= 4 A=  8.7  rho= 1.395 g/cm**3    *<br>	*   3.  NE102   Plastic             Z= 3 A=  6.5  rho= 1.032 g/cm**3    *<br>	*   4.  Ni      Nickel              Z=28 A= 58.7  rho= 8.902 g/cm**3    *<br>	*   5.  C3F8    Octofluoropropane   Z= 8 A= 17.1  rho= 0.008 g/cm**3    *<br>	*   6.  C       Carbon              Z= 6 A= 12.0  rho= 1.900 g/cm**3    *<br>	*   7.  Ag      Silver              Z=47 A=107.9  rho=10.500 g/cm**3    *<br>	*   8.  Sn      Tin                 Z=50 A=118.7  rho= 5.750 g/cm**3    *<br>	*   9.  CsI     CesiumIodide        Z=54 A=129.9  rho= 4.510 g/cm**3    *<br>	*  10.  Au      Gold                Z=79 A=197.0  rho=19.300 g/cm**3    *<br>	*  11.  U       Uranium             Z=92 A=238.0  rho=18.950 g/cm**3    *<br>	*  12.  Air     Air                 Z= 7 A= 14.4  rho= 0.001 g/cm**3    *<br>	*  13.  Nb      Nobium              Z=41 A= 92.9  rho= 8.570 g/cm**3    *<br>	*  14.  Ta      Tantalum            Z=73 A=180.9  rho=16.654 g/cm**3    *<br>	*  15.  Al      Aluminium           Z=13 A= 27.0  rho= 2.699 g/cm**3    *<br>	*  16.  KCl     KCl                 Z=18 A= 37.3  rho= 1.987 g/cm**3    *<br>	*  17.  CF4     Tetrafluoromethane  Z= 8 A= 17.6  rho= 0.004 g/cm**3    *<br>	*  18.  Ca      Calcium             Z=20 A= 40.1  rho= 1.550 g/cm**3    *<br>	*  19.  Ge      Germanium           Z=32 A= 72.6  rho= 5.323 g/cm**3    *<br>	*  20.  Cu      Copper              Z=29 A= 63.5  rho= 8.960 g/cm**3    *<br>	*  21.  Ti      Titanium            Z=22 A= 47.9  rho= 4.540 g/cm**3    *<br>	*  22.  Bi      Bismuth             Z=83 A=209.0  rho= 9.747 g/cm**3    *<br>	*  23.  V       Vanadium            Z=23 A= 50.9  rho= 6.110 g/cm**3    *<br>	*  24.  C4H10   Isobutane           Z= 2 A=  4.2  rho= 0.002 g/cm**3    *<br>	*  25.  Pb      Lead                Z=82 A=207.2  rho=11.350 g/cm**3    *<br>	*  26.  PbS     LeadSulphide        Z=49 A=120.0  rho= 7.500 g/cm**3    *<br>	*  27.  Mg      Magnesium           Z=12 A= 24.3  rho= 1.738 g/cm**3    *<br>	*  28.  Li      Lithium             Z= 3 A=  6.9  rho= 0.534 g/cm**3    *<br>	*  29.  Zn      Zinc                Z=30 A= 65.4  rho= 7.133 g/cm**3    *<br>	*                                                                       *<br>	*     TF1::Range::Npx =   20            TF1::EnergyLoss::Npx =   50     *<br>	*                      TF1::ResidualEnergy::Npx =   20                  *<br>	*                                                                       *<br>	*                       INITALISATION COMPLETE                          *<br>	*************************************************************************<br></pre>
 The tabulated range of ions in each material as a function of incident
@@ -326,7 +338,8 @@
 the
 two
 results
-were not always the same, and could have a significant
+were
+not always the same, and could have a significant
 difference).<br>
 <br>
 As mentioned above, all units and "thicknesses" have been rationalised


Follow ups