Esempio n. 1
0
Bool_t KVVAMOSDetector::Fired(Option_t* opt, Option_t* optP)
{
   //Returns kTRUE if detector was hit (fired) in an event
   //
   //The actual meaning of hit/fired depends on the context and the option string opt.
   //
   //opt="any" (default) and optP="":
   //Returns true if at least one working acquisition parameter
   //associated with the detector was fired in an event, for ANY of the types
   //in the list*.
   //
   //opt="all" and optP="" :
   //Returns true if at least one working acquisition parameter
   //associated with the detector was fired in an event, for ALL of the types
   //in the list*.
   //
   //opt="any" and optP="P" :
   //Returns true if at least one working acquisition parameter
   //associated with the detector was fired in an event and have a value
   //greater than their pedestal value, for ANY of the types in the list*.
   //
   //opt="all" and optP="P":
   //Returns true if at least one working acquisition parameter
   //associated with the detector was fired in an event and have a value
   //greater than their pedestal value, for ALL of the types in the list*.
   //
   // *the actual parameters taken into account can be fine tuned using environment variables such as
   //          KVVAMOSDetector.Fired.ACQParameterList.[type]: Q,E,T,T_HF,X,Y
   // See KVAMOSDetector::SetFiredBitmask() for more details.


   if (!IsDetecting()) return kFALSE; //detector not working, no answer at all

   Bool_t opt_all = !strcmp(opt, "all");
   Binary8_t event; // bitmask for event

   // Look at the three first bits for XYZ positions
   UChar_t xyz_mask = fFiredMask.Subvalue(2, 3);
// Info("Fired","Option %s, FiredBitmask %s, xyz_mask (%d)",opt,fFiredMask.String(), xyz_mask);
   if (xyz_mask) {
      Double_t xyz[3];
      UChar_t  xyz_res = GetRawPosition(xyz);
//    cout<<Form(" xyz_res (%d)",xyz_res)<<endl;
      if (opt_all && (xyz_mask != xyz_res)) return kFALSE;
      event.Set(xyz_res);
   }

   // Look at the other bits for  ACQ Parameters
   UChar_t Nbits = fFiredMask.GetNBits();
   Binary8_t keep_up(fFiredMask.Subvalue(Nbits - 1, Nbits - 3));
// Info("Fired","keep_up %s",keep_up.String());
   UChar_t id;
   TIter next(GetACQParamList());
   TIter next_t(GetTACQParamList());
   KVACQParam* par;
   while (keep_up.Value() && ((par = (KVACQParam*)next()) || (par = (KVACQParam*)next_t()))) {
      if (par->IsWorking() && par->Fired(optP)) {
         id = GetACQParamTypeIdxFromID(par->GetUniqueID());
         event.SetBit(id + 3);
         keep_up.ResetBit(id);
      }
// Info("Fired","%s is %s fired, keep_up %s",par->GetName(), par->Fired( optP ) ? "" : "NOT" ,keep_up.String());
   }

   Binary8_t ok = fFiredMask & event;
// Info("Fired","ok %s", ok.String());

   // "all" considered parameters fired if ok == mask
   // "any" considered parameters fired if ok != 0
   if (opt_all)  return (ok == fFiredMask);
   return (ok != "0");
}
Esempio n. 2
0
void KVVAMOSDetector::SetCalibrators()
{
   // Setup the calibrators for this detector. Call once name
   // has been set.
   // The calibrators are KVFunctionCal.
   // By default the all the calibration functions are first-degree
   // polynomial function and the range [Xmin,Xmax]=[0,4096].
   // Here the calibrator are not ready (KVFunctionCal::GetStatus()).
   // You have to give the parameters and change the status
   // (see KVFunctionCal::SetParameter(...) and KVFunctionCal::SetStatus(...))


   TIter nextpar(GetACQParamList());

   KVACQParam* par   = NULL;
   Double_t    maxch = 16384.;       // 14 bits

   TString  calibtype("ERROR");

   while ((par = (KVACQParam*)nextpar())) {
      Bool_t isTparam = kFALSE;

      if (par->IsType("E")) {
         calibtype = "channel->MeV";
      } else if (par->IsType("Q")) {
         calibtype = "channel->Volt";
         maxch     = 4096.;           // 12 bits
      } else if (par->GetType()[0] == 'T') {
         isTparam = kTRUE;
         calibtype = "channel->ns";
      } else continue;

      calibtype.Append(" ");
      calibtype.Append(par->GetName());

      TF1* func        = new TF1(calibtype.Data(), "pol1", 0., maxch);
      KVFunctionCal* c = new KVFunctionCal(this, func);
      c->SetType(calibtype.Data());
      c->SetLabel(par->GetLabel());
      c->SetNumber(par->GetNumber());
      c->SetUniqueID(par->GetUniqueID());
      c->SetACQParam(par);
      c->SetStatus(kFALSE);
      if (!AddCalibrator(c)) delete c;
      else if (isTparam) {
         if (!fTlist) fTlist = new TList;
         fTlist->Add(par);
         if (!fT0list) fT0list = new TList;
         fT0list->Add(new KVNamedParameter(par->GetName(), 0.));
      }
   }

   // Define and set to zero the T0 values for time of flight measurment
   // from this detector. The time of flight acq parameters are associated
   // to gVamos
   if (gVamos) {
      TIter next_vacq(gVamos->GetVACQParams());
      while ((par = (KVACQParam*)next_vacq())) {
         if ((par->GetType()[0] == 'T') && IsStartForT(par->GetName() + 1)) {
            if (!fTlist) fTlist = new TList;
            fTlist->Add(par);
            if (!fT0list) fT0list = new TList;
            fT0list->Add(new KVNamedParameter(par->GetName(), 0.));
         }
      }
   }

}