7 #include "QDetChannelCollectionHandle.hh"
17 using namespace Diana;
22 if ( GetIteration() == 1 ) {
23 fCoincidenceWindow = GetDouble(
"CoincidenceWindow", 0.100);
25 fUseRunningWindow = GetBool(
"UseRunningWindow",
true);
28 fEnergyLabel = GetString(
"EnergyLabel",
"ApplyCalibration@Energy");
30 fUseThermistorRanking =
false;
34 fThermistorRankingLabel = tmp;
35 fUseThermistorRanking =
true;
39 ev.
Add<
QInt>(
"OrderInMultiple");
41 ev.
Add<
QInt>(
"FirstEventNumber");
55 const int& run = header.
GetRun();
57 const double time_sec = header.GetTime().GetFromStartRunNs() / 1e9;
60 const int& event_number = header.GetEventNumber();
65 if ( fChannels.empty() ) {
67 GlobalData().Get(
"",&
rHandle,
"");
68 vector<int> allChannels =
rHandle.Get().fBolometerChannels;
73 set<int> channelsAndRelatives;
74 QDetChannelCollectionHandle dccHandle;
75 dccHandle.SetRun(run);
76 GlobalData().Get(
"",&dccHandle,
"");
78 for ( vector<int>::const_iterator ch = allChannels.begin();
79 ch != allChannels.end();
81 vector<int> relativeChannels = dccHandle.Get().GetRelativeChannels(
channel);
83 if ( channelsAndRelatives.count(*ch) == 0 ) {
84 fChannels.insert(*ch);
85 channelsAndRelatives.insert(*ch);
86 channelsAndRelatives.insert(
87 relativeChannels.begin(), relativeChannels.end()
93 const bool useThermistorRankingVariable = fUseThermistorRanking;
95 if ( GetIteration() == 1) {
96 bool useEvent =
false;
98 if (useThermistorRankingVariable) {
99 const int thermistorRanking= ev.
GetByLabel<
QInt>(fThermistorRankingLabel);
101 if (thermistorRanking <= 1) {
105 else if ( fChannels.count(
channel) != 0 ) {
112 event.fEnergy = energy;
113 event.fEventNumber = event_number;
114 event.fTime = time_sec;
116 fEventInfos.push_back(event);
117 fEventInfosIndex[event_number] = fEventInfos.size() - 1;
120 else if ( GetIteration() == 2 ) {
121 int multiplicity = -1;
122 int orderInMultiple = -1;
123 double totalEnergy = -1;
124 int firstEventNumber = -1;
125 if ( fEventInfosIndex.count(event_number) != 0 ) {
126 int index = fEventInfosIndex[event_number];
128 multiplicity = fEventInfos[index].fMultiplicity;
129 orderInMultiple = fEventInfos[index].fOrderInMultiple;
130 totalEnergy = fEventInfos[index].fTotalEnergy;
131 firstEventNumber = fEventInfos[index].fFirstEventNumber;
134 ev.
Get<
QInt>(
"Multiplicity") = multiplicity;
135 ev.
Get<
QInt>(
"OrderInMultiple") = orderInMultiple;
136 ev.
Get<
QInt>(
"FirstEventNumber") = firstEventNumber;
147 if ( GetIteration() == 1 ) {
151 for (
int index = 0; index < (int) fEventInfos.size(); ++index) {
153 if(fUseRunningWindow) {
154 DeltaT = fEventInfos[index].fTime
155 - fEventInfos[indexLast].fTime;
158 DeltaT = fEventInfos[index].fTime
159 - fEventInfos[indexFirst].fTime;
162 if (DeltaT < fCoincidenceWindow) {
166 double totalEnergy = 0;
167 for (
int i = indexFirst; i <= indexLast; ++i) {
168 totalEnergy += fEventInfos[i].fEnergy;
172 for (
int i = indexFirst; i <= indexLast; ++i) {
173 fEventInfos[i].fMultiplicity = indexLast - indexFirst + 1;
174 fEventInfos[i].fOrderInMultiple = order;
176 fEventInfos[i].fFirstEventNumber
177 = fEventInfos[indexFirst].fEventNumber;
178 fEventInfos[i].fTotalEnergy = totalEnergy;
187 double totalEnergy = 0;
188 for (
int i = indexFirst; i <= indexLast; ++i) {
189 totalEnergy += fEventInfos[i].fEnergy;
193 for (
int i = indexFirst; i <= indexLast; ++i) {
194 fEventInfos[i].fMultiplicity = indexLast - indexFirst + 1;
195 fEventInfos[i].fOrderInMultiple = order;
197 fEventInfos[i].fFirstEventNumber
198 = fEventInfos[indexFirst].fEventNumber;
199 fEventInfos[i].fTotalEnergy = totalEnergy;
QRunDataHandle rHandle(753)
#define REGISTER_MODULE(clazz)
Puts multiplicities and total energies in events.
void Do(Diana::QEvent &ev)
Do method.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
const Q & GetByLabel(const QEventLabel &label) const
Get a QObject in read mode by label.
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
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.
Raw event: bolometer channel, trigger positions and types.
const int & GetChannelId() const
Get ChannelId.
global handle for QRunData
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...