18 #include <TDirectory.h>
22 #include <QtCore/QDateTime>
23 #include <QtCore/QString>
24 #include <QtCore/QStringList>
47 typedef HelperAcqirisDetectors::helperinstancesmap_t::key_type
detectorkey_t;
53 typedef pair<DelaylineDetector::particles_t::key_type,
68 QStringList::const_iterator detName(detectorNamesList.begin());
69 for (; detName != detectorNamesList.end(); ++detName)
70 HelperAcqirisDetectors::instance(detName->toStdString())->
loadSettings();
80 bool isDLD(
const detectorkey_t &detkey)
82 HelperAcqirisDetectors::shared_pointer dethelp (HelperAcqirisDetectors::instance(detkey));
83 return (dethelp->detectortype() ==
Delayline);
100 detectorkey_t dld(qstr.toStdString());
102 throw invalid_argument(
"pp2001::loadSettings(): Error detector '" + dld +
103 "' is not a Delaylinedetector.");
107 if (!detectorNamesList.contains(qstr))
108 throw invalid_argument(
"pp2001::loadSettings(): Error detector '" + dld +
109 "' is not defined.");
127 particleskey_t particlekey(make_pair(qstr.toStdString(),
""));
128 const HelperAcqirisDetectors::helperinstancesmap_t & knownDetectors(HelperAcqirisDetectors::instances());
129 HelperAcqirisDetectors::helperinstancesmap_t::const_iterator det(knownDetectors.begin());
130 for (;det != knownDetectors.end(); ++det)
132 if (
isDLD(det->first))
134 HelperAcqirisDetectors &dethelp(*HelperAcqirisDetectors::instance(det->first));
135 const DetectorBackend &detback((dethelp.detector()));
136 const DelaylineDetector &dld(dynamic_cast<const DelaylineDetector&>(detback));
137 const DelaylineDetector::particles_t &particles(dld.particles());
138 DelaylineDetector::particles_t::const_iterator particle(particles.find(particlekey.first));
139 if (particle != particles.end())
141 particlekey.second = det->first;
146 throw invalid_argument(
"pp2001::loadSettings(): Error particle '" + particlekey.first +
147 "' is not part of any Delaylinedetector.");
162 map<string,double>::const_iterator last,
167 dest[(*first).first] = (*first).second;
176 _tree(new TTree(
"CASSData",
"Selected preprocessed data from the CASSEvent")),
177 _treestructure_ptr(&_treestructure),
178 _machinestructure_ptr(&_machinestructure),
179 _eventstatusstructure_ptr(&_eventstatusstructure),
180 _ppstructure_ptr(&_ppstructure)
183 throw invalid_argument(
"pp2001 (" + name +
"): '" + filename +
184 "' could not be opened! Maybe deleting the file helps.");
190 throw logic_error(
"pp2001::result: '"+
name()+
"' should never be called");
200 QStringList::const_iterator ppname(pps.begin());
201 bool allDepsAreThere(
true);
202 for (ppname = pps.begin(); ppname != pps.constEnd(); ++ppname)
205 allDepsAreThere = pp && allDepsAreThere;
206 if (pp && pp->result().dim() != 0)
207 throw invalid_argument(
"pp2001 (" +
name() +
"): Processor '" + pp->name() +
208 "' is not a 0d histogram.");
212 if (!(ret && allDepsAreThere))
224 if (
_tree->FindBranch(
"DLDetectorData") == 0)
227 if (
_tree->FindBranch(
"EvendId") == 0)
229 if (settings.
value(
"MachineData",
false).toBool())
230 if (
_tree->FindBranch(
"MachineData") == 0)
232 if (settings.
value(
"EventStatus",
false).toBool())
233 if (
_tree->FindBranch(
"EventStatus") == 0)
236 if (
_tree->FindBranch(
"Processors") == 0)
240 string output(
"Processor '" +
name() +
"' will write the hits of detectors: ");
241 dlddetectors_t::const_iterator detectorsIt(
_detectors.begin());
242 for (;detectorsIt!=
_detectors.end();++detectorsIt)
243 output += (
"'" + (*detectorsIt) +
"', ");
244 output +=
" and particles: ";
245 particleslist_t::const_iterator particle(
_particles.begin());
246 for (;particle !=
_particles.end();++particle)
247 output += (
"'" + particle->first +
"(" + particle->second +
")', ");
248 output += (
" to rootfile '" + string(
_rootfile->GetName()) +
"'. Condition is '" +
267 dlddetectors_t::const_iterator detectorEnd(
_detectors.end());
270 DetectorBackend &rawdet(
271 HelperAcqirisDetectors::instance(*detector)->detector(evt));
272 DelaylineDetector &det(dynamic_cast<DelaylineDetector&>(rawdet));
276 detectorHits_t::iterator
hit(det.hits().begin());
277 for (;
hit != det.hits().end(); ++
hit)
282 treehit[
"x"] = hitvalues[
x];
283 treehit[
"y"] = hitvalues[
y];
284 treehit[
"t"] = hitvalues[
t];
285 treehit[
"method"] = hitvalues[
method];
286 treedet.push_back(treehit);
289 particleslist_t::const_iterator particle(
_particles.begin());
290 particleslist_t::const_iterator particleEnd(
_particles.end());
291 for (;particle !=particleEnd;++particle)
293 DetectorBackend &rawdet(
294 HelperAcqirisDetectors::instance(particle->second)->detector(evt));
295 DelaylineDetector &det(dynamic_cast<DelaylineDetector&>(rawdet));
298 treeparticle.clear();
300 particleHits_t::iterator
hit(
hits.begin());
301 particleHits_t::iterator hitEnd(
hits.end());
302 for (;
hit != hitEnd; ++
hit)
307 treehit[
"px"] = hitvalues[
px];
308 treehit[
"py"] = hitvalues[
py];
309 treehit[
"pz"] = hitvalues[
pz];
310 treehit[
"x_mm"] = hitvalues[
x_mm];
311 treehit[
"y_mm"] = hitvalues[
y_mm];
312 treehit[
"tof_ns"] = hitvalues[
tof_ns];
313 treehit[
"xCor_mm"] = hitvalues[
xCor_mm];
314 treehit[
"yCor_mm"] = hitvalues[
yCor_mm];
319 treehit[
"tofCor_ns"] = hitvalues[
tofCor_ns];
320 treehit[
"roh"] = hitvalues[
roh];
321 treehit[
"theta"] = hitvalues[
theta];
322 treehit[
"phi"] = hitvalues[
phi];
323 treehit[
"e_au"] = hitvalues[
e_au];
324 treehit[
"e_eV"] = hitvalues[
e_eV];
325 treeparticle.push_back(treehit);
328 const Device &machinedata
336 std::list<shared_pointer>::const_iterator ProcessorsIt(
_pps.begin());
337 std::list<shared_pointer>::const_iterator ProcessorsEnd(
_pps.end());
338 for (;ProcessorsIt != ProcessorsEnd;++ProcessorsIt)
343 float value(val.getValue());
std::vector< double > detectorHit_t
define a detector hit
eventStatus_t * _eventstatusstructure_ptr
pointer to the event status structure
Event to store all LCLS Data.
uint64_t _eventid
copy of the event id
HelperAcqirisDetectors::helperinstancesmap_t::key_type detectorkey_t
typedef for easier code
pp2001(const name_t &, std::string)
Construct processor for converting histograms to root histograms.
virtual const result_t & result(const CASSEvent::id_t eventid=0)
overwrite the retrieval of an histogram
const name_t name() const
retrieve the name of this processor
file contains declaration of the CASSEvent
uint64_t id_t
define the id type
define which of the hitfinders defined above will be used as hit
bool _hide
flag to tell whether this pp should be hidden in the dropdown list
machinestructure_t * _machinestructure_ptr
pointer to the machine structure defined above
Average out the iShit status to get the avererage hits
void loadAllDets()
load the settings of all acqiris detectors defined in .ini file
std::map< std::string, double > treehit_t
a hit is just a map of hit values identified by a string
bool isDLD(const detectorkey_t &detkey)
check whether the key points to a delayline detector
list< detectorkey_t > dlddetectors_t
typedef for easier code
file contains declaration of processor 2001
TTree * _tree
the root tree to fill
static void add(Level level, const std::string &line)
add a string to the log
file contains the classes that describe a delayline detector.
TFile * _rootfile
the root file
std::vector< double > particleHit_t
define a particle hit
fromStdString(const std::string &str)
QMutex _lock
a lock to make the process reentrant
particleskey_t qstring2particle(const QString &qstr)
convert qstring to the particle key pair
treestructure_t _treestructure
structure that should be written to tree
base class for processors.
shared_pointer setupDependency(const std::string &depVarName, const name_t &name="")
setup the dependecy.
devices_t & devices()
setters
file contains declaration of classes and functions that help other processors to do their job...
contains the manager for the processors
list< particleskey_t > particleslist_t
typedef for easier code
std::list< ACQIRIS::HelperAcqirisDetectors::helperinstancesmap_t::key_type > _detectors
list of detectors who's hits should be filled into the tree
contains singleton definition for creating root files
value(const QString &key, const QVariant &defaultValue=QVariant()
std::list< shared_pointer > _pps
container for all 0d Processors that should be added to the tree
virtual void processEvent(const CASSEvent &)
only a stub does nothing, but needs to be there because its pure virtual in base class ...
static void close(TFile *rootfile)
close root file
void setupGeneral()
general setup of the processor
std::vector< treehit_t > treedetector_t
lots of hits are a delayline detector
pair< DelaylineDetector::particles_t::key_type, HelperAcqirisDetectors::helperinstancesmap_t::key_type > particleskey_t
typedef for easier code
definitions of a machine device
void copyMapValues(map< string, double >::const_iterator first, map< string, double >::const_iterator last, treehit_t &dest)
copy map values to map
void loadSettings(CASSSettings &s, CFDParameters &p, uint32_t &instrument, size_t &channelNbr)
implementation of loading settings for both CFD classes
virtual void loadSettings(size_t)
load the settings of this pp
file contains specialized class that do the settings for cass
ppstructure_t _ppstructure
0d processor structure
shared_pointer _condition
pointer to the processor that will contain the condition
eventStatus_t _eventstatusstructure
event status structure
bool setupCondition(bool defaultConditionType=true)
setup the condition.
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
std::vector< particleHit_t > particleHits_t
define container for all particle hits
check if there is some light in the chamber based upon the GMD value
detectorkey_t qstring2detector(const QString &qstr)
convert a qstring to the key in the list of detectors
defining structures for the root tree
beginGroup(const QString &prefix)
machinestructure_t _machinestructure
machine data structure
treestructure_t * _treestructure_ptr
pointer to the above structure (needed by the tree)
ppstructure_t * _ppstructure_ptr
pointer to the 0d processor structure
virtual const result_t & result(const CASSEvent::id_t eventid=0)
retrieve a result for a given id.
std::list< std::pair< ACQIRIS::DelaylineDetector::particles_t::key_type, ACQIRIS::HelperAcqirisDetectors::helperinstancesmap_t::key_type > > _particles
list of particles whos hits should be added to the tree