NtupleWriter13/NtupleWriter13-00-01-00/run/AANtupleWriter13.py

00001 ##############################
00002 #
00003 # Author: MDT group, MPI Munich
00004 #
00005 #    run with: athena  -c 'jetcontainer = "Cone4H1Topo" ; dataset = "5333" ; outputdir = "/.at/mdtraid06/mgroh"' AANtupleWriter13.py
00006 #
00007 #    for a more detailed description please see at the end of this file
00008 #
00009 ##############################
00010 
00011 # if values are not given as an argument
00012 # run with default values:
00013 
00014 sys.path.append('data')
00015 import datatools
00016 import datetime
00017 
00018 #check command line and set default values
00019 if not 'dataset' in dir():
00020    dataset = "default"
00021 
00022 if not 'outputdir' in dir():
00023    outputdir = ""
00024 
00025 if not 'AtlFastFlag' in dir():
00026    AtlFastFlag = False;
00027    if (dataset.lower().find('atlfast') != -1):
00028       AtlFastFlag = True;
00029 
00030 if not 'doAODFix1mm' in dir():
00031    doAODFix1mm = False;
00032 
00033 if not 'doEventWeight' in dir():
00034    doEventWeight = True;
00035    if (dataset.lower().find('sherpa') != -1):
00036       doEventWeight = False;
00037 
00038 if not 'filenumber' in dir() or filenumber < 0:
00039    filenumber = 0;
00040    
00041 if not 'jetcontainer' in dir():
00042    jetcontainer = "Cone4H1Topo"
00043 
00044 if not 'nevents' in dir():
00045    nevents = -1
00046 
00047 if not 'doTrackJets' in dir() or AtlFastFlag == True:
00048    doTrackJets = False
00049 
00050 # put the names of the jetcontainers together
00051 jetcontainername =  jetcontainer + "ParticleJets"
00052 namelist = ["H1Topo", "UnCalTopo", "Topo", "Tower"]
00053 truthjetcontainername = ""
00054 
00055 for k_string in namelist:
00056    
00057    if k_string in jetcontainername:
00058       
00059       truthjetcontainername = jetcontainername.replace(k_string,"Truth")
00060       break
00061 
00062 
00063 # import the data types 
00064 import EventKernel.ParticleDataType
00065 
00066 #EventSelector = Service( "EventSelector" )
00067 
00068 # load additional libraries for back navigation
00069 from AnalysisExamples.AnalysisFlags import AnalysisFlags
00070 
00071 include( "AthenaPoolCnvSvc/ReadAthenaPool_jobOptions.py" )
00072 
00073 if AnalysisFlags.DoNavigation:
00074    include ("RecExCommon/AllDet_detDescr.py")
00075    ServiceMgr.EventSelector.BackNavigation = True
00076 
00077 # the Dlls
00078 include( "ParticleBuilderOptions/ESD_PoolCnv_jobOptions.py" )
00079 include( "ParticleBuilderOptions/AOD_PoolCnv_jobOptions.py")
00080 include( "ParticleBuilderOptions/McAOD_PoolCnv_jobOptions.py")
00081 include( "EventAthenaPool/EventAthenaPool_joboptions.py" )
00082 include( "TrackIsolationTools/TrackIsolationTool_jobOptions.py" )
00083 
00084 
00085 if(doTrackJets):
00086    # configure VertexCollectionSvc
00087    theApp.ExtSvc += [ "VertexCollectionSvc" ]
00088    VertexCollectionSvc = Service( "VertexCollectionSvc" )
00089    theApp.TopAlg += [ "MPIHiggsAnalysis::VertexCollector" ]
00090    VertexCollector = Algorithm( "MPIHiggsAnalysis::VertexCollector" )
00091    #VertexCollector.VertexCollectionSvc = "MPIHiggsAnalysis::VertexCollector"
00092 
00093    include( "Cone4TrackJet_jobOptions.py" )
00094    include( "Cone4TruthTrackJet_jobOptions.py" )
00095 
00096 
00097 HistogramPersistencySvc = Service( "HistogramPersistencySvc" )
00098 theApp.Dlls += [ "RootHistCnv" ]
00099 theApp.HistogramPersistency = "ROOT"
00100 #HistogramPersistencySvc.OutputFile = "histos.root"
00101 
00102 
00103 # write out a summary of the time spent
00104 theApp.Dlls += [ "GaudiAud" ]
00105 theAuditorSvc = AuditorSvc()
00106 theAuditorSvc.Auditors  += [ "ChronoAuditor", "MemStatAuditor"]
00107 
00108 # User Analysis Dll's
00109 theApp.Dlls   += [ "CBNT_Athena", "CBNT_Utils" ]
00110 theApp.Dlls   += [ "AnalysisTools" ]
00111 theApp.Dlls   += [ "AnalysisExamples" ]
00112 
00113 # The algorithms to run
00114 #theApp.TopAlg += [ "CBNT_Athena/AOD_ANA" ]
00115 #AOD_ANA = Algorithm( "AOD_ANA" )
00116 
00117 #init the dataset library 
00118 data_lib = datatools.DataLib()
00119 
00120 
00121 #check if joboption from default path should be included 
00122 jo_path = ''
00123 
00124 if dataset.find('jo:') != -1:
00125    dataset = dataset.replace('jo:','');
00126    jo_path = '/.at/mdtraid04/12.0.X_data/data_jo_files/'
00127    print "Include data from .py file in path: ", jo_path 
00128 
00129 
00130 #fill the dataset library
00131 include("data/datasetdef.py")
00132 include("data/datasetdef_manfred.py")
00133 include("data/datasetdef_steffen.py")
00134 include("data/datasetdef_thies.py")
00135 include("data/datasetdef_joerg.py")
00136 
00137 #print data_lib
00138 
00139 #get the dataset
00140 if dataset == "default":
00141    datasetname = 'defaultfile' #will be used for the filename
00142    print '\nError: You have to pass a dataset through the command line'
00143    print '       or define a default dataset here.\n'
00144    sys.exit()
00145   
00146 elif dataset.endswith(".py"):
00147    include(jo_path + dataset)
00148    tuple = dataset.rsplit("/",1)
00149    datasetname = tuple[len(tuple)-1].replace(".py","")
00150 
00151 elif dataset.endswith(".root"):
00152    ServiceMgr.EventSelector.InputCollections = [ dataset ]
00153    tuple = dataset.rsplit("/",1)
00154    datasetname = tuple[len(tuple)-1].replace(".root","")
00155 
00156 else:
00157    ds = data_lib.find_dataset(dataset)
00158    print ds
00159    if jo_path == '':
00160       datatools.include_files(ds.get_path(),ServiceMgr.EventSelector)
00161    else:
00162       include(jo_path + ds.get_long() + '.py')
00163    datasetname = dataset
00164 
00165 
00166 if len(outputdir)>0 and not outputdir.endswith("/"):
00167    outputdir += "/"
00168 
00169 
00170 #put together filename
00171 filename = outputdir + datasetname + "_" + jetcontainername + ".aan.root"
00172 
00173 if filenumber > 0:
00174    filename = filename.replace(jetcontainername,
00175                                jetcontainername+"_"+str(filenumber))
00176 
00177 if (AtlFastFlag == True) and\
00178        (datasetname.lower().find('atlfast') == -1):
00179 
00180    filename = filename.replace("_"+jetcontainername,
00181                                "_atlfast_"+jetcontainername)
00182 
00183 if doAODFix1mm == True:
00184    filename = filename.replace(jetcontainername,
00185                                jetcontainername+"_1mmFix")
00186 
00187 if doTrackJets == True:
00188    filename = filename.replace(jetcontainername,
00189                                jetcontainername+"_TrackJets")
00190 
00191 #print configuration
00192 print '\n************************************************************\n'
00193 print " Using the following configuration: "
00194 print "   dataset:           ", dataset
00195 print "   datasetname:       ", datasetname
00196 print "   outputdir:         ", outputdir
00197 print "   AtlFastFlag:       ", AtlFastFlag
00198 print "   doAODFix1mm:       ", doAODFix1mm
00199 print "   doEventWeight:     ", doEventWeight
00200 print "   doTrackJets:       ", doTrackJets
00201 print "   filenumber:        ", filenumber
00202 print "   nevents:           ", nevents
00203 print "   filename:          ", filename
00204 print "   jetcontainer:      ", jetcontainername  
00205 print "   truthjetcontainer: ", truthjetcontainername
00206 print '\n************************************************************\n'
00207 
00208 #do 1mm correction
00209 #include( "ElectronPhotonAlgs/ElectronPhotonCorrector_jobOptions.py")
00210 #include( "JetMissingEtAlgs/ParticleJet1mmCorrection_jobOptions.py")
00211 #include( "JetMissingEtAlgs/MissingET1mmCorrection_jobOptions.py")
00212 
00213 
00214 theApp.Dlls   += [ "AnalysisTools" ]
00215 #theApp.Dlls   += [ "NtupleWriter13" ]
00216 CBNTAthenaAware = True
00217 include ("CBNT_Athena/CBNT_AthenaAware_jobOptions.py")
00218 include ("CBNT_Athena/CBNT_EventInfo_jobOptions.py")
00219 #CBNT_AthenaAware = Algorithm( "CBNT_AthenaAware" )
00220 #CBNT_AthenaAware.Members += [ "AANtupleWriter13" ]
00221 from NtupleWriter13.NtupleWriter13Conf import AANtupleWriter13
00222 CBNT_AthenaAware += AANtupleWriter13() 
00223 
00224 
00225 ############# The properties of the AANtupleWriter13 Algorithm
00226 
00227 #AANtupleWriter13 = Algorithm( "AANtupleWriter13" )
00228 
00229 CBNT_AthenaAware.AANtupleWriter13.doTrigger        = False
00230 CBNT_AthenaAware.AANtupleWriter13.doMissingEt      = True
00231 CBNT_AthenaAware.AANtupleWriter13.doElectrons      = True
00232 CBNT_AthenaAware.AANtupleWriter13.doPhotons        = True
00233 CBNT_AthenaAware.AANtupleWriter13.doMuons          = True
00234 CBNT_AthenaAware.AANtupleWriter13.doJets           = True
00235 CBNT_AthenaAware.AANtupleWriter13.doTauJets        = True
00236 CBNT_AthenaAware.AANtupleWriter13.doTruthJets      = True
00237 CBNT_AthenaAware.AANtupleWriter13.doTruthParticles = True
00238 CBNT_AthenaAware.AANtupleWriter13.doEventWeight    = doEventWeight
00239 
00240 CBNT_AthenaAware.AANtupleWriter13.doTrackJets      = doTrackJets
00241 CBNT_AthenaAware.AANtupleWriter13.doVertices       = doTrackJets
00242 
00243 CBNT_AthenaAware.AANtupleWriter13.truthparticleMaximumLeptonBarcode = 100000
00244 CBNT_AthenaAware.AANtupleWriter13.truthparticleNoPDGAbove100        = False
00245 
00246 CBNT_AthenaAware.AANtupleWriter13.AtlFastFlag = AtlFastFlag
00247 CBNT_AthenaAware.AANtupleWriter13.doAODFix1mm = doAODFix1mm
00248 
00249 
00250 CBNT_AthenaAware.AANtupleWriter13.AOD_files = ServiceMgr.EventSelector.InputCollections
00251 
00252 
00253 if AtlFastFlag == True:
00254     
00255    CBNT_AthenaAware.AANtupleWriter13.triggerDecisionContainer     = "notAvailable"
00256    CBNT_AthenaAware.AANtupleWriter13.photonContainer              = "AtlfastPhotonCollection"
00257    CBNT_AthenaAware.AANtupleWriter13.electronContainer            = "AtlfastElectronCollection"
00258    CBNT_AthenaAware.AANtupleWriter13.muonContainer                = ["AtlfastMuonCollection"]
00259    CBNT_AthenaAware.AANtupleWriter13.jetContainer                 = "AtlfastParticleJetContainer"
00260    CBNT_AthenaAware.AANtupleWriter13.taujetContainer              = "AtlfastTauJetContainer"
00261    CBNT_AthenaAware.AANtupleWriter13.missingEtContainerCollection = ["AtlfastMissingEt"]
00262    CBNT_AthenaAware.AANtupleWriter13.truthparticleContainer       = "SpclMC"
00263    CBNT_AthenaAware.AANtupleWriter13.truthjetContainer            = "notAvailable"
00264    CBNT_AthenaAware.AANtupleWriter13.truthmissingEtContainer      = "notAvailable"
00265    CBNT_AthenaAware.AANtupleWriter13.TrackParticleContainer       = "AtlfastTrackParticles"
00266 
00267    
00268 else:
00269 
00270    CBNT_AthenaAware.AANtupleWriter13.triggerDecisionContainer     = "TrigDecision"
00271    CBNT_AthenaAware.AANtupleWriter13.triggerLVL1ROIContainer      = "LVL1_ROI"
00272    CBNT_AthenaAware.AANtupleWriter13.photonContainer              = "PhotonAODCollection"
00273    CBNT_AthenaAware.AANtupleWriter13.electronContainer            = "ElectronAODCollection"
00274    CBNT_AthenaAware.AANtupleWriter13.muonContainer                = ["MuidMuonCollection",
00275                                                                      "StacoMuonCollection"]
00276    CBNT_AthenaAware.AANtupleWriter13.jetContainer                 = jetcontainername
00277    #CBNT_AthenaAware.AANtupleWriter13.jetContainer                 = "Cone4H1TopoParticleJets"
00278    CBNT_AthenaAware.AANtupleWriter13.taujetContainer              = "TauRecContainer"
00279    CBNT_AthenaAware.AANtupleWriter13.truthjetContainer            = truthjetcontainername
00280    #CBNT_AthenaAware.AANtupleWriter13.truthjetContainer           = "Cone4TruthParticleJets"
00281    CBNT_AthenaAware.AANtupleWriter13.missingEtContainerCollection = ["MET_Base",
00282                                                                               "MET_Calib",
00283                                                                               "MET_CorrTopo",
00284                                                                               "MET_LocHadTopo",
00285                                                                               "MET_Topo",
00286                                                                               "MET_TopoObj",
00287                                                                               "MET_MuonBoy",
00288                                                                               "MET_Cryo",
00289                                                                               "MET_CryoCone",
00290                                                                               "MET_RefFinal",
00291                                                                               "MET_RefEle",
00292                                                                               "MET_RefJet",
00293                                                                               "MET_CellOut",
00294                                                                               "MET_CorrTopo",
00295                                                                               "MET_LocHadTopo",
00296                                                                               #"LocHadTopoObj",
00297                                                                               #"TopoObj",
00298                                                                               "MET_Topo",
00299                                                                               "ObjMET_Elec",
00300                                                                               "ObjMET_Muon",
00301                                                                               "ObjMET_Jet",
00302                                                                               "ObjMET_MiniJet",
00303                                                                               "ObjMET_IdTrk",
00304                                                                               "ObjMET_Rest", 
00305                                                                               "ObjMET_Final"]
00306    CBNT_AthenaAware.AANtupleWriter13.truthmissingEtContainer      = "MET_Truth"
00307    CBNT_AthenaAware.AANtupleWriter13.truthparticleContainer       = "SpclMC"
00308    CBNT_AthenaAware.AANtupleWriter13.jetTrackContainer            = "Cone4TrackJets"
00309    CBNT_AthenaAware.AANtupleWriter13.jetTruthTrackContainer       = "Cone4TruthTrackJets"
00310    CBNT_AthenaAware.AANtupleWriter13.TrackParticleContainer       = "TrackParticleCandidate"
00311 
00312 # set the file info
00313 CBNT_AthenaAware.AANtupleWriter13.release    = "13.0.3"
00314 CBNT_AthenaAware.AANtupleWriter13.svnversion = os.popen("svnversion -n .").read()
00315 CBNT_AthenaAware.AANtupleWriter13.date       = datetime.datetime.now().strftime("%Y-%m-%d/%H:%M:%S")
00316 
00317 ##########################################
00318 # setup TTree registration Service
00319 # save ROOT histograms and Tuple
00320 
00321 #theApp.Dlls += [ "RootHistCnv" ]
00322 #theApp.HistogramPersistency = "ROOT"
00323 
00324 THistSvc         = Service ( "THistSvc" )
00325 THistSvc.Output  = ["AANT DATAFILE='"+filename+"' OPT='RECREATE'"]
00326 NTupleSvc        = Service( "NTupleSvc" )
00327 NTupleSvc.Output = [ "FILE1 DATAFILE='"+filename+"' OPT='NEW'" ]
00328 theApp.TopAlg += [ "AANTupleStream" ]
00329 AANTupleStream               = Algorithm( "AANTupleStream" )
00330 AANTupleStream.ExtraRefNames = [ "StreamATLFAST","Stream1" ]
00331 AANTupleStream.OutputName = filename
00332 AANTupleStream.WriteInputDataHeader = True
00333 AANTupleStream.OutputLevel = WARNING
00334 
00335 # Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL )
00336 MessageSvc = Service( "MessageSvc" )
00337 MessageSvc.OutputLevel = 3
00338 #MessageSvc.OutputLevel = WARNING
00339 #MessageSvc.OutputLevel = INFO
00340 
00341 # Number of Events to process
00342 theApp.EvtMax = nevents
00343 
00344 # skip events
00345 if(filenumber > 0):
00346    ServiceMgr.EventSelector.SkipEvents = (filenumber-1) * theApp.EvtMax
00347    print 'Skip:', ServiceMgr.EventSelector.SkipEvents, 'Events'
00348 
00349 
00350 ###############################################################
00351 #
00352 #  1) Default:  athena AANtupleWriter13.py
00353 #      - default values will be used (defined at the beginning of this file)
00354 #      - you have to put 'include("<your_dataset_jo>.py")' in the 'if dataset == "default"' block 
00355 #
00356 #  2) dataset: athena -c 'dataset="description"' AANtupleWriter13.py
00357 #      a) dataset="path/filename.py": joboptions will be directly included
00358 #      b) dataset="jo:filename.py":   joboptions will be icluded from path: /.at/mdtraid04/12.0.X_data/data_jo_files/
00359 #      c) dataset="filename.root"     the root file will directly be included
00360 #      d) dataset="long/short descr":
00361 #                   - e.g.:  dataset="5200_1206"
00362 #                   - the datset will be searched in the data_lib library
00363 #                   - both the short or long description can be specified, as defined in
00364 #                     data/datasetdef.py
00365 #                   - all files which contain '.root' in the name in the path defined
00366 #                     in the dataset definition will be included
00367 #      e) dataset="jo:5200_1206"                             
00368 #                   - same as d) but instead of looping over all rootfiles the
00369 #                     joboptions from the path: /.at/mdtraid04/12.0.X_data/data_jo_files/ is included
00370 #                   - the name of the joboption is build as: <long descripion of dataset>.py
00371 #    
00372 #  3) outpudir: athena -c 'outputdir="mydata/"' AANtupleWriter13.py
00373 #      - the path where the file will be written
00374 # 
00375 #  4) AtlFastFlag: athena -c 'AtlFastFlag=1' AANtupleWriter13.py
00376 #      - specifies if writer will be run on AtlFast containers
00377 #      - default value is False
00378 #      - if dataset is defined in command line an contains a string "atlfast"
00379 #        -> flag will be set to True
00380 #      - this will be overwritten if AtlFastFlag is set in the command line
00381 #      - if true: ouptfilename will contain a string: '_atlfast' 
00382 #
00383 #  5) doEventWeight: athena -c 'doEventWeight=0' AANtupleWriter13.py 
00384 #      - write EventWeight or not
00385 #      - default value is True
00386 #      - if dataset is defined in command line an contains a string "sherpa"
00387 #        ->  flag will be set to False
00388 #      - this will be overwritten if doEventWeight is set in the command line
00389 #
00390 #  6) doAODFix1mm: athena -c 'doAODFix1mm=1' AANtupleWriter13.py
00391 #      - default: false
00392 #      - if true 1mm bug corrections will be applied     
00393 #      - will be included in the outputfilename
00394 # 
00395 #
00396 #  7) filenumber: athena -c 'filenumber=3' AANtupleWriter13.py
00397 #      - default value is 0
00398 #      - if > 0: - (filenumber-1)*nevent will be skipped the nevents ar processed
00399 #                - filenumber will be included in the outputfilename
00400 #
00401 #  8) jetcontainer: athena -c 'jetcontainer="Cone4H1Tower"' AANtupleWriter13.py
00402 #     - default: "Cone4H1Topo"
00403 #     - use this jetcontainer in analysis
00404 #     - the appropriate truthjet container will be used
00405 #     - will be included in the outputfilename  
00406 #
00407 #  9) nevents: athena -c 'nevents="100"' AANtupleWriter13.py
00408 #     - the number of events which will be processed
00409 #
00410 # 10) Compose:
00411 #     athena  -c 'dataset="5200_1206_tid007900"; nevents=100' AANtupleWriter13.py
00412 #
00413 #
00414 #################################################################

Generated on Tue Oct 21 11:50:46 2008 for NtupleAnalysis by  doxygen 1.5.1