CMS 3D CMS Logo

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

#include <DTT0CalibrationRMS.h>

Inheritance diagram for DTT0CalibrationRMS:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 Fill the maps with t0 (by channel) More...
 
 DTT0CalibrationRMS (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob () override
 Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity. More...
 
 ~DTT0CalibrationRMS () 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
 
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 Member Functions

std::string getHistoName (const DTLayerId &lId) const
 
std::string getHistoName (const DTWireId &wId) const
 

Private Attributes

std::vector< std::string > cellsWithHistos
 
bool correctByChamberMean_
 
bool debug
 
std::string digiLabel
 
edm::ESHandle< DTGeometrydtGeom
 
unsigned int eventsForLayerT0
 
unsigned int eventsForWireT0
 
TH1D * hT0SectorHisto
 
std::map< DTWireId, double > mK
 
std::map< DTWireId, double > mK_ref
 
std::map< DTWireId, int > nDigiPerWire
 
std::map< DTWireId, int > nDigiPerWire_ref
 
unsigned int nevents
 
std::map< DTWireId, double > qK
 
unsigned int rejectDigiFromPeak
 
int selSector
 
int selWheel
 
std::map< DTWireId, double > theAbsoluteT0PerWire
 
std::string theCalibSector
 
std::string theCalibWheel
 
TFile * theFile
 
std::map< DTLayerId, TH1I * > theHistoLayerMap
 
std::map< DTWireId, TH1I * > theHistoWireMap
 
std::map< DTWireId, TH1I * > theHistoWireMap_ref
 
TFile * theOutputFile
 
std::map< DTWireId, double > theRelativeT0PerWire
 
std::map< std::string, double > theSigmaT0LayerMap
 
std::map< DTWireId, double > theSigmaT0PerWire
 
std::map< std::string, double > theT0LayerMap
 
double tpPeakWidth
 
std::vector< DTWireIdwireIdWithHistos
 

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
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>
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)
 
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

Analyzer class computes the mean and RMS of t0 from pulses. Those values are written in the DB with cell granularity. The mean value for each channel is normalized to a reference time common to all the sector. The t0 of wires in odd layers are corrected for the relative difference between odd and even layers

Definition at line 26 of file DTT0CalibrationRMS.h.

Constructor & Destructor Documentation

◆ DTT0CalibrationRMS()

DTT0CalibrationRMS::DTT0CalibrationRMS ( const edm::ParameterSet pset)

Constructor.

Definition at line 27 of file DTT0CalibrationRMS.cc.

27  {
28  // Get the debug parameter for verbose output
29  debug = pset.getUntrackedParameter<bool>("debug");
30  if (debug)
31  cout << "[DTT0CalibrationRMS]Constructor called!" << endl;
32 
33  // Get the label to retrieve digis from the event
34  digiLabel = pset.getUntrackedParameter<string>("digiLabel");
35 
36  // The root file which contain the histos per layer
37  string rootFileName = pset.getUntrackedParameter<string>("rootFileName", "DTT0PerLayer.root");
38  theFile = new TFile(rootFileName.c_str(), "RECREATE");
39 
41  pset.getUntrackedParameter<string>("calibWheel", "All"); //FIXME amke a vector of integer instead of a string
42  if (theCalibWheel != "All") {
43  stringstream linestr;
44  int selWheel;
45  linestr << theCalibWheel;
46  linestr >> selWheel;
47  cout << "[DTT0CalibrationRMSPerLayer] chosen wheel " << selWheel << endl;
48  }
49 
50  // Sector/s to calibrate
52  pset.getUntrackedParameter<string>("calibSector", "All"); //FIXME amke a vector of integer instead of a string
53  if (theCalibSector != "All") {
54  stringstream linestr;
55  int selSector;
56  linestr << theCalibSector;
57  linestr >> selSector;
58  cout << "[DTT0CalibrationRMSPerLayer] chosen sector " << selSector << endl;
59  }
60 
61  vector<string> defaultCell;
62  defaultCell.push_back("None");
63  cellsWithHistos = pset.getUntrackedParameter<vector<string> >("cellsWithHisto", defaultCell);
64  for (vector<string>::const_iterator cell = cellsWithHistos.begin(); cell != cellsWithHistos.end(); ++cell) {
65  if ((*cell) != "None") {
66  stringstream linestr;
67  int wheel, sector, station, sl, layer, wire;
68  linestr << (*cell);
69  linestr >> wheel >> sector >> station >> sl >> layer >> wire;
70  wireIdWithHistos.push_back(DTWireId(wheel, station, sector, sl, layer, wire));
71  }
72  }
73 
74  hT0SectorHisto = nullptr;
75 
76  nevents = 0;
77  eventsForLayerT0 = pset.getParameter<unsigned int>("eventsForLayerT0");
78  eventsForWireT0 = pset.getParameter<unsigned int>("eventsForWireT0");
79  rejectDigiFromPeak = pset.getParameter<unsigned int>("rejectDigiFromPeak");
80  tpPeakWidth = pset.getParameter<double>("tpPeakWidth");
81  //useReferenceWireInLayer_ = true;
82  correctByChamberMean_ = pset.getParameter<bool>("correctByChamberMean");
83 }

