~ma5dev/madanalysis5/v1.5beta

« back to all changes in this revision

Viewing changes to tools/ReportGenerator/Core/job_reader.py

  • Committer: Eric Conte
  • Date: 2016-12-08 10:28:55 UTC
  • Revision ID: eric.conte@cern.ch-20161208102855-thahw9h2be839yu6
update all-file with MA5banner + logging.getLogger(MA5)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
################################################################################
2
2
#  
3
 
#  Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks
 
3
#  Copyright (C) 2012-2016 Eric Conte, Benjamin Fuks
4
4
#  The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
5
5
#  
6
6
#  This file is part of MadAnalysis 5.
44
44
 
45
45
    def CheckDir(self):
46
46
        if not os.path.isdir(self.path):
47
 
            logging.error("Directory called '"+self.path+"' is not found.")
 
47
            logging.getLogger('MA5').error("Directory called '"+self.path+"' is not found.")
48
48
            return False
49
49
        elif not os.path.isdir(self.safdir):
50
 
            logging.error("Directory called '"+self.safdir+"' is not found.")
 
50
            logging.getLogger('MA5').error("Directory called '"+self.safdir+"' is not found.")
51
51
            return False
52
52
        else:
53
53
            return True
57
57
        if os.path.isfile(self.safdir+"/"+name+"/MadAnalysis5job.saf"):
58
58
            return True
59
59
        else:
60
 
            logging.error("File called '"+self.safdir+"/"+name+".saf' is not found.")
 
60
            logging.getLogger('MA5').error("File called '"+self.safdir+"/"+name+".saf' is not found.")
61
61
            return False
62
62
 
63
63
 
70
70
        try:
71
71
            results.xsection=float(words[0])
72
72
        except:
