CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
DTVDriftCalibration Class Reference

#include <DTVDriftCalibration.h>

Inheritance diagram for DTVDriftCalibration:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

class  cellInfo
 

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
 DTVDriftCalibration (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob () override
 
 ~DTVDriftCalibration () override
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 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 Types

typedef DTTMax::TMax TMax
 
enum  TMaxGranularity { byChamber, bySL, byPartition }
 

Private Attributes

bool debug
 
std::string digiLabel
 
bool findVDriftAndT0
 
h2DSegmh2DSegmRPhi
 
h2DSegmh2DSegmRZ
 
h4DSegmh4DSegmAllCh
 
TH1F * hChi2
 
dtcalibration::Histograms histograms_
 
std::unique_ptr
< DTSegmentSelector
select_
 
std::string theCalibChamber
 
edm::ParameterSet theCalibFilePar
 
const edm::ESGetToken
< DTGeometry,
MuonGeometryRecord
theDTGeomToken
 
TFile * theFile
 
std::unique_ptr
< DTMeanTimerFitter
theFitter
 
TMaxGranularity theGranularity
 
edm::EDGetTokenT
< DTRecSegment4DCollection
theRecHits4DToken
 
std::unique_ptr< DTTTrigBaseSynctheSync
 
std::string theVDriftOutputFile
 
std::map< DTWireId, cellInfo * > theWireIdAndCellMap
 
bool writeLegacyVDriftDB
 

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

No description available.

Author
M. Giunta

Definition at line 35 of file DTVDriftCalibration.h.

Member Typedef Documentation

Definition at line 54 of file DTVDriftCalibration.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

DTVDriftCalibration::DTVDriftCalibration ( const edm::ParameterSet pset)

Constructor.

Definition at line 44 of file DTVDriftCalibration.cc.

References edm::EDConsumerBase::esConsumes().

45  : // Get the synchronizer
47  theSync{DTTTrigSyncFactory::get()->create(pset.getParameter<string>("tTrigMode"),
48  pset.getParameter<ParameterSet>("tTrigModeConfig"),
50 
51 {
53  select_ = std::make_unique<DTSegmentSelector>(pset, collector);
54 
55  // The name of the 4D rec hits collection
56  theRecHits4DToken = (consumes<DTRecSegment4DCollection>(pset.getParameter<InputTag>("recHits4DLabel")));
57 
58  // The root file which will contain the histos
59  string rootFileName = pset.getUntrackedParameter<string>("rootFileName");
60  theFile = new TFile(rootFileName.c_str(), "RECREATE");
61  theFile->cd();
62 
63  debug = pset.getUntrackedParameter<bool>("debug", false);
64 
65  theFitter = std::make_unique<DTMeanTimerFitter>(theFile);
66  if (debug)
67  theFitter->setVerbosity(1);
68 
69  hChi2 = new TH1F("hChi2", "Chi squared tracks", 100, 0, 100);
70  h2DSegmRPhi = new h2DSegm("SLRPhi");
71  h2DSegmRZ = new h2DSegm("SLRZ");
72  h4DSegmAllCh = new h4DSegm("AllCh");
74 
75  findVDriftAndT0 = pset.getUntrackedParameter<bool>("fitAndWrite", false);
76 
77  // Chamber/s to calibrate
78  theCalibChamber = pset.getUntrackedParameter<string>("calibChamber", "All");
79 
80  // the txt file which will contain the calibrated constants
81  theVDriftOutputFile = pset.getUntrackedParameter<string>("vDriftFileName");
82 
83  // get parameter set for DTCalibrationMap constructor
84  theCalibFilePar = pset.getUntrackedParameter<ParameterSet>("calibFileConfig");
85 
86  // the granularity to be used for tMax
87  string tMaxGranularity = pset.getUntrackedParameter<string>("tMaxGranularity", "bySL");
88 
89  writeLegacyVDriftDB = pset.getParameter<bool>("writeLegacyVDriftDB");
90 
91  // Enforce it to be by SL since rest is not implemented
92  if (tMaxGranularity != "bySL") {
93  LogError("Calibration") << "[DTVDriftCalibration] tMaxGranularity will be fixed to bySL.";
94  tMaxGranularity = "bySL";
95  }
96  // Initialize correctly the enum which specify the granularity for the calibration
97  if (tMaxGranularity == "bySL") {
99  } else if (tMaxGranularity == "byChamber") {
101  } else if (tMaxGranularity == "byPartition") {
103  } else
104  throw cms::Exception("Configuration")
105  << "[DTVDriftCalibration] Check parameter tMaxGranularity: " << tMaxGranularity << " option not available";
106 
107  LogVerbatim("Calibration") << "[DTVDriftCalibration]Constructor called!";
108 }
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeomToken
TMaxGranularity theGranularity
std::unique_ptr< DTTTrigBaseSync > theSync
Log< level::Error, false > LogError
edm::ParameterSet theCalibFilePar
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< DTRecSegment4DCollection > theRecHits4DToken
std::unique_ptr< DTMeanTimerFitter > theFitter
dtcalibration::Histograms histograms_
std::unique_ptr< DTSegmentSelector > select_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define get
DTVDriftCalibration::~DTVDriftCalibration ( )
override

Destructor.

Definition at line 110 of file DTVDriftCalibration.cc.

110  {
111  theFile->Close();
112  LogVerbatim("Calibration") << "[DTVDriftCalibration]Destructor called!";
113 }
Log< level::Info, true > LogVerbatim

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 115 of file DTVDriftCalibration.cc.

References DTVDriftCalibration::cellInfo::add(), bySL, DTGeometry::chamber(), DTChamberId, h4DSegm::Fill(), h2DSegm::Fill(), edm::EventSetup::getData(), DTTMax::getTMax(), h2DSegmRPhi, h2DSegmRZ, h4DSegmAllCh, hChi2, histograms_, DTRecSegment2D::localDirection(), DTRecSegment2D::localPosition(), LogTrace, mergeVDriftHistosByStation::name, Geom::pi(), sistrip::SpyUtilities::range(), DTChamberId::sector(), select_, DTRecSegment2D::specificRecHits(), DTChamberId::station(), DTSuperLayerId::superLayer(), DTChamber::superLayer(), DTSLRecSegment2D::superLayerId(), DTLayerId::superlayerId(), theCalibChamber, theDTGeomToken, theGranularity, theRecHits4DToken, theSync, PV3DBase< T, PVType, FrameType >::theta(), theWireIdAndCellMap, GeomDet::toGlobal(), GeomDet::toLocal(), DTVDriftCalibration::cellInfo::update(), DTChamberId::wheel(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

115  {
116  LogTrace("Calibration") << "--- [DTVDriftCalibration] Event analysed #Run: " << event.id().run()
117  << " #Event: " << event.id().event();
118  theFile->cd();
119  DTChamberId chosenChamberId;
120 
121  if (theCalibChamber != "All") {
122  stringstream linestr;
123  int selWheel, selStation, selSector;
124  linestr << theCalibChamber;
125  linestr >> selWheel >> selStation >> selSector;
126  chosenChamberId = DTChamberId(selWheel, selStation, selSector);
127  LogTrace("Calibration") << "chosen chamber " << chosenChamberId;
128  }
129 
130  // Get the DT Geometry
131  const DTGeometry& dtGeom = eventSetup.getData(theDTGeomToken);
132 
133  // Get the rechit collection from the event
134  Handle<DTRecSegment4DCollection> all4DSegments;
135  event.getByToken(theRecHits4DToken, all4DSegments);
136 
137  // Set the event setup in the Synchronizer
138  theSync->setES(eventSetup);
139 
140  // Loop over segments by chamber
142  for (chamberIdIt = all4DSegments->id_begin(); chamberIdIt != all4DSegments->id_end(); ++chamberIdIt) {
143  // Get the chamber from the setup
144  const DTChamber* chamber = dtGeom.chamber(*chamberIdIt);
145  LogTrace("Calibration") << "Chamber Id: " << *chamberIdIt;
146 
147  // Calibrate just the chosen chamber/s
148  if ((theCalibChamber != "All") && ((*chamberIdIt) != chosenChamberId))
149  continue;
150 
151  // Get the range for the corresponding ChamberId
152  DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt));
153 
154  // Loop over the rechits of this DetUnit
155  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment != range.second; ++segment) {
156  if (!(*segment).hasZed() && !(*segment).hasPhi()) {
157  LogError("Calibration") << "4D segment without Z and Phi segments";
158  continue;
159  }
160 
161  LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition()
162  << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition());
163 
164  if (!((*select_)(*segment, event, eventSetup)))
165  continue;
166 
167  LocalPoint phiSeg2DPosInCham;
168  LocalVector phiSeg2DDirInCham;
169  map<DTSuperLayerId, vector<DTRecHit1D> > hitsBySLMap;
170  if ((*segment).hasPhi()) {
171  const DTChamberRecSegment2D* phiSeg = (*segment).phiSegment(); // phiSeg lives in the chamber RF
172  phiSeg2DPosInCham = phiSeg->localPosition();
173  phiSeg2DDirInCham = phiSeg->localDirection();
174  vector<DTRecHit1D> phiHits = phiSeg->specificRecHits();
175  for (vector<DTRecHit1D>::const_iterator hit = phiHits.begin(); hit != phiHits.end(); ++hit) {
176  DTWireId wireId = (*hit).wireId();
177  DTSuperLayerId slId = wireId.superlayerId();
178  hitsBySLMap[slId].push_back(*hit);
179  }
180  }
181  // Get the Theta 2D segment and plot the angle in the chamber RF
182  LocalVector zSeg2DDirInCham;
183  LocalPoint zSeg2DPosInCham;
184  if ((*segment).hasZed()) {
185  const DTSLRecSegment2D* zSeg = (*segment).zSegment(); // zSeg lives in the SL RF
186  const DTSuperLayer* sl = chamber->superLayer(zSeg->superLayerId());
187  zSeg2DPosInCham = chamber->toLocal(sl->toGlobal((*zSeg).localPosition()));
188  zSeg2DDirInCham = chamber->toLocal(sl->toGlobal((*zSeg).localDirection()));
189  hitsBySLMap[zSeg->superLayerId()] = zSeg->specificRecHits();
190  }
191 
192  LocalPoint segment4DLocalPos = (*segment).localPosition();
193  LocalVector segment4DLocalDir = (*segment).localDirection();
194  double chiSquare = ((*segment).chi2() / (*segment).degreesOfFreedom());
195 
196  hChi2->Fill(chiSquare);
197  if ((*segment).hasPhi())
198  h2DSegmRPhi->Fill(phiSeg2DPosInCham.x(), phiSeg2DDirInCham.x() / phiSeg2DDirInCham.z());
199  if ((*segment).hasZed())
200  h2DSegmRZ->Fill(zSeg2DPosInCham.y(), zSeg2DDirInCham.y() / zSeg2DDirInCham.z());
201 
202  if ((*segment).hasZed() && (*segment).hasPhi())
203  h4DSegmAllCh->Fill(segment4DLocalPos.x(),
204  segment4DLocalPos.y(),
205  atan(segment4DLocalDir.x() / segment4DLocalDir.z()) * 180. / Geom::pi(),
206  atan(segment4DLocalDir.y() / segment4DLocalDir.z()) * 180. / Geom::pi(),
207  180 - segment4DLocalDir.theta() * 180. / Geom::pi());
208  else if ((*segment).hasPhi())
209  h4DSegmAllCh->Fill(segment4DLocalPos.x(),
210  atan(segment4DLocalDir.x() / segment4DLocalDir.z()) * 180. / Geom::pi());
211  else if ((*segment).hasZed())
212  LogWarning("Calibration") << "4d segment with only Z";
213 
214  //loop over the segments
215  for (map<DTSuperLayerId, vector<DTRecHit1D> >::const_iterator slIdAndHits = hitsBySLMap.begin();
216  slIdAndHits != hitsBySLMap.end();
217  ++slIdAndHits) {
218  if (slIdAndHits->second.size() < 3)
219  continue;
220  DTSuperLayerId slId = slIdAndHits->first;
221 
222  // Create the DTTMax, that computes the 4 TMax
223  DTTMax slSeg(slIdAndHits->second,
224  *(chamber->superLayer(slIdAndHits->first)),
225  chamber->toGlobal((*segment).localDirection()),
226  chamber->toGlobal((*segment).localPosition()),
227  *theSync,
228  histograms_);
229 
230  if (theGranularity == bySL) {
231  vector<const TMax*> tMaxes = slSeg.getTMax(slId);
232  DTWireId wireId(slId, 0, 0);
233  theFile->cd();
234  cellInfo* cell = theWireIdAndCellMap[wireId];
235  if (cell == nullptr) {
236  TString name = (((((TString) "TMax" + (long)slId.wheel()) + (long)slId.station()) + (long)slId.sector()) +
237  (long)slId.superLayer());
238  cell = new cellInfo(name);
239  theWireIdAndCellMap[wireId] = cell;
240  }
241  cell->add(tMaxes);
242  cell->update(); // FIXME to reset the counter to avoid triple counting, which actually is not used...
243  } else {
244  LogWarning("Calibration") << "[DTVDriftCalibration] ###Warning: the chosen granularity is not implemented "
245  "yet, only bySL available!";
246  }
247  // to be implemented: granularity different from bySL
248 
249  // else if (theGranularity == byPartition) {
250  // // Use the custom granularity defined by partition();
251  // // in this case, add() should be called once for each Tmax of each layer
252  // // and triple counting should be avoided within add()
253  // vector<cellInfo*> cells;
254  // for (int i=1; i<=4; i++) {
255  // const DTTMax::InfoLayer* iLayer = slSeg.getInfoLayer(i);
256  // if(iLayer == 0) continue;
257  // cellInfo * cell = partition(iLayer->idWire);
258  // cells.push_back(cell);
259  // vector<const TMax*> tMaxes = slSeg.getTMax(iLayer->idWire);
260  // cell->add(tMaxes);
261  // }
262  // //reset the counter to avoid triple counting
263  // for (vector<cellInfo*>::const_iterator i = cells.begin();
264  // i!= cells.end(); i++) {
265  // (*i)->update();
266  // }
267  // }
268  }
269  }
270  }
271 }
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeomToken
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
LocalPoint localPosition() const override
local position in SL frame
LocalVector localDirection() const override
the local direction in SL frame
TMaxGranularity theGranularity
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
std::unique_ptr< DTTTrigBaseSync > theSync
Definition: DTTMax.h:32
T y() const
Definition: PV3DBase.h:60
void Fill(float x, float y, float phi, float theta, float impact)
Definition: vDriftHistos.h:40
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
identifier iterator
Definition: RangeMap.h:130
void Fill(float pos, float localAngle)
Definition: vDriftHistos.h:91
Log< level::Error, false > LogError
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
#define LogTrace(id)
const uint16_t range(const Frame &aFrame)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
bool getData(T &iHolder) const
Definition: EventSetup.h:128
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
std::map< DTWireId, cellInfo * > theWireIdAndCellMap
T z() const
Definition: PV3DBase.h:61
int superLayer() const
Return the superlayer number.
edm::EDGetTokenT< DTRecSegment4DCollection > theRecHits4DToken
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
dtcalibration::Histograms histograms_
std::unique_ptr< DTSegmentSelector > select_
int sector() const
Definition: DTChamberId.h:49
Log< level::Warning, false > LogWarning
constexpr double pi()
Definition: Pi.h:31
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
T x() const
Definition: PV3DBase.h:59
void DTVDriftCalibration::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 273 of file DTVDriftCalibration.cc.

