LArCalib_PhysWavePredictionConfig.py 7.41 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration

from AthenaConfiguration.ComponentFactory import CompFactory 
from AthenaConfiguration.MainServicesConfig import MainServicesCfg

def LArPhysWavePredictionCfg(flags):

    #Get basic services and cond-algos
    from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
    result=LArCalibBaseCfg(flags)

    from LArCalibProcessing.utils import FolderTagResolver
    FolderTagResolver._globalTag=flags.LArCalib.GlobalTag
    rs=FolderTagResolver()
    CaliWaveTag=rs.getFolderTag(flags.LArCalib.CaliWave.Folder)
    DetCellParamsTag=rs.getFolderTag(flags.LArCalib.DetCellParams.Folder)
    CaliPulseParamsTag=rs.getFolderTag(flags.LArCalib.CaliPulseParams.Folder)
    MphysOverMcalTag=rs.getFolderTag(flags.LArCalib.MPhysOverMCal.Folder)
    PhysWaveTag=rs.getFolderTag(flags.LArCalib.PhysWave.Folder)
    del rs #Close database

    #Retrieve inputs 
    from IOVDbSvc.IOVDbSvcConfig import addFolders
    result.merge(addFolders(flags,flags.LArCalib.CaliWave.Folder,detDb=flags.LArCalib.Input.Database, tag=CaliWaveTag))
    result.merge(addFolders(flags,flags.LArCalib.CaliPulseParams.Folder,detDb=flags.LArCalib.Input.Database, tag=CaliPulseParamsTag))
    result.merge(addFolders(flags,flags.LArCalib.DetCellParams.Folder,detDb=flags.LArCalib.Input.Database, tag=DetCellParamsTag))
    result.merge(addFolders(flags,"/LAR/ElecCalibOfl/Tdrift/Computed",detDb="LAR_OFL",tag="LARElecCalibOflTdriftComputed-calib-03"))
    

    if flags.LArCalib.Input.SubDet == "HEC":
        result.merge(addFolders(flags,"/LAR/ElecCalibOfl/PhysWaves/HECIdeal",detDb="LAR_OFL",db="COMP200",tag="LARElecCalibOflPhysWavesHECIdeal-calib-02"))


    LArPhysWavePredictor = CompFactory.LArPhysWavePredictor( "LArPhysWavePredictor" )
    LArPhysWavePredictor.ProblemsToMask= ["deadCalib","deadReadout","deadPhys","almostDead","short"]
    LArPhysWavePredictor.TestMode      = False
    LArPhysWavePredictor.isSC          = flags.LArCalib.isSC
    LArPhysWavePredictor.KeyCaliList   =  [ "LArCaliWave" ]
    LArPhysWavePredictor.UseCaliPulseParamsFromJO = False
    LArPhysWavePredictor.UseDetCellParamsFromJO   = False
    LArPhysWavePredictor.UseTdriftFromJO          = False
    #LArPhysWavePredictor.Tdrift	              = TdriftVector
    LArPhysWavePredictor.UseDoubleTriangle        = False
    #LArPhysWavePredictor.Tdrift2	              = TdriftVector2
    #LArPhysWavePredictor.WeightTriangle2          = TdriftWeight2
    LArPhysWavePredictor.UseTimeShiftFromJO       = True
    LArPhysWavePredictor.GroupingType             = flags.LArCalib.GroupingType
    LArPhysWavePredictor.NormalizeCali	          = flags.LArCalib.Input.SubDet != "HEC"
    LArPhysWavePredictor.KeyMphysMcali	          = "LArMphysOverMcal"
    LArPhysWavePredictor.DumpMphysMcali           = False # set to True to dump on a ASCII file
    LArPhysWavePredictor.KeyPhys                  = "LArPhysWave"
    LArPhysWavePredictor.isHEC                    = flags.LArCalib.Input.SubDet == "HEC"

    result.addEventAlgo(LArPhysWavePredictor)
    
    if (flags.LArCalib.Input.SubDet == "HEC"):
        LArPhysWaveHECTool=CompFactory.LArPhysWaveHECTool()
        LArPhysWaveHECTool.NormalizeCali     = False  
        LArPhysWaveHECTool.TimeOriginShift   = False
        LArPhysWaveHECTool.SubtractBaseline  = False
        result.addPublicTool(LArPhysWaveHECTool)


    else: #not HEC but EM:
        LArPhysWaveTool=CompFactory.LArPhysWaveTool()
        LArPhysWaveTool.NormalizeCali     = False # this is taken care by LArPhysWavePredictor
        LArPhysWaveTool.TimeOriginShift   = False
        LArPhysWaveTool.SubtractBaseline  = False
        LArPhysWaveTool.InjPointCorrLayer = [ 1, 1, 1, 1 ]
        LArPhysWaveTool.InjPointUseTauR   = [ 1, 1, 1, 1 ]
        result.addPublicTool(LArPhysWaveTool)
   
 
    rootfile=flags.LArCalib.Output.ROOTFile
    if rootfile != "":
      LArPhysWaves2Ntuple              = CompFactory.LArPhysWaves2Ntuple("LArPhysWaves2Ntuple")
      LArPhysWaves2Ntuple.NtupleName   = "PHYSWAVE" 
      LArPhysWaves2Ntuple.AddFEBTempInfo   = False  
      LArPhysWaves2Ntuple.KeyList      = [ "LArPhysWave"  ]
      LArPhysWaves2Ntuple.isSC = flags.LArCalib.isSC
      result.addEventAlgo(LArPhysWaves2Ntuple)

      LArMphysOverMcal2Ntuple                = CompFactory.LArMphysOverMcal2Ntuple( "LArMphysOverMcal2Ntuple" )
      LArMphysOverMcal2Ntuple.ContainerKey   = "LArMphysOverMcal"
      LArMphysOverMcal2Ntuple.AddFEBTempInfo   = False
      LArMphysOverMcal2Ntuple.isSC = flags.LArCalib.isSC
      result.addEventAlgo(LArMphysOverMcal2Ntuple)

      import os
      if os.path.exists(rootfile):
          os.remove(rootfile)
      result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
      result.setAppProperty("HistogramPersistency","ROOT")
    pass # end if ROOT ntuple writing
    

    from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
    result.merge(OutputConditionsAlgCfg(flags,
                                        outputFile=flags.LArCalib.Output.POOLFile,
                                        ObjectList=["LArPhysWaveContainer#LArPhysWave#"+flags.LArCalib.PhysWave.Folder,
                                                    "LArMphysOverMcalComplete#LArMphysOverMcal#"+flags.LArCalib.MPhysOverMCal.Folder,],
                                        IOVTagList=[PhysWaveTag,MphysOverMcalTag]
                                    ))

    #RegistrationSvc    
    result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = False))
    result.getService("IOVDbSvc").DBInstance=""

    #MC Event selector since we have no input data file 
    mcCnvSvc = CompFactory.McCnvSvc()
    cfg.addService(mcCnvSvc)
    cfg.addService(CompFactory.EvtPersistencySvc("EventPersistencySvc",CnvServices=[mcCnvSvc.getFullJobOptName(),]))
    eventSelector=CompFactory.McEventSelector("EventSelector",
                                              RunNumber = flags.LArCalib.Input.RunNumbers[0],
                                              EventsPerRun      = 1,
                                              FirstEvent	       = 0,
                                              InitialTimeStamp  = 0,
                                              TimeStampInterval = 1
                                          )

    result.addService(eventSelector)
    return result



