55 theFile =
new TFile(rootFileName.c_str(),
"RECREATE");
62 theFitter->setVerbosity(1);
64 hChi2 =
new TH1F(
"hChi2",
"Chi squared tracks",100,0,100);
89 if(tMaxGranularity !=
"bySL"){
90 LogError(
"Calibration") <<
"[DTVDriftCalibration] tMaxGranularity will be fixed to bySL.";
91 tMaxGranularity =
"bySL";
94 if(tMaxGranularity ==
"bySL") {
96 }
else if(tMaxGranularity ==
"byChamber"){
98 }
else if(tMaxGranularity==
"byPartition") {
100 }
else throw cms::Exception(
"Configuration") <<
"[DTVDriftCalibration] Check parameter tMaxGranularity: " 101 << tMaxGranularity <<
" option not available";
104 LogVerbatim(
"Calibration") <<
"[DTVDriftCalibration]Constructor called!";
110 LogVerbatim(
"Calibration") <<
"[DTVDriftCalibration]Destructor called!";
114 LogTrace(
"Calibration") <<
"--- [DTVDriftCalibration] Event analysed #Run: " <<
event.id().run()
115 <<
" #Event: " <<
event.id().event();
120 stringstream linestr;
121 int selWheel, selStation, selSector;
123 linestr >> selWheel >> selStation >> selSector;
124 chosenChamberId =
DTChamberId(selWheel, selStation, selSector);
125 LogTrace(
"Calibration") <<
"chosen chamber " << chosenChamberId;
146 DTRecSegment4DCollection::id_iterator chamberIdIt;
147 for (chamberIdIt = all4DSegments->id_begin();
148 chamberIdIt != all4DSegments->id_end();
153 LogTrace(
"Calibration") <<
"Chamber Id: " << *chamberIdIt;
164 segment!=range.second; ++segment){
166 if( !(*segment).hasZed() && !(*segment).hasPhi() ){
167 LogError(
"Calibration") <<
"4D segment without Z and Phi segments";
171 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
172 <<
"\nSegment global pos: " << chamber->
toGlobal((*segment).localPosition());
174 if( !
select_(*segment, event, eventSetup) )
continue;
178 map<DTSuperLayerId,vector<DTRecHit1D> > hitsBySLMap;
179 if((*segment).hasPhi()){
184 for(vector<DTRecHit1D>::const_iterator
hit = phiHits.begin();
185 hit != phiHits.end(); ++
hit) {
188 hitsBySLMap[slId].push_back(*
hit);
194 if((*segment).hasZed()) {
197 zSeg2DPosInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localPosition()));
198 zSeg2DDirInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localDirection()));
202 LocalPoint segment4DLocalPos = (*segment).localPosition();
203 LocalVector segment4DLocalDir = (*segment).localDirection();
204 double chiSquare = ((*segment).chi2()/(*segment).degreesOfFreedom());
206 hChi2->Fill(chiSquare);
207 if((*segment).hasPhi())
208 h2DSegmRPhi->
Fill(phiSeg2DPosInCham.
x(), phiSeg2DDirInCham.
x()/phiSeg2DDirInCham.
z());
209 if((*segment).hasZed())
210 h2DSegmRZ->
Fill(zSeg2DPosInCham.
y(), zSeg2DDirInCham.
y()/zSeg2DDirInCham.
z());
212 if((*segment).hasZed() && (*segment).hasPhi())
214 segment4DLocalPos.
y(),
215 atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())*180./
Geom::pi(),
216 atan(segment4DLocalDir.
y()/segment4DLocalDir.
z())*180./
Geom::pi(),
218 else if((*segment).hasPhi())
220 atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())*180./
Geom::pi());
221 else if((*segment).hasZed())
222 LogWarning(
"Calibration") <<
"4d segment with only Z";
225 for(
map<
DTSuperLayerId,vector<DTRecHit1D> >::const_iterator slIdAndHits = hitsBySLMap.begin(); slIdAndHits != hitsBySLMap.end(); ++slIdAndHits) {
226 if (slIdAndHits->second.size() < 3)
continue;
233 vector<const TMax*> tMaxes = slSeg.
getTMax(slId);
238 TString
name = (((((TString)
"TMax"+(
long) slId.
wheel()) +(
long) slId.
station())
247 LogWarning(
"Calibration") <<
"[DTVDriftCalibration] ###Warning: the chosen granularity is not implemented yet, only bySL available!";
277 gROOT->GetList()->Write();
297 DTWireId wireId = (*wireCell).first;
298 vector<float> newConstants;
299 TString
N=(((((TString)
"TMax"+(
long) wireId.
wheel()) +(
long) wireId.
station())
304 if(vDriftAndReso.front() == -1)
307 if(oldConstants !=
nullptr) {
308 newConstants.push_back((*oldConstants)[0]);
309 newConstants.push_back((*oldConstants)[1]);
310 newConstants.push_back((*oldConstants)[2]);
312 newConstants.push_back(-1);
313 newConstants.push_back(-1);
314 newConstants.push_back(-1);
316 for(
int ivd=0; ivd<=5;ivd++) {
319 newConstants.push_back(vDriftAndReso[ivd]);
322 calibValuesFile.
addCell(calibValuesFile.
getKey(wireId), newConstants);
329 LogTrace(
"Calibration") <<
" SL: " << (wireId.
layerId()).superlayerId()
330 <<
" vDrift = " << vDriftAndReso[0]
331 <<
" reso = " << vDriftAndReso[1];
370 LogVerbatim(
"Calibration") <<
"[DTVDriftCalibration]Writing vdrift object to DB!";
373 string record =
"DTMtimeRcd";
374 DTCalibDBUtils::writeToDB<DTMtime>(
record, mTime);
398 vector<const TMax*> tMaxes = _tMaxes;
409 unsigned hSubGroup = 0;
410 for (vector<const TMax*>::const_iterator it=tMaxes.begin(); it!=tMaxes.end();
417 if (addedCells.size()==4 ||
418 find(addedCells.begin(), addedCells.end(), (*it)->cells)
419 != addedCells.end()) {
422 addedCells.push_back((*it)->cells);
426 unsigned t0Factor = (*it)->t0Factor;
427 hSubGroup = (*it)->hSubGroup;
430 case notInit :
cout <<
"Error: no cell type assigned to TMax" << endl;
break;
431 case c123 : tmax123 =
t; t0_123 = t0Factor;
break;
432 case c124 : tmax124 =
t; s124 = sigma; t0_124 = t0Factor;
break;
433 case c134 : tmax134 =
t; s134 = sigma; t0_134 = t0Factor;
break;
434 case c234 : tmax234 =
t; t0_234 = t0Factor;
break;
439 histos->Fill(tmax123, tmax124, tmax134, tmax234, s124, s134, t0_123,
440 t0_124, t0_134, t0_234, hSubGroup);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Key getKey(DTWireId wireId) const
void writeConsts(const std::string &outputFileName) const
std::pair< const_iterator, const_iterator > range
iterator range
TMaxGranularity theGranularity
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void Fill(float x, float y, float phi, float theta, float impact)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
void Fill(float pos, float localAngle)
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::string theVDriftOutputFile
std::vector< const TMax * > getTMax(const DTWireId &idWire)
Geom::Theta< T > theta() const
virtual void setES(const edm::EventSetup &setup)=0
Pass the Event Setup to the synchronization module at each event.
std::map< DTWireId, cellInfo * > theWireIdAndCellMap
edm::ParameterSet theCalibFilePar
std::vector< float > CalibConsts
int superLayer() const
Return the superlayer number.
void addCell(Key wireId, const CalibConsts &calibConst)
void add(const std::vector< const TMax * > &tMaxes)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
LocalPoint localPosition() const override
local position in SL frame
~DTVDriftCalibration() override
Destructor.
DTSegmentSelector select_
DTMeanTimerFitter * theFitter
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
const CalibConsts * getConsts(DTWireId wireId) const
std::string theCalibChamber
DTLayerId layerId() const
Return the corresponding LayerId.
LocalVector localDirection() const override
the local direction in SL frame
DTVDriftCalibration(const edm::ParameterSet &pset)
Constructor.
int station() const
Return the station number.
int wheel() const
Return the wheel number.
DTTTrigBaseSync * theSync
std::vector< float > evaluateVDriftAndReso(const TString &N)
Fit the TMax histos and evaluate VDrift and resolution.
edm::InputTag theRecHits4DLabel
T get(const Candidate &c)