CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 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,
MuonGeometryRecord
dtGeomToken_
 
edm::ESHandle< DTGeometrymuonGeom
 
double rmsLimit
 
const DTTtrigtTrigMap
 
double ttrigMax
 
double ttrigMin
 
const edm::ESGetToken< DTTtrig,
DTTtrigRcd
ttrigToken_
 

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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (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 () noexcept
 
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...
 
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 ( const edm::ParameterSet pset)

Constructor.

Definition at line 28 of file DTTTrigCorrectionFirst.cc.

References debug, edm::ParameterSet::getUntrackedParameter(), 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 }
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_
DTTTrigCorrectionFirst::~DTTTrigCorrectionFirst ( )
override

Destructor.

Definition at line 38 of file DTTTrigCorrectionFirst.cc.

38 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 34 of file DTTTrigCorrectionFirst.h.

34 {}
void DTTTrigCorrectionFirst::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 32 of file DTTTrigCorrectionFirst.h.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 40 of file DTTTrigCorrectionFirst.cc.

References gather_cfg::cout, dtGeomToken_, edm::EventSetup::getData(), edm::EventSetup::getHandle(), muonGeom, tTrigMap, and ttrigToken_.

40  {
41  ESHandle<DTTtrig> tTrig;
42  tTrig = setup.getHandle(ttrigToken_);
43  tTrigMap = &setup.getData(ttrigToken_);
44  cout << "[DTTTrigCorrection]: TTrig version: " << tTrig->version() << endl;
46 }
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_
tuple cout
Definition: gather_cfg.py:144
edm::ESHandle< DTGeometry > muonGeom
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
void DTTTrigCorrectionFirst::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 48 of file DTTTrigCorrectionFirst.cc.

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

Referenced by o2olib.O2ORunMgr::executeJob().

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 
77  average = average / counter;
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 }
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
int average
Definition: PDRates.py:138
static std::atomic< unsigned int > counter
tuple cout
Definition: gather_cfg.py:144
edm::ESHandle< DTGeometry > muonGeom
const unsigned int kfactor

Member Data Documentation

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

Definition at line 41 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun().

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

Definition at line 40 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun(), and endJob().

double DTTTrigCorrectionFirst::rmsLimit
private

Definition at line 47 of file DTTTrigCorrectionFirst.h.

Referenced by DTTTrigCorrectionFirst(), and endJob().

const DTTtrig* DTTTrigCorrectionFirst::tTrigMap
private

Definition at line 43 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun(), and endJob().

double DTTTrigCorrectionFirst::ttrigMax
private

Definition at line 47 of file DTTTrigCorrectionFirst.h.

Referenced by DTTTrigCorrectionFirst().

double DTTTrigCorrectionFirst::ttrigMin
private

Definition at line 47 of file DTTTrigCorrectionFirst.h.

Referenced by DTTTrigCorrectionFirst(), and endJob().

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

Definition at line 44 of file DTTTrigCorrectionFirst.h.

Referenced by beginRun().