ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Gui
src
VP1EventFile.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
7
// //
8
// Implementation of class VP1EventFile //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: May 2008 //
12
// //
14
15
#include "
VP1Gui/VP1EventFile.h
"
16
#include <QStringList>
17
#include <QtCoreVersion>
18
19
//____________________________________________________________________
20
class
VP1EventFile::Imp
{
21
public
:
22
Imp
() :
runNumber
(0),
eventNumber
(0),
rawTime
(0),
valid
(false) {}
23
Imp
(
const
QString& fn,
const
QString& sum,
24
int
r
,
int
e,
unsigned
t,
bool
isvalid)
25
:
fileName
(fn),
md5Sum
(sum),
26
runNumber
(
r
),
eventNumber
(e),
rawTime
(t),
valid
(isvalid)
27
{}
28
QString
fileName
;
29
QString
md5Sum
;
30
int
runNumber
;
31
unsigned
long
long
eventNumber
;
32
unsigned
rawTime
;
33
bool
valid
;
34
35
static
Imp
*
initFromFilename
(
const
QString& filename,
const
QString& md5sum);
36
};
37
38
//____________________________________________________________________
39
VP1EventFile::VP1EventFile
()
40
:
m_d
(new
Imp
)
41
{
42
}
43
44
//____________________________________________________________________
45
VP1EventFile::Imp
*
VP1EventFile::Imp::initFromFilename
(
const
QString& filename,
const
QString& md5sum)
46
{
47
#if QTCORE_VERSION >= 0x050E00
48
QStringList filenameparts = filename.split(
'.'
, Qt::SkipEmptyParts );
49
#else
50
QStringList filenameparts = filename.split(
'.'
, QString::SkipEmptyParts );
51
#endif
52
if
(filenameparts.isEmpty())
53
return
new
Imp
;
54
55
//We find the relevant part of the filename the following way:
56
//Starting from the back, we find the first part which contains at
57
//least two underscores)
58
int
ieventinfo=-1;
59
for
(
int
i=filenameparts.count()-1;i>=0;--i) {
60
if
(filenameparts.at(i).count(
'_'
)>=2) {
61
ieventinfo = i;
62
break
;
63
}
64
}
65
if
(ieventinfo==-1)
66
return
new
Imp
;
67
68
#if QTCORE_VERSION >= 0x050E00
69
QStringList eventinfoparts = filenameparts.at(ieventinfo).split(
'_'
, Qt::SkipEmptyParts );
70
#else
71
QStringList eventinfoparts = filenameparts.at(ieventinfo).split(
'_'
, QString::SkipEmptyParts );
72
#endif
73
if
(eventinfoparts.count()<3)
74
return
new
Imp
;
75
bool
ok;
76
int
time
= eventinfoparts.at(eventinfoparts.count()-1).toInt(&ok);
77
// if (!ok||time<1175378400/*april 1. 2007*/||time>2058991200/*april 1 2035*/)
78
if
(!ok||
time
>2058991200
/*april 1 2035*/
)
//No lower bound sanity check, since the events sometimes have faulty ~1970 timestamps!
79
return
new
Imp
;
80
81
unsigned
long
long
eventnumber = eventinfoparts.at(eventinfoparts.count()-2).toInt(&ok);
82
if
(!ok)
83
return
new
Imp
;
84
int
runnumber
= eventinfoparts.at(eventinfoparts.count()-3).toInt(&ok);
85
if
(!ok)
86
return
new
Imp
;
87
return
new
Imp
(filename,md5sum,
runnumber
,eventnumber,
time
,
true
);
88
}
89
90
//____________________________________________________________________
91
VP1EventFile::VP1EventFile
(
const
QString& filename,
const
QString& md5sum)
92
:
m_d
(
Imp
::initFromFilename(filename,md5sum))
93
{
94
}
95
96
//____________________________________________________________________
97
VP1EventFile::VP1EventFile
(
const
QString& filename,
const
QString& md5sum,
98
int
runnumber
,
unsigned
long
long
eventnumber,
unsigned
time
,
bool
isvalid)
99
:
m_d
(new
Imp
(filename,md5sum,
runnumber
,eventnumber,
time
,isvalid))
100
{
101
}
102
103
//____________________________________________________________________
104
VP1EventFile::~VP1EventFile
()
105
{
106
delete
m_d
;
107
}
108
109
//____________________________________________________________________
110
bool
VP1EventFile::operator<
(
const
VP1EventFile
& other )
const
111
{
112
//newer (larger time, run and evt numbers) means "smaller".
113
if
(
m_d
->rawTime!=other.m_d->rawTime)
return
m_d
->rawTime>other.m_d->rawTime;
114
if
(
m_d
->runNumber!=other.m_d->runNumber)
return
m_d
->runNumber>other.m_d->runNumber;
115
if
(
m_d
->eventNumber!=other.m_d->eventNumber)
return
m_d
->eventNumber>other.m_d->eventNumber;
116
if
(
m_d
->fileName!=other.m_d->fileName)
return
m_d
->fileName<other.m_d->fileName;
117
if
(
m_d
->valid!=other.m_d->valid)
return
m_d
->valid;
118
return
m_d
->md5Sum<other.m_d->md5Sum;
119
}
120
121
//____________________________________________________________________
122
bool
VP1EventFile::operator==
(
const
VP1EventFile
& other )
const
123
{
124
return
m_d
->rawTime==other.m_d->rawTime
125
&&
m_d
->eventNumber==other.m_d->eventNumber
126
&&
m_d
->md5Sum==other.m_d->md5Sum
127
&&
m_d
->fileName==other.m_d->fileName
128
&&
m_d
->runNumber==other.m_d->runNumber
129
&&
m_d
->valid==other.m_d->valid;
130
}
131
132
//____________________________________________________________________
133
bool
VP1EventFile::operator!=
(
const
VP1EventFile
& other )
const
134
{
135
return
!(*
this
==other);
136
}
137
138
//____________________________________________________________________
139
VP1EventFile::VP1EventFile
(
const
VP1EventFile
& other )
140
:
m_d
(new
Imp
)
141
{
142
*
this
= other;
143
}
144
145
//____________________________________________________________________
146
VP1EventFile
&
VP1EventFile::operator=
(
const
VP1EventFile
& other )
147
{
148
m_d
->fileName = other.m_d->fileName;
149
m_d
->md5Sum = other.m_d->md5Sum;
150
m_d
->runNumber = other.m_d->runNumber;
151
m_d
->eventNumber = other.m_d->eventNumber;
152
m_d
->rawTime = other.m_d->rawTime;
153
m_d
->valid = other.m_d->valid;
154
return
*
this
;
155
}
156
157
//____________________________________________________________________
158
bool
VP1EventFile::isValid
()
const
159
{
160
return
m_d
->valid;
161
}
162
163
//____________________________________________________________________
164
const
QString&
VP1EventFile::fileName
()
const
165
{
166
return
m_d
->fileName;
167
}
168
169
//____________________________________________________________________
170
const
QString&
VP1EventFile::md5Sum
()
const
171
{
172
return
m_d
->md5Sum;
173
}
174
175
//____________________________________________________________________
176
int
VP1EventFile::runNumber
()
const
177
{
178
return
m_d
->runNumber;
179
}
180
181
//____________________________________________________________________
182
unsigned
long
long
VP1EventFile::eventNumber
()
const
183
{
184
return
m_d
->eventNumber;
185
}
186
187
//____________________________________________________________________
188
unsigned
VP1EventFile::rawTime
()
const
189
{
190
return
m_d
->rawTime;
191
}
192
193
//____________________________________________________________________
194
QDateTime
VP1EventFile::time
()
const
195
{
196
return
QDateTime::fromTime_t(
m_d
->rawTime);
197
}
198
199
//____________________________________________________________________
200
QString
VP1EventFile::print
()
const
201
{
202
if
(!
isValid
())
203
return
"[invalid]"
;
204
return
fileName
()
205
+
", run="
+QString::number(
runNumber
())
206
+
", evt="
+QString::number(
eventNumber
())
207
+
", time="
+
time
().toString()
208
+
", md5="
+
md5Sum
();
209
}
VP1EventFile.h
VP1EventFile::Imp
Definition
VP1EventFile.cxx:20
VP1EventFile::Imp::runNumber
int runNumber
Definition
VP1EventFile.cxx:30
VP1EventFile::Imp::fileName
QString fileName
Definition
VP1EventFile.cxx:28
VP1EventFile::Imp::rawTime
unsigned rawTime
Definition
VP1EventFile.cxx:32
VP1EventFile::Imp::Imp
Imp(const QString &fn, const QString &sum, int r, int e, unsigned t, bool isvalid)
Definition
VP1EventFile.cxx:23
VP1EventFile::Imp::initFromFilename
static Imp * initFromFilename(const QString &filename, const QString &md5sum)
Definition
VP1EventFile.cxx:45
VP1EventFile::Imp::Imp
Imp()
Definition
VP1EventFile.cxx:22
VP1EventFile::Imp::md5Sum
QString md5Sum
Definition
VP1EventFile.cxx:29
VP1EventFile::Imp::valid
bool valid
Definition
VP1EventFile.cxx:33
VP1EventFile::Imp::eventNumber
unsigned long long eventNumber
Definition
VP1EventFile.cxx:31
VP1EventFile::runNumber
int runNumber() const
Definition
VP1EventFile.cxx:176
VP1EventFile::print
QString print() const
Definition
VP1EventFile.cxx:200
VP1EventFile::time
QDateTime time() const
Definition
VP1EventFile.cxx:194
VP1EventFile::eventNumber
unsigned long long eventNumber() const
Definition
VP1EventFile.cxx:182
VP1EventFile::~VP1EventFile
~VP1EventFile()
Definition
VP1EventFile.cxx:104
VP1EventFile::m_d
Imp * m_d
Definition
VP1EventFile.h:52
VP1EventFile::rawTime
unsigned rawTime() const
Definition
VP1EventFile.cxx:188
VP1EventFile::operator<
bool operator<(const VP1EventFile &) const
Definition
VP1EventFile.cxx:110
VP1EventFile::VP1EventFile
VP1EventFile()
Definition
VP1EventFile.cxx:39
VP1EventFile::operator=
VP1EventFile & operator=(const VP1EventFile &)
Definition
VP1EventFile.cxx:146
VP1EventFile::fileName
const QString & fileName() const
Definition
VP1EventFile.cxx:164
VP1EventFile::isValid
bool isValid() const
Definition
VP1EventFile.cxx:158
VP1EventFile::operator!=
bool operator!=(const VP1EventFile &) const
Definition
VP1EventFile.cxx:133
VP1EventFile::operator==
bool operator==(const VP1EventFile &) const
Definition
VP1EventFile.cxx:122
VP1EventFile::md5Sum
const QString & md5Sum() const
Definition
VP1EventFile.cxx:170
r
int r
Definition
globals.cxx:22
runnumber
static std::vector< uint32_t > runnumber
Definition
iLumiCalc.h:37
Generated on
for ATLAS Offline Software by
1.17.0