6 #include <boost/lexical_cast.hpp>
133 time_t time0, timeA, timeB;
137 vector<triggeredSignals> vEvents;
139 vDomId.push_back(101);
140 vDomId.push_back(102);
141 vDomId.push_back(103);
145 int eventTrigger = 0;
148 TFile hfile(argv[3],
"RECREATE");
158 long long int startRunTime = 0;
159 bool startSet =
false;
160 bool toWrite =
false;
161 long long int endRunTime = 0;
163 cerr <<
"give the id of the first and last";
164 cerr <<
" runs you want to analyse and the root file name!" << endl;
168 int nbSlicePmt[
domNb] = {0, 0, 0};
169 int badSlice[
domNb] = {0, 0, 0};
170 for (
int r = boost::lexical_cast<int>(argv[1]); r <= boost::lexical_cast<int>(argv[2]); ++r) {
171 struct dirent* dirStruc;
172 const string dataPath =
"/home/alex/Data/Km3NeT/PPM-DU/raw/";
174 DIR* directory = opendir(dataPath.c_str());
176 char filenameStart[1024];
177 sprintf(filenameStart,
"RUN-PPM_DU-%0*d", 5, r);
178 char filenameEnd[1024];
179 sprintf(filenameEnd,
".rdat");
180 while ((dirStruc = readdir(directory))) {
181 const string dirname = string(dirStruc->d_name);
182 if ((dirname.find(filenameStart) != string::npos)
183 && (dirname.find(filenameEnd) != string::npos)) {
184 filename = dataPath + dirname;
188 for (
int g = 4; g <= argc - 1; ++g) {
189 const int wrongId = boost::lexical_cast<
int>(argv[g]);
190 if (r == wrongId) goodRun =
false;
193 file.open(filename.c_str(), ios::binary);
195 if ((!file) || (goodRun ==
false)) {
196 cerr << r <<
" is not the correct file name!" << endl;
200 twoGbSteps = int(
double(fileLength)/2.0e9) + 1;
201 if (twoGbSteps > 1) {
202 cerr <<
"file " << filename.c_str() <<
" is larger than 2.0GB - "
203 << twoGbSteps <<
" loops will be made" << endl;
205 long long int bitPosition = file.tellg();
207 cerr <<
"********** looking for the cut values **********\n";
208 for (
int i = 0; i < twoGbSteps; ++i) {
211 bitPosition =
FillRaw(file, vSlice, bitPosition, toWrite);
212 for (
unsigned int s = 0; s < vSlice.size(); ++s) {
213 const int curId = vSlice[s].GetDomHeader().GetDomId();
214 if (curId == vDomId[domId]) {
215 const long long int curtime = vSlice[s].GetDomHeader().GetDomTime();
216 if (vSlice[s].HasPmtData(
pmtId) ==
true) {
217 pmt curPmt = vSlice[s].GetPmtData(
pmtId);
219 const vector<signal> vSignal = curPmt.
GetSignal();
224 bool countedDom =
false;
225 for (
unsigned int j = 0; j < vDomId.size(); ++j) {
226 if (curId == vDomId[j]) {
231 if (vDomId.size() == 0) countedDom =
false;
232 if (countedDom ==
false) vDomId.push_back(curId);
242 file.open(filename.c_str(), ios::binary);
243 long long int bitPosition = file.tellg();
245 cerr <<
"cut values are (in kHz):\n";
252 cerr <<
"time of analysis: " << difftime(timeB, timeA) <<
's' << endl;
255 vector<triggeredSignals> v2GigaResults;
256 for (
int i = 0; i < twoGbSteps; ++i) {
258 cerr <<
"********** Filling the DOM with data - loop " << i <<
" **********\n";
260 bitPosition =
FillRaw(file, vSlice, bitPosition, toWrite);
262 cerr <<
"time of analysis: " << difftime(timeB, timeA) <<
's' << endl;
263 cerr <<
"********** Filling histograms **********\n";
268 cerr <<
"time of analysis: " << difftime(timeA, timeB) <<
's' << endl;
269 cerr <<
"********** Filling events and first level trigger **********\n";
270 vector<triggeredSignals> vTrig2pmtResult;
271 vTrig2pmtResult.clear();
272 vector<triggeredSignals> vTrigXpmtResult;
273 vTrigXpmtResult.clear();
274 vector<signals> vSignals;
276 sliceTot += vSlice.size();
277 for (
unsigned int e = 0; e < vSlice.size(); ++e) {
279 const domHeader& domHead = vSlice[e].GetDomHeader();
280 const long long int domTime = domHead.
GetDomTime();
281 if (startSet ==
false) {
282 startRunTime = domTime;
285 if (e == vSlice.size() - 1) endRunTime = domTime;
286 const int domId = domHead.
GetDomId();
290 const vector<pmt>& pmtSample = vSlice[e].GetPmtsData();
291 if (!pmtSample.size())
continue;
293 for (
unsigned int j = 0; j < pmtSample.size(); ++j) {
294 vector<signal> sigSample = pmtSample[j].GetSignal();
295 const int sigSampleSize = sigSample.size();
296 sigInSlice += sigSampleSize;
297 if (!sigSampleSize)
continue;
299 const int pmtId = pmtSample[j].GetPmtId();
300 if (
IsNoisySlice(sigSampleSize, cutValues[domIndex][pmtId])) {
301 ++badSlice[domIndex];
303 ++nbSlicePmt[domIndex];
304 for (
int k = 0; k < sigSampleSize; ++k) {
305 const long long int start = sigSample[k].GetStart() + domTime;
306 const signals oneSig(domIndex, pmtId, start, start + sigSample[k].GetDuration());
311 eventTotal += sigInSlice;
322 char f4foldname[1024];
323 sprintf(f4foldname,
"/home/alex/Data/Km3NeT/PPM-DU/stats/RUN-PPM_DU-%0*d-%dfold-%dns.dat",
325 ofstream out4fold(f4foldname, ios::app);
326 for (
unsigned int i = 0; i < vTrigXpmtResult.size(); ++i) {
327 const std::vector<signals>& vSignals4fold = vTrigXpmtResult[i].GetSignals();
328 if (vSignals4fold.size() == unsigned(localmulti)) {
329 out4fold << vSignals4fold[0].GetDomId() <<
' ';
330 for (
unsigned int j = 0; j < vSignals4fold.size(); ++j) {
331 out4fold << vSignals4fold[j].GetPmtId() <<
' ' << vSignals4fold[j].GetStart()
332 <<
' ' << vSignals4fold[j].GetStop() <<
' ';
346 vector<triggeredSignals> vTrig2Result;
352 cerr <<
"time of analysis: " << difftime(timeB, timeA) <<
's' << endl;
354 cerr <<
"*************** Second level trigger ****************" << endl;
357 eventTrigger = vEvents.size();
358 event2Doms = v2GigaResults.size();
366 cout << r <<
' ' << sliceTot <<
" 0 " << nbSlicePmt[0] <<
' ' << badSlice[0]
367 <<
" 1 " << nbSlicePmt[1] <<
' ' << badSlice[1]
368 <<
" 2 " << nbSlicePmt[2] <<
' ' << badSlice[2] << endl;
373 cerr <<
"number of not noisy pmts - number of noisy pmts\n"
374 <<
"dom 101: " << nbSlicePmt[0] <<
' ' << badSlice[0] <<
"\n"
375 <<
"dom 102: " << nbSlicePmt[1] <<
' ' << badSlice[1] <<
"\n"
376 <<
"dom 103: " << nbSlicePmt[2] <<
' ' << badSlice[2] <<
"\n"
377 <<
"Total number of signals: " << eventTotal
378 <<
" - number of events for a multiplicity of " <<
multiplicityForMuon <<
": " << event2Doms
379 <<
" - number of 2 Doms signals: " << eventTrigger << endl;
381 const double durationInS = double(endRunTime - startRunTime)*1e-9 + 0.134217728;
382 const int runHour = int(durationInS/3600.);
383 const int runMin = int((durationInS -
double(3600*runHour))/60.);
384 const double runSec = durationInS - double(3600*runHour) - double(60*runMin);
385 cerr <<
"time of analysis: " << difftime(timeA, time0) <<
"s\n"
386 <<
"run duration: " << runHour <<
"h " << runMin <<
"min " << runSec <<
"s"<< endl;
void DrawDeltaT(const int refID)
draw the histo, one per pmt
const bool HasSignal() const
test if one pmt has signal during the slice reading
void Do2DomTrigger(std::vector< triggeredSignals > &vTrigSignals, std::vector< triggeredSignals > &vFinalEvent, const int domTimeWindow)
void SortSignals(std::vector< signals > &vSig)
void DrawSliceTimeSeries()
draw the slice time series histo.
organisation of the data - dom level
void InitDeltaT(const int refID)
initialize the delta T histo (time difference between pmts).
void AddDom2Event(std::vector< triggeredSignals > &vTriggeredDom, std::vector< triggeredSignals > &vEventList)
to come...
void FillDeltaT(const std::vector< triggeredSignals > &vTrigger, const int domId, const int refID)
fill the time difference between all pmts and the reference pmt (given by the integer) ...
void FillFrequency(const int domId, const std::vector< pmt > &pmtSample, double cutValues[domNb][pmtNb])
fill the histo with the time difference between 2 signals for a list of signals (one histo per Pmt nu...
bool DoT2Pmts(const std::vector< signals > &vSig, std::vector< triggeredSignals > &vTrig)
define the 31 pmt signals of an dom for an event
bool SelectingMultiplicity(std::vector< triggeredSignals > &vTrigInit, std::vector< triggeredSignals > &vTrigFinal, const int multiplicity)
remove all dom events with a multiplicity lower than the chosen one
long long int FillRaw(std::ifstream &str, std::vector< dom > &vSlice, long long int bitPosition, bool toWrite)
const bool individualPmts
const int coincWindowDoms
void DrawDurations()
draw the histo, one per pmt
Identify and fill the pmts with data.
void InitSignal()
initialize the signal histo.
void FillEventPerSlice(const std::vector< dom > &domSample, const bool individualPmt, const std::vector< int > &vDomId)
fill the event per slice histo.
const std::vector< signal > GetSignal() const
get the signal measured by the pmt (see signal.h for the format)
void FillDomDeltaT(const std::vector< triggeredSignals > &vTrigger, const std::vector< int > &vDomId)
fill the time difference between all Dom neighbors
void SetRunId(const int id)
set the ID of the run
void FillSignals(const signals sig, std::vector< signals > &vSig)
Merging of the signals of all the pmts of the dom.
void FillCoincidenceRate(const std::vector< triggeredSignals > &vTrigger)
Fill the coincidence rate histo.
make the event trigger (coincidence between doms)
void InitFrequency(const std::vector< int > &vDomId)
initialize the frequency histo (depends on the pmt id).
void DrawDomDeltaT()
draw the histo
bool DoTmultiPmts(const std::vector< signals > &vSig, std::vector< triggeredSignals > &vTrig, const int coincWindow)
make the DOM trigger (coincidence between pmts)
replace drawing.h: do online histos
const int coincWindowPmts
void DrawCoincidenceRate()
draw the coincidence rate histo.
bool IsNoisySlice(const int signalNb, const double limitNb)
void DrawEventPerSlice(const bool individualPmt, double cutValues[domNb][pmtNb], const std::vector< int > &vDomId)
draw the event per slice histo.
void DrawSignal()
draw the histo
void SetDomId(const int id)
set the Id of the DOM
void FillSliceTimeSeries(const std::vector< dom > &domSample, const std::vector< int > &vDomId)
fill the slice time series histo.
long long int GetFileLength(std::ifstream &str)
void DrawFrequency()
draw the histo, one per pmt
void FillSignal(const signal &sig)
fill the histo with one signal (it can be for instance one signal of one Pmt of one DOM) ...
void InitCoincidenceRate(const std::vector< int > &vDomId)
initialize the coincidence rate histo.
void DrawPmtStats(const std::vector< dom > &domSample, const std::vector< int > &vDomId)
draw the number of signal as a function of the pmt number (for one event)
const int multiplicityForMuon
void FillDurations(const int domId, const std::vector< pmt > &pmtSample, double cutValues[domNb][pmtNb])
fill the histo with all the signal durations of a list of signal (one histo per Pmt number) ...
int FindDomIndex(const int id, const std::vector< int > &vDomId)
find the index associates to a Dom Id
void InitDomDeltaT(const std::vector< int > &vDomId)
initialize the delta T histo (time difference between doms).
void InitEventPerSlice(const bool individualPmt, const std::vector< int > &vDomId)
initialize the event per slice histo.
void InitSliceTimeSeries(const std::vector< int > &vDomId)
initialize the slice time series histo.
int main(int argc, char *argv[])
void InitDurations(const std::vector< int > &vDomId)
initialize the duration histo (depends on the pmt id).