Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:00

0001 #include <iostream>
0002 #include <math.h>
0003 #include <fstream>
0004 #include <stdlib.h>
0005 #include <string>
0006 #include <sstream>
0007 #include <time.h>
0008 #include <unistd.h>
0009 #include <stdio.h>
0010 #include <vector>
0011 #include <map>
0012 
0013 #include <assert.h>
0014 
0015 //#include <istrstream>

0016 
0017 #include <TChain.h>
0018 #include <TFile.h>
0019 #include <TObjString.h>
0020 #include <TString.h>
0021 #include <TStopwatch.h>
0022 #include <TGraph.h>
0023 
0024 using namespace std;
0025 
0026 #include "../../interface/ME.h"
0027 #include "MECanvasHolder.hh"
0028 #include "../../interface/MEGeom.h"
0029 
0030 void writeEBGeom()
0031 {
0032   const int nsupermodules   =  36;
0033 
0034   TFile* test= new TFile( "ebgeom.root", "RECREATE" );
0035 
0036   //  list< pair<int,int> > l;

0037 
0038   TH2* eb_loc      = new TH2F( "eb_loc", "eb_loc", 95, -5.5, 89.5, 24, -2.5, 21.5 );
0039   MECanvasHolder::setHistoStyle( eb_loc );
0040 
0041   TH2* eb          = new TH2F( "eb", "eb", 190, -95.5, 94.5, 380, -9.5, 370.5 );
0042   MECanvasHolder::setHistoStyle( eb );
0043 
0044   TH2* eb_sm       = (TH2*) eb->Clone( "eb_sm"       );
0045   TH2* eb_dcc      = (TH2*) eb->Clone( "eb_dcc"      );
0046   TH2* eb_side     = (TH2*) eb->Clone( "eb_side"     );
0047   TH2* eb_lmmod    = (TH2*) eb->Clone( "eb_lmmod"    );
0048   TH2* eb_lmr      = (TH2*) eb->Clone( "eb_lmr"      );
0049   TH2* eb_tt       = (TH2*) eb->Clone( "eb_tt"       );
0050   TH2* eb_cr_in_sm = (TH2*) eb->Clone( "eb_cr_in_sm" );
0051 
0052   TH2* eb_loc_side     = (TH2*) eb_loc->Clone( "eb_loc_side"     );
0053   TH2* eb_loc_lmmod    = (TH2*) eb_loc->Clone( "eb_loc_lmmod"    );
0054   TH2* eb_loc_cr       = (TH2*) eb_loc->Clone( "eb_loc_cr"       );
0055   TH2* eb_loc_elecr    = (TH2*) eb_loc->Clone( "eb_loc_elecr"    );
0056   TH2* eb_loc_hv       = (TH2*) eb_loc->Clone( "eb_loc_hv"       );
0057   TH2* eb_loc_lv       = (TH2*) eb_loc->Clone( "eb_loc_lv"       );
0058   TH2* eb_loc_tt       = (TH2*) eb_loc->Clone( "eb_loc_tt"       );
0059 
0060   for( int ii=1; ii<=nsupermodules; ii++ )
0061     {
0062       TGraph* g_ = MEEBGeom::getGraphBoundary( MEEBGeom::iSuperModule, ii, true );
0063       assert( g_!=0 );
0064       TString gname = "SuperModule_"; gname += ii;
0065       g_->SetName( gname );
0066       g_->Write();
0067     }
0068  
0069   {
0070     TGraph* g_ = MEEBGeom::getGraphBoundary( MEEBGeom::iSuperModule, 1, false );
0071     assert( g_!=0 );
0072     TString gname = "SuperModule";
0073     g_->SetName( gname );
0074     g_->Write();
0075   }
0076 
0077   for( int ii=1; ii<=72; ii++ )
0078     {      
0079       TGraph* g_ = MEEBGeom::getGraphBoundary( MEEBGeom::iLMRegion, ii, true );
0080       assert( g_!=0 );
0081       TString gname = "MonitoringRegion_"; gname += ii;
0082       g_->SetName( gname );
0083       g_->Write();
0084     }
0085 
0086   for( int iside=0; iside<2; iside++ )
0087     {
0088       TGraph* g_ = MEEBGeom::getGraphBoundary( MEEBGeom::iLMRegion, iside, false );
0089       assert( g_!=0 );
0090       TString gname = "Side_";
0091       gname += iside;
0092       g_->SetName( gname );
0093       g_->Write();
0094     }
0095 
0096   for( int ieta=-85; ieta<=85; ieta++ )
0097     {
0098       if( ieta==0 ) continue;
0099       for( int iphi=1; iphi<=360; iphi++ )
0100     {     
0101 
0102       int ism = MEEBGeom::sm( ieta, iphi );
0103       assert( ism>0 );
0104 
0105       int idcc = MEEBGeom::dcc( ieta, iphi );
0106       assert( idcc>0 );
0107 
0108       int iside = MEEBGeom::side( ieta, iphi );
0109       int ilmr  = MEEBGeom::lmr( ieta, iphi );
0110       int itt   = MEEBGeom::tt( ieta, iphi );
0111       int icr_in_sm   = MEEBGeom::crystal( ieta, iphi );
0112 
0113       int ilmmod = MEEBGeom::lmmod( ieta, iphi );
0114       // int ilmmod = 1;

0115       assert( ilmmod>0 );
0116 
0117       eb_sm     -> Fill( ieta, iphi, ism    );
0118       eb_dcc    -> Fill( ieta, iphi, idcc   );
0119       eb_side   -> Fill( ieta, iphi, iside  );
0120       eb_lmr    -> Fill( ieta, iphi, ilmr   );
0121       eb_lmmod  -> Fill( ieta, iphi, ilmmod );
0122       eb_tt     -> Fill( ieta, iphi, itt    );
0123       eb_cr_in_sm  -> Fill( ieta, iphi, icr_in_sm    );
0124 
0125     }
0126     }
0127 
0128   for( int ix=0; ix<=84; ix++ )
0129     {
0130       for( int iy=0; iy<=19; iy++ )
0131     {     
0132       int icr    = MEEBGeom::crystal_channel( ix, iy );
0133       int ielecr = MEEBGeom::electronic_channel( ix, iy );
0134 
0135       int iX = ix/5;
0136       int iY = iy/5;      
0137       int ihv   = MEEBGeom::hv_channel( iX, iY );
0138       int ilv   = MEEBGeom::lv_channel( iX, iY );
0139       int itt   = MEEBGeom::tt_channel( iX, iY );
0140       int ilmmod = MEEBGeom::lm_channel( iX, iY );
0141       int iside = (ilmmod%2==0)?1:0;
0142       assert( ilmmod>0 );
0143 
0144       eb_loc_side   -> Fill( ix, iy, iside+0.1  );
0145       eb_loc_lmmod  -> Fill( ix, iy, ilmmod );
0146       eb_loc_tt     -> Fill( ix, iy, itt    );
0147       eb_loc_cr     -> Fill( ix, iy, icr    );
0148       eb_loc_elecr  -> Fill( ix, iy, ielecr );
0149       eb_loc_hv     -> Fill( ix, iy, ihv    );
0150       eb_loc_lv     -> Fill( ix, iy, ilv    );
0151 
0152     }
0153     }
0154 
0155   eb->Write();
0156   eb_sm->Write();
0157   eb_dcc->Write();
0158   eb_side->Write();
0159   eb_lmmod->Write();
0160   eb_lmr->Write();
0161   eb_tt->Write();
0162   eb_cr_in_sm->Write();
0163 
0164   eb_loc->Write();
0165   eb_loc_side->Write();
0166   eb_loc_lmmod->Write();
0167   eb_loc_tt->Write();
0168   eb_loc_cr->Write();
0169   eb_loc_elecr->Write();
0170   eb_loc_hv->Write();
0171   eb_loc_lv->Write();
0172 
0173   test->Close();
0174 
0175 }
0176 
0177 void writeEEGeom( int iz )
0178 {
0179   //  int iz=-1;

0180   const int nsectors   =  9;
0181   const int nlmregions = 10;
0182   const int nlmmodules = 19;
0183   const int nquadrants =  4;
0184 
0185   TString fname = "eegeom_"; 
0186   fname += (iz>0)?2:1;
0187   fname += ".root";
0188   TFile* test= new TFile( fname, "RECREATE" );
0189 
0190   //  list< pair<int,int> > l;

0191 
0192   TH2* eem          = new TH2F( "eem", "eem", 110,-4.5,105.5,110,-4.5,105.5 );
0193   MECanvasHolder::setHistoStyle( eem );
0194   TH2* eem_sect     = (TH2*) eem->Clone( "eem_sect" );
0195   TH2* eem_quad     = (TH2*) eem->Clone( "eem_quad" );
0196   TH2* eem_sc       = (TH2*) eem->Clone( "eem_sc" );
0197   TH2* eem_lmmod    = (TH2*) eem->Clone( "eem_lmmod" );
0198   TH2* eem_dcc      = (TH2*) eem->Clone( "eem_dcc" );
0199   TH2* eem_lmr      = (TH2*) eem->Clone( "eem_lmr" );
0200   TH2* eem_cr       = (TH2*) eem->Clone( "eem_cr" );
0201   TH2* eem_cr_in_sc = (TH2*) eem->Clone( "eem_cr_in_sc" );
0202 
0203   TH2* eem_loc[nsectors+1];
0204   TH2* eem_loc_lmmod[nsectors+1];
0205   TH2* eem_loc_cr[nsectors+1];
0206   TH2* eem_loc_sc[nsectors+1];
0207 
0208   // loop on sectors

0209   for( int ii=1; ii<=nsectors; ii++ )
0210     {
0211       TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iSector, ii );
0212       assert( g_!=0 );
0213       TString gname = "Sector_"; gname += ii;
0214       g_->SetName( gname );
0215       g_->Write();
0216       
0217       // determine the histogram boundaries

0218       double xmin=101;
0219       double xmax=-1;
0220       double ymin=101;
0221       double ymax=-1;
0222       for( int jj=0; jj<g_->GetN(); jj++ )
0223     {
0224       double x,y;
0225       g_->GetPoint( jj, x, y );
0226       if( x<xmin ) xmin=x;
0227       if( x>xmax ) xmax=x;
0228       if( y<ymin ) ymin=y;
0229       if( y>ymax ) ymax=y;
0230     }
0231       xmin -=5;
0232       xmax +=5;
0233       ymin -=5;
0234       ymax +=5;
0235 
0236       TString hname0("eem_S");
0237       hname0 += ii;
0238       eem_loc[ii] = new TH2F( hname0, hname0, 
0239                   (int)(xmax-xmin), (float) xmin, (float) xmax, 
0240                   (int)(ymax-ymin), (float) ymin, (float) ymax );
0241       MECanvasHolder::setHistoStyle( eem_loc[ii] );
0242       
0243       TString hname;
0244       hname = hname0; hname += "_lmmod";
0245       eem_loc_lmmod[ii] = (TH2*) eem_loc[ii]->Clone( hname );
0246       hname = hname0; hname += "_sc";
0247       eem_loc_sc[ii] = (TH2*) eem_loc[ii]->Clone( hname );
0248       hname = hname0; hname += "_cr";
0249       eem_loc_cr[ii] = (TH2*) eem_loc[ii]->Clone( hname );
0250 
0251     }
0252 
0253   for( int ii=1; ii<=nlmregions; ii++ )
0254     {
0255       int lmr_ = ii;
0256       if( iz==-1 ) lmr_+=82;
0257       else if( iz==+1 ) lmr_+=72;
0258       else abort();
0259       TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMRegion, lmr_, iz );
0260       assert( g_!=0 );
0261       TString gname = "LMRegion_"; gname += ii;
0262       g_->SetName( gname );
0263       g_->Write();
0264     }
0265 
0266   for( int ii=1; ii<=nquadrants; ii++ )
0267     {
0268       TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iQuadrant, ii );
0269       assert( g_!=0 );
0270       TString gname = "Quadrant_"; gname += ii;
0271       g_->SetName( gname );
0272       g_->Write();
0273     }
0274 
0275   for( int xside=1; xside<=2; xside++ )
0276     {
0277       for( int ilmmod=1; ilmmod<=nlmmodules; ilmmod++ )
0278     {
0279       TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, ilmmod, iz, xside );
0280       if( g_==0 ) continue;
0281       TString gname = "LMModule_"; gname += ilmmod; gname += "_"; gname += xside;
0282       g_->SetName( gname );
0283       g_->Write();
0284     }
0285     }
0286 
0287   for( int ix=1; ix<=100; ix++ )
0288     {
0289       for( int iy=1; iy<=100; iy++ )
0290     {     
0291       int icr = MEEEGeom::crystal( ix, iy );
0292       bool ok = icr>0;
0293       if( !ok ) 
0294         continue;
0295 
0296       int icr_in_sc = MEEEGeom::crystal_in_sc( ix, iy );
0297       
0298       int iX = (ix-1)/5+1;
0299       int iY = (iy-1)/5+1;
0300       
0301       int isect = MEEEGeom::sector( iX, iY );
0302       assert( isect>=1 && isect<=nsectors );
0303       
0304       int iquad = MEEEGeom::quadrant( iX, iY );
0305       assert( iquad>0 );
0306       
0307       int isc   = MEEEGeom::sc( iX, iY );
0308       assert( isc>0 );
0309       
0310       int ilmmod = MEEEGeom::lmmod( iX, iY );
0311       assert( ilmmod>0 );
0312       
0313       int idcc= MEEEGeom::dcc( iX, iY, iz );
0314       assert( idcc>0 );
0315       
0316       int ilmr= MEEEGeom::lmr( iX, iY, iz );
0317       assert( ilmr>0 );
0318 
0319       eem_sect  -> Fill( ix, iy, isect  );
0320       eem_quad  -> Fill( ix, iy, iquad  );
0321       eem_sc    -> Fill( ix, iy, isc    );
0322       eem_lmmod -> Fill( ix, iy, ilmmod );
0323       eem_dcc   -> Fill( ix, iy, idcc   );
0324       eem_lmr   -> Fill( ix, iy, ilmr   );
0325       eem_cr    -> Fill( ix, iy, icr    );
0326       eem_cr_in_sc   -> Fill( ix, iy, icr_in_sc  );
0327 
0328       eem_loc_lmmod[isect] -> Fill( ix, iy, ilmmod );
0329       eem_loc_sc[isect]    -> Fill( ix, iy, isc );
0330       eem_loc_cr[isect]    -> Fill( ix, iy, icr );
0331     }
0332     }
0333 
0334   eem->Write();
0335   eem_sect->Write();
0336   eem_quad->Write();
0337   eem_sc->Write();
0338   eem_lmmod->Write();
0339   eem_dcc->Write();
0340   eem_lmr->Write();
0341   eem_cr->Write();
0342   eem_cr_in_sc->Write();
0343 
0344   for( int isect=1; isect<=nsectors; isect++ )
0345     {
0346       eem_loc[isect]->Write();
0347       eem_loc_lmmod[isect]->Write();
0348       eem_loc_sc[isect]->Write();
0349       eem_loc_cr[isect]->Write();
0350     }
0351 
0352   test->Close();
0353 
0354 }
0355 
0356 void writeEEGeom()
0357 {
0358   //  int iz=-1;

0359   const int nsectors   =  9;
0360   const int nlmregions = 10;
0361   const int nlmmodules = 19;
0362   const int nquadrants =  4;
0363 
0364   TString fname = "eegeom"; 
0365   fname += ".root";
0366   TFile* test= new TFile( fname, "RECREATE" );
0367 
0368   //  list< pair<int,int> > l;

0369 
0370   TH2* ee          = new TH2F( "ee", "ee", 110,-4.5,105.5,211,-105.5,105.5 );
0371   MECanvasHolder::setHistoStyle( ee );
0372   TH2* ee_sect     = (TH2*) ee->Clone( "ee_sect" );
0373   TH2* ee_quad     = (TH2*) ee->Clone( "ee_quad" );
0374   TH2* ee_sc       = (TH2*) ee->Clone( "ee_sc" );
0375   TH2* ee_lmmod    = (TH2*) ee->Clone( "ee_lmmod" );
0376   TH2* ee_dcc      = (TH2*) ee->Clone( "ee_dcc" );
0377   TH2* ee_lmr      = (TH2*) ee->Clone( "ee_lmr" );
0378   TH2* ee_cr       = (TH2*) ee->Clone( "ee_cr" );
0379   TH2* ee_cr_in_sc = (TH2*) ee->Clone( "ee_cr_in_sc" );
0380 
0381   TH2* ee_loc[2*nsectors+1];
0382   TH2* ee_loc_lmmod[2*nsectors+1];
0383   TH2* ee_loc_cr[2*nsectors+1];
0384   TH2* ee_loc_sc[2*nsectors+1];
0385 
0386   for( int kk=0; kk<2; kk++ )
0387     {
0388       int iz = 1 - 2*kk;
0389       // kk=0 EEP, kk=1 EEM

0390       // loop on sectors

0391       for( int ii=1; ii<=nsectors; ii++ )
0392     {
0393       int isect = ii + kk*nsectors;
0394       TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iSector, ii );
0395       assert( g_!=0 );
0396       for( int jj=0; jj<g_->GetN(); jj++ )
0397         {
0398           double x,y;
0399           g_->GetPoint( jj, x, y );
0400           g_->SetPoint( jj, x, iz*y );
0401         }
0402       TString gname = "Sector_"; gname += isect;
0403       g_->SetName( gname );
0404       g_->Write();
0405       
0406       // determine the histogram boundaries

0407       double xmin=101;
0408       double xmax=-1;
0409       double ymin=101;
0410       double ymax=-101;
0411       for( int jj=0; jj<g_->GetN(); jj++ )
0412         {
0413           double x,y;
0414           g_->GetPoint( jj, x, y );
0415           if( x<xmin ) xmin=x;
0416           if( x>xmax ) xmax=x;
0417           if( y<ymin ) ymin=y;
0418           if( y>ymax ) ymax=y;
0419         }
0420       xmin -=5;
0421       xmax +=5;
0422       ymin -=5;
0423       ymax +=5;
0424 
0425       TString hname0("ee_S");
0426       hname0 += isect;
0427       ee_loc[isect] = new TH2F( hname0, hname0, 
0428                      (int)(xmax-xmin), (float) xmin, (float) xmax, 
0429                      (int)(ymax-ymin), (float) ymin, (float) ymax );
0430       MECanvasHolder::setHistoStyle( ee_loc[isect] );
0431       
0432       TString hname;
0433       hname = hname0; hname += "_lmmod";
0434       ee_loc_lmmod[isect] = (TH2*) ee_loc[isect]->Clone( hname );
0435       hname = hname0; hname += "_sc";
0436       ee_loc_sc[isect] = (TH2*) ee_loc[isect]->Clone( hname );
0437       hname = hname0; hname += "_cr";
0438       ee_loc_cr[isect] = (TH2*) ee_loc[isect]->Clone( hname );
0439 
0440     }
0441 
0442       //      if( 1 ) continue;

0443 
0444 
0445 
0446       for( int ii=1; ii<=nlmregions; ii++ )
0447     {
0448       int lmr_ = 72+ii+kk*nlmregions;
0449       TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMRegion, lmr_, iz );
0450       assert( g_!=0 );
0451       for( int jj=0; jj<g_->GetN(); jj++ )
0452         {
0453           double x,y;
0454           g_->GetPoint( jj, x, y );
0455           g_->SetPoint( jj, x, iz*y );
0456         }
0457       TString gname = "LMRegion_"; gname += lmr_;
0458       g_->SetName( gname );
0459       g_->Write();
0460     }
0461 
0462       for( int ii=1; ii<=nquadrants; ii++ )
0463     {
0464       int quad_ = ii+kk*nquadrants;
0465       TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iQuadrant, ii );
0466       assert( g_!=0 );
0467       for( int jj=0; jj<g_->GetN(); jj++ )
0468         {
0469           double x,y;
0470           g_->GetPoint( jj, x, y );
0471           g_->SetPoint( jj, x, iz*y );
0472         }
0473       TString gname = "Quadrant_"; gname += quad_;
0474       g_->SetName( gname );
0475       g_->Write();
0476     }
0477 
0478       for( int xside=1; xside<=2; xside++ )
0479     {
0480       for( int ilmmod=1; ilmmod<=nlmmodules; ilmmod++ )
0481         {
0482           int mod_ = ilmmod + kk*nlmmodules;
0483           TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, ilmmod, iz, xside );
0484           if( g_==0 ) continue;
0485           for( int jj=0; jj<g_->GetN(); jj++ )
0486         {
0487           double x,y;
0488           g_->GetPoint( jj, x, y );
0489           g_->SetPoint( jj, x, iz*y );
0490         }
0491           TString gname = "LMModule_"; gname += mod_; gname += "_"; gname += xside;
0492           g_->SetName( gname );
0493           g_->Write();
0494         }
0495     }
0496 
0497       for( int ix=1; ix<=100; ix++ )
0498     {
0499       for( int iy=1; iy<=100; iy++ )
0500         {     
0501           int icr = MEEEGeom::crystal( ix, iy );
0502           bool ok = icr>0;
0503           if( !ok ) 
0504         continue;
0505 
0506           int icr_in_sc = MEEEGeom::crystal_in_sc( ix, iy );
0507       
0508           int iX = (ix-1)/5+1;
0509           int iY = (iy-1)/5+1;
0510       
0511           int isect = MEEEGeom::sector( iX, iY );
0512           assert( isect>=1 && isect<=nsectors );
0513           int sect_ = isect+kk*nsectors;
0514       
0515           int iquad = MEEEGeom::quadrant( iX, iY );
0516           assert( iquad>0 );
0517       
0518           int isc   = MEEEGeom::sc( iX, iY );
0519           assert( isc>0 );
0520       
0521           int ilmmod = MEEEGeom::lmmod( iX, iY );
0522           assert( ilmmod>0 );
0523       
0524           int idcc= MEEEGeom::dcc( iX, iY, iz );
0525           assert( idcc>0 );
0526       
0527           int ilmr= MEEEGeom::lmr( iX, iY, iz );
0528           assert( ilmr>0 );
0529 
0530           ee_sect  -> Fill( ix, iz*iy, isect  );
0531           ee_quad  -> Fill( ix, iz*iy, iquad  );
0532           ee_sc    -> Fill( ix, iz*iy, isc    );
0533           ee_lmmod -> Fill( ix, iz*iy, ilmmod );
0534           ee_dcc   -> Fill( ix, iz*iy, idcc   );
0535           ee_lmr   -> Fill( ix, iz*iy, ilmr   );
0536           ee_cr    -> Fill( ix, iz*iy, icr    );
0537           ee_cr_in_sc   -> Fill( ix, iz*iy, icr_in_sc  );
0538 
0539           ee_loc_lmmod[sect_] -> Fill( ix, iz*iy, ilmmod );
0540           ee_loc_sc[sect_]    -> Fill( ix, iz*iy, isc );
0541           ee_loc_cr[sect_]    -> Fill( ix, iz*iy, icr );
0542         }
0543     }
0544     }
0545 
0546   ee->Write();
0547   ee_sect->Write();
0548   ee_quad->Write();
0549   ee_sc->Write();
0550   ee_lmmod->Write();
0551   ee_dcc->Write();
0552   ee_lmr->Write();
0553   ee_cr->Write();
0554   ee_cr_in_sc->Write();
0555 
0556   for( int isect=1; isect<=2*nsectors; isect++ )
0557     {
0558       ee_loc[isect]->Write();
0559       ee_loc_lmmod[isect]->Write();
0560       ee_loc_sc[isect]->Write();
0561       ee_loc_cr[isect]->Write();
0562     }
0563 
0564   test->Close();
0565 
0566 }
0567 
0568 void writeGeom()
0569 {
0570   TFile* test= new TFile( "ecalgeom.root", "RECREATE" );
0571 
0572   //  list< pair<int,int> > l;

0573 
0574   TH2* ecal_sm            = MEGeom::getGlobalHist( "Sectors" );
0575   TH2* ecal_lmr           = MEGeom::getGlobalHist( "MonitoringRegions" );
0576 
0577   MECanvasHolder::setHistoStyle( ecal_sm );
0578   MECanvasHolder::setHistoStyle( ecal_lmr );
0579 
0580   for( int ieta=-85; ieta<=85; ieta++ )
0581     {
0582       if( ieta==0 ) continue;
0583       for( int iphi=1; iphi<=360; iphi++ )
0584     {     
0585 
0586       int ism = MEEBGeom::sm( ieta, iphi );
0587       assert( ism>0 );
0588 
0589       int ilmr = MEEBGeom::lmr( ieta, iphi );
0590       assert( ilmr>0 );
0591 
0592       MEGeom::setBinGlobalHist( ecal_sm,  ieta, iphi, 0, (float)ism  );
0593       MEGeom::setBinGlobalHist( ecal_lmr, ieta, iphi, 0, (float)ilmr );
0594     }
0595     }
0596 
0597   for( int iz=-1; iz<=1; iz+=2 )
0598     { 
0599       for( int ix=1; ix<=100; ix++ )
0600     {
0601       for( int iy=1; iy<=100; iy++ )
0602         {     
0603           int icr = MEEEGeom::crystal( ix, iy );
0604           bool ok = icr>0;
0605           if( !ok ) 
0606         continue;
0607           
0608           int iX = (ix-1)/5+1;
0609           int iY = (iy-1)/5+1;
0610           
0611           int isect = MEEEGeom::sector( iX, iY );
0612           int ilmr  = MEEEGeom::lmr( iX, iY, iz );
0613           
0614           MEGeom::setBinGlobalHist( ecal_sm,  ix, iy, iz, (float)isect ); 
0615           MEGeom::setBinGlobalHist( ecal_lmr, ix, iy, iz, (float)ilmr  ); 
0616 
0617         }
0618     }
0619     }
0620 
0621   ecal_sm->Write();
0622   ecal_lmr->Write();
0623   test->Close();
0624 }
0625 
0626 int main(int argc, char **argv)
0627 {
0628 
0629   //  std::ofstream o("eenum.txt");

0630 
0631   //

0632   // Test that the geometry corresponds to that of EEDetId

0633   //

0634   //   for( int iz=+1; iz>=-1; iz-=2 )

0635   //     {

0636   //       for( int ix=1; ix<=100; ix++ )

0637   //    {

0638   //      for( int iy=1; iy<=100; iy++ )

0639   //        {

0640   //          //          bool ok = EEDetId::validDetId( ix, iy, iz ); 

0641   //          int icr = MEEEGeom::crystal( ix, iy );

0642   //          bool ok = icr>=0;

0643   //          if( !ok ) 

0644   //        {

0645   //          //          assert( icr<0 );

0646   //          continue;

0647   //        }

0648   //          //          EEDetId id( ix, iy, iz );

0649   //          //          EEDetId id_sc( id.isc(), id.ic(), iz, 1 );

0650 
0651   //          int icr_in_sc = MEEEGeom::crystal_in_sc( ix, iy );

0652           
0653   //          int iX = (ix-1)/5+1;

0654   //          int iY = (iy-1)/5+1;

0655 
0656   //          int isect = MEEEGeom::sector( iX, iY );

0657   //          assert( isect!=0 );

0658   //          if( isect<0 ) continue;

0659 
0660   //          int iquad = MEEEGeom::quadrant( iX, iY );

0661   //          //          int idee  = MEEEGeom::dee( iX, iY, iz );

0662   //          int isc   = MEEEGeom::sc( iX, iY );

0663   //          assert( isc>0 );

0664 
0665   //          int ilmmod = MEEEGeom::lmmod( iX, iY );

0666   //          assert( ilmmod>0 );

0667 
0668   //          int idcc= MEEEGeom::dcc( iX, iY, iz );

0669   //          assert( idcc>0 );

0670 
0671   //          int ilmr= MEEEGeom::lmr( iX, iY, iz );

0672   //          assert( ilmr>0 );

0673 
0674   //          o << "ix=" << id.ix();

0675   //          o << "\tiy=" << id.iy();

0676   //          o << "\tiz=" << id.zside();

0677   //          o << "\tisc=" << id.isc();

0678   //          o << "\tic=" << id.ic();

0679   //          o << "\tiquad=" << id.iquadrant();

0680   //          o << endl;

0681   //          o << "ix=" << id_sc.ix();

0682   //          o << "\tiy=" << id_sc.iy();

0683   //          o << "\tiz=" << id_sc.zside();

0684   //          o << "\tisc=" << id_sc.isc();

0685   //          o << "\tic=" << id_sc.ic();

0686   //          o << "\tiquad=" << id_sc.iquadrant();

0687   //          o << endl;

0688 
0689   //          assert( id.ix()==id_sc.ix() );

0690   //          assert( id.iy()==id_sc.iy() );

0691   //          assert( id.zside()==id_sc.zside() );

0692   //          assert( id.isc()==id_sc.isc() );

0693   //          assert( id.ic()==id_sc.ic() );

0694   //          assert( id.iquadrant()==id_sc.iquadrant() );

0695   //          assert( ix==id.ix() );

0696   //          assert( iy==id.iy() );

0697   //          assert( iz==id.zside() );

0698   //          assert( isc==id.isc() );

0699   //          assert( icr_in_sc==id.ic() );

0700   //          assert( iquad==id.iquadrant() );

0701 
0702   //          o << " x=" << ix;

0703   //          o << "\t y=" << iy;

0704   //          o << "\t z=" << iz;

0705   //          o << "\t sc=" << isc;

0706   //          o << "\t c=" << icr_in_sc;          

0707   //          o << "\tdee=" << idee;

0708   //          o << "\tquad=" << iquad;

0709   //          o << "\tsect=" << isect;

0710   //          o << "\tlmmod=" << ilmmod;

0711   //          o << "\tdcc=" << idcc;

0712   //          o << "\tlmr=" << ilmr;

0713   //          o << endl;

0714   //        }

0715   //    }      

0716   //    }

0717 
0718   writeEEGeom( -1 );
0719   writeEBGeom();
0720   writeEEGeom( +1 );
0721   writeEEGeom();
0722   writeGeom();
0723 
0724   //   const int nlmregions      =  92;

0725 
0726   //   for ( int ii=1; ii<=nlmregions; ii++ )

0727   //     {

0728   //       TH2* h_ = MEGeom::getHist( ii, MEGeom::iSuperCrystal );

0729   //       assert( h_!=0 );

0730   //       h_->Print();

0731   //       cout << h_->GetTitle() << endl;

0732   //     }

0733 
0734   //   for( int ii=0; ii<ME::iSizeC; ii++ )

0735   //     {

0736   //       cout << ME::color[ii] << endl;

0737   //     }

0738 
0739   
0740   return(0);
0741 }
0742