CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DTTTrigCorrectionFirst Class Reference

#include <DTTTrigCorrectionFirst.h>

Inheritance diagram for DTTTrigCorrectionFirst:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 
void beginJob () override
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 DTTTrigCorrectionFirst (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob () override
 
 ~DTTTrigCorrectionFirst () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::string dbLabel
 
bool debug
 
edm::ESHandle< DTGeometrymuonGeom
 
double rmsLimit
 
const DTTtrigtTrigMap
 
double ttrigMax
 
double ttrigMin
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 20 of file DTTTrigCorrectionFirst.h.

Constructor & Destructor Documentation

◆ DTTTrigCorrectionFirst()

DTTTrigCorrectionFirst::DTTTrigCorrectionFirst ( const edm::ParameterSet pset)

Constructor.

Definition at line 28 of file DTTTrigCorrectionFirst.cc.

28  {
29  debug = pset.getUntrackedParameter<bool>("debug", false);
30  ttrigMin = pset.getUntrackedParameter<double>("ttrigMin", 0);
31  ttrigMax = pset.getUntrackedParameter<double>("ttrigMax", 5000);
32  rmsLimit = pset.getUntrackedParameter<double>("rmsLimit", 5.);
33 
34  dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
35 }

References TriggerEventFlag_cfi::dbLabel, debug, and muonDTDigis_cfi::pset.

◆ ~DTTTrigCorrectionFirst()

DTTTrigCorrectionFirst::~DTTTrigCorrectionFirst ( )
override

Destructor.

Definition at line 37 of file DTTTrigCorrectionFirst.cc.

37 {}

Member Function Documentation

◆ analyze()

void DTTTrigCorrectionFirst::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
inlineoverridevirtual

Implements edm::EDAnalyzer.

Definition at line 32 of file DTTTrigCorrectionFirst.h.

32 {}

◆ beginJob()

void DTTTrigCorrectionFirst::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 30 of file DTTTrigCorrectionFirst.h.

30 {}

◆ beginRun()

void DTTTrigCorrectionFirst::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file DTTTrigCorrectionFirst.cc.

39  {
41  setup.get<DTTtrigRcd>().get(dbLabel, tTrig);
42  tTrigMap = &*tTrig;
43  cout << "[DTTTrigCorrection]: TTrig version: " << tTrig->version() << endl;
44 
46 }

References gather_cfg::cout, TriggerEventFlag_cfi::dbLabel, edm::get(), singleTopDQM_cfi::setup, and dttriganalyzer_cfi::tTrig.

◆ endJob()

void DTTTrigCorrectionFirst::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 48 of file DTTTrigCorrectionFirst.cc.

48  {
49  // Create the object to be written to DB
50  DTTtrig* tTrigNewMap = new DTTtrig();
51  //Get the superlayers list
52  vector<const DTSuperLayer*> dtSupLylist = muonGeom->superLayers();
53 
54  //Loop on all superlayers to compute the mean
55  double average = 0.;
56  double average2 = 0.;
57  double rms = 0.;
58  double averageSigma = 0.;
59  double average2Sigma = 0.;
60  double rmsSigma = 0.;
61  double counter = 0.;
62  double averagekfactor = 0;
63  float kfactor = 0;
64 
65  for (auto sl = dtSupLylist.begin(); sl != dtSupLylist.end(); sl++) {
66  float ttrigMean = 0;
67  float ttrigSigma = 0;
68  tTrigMap->get((*sl)->id(), ttrigMean, ttrigSigma, kfactor, DTTimeUnits::ns);
69  if (ttrigMean < ttrigMax && ttrigMean > ttrigMin) {
70  average += ttrigMean;
71  averageSigma += ttrigSigma;
72  if (ttrigMean > 0)
73  counter += 1.;
74  }
75  } //End of loop on superlayers
76 
78  averageSigma = averageSigma / counter;
79  averagekfactor = kfactor;
80 
81  // cout << " average counter "<< average << " "<< counter <<endl;
82 
83  for (auto sl = dtSupLylist.begin(); sl != dtSupLylist.end(); sl++) {
84  float ttrigMean = 0;
85  float ttrigSigma = 0;
86  float kfactor = 0;
87  tTrigMap->get((*sl)->id(), ttrigMean, ttrigSigma, kfactor, DTTimeUnits::ns);
88  if (ttrigMean < ttrigMax && ttrigMean > ttrigMin) {
89  average2 += (ttrigMean - average) * (ttrigMean - average);
90  average2Sigma += (ttrigSigma - averageSigma) * (ttrigSigma - averageSigma);
91  }
92  } //End of loop on superlayers
93 
94  rms = average2 / (counter - 1);
95  rmsSigma = average2Sigma / (counter - 1);
96  rms = sqrt(rms);
97  rmsSigma = sqrt(rmsSigma);
98  cout << "average averageSigma counter rms " << average << " " << averageSigma << " " << counter << " " << rms << endl;
99 
100  for (auto sl = dtSupLylist.begin(); sl != dtSupLylist.end(); sl++) {
101  //Compute new ttrig
102  double newTTrigMean = 0;
103  double newTTrigSigma = 0;
104  double newkfactor = 0;
105  float tempttrigMean = 0;
106  float tempttrigSigma = 0;
107  float tempkfactor = 0;
108  float ttrigMean = 0;
109  float ttrigSigma = 0;
110  float kfactor = 0;
111  tTrigMap->get((*sl)->id(), ttrigMean, ttrigSigma, kfactor, DTTimeUnits::ns);
112  int chamber = (*sl)->id().chamberId().station();
113 
114  //check if ttrigMean is similar to the mean
115  if (abs(ttrigMean - average) < rmsLimit * rms) {
116  newTTrigMean = ttrigMean;
117  newTTrigSigma = ttrigSigma;
118  newkfactor = kfactor;
119  } else {
120  // do not consider if ttrig == 0
121  if (ttrigMean > 0) {
122  //cout << "ttrig chamber " << ttrigMean <<" "<<chamber<<endl;
123  if (((*sl)->id().superlayer()) == 1) {
124  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
125  DTSuperLayerId slId((*sl)->id().chamberId(), 3);
126  tTrigMap->get(slId, tempttrigMean, tempttrigSigma, tempkfactor, DTTimeUnits::ns);
127  if (abs(tempttrigMean - average) < rmsLimit * rms) {
128  newTTrigMean = tempttrigMean;
129  newTTrigSigma = tempttrigSigma;
130  newkfactor = tempkfactor;
131  cout << "Chamber " << chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig " << ttrigMean
132  << " -> takes value of sl 3 " << newTTrigMean << endl;
133  } else if (chamber == 4) {
134  cout << "No correction possible within same chamber (sl1) " << endl;
135  newTTrigMean = average;
136  newTTrigSigma = averageSigma;
137  newkfactor = averagekfactor;
138  cout << "####### Bad SL: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
139  } else if (chamber != 4) {
140  DTSuperLayerId slId((*sl)->id().chamberId(), 2);
141  tTrigMap->get(slId, tempttrigMean, tempttrigSigma, tempkfactor, DTTimeUnits::ns);
142  if (abs(tempttrigMean - average) < rmsLimit * rms) {
143  newTTrigMean = tempttrigMean;
144  newTTrigSigma = tempttrigSigma;
145  newkfactor = tempkfactor;
146  cout << "Chamber " << chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig " << ttrigMean
147  << " -> takes value of sl 2 " << newTTrigMean << endl;
148  } else {
149  cout << "No correction possible within same chamber (sl1) " << endl;
150  newTTrigMean = average;
151  newTTrigSigma = averageSigma;
152  newkfactor = averagekfactor;
153  cout << "####### Bad SL: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
154  }
155  }
156  } else if (((*sl)->id().superlayer()) == 2) {
157  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
158  DTSuperLayerId slId((*sl)->id().chamberId(), 1);
159  tTrigMap->get(slId, tempttrigMean, tempttrigSigma, tempkfactor, DTTimeUnits::ns);
160  if (abs(tempttrigMean - average) < rmsLimit * rms) {
161  newTTrigMean = tempttrigMean;
162  newTTrigSigma = tempttrigSigma;
163  newkfactor = tempkfactor;
164  cout << "Chamber " << chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig " << ttrigMean
165  << " -> takes value of sl 1 " << newTTrigMean << endl;
166  } else {
167  DTSuperLayerId slId((*sl)->id().chamberId(), 3);
168  tTrigMap->get(slId, tempttrigMean, tempttrigSigma, tempkfactor, DTTimeUnits::ns);
169  if (abs(tempttrigMean - average) < rmsLimit * rms) {
170  newTTrigMean = tempttrigMean;
171  newTTrigSigma = tempttrigSigma;
172  newkfactor = tempkfactor;
173  cout << "Chamber " << chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig " << ttrigMean
174  << "-> takes value of sl 3 " << newTTrigMean << endl;
175  } else {
176  cout << "No correction possible within same chamber (sl2) " << endl;
177  newTTrigMean = average;
178  newTTrigSigma = averageSigma;
179  newkfactor = averagekfactor;
180  cout << "####### Bad SL: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
181  }
182  }
183 
184  } else if (((*sl)->id().superlayer()) == 3) {
185  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
186  DTSuperLayerId slId((*sl)->id().chamberId(), 1);
187  tTrigMap->get(slId, tempttrigMean, tempttrigSigma, tempkfactor, DTTimeUnits::ns);
188  if (abs(tempttrigMean - average) < rmsLimit * rms) {
189  newTTrigMean = tempttrigMean;
190  newTTrigSigma = tempttrigSigma;
191  newkfactor = tempkfactor;
192  cout << "Chamber " << chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig " << ttrigMean
193  << " -> takes value of sl 1 " << newTTrigMean << endl;
194  } else if (chamber == 4) {
195  cout << "No correction possible within same chamber (sl3)" << endl;
196  newTTrigMean = average;
197  newTTrigSigma = averageSigma;
198  newkfactor = averagekfactor;
199  cout << "####### Bad SL: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
200  } else if (chamber != 4) {
201  DTSuperLayerId slId((*sl)->id().chamberId(), 2);
202  tTrigMap->get(slId, tempttrigMean, tempttrigSigma, tempkfactor, DTTimeUnits::ns);
203  if (abs(tempttrigMean - average) < rmsLimit * rms) {
204  newTTrigMean = tempttrigMean;
205  newTTrigSigma = tempttrigSigma;
206  newkfactor = tempkfactor;
207  cout << "Chamber " << chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig " << ttrigMean
208  << " -> takes value of sl 2 " << newTTrigMean << endl;
209  } else {
210  cout << "No correction possible within same chamber (sl3) " << endl;
211  newTTrigMean = average;
212  newTTrigSigma = averageSigma;
213  newkfactor = averagekfactor;
214  cout << "####### Bad SL: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
215  }
216  }
217  }
218  } else {
219  // cout << "SL not present " << ttrigMean << " " <<((*sl)->id().superlayer()) <<endl;
220  newTTrigMean = average;
221  newTTrigSigma = averageSigma;
222  newkfactor = averagekfactor;
223  cout << "####### NotPresent SL: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
224  }
225  }
226 
227  //Store new ttrig in the new map
228  tTrigNewMap->set((*sl)->id(), newTTrigMean, newTTrigSigma, newkfactor, DTTimeUnits::ns);
229  if (debug) {
230  cout << "New tTrig: " << (*sl)->id() << " from " << ttrigMean << " to " << newTTrigMean << endl;
231  cout << "New tTrigSigma: " << (*sl)->id() << " from " << ttrigSigma << " to " << newTTrigSigma << endl;
232  }
233  } //End of loop on superlayers
234 
235  //Write object to DB
236  cout << "[DTTTrigCorrection]: Writing ttrig object to DB!" << endl;
237  string record = "DTTtrigRcd";
238  DTCalibDBUtils::writeToDB<DTTtrig>(record, tTrigNewMap);
239 }

References funct::abs(), PDRates::average, relativeConstraints::chamber, counter, gather_cfg::cout, debug, kfactor, DTTimeUnits::ns, GlobalPosition_Frontier_DevDB_cff::record, SiStripPI::rms, DTTtrig::set(), and mathSSE::sqrt().

Referenced by o2olib.O2ORunMgr::executeJob().

Member Data Documentation

◆ dbLabel

std::string DTTTrigCorrectionFirst::dbLabel
private

Definition at line 41 of file DTTTrigCorrectionFirst.h.

◆ debug

bool DTTTrigCorrectionFirst::debug
private

◆ muonGeom

edm::ESHandle<DTGeometry> DTTTrigCorrectionFirst::muonGeom
private

Definition at line 39 of file DTTTrigCorrectionFirst.h.

◆ rmsLimit

double DTTTrigCorrectionFirst::rmsLimit
private

Definition at line 44 of file DTTTrigCorrectionFirst.h.

◆ tTrigMap

const DTTtrig* DTTTrigCorrectionFirst::tTrigMap
private

Definition at line 38 of file DTTTrigCorrectionFirst.h.

◆ ttrigMax

double DTTTrigCorrectionFirst::ttrigMax
private

Definition at line 44 of file DTTTrigCorrectionFirst.h.

◆ ttrigMin

double DTTTrigCorrectionFirst::ttrigMin
private

Definition at line 44 of file DTTTrigCorrectionFirst.h.

DTSuperLayerId
Definition: DTSuperLayerId.h:12
counter
Definition: counter.py:1
DTTtrig
Definition: DTTtrig.h:68
DTTTrigCorrectionFirst::tTrigMap
const DTTtrig * tTrigMap
Definition: DTTTrigCorrectionFirst.h:38
DTTtrigRcd
Definition: DTTtrigRcd.h:5
dttriganalyzer_cfi.tTrig
tTrig
Definition: dttriganalyzer_cfi.py:11
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
DTTTrigCorrectionFirst::debug
bool debug
Definition: DTTTrigCorrectionFirst.h:43
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
PDRates.average
average
Definition: PDRates.py:139
DTTTrigCorrectionFirst::dbLabel
std::string dbLabel
Definition: DTTTrigCorrectionFirst.h:41
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DTTTrigCorrectionFirst::ttrigMin
double ttrigMin
Definition: DTTTrigCorrectionFirst.h:44
DTTTrigCorrectionFirst::ttrigMax
double ttrigMax
Definition: DTTTrigCorrectionFirst.h:44
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
edm::ESHandle< DTTtrig >
DTTtrig::get
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:59
DTTTrigCorrectionFirst::muonGeom
edm::ESHandle< DTGeometry > muonGeom
Definition: DTTTrigCorrectionFirst.h:39
DTGeometry::superLayers
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:86
average
Definition: average.py:1
DTTtrig::set
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:172
kfactor
const unsigned int kfactor
Definition: FileRandomMultiParticlePGunProducer.cc:19
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:17
get
#define get
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
DTTTrigCorrectionFirst::rmsLimit
double rmsLimit
Definition: DTTTrigCorrectionFirst.h:44