References gather_cfg::cout, debug, DataMixerDataOnData_cff::digiLabel, cmsHarvester::nevents, muonDTDigis_cfi::pset, CSCSkim_cfi::rootFileName, relativeConstraints::station, interactiveExample::theFile, and makeMuonMisalignmentScenario::wheel.

◆ ~DTT0CalibrationRMS()

DTT0CalibrationRMS::~DTT0CalibrationRMS ( )
override

Destructor.

Definition at line 86 of file DTT0CalibrationRMS.cc.

86  {
87  if (debug)
88  cout << "[DTT0CalibrationRMS]Destructor called!" << endl;
89 
90  theFile->Close();
91 }

References gather_cfg::cout, debug, and interactiveExample::theFile.

Member Function Documentation

◆ analyze()

void DTT0CalibrationRMS::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
overridevirtual

Fill the maps with t0 (by channel)

Perform the real analysis.

Implements edm::EDAnalyzer.

Definition at line 94 of file DTT0CalibrationRMS.cc.

94  {
95  if (debug || event.id().event() % 500 == 0)
96  cout << "--- [DTT0CalibrationRMS] Analysing Event: #Run: " << event.id().run() << " #Event: " << event.id().event()
97  << endl;
98  nevents++;
99 
100  // Get the digis from the event
102  event.getByLabel(digiLabel, digis);
103 
104  // Get the DT Geometry
106 
107  // Iterate through all digi collections ordered by LayerId
109  for (dtLayerIt = digis->begin(); dtLayerIt != digis->end(); ++dtLayerIt) {
110  // Get the iterators over the digis associated with this LayerId
111  const DTDigiCollection::Range& digiRange = (*dtLayerIt).second;
112 
113  // Get the layerId
114  const DTLayerId layerId = (*dtLayerIt).first; //FIXME: check to be in the right sector
115 
116  if ((theCalibWheel != "All") && (layerId.superlayerId().chamberId().wheel() != selWheel))
117  continue;
118  if ((theCalibSector != "All") && (layerId.superlayerId().chamberId().sector() != selSector))
119  continue;
120 
121  //if(debug) {
122  // cout << "Layer " << layerId<<" with "<<distance(digiRange.first, digiRange.second)<<" digi"<<endl;
123  //}
124 
125  // Loop over all digis in the given layer
126  for (DTDigiCollection::const_iterator digi = digiRange.first; digi != digiRange.second; ++digi) {
127  double t0 = (*digi).countsTDC();
128 
129  //Use first bunch of events to fill t0 per layer
130  if (nevents < eventsForLayerT0) {
131  //Get the per-layer histo from the map
132  TH1I* hT0LayerHisto = theHistoLayerMap[layerId];
133  //If it doesn't exist, book it
134  if (hT0LayerHisto == nullptr) {
135  theFile->cd();
136  hT0LayerHisto = new TH1I(getHistoName(layerId).c_str(),
137  "T0 from pulses by layer (TDC counts, 1 TDC count = 0.781 ns)",
138  200,
139  t0 - 100,
140  t0 + 100);
141  if (debug)
142  cout << " New T0 per Layer Histo: " << hT0LayerHisto->GetName() << endl;
143  theHistoLayerMap[layerId] = hT0LayerHisto;
144  }
145 
146  //Fill the histos
147  theFile->cd();
148  if (hT0LayerHisto != nullptr) {
149  // if(debug)
150  // cout<<"Filling histo "<<hT0LayerHisto->GetName()<<" with digi "<<t0<<" TDC counts"<<endl;
151  hT0LayerHisto->Fill(t0);
152  }
153  }
154 
155  //Use all the remaining events to compute t0 per wire
156  if (nevents > eventsForLayerT0) {
157  // Get the wireId
158  const DTWireId wireId(layerId, (*digi).wire());
159  if (debug) {
160  cout << " Wire: " << wireId << endl << " time (TDC counts): " << (*digi).countsTDC() << endl;
161  }
162 
163  //Fill the histos per wire for the chosen cells
164  vector<DTWireId>::iterator it_wire = find(wireIdWithHistos.begin(), wireIdWithHistos.end(), wireId);
165  if (it_wire != wireIdWithHistos.end()) {
166  if (theHistoWireMap.find(wireId) == theHistoWireMap.end()) {
167  theHistoWireMap[wireId] = new TH1I(getHistoName(wireId).c_str(),
168  "T0 from pulses by wire (TDC counts, 1 TDC count = 0.781 ns)",
169  7000,
170  0,
171  7000);
172  if (debug)
173  cout << " New T0 per wire Histo: " << (theHistoWireMap[wireId])->GetName() << endl;
174  }
175  if (theHistoWireMap_ref.find(wireId) == theHistoWireMap_ref.end()) {
176  theHistoWireMap_ref[wireId] = new TH1I((getHistoName(wireId) + "_ref").c_str(),
177  "T0 from pulses by wire (TDC counts, 1 TDC count = 0.781 ns)",
178  7000,
179  0,
180  7000);
181  if (debug)
182  cout << " New T0 per wire Histo: " << (theHistoWireMap_ref[wireId])->GetName() << endl;
183  }
184 
185  TH1I* hT0WireHisto = theHistoWireMap[wireId];
186  //Fill the histos
187  theFile->cd();
188  if (hT0WireHisto)
189  hT0WireHisto->Fill(t0);
190  }
191 
192  //Check the tzero has reasonable value
193  if (abs(hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin()) - t0) > rejectDigiFromPeak) {
194  if (debug)
195  cout << "digi skipped because t0 per sector "
196  << hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin()) << endl;
197  continue;
198  }
199 
200  //Use second bunch of events to compute a t0 reference per wire
202  //Fill reference wire histos
203  if (it_wire != wireIdWithHistos.end()) {
204  TH1I* hT0WireHisto_ref = theHistoWireMap_ref[wireId];
205  theFile->cd();
206  if (hT0WireHisto_ref)
207  hT0WireHisto_ref->Fill(t0);
208  }
209  if (!nDigiPerWire_ref[wireId]) {
210  mK_ref[wireId] = 0;
211  }
212  nDigiPerWire_ref[wireId] = nDigiPerWire_ref[wireId] + 1;
213  mK_ref[wireId] = mK_ref[wireId] + (t0 - mK_ref[wireId]) / nDigiPerWire_ref[wireId];
214  }
215  //Use last all the remaining events to compute the mean and sigma t0 per wire
216  else if (nevents > (eventsForLayerT0 + eventsForWireT0)) {
217  if (abs(t0 - mK_ref[wireId]) > tpPeakWidth)
218  continue;
219  if (!nDigiPerWire[wireId]) {
220  theAbsoluteT0PerWire[wireId] = 0;
221  qK[wireId] = 0;
222  mK[wireId] = 0;
223  }
224  nDigiPerWire[wireId] = nDigiPerWire[wireId] + 1;
225  theAbsoluteT0PerWire[wireId] = theAbsoluteT0PerWire[wireId] + t0;
226  //theSigmaT0PerWire[wireId] = theSigmaT0PerWire[wireId] + (t0*t0);
227  qK[wireId] =
228  qK[wireId] + ((nDigiPerWire[wireId] - 1) * (t0 - mK[wireId]) * (t0 - mK[wireId]) / nDigiPerWire[wireId]);
229  mK[wireId] = mK[wireId] + (t0 - mK[wireId]) / nDigiPerWire[wireId];
230  }
231  } //end if(nevents>1000)
232  } //end loop on digi
233  } //end loop on layer
234 
235  //Use the t0 per layer histos to have an indication about the t0 position
236  if (nevents == eventsForLayerT0) {
237  for (map<DTLayerId, TH1I*>::const_iterator lHisto = theHistoLayerMap.begin(); lHisto != theHistoLayerMap.end();
238  ++lHisto) {
239  if (debug)
240  cout << "Reading histogram " << (*lHisto).second->GetName() << " with mean " << (*lHisto).second->GetMean()
241  << " and RMS " << (*lHisto).second->GetRMS();
242 
243  //Take the mean as a first t0 estimation
244  if ((*lHisto).second->GetRMS() < 5.0) {
245  if (hT0SectorHisto == nullptr) {
246  hT0SectorHisto = new TH1D("hT0AllLayerOfSector",
247  "T0 from pulses per layer in sector",
248  //20, (*lHisto).second->GetMean()-100, (*lHisto).second->GetMean()+100);
249  700,
250  0,
251  7000);
252  }
253  if (debug)
254  cout << " accepted" << endl;
255  hT0SectorHisto->Fill((*lHisto).second->GetMean());
256  }
257  //Take the mean of noise + 400ns as a first t0 estimation
258  // if((*lHisto).second->GetRMS()>10.0 && ((*lHisto).second->GetRMS()<15.0)){
259  // double t0_estim = (*lHisto).second->GetMean() + 400;
260  // if(hT0SectorHisto == 0){
261  // hT0SectorHisto = new TH1D("hT0AllLayerOfSector","T0 from pulses per layer in sector",
262  // //20, t0_estim-100, t0_estim+100);
263  // 700, 0, 7000);
264  // }
265  // if(debug)
266  // cout<<" accepted + 400ns"<<endl;
267  // hT0SectorHisto->Fill((*lHisto).second->GetMean() + 400);
268  // }
269  if (debug)
270  cout << endl;
271 
272  theT0LayerMap[(*lHisto).second->GetName()] = (*lHisto).second->GetMean();
273  theSigmaT0LayerMap[(*lHisto).second->GetName()] = (*lHisto).second->GetRMS();
274  }
275  if (!hT0SectorHisto) {
276  cout << "[DTT0CalibrationRMS]: All the t0 per layer are still uncorrect: trying with greater number of events"
277  << endl;
279  return;
280  }
281  if (debug)
282  cout << "[DTT0CalibrationRMS] t0 reference for this sector "
283  << hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin()) << endl;
284  }
285 }

