KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVFAZIA.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Tue Jan 27 11:37:39 2015
2 //Author: ,,,
3 
4 #include "KVFAZIA.h"
5 #include "KVGeoImport.h"
6 #include "KVSignal.h"
7 #include "KVFAZIADetector.h"
8 #include "KVGroup.h"
9 #include "KVFAZIABlock.h"
10 #include "KVDetectorEvent.h"
11 #include "KVTarget.h"
12 #include "TSystem.h"
13 #include "KVDataSet.h"
14 #include "KVConfig.h"
15 #include "KVFAZIAIDSiPSA.h"
16 #include "KVFAZIAIDCsI.h"
17 #include "KVFAZIAIDSiCsI.h"
18 #include "KVFAZIAIDSiSi.h"
19 
20 #include "TGeoCompositeShape.h"
21 #include "TGeoEltu.h"
22 
23 #include <KVReconstructedNucleus.h>
24 
25 #ifdef WITH_MFM
26 #include "MFMFaziaFrame.h"
27 #endif
28 
29 #ifdef WITH_PROTOBUF
30 #include "FzEventSet.pb.h"
31 #include "KVFzDataReader.h"
32 #endif
33 
35 
36 // BEGIN_HTML <!--
38 /* -->
39 <h2>KVFAZIA</h2>
40 <h4>Base class for description of the FAZIA set up</h4>
41 <!-- */
42 // --> END_HTML
45 
46 static Char_t const* const FzDataType_str[] = { "QH1", "I1", "QL1", "Q2", "I2", "Q3", "ADC", "UNK" };
47 static Char_t const* const FzDetector_str[] = { "SI1", "SI1", "SI1", "SI2", "SI2", "CSI" };
48 
49 
52 
53 KVFAZIA::KVFAZIA(const Char_t* title)
54  : KVMultiDetArray("FAZIA", title)
55 {
56  // Default constructor
58  gFazia = this;
59  fDetectorLabels = "";
60  fSignalTypes = "QL1,I1,QH1,Q2,I2,Q3";
63 
64  // values of trapezoidal filter rise time set in the fpgas to be linked with a database...
65  fQH1risetime = GetSetupParameter("QH1.FPGARiseTime");
66  fQ2risetime = GetSetupParameter("Q2.FPGARiseTime");
67  fQ3slowrisetime = GetSetupParameter("Q3.slow.FPGARiseTime");
68  fQ3fastrisetime = GetSetupParameter("Q3.fast.FPGARiseTime");
69 
70  Info("KVFAZIA", "fpga shapers: %lf %lf %lf %lf", fQH1risetime, fQ2risetime, fQ3slowrisetime, fQ3fastrisetime);
71 }
72 
73 
74 
76 
78 {
79 
80  Double_t lval = -1;
81  if (gDataSet) lval = gDataSet->GetDataSetEnv(parname, 0.0);
82  else lval = gEnv->GetValue(parname, 0.0);
83  return lval;
84 }
85 
86 
87 
90 
92 {
93  // Overrides base method in order to set the value of the trigger bit pattern for the event
95  if (l.HasIntParameter("FAZIA.TRIGPAT")) SetTriggerPattern(l.GetIntValue("FAZIA.TRIGPAT"));
96  else SetTriggerPattern(0);// FAZIA absent from event
97 }
98 
99 
100 
103 
105 {
106  // Override base method in order to read FAZIA trigger for each run
107 
110 }
111 
112 
113 
127 
129 {
130  // Returns the symbolic name for the principal DAQ trigger used for the current run
131  // e.g. 'Mult2', 'Mult1/100', etc. (see SetTriggerPatternsForDataSet()).
132  //
133  // This can be used to test if the actual DAQ trigger for an event was consistent
134  // with the principal trigger by doing:
135  //
136  //~~~~{.cpp}
137  // if( gFazia->GetTrigger().IsTrigger( gFazia->GetTriggerForCurrentRun() ) )
138  // {
139  // ===ok in this case trigger is consistent==
140  // }
141  //~~~~
142 
143  if (gExpDB) {
144  if (gExpDB->GetTable("FAZIA.Triggers")) {
145  auto rundb = gExpDB->GetDBRun(GetCurrentRunNumber());
146  if (rundb) {
147  auto links = rundb->GetLinks("FAZIA.Triggers");
148  if (links && links->GetEntries())
149  return links->First()->GetName();
150  }
151  }
152  }
153  return "";
154 }
155 
156 
157 
158 
161 
163 {
164  // Destructor
165 
166  if (gFazia == this) gFazia = nullptr;
167 }
168 
169 
170 
172 
174 {
175  if (fDetectorLabels == "") fDetectorLabels += label;
176  else if (!fDetectorLabels.Contains(label)) fDetectorLabels += Form(",%s", label);
177 }
178 
179 
180 
184 
186 {
187  // Look for the geometry object <-> detector name correspondance file in the dataset directory
188  // If not found, we create it
189 
190  fCorrespondanceFile = "";
192  if (fCorrespondanceFile != "") return;
193 
194 #ifdef WITH_GNU_INSTALL
196 #else
198 #endif
199  Info("GenerateCorrespondanceFile", "Creation de %s", fCorrespondanceFile.Data());
200  KVEnv env;
201 
202  fDetectorLabels = "SI1,SI2,CSI";
203 
204  SetNameOfDetectors(env);
205  if (env.GetTable() && env.GetTable()->GetEntries() > 0) {
206  env.AddCommentLine(Form("Automatic generated file by %s::GenerateCorrespondanceFile", ClassName()));
207  env.AddCommentLine("Make link between geometric ROOT objects and detector names");
209  }
210  fDetectorLabels = "";
211 }
212 
213 
214 
222 
224 {
225  //define the format of detectors name
226  // label-index
227  // where index = block*100+quartet*10+telescope
228  // example :
229  // SI1-123 is the Silicon 1 of the block 1, the quartet 2 and the telescope 3
230  //
231 
232  for (Int_t bb = fStartingBlockNumber; bb < fNblocks; bb += 1) {
233  for (Int_t qq = 1; qq <= 4; qq += 1) {
234  for (Int_t tt = 1; tt <= 4; tt += 1) {
235  fDetectorLabels.Begin(",");
236  while (!fDetectorLabels.End()) {
237  KVString sdet = fDetectorLabels.Next();
238  env.SetValue(
239  Form("BLOCK_%d_QUARTET_%d_%s-T%d", bb, qq, sdet.Data(), tt),
240  Form("%s-%d", sdet.Data(), bb * 100 + qq * 10 + tt)
241  );
242  }
243  }
244  }
245  }
246 }
247 
248 
249 
253 
255 {
256  // Finalise description of array performing all operations which require ROOT
257  // geometry to be closed
258 
261  imp.SetDetectorPlugin(GetDataSetEnv(GetDataSet(), "FAZIADetectorPlugin", "FAZIADetector"));
263  // any additional structure name formatting definitions
265  imp.AddAcceptedDetectorName("SI1-");
266  imp.AddAcceptedDetectorName("SI2-");
267  imp.AddAcceptedDetectorName("CSI-");
268 
269  // the following parameters are optimized for a 12-block compact
270  // geometry placed at 80cm with rings 1-5 of INDRA removed.
271  // make sure that the expected number of detectors get imported!
273 
275 
277  SetBit(kIsBuilt);
278 }
279 
280 
281 
284 
286 {
287  //Called by the Build method
288  AbstractMethod("GetGeometryParameters");
289 }
290 
291 
292 
312 
314 {
315  // Read and set up definitions of trigger patterns for this dataset.
316  // These should be given by variables such as:
317  //
318  //~~~~
319  // +[dataset].FAZIA.TriggerPatterns: [name1]
320  // [dataset].FAZIA.TriggerPattern.[name1]: [value1]
321  // +[dataset].FAZIA.TriggerPatterns: [name2]
322  // [dataset].FAZIA.TriggerPattern.[name2]: [value2]
323  //~~~~
324  //
325  // where [name*]='Mult1','Mult1/100','Mult2', etc. (see KVFAZIATrigger for known trigger patterns).
326  //
327  // and [value*] is the value of the corresponding bit pattern, e.g. if bit '3' (0b100) corresponds to
328  // 'Mult2' (i.e. multiplicity >= 2) then this would give
329  //
330  //~~~~
331  // [dataset].FAZIA.TriggerPattern.Mult2: 4
332  //~~~~
333 
334  KVString patterns = GetDataSetEnv(dataset, "FAZIA.TriggerPatterns", "");
335  if (patterns.Length()) {
336  patterns.Begin(" ");
337  while (!patterns.End()) {
338  auto pattern = patterns.Next(kTRUE);
339  uint16_t val = (uint16_t)GetDataSetEnv(dataset, Form("FAZIA.TriggerPattern.%s", pattern.Data()), 0.);
340  fTrigger.AddTriggerPattern(pattern, val);
341  }
342  }
343 }
344 
345 
346 
349 
351 {
352  //Called by the Build method
353  Info("BuildFAZIA", "to be defined in child class ...");
354 
355 }
356 
357 
358 
360 
362 {
363 
364  KVMaterial target_holder_mat("Al");
365  new TGeoBBox("TARGET_FRAME", 3., 3., 0.1 / 2.);
366  new TGeoEltu("TARGET_HOLE", 2., 2., 0.1 / 2.);
367  TGeoCompositeShape* cs = new TGeoCompositeShape("TARGET_FRAME", "TARGET_FRAME - TARGET_HOLE");
368  TGeoVolume* target_frame = new TGeoVolume("TARGET_FRAME", cs, target_holder_mat.GetGeoMedium());
369  gGeoManager->GetTopVolume()->AddNode(target_frame, 1);
370 
371  KVTarget* T = GetTarget();
372  if (T) {
373  KVMaterial* targMat = (KVMaterial*)T->GetLayers()->First();
374  TGeoVolume* target = gGeoManager->MakeEltu("TARGET", targMat->GetGeoMedium(), 2., 2., targMat->GetThickness() / 2.);
375  gGeoManager->GetTopVolume()->AddNode(target, 1);
376  }
377 }
378 
379 
380 
383 
385 {
386  // Build the FAZIA array
389 
391 
392  BuildFAZIA();
393 
394  if (fBuildTarget)
395  BuildTarget();
396 
397  if (fCloseGeometryNow) {
400  }
401 
403 }
404 
405 
406 
418 
419 void KVFAZIA::GetDetectorEvent(KVDetectorEvent* detev, const TSeqCollection* dets)
420 {
421  // First step in event reconstruction based on current status of detectors in array.
422  //
423  // Fills the given KVDetectorEvent with the list of all groups which have fired.
424  // i.e. loop over all groups of the array and test whether KVGroup::Fired() returns true or false.
425  //
426  // This can be made more efficient if the detectors which were hit in the event are already known:
427  // then their list should be given to argument dets
428  //
429  // If the list of fired detectors dets is not given, we use the internal fFiredACQParams list
430  // which is filled with all hit detectors when raw data is treated in treat_event()
431 
432  if (!fHandledRawData) {
433  //Info("GetDetectorEvent","i didnt handle any data...");
434  return;
435  }
436  if (!dets || !dets->GetEntries()) {
437  if (fFiredACQParams.GetEntries()) {
438  dets = &fFiredACQParams;
439  //Info("GetDetectorEvent", "using internal list");
440  }
441  }
442  if (dets && dets->GetEntries()) {
443  TIter next_det(dets);
444 
445  KVDetector* det = 0;
446  while ((det = (KVDetector*)next_det())) {
447 
448  if (det->GetGroup()->Fired()) detev->AddGroup(det->GetGroup());
449 
450  }
451  }
452  else {
453  //Info("GetDetectorEvent", "Calling base method");
455  }
456 }
457 
458 
459 
464 
466 {
467  // Protected method, called when required to fill fDetList with pointers to
468  // the detectors whose names are stored in fDetNames.
469  // Also set all raw data values in the detectors.
470 
471  KVFAZIADetector* det = 0;
472 
473  DetList->Clear();
474  DetNames.Begin("/");
475  while (!DetNames.End()) {
476  KVString sdet = DetNames.Next(kTRUE);
477  det = (KVFAZIADetector*)GetDetector(sdet.Data());
478  if (!det) {
480  }
481 
482  if (det) {
483  DetList->Add(det);
484  // read and set from the particle's parameter list any relevant detector signal values
485  // each signal is stored with a name "[detname].[signal name]"
486  // except GTTag and DetTag which have the same value for all detectors of the same telescope
487  // and so are only stored once with name "DetTag" or "GTTag".
488 
489  TIter it(&det->GetListOfDetectorSignals());
490  KVDetectorSignal* ds;
491  while ((ds = (KVDetectorSignal*)it())) {
492  if (ds->IsRaw() && !ds->IsExpression())
493  // only look for raw data, excluding any expressions based only on raw data
494  {
495  TString pname = Form("%s.%s", det->GetName(), ds->GetName());
496  if (rnuc->GetParameters()->HasParameter(pname))
497  ds->SetValue(rnuc->GetParameters()->GetDoubleValue(pname));
498  }
499  }
500  if (rnuc->GetParameters()->HasParameter("GTTag"))
501  det->SetGTTag(rnuc->GetParameters()->GetIntValue("GTTag"));
502  if (rnuc->GetParameters()->HasParameter("DetTag"))
503  det->SetDetTag(rnuc->GetParameters()->GetIntValue("DetTag"));
504  }
505  }
506 }
507 
508 
509 
512 
514 {
515  // Specialized group reconstructor for FAZIA
516 
517  KVGroupReconstructor* gr(nullptr);
518  if (GetGroup(g->GetName())) { // make sure group belongs to us
520  }
521  return gr;
522 }
523 
524 
525 
527 
529 {
530 
531  TString sname;
532  if (bb == 4) {
533  if (fDataSet == "FAZIASYM") {
534  sname.Form("%s-RUTH", FzDataType_str[idsig]);
535  }
536  else {
537  sname.Form("%s-%d", FzDataType_str[idsig], 100 * bb + 10 * qq + tt);
538  }
539  }
540  else if (bb == 6) {
541  if (fDataSet == "FAZIAPRE") {
542  sname.Form("%s-RUTH", FzDataType_str[idsig]);
543  }
544  else {
545  sname.Form("%s-%d", FzDataType_str[idsig], 100 * bb + 10 * qq + tt);
546  }
547  }
548  else {
549  sname.Form("%s-%d", FzDataType_str[idsig], 100 * bb + 10 * qq + tt);
550  }
551  return sname;
552 
553 }
554 
555 
556 #ifdef WITH_PROTOBUF
557 
559 
561 {
562  return treat_event(((KVFzDataReader&)R).get_fazia_event());
563 }
564 
565 
566 
568 
570 {
571  Int_t value = (val << 2);
572  value >>= 2;
573  Double_t dval = -1.;
574  switch (sigid) {
575  case DAQ::FzData_FzDataType_QH1:
576  if (eid == 0) dval = value / (fQH1risetime * 1e3 / 10.);
577  break;
578  case DAQ::FzData_FzDataType_I1:
579  break;
580  case DAQ::FzData_FzDataType_QL1:
581  break;
582  case DAQ::FzData_FzDataType_Q2:
583  if (eid == 0) dval = value / (fQ2risetime * 1e3 / 10.);
584  break;
585  case DAQ::FzData_FzDataType_I2:
586  break;
587  case DAQ::FzData_FzDataType_Q3:
588  if (eid == 0) dval = value / (fQ3slowrisetime * 1e3 / 10.);
589  if (eid == 1) dval = value / (fQ3fastrisetime * 1e3 / 10.);
590  break;
591  }
592  return dval;
593 }
594 
595 
596 
599 
600 Bool_t KVFAZIA::treat_event(const DAQ::FzEvent& e)
601 {
602  // Read raw data for an event
603 
604  Bool_t good = kTRUE;
605 
606  //get info from trigger
607  int ts = e.trinfo_size();
608  uint64_t dt = 0;
609  uint64_t tot = 0;
610  for (Int_t tr = ts - 1; tr >= 0; tr--) {
611  const DAQ::FzTrigInfo& rdtrinfo = e.trinfo(tr);
612  uint64_t triggervalue = rdtrinfo.value();
613  if (tr == ts - 5) {
614  fReconParameters.SetValue("FAZIA.TRIGPAT", (int)triggervalue);
615  SetTriggerPattern((uint16_t)triggervalue);
616  }
617  else if (tr == ts - 6) fReconParameters.SetValue64bit("FAZIA.EC", ((triggervalue << 12) + e.ec()));
618  else if (tr == ts - 8) dt = triggervalue;
619  else if (tr == ts - 9) fReconParameters.SetValue("FAZIA.TRIGRATE.EXT", 1.*triggervalue / dt);
620  else if (tr == ts - 10) fReconParameters.SetValue("FAZIA.TRIGRATE.MAN", 1.*triggervalue / dt);
621  else if (tr == ts - 11) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
622  else if (tr == ts - 12) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
623  else if (tr == ts - 13) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
624  else if (tr == ts - 14) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
625  else if (tr == ts - 15) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
626  else if (tr == ts - 16) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
627  else if (tr == ts - 17) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
628  else if (tr == ts - 18) fReconParameters.SetValue(Form("FAZIA.TRIGRATE.PAT%d", tr - 2), 1.*triggervalue / dt);
629  else if (tr == ts - 19) {
630  fReconParameters.SetValue("FAZIA.TRIGRATE.TOT", 1.*triggervalue / dt);
631  tot = triggervalue;
632  }
633  else if (tr == ts - 20) {
634  fReconParameters.SetValue("FAZIA.TRIGRATE.VAL", 1.*triggervalue / dt);
635  fReconParameters.SetValue("FAZIA.DEADTIME", 100.*(1. - 1.*triggervalue / tot));
636  }
637  else {}
638  }
639 
640  for (int b = 0; b < e.block_size(); ++b) {
641 
642  // check block errors
643  if (e.block(b).len_error() || e.block(b).crc_error() || (!good)) {
644  //Warning("treat_event", "BLOCK LEN OR CRC ERROR B%03d", e.block(b).blkid());
645  good = kFALSE;
646  break; //stop iteration on blocks
647  }
648  int fIdBlk = e.block(b).blkid();
649 
650  for (int f = 0; f < e.block(b).fee_size(); ++f) {
651 
652  const DAQ::FzFee& rdfee = e.block(b).fee(f);
653 
654  for (int h = 0; h < rdfee.hit_size(); ++h) {
655 
656  const DAQ::FzHit& rdhit = rdfee.hit(h);
657  // check fee errors
658  if (rdfee.len_error() || rdfee.crc_error() || (!good)) {
659  Warning("treat_event", "FEE LEN OR CRC ERROR B%03d-FE%d", e.block(b).blkid(), rdfee.feeid());
660  good = kFALSE;
661  break; //stop iteration on hits
662  }
663  int fIdFee = rdhit.feeid();
664  int fIdTel = rdhit.telid();
665 
666  for (Int_t mm = 0; mm < rdhit.data_size(); mm++) {
667  const DAQ::FzData& rdata = rdhit.data(mm);
668  int fIdSignal = rdata.type();
669 
670  int DetTag = rdhit.dettag();
671  int GTTag = rdhit.gttag();
672  if (DetTag >= 16384 && GTTag < 16384) GTTag += 32768;
673 
674  //on decompile le HIT
675  int fIdQuartet = fQuartet[fIdFee][fIdTel];
676  int fIdTelescope = fTelescope[fIdFee][fIdTel];
677 
678  KVFAZIADetector* det = (KVFAZIADetector*)GetDetector(Form("%s-%d", FzDetector_str[fIdSignal], 100 * fIdBlk + 10 * fIdQuartet + fIdTelescope));
679  if (!det) {
680 // Error("treat_event", "No detector %s-%d found in FAZIA geometry...", FzDetector_str[fIdSignal], 100 * fIdBlk + 10 * fIdQuartet + fIdTelescope);
681  continue;
682  }
683  det->SetDetTag(DetTag);
684  det->SetGTTag(GTTag);
685 
686  if (!rdata.has_energy() && !rdata.has_waveform()) {
687  Warning("treat_event", "[NO DATA] [%s %s]", det->GetName(), FzDataType_str[fIdSignal]);
688  continue;
689  }
690 
691  if (rdata.has_energy()) {
692  const DAQ::Energy& ren = rdata.energy();
693  for (Int_t ee = 0; ee < ren.value_size(); ee++) {
694  Double_t energy = TreatEnergy(fIdSignal, ee, ren.value(ee));
695  det->SetFPGAEnergy(fIdSignal, ee, energy);
696  }
697  fFiredACQParams.Add(det);
698  }
699  if (rdata.has_waveform()) {
700  const DAQ::Waveform& rwf = rdata.waveform();
701  Int_t supp;
702 
703  if (fIdSignal <= 5) {
704  TString sname = GetSignalName(fIdBlk, fIdQuartet, fIdTelescope, fIdSignal);//QH1-123 etc.
705  if (sname == "")
706  Warning("treat_event", "signal name is empty !!! blk=%d qua=%d tel=%d\n", fIdBlk, fIdQuartet, fIdTelescope);
707 
708  TGraph sig(rwf.sample_size());
709 
710  for (Int_t nn = 0; nn < rwf.sample_size(); nn++) {
711  if (fIdSignal != DAQ::FzData::ADC) {
712  if (rwf.sample(nn) > 8191) {
713  supp = rwf.sample(nn) | 0xFFFFC000;
714  }
715  else {
716  supp = rwf.sample(nn);
717  }
718  }
719  else {
720  supp = rwf.sample(nn);
721  }
722  sig.SetPoint(nn, nn, supp);
723  }
724  det->SetSignal(&sig, sname);
725  }
726  else {
727  if (fIdSignal > 5)
728  Warning("treat_event", "datatype %d>5 - taille = %d\n", fIdSignal, rwf.sample_size());
729  }
730  }
731  }
732  }
733  }
734  }
735 
736 // cout << "good=" << good << endl;
737 // fFPGAParameters.ls();
738 // fSignals.ls();
739 
740  return good;
741 }
742 
743 #endif
744 
745 #ifdef WITH_MFM
746 
751 
753 {
754  // Treatment of raw data in MFM frames with type MFM_FAZIA_FRAME_TYPE
755  // The timestamp is extracted from the frame header and added to fReconParameters
756  // in a 64 bit parameter with name "FAZIA.TS"
757 
758  if (f.GetFrameType() != MFM_FAZIA_FRAME_TYPE) return kFALSE;
759  fReconParameters.SetValue64bit("FAZIA.TS", f.GetTimeStamp());
760 
761 #ifdef WITH_PROTOBUF
762  DAQ::FzEventSet fazia_set;
763  DAQ::FzEvent fazia_event;
764  // Parse protobuf data in MFM frame
765  if (fazia_set.ParseFromArray(f.GetPointUserData(), ((MFMFaziaFrame&)f).GetEventSize())) {
766  // Parsed an event set
767  if (fazia_set.ev_size() > 1) {
768  Warning("handle_raw_data_event_mfmframe",
769  "Got a FzEventSet from data: cannot handle multiple events at once!");
770  return kFALSE;
771  }
772  return treat_event(fazia_set.ev(0));
773  }
774  else if (fazia_event.ParseFromArray(f.GetPointUserData(), ((MFMFaziaFrame&)f).GetEventSize())) {
775  // Parsed an event
776  return treat_event(fazia_event);
777  }
778 #endif
779  return kTRUE;
780 }
781 
782 #endif
783 
784 
788 
790 {
791  // set up correspondence between FPGA number/FEE number (from acquisition)
792  // and Quartet/Telescope numbers
793 
794  TString DataFilePath;
795  if (!KVBase::SearchKVFile("ElecDetLink.env", DataFilePath, "data")) {
796  Error("CreateCorrespondence", "ElecDetLink.env not found");
797  return;
798  }
799  KVEnv DetLink;
800  DetLink.ReadFile(DataFilePath, kEnvUser);
801  for (int t = 1; t <= 4; t++) {
802  for (int q = 1; q <= 4; q++) {
803  TString elec = DetLink.GetValue(Form("T%1d-Q%1d", t, q), " ");
804  if (!elec.IsWhitespace()) {
805  int fee, fpga;
806  sscanf(elec.Data(), "FPGA%d-FE%d", &fpga, &fee);
807  fQuartet[fee][fpga] = q;
808  fTelescope[fee][fpga] = t;
809  }
810  else {
811  Error("CreateCorrespondence", "Problem reading FAZIA ElecDetLink.env file : T%1d-Q%1d = %s", t, q, elec.Data());
812  }
813  }
814  }
815 }
816 
817 
818 
833 
835 {
836  // Read a file containing runlists for each principal trigger used during an experiment
837  //
838  // The file should be in TEnv format like so:
839  //
840  //~~~~
841  // Mult1: 100-122,541-1938
842  // Mult2: 91-765
843  //~~~~
844  //
845  // where each trigger pattern name must be known and declared to occur during the dataset
846  // (see SetTriggerPatternsForDataSet()) and the list of runs are given using KVNumberList syntax.
847  //
848  // The data is added to the database in a table 'FAZIA.Triggers'.
849 
850  TString fullpath;
851  if (!db->FindCalibFile("Triggers", fullpath)) return;
852 
853  Info("ReadTriggerPatterns()", "Reading FAZIA triggers used during runs...");
854  auto trigs = db->AddTable("FAZIA.Triggers", "Principal triggers used by FAZIA");
855 
856  KVDBRecord* dbrec = 0;
857  TEnv env;
858  TEnvRec* rec = 0;
859  env.ReadFile(fullpath.Data(), kEnvAll);
860  TIter it(env.GetTable());
861 
862  while ((rec = (TEnvRec*)it.Next())) {
863  KVString srec(rec->GetName());
864  KVNumberList nl(rec->GetValue());
865  dbrec = new KVDBRecord(rec->GetName(), "FAZIA Trigger");
866  dbrec->AddKey("Runs", "List of Runs");
867  trigs->AddRecord(dbrec);
868  db->LinkRecordToRunRange(dbrec, nl);
869  }
870 }
871 
872 
873 
876 
878 {
879  // Set the FAZIA-specific general identification code for the given telescope
880 
881  if (idt->InheritsFrom(KVFAZIAIDSiPSA::Class())) idt->SetIDCode(IDCodes::ID_SI1_PSA);
882  else if (idt->InheritsFrom(KVFAZIAIDSiSi::Class())) idt->SetIDCode(IDCodes::ID_SI1_SI2);
883  else if (idt->InheritsFrom(KVFAZIAIDSiCsI::Class())) idt->SetIDCode(IDCodes::ID_SI2_CSI);
884  else if (idt->InheritsFrom(KVFAZIAIDCsI::Class())) idt->SetIDCode(IDCodes::ID_CSI_PSA);
885  else {
886  Error("SetIDCodeForIDTelescope", "Request for telescope name=%s of unknown class=%s",
887  idt->GetName(), idt->IsA()->GetName());
888  }
889 }
890 
891 
int Int_t
unsigned int UInt_t
KVDataSet * gDataSet
Definition: KVDataSet.cpp:30
KVExpDB * gExpDB
Definition: KVExpDB.cpp:12
KVFAZIA * gFazia
Definition: KVFAZIA.cpp:44
static Char_t const *const FzDataType_str[]
Definition: KVFAZIA.cpp:46
static Char_t const *const FzDetector_str[]
Definition: KVFAZIA.cpp:47
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
static Double_t energy[]
#define b(i)
#define f(i)
#define e(i)
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
const Bool_t kTRUE
R__EXTERN TEnv * gEnv
kEnvUser
kEnvAll
R__EXTERN TGeoManager * gGeoManager
float * q
char * Form(const char *fmt,...)
static const Char_t * WorkingDirectory()
Definition: KVBase.h:174
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
Definition: KVBase.cpp:1582
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:541
Record folder for the database.
Definition: KVDBRecord.h:42
virtual Bool_t AddKey(KVDBKey *key, Bool_t check=kTRUE)
Definition: KVDBRecord.cpp:65
virtual KVRList * GetLinks(const Char_t *key) const
Returns the list of records linked to this record in table "key".
Definition: KVDBRecord.cpp:206
virtual KVDBTable * GetTable(const Char_t *table) const
Definition: KVDataBase.h:158
virtual Bool_t AddTable(KVDBTable *table)
Definition: KVDataBase.cpp:84
const Char_t * GetDataSetDir() const
Definition: KVDataSet.cpp:719
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
Definition: KVDataSet.cpp:757
TString GetFullPathToDataSetFile(const Char_t *filename)
Definition: KVDataSet.cpp:1886
Output signal data produced by a detector.
virtual Bool_t IsExpression() const
virtual void SetValue(Double_t x)
virtual Bool_t IsRaw() const
Base class for detector geometry description, interface to energy-loss calculations.
Definition: KVDetector.h:121
KVGroup * GetGroup() const
const KVSeqCollection & GetListOfDetectorSignals() const
Definition: KVDetector.h:732
Extension of TEnv to allow the writing of comments in the file.
Definition: KVEnv.h:16
void AddCommentLine(const Char_t *line)
Definition: KVEnv.cpp:104
virtual Int_t WriteFile(const char *fname, EEnvLevel level=kEnvAll)
Definition: KVEnv.cpp:174
Base class to describe database of an experiment ,.
Definition: KVExpDB.h:18
Bool_t FindCalibFile(const Char_t *type, TString &fullpath) const
Definition: KVExpDB.cpp:476
KVDBRun * GetDBRun(Int_t number) const
Definition: KVExpDB.h:74
virtual void LinkRecordToRunRange(KVDBRecord *rec, UInt_t first_run, UInt_t last_run)
Definition: KVExpDB.cpp:86
Base class for FAZIA detectors.
void SetFPGAEnergy(int sigid, Int_t idx, Double_t energy)
void SetSignal(TGraph *signal, const Char_t *signal_name)
void SetGTTag(Int_t t)
void SetDetTag(Int_t t)
static const Char_t * GetNewName(KVString oldname)
void AddTriggerPattern(const TString &name, uint16_t value)
Description of a FAZIA detector geometry.
Definition: KVFAZIA.h:32
Double_t fImport_Xorg
for geometry import
Definition: KVFAZIA.h:49
Double_t fImport_ThetaMin
for geometry import
Definition: KVFAZIA.h:45
Double_t fQ2risetime
Definition: KVFAZIA.h:57
KVGroupReconstructor * GetReconstructorForGroup(const KVGroup *) const
Specialized group reconstructor for FAZIA.
Definition: KVFAZIA.cpp:513
Double_t fQH1risetime
values of trapezoidal filter rise time set in the fpgas defined in .kvrootrc
Definition: KVFAZIA.h:56
Double_t TreatEnergy(Int_t sigid, Int_t eid, UInt_t val)
Definition: KVFAZIA.cpp:569
Double_t fQ3slowrisetime
Definition: KVFAZIA.h:58
void SetTriggerPatternsForDataSet(const TString &dataset)
Definition: KVFAZIA.cpp:313
void FillDetectorList(KVReconstructedNucleus *rnuc, KVHashList *DetList, const KVString &DetNames)
Definition: KVFAZIA.cpp:465
void SetGeometryImportParameters(Double_t dt=0.25, Double_t dp=1.0, Double_t tmin=2., Double_t pmin=0, Double_t tmax=20., Double_t pmax=360., Double_t xorg=0, Double_t yorg=0, Double_t zorg=0)
Definition: KVFAZIA.h:208
int fQuartet[8][2]
quartet number from #FEE and #FPGA
Definition: KVFAZIA.h:52
Double_t GetSetupParameter(const Char_t *parname)
Definition: KVFAZIA.cpp:77
Double_t fImport_dTheta
for geometry import
Definition: KVFAZIA.h:43
void SetIDCodeForIDTelescope(KVIDTelescope *) const
Set the FAZIA-specific general identification code for the given telescope.
Definition: KVFAZIA.cpp:877
std::string GetTriggerForCurrentRun() const
Definition: KVFAZIA.cpp:128
void AddDetectorLabel(const Char_t *label)
Definition: KVFAZIA.cpp:173
Bool_t handle_raw_data_event_protobuf(KVProtobufDataReader &)
Definition: KVFAZIA.cpp:560
virtual void BuildTarget()
Definition: KVFAZIA.cpp:361
Int_t fStartingBlockNumber
Definition: KVFAZIA.h:38
TString fCorrespondanceFile
Bool_t fBuildTarget; //kTRUE to include target frame in the geometry.
Definition: KVFAZIA.h:40
Double_t fImport_PhiMax
for geometry import
Definition: KVFAZIA.h:48
virtual void SetNameOfDetectors(KVEnv &env)
Definition: KVFAZIA.cpp:223
Double_t fImport_Zorg
for geometry import
Definition: KVFAZIA.h:51
virtual void BuildFAZIA()
methods to be implemented in child classes
Definition: KVFAZIA.cpp:350
KVFAZIA(const Char_t *title="")
Default constructor.
Definition: KVFAZIA.cpp:53
void ReadTriggerPatterns(KVExpDB *db)
Definition: KVFAZIA.cpp:834
virtual void DefineStructureFormats(KVGeoImport &)
Definition: KVFAZIA.h:79
void GenerateCorrespondanceFile()
Definition: KVFAZIA.cpp:185
Double_t fQ3fastrisetime
Definition: KVFAZIA.h:59
KVString fSignalTypes
Definition: KVFAZIA.h:42
void PerformClosedROOTGeometryOperations()
Definition: KVFAZIA.cpp:254
Bool_t treat_event(const DAQ::FzEvent &)
Read raw data for an event.
Definition: KVFAZIA.cpp:600
virtual ~KVFAZIA()
Destructor.
Definition: KVFAZIA.cpp:162
Double_t fImport_dPhi
for geometry import
Definition: KVFAZIA.h:44
Double_t fImport_ThetaMax
for geometry import
Definition: KVFAZIA.h:46
int fTelescope[8][2]
telescope number from #FEE and #FPGA
Definition: KVFAZIA.h:53
KVFAZIATrigger fTrigger
trigger pattern read from data for each event
Definition: KVFAZIA.h:62
virtual void MakeCalibrationTables(KVExpDB *)
Override base method in order to read FAZIA trigger for each run.
Definition: KVFAZIA.cpp:104
Bool_t handle_raw_data_event_mfmframe(const MFMCommonFrame &)
Definition: KVFAZIA.cpp:752
virtual void GetGeometryParameters()
Called by the Build method.
Definition: KVFAZIA.cpp:285
void SetTriggerPattern(uint16_t fp)
Definition: KVFAZIA.h:65
TString GetSignalName(Int_t bb, Int_t qq, Int_t tt, Int_t idsig)
Definition: KVFAZIA.cpp:528
Double_t fImport_PhiMin
for geometry import
Definition: KVFAZIA.h:47
Int_t fNblocks
number of blocks
Definition: KVFAZIA.h:37
void GetDetectorEvent(KVDetectorEvent *detev, const TSeqCollection *dets)
Definition: KVFAZIA.cpp:419
virtual void Build(Int_t=-1)
Build the FAZIA array.
Definition: KVFAZIA.cpp:384
Double_t fImport_Yorg
for geometry import
Definition: KVFAZIA.h:50
KVString fDetectorLabels
Definition: KVFAZIA.h:41
void CreateCorrespondence()
Definition: KVFAZIA.cpp:789
virtual void SetRawDataFromReconEvent(KVNameValueList &)
Overrides base method in order to set the value of the trigger bit pattern for the event.
Definition: KVFAZIA.cpp:91
Handle FAZIA protobuf-format raw data files.
Import detector array described by ROOT geometry and set up corresponding KVMultiDetArray object.
Definition: KVGeoImport.h:67
void AddAcceptedDetectorName(const char *name)
void SetOrigin(double x, double y, double z)
Definition: KVGeoImport.h:100
void SetDetectorPlugin(const TString &name)
Definition: KVGeoImport.h:94
void ImportGeometry(Double_t dTheta=0.1, Double_t dPhi=1.0, Double_t ThetaMin=0.0, Double_t PhiMin=0.0, Double_t ThetaMax=180.0, Double_t PhiMax=360.0)
Definition: KVGeoImport.cpp:99
void SetNameCorrespondanceList(const Char_t *)
virtual Bool_t Fired(Option_t *opt="any") const
KVDetector * GetDetector(const Char_t *name) const
Return detector in this structure with given name.
Base class for particle reconstruction in one group of a detector array.
static KVGroupReconstructor * Factory(const TString &plugin="")
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:19
Extended version of ROOT THashList.
Definition: KVHashList.h:28
Base class for all detectors or associations of detectors in array which can identify charged particl...
Definition: KVIDTelescope.h:88
virtual void SetIDCode(UShort_t c)
Description of physical materials used to construct detectors; interface to range tables.
Definition: KVMaterial.h:41
virtual Double_t GetThickness() const
Definition: KVMaterial.cpp:380
virtual TGeoMedium * GetGeoMedium(const Char_t *="")
Definition: KVMaterial.cpp:971
static KVIonRangeTable * GetRangeTable()
Definition: KVMaterial.cpp:153
Base class for describing the geometry of a detector array.
virtual void SetDetectorThicknesses()
virtual void GetDetectorEvent(KVDetectorEvent *detev, const TSeqCollection *fired_params=0)
static Bool_t fCloseGeometryNow
virtual KVGroup * GetGroup(const Char_t *) const
Return pointer to group with name.
void CreateGeoManager(Double_t dx=500, Double_t dy=500, Double_t dz=500)
Bool_t fHandledRawData
set to true if multidetector handles data in last call to HandleRawData
KVTarget * GetTarget()
TString GetDataSet() const
virtual void MakeCalibrationTables(KVExpDB *)
KVUniqueNameList fFiredACQParams
list of fired acquisition parameters after reading raw data event
UInt_t GetCurrentRunNumber() const
virtual void SetIdentifications()
static Bool_t fBuildTarget
virtual void SetRawDataFromReconEvent(KVNameValueList &)
KVNameValueList fReconParameters
general purpose list of parameters for storing information on data reconstruction
TString fDataSet
name of associated dataset, used with MakeMultiDetector()
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Int_t GetIntValue(const Char_t *name) const
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
void SetValue64bit(const Char_t *name, ULong64_t)
Bool_t HasParameter(const Char_t *name) const
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:83
KVNameValueList * GetParameters() const
Definition: KVParticle.h:735
Read Google Protobuf DAQ files.
Nuclei reconstructed from data measured by a detector array ,.
virtual void Clear(Option_t *option="")
virtual void Add(TObject *obj)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
void Begin(TString delim) const
Definition: KVString.cpp:562
Bool_t End() const
Definition: KVString.cpp:625
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:675
Calculation/correction of energy losses of particles through an experimental target.
Definition: KVTarget.h:126
virtual void Add(TObject *obj)
virtual Int_t GetEntries() const
const char * GetName() const
const char * GetValue() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
THashList * GetTable() const
void CloseGeometry(Option_t *option="d")
TGeoVolume * GetTopVolume() const
TGeoVolume * MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz)
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
TObject * Next()
virtual const char * GetName() const
void AbstractMethod(const char *method) const
virtual const char * GetName() const
void SetBit(UInt_t f)
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
TObject * First() const
Ssiz_t Length() const
const char * Data() const
Bool_t IsWhitespace() const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TGraphErrors * gr
TH1 * h
const long double mm
Definition: KVUnits.h:69
const long double g
masses
Definition: KVUnits.h:72
double T(double x)
constexpr Double_t R()
auto * tt
auto * l