コード例 #1
0
ファイル: KVFAZIADetector.cpp プロジェクト: pwigg/kaliveda
//________________________________________________________________
Bool_t KVFAZIADetector::SetProperties()
{
	// detector name are assumed to be defined as
   // SI2-T2-Q2-B001
	//	CSI-T2-Q2-B001
	// SI1-T1-Q1-B001
	//
   
   KVString tmp;
   KVString sname(GetName());
   sname.Begin("-");
   SetLabel(sname.Next());
	gFazia->AddDetectorLabel(GetLabel());
   
	tmp = sname.Next(); tmp.ReplaceAll("T",""); fTelescope = tmp.Atoi();
	tmp = sname.Next(); tmp.ReplaceAll("Q",""); fQuartet = tmp.Atoi();
	tmp = sname.Next(); tmp.ReplaceAll("B",""); fBlock = tmp.Atoi();
	KVSignal* sig=0;
   //"QH1", "I1", "QL1", "Q2", "I2", "Q3
	if (fSignals)
   	delete fSignals;
   fSignals = new KVList(kTRUE);
	KVString lsignals="";
   if ( !strcmp(GetLabel(),"SI1") ) {	lsignals="QH1,I1,QL1";	}
   else if ( !strcmp(GetLabel(),"SI2" ) ) {	lsignals="Q2,I2";	}
	else if ( !strcmp(GetLabel(),"CSI" ) ) {	lsignals="Q3";	}
   else{
   	Warning("SetProperties","Unknown label \"%s\" for this detector : %s\n",GetLabel(),GetName());
		lsignals="";
	}
   
	lsignals.Begin(",");
	while ( !lsignals.End() )
	{
		KVString ssig = lsignals.Next();
		if (ssig.BeginsWith("Q")){
			sig = new KVChargeSignal(ssig.Data());
		}
		else if (ssig.BeginsWith("I")){
			sig = new KVCurrentSignal(ssig.Data());
		}
		else{
			Warning("unknown format signal detectorlabel=%s, signal=%s\n",GetLabel(),ssig.Data());
			sig = new KVSignal(ssig.Data(),"unknown");
		}
		
		sig->LoadPSAParameters(GetLabel());
		sig->SetDetectorName(GetName());
		fSignals->Add(sig);
	}
	
	return kTRUE;
}
コード例 #2
0
void KV_CCIN2P3_GE::ChangeDefJobOpt(KVDataAnalyser* da)
{
   // PRIVATE method called by SubmitTask() at moment of job submission.
   // Depending on the current environment, the default job submission options
   // may be changed by this method.
   //
   // This method overrides and augments KVBatchSystem::ChangeDefJobOpt (which
   // changes the options as a function of the type of analysis task).
   // Here we add the CCIN2P3-specific case where the job is launched from a directory
   // on the /sps/ semi-permanent storage facility, or if the data being analysed is
   // stored in a repository on /sps/. In this case we need to add
   // the option '-l u_sps_indra' to the 'qsub' command (if not already in the
   // default job options)
   //
   KVBatchSystem::ChangeDefJobOpt(da);
   KVString taskname = da->GetAnalysisTask()->GetName();
   KVString rootdir = da->GetRootDirectoryOfDataToAnalyse();
   Bool_t repIsSPS = rootdir.BeginsWith("/sps/");

   KVString wrkdir(gSystem->WorkingDirectory());
   KVString oldoptions(GetDefaultJobOptions());

   if (!oldoptions.Contains("sps")) {
      Bool_t NeedToAddSPS = wrkdir.Contains("/sps/");
      if ((NeedToAddSPS || repIsSPS)) {
         oldoptions += " -l sps=1";
         SetDefaultJobOptions(oldoptions.Data());
         Info("ChangeDefJobOpt",
              "Your job is being launched from /sps/... zone.\nTherefore the ressource 'sps' has been declared and the number of jobs which can be treated concurrently will be limited.");
      }
   }
}
コード例 #3
0
void KVDP2toCsIGridConvertor::ReadGammaFile(const Char_t* gammafile)
{
   ifstream gamfile;
   gamfile.open(gammafile);

   if (!gamfile.good()) {
      Error(KV__ERROR(ReadGammaFile),
            "Problem reading file %s", gammafile);
      return;
   }
   KVString s;

   s.ReadLine(gamfile);

   while (gamfile.good()) {

      if (s == "") {
         s.ReadLine(gamfile);
         continue;
      }

      if (!s.BeginsWith('#')) { //'#' sign signals comments
         int ring, modu, frun, lrun;
         if (sscanf(s.Data(), "%d %d %d %d", &ring, &modu, &frun, &lrun) !=
               4) {
            Error(KV__ERROR(ReadGammaFile), "Problem reading file %s\nLast line read: %s",
                  gammafile, s.Data());
            return;
         };
         //get grid for this ring,mod
         TString name;
         name.
         Form
         ("CsI R-L Grid First run=%d Last run=%d Ring min=%d Ring max=%d Mod min=%d Mod max=%d",
          frun, lrun, ring, ring, modu, modu);
         KVIDGrid* grid = (KVIDGrid*)fGrids->FindObject(name.Data());
         if (!grid) {
            Error(KV__ERROR(ReadGammaFile), "Can't find grid %s", name.Data());
         }
         int npoints;
         gamfile >> npoints;
         //found gamma line
         KVIDLine* line = 0;
         if (grid) {
            line = grid->NewLine("ok");
            line->SetName("gamma_line");
            line->Set(npoints);
            grid->Add("ok", line);
         }
         //read in points
         for (int i = 0; i < npoints; i++) {
            Double_t x, y;
            gamfile >> x >> y;
            if (grid)
               line->SetPoint(i, x, y);
         }
      }
      s.ReadLine(gamfile);
   }
コード例 #4
0
ファイル: KVTGIDGrid.cpp プロジェクト: FableQuentin/kaliveda
void KVTGIDGrid::ReadFromAsciiFile(ifstream& gridfile)
{
   // Read grid and parameters of LTG fit used to generate grid in gridfile.
   KVIDGraph::ReadFromAsciiFile(gridfile);
   KVString line;
   if (fPar->GetIntValue("HasTGID")) {
      line.ReadLine(gridfile);
      if (line.BeginsWith("++KVTGID"))  fTGID = KVTGID::ReadFromAsciiFile(GetName(), gridfile);
   }
   FindAxisLimits();
}
コード例 #5
0
ファイル: KVINDRA.cpp プロジェクト: FableQuentin/kaliveda
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", ""));
   }
}
コード例 #6
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;
}
コード例 #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();
}
コード例 #8
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);
      }
   }
}
コード例 #9
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;
}
コード例 #10
0
void KVDP2toIDGridConvertor::ReadFile(const Char_t* filename)
{
   // Read grids in file and add to fGrids list

   if (!fGridClass) {
      Error(KV__ERROR(ReadFile),
            "Set class of ID grids to generate first!");
      return;
   }

   ifstream datfile;
   datfile.open(filename);

   if (!datfile.good()) {
      Error(KV__ERROR(ReadFile),
            "Problem reading file %s", filename);
      return;
   }
   KVString s;

   s.ReadLine(datfile);

   while (datfile.good()) {

      if (s == "") {
         s.ReadLine(datfile);
         continue;
      }

      if (!s.BeginsWith('#')) { //'#' sign signals comments
         int ring, modu, frun, lrun, totpoints;
         if (sscanf(s.Data(), "%d %d %d %d", &ring, &modu, &frun, &lrun) !=
               4) {
            Error(KV__ERROR(ReadFile), "Problem reading file %s\nLast line read: %s",
                  filename, s.Data());
            return;
         };
         KVIDGrid* grid = (KVIDGrid*) fGridClass->New(); //create new grid

         //add to list of grids
         fGrids->Add(grid);

         grid->GetParameters()->SetValue("First run", frun);
         grid->GetParameters()->SetValue("Last run", lrun);
         grid->GetParameters()->SetValue("Ring min", ring);
         grid->GetParameters()->SetValue("Ring max", ring);
         grid->GetParameters()->SetValue("Mod min", modu);
         grid->GetParameters()->SetValue("Mod max", modu);
         int nlines;
         datfile >> nlines;
         totpoints = 0;
         //read Z,A and number of points in each line
         for (int i = 0; i < nlines; i++) {
            int z, a, npoints;
            datfile >> z >> a >> npoints;
            totpoints += 2 * npoints;
            if (z > 0) {
               //identification line
               KVIDLine* line = (KVIDLine*)grid->NewLine("id");
               line->SetZ(z);
               line->SetA(a);
               line->Set(npoints);
               grid->Add("id", line);
            }
            else {
               //"ok" line
               KVIDLine* line = (KVIDLine*)grid->NewLine("ok");
               line->Set(npoints);
               grid->Add("ok", line);
            }
         }
         ReadLineCoords(grid, datfile);
         //calculate line widths in grid
         grid->CalculateLineWidths();
      }
      s.ReadLine(datfile);
   }
コード例 #11
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;
         }
      }
   }
}