References funct::abs(), DTSuperLayerId::chamberId(), gather_cfg::cout, debug, DataMixerDataOnData_cff::digiLabel, options_cfi::eventSetup, spr::find(), get, mergeVDriftHistosByStation::getHistoName(), cmsHarvester::nevents, DTChamberId::sector(), DTLayerId::superlayerId(), FrontierCondition_GT_autoExpress_cfi::t0, interactiveExample::theFile, and DTChamberId::wheel().

◆ endJob()

void DTT0CalibrationRMS::endJob ( void  )
overridevirtual

Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity.

Loop on superlayer to correct between even-odd layers (2 different test pulse lines!)

Change t0 absolute reference -> from sector peak to chamber average

Write the t0 map into DB

Reimplemented from edm::EDAnalyzer.

Definition at line 287 of file DTT0CalibrationRMS.cc.

287  {
288  DTT0* t0sAbsolute = new DTT0();
289  DTT0* t0sRelative = new DTT0();
290  DTT0* t0sWRTChamber = new DTT0();
291 
292  //if(debug)
293  cout << "[DTT0CalibrationRMSPerLayer]Writing histos to file!" << endl;
294 
295  theFile->cd();
296  theFile->WriteTObject(hT0SectorHisto);
297  //hT0SectorHisto->Write();
298  for (map<DTWireId, TH1I*>::const_iterator wHisto = theHistoWireMap.begin(); wHisto != theHistoWireMap.end();
299  ++wHisto) {
300  (*wHisto).second->Write();
301  }
302  for (map<DTWireId, TH1I*>::const_iterator wHisto = theHistoWireMap_ref.begin(); wHisto != theHistoWireMap_ref.end();
303  ++wHisto) {
304  (*wHisto).second->Write();
305  }
306  for (map<DTLayerId, TH1I*>::const_iterator lHisto = theHistoLayerMap.begin(); lHisto != theHistoLayerMap.end();
307  ++lHisto) {
308  (*lHisto).second->Write();
309  }
310 
311  //if(debug)
312  cout << "[DTT0CalibrationRMS] Compute and store t0 and sigma per wire" << endl;
313 
314  for (map<DTWireId, double>::const_iterator wiret0 = theAbsoluteT0PerWire.begin();
315  wiret0 != theAbsoluteT0PerWire.end();
316  ++wiret0) {
317  if (nDigiPerWire[(*wiret0).first]) {
318  double t0 = (*wiret0).second / nDigiPerWire[(*wiret0).first];
319 
320  theRelativeT0PerWire[(*wiret0).first] = t0 - hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin());
321 
322  //theSigmaT0PerWire[(*wiret0).first] = sqrt((theSigmaT0PerWire[(*wiret0).first] / nDigiPerWire[(*wiret0).first]) - t0*t0);
323  theSigmaT0PerWire[(*wiret0).first] = sqrt(qK[(*wiret0).first] / nDigiPerWire[(*wiret0).first]);
324 
325  cout << "Wire " << (*wiret0).first << " has t0 " << t0 << "(absolute) " << theRelativeT0PerWire[(*wiret0).first]
326  << "(relative)"
327  << " sigma " << theSigmaT0PerWire[(*wiret0).first] << endl;
328 
329  t0sAbsolute->set((*wiret0).first, t0, theSigmaT0PerWire[(*wiret0).first], DTTimeUnits::counts);
330  } else {
331  cout << "[DTT0CalibrationRMS] ERROR: no digis in wire " << (*wiret0).first << endl;
332  abort();
333  }
334  }
335 
336  if (correctByChamberMean_) {
338  // Get all the sls from the setup
339  const vector<const DTSuperLayer*> superLayers = dtGeom->superLayers();
340  // Loop over all SLs
341  for (vector<const DTSuperLayer*>::const_iterator sl = superLayers.begin(); sl != superLayers.end(); sl++) {
342  //Compute mean for odd and even superlayers
343  double oddLayersMean = 0;
344  double evenLayersMean = 0;
345  double oddLayersDen = 0;
346  double evenLayersDen = 0;
347  for (map<DTWireId, double>::const_iterator wiret0 = theRelativeT0PerWire.begin();
348  wiret0 != theRelativeT0PerWire.end();
349  ++wiret0) {
350  if ((*wiret0).first.layerId().superlayerId() == (*sl)->id()) {
351  if (debug)
352  cout << "[DTT0CalibrationRMS] Superlayer " << (*sl)->id() << "layer " << (*wiret0).first.layerId().layer()
353  << " with " << (*wiret0).second << endl;
354  if (((*wiret0).first.layerId().layer()) % 2) {
355  oddLayersMean = oddLayersMean + (*wiret0).second;
356  oddLayersDen++;
357  } else {
358  evenLayersMean = evenLayersMean + (*wiret0).second;
359  evenLayersDen++;
360  }
361  }
362  }
363  oddLayersMean = oddLayersMean / oddLayersDen;
364  evenLayersMean = evenLayersMean / evenLayersDen;
365  //if(debug && oddLayersMean)
366  cout << "[DTT0CalibrationRMS] Relative T0 mean for odd layers " << oddLayersMean << " even layers"
367  << evenLayersMean << endl;
368 
369  //Compute sigma for odd and even superlayers
370  double oddLayersSigma = 0;
371  double evenLayersSigma = 0;
372  for (map<DTWireId, double>::const_iterator wiret0 = theRelativeT0PerWire.begin();
373  wiret0 != theRelativeT0PerWire.end();
374  ++wiret0) {
375  if ((*wiret0).first.layerId().superlayerId() == (*sl)->id()) {
376  if (((*wiret0).first.layerId().layer()) % 2) {
377  oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean);
378  } else {
379  evenLayersSigma =
380  evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean);
381  }
382  }
383  }
384  oddLayersSigma = oddLayersSigma / oddLayersDen;
385  evenLayersSigma = evenLayersSigma / evenLayersDen;
386  oddLayersSigma = sqrt(oddLayersSigma);
387  evenLayersSigma = sqrt(evenLayersSigma);
388 
389  //if(debug && oddLayersMean)
390  cout << "[DTT0CalibrationRMS] Relative T0 sigma for odd layers " << oddLayersSigma << " even layers"
391  << evenLayersSigma << endl;
392 
393  //Recompute the mean for odd and even superlayers discarding fluctations
394  double oddLayersFinalMean = 0;
395  double evenLayersFinalMean = 0;
396  for (map<DTWireId, double>::const_iterator wiret0 = theRelativeT0PerWire.begin();
397  wiret0 != theRelativeT0PerWire.end();
398  ++wiret0) {
399  if ((*wiret0).first.layerId().superlayerId() == (*sl)->id()) {
400  if (((*wiret0).first.layerId().layer()) % 2) {
401  if (abs((*wiret0).second - oddLayersMean) < (2 * oddLayersSigma))
402  oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second;
403  } else {
404  if (abs((*wiret0).second - evenLayersMean) < (2 * evenLayersSigma))
405  evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second;
406  }
407  }
408  }
409  oddLayersFinalMean = oddLayersFinalMean / oddLayersDen;
410  evenLayersFinalMean = evenLayersFinalMean / evenLayersDen;
411  //if(debug && oddLayersMean)
412  cout << "[DTT0CalibrationRMS] Final relative T0 mean for odd layers " << oddLayersFinalMean << " even layers"
413  << evenLayersFinalMean << endl;
414 
415  for (map<DTWireId, double>::const_iterator wiret0 = theRelativeT0PerWire.begin();
416  wiret0 != theRelativeT0PerWire.end();
417  ++wiret0) {
418  if ((*wiret0).first.layerId().superlayerId() == (*sl)->id()) {
419  double t0 = -999;
420  if (((*wiret0).first.layerId().layer()) % 2)
421  t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean);
422  else
423  t0 = (*wiret0).second;
424 
425  cout << "[DTT0CalibrationRMS] Wire " << (*wiret0).first << " has t0 " << (*wiret0).second
426  << " (relative, after even-odd layer corrections) "
427  << " sigma " << theSigmaT0PerWire[(*wiret0).first] << endl;
428 
429  //Store the results into DB
430  t0sRelative->set((*wiret0).first, t0, theSigmaT0PerWire[(*wiret0).first], DTTimeUnits::counts);
431  }
432  }
433  }
434 
436  //if(debug)
437  cout << "[DTT0CalibrationRMS]Computing relative t0 wrt to chamber average" << endl;
438  //Compute the reference for each chamber
439  map<DTChamberId, double> sumT0ByChamber;
440  map<DTChamberId, int> countT0ByChamber;
441  for (DTT0::const_iterator tzero = t0sRelative->begin(); tzero != t0sRelative->end(); ++tzero) {
442  int channelId = tzero->channelId;
443  if (channelId == 0)
444  continue;
445  DTWireId wireId(channelId);
446  DTChamberId chamberId(wireId.chamberId());
447  //sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + tzero->t0mean;
448  // @@@ better DTT0 usage
449  float t0mean_f;
450  float t0rms_f;
451  t0sRelative->get(wireId, t0mean_f, t0rms_f, DTTimeUnits::counts);
452  sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f;
453  // @@@ NEW DTT0 END
454  countT0ByChamber[chamberId]++;
455  }
456 
457  //Change reference for each wire and store the new t0s in the new map
458  for (DTT0::const_iterator tzero = t0sRelative->begin(); tzero != t0sRelative->end(); ++tzero) {
459  int channelId = tzero->channelId;
460  if (channelId == 0)
461  continue;
462  DTWireId wireId(channelId);
463  DTChamberId chamberId(wireId.chamberId());
464  //double t0mean = (tzero->t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
465  //double t0rms = tzero->t0rms;
466  // @@@ better DTT0 usage
467  float t0mean_f;
468  float t0rms_f;
469  t0sRelative->get(wireId, t0mean_f, t0rms_f, DTTimeUnits::counts);
470  double t0mean = t0mean_f - (sumT0ByChamber[chamberId] / countT0ByChamber[chamberId]);
471  double t0rms = t0rms_f;
472  // @@@ NEW DTT0 END
473  t0sWRTChamber->set(wireId, t0mean, t0rms, DTTimeUnits::counts);
474  //if(debug)
475  //cout<<"Chamber "<<chamberId<<" has reference "<<(sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
476  cout << "Changing t0 of wire " << wireId << " from " << t0mean_f << " to " << t0mean << endl;
477  }
478  }
479 
481  if (debug)
482  cout << "[DTT0CalibrationRMS]Writing values in DB!" << endl;
483  // FIXME: to be read from cfg?
484  string t0Record = "DTT0Rcd";
485  // Write the t0 map to DB
487  DTCalibDBUtils::writeToDB(t0Record, t0sWRTChamber);
488  else
489  DTCalibDBUtils::writeToDB(t0Record, t0sAbsolute);
490 }

