Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JSupernovaL0.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "JGizmo/JManager.hh"
#include "JDAQ/JDAQ.hh"
#include "JDAQ/JDAQTimeslice.hh"
#include "JDAQ/JDAQSummaryslice.hh"
#include "JDAQ/JDAQEvaluator.hh"
#include "JDAQ/JDAQSummaryFrame.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JTools/JRange.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Author
mlincett

Preliminary study of summary rates for supernova detection

Definition in file JSupernovaL0.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 34 of file JSupernovaL0.cc.

35 {
36  using namespace std;
37  using namespace JPP;
38  using namespace KM3NETDAQ;
39 
40  JMultipleFileScanner<JDAQSummaryslice> inputFile;
41  string outputFile;
42  int debug;
43  int nLines;
44 
45  try {
46 
47  JParser<> zap("Monitoring of PMT time over threshold distributions.");
48 
49  zap['f'] = make_field(inputFile);
50  zap['o'] = make_field(outputFile) = "summaryrates.root";
51  zap['d'] = make_field(debug) = 1;
52  zap['n'] = make_field(nLines) = 2;
53  zap(argc, argv);
54 
55  }
56  catch(const exception &error) {
57  FATAL(error.what() << endl);
58  }
59 
60  JTreeScanner<JDAQSummaryslice, JDAQEvaluator> in(inputFile);
61 
62  cout.tie(&cerr);
63 
64  using namespace KM3NETDAQ;
65 
66  const double factor = 1.0/1000 ;
67  const int Nbins = 90 ; // reasonable range for singles rates from 0-20 kHz
68 
69  set<int> modules;
70 
71 
72  const double maxRate_kHz = 20;
73 
74  JManager<int, TH2D> SinglesRatedistr(new TH2D("%.2S", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS-0.5, Nbins, JDAQRate::getData(factor))) ;
75 
76  JManager<int, TH1D> PMT(new TH1D("pmt_S%", NULL, Nbins, JDAQRate::getData(factor)));
77  JManager<int, TH1D> DOM(new TH1D("dom_S%", NULL, 1000, 0, maxRate_kHz * NUMBER_OF_PMTS ));
78  JManager<int, TH1D> DET(new TH1D("det_S%", NULL, 1000, 0, nLines * 18 * maxRate_kHz * NUMBER_OF_PMTS));
79 
80  JManager<int, TH1D> Delta(new TH1D("delta_S%", NULL, 2000, -5000, +5000));
81 
82  JManager<int, TH1D> History(new TH1D("history_S%", NULL, 300000, 0, 300000));
83 
84  const int nStages = 3;
85 
86  vector<double> deltaRate(nStages, 0);
87  vector<double> detRateBuf(nStages, 0);
88 
89  while (in.hasNext()) {
90 
91  vector<double> detRate(nStages, 0);
92 
93  int counter = in.getCounter();
94 
95  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
96 
97  JDAQSummaryslice* summary = in.next();
98 
99  JDAQSummaryslice* previous_summary;
100 
101  int nDetectorActivePMTs = 0;
102 
103  int nDetectorTotalPMTs = 0;
104 
105  // loop over modules
106 
107  for (KM3NETDAQ::JDAQSummaryslice::const_iterator summary_frame = summary->begin(); summary_frame != summary->end(); ++summary_frame) {
108 
109  vector<double> domRate(nStages, 0);
110 
111  int DOMID = summary_frame->getModuleID() ;
112 
113  TH2D* h_i = SinglesRatedistr[DOMID];
114 
115  int nModuleActivePMTs = 0;
116 
117  for (int ipmt = 0 ; ipmt < NUMBER_OF_PMTS ; ipmt++) {
118 
119  double pmtRate = summary_frame->getRate(ipmt, factor);
120 
121  h_i->Fill(ipmt, pmtRate, summary_frame->getWeight(ipmt, factor));
122 
123  PMT[0]->Fill(pmtRate);
124 
125  domRate[0] += pmtRate;
126 
127  nDetectorTotalPMTs++;
128 
129  if ( !( summary_frame->testHighRateVeto(ipmt) || summary_frame->testFIFOStatus(ipmt) ) ) {
130 
131  nModuleActivePMTs++;
132 
133  PMT[1]->Fill(pmtRate);
134 
135  domRate[1] += pmtRate;
136 
137  /*
138  if (counter != 0) {
139 
140  KM3NETDAQ::JDAQSummaryslice::const_iterator previous_frame = previous_summary->begin();
141 
142  for ( ; previous_frame != previous_summary->end(); ++previous_frame) {
143  if (DOMID == previous_frame->getModuleID()) {
144  break;
145  }
146  }
147 
148  if (!( previous_frame->testHighRateVeto(ipmt) || previous_frame->testFIFOStatus(ipmt) ) ) {
149  PMT[2]->Fill(pmtRate);
150  domRate[2] += pmtRate;
151  }
152  }
153 
154  */
155  }
156  }
157 
158 
159  // DOM summary
160 
161  nDetectorActivePMTs += nModuleActivePMTs;
162  nDetectorTotalPMTs += NUMBER_OF_PMTS;
163 
164  for (int i = 0; i < nStages; i++) {
165  if (domRate[i] > 0) {
166  detRate[i] += domRate[i];
167  if (i == 1) {
168  domRate[i] /= ((double)nModuleActivePMTs) / NUMBER_OF_PMTS;
169  }
170  DOM[i]->Fill(domRate[i]);
171 
172  if (i == 0) { modules.insert(DOMID); }
173  }
174  }
175  }
176 
177  for (int i = 0; i < nStages; i++) {
178 
179  DET[i]->Fill(detRate[i]);
180  if (i == 1) {
181  detRate[i] /= ((double)nDetectorActivePMTs)/((double)nDetectorTotalPMTs);
182  }
183  History[i]->Fill(counter, detRate[i]);
184 
185  if (counter != 0) {
186  double deltaRate = detRate[i] - detRateBuf[i];
187  Delta[i]->Fill(deltaRate);
188  }
189 
190  detRateBuf[i] = detRate[i];
191 
192  }
193 
194  previous_summary = summary;
195 
196  }
197 
198  STATUS(endl);
199 
200  STATUS(modules.size() << " modules active in the run." << endl);
201 
202  // Store histogram(s).
203 
204  TFile out(outputFile.c_str(), "recreate");
205 
206  PMT.Write(out);
207  DOM.Write(out);
208  DET.Write(out);
209  Delta.Write(out);
210  History.Write(out);
211 
212 
213  // SinglesRatedistr.Write(out) ;
214 
215  out.Write();
216  out.Close();
217 
218 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Auxiliary class to manage set of histograms.
#define STATUS(A)
Definition: JMessage.hh:61
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
JDAQPMTIdentifier PMT
Command line options.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60