27 #include "MFMFaziaFrame.h"
31 #include "FzEventSet.pb.h"
148 auto links = rundb->
GetLinks(
"FAZIA.Triggers");
149 if (links && links->GetEntries())
184 KVDetector* csi{
nullptr}, *si2{
nullptr}, *si1{
nullptr};
186 auto d =
N->GetDetector();
187 if (
d->IsLabelled(
"SI1") &&
d->IsOK()) si1 =
d;
188 else if (
d->IsLabelled(
"SI2") &&
d->IsOK()) si2 =
d;
189 else if (
d->IsLabelled(
"CSI") &&
d->IsOK()) csi =
d;
202 add_telescope(idt, csi->
GetGroup());
207 add_telescope(idt, csi->
GetGroup());
213 idt->
SetName(
Form(
"ID_SI_CSI_%d", csi->GetIndex()));
214 add_telescope(idt, csi->
GetGroup());
221 add_telescope(idt, si2->
GetGroup());
227 add_telescope(idt, si2->
GetGroup());
232 add_telescope(idt, si1->
GetGroup());
275 #ifdef WITH_GNU_INSTALL
288 env.
AddCommentLine(
"Make link between geometric ROOT objects and detector names");
314 for (
Int_t qq = 1; qq <= 4; qq += 1) {
320 Form(
"BLOCK_%d_QUARTET_%d_%s-T%d", bb, qq, sdet.
Data(),
tt),
321 Form(
"%s-%d", sdet.
Data(), bb * 100 + qq * 10 +
tt)
418 while (!patterns.
End()) {
420 uint16_t val = (uint16_t)
GetDataSetEnv(dataset,
Form(
"FAZIA.TriggerPattern.%s", pattern.Data()), 0.);
434 Info(
"BuildFAZIA",
"to be defined in child class ...");
446 new TGeoBBox(
"TARGET_FRAME", 3., 3., 0.1 / 2.);
447 new TGeoEltu(
"TARGET_HOLE", 2., 2., 0.1 / 2.);
524 TIter next_det(dets);
556 while (!DetNames.
End()) {
652 Int_t value = (val << 2);
656 case DAQ::FzData_FzDataType_QH1:
657 if (eid == 0) dval = value / (
fQH1risetime * 1e3 / 10.);
659 case DAQ::FzData_FzDataType_I1:
661 case DAQ::FzData_FzDataType_QL1:
663 case DAQ::FzData_FzDataType_Q2:
664 if (eid == 0) dval = value / (
fQ2risetime * 1e3 / 10.);
666 case DAQ::FzData_FzDataType_I2:
668 case DAQ::FzData_FzDataType_Q3:
688 int ts =
e.trinfo_size();
691 for (
Int_t tr = ts - 1; tr >= 0; tr--) {
692 const DAQ::FzTrigInfo& rdtrinfo =
e.trinfo(tr);
693 uint64_t triggervalue = rdtrinfo.value();
699 else if (tr == ts - 8) dt = triggervalue;
710 else if (tr == ts - 19) {
714 else if (tr == ts - 20) {
721 for (
int b = 0;
b <
e.block_size(); ++
b) {
724 if (
e.block(
b).len_error() ||
e.block(
b).crc_error() || (!good)) {
729 int fIdBlk =
e.block(
b).blkid();
731 for (
int f = 0;
f <
e.block(
b).fee_size(); ++
f) {
733 const DAQ::FzFee& rdfee =
e.block(
b).fee(
f);
735 for (
int h = 0;
h < rdfee.hit_size(); ++
h) {
737 const DAQ::FzHit& rdhit = rdfee.hit(
h);
739 if (rdfee.len_error() || rdfee.crc_error() || (!good)) {
740 Warning(
"treat_event",
"FEE LEN OR CRC ERROR B%03d-FE%d",
e.block(
b).blkid(), rdfee.feeid());
744 int fIdFee = rdhit.feeid();
745 int fIdTel = rdhit.telid();
748 const DAQ::FzData& rdata = rdhit.data(
mm);
749 int fIdSignal = rdata.type();
751 int DetTag = rdhit.dettag();
752 int GTTag = rdhit.gttag();
753 if (DetTag >= 16384 && GTTag < 16384) GTTag += 32768;
756 int fIdQuartet =
fQuartet[fIdFee][fIdTel];
757 int fIdTelescope =
fTelescope[fIdFee][fIdTel];
761 Error(
"treat_event",
"No detector %s-%d found in FAZIA geometry...",
FzDetector_str[fIdSignal], 100 * fIdBlk + 10 * fIdQuartet + fIdTelescope);
767 if (!rdata.has_energy() && !rdata.has_waveform()) {
772 if (rdata.has_energy()) {
773 const DAQ::Energy& ren = rdata.energy();
774 for (
Int_t ee = 0; ee < ren.value_size(); ee++) {
780 if (rdata.has_waveform()) {
781 const DAQ::Waveform& rwf = rdata.waveform();
784 if (fIdSignal <= 5) {
787 Warning(
"treat_event",
"signal name is empty !!! blk=%d qua=%d tel=%d\n", fIdBlk, fIdQuartet, fIdTelescope);
789 TGraph sig(rwf.sample_size());
791 for (
Int_t nn = 0; nn < rwf.sample_size(); nn++) {
792 if (fIdSignal != DAQ::FzData::ADC) {
793 if (rwf.sample(nn) > 8191) {
794 supp = rwf.sample(nn) | 0xFFFFC000;
797 supp = rwf.sample(nn);
801 supp = rwf.sample(nn);
809 Warning(
"treat_event",
"datatype %d>5 - taille = %d\n", fIdSignal, rwf.sample_size());
839 if (
f.GetFrameType() != MFM_FAZIA_FRAME_TYPE)
return kFALSE;
843 DAQ::FzEventSet fazia_set;
844 DAQ::FzEvent fazia_event;
846 if (fazia_set.ParseFromArray(
f.GetPointUserData(), ((MFMFaziaFrame&)
f).GetEventSize())) {
848 if (fazia_set.ev_size() > 1) {
849 Warning(
"handle_raw_data_event_mfmframe",
850 "Got a FzEventSet from data: cannot handle multiple events at once!");
855 else if (fazia_event.ParseFromArray(
f.GetPointUserData(), ((MFMFaziaFrame&)
f).GetEventSize())) {
877 Error(
"CreateCorrespondence",
"ElecDetLink.env not found");
882 for (
int t = 1; t <= 4; t++) {
883 for (
int q = 1;
q <= 4;
q++) {
887 sscanf(elec.
Data(),
"FPGA%d-FE%d", &fpga, &fee);
892 Error(
"CreateCorrespondence",
"Problem reading FAZIA ElecDetLink.env file : T%1d-Q%1d = %s", t,
q, elec.
Data());
934 Info(
"ReadTriggerPatterns()",
"Reading FAZIA triggers used during runs...");
935 auto trigs = db->
AddTable(
"FAZIA.Triggers",
"Principal triggers used by FAZIA");
947 dbrec->
AddKey(
"Runs",
"List of Runs");
948 trigs->AddRecord(dbrec);
964 else idt->
SetIDCode(IDCodes::ID_SI2_PSA);
968 else if (idt->
InheritsFrom(KVFAZIAIDSiSiCsI::Class())) {
971 if (labsY.Contains(
"SI1") && labsY.Contains(
"SI2"))
973 else if (labsY.Contains(
"SI1"))
975 else if (labsY.Contains(
"SI2"))
980 Error(
"SetIDCodeForIDTelescope",
"Request for telescope name=%s of unknown class=%s",
static Char_t const *const FzDataType_str[]
static Char_t const *const FzDetector_str[]
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
R__EXTERN TGeoManager * gGeoManager
char * Form(const char *fmt,...)
static const Char_t * WorkingDirectory()
Bool_t IsLabelled(const Char_t *l) const
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
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)
const Char_t * GetDataSetDir() const
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
TString GetFullPathToDataSetFile(const Char_t *filename)
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.
KVGroup * GetGroup() const
const KVSeqCollection & GetListOfDetectorSignals() const
Extension of TEnv to allow the writing of comments in the file.
void AddCommentLine(const Char_t *line)
virtual Int_t WriteFile(const char *fname, EEnvLevel level=kEnvAll)
Base class to describe database of an experiment ,.
Bool_t FindCalibFile(const Char_t *type, TString &fullpath) const
KVDBRun * GetDBRun(Int_t number) const
virtual void LinkRecordToRunRange(KVDBRecord *rec, UInt_t first_run, UInt_t last_run)
Base class for FAZIA detectors.
void SetSignal(TGraph *signal, const Char_t *signal_name)
static const Char_t * GetNewName(KVString oldname)
KVDetectorSignal * SetFPGAEnergy(int sigid, Int_t idx, Double_t energy)
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
Double_t fImport_ThetaMin
for geometry import
KVGroupReconstructor * GetReconstructorForGroup(const KVGroup *) const
Specialized group reconstructor for FAZIA.
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 FillDetectorList(KVReconstructedNucleus *rnuc, KVHashList *DetList, const KVString &DetNames)
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
void SetIDCodeForIDTelescope(KVIDTelescope *) const
Set the FAZIA-specific general identification code for the given telescope.
std::string GetTriggerForCurrentRun() const
void AddDetectorLabel(const Char_t *label)
Bool_t handle_raw_data_event_protobuf(KVProtobufDataReader &)
virtual void BuildTarget()
Int_t fStartingBlockNumber
void DeduceIdentificationTelescopesFromGeometry()
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
KVFAZIA(const Char_t *title="")
Default constructor.
void ReadTriggerPatterns(KVExpDB *db)
virtual void DefineStructureFormats(KVGeoImport &)
void GenerateCorrespondanceFile()
void PerformClosedROOTGeometryOperations()
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
virtual void MakeCalibrationTables(KVExpDB *)
Override base method in order to read FAZIA trigger for each run.
Bool_t handle_raw_data_event_mfmframe(const MFMCommonFrame &)
virtual void GetGeometryParameters()
Called by the Build method.
void SetTriggerPattern(uint16_t fp)
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
void GetDetectorEvent(KVDetectorEvent *detev, const TSeqCollection *dets)
virtual void Build(Int_t=-1)
Build the FAZIA array.
Double_t fImport_Yorg
for geometry import
void CreateCorrespondence()
virtual void SetRawDataFromReconEvent(KVNameValueList &)
Overrides base method in order to set the value of the trigger bit pattern for the event.
Handle FAZIA protobuf-format raw data files.
Path taken by particles through multidetector geometry.
KVGeoDetectorNode * GetNextNode() const
KVSeqCollection * AccessIDTelescopeList()
void IterateBackFrom(const KVGeoDetectorNode *node0=nullptr) const
Information on relative positions of detectors & particle trajectories.
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
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.
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
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
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
KVSeqCollection * fIDTelescopes
deltaE-E telescopes in groups
TString GetDataSet() 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
KVNameValueList fReconParameters
general purpose list of parameters for storing information on data reconstruction
TString fDataSet
name of associated dataset, used with MakeMultiDetector()
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)
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 .
virtual void Clear(Option_t *option="")
virtual void Add(TObject *obj)
virtual void Delete(Option_t *option="")
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.
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)
virtual const char * GetName() const
virtual void SetName(const char *name)
void AbstractMethod(const char *method) const
virtual const char * GetName() const
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
const char * Data() const
Bool_t IsWhitespace() const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
const long double g
masses