10 using namespace Diana;
15 fMaxNeighbours = GetInt(
"MaximumNumberOfNeighbours",2);
16 if(fMaxNeighbours < 1) Panic(
"MaximumNumberOfNeighbours = %d not allowed",fMaxNeighbours);
18 fLabels.resize(fMaxNeighbours);
22 std::map<std::string, QVdt*> wparams = GetModuleParameters(GetSequence().GetWriterName(), 0);
24 if(wparams.find(
"AliasFileName") != wparams.end()) {
25 aliases.
FillFromFile(wparams[
"AliasFileName"]->GetString());
27 if(wparams.find(
"CustomAliasFileName") != wparams.end()) {
28 aliases.
FillFromFile(wparams[
"CustomAliasFileName"]->GetString());
33 std::vector<QEventLabel> originalObjects = eva.
GetLabels();
34 for(
size_t i = 0; i < originalObjects.size(); i++) {
37 if(!GetBool(label,
false,
false))
continue;
38 QObject**
object = eva.
Get(label.
owner.c_str(),label.
name.c_str());
39 (*object)->SetIsRequired();
41 for(
size_t n = 0; n < (size_t)fMaxNeighbours; n++) {
43 std::stringstream newOwner;
44 newOwner<<std::string(GetString(
"Prefix",
"N",
false));
47 newOwner<<label.
owner;
49 QObject** newObject = eva.
Get(newOwner.str().c_str(),label.
name.c_str());
52 newObject =
new (QObject*);
53 *newObject = (*object)->Duplicate();
54 (*object)->FullyFill(*newObject);
55 (*newObject)->SetIsJustAdded();
58 eva.
Add(newLabel.
owner.c_str(),newLabel.
name.c_str(),newObject);
60 (*newObject)->SetIsJustAdded();
67 fLabels[n].push_back(labels);
70 std::map<std::string,std::string> thisAliases = aliases.
Find(label);
71 std::map<std::string,std::string>::const_iterator aiter = thisAliases.begin();
72 while(aiter != thisAliases.end()) {
73 std::stringstream nalias;
74 nalias<<std::string(GetString(
"Prefix",
"N"));
78 aliases.
Add(newLabel,aiter->second,nalias.str());
84 if(fLabels[0].empty()) {
85 Error(
"No QObject from neighbours will be packed");
87 std::stringstream msg;
89 for(
size_t n = 0; n < fLabels[0].size(); n++) msg<<fLabels[0][n].fOriginalLabel.GetStringLabel()<<
" ";
91 Info(
"%s",msg.str().c_str());
94 fMaxNeighboursAchieved = 0;
100 for(
size_t n = 0; n < neigh.
Size(); n++) {
101 if(n < (
size_t)fMaxNeighbours) {
102 for(
size_t l = 0; l < fLabels[n].size(); l++) {
104 const QEventLabel& originalLabel = fLabels[n][l].fOriginalLabel;
108 const QObject* originalObject = &
rHandle.Get();
109 QObject**
object = eva.
Get(label.
owner.c_str(),label.
name.c_str());
110 originalObject->FullyFill(*
object);
111 (*object)->SetIsJustAdded();
119 if(neigh.
Size() > fMaxNeighboursAchieved) fMaxNeighboursAchieved = neigh.
Size();
126 if(fMaxNeighboursAchieved > (
size_t)fMaxNeighbours)
127 Warn(
"Only %d neighbours per event have been packed, while the maximum number available was %d", fMaxNeighbours, fMaxNeighboursAchieved);
128 else if(fMaxNeighboursAchieved < (
size_t)fMaxNeighbours)
129 Warn(
"Could not pack %d neighbours per event, since maximum number available was only %d",fMaxNeighbours, fMaxNeighboursAchieved);
130 GlobalHandle<QInt> nHandle(
"NumberOfNeighbours");
131 nHandle.Set(fMaxNeighbours);
132 GlobalData().Set(&nHandle,
"CurrentWriter");
QRunDataHandle rHandle(753)
#define REGISTER_MODULE(clazz)
Internal class to save new (NX_owner@name) and original (owner@name) label of a QObject.
Diana::QEventLabel fOriginalLabel
Diana::QEventLabel fLabel
Save user selected QObjects from neighbours QEvents into the main QEvent.
Action Do(Diana::QEventAssembler &eva, const Diana::QEventList &neigh)
Do.
Action Init(Diana::QEventAssembler &eva)
Init.
QError FillFromFile(const std::string &filename)
void Add(const QEventLabel &label, const std::string &path, const std::string &alias)
std::map< std::string, std::string > Find(const QEventLabel &label) const
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
class to store ActionId and fEventNumber (in case fActionId=ACT_GOTOEV)
Visitor class of QEvent that provides full handling of QEvent.
QEvent & GetEvent()
Get the QEvent.
std::vector< QEventLabel > GetLabels() const
Get the list of all QObject labels in the event.
void Get(const char *owner, WriteHandle< Q > &handle)
Get QObject from the event in write mode. This method has to be called in the event loop,...
const QAliases & GetAliases() const
get aliases (const version)
void Add(const char *owner, WriteHandle< Q > &handle)
Add QObject to the event. This method has to be called before the event loop, e.g....
label for QObject in the QEvent
std::string owner
owner of the QObject
std::string name
name of the QObject
list of references to const QEvent (s)
size_t Size() const
number of QEvent (s)
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
void Add(WriteHandle< Q > &handle)
Add a QObject to the event.
read handle to access QEvent QObject's.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...