16 #include "TGeoMatrix.h" 
   17 #include "TGeoManager.h" 
   20 #include "TRotation.h" 
   25 #include "TObjString.h" 
   44 return (a>0 ? 1: a<0 ? -1 : 0);
 
   58                         cout<<
"Empty geometry passed to PndEmcStructure"<<endl;
 
   75                         cout<<
"gGeoManager does not exist"<<endl;
 
   91         int module,copy,
row,crystal;
 
   94         const TGeoMatrix *crystal_matrix;
 
  101         TGeoIterator 
next(geoMan->GetTopVolume());
 
  104         while ((node=
next())) {
 
  105                 next.GetPath(node_path);
 
  108                 if (!isEmcModule) 
continue;
 
  111                 detId =  module*100000000 + row*1000000 + copy*10000 + crystal;
 
  118                         cout<<
"Not found tci for index = "<<detId<<
" in PndEmcStructure"<<endl;
 
  119                         cout<<node_path<<endl;
 
  124                 crystal_matrix=
next.GetCurrentMatrix();
 
  126                 trans=crystal_matrix->GetTranslation();
 
  127                 TVector3 
pos(trans[0],trans[1],trans[2]);
 
  128                 emcX[detId] = pos.X();
 
  129                 emcY[detId] = pos.Y();
 
  130                 emcZ[detId] = pos.Z();
 
  132                 geoRot.SetMatrix(crystal_matrix->GetRotationMatrix());
 
  138                 TString shapeType = node->GetVolume()->GetShape()->ClassName();
 
  139                 if (shapeType == 
"TGeoTrap") {
 
  140                         TGeoTrap *trap = 
dynamic_cast<TGeoTrap *
>(
 
  141                                         node->GetVolume()->GetShape());
 
  143                         xtal = 
new PndEmcXtal(tci, *trap, pos, geoRot);
 
  144                 } 
else if (shapeType == 
"TGeoArb8") {
 
  145                         TGeoArb8 *arb8 = 
dynamic_cast<TGeoArb8 *
>(
 
  146                                         node->GetVolume()->GetShape());
 
  150                         Double_t *verts = arb8->GetVertices();
 
  153                         Double_t tx = (verts[4*2+0] + verts[5*2+0] + verts[6*2+0] + verts[7*2+0] - verts[0*2+0] - verts[1*2+0] - verts[2*2+0] - verts[3*2+0]) / (2 * 4 * dz);
 
  154                         Double_t ty = (verts[4*2+1] + verts[5*2+1] + verts[6*2+1] + verts[7*2+1] - verts[0*2+1] - verts[1*2+1] - verts[2*2+1] - verts[3*2+1]) / (2 * 4 * dz);
 
  159                         Double_t h1 = (verts[1*2+1] + verts[2*2+1] - verts[0*2+1] - verts[3*2+1])/(2*2);
 
  160                         Double_t bl1 = (verts[3*2+0] - verts[0*2+0]) / 2;
 
  161                         Double_t tl1 = (verts[2*2+0] - verts[1*2+0]) / 2;
 
  162                         Double_t alpha1 = TMath::ATan((verts[1*2+0]+verts[2*2+0]-verts[0*2+0]-verts[3*2+0])/(2*2*h1)) * TMath::RadToDeg();
 
  164                         Double_t h2 = (verts[5*2+1] + verts[6*2+1] - verts[4*2+1] - verts[7*2+1])/(2*2);
 
  165                         Double_t bl2 = (verts[7*2+0] - verts[4*2+0]) / 2;
 
  166                         Double_t tl2 = (verts[6*2+0] - verts[5*2+0]) / 2;
 
  167                         Double_t alpha2 = TMath::ATan((verts[5*2+0]+verts[6*2+0]-verts[4*2+0]-verts[7*2+0])/(2*2*h2)) * TMath::RadToDeg();
 
  169                         TGeoTrap *crystal_shape = 
new TGeoTrap(dz, thetac, phic,
 
  170                                                                                   h1, bl1, tl1, alpha1,
 
  171                                                                                   h2, bl2, tl2, alpha2);
 
  182                         xtal = 
new PndEmcXtal(tci, *crystal_shape, pos, geoRot);
 
  183                 } 
else if (shapeType == 
"TGeoBBox" || shapeType == 
"TGeoScaledShape") {
 
  184                         TGeoBBox 
const *box = 
dynamic_cast<TGeoBBox const*
>(
 
  185                                         node->GetVolume()->GetShape());
 
  188                         TGeoTrap *crystal_shape = 
new TGeoTrap(box->GetDZ(), 0, 0,
 
  189                                                                                   box->GetDY(), box->GetDX(), box->GetDX(), 0,
 
  190                                                                                   box->GetDY(), box->GetDX(), box->GetDX(), 0);
 
  192                         xtal = 
new PndEmcXtal(tci,*crystal_shape,pos,geoRot);
 
  195                         cout << 
"Unknown geometry type " << shapeType << 
" in module " << module << endl;
 
  209         if (!(node_path.Contains(
"emc") || node_path.Contains(
"Crystal") || node_path.Contains(
"FscModuleVolume"))) 
return false;
 
  214         if (node_path.Contains(
"Fsc_")){
 
  216                 if (node_path.Contains(
"FscLayer"))
 
  218                 sscanf(node_path.Data(),
"cave/Fsc_%d/emc%dr%dc%d_0",©,&module,&
row,&crystal);
 
  225         if (node_path.Contains(
"FscModuleVolume")){
 
  228                 if (node_path.Contains(
"FscLayer") || node_path.Contains(
"FscFibHole"))
 
  240                 sscanf(node_path.Data(),
"cave/Emc%d_%d/FscSuperModuleVolume_%d/FscTyvekVolume_%d/FscModuleVolume_%d",
 
  241                         &module,©,&SupModCopy,&dummyTyv,&LocCopy);
 
  244                 nSupCol = SupModCopy/100;
 
  245                 nSupRow = SupModCopy%100;
 
  251                 crystal = (nSupCol - 1)*2 + nModCol + 1;
 
  252                 row = (nSupRow - 1)*2 + nModRow + 1;
 
  262         if (node_path.Contains(
"Emc12Hole")){
 
  264                 if (node_path.Contains(
"EmcLayer2Hole"))
 
  266                         sscanf(node_path.Data(),
"cave/Emc12Hole_%d/EmcLayer2Hole_0/emc%dr%dc%d_0$",©,&module,&
row,&crystal);
 
  270                         sscanf(node_path.Data(),
"cave/Emc12Hole_%d/EmcLayer1_0/emc%dr%dc%d_0$",©,&module,&
row,&crystal);
 
  278         if (node_path.Contains(
"EmcLayer")){
 
  280                 sscanf(node_path.Data(),
"cave/Emc%d_%d/EmcLayer%d_0/emc%dr%dc%d_0$",&tmp1,©,&tmp2,&module,&
row,&crystal);
 
  286         if (node_path.Contains(
"Slice_target")){
 
  287     int iSM, copySM, iMod, copyMod, iAlv, iCry, copyCry;
 
  288     char sgnMod, sgnCry, typeCry;
 
  289     sscanf(node_path.Data(),
 
  290       "cave/BarrelEMC_0/Slice_target_%d/SuperModule%d_Target_%d/Module%d%c_%d/Crystal-%d%c-%c%d_%d",
 
  291       ©, &iSM, ©SM, &iMod, &sgnMod, ©Mod, &iAlv, &sgnCry, &typeCry, &iCry, ©Cry);
 
  294     if (sgnCry == 
'p') module = 1;
 
  295     else if (sgnCry == 
'm') module = 2;
 
  299     row = (iAlv - 1) * 4 + iCry;
 
  303       if (typeCry == 
'L') crystal = (copyCry - 1) * 2 + 1;
 
  304       if (typeCry == 
'R') crystal = (copyCry - 1) * 2 + 2;
 
  306     else if (module == 2) {
 
  307       if (typeCry == 
'R') crystal = (copyCry - 1) * 2 + 1;
 
  308       if (typeCry == 
'L') crystal = (copyCry - 1) * 2 + 2;
 
  311       std::cout << 
"Error!!!" << std::endl;
 
  320         if (node_path.Contains(
"Slice")){
 
  321     int iSM, copySM, iMod, copyMod, iAlv, iCry, copyCry;
 
  322     char sgnMod, sgnCry, typeCry;
 
  323     sscanf(node_path.Data(),
 
  324       "cave/BarrelEMC_0/Slice_%d/SuperModule%d_%d/Module%d%c_%d/Crystal-%d%c-%c%d_%d",
 
  325       ©, &iSM, ©SM, &iMod, &sgnMod, ©Mod, &iAlv, &sgnCry, &typeCry, &iCry, ©Cry);
 
  328     if (sgnCry == 
'p') module = 1;
 
  329     else if (sgnCry == 
'm') module = 2;
 
  333     row = (iAlv - 1) * 4 + iCry;
 
  337       if (typeCry == 
'L') crystal = (copyCry - 1) * 2 + 1;
 
  338       if (typeCry == 
'R') crystal = (copyCry - 1) * 2 + 2;
 
  340     else if (module == 2) {
 
  341       if (typeCry == 
'R') crystal = (copyCry - 1) * 2 + 1;
 
  342       if (typeCry == 
'L') crystal = (copyCry - 1) * 2 + 2;
 
  345       std::cout << 
"Error!!!" << std::endl;
 
  354         else if (node_path.Contains(
"EmcTest")) {
 
  355                 sscanf(node_path.Data(),
"cave/EmcTest_%d/emc%dr%dc%d_0$",©,&module,&
row,&crystal);
 
  361         else if (node_path.Contains(
"SubunitVolFwEndCap")) {
 
  362                 Int_t copyNoSub, copyNoBox, copyNoCrys;
 
  364                 if (node_path.Contains(
"HalfSubunitVolFwEndCap")) 
 
  365                   sscanf(node_path.Data(),
"cave/Emc3_0/HalfSubunitVolFwEndCap_%d/BoxVol_%d/CrystalVol_%d", ©NoSub, ©NoBox, ©NoCrys);
 
  367                   sscanf(node_path.Data(),
"cave/Emc3_0/SubunitVolFwEndCap_%d/BoxVol_%d/CrystalVol_%d", ©NoSub, ©NoBox, ©NoCrys);
 
  372                 Int_t SubunitCol=-100, SubunitRow=-100, CrystalCol=-100, CrystalRow=-100;
 
  373                 Int_t RestOfHalfSubunitRowNo[6] = {5, 6, 7, 8, 9, 9};
 
  374                 Int_t RestOfHalfSubunitColNo[6] = {8, 7, 6, 5, 3, 2};
 
  376                 if (copyNoSub >= 1 && copyNoSub <= 10){       
 
  378                   SubunitCol = pow(-1.,1+(copyNoSub-1)/5)*(4+(copyNoSub-1)%5);
 
  380                 else if (copyNoSub > 11 && copyNoSub < 24){ 
 
  381                   SubunitRow = pow(-1.,(copyNoSub-11)/7)*2;
 
  382                   SubunitCol = ((copyNoSub-11)%7)-3;
 
  384                 else if ((copyNoSub >= 25 && copyNoSub <= 27) || copyNoSub==57 || copyNoSub==58){ 
 
  385                   if (copyNoSub >= 25 && copyNoSub <= 27)
 
  386                     SubunitRow = copyNoSub - 25;
 
  388                     SubunitRow = copyNoSub - 59;
 
  391                 else if (copyNoSub >= 40 && copyNoSub <= 44){ 
 
  392                   SubunitRow = 42 - copyNoSub;
 
  395                 else if (copyNoSub == 28 || copyNoSub ==39 || copyNoSub == 45 || copyNoSub == 56) { 
 
  397                     SubunitRow = RestOfHalfSubunitRowNo[0];
 
  399                     SubunitRow = -RestOfHalfSubunitRowNo[0];
 
  400                   SubunitCol = pow(-1.,copyNoSub-1)*RestOfHalfSubunitColNo[0];
 
  402                 else if (copyNoSub == 29 || copyNoSub == 38 || copyNoSub == 46 || copyNoSub == 55) { 
 
  404                     SubunitRow = RestOfHalfSubunitRowNo[1];
 
  406                     SubunitRow = -RestOfHalfSubunitRowNo[1];
 
  407                   SubunitCol = pow(-1.,copyNoSub)*RestOfHalfSubunitColNo[1];
 
  409                 else if (copyNoSub == 30 || copyNoSub == 37 || copyNoSub == 47 || copyNoSub == 54) { 
 
  411                     SubunitRow = RestOfHalfSubunitRowNo[2];
 
  413                     SubunitRow = -RestOfHalfSubunitRowNo[2];
 
  414                   SubunitCol = pow(-1.,copyNoSub-1)*RestOfHalfSubunitColNo[2];
 
  416                 else if (copyNoSub == 31 || copyNoSub == 36 || copyNoSub == 48 || copyNoSub == 53) { 
 
  418                     SubunitRow = RestOfHalfSubunitRowNo[3];
 
  420                     SubunitRow = -RestOfHalfSubunitRowNo[3];
 
  421                   SubunitCol = pow(-1.,copyNoSub)*RestOfHalfSubunitColNo[3];
 
  423                 else if (copyNoSub == 32 || copyNoSub == 35 || copyNoSub == 49 || copyNoSub == 52) { 
 
  425                     SubunitRow = RestOfHalfSubunitRowNo[4];
 
  427                     SubunitRow = -RestOfHalfSubunitRowNo[4];
 
  428                   SubunitCol = pow(-1.,copyNoSub-1)*RestOfHalfSubunitColNo[4];
 
  430                 else if (copyNoSub == 33 || copyNoSub == 34 || copyNoSub == 50 || copyNoSub == 51) { 
 
  432                     SubunitRow = RestOfHalfSubunitRowNo[5];
 
  434                     SubunitRow = -RestOfHalfSubunitRowNo[5];
 
  435                   SubunitCol = pow(-1.,copyNoSub)*RestOfHalfSubunitColNo[5];
 
  437                 else if (copyNoSub >= 61 && copyNoSub <= 74){ 
 
  438                   SubunitRow = pow(-1.,(copyNoSub-61)/7)*((copyNoSub - 61)%7 + 3);
 
  441                 else if (copyNoSub%100 >= 1 && copyNoSub%100 <= 5){ 
 
  442                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  444                     SubunitCol = pow(-1.,1+copyNoSub/100)*(3 + copyNoSub%100);
 
  448                     SubunitCol = pow(-1.,copyNoSub/100)*(3 + copyNoSub%100);
 
  451                 else if (copyNoSub%100 >= 6 && copyNoSub%100 <= 11){ 
 
  452                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  454                     SubunitCol = pow(-1.,1+copyNoSub/100)*(2 + copyNoSub%100 - 5);
 
  458                     SubunitCol = pow(-1.,copyNoSub/100)*(2 + copyNoSub%100 - 5);
 
  461                 else if (copyNoSub%100 >= 12 && copyNoSub%100 <= 19){ 
 
  462                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  464                     SubunitCol = pow(-1.,1+copyNoSub/100)*(copyNoSub%100 - 11);
 
  468                     SubunitCol = pow(-1.,copyNoSub/100)*(copyNoSub%100 - 11);
 
  471                 else if (copyNoSub%100 >= 20 && copyNoSub%100 <= 27){ 
 
  472                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  474                     SubunitCol = pow(-1.,1+copyNoSub/100)*(copyNoSub%100 - 19);
 
  478                     SubunitCol = pow(-1.,copyNoSub/100)*(copyNoSub%100 - 19);
 
  481                 else if (copyNoSub%100 >= 28 && copyNoSub%100 <= 34){ 
 
  482                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  484                     SubunitCol = pow(-1.,1+copyNoSub/100)*(copyNoSub%100 - 27);
 
  488                     SubunitCol = pow(-1.,copyNoSub/100)*(copyNoSub%100 - 27);
 
  491                 else if (copyNoSub%100 >= 35 && copyNoSub%100 <= 40){ 
 
  492                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  494                      SubunitCol = pow(-1.,1+copyNoSub/100)*(copyNoSub%100 - 34);
 
  498                      SubunitCol = pow(-1.,copyNoSub/100)*(copyNoSub%100 - 34);
 
  501                 else if (copyNoSub%100 >= 41 && copyNoSub%100 <= 45){ 
 
  502                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  504                     SubunitCol = pow(-1.,1+copyNoSub/100)*(copyNoSub%100 - 40);
 
  508                     SubunitCol = pow(-1.,copyNoSub/100)*(copyNoSub%100 - 40);
 
  511                 else if (copyNoSub%100 >= 46 && copyNoSub%100 <= 49){ 
 
  512                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  514                     SubunitCol = pow(-1.,1+copyNoSub/100)*(copyNoSub%100 - 45);
 
  518                     SubunitCol = pow(-1.,copyNoSub/100)*(copyNoSub%100 - 45);
 
  521                 else if (copyNoSub%100 == 50 ){ 
 
  522                   if (copyNoSub/100 == 1 || copyNoSub/100 == 4){
 
  524                     SubunitCol = pow(-1.,1+copyNoSub/100);
 
  528                     SubunitCol = pow(-1.,copyNoSub/100);
 
  533                 if (
fabs(SubunitRow)<=1 && 
fabs(SubunitCol)<=3) flag=0;      
 
  534                 else if (
fabs(SubunitCol)==9 && 
fabs(SubunitRow)>=3) flag=0; 
 
  535                 else if (
fabs(SubunitCol)==8 && 
fabs(SubunitRow)>=6) flag=0; 
 
  536                 else if (
fabs(SubunitCol)==7 && 
fabs(SubunitRow)>=7) flag=0; 
 
  537                 else if (
fabs(SubunitCol)==6 && 
fabs(SubunitRow)>=8) flag=0; 
 
  538                 else if (
fabs(SubunitCol)>=4 && 
fabs(SubunitRow)==9) flag=0; 
 
  541                 if (flag && copyNoSub >= 61){
 
  542                       if(copyNoBox==1 || copyNoBox==4){
 
  543                         if(copyNoCrys==1 || copyNoCrys==3)
 
  544                           CrystalRow = SubunitRow*4 + (3-
getsign(SubunitRow))/2;
 
  546                           CrystalRow = SubunitRow*4 + (1-
getsign(SubunitRow))/2;
 
  548                       else if(copyNoBox==2 || copyNoBox==3){
 
  549                         if(copyNoCrys==1 || copyNoCrys==3)
 
  550                           CrystalRow = SubunitRow*4 - (1+
getsign(SubunitRow))/2;
 
  552                           CrystalRow = SubunitRow*4 - (3+
getsign(SubunitRow))/2;
 
  555                       if (copyNoSub >= 61 && copyNoSub <= 74) {
 
  556                           if(copyNoBox==1 || copyNoBox==3){
 
  557                             if(copyNoCrys==1 || copyNoCrys==4)
 
  562                           else if(copyNoBox==4 || copyNoBox==2){
 
  563                             if(copyNoCrys==1 || copyNoCrys==4)
 
  570                           if(copyNoBox==1 || copyNoBox==3){
 
  571                             if(copyNoCrys==1 || copyNoCrys==4)
 
  572                               CrystalCol = SubunitCol*4 + (3+
getsign(SubunitCol))/2;
 
  574                               CrystalCol = SubunitCol*4 + (1+
getsign(SubunitCol))/2;
 
  576                           else if(copyNoBox==4 || copyNoBox==2){
 
  577                             if(copyNoCrys==1 || copyNoCrys==4)
 
  578                               CrystalCol = SubunitCol*4 - (1-
getsign(SubunitCol))/2;
 
  580                               CrystalCol = SubunitCol*4 - (3-
getsign(SubunitCol))/2;
 
  585                 else if (flag && copyNoSub <= 10) {
 
  586                       if(copyNoCrys==1 || copyNoCrys==3)
 
  592                         if(copyNoCrys==1 || copyNoCrys==4)
 
  593                           CrystalCol = SubunitCol*4 + (3+
getsign(SubunitCol))/2;
 
  595                           CrystalCol = SubunitCol*4 + (1+
getsign(SubunitCol))/2;
 
  598                         if(copyNoCrys==1 || copyNoCrys==4)
 
  599                           CrystalCol = SubunitCol*4 - (1-
getsign(SubunitCol))/2;
 
  601                           CrystalCol = SubunitCol*4 - (3-
getsign(SubunitCol))/2;
 
  604                 else if (flag && copyNoSub > 11 && copyNoSub < 24) {
 
  605                       if(copyNoCrys==1 || copyNoCrys==3)
 
  606                         CrystalRow = (1+17*
getsign(SubunitRow))/2;
 
  608                         CrystalRow = (17*
getsign(SubunitRow)-1)/2;
 
  610                       if (SubunitCol == 0 && copyNoBox==1) {
 
  611                         if(copyNoCrys==1 || copyNoCrys==4)
 
  616                       else if (SubunitCol == 0) {
 
  617                         if (copyNoCrys==1 || copyNoCrys==4)
 
  622                       else if(copyNoBox==1){
 
  623                         if(copyNoCrys==1 || copyNoCrys==4)
 
  624                           CrystalCol = SubunitCol*4 + (3+
getsign(SubunitCol))/2;
 
  626                           CrystalCol = SubunitCol*4 + (1+
getsign(SubunitCol))/2;
 
  629                         if(copyNoCrys==1 || copyNoCrys==4)
 
  630                           CrystalCol = SubunitCol*4 - (1-
getsign(SubunitCol))/2;
 
  632                           CrystalCol = SubunitCol*4 - (3-
getsign(SubunitCol))/2;
 
  635                 else if (flag && ((copyNoSub >= 25 && copyNoSub <= 27) || copyNoSub == 57 || copyNoSub == 58 || (copyNoSub >= 40 && copyNoSub <= 44))) {
 
  636                       if(copyNoBox==1 && (copyNoCrys==1 || copyNoCrys==4))
 
  637                         if (copyNoSub == 25 || copyNoSub == 42)
 
  640                           CrystalRow = SubunitRow*4 + (3+
getsign(SubunitRow))/2;
 
  641                       else if (copyNoBox==1)
 
  642                         if (copyNoSub == 25 || copyNoSub == 42)
 
  645                           CrystalRow = SubunitRow*4 + (1+
getsign(SubunitRow))/2;
 
  647                       else if (copyNoBox==2 && (copyNoCrys==1 || copyNoCrys==4))
 
  648                         if (copyNoSub == 25 || copyNoSub == 42)
 
  651                           CrystalRow = SubunitRow*4 - (1-
getsign(SubunitRow))/2;
 
  652                       else if (copyNoBox==2)
 
  653                         if (copyNoSub == 25 || copyNoSub == 42)
 
  656                           CrystalRow = SubunitRow*4 - (3-
getsign(SubunitRow))/2;
 
  658                       if (copyNoCrys==1 || copyNoCrys==3)
 
  659                         if (!(copyNoSub >= 40 && copyNoSub <= 44))
 
  664                         if (!(copyNoSub >= 40 && copyNoSub <= 44))
 
  669                 else if (flag && (copyNoSub == 28 || copyNoSub ==29 || copyNoSub == 38 || copyNoSub == 39 || copyNoSub == 45 || copyNoSub == 46 || copyNoSub == 55 || copyNoSub == 56)) {
 
  670                       if (copyNoBox==1 && (copyNoCrys==1 || copyNoCrys==4))
 
  671                         CrystalRow = SubunitRow*4 + (3-
getsign(SubunitRow))/2;
 
  672                       else if (copyNoBox==1) 
 
  673                         CrystalRow = SubunitRow*4 + (1-
getsign(SubunitRow))/2;
 
  674                       else if(copyNoCrys==1 || copyNoCrys==4) 
 
  675                         CrystalRow = SubunitRow*4 - (1+
getsign(SubunitRow))/2;
 
  677                         CrystalRow = SubunitRow*4 - (3+
getsign(SubunitRow))/2;
 
  679                       if (copyNoCrys==4 || copyNoCrys==2)
 
  680                         CrystalCol = SubunitCol*4 + (1-
getsign(SubunitCol))/2;
 
  682                         CrystalCol = SubunitCol*4 - (1+
getsign(SubunitCol))/2;
 
  684                 else if (flag && ((copyNoSub >= 30 && copyNoSub <= 37) || (copyNoSub >=47 && copyNoSub <= 54))) {
 
  685                       if (copyNoCrys==1 || copyNoCrys==3)
 
  686                         CrystalRow = SubunitRow*4 + (1-3*
getsign(SubunitRow))/2;
 
  688                         CrystalRow = SubunitRow*4 - (1+3*
getsign(SubunitRow))/2;
 
  690                       if (copyNoBox==1 && (copyNoCrys==1 || copyNoCrys==4))
 
  691                         CrystalCol = SubunitCol*4 + (3+
getsign(SubunitCol))/2;
 
  692                       else if (copyNoBox==1) 
 
  693                         CrystalCol = SubunitCol*4 + (1+
getsign(SubunitCol))/2;
 
  694                       else if (copyNoCrys==1 || copyNoCrys==4) 
 
  695                         CrystalCol = SubunitCol*4 - (1-
getsign(SubunitCol))/2;
 
  697                         CrystalCol = SubunitCol*4 - (3-
getsign(SubunitCol))/2;
 
  702                 crystal = CrystalCol + 36;
 
  703                 row = CrystalRow + 37;
 
  718         else if (node_path.Contains(
"Quarter4Vol")) {
 
  720                 int copyNoSub, copyNoBox, copyNoCrys;
 
  723                 if (node_path.Contains(
"SubunitVol_")){
 
  724                         sscanf(node_path.Data(),
"cave/Emc4_0/Quarter4Vol_%d/SubunitVol_%d/BoxVol_%d/CrystalVol_%d",©, ©NoSub, ©NoBox, ©NoCrys);
 
  727                         if (node_path.Contains(
"BoxVol_")){
 
  728                                 sscanf(node_path.Data(),
"cave/Emc4_0/Quarter4Vol_%d/SubunitVol%d_%d/BoxVol_%d/CrystalVol_%d",©,&tmp1, ©NoSub, ©NoBox, ©NoCrys);
 
  731                                 sscanf(node_path.Data(),
"cave/Emc4_0/Quarter4Vol_%d/SubunitVol%d_%d/BoxVol%d_%d/CrystalVol_%d",©, &tmp1, ©NoSub, &tmp2, ©NoBox, ©NoCrys);
 
  736                 Int_t 
col=0, nRow=-1, nCrys=-1; 
 
  743                 if((copyNoSub >=  0) && (copyNoSub <=  3)){
 
  746                 }
else if((copyNoSub >=  4) && (copyNoSub <= 7)){
 
  747                         next  = (copyNoSub-4);
 
  749                 }
else if((copyNoSub >= 8) && (copyNoSub <= 10)){
 
  750                         next  = (copyNoSub-8);
 
  752                 }
else if((copyNoSub >= 11) && (copyNoSub <= 12)){
 
  753                         next  = (copyNoSub-11);
 
  761                 if (next>1  && col>2) flag4=0; 
 
  762                 if (next>2  && col>1) flag4=0; 
 
  765                         if ( (copyNoBox == 0)  || (copyNoBox == 3) ){
 
  766                                 if(copyNoCrys == 1 || copyNoCrys == 3){
 
  768                                 }
else if (copyNoCrys == 0 || copyNoCrys == 2){
 
  771                         }
else if ( (copyNoBox == 1)  || (copyNoBox == 2) ){
 
  772                                 if(copyNoCrys == 0 || copyNoCrys == 2){
 
  774                                 }
else if (copyNoCrys == 1 || copyNoCrys == 3){
 
  778                         if ( (copyNoBox == 0)  || (copyNoBox == 2) ){
 
  779                                 if(copyNoCrys == 0 || copyNoCrys == 3){
 
  780                                         nRow = subrow*col + 4;
 
  781                                 }
else if (copyNoCrys == 1 || copyNoCrys == 2){
 
  782                                         nRow = subrow*col + 3;
 
  784                         }
else if ( (copyNoBox == 1)  || (copyNoBox == 3) ){
 
  785                                 if(copyNoCrys == 0 || copyNoCrys == 3){
 
  786                                         nRow = subrow*col + 2;
 
  787                                 }
else if (copyNoCrys == 1 || copyNoCrys == 2){
 
  788                                         nRow = subrow*col + 1;
 
  801         else if (node_path.Contains(
"QuarterNewVol")){
 
  803                 int copyNoSub, copyNoBox, copyNoCrys;
 
  806                 if (node_path.Contains(
"SubunitVol_")){
 
  807                         sscanf(node_path.Data(),
"cave/Emc4_0/QuarterNewVol_%d/SubunitVol_%d/BoxVol_%d/CrystalVol_%d",©, ©NoSub, ©NoBox, ©NoCrys);
 
  810                         if (node_path.Contains(
"BoxVol_")){
 
  811                                 sscanf(node_path.Data(),
"cave/Emc4_0/QuarterNewVol_%d/SubunitVol%d_%d/BoxVol_%d/CrystalVol_%d",©, &tmp1, ©NoSub, ©NoBox, ©NoCrys);
 
  814                                 sscanf(node_path.Data(),
"cave/Emc4_0/QuarterNewVol_%d/SubunitVol%d_%d/BoxVol%d_%d/CrystalVol_%d",©, &tmp1, ©NoSub, &tmp2, ©NoBox, ©NoCrys);
 
  819                 Int_t 
col=0, nRow=-1, nCrys=-1;
 
  825                 if((copyNoSub >=  0) && (copyNoSub <=  2)){
 
  828                 }
else if((copyNoSub >=  3) && (copyNoSub <= 6)){
 
  829                         next  = (copyNoSub-3);
 
  831                 }
else if((copyNoSub >= 7) && (copyNoSub <= 10)){
 
  832                         next  = (copyNoSub-7);
 
  834                 }
else if((copyNoSub >= 11) && (copyNoSub <= 13)){
 
  835                         next  = (copyNoSub-11);
 
  844                 if (next==3  && col==3) flag4=0; 
 
  845                 if (next==0  && col==0) flag4=0; 
 
  848                         if ( (copyNoBox == 0)  || (copyNoBox == 3) ){
 
  849                                 if(copyNoCrys == 1 || copyNoCrys == 3){
 
  851                                 }
else if (copyNoCrys == 0 || copyNoCrys == 2){
 
  854                         }
else if ( (copyNoBox == 1)  || (copyNoBox == 2) ){
 
  855                                 if(copyNoCrys == 0 || copyNoCrys == 2){
 
  857                                 }
else if (copyNoCrys == 1 || copyNoCrys == 3){
 
  861                         if ( (copyNoBox == 0)  || (copyNoBox == 2) ){
 
  862                                 if(copyNoCrys == 0 || copyNoCrys == 3){
 
  864                                 }
else if (copyNoCrys == 1 || copyNoCrys == 2){
 
  867                         }
else if ( (copyNoBox == 1)  || (copyNoBox == 3) ){
 
  868                                 if(copyNoCrys == 0 || copyNoCrys == 3){
 
  870                                 }
else if (copyNoCrys == 1 || copyNoCrys == 2){
 
  883         else if(node_path.Contains(
"BWECinnerVol")){
 
  885           const char pathform[]=
"cave/Emc4_0/BWECouterVol_0/BWECinnerVol_0/BWECquarter_%d/BWECsubmodule%d_%d/PWOCrystal_%d";
 
  886           sscanf(node_path.Data(),pathform, ©, &submodType, &
row, &crystal);
 
  892         else if(node_path.Contains(
"EmcProto")){
 
  895                 sscanf(node_path.Data(),
"cave/EmcProto_0/emc07r%dc%d_0",&
row, &crystal);
 
  901         else if(node_path.Contains(
"Proto60")){
 
  902                 if(node_path.Contains(
"Passive") || node_path.Contains(TRegexp(
".*PartAss_[0-9]*$"))  ){
 
  909                 if(node_path.Contains(
"CrystalType6aoPartAss"))
 
  911                         sscanf(node_path.Data(),
"cave/Proto60_0/Active_1/Row%d_1/CrystalType6aoPartAss_%d/CrystalType6a_1",&
row, &crystal);
 
  912                 } 
else if (node_path.Contains(
"CrystalType6boPartAss"))
 
  914                         sscanf(node_path.Data(),
"cave/Proto60_0/Active_1/Row%d_1/CrystalType6boPartAss_%d/CrystalType6b_1",&
row, &crystal);
 
  918                         cout<<
"crystal name in  Emc Proto: "<<node_path<<
" missmatch pattern"<<endl;
 
  921                 crystal = ((crystal-1)%5)*2 +type;
 
  931                 sscanf(node_path.Data(),
"cave/Emc%d_%d/emc%dr%dc%d_0",&tmp1, ©, &module, &
row, &crystal);
 
  941         TVector3 
vec(0,0,10);
 
  948         PndEmcTciXtalMap::const_iterator iter=
fTciXtalMap.begin();
 
  951                 TVector3 vec2= ((*iter).second)->frontCentre();
 
  952                 double tmpDiff=vec2.Angle(vec);
 
  970         ofstream 
f(filename.c_str());
 
  974                 f<<
"detID"<<
"\t"<<
"ThetaInd"<<
"\t"<<
"PhiInd"<<
"\t"<<
"theta_centre"<<
"\t"<<
"theta_frontface"<<
"\t"<<
"dTheta"<<
"\t"<<
"phi_centre"<<
"\t"<<
"phi_frontface"<<
"\t"<<
"dPhi"<<endl;
 
  975                 TVector3 centre, front_centre;
 
  976                 double theta_c, theta_f, phi_c, phi_f;
 
  979                 PndEmcTciXtalMap::const_iterator iter=
fTciXtalMap.begin();
 
  984                         centre= ((*iter).second)->centre();
 
  985                         front_centre=((*iter).second)->frontCentre();
 
  986                         theta_c=centre.Theta()*TMath::RadToDeg();
 
  987                         phi_c=centre.Phi()*TMath::RadToDeg();
 
  988                         theta_f=front_centre.Theta()*TMath::RadToDeg();
 
  989                         phi_f=front_centre.Phi()*TMath::RadToDeg();
 
  991                         dTheta=theta_c-theta_f;
 
  994                         f<<tci->
Index()<<
"\t"<<tci->
XCoord()<<
"\t"<<tci->
YCoord()<<
"\t"<<theta_c<<
"\t"<<theta_f<<
"\t"<<dTheta<<
"\t"<<phi_c<<
"\t"<<phi_f<<
"\t"<<dPhi<<endl;
 
  997         } 
else if (option==2)
 
  999                 f<<
"detID"<<
"\t"<<
"ThetaInd"<<
"\t"<<
"PhiInd"<<
"\t"<<
"X"<<
"\t"<<
"Y"<<
"\t"<<
"Z"<<endl;
 
 1000                 TVector3 front_centre;
 
 1004                 PndEmcTciXtalMap::const_iterator iter=
fTciXtalMap.begin();
 
 1008                         tci = (*iter).first;
 
 1009                         front_centre=((*iter).second)->frontCentre();
 
 1010                         centre=((*iter).second)->centre();
 
 1012                         x=centre.X();y=centre.Y();z=centre.Z();
 
 1014                         f<<tci->
Index()<<
"\t"<<tci->
XCoord()<<
"\t"<<tci->
YCoord()<<
"\t"<<x<<
"\t"<<y<<
"\t"<<z<<endl;
 
 1021         cout<<
"write emc structure to log file"<<endl;
 
PndEmcStructure(TGeoManager *)
static T Sqrt(const T &x)
PndEmcTciXtalMap fTciXtalMap
represents coordinates of one crystal 
stores crystal index coordinates (x,y) or (theta,phi) 
PndEmcTwoCoordIndex * GetTCI(Int_t DetectorId)
TGeoManager * gGeoManager
void Print(string, Int_t option=1) const 
bool crystal_name_analysis(TString, int &module, int ©, int &row, int &crystal)
static PndEmcStructure * _instance
static T ATan2(const T &y, const T &x)
friend F32vec4 fabs(const F32vec4 &a)
PndEmcTwoCoordIndex * locateIndex(double theta, double phi) const 
static PndEmcStructure * Instance()
static PndEmcMapper * Instance()
virtual ~PndEmcStructure()