void KVFAZIARawDataReconstructor::ExtraProcessing()
{
   KVString label = "";

   KVFAZIADetector* det = 0;
   KVSignal* sig = 0;
   KVReconstructedNucleus* recnuc = 0;
   while ((recnuc = recev->GetNextParticle())) {
      TIter next_d(recnuc->GetDetectorList());
      while ((det = (KVFAZIADetector*)next_d())) {
         TIter next_s(det->GetListOfSignals());
         while ((sig = (KVSignal*)next_s())) {
            if (sig->HasFPGA()) {
               for (Int_t ii = 0; ii < sig->GetNFPGAValues(); ii += 1) {
                  //SI2-T3-Q1-B003.Q2.RawAmplitude=14
                  if (ii == 0) label = "FPGAEnergy";
                  if (ii == 1) label = "FPGAFastEnergy"; //only for CsI Q3
                  TString ene = GetEvent()->GetFPGAEnergy(
                                   det->GetBlockNumber(),
                                   det->GetQuartetNumber(),
                                   det->GetTelescopeNumber(),
                                   sig->GetType(),
                                   ii
                                );

                  recnuc->GetParameters()->SetValue(
                     Form("%s.%s.%s", det->GetName(), sig->GetName(), label.Data()),
                     ene.Data()
                  );
               }
            }
            if (!sig->PSAHasBeenComputed()) {
               sig->TreateSignal();
            }

            KVNameValueList* psa = sig->GetPSAResult();
            if (psa) {
               *(recnuc->GetParameters()) += *psa;
               delete psa;
            }
         }
      }
   }
}
Bool_t ExampleFilteredSimDataAnalysis::Analysis()
{
   // EVENT BY EVENT ANALYSIS

   // Reject events with less good particles than acquisition trigger for run
   if (!GetEvent()->IsOK()) return kTRUE;

   mult = GetEvent()->GetMult("ok");

   // if we can access the events of the unfiltered simulation, read in the event corresponding
   // to the currently analysed reconstructed event
   if (link_to_unfiltered_simulation) GetFriendTreeEntry(GetEvent()->GetParameters()->GetIntValue("SIMEVENT_TREE_ENTRY"));

   for (int i = 0; i < mult; i++) {
      KVReconstructedNucleus* part = (KVReconstructedNucleus*)ZMAX->GetZmax(i);
      Z[i] = part->GetZ();
      A[i] = part->GetA();
      idcode[i] = part->GetIDCode();
      ecode[i] = part->GetECode();
      Ameasured[i] = part->IsAMeasured();
      // Example for events filtered with FAZIA@INDRA set-up
      if (part->GetParameters()->GetTStringValue("ARRAY") == "INDRA") array[i] = 0;
      else if (part->GetParameters()->GetTStringValue("ARRAY") == "FAZIA") array[i] = 1;
      else array[i] = -1;
      Vper[i] = part->GetFrame("cm")->GetVperp();
      Vpar[i] = part->GetFrame("cm")->GetVpar();
      ELab[i] = part->GetEnergy();
      ThetaLab[i] = part->GetTheta();
      PhiLab[i] = part->GetPhi();
      // if we can access the events of the unfiltered simulation, and if Gemini++ was used
      // to decay events before filtering, this is how you can access the "parent" nucleus
      // of the current detected decay product
      // KVSimNucleus* papa = (KVSimNucleus*)GetFriendEvent()->GetParticle( part->GetParameters()->GetIntValue("GEMINI_PARENT_INDEX") );
   }

   GetGVList()->FillBranches();
   FillTree();

   return kTRUE;
}
Bool_t KVINDRABackwardGroupReconstructor::CoherencyChIoCsI(KVReconstructedNucleus& PART)
{
   // Called by Identify() for particles stopping in CsI detectors on rings 10-17,
   // which have a ChIo detector just in front of them.
   //
   // fPileupChIo = kTRUE if ChIo-CsI identification gives Z >> CsI-R/L identification
   //              this means that the particle identified in CsI-R/L is correct,
   //              and there is probably a second particle which stopped in the ChIo
   //              detector at the same time (will be added as a Zmin/code5)

   KVIdentificationResult* IDcsi = PART.GetIdentificationResult(1);
   KVIdentificationResult* IDcicsi = PART.GetIdentificationResult(2);
   KVIDTelescope* idt_cicsi = (KVIDTelescope*)PART.GetReconstructionTrajectory()->GetIDTelescopes()->FindObjectByType(IDcicsi->GetType());
   KVIDTelescope* idt_csi = (KVIDTelescope*)PART.GetReconstructionTrajectory()->GetIDTelescopes()->FindObjectByType(IDcsi->GetType());

   PART.SetParameter("PileupChIo", kFALSE);

   // Unsuccessful/no CsI id attempt with successful ChIo-CsI id ?
   // Then use ChIo-CsI identification result
   if (IDcsi && !IDcsi->IDOK) {
      if (IDcicsi && IDcicsi->IDOK) {
         partID = *IDcicsi;
         identifying_telescope = idt_cicsi;
         return kTRUE;
      }
   }

   // check coherency of CsI-R/L and ChIo-CsI identifications
   if (IDcsi && IDcsi->IDOK) {

      // We check the coherency of the identifications
      // Because ChIo-Csi identification is not of very high quality (compared to CsI R-L),
      // we only check that the Z given by ChIo-CsI is < Zref+1
      // If not, we can suspect the presence of another particle in the ChIo

      if (IDcicsi && IDcicsi->IDOK) {
         Int_t Zref = IDcsi->Z;
         if (IDcicsi->Z > (Zref + 1) && PART.GetParameters()->GetBoolValue("UseFullChIoEnergyForCalib")) {
            PART.SetParameter("PileupChIo", kTRUE);
            IDcicsi->SetComment("Possible pile-up in ChIo");
         }
      }

      // in all other cases accept CsI identification
      partID = *IDcsi;
      identifying_telescope = idt_csi;
      return kTRUE;
   }
   return kFALSE;
}