47 using namespace dttmaxenums;
57 theFile =
new TFile(rootFileName.c_str(),
"RECREATE");
64 theFitter->setVerbosity(1);
66 hChi2 =
new TH1F(
"hChi2",
"Chi squared tracks",100,0,100);
91 if(tMaxGranularity !=
"bySL"){
92 LogError(
"Calibration") <<
"[DTVDriftCalibration] tMaxGranularity will be fixed to bySL.";
93 tMaxGranularity =
"bySL";
96 if(tMaxGranularity ==
"bySL") {
98 }
else if(tMaxGranularity ==
"byChamber"){
100 }
else if(tMaxGranularity==
"byPartition") {
102 }
else throw cms::Exception(
"Configuration") <<
"[DTVDriftCalibration] Check parameter tMaxGranularity: "
103 << tMaxGranularity <<
" option not available";
106 LogVerbatim(
"Calibration") <<
"[DTVDriftCalibration]Constructor called!";
112 LogVerbatim(
"Calibration") <<
"[DTVDriftCalibration]Destructor called!";
116 LogTrace(
"Calibration") <<
"--- [DTVDriftCalibration] Event analysed #Run: " <<
event.id().run()
117 <<
" #Event: " <<
event.id().event();
122 stringstream linestr;
123 int selWheel, selStation, selSector;
125 linestr >> selWheel >> selStation >> selSector;
126 chosenChamberId =
DTChamberId(selWheel, selStation, selSector);
127 LogTrace(
"Calibration") <<
"chosen chamber " << chosenChamberId;
149 for (chamberIdIt = all4DSegments->id_begin();
150 chamberIdIt != all4DSegments->id_end();
154 const DTChamber* chamber = dtGeom->chamber(*chamberIdIt);
155 LogTrace(
"Calibration") <<
"Chamber Id: " << *chamberIdIt;
166 segment!=range.second; ++segment){
168 if( !(*segment).hasZed() && !(*segment).hasPhi() ){
169 LogError(
"Calibration") <<
"4D segment without Z and Phi segments";
173 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
174 <<
"\nSegment global pos: " << chamber->
toGlobal((*segment).localPosition());
176 if( !
select_(*segment, event, eventSetup) )
continue;
180 map<DTSuperLayerId,vector<DTRecHit1D> > hitsBySLMap;
181 if((*segment).hasPhi()){
186 for(vector<DTRecHit1D>::const_iterator
hit = phiHits.begin();
187 hit != phiHits.end(); ++
hit) {
190 hitsBySLMap[slId].push_back(*
hit);
196 if((*segment).hasZed()) {
199 zSeg2DPosInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localPosition()));
200 zSeg2DDirInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localDirection()));
204 LocalPoint segment4DLocalPos = (*segment).localPosition();
205 LocalVector segment4DLocalDir = (*segment).localDirection();
206 double chiSquare = ((*segment).chi2()/(*segment).degreesOfFreedom());
208 hChi2->Fill(chiSquare);
209 if((*segment).hasPhi())
210 h2DSegmRPhi->
Fill(phiSeg2DPosInCham.
x(), phiSeg2DDirInCham.
x()/phiSeg2DDirInCham.
z());
211 if((*segment).hasZed())
212 h2DSegmRZ->
Fill(zSeg2DPosInCham.
y(), zSeg2DDirInCham.
y()/zSeg2DDirInCham.
z());
214 if((*segment).hasZed() && (*segment).hasPhi())
216 segment4DLocalPos.
y(),
217 atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())*180./
Geom::pi(),
218 atan(segment4DLocalDir.
y()/segment4DLocalDir.
z())*180./
Geom::pi(),
220 else if((*segment).hasPhi())
222 atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())*180./
Geom::pi());
223 else if((*segment).hasZed())
224 LogWarning(
"Calibration") <<
"4d segment with only Z";
227 for(
map<
DTSuperLayerId,vector<DTRecHit1D> >::const_iterator slIdAndHits = hitsBySLMap.begin(); slIdAndHits != hitsBySLMap.end(); ++slIdAndHits) {
228 if (slIdAndHits->second.size() < 3)
continue;
235 vector<const TMax*> tMaxes = slSeg.
getTMax(slId);
240 TString
name = (((((TString)
"TMax"+(
long) slId.
wheel()) +(
long) slId.
station())
249 LogWarning(
"Calibration") <<
"[DTVDriftCalibration] ###Warning: the chosen granularity is not implemented yet, only bySL available!";
279 gROOT->GetList()->Write();
299 DTWireId wireId = (*wireCell).first;
300 vector<float> newConstants;
301 TString
N=(((((TString)
"TMax"+(
long) wireId.
wheel()) +(
long) wireId.
station())
306 if(vDriftAndReso.front() == -1)
309 if(oldConstants != 0) {
310 newConstants.push_back((*oldConstants)[0]);
311 newConstants.push_back((*oldConstants)[1]);
312 newConstants.push_back((*oldConstants)[2]);
314 newConstants.push_back(-1);
315 newConstants.push_back(-1);
316 newConstants.push_back(-1);
318 for(
int ivd=0; ivd<=5;ivd++) {
321 newConstants.push_back(vDriftAndReso[ivd]);
324 calibValuesFile.
addCell(calibValuesFile.
getKey(wireId), newConstants);
331 LogTrace(
"Calibration") <<
" SL: " << (wireId.
layerId()).superlayerId()
332 <<
" vDrift = " << vDriftAndReso[0]
333 <<
" reso = " << vDriftAndReso[1];
372 LogVerbatim(
"Calibration") <<
"[DTVDriftCalibration]Writing vdrift object to DB!";
375 string record =
"DTMtimeRcd";
376 DTCalibDBUtils::writeToDB<DTMtime>(
record, mTime);
400 vector<const TMax*> tMaxes = _tMaxes;
411 unsigned hSubGroup = 0;
412 for (vector<const TMax*>::const_iterator it=tMaxes.begin(); it!=tMaxes.end();
428 unsigned t0Factor = (*it)->t0Factor;
429 hSubGroup = (*it)->hSubGroup;
432 case notInit :
cout <<
"Error: no cell type assigned to TMax" << endl;
break;
433 case c123 : tmax123 =
t; t0_123 = t0Factor;
break;
434 case c124 : tmax124 =
t; s124 = sigma; t0_124 = t0Factor;
break;
435 case c134 : tmax134 =
t; s134 = sigma; t0_134 = t0Factor;
break;
436 case c234 : tmax234 =
t; t0_234 = t0Factor;
break;
441 histos->
Fill(tmax123, tmax124, tmax134, tmax234, s124, s134, t0_123,
442 t0_124, t0_134, t0_234, hSubGroup);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Key getKey(DTWireId wireId) const
void writeConsts(const std::string &outputFileName) const
std::pair< const_iterator, const_iterator > range
iterator range
TMaxGranularity theGranularity
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
C::const_iterator const_iterator
constant access iterator type
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)
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual ~DTVDriftCalibration()
Destructor.
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
virtual LocalPoint localPosition() const
local position in SL frame
void Fill(float tmax123, float tmax124, float tmax134, float tmax234, dttmaxenums::SigmaFactor s124, dttmaxenums::SigmaFactor s134, unsigned t0_123, unsigned t0_124, unsigned t0_134, unsigned t0_234, unsigned hSubGroup)
DTSegmentSelector select_
DTMeanTimerFitter * theFitter
const CalibConsts * getConsts(DTWireId wireId) const
std::string theCalibChamber
DTLayerId layerId() const
Return the corresponding LayerId.
DTVDriftCalibration(const edm::ParameterSet &pset)
Constructor.
virtual LocalVector localDirection() const
the local direction in SL frame
std::vector< dttmaxenums::TMaxCells > addedCells
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)
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return the superlayer corresponding to the given id.