References DTCalibrationMap::addCell(), bySL, DTVelocityUnits::cm_per_ns, findVDriftAndT0, DTCalibrationMap::getConsts(), DTVDriftCalibration::cellInfo::getHists(), DTCalibrationMap::getKey(), h2DSegmRPhi, h2DSegmRZ, h4DSegmAllCh, hChi2, DTWireId::layerId(), LogTrace, N, submitPVValidationJobs::params, GlobalPosition_Frontier_DevDB_cff::record, DTChamberId::sector(), DTRecoConditions::set(), DTMtime::set(), DTRecoConditions::setFormulaExpr(), DTRecoConditions::setVersion(), DTChamberId::station(), DTSuperLayerId::superLayer(), theGranularity, theWireIdAndCellMap, DTChamberId::wheel(), h4DSegm::Write(), h2DSegm::Write(), hTMaxCell::Write(), and DTCalibrationMap::writeConsts().

Referenced by o2olib.O2ORunMgr::executeJob().

273  {
274  theFile->cd();
275  gROOT->GetList()->Write();
276  h2DSegmRPhi->Write();
277  h2DSegmRZ->Write();
278  h4DSegmAllCh->Write();
279  hChi2->Write();
280  // Instantiate a DTCalibrationMap object if you want to calculate the calibration constants
281  DTCalibrationMap calibValuesFile(theCalibFilePar);
282  // Create the object to be written to DB
283  DTMtime* mTime = nullptr;
284  DTRecoConditions* vDrift = nullptr;
285  if (writeLegacyVDriftDB) {
286  mTime = new DTMtime();
287  } else {
288  vDrift = new DTRecoConditions();
289  vDrift->setFormulaExpr("[0]");
290  //vDriftNewMap->setFormulaExpr("[0]*(1-[1]*x)"); // add parametrization for dependency along Y
291  vDrift->setVersion(1);
292  }
293 
294  // write the TMax histograms of each SL to the root file
295  if (theGranularity == bySL) {
296  for (map<DTWireId, cellInfo*>::const_iterator wireCell = theWireIdAndCellMap.begin();
297  wireCell != theWireIdAndCellMap.end();
298  ++wireCell) {
299  cellInfo* cell = theWireIdAndCellMap[(*wireCell).first];
300  hTMaxCell* cellHists = cell->getHists();
301  theFile->cd();
302  cellHists->Write();
303  if (findVDriftAndT0) { // if TRUE: evaluate calibration constants from TMax hists filled in this job
304  // evaluate v_drift and sigma from the TMax histograms
305  DTWireId wireId = (*wireCell).first;
306  vector<float> newConstants;
307  TString N = (((((TString) "TMax" + (long)wireId.wheel()) + (long)wireId.station()) + (long)wireId.sector()) +
308  (long)wireId.superLayer());
309  vector<float> vDriftAndReso = theFitter->evaluateVDriftAndReso(N);
310 
311  // Don't write the constants for the SL if the vdrift was not computed
312  if (vDriftAndReso.front() == -1)
313  continue;
314  const DTCalibrationMap::CalibConsts* oldConstants = calibValuesFile.getConsts(wireId);
315  if (oldConstants != nullptr) {
316  newConstants.push_back((*oldConstants)[0]);
317  newConstants.push_back((*oldConstants)[1]);
318  newConstants.push_back((*oldConstants)[2]);
319  } else {
320  newConstants.push_back(-1);
321  newConstants.push_back(-1);
322  newConstants.push_back(-1);
323  }
324  for (int ivd = 0; ivd <= 5; ivd++) {
325  // 0=vdrift, 1=reso, 2=(3deltat0-2deltat0), 3=(2deltat0-1deltat0),
326  // 4=(1deltat0-0deltat0), 5=deltat0 from hists with max entries,
327  newConstants.push_back(vDriftAndReso[ivd]);
328  }
329 
330  calibValuesFile.addCell(calibValuesFile.getKey(wireId), newConstants);
331 
332  // vdrift is cm/ns , resolution is cm
333  if (writeLegacyVDriftDB) {
334  mTime->set((wireId.layerId()).superlayerId(), vDriftAndReso[0], vDriftAndReso[1], DTVelocityUnits::cm_per_ns);
335  } else {
336  vector<double> params = {vDriftAndReso[0]};
337  vDrift->set(wireId, params);
338  }
339  LogTrace("Calibration") << " SL: " << (wireId.layerId()).superlayerId() << " vDrift = " << vDriftAndReso[0]
340  << " reso = " << vDriftAndReso[1];
341  }
342  }
343  }
344 
345  // to be implemented: granularity different from bySL
346 
347  // if(theGranularity == "byChamber") {
348  // const vector<DTChamber*> chambers = dMap.chambers();
349 
350  // // Loop over all chambers
351  // for(vector<MuBarChamber*>::const_iterator chamber = chambers.begin();
352  // chamber != chambers.end(); chamber ++) {
353  // MuBarChamberId chamber_id = (*chamber)->id();
354  // MuBarDigiParameters::Key wire_id(chamber_id, 0, 0, 0);
355  // vector<float> newConstants;
356  // vector<float> vDriftAndReso = evaluateVDriftAndReso(wire_id, f);
357  // const CalibConsts* oldConstants = digiParams.getConsts(wire_id);
358  // if(oldConstants !=0) {
359  // newConstants = *oldConstants;
360  // newConstants.push_back(vDriftAndReso[0]);
361  // newConstants.push_back(vDriftAndReso[1]);
362  // newConstants.push_back(vDriftAndReso[2]);
363  // newConstants.push_back(vDriftAndReso[3]);
364  // } else {
365  // newConstants.push_back(-1);
366  // newConstants.push_back(-1);
367  // newConstants.push_back(vDriftAndReso[0]);
368  // newConstants.push_back(vDriftAndReso[1]);
369  // newConstants.push_back(vDriftAndReso[2]);
370  // newConstants.push_back(vDriftAndReso[3]);
371  // }
372  // digiParams.addCell(wire_id, newConstants);
373  // }
374  // }
375 
376  // Write values to a table
377  calibValuesFile.writeConsts(theVDriftOutputFile);
378 
379  LogVerbatim("Calibration") << "[DTVDriftCalibration]Writing vdrift object to DB!";
380 
381  // Write the vdrift object to DB
382  if (writeLegacyVDriftDB) {
383  string record = "DTMtimeRcd";
384  DTCalibDBUtils::writeToDB<DTMtime>(record, mTime);
385  } else {
386  DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsVdriftRcd", vDrift);
387  }
388 }
Log< level::Info, true > LogVerbatim
TMaxGranularity theGranularity
void setVersion(int version)
void set(const DTWireId &wireid, const std::vector< double > &values)
Fill the payload.
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:168
void Write()
Definition: vDriftHistos.h:96
#define LogTrace(id)
std::map< DTWireId, cellInfo * > theWireIdAndCellMap
edm::ParameterSet theCalibFilePar
std::vector< float > CalibConsts
int superLayer() const
Return the superlayer number.
void Write()
Definition: vDriftHistos.h:463
std::unique_ptr< DTMeanTimerFitter > theFitter
#define N
Definition: blowfish.cc:9
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:45
int sector() const
Definition: DTChamberId.h:49
void setFormulaExpr(const std::string &expr)
Set the expression representing the formula used for parametrization.
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
void Write()
Definition: vDriftHistos.h:51

