CMS 3D CMS Logo

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

#include <DTTTrigCorrectionFirst.h>

Inheritance diagram for DTTTrigCorrectionFirst:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase 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
 
void endRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 ~DTTTrigCorrectionFirst () override
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

bool debug
 
const edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomToken_
 
edm::ESHandle< DTGeometrymuonGeom
 
double rmsLimit
 
const DTTtrigtTrigMap
 
double ttrigMax
 
double ttrigMin
 
const edm::ESGetToken< DTTtrig, DTTtrigRcdttrigToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 22 of file DTTTrigCorrectionFirst.h.

Constructor & Destructor Documentation

◆ DTTTrigCorrectionFirst()

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

Constructor.

Definition at line 28 of file DTTTrigCorrectionFirst.cc.

References debug, muonDTDigis_cfi::pset, rmsLimit, ttrigMax, and ttrigMin.

29  : dtGeomToken_(esConsumes<edm::Transition::BeginRun>()),
31  esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getUntrackedParameter<string>("dbLabel")))) {
32  debug = pset.getUntrackedParameter<bool>("debug", false);
33  ttrigMin = pset.getUntrackedParameter<double>("ttrigMin", 0);
34  ttrigMax = pset.getUntrackedParameter<double>("ttrigMax", 5000);
35  rmsLimit = pset.getUntrackedParameter<double>("rmsLimit", 5.);
36 }
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_

◆ ~DTTTrigCorrectionFirst()

DTTTrigCorrectionFirst::~DTTTrigCorrectionFirst ( )
override

Destructor.

Definition at line 38 of file DTTTrigCorrectionFirst.cc.

38 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 34 of file DTTTrigCorrectionFirst.h.

34 {}

◆ beginJob()

void DTTTrigCorrectionFirst::beginJob ( )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 32 of file DTTTrigCorrectionFirst.h.

32 {}

◆ beginRun()

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

Definition at line 40 of file DTTTrigCorrectionFirst.cc.

References gather_cfg::cout, dtGeomToken_, muonGeom, singleTopDQM_cfi::setup, dttriganalyzer_cfi::tTrig, tTrigMap, and ttrigToken_.

40  {
42  tTrig = setup.getHandle(ttrigToken_);
43  tTrigMap = &setup.getData(ttrigToken_);
44  cout << "[DTTTrigCorrection]: TTrig version: " << tTrig->version() << endl;
45  muonGeom = setup.getHandle(dtGeomToken_);
46 }
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_
edm::ESHandle< DTGeometry > muonGeom

◆ endJob()

void DTTTrigCorrectionFirst::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 48 of file DTTTrigCorrectionFirst.cc.

References funct::abs(), PDRates::average, relativeConstraints::chamber, counter, gather_cfg::cout, debug, DTTtrig::get(), kfactor, muonGeom, DTTimeUnits::ns, AlCaHarvesting_cff::record, SiStripPI::rms, rmsLimit, DTTtrig::set(), mathSSE::sqrt(), DTGeometry::superLayers(), tTrigMap, and ttrigMin.

Referenced by o2olib.O2ORunMgr::executeJob().

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

◆ endRun()

void DTTTrigCorrectionFirst::endRun ( const edm::Run run,
const edm::EventSetup setup 
)
inlineoverride

Definition at line 36 of file DTTTrigCorrectionFirst.h.

36 {};

Member Data Documentation

◆ debug

bool DTTTrigCorrectionFirst::debug
private

◆ dtGeomToken_

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTTTrigCorrectionFirst::dtGeomToken_
private

Definition at line 42 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun().

◆ muonGeom

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

Definition at line 41 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun(), and endJob().

◆ rmsLimit

double DTTTrigCorrectionFirst::rmsLimit
private

Definition at line 48 of file DTTTrigCorrectionFirst.h.

Referenced by DTTTrigCorrectionFirst(), and endJob().

◆ tTrigMap

const DTTtrig* DTTTrigCorrectionFirst::tTrigMap
private

Definition at line 44 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun(), and endJob().

◆ ttrigMax

double DTTTrigCorrectionFirst::ttrigMax
private

Definition at line 48 of file DTTTrigCorrectionFirst.h.

Referenced by DTTTrigCorrectionFirst().

◆ ttrigMin

double DTTTrigCorrectionFirst::ttrigMin
private

Definition at line 48 of file DTTTrigCorrectionFirst.h.

Referenced by DTTTrigCorrectionFirst(), and endJob().

◆ ttrigToken_

const edm::ESGetToken<DTTtrig, DTTtrigRcd> DTTTrigCorrectionFirst::ttrigToken_
private

Definition at line 45 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun().