46 using namespace dttmaxenums;
52 theFile =
new TFile(rootFileName.c_str(),
"RECREATE");
59 theFitter->setVerbosity(1);
61 hChi2 =
new TH1F(
"hChi2",
"Chi squared tracks",100,0,100);
62 h2DSegmRPhi =
new h2DSegm(
"SLRPhi");
63 h2DSegmRZ =
new h2DSegm(
"SLRZ");
64 h4DSegmAllCh =
new h4DSegm(
"AllCh");
92 theMaxPhiAngle = pset.
getParameter<
double>(
"maxAnglePhi");
101 if(tMaxGranularity ==
"bySL") {
102 theGranularity = bySL;
103 }
else if(tMaxGranularity ==
"byChamber"){
104 theGranularity = byChamber;
105 }
else if(tMaxGranularity==
"byPartition") {
106 theGranularity = byPartition;
108 cout <<
"[DTVDriftCalibration]###Warning: Check parameter tMaxGranularity: "
109 << tMaxGranularity <<
" options not available!" << endl;
113 cout <<
"[DTVDriftCalibration]Constructor called!" << endl;
120 cout <<
"[DTVDriftCalibration]Destructor called!" << endl;
126 cout << endl<<
"--- [DTVDriftCalibration] Event analysed #Run: " <<
event.id().run()
127 <<
" #Event: " <<
event.id().event() << endl;
131 if(theCalibChamber !=
"All") {
132 stringstream linestr;
133 int selWheel, selStation, selSector;
134 linestr << theCalibChamber;
135 linestr >> selWheel >> selStation >> selSector;
136 chosenChamberId =
DTChamberId(selWheel, selStation, selSector);
137 cout <<
"chosen chamber " << chosenChamberId << endl;
146 event.getByLabel(theRecHits4DLabel, all4DSegments);
155 theSync->setES(eventSetup);
159 for (chamberIdIt = all4DSegments->id_begin();
160 chamberIdIt != all4DSegments->id_end();
164 const DTChamber* chamber = dtGeom->chamber(*chamberIdIt);
166 cout <<
"Chamber Id: " << *chamberIdIt << endl;
170 if((theCalibChamber !=
"All") && ((*chamberIdIt) != chosenChamberId))
178 segment!=range.second; ++segment){
181 cout <<
"Segment local pos (in chamber RF): " << (*segment).localPosition() << endl;
182 cout <<
"Segment global pos: " << chamber->
toGlobal((*segment).localPosition()) << endl;;
186 double chiSquare = ((*segment).chi2()/(*segment).degreesOfFreedom());
191 if(!((*segment).phiSegment())){
192 cout<<
"No phi segment"<<endl;
197 bool segmNoisy =
false;
198 map<DTSuperLayerId,vector<DTRecHit1D> > hitsBySLMap;
200 if((*segment).hasPhi()){
206 for(vector<DTRecHit1D>::const_iterator
hit = phiHits.begin();
207 hit != phiHits.end(); ++
hit) {
210 hitsBySLMap[slId].push_back(*
hit);
214 bool isNoisy =
false;
215 bool isFEMasked =
false;
216 bool isTDCMasked =
false;
217 bool isTrigMask =
false;
220 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
223 cout <<
"Wire: " << wireId <<
" is noisy, skipping!" << endl;
233 if((*segment).hasZed()) {
236 zSeg2DPosInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localPosition()));
237 zSeg2DDirInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localDirection()));
242 for(vector<DTRecHit1D>::const_iterator
hit = zHits.begin();
243 hit != zHits.end(); ++
hit) {
246 bool isNoisy =
false;
247 bool isFEMasked =
false;
248 bool isTDCMasked =
false;
249 bool isTrigMask =
false;
252 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
255 cout <<
"Wire: " << wireId <<
" is noisy, skipping!" << endl;
262 if (segmNoisy)
continue;
264 LocalPoint segment4DLocalPos = (*segment).localPosition();
265 LocalVector segment4DLocalDir = (*segment).localDirection();
266 if(fabs(atan(segment4DLocalDir.
y()/segment4DLocalDir.
z())* 180./
Geom::pi()) > theMaxZAngle)
continue;
267 if(fabs(atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())* 180./
Geom::pi()) > theMaxPhiAngle)
continue;
269 hChi2->Fill(chiSquare);
270 if((*segment).hasPhi())
271 h2DSegmRPhi->Fill(phiSeg2DPosInCham.
x(), phiSeg2DDirInCham.
x()/phiSeg2DDirInCham.
z());
272 if((*segment).hasZed())
273 h2DSegmRZ->Fill(zSeg2DPosInCham.
y(), zSeg2DDirInCham.
y()/zSeg2DDirInCham.
z());
275 if((*segment).hasZed() && (*segment).hasPhi())
276 h4DSegmAllCh->Fill(segment4DLocalPos.
x(),
277 segment4DLocalPos.
y(),
278 atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())* 180./
Geom::pi(),
279 atan(segment4DLocalDir.
y()/segment4DLocalDir.
z())* 180./
Geom::pi(),
281 else if((*segment).hasPhi())
282 h4DSegmAllCh->Fill(segment4DLocalPos.
x(),
283 atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())* 180./
Geom::pi());
284 else if((*segment).hasZed())
285 cout<<
"4d segment with only Z"<<endl;
287 cout<<
"ERROR: 4D segment without Z and Phi. Aborting!"<<endl;
292 for(
map<
DTSuperLayerId,vector<DTRecHit1D> >::const_iterator slIdAndHits = hitsBySLMap.begin(); slIdAndHits != hitsBySLMap.end(); ++slIdAndHits) {
293 if (slIdAndHits->second.size() < 3)
continue;
297 DTTMax slSeg(slIdAndHits->second, *(chamber->
superLayer(slIdAndHits->first)),chamber->
toGlobal((*segment).localDirection()), chamber->
toGlobal((*segment).localPosition()), theSync);
299 if(theGranularity == bySL) {
300 vector<const TMax*> tMaxes = slSeg.
getTMax(slId);
303 cellInfo* cell = theWireIdAndCellMap[wireId];
305 TString
name = (((((TString)
"TMax"+(
long) slId.
wheel()) +(
long) slId.
station())
308 theWireIdAndCellMap[wireId] = cell;
314 cout <<
"[DTVDriftCalibration]###Warning: the chosen granularity is not implemented yet, only bySL available!" << endl;
344 gROOT->GetList()->Write();
345 h2DSegmRPhi->Write();
347 h4DSegmAllCh->Write();
355 if(theGranularity == bySL) {
356 for(map<DTWireId, cellInfo*>::const_iterator wireCell = theWireIdAndCellMap.begin();
357 wireCell != theWireIdAndCellMap.end(); wireCell++) {
358 cellInfo* cell= theWireIdAndCellMap[(*wireCell).first];
362 if(findVDriftAndT0) {
364 DTWireId wireId = (*wireCell).first;
365 vector<float> newConstants;
366 TString
N=(((((TString)
"TMax"+(
long) wireId.
wheel()) +(
long) wireId.
station())
368 vector<float> vDriftAndReso = theFitter->evaluateVDriftAndReso(N);
371 if(vDriftAndReso.front() == -1)
374 if(oldConstants != 0) {
375 newConstants.push_back((*oldConstants)[0]);
376 newConstants.push_back((*oldConstants)[1]);
377 newConstants.push_back((*oldConstants)[2]);
379 newConstants.push_back(-1);
380 newConstants.push_back(-1);
381 newConstants.push_back(-1);
383 for(
int ivd=0; ivd<=5;ivd++) {
386 newConstants.push_back(vDriftAndReso[ivd]);
389 calibValuesFile.
addCell(calibValuesFile.
getKey(wireId), newConstants);
397 cout <<
" SL: " << (wireId.
layerId()).superlayerId()
398 <<
" vDrift = " << vDriftAndReso[0]
399 <<
" reso = " << vDriftAndReso[1] << endl;
440 cout <<
"[DTVDriftCalibration]Writing vdrift object to DB!" << endl;
443 string record =
"DTMtimeRcd";
444 DTCalibDBUtils::writeToDB<DTMtime>(
record, mTime);
481 unsigned hSubGroup = 0;
482 for (vector<const TMax*>::const_iterator it=tMaxes.begin(); it!=tMaxes.end();
489 if (addedCells.size()==4 ||
490 find(addedCells.begin(), addedCells.end(), (*it)->cells)
491 != addedCells.end()) {
494 addedCells.push_back((*it)->cells);
498 unsigned t0Factor = (*it)->t0Factor;
499 hSubGroup = (*it)->hSubGroup;
502 case notInit :
cout <<
"Error: no cell type assigned to TMax" << endl;
break;
503 case c123 : tmax123 =
t; t0_123 = t0Factor;
break;
504 case c124 : tmax124 =
t; s124 =
sigma; t0_124 = t0Factor;
break;
505 case c134 : tmax134 =
t; s134 =
sigma; t0_134 = t0Factor;
break;
506 case c234 : tmax234 =
t; t0_234 = t0Factor;
break;
511 histos->Fill(tmax123, tmax124, tmax134, tmax234, s124, s134, t0_123,
512 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
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.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
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::vector< const TMax * > getTMax(const DTWireId &idWire)
Geom::Theta< T > theta() const
C::const_iterator const_iterator
constant access iterator type
std::vector< float > CalibConsts
int superLayer() const
Return the superlayer number.
void addCell(Key wireId, const CalibConsts &calibConst)
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
const CalibConsts * getConsts(DTWireId wireId) const
DTLayerId layerId() const
Return the corresponding LayerId.
DTVDriftCalibration(const edm::ParameterSet &pset)
Constructor.
virtual LocalVector localDirection() const
the local direction in SL frame
int station() const
Return the station number.
int wheel() const
Return the wheel number.
void add(std::vector< const TMax * > tMaxes)
T get(const Candidate &c)
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return the superlayer corresponding to the given id.