BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
add_GEM_pedestals.C
Go to the documentation of this file.
1// macro for adding parameter value (if parameter exist - you could check existing parameters by
2// 'UniParameter::PrintAll()' function)
3void ReadAndPut(TString fName, vector<UniValue*>& pValues);
5
6void AssignMapStructure(vector<UniValue*>& pArray, unsigned int ser, int ch, double ped, double noise)
7{
9 pValue->serial = ser;
10 pValue->channel = ch;
11 pValue->pedestal = ped;
12 pValue->noise = noise;
13
14 pArray.push_back(pValue);
15}
16
18{
19 bool return_error = false;
20
21 // UniParameter::CreateParameter("GEM_pedestal", GemPedestalType);
22 // UniParameter::CreateParameter("GEM_size_ped_map", IntType);
23
24 TString path = TString(getenv("VMCWORKDIR")) + TString("/input/");
25 Int_t size = CalcSize(path + TString("GEM_pedestals.txt"));
26 vector<UniValue*> Ped;
27 ReadAndPut(path + TString("GEM_pedestals.txt"), Ped);
28
29 IntValue iValue;
30 iValue.value = size;
31 UniDetectorParameter::CreateDetectorParameter("GEM", "GEM_size_ped_map", 4, 61, 4, 84, &iValue);
32 UniDetectorParameter::CreateDetectorParameter("GEM", "GEM_pedestal", 4, 61, 4, 84, Ped);
33
34 // clean memory after work
35 for (int i = 0; i < Ped.size(); i++)
36 delete Ped[i];
37
38 if (return_error)
39 cout << "\nMacro finished with errors" << endl;
40 else
41 cout << "\nMacro finished successfully" << endl;
42}
43
45{
46 TString dummy;
47 ifstream inFile(fName.Data());
48 if (!inFile.is_open())
49 cout << "Error opening map-file (" << fName << ")!" << endl;
50 inFile >> dummy >> dummy >> dummy >> dummy;
51 inFile >> dummy;
52
53 Int_t i = 0;
54 while (inFile >> dummy >> dummy >> dummy >> dummy)
55 i++;
56
57 inFile.close();
58 return i;
59}
60
61void ReadAndPut(TString fName, vector<UniValue*>& pValues)
62{
63 UInt_t ser = 0;
64 Int_t ch = 0;
65 double ped = 0;
66 double rms = 0;
67 TString dummy;
68 ifstream inFile(fName.Data());
69 if (!inFile.is_open())
70 cout << "Error opening map-file (" << fName << ")!" << endl;
71 inFile >> dummy >> dummy >> dummy >> dummy;
72 inFile >> dummy;
73
74 while (inFile >> std::hex >> ser >> std::dec >> ch >> ped >> rms)
75 AssignMapStructure(pValues, ser, ch, ped, rms);
76}
int i
Definition P4_F32vec4.h:22
int Int_t
unsigned int UInt_t
void AssignMapStructure(vector< UniValue * > &pArray, unsigned int ser, int ch, double ped, double noise)
void ReadAndPut(TString fName, vector< UniValue * > &pValues)
Int_t CalcSize(TString fName)
void add_GEM_pedestals()
const char * Data() const
static UniDetectorParameter * CreateDetectorParameter(TString detector_name, int parameter_id, int start_period, int start_run, int end_period, int end_run, int value_key, unsigned char *parameter_value, Long_t size_parameter_value, TDatime *expiry_date)
add new detector parameter to the database