5 #include "KVGeoImport.h"
6 #include "KVFAZIADetector.h"
8 #include "KVDetectorEvent.h"
10 #include "KVDataSet.h"
12 #include "KVFAZIAIDSiPSA.h"
13 #include "KVFAZIAIDCsI.h"
14 #include "KVFAZIAIDSiCsI.h"
15 #include "KVFAZIAIDSiSi.h"
20 #include <KVFAZIAIDSiSiCsI.h>
21 #include <KVReconstructedNucleus.h>
24 #include "MFMFaziaFrame.h"
28 #include "FzEventSet.pb.h"
29 #include "KVFzDataReader.h"
44 static Char_t const*
const FzDataType_str[] = {
"QH1",
"I1",
"QL1",
"Q2",
"I2",
"Q3",
"ADC",
"UNK" };
45 static Char_t const*
const FzDetector_str[] = {
"SI1",
"SI1",
"SI1",
"SI2",
"SI2",
"CSI" };
142 if (gExpDB->
GetTable(
"FAZIA.Triggers")) {
145 auto links = rundb->
GetLinks(
"FAZIA.Triggers");
146 if (links && links->GetEntries())
206 auto id_tel_list = GetDataSetEnv<KVString>(
fDataSet,
"FAZIA.IDTelescopes");
216 KVDetector* csi{
nullptr}, *si2{
nullptr}, *si1{
nullptr};
218 auto d =
N->GetDetector();
219 if (
d->IsLabelled(
"SI1") &&
d->IsOK()) si1 =
d;
220 else if (
d->IsLabelled(
"SI2") &&
d->IsOK()) si2 =
d;
221 else if (
d->IsLabelled(
"CSI") &&
d->IsOK()) csi =
d;
232 if (id_tel_list.Contains(
"CSI-PSA")) {
235 add_telescope(idt, csi->
GetGroup());
238 if (id_tel_list.Contains(
"SI2-CSI")) {
242 add_telescope(idt, csi->
GetGroup());
245 if (id_tel_list.Contains(
"SI1+SI2-CSI")) {
250 idt->
SetName(
Form(
"ID_SI_CSI_%d", csi->GetIndex()));
251 add_telescope(idt, csi->
GetGroup());
257 if (id_tel_list.Contains(
"SI2-PSA")) {
260 add_telescope(idt, si2->
GetGroup());
264 if (id_tel_list.Contains(
"SI1-SI2")) {
268 add_telescope(idt, si2->
GetGroup());
272 if (id_tel_list.Contains(
"SI1-PSA")) {
275 add_telescope(idt, si1->
GetGroup());
300 if (geo_dn_traj->
GetN() != 3) {
301 Warning(
"AssociateNodesAndTrajectories",
303 rubbish.
Add(geo_dn_traj);
309 std::optional<int>
index;
313 Warning(
"AssociateNodesAndTrajectories",
315 rubbish.
Add(geo_dn_traj);
325 for (
auto tr : rubbish) {
341 if (gFazia ==
this) gFazia =
nullptr;
369 #ifdef WITH_GNU_INSTALL
382 env.
AddCommentLine(
"Make link between geometric ROOT objects and detector names");
408 for (
Int_t qq = 1; qq <= 4; qq += 1) {
414 Form(
"BLOCK_%d_QUARTET_%d_%s-T%d", bb, qq, sdet.
Data(),
tt),
415 Form(
"%s-%d", sdet.
Data(), bb * 100 + qq * 10 +
tt)
509 auto patterns = GetDataSetEnv<KVString>(dataset,
"FAZIA.TriggerPatterns");
510 if (patterns.Length()) {
512 while (!patterns.End()) {
513 auto pattern = patterns.Next(
kTRUE);
514 uint16_t val = (uint16_t)
GetDataSetEnv(dataset,
Form(
"FAZIA.TriggerPattern.%s", pattern.Data()), 0.);
528 Info(
"BuildFAZIA",
"to be defined in child class ...");
540 new TGeoBBox(
"TARGET_FRAME", 3., 3., 0.1 / 2.);
541 new TGeoEltu(
"TARGET_HOLE", 2., 2., 0.1 / 2.);
618 TIter next_det(dets);
650 while (!DetNames.
End()) {
711 sname.
Form(
"%s-RUTH", FzDataType_str[idsig]);
714 sname.
Form(
"%s-%d", FzDataType_str[idsig], 100 * bb + 10 * qq +
tt);
719 sname.
Form(
"%s-RUTH", FzDataType_str[idsig]);
722 sname.
Form(
"%s-%d", FzDataType_str[idsig], 100 * bb + 10 * qq +
tt);
726 sname.
Form(
"%s-%d", FzDataType_str[idsig], 100 * bb + 10 * qq +
tt);
752 case DAQ::FzData_FzDataType_QH1:
755 case DAQ::FzData_FzDataType_I1:
757 case DAQ::FzData_FzDataType_QL1:
759 case DAQ::FzData_FzDataType_Q2:
762 case DAQ::FzData_FzDataType_I2:
764 case DAQ::FzData_FzDataType_Q3:
784 int ts =
e.trinfo_size();
787 for (
Int_t tr = ts - 1; tr >= 0; tr--) {
788 const DAQ::FzTrigInfo& rdtrinfo =
e.trinfo(tr);
789 uint64_t triggervalue = rdtrinfo.value();
795 else if (tr == ts - 8) {
796 dt = triggervalue / (1e6);
812 else if (tr == ts - 19) {
816 else if (tr == ts - 20) {
825 for (
int b = 0;
b <
e.block_size(); ++
b) {
828 if (
e.block(
b).len_error() ||
e.block(
b).crc_error() || (!good)) {
833 int fIdBlk =
e.block(
b).blkid();
835 for (
int f = 0;
f <
e.block(
b).fee_size(); ++
f) {
837 const DAQ::FzFee& rdfee =
e.block(
b).fee(
f);
839 for (
int h = 0;
h < rdfee.hit_size(); ++
h) {
841 const DAQ::FzHit& rdhit = rdfee.hit(
h);
843 if (rdfee.len_error() || rdfee.crc_error() || (!good)) {
844 Warning(
"treat_event",
"FEE LEN OR CRC ERROR B%03d-FE%d",
e.block(
b).blkid(), rdfee.feeid());
848 int fIdFee = rdhit.feeid();
849 int fIdTel = rdhit.telid();
851 for (
Int_t mm = 0; mm < rdhit.data_size(); mm++) {
852 const DAQ::FzData& rdata = rdhit.data(mm);
853 int fIdSignal = rdata.type();
855 int DetTag = rdhit.dettag();
856 int GTTag = rdhit.gttag();
857 if (DetTag >= 16384 && GTTag < 16384) GTTag += 32768;
860 int fIdQuartet =
fQuartet[fIdFee][fIdTel];
861 int fIdTelescope =
fTelescope[fIdFee][fIdTel];
865 Error(
"treat_event",
"No detector %s-%d found in FAZIA geometry...", FzDetector_str[fIdSignal], 100 * fIdBlk + 10 * fIdQuartet + fIdTelescope);
871 if (!rdata.has_energy() && !rdata.has_waveform()) {
872 if (FzDataType_str[fIdSignal] !=
"I2")
Warning(
"treat_event",
"[NO DATA] [%s %s]", det->
GetName(), FzDataType_str[fIdSignal]);
876 if (rdata.has_energy()) {
877 const DAQ::Energy& ren = rdata.energy();
878 for (
Int_t ee = 0; ee < ren.value_size(); ee++) {
884 Warning(
"treat_event",
"FPGAEnergy signal not found for %s", det->
GetName());
888 if (rdata.has_baseline()) {
894 Warning(
"treat_event",
"BaseLine signal not found for %s", det->
GetName());
896 if (rdata.has_waveform()) {
897 const DAQ::Waveform& rwf = rdata.waveform();
900 if (fIdSignal <= 5) {
903 Warning(
"treat_event",
"signal name is empty !!! blk=%d qua=%d tel=%d\n", fIdBlk, fIdQuartet, fIdTelescope);
905 TGraph sig(rwf.sample_size());
907 for (
Int_t nn = 0; nn < rwf.sample_size(); nn++) {
908 if (fIdSignal != DAQ::FzData::ADC) {
909 if (rwf.sample(nn) > 8191) {
910 supp = rwf.sample(nn) | 0xFFFFC000;
913 supp = rwf.sample(nn);
917 supp = rwf.sample(nn);
925 Warning(
"treat_event",
"datatype %d>5 - taille = %d\n", fIdSignal, rwf.sample_size());
955 if (
f.GetFrameType() != MFM_FAZIA_FRAME_TYPE)
return kFALSE;
959 DAQ::FzEventSet fazia_set;
960 DAQ::FzEvent fazia_event;
962 if (fazia_set.ParseFromArray(
f.GetPointUserData(), ((MFMFaziaFrame&)
f).GetEventSize())) {
964 if (fazia_set.ev_size() > 1) {
965 Warning(
"handle_raw_data_event_mfmframe",
966 "Got a FzEventSet from data: cannot handle multiple events at once!");
971 else if (fazia_event.ParseFromArray(
f.GetPointUserData(), ((MFMFaziaFrame&)
f).GetEventSize())) {
993 Error(
"CreateCorrespondence",
"ElecDetLink.env not found");
998 for (
int t = 1; t <= 4; t++) {
999 for (
int q = 1;
q <= 4;
q++) {
1003 sscanf(elec.
Data(),
"FPGA%d-FE%d", &fpga, &fee);
1008 Error(
"CreateCorrespondence",
"Problem reading FAZIA ElecDetLink.env file : T%1d-Q%1d = %s", t,
q, elec.
Data());
1050 Info(
"ReadTriggerPatterns()",
"Reading FAZIA triggers used during runs...");
1051 auto trigs = db->
AddTable(
"FAZIA.Triggers",
"Principal triggers used by FAZIA");
1063 dbrec->
AddKey(
"Runs",
"List of Runs");
1064 trigs->AddRecord(dbrec);
1080 else idt->
SetIDCode(IDCodes::ID_SI2_PSA);
1087 if (labsY.Contains(
"SI1") && labsY.Contains(
"SI2"))
1089 else if (labsY.Contains(
"SI1"))
1091 else if (labsY.Contains(
"SI2"))
1096 Error(
"SetIDCodeForIDTelescope",
"Request for telescope name=%s of unknown class=%s",
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t g
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
static const Char_t * WorkingDirectory()
void Error(const char *method, const char *msgfmt,...) const override
Bool_t IsLabelled(const Char_t *l) const
static ValType GetDataSetEnv(const KVString &dataset, const KVString &type, const ValType &defval={})
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
void Warning(const char *method, const char *msgfmt,...) const override
Record folder for the database.
virtual Bool_t AddKey(KVDBKey *key, Bool_t check=kTRUE)
virtual KVRList * GetLinks(const Char_t *key) const
Returns the list of records linked to this record in table "key".
virtual KVDBTable * GetTable(const Char_t *table) const
virtual Bool_t AddTable(KVDBTable *table)
TString GetFullPathToDataSetFile(const Char_t *filename) const
const Char_t * GetDataSetDir() const
ValType GetDataSetEnv(const Char_t *type, const ValType &defval={}) const
List of hit groups in a multidetector array.
void AddGroup(KVGroup *grp)
Base class for 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.
KVGroup * GetGroup() const
virtual Int_t GetIndex() const
const KVSeqCollection & GetListOfDetectorSignals() const
Extension of TEnv to allow the writing of comments in the file.
void AddCommentLine(const Char_t *line)
Int_t WriteFile(const char *fname, EEnvLevel level=kEnvAll) override
Base class to describe database of an experiment ,,.
KVDBRun * GetDBRun(Int_t number) const
virtual void LinkRecordToRunRange(KVDBRecord *rec, UInt_t first_run, UInt_t last_run)
Bool_t FindCalibFile(const Char_t *type, TString &fullpath, const TString &array_name="") const
Base class for FAZIA detectors.
void SetSignal(TGraph *signal, const Char_t *signal_name)
KVDetectorSignal * SetFPGAEnergy(int sigid, Int_t idx, Double_t energy)
KVDetectorSignal * SetBaseLine(int sigid, Float_t baseline)
static const Char_t * GetNewName(KVString oldname)
Telescope for FAZIA identification using SI1 and/or SI2 with CSI.
void AddTriggerPattern(const TString &name, uint16_t value)
Description of a FAZIA detector geometry.
Double_t fImport_Xorg
for geometry import
void PerformClosedROOTGeometryOperations() override
Double_t fImport_ThetaMin
for geometry import
Double_t fQH1risetime
values of trapezoidal filter rise time set in the fpgas defined in .kvrootrc
Double_t TreatEnergy(Int_t sigid, Int_t eid, UInt_t val)
void SetTriggerPatternsForDataSet(const TString &dataset)
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)
int fQuartet[8][2]
quartet number from #FEE and #FPGA
Double_t GetSetupParameter(const Char_t *parname)
Double_t fImport_dTheta
for geometry import
Bool_t handle_raw_data_event_mfmframe(const MFMCommonFrame &) override
void SetIDCodeForIDTelescope(KVIDTelescope *) const override
Set the FAZIA-specific general identification code for the given telescope.
std::string GetTriggerForCurrentRun() const
void AddDetectorLabel(const Char_t *label)
void GetDetectorEvent(KVDetectorEvent *detev, const TSeqCollection *dets) override
virtual void BuildTarget()
void AssociateTrajectoriesAndNodes() override
void Build(Int_t=-1) override
Build the FAZIA array.
Int_t fStartingBlockNumber
TString fCorrespondanceFile
Bool_t fBuildTarget; //kTRUE to include target frame in the geometry.
Double_t fImport_PhiMax
for geometry import
virtual void SetNameOfDetectors(KVEnv &env)
Double_t fImport_Zorg
for geometry import
virtual void BuildFAZIA()
methods to be implemented in child classes
void DeduceIdentificationTelescopesFromGeometry() override
KVFAZIA(const Char_t *title="")
Default constructor.
void FillDetectorList(KVReconstructedNucleus *rnuc, KVHashList *DetList, const KVString &DetNames) override
void ReadTriggerPatterns(KVExpDB *db)
virtual void DefineStructureFormats(KVGeoImport &)
void GenerateCorrespondanceFile()
Bool_t treat_event(const DAQ::FzEvent &)
Read raw data for an event.
virtual ~KVFAZIA()
Destructor.
Double_t fImport_dPhi
for geometry import
Double_t fImport_ThetaMax
for geometry import
int fTelescope[8][2]
telescope number from #FEE and #FPGA
KVFAZIATrigger fTrigger
trigger pattern read from data for each event
KVGroupReconstructor * GetReconstructorForGroup(const KVGroup *) const override
Specialized group reconstructor for FAZIA.
void SetRawDataFromReconEvent(KVNameValueList &) override
Overrides base method in order to set the value of the trigger bit pattern for the event.
virtual void GetGeometryParameters()
Called by the Build method.
void SetTriggerPattern(uint16_t fp)
double oldfaziats
dummy ts to control trigger info transmission rate
Bool_t handle_raw_data_event_protobuf(KVProtobufDataReader &) override
TString GetSignalName(Int_t bb, Int_t qq, Int_t tt, Int_t idsig)
Double_t fImport_PhiMin
for geometry import
Int_t fNblocks
number of blocks
Double_t fImport_Yorg
for geometry import
void CreateCorrespondence()
void MakeCalibrationTables(KVExpDB *) override
Override base method in order to read FAZIA trigger for each run.
Handle FAZIA protobuf-format raw data files.
Path taken by particles through multidetector geometry.
KVGeoDetectorNode * GetNextNode() const
KVSeqCollection * AccessIDTelescopeList()
KVString GetPathString() const
void IterateFrom(const KVGeoDetectorNode *node0=nullptr) const
void IterateBackFrom(const KVGeoDetectorNode *node0=nullptr) const
Information on relative positions of detectors & particle trajectories.
KVDetector * GetDetector() const
Import detector array described by ROOT geometry and set up corresponding KVMultiDetArray object.
void AddAcceptedDetectorName(const char *name)
void SetOrigin(double x, double y, double z)
void SetDetectorPlugin(const TString &name)
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)
void SetNameCorrespondanceList(const Char_t *)
virtual Bool_t Fired(Option_t *opt="any") const
virtual 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="", const KVGroup *g=nullptr)
Group of detectors which can be treated independently of all others in array.
Extended version of ROOT THashList.
Base class for all detectors or associations of detectors in array which can identify charged particl...
void SetGroup(KVGroup *kvg)
KVDetector * GetDetector(UInt_t n) const
virtual void SetIDCode(UShort_t c)
KVGroup * GetGroup() const
virtual void AddDetector(KVDetector *d)
KVString GetDetectorLabelsForGridCoord(const KVString &axis) const
Extended TList class which owns its objects by default.
Description of physical materials used to construct detectors & targets; interface to range tables.
virtual Double_t GetThickness() const
virtual TGeoMedium * GetGeoMedium(const Char_t *="")
static KVIonRangeTable * GetRangeTable()
Base class for describing the geometry of a detector array.
void SetDetectorThicknesses()
virtual void GetDetectorEvent(KVDetectorEvent *detev, const TSeqCollection *fired_params=0)
static Bool_t fCloseGeometryNow
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
KVSeqCollection * fIDTelescopes
deltaE-E telescopes in groups
TString GetDataSet() const
KVGroup * GetGroup(const Char_t *name) const
virtual void MakeCalibrationTables(KVExpDB *)
UInt_t GetCurrentRunNumber() const
virtual void SetIdentifications()
const TSeqCollection * GetTrajectories() const
static Bool_t fBuildTarget
virtual void SetRawDataFromReconEvent(KVNameValueList &)
KVUniqueNameList fFiredDetectors
list of fired detectors after reading raw data event
KVUniqueNameList fTrajectories
list of all possible trajectories through detectors of array
KVNameValueList fReconParameters
general purpose list of parameters for storing information on data reconstruction
TString fDataSet
name of associated dataset, used with MakeMultiDetector()
virtual void AssociateTrajectoriesAndNodes()
KVUnownedList fFiredSignals
list of fired signals after reading raw data event
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)
ULong64_t GetValue64bit(const Char_t *name) const
Bool_t HasParameter(const Char_t *name) const
Strings used to represent a set of ranges of values.
KVNameValueList * GetParameters() const
Read Google Protobuf DAQ files.
Nuclei reconstructed from data measured by a detector array .
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
void Clear(Option_t *option="") override
void Delete(Option_t *option="") override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
Calculation/correction of energy losses of particles through an experimental target.
void Add(TObject *obj) override
virtual Int_t GetEntries() const
THashList * GetTable() 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)
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 TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
const char * GetName() const override
virtual void SetName(const char *name)
TClass * IsA() const override
void AbstractMethod(const char *method) const
virtual const char * GetName() const
virtual const char * ClassName() const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Info(const char *method, const char *msgfmt,...) const
TObject * First() const override
const char * Data() const
Bool_t IsWhitespace() const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const