Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JDarkroomNB.cc File Reference
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include "TH1D.h"
#include "TH2D.h"
#include "km3net-dataformat/online/JDAQ.hh"
#include "km3net-dataformat/online/JDAQTimeslice.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTriggeredHitIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JROOT/JManager.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JTrigger/JSuperFrame2D.hh"
#include "JTrigger/JHitR0.hh"
#include "JTrigger/JHitL0.hh"
#include "JTrigger/JHitToolkit.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JTrigger/JTimesliceRouter.hh"
#include "Jeep/JParser.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 45 of file JDarkroomNB.cc.

45 {
46
48 string detectorFile;
50 string outFile;
51 double frequency;
52 int PMTSelector;
53 int Stagger;
54
55 try {
56 JParser<> zap;
57
58 zap['f'] = make_field(inputFiles );
59 zap['a'] = make_field(detectorFile );
60 zap['o'] = make_field(outFile ); //outfile
61 zap['H'] = make_field(frequency ); //flashing frequency in kHz
62 zap['P'] = make_field(PMTSelector ) = 0; //Select a PMT to analyze
63 zap['S'] = make_field(Stagger ) = 3520; //Currently this is the stagger offset used
64
65 zap(argc,argv);
66 }
67 catch(const exception &error) {
68 ERROR(error.what() << endl);
69 }
70
71 load(detectorFile, detector);
72 JModuleRouter moduleRouter(detector);
73
74 JTriggerParameters triggerParameters;
75
76 int pulse_period = 1e9/(frequency*1e3); //pulse period in ns and frequency in kHz
77
78 JManager < string, TH2F >* Pulses; //time on x-axis and ToT on y axis
79 Pulses = new JManager < string, TH2F > ( new TH2F("%", "", Stagger, -0.5, Stagger-0.5, 256, -0.5, 255.5) );
80
81 while( inputFiles.hasNext() ) {
82
83 JDAQTimesliceL0 slice = *(inputFiles.next());
84 JTimesliceRouter timesliceRouter(triggerParameters.numberOfBins);
85
86 timesliceRouter.configure(slice);
87
88 for(JDetector::iterator module = detector.begin(); module != detector.end(); ++module){
89
90 int String = module->getString();
91 int Floor = module->getFloor();
92
93 if(timesliceRouter.hasSuperFrame( module->getID() )){
94 JDAQSuperFrame SuperFrame = timesliceRouter.getSuperFrame( module->getID() );
95 for(JDAQSuperFrame::const_iterator hit = SuperFrame.begin(); hit != SuperFrame.end(); ++hit){
96 int PMT = static_cast<int>(hit->getPMT());
97 if(PMT == PMTSelector){
98 double raw_time = hit->getT();
99 double time = raw_time - pulse_period * int(raw_time/pulse_period) - Stagger*(Floor - 1);
100 double ToT = hit->getToT();
101 (*Pulses)[ MAKE_STRING( "S"+to_string(String)+"F"+to_string(Floor) ).c_str() ]->Fill(time,ToT);
102 }
103 }
104 }
105 }
106 }
107
108 cout << " Writing histograms to output" << endl;
109 TFile output(outFile.c_str() , "recreate") ;
110 Pulses -> Write(output);
111
112}
JDAQPMTIdentifier PMT
Command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2140
#define MAKE_STRING(A)
Make string.
Definition JPrint.hh:48
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
Utility class to parse command line options.
Definition JParser.hh:1697
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
const_iterator end() const
Definition JDAQFrame.hh:166
const_iterator begin() const
Definition JDAQFrame.hh:165
Hit data structure.
Definition JDAQHit.hh:35
Data frame of one optical module.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
std::string to_string(const T &value)
Convert value to string.
General purpose string class.
Definition JHead.hh:152
Detector file.
Definition JHead.hh:227
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
Timeslice data structure for L0 data.