Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 #include <iostream>
002 #include <cmath>
003 #include <cstdlib>
004 #include <fstream>
005 #include "AtlfastAlgs/MuonMisalignmentCalculator.h"
006 
007 namespace Atlfast{
008   using std::pair;
009 
010   MuonMisalignmentCalculator::MuonMisalignmentCalculator(const char* filenameAlign, const char* filenameAlignLinearFit){
011     
012     // for the alignment resolution
013     std::string line;
014     std::ifstream myfile (filenameAlign);
015     if (myfile.is_open())
016       {
017 
018         while (! myfile.eof() )
019           {
020             getline (myfile,line);
021             
022             std::string myLine(line);
023             
024             std::string::size_type pos0 = line.find_first_of(" ",0);
025             int Align = atoi ((line.substr(0,pos0)).c_str());
026 
027             std::string::size_type pos1 = line.find_first_of(" ",pos0+1);
028             double Eta = atof ((line.substr(pos0+1,pos1-pos0)).c_str());
029 
030             std::string::size_type pos2 = line.find_first_of(" ",pos1+1);
031             double EtaWidth = atof ((line.substr(pos1+1,pos2-pos1)).c_str());
032 
033             pair<double, double> etaInfo(Eta,EtaWidth);
034 
035             TH1name     = "ResoAlign_" + line.substr(0,pos0) + "_Eta_" + line.substr(pos0+1,pos1-pos0);
036 
037             double Resolution;
038             TH1D tmp;
039             if (Eta < 1) 
040               {
041                 TH1D ResoAlignBarrel(TH1name.c_str(), "Alignment contribution to the resolution for the Barrel" , 20, -3.14159265/2., 0.);
042 
043                 std::string::size_type pos3 = line.find_first_of(" ",pos2+1);
044                 Resolution = atof ((line.substr(pos2+1,pos3-pos2)).c_str());
045                 ResoAlignBarrel.SetBinContent(1, Resolution);
046 
047                 std::string::size_type pos4 = line.find_first_of(" ",pos3+1);
048                 Resolution = atof ((line.substr(pos3+1,pos4-pos3)).c_str());
049                 ResoAlignBarrel.SetBinContent(2, Resolution);
050                 
051                 std::string::size_type pos5 = line.find_first_of(" ",pos4+1);
052                 Resolution = atof ((line.substr(pos4+1,pos5-pos4)).c_str());
053                 ResoAlignBarrel.SetBinContent(3, Resolution);
054                 
055                 std::string::size_type pos6 = line.find_first_of(" ",pos5+1);
056                 Resolution = atof ((line.substr(pos5+1,pos6-pos5)).c_str());
057                 ResoAlignBarrel.SetBinContent(4, Resolution);
058 
059                 std::string::size_type pos7 = line.find_first_of(" ",pos6+1);
060                 Resolution = atof ((line.substr(pos6+1,pos7-pos6)).c_str());
061                 ResoAlignBarrel.SetBinContent(5, Resolution);
062                 
063                 std::string::size_type pos8 = line.find_first_of(" ",pos7+1);
064                 Resolution = atof ((line.substr(pos7+1,pos8-pos7)).c_str());
065                 ResoAlignBarrel.SetBinContent(6, Resolution);
066 
067                 std::string::size_type pos9 = line.find_first_of(" ",pos8+1);
068                 Resolution = atof ((line.substr(pos8+1,pos9-pos8)).c_str());
069                 ResoAlignBarrel.SetBinContent(7, Resolution);
070                 
071                 std::string::size_type pos10 = line.find_first_of(" ",pos9+1);
072                 Resolution = atof ((line.substr(pos9+1,pos10-pos9)).c_str());
073                 ResoAlignBarrel.SetBinContent(8, Resolution);
074 
075                 std::string::size_type pos11 = line.find_first_of(" ",pos10+1);
076                 Resolution = atof ((line.substr(pos10+1,pos11-pos10)).c_str());
077                 ResoAlignBarrel.SetBinContent(9, Resolution);
078 
079                 std::string::size_type pos12 = line.find_first_of(" ",pos11+1);
080                 Resolution = atof ((line.substr(pos11+1,pos12-pos11)).c_str());
081                 ResoAlignBarrel.SetBinContent(10, Resolution);
082             
083                 std::string::size_type pos13 = line.find_first_of(" ",pos12+1);
084                 Resolution = atof ((line.substr(pos12+1,pos13-pos12)).c_str());
085                 ResoAlignBarrel.SetBinContent(11, Resolution);
086 
087                 std::string::size_type pos14 = line.find_first_of(" ",pos13+1);
088                 Resolution = atof ((line.substr(pos13+1,pos14-pos13)).c_str());
089                 ResoAlignBarrel.SetBinContent(12, Resolution);
090 
091                 std::string::size_type pos15 = line.find_first_of(" ",pos14+1);
092                 Resolution = atof ((line.substr(pos14+1,pos15-pos14)).c_str());
093                 ResoAlignBarrel.SetBinContent(13, Resolution);
094 
095                 std::string::size_type pos16 = line.find_first_of(" ",pos15+1);
096                 Resolution = atof ((line.substr(pos15+1,pos16-pos15)).c_str());
097                 ResoAlignBarrel.SetBinContent(14, Resolution);
098                 
099                 std::string::size_type pos17 = line.find_first_of(" ",pos16+1);
100                 Resolution = atof ((line.substr(pos16+1,pos17-pos16)).c_str());
101                 ResoAlignBarrel.SetBinContent(15, Resolution);
102                 
103                 std::string::size_type pos18 = line.find_first_of(" ",pos17+1);
104                 Resolution = atof ((line.substr(pos17+1,pos18-pos17)).c_str());
105                 ResoAlignBarrel.SetBinContent(16, Resolution);
106 
107                 std::string::size_type pos19 = line.find_first_of(" ",pos18+1);
108                 Resolution = atof ((line.substr(pos18+1,pos19-pos18)).c_str());
109                 ResoAlignBarrel.SetBinContent(17, Resolution);
110                 
111                 std::string::size_type pos20 = line.find_first_of(" ",pos19+1);
112                 Resolution = atof ((line.substr(pos19+1,pos20-pos19)).c_str());
113                 ResoAlignBarrel.SetBinContent(18, Resolution);
114                 
115                 std::string::size_type pos21 = line.find_first_of(" ",pos20+1);
116                 Resolution = atof ((line.substr(pos20+1,pos21-pos20)).c_str());
117                 ResoAlignBarrel.SetBinContent(19, Resolution);
118                 
119                 std::string::size_type pos22 = line.find_first_of(" ",pos21+1);
120                 Resolution = atof ((line.substr(pos21+1,pos22-pos21)).c_str());
121                 ResoAlignBarrel.SetBinContent(20, Resolution);
122                 tmp = ResoAlignBarrel;
123               }
124 
125             else 
126               {
127                 TH1D ResoAlignEC(TH1name.c_str(), "Alignment contribution to the resolution for the End-Cap", 10, -3.14159265/8., 0.);
128 
129                 std::string::size_type pos3 = line.find_first_of(" ",pos2+1);
130                 Resolution = atof ((line.substr(pos2+1,pos3-pos2)).c_str());
131                 ResoAlignEC.SetBinContent(1, Resolution);
132 
133                 std::string::size_type pos4 = line.find_first_of(" ",pos3+1);
134                 Resolution = atof ((line.substr(pos3+1,pos4-pos3)).c_str());
135                 ResoAlignEC.SetBinContent(2, Resolution);
136                 
137                 std::string::size_type pos5 = line.find_first_of(" ",pos4+1);
138                 Resolution = atof ((line.substr(pos4+1,pos5-pos4)).c_str());
139                 ResoAlignEC.SetBinContent(3, Resolution);
140                 
141                 std::string::size_type pos6 = line.find_first_of(" ",pos5+1);
142                 Resolution = atof ((line.substr(pos5+1,pos6-pos5)).c_str());
143                 ResoAlignEC.SetBinContent(4, Resolution);
144 
145                 std::string::size_type pos7 = line.find_first_of(" ",pos6+1);
146                 Resolution = atof ((line.substr(pos6+1,pos7-pos6)).c_str());
147                 ResoAlignEC.SetBinContent(5, Resolution);
148                 
149                 std::string::size_type pos8 = line.find_first_of(" ",pos7+1);
150                 Resolution = atof ((line.substr(pos7+1,pos8-pos7)).c_str());
151                 ResoAlignEC.SetBinContent(6, Resolution);
152 
153                 std::string::size_type pos9 = line.find_first_of(" ",pos8+1);
154                 Resolution = atof ((line.substr(pos8+1,pos9-pos8)).c_str());
155                 ResoAlignEC.SetBinContent(7, Resolution);
156                 
157                 std::string::size_type pos10 = line.find_first_of(" ",pos9+1);
158                 Resolution = atof ((line.substr(pos9+1,pos10-pos9)).c_str());
159                 ResoAlignEC.SetBinContent(8, Resolution);
160 
161                 std::string::size_type pos11 = line.find_first_of(" ",pos10+1);
162                 Resolution = atof ((line.substr(pos10+1,pos11-pos10)).c_str());
163                 ResoAlignEC.SetBinContent(9, Resolution);
164 
165                 std::string::size_type pos12 = line.find_first_of(" ",pos11+1);
166                 Resolution = atof ((line.substr(pos11+1,pos12-pos11)).c_str());
167                 ResoAlignEC.SetBinContent(10, Resolution);
168                 tmp = ResoAlignEC;
169               }
170             tmp.GetNbinsX();
171             pair<pair<double, double>, TH1D> etaPhiInfo(etaInfo, tmp);
172             m_resoAlign.push_back(etaPhiInfo);
173             if (m_resoAlign.size() == 15) 
174               {
175                 m_resoAlignSpectrometer[Align] = m_resoAlign;
176                 m_resoAlign.clear();
177               }
178           }
179         myfile.close();
180 
181       }
182 
183 
184     std::ifstream myfileBis (filenameAlignLinearFit);
185     if (myfileBis.is_open())
186       {
187 
188         while (! myfileBis.eof() )
189           {
190             getline (myfileBis,line);
191             std::string myLine(line);
192 
193             std::string::size_type pos0 = line.find_first_of(" ",0);
194             double Eta = atof ((line.substr(0,pos0)).c_str());
195 
196             std::string::size_type pos1 = line.find_first_of(" ",pos0+1);
197             double EtaWidth = atof ((line.substr(pos0+1,pos1-pos0)).c_str());
198 
199             if (Eta==0 && EtaWidth==0) break;
200 
201 
202             pair<double, double> etaInfo(Eta,EtaWidth);
203 
204             TH1name     = "ResoAlignEta_" + line.substr(0,pos0);
205 
206             double Resolution;
207             TH1D tmp;
208             if (Eta < 1) 
209               {
210 //              TH1D ResoAlignBarrel(TH1name.c_str(), "Alignment contribution to the resolution for the Barrel" , 20, -3.14159265/2., 0.);
211                 TH1D ResoAlignBarrel(TH1name.c_str(), "Alignment contribution to the resolution for the Barrel" , 10, -3.14159265/2., 0.);
212 
213                 std::string::size_type pos2 = line.find_first_of(" ",pos1+1);
214                 Resolution = atof ((line.substr(pos1+1,pos2-pos1)).c_str());
215                 ResoAlignBarrel.SetBinContent(1, Resolution);
216 
217                 std::string::size_type pos3 = line.find_first_of(" ",pos2+1);
218                 Resolution = atof ((line.substr(pos2+1,pos3-pos2)).c_str());
219                 ResoAlignBarrel.SetBinContent(2, Resolution);
220 
221                 std::string::size_type pos4 = line.find_first_of(" ",pos3+1);
222                 Resolution = atof ((line.substr(pos3+1,pos4-pos3)).c_str());
223                 ResoAlignBarrel.SetBinContent(3, Resolution);
224 
225                 std::string::size_type pos5 = line.find_first_of(" ",pos4+1);
226                 Resolution = atof ((line.substr(pos4+1,pos5-pos4)).c_str());
227                 ResoAlignBarrel.SetBinContent(4, Resolution);
228                                 
229                 std::string::size_type pos6 = line.find_first_of(" ",pos5+1);
230                 Resolution = atof ((line.substr(pos5+1,pos6-pos5)).c_str());
231                 ResoAlignBarrel.SetBinContent(5, Resolution);
232 
233                 std::string::size_type pos7 = line.find_first_of(" ",pos6+1);
234                 Resolution = atof ((line.substr(pos6+1,pos7-pos6)).c_str());
235                 ResoAlignBarrel.SetBinContent(6, Resolution);
236 
237                 std::string::size_type pos8 = line.find_first_of(" ",pos7+1);
238                 Resolution = atof ((line.substr(pos7+1,pos8-pos7)).c_str());
239                 ResoAlignBarrel.SetBinContent(7, Resolution);
240 
241                 std::string::size_type pos9 = line.find_first_of(" ",pos8+1);
242                 Resolution = atof ((line.substr(pos8+1,pos9-pos8)).c_str());
243                 ResoAlignBarrel.SetBinContent(8, Resolution);
244 
245                 std::string::size_type pos10 = line.find_first_of(" ",pos9+1);
246                 Resolution = atof ((line.substr(pos9+1,pos10-pos9)).c_str());
247                 ResoAlignBarrel.SetBinContent(9, Resolution);
248 
249                 std::string::size_type pos11 = line.find_first_of(" ",pos10+1);
250                 Resolution = atof ((line.substr(pos10+1,pos11-pos10)).c_str());
251                 ResoAlignBarrel.SetBinContent(10, Resolution);
252 
253 //              std::string::size_type pos12 = line.find_first_of(" ",pos11+1);
254 //              Resolution = atof ((line.substr(pos11+1,pos12-pos11)).c_str());
255 //              ResoAlignBarrel.SetBinContent(11, Resolution);
256 //              std::cout << " " << Resolution;
257 
258 //              std::string::size_type pos13 = line.find_first_of(" ",pos12+1);
259 //              Resolution = atof ((line.substr(pos12+1,pos13-pos12)).c_str());
260 //              ResoAlignBarrel.SetBinContent(12, Resolution);
261 //              std::cout << " " << Resolution;
262 
263 //              std::string::size_type pos14 = line.find_first_of(" ",pos13+1);
264 //              Resolution = atof ((line.substr(pos13+1,pos14-pos13)).c_str());
265 //              ResoAlignBarrel.SetBinContent(13, Resolution);
266 //              std::cout << " " << Resolution;
267 
268 //              std::string::size_type pos15 = line.find_first_of(" ",pos14+1);
269 //              Resolution = atof ((line.substr(pos14+1,pos15-pos14)).c_str());
270 //              ResoAlignBarrel.SetBinContent(14, Resolution);
271 //              std::cout << " " << Resolution;
272 
273 //              std::string::size_type pos16 = line.find_first_of(" ",pos15+1);
274 //              Resolution = atof ((line.substr(pos15+1,pos16-pos15)).c_str());
275 //              ResoAlignBarrel.SetBinContent(15, Resolution);
276 //              std::cout << " " << Resolution;
277 
278 //              std::string::size_type pos17 = line.find_first_of(" ",pos16+1);
279 //              Resolution = atof ((line.substr(pos16+1,pos17-pos16)).c_str());
280 //              ResoAlignBarrel.SetBinContent(16, Resolution);
281 //              std::cout << " " << Resolution;
282                                 
283 //              std::string::size_type pos18 = line.find_first_of(" ",pos17+1);
284 //              Resolution = atof ((line.substr(pos17+1,pos18-pos17)).c_str());
285 //              ResoAlignBarrel.SetBinContent(17, Resolution);
286 //              std::cout << " " << Resolution;
287 
288 //              std::string::size_type pos19 = line.find_first_of(" ",pos18+1);
289 //              Resolution = atof ((line.substr(pos18+1,pos19-pos18)).c_str());
290 //              ResoAlignBarrel.SetBinContent(18, Resolution);
291 //              std::cout << " " << Resolution;
292 
293 //              std::string::size_type pos20 = line.find_first_of(" ",pos19+1);
294 //              Resolution = atof ((line.substr(pos19+1,pos20-pos19)).c_str());
295 //              ResoAlignBarrel.SetBinContent(19, Resolution);
296 //              std::cout << " " << Resolution;
297 
298 //              std::string::size_type pos21 = line.find_first_of(" ",pos20+1);
299 //              Resolution = atof ((line.substr(pos20+1,pos21-pos20)).c_str());
300 //              ResoAlignBarrel.SetBinContent(20, Resolution);
301 //              std::cout << " " << Resolution << std::endl;
302 
303                 tmp = ResoAlignBarrel;
304               }
305 
306             else 
307               {
308                 TH1D ResoAlignEC(TH1name.c_str(), "Alignment contribution to the resolution for the End-Cap", 10, -3.14159265/8., 0.);
309 
310                 std::string::size_type pos2 = line.find_first_of(" ",pos1+1);
311                 Resolution = atof ((line.substr(pos1+1,pos2-pos1)).c_str());
312                 ResoAlignEC.SetBinContent(1, Resolution);
313 
314                 std::string::size_type pos3 = line.find_first_of(" ",pos2+1);
315                 Resolution = atof ((line.substr(pos2+1,pos3-pos2)).c_str());
316                 ResoAlignEC.SetBinContent(2, Resolution);
317 
318                 std::string::size_type pos4 = line.find_first_of(" ",pos3+1);
319                 Resolution = atof ((line.substr(pos3+1,pos4-pos3)).c_str());
320                 ResoAlignEC.SetBinContent(3, Resolution);
321 
322                 std::string::size_type pos5 = line.find_first_of(" ",pos4+1);
323                 Resolution = atof ((line.substr(pos4+1,pos5-pos4)).c_str());
324                 ResoAlignEC.SetBinContent(4, Resolution);
325 
326                 std::string::size_type pos6 = line.find_first_of(" ",pos5+1);
327                 Resolution = atof ((line.substr(pos5+1,pos6-pos5)).c_str());
328                 ResoAlignEC.SetBinContent(5, Resolution);
329 
330                 std::string::size_type pos7 = line.find_first_of(" ",pos6+1);
331                 Resolution = atof ((line.substr(pos6+1,pos7-pos6)).c_str());
332                 ResoAlignEC.SetBinContent(6, Resolution);
333 
334                 std::string::size_type pos8 = line.find_first_of(" ",pos7+1);
335                 Resolution = atof ((line.substr(pos7+1,pos8-pos7)).c_str());
336                 ResoAlignEC.SetBinContent(7, Resolution);
337 
338                 std::string::size_type pos9 = line.find_first_of(" ",pos8+1);
339                 Resolution = atof ((line.substr(pos8+1,pos9-pos8)).c_str());
340                 ResoAlignEC.SetBinContent(8, Resolution);
341 
342                 std::string::size_type pos10 = line.find_first_of(" ",pos9+1);
343                 Resolution = atof ((line.substr(pos9+1,pos10-pos9)).c_str());
344                 ResoAlignEC.SetBinContent(9, Resolution);
345 
346                 std::string::size_type pos11 = line.find_first_of(" ",pos10+1);
347                 Resolution = atof ((line.substr(pos10+1,pos11-pos10)).c_str());
348                 ResoAlignEC.SetBinContent(10, Resolution);
349 
350                 tmp = ResoAlignEC;
351               }
352             tmp.GetNbinsX();
353             pair<pair<double, double>, TH1D> etaPhiInfo(etaInfo, tmp);
354             m_resoAlignSpectrometerLinearFit.push_back(etaPhiInfo);
355 
356           }
357       }
358     
359     else std::cout << "Unable to open file"; 
360 
361 
362 
363 
364     
365   }
366   
367   double MuonMisalignmentCalculator::calculateResoAlign(const HepLorentzVector& avec, const double alignValue){
368     double Eta = avec.pseudoRapidity();
369     double Phi = avec.phi();
370     if (alignValue < 40)   return 0; // Set alignment resolution to 0 if alignment < 40 microns
371 
372     pair <double, double> alignpr = getAlignValues(alignValue);
373 
374     if (alignpr.first == alignpr.second) {
375       double resoalign = 0;
376       TH1D  tmp;
377       if (fabs(Eta)<2.7)  tmp = getHistoReso(alignpr.first,Eta);
378       if (fabs(Eta)<=1)                         resoalign = getResoAlignBarrel(Phi, tmp);
379       else if (fabs(Eta)>1 && fabs(Eta)<2.7)    resoalign = getResoAlignEC(Phi, tmp);
380       else resoalign = 1;
381       return resoalign;
382     }
383     else {
384 
385       double resoalign1 = 0;
386       double resoalign2 = 0;
387       double resoalign  = 0;
388       TH1D  tmp1;
389       TH1D  tmp2;
390 
391       if (fabs(Eta)<2.7){
392         tmp1 = getHistoReso(alignpr.first,Eta);
393         tmp2 = getHistoReso(alignpr.second,Eta);
394       }
395 
396       if (fabs(Eta)<=1){
397         resoalign1 = getResoAlignBarrel(Phi, tmp1);
398         resoalign2 = getResoAlignBarrel(Phi, tmp2);
399         resoalign  = (resoalign1 - resoalign2)*(alignValue - alignpr.first)/(alignpr.first - alignpr.second) + resoalign1;
400       }
401       else if (fabs(Eta)>1 && fabs(Eta)<2.7){ 
402 
403         resoalign1 = getResoAlignEC(Phi, tmp1);
404         resoalign2 = getResoAlignEC(Phi, tmp2);
405         resoalign  = (resoalign1 - resoalign2)*(alignValue - alignpr.first)/(alignpr.first - alignpr.second) + resoalign1;
406       }
407       else resoalign  = 1;
408   
409       return resoalign;
410 
411     }
412 
413 
414   }
415 
416 
417  double MuonMisalignmentCalculator::calculateResoAlignLinearFit(const HepLorentzVector& avec, const double alignValue){
418    double Eta = avec.pseudoRapidity();
419    double Phi = avec.phi();
420    
421    double resoalign = 0;
422    TH1D  tmp;
423    if (fabs(Eta)<2.7)                        tmp = getHistoResoLinearFit(Eta);
424    if (fabs(Eta)<=1)                         resoalign = getResoAlignBarrel(Phi, tmp);
425    else if (fabs(Eta)>1 && fabs(Eta)<2.7)    resoalign = getResoAlignEC(Phi, tmp);
426    else return 1;
427    double resotoreturn = resoalign*alignValue;
428    return resotoreturn;
429    
430  }
431 
432 
433   TH1D MuonMisalignmentCalculator::getHistoReso(double align, double Eta){
434     int align_index = static_cast<int>(align);
435     std::vector< pair< pair<double, double>, TH1D > >  vecres = m_resoAlignSpectrometer.find(align_index)->second;
436     for (int i=0; i<abs(vecres.size());i++){
437       pair <double, double> etaInfo = vecres[i].first;
438       double eta = etaInfo.first;
439       double etaWidth = etaInfo.second;
440       if ( (fabs(Eta) < eta + etaWidth) && (fabs(Eta) > eta - etaWidth) ) return vecres[i].second;
441 
442     }
443     // Return dummy histo for now
444     std::cout << "MuonMisalignmentCalculator: no resolution histogram found, returning dummy" << std::endl;
445     return TH1D();
446   }
447 
448   TH1D MuonMisalignmentCalculator::getHistoResoLinearFit(double Eta){
449     for (int i=0; i<abs(m_resoAlignSpectrometerLinearFit.size());i++){
450       pair <double, double> etaInfo = m_resoAlignSpectrometerLinearFit[i].first;
451       double eta = etaInfo.first;
452       double etaWidth = etaInfo.second;
453       if ( (fabs(Eta) < eta + etaWidth) && (fabs(Eta) > eta - etaWidth) ) return m_resoAlignSpectrometerLinearFit[i].second;
454 
455     }
456     // Return dummy histo for now
457     std::cout << "MuonMisalignmentCalculator: no linear resolution histogram found, returning dummy" << std::endl;
458     return TH1D();
459   }
460 
461 
462   double MuonMisalignmentCalculator::getResoAlignBarrel(double Phi, TH1D resoPhi){
463     const double _pi = 3.14159265;
464 
465     if ( (_pi/2. <= Phi) && (Phi < _pi) )                      Phi = _pi - Phi;
466     if ( (- _pi  <= Phi) && (Phi < - _pi/2.) )                 Phi = - _pi - Phi;
467     if ( (Phi > 0) && (Phi >= _pi/4.)  )                       Phi = _pi/2. - Phi;
468     if ( (Phi > 0) && (Phi >= _pi/8.)  )                       Phi = _pi/4. - Phi;
469     if ( Phi > 0)                                              Phi = - Phi;
470     int nbins = resoPhi.GetNbinsX();
471     double binwidth = resoPhi.GetBinWidth(1)/2;
472     for (int i=0; i<nbins; i++){
473       double binCenter = resoPhi.GetBinCenter(i+1);
474       if (Phi < binCenter + binwidth && Phi > binCenter - binwidth) return resoPhi.GetBinContent(i+1);
475     }
476     // Return dummy resolution for now
477     std::cout << "MuonMisalignmentCalculator: no resolution calculated in barrel, returning 0!" << std::endl;
478     return 0.0;
479   }
480 
481   double MuonMisalignmentCalculator::getResoAlignEC(double Phi, TH1D resoPhi){
482 
483     const double _pi = 3.14159265;
484 
485     if ( (_pi/2. <= Phi) && (Phi < _pi) )                      Phi = _pi - Phi;
486     if ( (- _pi  <= Phi) && (Phi < - _pi/2.) )                 Phi = - _pi - Phi;
487     if ( Phi >= 0)                                             Phi = - Phi;
488     if ( Phi <= -_pi/4. )                                      Phi = -_pi/2. - Phi;
489     if ( Phi <= -_pi/8. )                                      Phi = -_pi/4. - Phi;
490 
491     int nbins = resoPhi.GetNbinsX();
492     double binwidth = resoPhi.GetBinWidth(1)/2;
493     for (int i=0; i<nbins; i++){
494       double binCenter = resoPhi.GetBinCenter(i+1);
495       if (Phi < binCenter + binwidth && Phi > binCenter - binwidth) return resoPhi.GetBinContent(i+1);
496     }
497     // Return dummy resolution for now
498     std::cout << "MuonMisalignmentCalculator: no resolution calculated in endcap, returning 0!" << std::endl;
499     return 0.0;
500   }
501 
502   pair<double, double> MuonMisalignmentCalculator::getAlignValues(const double alignValue){
503     const int nbalign = 8;
504     double AlignValues[nbalign] = {
505       0
506       ,40
507       ,100
508       ,200
509       ,300
510       ,500
511       ,700
512       ,1000
513     };
514     for (int i=0; i<nbalign; i++){
515       if      (AlignValues[i]==alignValue) {pair<double, double>  alignpr(AlignValues[i],AlignValues[i]);   return alignpr;}
516       else if (alignValue<AlignValues[i])  {pair<double, double>  alignpr(AlignValues[i-1],AlignValues[i]); return alignpr;}
517     }
518     // Return dummy pair for now
519     std::cout << "MuonMisalignmentCalculator: no alignment values found, returning zeroes!" << std::endl;
520     return pair<double, double>(0,0);
521   }
522   
523 } // namespace Atlfast
524 

source navigation ] diff markup ] identifier search ] general search ]

Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems
This page was automatically generated by the LXR engine. Valid HTML 4.01!