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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

Detailed Description

Definition at line 20 of file DTTTrigCorrectionFirst.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 28 of file DTTTrigCorrectionFirst.cc.

References RecoTauHPSTancTauProdcuer_cfi::dbLabel, debug, and edm::ParameterSet::getUntrackedParameter().

28  {
29 
30  debug = pset.getUntrackedParameter<bool>("debug",false);
31  ttrigMin = pset.getUntrackedParameter<double>("ttrigMin",0);
32  ttrigMax = pset.getUntrackedParameter<double>("ttrigMax",5000);
33  rmsLimit = pset.getUntrackedParameter<double>("rmsLimit",5.);
34 
35  dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
36 }
T getUntrackedParameter(std::string const &, T const &) const
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 
)
inlineoverride

Definition at line 32 of file DTTTrigCorrectionFirst.h.

References endJob().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 30 of file DTTTrigCorrectionFirst.h.

References beginRun(), findQualityFiles::run, and GeneralSetup::setup().

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

Definition at line 40 of file DTTTrigCorrectionFirst.cc.

References gather_cfg::cout, RecoTauHPSTancTauProdcuer_cfi::dbLabel, edm::EventSetup::get(), and DTTtrig::version().

Referenced by beginJob().

40  {
41  ESHandle<DTTtrig> tTrig;
42  setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
43  tTrigMap = &*tTrig;
44  cout << "[DTTTrigCorrection]: TTrig version: " << tTrig->version() << endl;
45 
46  setup.get<MuonGeometryRecord>().get(muonGeom);
47 }
const std::string & version() const
access version
Definition: DTTtrig.cc:231
const T & get() const
Definition: EventSetup.h:59
edm::ESHandle< DTGeometry > muonGeom
void DTTTrigCorrectionFirst::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 49 of file DTTTrigCorrectionFirst.cc.

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

Referenced by analyze(), and o2olib.O2ORunMgr::executeJob().