References funct::abs(), DTT0::begin(), DTSuperLayerId::chamberId(), DTTimeUnits::counts, gather_cfg::cout, debug, DTT0::end(), DTT0::get(), DTT0::set(), mathSSE::sqrt(), FrontierCondition_GT_autoExpress_cfi::t0, interactiveExample::theFile, tzero, and DTCalibDBUtils::writeToDB().

Referenced by o2olib.O2ORunMgr::executeJob().

◆ getHistoName() [1/2]

string DTT0CalibrationRMS::getHistoName ( const DTLayerId lId) const
private

Definition at line 499 of file DTT0CalibrationRMS.cc.

499  {
500  string histoName = "Ch_" + std::to_string(lId.wheel()) + "_" + std::to_string(lId.station()) + "_" +
501  std::to_string(lId.sector()) + "_SL" + std::to_string(lId.superlayer()) + "_L" +
502  std::to_string(lId.layer()) + "_hT0Histo";
503  return histoName;
504 }

References HltBtagPostValidation_cff::histoName, DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), and DTChamberId::wheel().

◆ getHistoName() [2/2]

string DTT0CalibrationRMS::getHistoName ( const DTWireId wId) const
private

Definition at line 492 of file DTT0CalibrationRMS.cc.

492  {
493  string histoName = "Ch_" + std::to_string(wId.wheel()) + "_" + std::to_string(wId.station()) + "_" +
494  std::to_string(wId.sector()) + "_SL" + std::to_string(wId.superlayer()) + "_L" +
495  std::to_string(wId.layer()) + "_W" + std::to_string(wId.wire()) + "_hT0Histo";
496  return histoName;
497 }

