Beispiel #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;
}
Beispiel #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());
}
Beispiel #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();


}
Beispiel #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);
   }
}
Beispiel #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());
}
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;
}
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);
      }
   }
}
Beispiel #8
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();

}