Exemplo n.º 1
0
Bool_t KVGANILDataReader::GetNextEvent()
{
   // Read next event in raw data file.
   // Returns false if no event found (end of file).
   // The list of all fired acquisition parameters is filled, and can be retrieved with
   // GetFiredDataParameters().
   // If SetUserTree(TTree*) has been called, the TTree is filled with the values of all
   // parameters in this event.

   Bool_t ok = fGanilData->Next();
   FillFiredParameterList();
   if( fUserTree ){
      if( make_arrays ){
         NbParFired = fFired->GetEntries();
         TIter next(fFired); KVACQParam* par;
         int i=0;
         while( (par = (KVACQParam*)next()) ){
            ParVal[i] = par->GetCoderData();
            ParNum[i] = par->GetNumber();
            i++;
         }
      }
      fUserTree->Fill();
   }
   return ok;
}
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;
}
Exemplo n.º 3
0
void KVGANILDataReader::FillFiredParameterList()
{
    // clears and then fills list fFired with all fired acquisition parameters in event
   fFired->Clear();
   TIter next(fParameters);
   KVACQParam *par;
   while( (par = (KVACQParam*)next()) ) if(par->Fired()) fFired->Add(par);
}
Exemplo n.º 4
0
Float_t KVVAMOSDetector::GetT(const Char_t* type)
{
   // Returns the coder value of a time acquisition parameter (in channel)
   //  of type 'type' (SED_HF, SI_HF, SI_SED1, ...).
   // A time signal is always associated to an object KVVAMOS pointed by
   // gVamos, then gVamos has to be different to zero. If gVamos is null
   // or type is not correct, this method returns -1;

   if (!IsStartForT(type) || !gVamos) return -1;
   KVACQParam* par = gVamos->GetACQParam(Form("T%s", type));
   return (par ? par->GetData() : -1);
}
Exemplo n.º 5
0
void KVHarpeeSi::SetACQParams(){
// Setup the energy acquisition parameter for this silicon detector.
// This parameter has the name of the detector and has the type 'E' 
// (for energy).
// 
	KVACQParam *par = new KVACQParam;
	par->SetName( GetEBaseName() );
	par->SetType("E");
	par->SetNumber( GetNumber() );
	par->SetUniqueID( CalculateUniqueID( par ) );
	AddACQParam(par);
}
Exemplo n.º 6
0
void KVSiliconVamos::SetACQParams()
{
   // Add an acquisition parameter to this detector

   if (!fACQParams) {
      fACQParams = new KVList();
   }
   // creer parametre d'acquisition avec meme nom que le detecteur
   KVACQParam* par = new KVACQParam(GetName());
   par->SetDetector(this);
   par->SetType("E");
   fACQParams->Add(par);
}
Exemplo n.º 7
0
KVList *KVSpectroDetector::GetFiredACQParamList(Option_t *opt){
	// Returns a list with all the fired acquisiton parameters of
	// this detector. The option is set to the method KVACQParam::Fired;
	//
	// *** WARNING *** : DELETE the list returned by this method after using it !!!
	TIter next( GetACQParamList() );
	KVACQParam *par = NULL;
	KVList *list = new KVList( kFALSE );
	while( (par = (KVACQParam *)next()) ){
		if( par->Fired( opt ) ) list->Add( par ); 
	}
	return list;
}
Exemplo n.º 8
0
void KVBIC::AddACQParam(const Char_t* type)
{
   //Add an acquisition parameter of given type to this detector
   //The parameters for the BIC in blocking telescopes 1, 2, and 3
   //were called CI_1601_x, CI_1602_x, and CI_1603_x respectively,
   //so here we have to override the KVDetector default behaviour.

   if (!fACQParams)
      fACQParams = new KVList();
   KVACQParam* par = new KVACQParam();
   TString name;
   name.Form("CI_16%02d_%s", GetTelescope()->GetNumber(), type);
   par->SetName(name);
   par->SetDetector(this);
   par->SetType(type);
   fACQParams->Add(par);
}
Exemplo n.º 9
0
void KVINDRAUpDater_e475s::SetCalibrationParameters(UInt_t run){


    //Set calibration parameters for this run.
    //This will:
    //      remove all the calibrators of all the detectors ready to receive the calibrators for the run (handled by child classes),
    //      set calibration parameters for the run
    //      set pedestals for the run
    
    cout << "Setting calibration parameters of INDRA array for run " << run << ":" <<
    endl;
    KVDBRun *kvrun = gIndraDB->GetRun(run);
    if (!kvrun)
    {
        Error("SetParameters(UInt_t)", "Run %u not found in database!", run);
        return;
    }
    //Reset all calibrators of all detectors first
    TIter next(gIndra->GetListOfDetectors());
    KVDetector *kvd;
    while ((kvd = (KVDetector *) next()))
    {
      if (kvd->InheritsFrom("KVSiLi") || kvd->InheritsFrom("KVSi75")){
		 	if (kvd->GetListOfCalibrators())
			kvd->RemoveCalibrators();
		 	kvd->SetCalibrators();
		  }
		 else {
		  if (kvd->GetListOfCalibrators())
        {
            kvd->RemoveCalibrators();
				TIter lacq(kvd->GetACQParamList());
				KVACQParam* acq = 0;
				while ( (acq = (KVACQParam* )lacq()) ){
					acq->SetPedestal(0);
				}
		  }
    	}
	 }
    SetCalibParameters(kvrun);
    SetPedestals(kvrun);

}
Exemplo n.º 10
0
void KVINDRAUpDater::SetCsIGainCorrectionParameters(KVDBRun* kvrun)
{
   // Sets KVCsI::fGainCorrection data member, used by KVCsI::GetCorrectedLumiereTotale
   // to return the total light output corrected by a run-dependent factor.
   // We set all detectors' correction to 1, then set the corrections defined for this
   // run, if any.

   TIter next_csi(GetINDRA()->GetListOfCsI());
   KVCsI* csi;
   while ((csi = (KVCsI*)next_csi())) {
      csi->SetTotalLightGainCorrection(1.0);
   }

   KVRList* param_list = kvrun->GetLinks("CsIGainCorr");
   if (!param_list) {
      return;
   }
   if (!param_list->GetSize()) {
      return;
   }

   TIter next_ps(param_list);
   KVDBParameterSet* dbps;
   while ((dbps = (KVDBParameterSet*)next_ps())) {

      csi = (KVCsI*)fArray->GetDetector(dbps->GetName());
      if (!csi) {
         // the name of the parameter set should be the name of the detector;
         // however, it may be the name of an acquisition parameter associated with
         // the detector!
         KVACQParam* a = fArray->GetACQParam(dbps->GetName());
         if (a) csi = (KVCsI*)a->GetDetector();
         // still no good ?
         if (!csi) {
            Warning("SetCsIGainCorrectionParameters",
                    "Cannot find detector associated with %s", dbps->GetName());
            continue;
         }
      }
      csi->SetTotalLightGainCorrection(dbps->GetParameter());
      Info("SetCsIGainCorrectionParameters", "%s gain correction = %f", csi->GetName(), csi->GetTotalLightGainCorrection());
   }
}
Exemplo n.º 11
0
KVACQParam* KVGANILDataReader::CheckACQParam( const Char_t* par_name )
{
   //Check the named acquisition parameter.
   //We look for a corresponding parameter in the list of acq params belonging to
   //the current KVMultiDetArray (if one exists).
   //If none is found, we create a new acq param which is added to the list of "unknown parameters"

   KVACQParam *par;
   if( !gMultiDetArray || !(par = gMultiDetArray->GetACQParam( par_name )) ){
      //create new unknown parameter
      par = new KVACQParam;
      par->SetName( par_name );
		if(!fExtParams){
			fExtParams=new KVHashList;
			fExtParams->SetOwner(kTRUE);
		}
      fExtParams->Add( par );
   }
   return par;
}
Exemplo n.º 12
0
UInt_t KVHarpeeIC::GetFiredSegNumber(Option_t* opt)
{
   // return the number of the fired segment of this Harpee ionisation chamber
   // ( number between 1 to 7 ). Returns 0 if no segment or several segments
   // are fired. A segment is considered as fired if at least one of its 3
   // acquisition parameters (A, B and C) is fired (KVACQParam::Fired( opt )).
   // Set the option opt = "P" to accept only the acquisition parameters with
   // their value above the pedestal.

   TIter next(GetACQParamList());
   KVACQParam* par = NULL;
   UInt_t num = 0;

   while ((par = (KVACQParam*)next())) {
      if (par->Fired(opt)) {
         if (num && (num != par->GetNumber())) return 0;
         num = par->GetNumber();
      }
   }
   return num;
}
Exemplo n.º 13
0
void KVINDRAReconDataAnalyser::preAnalysis()
{
	// Read and set raw data for the current reconstructed event
    // Any required data patches ("rustines") are applied.

	if(!theRawData) return;
	// all recon events are numbered 1, 2, ... : therefore entry number is N-1
	Long64_t rawEntry = fSelector->GetEventNumber() - 1;

	gIndra->GetACQParams()->R__FOR_EACH(KVACQParam,Clear)();

	theRawData->GetEntry(rawEntry);
	for(int i=0; i<NbParFired; i++){
		KVACQParam* par = gIndra->GetACQParam((*parList)[ParNum[i]]->GetName());
		if(par) {par->SetData(ParVal[i]);}
	}

    // as rustines often depend on a knowledge of the original raw data,
    // we apply them after it has been read in
    if(fRustines.HasActivePatches()) fRustines.Apply(fSelector->GetEvent());
}
Exemplo n.º 14
0
void KVHarpeeIC::SetACQParams()
{
   // Setup acquisition parameters of this ionisation chamber.
   // ACQ parameters with type 'E':
   // E[detector type]_[A,B,C]_[detector number]
   //
   // WARNING: actually only the acquisition parameters with indice 'A'
   // are defined ('B' and 'C' were not coded in e494s and e503 experiment ).

   TString name;
   Char_t idx[] = {'A', 'B', 'C'};

   for (Int_t num = 1; num <= ARPEEIC_NSEG; num++) {
//    for(Int_t i = 0; i<3; i++){
      for (Int_t i = 0; i < 1; i++) {
         KVACQParam* par = new KVACQParam;
         name.Form("E%s_%c_%d", GetType(), idx[i], num);
         par->SetName(name);
         par->SetType("E");
         par->SetLabel(Form("%c", idx[i]));
         par->SetNumber(num);
         par->SetUniqueID(CalculateUniqueID(par));
         AddACQParam(par);
      }
   }
}
Exemplo n.º 15
0
Int_t KVSpectroDetector::GetMult(Option_t *opt){
	// Returns the multiplicity of fired (value above the pedestal) 
	// acquisition parameters if opt = "" (default).
	// If opt = "root" returns the multiplicity of only fired acq. 
	// parameters with GetName() containing "root". For example if
	// you want the multiplicity of fired segments B of a child class
	// KVHarpeeIC call GetMult("ECHI_B").

	Int_t mult   = 0;

	TString str( opt );
	Bool_t withroot = !str.IsNull();

	TIter next( GetACQParamList() );
	KVACQParam *par = NULL;
	while( (par = (KVACQParam *)next()) ){
		if( withroot ){
			str = par->GetName();
			if( !str.Contains( opt ) ) continue;
		}
		if( par->Fired("P") ) mult++;
	}
	return mult;
}
Exemplo n.º 16
0
void KVGANILDataReader::ConnectRawDataParameters()
{
        //Private utility method called by KVGANILDataReader ctor.
	//fParameters is filled with a KVACQParam for every acquisition parameter in the file.
	//If there exists a gMultiDetArray corresponding to this data, we use the KVACQParams
	//already defined for the detectors of the array whenever possible.
	//For any parameters for which no KVACQParam already exists (a fortiori if no
	//gMultiDetArray exists) we create new KVACQParam objects which will be deleted
	//with this KVGANILDataReader (these objects can be accessed from the list
	//returned by GetUnknownParameters()).
	//To access the full list of data parameters in the file after this method has been
	//called (i.e. after the file is opened), use GetRawDataParameters().

   TIter next( fGanilData->GetListOfDataParameters() );
   KVACQParam *par;
   GTDataPar* daq_par;
   while ((daq_par = (GTDataPar*) next())) {//loop over all parameters
      par=CheckACQParam( daq_par->GetName() );
      fGanilData->Connect(par->GetName(), par->ConnectData());
      par->SetNumber(daq_par->Index());
      par->SetNbBits(daq_par->Bits());
      fParameters->Add(par);
   }
}
Exemplo n.º 17
0
void KVGANILDataReader::SetUserTree(TTree* T, Option_t* opt)
{
   // To fill a TTree with the data in the current file, create a TTree:
   //    TFile* file = new TFile("run1.root","recreate");
   //    TTree* T = new TTree("Run1", "Raw data for Run1");
   // and then call this method: SetUserTree(T)
   // If you read all events of the file, the TTree will be automatically filled
   // with data :
   //    while( runfile->GetNextEvent() ) ;
   //
   // Two different TTree structures are available, depending on the option string:
   //
   //    opt = "arrays": [default]
   //
   // The TTree will have the following structure:
   //
   //    *Br    0 :NbParFired : NbParFired/I    = number of fired parameters in event
   //    *............................................................................*
   //    *Br    1 :ParNum    : ParNum[NbParFired]/i   = array of indices of fired parameters
   //    *............................................................................*
   //    *Br    2 :ParVal    : ParVal[NbParFired]/s   = array of values of fired parameters
   //
   // This structure is the fastest to fill and produces the smallest file sizes.
   // In order to be able to directly access the parameters as if option "leaves" were used
   // (i.e. one branch/leaf for each parameter), we add two aliases for each parameter to
   // the tree:
   //        PARNAME           = value of parameter if present in event
   //        PARNAME_M      = number of times parameter appears in event
   // Assuming that each parameter only appears at most once in each event, i.e. PARNAME_M=0 or 1,
   // then
   //    root[0] T->Draw("PARNAME", "PARNAME_M")
   // will histogram the value of PARNAME for each event in which it is present.
   // (if the selection condition "PARNAME_M" is not used, the histogram will also be filled with a 0
   // for each event in which PARNAME does not appear).
   //          N.B. the PARNAME alias is in fact the sum of the values of PARNAME in each event.
   //          If PARNAME_M>1 in some events, it is not the individual values but their sum which will
   //          be histogrammed in this case.
   //
   // Thus, if the data file has parameters called "PAR_1" and "PAR_2",
   // the following command will work
   //
   //    root[0]  T->Draw("PAR_1:PAR_2", "PAR_1_M&&PAR_2_M", "col")
   //
   // even though no branches "PAR_1" or "PAR_2" exist.
   //
   //
   //
   //    opt = "leaves":
   //
   // The TTree will have a branch/leaf for each parameter. This option is slower and produces
   // larger files.
   //
   // If the option string contains both "arrays" and "leaves", then both structures will be used
   // (in this case there is a high redundancy, as each parameter is stored twice).
   //
   // The full list of parameters is stored in a TObjArray in the list returned by TTree::GetUserInfo().
   // Each parameter is represented by a TNamed object.
   // In order to retrieve the name of the parameter with index 674 (e.g. taken from branch ParNum),
   // do:
   //     TObjArray* parlist = (TObjArray*) T->GetUserInfo()->FindObject("ParameterList");
   //     cout << "Par 674 name = " << (*parlist)[674]->GetName() << endl;
   //
   //
   //  Automatic creation & filling of Scalers TTree
   //
   // give an option string containing "scalers", i.e. "leaves,scalers", or "ARRAYS+SCALERS", etc.
   // a TTree with name 'Scalers' will be created, all scaler buffers will be written in it.


   TString option = opt;
   option.ToUpper();
   make_arrays = option.Contains("ARRAYS");
   make_leaves = option.Contains("LEAVES");
   Bool_t make_scalers = option.Contains("SCALERS");
   if(make_scalers){
   	fGanilData->SetScalerBuffersManagement(GTGanilData::kAutoWriteScaler);
   }

   fUserTree = T;
   if( make_arrays ){
      Int_t maxParFired = GetRawDataParameters()->GetEntries();
      ParVal = new UShort_t[maxParFired];
      ParNum = new UInt_t[maxParFired];
      fUserTree->Branch("NbParFired", &NbParFired, "NbParFired/I");
      fUserTree->Branch("ParNum", ParNum, "ParNum[NbParFired]/i");
      fUserTree->Branch("ParVal", ParVal, "ParVal[NbParFired]/s");
   }
   if( make_leaves ){
      TIter next_rawpar( GetRawDataParameters() );
      KVACQParam* acqpar;
      while( (acqpar = (KVACQParam*)next_rawpar()) ){
         TString leaf;
         leaf.Form("%s/S", acqpar->GetName());
         // for parameters with <=8 bits only use 1 byte for storage
         if(acqpar->GetNbBits()<=8) leaf += "1";
         fUserTree->Branch( acqpar->GetName(), *(acqpar->ConnectData()), leaf.Data() );
      }
   }

#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
   fUserTree->SetAutoFlush(0);
#endif
#endif

   // add list of parameter names in fUserTree->GetUserInfos()
   // and if option="arrays" add aliases for each parameter & its multiplicity
	
	// TObjArray has to be as big as the largest parameter number in the list
	// of raw data parameters. So first loop over parameters to find max param number.
    UInt_t maxpar = 0;
   TIter next(GetRawDataParameters());
   KVACQParam* par;
	while( (par=(KVACQParam*)next()) ) if (par->GetNumber()>maxpar) maxpar=par->GetNumber();
	
   TObjArray *parlist = new TObjArray(maxpar,1);
   parlist->SetName("ParameterList");
	
	next.Reset();
   while( (par = (KVACQParam*)next()) ){
      parlist->AddAt( new TNamed( par->GetName(), Form("index=%d",par->GetNumber()) ), par->GetNumber() );
      if( make_arrays ){
          fUserTree->SetAlias( par->GetName(), Form("Sum$((ParNum==%d)*ParVal)", par->GetNumber() ) );
          fUserTree->SetAlias( Form("%s_M", par->GetName()), Form("Sum$(ParNum==%d)", par->GetNumber() ) );
      }
   }
   fUserTree->GetUserInfo()->Add(parlist);
}
Exemplo n.º 18
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");
}
Exemplo n.º 19
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.));
         }
      }
   }

}
Exemplo n.º 20
0
//_______________________________________________________________//
void KVINDRAUpDater::CheckStatusOfDetectors(KVDBRun* kvrun)
{

   KVRList* absdet = kvrun->GetLinks("Absent Detectors");
   KVRList* oooacq = kvrun->GetLinks("OoO ACQPars");
   KVRList* ooodet = kvrun->GetLinks("OoO Detectors");

   TIter next(fArray->GetDetectors());
   KVDetector* det;
   KVACQParam* acq;

   Int_t ndet_absent = 0;
   Int_t ndet_ooo = 0;
   Int_t nacq_ooo = 0;

   while ((det = (KVDetector*)next())) {
      //Test de la presence ou non du detecteur
      if (!absdet) {
         det->SetPresent();
      }
      else {
         if (absdet->FindObject(det->GetName(), "Absent Detector")) {
            det->SetPresent(kFALSE);
            ndet_absent += 1;
         }
         else {
            det->SetPresent();
         }
      }
      if (det->IsPresent()) {
         //Test du bon fonctionnement ou non du detecteur
         if (!ooodet) {
            det->SetDetecting();
         }
         else {
            if (ooodet->FindObject(det->GetName(), "OoO Detector")) {
               det->SetDetecting(kFALSE);
               ndet_ooo += 1;
            }
            else {
               det->SetDetecting();
            }
         }
         //Test du bon fonctionnement ou non des parametres d acquisition
         if (det->IsDetecting()) {
            TIter next_acq(det->GetACQParamList());
            if (!oooacq) {
               while ((acq = (KVACQParam*)next_acq())) {
                  acq->SetWorking();
               }
            }
            else {
               Int_t noff = 0;
               while ((acq = (KVACQParam*)next_acq())) {
                  if (oooacq->FindObject(acq->GetName(), "OoO ACQPar")) {
                     acq->SetWorking(kFALSE);
                     noff += 1;
                     nacq_ooo += 1;
                  }
                  else {
                     acq->SetWorking();
                  }
               }
               if (noff == 3) {
                  det->SetDetecting(kFALSE);
                  ndet_ooo += 1;
                  nacq_ooo -= 3;
               }
            }
         }
      }
   }

   Info("KVINDRAUpDater", "%d detecteurs absents", ndet_absent);
   Info("KVINDRAUpDater", "%d detecteurs ne fonctionnent pas", ndet_ooo);
   Info("KVINDRAUpDater", "%d parametres d acquisition ne fonctionnent pas", nacq_ooo);



}
void KVINDRARawDataReconstructor::InitRun()
{
   // Creates new ROOT file with TTree for reconstructed/calibrated events.
   // By default this file will be written in the same data repository as the raw data file we are reading.
   // This can be changed by setting the environment variable(s):
   //
   //     Reconstruction.DataAnalysisTask.OutputRepository:     [name of repository]
   //     [name of dataset].Reconstruction.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 raw file (if possible, i.e. if repository is not remote).

   // Create new KVINDRAReconEvent used to reconstruct & store events
   // The condition used to seed new reconstructed particles (see KVReconstructedEvent::AnalyseTelescopes)
   // is set by reading the value of the environment variables:
   //     Reconstruction.DataAnalysisTask.ParticleSeedCond:        [all/any]
   //     [name of dataset].Reconstruction.DataAnalysisTask.ParticleSeedCond:     [all/any]
   // If no value is set for the current dataset (second variable), the value of the
   // first variable will be used.

   if (!recev) recev = new KVINDRAReconEvent;
   recev->SetPartSeedCond(gDataSet->GetDataSetEnv("Reconstruction.DataAnalysisTask.ParticleSeedCond"));

   // get dataset to which we must associate new run
   KVDataSet* OutputDataset =
      gDataRepositoryManager->GetDataSet(gDataSet->GetOutputRepository(taskname), gDataSet->GetName());

   file = OutputDataset->NewRunfile(datatype.Data(), fRunNumber);

   cout << "Writing \"" << datatype.Data() << "\" events in ROOT file " << file->GetName() << endl;

   //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");
   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";
   GetRawDataReader()->SetUserTree(rawtree, raw_opt.Data());
   Info("InitRun", "Created raw data tree (%s : %s). Format: %s",
        rawtree->GetName(), rawtree->GetTitle(), raw_opt.Data());

#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
   rawtree->SetAutoFlush(0);
#endif
#endif


   //tree for reconstructed events
   tree = new TTree("ReconstructedEvents", Form("%s : %s : %s events created from raw data",
                    gIndraDB->GetRun(fRunNumber)->GetName(),
                    gIndraDB->GetRun(fRunNumber)->GetTitle(),
                    datatype.Data())
                   );
#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
   tree->SetAutoFlush(0);
#endif
#endif


   //leaves for reconstructed events
   KVEvent::MakeEventBranch(tree, "INDRAReconEvent", "KVINDRAReconEvent", &recev);

   Info("InitRun", "Created reconstructed data tree %s : %s", tree->GetName(), tree->GetTitle());

   //tree for gene data
   genetree = new TTree("GeneData", Form("%s : %s : gene data",
                                         gIndraDB->GetRun(fRunNumber)->GetName(), gIndraDB->GetRun(fRunNumber)->GetTitle()));

   //we add to the 'gene tree' a branch for every acquisition parameter of the detector
   genetree->Branch("RunNumber", &fRunNumber, "RunNumber/I");
   genetree->Branch("EventNumber", &fEventNumber, "EventNumber/I");
   KVACQParam* acqpar;
   TIter next_acqpar(gIndra->GetACQParams());
   while ((acqpar = (KVACQParam*)next_acqpar())) {
      genetree->Branch(acqpar->GetName(), *(acqpar->ConnectData()), Form("%s/S", acqpar->GetName()));
   }
#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
   genetree->SetAutoFlush(0);
#endif
#endif


   Info("InitRun", "Created pulser/laser data tree (%s : %s) for %d parameters",
        genetree->GetName(), genetree->GetTitle(), genetree->GetNbranches());
   //initialise number of reconstructed events
   nb_recon = 0;

}