References HltBtagPostValidation_cff::histoName, DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), DTChamberId::wheel(), and DTWireId::wire().

Member Data Documentation

◆ cellsWithHistos

std::vector<std::string> DTT0CalibrationRMS::cellsWithHistos
private

Definition at line 88 of file DTT0CalibrationRMS.h.

◆ correctByChamberMean_

bool DTT0CalibrationRMS::correctByChamberMean_
private

Definition at line 73 of file DTT0CalibrationRMS.h.

◆ debug

bool DTT0CalibrationRMS::debug
private

◆ digiLabel

std::string DTT0CalibrationRMS::digiLabel
private

Definition at line 52 of file DTT0CalibrationRMS.h.

◆ dtGeom

edm::ESHandle<DTGeometry> DTT0CalibrationRMS::dtGeom
private

Definition at line 107 of file DTT0CalibrationRMS.h.

◆ eventsForLayerT0

unsigned int DTT0CalibrationRMS::eventsForLayerT0
private

Definition at line 62 of file DTT0CalibrationRMS.h.

◆ eventsForWireT0

unsigned int DTT0CalibrationRMS::eventsForWireT0
private

Definition at line 64 of file DTT0CalibrationRMS.h.

◆ hT0SectorHisto

TH1D* DTT0CalibrationRMS::hT0SectorHisto
private

