26 #include <gan_tape_erreur.h>
27 #include <gan_tape_general.h>
28 #include <gan_tape_param.h>
29 #include <gan_tape_test.h>
30 #include <gan_tape_alloc.h>
31 #include <gan_tape_mount.h>
32 #include <gan_tape_file.h>
33 #include <acq_mt_fct_ganil.h>
34 #include <acq_ebyedat_get_next_event.h>
35 #include <gan_tape_get_parametres.h>
50 #include "GTGanilData.h"
52 bool AutoswBuf, Swbufon;
96 if (
filename.BeginsWith(
"rfio:")) fFileName.Remove(0, 5);
97 strncpy(fDevice->DevName, fFileName, MAX_CARACTERES);
106 if (fScaler)
delete fScaler;
107 if (fDataParameters)
delete fDataParameters;
108 if (fDevice)
delete fDevice;
110 if (fStructEvent)
delete[] fStructEvent;
111 if (fDataArray)
delete[] fDataArray;
112 if (fFired)
delete[] fFired;
113 if (fEventBrut)
delete[] fEventBrut;
114 if (fEventCtrl)
delete[] fEventCtrl;
146 fIsScalerBuffer =
false;
151 fBuffer =
new in2p3_buffer_struct;
152 fStructEvent =
new char[STRUCTEVENTSIZE];
159 fStatus = acq_get_param_env(lun_id, &DeRetour, argc, argv);
160 if (DeRetour.Val_INT >= 0) fLun = DeRetour.Val_INT;
164 fStatus = acq_get_param_env(device_id, &DeRetour, argc, argv);
165 strncpy(fDevice->DevName, DeRetour.Val_CAR, MAX_CARACTERES);
166 fFileName = DeRetour.Val_CAR;
169 fStatus = acq_get_param_env(autoswbuf_id, &DeRetour, argc, argv);
170 AutoswBuf = DeRetour.Val_BOL;
172 fStatus = acq_get_param_env(swbufon_id, &DeRetour, argc, argv);
173 Swbufon = DeRetour.Val_BOL;
176 fStatus = acq_get_param_env(ctrlform_id, &DeRetour, argc, argv);
177 fCtrlForm = DeRetour.Val_INT;
179 fStatus = acq_get_param_env(density_id, &DeRetour, argc, argv);
180 fDensity = DeRetour.Val_INT;
182 fStatus = acq_get_param_env(bufsize_id, &DeRetour, argc, argv);
183 fBufSize = DeRetour.Val_INT;
187 fStatus = acq_get_param_env(evbsize_id, &DeRetour, argc, argv);
188 fEvbsize = DeRetour.Val_INT;
190 fStatus = acq_get_param_env(evcsize_id, &DeRetour, argc, argv);
191 fEvcsize = DeRetour.Val_INT;
193 fEventBrut =
new UShort_t[fEvbsize];
194 fEventCtrl =
new UShort_t[fEvcsize];
199 fCTRLEVNT_HD =
sizeof(CTRL_EVENT) / 2 - 1;
242 Int_t structEvent_size = STRUCTEVENTSIZE;
244 fStatus = acq_dev_is_alloc_c(*fDevice);
245 if (fStatus == ACQ_OK) fAllocated =
true;
247 gan_tape_erreur(fStatus,
"test d'allocation");
251 fStatus = acq_mt_alloc_c(*fDevice);
252 if (fStatus != ACQ_OK) {
253 if (fStatus == ACQ_NOTALLOC)
254 cout <<
"This tape drive is already in use !" << endl;
255 gan_tape_erreur(fStatus,
"allocation");
259 fStatus = acq_mt_mount_c(*fDevice, fDensity, fBufSize);
260 if (fStatus != ACQ_OK) {
261 if (fStatus == ACQ_ALREADYMOUNT)
262 cout <<
"The tape you want to use is already mounted" << endl;
263 gan_tape_erreur(fStatus,
"mount");
267 fStatus = acq_mt_open_c(fDevice, o_read, &fLun);
268 if (fStatus != ACQ_OK) {
269 gan_tape_erreur(fStatus,
"open");
274 fStatus = acq_mt_ini_run_c(fLun,
fBuffer, fBufSize, &fRunNumber,
275 fStructEvent, structEvent_size, Date);
278 if (fStatus != ACQ_OK) {
279 gan_tape_erreur(fStatus,
"Init Run");
282 cout <<
"Run " << fRunNumber <<
" opened" << endl;
303 if (strcmp(fHeader, PARAM_Id) == 0)
304 fDataArraySize = fDataParameters->Fill(
fBuffer->les_donnees.cas.Buf_param);
306 while (strcmp(fHeader, PARAM_Id) == 0);
308 fDataArray =
new UShort_t[fDataArraySize + 1];
309 fFired =
new Bool_t[fDataArraySize + 1];
310 for (
Int_t i = 1; i <= fDataArraySize; i++) {
324 if ((
index < 1) || (
index > fDataArraySize)) {
325 cout <<
"Invalid connexion:" <<
index <<
". Valid only in 1<=index<="
326 << fDataArraySize << endl;
329 *
p = &(fDataArray[
index]);
341 if ((
index < 1) || (
index > fDataArraySize)) {
342 cout <<
"Invalid connexion:" <<
index <<
". Valid only in 1<=index<="
343 << fDataArraySize << endl;
425 if (fStatus)
return (
false);
432 if (strcmp(fHeader, SCALER_Id) == 0) {
433 switch (fWhatScaler) {
437 fScaler->Fill((
scale*) & (
fBuffer->les_donnees.cas.scale));
438 fScaler->DumpScalers();
442 fScaler->Fill((
scale*) & (
fBuffer->les_donnees.cas.scale));
443 fIsScalerBuffer =
true;
446 case kAutoWriteScaler: {
447 fScaler->Fill((
scale*) & (
fBuffer->les_donnees.cas.scale));
448 fScaler->DumpScalers();
454 cout <<
"GTGanilData::Next: unexpected value for fWhatScaler" << endl;
457 if (strcmp(fHeader, EVENTDB_Id) == 0) {
458 fIsScalerBuffer =
false;
461 return (ReadNextEvent());
463 else if (strcmp(fHeader, EVENTCT_Id) == 0) {
464 fIsScalerBuffer =
false;
467 return (ReadNextEvent());
469 else if (strcmp(fHeader, EBYEDAT_Id) == 0) {
470 fIsScalerBuffer =
false;
473 return (ReadNextEvent_EBYEDAT());
475 cout <<
"Unknown header in GTGanilData::Next:" << fHeader << endl;
494 theFilename = fFileName +
".root";
496 TFile theTreeFile(theFilename,
"recreate");
497 TTree theTree(
"AutoTree",
"Automatic filled Tree");
498 for (
Int_t i = 1; i <= fDataArraySize; i++) {
499 TString parName = fDataParameters->GetParName(i);
500 TString parType = parName +
"/s";
501 theTree.
Branch(parName, &(fDataArray[i]), parType);
507 if (nEvents <= 0)
break;
525 fStatus = get_next_event(
fBuffer, fBufSize,
526 (
short*)fEventBrut, fEvbsize, &fEventNumber);
527 if (fStatus == ACQ_OK) {
528 fStatus = s_evctrl((
short*)fEventBrut, (
short*)fEventCtrl,
529 fStructEvent, &fCtrlForm);
530 if (fStatus == GR_OK)
531 return (EventUnravelling((CTRL_EVENT*)fEventCtrl));
533 puts(
"\n>>> Erreur de reconstruction");
537 else if (fStatus == ACQ_ENDOFBUFFER) {
542 gan_tape_erreur(fStatus,
"obtention d'evenement");
547 fStatus = get_next_event(
fBuffer, fBufSize, (
short*)fEventCtrl,
548 fEvcsize, &fEventNumber);
549 if (fStatus == ACQ_OK) {
550 return (EventUnravelling((CTRL_EVENT*)fEventCtrl));
552 else if (fStatus == ACQ_ENDOFBUFFER) {
557 gan_tape_erreur(fStatus,
"obtention d'evenement");
576 UNSINT16* ebyeEventCtrl;
577 fStatus = acq_ebyedat_get_next_event((UNSINT16*)
fBuffer, &ebyeEventCtrl, &fEventNumber, EVCT_VAR);
578 if (fStatus == ACQ_OK)
return (EventUnravelling((CTRL_EVENT*)ebyeEventCtrl));
579 else if (fStatus == ACQ_ENDOFBUFFER) {
584 cout <<
" in ReadNextEvent__EBEYEDAT error status: " << fStatus <<
" n";
589 fStatus = ACQ_BADEVENTFORM;
604 fStatus = acq_mt_read_c(fLun,
fBuffer->Buffer, &fBufSize);
608 strncpy(fHeader,
fBuffer->les_donnees.Ident, 8);
631 Short_t* brutData = &(pCtrlEvent->ct_par);
633 Int_t eventLength = pCtrlEvent->ct_len - fCTRLEVNT_HD;
636 for (
Int_t i = 1; i <= fDataArraySize; i++) {
640 for (
Int_t i = 0; i < eventLength; i += 2) {
641 if (brutData[i] <= fDataArraySize && brutData[i] >= 1) {
642 fDataArray[brutData[i]] = brutData[i + 1];
643 fFired[brutData[i]] =
true;
661 cout <<
"--------- DUMPING EVENT ----------------------------" << endl;
662 cout <<
"------- number:" << fEventCount << endl;
663 for (
Int_t i = 1; i <= fDataArraySize; i++) {
664 if (fFired[i]) cout <<
"index :" << i <<
" " << fDataParameters->GetParName(i) <<
" : " << fDataArray[i] << endl;
666 cout <<
"--------- END ----------------------------" << endl;
678 cout <<
"--------- DUMPING PARAMETERS ----------------------------" << endl;
679 cout <<
"------- number:" << fEventCount << endl;
680 for (
Int_t i = 1; i <= fDataArraySize; i++) {
682 cout <<
"index :" << i <<
" " << fDataParameters->GetParName(i) << endl;
684 cout <<
"--------- END ----------------------------" << endl;
720 if (fWhatScaler == kAutoWriteScaler) {
722 fScalerTree =
new TTree(
"Scalers",
"Automatic filled scalers");
723 fScalerTree->Branch(
"scalers", fScaler, 8000, 99);
726 cout <<
"Error in <GTGanilData::SetScalerBuffersManagement> : ";
727 cout <<
"You must open a writable TFile before calling SetScalerBuffersManagement(kAutoWriteScaler)" << endl;
728 fWhatScaler = kSkipScaler;
752 return (fStatus == ACQ_OK && fLun);
winID h TVirtualViewer3D TVirtualGLPainter p
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 filename
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
void ReadBuffer(char *&buffer) override
R__EXTERN TSystem * gSystem
Read GANIL formatted tapes or files.
void ConnectFired(const Int_t index, Bool_t **p) const
Connect a pointer to a data to the defined index in the Data Array.
void InitDefault(const Int_t argc=0, char **argv=NULL)
void DumpEvent(void) const
Dump parameter index, name and value for the current event.
void Connect(const Int_t index, UShort_t **p) const
Connect a pointer to a data to the defined index in the Data Array.
Int_t GetRunNumber(void) const
Returns current run number.
void SetFileName(const TString filename)
bool ReadNextEvent_EBYEDAT(void)
void PrintRunParameters(void) const
Print every class parameters, for now a simple dump.
virtual void SetUserTree(TTree *)
Not used.
void DumpParameterName(void) const
Dump parameter index and name.
Bool_t IsOpen(void) const
virtual void ReadParameters(void)
GTGanilData()
Default constructor.
void SetScalerBuffersManagement(const ScalerWhat_t sc)
void MakeTree(const TString filename="", UInt_t nEvents=kMaxUInt)
virtual ~GTGanilData(void)
virtual bool EventUnravelling(CTRL_EVENT *)
void PrintDataParameters(void) const
ScalerWhat_t
What to do with scaler buffer.
Handle scaler buffers in GANIL DAQ data.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
union SCALE::JBUS_SCALE jbus_scale
UNSINT16 Info_jbus[NB_MAX_JBUS]
scale_struct UnScale[NB_MAX_CHANNEL]