2121 *************************************************************************/
2222
2323// ////////////////////////////////////////////////////////////////////////
24- // / The TRestRawFeminosRootToSignalProcess ...
24+ // / The TRestRawFeminosRootToSignalProcess converts the events acquired by
25+ // / the Feminos DAQ into TRestRawSignalEvent objects.
2526// /
26- // / DOCUMENTATION TO BE WRITTEN (main description, methods, data members)
27+ // / ### Parameters
28+ // / - **fUseFeminosDaqRunInfo**: Flag to determine if Feminos DAQ run info is transferred
29+ // / to the TRestRun object. If `true` (default), the run info such as start time,
30+ // / run number, tag, and description are set from the Feminos DAQ run info (stored
31+ // / in the run tree of the .root file). If `false`, this behavior is disabled and the
32+ // / start time is set from the first processed event timestamp. *Note: if you are using
33+ // / inputFormat in TRestRun to extract the run information (run number and tag usually),
34+ // / be aware that this happens before TRestRawFeminosRootToSignalProcess. The process,
35+ // / with fUseFeminosDaqRunInfo set to true, will overwrite the run info so the final
36+ // / values in the TRestRun will come from the .root file generated by feminos-daq,
37+ // / not the filename.*
2738// /
2839// / \warning This process might be obsolete today. It may need additional
2940// / revision, validation, and documentation. Use it under your own risk. If you
5667// / 2024-Aug: First implementation
5768// / Luis Obis
5869// /
70+ // / 2025-May: Extract Feminos DAQ run info
71+ // / Álvaro Ezquerro
72+ // /
5973// / \class TRestRawFeminosRootToSignalProcess
6074// / \author Luis Obis
6175// /
@@ -109,7 +123,47 @@ void TRestRawFeminosRootToSignalProcess::InitProcess() {
109123 exit (1 );
110124 }
111125
112- fRunInfo ->SetFeminosDaqTotalEvents (fInputEventTree ->GetEntries ());
126+ if (fUseFeminosDaqRunInfo ) {
127+ ULong64_t startTimeStampMilliseconds = 0 ;
128+ ULong64_t runNumber = 0 ;
129+ std::string* runTag = new std::string ();
130+ std::string* runDescription = new std::string ();
131+ fInputRunTree ->SetBranchAddress (" timestamp" , &startTimeStampMilliseconds);
132+ fInputRunTree ->SetBranchAddress (" number" , &runNumber);
133+ fInputRunTree ->SetBranchAddress (" tag" , &runTag);
134+ fInputRunTree ->SetBranchAddress (" comments" , &runDescription);
135+
136+ /* // Unused because they cannot be set in the run info
137+ std::string* runComment = new std::string();
138+ fInputRunTree->SetBranchAddress("comments", &runComment);
139+ std::string* runDetector = new std::string();
140+ fInputRunTree->SetBranchAddress("detector", &runDetector);
141+ Float_t driftField = 0;
142+ fInputRunTree->SetBranchAddress("drift_field_V_cm_bar", &driftField);
143+ Float_t meshVoltage = 0;
144+ fInputRunTree->SetBranchAddress("mesh_voltage_V", &meshVoltage);
145+ Float_t detectorPressure = 0;
146+ fInputRunTree->SetBranchAddress("detector_pressure_bar", &detectorPressure);
147+ */
148+
149+ // retrieve row 0
150+ fInputRunTree ->GetEntry (0 );
151+
152+ // set run info
153+ Double_t startTimeStamp = startTimeStampMilliseconds / 1000.0 ; // convert ms to seconds
154+ fRunInfo ->SetStartTimeStamp (startTimeStamp);
155+ fRunInfo ->SetRunNumber (runNumber);
156+ // mclient sets the run tag and description to "\n" if they are empty
157+ if (*runTag == " \n " ) {
158+ runTag->clear ();
159+ }
160+ if (*runDescription == " \n " ) {
161+ runDescription->clear ();
162+ }
163+ fRunInfo ->SetRunTag (*runTag);
164+ fRunInfo ->SetRunDescription (*runDescription);
165+ fRunInfo ->SetFeminosDaqTotalEvents (fInputEventTree ->GetEntries ());
166+ }
113167
114168 fInputEventTree ->SetBranchAddress (" timestamp" , &fInputEventTreeTimestamp );
115169 fInputEventTree ->SetBranchAddress (" signal_ids" , &fInputEventTreeSignalIds );
@@ -126,6 +180,16 @@ TRestEvent* TRestRawFeminosRootToSignalProcess::ProcessEvent(TRestEvent* inputEv
126180 // fInputEventTreeTimestamp is in milliseconds and TRestEvent::SetTime(seconds, nanoseconds)
127181 fSignalEvent ->SetTime (fInputEventTreeTimestamp / 1000 , fInputEventTreeTimestamp % 1000 * 1000000 );
128182
183+ // get the first event timestamp (if we are not using FeminosDaq run info where this is set from the run
184+ // tree)
185+ if (!fUseFeminosDaqRunInfo && fInputEventTreeTimestamp < fStartTimestamp ) {
186+ fStartTimestamp = fInputEventTreeTimestamp ;
187+ }
188+ // get the last event timestamp
189+ if (fInputEventTreeTimestamp > fEndTimestamp ) {
190+ fEndTimestamp = fInputEventTreeTimestamp ;
191+ }
192+
129193 for (size_t i = 0 ; i < fInputEventTreeSignalIds ->size (); i++) {
130194 auto signal = TRestRawSignal ();
131195 signal.Initialize ();
@@ -148,3 +212,12 @@ TRestEvent* TRestRawFeminosRootToSignalProcess::ProcessEvent(TRestEvent* inputEv
148212
149213 return fSignalEvent ;
150214}
215+
216+ void TRestRawFeminosRootToSignalProcess::EndProcess () {
217+ // use first event timestamp as start of run if we are not using FeminosDaq run info
218+ if (!fUseFeminosDaqRunInfo ) {
219+ fRunInfo ->SetStartTimeStamp (fStartTimestamp / 1000.0 ); // convert from ms to s
220+ }
221+ // use last event timestamp as end of run
222+ fRunInfo ->SetEndTimeStamp (fEndTimestamp / 1000.0 ); // convert from ms to s
223+ }
0 commit comments