ATLAS Offline Software
Loading...
Searching...
No Matches
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//____________________________________________________________________
21public:
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;
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//____________________________________________________________________
43
44//____________________________________________________________________
45VP1EventFile::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//____________________________________________________________________
91VP1EventFile::VP1EventFile(const QString& filename, const QString& md5sum)
92 : m_d(Imp::initFromFilename(filename,md5sum))
93{
94}
95
96//____________________________________________________________________
97VP1EventFile::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//____________________________________________________________________
105{
106 delete m_d;
107}
108
109//____________________________________________________________________
110bool 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//____________________________________________________________________
122bool 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//____________________________________________________________________
133bool VP1EventFile::operator!=(const VP1EventFile & other ) const
134{
135 return !(*this==other);
136}
137
138//____________________________________________________________________
140 : m_d(new Imp)
141{
142 *this = other;
143}
144
145//____________________________________________________________________
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//____________________________________________________________________
159{
160 return m_d->valid;
161}
162
163//____________________________________________________________________
164const QString& VP1EventFile::fileName() const
165{
166 return m_d->fileName;
167}
168
169//____________________________________________________________________
170const QString& VP1EventFile::md5Sum() const
171{
172 return m_d->md5Sum;
173}
174
175//____________________________________________________________________
177{
178 return m_d->runNumber;
179}
180
181//____________________________________________________________________
182unsigned long long VP1EventFile::eventNumber() const
183{
184 return m_d->eventNumber;
185}
186
187//____________________________________________________________________
188unsigned VP1EventFile::rawTime() const
189{
190 return m_d->rawTime;
191}
192
193//____________________________________________________________________
194QDateTime VP1EventFile::time() const
195{
196 return QDateTime::fromTime_t(m_d->rawTime);
197}
198
199//____________________________________________________________________
200QString 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}
Imp(const QString &fn, const QString &sum, int r, int e, unsigned t, bool isvalid)
static Imp * initFromFilename(const QString &filename, const QString &md5sum)
unsigned long long eventNumber
int runNumber() const
QString print() const
QDateTime time() const
unsigned long long eventNumber() const
unsigned rawTime() const
bool operator<(const VP1EventFile &) const
VP1EventFile & operator=(const VP1EventFile &)
const QString & fileName() const
bool isValid() const
bool operator!=(const VP1EventFile &) const
bool operator==(const VP1EventFile &) const
const QString & md5Sum() const
int r
Definition globals.cxx:22
static std::vector< uint32_t > runnumber
Definition iLumiCalc.h:37