Definition at line 84 of file DTT0CalibrationRMS.h.

◆ mK

std::map<DTWireId, double> DTT0CalibrationRMS::mK
private

Definition at line 96 of file DTT0CalibrationRMS.h.

◆ mK_ref

std::map<DTWireId, double> DTT0CalibrationRMS::mK_ref
private

Definition at line 97 of file DTT0CalibrationRMS.h.

◆ nDigiPerWire

std::map<DTWireId, int> DTT0CalibrationRMS::nDigiPerWire
private

Definition at line 94 of file DTT0CalibrationRMS.h.

◆ nDigiPerWire_ref

std::map<DTWireId, int> DTT0CalibrationRMS::nDigiPerWire_ref
private

Definition at line 95 of file DTT0CalibrationRMS.h.

◆ nevents

unsigned int DTT0CalibrationRMS::nevents
private

Definition at line 60 of file DTT0CalibrationRMS.h.

◆ qK

std::map<DTWireId, double> DTT0CalibrationRMS::qK
private

Definition at line 98 of file DTT0CalibrationRMS.h.

◆ rejectDigiFromPeak

unsigned int DTT0CalibrationRMS::rejectDigiFromPeak
private

Definition at line 67 of file DTT0CalibrationRMS.h.

◆ selSector

int DTT0CalibrationRMS::selSector
private

