6 from Configuration.AlCa.autoCond
import autoCond
10 from subprocess
import *
20 """ Adjust trigger content in AOD for CMSSW_5_2_X
22 _label =
'run52xOn51xTrigger'
23 _defaultParameters = dicttypes.SortedKeysDict()
26 ConfigToolBase.__init__( self )
27 self.addParameter( self.
_defaultParameters,
'sequence',
'patDefaultSequence',
"Name of sequence to use, default: 'patDefaultSequence'" )
38 self.setParameter(
'sequence', sequence )
39 return self.
apply( process )
45 process.l1L1GtObjectMap = convertObjectMapRecord.clone()
46 getattr( process, sequence ).
insert( 0, getattr( process,
'l1L1GtObjectMap' ) )
56 """ Picks up RelVal input files automatically and
57 returns a vector of strings with the paths to be used in [PoolSource].fileNames
58 PickRelValInputFiles( cmsswVersion, relVal, dataTier, condition, globalTag, maxVersions, skipFiles, numberOfFiles, debug )
59 - useDAS : switch to perform query in DAS rather than in DBS
60 optional; default: False
61 - cmsswVersion : CMSSW release to pick up the RelVal files from
62 optional; default: the current release (determined automatically from environment)
63 - formerVersion: use the last before the last valid CMSSW release to pick up the RelVal files from
64 applies also, if 'cmsswVersion' is set explicitly
65 optional; default: False
66 - relVal : RelVal sample to be used
67 optional; default: 'RelValTTbar'
68 - dataTier : data tier to be used
69 optional; default: 'GEN-SIM-RECO'
70 - condition : identifier of GlobalTag as defined in Configurations/PyReleaseValidation/python/autoCond.py
71 possibly overwritten, if 'globalTag' is set explicitly
72 optional; default: 'startup'
73 - globalTag : name of GlobalTag as it is used in the data path of the RelVals
74 optional; default: determined automatically as defined by 'condition' in Configurations/PyReleaseValidation/python/autoCond.py
75 !!! Determination is done for the release one runs in, not for the release the RelVals have been produced in.
76 !!! Example of deviation: data RelVals (CMSSW_4_1_X) might not only have the pure name of the GlobalTag 'GR_R_311_V2' in the full path,
77 but also an extension identifying the data: 'GR_R_311_V2_RelVal_wzMu2010B'
78 - maxVersions : max. versioning number of RelVal to check
80 - skipFiles : number of files to skip for a found RelVal sample
82 - numberOfFiles: number of files to pick up
83 setting it to negative values, returns all found ('skipFiles' remains active though)
85 - debug : switch to enable enhanced messages in 'stdout'
86 optional; default: False
89 _label =
'pickRelValInputFiles'
90 _defaultParameters = dicttypes.SortedKeysDict()
96 ConfigToolBase.__init__( self )
98 self.addParameter( self.
_defaultParameters,
'cmsswVersion' , os.getenv(
"CMSSW_VERSION" ) ,
'auto from environment' )
113 , cmsswVersion =
None
114 , formerVersion =
None
121 , numberOfFiles =
None
126 if cmsswVersion
is None:
128 if formerVersion
is None:
134 if condition
is None:
136 if globalTag
is None:
137 globalTag = autoCond[ condition ][ : -5 ]
138 if maxVersions
is None:
140 if skipFiles
is None:
142 if numberOfFiles
is None:
146 self.setParameter(
'useDAS' , useDAS )
147 self.setParameter(
'cmsswVersion' , cmsswVersion )
148 self.setParameter(
'formerVersion', formerVersion )
149 self.setParameter(
'relVal' , relVal )
150 self.setParameter(
'dataTier' , dataTier )
151 self.setParameter(
'condition' , condition )
152 self.setParameter(
'globalTag' , globalTag )
153 self.setParameter(
'maxVersions' , maxVersions )
154 self.setParameter(
'skipFiles' , skipFiles )
155 self.setParameter(
'numberOfFiles', numberOfFiles )
156 self.setParameter(
'debug' , debug )
160 print '%s DEBUG: Empty file list returned'%( self.
_label )
161 print ' This might be overwritten by providing input files explicitly to the source module in the main configuration file.'
165 cmsswVersion = self.
_parameters[
'cmsswVersion' ].value
166 formerVersion = self.
_parameters[
'formerVersion' ].value
171 maxVersions = self.
_parameters[
'maxVersions' ].value
173 numberOfFiles = self.
_parameters[
'numberOfFiles' ].value
181 hltPatchId =
'_hltpatch'
182 dqmPatchId =
'_dqmpatch'
186 if patchId
in cmsswVersion:
187 cmsswVersion = cmsswVersion.split( patchId )[ 0 ]
188 elif hltPatchId
in cmsswVersion:
189 cmsswVersion = cmsswVersion.split( hltPatchId )[ 0 ]
190 elif dqmPatchId
in cmsswVersion:
191 cmsswVersion = cmsswVersion.split( dqmPatchId )[ 0 ]
192 elif rootId
in cmsswVersion:
193 cmsswVersion = cmsswVersion.split( rootId )[ 0 ]
194 elif slhcId
in cmsswVersion:
195 cmsswVersion = cmsswVersion.split( slhcId )[ 0 ]
196 elif ibId
in cmsswVersion
or formerVersion:
197 outputTuple = Popen( [
'scram',
'l -c CMSSW' ], stdout = PIPE, stderr = PIPE ).
communicate()
198 if len( outputTuple[ 1 ] ) != 0:
199 print '%s INFO : SCRAM error'%( self.
_label )
201 print ' from trying to determine last valid releases before \'%s\''%( cmsswVersion )
203 print outputTuple[ 1 ]
207 versions = {
'last' :
''
210 for line
in outputTuple[ 0 ].splitlines():
211 version = line.split()[ 1 ]
212 if cmsswVersion.split( ibId )[ 0 ]
in version
or cmsswVersion.rpartition(
'_' )[ 0 ]
in version:
213 if not ( patchId
in version
or hltPatchId
in version
or dqmPatchId
in version
or slhcId
in version
or ibId
in version
or rootId
in version ):
214 versions[
'lastToLast' ] = versions[
'last' ]
215 versions[
'last' ] = version
216 if version == cmsswVersion:
221 if preId
in versions[
'lastToLast' ]
and not preId
in versions[
'last' ]
and not versions[
'last' ].endswith(
'_0' ):
222 versions[
'lastToLast' ] = versions[
'lastToLast' ].
split( preId )[ 0 ]
224 elif versions[
'last' ].endswith(
'_0' )
and not ( preId
in versions[
'lastToLast' ]
and versions[
'lastToLast' ].startswith( versions[
'last' ] ) ):
225 versions[
'lastToLast' ] =
''
226 for line
in outputTuple[ 0 ].splitlines():
227 version = line.split()[ 1 ]
228 versionParts = version.partition( preId )
229 if versionParts[ 0 ] == versions[
'last' ]
and versionParts[ 1 ] == preId:
230 versions[
'lastToLast' ] = version
231 elif versions[
'lastToLast' ] !=
'':
234 elif preId
in versions[
'last' ]
and not preId
in versions[
'lastToLast' ]
and versions[
'lastToLast' ].endswith(
'_0' ):
235 versions[
'lastToLast' ] =
''
236 cmsswVersion = versions[
'lastToLast' ]
238 cmsswVersion = versions[
'last' ]
242 print '%s DEBUG: Called with...'%( self.
_label )
243 for key
in self._parameters.keys():
244 print ' %s:\t'%( key ),
250 if key ==
'cmsswVersion' and cmsswVersion != self.
_parameters[ key ].value:
252 print ' ==> modified to last to last valid release %s (s. \'formerVersion\' parameter)'%( cmsswVersion )
254 print ' ==> modified to last valid release %s'%( cmsswVersion )
257 domain = socket.getfqdn().
split(
'.' )
259 if len( domain ) == 0:
260 print '%s INFO : Cannot determine domain of this computer'%( self.
_label )
264 elif os.uname()[0] ==
"Darwin":
265 print '%s INFO : Running on MacOSX without direct access to RelVal files.'%( self.
_label )
269 elif len( domain ) == 1:
270 print '%s INFO : Running on local host \'%s\' without direct access to RelVal files'%( self.
_label, domain[ 0 ] )
274 if not ( ( domain[ -2 ] ==
'cern' and domain[ -1 ] ==
'ch' )
or ( domain[ -2 ] ==
'fnal' and domain[ -1 ] ==
'gov' ) ):
275 print '%s INFO : Running on site \'%s.%s\' without direct access to RelVal files'%( self.
_label, domain[ -2 ], domain[ -1 ] )
279 if domain[ -2 ] ==
'cern':
280 domainSE =
'T2_CH_CERN'
281 elif domain[ -2 ] ==
'fnal':
282 domainSE =
'T1_US_FNAL_MSS'
284 print '%s DEBUG: Running at site \'%s.%s\''%( self.
_label, domain[ -2 ], domain[ -1 ] )
285 print '%s DEBUG: Looking for SE \'%s\''%( self.
_label, domainSE )
290 datasetAll =
'/%s/%s-%s-v*/%s'%( relVal, cmsswVersion, globalTag, dataTier )
293 print '%s DEBUG: Using DAS query'%( self.
_label )
294 dasLimit = numberOfFiles
297 for version
in range( maxVersions, 0, -1 ):
301 dataset =
'/%s/%s-%s-v%i/%s'%( relVal, cmsswVersion, globalTag, version, dataTier )
302 dasQuery =
'file dataset=%s | grep file.name'%( dataset )
304 print '%s DEBUG: Querying dataset \'%s\' with'%( self.
_label, dataset )
305 print ' \'%s\''%( dasQuery )
307 jsondict = das_client.get_data(
'https://cmsweb.cern.ch', dasQuery, 0, dasLimit,
False )
309 print '%s DEBUG: Received DAS JSON dictionary:'%( self.
_label )
310 print ' \'%s\''%( jsondict )
311 if jsondict[
'status' ] !=
'ok':
312 print 'There was a problem while querying DAS with query \'%s\'. Server reply was:\n %s' % (dasQuery, jsondict)
314 mongo_query = jsondict[
'mongo_query' ]
315 filters = mongo_query[
'filters' ]
316 data = jsondict[
'data' ]
318 print '%s DEBUG: Query in JSON dictionary:'%( self.
_label )
319 print ' \'%s\''%( mongo_query )
320 print '%s DEBUG: Filters in query:'%( self.
_label )
321 print ' \'%s\''%( filters )
322 print '%s DEBUG: Data in JSON dictionary:'%( self.
_label )
323 print ' \'%s\''%( data )
325 filePath = [ r
for r
in das_client.get_value( row, filters[
'grep' ] ) ][ 0 ]
327 print '%s DEBUG: Testing file entry \'%s\''%( self.
_label, filePath )
328 if len( filePath ) > 0:
329 if validVersion != version:
330 jsontestdict = das_client.get_data(
'https://cmsweb.cern.ch',
'site dataset=%s | grep site.name'%( dataset ), 0, 999,
False )
331 mongo_testquery = jsontestdict[
'mongo_query' ]
332 testfilters = mongo_testquery[
'filters' ]
333 testdata = jsontestdict[
'data' ]
335 print '%s DEBUG: Received DAS JSON dictionary (site test):'%( self.
_label )
336 print ' \'%s\''%( jsontestdict )
337 print '%s DEBUG: Query in JSON dictionary (site test):'%( self.
_label )
338 print ' \'%s\''%( mongo_testquery )
339 print '%s DEBUG: Filters in query (site test):'%( self.
_label )
340 print ' \'%s\''%( testfilters )
341 print '%s DEBUG: Data in JSON dictionary (site test):'%( self.
_label )
342 print ' \'%s\''%( testdata )
344 for testrow
in testdata:
345 siteName = [ tr
for tr
in das_client.get_value( testrow, testfilters[
'grep' ] ) ][ 0 ]
346 if siteName == domainSE:
351 print '%s DEBUG: Possible version \'v%s\' not available on SE \'%s\''%( self.
_label, version, domainSE )
353 validVersion = version
355 print '%s DEBUG: Valid version set to \'v%i\''%( self.
_label, validVersion )
356 if numberOfFiles == 0:
359 if not filePath
in filePathsTmp:
360 filePathsTmp.append( filePath )
362 print '%s DEBUG: File \'%s\' found'%( self.
_label, filePath )
365 if fileCount > skipFiles:
366 filePaths.append( filePath )
368 print '%s DEBUG: File \'%s\' found again'%( self.
_label, filePath )
370 if numberOfFiles == 0
and debug:
371 print '%s DEBUG: No files requested'%( self.
_label )
375 print '%s DEBUG: Using DBS query'%( self.
_label )
376 print '%s WARNING: DBS query disabled for DBS3 transition to new API'%( self.
_label )
422 if validVersion == 0:
423 print '%s WARNING : No RelVal file(s) found at all in datasets \'%s*\' on SE \'%s\''%( self.
_label, datasetAll, domainSE )
426 elif len( filePaths ) == 0:
427 print '%s WARNING : No RelVal file(s) picked up in dataset \'%s\''%( self.
_label, dataset )
430 elif len( filePaths ) < numberOfFiles:
431 print '%s INFO : Only %i RelVal file(s) instead of %i picked up in dataset \'%s\''%( self.
_label, len( filePaths ), numberOfFiles, dataset )
434 print '%s DEBUG: returning %i file(s):\n%s'%( self.
_label, len( filePaths ), filePaths )
static void * communicate(void *obj)
bool insert(Storage &, ItemType *, const IdTag &)