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 "MuonGeoModel/Station.h"
002 #include "MuonGeoModel/MYSQL.h"
003 #include "MuonGeoModel/MDT_Technology.h"
004 #include "MuonGeoModel/StandardComponent.h"
005 #include "MuonGeoModel/SupComponent.h"
006 #include "MuonGeoModel/TgcComponent.h"
007 #include "CLHEP/Vector/ThreeVector.h"
008 #include "CLHEP/Units/SystemOfUnits.h"
009 #include "GaudiKernel/MsgStream.h"
010 #include "AthenaKernel/getMessageSvc.h"
011 #include <iostream>
012 #include <algorithm>
013 #include <cassert>
014 
015 namespace MuonGM {
016 
017 Station::Station(std::string s):name(s)
018 {
019   m_msgSvc = Athena::getMessageSvc();
020   MsgStream log(m_msgSvc, "MuonGeoModel");
021     //    log << MSG::DEBUG<<"creating station "<<name<<" "<<this<<" with name "<<s<<endreq;
022     thickness=width1=width2=length=0;
023     amdbOrigine_along_length = 0;
024     amdbOrigine_along_thickness = 0;
025     MYSQL *mysql=MYSQL::GetPointer();
026     m_hasMdts = false;
027     mysql->StoreStation(this);
028     //    log << MSG::DEBUG<<" stored in MYSQL "<<mysql<<endreq;
029 }
030 
031 Station::Station()
032 {
033     m_msgSvc = Athena::getMessageSvc();
034     thickness=width1=width2=length=0;
035     amdbOrigine_along_length = 0;
036     amdbOrigine_along_thickness = 0;
037     name = "unknown";
038     m_hasMdts = false;
039     MsgStream log(m_msgSvc, "MuonGeoModel");
040     log << MSG::DEBUG << "Creating a Station..." << endreq;
041 }
042 
043 Station::Station(const Station& s)
044 {
045   m_msgSvc = Athena::getMessageSvc();
046         MsgStream log(m_msgSvc, "MuonGeoModel");
047         log << MSG::DEBUG << "Creating a Station..." << endreq;
048         thickness=width1=width2=length=0;
049         amdbOrigine_along_length = 0;
050         amdbOrigine_along_thickness = 0;
051         m_hasMdts = s.m_hasMdts;
052         name=s.name;
053         for (unsigned int i=0;i<s.components.size();i++)
054                 components.push_back(s.components[i]);
055         for (unsigned int i=0;i<s.cutouts.size();i++)
056                 cutouts.push_back(s.cutouts[i]);
057 }
058 
059 
060 Station::~Station()
061 {
062     for (unsigned int i=0;i<components.size();i++)
063     {
064         delete components[i];
065     }
066     for (unsigned int i=0;i<cutouts.size();i++)
067     {
068         delete cutouts[i];
069     }    
070 }
071 
072 void Station::SetAlignPos(const AlignPos& p)
073 {
074   MsgStream log(m_msgSvc, "MuonGeoModel");
075   if (FindAlignPos(p.zindex, p.phiindex) != alignpositions.end()) {
076     log << MSG::WARNING <<" this alignposition already exists !!!"<<endreq;
077     log << MSG::WARNING<<" for station named "<<name
078              <<" setting alignposition at z,phi, key "
079              <<p.zindex<<" "
080              <<p.phiindex<<" "
081              <<p.zindex*100+p.phiindex<<endreq;
082     assert(0);
083   }    
084   alignpositions[p.zindex*100+p.phiindex]=p;
085   /*
086     log << MSG::DEBUG <<" setting position with key "<<
087     p.zindex*100+p.phiindex<<" zi, phi = "
088     <<p.zindex<<" "<<p.phiindex<<endreq;
089   */
090 }
091 
092 AlignPosIterator Station::FindAlignPos(int iz, int iphi) const
093 {
094   // imt - probably needs to be different key for align pos
095   int key = iz*100+iphi;
096   //std::cout<<" looking for align pos. with key "<<key<<std::endl;
097   return alignpositions.find(key);
098 }
099 
100 AlignPosIterator Station::abegin() const
101 {
102         return alignpositions.begin();
103 }
104 AlignPosIterator Station::aend() const
105 {
106         return alignpositions.end();
107 }
108 
109 
110 void Station::SetComponent(Component* c)
111 {
112         components.push_back(c);
113 }
114 
115 void Station::SetCutout(Cutout* c)
116 {
117         cutouts.push_back(c);
118 }
119 
120 Component* Station::GetComponent(int i)  const 
121 {
122         return components[i];
123 }
124 
125 Cutout* Station::GetCutout(int i)  const 
126 {
127         return cutouts[i];
128 }
129 
130 void Station::SetPosition(Position p)
131 {
132   MsgStream log(m_msgSvc, "MuonGeoModel");
133     if (FindPosition(p.zindex, p.phiindex) != end()) {
134         log << MSG::WARNING <<" this position already exists !!!"<<endreq;
135         log << MSG::WARNING
136             <<" for station named "<<name<<" setting position at z,phi, key "
137                  <<p.zindex<<" "
138                  <<p.phiindex<<" "
139                  <<p.zindex*100+p.phiindex<<endreq;
140         assert(0);
141     }
142     else
143     {
144         p.isAssigned = true;
145         positions[p.zindex*100+p.phiindex]=p;
146         //     log << MSG::DEBUG<<" setting position with key "
147         //         <<p.zindex*100+p.phiindex<<" zi, phi = "
148         //              <<p.zindex<<" "<<p.phiindex<<endreq;
149     }
150     
151 }
152 
153 PositionIterator Station::FindPosition(int iz, int iphi) const
154 {
155     int key = iz*100+iphi;
156     //    std::cout<<" looking for pos. with key "<<key<<std::endl;
157     return positions.find(key);
158 }
159 int Station::Npositions() const
160 {
161     return positions.size();
162 }
163 
164 PositionIterator Station::begin() const
165 {
166         return positions.begin();
167 }
168 PositionIterator Station::end() const
169 {
170         return positions.end();
171 }
172 std::string Station::GetName() const
173 {
174     //  cout<<"name "<<name<<endl;
175         return name;
176 }
177 double Station::GetThickness() const
178 {
179   MsgStream log(m_msgSvc, "MuonGeoModel");
180   std::string geov = MYSQL::GetPointer()->getGeometryVersion();
181   //    log << MSG::DEBUG<<" station thickness for stat = "<<name<<endreq;
182     
183   if (thickness) {
184 //        log << MSG::DEBUG<<" Ststion::thickness already defined = "<<thickness<<" for station "<<name<<endreq;
185     return thickness;
186   }
187     
188   else 
189     {
190       //            log << MSG::DEBUG<<"    not defined yet "<<endreq;
191       double thick=0;
192       if (name[0]=='T')
193         {                    
194           for (unsigned int i=0;i<components.size();i++)
195             {
196               //std::string n=components[i]->name.substr(0,3);
197               //if (n=="TGC")
198               //{
199               TgcComponent *t=(TgcComponent *)components[i];
200               thick=thick > t->GetThickness()+t->posz ? thick : t->GetThickness()+t->posz;
201             }
202         }
203       else
204         {
205           double zstart = 999999999.;
206           for (unsigned int i=0;i<components.size();i++)
207             {
208               StandardComponent *s=(StandardComponent *)components[i];
209               thick = thick > s->GetThickness()+s->posz ? thick : s->GetThickness()+s->posz;
210               if (i==0 || s->posz < zstart) zstart = s->posz;
211               log<<MSG::VERBOSE<<"Station "<<name<<" calculating  Thinkness = "<<thick<<" and zstart = "<<zstart<<endreq;       
212               
213             }
214           if (fabs(zstart) > 0.001)
215             {
216               //                 std::cout<<"getThickness for station "
217               //                          <<name<<" zstart = "
218               //                          <<zstart
219               //                          <<std::endl;
220               if (geov.substr(0,3) != "P03" ) {
221                   // std::cout<<"station "<<name<<" zstart "<<zstart<<" redefining thick "<<thick<<" "<< thick - zstart<<std::endl;
222                   thick = thick - zstart;
223                   amdbOrigine_along_thickness = -zstart;
224                   log<<MSG::VERBOSE<<"Station "<<name<<" redefining Thinkness = "<<thick<<" because zstart = "<<zstart
225                      <<"; then amdbOrigine_along_thickness = "<<amdbOrigine_along_thickness<<endreq;
226               }                
227             }
228         }
229       thickness=thick;
230       return thick;
231     }
232 }
233 //                    //                log << MSG::DEBUG<<" component "<<s->name<<" found"<<endreq;
234 //                     if ((s->name).substr(0,3) == "SUP") {
235 //                         //log << MSG::DEBUG<<" thick "<<s->GetThickness()<<" posz "<<s->posz<<endreq;
236 //                         //thick > s->GetThickness() ? thick : s->GetThickness();
237 //                     }
238 //                    else 
239 //                    {
240 //                        thick=
241 //                            thick > s->GetThickness()+s->posz ? thick : s->GetThickness()+s->posz;
242 //                    }
243 //                     //log << MSG::DEBUG<<" thickness is now = "<<thick<<endreq;
244 //                }
245 //            }
246 //            thickness=thick;
247 //            return thick;
248 //      }
249 //}
250 double Station::GetExtraTopThickness() const
251 {
252   MsgStream log(m_msgSvc, "MuonGeoModel");
253     //    log << MSG::DEBUG<<" GetExtraTopThickness for stat = "<<name<<endreq;
254     if (name[0] != 'B') return 0.;
255 
256     return 0.;
257     double xupsup = 0.;
258     double deltaup = 0.;
259     int nsup=0;
260     for (unsigned int i=0;i<components.size();i++)
261     {
262         std::string n=components[i]->name.substr(0,3);
263         if (n=="SUP")
264         {
265             ++nsup;
266             SupComponent *s=(SupComponent *)components[i];
267             deltaup = s->posz + s->topsizewrtAMDB0();
268 //             log << MSG::DEBUG<<" deltaup: s->posz, s->topsizewrtAMDB0 "
269 //                      <<s->posz<<" "
270 //                      <<s->topsizewrtAMDB0()<<endreq;
271             double pos = -thickness/2. + deltaup;
272 //            log << MSG::DEBUG<<" pos, thickness/2., deltaup "<<pos<<" "
273 //          <<-thickness/2.<<" "<<deltaup<<endreq;
274             //xupsup > pos ? xupsup : pos;
275             if (xupsup <= pos) xupsup=pos;
276 //             log << MSG::DEBUG<<" SUP component named "<<s->name
277 //                       <<" xupsup, thickness/2. ="<<xupsup<<" "<<thickness/2.<<endreq;
278         }
279     }
280     double dtop=xupsup - thickness/2.;
281     //log << MSG::DEBUG<<" dtop = "<<dtop<<endreq;
282     if (dtop > 0.) {
283       log << MSG::VERBOSE<<" GetExtraTopThickness for stat = "
284           <<name<<" with "<<nsup<<" SUPs is "<<dtop<<endreq;
285         return dtop;
286     }
287     
288     return 0.;
289 }
290 double Station::GetExtraBottomThickness() const
291 {
292   MsgStream log(m_msgSvc, "MuonGeoModel");
293     //    log << MSG::DEBUG<<" GetExtraBottomThickness  for stat = "<<name<<endreq;
294     if (name[0] != 'B') return 0.;
295 
296     return 0.;
297     double xdownsup = 0.;
298     double deltadown = 0.;
299     int nsup =0;
300     for (unsigned int i=0;i<components.size();i++)
301     {
302         std::string n=components[i]->name.substr(0,3);
303         if (n=="SUP")
304         {
305             ++nsup;
306             SupComponent *s=(SupComponent *)components[i];
307             deltadown = s->posz - s->bottomsizewrtAMDB0();
308 //             log << MSG::DEBUG<<" deltadown: s->posz, s->bottomsizewrtAMDB0 "
309 //                      <<s->posz<<" "
310 //                      <<s->bottomsizewrtAMDB0()<<endreq;
311             double pos = -thickness/2. + deltadown;
312             // log << MSG::DEBUG<<" pos, thickness/2., deltadown "<<pos
313             //      <<" "<<-thickness/2.<<" "<<deltadown<<endreq;
314             //xdownsup < pos ? xdownsup : pos;
315             if (xdownsup >=pos ) xdownsup=pos;
316 //             log << MSG::DEBUG<<" SUP component named "<<s->name
317 //                      <<" xdownsup, -thickness/2. ="<<xdownsup<<" "<<-thickness/2.<<endreq;
318         }
319     }
320     double dbottom = - xdownsup - thickness/2.;
321     if (dbottom > 0.) {
322       log << MSG::VERBOSE <<" GetExtraBottomThickness for stat = "
323           <<name<<" with "<<nsup<<" SUPs is "<<dbottom<<endreq;
324         return dbottom;
325     }
326     return 0.;
327 }
328 double Station::GetLength() const 
329 {
330     MsgStream log(m_msgSvc, "MuonGeoModel-GetLength");
331     MYSQL *mysql=MYSQL::GetPointer();
332     if (length) {
333         return length;
334     }
335     else
336     {
337         double len=0;
338         if (name[0] == 'T')
339         {
340             double innerrad = 99999.;
341             double outerrad = 0.;
342             for (unsigned int i=0;i<components.size();i++)
343             {
344               TgcComponent *tg=(TgcComponent *)components[i];
345               if (tg->posy < innerrad) {
346                 innerrad = tg->posy;
347               }
348               if (tg->posy+tg->dy > outerrad) {
349                 outerrad = tg->posy+tg->dy;
350               }
351             }
352             len = outerrad - innerrad;
353         }
354         else
355         {
356             double ystart = 999999.;
357             for (unsigned int i=0;i<components.size();i++)
358             {
359                 StandardComponent *sc=(StandardComponent *)components[i];
360                 //if (name == "EIL8" || name == "EIL9")
361                 log<<MSG::VERBOSE<<"Station "<<name<<" *** comp "<<i<<" named "<<sc->name
362                        <<" posy "<<sc->posy<<" dy "<<sc->dy<<" len "<<len<<" ystart "<<ystart<<endreq;
363                 //if (name == "CSS1")std::cout<<" getLength() --- Station "<<name<<" *** comp "<<i<<" named "<<sc->name
364                 //       <<" posy "<<sc->posy<<" dy "<<sc->dy<<" len "<<len<<" ystart "<<ystart<<std::endl;
365                 if ((sc->dy + sc->posy) > len) len = sc->dy+sc->posy;
366                 if (i==0 || sc->posy < ystart ) ystart = sc->posy;
367                 //if (name == "EIL8" || name == "EIL9")
368                 log<<MSG::VERBOSE<<" now len = "<<len<<" ystart = "<<ystart<<endreq;
369                 //if (name == "CSS1")std::cout<<"Now length = "<<len<<" ystart = "<<ystart<<std::endl;
370             }
371             if (fabs(ystart) > 0.001)
372             {
373 //                 std::cout<<"getlength for station "
374 //                          <<name<<" ystart = "
375 //                          <<ystart
376 //                          <<std::endl;
377                 if (mysql->getGeometryVersion().substr(0,3) != "P03" ) {
378                     // std::cout<<"station "<<name<<" ystart "<<ystart<<" redefining len "<<len<<" "<< len - ystart<<std::endl;
379                     len = len - ystart;
380                     amdbOrigine_along_length = -ystart;
381                     //if (name == "EIL8" || name == "EIL9")
382                     log<<MSG::VERBOSE<<"Station "<<name<<" redefining len = "<<len<<" because ystart = "
383                        <<ystart<<"; then amdbOrigine_along_length = "<<amdbOrigine_along_length<<endreq;
384                 }
385             }
386         }
387 //    else
388 //    {
389 //        //log << MSG::DEBUG<<" building length "<<endreq;        
390 //        double len=0;
391 //        //std::cerr<<"Station "<<name<<" calculating the length "<<std::endl;
392 //        for (unsigned int i=0;i<components.size();i++)
393 //        {
394 //            StandardComponent *cc=(StandardComponent *)components[i];
395 //            std::string n=components[i]->name.substr(0,3);
396 //            if (n=="TGC")
397 //            {
398 //                len+=components[i]->dy;
399 //            }
400 //            else
401 //            {
402 //                
403 //                if (mysql->getGeometryVersion().substr(0,3) == "P03" )
404 //                {
405 //                    // this is the P03 implementation which is wrong in general,
406 //                    // due to the fact that sometimes  cc->posy can be <0 !!!
407 //                    if ((components[i]->dy+cc->posy) > len) len = components[i]->dy+cc->posy;
408 //                }
409 //                else
410 //                {
411 //                    if ((components[i]->dy+fabs(cc->posy)) > len) len = components[i]->dy+cc->posy;
412 //                    if (name.substr(0,2)=="CS") std::cout<<" station "<<name<<" comp. "<<components[i]->name
413 //                                                         <<" len, components[i]->dy, cc->posy "
414 //                                                         <<len<<" "
415 //                                                         <<components[i]->dy<<" "
416 //                                                         <<cc->posy<<std::endl;
417 //                    if (cc->posy < 0.) {
418 //                        len = len + fabs(cc->posy);
419 //                        std::cout<<" This is happening for station "<<name
420 //                                 <<" comp. "<<components[i]->name
421 //                                 <<" offset "<<cc->posy<<std::endl;
422 //                        if (name.substr(0,2)=="CS") std::cout<<"CORRECT station "<<name<<" comp. "<<components[i]->name
423 //                                                             <<" len, components[i]->dy, cc->posy "
424 //                                                             <<len<<" "
425 //                                                             <<components[i]->dy<<" "
426 //                                                             <<cc->posy<<std::endl;
427 //                    }
428 //                }
429 //            }            
430 //        }
431         length = len;
432         //if (name == "CSS1")std::cout<<"In the end length is = "<<length<<std::endl;
433         return len;
434     }
435 }
436 double Station::GetWidth1() const 
437 {
438         MsgStream log(m_msgSvc, "MuonGeoModel");
439         if (width1) return width1;
440         else
441         {
442             double maxdxmin = -99999.;
443             double ymin= -getAmdbOrigine_along_length();
444             //double ymax= GetLength()-getAmdbOrigine_along_length();
445           //            log << MSG::DEBUG<<" building width1"<<endreq;
446                 double w=0;
447                 for (unsigned int i=0;i<components.size();i++)
448                 {
449                     std::string n=components[i]->name.substr(0,3);
450                     if (n=="TGC")
451                     {
452                         double dw = 20.;
453                         std::string typetgc = components[i]->name.substr(3,2);
454                         // in case of station containing one module
455                         if (typetgc == "01" || typetgc == "06" ||
456                             typetgc == "12" || typetgc == "18" ||
457                             typetgc == "19" || typetgc == "20" ||
458                             typetgc == "21" ) {
459                           dw = 0.;
460                         }
461                         if (w==0)
462                         {
463                             w=components[i]->dx1+dw;
464                         }
465                         else {
466                             if (w>components[i]->dx1+dw)
467                             {
468                                 w=components[i]->dx1+dw;
469                             }
470                         }
471                     }
472                     else
473                     {
474                         double dxmin = 0.;
475                         if (fabs(components[i]->dy)<1.e-10) dxmin = components[i]->dx1;
476                         else 
477                         {
478                             double num = (components[i]->dx2-components[i]->dx1)/2.;
479                             double tantheta = num != 0 ? num / components[i]->dy : 0;
480                             double y = ((StandardComponent*)components[i])->posy;
481                             dxmin    =  components[i]->dx1 + 2.*tantheta * (ymin-y);
482                         }
483                         //std::cout<<"dxmin for component "<<dxmin<<" "<< components[i]->name<<" dx1, dx2, y, ymin "<<components[i]->dx1<<" "<<components[i]->dx2<<" "<<y<<" "<<ymin<<std::endl;
484                         if ( maxdxmin < dxmin && (n.substr(0,2) != "LB" || name[0]=='B') ) maxdxmin = dxmin;
485                         //std::cout<<"Maxdxmin = "<<maxdxmin<<std::endl;
486 
487                         /* 060602007 fix envelop for trapezoidal components shifted one w.r.t. the other
488                         if (w<components[i]->dx1)
489                         {
490                             // imt do NOT let dx1 of the longer LB
491                             //     determine width1 of EC chambers!
492                             if (n.substr(0,2) != "LB" || name[0]=='B')
493                             {
494                                 w=components[i]->dx1;
495                                 //std::cout<<" calculating short width "<<w<<" after component "<<n<<std::endl;
496                             }
497                             else
498                             {
499                                 log << MSG::VERBOSE
500                                     << "Component "
501                                     << components[i]->name
502                                     << " has longer dx1 but"
503                                     << " is not at narrow point"
504                                     << " so should not determine"
505                                     << " short width of endcap station "
506                                     << name
507                                     <<  endreq;
508                             }
509                             }*/
510                     }
511                 }
512 //                 if (name.substr(0,1)!="T")
513 //                 {
514 //                     std::cout<<"shortWidth of station "<<name<<" std = "<<w<<" new "<<maxdxmin<<std::endl;
515 //                     if (fabs(maxdxmin - w)>0.01) std::cout<<" AAAAAAAAAAAAAAAAAAAAATTENZIONE abs(maxdxmin - w)="<<fabs(maxdxmin - w)<<" in station "<<name<<std::endl;
516 //                 }
517                 if (name.substr(0,1)=="T")width1=w;
518                 else width1=maxdxmin;
519                 //std::cout<<"Station name is "<<name<<" width1 = "<<width1<<std::endl;
520                 return width1;
521         }
522 }
523 double Station::GetWidth2() const
524 {
525     MsgStream log(m_msgSvc, "MuonGeoModel");
526     if (width2) return width2;
527     else
528     {
529         //double ymin= -getAmdbOrigine_along_length();
530         double ymax= GetLength()-getAmdbOrigine_along_length();
531         double maxdxmax = -99999.;
532         double w=0;
533         for (unsigned int i=0;i<components.size();i++)
534         {
535             if (w< components[i]->dx2)   
536             {    
537                 w=components[i]->dx2;    
538                 //std::cout<<" calculating long width "<<w<<" after component "<<components[i]->name<<std::endl;         
539             }
540             std::string n=components[i]->name.substr(0,3);
541             if (n == "TGC") {
542                 double dw = 20.;
543                 std::string typetgc = components[i]->name.substr(3,2);
544                 // in case of one station containing one module
545                 if (typetgc == "01" || typetgc == "06" ||
546                     typetgc == "12" || typetgc == "18" ||
547                     typetgc == "19" || typetgc == "20" ||
548                     typetgc == "21" ) {
549                     dw = 0.;
550                 }
551                 w += dw;
552             }
553             else 
554             {
555                 /* fix envelop for trapezoidal components shifted one w.r.t. the other
556                 if (w< components[i]->dx2)
557                 {
558                     w=components[i]->dx2;
559                     //std::cout<<" calculating long width "<<w<<" after component "<<components[i]->name<<std::endl;
560                     }*/
561                 double dxmax = 0.;
562                 if (fabs(components[i]->dy)<1.e-10) dxmax =  components[i]->dx2;
563                 else 
564                 {
565                     double num = (components[i]->dx2-components[i]->dx1)/2.;
566                     double tantheta = num != 0 ? num / components[i]->dy : 0;
567                     double y = ((StandardComponent*)components[i])->posy;
568                     dxmax    =  components[i]->dx1 + 2.*tantheta * (ymax-y);
569                 }
570 //                 std::cout<<"dxmax for component "<<dxmax<<" "<< components[i]->name
571 //                          <<" dx1, dx2, y, ymax "<<components[i]->dx1<<" "<<components[i]->dx2
572 //                          <<" "<<y<<" "<<ymax<<" length = "<<GetLength()<<std::endl;
573                 if (maxdxmax < dxmax ) maxdxmax = dxmax;
574 //                 std::cout<<"Maxdxmax = "<<maxdxmax<<std::endl;
575             }                       
576         }
577 //         if (name.substr(0,1)!="T")
578 //         {
579 //             std::cout<<"longWidth of station "<<name<<" std = "<<w<<" new "<<maxdxmax<<std::endl;
580 //             if (fabs(maxdxmax - w)>0.01) std::cout<<" AAAAAAAAAAAAAAAAAAAAATTENZIONE abs(maxdxmax - w)="<<fabs(maxdxmax - w)<<" in station "<<name<<std::endl;
581 //         }
582         if (name.substr(0,1)=="T") width2=w;
583         else width2=maxdxmax;
584         //        log << MSG::DEBUG<<" it is "<<w<<endreq;
585         //std::cout<<"Station name is "<<name<<" width2 = "<<width2<<std::endl;
586         return width2;
587     }
588 }
589 
590 int Station::GetNrOfComponents() const
591 {
592         return components.size();
593 }
594 
595 int Station::GetNrOfCutouts() const
596 {
597         return cutouts.size();
598 }
599 
600 std::ostream& operator<<(std::ostream& os,const Station& s)
601 {
602         os<<"Station name: "<<s.name<<" "<<s.components.size()<<std::endl;
603         for (unsigned int i=0;i<s.components.size();i++)
604                 os<<"\t"<<s.components[i]<<std::endl;
605         PositionIterator k;
606         for (k=s.begin();k!=s.end();k++)
607                 os<<"\t\t"<<(*k).second<<std::endl;
608         AlignPosIterator ak;
609         for (ak=s.abegin();ak!=s.aend();ak++)
610                 os<<"\t\t"<<(*ak).second<<std::endl;
611         os<<"--------------------------------------------------"<<std::endl;
612         return os;
613 }
614 
615 
616 
617 
618 //this is really needed 
619 HepTransform3D Station::native_to_tsz_frame( const Position & p ) const {
620 
621     MsgStream log(m_msgSvc, "MGM-native_to_tsz");
622     std::string geov = MYSQL::GetPointer()->getGeometryVersion();
623     int amdbVersion = MYSQL::GetPointer()->getNovaReadVersion();
624     if (amdbVersion > 0 && amdbVersion < 7 && name[0]!='B')
625       log << MSG::DEBUG << "For AMDB version " << amdbVersion
626                 << " a left-handed chamber coordinate system was used "
627                 << " for endcap side A so be very careful."
628                 << endreq;
629     
630     HepTransform3D nominalTransf;
631     
632     // first apply here the mirror symmetry: (we, in fact, apply a rotation)
633     HepTransform3D mirrsym=HepTransform3D::Identity;
634     if (p.isMirrored) 
635     {
636         if (name[0]=='B' )
637         {
638             mirrsym = HepRotateX3D(180.*deg);
639         }
640     }
641 
642     // define the translation to position the chamber in the tzs frame
643     HepTranslate3D AMDBorgTranslation;
644     if ( (name[0]=='B' || p.isBarrelLike) && p.zindex<0 && (!p.isMirrored) && hasMdts())
645     {
646         MYSQL* mysql=MYSQL::GetPointer();
647         MDT       *m= (MDT *)mysql->GetATechnology("MDT0");
648         double halfpitch = (m->pitch)/2.;
649         //halfpitch =0.; 
650         AMDBorgTranslation =
651             HepTranslate3D(GetThickness()/2.-getAmdbOrigine_along_thickness(),
652                            0.,
653 //                      GetLength()/2.-(getAmdbOrigine_along_length()+halfpitch));
654                            GetLength()/2.-(halfpitch));
655         log<<MSG::VERBOSE<<" GetThickness / getAmdbO_thick / GetLength() / getAmdbO_length "
656            <<GetThickness()<<" "
657            <<getAmdbOrigine_along_thickness()<<" "
658            <<GetLength()<<" "
659            <<getAmdbOrigine_along_length()+halfpitch<<endreq;
660     }
661     else
662     {
663         AMDBorgTranslation =
664             HepTranslate3D(GetThickness()/2.-getAmdbOrigine_along_thickness(),
665                            0.,
666                            GetLength()/2.-getAmdbOrigine_along_length());
667         log<<MSG::VERBOSE<<" GetThickness / getAmdbO_thick / GetLength() / getAmdbO_length "
668            <<GetThickness()<<" "
669            <<getAmdbOrigine_along_thickness()<<" "
670            <<GetLength()<<" "
671            <<getAmdbOrigine_along_length()<<endreq;
672     }
673 
674     // define the rotations by alpha, beta, gamma
675     HepRotate3D ralpha = HepRotateX3D(p.alpha*deg);
676     HepRotate3D rbeta  = HepRotateZ3D(p.beta*deg);
677     HepRotate3D rgamma;
678     if (name[0]=='B' || p.isBarrelLike  || geov != "CTB2004") // pay attention here !!!!!!!!!
679     {
680         rgamma = HepRotateY3D(p.gamma*deg);
681         log<<MSG::VERBOSE<<" gamma is not changing sign - original "<<p.gamma<<" new one "<<p.gamma<<endreq;
682     }
683     else
684     {
685         log<<MSG::VERBOSE<<" gamma is changing sign - original "<<p.gamma<<" new one "<<-p.gamma<<endreq;
686         rgamma = HepRotateY3D(-p.gamma*deg);  //WHY???
687     }
688     log<<MSG::VERBOSE<<" alpha / beta "<<p.alpha<<" "<<p.beta<<endreq;
689 
690     // apply all transform in sequence 
691     //    HepTransform3D to_tsz = rgamma*rbeta*ralpha*AMDBorgTranslation*mirrsym;  // works for barrel and barrel-like
692     // imt: tested for CTB2004, seems to work for all amdb versions...
693     HepTransform3D to_tsz = rgamma*rbeta*ralpha*AMDBorgTranslation*mirrsym;
694 
695     return to_tsz;
696 }
697 HepTransform3D Station::tsz_to_native_frame( const Position & p ) const {
698 
699     return (native_to_tsz_frame( p )).inverse();
700 }
701 // this is really needed 
702 HepTransform3D Station::tsz_to_global_frame( const Position & p ) const {
703 
704     MsgStream log(m_msgSvc, "MGM tsz_to_global_frame");
705     
706     HepTransform3D nominalTransf= HepTransform3D::Identity;
707     
708     std::string geov = MYSQL::GetPointer()->getGeometryVersion();
709     Hep3Vector vec;
710     double rad;
711     if (geov != "CTB2004" && name[0]=='T')
712         rad=((TgcComponent *)GetComponent(0))->posy;
713     else
714         rad=p.radius;
715     vec.setX(rad*cos(p.phi*deg));
716     vec.setX(vec.x()-p.shift*sin((p.phi)*deg));
717     vec.setY(rad*sin(p.phi*deg));
718     vec.setY(vec.y()+p.shift*cos((p.phi)*deg));
719     // 
720     if (p.isMirrored)
721         if ( (p.isBarrelLike) || (name[0]=='B') )
722         {
723             // correct the z location (=-p.z-length) for possible amdbOrigine_along_length
724             if (geov.substr(0,1) != "P")
725             {
726                 vec.setZ(p.z + getAmdbOrigine_along_length());
727             }
728             else vec.setZ(p.z);
729 //             std::cout<<" tsz_to_global for station "<<name<<" at fi/zi "<<p.phiindex+1<<"/"<<p.zindex<<" isMirr. "<<p.isMirrored
730 //                      <<" transl. to "<<vec<<" p.z = "<<p.z<<" length "<<GetLength()<<" AmdbOrigine_along_length "<<getAmdbOrigine_along_length()<<std::endl;
731         }
732         else
733         {
734             vec.setZ(p.z + GetThickness()); // re-establish the amdb z location (with a - sign)
735         }
736     else
737     {
738         if ( (p.isBarrelLike) || (name[0]=='B' && p.zindex<0 && hasMdts()) )
739         {
740             MYSQL* mysql=MYSQL::GetPointer();
741             MDT       *m= (MDT *)mysql->GetATechnology("MDT0");
742             double halfpitch = (m->pitch)/2.;
743             vec.setZ(p.z + (-getAmdbOrigine_along_length()+halfpitch));
744         }
745         else
746             vec.setZ(p.z);
747     }
748     
749 
750     log<<MSG::VERBOSE<<" translation according to "<<vec.x()<<" "<<vec.y()<<" "<<vec.z()<<endreq;
751     
752     if ( name[0]=='B' || p.isBarrelLike )
753     {    
754         // here all Barrel chambers 
755         nominalTransf =  HepRotateZ3D(p.phi*deg);
756     }
757     else
758     {
759 // replace this with the folowing lines 8/06/2006 SS because, EC not mirrored chambers have anyway to be rotated
760 // by 180deg around z to mov ecoherently their local reference frame and the tube-layer numbering
761 //         if ( p.z>=0 || ( p.z<0 && !(p.isMirrored) ) ){
762 //             nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*
763 //                                          HepRotateX3D(p.phi*deg-180*deg));
764 //         }
765 //         else if (p.z<0 && p.isMirrored){
766 //             nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*
767 //                                             HepRotateX3D(p.phi*deg-180*deg)*
768 //                                             HepRotateZ3D(180*deg));
769 //         }
770         if ( p.z>=0 ){
771             nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*
772                                             HepRotateX3D(p.phi*deg-180*deg));
773         }
774         else if ( p.z<0 ){
775             nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*
776                                             HepRotateX3D(p.phi*deg-180*deg)*
777                                             HepRotateZ3D(180*deg));
778         }
779         else log << MSG::WARNING<<" AAAAAA problem here p.z, mirrored "
780                     <<p.z<<" "<<p.isMirrored<<endreq;
781     }
782     return HepTranslate3D(vec)*nominalTransf;
783 }
784 
785 HepTransform3D Station::global_to_tsz_frame( const Position & p ) const {
786     
787     return (tsz_to_global_frame( p )).inverse();
788 }
789 HepTransform3D Station::getNominalTransform(const Position & p) const 
790 {
791     //    std::cout<<"Station::getNominalTransform for Position P defined below *********"<<std::endl;
792     //    std::cout<<p<<std::endl;
793     return  tsz_to_global_frame( p ) * native_to_tsz_frame( p );
794 }
795 HepTransform3D Station::getAlignedTransform(const AlignPos & ap, const Position & p) const 
796 {
797     return  tsz_to_global_frame( p ) * getDeltaTransform_tszFrame( ap ) * native_to_tsz_frame( p );
798 }
799 HepTransform3D Station::getDeltaTransform_tszFrame(const AlignPos & ap) const
800 {
801   MsgStream log(m_msgSvc, "MGM getDeltaTransform_tszFrame");
802   int amdbVersion = MYSQL::GetPointer()->getNovaReadVersion();
803   std::string geov = MYSQL::GetPointer()->getGeometryVersion();
804   if (ap.tras!=0 ||ap.trat!= 0 ||ap.traz!=0 ||
805       ap.rots!=0 || ap.rott!=0||ap.rotz!=0)
806     {
807       log << MSG::VERBOSE << "Setting corrections." << endreq;
808       log << MSG::VERBOSE << "For station " << name <<
809           " corrections sent are " << ap.tras << " " <<
810           ap.traz << " " << ap.trat << " " << ap.rots << " " << ap.rotz <<
811           " " << ap.rott << " isBarrel=" << ap.isBarrel << endreq;
812       log << MSG::VERBOSE << "length="<< GetLength()<<" thickness="
813           <<GetThickness()<<endreq;
814     }
815 
816   HepRotate3D rott = HepRotateX3D(ap.rott);
817   HepRotate3D rotz = HepRotateZ3D(ap.rotz);
818   HepRotate3D rots = HepRotateY3D(ap.rots);
819   HepTransform3D trans = HepTranslateY3D(ap.tras)*
820                          HepTranslateZ3D(ap.traz)*HepTranslateX3D(ap.trat);
821 
822   // imt The following is probably also true for ATLAS geometries, but has
823   //     only been tested for CTB:
824   if (geov=="CTB2004")
825     {
826       if (amdbVersion > 0 && amdbVersion < 7 && !ap.isBarrel)
827         {
828         log << MSG::DEBUG << "For AMDB version " << amdbVersion
829                   << " a left-handed chamber coordinate system was used " 
830                   << " for endcap side A, so s-axis flipped for corrections."
831                   << endreq;
832           rots = HepRotateY3D(-(ap.rots));
833           trans = HepTranslateY3D(-(ap.tras))*
834             HepTranslateZ3D(ap.traz)*HepTranslateX3D(ap.trat);
835         }
836     }
837 
838   HepTransform3D delta = trans*rots*rotz*rott;
839   log << MSG::VERBOSE<<" delta transform in the tsz frame --------------"<<endreq
840       <<
841       (delta)[0][0] << " " <<
842       (delta)[0][1] << " " <<
843       (delta)[0][2] << " " <<
844       (delta)[0][3] << " " << endreq <<
845       (delta)[1][0] << " " <<
846       (delta)[1][1] << " " <<
847       (delta)[1][2] << " " <<
848       (delta)[1][3] << " " << endreq <<
849       (delta)[2][0] << " " <<
850       (delta)[2][1] << " " <<
851       (delta)[2][2] << " " <<
852       (delta)[2][3] << " " << endreq;  
853 
854   // our delta transform must be applied in the tsz frame:
855   return delta;
856 }
857 HepTransform3D Station::getDeltaTransform(const AlignPos & ap, const Position & p) const
858 {
859     // GM applies Delta transform like transform*delta
860     HepTransform3D deltaGM = tsz_to_native_frame(p) *
861                              getDeltaTransform_tszFrame( ap ) * native_to_tsz_frame(p);
862     return deltaGM;
863 }
864 
865 
866 double Station::getAmdbOrigine_along_length() const 
867 {
868     if (length)
869         return amdbOrigine_along_length;
870     else {
871         length = GetLength();
872         return amdbOrigine_along_length;
873     }
874 //     if (amdbOrigine_along_length) return amdbOrigine_along_length;
875 //     else return 0.;
876 }
877 double Station::getAmdbOrigine_along_thickness() const 
878 {
879     if (thickness) return amdbOrigine_along_thickness;
880     else 
881     {
882         thickness = GetThickness();
883         return amdbOrigine_along_thickness;
884     }    
885 //     if (amdbOrigine_along_thickness) return amdbOrigine_along_thickness;
886 //     else return 0.;
887 }
888 
889 
890 // /* 17/06/2008 This is not needed anywhere 
891 // HepTransform3D Station::getTransform( const AlignPos & ap) const {
892 //   MsgStream log(m_msgSvc, "MuonGeoModel");
893 //   HepTranslate3D theTranslation, AMDBorgTranslation;
894 //   HepTransform3D theRotation;
895 //   std::string geov = MYSQL::GetPointer()->getGeometryVersion();
896 //   if (geov == "CTB2004")
897 //     {
898 //       log << MSG::INFO << "Calling obsolete getTransform(AlignPos) for "
899 //              << name << "...  Better switch to getDeltaTransform!"
900 //              << endreq;
901 //     }
902 //   float tras=0, traz=0, trat=0, rots=0, rotz=0, rott=0;
903 //   bool isBarrel = false;
904 //   isBarrel = ap.isBarrel;
905 //   tras = ap.tras;
906 //   traz = ap.traz;
907 //   trat = ap.trat;
908 //   rots = ap.rots;
909 //   rotz = ap.rotz;
910 //   rott = ap.rott;
911 //   if (tras!=0 || trat!= 0 || traz!=0 || rots!=0 || rott!=0||rotz!=0)
912 //     {
913 //       log << MSG::DEBUG << "Setting corrections." << endreq;
914 //       log << MSG::DEBUG << "For station " << name <<
915 //      " corrections sent are " << tras << " " <<
916 //      traz << " " << trat << " " << rots << " " << rotz <<
917 //      " " << rott << " isBarrel=" << isBarrel << endreq;
918 //       log << MSG::DEBUG << "length="<< GetLength()<<" thickness="
919 //              <<GetThickness()<<endreq;
920 //     }
921 
922 //   if (ap.isBarrel && !(ap.isTrapezoid))
923 //     {   // rectangular barrel chambers
924 //       // AMDB org is at z=0, t=0 (not z=length/2, t=thickness/2)
925 //       AMDBorgTranslation = HepTranslate3D(GetThickness()/2.,0.,GetLength()/2.);
926 //       // RSZ = tsz
927 //       theTranslation = HepTranslate3D(trat,tras,traz);
928 //       // SZR = szt
929 //       theRotation = HepRotateY3D(rots)*HepRotateZ3D(rotz)*
930 //      HepRotateX3D(rott);
931 //     }
932 //   else if (ap.isBarrel && ap.isTrapezoid)
933 //     {   // we can get rid of isTrapezoid after AMDB version 7.
934 //       theTranslation = HepTranslate3D(trat,-tras,traz);
935 //       theRotation = HepRotateY3D(-rots)*HepRotateZ3D(rotz)*
936 //      HepRotateX3D(rott);      
937 //       AMDBorgTranslation = HepTranslate3D(GetThickness()/2.,0.,GetLength()/2.);
938 //     }
939 //   else
940 //     { // assumed to be trapezoidal endcap chambers
941 // //       
942 // //       // RSZ = zst 
943 // //       theTranslation = HepTranslate3D(traz,tras,trat);
944 // //       // SZR = stz  so you would expect:
945 // //       theRotation = HepRotateY3D(rots)*HepRotateZ3D(rott)*
946 // //       HepRotateX3D(rotz);
947 // //       
948 //       // but in fact the s-axis is flipped in MuonGM wrt AMDB,
949 //       // and the z and t axes are exchanged:
950 //       theTranslation = HepTranslate3D(trat,-tras,traz);
951 //       theRotation = HepRotateY3D(-rots)*HepRotateZ3D(rotz)*
952 //      HepRotateX3D(rott);      
953 //       AMDBorgTranslation = HepTranslate3D(GetLength()/2.,0.,GetThickness()/2.);
954 //     }
955 //   //  return theTranslation*theRotation;
956 //   // put it in AMDB coordinates for the transformation, then go back to MuonGM
957 //   return AMDBorgTranslation.inverse()*theTranslation*theRotation*
958 //     AMDBorgTranslation;
959 // }
960 // */
961 // not needed 17/06/2008 
962 // HepTransform3D Station::getAmdbOrgTrans(const Position & p) const
963 // { // in tsz coordinates:
964 //   //MsgStream log(m_msgSvc, "MGM getAmdbOrgTrans");
965 //   HepTranslate3D AMDBorgTranslation;
966 //   if (name[0]=='B' || p.isBarrelLike )
967 //     {
968 //         AMDBorgTranslation =
969 //             HepTranslate3D(GetThickness()/2.,0.,GetLength()/2.);
970 //     }
971 //   else
972 //     {
973 //         AMDBorgTranslation =
974 //             HepTranslate3D(GetThickness()/2.,0.,GetLength()/2.);
975 //     }
976 //   //log << MSG::VERBOSE<< "length = "<<GetLength()<<" thickness="<<GetThickness()
977 //   //     << endreq;
978 //   return AMDBorgTranslation;
979 // }
980 
981 // 17/06/2008 not needed anywhere
982 // HepTransform3D Station::getTransform( const Position & p) const {
983 //   MsgStream log(m_msgSvc, "MuonGeoModel");
984 //     std::string geov = MYSQL::GetPointer()->getGeometryVersion();
985 //     if (geov == "CTB2004") 
986 //     {
987 //       /* IMT - replace this whole section with call to getNominalTransform
988 //         HepTransform3D nominalTransf;
989 //         HepTranslate3D AMDBorgTranslation;
990 //         static Hep3Vector vec;
991 //         static Hep3Vector vecRot;
992 //         if (name[0]=='B' || p.isBarrelLike) {
993 //             // The chamber orientation is given by the direction of the
994 //             //  R-axis (T-axis), NOT by a vector pointing to the centre
995 //             //  of the chamber or even to the AMDB origin!
996 //             vecRot.setX(cos(p.phi*deg));
997 //             vecRot.setY(sin(p.phi*deg));
998 //             vecRot.setZ(1.);
999 //             if (p.isBarrelLike)  // EC chamber treated as barrel, be careful!
1000 //             {
1001 //                 // defining the position of the centre of any station
1002 //                 vec.setX((p.radius+GetLength()/2.)*cos(p.phi*deg));
1003 //                 vec.setX(vec.x()-p.shift*sin((p.phi)*deg));
1004 //                 vec.setY((p.radius+GetLength()/2.)*sin(p.phi*deg));
1005 //                 vec.setY(vec.y()+p.shift*cos((p.phi)*deg));
1006 //                 vec.setZ(p.z+GetThickness()/2.);
1007 //                 AMDBorgTranslation =HepTranslate3D(GetLength()/2.,0.,GetThickness()/2.);
1008 //             }
1009 //             else  // normal barrel case:
1010 //             {
1011 //                 // defining the position of the centre of any station
1012 //                 // here using the stations in DBSC (described in amdb + the ones at z<0)
1013 //                 vec.setX((p.radius+GetThickness()/2.)*cos(p.phi*deg));
1014 //                 vec.setX(vec.x()-p.shift*sin((p.phi)*deg));
1015 //                 vec.setY((p.radius+GetThickness()/2.)*sin(p.phi*deg));
1016 //                 vec.setY(vec.y()+p.shift*cos((p.phi)*deg));
1017 //                 vec.setZ(p.z+GetLength()/2.);
1018 //                 AMDBorgTranslation =HepTranslate3D(GetThickness()/2.,0.,GetLength()/2.);
1019 //             }
1020 //         }
1021 //         else {      // if (name[0]=='T') 
1022 //             // defining the position of the centre of stations at z><0
1023 //             double rad;
1024 //             // IMT this should be version dependent, bad for CTB geom...
1025 //             //if (name[0]=='T') rad=((TgcComponent *)GetComponent(0))->posy;
1026 //             //else
1027 //             rad=p.radius;
1028 //             //        vec.setX((rad+GetLength()/2.)*cos(p.phi*deg));
1029 //             vec.setX((rad+GetThickness()/2.)*cos(p.phi*deg));
1030 //             vec.setX(vec.x()-p.shift*sin((p.phi)*deg));
1031 //             //        vec.setY((rad+GetLength()/2.)*sin(p.phi*deg));
1032 //             vec.setY((rad+GetThickness()/2.)*sin(p.phi*deg));
1033 //             vec.setY(vec.y()+p.shift*cos((p.phi)*deg));
1034 //             if (p.z<0) {
1035 //                 //            vec.setZ(p.z+GetThickness()/2.);
1036 //                 vec.setZ(p.z+GetLength()/2.);
1037 //             }
1038 //             else { 
1039 //                 //            vec.setZ(p.z+GetThickness()/2.);
1040 //                 vec.setZ(p.z+GetLength()/2.);
1041 //             }
1042 //             // The chamber orientation is given by the direction of the
1043 //             //  R-axis (T-axis), NOT by a vector pointing to the centre
1044 //             //  of the chamber or even to the AMDB origin!
1045 //             vecRot.setX(cos(p.phi*deg));
1046 //             vecRot.setY(sin(p.phi*deg));
1047 //             vecRot.setZ(1.);
1048 //             AMDBorgTranslation =
1049 //                 //     HepTranslate3D(GetLength()/2.,0.,GetThickness()/2.);
1050 //                 HepTranslate3D(GetThickness()/2.,0.,GetLength()/2.);
1051 //         }
1052 //           //log << MSG::DEBUG << "AMDB org is (" << GetLength()/2. << ", " << 0
1053 //           //<< ", " << GetThickness()/2.
1054 //           //<< ") which is (length/2, 0, thickness/2)" << endreq;
1055 //         const HepVector3D zaxis   = HepVector3D(0.,0.,1.);
1056 //         //const HepVector3D raxis   = HepVector3D(vec.x(), vec.y(), 0.);
1057 //         // imt redefine these to use vectors given by phi-direction only...
1058 //         const HepVector3D raxis   = HepVector3D(vecRot.x(), vecRot.y(), 0.);
1059 //         const HepVector3D phiaxis = HepVector3D(-raxis.y(), raxis.x(), 0.); // phi = z cross r
1060 //         // order of extra rotations is alpha(r), then beta(z), then gamma(phi)
1061 //         // imt alpha is rotation about station T-axis and beta about Z-axis.
1062 //         //     these are swapped around for the EC chambers.
1063 //           //HepRotate3D ralpha(p.alpha*deg, raxis);
1064 //           //HepRotate3D rbeta (p.beta*deg,  zaxis);
1065 //           ////  the minus is here temporary
1066 //           //HepRotate3D rgamma(-p.gamma*deg, phiaxis);
1067 //         HepRotate3D ralpha, rbeta, rgamma;
1068 //         if (name[0]=='B' || p.isBarrelLike)
1069 //         {
1070 //             ralpha=HepRotate3D(p.alpha*deg, raxis);
1071 //             rbeta=HepRotate3D(p.beta*deg,  zaxis);
1072 //             rgamma=HepRotate3D(p.gamma*deg, phiaxis);
1073 //         }
1074 //         else
1075 //         {
1076 //              // ralpha=HepRotate3D(p.beta*deg, raxis);
1077 //              // rbeta=HepRotate3D(p.alpha*deg,  zaxis);
1078 //             ralpha=HepRotate3D(p.alpha*deg,  zaxis);// which is really T-axis
1079 //             rbeta=HepRotate3D(p.beta*deg, raxis);   // which is really Z-axis
1080 //             rgamma=HepRotate3D(p.gamma*deg, phiaxis);
1081 //         }
1082 //         if (name[0]=='B' || p.isBarrelLike)
1083 //         {    
1084 //             // here all Barrel chambers 
1085 //             if (p.isMirrored) nominalTransf = HepRotateZ3D(p.phi*deg)*HepRotateX3D(180.*deg);
1086 //             else nominalTransf =  HepRotateZ3D(p.phi*deg);
1087 //         }
1088 //           //else if (p.isBarrelLike)
1089 //           //{
1090 //           //// here all encap chambers positioned like barrel chambers
1091 //           //// initial 180 deg Y-flip is because of intrinsic GeoTrap orientation
1092 //           //if (p.isMirrored) nominalTransf =
1093 //        //HepRotateZ3D(p.phi*deg)*HepRotateX3D(180.*deg)*
1094 //        //HepRotateY3D(180.*deg);
1095 //           //else nominalTransf =  HepRotateZ3D(p.phi*deg)*HepRotateY3D(180.*deg);
1096 //           //}
1097 //         else
1098 //         {    
1099 //             if ( p.z>=0 || ( p.z<0 && !(p.isMirrored) ) ){
1100 //                 nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*HepRotateX3D(p.phi*deg-180*deg));
1101 //             }
1102 //             else if (p.z<0 && p.isMirrored){
1103 //                 nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*
1104 //                                                 HepRotateX3D(p.phi*deg-180*deg)*
1105 //                                                 HepRotateZ3D(180*deg));
1106 //             }
1107 //             else log << MSG::WARNING <<" AAAAAA problem here p.z, mirrored "
1108 //          <<p.z<<" "<<p.isMirrored<<endreq;
1109 //         }
1110 //         HepTransform3D transf = HepTranslate3D(vec)*AMDBorgTranslation.inverse()*rgamma*rbeta*ralpha*AMDBorgTranslation*nominalTransf;
1111 //         HepTransform3D dummyRot = rgamma*rbeta*ralpha;
1112 //         return transf;
1113 //       */
1114 //       return getNominalTransform(p); // works for barrel & barrel-like
1115 //     }
1116 //     else
1117 //     {
1118 //         HepTransform3D nominalTransf;
1119 //         HepTransform3D AMDBorgTranslation = HepTransform3D::Identity;    
1120 //         static Hep3Vector vec;
1121 //         if (name[0]=='B') {
1122 //             // defining the position of the centre of any station
1123 //             // here using the stations in DBSC (described in amdb + the ones at z<0)
1124 //             vec.setX((p.radius+GetThickness()/2.)*cos(p.phi*deg));
1125 //             vec.setX(vec.x()-p.shift*sin((p.phi)*deg));
1126 //             vec.setY((p.radius+GetThickness()/2.)*sin(p.phi*deg));
1127 //             vec.setY(vec.y()+p.shift*cos((p.phi)*deg));
1128 //             vec.setZ(p.z+GetLength()/2.);
1129 //             AMDBorgTranslation = HepTranslate3D(GetThickness()*cos(p.phi*deg)/2.,
1130 //                                                 GetThickness()*sin(p.phi*deg)/2.,
1131 //                                                 GetLength()/2.);
1132 //         }
1133 //         else {      // if (name[0]=='T') 
1134 //             // defining the position of the centre of stations at z><0
1135 //             double rad;
1136 //             // IMT this should be version dependent, bad for CTB geom...
1137 //             if (name[0]=='T')
1138 //                 rad=((TgcComponent *)GetComponent(0))->posy;
1139 //             else
1140 //                 rad=p.radius;
1141 //             if (name[0]!='C') 
1142 //             {
1143 //                 vec.setX((rad+GetLength()/2.)*cos(p.phi*deg));
1144 //                 vec.setX(vec.x()-p.shift*sin((p.phi)*deg));
1145 //                 vec.setY((rad+GetLength()/2.)*sin(p.phi*deg));
1146 //                 vec.setY(vec.y()+p.shift*cos((p.phi)*deg));
1147 //                 vec.setZ(p.z+GetThickness()/2.);
1148 //             }
1149 //             else 
1150 //             {
1151 //                 vec.setX(rad*cos(p.phi*deg));
1152 //                 vec.setX(vec.x()-p.shift*sin((p.phi)*deg));
1153 //                 vec.setY(rad*sin(p.phi*deg));
1154 //                 vec.setY(vec.y()+p.shift*cos((p.phi)*deg));
1155 //                 if (p.z>0) vec.setZ(p.z);
1156 //                 else vec.setZ(p.z+GetThickness());
1157 //             }
1158 //         }
1159 // //         HepTransform3D AMDBorgTranslation = HepTransform3D::Identity;
1160 // //         AMDBorgTranslation = HepTranslate3D(GetThickness()/2.,
1161 // //                                             0.,
1162 // //                                             GetLength()/2.);        
1163 //         const HepVector3D zaxis   = HepVector3D(0.,0.,1.);
1164 //         const HepVector3D raxis   = HepVector3D(vec.x(), vec.y(), 0.);
1165 //         const HepVector3D phiaxis = HepVector3D(-raxis.y(), raxis.x(), 0.); // phi = z cross r
1166 //         // order of extra rotations is alpha(r), then beta(z), then gamma(phi)
1167 //         HepRotate3D ralpha, rbeta, rgamma;
1168 //         ralpha = HepRotate3D(p.alpha*deg, raxis);
1169 //         rbeta  = HepRotate3D(p.beta*deg,  zaxis);
1170 //         if ( p.zindex<0 && !(name[0] == 'B') ) {
1171 //             rgamma = HepRotate3D(p.gamma*deg, phiaxis);
1172 //             //            if (name[0]=='C') log << MSG::DEBUG <<"zi,fi  gamma applied "<<name<<" "<<p.zindex<<" "<<p.phiindex<<" "<<p.gamma<<endreq;
1173 //         }
1174 //         else {
1175 //             rgamma = HepRotate3D(-p.gamma*deg, phiaxis);        
1176 //             //            if (name[0]=='C') log << MSG::DEBUG<<"zi,fi  gamma applied "<<name<<" "<<p.zindex<<" "<<p.phiindex<<" "<<-p.gamma<<endreq;
1177 //         }        
1178 //         if (name[0]=='B' || p.isBarrelLike)
1179 //         {    
1180 //             // here all Barrel chambers 
1181 //             if (p.isMirrored) nominalTransf = HepRotateZ3D(p.phi*deg)*HepRotateX3D(180.*deg);
1182 //             else nominalTransf =  HepRotateZ3D(p.phi*deg);
1183 //         }
1184 //         else
1185 //         {    
1186 //             if ( p.z>=0 || ( p.z<0 && !(p.isMirrored) ) ){
1187 //                 nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*HepRotateX3D(p.phi*deg-180*deg));
1188 //             }
1189 //             else if (p.z<0 && p.isMirrored){
1190 //                 nominalTransf =  HepTransform3D(HepRotateY3D(-90*deg)*
1191 //                                                 HepRotateX3D(p.phi*deg-180*deg)*
1192 //                                                 HepRotateZ3D(180*deg));
1193 //             }
1194 //             else log << MSG::WARNING<<" AAAAAA problem here p.z, mirrored "
1195 //                   <<p.z<<" "<<p.isMirrored<<endreq;
1196 //         }
1197 //         HepTransform3D transf;
1198 //         if (name[0]!='C') transf = HepTranslate3D(vec)*rgamma*rbeta*ralpha*nominalTransf;
1199 //         else transf = HepTranslate3D(vec)*nominalTransf*
1200 //                       HepRotateY3D(p.gamma*deg)*
1201 //                       HepTranslate3D(GetThickness()/2.,0.,GetLength()/2.);
1202 //         return transf;
1203 //     }
1204 // }
1205 
1206 } // namespace MuonGM
1207 

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!