49  {
50  // Create the object to be written to DB
51  DTTtrig* tTrigNewMap = new DTTtrig();
52  //Get the superlayers list
53  vector<const DTSuperLayer*> dtSupLylist = muonGeom->superLayers();
54 
55  //Loop on all superlayers to compute the mean
56  double average = 0.;
57  double average2 = 0.;
58  double rms = 0.;
59  double averageSigma = 0.;
60  double average2Sigma = 0.;
61  double rmsSigma = 0.;
62  double counter = 0.;
63  double averagekfactor = 0;
64  float kfactor = 0;
65 
66  for (auto sl = dtSupLylist.begin();
67  sl != dtSupLylist.end(); sl++) {
68  float ttrigMean = 0;
69  float ttrigSigma = 0;
70  tTrigMap->get((*sl)->id(),
71  ttrigMean,
72  ttrigSigma,
73  kfactor,
75  if( ttrigMean < ttrigMax && ttrigMean > ttrigMin ) {
76  average += ttrigMean;
77  averageSigma += ttrigSigma;
78  if(ttrigMean > 0)
79  counter += 1.;
80  }
81  }//End of loop on superlayers
82 
83  average = average/ counter;
84  averageSigma = averageSigma/counter;
85  averagekfactor = kfactor;
86 
87  // cout << " average counter "<< average << " "<< counter <<endl;
88 
89  for (auto sl = dtSupLylist.begin();
90  sl != dtSupLylist.end(); sl++) {
91  float ttrigMean = 0;
92  float ttrigSigma = 0;
93  float kfactor = 0;
94  tTrigMap->get((*sl)->id(),
95  ttrigMean,
96  ttrigSigma,
97  kfactor,
99  if( ttrigMean < ttrigMax && ttrigMean > ttrigMin ) {
100  average2 += (ttrigMean-average)*(ttrigMean-average);
101  average2Sigma += (ttrigSigma-averageSigma)*(ttrigSigma-averageSigma);
102  }
103  }//End of loop on superlayers
104 
105  rms = average2 /(counter-1);
106  rmsSigma = average2Sigma /(counter-1);
107  rms = sqrt(rms);
108  rmsSigma = sqrt(rmsSigma);
109  cout << "average averageSigma counter rms "<< average <<" " << averageSigma << " " << counter << " " << rms <<endl;
110 
111 
112  for (auto sl = dtSupLylist.begin();
113  sl != dtSupLylist.end(); sl++) {
114  //Compute new ttrig
115  double newTTrigMean = 0;
116  double newTTrigSigma = 0;
117  double newkfactor =0;
118  float tempttrigMean = 0;
119  float tempttrigSigma = 0;
120  float tempkfactor = 0;
121  float ttrigMean = 0;
122  float ttrigSigma = 0;
123  float kfactor = 0;
124  tTrigMap->get((*sl)->id(),
125  ttrigMean,
126  ttrigSigma,
127  kfactor,
129  int chamber = (*sl)->id().chamberId().station();
130 
131  //check if ttrigMean is similar to the mean
132  if (abs(ttrigMean - average) < rmsLimit*rms ){
133  newTTrigMean = ttrigMean;
134  newTTrigSigma = ttrigSigma;
135  newkfactor = kfactor;
136  } else {
137  // do not consider if ttrig == 0
138  if(ttrigMean > 0) {
139  //cout << "ttrig chamber " << ttrigMean <<" "<<chamber<<endl;
140  if(((*sl)->id().superlayer()) == 1){
141  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
142  DTSuperLayerId slId((*sl)->id().chamberId(),3);
143  tTrigMap->get(slId,
144  tempttrigMean,
145  tempttrigSigma,
146  tempkfactor,
148  if (abs(tempttrigMean - average) < rmsLimit*rms) {
149  newTTrigMean = tempttrigMean;
150  newTTrigSigma = tempttrigSigma;
151  newkfactor = tempkfactor;
152  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
153  << " -> takes value of sl 3 " << newTTrigMean <<endl;
154  } else if(chamber == 4){
155  cout << "No correction possible within same chamber (sl1) " <<endl;
156  newTTrigMean = average;
157  newTTrigSigma = averageSigma;
158  newkfactor = averagekfactor;
159  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
160  } else if(chamber != 4){
161  DTSuperLayerId slId((*sl)->id().chamberId(),2);
162  tTrigMap->get(slId,
163  tempttrigMean,
164  tempttrigSigma,
165  tempkfactor,
167  if (abs(tempttrigMean - average) < rmsLimit*rms) {
168  newTTrigMean = tempttrigMean;
169  newTTrigSigma = tempttrigSigma;
170  newkfactor = tempkfactor;
171  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
172  <<" -> takes value of sl 2 " << newTTrigMean <<endl;
173  } else {
174  cout << "No correction possible within same chamber (sl1) " <<endl;
175  newTTrigMean = average;
176  newTTrigSigma = averageSigma;
177  newkfactor = averagekfactor;
178  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
179  }
180  }
181  } else if (((*sl)->id().superlayer()) == 2) {
182  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
183  DTSuperLayerId slId((*sl)->id().chamberId(),1);
184  tTrigMap->get(slId,
185  tempttrigMean,
186  tempttrigSigma,
187  tempkfactor,
189  if (abs(tempttrigMean - average) < rmsLimit*rms) {
190  newTTrigMean = tempttrigMean;
191  newTTrigSigma = tempttrigSigma;
192  newkfactor = tempkfactor;
193  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
194  << " -> takes value of sl 1 " << newTTrigMean <<endl;
195  } else {
196  DTSuperLayerId slId((*sl)->id().chamberId(),3);
197  tTrigMap->get(slId,
198  tempttrigMean,
199  tempttrigSigma,
200  tempkfactor,
202  if (abs(tempttrigMean - average) < rmsLimit*rms) {
203  newTTrigMean = tempttrigMean;
204  newTTrigSigma = tempttrigSigma;
205  newkfactor = tempkfactor;
206  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
207  << "-> takes value of sl 3 " << newTTrigMean <<endl;
208  } else {
209  cout << "No correction possible within same chamber (sl2) " <<endl;
210  newTTrigMean = average;
211  newTTrigSigma = averageSigma;
212  newkfactor = averagekfactor;
213  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
214  }
215  }
216 
217 
218  } else if (((*sl)->id().superlayer()) == 3) {
219  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
220  DTSuperLayerId slId((*sl)->id().chamberId(),1);
221  tTrigMap->get(slId,
222  tempttrigMean,
223  tempttrigSigma,
224  tempkfactor,
226  if (abs(tempttrigMean - average) < rmsLimit*rms) {
227  newTTrigMean = tempttrigMean;
228  newTTrigSigma = tempttrigSigma;
229  newkfactor = tempkfactor;
230  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
231  << " -> takes value of sl 1 " << newTTrigMean <<endl;
232  } else if(chamber == 4) {
233  cout << "No correction possible within same chamber (sl3)" <<endl;
234  newTTrigMean = average;
235  newTTrigSigma = averageSigma;
236  newkfactor = averagekfactor;
237  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
238  } else if(chamber != 4){
239  DTSuperLayerId slId((*sl)->id().chamberId(),2);
240  tTrigMap->get(slId,
241  tempttrigMean,
242  tempttrigSigma,
243  tempkfactor,
245  if (abs(tempttrigMean - average) < rmsLimit*rms) {
246  newTTrigMean = tempttrigMean;
247  newTTrigSigma = tempttrigSigma;
248  newkfactor = tempkfactor;
249  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
250  << " -> takes value of sl 2 " << newTTrigMean <<endl;
251  } else {
252  cout << "No correction possible within same chamber (sl3) " <<endl;
253  newTTrigMean = average;
254  newTTrigSigma = averageSigma;
255  newkfactor = averagekfactor;
256  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
257  }
258  }
259 
260  }
261  } else {
262  // cout << "SL not present " << ttrigMean << " " <<((*sl)->id().superlayer()) <<endl;
263  newTTrigMean = average;
264  newTTrigSigma = averageSigma;
265  newkfactor = averagekfactor;
266  cout<<"####### NotPresent SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
267  }
268  }
269 
270  //Store new ttrig in the new map
271  tTrigNewMap->set((*sl)->id(), newTTrigMean, newTTrigSigma, newkfactor, DTTimeUnits::ns);
272  if(debug){
273  cout<<"New tTrig: " << (*sl)->id()
274  << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
275  cout<<"New tTrigSigma: " << (*sl)->id()
276  << " from "<<ttrigSigma <<" to "<< newTTrigSigma <<endl;
277 
278  }
279  }//End of loop on superlayers
280 
281 
282  //Write object to DB
283  cout << "[DTTTrigCorrection]: Writing ttrig object to DB!" << endl;
284  string record = "DTTtrigRcd";
285  DTCalibDBUtils::writeToDB<DTTtrig>(record, tTrigNewMap);
286 }
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:248
JetCorrectorParameters::Record record
Definition: classes.h:7
T sqrt(T t)
Definition: SSEVec.h:18
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:85
static std::atomic< unsigned int > counter
edm::ESHandle< DTGeometry > muonGeom
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:89

Member Data Documentation

std::string DTTTrigCorrectionFirst::dbLabel
private

Definition at line 42 of file DTTTrigCorrectionFirst.h.

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

Definition at line 40 of file DTTTrigCorrectionFirst.h.

double DTTTrigCorrectionFirst::rmsLimit
private

Definition at line 45 of file DTTTrigCorrectionFirst.h.

const DTTtrig* DTTTrigCorrectionFirst::tTrigMap
private

Definition at line 39 of file DTTTrigCorrectionFirst.h.

double DTTTrigCorrectionFirst::ttrigMax
private

Definition at line 45 of file DTTTrigCorrectionFirst.h.

double DTTTrigCorrectionFirst::ttrigMin
private

Definition at line 45 of file DTTTrigCorrectionFirst.h.