Definition at line 79 of file DTT0CalibrationRMS.h.

◆ selWheel

int DTT0CalibrationRMS::selWheel
private

Definition at line 77 of file DTT0CalibrationRMS.h.

◆ theAbsoluteT0PerWire

std::map<DTWireId, double> DTT0CalibrationRMS::theAbsoluteT0PerWire
private

Definition at line 91 of file DTT0CalibrationRMS.h.

◆ theCalibSector

std::string DTT0CalibrationRMS::theCalibSector
private

Definition at line 78 of file DTT0CalibrationRMS.h.

◆ theCalibWheel

std::string DTT0CalibrationRMS::theCalibWheel
private

Definition at line 76 of file DTT0CalibrationRMS.h.

◆ theFile

TFile* DTT0CalibrationRMS::theFile
private

Definition at line 55 of file DTT0CalibrationRMS.h.

◆ theHistoLayerMap

std::map<DTLayerId, TH1I*> DTT0CalibrationRMS::theHistoLayerMap
private

Definition at line 82 of file DTT0CalibrationRMS.h.

◆ theHistoWireMap

std::map<DTWireId, TH1I*> DTT0CalibrationRMS::theHistoWireMap
private

Definition at line 100 of file DTT0CalibrationRMS.h.

◆ theHistoWireMap_ref

std::map<DTWireId, TH1I*> DTT0CalibrationRMS::theHistoWireMap_ref
private

Definition at line 101 of file DTT0CalibrationRMS.h.

◆ theOutputFile

TFile* DTT0CalibrationRMS::theOutputFile
private

Definition at line 57 of file DTT0CalibrationRMS.h.

◆ theRelativeT0PerWire

std::map<DTWireId, double> DTT0CalibrationRMS::theRelativeT0PerWire
private

Definition at line 92 of file DTT0CalibrationRMS.h.

◆ theSigmaT0LayerMap

std::map<std::string, double> DTT0CalibrationRMS::theSigmaT0LayerMap
private

Definition at line 104 of file DTT0CalibrationRMS.h.

◆ theSigmaT0PerWire

std::map<DTWireId, double> DTT0CalibrationRMS::theSigmaT0PerWire
private

Definition at line 93 of file DTT0CalibrationRMS.h.

◆ theT0LayerMap

std::map<std::string, double> DTT0CalibrationRMS::theT0LayerMap
private

Definition at line 103 of file DTT0CalibrationRMS.h.

◆ tpPeakWidth

double DTT0CalibrationRMS::tpPeakWidth
private

Definition at line 70 of file DTT0CalibrationRMS.h.

◆ wireIdWithHistos

std::vector<DTWireId> DTT0CalibrationRMS::wireIdWithHistos
private

Definition at line 87 of file DTT0CalibrationRMS.h.

