Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDarkroomNB.cc
Go to the documentation of this file.
1 // c++ standard library
2 #include <string>
3 #include <iostream>
4 #include <sstream>
5 #include <iomanip>
6 #include <cmath>
7 
8 // JPP
9 #include "Jeep/JParser.hh"
12 
13 #include "JDAQ/JDAQEventIO.hh"
15 #include "JDAQ/JDAQTimesliceIO.hh"
17 #include "JROOT/JManager.hh"
18 
20 #include "JSupport/JSupport.hh"
21 #include "JDetector/JDetector.hh"
25 #include "JTrigger/JHitR0.hh"
26 #include "JTrigger/JHitL0.hh"
27 #include "JTrigger/JHitToolkit.hh"
30 
31 // root
32 #include "TH1D.h"
33 #include "TH2D.h"
34 
35 // namespaces
36 using namespace std;
37 using namespace KM3NETDAQ ; // for JDAQTimeSlice
38 using namespace JSUPPORT; // for JFileScanner
39 using namespace JLANG; // for JMultipleFileScanner
40 using namespace JDETECTOR ;
41 using namespace JPP ;
42 
43 int main(int argc , char** argv){
44 
46  string detectorFile;
48  string outFile;
49  double frequency;
50  int PMTSelector;
51  int Stagger;
52 
53  try {
54  JParser<> zap;
55 
56  zap['f'] = make_field(inputFiles );
57  zap['a'] = make_field(detectorFile );
58  zap['o'] = make_field(outFile ); //outfile
59  zap['H'] = make_field(frequency ); //flashing frequency in kHz
60  zap['P'] = make_field(PMTSelector ) = 0; //Select a PMT to analyze
61  zap['S'] = make_field(Stagger ) = 3520; //Currently this is the stagger offset used
62 
63  zap(argc,argv);
64  }
65  catch(const exception &error) {
66  ERROR(error.what() << endl);
67  }
68 
69  load(detectorFile, detector);
70  JModuleRouter moduleRouter(detector);
71 
73 
74  int pulse_period = 1e9/(frequency*1e3); //pulse period in ns and frequency in kHz
75 
76  JManager < string, TH2F >* Pulses; //time on x-axis and ToT on y axis
77  Pulses = new JManager < string, TH2F > ( new TH2F("%", "", Stagger, -0.5, Stagger-0.5, 256, -0.5, 255.5) );
78 
79  while( inputFiles.hasNext() ) {
80 
81  JDAQTimesliceL0 slice = *(inputFiles.next());
82  JTimesliceRouter timesliceRouter(triggerParameters.numberOfBins);
83 
84  timesliceRouter.configure(slice);
85 
86  for(JDetector::iterator module = detector.begin(); module != detector.end(); ++module){
87 
88  int String = module->getString();
89  int Floor = module->getFloor();
90 
91  if(timesliceRouter.hasSuperFrame( module->getID() )){
92  JDAQSuperFrame SuperFrame = timesliceRouter.getSuperFrame( module->getID() );
93  for(JDAQSuperFrame::const_iterator hit = SuperFrame.begin(); hit != SuperFrame.end(); ++hit){
94  int PMT = static_cast<int>(hit->getPMT());
95  if(PMT == PMTSelector){
96  double raw_time = hit->getT();
97  double time = raw_time - pulse_period * int(raw_time/pulse_period) - Stagger*(Floor - 1);
98  double ToT = hit->getToT();
99  (*Pulses)[ MAKE_STRING( "S"+to_string(String)+"F"+to_string(Floor) ).c_str() ]->Fill(time,ToT);
100  }
101  }
102  }
103  }
104  }
105 
106  cout << " Writing histograms to output" << endl;
107  TFile output(outFile.c_str() , "recreate") ;
108  Pulses -> Write(output);
109 
110 }
const JDAQSuperFrame & getSuperFrame(const JDAQModuleIdentifier &module) const
Get super frame.
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Basic data structure for L0 hit.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
static const JPBS_t PMT(3, 4, 2, 3)
PBS of photo-multiplier tube (PMT)
Detector data structure.
Definition: JDetector.hh:89
void configure(const JDAQTimeslice &timeslice)
Configure.
bool hasSuperFrame(const JDAQModuleIdentifier &module) const
Check presence of module.
Router for direct addressing of module data in detector data structure.
Dynamic ROOT object management.
Data structure for detector geometry and calibration.
Tools for handling different hit types.
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:142
Basic data structure for L0 hit.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
virtual bool hasNext() override
Check availability of next element.
Hit data structure.
Definition: JDAQHit.hh:34
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
const_iterator begin() const
Definition: JDAQFrame.hh:164
#define ERROR(A)
Definition: JMessage.hh:66
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to module in detector data structure.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
General purpose string class.
Definition: JHead.hh:150
std::string to_string(const T &value)
Convert value to string.
virtual const pointer_type & next() override
Get next element.
do set_variable DETECTOR_TXT $WORKDIR detector
KM3NeT DAQ constants, bit handling, etc.
triggerParameters
Data frame of one optical module.
Timeslice data structure for L0 data.
const_iterator end() const
Definition: JDAQFrame.hh:165