Member Data Documentation

bool DTVDriftCalibration::debug
private
std::string DTVDriftCalibration::digiLabel
private

Definition at line 98 of file DTVDriftCalibration.h.

bool DTVDriftCalibration::findVDriftAndT0
private

Definition at line 108 of file DTVDriftCalibration.h.

Referenced by endJob().

h2DSegm* DTVDriftCalibration::h2DSegmRPhi
private

Definition at line 79 of file DTVDriftCalibration.h.

Referenced by analyze(), and endJob().

h2DSegm* DTVDriftCalibration::h2DSegmRZ
private

Definition at line 78 of file DTVDriftCalibration.h.

Referenced by analyze(), and endJob().

h4DSegm* DTVDriftCalibration::h4DSegmAllCh
private

Definition at line 80 of file DTVDriftCalibration.h.

Referenced by analyze(), and endJob().

TH1F* DTVDriftCalibration::hChi2
private

Definition at line 77 of file DTVDriftCalibration.h.

Referenced by analyze(), and endJob().

dtcalibration::Histograms DTVDriftCalibration::histograms_
private

Definition at line 56 of file DTVDriftCalibration.h.

Referenced by analyze().

std::unique_ptr<DTSegmentSelector> DTVDriftCalibration::select_
private

Definition at line 51 of file DTVDriftCalibration.h.

