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.*.* ] 

001 #include "LArReadoutGeometry/FCAL_ChannelMap.h"
002 #include "LArGeoFcal/FCALConstruction.h"
003 
004 #include "GeoModelKernel/GeoElement.h"
005 #include "GeoModelKernel/GeoMaterial.h"
006 #include "GeoModelKernel/GeoFullPhysVol.h"
007 #include "GeoModelKernel/GeoPhysVol.h"
008 #include "GeoModelKernel/GeoVPhysVol.h"
009 #include "GeoModelKernel/GeoLogVol.h"
010 #include "GeoModelKernel/GeoTransform.h"
011 #include "GeoModelKernel/GeoAlignableTransform.h"
012 #include "GeoModelKernel/GeoIdentifierTag.h"
013 #include "GeoModelKernel/GeoNameTag.h"
014 #include "GeoModelKernel/GeoSerialIdentifier.h"
015 #include "GeoModelKernel/GeoSerialTransformer.h"
016 #include "GeoModelKernel/GeoXF.h"
017 
018 // volumes used:  Pcon, Tubs, Cons, Box, Trap 
019 #include "GeoModelKernel/GeoPcon.h"
020 #include "GeoModelKernel/GeoTubs.h"
021 #include "GeoModelKernel/GeoCons.h"
022 #include "GeoModelKernel/GeoBox.h"
023 #include "GeoModelKernel/GeoTrap.h"
024 #include "StoreGate/StoreGateSvc.h"
025 #include "StoreGate/DataHandle.h"
026 #include "GeoModelSvc/AbsMaterialManager.h"
027 #include "GeoModelSvc/DecodeVersionKey.h"
028 #include "GeoModelSvc/StoredMaterialManager.h"
029 #include "GeoModelSvc/IGeoModelSvc.h"
030 #include "GeoModelSvc/StoredPhysVol.h"
031 #include "GeoModelSvc/StoredAlignX.h"
032 #include "GeoModelSvc/GeoDBUtils.h"
033 
034 // For transforms:
035 #include "CLHEP/Geometry/Transform3D.h"
036 #include "CLHEP/Vector/Rotation.h"
037 // For functions:
038 #include "CLHEP/GenericFunctions/Abs.hh"
039 #include "CLHEP/GenericFunctions/Sin.hh"
040 #include "CLHEP/GenericFunctions/Cos.hh"
041 #include "CLHEP/GenericFunctions/Sqrt.hh"
042 #include "CLHEP/GenericFunctions/ATan.hh"
043 #include "CLHEP/GenericFunctions/Rectangular.hh"
044 #include "CLHEP/GenericFunctions/Mod.hh"
045 #include "CLHEP/GenericFunctions/Variable.hh"
046 #include "CLHEP/GenericFunctions/FixedConstant.hh"
047 #include "CLHEP/GenericFunctions/ArrayFunction.hh"
048 
049 #include "RDBAccessSvc/IRDBRecord.h"
050 #include "RDBAccessSvc/IRDBRecordset.h"
051 #include "RDBAccessSvc/IRDBAccessSvc.h"
052 #include "RDBAccessSvc/IRDBQuery.h"
053 
054 #include "RelationalAccess/ICursor.h"
055 #include "CoralBase/AttributeList.h"
056 #include "CoralBase/Attribute.h"
057 
058 // For units:
059 #include "CLHEP/Units/PhysicalConstants.h"
060 #include "GaudiKernel/MsgStream.h"
061 #include "GaudiKernel/Bootstrap.h"
062 #include <string>
063 #include <cmath>
064 #include <cfloat>
065 #include <sstream>
066 #include <fstream>
067 #include <stdexcept>
068 
069 #include "GaudiKernel/ISvcLocator.h"
070 #include "GaudiKernel/Bootstrap.h"
071 #include "StoreGate/StoreGateSvc.h"
072  
073 
074 struct Electrode_t {
075   std::string name;
076   unsigned int id;
077   int i;
078   int j;
079   double x;
080   double y;
081 };
082 
083 
084 struct FCALData_t
085 {
086   double      innerModuleRadius;
087   double      outerModuleRadius;
088   double      fullModuleDepth;
089   double      innerGapRadius;
090   double      outerGapRadius;
091   double      fullGapDepth;
092   int         FCalSampling;
093 };
094 
095 
096 FCALData_t fcalData[] = {
097   {7.2*cm,44.96*cm,44.42*cm,0.2355*cm,0.2622*cm,44.42*cm,1},
098   {7.9*cm,44.96*cm,44.23*cm,0.2465*cm,0.2840*cm,44.23*cm,2},
099   {8.6*cm,44.96*cm,44.23*cm,0.2750*cm,0.3250*cm,44.23*cm,3}
100 };
101 
102 //===================constructor
103 
104 LArGeo::FCALConstruction::FCALConstruction():
105   m_fcalPhysical(0),
106   m_absPhysical1(0),
107   m_absPhysical2(0),
108   m_absPhysical3(0),
109   m_VisLimit(0)
110 {
111   m_svcLocator = Gaudi::svcLocator();
112   IRDBAccessSvc* rdbAccess;
113   IGeoModelSvc * geoModel;
114   
115   if(m_svcLocator->service ("GeoModelSvc",geoModel) == StatusCode::FAILURE)
116     throw std::runtime_error("Error in FCALConstruction, cannot access GeoModelSvc");
117   if(m_svcLocator->service ("RDBAccessSvc",rdbAccess) == StatusCode::FAILURE)
118     throw std::runtime_error("Error in FCALConstruction, cannot access RDBAccessSvc");
119   DecodeVersionKey larVersionKey(geoModel, "LAr");
120 
121   IRDBQuery* _query = rdbAccess->getQuery("LArFCalElectrodes", larVersionKey.tag(),larVersionKey.node());
122 
123   if(!_query)
124   {
125     _query = rdbAccess->getQuery("LArFCalElectrodes", "LArFCalElectrodes-00");
126     if(!_query)
127       throw std::runtime_error("Error getting Session and Query pointers");
128   }
129   coral::ICursor& _cursor = _query->execute();
130 
131   // Process Query results
132   while(_cursor.next()) 
133   {
134     const coral::AttributeList& row = _cursor.currentRow();
135     
136     FcalElectrodeGeomdb* curr_electrode = new FcalElectrodeGeomdb;
137     curr_electrode->tileName  = row["LARFCALELECTRODES_DATA.TILENAME"].data<std::string>();
138 
139     // Workaround for MySQL mapping
140     if(row["LARFCALELECTRODES_DATA.I"].specification().type()==typeid(long))
141     {
142       curr_electrode->i         = row["LARFCALELECTRODES_DATA.I"].data<long>();
143       curr_electrode->j         = row["LARFCALELECTRODES_DATA.J"].data<long>();
144       
145       curr_electrode->id        = row["LARFCALELECTRODES_DATA.ID"].data<long>(); 
146       curr_electrode->modNumber = row["LARFCALELECTRODES_DATA.MODNUMBER"].data<long>();
147     }
148     else
149     {
150       curr_electrode->i         = row["LARFCALELECTRODES_DATA.I"].data<int>();
151       curr_electrode->j         = row["LARFCALELECTRODES_DATA.J"].data<int>();
152       
153       curr_electrode->id        = row["LARFCALELECTRODES_DATA.ID"].data<int>(); 
154       curr_electrode->modNumber = row["LARFCALELECTRODES_DATA.MODNUMBER"].data<int>();
155     }
156 
157     curr_electrode->x         = row["LARFCALELECTRODES_DATA.X"].data<double>();
158     curr_electrode->y         = row["LARFCALELECTRODES_DATA.Y"].data<double>();
159     curr_electrode->hvFT      = row["LARFCALELECTRODES_DATA.HVFEEDTHROUGHID"].data<std::string>();////////Gabe
160 
161     
162     m_fcalElectrodes.push_back(curr_electrode);
163   }
164 
165   _query->finalize();
166   delete _query;
167 
168   m_fcalMod = rdbAccess->getRecordset("FCalMod", larVersionKey.tag(),larVersionKey.node());
169   if (m_fcalMod->size()==0) {
170     m_fcalMod=rdbAccess->getRecordset("FCalMod", "FCalMod-00");
171     if (m_fcalMod->size()==0) {
172       throw std::runtime_error("Error getting FCAL Module parameters from database");
173     }
174   } 
175 
176   m_LArPosition  =  rdbAccess->getRecordset("LArPosition", larVersionKey.tag(), larVersionKey.node());
177   if (m_LArPosition->size()==0 ) {
178     m_LArPosition = rdbAccess->getRecordset("LArPosition", "LArPosition-00");
179     if (m_LArPosition->size()==0 ) {
180       throw std::runtime_error("Error, no lar position table in database!");
181     }
182   }
183 
184 
185 }  
186 
187 
188 //===================destructor
189 
190 LArGeo::FCALConstruction::~FCALConstruction()
191 {
192 }
193 
194 //================== get envelope
195 
196 GeoVFullPhysVol* LArGeo::FCALConstruction::GetEnvelope(bool bPos)
197 {
198 
199   // Flags to turn on volumes.
200   const bool F1=true,F2=true,F3=true;
201 
202   
203   IMessageSvc * msgSvc;
204   if (m_svcLocator->service("MessageSvc", msgSvc, true )==StatusCode::FAILURE) {
205     throw std::runtime_error("Error in FCALConstruction, cannot access MessageSvc");
206   }
207   MsgStream log(msgSvc, "FCALConstruction"); 
208   
209   log << MSG::INFO;
210   
211   log  << "++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
212   log << "+                                                  +" << std::endl;
213   log << "+         Start of FCAL GeoModel definition        +" << std::endl;
214   log << "+                                                  +" << std::endl;
215   log << "++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
216 
217   StoreGateSvc *detStore;
218   if (m_svcLocator->service("DetectorStore", detStore, false )==StatusCode::FAILURE) {
219     throw std::runtime_error("Error in FCALConstruction, cannot access DetectorStore");
220   }
221 
222 
223 
224 
225   DataHandle<StoredMaterialManager> materialManager;
226   if (StatusCode::SUCCESS != detStore->retrieve(materialManager, std::string("MATERIALS"))) return NULL;
227   
228   GeoMaterial *Copper  = materialManager->getMaterial("std::Copper");
229   if (!Copper) throw std::runtime_error("Error in FCALConstruction, std::Copper is not found.");
230   
231   GeoMaterial *Iron  = materialManager->getMaterial("std::Iron");
232   if (!Iron) throw std::runtime_error("Error in FCALConstruction, std::Iron is not found.");
233   
234   GeoMaterial *Lead  = materialManager->getMaterial("std::Lead");
235   if (!Lead) throw std::runtime_error("Error in FCALConstruction, std::Lead is not found.");
236   
237   GeoMaterial *LAr  = materialManager->getMaterial("std::LiquidArgon");
238   if (!LAr) throw std::runtime_error("Error in FCALConstruction, std::LiquidArgon is not found.");
239   
240   GeoMaterial *Air  = materialManager->getMaterial("std::Air");
241   if (!Air) throw std::runtime_error("Error in FCALConstruction, std::Air is not found.");
242   
243   GeoMaterial *Kapton  = materialManager->getMaterial("std::Kapton");
244   if (!Kapton) throw std::runtime_error("Error in FCALConstruction, std::Kapton is not found.");
245   
246   GeoMaterial *Glue  = materialManager->getMaterial("LAr::Glue");
247   if (!Glue) throw std::runtime_error("Error in FCALConstruction, LAr::Glue is not found.");
248   
249   GeoMaterial *G10  = materialManager->getMaterial("LAr::G10");
250   if (!G10) throw std::runtime_error("Error in FCALConstruction, LAr::G10 is not found.");
251   
252   
253   GeoMaterial *FCal1Absorber = materialManager->getMaterial("LAr::FCal1Absorber");
254   if (!FCal1Absorber) throw std::runtime_error("Error in FCALConstruction, LAr::FCal1Absorber is not found.");
255 
256   GeoMaterial *FCal23Absorber = materialManager->getMaterial("LAr::FCal23Absorber");
257   if (!FCal23Absorber) throw std::runtime_error("Error in FCALConstruction, LAr::FCal23Absorber is not found.");
258 
259   GeoMaterial *FCalCableHarness = materialManager->getMaterial("LAr::FCalCableHarness");
260   if (!FCalCableHarness) throw std::runtime_error("Error in FCALConstruction, LAr::FCalCableHarness is not found.");
261 
262   GeoMaterial *FCal23Slugs = materialManager->getMaterial("LAr::FCal23Slugs");
263   if (!FCal23Slugs) throw std::runtime_error("Error in FCALConstruction, LAr::FCal23Slugs is not found.");
264 
265 
266   static FCAL_ChannelMap *cmap = new FCAL_ChannelMap(0);
267 
268   GeoFullPhysVol *fcalPhysical(NULL);
269 
270   std::string baseName = "LAr::FCAL::";
271 
272   double fcalHalfDepth=0;
273   double startZFCal1 = (*m_fcalMod)[0]->getDouble("STARTPOSITION"); //466.85 * cm;
274   //double startZFCal2 = (*m_fcalMod)[1]->getDouble("STARTPOSITION"); //512.83 * cm;
275   double startZFCal3 = (*m_fcalMod)[2]->getDouble("STARTPOSITION"); //560.28 * cm;
276 
277   // FCAL VOLUME.  IT DOES NOT INCLUDE THE COPPER PLUG, ONLY THE LAR AND MODS 1-3
278   {
279 
280     double outerRadius = std::max(fcalData[0].outerModuleRadius,std::max(fcalData[1].outerModuleRadius,fcalData[2].outerModuleRadius));
281     double innerRadius = std::min(fcalData[0].innerModuleRadius,std::min(fcalData[1].innerModuleRadius,fcalData[2].innerModuleRadius));
282     double depthZFCal3 = fcalData[2].fullModuleDepth;
283     double stopZFCal3  = startZFCal3 + depthZFCal3;
284     
285     double totalDepth  = stopZFCal3 - startZFCal1;
286     double halfDepth   = totalDepth/2.;
287 
288     std::string name = baseName + "LiquidArgonC";
289     GeoTubs *tubs = new GeoTubs(innerRadius,outerRadius,halfDepth,0,360*deg);
290     GeoLogVol *logVol= new GeoLogVol(name, tubs, LAr);
291     fcalPhysical = new GeoFullPhysVol(logVol);
292 
293     fcalHalfDepth = halfDepth;
294   }
295 
296  
297 
298   if (F1) 
299     {
300       // Module 1
301       GeoFullPhysVol *modPhysical =0;
302       {
303         double halfDepth       = fcalData[0].fullModuleDepth/2;
304         double innerRadius     = fcalData[0].innerModuleRadius;
305         double outerRadius     = fcalData[0].outerModuleRadius;
306         GeoFullPhysVol *physVol;
307 
308         if(m_absPhysical1)
309           physVol = m_absPhysical1->clone();
310         else
311         {
312           GeoTubs *tubs          = new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*M_PI);
313           GeoLogVol  *logVol     = new GeoLogVol(baseName + "Module1::Absorber", tubs, FCal1Absorber);
314           physVol     = new GeoFullPhysVol(logVol);
315         }
316 
317         // Alignable transform
318         
319         const IRDBRecord *posRec = GeoDBUtils::getTransformRecord(m_LArPosition, bPos ? "FCAL1_POS":"FCAL1_NEG");
320         if (!posRec) throw std::runtime_error("Error, no lar position record in the database") ;
321         HepTransform3D xfPos = GeoDBUtils::getTransform(posRec);
322         GeoAlignableTransform *xfAbs1 = new GeoAlignableTransform(xfPos);
323         
324         fcalPhysical->add(xfAbs1);
325         if (!bPos)  fcalPhysical->add(new GeoTransform(HepRotateY3D(180*deg)));
326         fcalPhysical->add(physVol);
327         modPhysical = physVol;
328         
329         std::string tag = bPos? std::string("FCAL1_POS") : std::string("FCAL1_NEG");
330         StatusCode status;
331         
332         StoredPhysVol *sPhysVol = new StoredPhysVol(physVol);
333         status=detStore->record(sPhysVol,tag);
334         if(!status.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag).c_str());
335         
336         StoredAlignX *sAlignX = new StoredAlignX(xfAbs1);
337         status=detStore->record(sAlignX,tag);
338         if(!status.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag).c_str());
339         
340       }   
341       // 16 Troughs representing  Cable Harnesses:
342       if(m_absPhysical1==0)
343         {
344           double troughDepth       = 1.0 * cm;
345           double outerRadius       = fcalData[0].outerModuleRadius;
346           double innerRadius       = outerRadius - troughDepth;
347           double halfLength        = fcalData[0].fullModuleDepth/ 2.0;
348           double deltaPhi          = 5.625 * deg;
349           double startPhi          = 11.25 * deg - deltaPhi/2.0;
350           GeoTubs * tubs = new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,deltaPhi );
351           GeoLogVol *logVol = new GeoLogVol(baseName+"Module1::CableTrough",tubs,FCalCableHarness);
352           GeoPhysVol *physVol = new GeoPhysVol(logVol);
353           Genfun::Variable i;
354           Genfun::GENFUNCTION rotationAngle = 22.5*deg*i;
355           GeoXF::TRANSFUNCTION xf = GeoXF::Pow(HepRotateZ3D(1.0),rotationAngle);
356           GeoSerialTransformer *st = new GeoSerialTransformer(physVol,&xf,16);
357           modPhysical->add(st);
358         }
359       
360       if(m_absPhysical1==0)
361         {
362           double halfDepth    = fcalData[0].fullGapDepth/2.0;
363           double innerRadius  = fcalData[0].innerGapRadius;
364           double outerRadius  = fcalData[0].outerGapRadius;
365           GeoTubs *tubs       = new GeoTubs(innerRadius,outerRadius,halfDepth,0.0, 2.0*M_PI);
366           GeoLogVol *logVol   = new GeoLogVol(baseName + "Module1::Gap",tubs, LAr);
367           GeoPhysVol *physVol = new GeoPhysVol(logVol);
368           
369           int counter=0;
370           modPhysical->add(new GeoSerialIdentifier(0));
371           
372           
373           // Electrodes:
374           int myGroup=1;
375 
376           if (m_fcalElectrodes.size()>0) {
377             for (unsigned int i=0;i<m_fcalElectrodes.size();i++) {
378               FcalElectrodeGeomdb* electrode = m_fcalElectrodes[i];
379               
380               int    thisGroup=electrode->modNumber;
381               if (thisGroup!=myGroup) continue;
382 
383               std::string thisTileStr=electrode->tileName;
384               int    thisTubeI=electrode->i;
385               int    thisTubeJ= electrode->j;
386               int    thisTubeID = electrode->id;
387               int    thisTubeMod = electrode->modNumber;
388               double thisTubeX= electrode->x;
389               double thisTubeY= electrode->y;
390               std::string thisHVft=electrode->hvFT;////Gabe
391                 
392               cmap->add_tube(thisTileStr, thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY, thisHVft);/// Gabe: New add_tube
393               
394               if (m_VisLimit != -1 && (counter++ > m_VisLimit)) continue;
395               
396               GeoTransform *xf = new GeoTransform(HepTranslate3D(thisTubeX*cm, thisTubeY*cm,0));
397               modPhysical->add(xf);
398               modPhysical->add(physVol);
399             }
400           }
401           
402           m_absPhysical1 = modPhysical;
403         } // if (F1)
404     }
405   if (F2) 
406     {
407       // Module 2
408       GeoFullPhysVol *modPhysical =0;
409       {
410         double halfDepth       = fcalData[1].fullModuleDepth/2;
411         double innerRadius     = fcalData[1].innerModuleRadius;
412         double outerRadius     = fcalData[1].outerModuleRadius;
413         GeoFullPhysVol *physVol;
414         
415         if(m_absPhysical2)
416           physVol = m_absPhysical2->clone();
417         else
418           {
419             GeoTubs *tubs          = new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*M_PI);
420           GeoLogVol  *logVol     = new GeoLogVol(baseName + "Module2::Absorber", tubs, FCal23Absorber);
421           physVol     = new GeoFullPhysVol(logVol);
422         }
423 
424         // Alignable transform
425 
426         const IRDBRecord *posRec = GeoDBUtils::getTransformRecord(m_LArPosition, bPos ? "FCAL2_POS":"FCAL2_NEG");
427         if (!posRec) throw std::runtime_error("Error, no lar position record in the database") ;
428         HepTransform3D xfPos = GeoDBUtils::getTransform(posRec);
429         GeoAlignableTransform *xfAbs2 = new GeoAlignableTransform(xfPos);
430         
431         fcalPhysical->add(xfAbs2);
432         if (!bPos)  fcalPhysical->add(new GeoTransform(HepRotateY3D(180*deg)));
433         fcalPhysical->add(physVol);
434         modPhysical = physVol;
435         
436         std::string tag = bPos? std::string("FCAL2_POS") : std::string("FCAL2_NEG");
437         StatusCode status;
438         
439         StoredPhysVol *sPhysVol = new StoredPhysVol(physVol);
440         status=detStore->record(sPhysVol,tag);
441         if(!status.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag).c_str());
442         
443         StoredAlignX *sAlignX = new StoredAlignX(xfAbs2);
444         status=detStore->record(sAlignX,tag);
445         if(!status.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag).c_str());
446         
447       }   
448       // 16 Troughs representing  Cable Harnesses:
449       if(m_absPhysical2==0)
450         {
451           double troughDepth       = 1.0 * cm;
452           double outerRadius       = fcalData[1].outerModuleRadius;
453           double innerRadius       = outerRadius - troughDepth;
454           double halfLength        = fcalData[1].fullModuleDepth/ 2.0;
455           double deltaPhi          = 5.625 * deg;
456           double startPhi          = 11.25 * deg - deltaPhi/2.0;
457           GeoTubs * tubs = new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,deltaPhi );
458           GeoLogVol *logVol = new GeoLogVol(baseName+"Module2::CableTrough",tubs,FCalCableHarness);
459           GeoPhysVol *physVol = new GeoPhysVol(logVol);
460           Genfun::Variable i;
461           Genfun::GENFUNCTION rotationAngle = 22.5*deg*i;
462           GeoXF::TRANSFUNCTION xf = GeoXF::Pow(HepRotateZ3D(1.0),rotationAngle);
463           GeoSerialTransformer *st = new GeoSerialTransformer(physVol,&xf,16);
464           modPhysical->add(st);
465         }
466       
467       // Electrodes:
468       if(m_absPhysical2==0)
469       {
470         
471         double halfDepth    = fcalData[1].fullGapDepth/2.0;
472         double innerRadius  = fcalData[1].innerGapRadius;
473         double outerRadius  = fcalData[1].outerGapRadius;
474         
475         GeoTubs *gapTubs       = new GeoTubs(0,outerRadius,halfDepth,0.0, 2.0*M_PI);
476         GeoLogVol *gapLog      = new GeoLogVol(baseName + "Module2::Gap",gapTubs, LAr);
477         GeoPhysVol *gapPhys    = new GeoPhysVol(gapLog);
478         
479         GeoTubs *rodTubs       = new GeoTubs(0,innerRadius,halfDepth,0.0, 2.0*M_PI);
480         GeoLogVol *rodLog      = new GeoLogVol(baseName + "Module2::Rod",rodTubs, FCal23Slugs);
481         GeoPhysVol *rodPhys    = new GeoPhysVol(rodLog);
482         
483         gapPhys->add(rodPhys);
484         
485         int counter=0;
486         modPhysical->add(new GeoSerialIdentifier(0));
487         
488         int myGroup=2;
489         if (m_fcalElectrodes.size()>0) {
490           for (unsigned int i=0;i<m_fcalElectrodes.size();i++) {
491             FcalElectrodeGeomdb* electrode = m_fcalElectrodes[i];
492               
493             int    thisGroup=electrode->modNumber;
494             if (thisGroup!=myGroup) continue;
495             
496             std::string thisTileStr=electrode->tileName;
497             int    thisTubeI=electrode->i;
498             int    thisTubeJ= electrode->j;
499             int    thisTubeID = electrode->id;
500             int    thisTubeMod = electrode->modNumber;
501             double thisTubeX= electrode->x;
502             double thisTubeY= electrode->y;
503             std::string thisHVft=electrode->hvFT;///Gabe
504 
505             cmap->add_tube(thisTileStr, thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY, thisHVft);/////Gabe: new add_tube
506 
507             if (m_VisLimit!=-1 && (counter++ > m_VisLimit)) continue;
508             
509             GeoTransform *xf = new GeoTransform(HepTranslate3D(thisTubeX*cm, thisTubeY*cm,0));
510             modPhysical->add(xf);
511             modPhysical->add(gapPhys);
512           }
513         }
514         m_absPhysical2 = modPhysical;
515       }
516     } // if (F2)
517   
518   if (F3) 
519     {
520       // Module 3
521       GeoFullPhysVol *modPhysical =0;
522       {
523         double halfDepth       = fcalData[2].fullModuleDepth/2;
524         double innerRadius     = fcalData[2].innerModuleRadius;
525         double outerRadius     = fcalData[2].outerModuleRadius;
526         GeoFullPhysVol *physVol;
527 
528         if(m_absPhysical3)
529           physVol = m_absPhysical3->clone();
530         else
531         {
532           GeoTubs *tubs          = new GeoTubs( innerRadius, outerRadius, halfDepth, 0, 2*M_PI);
533           GeoLogVol  *logVol     = new GeoLogVol(baseName + "Module3::Absorber", tubs, FCal23Absorber);
534           physVol     = new GeoFullPhysVol(logVol);
535         }
536 
537         // Alignable transform
538         const IRDBRecord *posRec = GeoDBUtils::getTransformRecord(m_LArPosition, bPos ? "FCAL3_POS":"FCAL3_NEG");
539         if (!posRec) throw std::runtime_error("Error, no lar position record in the database") ;
540         HepTransform3D xfPos = GeoDBUtils::getTransform(posRec);
541         GeoAlignableTransform *xfAbs3 = new GeoAlignableTransform(xfPos);
542         
543         fcalPhysical->add(xfAbs3);
544         if (!bPos)  fcalPhysical->add(new GeoTransform(HepRotateY3D(180*deg)));
545         fcalPhysical->add(physVol);
546         modPhysical = physVol;
547 
548         std::string tag = bPos? std::string("FCAL3_POS") : std::string("FCAL3_NEG");
549         StatusCode status;
550 
551         StoredPhysVol *sPhysVol = new StoredPhysVol(physVol);
552         status=detStore->record(sPhysVol,tag);
553         if(!status.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag).c_str());
554 
555         StoredAlignX *sAlignX = new StoredAlignX(xfAbs3);
556         status=detStore->record(sAlignX,tag);
557         if(!status.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag).c_str());
558 
559         
560       }   
561       // 16 Troughs representing  Cable Harnesses:
562       if(m_absPhysical3==0)
563       {
564         
565         
566         static double rotAngles[] =
567           { 11.25 * deg,
568             22.50 * deg,
569             45.00 * deg,
570             56.25 * deg,
571             67.50 * deg,
572             90.00 * deg,  // first quarter
573             101.25 * deg,
574             112.50 * deg,
575             135.00 * deg,
576             146.25 * deg,
577             157.50 * deg,
578             180.00 * deg,  // second quarter
579             191.25 * deg,
580             202.50 * deg,
581             225.00 * deg,
582             236.25 * deg,
583             247.50 * deg,
584             270.00 * deg,  // third quarter
585             281.25 * deg,
586             292.50 * deg,
587             315.00 * deg,
588             326.25 * deg,
589             337.50 * deg,
590             360.00 * deg };
591         
592         Genfun::ArrayFunction rotationAngle(rotAngles,rotAngles+24);
593         double troughDepth       = 1.0 * cm;
594         double outerRadius       = fcalData[2].outerModuleRadius;
595         double innerRadius       = outerRadius - troughDepth;
596         double halfLength        = fcalData[2].fullModuleDepth/ 2.0;
597         double deltaPhi          = 5.625 * deg;
598         double startPhi          = 11.25 * deg - deltaPhi/2.0;
599         GeoTubs * tubs = new GeoTubs(innerRadius,outerRadius,halfLength,startPhi,deltaPhi );
600         GeoLogVol *logVol = new GeoLogVol(baseName+"Module3::CableTrough",tubs,FCalCableHarness);
601         GeoPhysVol *physVol = new GeoPhysVol(logVol);
602         GeoXF::TRANSFUNCTION xf = GeoXF::Pow(HepRotateZ3D(1.0),rotationAngle);
603         GeoSerialTransformer *st = new GeoSerialTransformer(physVol,&xf,24);
604         modPhysical->add(st);
605       }
606       
607       // Electrodes:
608       if(m_absPhysical3==0)
609       {
610         
611         
612         double halfDepth    = fcalData[2].fullGapDepth/2.0;
613         double innerRadius  = fcalData[2].innerGapRadius;
614         double outerRadius  = fcalData[2].outerGapRadius;
615         
616         GeoTubs *gapTubs       = new GeoTubs(0,outerRadius,halfDepth,0.0, 2.0*M_PI);
617         GeoLogVol *gapLog      = new GeoLogVol(baseName + "Module3::Gap",gapTubs, LAr);
618         GeoPhysVol *gapPhys    = new GeoPhysVol(gapLog);
619         
620         GeoTubs *rodTubs       = new GeoTubs(0,innerRadius,halfDepth,0.0, 2.0*M_PI);
621         GeoLogVol *rodLog      = new GeoLogVol(baseName + "Module3::Rod",rodTubs, FCal23Slugs);
622         GeoPhysVol *rodPhys    = new GeoPhysVol(rodLog);
623         
624         gapPhys->add(rodPhys);
625         
626         int counter=0;
627         modPhysical->add(new GeoSerialIdentifier(0));
628         
629         int myGroup=3;
630         if (m_fcalElectrodes.size()>0) {
631           for (unsigned int i=0;i<m_fcalElectrodes.size();i++) {
632             FcalElectrodeGeomdb* electrode = m_fcalElectrodes[i];
633             
634             int    thisGroup=electrode->modNumber;
635             if (thisGroup!=myGroup) continue;
636             
637             std::string thisTileStr=electrode->tileName;
638             int    thisTubeI=electrode->i;
639             int    thisTubeJ= electrode->j;
640             int    thisTubeID = electrode->id;
641             int    thisTubeMod = electrode->modNumber;
642             double thisTubeX= electrode->x;
643             double thisTubeY= electrode->y;
644             std::string thisHVft=electrode->hvFT;/////Gabe
645                       
646 
647             cmap->add_tube(thisTileStr, thisTubeMod, thisTubeID, thisTubeI,thisTubeJ, thisTubeX, thisTubeY, thisHVft);///Gabe" new add_tube
648 
649             
650             if (m_VisLimit!=-1 && (counter++ > m_VisLimit)) continue;
651             
652             GeoTransform *xf = new GeoTransform(HepTranslate3D(thisTubeX*cm, thisTubeY*cm,0));
653             modPhysical->add(xf);
654             modPhysical->add(gapPhys);
655           }
656         }
657         m_absPhysical3 = modPhysical;
658       }
659     } // if (F3)
660   
661   // Did I already store it?
662   //FCAL_ChannelMap *aChannelMap(NULL);
663   //  if (detStore->retrieve(aChannelMap)==StatusCode::FAILURE) {
664   if (!detStore->contains<FCAL_ChannelMap>("FCAL_ChannelMap")) {
665     cmap->finish();
666     StatusCode status=detStore->record(cmap,"FCAL_ChannelMap");
667     if(!status.isSuccess()) throw std::runtime_error ("Cannot store FCAL_ChannelMap");
668   }
669 
670   return fcalPhysical;
671   
672 }
673 
674 
675 void LArGeo::FCALConstruction::cleanMemory()
676 {
677   for(unsigned int i=0; i<m_fcalElectrodes.size(); i++)
678     delete m_fcalElectrodes[i];
679   m_fcalElectrodes.clear();
680 
681   m_fcalMod->unref();
682   if (m_LArPosition)  m_LArPosition->unref();
683 
684   m_fcalMod = 0;
685   if (m_LArPosition)  m_LArPosition = 0;
686 }

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!