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