17 #include <TDirectory.h>
21 #include <QtCore/QDateTime>
47 uint32_t timet(static_cast<uint32_t>((eventid & 0xFFFFFFFF00000000) >> 32));
48 uint32_t eventFiducial =
static_cast<uint32_t
>((eventid & 0x00000000FFFFFFFF) >> 8);
54 name << time.
toString(Qt::ISODate).toStdString() <<
"_"<<eventFiducial;
58 name <<
"UnknownTime_"<<
eventid;
75 TDirectory * direc = file->GetDirectory(dirname.c_str());
85 if (tmp.find(
"/") == string::npos)
92 lhs = tmp.substr(0,tmp.find(
"/"));
93 rhs = tmp.substr(tmp.find(
"/")+1,tmp.length());
97 direc = gDirectory->GetDirectory(lhs.c_str());
100 gDirectory->cd(lhs.c_str());
104 direc = gDirectory->mkdir(lhs.c_str());
105 gDirectory->cd(lhs.c_str());
109 if (tmp.find(
"/") == string::npos)
130 switch (casshist.
dim())
134 roothist =
new TH1F(valname.c_str(),valname.c_str(),
136 roothist->SetBinContent(1,casshist.
getValue());
143 roothist =
new TH1F(valname.c_str(),valname.c_str(),
144 xaxis.nBins, xaxis.low, xaxis.up);
146 roothist->GetXaxis()->CenterTitle(
true);
147 roothist->SetXTitle(xaxis.title.c_str());
149 for (
size_t iX(0); iX<xaxis.nBins;++iX)
150 roothist->SetBinContent(roothist->GetBin(iX+1),casshist[iX]);
152 size_t OverUnderFlowStart (xaxis.nBins);
164 roothist =
new TH2F(valname.c_str(),valname.c_str(),
165 xaxis.nBins, xaxis.low, xaxis.up,
166 yaxis.nBins, yaxis.low, yaxis.up);
168 roothist->SetOption(
"colz");
170 roothist->SetXTitle(xaxis.title.c_str());
171 roothist->GetXaxis()->CenterTitle(
true);
172 roothist->SetYTitle(yaxis.title.c_str());
173 roothist->GetYaxis()->CenterTitle(
true);
174 roothist->GetYaxis()->SetTitleOffset(1.5);
176 for (
size_t iY(0); iY<yaxis.nBins;++iY)
177 for (
size_t iX(0); iX<xaxis.nBins;++iX)
178 roothist->SetBinContent(roothist->GetBin(iX+1,iY+1),casshist[iX + iY*xaxis.nBins]);
180 size_t OverUnderFlowStart (xaxis.nBins*yaxis.nBins);
197 roothist->Write(0,TObject::kOverwrite);
210 throw logic_error(
"pp2000::result: '"+
name()+
"' should never be called");
219 bool allDepsAreThere(
true);
221 for (
int i = 0; i <
size; ++i)
224 string ppname(s.
value(
"Name",
"Unknown").toString().toStdString());
225 if (ppname ==
"Unknown")
228 allDepsAreThere = pp && allDepsAreThere;
229 string groupname(s.
value(
"GroupName",
"/").toString().toStdString());
236 for (
int i = 0; i <
size; ++i)
239 string ppname(s.
value(
"Name",
"Unknown").toString().toStdString());
240 if (ppname ==
"Unknown")
243 allDepsAreThere = pp && allDepsAreThere;
244 string groupname(s.
value(
"GroupName",
"/").toString().toStdString());
251 if (!(ret && allDepsAreThere))
259 string filename(s.
value(
"FileName",
"output.root").toString().toStdString());
262 throw invalid_argument(
"pp2000 (" +
name() +
"): '" + filename +
263 "' could not be opened! Maybe deleting the file helps.");
265 "' will write all cass histograms with the write flag set " +
266 "to rootfile '" + _rootfile->GetName() +
"'. Condition is '" +
273 "): Histograms will be written to: '" +
_rootfile->GetName() +
"'");
286 string folder(
"/Summary/" + it->groupname);
312 list<entry_t>::const_iterator it(
_ppList.begin());
313 list<entry_t>::const_iterator last(
_ppList.end());
319 string folder(
"/" + dirname +
"/" + it->groupname);
size_t dim() const
what is the dimension of the result
value_t getValue() const
return the value
Event to store all LCLS Data.
toString(const QString &format)
const name_t name() const
retrieve the name of this processor
void copyHistToRootFile(const Processor::result_t &casshist, const string &valname)
function that will copy a histogram to file
check if FEL is off by checking for bykick which is eventid
file contains declaration of the CASSEvent
uint64_t id_t
define the id type
bool _hide
flag to tell whether this pp should be hidden in the dropdown list
static TFile * create(const std::string &rootfilename, const std::string &options="RECREATE")
create and return an instance of the rootfile
an axis of a more than 0 dimensional container
things written only at end of run H5Dump ProcessorSummary size
QMutex _lock
a lock to make the process reentrant
file contains declaration of processor 2000
string eventIdToDirectoryName(uint64_t eventid)
function to create a human readable directory name from the eventid
static void add(Level level, const std::string &line)
add a string to the log
fromStdString(const std::string &str)
beginReadArray(const QString &prefix)
base class for processors.
std::list< entry_t > _ppSummaryList
container for all pps that should be written when program quits
shared_pointer setupDependency(const std::string &depVarName, const name_t &name="")
setup the dependecy.
const axis_t & axis() const
read access to the axis
void changeDir(TFile *file, const string &dirname)
create a directory if it does not exist and cd into it
std::list< entry_t > _ppList
container with all pps that contain the histograms to dump to hdf5
pp2000(const name_t &name)
Construct processor for converting histograms to root histograms.
virtual void processEvent(const CASSEvent &)
only a stub does nothing, but needs to be there because its pure virtual in base class ...
contains singleton definition for creating root files
value(const QString &key, const QVariant &defaultValue=QVariant()
static void close(TFile *rootfile)
close root file
void setupGeneral()
general setup of the processor
virtual const result_t & result(const CASSEvent::id_t eventid=0)
overwrite the retrieval of an histogram
file contains specialized class that do the settings for cass
virtual void loadSettings(size_t)
load the settings of this pp
shared_pointer _condition
pointer to the processor that will contain the condition
bool setupCondition(bool defaultConditionType=true)
setup the condition.
TFile * _rootfile
the root file
std::string name_t
define the name type
contains a logger for cass
std::tr1::shared_ptr< Processor > shared_pointer
a shared pointer of this
virtual void aboutToQuit()
dump all histogram to a root file just before quitting
beginGroup(const QString &prefix)
struct bundleing info for writing an entry to file