if __name__ == "__main__":


    from AthenaConfiguration.AllConfigFlags import ConfigFlags
    from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
    addLArCalibFlags(ConfigFlags)



    ConfigFlags.LArCalib.Input.RunNumbers=[401351,]
    ConfigFlags.LArCalib.Input.Database="/home/wlampl/calibTest/00400939_00400943_00400945_Barrel-EMB-EMEC_HIGH_40_21.0.20_1/poolFiles/myDB200_00400939_00400943_00400945_EB-EMBA_one.db_Delay"
    ConfigFlags.LArCalib.Input.SubDet="EM"
    ConfigFlags.LArCalib.BadChannelDB="/home/wlampl/calibTest/00400939_00400943_00400945_Barrel-EMB-EMEC_HIGH_40_21.0.20_1/poolFiles/SnapshotBadChannel_00400939_00400943_00400945_EB-EMBA.db"
    ConfigFlags.LArCalib.BadChannelTag="-RUN2-UPD3-00"
    ConfigFlags.LArCalib.Output.ROOTFile="physwave.root"
    ConfigFlags.IOVDb.DatabaseInstance="CONDBR2"
    ConfigFlags.IOVDb.DBConnection="sqlite://;schema=output.sqlite;dbname=CONDDBR2"
    ConfigFlags.IOVDb.GlobalTag="LARCALIB-RUN2-02"
    #ConfigFlags.Exec.OutputLevel=1

    cfg=MainServicesCfg(ConfigFlags)
    cfg.merge(LArPhysWavePredictionCfg(ConfigFlags))

    print("Start running...")
    cfg.run(1)