13os.environ[
'TERM'] =
'linux'
16 print (
"Usage: ",sys.argv[0],
" [OPTION] ... ")
17 print (
"Prepare sqlite file with Lumi values for CALO database")
19 print (
"-h, --help shows this help")
20 print (
"-i, --inschema= specify name of input JSON file or CREST_SERVER_PATH")
21 print (
"-o, --outschema= specify name of output JSON file, default is CaloNoise.json")
22 print (
"-t, --tag= specify the tag")
23 print (
"-f, --folder= specify folder to use e.g. /CALO/Ofl/Noise/PileUpNoiseLumi ")
24 print (
"-x, --txtfile= specify the text file with the new noise constants")
25 print (
"-v, --value= specify new lumi value")
26 print (
"-V, --value2= specify new valid flag")
27 print (
"-c, --channel= specify COOL channel, by default COOL channels 0 and 1 are used")
28 print (
"-r, --run= specify run number for start of IOV")
29 print (
"-l, --lumi= specify lumiblock number for start of IOV, default is 0")
31letters =
"hi:o:t:f:x:v:V:c:r:l:u"
32keywords = [
"help",
"inschema=",
"outschema=",
"tag=",
"folder=",
"txtfile=",
"value=",
"value2=",
"channel=",
"run=",
"lumi=",
"update",
"infile=",
"outfile="]
35 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
36except getopt.GetoptError
as err:
43outSchema =
'PileUp.json'
44folderPath =
'/CALO/Ofl/Noise/PileUpNoiseLumi'
56 if o
in (
"-i",
"--inschema",
"--infile"):
58 elif o
in (
"-o",
"--outschema",
"--outfile"):
60 elif o
in (
"-t",
"--tag"):
62 elif o
in (
"-f",
"--folder"):
64 elif o
in (
"-c",
"--channel"):
66 elif o
in (
"-r",
"--run"):
68 elif o
in (
"-l",
"--lumi"):
70 elif o
in (
"-u",
"--update"):
72 elif o
in (
"-x",
"--txtfile"):
74 elif o
in (
"-v",
"--value"):
76 elif o
in (
"-V",
"--value2"):
78 elif o
in (
"-h",
"--help"):
88inputIsFile = os.path.isfile(inSchema)
89tagIsFullTag = tag.upper().startswith(
'CALO')
91 print(
"Please, provide inschema (e.g. --inschema=PileUp.json or --inschema=CREST)")
94 print(
"Please, provide outschema (e.g. --outschema=PileUp.json)")
97 if len(folderPath)<1
and not tagIsFullTag:
98 print(
"Please, provide folder (e.g. --folder=/CALO/Ofl/Noise/PileUpNoiseLumi)")
101 print(
"Please, provide tag (e.g. --tag=RUN2-UPD4-05 or --tag=CALOOflNoisePileUpNoiseLumi-RUN2-UPD4-05)")
105 print(
"Please, provide full tag (e.g. --tag=CALOOflNoisePileUpNoiseLumi-RUN2-UPD4-05)")
109 print(
"Please, provide run number (e.g. --run=123456)")
112from TileCalibBlobPython
import TileCalibCrest
113from TileCalibBlobPython.TileCalibLogger
import getLogger
116log = getLogger(
"WriteLumi")
118log.setLevel(logging.DEBUG)
125 log.info(
"Initializing folder %s with tag %s", folder, tag)
126reader = TileCalibCrest.TileBlobReaderCrest(inSchema,folder,tag,run,lumi,channels[0],channels[-1],
True)
127obj = reader.getPayload(
None,
False)
129 log.critical(
"Could not read payload from CREST DB")
132 tag = reader.getTag()
136 if value
is not None:
137 obj[str(chan)][0] = value
138 if value2
is not None:
139 obj[str(chan)][1] = value2
141 log.critical(f
"Can not set values for channel {chan}")
142 log.critical(
"Full payload is: "+str(obj))
147 with open(txtFile,
"r")
as f:
148 allData = f.readlines()
150 print(
"\nCan not read input file %s" % (txtFile))
158 if fields[0].startswith(
"#"):
162 for chan
in (channels
if ch<0
else [ch]):
163 if len(fields)>1
and fields[1].lower() !=
"keep":
164 obj[str(chan)][0] = float(fields[1])
165 if len(fields)>2
and fields[2].lower() !=
"keep":
166 obj[str(chan)][1] = int(fields[2])
168 log.error(f
"Can not process line {line} - skipping")
170log.info(
"Writing payload "+str(obj) )
171writer = TileCalibCrest.TileBlobWriterCrest(outSchema,folder,
None,obj)
172writer.register((run,lumi), tag)
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")