DTT0CalibrationRMS::digiLabel
std::string digiLabel
Definition: DTT0CalibrationRMS.h:52
DTT0CalibrationRMS::theCalibWheel
std::string theCalibWheel
Definition: DTT0CalibrationRMS.h:76
DTT0CalibrationRMS::nDigiPerWire_ref
std::map< DTWireId, int > nDigiPerWire_ref
Definition: DTT0CalibrationRMS.h:95
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
DTT0CalibrationRMS::tpPeakWidth
double tpPeakWidth
Definition: DTT0CalibrationRMS.h:70
DTT0CalibrationRMS::nDigiPerWire
std::map< DTWireId, int > nDigiPerWire
Definition: DTT0CalibrationRMS.h:94
DTT0CalibrationRMS::theRelativeT0PerWire
std::map< DTWireId, double > theRelativeT0PerWire
Definition: DTT0CalibrationRMS.h:92
DTT0CalibrationRMS::hT0SectorHisto
TH1D * hT0SectorHisto
Definition: DTT0CalibrationRMS.h:84
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DTT0CalibrationRMS::theHistoWireMap_ref
std::map< DTWireId, TH1I * > theHistoWireMap_ref
Definition: DTT0CalibrationRMS.h:101
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTT0CalibrationRMS::theHistoWireMap
std::map< DTWireId, TH1I * > theHistoWireMap
Definition: DTT0CalibrationRMS.h:100
DTT0CalibrationRMS::mK_ref
std::map< DTWireId, double > mK_ref
Definition: DTT0CalibrationRMS.h:97
DTSuperLayerId::superlayer
int superlayer() const
Return the superlayer number (deprecated method name)
Definition: DTSuperLayerId.h:42
DTT0CalibrationRMS::selSector
int selSector
Definition: DTT0CalibrationRMS.h:79
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle< DTDigiCollection >
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
DTT0CalibrationRMS::eventsForWireT0
unsigned int eventsForWireT0
Definition: DTT0CalibrationRMS.h:64
DTT0CalibrationRMS::qK
std::map< DTWireId, double > qK
Definition: DTT0CalibrationRMS.h:98
DTT0CalibrationRMS::theT0LayerMap
std::map< std::string, double > theT0LayerMap
Definition: DTT0CalibrationRMS.h:103
DTT0::get
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float &t0mean, float &t0rms, DTTimeUnits::type unit) const
Definition: DTT0.cc:48
DTT0CalibrationRMS::getHistoName
std::string getHistoName(const DTWireId &wId) const
Definition: DTT0CalibrationRMS.cc:492
DTWireId
Definition: DTWireId.h:12
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
DTT0CalibrationRMS::eventsForLayerT0
unsigned int eventsForLayerT0
Definition: DTT0CalibrationRMS.h:62
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DTT0::set
int set(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float t0mean, float t0rms, DTTimeUnits::type unit)
Definition: DTT0.cc:97
tzero
static const double tzero[3]
Definition: CastorTimeSlew.cc:5
DTT0CalibrationRMS::rejectDigiFromPeak
unsigned int rejectDigiFromPeak
Definition: DTT0CalibrationRMS.h:67
DTT0CalibrationRMS::nevents
unsigned int nevents
Definition: DTT0CalibrationRMS.h:60
DTLayerId
Definition: DTLayerId.h:12
DTT0CalibrationRMS::mK
std::map< DTWireId, double > mK
Definition: DTT0CalibrationRMS.h:96
DTT0CalibrationRMS::theHistoLayerMap
std::map< DTLayerId, TH1I * > theHistoLayerMap
Definition: DTT0CalibrationRMS.h:82
DTT0CalibrationRMS::theCalibSector
std::string theCalibSector
Definition: DTT0CalibrationRMS.h:78
DTSuperLayerId::chamberId
DTChamberId chamberId() const
Return the corresponding ChamberId.
Definition: DTSuperLayerId.h:45
DTT0CalibrationRMS::theSigmaT0PerWire
std::map< DTWireId, double > theSigmaT0PerWire
Definition: DTT0CalibrationRMS.h:93
DTT0CalibrationRMS::wireIdWithHistos
std::vector< DTWireId > wireIdWithHistos
Definition: DTT0CalibrationRMS.h:87
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
DTT0CalibrationRMS::theFile
TFile * theFile
Definition: DTT0CalibrationRMS.h:55
DTGeometry::superLayers
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:86
DTT0CalibrationRMS::debug
bool debug
Definition: DTT0CalibrationRMS.h:49
get
#define get
DTT0CalibrationRMS::correctByChamberMean_
bool correctByChamberMean_
Definition: DTT0CalibrationRMS.h:73
DTT0::end
const_iterator end() const
Definition: DTT0.cc:147
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
DTTimeUnits::counts
Definition: DTTimeUnits.h:32
DTLayerId::superlayerId
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
DTT0::begin
const_iterator begin() const
Definition: DTT0.cc:145
options_cfi.eventSetup
eventSetup
Definition: options_cfi.py:12
DTT0
Definition: DTT0.h:48
DTT0CalibrationRMS::cellsWithHistos
std::vector< std::string > cellsWithHistos
Definition: DTT0CalibrationRMS.h:88
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
CSCSkim_cfi.rootFileName
rootFileName
Definition: CSCSkim_cfi.py:9
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTChamberId
Definition: DTChamberId.h:14
DTT0CalibrationRMS::theSigmaT0LayerMap
std::map< std::string, double > theSigmaT0LayerMap
Definition: DTT0CalibrationRMS.h:104
event
Definition: event.py:1
DigiContainerIterator
Definition: MuonDigiCollection.h:30
DTLayerId::layer
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
DTT0CalibrationRMS::dtGeom
edm::ESHandle< DTGeometry > dtGeom
Definition: DTT0CalibrationRMS.h:107
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTT0CalibrationRMS::selWheel
int selWheel
Definition: DTT0CalibrationRMS.h:77
DTCalibDBUtils::writeToDB
static void writeToDB(std::string record, T *payload)
Definition: DTCalibDBUtils.h:28
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
DTT0::const_iterator
std::vector< DTT0Data >::const_iterator const_iterator
Access methods to data.
Definition: DTT0.h:122
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
DTT0CalibrationRMS::theAbsoluteT0PerWire
std::map< DTWireId, double > theAbsoluteT0PerWire
Definition: DTT0CalibrationRMS.h:91