43 LogVerbatim(
"Calibration") <<
"[DTTTrigOffsetCalibration] Constructor called!";
47 theFile_ =
new TFile(rootFileName.c_str(),
"RECREATE");
62 checkNoisyChannels_ = pset.
getParameter<
bool>(
"checkNoisyChannels");
68 theMaxPhiAngle_ = pset.
getParameter<
double>(
"maxAnglePhi");
75 if(doTTrigCorrection_){
79 LogVerbatim(
"Calibration") <<
"[DTTTrigOffsetCalibration]: TTrig version: " << tTrig->version() << endl;
85 LogVerbatim(
"Calibration") <<
"[DTTTrigOffsetCalibration] Destructor called!";
92 if(theCalibChamber_ !=
"All") {
94 int selWheel, selStation, selSector;
95 linestr << theCalibChamber_;
96 linestr >> selWheel >> selStation >> selSector;
97 chosenChamberId =
DTChamberId(selWheel, selStation, selSector);
98 LogVerbatim(
"Calibration") <<
" chosen chamber " << chosenChamberId << endl;
107 event.getByLabel(theRecHits4DLabel_, all4DSegments);
115 for (chamberIdIt = all4DSegments->id_begin();
116 chamberIdIt != all4DSegments->id_end();
120 const DTChamber* chamber = dtGeom->chamber(*chamberIdIt);
121 LogTrace(
"Calibration") <<
"Chamber Id: " << *chamberIdIt;
124 if(theT0SegHistoMap_.find(*chamberIdIt) == theT0SegHistoMap_.end()){
129 if((theCalibChamber_ !=
"All") && ((*chamberIdIt) != chosenChamberId))
continue;
136 segment!=range.second; ++segment){
138 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
139 <<
"\nSegment global pos: " << chamber->
toGlobal((*segment).localPosition());
142 double chiSquare = ((*segment).chi2()/(*segment).degreesOfFreedom());
144 if(chiSquare > theMaxChi2_)
continue;
147 if(!((*segment).phiSegment())){
148 LogTrace(
"Calibration") <<
"No phi segment";
153 bool segmNoisy =
false;
154 map<DTSuperLayerId,vector<DTRecHit1D> > hitsBySLMap;
156 if((*segment).hasPhi()){
162 for(vector<DTRecHit1D>::const_iterator
hit = phiHits.begin();
163 hit != phiHits.end(); ++
hit) {
166 hitsBySLMap[slId].push_back(*
hit);
169 if(checkNoisyChannels_) {
170 bool isNoisy =
false;
171 bool isFEMasked =
false;
172 bool isTDCMasked =
false;
173 bool isTrigMask =
false;
176 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
178 LogTrace(
"Calibration") <<
"Wire: " << wireId <<
" is noisy, skipping!";
188 if((*segment).hasZed()) {
191 zSeg2DPosInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localPosition()));
192 zSeg2DDirInCham = chamber->
toLocal(sl->
toGlobal((*zSeg).localDirection()));
197 for(vector<DTRecHit1D>::const_iterator
hit = zHits.begin();
198 hit != zHits.end(); ++
hit) {
200 if(checkNoisyChannels_) {
201 bool isNoisy =
false;
202 bool isFEMasked =
false;
203 bool isTDCMasked =
false;
204 bool isTrigMask =
false;
207 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
209 LogTrace(
"Calibration") <<
"Wire: " << wireId <<
" is noisy, skipping!";
216 if (segmNoisy)
continue;
218 LocalPoint segment4DLocalPos = (*segment).localPosition();
219 LocalVector segment4DLocalDir = (*segment).localDirection();
220 if(fabs(atan(segment4DLocalDir.
y()/segment4DLocalDir.
z())* 180./
Geom::pi()) > theMaxZAngle_)
continue;
221 if(fabs(atan(segment4DLocalDir.
x()/segment4DLocalDir.
z())* 180./
Geom::pi()) > theMaxPhiAngle_)
continue;
223 if((*segment).hasPhi()) {
225 if(segment->phiSegment()->ist0Valid()){
226 (theT0SegHistoMap_[*chamberIdIt])[0]->Fill(segment->phiSegment()->t0());
229 if((*segment).hasZed()){
231 if(segment->zSegment()->ist0Valid()){
232 (theT0SegHistoMap_[*chamberIdIt])[1]->Fill(segment->zSegment()->t0());
254 LogVerbatim(
"Calibration") <<
"[DTTTrigOffsetCalibration]Writing histos to file!" << endl;
256 for(ChamberHistosMap::const_iterator itChHistos = theT0SegHistoMap_.begin(); itChHistos != theT0SegHistoMap_.end(); ++itChHistos){
257 for(vector<TH1F*>::const_iterator itHist = (*itChHistos).second.begin();
258 itHist != (*itChHistos).second.end(); ++itHist) (*itHist)->Write();
261 if(doTTrigCorrection_){
265 for(ChamberHistosMap::const_iterator itChHistos = theT0SegHistoMap_.begin(); itChHistos != theT0SegHistoMap_.end(); ++itChHistos){
268 vector<DTSuperLayerId> slIds;
273 for(vector<DTSuperLayerId>::const_iterator itSl = slIds.begin(); itSl != slIds.end(); ++itSl){
276 float ttrigSigma = 0;
281 float ttrigMeanNew = ttrigMean;
282 float ttrigSigmaNew = ttrigSigma;
283 float t0SegMean = (itSl->superLayer() != 2)?itChHistos->second[0]->GetMean():itChHistos->second[1]->GetMean();
285 float kFactorNew = (kFactor*ttrigSigma+t0SegMean)/ttrigSigma;
290 LogVerbatim(
"Calibration")<<
"[DTTTrigOffsetCalibration]Writing ttrig object to DB!" << endl;
292 string tTrigRecord =
"DTTtrigRcd";
300 LogTrace(
"Calibration") <<
" Booking histos for Chamber: " << chId;
303 stringstream wheel; wheel << chId.
wheel();
305 stringstream sector; sector << chId.
sector();
309 "_St" + station.str() +
310 "_Sec" + sector.str();
332 histos.push_back(
new TH1F((
"hRPhiSegT0"+chHistoName).c_str(),
"t0 from Phi segments", 250, -60., 60.));
333 if(chId.
station() != 4) histos.push_back(
new TH1F((
"hRZSegT0"+chHistoName).c_str(),
"t0 from Z segments", 250, -60., 60.));
335 theT0SegHistoMap_[chId] =
histos;
virtual ~DTTTrigOffsetCalibration()
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void beginRun(const edm::Run &run, const edm::EventSetup &setup)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
C::const_iterator const_iterator
constant access iterator type
void bookHistos(DTChamberId)
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
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
virtual LocalVector localDirection() const
the local direction in SL frame
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
int station() const
Return the station number.
int wheel() const
Return the wheel number.
static void writeToDB(std::string record, T *payload)
DTTTrigOffsetCalibration(const edm::ParameterSet &pset)
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return the superlayer corresponding to the given id.