void KVINDRAPulserDataTree::CreateTree()
{
   // Create new TTree with
   //   1 branch 'Run' with run number
   //   1 branch for each acquisition parameter of every detector (except time markers)
   //   2 branches for each 'PILA_...' or 'SI_PIN...' parameter, suffixed with '_laser' and '_gene'
   //
   // NB if multidetector has not been built, it will be built by this method

   fArb = new TTree("PulserData", "Created by KVINDRAPulserDataTree");
   fArb->SetDirectory(0);

   fArb->Branch("Run", &fRun, "Run/I");

   if (!gIndra) KVMultiDetArray::MakeMultiDetector(gDataSet->GetName());

   KVSeqCollection* acq_pars = gIndra->GetACQParams();

   fTab_siz = acq_pars->GetEntries() + 20;
   fVal = new Float_t[fTab_siz];
   fIndex = new THashTable(20, 5);
   fIndex->SetOwner(kTRUE);

   TIter nxtACQ(acq_pars);
   KVACQParam* ap = 0;
   Int_t ap_num = 0;
   KVBase* iob;
   while ((ap = (KVACQParam*)nxtACQ())) {

      TString ap_name(ap->GetName());
      TString ap_type(ap->GetType());
      if (ap_name.BeginsWith("PILA") || ap_name.BeginsWith("SI_PIN")) {
         ap_name += "_laser";
         iob = new KVBase(ap_name.Data());
         iob->SetNumber(ap_num);
         fIndex->Add(iob);
         fArb->Branch(ap_name.Data(), &fVal[ap_num++] , Form("%s/F", ap_name.Data()));
         ap_name.Form("%s%s", ap->GetName(), "_gene");
         iob = new KVBase(ap_name.Data());
         iob->SetNumber(ap_num);
         fIndex->Add(iob);
         fArb->Branch(ap_name.Data(), &fVal[ap_num++] , Form("%s/F", ap_name.Data()));
      } else if (ap_type != "T") {
         iob = new KVBase(ap_name.Data());
         iob->SetNumber(ap_num);
         fIndex->Add(iob);
         fArb->Branch(ap_name.Data(), &fVal[ap_num++] , Form("%s/F", ap_name.Data()));
      }
      if (ap_num > fTab_siz - 2) {
         Error("CreateTree",
               "Number of branches to create is greater than estimated (%d). Not all parameters can be treated.",
               fTab_siz);
         return;
      }

   }
   //keep number of used 'slots' in array
   fTab_siz = ap_num;
}
示例#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.));
         }
      }
   }

}