Referenced by analyze().

std::string DTVDriftCalibration::theCalibChamber
private

Definition at line 135 of file DTVDriftCalibration.h.

Referenced by analyze().

edm::ParameterSet DTVDriftCalibration::theCalibFilePar
private

Definition at line 123 of file DTVDriftCalibration.h.

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTVDriftCalibration::theDTGeomToken
private

Definition at line 92 of file DTVDriftCalibration.h.

Referenced by analyze().

TFile* DTVDriftCalibration::theFile
private

Definition at line 101 of file DTVDriftCalibration.h.

std::unique_ptr<DTMeanTimerFitter> DTVDriftCalibration::theFitter
private

Definition at line 104 of file DTVDriftCalibration.h.

TMaxGranularity DTVDriftCalibration::theGranularity
private

Definition at line 87 of file DTVDriftCalibration.h.

Referenced by analyze(), and endJob().

edm::EDGetTokenT<DTRecSegment4DCollection> DTVDriftCalibration::theRecHits4DToken
private

Definition at line 90 of file DTVDriftCalibration.h.

Referenced by analyze().

std::unique_ptr<DTTTrigBaseSync> DTVDriftCalibration::theSync
private

Definition at line 120 of file DTVDriftCalibration.h.

Referenced by analyze().

std::string DTVDriftCalibration::theVDriftOutputFile
private

Definition at line 111 of file DTVDriftCalibration.h.

std::map<DTWireId, cellInfo*> DTVDriftCalibration::theWireIdAndCellMap
private

Definition at line 114 of file DTVDriftCalibration.h.

Referenced by analyze(), and endJob().

bool DTVDriftCalibration::writeLegacyVDriftDB
private

Definition at line 138 of file DTVDriftCalibration.h.