diff --git a/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelCalibSvc.cxx b/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelCalibSvc.cxx index 8ad6936ce4aa2947b790afbf2e6a3bc56895a49e..4801ecf234ab2a74b7e1dd8574c4efcf6776bd63 100755 --- a/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelCalibSvc.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelCalibSvc.cxx @@ -1,7 +1,3 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - /////////////////////////////////////////////////////////////////// // PixelCalibSvc.cxx, (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// @@ -97,6 +93,7 @@ PixelCalibSvc::PixelCalibSvc(const std::string& name, ISvcLocator* sl):AthServic declareProperty("DiscrThreshVar", m_discrThreshSigma, "Discriminator threshold sigma"); declareProperty("IntimeThresh", m_intimeThresh, "Discriminator in-time threshold"); declareProperty("NoiseThresh", m_noiseThresh, "Discriminator noise"); + declareProperty("DisableDB", m_disableDb, "Disable DB"); declareProperty("IBLParameterService", m_IBLParameterSvc); declareProperty("GeoModelService", m_geoModelSvc); declareProperty("PixelOfflineCalibSvc",m_offlineCalibSvc); @@ -144,7 +141,7 @@ StatusCode PixelCalibSvc::initialize() { CHECK(m_offlineCalibSvc.retrieve()); // locate PixelCalibTools - CHECK(m_dbTool.retrieve()); + if (!m_disableDb) { CHECK(m_dbTool.retrieve()); } if (m_IBLParameterSvc.retrieve().isFailure()) { ATH_MSG_WARNING( "Could not retrieve IBLParameterSvc"); @@ -694,35 +691,18 @@ float PixelCalibSvc::getTotRes(const Identifier& pix_id, float Q) const { //getTotMean float PixelCalibSvc::getTotMean(const Identifier& pix_id, float Q) const { + if (m_disableDb) { return m_totparA*(m_totparE+Q)/(m_totparC+Q); } Identifier wafer_id = m_pixid->wafer_id(pix_id); int circ; int type = PixelType(pix_id,wafer_id,circ); - float ToT = 0.0; - if (!m_disableDb && m_dbTool->getCalibPtr(wafer_id) && circ>-1) { - ToT = m_dbTool->getCalibPtr(wafer_id)->getPixelChipSummaryData(circ)->getQ2Tot(type,Q); + if (m_dbTool->getCalibPtr(wafer_id) && circ>-1) { + return m_dbTool->getCalibPtr(wafer_id)->getPixelChipSummaryData(circ)->getQ2Tot(type,Q); } else { ATH_MSG_WARNING("Condition DB is not available. Use hardcoded value."); - ToT = m_totparA*(m_totparE+Q)/(m_totparC+Q); - } - -/* - // In Pixel Digitization the DBM is separately treated as the below constant ToT formation. - // This should be revisited. - const InDetDD::SiDetectorElement *element = m_detManager->getDetectorElement(wafer_id); - const InDetDD::PixelModuleDesign *p_design = dynamic_cast<const InDetDD::PixelModuleDesign*>(&element->design()); - if (m_pixid->is_dbm(wafer_id)) { // DBM uses constant so far. - ToT = 8.0*(Q-1200.0)/(8000.0-1200.0); + return m_totparA*(m_totparE+Q)/(m_totparC+Q); } - else { - if (p_design->getReadoutTechnology()==InDetDD::PixelModuleDesign::FEI4) { - if (ToT>=m_offlineCalibSvc->getIBLToToverflow()) { ToT=m_offlineCalibSvc->getIBLToToverflow(); } - } - } -*/ - - return ToT; } //getCharge diff --git a/InnerDetector/InDetConditions/PixelConditionsServices/src/SpecialPixelMapSvc.cxx b/InnerDetector/InDetConditions/PixelConditionsServices/src/SpecialPixelMapSvc.cxx index eb86e3eb26d70218f47facdbe2b32f3f077038e7..8ee28564bb2e474350983605c663b909212fb41e 100755 --- a/InnerDetector/InDetConditions/PixelConditionsServices/src/SpecialPixelMapSvc.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsServices/src/SpecialPixelMapSvc.cxx @@ -851,102 +851,97 @@ StatusCode SpecialPixelMapSvc::registerCondAttrListCollection(const DetectorSpec } StatusCode SpecialPixelMapSvc::createFromDetectorStore(const std::string condAttrListCollectionKey, - const std::string pixelMapKey, - bool fillMissing ) const{ - + const std::string pixelMapKey, + bool fillMissing ) const{ + DetectorSpecialPixelMap* spm = new DetectorSpecialPixelMap(); spm->resize(m_pixelID->wafer_hash_max(),NULL); - + StatusCode sc = m_detStore->record(spm, pixelMapKey); if ( !sc.isSuccess() ){ ATH_MSG_ERROR( "Unable to record DetectorSpecialPixelMap at " << pixelMapKey ); return StatusCode::FAILURE; } - + const CondAttrListCollection* attrListColl = 0; - + sc = m_detStore->retrieve(attrListColl, condAttrListCollectionKey); if( !sc.isSuccess() ){ - ATH_MSG_ERROR( "Unable to retrieve CondAttrListCollection," - << " constructing empty DetectorSpecialPixelMap" ); + ATH_MSG_ERROR( "Unable to retrieve CondAttrListCollection," << " constructing empty DetectorSpecialPixelMap" ); } else{ ATH_MSG_DEBUG( "CondAttrListCollection retrieved" ); - + if( attrListColl->size() == 0 ){ - ATH_MSG_INFO( "CondAttrListCollection is empty," - << " constructing empty DetectorSpecialPixelMap" ); - } - else{ - - for(CondAttrListCollection::const_iterator attrList = attrListColl->begin(); - attrList != attrListColl->end(); ++attrList){ - - std::ostringstream attrStr; - (*attrList).second.toOutputStream(attrStr); - ATH_MSG_VERBOSE( "ChanNum " << (*attrList).first << " Attribute list " << attrStr.str() ); - - CondAttrListCollection::ChanNum chanNum = (*attrList).first; - CondAttrListCollection::iov_const_iterator iovIt = attrListColl->chanIOVPair(chanNum); - const IOVRange& range = (*iovIt).second; - - if(range.start().isTimestamp()) { - ATH_MSG_VERBOSE( "Range timestamp : from " << range.start().timestamp() - << " until " << range.stop().timestamp() ); - } - else { - ATH_MSG_VERBOSE( "Range R/E : from " << range.start().run() << " " << range.start().event() - << " until " << range.stop().run() << " " << range.stop().event() ); - } - - const unsigned int moduleID = static_cast<unsigned int>((*attrList).second["moduleID"].data<const int>()); - unsigned int idhash; - if (m_forceNewDBContent) idhash = IdentifierHash(moduleID); - else if(isIBL){ - if(m_dummy || IdentifierHash(moduleID)>m_pixelID->wafer_hash_max()){ - // continue (useful to transport the old DB to new DB with IBL!; - int component = static_cast<int>((moduleID & (3 << 25)) / 33554432) * 2 - 2; - unsigned int layer = (moduleID & (3 << 23)) / 8388608 ; - if(component==0)layer +=1; // shift layer - unsigned int phi = (moduleID & (63 << 17)) / 131072 ; - int eta = static_cast<int>((moduleID & (15 << 13)) / 8192) - 6 ; - Identifier id = m_pixelID->wafer_id( component, layer, phi, eta ); - idhash = m_pixelID->wafer_hash(id); + ATH_MSG_INFO( "CondAttrListCollection is empty," << " constructing empty DetectorSpecialPixelMap" ); } else{ - idhash = IdentifierHash(moduleID); - } - } - else { - int component = static_cast<int>((moduleID & (3 << 25)) / 33554432) * 2 - 2; - unsigned int layer = (moduleID & (3 << 23)) / 8388608 ; - unsigned int phi = (moduleID & (63 << 17)) / 131072 ; - int eta = static_cast<int>((moduleID & (15 << 13)) / 8192) - 6 ; - Identifier id = m_pixelID->wafer_id( component, layer, phi, eta ); - idhash = m_pixelID->wafer_hash(id); - } - if( idhash < m_pixelID->wafer_hash_max()){ - coral::AttributeList::const_iterator attribute = (*attrList).second.begin(); - ++attribute; - if( (*attribute).specification().typeName() == "blob" ){ + for(CondAttrListCollection::const_iterator attrList = attrListColl->begin(); attrList != attrListColl->end(); ++attrList){ - const coral::Blob& blob = (*attrList).second["SpecialPixelMap"].data<const coral::Blob>(); - delete (*spm)[idhash]; - (*spm)[idhash] = new ModuleSpecialPixelMap(blob, getChips(idhash) ); - } - else{ + std::ostringstream attrStr; + (*attrList).second.toOutputStream(attrStr); + ATH_MSG_VERBOSE( "ChanNum " << (*attrList).first << " Attribute list " << attrStr.str() ); - const std::string& clob = (*attrList).second["ModuleSpecialPixelMap_Clob"].data<const std::string>(); - delete (*spm)[idhash]; - (*spm)[idhash] = new ModuleSpecialPixelMap(clob, getChips(idhash) ); - } - } - else{ - ATH_MSG_FATAL( "Module hashID out of range: " << idhash ); - return StatusCode::FAILURE; - } + CondAttrListCollection::ChanNum chanNum = (*attrList).first; + CondAttrListCollection::iov_const_iterator iovIt = attrListColl->chanIOVPair(chanNum); + const IOVRange& range = (*iovIt).second; + + if(range.start().isTimestamp()) { + ATH_MSG_VERBOSE( "Range timestamp : from " << range.start().timestamp() << " until " << range.stop().timestamp() ); + } + else { + ATH_MSG_VERBOSE( "Range R/E : from " << range.start().run() << " " << range.start().event() << " until " << range.stop().run() << " " << range.stop().event() ); + } + + const unsigned int moduleID = static_cast<unsigned int>((*attrList).second["moduleID"].data<const int>()); + unsigned int idhash; + if (m_forceNewDBContent) idhash = IdentifierHash(moduleID); + else if(isIBL){ + if(m_dummy || IdentifierHash(moduleID)>m_pixelID->wafer_hash_max()){ + // continue (useful to transport the old DB to new DB with IBL!; + int component = static_cast<int>((moduleID & (3 << 25)) / 33554432) * 2 - 2; + unsigned int layer = (moduleID & (3 << 23)) / 8388608 ; + if(component==0)layer +=1; // shift layer + unsigned int phi = (moduleID & (63 << 17)) / 131072 ; + int eta = static_cast<int>((moduleID & (15 << 13)) / 8192) - 6 ; + Identifier id = m_pixelID->wafer_id( component, layer, phi, eta ); + idhash = m_pixelID->wafer_hash(id); + } + else{ + idhash = IdentifierHash(moduleID); + } + } + else { + int component = static_cast<int>((moduleID & (3 << 25)) / 33554432) * 2 - 2; + unsigned int layer = (moduleID & (3 << 23)) / 8388608 ; + unsigned int phi = (moduleID & (63 << 17)) / 131072 ; + int eta = static_cast<int>((moduleID & (15 << 13)) / 8192) - 6 ; + Identifier id = m_pixelID->wafer_id( component, layer, phi, eta ); + idhash = m_pixelID->wafer_hash(id); + } + if( idhash < m_pixelID->wafer_hash_max()){ + + coral::AttributeList::const_iterator attribute = (*attrList).second.begin(); + ++attribute; + if( (*attribute).specification().typeName() == "blob" ){ + + const coral::Blob& blob = (*attrList).second["SpecialPixelMap"].data<const coral::Blob>(); + delete (*spm)[idhash]; + (*spm)[idhash] = new ModuleSpecialPixelMap(blob, getChips(idhash) ); + } + else{ + + const std::string& clob = (*attrList).second["ModuleSpecialPixelMap_Clob"].data<const std::string>(); + delete (*spm)[idhash]; + (*spm)[idhash] = new ModuleSpecialPixelMap(clob, getChips(idhash) ); + } + } + else{ + ATH_MSG_FATAL( "Module hashID out of range: " << idhash ); + return StatusCode::FAILURE; + } } } } diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py index 7dca8ed764f072fef5950c60df8ffca214291fce..d0b593704ecd27d7fed4c5292c1e261cc9fdf2a8 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py @@ -81,8 +81,11 @@ def PixelNoisyCellGenerator(name="PixelNoisyCellGenerator", **kwargs): NoiseShape = [0.00596, 0.03491, 0.07058, 0.11991, 0.17971, 0.24105, 0.29884, 0.35167, 0.39912, 0.44188, 0.48016, 0.51471, 0.54587, 0.57405, 0.59958, 0.62288, 0.64411, 0.66360, 0.68159, 0.69823, 0.71362, 0.72781, 0.74096, 0.75304, 0.76415, 0.77438, 0.78383, 0.79256, 0.80066, 0.80821, 0.81547, 0.82246, 0.82918, 0.83501, 0.84054, 0.84576, 0.85078, 0.85558, 0.86018, 0.86455, 0.86875, 0.87273, 0.87653, 0.88020, 0.88369, 0.88705, 0.89027, 0.89336, 0.89633, 0.89921, 0.90195, 0.90460, 0.90714, 0.90961, 0.91198, 0.91426, 0.91644, 0.91853, 0.92055, 0.92250, 0.92435, 0.92611, 0.92782, 0.92947, 0.93105, 0.93257, 0.93404, 0.93547, 0.93688, 0.93822, 0.93953, 0.94079, 0.94201, 0.94318, 0.94432, 0.94542, 0.94649, 0.94751, 0.94851, 0.94949, 0.95045, 0.95137, 0.95227, 0.95314, 0.95399, 0.95483, 0.95563, 0.95646, 0.95729, 0.95812, 0.95896, 0.95980, 0.96063, 0.96144, 0.96224, 0.96301, 0.96377, 0.96451, 0.96521, 0.96590, 0.96657, 0.96722, 0.96787, 0.96849, 0.96911, 0.96971, 0.97031, 0.97090, 0.97148, 0.97204, 0.97260, 0.97314, 0.97367, 0.97421, 0.97474, 0.97525, 0.97576, 0.97627, 0.97676, 0.97722, 0.97769, 0.97815, 0.97861, 0.97906, 0.97950, 0.97992, 0.98033, 0.98073, 0.98111, 0.98147, 0.98182, 0.98216, 0.98249, 0.98281, 0.98312, 0.98343, 0.98374, 0.98402, 0.98430, 0.98456, 0.98482, 0.98507, 0.98532, 0.98555, 0.98579, 0.98602, 0.98624, 0.98646, 0.98668, 0.98690, 0.98711, 0.98732, 0.98753, 0.98773, 0.98793, 0.98813, 0.98832, 0.98851, 0.98870, 0.98888, 0.98907, 0.98925, 0.98943, 0.98961, 0.98979, 0.98996, 0.99014, 0.99031, 0.99048, 0.99064, 0.99081, 0.99098, 0.99114, 0.99131, 0.99147, 0.99163, 0.99179, 0.99194, 0.99210, 0.99225, 0.99240, 0.99256, 0.99271, 0.99286, 0.99300, 0.99315, 0.99329, 0.99344, 0.99358, 0.99372, 0.99386, 0.99400, 0.99414, 0.99427, 0.99440, 0.99453, 0.99466, 0.99479, 0.99491, 0.99503, 0.99515, 0.99527, 0.99538, 0.99549, 0.99560, 0.99571, 0.99582, 0.99592, 0.99602, 0.99613, 0.99623, 0.99633, 0.99643, 0.99653, 0.99662, 0.99672, 0.99682, 0.99691, 0.99701, 0.99710, 0.99719, 0.99728, 0.99737, 0.99746, 0.99755, 0.99764, 0.99772, 0.99781, 0.99790, 0.99798, 0.99806, 0.99814, 0.99823, 0.99831, 0.99839, 0.99847, 0.99855, 0.99863, 0.99871, 0.99879, 0.99887, 0.99895, 0.99902, 0.99910, 0.99918, 0.99925, 0.99933, 0.99940, 0.99948, 0.99955, 0.99963, 0.99971, 0.99978, 0.99985, 0.99993, 1.00000] kwargs.setdefault("NoiseShape",NoiseShape) #print "Noise Shape = ",NoiseShape - if jobproperties.Beam.beamType != "cosmics" : - kwargs.setdefault("RndNoiseProb", 1.e-10) + if jobproperties.Beam.beamType == "cosmics" : + kwargs.setdefault("TimeBCN",8.0) + else: + kwargs.setdefault("RndNoiseProb", 1.e-10) + kwargs.setdefault("TimeBCN",1.0) return CfgMgr.PixelNoisyCellGenerator(name, **kwargs) def PixelChargeSmearer(name="PixelChargeSmearer", **kwargs): @@ -92,47 +95,48 @@ def PixelChargeSmearer(name="PixelChargeSmearer", **kwargs): def PixelDiodeCrossTalkGenerator(name="PixelDiodeCrossTalkGenerator", **kwargs): return CfgMgr.PixelDiodeCrossTalkGenerator(name, **kwargs) -def TimeSvc(name="TimeSvc", **kwargs): +def PixelRandomDisabledCellGenerator(name="PixelRandomDisabledCellGenerator", **kwargs): + return CfgMgr.PixelRandomDisabledCellGenerator(name, **kwargs) + +def FrontEndSimTool(name="FrontEndSimTool", **kwargs): kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) kwargs.setdefault("RndmEngine", "PixelDigitization") - timeBCN = 5 - timePerBCO = 25.0 - if digitizationFlags.bunchSpacing.get_Value() > 0: - timeBCN = max(int(digitizationFlags.bunchSpacing.get_Value()/timePerBCO),timeBCN) from AthenaCommon.BeamFlags import jobproperties if jobproperties.Beam.beamType == "cosmics" : - ## Timing for cosmics run - kwargs.setdefault("UseComTime", True) - kwargs.setdefault("TimeJitter", 25.) - kwargs.setdefault("TimeZero", 100.) - timeBCN = 8 + kwargs.setdefault("UseComTime", True) + kwargs.setdefault("TimeJitter", 25.0) + kwargs.setdefault("TimeBCN",8.0) + kwargs.setdefault("TimeZero", 100.0) else: - kwargs.setdefault("TimeZero", 5.) - timeBCN = 1 + kwargs.setdefault("TimeBCN",1.0) + kwargs.setdefault("TimeZero", 5.0) kwargs.setdefault("TimePerBCO", 25.0) - kwargs.setdefault("TimeBCN",timeBCN) - return CfgMgr.TimeSvc(name, **kwargs) - -def PixelRandomDisabledCellGenerator(name="PixelRandomDisabledCellGenerator", **kwargs): - return CfgMgr.PixelRandomDisabledCellGenerator(name, **kwargs) + return CfgMgr.FrontEndSimTool(name, **kwargs) -def FrontEndSimTool(name="FrontEndSimTool", **kwargs): +def RD53SimTool(name="RD53SimTool", **kwargs): kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) kwargs.setdefault("RndmEngine", "PixelDigitization") - return CfgMgr.FrontEndSimTool(name, **kwargs) + kwargs.setdefault("BarrelAnalogthreshold", [-1, -1, -1, -1, -1]) + kwargs.setdefault("EndcapAnalogthreshold", [-1, -1, -1, -1]) + kwargs.setdefault("BarrelToTthreshold", [-1, -1, -1, -1, -1]) + kwargs.setdefault("EndcapToTthreshold", [-1, -1, -1, -1]) + return CfgMgr.RD53SimTool(name, **kwargs) def FEI4SimTool(name="FEI4SimTool", **kwargs): kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) kwargs.setdefault("RndmEngine", "PixelDigitization") + kwargs.setdefault("BarrelAnalogthreshold", [-1]) + kwargs.setdefault("EndcapAnalogthreshold", [-1, -1, -1]) kwargs.setdefault("BarrelToTthreshold", [-1]) kwargs.setdefault("EndcapToTthreshold", [-1,-1,-1]) kwargs.setdefault("HitDiscConfig", 2) - kwargs.setdefault("TimingTune", 2015) return CfgMgr.FEI4SimTool(name, **kwargs) def FEI3SimTool(name="FEI3SimTool", **kwargs): kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) kwargs.setdefault("RndmEngine", "PixelDigitization") + kwargs.setdefault("BarrelAnalogthreshold", [-1, -1, -1, -1]) # first argument is dummy + kwargs.setdefault("EndcapAnalogthreshold", [-1, -1, -1]) kwargs.setdefault("BarrelToTthreshold", [-1, 5, 5, 5]) # first argument is dummy kwargs.setdefault("EndcapToTthreshold", [ 5, 5, 5]) kwargs.setdefault("BarrelLatency", [ -1, 151, 256, 256]) @@ -177,7 +181,7 @@ def BasicPixelDigitizationTool(name="PixelDigitizationTool", **kwargs): if GeometryFlags.isSLHC(): procTools += ['PixelDiodeCrossTalkGenerator'] chargeTools += ['PixelPlanarChargeTool'] - feSimTools += ['FEI4SimTool'] + feSimTools += ['RD53SimTool'] else: procTools += ['PixelDiodeCrossTalkGenerator'] procTools += ['PixelChargeSmearer'] diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py index ea47b1caa44a8694963986fc24a6dc0b274784b5..3d30c5273416bf4796ab3871bc808e42f5b95e3b 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py @@ -21,9 +21,9 @@ addTool("PixelDigitization.PixelDigitizationConfig.PixelPlanarChargeTool","Pixel addTool("PixelDigitization.PixelDigitizationConfig.Pixel3DChargeTool","Pixel3DChargeTool") addTool("PixelDigitization.PixelDigitizationConfig.SubChargesTool","SubChargesTool") addTool("PixelDigitization.PixelDigitizationConfig.FrontEndSimTool","FrontEndSimTool") +addTool("PixelDigitization.PixelDigitizationConfig.RD53SimTool","RD53SimTool") addTool("PixelDigitization.PixelDigitizationConfig.FEI4SimTool","FEI4SimTool") addTool("PixelDigitization.PixelDigitizationConfig.FEI3SimTool","FEI3SimTool") -addService("PixelDigitization.PixelDigitizationConfig.TimeSvc","TimeSvc") addTool("PixelDigitization.PixelDigitizationConfig.PixelOverlayDigitizationTool", "PixelOverlayDigitizationTool") addAlgorithm("PixelDigitization.PixelDigitizationConfig.PixelOverlayDigitization", "PixelOverlayDigitization") addTool("PixelDigitization.PixelDigitizationConfig.BichselSimTool", "BichselSimTool") diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.cxx index 6f2486ff78f3f00e103edc83066cb3e1be34a0fe..639188126a93bfa376e5bbf2c896401da629474f 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.cxx @@ -9,6 +9,8 @@ #include "SiDigitization/SiHelper.h" #include "InDetReadoutGeometry/SiReadoutCellId.h" +#include "CLHEP/Random/RandFlat.h" + FEI3SimTool::FEI3SimTool( const std::string& type, const std::string& name,const IInterface* parent): FrontEndSimTool(type,name,parent), m_BarrelHitDuplication({false,false,false,false,false,false,false}), @@ -82,6 +84,7 @@ void FEI3SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle for (SiChargedDiodeIterator i_chargedDiode=chargedDiodes.begin(); i_chargedDiode!=chargedDiodes.end(); ++i_chargedDiode) { Identifier diodeID = chargedDiodes.getId((*i_chargedDiode).first); + double charge = (*i_chargedDiode).second.charge(); // Apply analogu threshold, timing simulation double th0 = m_pixelCalibSvc->getThreshold(diodeID); @@ -90,45 +93,47 @@ void FEI3SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle double threshold = th0+m_pixelCalibSvc->getThresholdSigma(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine)+m_pixelCalibSvc->getNoise(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine); double intimethreshold = (ith0/th0)*threshold; - if ((*i_chargedDiode).second.charge()>threshold) { + if (charge>threshold) { int bunchSim; if ((*i_chargedDiode).second.totalCharge().fromTrack()) { - if (m_timingTune==2015) { bunchSim = m_TimeSvc->relativeBunch2015((*i_chargedDiode).second.totalCharge(),barrel_ec,layerIndex,moduleIndex); } - else { bunchSim = m_TimeSvc->relativeBunch2009(threshold,intimethreshold,(*i_chargedDiode).second.totalCharge(),1); } + if (m_timingTune==2015) { bunchSim = relativeBunch2015((*i_chargedDiode).second.totalCharge(),barrel_ec,layerIndex,moduleIndex); } + else { bunchSim = relativeBunch2009(threshold,intimethreshold,(*i_chargedDiode).second.totalCharge()); } } else { - bunchSim = CLHEP::RandFlat::shootInt(m_rndmEngine,m_TimeSvc->getTimeBCN()); + bunchSim = CLHEP::RandFlat::shootInt(m_rndmEngine,m_timeBCN); } - if (bunchSim<0 || bunchSim>m_TimeSvc->getTimeBCN()) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } - else { SiHelper::SetBunch((*i_chargedDiode).second,bunchSim); } + if (bunchSim<0 || bunchSim>m_timeBCN) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + else { SiHelper::SetBunch((*i_chargedDiode).second,bunchSim); } } else { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } - // Filter events - if (SiHelper::isMaskOut((*i_chargedDiode).second)) { continue; } - if (SiHelper::isDisabled((*i_chargedDiode).second)) { continue; } - - if (!m_pixelConditionsSvc->isActive(moduleHash,diodeID)) { - SiHelper::disabled((*i_chargedDiode).second,true,true); - continue; - } - + if (barrel_ec==0 && charge<m_BarrelAnalogthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + if (barrel_ec!=0 && charge<m_EndcapAnalogthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } // charge to ToT conversion - double tot = m_pixelCalibSvc->getTotMean(diodeID,(*i_chargedDiode).second.charge()); + double tot = m_pixelCalibSvc->getTotMean(diodeID,charge); double totsig = m_pixelCalibSvc->getTotRes(diodeID,tot); int nToT = static_cast<int>(CLHEP::RandGaussZiggurat::shoot(m_rndmEngine,tot,totsig)); if (nToT<1) { nToT=1; } - if (barrel_ec==0 && nToT<=m_BarrelToTthreshold.at(layerIndex)) { continue; } - if (barrel_ec!=0 && nToT<=m_EndcapToTthreshold.at(layerIndex)) { continue; } + if (barrel_ec==0 && nToT<=m_BarrelToTthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + if (barrel_ec!=0 && nToT<=m_EndcapToTthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + + if (barrel_ec==0 && nToT>=m_BarrelLatency.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + if (barrel_ec!=0 && nToT>=m_EndcapLatency.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + + // Filter events + if (SiHelper::isMaskOut((*i_chargedDiode).second)) { continue; } + if (SiHelper::isDisabled((*i_chargedDiode).second)) { continue; } - if (barrel_ec==0 && nToT>=m_BarrelLatency.at(layerIndex)) { continue; } - if (barrel_ec!=0 && nToT>=m_EndcapLatency.at(layerIndex)) { continue; } + if (!m_pixelConditionsSvc->isActive(moduleHash,diodeID)) { + SiHelper::disabled((*i_chargedDiode).second,true,true); + continue; + } int flag = (*i_chargedDiode).second.flag(); int bunch = (flag>>8)&0xff; @@ -137,20 +142,20 @@ void FEI3SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle const Identifier id_readout = chargedDiodes.element()->identifierFromCellId(cellId); // Front-End simulation - if (bunch>=0 && bunch<m_TimeSvc->getTimeBCN()) { + if (bunch>=0 && bunch<m_timeBCN) { Pixel1RawData *p_rdo = new Pixel1RawData(id_readout,nToT,bunch,0,bunch); rdoCollection.push_back(p_rdo); } // Duplication mechanism for FEI3 small hits : if (barrel_ec==0 && m_BarrelHitDuplication.at(layerIndex)) { - if (nToT<=m_BarrelSmallHitToT.at(layerIndex) && bunch>0 && bunch<=m_TimeSvc->getTimeBCN()) { + if (nToT<=m_BarrelSmallHitToT.at(layerIndex) && bunch>0 && bunch<=m_timeBCN) { Pixel1RawData *p_rdo = new Pixel1RawData(id_readout,nToT,bunch-1,0,bunch-1); rdoCollection.push_back(p_rdo); } } if (barrel_ec!=0 && m_EndcapHitDuplication.at(layerIndex)) { - if (nToT<=m_EndcapSmallHitToT.at(layerIndex) && bunch>0 && bunch<=m_TimeSvc->getTimeBCN()) { + if (nToT<=m_EndcapSmallHitToT.at(layerIndex) && bunch>0 && bunch<=m_timeBCN) { Pixel1RawData *p_rdo = new Pixel1RawData(id_readout,nToT,bunch-1,0,bunch-1); rdoCollection.push_back(p_rdo); } @@ -159,4 +164,245 @@ void FEI3SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle return; } +int FEI3SimTool::relativeBunch2009(const double threshold, const double intimethreshold, const SiTotalCharge &totalCharge) const { + + int BCID=0; + double myTimeWalkEff = 0.; + double overdrive = intimethreshold - threshold ; + + //my TimeWalk computation through PARAMETRIZATION (by Francesco De Lorenzi - Milan) + //double curvature = 7.6e7*overdrive-2.64e10; + //double divergence = -1.6*overdrive+942 ; + //double myTimeWalk = curvature/(pow((totalCharge.charge()-divergence),2.5)); + + //my TimeWalk computation through PARAMETRIZATION from 2009 cosmic data (by I. Ibragimov and D. Miller) + double p1 = 20./log(intimethreshold/overdrive); + double p0 = p1 * log (1. - threshold/100000.); + + double myTimeWalk = -p0 -p1 * log(1. - threshold/totalCharge.charge()); + + myTimeWalkEff = myTimeWalk+myTimeWalk*0.2*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine); + + double randomjitter = CLHEP::RandFlat::shoot(m_rndmEngine,(-m_timeJitter/2.0),(m_timeJitter/2.0)); + + //double G4Time = totalCharge.time(); + + double G4Time = getG4Time(totalCharge); + double timing = m_timeZero+myTimeWalkEff+(randomjitter)+G4Time-m_comTime; + BCID = static_cast<int>(floor(timing/m_timePerBCO)); + //ATH_MSG_DEBUG ( CTW << " , " << myTimeWalkEff << " , " << G4Time << " , " << timing << " , " << BCID ); + + return BCID; +} + +// This is the new parameterization based on the 2015 collision data. +int FEI3SimTool::relativeBunch2015(const SiTotalCharge &totalCharge, int barrel_ec, int layer_disk, int moduleID) const { + + /** + * 2016.03.29 Soshi.Tsuno@cern.ch + * + * The time walk effect is directly tuned with timing scan data (collision) in 2015. + * + * See reference in the talk, + * https://indico.cern.ch/event/516099/contributions/1195889/attachments/1252177/1846815/pixelOffline_timing_04.04.2016_soshi.pdf + * + * Ideally, it could be directly parameterized as a function of given ToT. + * However, the ToT calibration was changed over 2015-2016, where newly calibrated ToT value was not available for 2016. + * For instance, the b-layer charge tuning was changed from ToT30@MIP (2015) to ToT18@MIP (2016). + * Thus the time walk effect needs to be parameterized with more universal value, that is, charge information. + * But it was non-trivial because of the migration effect between the border in ToT. + * + * Here in 2015 version, we apply the threshold of the 60% total charge to get a certain ToT value, + * which most describes the data timing structure. + * + * 60% working point tune-2 + */ + + double prob = 0.0; + if (barrel_ec==0 && layer_disk==1) { + if (abs(moduleID)==0) { + if (totalCharge.charge()<4100.0) { prob = 0.9349; } // corresponds to ToT=4 + else if (totalCharge.charge()<4150.0) { prob = 0.2520; } // ToT=5 + else if (totalCharge.charge()<4600.0) { prob = 0.0308; } // ToT=6 + else if (totalCharge.charge()<5250.0) { prob = 0.0160; } // ToT=7 + else if (totalCharge.charge()<5850.0) { prob = 0.0104; } // ToT=8 + else if (totalCharge.charge()<6500.0) { prob = 0.0127; } // ToT=9 + } + if (abs(moduleID)==1) { + if (totalCharge.charge()<4100.0) { prob = 0.9087; } + else if (totalCharge.charge()<4150.0) { prob = 0.2845; } + else if (totalCharge.charge()<4600.0) { prob = 0.0504; } + else if (totalCharge.charge()<5250.0) { prob = 0.0198; } + else if (totalCharge.charge()<5850.0) { prob = 0.0141; } + else if (totalCharge.charge()<6500.0) { prob = 0.0122; } + } + if (abs(moduleID)==2) { + if (totalCharge.charge()<4100.0) { prob = 0.9060; } + else if (totalCharge.charge()<4150.0) { prob = 0.2885; } + else if (totalCharge.charge()<4600.0) { prob = 0.0387; } + else if (totalCharge.charge()<5250.0) { prob = 0.0126; } + else if (totalCharge.charge()<5850.0) { prob = 0.0116; } + else if (totalCharge.charge()<6500.0) { prob = 0.0052; } + } + if (abs(moduleID)==3) { + if (totalCharge.charge()<4100.0) { prob = 0.8774; } + else if (totalCharge.charge()<4150.0) { prob = 0.3066; } + else if (totalCharge.charge()<4600.0) { prob = 0.0449; } + else if (totalCharge.charge()<5250.0) { prob = 0.0188; } + else if (totalCharge.charge()<5850.0) { prob = 0.0169; } + else if (totalCharge.charge()<6500.0) { prob = 0.0096; } + } + if (abs(moduleID)==4) { + if (totalCharge.charge()<4100.0) { prob = 0.8725; } + else if (totalCharge.charge()<4150.0) { prob = 0.2962; } + else if (totalCharge.charge()<4600.0) { prob = 0.0472; } + else if (totalCharge.charge()<5250.0) { prob = 0.0188; } + else if (totalCharge.charge()<5850.0) { prob = 0.0141; } + else if (totalCharge.charge()<6500.0) { prob = 0.0130; } + } + if (abs(moduleID)==5) { + if (totalCharge.charge()<4100.0) { prob = 0.8731; } + else if (totalCharge.charge()<4150.0) { prob = 0.3443; } + else if (totalCharge.charge()<4600.0) { prob = 0.0686; } + else if (totalCharge.charge()<5250.0) { prob = 0.0243; } + else if (totalCharge.charge()<5850.0) { prob = 0.0139; } + else if (totalCharge.charge()<6500.0) { prob = 0.0089; } + } + if (abs(moduleID)==6) { + if (totalCharge.charge()<4100.0) { prob = 0.8545; } + else if (totalCharge.charge()<4150.0) { prob = 0.2946; } + else if (totalCharge.charge()<4600.0) { prob = 0.0524; } + else if (totalCharge.charge()<5250.0) { prob = 0.0218; } + else if (totalCharge.charge()<5850.0) { prob = 0.0218; } + else if (totalCharge.charge()<6500.0) { prob = 0.0191; } + } + } + if (barrel_ec==0 && layer_disk==2) { + if (abs(moduleID)==0) { + if (totalCharge.charge()<4100.0) { prob = 0.9479; } + else if (totalCharge.charge()<4150.0) { prob = 0.6051; } + else if (totalCharge.charge()<4600.0) { prob = 0.2031; } + else if (totalCharge.charge()<5250.0) { prob = 0.0735; } + else if (totalCharge.charge()<5850.0) { prob = 0.0462; } + else if (totalCharge.charge()<6500.0) { prob = 0.0272; } + } + if (abs(moduleID)==1) { + if (totalCharge.charge()<4100.0) { prob = 0.9736; } + else if (totalCharge.charge()<4150.0) { prob = 0.6344; } + else if (totalCharge.charge()<4600.0) { prob = 0.2439; } + else if (totalCharge.charge()<5250.0) { prob = 0.1000; } + else if (totalCharge.charge()<5850.0) { prob = 0.0435; } + else if (totalCharge.charge()<6500.0) { prob = 0.0335; } + } + if (abs(moduleID)==2) { + if (totalCharge.charge()<4100.0) { prob = 0.9461; } + else if (totalCharge.charge()<4150.0) { prob = 0.6180; } + else if (totalCharge.charge()<4600.0) { prob = 0.1755; } + else if (totalCharge.charge()<5250.0) { prob = 0.0647; } + else if (totalCharge.charge()<5850.0) { prob = 0.0476; } + else if (totalCharge.charge()<6500.0) { prob = 0.0470; } + } + if (abs(moduleID)==3) { + if (totalCharge.charge()<4100.0) { prob = 0.9542; } + else if (totalCharge.charge()<4150.0) { prob = 0.5839; } + else if (totalCharge.charge()<4600.0) { prob = 0.1899; } + else if (totalCharge.charge()<5250.0) { prob = 0.0604; } + else if (totalCharge.charge()<5850.0) { prob = 0.0576; } + else if (totalCharge.charge()<6500.0) { prob = 0.0285; } + } + if (abs(moduleID)==4) { + if (totalCharge.charge()<4100.0) { prob = 0.9233; } + else if (totalCharge.charge()<4150.0) { prob = 0.5712; } + else if (totalCharge.charge()<4600.0) { prob = 0.1633; } + else if (totalCharge.charge()<5250.0) { prob = 0.0796; } + else if (totalCharge.charge()<5850.0) { prob = 0.0612; } + else if (totalCharge.charge()<6500.0) { prob = 0.0384; } + } + if (abs(moduleID)==5) { + if (totalCharge.charge()<4100.0) { prob = 0.8994; } + else if (totalCharge.charge()<4150.0) { prob = 0.5176; } + else if (totalCharge.charge()<4600.0) { prob = 0.1626; } + else if (totalCharge.charge()<5250.0) { prob = 0.0698; } + else if (totalCharge.charge()<5850.0) { prob = 0.0416; } + else if (totalCharge.charge()<6500.0) { prob = 0.0382; } + } + if (abs(moduleID)==6) { + if (totalCharge.charge()<4100.0) { prob = 0.8919; } + else if (totalCharge.charge()<4150.0) { prob = 0.5313; } + else if (totalCharge.charge()<4600.0) { prob = 0.1585; } + else if (totalCharge.charge()<5250.0) { prob = 0.0520; } + else if (totalCharge.charge()<5850.0) { prob = 0.0318; } + else if (totalCharge.charge()<6500.0) { prob = 0.0254; } + } + } + if (barrel_ec==0 && layer_disk==3) { + if (abs(moduleID)==0) { + if (totalCharge.charge()<4100.0) { prob = 0.9182; } + else if (totalCharge.charge()<4150.0) { prob = 0.6744; } + else if (totalCharge.charge()<4600.0) { prob = 0.3174; } + else if (totalCharge.charge()<5250.0) { prob = 0.1460; } + else if (totalCharge.charge()<5850.0) { prob = 0.1001; } + else if (totalCharge.charge()<6500.0) { prob = 0.0587; } + } + if (abs(moduleID)==1) { + if (totalCharge.charge()<4100.0) { prob = 0.9255; } + else if (totalCharge.charge()<4150.0) { prob = 0.6995; } + else if (totalCharge.charge()<4600.0) { prob = 0.3046; } + else if (totalCharge.charge()<5250.0) { prob = 0.1449; } + else if (totalCharge.charge()<5850.0) { prob = 0.0954; } + else if (totalCharge.charge()<6500.0) { prob = 0.0608; } + } + if (abs(moduleID)==2) { + if (totalCharge.charge()<4100.0) { prob = 0.9419; } + else if (totalCharge.charge()<4150.0) { prob = 0.7380; } + else if (totalCharge.charge()<4600.0) { prob = 0.3346; } + else if (totalCharge.charge()<5250.0) { prob = 0.1615; } + else if (totalCharge.charge()<5850.0) { prob = 0.0726; } + else if (totalCharge.charge()<6500.0) { prob = 0.0564; } + } + if (abs(moduleID)==3) { + if (totalCharge.charge()<4100.0) { prob = 0.9319; } + else if (totalCharge.charge()<4150.0) { prob = 0.6747; } + else if (totalCharge.charge()<4600.0) { prob = 0.2640; } + else if (totalCharge.charge()<5250.0) { prob = 0.1018; } + else if (totalCharge.charge()<5850.0) { prob = 0.0588; } + else if (totalCharge.charge()<6500.0) { prob = 0.0502; } + } + if (abs(moduleID)==4) { + if (totalCharge.charge()<4100.0) { prob = 0.9276; } + else if (totalCharge.charge()<4150.0) { prob = 0.6959; } + else if (totalCharge.charge()<4600.0) { prob = 0.2859; } + else if (totalCharge.charge()<5250.0) { prob = 0.1214; } + else if (totalCharge.charge()<5850.0) { prob = 0.0776; } + else if (totalCharge.charge()<6500.0) { prob = 0.0387; } + } + if (abs(moduleID)==5) { + if (totalCharge.charge()<4100.0) { prob = 0.8845; } + else if (totalCharge.charge()<4150.0) { prob = 0.6270; } + else if (totalCharge.charge()<4600.0) { prob = 0.2798; } + else if (totalCharge.charge()<5250.0) { prob = 0.1209; } + else if (totalCharge.charge()<5850.0) { prob = 0.0706; } + else if (totalCharge.charge()<6500.0) { prob = 0.0703; } + } + if (abs(moduleID)==6) { + if (totalCharge.charge()<4100.0) { prob = 0.8726; } + else if (totalCharge.charge()<4150.0) { prob = 0.6358; } + else if (totalCharge.charge()<4600.0) { prob = 0.2907; } + else if (totalCharge.charge()<5250.0) { prob = 0.1051; } + else if (totalCharge.charge()<5850.0) { prob = 0.0646; } + else if (totalCharge.charge()<6500.0) { prob = 0.0685; } + } + } + + double G4Time = getG4Time(totalCharge); + double rnd = CLHEP::RandFlat::shoot(m_rndmEngine,0.0,1.0); + + double timeWalk = 0.0; + if (rnd<prob) { timeWalk = 25.0; } + + int BCID = static_cast<int>(floor((G4Time+m_timeZero+timeWalk)/m_timePerBCO)); + + return BCID; +} + diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.h index b7c9c41d8116104f0b5b240f7250a3a8062204b4..4084f5777b126737e8255b67026771d2d0393f41 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI3SimTool.h @@ -28,6 +28,10 @@ class FEI3SimTool:public FrontEndSimTool { int m_timingTune; + int relativeBunch2009(const double threshold, const double intimethreshold, const SiTotalCharge &totalCharge) const; + + int relativeBunch2015(const SiTotalCharge &totalCharge, int barrel_ec, int layer_disk, int moduleID) const; + }; #endif // PIXELDIGITIZATION_FEI3SimTool_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.cxx index de08274927e9dcb7ebbb254db5a8b5d6a4766967..233abfe20986f68036050518cf18cdad3a5936f6 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.cxx @@ -9,13 +9,13 @@ #include "SiDigitization/SiHelper.h" #include "InDetReadoutGeometry/SiReadoutCellId.h" +#include "CLHEP/Random/RandFlat.h" + FEI4SimTool::FEI4SimTool( const std::string& type, const std::string& name,const IInterface* parent): FrontEndSimTool(type,name,parent), - m_HitDiscConfig(2), - m_timingTune(2015) + m_HitDiscConfig(2) { declareProperty("HitDiscConfig", m_HitDiscConfig); - declareProperty("TimingTune", m_timingTune, "Version of the timing calibration"); } FEI4SimTool::~FEI4SimTool() { } @@ -52,7 +52,6 @@ void FEI4SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle int barrel_ec = pixelId->barrel_ec(chargedDiodes.element()->identify()); int layerIndex = pixelId->layer_disk(chargedDiodes.element()->identify()); - int moduleIndex = pixelId->eta_module(chargedDiodes.element()->identify()); std::vector<Pixel1RawData*> p_rdo_small_fei4; int nSmallHitsFEI4 = 0; @@ -64,48 +63,41 @@ void FEI4SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle for (SiChargedDiodeIterator i_chargedDiode=chargedDiodes.begin(); i_chargedDiode!=chargedDiodes.end(); ++i_chargedDiode) { Identifier diodeID = chargedDiodes.getId((*i_chargedDiode).first); + double charge = (*i_chargedDiode).second.charge(); // Apply analogu threshold, timing simulation double th0 = m_pixelCalibSvc->getThreshold(diodeID); double ith0 = m_pixelCalibSvc->getTimeWalk(diodeID); double threshold = th0+m_pixelCalibSvc->getThresholdSigma(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine)+m_pixelCalibSvc->getNoise(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine); - double intimethreshold = (ith0/th0)*threshold; - if ((*i_chargedDiode).second.charge()>threshold) { + if (charge>threshold) { int bunchSim; if ((*i_chargedDiode).second.totalCharge().fromTrack()) { - if (m_timingTune==2015) { bunchSim = m_TimeSvc->relativeBunch2015((*i_chargedDiode).second.totalCharge(),barrel_ec,layerIndex,moduleIndex); } - else { bunchSim = m_TimeSvc->relativeBunch2009(threshold,intimethreshold,(*i_chargedDiode).second.totalCharge(),0); } + bunchSim = static_cast<int>(floor((getG4Time((*i_chargedDiode).second.totalCharge())+m_timeZero)/m_timePerBCO)); } else { - bunchSim = CLHEP::RandFlat::shootInt(m_rndmEngine,m_TimeSvc->getTimeBCN()); + bunchSim = CLHEP::RandFlat::shootInt(m_rndmEngine,m_timeBCN); } - if (bunchSim<0 || bunchSim>m_TimeSvc->getTimeBCN()) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } - else { SiHelper::SetBunch((*i_chargedDiode).second,bunchSim); } + if (bunchSim<0 || bunchSim>m_timeBCN) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + else { SiHelper::SetBunch((*i_chargedDiode).second,bunchSim); } } else { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } - // Filter events - if (SiHelper::isMaskOut((*i_chargedDiode).second)) { continue; } - if (SiHelper::isDisabled((*i_chargedDiode).second)) { continue; } - - if (!m_pixelConditionsSvc->isActive(moduleHash,diodeID)) { - SiHelper::disabled((*i_chargedDiode).second,true,true); - continue; - } + if (barrel_ec==0 && charge<m_BarrelAnalogthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + if (barrel_ec!=0 && charge<m_EndcapAnalogthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } // charge to ToT conversion - double tot = m_pixelCalibSvc->getTotMean(diodeID,(*i_chargedDiode).second.charge()); + double tot = m_pixelCalibSvc->getTotMean(diodeID,charge); double totsig = m_pixelCalibSvc->getTotRes(diodeID,tot); int nToT = static_cast<int>(CLHEP::RandGaussZiggurat::shoot(m_rndmEngine,tot,totsig)); const PixelID* pixelId = static_cast<const PixelID*>(chargedDiodes.element()->getIdHelper()); if (pixelId->is_dbm(chargedDiodes.element()->identify())) { - nToT = 8*((*i_chargedDiode).second.charge() - 1200. )/(8000. - 1200.); + nToT = 8*(charge - 1200. )/(8000. - 1200.); } if (nToT<1) { nToT=1; } @@ -114,8 +106,17 @@ void FEI4SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle if (nToT==2 && maxFEI4SmallHit==2) { nToT=1; } if (nToT>=overflowToT) { nToT=overflowToT; } - if (barrel_ec==0 && nToT<=m_BarrelToTthreshold.at(layerIndex)) { continue; } - if (barrel_ec!=0 && nToT<=m_EndcapToTthreshold.at(layerIndex)) { continue; } + if (barrel_ec==0 && nToT<=m_BarrelToTthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + if (barrel_ec!=0 && nToT<=m_EndcapToTthreshold.at(layerIndex)) { SiHelper::belowThreshold((*i_chargedDiode).second,true,true); } + + // Filter events + if (SiHelper::isMaskOut((*i_chargedDiode).second)) { continue; } + if (SiHelper::isDisabled((*i_chargedDiode).second)) { continue; } + + if (!m_pixelConditionsSvc->isActive(moduleHash,diodeID)) { + SiHelper::disabled((*i_chargedDiode).second,true,true); + continue; + } int flag = (*i_chargedDiode).second.flag(); int bunch = (flag>>8)&0xff; @@ -128,7 +129,7 @@ void FEI4SimTool::process(SiChargedDiodeCollection &chargedDiodes,PixelRDO_Colle if (iicol>=maxCol) { iicol=iicol-maxCol; } // FEI4 copy mechanism works per FE. // Front-End simulation - if (bunch>=0 && bunch<m_TimeSvc->getTimeBCN()) { + if (bunch>=0 && bunch<m_timeBCN) { Pixel1RawData *p_rdo = new Pixel1RawData(id_readout,nToT,bunch,0,bunch); if (nToT>maxFEI4SmallHit) { rdoCollection.push_back(p_rdo); diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.h index c38774a8789c98393239e0e50f26d5092a95e0c5..0bc97c27888e5e4edccc0a30a1a3df69a3c92f45 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/FEI4SimTool.h @@ -22,7 +22,6 @@ class FEI4SimTool:public FrontEndSimTool { FEI4SimTool(); int m_HitDiscConfig; - int m_timingTune; }; #endif // PIXELDIGITIZATION_FEI4SimTool_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/FrontEndSimTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/FrontEndSimTool.h index 90a68cf66654c9573d1b978811e41d89c61ac517..480e4161e31efab13417ec30413088bf6357dbc9 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/FrontEndSimTool.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/FrontEndSimTool.h @@ -17,7 +17,9 @@ #include "InDetConditionsSummaryService/IInDetConditionsSvc.h" #include "PixelConditionsServices/IPixelCalibSvc.h" -#include "TimeSvc.h" +#include "InDetSimEvent/SiTotalCharge.h" + +#include "CommissionEvent/ComTime.h" static const InterfaceID IID_IFrontEndSimTool("FrontEndSimTool", 1, 0); @@ -31,7 +33,16 @@ class FrontEndSimTool:public AthAlgTool,virtual public IAlgTool { m_rndmEngine(nullptr), m_pixelConditionsSvc("PixelConditionsSummarySvc",name), m_pixelCalibSvc("PixelCalibSvc",name), - m_TimeSvc("TimeSvc",name), + m_timeBCN(1), + m_timeZero(5.0), + m_timePerBCO(25.0), + m_useComTime(false), + m_ComputedTime(nullptr), + m_comTime(0.0), + m_timeJitter(0.0), + m_eventStore("StoreGateSvc", name), + m_BarrelAnalogthreshold({-1,-1,-1,-1,-1,-1,-1}), + m_EndcapAnalogthreshold({-1,-1,-1,-1,-1,-1,-1}), m_BarrelToTthreshold({-1,-1,-1,-1,-1,-1,-1}), m_EndcapToTthreshold({-1,-1,-1,-1,-1,-1,-1}), m_BarrelLatency({256,256,256,256,256,256,256}), @@ -42,7 +53,13 @@ class FrontEndSimTool:public AthAlgTool,virtual public IAlgTool { declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); declareProperty("PixelConditionsSummarySvc", m_pixelConditionsSvc); declareProperty("PixelCalibSvc", m_pixelCalibSvc); - declareProperty("TimeSvc", m_TimeSvc); + declareProperty("TimeBCN", m_timeBCN, "Number of BCID"); + declareProperty("TimeZero", m_timeZero, "Time zero...?"); + declareProperty("TimePerBCO", m_timePerBCO, "Time per BCO - should be 25ns"); + declareProperty("UseComTime", m_useComTime, "Use ComTime for timing"); + declareProperty("TimeJitter", m_timeJitter, "Time jitter"); + declareProperty("BarrelAnalogthreshold", m_BarrelAnalogthreshold); + declareProperty("EndcapAnalogthreshold", m_EndcapAnalogthreshold); declareProperty("BarrelToTthreshold", m_BarrelToTthreshold); declareProperty("EndcapToTthreshold", m_EndcapToTthreshold); declareProperty("BarrelLatency", m_BarrelLatency); @@ -60,8 +77,6 @@ class FrontEndSimTool:public AthAlgTool,virtual public IAlgTool { CHECK(m_pixelCalibSvc.retrieve()); - CHECK(m_TimeSvc.retrieve()); - m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); if (!m_rndmEngine) { ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); @@ -71,6 +86,17 @@ class FrontEndSimTool:public AthAlgTool,virtual public IAlgTool { ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); } + if (m_useComTime) { + CHECK(m_eventStore.retrieve()); + if (StatusCode::SUCCESS==m_eventStore->retrieve(m_ComputedTime,"ComTime")) { + m_comTime = m_ComputedTime->getTime(); + ATH_MSG_DEBUG("Found tool for cosmic/commissioning timing: ComTime"); + } + else { + ATH_MSG_WARNING("Did not find tool needed for cosmic/commissioning timing: ComTime"); + } + } + return StatusCode::SUCCESS; } @@ -88,13 +114,48 @@ class FrontEndSimTool:public AthAlgTool,virtual public IAlgTool { ServiceHandle<IInDetConditionsSvc> m_pixelConditionsSvc; ServiceHandle<IPixelCalibSvc> m_pixelCalibSvc; - ServiceHandle<TimeSvc> m_TimeSvc; + double m_timeBCN; + double m_timeZero; + double m_timePerBCO; + bool m_useComTime; /**< use ComTime for timing */ + ComTime *m_ComputedTime; + double m_comTime; /**< cosmics timing ofs */ + double m_timeJitter; + ServiceHandle<StoreGateSvc> m_eventStore; + std::vector<int> m_BarrelAnalogthreshold; + std::vector<int> m_EndcapAnalogthreshold; std::vector<int> m_BarrelToTthreshold; std::vector<int> m_EndcapToTthreshold; std::vector<int> m_BarrelLatency; std::vector<int> m_EndcapLatency; + double getG4Time(const SiTotalCharge &totalCharge) const { + // If there is one single charge, return its time: + if (totalCharge.chargeComposition().empty()) { return totalCharge.time(); } + + std::list<SiCharge>::const_iterator p_charge=totalCharge.chargeComposition().begin(); + int findfirst = 0; + SiCharge first = *p_charge; + + // Look for first charge which is not noise + for ( ; p_charge!=totalCharge.chargeComposition().end() ; p_charge++) { + if (p_charge->processType()!=SiCharge::noise) { findfirst=1; break; } + } + + // if all charges were noise, return the time of the highest charge + if (findfirst == 0) { return totalCharge.time(); } + + // look for the earlist charge among the remaining non-noise charges: + first = *p_charge; + p_charge++; + + for ( ; p_charge!=totalCharge.chargeComposition().end() ; p_charge++) { + if (p_charge->time()<first.time() && p_charge->processType()!=SiCharge::noise) { first=*p_charge; } + } + return first.time(); + } + }; #endif // PIXELDIGITIZATION_FrontEndSimTool_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx index f6444313136b0dfe4c48eed7f2b852d8846414b5..71a774b1638b5089668983d96fe12e522d6c2cbe 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx @@ -13,6 +13,7 @@ #include "InDetReadoutGeometry/SiCellId.h" #include "InDetReadoutGeometry/SiReadoutCellId.h" +#include "CLHEP/Random/RandFlat.h" #include "CLHEP/Random/RandPoisson.h" #include<fstream> @@ -23,15 +24,16 @@ PixelNoisyCellGenerator::PixelNoisyCellGenerator(const std::string& type, const std::string& name,const IInterface* parent): PixelProcessorTool(type,name,parent), - m_TimeSvc("TimeSvc",name), m_pixelCalibSvc("PixelCalibSvc", name), + m_timeBCN(1), m_mergeCharge(false), m_pixelID(0), m_rndNoiseProb(5e-8) { - declareProperty("NoiseShape",m_noiseShape,"Vector containing noise ToT shape"); - declareProperty("MergeCharge", m_mergeCharge, ""); - declareProperty("RndNoiseProb", m_rndNoiseProb, "Random noisy pixels, amplitude from calib. - NOT special pixels!"); + declareProperty("TimeBCN", m_timeBCN, "Number of BCID"); + declareProperty("NoiseShape", m_noiseShape, "Vector containing noise ToT shape"); + declareProperty("MergeCharge", m_mergeCharge, ""); + declareProperty("RndNoiseProb", m_rndNoiseProb, "Random noisy pixels, amplitude from calib. - NOT special pixels!"); } PixelNoisyCellGenerator::~PixelNoisyCellGenerator() {} @@ -39,8 +41,6 @@ PixelNoisyCellGenerator::~PixelNoisyCellGenerator() {} StatusCode PixelNoisyCellGenerator::initialize() { CHECK(PixelProcessorTool::initialize()); - CHECK(m_TimeSvc.retrieve()); - CHECK(m_pixelCalibSvc.retrieve()); ATH_MSG_DEBUG("Retrieved PixelCalibSvc"); @@ -71,9 +71,6 @@ void PixelNoisyCellGenerator::process(SiChargedDiodeCollection &collection) { void PixelNoisyCellGenerator::addRandomNoise(SiChargedDiodeCollection &collection, double occupancy) const { - // number of bunch crossings - int bcn = m_TimeSvc->getTimeBCN(); - // get pixel module design and check it const InDetDD::PixelModuleDesign *p_design = static_cast<const InDetDD::PixelModuleDesign *>(&(collection.design())); @@ -85,7 +82,7 @@ void PixelNoisyCellGenerator::addRandomNoise(SiChargedDiodeCollection &collectio *p_design->columnsPerCircuit() // =18 *p_design->rowsPerCircuit() // =320 *occupancy - *static_cast<double>(bcn)); + *static_cast<double>(m_timeBCN)); for (int i=0; i<number_rndm; i++) { int circuit = CLHEP::RandFlat::shootInt(m_rndmEngine,p_design->numberOfCircuits()); diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h index 8fd6b926c089bdaa371d4f43ebb0bbd55674e9ed..0da7e0c02b264ce82d1a0c3dca07741dd9e2cf48 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h @@ -13,7 +13,6 @@ #include "PixelProcessorTool.h" -#include "TimeSvc.h" #include "PixelConditionsServices/IPixelCalibSvc.h" #include "InDetReadoutGeometry/PixelModuleDesign.h" @@ -33,8 +32,8 @@ class PixelNoisyCellGenerator:public PixelProcessorTool { private: PixelNoisyCellGenerator(); - ServiceHandle<TimeSvc> m_TimeSvc; ServiceHandle<IPixelCalibSvc> m_pixelCalibSvc; + double m_timeBCN; bool m_mergeCharge; std::vector<double> m_noiseShape; void addRandomNoise(SiChargedDiodeCollection &collection, double occupancy) const; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx index 3b201d2cfc833bd5d68b27d0b8fa63168017a2e7..645d3ab731b51f3e74b61fdb14965761c854929d 100755 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx @@ -6,12 +6,12 @@ #include "src/PixelChargeSmearer.h" #include "src/PixelDiodeCrossTalkGenerator.h" #include "src/PixelRandomDisabledCellGenerator.h" -#include "src/TimeSvc.h" #include "src/PixelPlanarChargeTool.h" #include "src/Pixel3DChargeTool.h" #include "src/DBMChargeTool.h" #include "src/ChargeCollProbSvc.h" #include "src/BichselSimTool.h" +#include "src/RD53SimTool.h" #include "src/FEI4SimTool.h" #include "src/FEI3SimTool.h" @@ -25,10 +25,10 @@ DECLARE_TOOL_FACTORY(PixelRandomDisabledCellGenerator) DECLARE_TOOL_FACTORY(PixelPlanarChargeTool) DECLARE_TOOL_FACTORY(Pixel3DChargeTool) DECLARE_TOOL_FACTORY(DBMChargeTool) +DECLARE_TOOL_FACTORY(RD53SimTool) DECLARE_TOOL_FACTORY(FEI4SimTool) DECLARE_TOOL_FACTORY(FEI3SimTool) DECLARE_SERVICE_FACTORY(ChargeCollProbSvc) -DECLARE_SERVICE_FACTORY(TimeSvc) DECLARE_FACTORY_ENTRIES(PixelDigitization) { DECLARE_ALGORITHM(PixelDigitization) @@ -41,9 +41,9 @@ DECLARE_FACTORY_ENTRIES(PixelDigitization) { DECLARE_TOOL(PixelPlanarChargeTool) DECLARE_TOOL(Pixel3DChargeTool) DECLARE_TOOL(DBMChargeTool) + DECLARE_TOOL(RD53SimTool) DECLARE_TOOL(FEI4SimTool) DECLARE_TOOL(FEI3SimTool) DECLARE_SERVICE(ChargeCollProbSvc) - DECLARE_SERVICE(TimeSvc) } diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx index c83509ba10da818331685036f687995ff2198c2a..e044f4a24c825c6a739338f0c111225c67c71f1c 100755 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx @@ -2,4 +2,3 @@ LOAD_FACTORY_ENTRIES( PixelDigitization ) LOAD_FACTORY_ENTRIES( ChargeCollProbSvc ) -LOAD_FACTORY_ENTRIES( TimeSvc )