00001
00002
00003 #include "VisFramework/VisEventSetup/interface/VisEventSetupContent.h"
00004 #include "VisFramework/VisEventSetup/interface/VisEventSetupService.h"
00005 #include "VisFramework/VisEventSetup/interface/VisCaloGeometryTwig.h"
00006 #include "VisFramework/VisEventSetup/interface/VisCSCGeometryTwig.h"
00007 #include "VisFramework/VisEventSetup/interface/VisDTGeometryTwig.h"
00008 #include "VisFramework/VisEventSetup/interface/VisRPCGeometryTwig.h"
00009 #include "VisFramework/VisEventSetup/interface/VisTrackerGeometryTwig.h"
00010 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00011 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00012 #include "Iguana/Studio/interface/IgDocumentData.h"
00013 #include "Iguana/Framework/interface/IgTwig.h"
00014 #include "Iguana/Studio/interface/IgQtLock.h"
00015 #include <qstring.h>
00016 #include <classlib/utils/Callback.h>
00017
00018
00019
00020
00021
00022
00023
00024
00025 IG_DEFINE_STATE_ELEMENT (VisEventSetupContent, "Data/Framework/EventSetup");
00026
00027
00028
00029
00030
00031 VisEventSetupContent::VisEventSetupContent (IgState *state)
00032 : VisContent (state, s_key, MAIN_THREAD,
00033 lat::CreateCallback (this, &VisEventSetupContent::init))
00034 {}
00035
00036 void
00037 VisEventSetupContent::init (void)
00038 {
00039 IgQtLock ();
00040
00041 VisEventSetupService *esService = VisEventSetupService::get (state ());
00042 if (! esService)
00043 {
00044 esService = new VisEventSetupService (state ());
00045 }
00046
00047 IgTwig *rootTwig = IgDocumentData::get (state ())->root ();
00048 IgTwig *topTwig = 0;
00049 IgTwig *detTwig = 0;
00050
00051 topTwig = rootTwig->lookup ("CMS Event and Detector");
00052 if (!topTwig) topTwig = new IgSimpleTwig (rootTwig, "CMS Event and Detector");
00053 detTwig = new IgSimpleTwig (topTwig, "Reco Detector");
00054 detTwig->cascade (false);
00055
00056 std::vector<std::string> twigs (4);
00057 twigs.push_back ("CaloGeometry");
00058 twigs.push_back ("CSCGeometry");
00059 twigs.push_back ("DTGeometry");
00060 twigs.push_back ("RPCGeometry");
00061 twigs.push_back ("TrackerGeometry");
00062
00063 const edm::ParameterSet *pset = VisConfigurationService::pSet ();
00064 if (pset)
00065 {
00066 twigs = pset->getUntrackedParameter<std::vector<std::string> > ("VisEventSetup", twigs);
00067 }
00068
00069 if (std::find (twigs.begin (), twigs.end (), "CaloGeometry") != twigs.end ())
00070 {
00071 VisCaloGeometryTwig *caloDetTwig = new VisCaloGeometryTwig (state (), detTwig, "Calo");
00072 buildCalo (caloDetTwig);
00073 caloDetTwig->cascade (false);
00074 caloDetTwig->selfVisible (true);
00075 }
00076
00077 if (std::find (twigs.begin (), twigs.end (), "CSCGeometry") != twigs.end ())
00078 {
00079 VisCSCGeometryTwig *cscDetTwig = new VisCSCGeometryTwig (state (), detTwig, "CSCs");
00080 buildCSCs (cscDetTwig);
00081 cscDetTwig->cascade (false);
00082 }
00083
00084 if (std::find (twigs.begin (), twigs.end (), "DTGeometry") != twigs.end ())
00085 {
00086 VisDTGeometryTwig *dtDetTwig = new VisDTGeometryTwig (state (), detTwig, "DTs");
00087 buildDTs (dtDetTwig);
00088 dtDetTwig->cascade (false);
00089 }
00090
00091 if (std::find (twigs.begin (), twigs.end (), "RPCGeometry") != twigs.end ())
00092 {
00093 VisRPCGeometryTwig *rpcDetTwig = new VisRPCGeometryTwig (state (), detTwig, "RPCs");
00094 buildRPCs (rpcDetTwig);
00095 rpcDetTwig->cascade (false);
00096 }
00097
00098 if (std::find (twigs.begin (), twigs.end (), "TrackerGeometry") != twigs.end ())
00099 {
00100 VisTrackerGeometryTwig *trackerDetTwig = new VisTrackerGeometryTwig (state (), detTwig, "Tracker");
00101 buildTracker (trackerDetTwig);
00102 trackerDetTwig->cascade (false);
00103 }
00104 }
00105
00106 void
00107 VisEventSetupContent::buildCalo (IgTwig *twig)
00108 {
00109 new VisCaloGeometryTwig (state (), twig, "Hcal Barrel", "Hcal", HcalBarrel);
00110 new VisCaloGeometryTwig (state (), twig, "Hcal Endcap", "Hcal", HcalEndcap);
00111 new VisCaloGeometryTwig (state (), twig, "Hcal Outer", "Hcal", HcalOuter);
00112 new VisCaloGeometryTwig (state (), twig, "Hcal Forward", "Hcal", HcalForward);
00113
00114 new VisCaloGeometryTwig (state (), twig, "Ecal Barrel", "Ecal", EcalBarrel);
00115 new VisCaloGeometryTwig (state (), twig, "Ecal Endcap", "Ecal", EcalEndcap);
00116 }
00117
00118 void
00119 VisEventSetupContent::buildCSCs (IgTwig *twig)
00120 {
00121 std::string ename ("Endcap ");
00122 std::string sname ("Station ");
00123 std::string rname ("Ring ");
00124 std::string cname ("Chamber ");
00125 int nChambers = 36;
00126
00127 for (int e = 1; e <= 2; ++e)
00128 {
00129 VisCSCGeometryTwig *endcapDetTwig = new VisCSCGeometryTwig (state (), twig, ename + QString ("%1").arg (e).latin1 (), e);
00130 for (int s = 1; s <= 4; ++s)
00131 {
00132 VisCSCGeometryTwig *stationDetTwig = new VisCSCGeometryTwig (state (), endcapDetTwig, sname + QString ("%1").arg (s).latin1 (), e, s);
00133 int nRings = 4;
00134
00135 if (s == 2 || s == 3) nRings = 2;
00136 if (s == 4) nRings = 1;
00137
00138 for (int r = 1; r <= nRings; ++r)
00139 {
00140 VisCSCGeometryTwig *ringDetTwig = new VisCSCGeometryTwig (state (), stationDetTwig, rname + QString ("%1").arg (r).latin1 (), e, s, r);
00141
00142 ((s == 2 && r == 1) || (s == 3 && r == 1) || (s == 4 && r == 1)) ? nChambers = 18 : nChambers = 36;
00143
00144 for (int c = 1; c <= nChambers; ++c)
00145 {
00146 new VisCSCGeometryTwig (state (), ringDetTwig, cname + QString ("%1").arg (c).latin1 (), e, s, r, c);
00147 }
00148 ringDetTwig->cascade (false);
00149 }
00150 stationDetTwig->cascade (false);
00151 }
00152 endcapDetTwig->cascade (false);
00153 }
00154 }
00155
00156 void
00157 VisEventSetupContent::buildDTs (IgTwig *twig)
00158 {
00159 std::string wname ("Wheel ");
00160 std::string stname ("Station ");
00161 std::string sename ("Sector ");
00162
00163 VisDTGeometryTwig *wheelDetTwig;
00164 VisDTGeometryTwig *stationDetTwig;
00165 VisDTGeometryTwig *sectorDetTwig;
00166
00167 for (int w = -2; w <= +2; ++w)
00168 {
00169 wheelDetTwig = new VisDTGeometryTwig (state (), twig, wname + QString ("%1").arg (w).latin1 (), w);
00170 for (int se = 1; se <= 14; ++se)
00171 {
00172 sectorDetTwig = new VisDTGeometryTwig (state (), wheelDetTwig, sename + QString ("%1").arg (se).latin1 (), w, se);
00173 for (int st = 1; st <= 4; ++st)
00174 {
00175 stationDetTwig = new VisDTGeometryTwig (state (), sectorDetTwig, stname + QString ("%1").arg (st).latin1 (), w, se, st);
00176 stationDetTwig->cascade (false);
00177 }
00178 sectorDetTwig->cascade (false);
00179 }
00180 wheelDetTwig->cascade (false);
00181 }
00182 }
00183
00184 void
00185 VisEventSetupContent::buildRPCs (IgTwig *twig)
00186 {
00187 std::string bname ("Barrel ");
00188 std::string ename ("Endcap ");
00189 std::string wname ("Wheel ");
00190 std::string sename ("Sector ");
00191 std::string stname ("Station ");
00192
00193 VisRPCGeometryTwig *barrelDetTwig = 0;
00194 VisRPCGeometryTwig *endcapDetTwig = 0;
00195 VisRPCGeometryTwig *rpcWheelDetTwig = 0;
00196 VisRPCGeometryTwig *rpcStationDetTwig = 0;
00197 VisRPCGeometryTwig *rpcSectorDetTwig = 0;
00198
00199 int r = 0;
00200 barrelDetTwig = new VisRPCGeometryTwig (state (), twig, "Barrel", r);
00201
00202 for (int w = -2; w <= +2; ++w)
00203 {
00204 rpcWheelDetTwig = new VisRPCGeometryTwig (state (), barrelDetTwig, wname + QString ("%1").arg (w).latin1 (), r, w);
00205 int nSector = 12;
00206
00207 for (int se = 1; se <= nSector; ++se)
00208 {
00209 rpcSectorDetTwig = new VisRPCGeometryTwig (state (), rpcWheelDetTwig, sename + QString ("%1").arg (se).latin1 (), r, w, se);
00210 for (int st = 1; st <= 4; ++st)
00211 {
00212 rpcStationDetTwig = new VisRPCGeometryTwig (state (), rpcSectorDetTwig, stname + QString ("%1").arg (st).latin1 (), r, w, se, st);
00213 rpcStationDetTwig->cascade (false);
00214 }
00215 rpcSectorDetTwig->cascade (false);
00216 }
00217 rpcWheelDetTwig->cascade (false);
00218 }
00219 barrelDetTwig->cascade (false);
00220
00221 for (r = -1; r <=1; r += 2)
00222 {
00223 endcapDetTwig = new VisRPCGeometryTwig (state (), twig, ename + QString ("%1").arg (r).latin1 (), r);
00224 for (int w = 2; w <= 3; ++w)
00225 {
00226 rpcWheelDetTwig = new VisRPCGeometryTwig (state (), endcapDetTwig, wname + QString ("%1").arg (w).latin1 (), r, w);
00227 int nSector = 6;
00228 for (int se = 1; se <= nSector; ++se)
00229 {
00230 rpcSectorDetTwig = new VisRPCGeometryTwig (state (), rpcWheelDetTwig, sename + QString ("%1").arg (se).latin1 (), r, w, se);
00231 for (int st = 1; st <= 3; ++st)
00232 {
00233 rpcStationDetTwig = new VisRPCGeometryTwig (state (), rpcSectorDetTwig, stname + QString ("%1").arg (st).latin1 (), r, w, se, st);
00234 rpcStationDetTwig->cascade (false);
00235 }
00236 rpcSectorDetTwig->cascade (false);
00237 }
00238 rpcWheelDetTwig->cascade (false);
00239 }
00240 endcapDetTwig->cascade (false);
00241 }
00242 }
00243
00244 void
00245 VisEventSetupContent::buildTracker (IgTwig *twig)
00246 {
00247 new VisTrackerGeometryTwig (state (), twig, "PixelBarrel");
00248 new VisTrackerGeometryTwig (state (), twig, "PixelEndcap");
00249 new VisTrackerGeometryTwig (state (), twig, "TIB");
00250 new VisTrackerGeometryTwig (state (), twig, "TOB");
00251 new VisTrackerGeometryTwig (state (), twig, "TID");
00252 new VisTrackerGeometryTwig (state (), twig, "TEC");
00253 }