Esempio n. 1
0
KVINDRATelescope* KVINDRA::BuildTelescope(const Char_t* prefix, Int_t module)
{
   // Build telescope from infos in file "$KVROOT/KVFiles/data/indra-struct.[dataset].env"

   //Info("BuildTelescope", "Building telescope %s",name);
   KVINDRATelescope* kvt = new KVINDRATelescope;
   KVString telescopes = fStrucInfos.GetValue(Form("%s.Telescope", prefix), "");
   telescopes.Begin(" ");
   KVString name;
   while (!telescopes.End()) {
      name = telescopes.Next();
      KVNumberList mods = fStrucInfos.GetValue(Form("%s.Telescope.%s.Modules", prefix, name.Data()), "1-100");
      if (mods.Contains(module)) break;
   }

   KVString detectors = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.Detectors", name.Data()), "");
   Double_t aziwidth = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.AziWidth", name.Data()), 1.0);
   Double_t dist = fStrucInfos.GetValue(Form("%s.Dist", prefix), 0.0);
   kvt->SetDistance(dist);
   detectors.Begin(" ");
   Int_t idet = 1;
   while (!detectors.End()) {
      KVString detector = detectors.Next();
      detector.Begin("()");
      KVString dettype = detector.Next();
      Double_t detthick = detector.Next().Atof();
      KVDetector* det = KVDetector::MakeDetector(Form("%s.%s", fDataSet.Data(), dettype.Data()), detthick);
      kvt->Add(det);
      Double_t depth = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.Depth.%s", name.Data(), dettype.Data()), 0.);
      kvt->SetDepth(idet, depth);
      idet++;
   }
   kvt->SetAzimuthalWidth(aziwidth);
   return kvt;
}
Esempio n. 2
0
void KVEventSelector::ParseOptions()
{
   // Analyse comma-separated list of options given to TTree::Process
   // and store all "option=value" pairs in fOptionList.
   // Options can then be accessed using IsOptGiven(), GetOptString(), etc.
   //
   //     BranchName=xxxx  :  change name of branch in TTree containing data
   //     EventsReadInterval=N: print "+++ 12345 events processed +++" every N events
   //
   // This method is called by SlaveBegin
   //

	fOptionList.Clear(); // clear list
   KVString option = GetOption();
   option.Begin(",");
   while (!option.End()) {

      KVString opt = option.Next();
      opt.Begin("=");
      KVString param = opt.Next();
      KVString val=opt.Next();
      while(!opt.End()){
          val+="=";
          val+=opt.Next();
      }

      SetOpt(param.Data(), val.Data());
   }
	
	fOptionList.Print();
	// check for branch name
	if(IsOptGiven("BranchName")) SetBranchName(GetOpt("BranchName"));
	// check for events read interval
	if(IsOptGiven("EventsReadInterval")) SetEventsReadInterval(GetOpt("EventsReadInterval").Atoi());
}
Esempio n. 3
0
//___________________________________________________________________________________________
void KVValues::init_val_base()
{
//protected method
//Mise en correspondance du noms des differentes valeurs a calculees
//et de leur position dans le tableau values
// Ex:
// nom_valeurs -> id_valeurs -> values[id_valeurs]

   KVString lname = "MIN MAX";
   lname.Begin(" ");
   kval_base = 0;    //variables de base disponibles

   kval_tot = 0; //nombre de variables totales disponibles
   while (!lname.End()) {
      KVString tamp = lname.Next();
      SetValue(tamp.Data(), kval_tot++);
   }
   kdeb = kval_tot;  //ici pos_deb=2 (par defaut)

   KVString smoment;
   for (Int_t mm = 0; mm <= kordre_mom_max; mm += 1) { //Ex: moment_max = 3
      smoment.Form("SUM%d", mm);
      SetValue(smoment.Data(), kval_tot++);
   }
   kval_base = kval_tot;   //ici nbase=6 (par defaut)

   values = new Double_t[knbre_val_max];
   init_val();


}
Esempio n. 4
0
KVRangeYanez::KVRangeYanez()
   : KVIonRangeTable("RANGE",
                     "Interface to Range dE/dx and range library (Ricardo Yanez)")
{
   // Default constructor
   // Predefined materials are created based on the contents of the file(s) whose
   // names are given as values of the variable KVRangeYanez.PredefMaterials.
   // A default file is specified in the main .kvrootrc file.
   // If you want to add your own definitions, just put in your .kvrootrc:
   //+RANGE.PredefMaterials: myfile1.dat
   //+RANGE.PredefMaterials: myfile2.dat
   // If you want to override the default definitions:
   //RANGE.PredefMaterials: myfile1.dat
   //+RANGE.PredefMaterials: myfile2.dat

   KVString DataFilePaths = gEnv->GetValue("RANGE.PredefMaterials", "");
   DataFilePaths.Begin(" ");
   KVString nextPath;
   KVString lastPath;
   while (!DataFilePaths.End()) {
      nextPath = DataFilePaths.Next();
      if (nextPath == lastPath) break; //check for double occurrence of last file : TEnv bug?
      lastPath = nextPath;
      ReadPredefinedMaterials(nextPath);
   }
}
Esempio n. 5
0
void KVINDRA::BuildGeometry()
{
   // Construction of INDRA detector array.
   // Uses infos in file $KVROOT/KVFiles/data/indra_struct.[dataset].env
   //                 or $KVROOT/KVFiles/data/indra_struct.env
   // if no dataset-specific file found


   TString path = Form("indra-struct.%s.env", fDataSet.Data());
   TString path2;
   SearchKVFile(path.Data(), path2, "data");
   if (path2 == "") {
      path = "indra-struct.env";
      SearchKVFile(path.Data(), path2, "data");
   }
   fStrucInfos.ReadFile(path2, kEnvAll);

   KVString lruns = fStrucInfos.GetValue("AddOnForRuns", "");
   //test if additional geometrical specification exists
   if (lruns != "") {
      lruns.Begin(",");
      while (!lruns.End()) {
         KVString sruns = lruns.Next();
         KVNumberList nlr(sruns.Data());
         //the current run needs specific geometry
         if (nlr.Contains(fCurrentRun)) {
            path = fStrucInfos.GetValue(sruns.Data(), "");
            Info("BuildGeometry", "Additional geometry for run=%d in file #%s#", fCurrentRun, path.Data());
            SearchKVFile(path.Data(), path2, "data");
            if (path2 == "") {
               Warning("BuildGeometry", "fichier %s inconnu", path.Data());
            }
            else {
               fStrucInfos.ReadFile(path2, kEnvChange);
            }
         }
      }
   }

   SetName(fStrucInfos.GetValue("INDRA.Name", ""));
   SetTitle(fStrucInfos.GetValue("INDRA.Title", ""));

   KVString layers = fStrucInfos.GetValue("INDRA.Layers", "");
   layers.Begin(" ");
   while (!layers.End()) BuildLayer(layers.Next());
}
Esempio n. 6
0
void KVINDRA::SetPinLasersForCsI()
{
   // Sets the KVCsI::fPinLaser member of each CsI detector with the number of the
   // pin laser associated for the stability control of these detectors.
   //
   // We look for a file with the following format:
   //
   // CSI_0101     1
   // CSI_0102     1
   // CSI_0103     1
   // CSI_0104     1
   // etc.
   //
   // i.e. 'name of CsI detector'   'number of pin laser (1-8)'
   // Comment lines must begin with '#'
   //
   // The default name of this file is defined in .kvrootrc by
   //
   // INDRADB.CsIPinCorr:          CsI_PILA.dat
   //
   // Dataset-specific version can be specified:
   //
   // INDRA_e999.INDRADB.CsIPinCorr:    CorrCsIPin_2054.dat
   //
   // This file should be in the directory corresponding to the current dataset,
   // i.e. in $KVROOT/KVFiles/name_of_dataset

   ifstream pila_file;
   if (gDataSet->OpenDataSetFile(gDataSet->GetDataSetEnv("INDRADB.CsIPinCorr", ""), pila_file)) {

      Info("SetPinLasersForCsI", "Setting correspondance CsI-PinLaser using file %s.",
           gDataSet->GetDataSetEnv("INDRADB.CsIPinCorr", ""));
      // read file, set correspondance
      KVString line;
      line.ReadLine(pila_file);
      while (pila_file.good()) {
         if (!line.BeginsWith("#")) {
            line.Begin(" ");
            KVString detname = line.Next(kTRUE);
            KVCsI* det = (KVCsI*)GetDetector(detname.Data());
            Int_t pila = line.Next(kTRUE).Atoi();
            if (det) {
               det->SetPinLaser(pila);
            }
         }
         line.ReadLine(pila_file);
      }
      pila_file.close();
   }
   else {
      Info("SetPinLasersForCsI", "File %s not found. Correspondance Csi-PinLaser is unknown.",
           gDataSet->GetDataSetEnv("CsIPinCorr", ""));
   }
}
Esempio n. 7
0
void KVINDRAPulserDataTree::ReadFile(ifstream& fin)
{
	// Read data in one file

	KVString line;
	line.ReadLine(fin);
	while( fin.good() ){
		if( !line.BeginsWith("#") ){
			line.Begin(" ");
			KVString br_name = line.Next(kTRUE);
			Int_t index = GetIndex(br_name.Data());
			fVal[index] = line.Next(kTRUE).Atof();
		}
		line.ReadLine(fin);
	}
	fin.close();
}
Esempio n. 8
0
void KVGeoNavigator::FormatStructureName(const Char_t* type, Int_t number, KVString& name)
{
   // If a format for naming structures of given type has been defined by a call
   // to SetStructureNameFormat(const Char_t *, const Char_t *), we use it to
   // format the name in the TString.
   // If no format was given, we use by default "[type]_[number]"
   // If SetNameCorrespondanceList(const Char_t *) was used, we use it to translate
   // any names resulting from this formatting to their final value.

   name = "";
   if (fStrucNameFmt.HasParameter(type)) {
      KVString fmt = fStrucNameFmt.GetStringValue(type);
      fmt.Begin("$");
      while (!fmt.End()) {
         KVString bit = fmt.Next();
         if (bit.BeginsWith("type")) {
            Ssiz_t ind = bit.Index("%");
            if (ind > -1) {
               bit.Remove(0, ind);
               name += Form(bit.Data(), type);
            } else
               name += type;
         } else if (bit.BeginsWith("number")) {
            Ssiz_t ind = bit.Index("%");
            if (ind > -1) {
               bit.Remove(0, ind);
               name += Form(bit.Data(), number);
            } else
               name += number;
         } else
            name += bit;
      }
   } else
      name.Form("%s_%d", type, number);
   TString tmp;
   GetNameCorrespondance(name.Data(), tmp);
   name = tmp;
}
Esempio n. 9
0
void KVGeoNavigator::ExtractDetectorNameFromPath(KVString& detname)
{
   // We analyse the current path in order to construct the full (unique) name
   // of the detector, i.e. if the current path is
   //
   // /TOP_1/STRUCT_BLOCK_2/CHIO_WALL_1/DET_CHIO_2/WINDOW_1
   //
   // then the default name of the detector will be "BLOCK_2_CHIO_2"
   // (see below to override this)
   //
   // This method also fills the fCurrentStructures array with elements
   // deduced from the path, e.g. if the path is
   //
   // /TOP_1/STRUCT_BLOCK_2/STRUCT_QUARTET_1/DET_SI1-T1
   //
   // then by default
   //  fCurrentStructures[0] = KVGeoStrucElement(name = "BLOCK_2", type = "BLOCK", number = 2)
   //  fCurrentStructures[1] = KVGeoStrucElement(name = "QUARTET_1", type = "QUARTET", number = 1)
   //
   // and the default name of the detector will be "BLOCK_2_QUARTET_1_SI1-T1"
   //
   // STRUCTURE & DETECTOR NAME FORMATTING
   // ====================================
   //    -- STRUCTURES --
   // The default names for structures are taken from the node name by stripping off
   // the "STRUCT_" prefix. It is assumed that the remaining string is of the form
   //    "[structure type]_[structure number]"
   // (the structure number is always taken after the last occurence of '_' in the
   // node name). This is the name that will be used by default for the structure.
   // However, this format can be change by calling method
   //    SetStructureNameFormat("[structure type]", "[format]")
   // where format can contain any of the following tokens:
   //    $type$         - will be replaced by the structure type name
   //    $type%[fmt]$   - will be replaced by the structure type name using given format
   //    $number$       - will be replaced by the structure number
   //    $number%[fmt]$ - will be replaced by the structure number using given format
   //
   // Example: to change the name of the block in the previous example to "B-02",
   //   SetStructureNameFormat("BLOCK", "$type%.1s$-$number%02d$")
   //
   //    -- DETECTORS --
   // The default base names for detectors are taken from the node name by stripping off
   // the "DET_" prefix. In order to ensure that all detectors have unique names,
   // by default we prefix the names of the parent structures to the basename in
   // order to generate the full name of the detector:
   //    [struc1-name]_[struc2-name]_..._[detector-basename]
   // However, this format can be changed by calling method
   //    SetDetectorNameFormat("[format]")
   // where format can contain any of the following tokens:
   //    $det:name$             - will be replaced by the detector basename
   //    $struc:[type]:name$    - will be replaced by the name of the parent structure of given type
   //    $struc:[type]:type$    - will be replaced by the type of the parent structure of given type
   //    $struc:[type]:number$  - will be replaced by the number of the parent structure of given type
   // plus additional formatting information as for SetStructureNameFormat (see above).
   //
   // Example: to change the name of the "SI1-T1" detector in the previous example to
   //  "SI1-T1-Q1-B2":
   //   SetDetectorNameFormat("$det:name$-Q$struc:QUARTET:number$-B$struc:BLOCK:number$")
   // Or if you also change the format of the structure names:
   //   SetStructureNameFormat("BLOCK", "$type%.1s$$number$")
   //   SetStructureNameFormat("QUARTET", "$type%.1s$$number$")
   //   SetDetectorNameFormat("$det:name$-$struc:QUARTET:name$-$struc:BLOCK:name$")


   KVString path = GetCurrentPath();
   path.Begin("/");
   detname = "";
   fCurrentStructures.Clear("C");
   fCurStrucNumber = 0;
   while (!path.End()) {
      KVString elem = path.Next();
      if (elem.BeginsWith("STRUCT_")) {
         // structure element. strip off "STRUCT_" and extract type and number of structure.
         KVString struc_name(elem(7, elem.Length() - 7));
         KVGeoStrucElement* gel = (KVGeoStrucElement*)fCurrentStructures.ConstructedAt(fCurStrucNumber++);
         Ssiz_t last_ = struc_name.Last('_'); // find last '_' in structure name
         TString type = struc_name(0, last_);
         TString nums = struc_name(last_ + 1, struc_name.Length() - last_ - 1);
         Int_t number = nums.Atoi();
         KVString name;
         FormatStructureName(type, number, name);
         gel->SetNameTitle(name, type);
         gel->SetNumber(number);
      } else if (elem.BeginsWith("DET_")) {
         // detector name. strip off "DET_" and use rest as basename
         KVString basename(elem(4, elem.Length() - 4));
         FormatDetectorName(basename, detname);
      }
   }
}
Esempio n. 10
0
void KVGeoNavigator::FormatDetectorName(const Char_t* basename, KVString& name)
{
   // If a format for naming detectors has been defined by a call
   // to SetDetectorNameFormat(const Char_t *), we use it to
   // format the name in the TString.
   // If no format was given we prefix the names of the parent structures
   // to the basename in order to generate the full name of the detector:
   //    [struc1-name]_[struc2-name]_..._[detector-basename]
   // If SetNameCorrespondanceList(const Char_t *) was used, we use it to translate
   // any names resulting from this formatting to their final value.

   name = "";
   if (!fCurStrucNumber) {
      // no parent structures
      name = basename;
   } else {
      if (fDetNameFmt == "") {
         for (int i = 0; i < fCurStrucNumber; i++) {
            KVGeoStrucElement* el = (KVGeoStrucElement*)fCurrentStructures[i];
            name += Form("%s_", el->GetName());
         }
         name += basename;
      } else {
         //    $det:name$             - will be replaced by the detector basename
         //    $struc:[type]:name$    - will be replaced by the name of the parent structure of given type
         //    $struc:[type]:type$    - will be replaced by the type of the parent structure of given type
         //    $struc:[type]:number$  - will be replaced by the number of the parent structure of given type
         fDetNameFmt.Begin("$");
         while (!fDetNameFmt.End()) {
            KVString bit = fDetNameFmt.Next();
            if (bit.Contains(":")) {
               bit.Begin(":");
               KVString itbit = bit.Next();
               if (itbit == "det") {
                  itbit = bit.Next();
                  if (itbit.BeginsWith("name")) {
                     Ssiz_t ind = itbit.Index("%");
                     if (ind > -1) {
                        itbit.Remove(0, ind);
                        name += Form(itbit.Data(), basename);
                     } else
                        name += basename;
                  }
               } else if (itbit == "struc") {
                  KVString struc_typ = bit.Next();
                  KVGeoStrucElement* el = 0;
                  for (int i = 0; i < fCurStrucNumber; i++) {
                     el = (KVGeoStrucElement*)fCurrentStructures[i];
                     if (el->IsType(struc_typ)) break;
                  }
                  if (el) {
                     itbit = bit.Next();
                     if (itbit.BeginsWith("name")) {
                        Ssiz_t ind = itbit.Index("%");
                        if (ind > -1) {
                           itbit.Remove(0, ind);
                           name += Form(itbit.Data(), el->GetName());
                        } else
                           name += el->GetName();
                     } else if (itbit.BeginsWith("type")) {
                        Ssiz_t ind = itbit.Index("%");
                        if (ind > -1) {
                           itbit.Remove(0, ind);
                           name += Form(itbit.Data(), el->GetType());
                        } else
                           name += el->GetType();
                     } else if (itbit.BeginsWith("number")) {
                        Ssiz_t ind = itbit.Index("%");
                        if (ind > -1) {
                           itbit.Remove(0, ind);
                           name += Form(itbit.Data(), el->GetNumber());
                        } else
                           name += el->GetNumber();
                     }
                  }
               }
            } else
               name += bit;
         }
      }
   }
   TString tmp;
   GetNameCorrespondance(name.Data(), tmp);
   name = tmp;
}
Esempio n. 11
0
void KVEventListMaker::Process(){

if (!IsReady()) return;

//open file where tree is stored
TFile *file = new TFile(GetFileName().Data(),"update");
KVList *kevtlist = new KVList(); 

TTree *tt = NULL;

//just count the number of branches
KVString lname = GetBranchName();
Int_t  nbre=0;
lname.Begin(" ");
while (!lname.End()) {KVString stamp=lname.Next(); nbre+=1;}
if (nbre==0) return;

Int_t *variable = new Int_t[nbre];
KVString evtname;
Bool_t ok=kFALSE;
//check if the tree are there
if ( (tt = (TTree *)file->Get(GetTreeName().Data())) ){
	Int_t nentries = tt->GetEntries();
	printf("nbre d entree %d\n",nentries);
	TBranch* bb = NULL;
	
	nbre=0;
	lname.Begin(" ");
	//loop on branche names validity, if there is one wrong name
	//the program will exit
	while (!lname.End()) {
		KVString stamp = lname.Next();
		if ( (bb = tt->GetBranch(stamp.Data())) ){
			tt->SetBranchAddress(stamp.Data(),&variable[nbre]);
			nbre+=1;
			ok=kTRUE;
		}
	}

	if (!ok) return;
	
	TEventList *el = NULL;
	//loop on tree entries
	for (Int_t kk=0;kk<nentries;kk+=1){
		if (kk%10000==0) printf("%d evts lus\n",kk);

		tt->GetEntry(kk);
		evtname="";
		nbre=0;
		lname.Begin(" ");
		//compute the name of the TEventList
		//using branch name and branch value
		while (!lname.End()) {
			KVString stamp = lname.Next();
			if ( (bb = tt->GetBranch(stamp.Data())) ){
				KVString val; val.Form("%s_%d_",stamp.Data(),variable[nbre]);
				evtname+=val;
				nbre+=1;
			}
		}
		
		if ( !(el = (TEventList *)kevtlist->FindObject(evtname.Data())) ){
			printf("creation de %s \n",evtname.Data());
			kevtlist->Add(new TEventList(evtname.Data()));
			el = (TEventList *)kevtlist->Last();
		}
		el->Enter(kk);
	}
		
	//write TEventList created
	if (ktag_tree){
		for (Int_t nn=0;nn<kevtlist->GetEntries();nn+=1){
			KVString tampname;
			tampname.Form("%s_%s",GetTreeName().Data(),kevtlist->At(nn)->GetName());
			((TEventList*) kevtlist->At(nn))->SetName(tampname.Data());
			kevtlist->At(nn)->Write();
		}
	}
	else {	
		kevtlist->Write();
	}	
}
else printf("%s n existe pas\n",GetTreeName().Data());

delete [] variable;
//close the file
file->Close();

}
Esempio n. 12
0
KVString  GetValue(KVString &l, char c)
{
    l.Begin(c);
    l.Next();
    return l.Next(kTRUE);
}
Esempio n. 13
0
void KVRangeYanez::ReadPredefinedMaterials(const Char_t* filename)
{
   // Read materials from file whose name is given

   TString DataFilePath = filename;

   ifstream filestream;
   if (!SearchAndOpenKVFile(DataFilePath, filestream, "data")) {
      Error("ReadPredefinedMaterials", "Cannot open %s for reading", DataFilePath.Data());
      return;
   }
   Info("ReadPredefinedMaterials", "Reading materials in file : %s", filename);

   Bool_t compound, mixture;
   compound = mixture = kFALSE;

   KVString line;
   while (filestream.good()) {
      line.ReadLine(filestream);
      if (filestream.good()) {
         if (line.BeginsWith("//")) continue;
         if (line.BeginsWith("COMPOUND")) {
            compound = kTRUE;
            mixture = kFALSE;
         } else if (line.BeginsWith("MIXTURE")) {
            compound = kFALSE;
            mixture = kTRUE;
         }
         if (compound || mixture) {
            // new compound or mixed material
            KVString name, symbol, state;
            Double_t density = -1;
            KVString element[10];
            Int_t natoms[10];
            Int_t z[10], a[10];
            Double_t proportion[10];
            Int_t nelem = 0;
            line.ReadLine(filestream);
            while (filestream.good() && !line.IsWhitespace() && line != "\n") {
               line.Begin("=");
               KVString next = line.Next();
               if (next == "name") name = line.Next();
               else if (next == "symbol") symbol = line.Next();
               else if (next == "state") state = line.Next();
               else if (next == "density") density = line.Next().Atof();
               else if (next == "nelem") {
                  nelem = line.Next().Atoi();
                  for (int i = 0; i < nelem; i++) {
                     line.ReadLine(filestream);
                     line.Begin(" ");
                     element[i] = line.Next();
                     a[i] = KVNucleus::IsMassGiven(element[i]);
                     KVNucleus n(element[i]);
                     z[i] = n.GetZ();
                     if (!a[i]) a[i] = TMath::Nint(n.GetNaturalA());
                     natoms[i] = line.Next().Atoi();
                     if (mixture) proportion[i] = line.Next().Atof();
                  }
               }
               line.ReadLine(filestream, kFALSE); //do not skip 'whitespace'
            }
            if (compound) AddCompoundMaterial(name, symbol, nelem, z, a, natoms, density);
            else if (mixture) AddMixedMaterial(name, symbol, nelem, z, a, natoms, proportion, density);
            compound = mixture = kFALSE;
         }
      }
   }
}