73
 
            logging.error("xsection is not a float value:"+\
 
73
            logging.getLogger('MA5').error("xsection is not a float value:"+\
74
74
                          words[0])
75
75
 
76
76
        # Extracting xsection error
77
77
        try:
78
78
            results.xerror=float(words[1])
79
79
        except:
80
 
            logging.error("xsection_error is not a float value:"+\
 
80
            logging.getLogger('MA5').error("xsection_error is not a float value:"+\
81
81
                          words[1])
82
82
 
83
83
        # Extracting number of events
84
84
        try:
85
85
            results.nevents=int(words[2])
86
86
        except:
87
 
            logging.error("nevents is not an integer value:"+\
 
87
            logging.getLogger('MA5').error("nevents is not an integer value:"+\
88
88
                          words[2])
89
89
 
90
90
        # Extracting sum positive weights
91
91
        try:
92
92
            results.sumw_positive=float(words[3])
93
93
        except:
94
 
            logging.error("sum_weight+ is not a float value:"+\
 
94
            logging.getLogger('MA5').error("sum_weight+ is not a float value:"+\
95
95
                          words[3])
96
96
 
97
97
        # Extracting sum negative weights
98
98
        try:
99
99
            results.sumw_negative=float(words[4])
100
100
        except:
101
 
            logging.error("sum_weight- is not a float value:"+\
 
101
            logging.getLogger('MA5').error("sum_weight- is not a float value:"+\
102
102
                          words[4])
103
103
 
104
104
        return results
110
110
        try:
111
111
            a=float(words[0])
112
112
        except:
113
 
            logging.error("Counter is not a float value:"+words[0])
 
113
            logging.getLogger('MA5').error("Counter is not a float value:"+words[0])
114
114
 
115
115
        # Extracting xsection error
116
116
        try:
117
117
            b=float(words[1])
118
118
        except:
119
 
            logging.error("Counter is not a float value:"+words[1])
 
119
            logging.getLogger('MA5').error("Counter is not a float value:"+words[1])
120
120
 
121
121
        # Returning exracting values
122
122
        return [a,b]
129
129
        try:
130
130
            a=int(words[0])
131
131
        except:
132
 
            logging.error("nbin is not a int value:"+words[0])
 
132
            logging.getLogger('MA5').error("nbin is not a int value:"+words[0])
133
133
 
134
134
        # Extracting xmin
135
135
        try:
136
136
            b=float(words[1])
137
137
        except:
138
 
            logging.error("xmin is not a float value:"+words[1])
 
138
            logging.getLogger('MA5').error("xmin is not a float value:"+words[1])
139
139
 
140
140
        # Extracting xmax
141
141
        try:
142
142
            c=float(words[2])
143
143
        except:
144
 
            logging.error("xmax is not a float value:"+words[2])
 
144
            logging.getLogger('MA5').error("xmax is not a float value:"+words[2])
145
145
 
146
146
        # Returning exracting values
147
147
        return [a,b,c]
153
153
        try:
154
154
            a=int(words[0])
155
155
        except:
156
 
            logging.error(str(words[0])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
 
156
            logging.getLogger('MA5').error(str(words[0])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
157
157
            a=0
158
158
        if a<0:
159
 
            logging.error(str(words[0])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
 
159
            logging.getLogger('MA5').error(str(words[0])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
160
160
            a=0
161
161
 
162
162
        # Extracting negative
163
163
        try:
164
164
            b=int(words[1])
165
165
        except:
166
 
            logging.error(str(words[1])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
 
166
            logging.getLogger('MA5').error(str(words[1])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
167
167
            b=0
168
168
        if b<0:
169
 
            logging.error(str(words[1])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
 
169
            logging.getLogger('MA5').error(str(words[1])+' must be a positive integer value @ "'+filename+'" line='+str(numline))
170
170
            b=0
171
171
 
172
172
        # Returning exracting values
179
179
        try:
180
180
            a=float(words[0])
181
181
        except:
182
 
            logging.error(str(words[0])+' must be a float value @ "'+filename+'" line='+str(numline))
 
182
            logging.getLogger('MA5').error(str(words[0])+' must be a float value @ "'+filename+'" line='+str(numline))
183
183
            a=0.
184
184
 
185
185
        # Extracting negative
186
186
        try:
187
187
            b=float(words[1])
188
188
        except:
189
 
            logging.error(str(words[1])+' must be a float value @ "'+filename+'" line='+str(numline))
 
189
            logging.getLogger('MA5').error(str(words[1])+' must be a float value @ "'+filename+'" line='+str(numline))
190
190
            b=0.
191
191
 
192
192
        # Returning exracting values
199
199
        try:
200
200
            a=int(words[0])
201
201
        except:
202
 
            logging.error(str(words[0])+' must be an integer value @ "'+filename+'" line='+str(numline))
 
202
            logging.getLogger('MA5').error(str(words[0])+' must be an integer value @ "'+filename+'" line='+str(numline))
203
203
            a=0.
204
204
 
205
205
        # Extracting positive
206
206
        try:
207
207
            b=float(words[1])
208
208
        except:
209
 
            logging.error(str(words[1])+' must be a float value @ "'+filename+'" line='+str(numline))
 
209
            logging.getLogger('MA5').error(str(words[1])+' must be a float value @ "'+filename+'" line='+str(numline))
210
210
            b=0.
211
211
 
212
212
        # Extracting negative
213
213
        try:
214
214
            c=float(words[2])
215
215
        except:
216
 
            logging.error(str(words[2])+' must be a float value @ "'+filename+'" line='+str(numline))
 
216
            logging.getLogger('MA5').error(str(words[2])+' must be a float value @ "'+filename+'" line='+str(numline))
217
217
            c=0.
218
218
 
219
219
        # Returning exracting values
240
240
        try:
241
241
            file = open(filename,'r')
242
242
        except:
243
 
            logging.error("File called '"+filename+"' is not found")
 
243
            logging.getLogger('MA5').error("File called '"+filename+"' is not found")
244
244
            return
245
245
 
246
246
        # Initializing tags
397
397
                    cut.initial.sumw2_pos = results[0]
398
398
                    cut.initial.sumw2_neg = results[1]
399
399
                else:
400
 
                    logging.warning('Extra line is found: '+line)
 
400
                    logging.getLogger('MA5').warning('Extra line is found: '+line)
401
401
                initialTag.newline()
402
402
 
403
403
            # Looking for cut counter
414
414
                    cutinfo.sumw2_pos = results[0]
415
415
                    cutinfo.sumw2_neg = results[1]
416
416
                else:
417
 
                    logging.warning('Extra line is found: '+line)
 
417
                    logging.getLogger('MA5').warning('Extra line is found: '+line)
418
418
                cutTag.newline()    
419
419
 
420
420
            # Looking from histogram description
430
430
                        elif histoFreqTag.activated:
431
431
                            histofreqinfo.name=myname
432
432
                    else:
433
 
                        logging.error('invalid name for histogram @ line=' + str(numline) +' : ')
434
 
                        logging.error(str(line))
 
433
                        logging.getLogger('MA5').error('invalid name for histogram @ line=' + str(numline) +' : ')
 
434
                        logging.getLogger('MA5').error(str(line))
435
435
                elif descriptionTag.Nlines==1 and not histoFreqTag.activated and \
436
436
                     len(words)==3:
437
437
                    results = self.ExtractDescription(words,numline,filename)
444
444
                        histologxinfo.xmin=results[1]
445
445
                        histologxinfo.xmax=results[2]
446
446
                else:
447
 
                    logging.warning('Extra line is found: '+line)
 
447
                    logging.getLogger('MA5').warning('Extra line is found: '+line)
448
448
                descriptionTag.newline()    
449
449
 
450
450
            # Looking from histogram statistics
527
527
                        histologxinfo.negative.sumw2x=results[1]
528
528
 
529
529
                else:
530
 
                    logging.warning('Extra line is found: '+line)
 
530
                    logging.getLogger('MA5').warning('Extra line is found: '+line)
531
531
                statisticsTag.newline()    
532
532
 
533
533
            # Looking from histogram data [ histo and histoLogX ]
554
554
                        data_positive.append(results[0])
555
555
                        data_negative.append(results[1])
556
556
                else:
557
 
                    logging.warning('Extra line is found: '+line)
 
557
                    logging.getLogger('MA5').warning('Extra line is found: '+line)
558
558
                dataTag.newline()    
559
559
 
560
560
            # Looking from histogram data [ histoFreq ]
570
570
            
571
571
        # Information found ?
572
572
        if beginTag.Nactivated==0 or beginTag.activated:
573
 
            logging.error("SAF header <SAFheader> and </SAFheader> is not "+\
 
573
            logging.getLogger('MA5').error("SAF header <SAFheader> and </SAFheader> is not "+\
574
574
                          "found.")
575
575
        if endTag.Nactivated==0 or endTag.activated:
576
 
            logging.error("SAF footer <SAFfooter> and </SAFfooter> is not "+\
 
576
            logging.getLogger('MA5').error("SAF footer <SAFfooter> and </SAFfooter> is not "+\
577
577
                          "found.")
578
578
        if globalTag.Nactivated==0 or globalTag.activated:
579
 
            logging.error("Information corresponding to the block "+\
 
579
            logging.getLogger('MA5').error("Information corresponding to the block "+\
580
580
                          "<SampleGlobalInfo> is not found.")
581
 
            logging.error("Information on the dataset '"+dataset.name+\
 
581
            logging.getLogger('MA5').error("Information on the dataset '"+dataset.name+\
582
582
                          "' are not updated.")
583
583
        if detailTag.Nactivated==0 or globalTag.activated:
584
 
            logging.error("Information corresponding to the block "+\
 
584
            logging.getLogger('MA5').error("Information corresponding to the block "+\
585
585
                          "<SampleDetailInfo> is not found.")
586
 
            logging.error("Information on the dataset '"+dataset.name+\
 
586
            logging.getLogger('MA5').error("Information on the dataset '"+dataset.name+\
587
587
                          "' are not updated.")
588
588
            
589
589
        # Closing the file