BmnRoot
Loading...
Searching...
No Matches
BmnTof1Raw2Digit.h
Go to the documentation of this file.
1#ifndef BMNTOF1RAW2DIGIT_H
2#define BMNTOF1RAW2DIGIT_H
3
4#include "BmnMath.h"
5#include "BmnTDCDigit.h"
6#include "BmnTof1Digit.h"
7#include "Riostream.h"
8#include "TClonesArray.h"
9#include "TString.h"
10
11#include <UniDetectorParameter.h>
12#include <cstdlib>
13#include <fstream>
14#include <iostream>
15#include <map>
16#include <set>
17#include <sstream>
18#include <string>
19#include <unordered_map>
20#include <utility>
21
22// Side of the strip is stored as a bool variable
23#define TOF1_LEFT true
24#define TOF1_RIGHT false
25
26#define TOF1_CHANNEL_NUMBER 72
27#define TOF1_BIN_NUMBER 1024
28#define TOF1_MAX_TIME (24.) // In ns
29#define TOF1_TDC_TYPE (0x12) // TDC72VHL
30#define TOF1_TDCVXS_TYPE (0xD0) // TDC72VXS
31
32// A simple class to compare the TDCDigits. See .cxx code
34{
35 bool operator()(const BmnTDCDigit& a, const BmnTDCDigit& b) const;
36};
37
38// Map element
40{
41 Short_t plane;
42 Short_t strip;
43 Bool_t side;
44 BmnTof1Map2(Short_t, Short_t, Bool_t);
46};
47
48// TDC parameters
50{
52 BmnTof1Map2 ChannelMap[TOF1_CHANNEL_NUMBER]; // A BmnTof1Map2 for every channel
53 double t[TOF1_CHANNEL_NUMBER]; // To store the value temporarily. See .cxx code
54 BmnTof1TDCParameters(); // Simple constructor
55};
56
58{
59 public:
60 BmnTof1Raw2Digit(); // BmnTof1Raw2Digit main constructor
61 BmnTof1Raw2Digit(Int_t nPeriod, Int_t nRun, Int_t verbose); // Calls setRun(...)
62 virtual ~BmnTof1Raw2Digit(); // Destructor
63
64 Bool_t setRun(Int_t nPerion, Int_t nRun); // Load mapping and INL from the DB for run #nRun in period #nPeriod
65 Bool_t setMapFromFile(TString placementMapFile, TString mapFile); // Load mapping from two files
66 void saveMapToFile(std::string placementMapFile, std::string mapFile); // Save the mapping to two files
67
68 void setINLFromFile(std::string INLFile); // Load INL from an INI file
69 void saveINLToFile(std::string INLFile, unsigned int TDCSerial); // Save INL for TDCSerial to an INI file
70
71 void print() {} // Prints some info
72 void setVerbose(Int_t verbose) { fVerbose = verbose; }
73
74 void FillEvent(TClonesArray* data, unordered_map<UInt_t, Long64_t>* mapTS, TClonesArray* tof1digit); //
75
76 static UShort_t ToGlobalChannel(UChar_t HptdcId, UChar_t channel);
77
78 private:
79 ClassDef(BmnTof1Raw2Digit, 1);
80 void init(); // BmnTof1Raw2Digit init function (called in BmnTof1Raw2Digit constructors)
81 Int_t RunIndex, PeriodIndex, fVerbose; // To store the RunIndex and PeriodIndex and print level
82 UInt_t fSerialForTS;
83 std::map<std::pair<UInt_t, UChar_t>, UInt_t> PlacementMap; // Stores the placement map
84 std::map<UInt_t, BmnTof1TDCParameters>
85 TDCMap; // Stores the TDC mapping (TDC's channel -> plane/strip/side) and INL
86 void plmap_insert(UInt_t Serial, UChar_t Slot, UInt_t TDCSerial); // See .cxx code
87
88 // std::map provides a way to find TDC by Serial and Slot really fast (O(logN))
89 // BmnTof1Parameters could also be found so fast (O(logN))
90 // All other operations (extracting the INL, for example) are already fast because of the structure - O(1)
91};
92#endif /* BMNTOF1RAW2DIGIT_H */
void setVerbose(Int_t verbose)
Bool_t setRun(Int_t nPerion, Int_t nRun)
void saveINLToFile(std::string INLFile, unsigned int TDCSerial)
static UShort_t ToGlobalChannel(UChar_t HptdcId, UChar_t channel)
Bool_t setMapFromFile(TString placementMapFile, TString mapFile)
void setINLFromFile(std::string INLFile)
void FillEvent(TClonesArray *data, unordered_map< UInt_t, Long64_t > *mapTS, TClonesArray *tof1digit)
void saveMapToFile(std::string placementMapFile, std::string mapFile)
#define TOF1_CHANNEL_NUMBER
#define TOF1_BIN_NUMBER
BmnTof1Map2 ChannelMap[TOF1_CHANNEL_NUMBER]
double t[TOF1_CHANNEL_NUMBER]
double INL[TOF1_CHANNEL_NUMBER][TOF1_BIN_NUMBER]
bool operator()(const BmnTDCDigit &a, const BmnTDCDigit &b) const