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 "km3net-dataformat/online/JDAQ.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDAQ/JDAQEvaluator.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 33 of file JSupernovaL0.cc.

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