SND@LHC Software
Loading...
Searching...
No Matches
ecal.cxx
Go to the documentation of this file.
1
8#include "ecal.h"
9
10#include "ecalPoint.h"
11#include "ecalLightMap.h"
12
13#include "FairGeoInterface.h"
14#include "FairGeoLoader.h"
15#include "FairGeoNode.h"
16#include "FairGeoRootBuilder.h"
17#include "FairRuntimeDb.h"
18#include "FairRootManager.h"
19#include "FairRun.h"
20#include "FairRunAna.h"
21#include "ShipStack.h"
22#include "FairVolume.h"
23#include "FairGeoMedium.h"
24#include "FairGeoMedia.h"
25
26#include "TClonesArray.h"
27#include "TGeoMCGeometry.h"
28#include "TGeoManager.h"
29#include "TParticle.h"
30#include "TVirtualMC.h"
31#include "TGeoBBox.h"
32#include "TGeoPgon.h"
33#include "TGeoTube.h"
34#include "TGeoEltu.h"
35#include "TGeoMatrix.h"
36#include "TList.h"
37
38#include <iostream>
39#include <stdlib.h>
40
41using namespace std;
42
43#define kN kNumberOfECALSensitiveVolumes
44
45// ----- Default constructor -------------------------------------------
47 : FairDetector("ECAL", kTRUE, kecal),
48 fInf(NULL),
49 fDebug(NULL),
50 fTrackID(-1),
51 fVolumeID(-1),
52 fPos(),
53 fMom(),
54 fTime(-1.),
55 fLength(-1.),
56 fELoss(-1.),
57 fPosIndex(0),
58 fEcalCollection(new TClonesArray("ecalPoint")),
59 fLiteCollection(new TClonesArray("ecalPoint")),
60 fEcalSize(),
61 fSimpleGeo(0),
62 fXSize(0),
63 fYSize(0),
64 fDX(0.),
65 fDY(0.),
66 fModuleSize(0.),
67 fZEcal(0.),
68 fSemiX(0.),
69 fSemiY(0.),
70 fThicknessLead(0.),
71 fThicknessScin(0.),
72 fThicknessTyvk(0.),
73 fThicknessLayer(0.),
74 fThicknessSteel(0.),
75 fEdging(0.),
76 fHoleRad(0.),
77 fFiberRad(0.),
78 fXCell(),
79 fYCell(),
80 fNH(),
81 fCF(),
82 fLightMapNames(),
83 fLightMaps(),
84 fNLayers(0),
85 fModuleLenght(0.),
86 fGeoScale(0.),
87 fNColumns1(0),
88 fNRows1(0),
89 fNColumns2(0),
90 fNRows2(0),
91 fNColumns(0),
92 fNRows(0),
93 fVolIdMax(0),
94 fFirstNumber(0),
95 fVolArr(),
96 fModules(),
97 fCells(),
98 fScTiles(),
99 fTileEdging(),
100 fPbTiles(),
101 fTvTiles(),
102 fHoleVol(),
103 fFiberVol(),
104 fSteelTapes(),
105 fHolePos(),
106 fModulesWithType(),
107 fRawNumber(),
108 fStructureId()
109{
110 fVerboseLevel = 1;
111
112 Int_t i;
113
114 for(i=kN-1;i>-1;i--)
115 fVolArr[i]=-1111;
116}
117// -------------------------------------------------------------------------
118
119
120
121// ----- Standard constructor ------------------------------------------
122ecal::ecal(const char* name, Bool_t active, const char* fileGeo)
123 : FairDetector(name, active, kecal),
124 fInf(NULL),
125 fDebug(NULL),
126 fTrackID(-1),
127 fVolumeID(-1),
128 fPos(),
129 fMom(),
130 fTime(-1.),
131 fLength(-1.),
132 fELoss(-1.),
133 fPosIndex(0),
134 fEcalCollection(new TClonesArray("ecalPoint")),
135 fLiteCollection(new TClonesArray("ecalPoint")),
136 fEcalSize(),
137 fSimpleGeo(0),
138 fXSize(0),
139 fYSize(0),
140 fDX(0.),
141 fDY(0.),
142 fModuleSize(0.),
143 fZEcal(0.),
144 fSemiX(0.),
145 fSemiY(0.),
146 fThicknessLead(0.),
147 fThicknessScin(0.),
148 fThicknessTyvk(0.),
149 fThicknessLayer(0.),
150 fThicknessSteel(0.),
151 fEdging(0.),
152 fHoleRad(0.),
153 fFiberRad(0.),
154 fXCell(),
155 fYCell(),
156 fNH(),
157 fCF(),
158 fLightMapNames(),
159 fLightMaps(),
160 fNLayers(0),
161 fModuleLenght(0.),
162 fGeoScale(0.),
163 fNColumns1(0),
164 fNRows1(0),
165 fNColumns2(0),
166 fNRows2(0),
167 fNColumns(0),
168 fNRows(0),
169 fVolIdMax(0),
170 fFirstNumber(0),
171 fVolArr(),
172 fModules(),
173 fCells(),
174 fScTiles(),
175 fTileEdging(),
176 fPbTiles(),
177 fTvTiles(),
178 fHoleVol(),
179 fFiberVol(),
180 fSteelTapes(),
181 fHolePos(),
182 fModulesWithType(),
183 fRawNumber(),
184 fStructureId()
185{
193 fVerboseLevel=0;
194 Int_t i;
195 Int_t j;
196 TString nm;
197 Info("ecal","Geometry is read from file %s.", fileGeo);
198 fInf=ecalInf::GetInstance(fileGeo);
199 if (fInf==NULL)
200 {
201 Fatal("ecal"," Can't read geometry from %s.", fileGeo);
202 return;
203 }
204 fGeoScale=1.;
208
210
215
218
219 fPosIndex=0;
220 fDebug="";
221
222 fSemiX=fInf->GetVariableStrict("xsemiaxis");
223 fSemiY=fInf->GetVariableStrict("ysemiaxis");
224 fHoleRad=fInf->GetVariableStrict("holeradius");
225 fFiberRad=fInf->GetVariableStrict("fiberradius");
227 fEdging=fInf->GetVariableStrict("tileedging");
228 fModuleSize=fInf->GetVariableStrict("modulesize");
229 fSimpleGeo=(Int_t)fInf->GetVariableStrict("usesimplegeo");
230 fDX=fInf->GetVariableStrict("xpos");
231 fDY=fInf->GetVariableStrict("ypos");
232
233 fInf->AddVariable("ecalversion", "1");
234 for(i=kN-1;i>-1;i--)
235 fVolArr[i]=-1111;
236
237
238 for(i=0;i<cMaxModuleType;i++)
239 {
240 fModules[i]=NULL;
241 fCells[i]=NULL;
242 fScTiles[i]=NULL;
243 fPbTiles[i]=NULL;
244 fTvTiles[i]=NULL;
245 fHolePos[i]=NULL;
246 fTileEdging[i]=NULL;
247 fModulesWithType[i]=0;
248 fLightMapNames[i]="";
249 fLightMaps[i]=NULL;
250 }
251 for(i=0;i<2;i++)
252 {
253 fSteelTapes[i]=NULL;
254 }
255 for(i=0;i<3;i++)
256 {
257 fHoleVol[i]=NULL;
258 fFiberVol[i]=NULL;
259 }
261 for(i=0;i<fInf->GetXSize();i++)
262 for(j=0;j<fInf->GetYSize();j++)
264
265 for(i=1;i<cMaxModuleType;i++)
266 {
267 if (fModulesWithType[i]==0) continue;
268 nm="cf["; nm+=i; nm+="]";
269 fCF[i]=(Int_t)fInf->GetVariableStrict(nm);
270 nm="nh[";nm+=i; nm+="]";
271 fNH[i]=(Int_t)fInf->GetVariableStrict(nm);
272 nm="lightmap["; nm+=i; nm+="]";
274 if (fLightMapNames[i]!="none")
275 {
277 Info("ecal", "Number of modules of type %d is %d (%d channels), lightmap %s", i, fModulesWithType[i], fModulesWithType[i]*i*i, fLightMapNames[i].Data());
278 }
279 else
280 fLightMaps[i]=NULL;
283 Info("ecal", "Size of cell of type %d is %f cm.", i, fXCell[i]);
284 }
285}
286
287// -------------------------------------------------------------------------
288
290{
291 FairDetector::Initialize();
292/*
293 FairRun* sim = FairRun::Instance();
294 FairRuntimeDb* rtdb=sim->GetRuntimeDb();
295 CbmGeoEcalPar *par=new CbmGeoEcalPar();
296// fInf->FillGeoPar(par,0);
297 rtdb->addContainer(par);
298*/
299}
300
301// ----- Destructor ----------------------------------------------------
303{
304 if (fEcalCollection) {
305 fEcalCollection->Delete();
306 delete fEcalCollection;
307 fEcalCollection=NULL;
308 }
309 if (fLiteCollection) {
310 fLiteCollection->Delete();
311 delete fLiteCollection;
312 fLiteCollection=NULL;
313 }
314}
315// -------------------------------------------------------------------------
316
317// ----- Private method SetEcalCuts ------------------------------------
318void ecal::SetEcalCuts(Int_t medium)
319{
321 if (fInf->GetElectronCut() > 0) {
322 gMC->Gstpar(medium,"CUTGAM",fInf->GetElectronCut());
323 gMC->Gstpar(medium,"CUTELE",fInf->GetElectronCut());
324 gMC->Gstpar(medium,"BCUTE" ,fInf->GetElectronCut());
325 gMC->Gstpar(medium,"BCUTM" ,fInf->GetElectronCut());
326 }
327
328 if (fInf->GetHadronCut() > 0) {
329 gMC->Gstpar(medium,"CUTNEU",fInf->GetHadronCut());
330 gMC->Gstpar(medium,"CUTHAD",fInf->GetHadronCut());
331 gMC->Gstpar(medium,"CUTMUO",fInf->GetHadronCut());
332 gMC->Gstpar(medium,"PPCUTM",fInf->GetHadronCut());
333 }
334 ;
335}
336// -------------------------------------------------------------------------
337
339{
340 fFirstNumber=fLiteCollection->GetEntriesFast();
341}
342
343//_____________________________________________________________________________
345{
346 Double_t edep = fELoss;
347 Double_t el=oldHit->GetEnergyLoss();
348 Double_t ttime=gMC->TrackTime()*1.0e9;
349 oldHit->SetEnergyLoss(el+edep);
350 if(ttime<oldHit->GetTime())
351 oldHit->SetTime(ttime);
352}
353
354//_____________________________________________________________________________
356{
360 FairRun* fRun = FairRun::Instance();
361// if (strcmp(fRun->GetName(),"TGeant3") == 0)
362 {
363 Int_t mediumID;
364 mediumID = gGeoManager->GetMedium("Scintillator")->GetId();
365 SetEcalCuts(mediumID);
366 mediumID = gGeoManager->GetMedium("Lead")->GetId();
367 SetEcalCuts(mediumID);
368 mediumID = gGeoManager->GetMedium("Tyvek")->GetId();
369 SetEcalCuts(mediumID);
370 mediumID = gGeoManager->GetMedium("SensVacuum")->GetId();
371 SetEcalCuts(mediumID);
372 mediumID = gGeoManager->GetMedium("ECALAir")->GetId();
373 SetEcalCuts(mediumID);
374 mediumID = gGeoManager->GetMedium("ECALFiber")->GetId();
375 SetEcalCuts(mediumID);
376 mediumID = gGeoManager->GetMedium("ECALTileEdging")->GetId();
377 SetEcalCuts(mediumID);
378 mediumID = gGeoManager->GetMedium("ECALSteel")->GetId();
379 SetEcalCuts(mediumID);
380 }
381}
382
383// ----- Public method ProcessHits --------------------------------------
384Bool_t ecal::ProcessHits(FairVolume* vol)
385{
387 TString Ecal="Ecal";
388 fELoss = gMC->Edep();
389 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
390 fTime = gMC->TrackTime()*1.0e09;
391 fLength = gMC->TrackLength();
392 Double_t bx, by, bz;
393 TParticle* bp=gMC->GetStack()->GetCurrentTrack();
394 gMC->TrackPosition(bx, by, bz);
395 Int_t volID;
396 gMC->CurrentVolID(volID);
397 //cout <<"Ecal called "<<volID<<" "<<vol->getVolumeId()<<" "<<fStructureId<<" "<<fELoss*1e10<<" "<<gGeoManager->GetVolume(vol->getVolumeId())->GetName()<<" "<<gMC->CurrentVolName()<<" "<<bz<<endl;
398 //if (vol->getVolumeId()==fStructureId) {
399 if (Ecal.CompareTo(gMC->CurrentVolName())==0) {
400 if (gMC->IsTrackEntering()) {
402 //cout <<"fill wallpoint "<<vol->getVolumeId()<<" "<<fStructureId<<" "<<fELoss*1e10<<endl;
403 ((ShipStack*)gMC->GetStack())->AddPoint(kecal, fTrackID);
404
406
407 return kTRUE;
408 } else {
409 return kFALSE;
410 }
411 }
412
413 if (fELoss<=0) return kFALSE;
414
415 if (fELoss>0)
416 {
417 Int_t i;
418 TParticle* p=gMC->GetStack()->GetCurrentTrack();
419 Double_t x, y, z;
420 Double_t px;
421 Double_t py;
422 Double_t dx;
423 Int_t mx;
424 Int_t my;
425 Int_t cell;
426 Int_t type;
427 Int_t cx;
428 Int_t cy;
429 gMC->TrackPosition(x, y, z);
430// cout << "Id: " << p->GetPdgCode() << " (" << x << ", " << y << ", ";
431// cout << z << "): ";
432// cout << endl;
433/*
434 for(i=0;i<10;i++)
435 {
436 gMC->CurrentVolOffID(i, mx); cout << i << ":" << mx << ", ";
437 }
438 cout << endl;
439*/
440 if (fSimpleGeo==0)
441 {
442 gMC->CurrentVolOffID(3, mx); mx--;
443 gMC->CurrentVolOffID(4, my); my--;
444 gMC->CurrentVolOffID(2, cell); cell--;
445 }
446 else
447 {
448 gMC->CurrentVolOffID(2, mx); mx--;
449 gMC->CurrentVolOffID(3, my); my--;
450 gMC->CurrentVolOffID(1, cell); cell--;
451 }
452 Int_t id=(my*100+mx)*100+cell+1;
453 if (id<0){
454 if (Ecal.CompareTo(gMC->CurrentVolName())==0&&fELoss<1e-19)
455 return kTRUE;
456 cout << "neg id "<<mx<<" "<<my<<" "<<cell<<" "<<gMC->CurrentVolName()<<" "<<gMC->CurrentVolOffName(1)<<" "<<gMC->CurrentVolOffName(2)<<" "<<fELoss<<" "<<fELoss*1e10<<endl;
457 }
458/*
459 Float_t rx; Float_t ry; Int_t ten;
460 GetCellCoordInf(id, rx, ry, ten); rx--; ry--;
461 type=fInf->GetType(mx, my);
462 Float_t d=fInf->GetVariableStrict("modulesize")/type;
463 if (x>rx-0.001&&x<rx+d+0.001&&y>ry-0.001&&y<ry+d+0.001)
464 {
465// cout << "+++ ";
466 ;
467 }
468 else
469 {
470 cout << mx << ", " << my << ", " << cell << endl;
471 cout << "--- ";
472 cout << "(" << x << ", " << y << ") : (" << rx << ", " << ry << ")" << endl;
473 }
474*/
475 fVolumeID=id;
476 if (fSimpleGeo==0)
477 {
478 type=fInf->GetType(mx, my);
479 cx=cell%type;
480 cy=cell/type;
481 // An old version
482 // px=mx*fModuleSize-fEcalSize[0]/2.0+cx*fModuleSize/type;
483 // py=my*fModuleSize-fEcalSize[1]/2.0+cy*fModuleSize/type;
484 // With correction for steel tapes and edging
485 px=mx*fModuleSize-fEcalSize[0]/2.0+fXCell[type]*cx+(2*cx+1)*fEdging+fThicknessSteel;
486 py=my*fModuleSize-fEcalSize[1]/2.0+fYCell[type]*cy+(2*cy+1)*fEdging+fThicknessSteel;
487
488 px=(x-px)/fXCell[type];
489 py=(y-py)/fYCell[type];
490 if (px>=0&&px<1&&py>=0&&py<1)
491 {
492 fELoss*=fLightMaps[type]->Data(px-0.5, py-0.5);
493 FillLitePoint(0);
494 }
495 }
496 else
497 FillLitePoint(0);
498// for(i=0;i<8;i++)
499// {
500// Int_t t;
501//
502// gMC->CurrentVolOffID(i, t);
503// cout << i << ": " << gMC->CurrentVolOffName(i) << " " << t << "; ";
504// }
505// cout << endl;
506 }
507 ((ShipStack*)gMC->GetStack())->AddPoint(kecal, fTrackID);
508
510
511 return kTRUE;
512
513}
514
516Int_t ecal::GetVolType(Int_t volnum)
517{
518 Int_t i;
519 for(i=kN-1;i>-1;i--) {
520 if (fVolArr[i]==volnum) break;
521 }
522
523 return i;
524}
525
526//-----------------------------------------------------------------------------
528{
531 gMC->TrackPosition(fPos);
532 gMC->TrackMomentum(fMom);
533 fVolumeID = -1;
534 Double_t mass = gMC->TrackMass();
535 // Calculate kinetic energy
536 Double_t ekin = TMath::Sqrt( fMom.Px()*fMom.Px() +
537 fMom.Py()*fMom.Py() +
538 fMom.Pz()*fMom.Pz() +
539 mass * mass ) - mass;
540 fELoss = ekin;
541 // Create ecalPoint at the entrance of calorimeter
542 // for particles with pz>0 coming through the front wall
543 if (fMom.Pz() > 0 && fPos.Z() < fZEcal+0.01)
544 {
545 TParticle* part=((ShipStack*)gMC->GetStack())->GetParticle(fTrackID);
546 AddHit(fTrackID, fVolumeID, TVector3(fPos.X(), fPos.Y(), fPos.Z()),
547 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength,
548 fELoss, part->GetPdgCode());
549 }
550 fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
551}
552
553ecalPoint* ecal::FindHit(Int_t VolId, Int_t TrackId)
554{
555 for(Int_t i=fFirstNumber;i<fLiteCollection->GetEntriesFast();i++)
556 {
557 ecalPoint* point=(ecalPoint*)fLiteCollection->At(i);
558 if (point->GetTrackID()==TrackId&&point->GetDetectorID()==VolId)
559 return point;
560 }
561 return NULL;
562}
563//-----------------------------------------------------------------------------
564Bool_t ecal::FillLitePoint(Int_t volnum)
565{
568 //Search for input track
569
570 static Float_t zmin=fZEcal-0.0001;
571 static Float_t zmax=fZEcal+fEcalSize[2];
572 static Float_t xecal=fEcalSize[0]/2;
573 static Float_t yecal=fEcalSize[1]/2;
574 TParticle* part=gMC->GetStack()->GetCurrentTrack();
575 fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
576
577// cout << zmin << " : " << zmax << " : " << xecal << ", " << yecal << endl;
578// cout << part->GetFirstMother() << " : " << part->Vx() << ", " << part->Vy() << ", " << part->Vz() << endl;
580 while (part->GetFirstMother()>=0&&part->Vz()>=zmin&&part->Vz()<=zmax&&TMath::Abs(part->Vx())<=xecal&&TMath::Abs(part->Vy())<=yecal)
581 {
582 fTrackID=part->GetFirstMother();
583 part =((ShipStack*)gMC->GetStack())->GetParticle(fTrackID);
584// cout << "-> " << part->GetFirstMother() << " : " << part->Vx() << ", " << part->Vy() << ", " << part->Vz() << endl;
585 }
586// if (part->Vz()>500)
587// cout << part->Vx() << ", " << part->Vy() << ", " << part->Vz() << endl;
588#ifdef _DECAL
589 if (fTrackID<0) cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!fTrackID="<<fTrackID<<endl;
590#endif
591 ecalPoint* oldHit;
592 ecalPoint* newHit;
593
594 if ((oldHit=FindHit(fVolumeID,fTrackID))!=NULL)
595 ChangeHit(oldHit);
596 else
597 // Create ecalPoint for scintillator volumes
599
600
601 return kTRUE;
602}
603
604// ----- Public method EndOfEvent --------------------------------------
606 if (fVerboseLevel) Print();
607 fEcalCollection->Clear();
608
609 fLiteCollection->Clear();
610 fPosIndex = 0;
611 fFirstNumber=0;
612}
613// -------------------------------------------------------------------------
614
615// ----- Public method GetCollection -----------------------------------
616TClonesArray* ecal::GetCollection(Int_t iColl) const
617{
618 if (iColl == 0) return fEcalCollection;
619 if (iColl == 1) return fLiteCollection;
620 else return NULL;
621}
622// -------------------------------------------------------------------------
623
624// ----- Public method Reset -------------------------------------------
626{
627 fEcalCollection->Clear();
628 fLiteCollection->Clear();
630 fFirstNumber=0;
631}
632// -------------------------------------------------------------------------
633
634// ----- Public method Print -------------------------------------------
635void ecal::Print() const
636{
637 Int_t nHits = fEcalCollection->GetEntriesFast();
638 Int_t nLiteHits;
639 Int_t i;
640
641 cout << "-I- ecal: " << nHits << " points registered in this event.";
642 cout << endl;
643
644 nLiteHits=fLiteCollection->GetEntriesFast();
645 cout << "-I- ecal: " << nLiteHits << " lite points registered in this event.";
646 cout << endl;
647
648 if (fVerboseLevel>1)
649 {
650 for (i=0;i<nHits;i++)
651 (*fEcalCollection)[i]->Print();
652 for (i=0;i<nLiteHits;i++)
653 (*fLiteCollection)[i]->Print();
654 }
655}
656// -------------------------------------------------------------------------
657
658// ----- Public method CopyClones --------------------------------------
659void ecal::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset)
660{
661 Int_t nEntries = cl1->GetEntriesFast();
662 Int_t i;
663 Int_t index;
664 cout << "-I- ecal: " << nEntries << " entries to add." << endl;
665 TClonesArray& clref = *cl2;
666 if (cl1->GetClass()==ecalPoint::Class()) {
667 ecalPoint* oldpoint = NULL;
668 for (i=0; i<nEntries; i++) {
669 oldpoint = (ecalPoint*) cl1->At(i);
670 index = oldpoint->GetTrackID()+offset;
671 oldpoint->SetTrackID(index);
672 new (clref[fPosIndex]) ecalPoint(*oldpoint);
673 fPosIndex++;
674 }
675 cout << "-I- ecal: " << cl2->GetEntriesFast() << " merged entries."
676 << endl;
677 }
678 else if (cl1->GetClass()==ecalPoint::Class()) {
679 ecalPoint* oldpoint = NULL;
680 for (i=0; i<nEntries; i++) {
681 oldpoint = (ecalPoint*) cl1->At(i);
682 index = oldpoint->GetTrackID()+offset;
683 oldpoint->SetTrackID(index);
684 new (clref[fPosIndex]) ecalPoint(*oldpoint);
685 fPosIndex++;
686 }
687 cout << "-I- ecal: " << cl2->GetEntriesFast() << " merged entries."
688 << endl;
689 }
690}
691// -------------------------------------------------------------------------
692
693// ----- Public method Register ----------------------------------------
695{
696 FairRootManager::Instance()->Register("EcalPoint","Ecal",fEcalCollection,kTRUE);
697 FairRootManager::Instance()->Register("EcalPointLite","EcalLite",fLiteCollection,kTRUE);
698 ;
699}
700// -------------------------------------------------------------------------
701
702// ----- Public method ConstructGeometry -------------------------------
704{
705 FairGeoLoader*geoLoad = FairGeoLoader::Instance();
706 FairGeoInterface *geoFace = geoLoad->getGeoInterface();
707 FairGeoMedia *Media = geoFace->getMedia();
708 FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
709
710 TGeoVolume *top=gGeoManager->GetTopVolume();
711
712 // cout << top->GetName() << endl;
713 TGeoVolume *volume;
714 FairGeoMedium *CbmMedium;
715 TGeoPgon *spl;
716
717 Float_t *buf = 0;
718 Int_t i;
719 Double_t par[10];
720 Float_t y;
721 TString nm;
722 Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
723 Double_t moduleth=thickness*fNLayers;
724// Float_t sumWeight;
725// Int_t i;
726
727 // create SensVacuum which is defined in the media file
728
730 InitMedia();
731 par[0]=fSemiX;
732 par[1]=fSemiY;
733 par[2]=moduleth/2.0+0.1;
734 volume=gGeoManager->Volume("Ecal", "BOX", gGeoManager->GetMedium("SensVacuum")->GetId(), par, 3);
735 gGeoManager->Node("Ecal", 1, top->GetName(), 0.0,0.0, fZEcal+par[2]-0.05, 0, kTRUE, buf, 0);
736 volume->SetVisLeaves(kTRUE);
737 volume->SetVisContainers(kFALSE);
738 volume->SetVisibility(kFALSE);
739 AddSensitiveVolume(volume);
740 fStructureId=volume->GetNumber();
741
742 for(i=1;i<cMaxModuleType;i++) {
743 if (fModulesWithType[i]>0) {
744 if (fSimpleGeo==0)
746 else
748 }
749 }
750
751 TGeoVolume* vol=new TGeoVolumeAssembly("EcalStructure");
752//To suppress warring
753 vol->SetMedium(gGeoManager->GetMedium("SensVacuum"));
754 for(i=0;i<fYSize;i++)
755 {
756// cout << i << " " << flush;
757 volume=ConstructRaw(i);
758 if (volume==NULL)
759 {
760// cout << endl;
761 continue;
762 }
763 nm=volume->GetName();
764 y=(i-fYSize/2.0+0.5)*fModuleSize;
765// cout << volume->GetName() << flush;
766 gGeoManager->Node(nm.Data(), i+1, "EcalStructure", 0.0, y, 0.0, 0, kTRUE, buf, 0);
767// cout << endl << flush;
768 }
769//TODO:
770//Should move the guarding volume, not structure itself
771 gGeoManager->Node("EcalStructure", 1, "Ecal", fDX, fDY, 0.0, 0, kTRUE, buf, 0);
772}
773// -------------------------------------------------------------------------
774
775// ----- Public method ConstructRaw ----------------------------------------
776TGeoVolume* ecal::ConstructRaw(Int_t num)
777{
778 Int_t i;
779 list<pair<Int_t, TGeoVolume*> >::const_iterator p=fRawNumber.begin();
780 pair<Int_t, TGeoVolume*> out;
781 Float_t x;
782 Float_t* buf=NULL;
783 for(i=0;i<fXSize;i++)
784 if ((Int_t)fInf->GetType(i, num)!=0) break;
785 if (i==fXSize)
786 return NULL;
787 for(;p!=fRawNumber.end();++p)
788 {
789 for(i=0;i<fXSize;i++)
790 if (fInf->GetType(i, num)!=fInf->GetType(i, (*p).first))
791 break;
792 if (i==fXSize)
793 break;
794 }
795 if (p!=fRawNumber.end())
796 return (*p).second;
797 TString nm="ECALRaw"; nm+=num;
798 TString md;
799 TGeoVolume* vol=new TGeoVolumeAssembly(nm);
800//To suppress warring
801 vol->SetMedium(gGeoManager->GetMedium("SensVacuum"));
802 for(i=0;i<fXSize;i++)
803 {
804 x=(i-fXSize/2.0+0.5)*fModuleSize;
805 if (fInf->GetType(i, num)==0) continue;
806 md="EcalModule"; md+=(Int_t)fInf->GetType(i, num);
807 gGeoManager->Node(md.Data(),i+1, nm.Data(), x, 0.0, 0.0, 0, kTRUE, buf, 0);
808 }
809
810 out.first=num;
811 out.second=vol;
812 fRawNumber.push_back(out);
813 return out.second;
814}
815// -------------------------------------------------------------------------
816
817
818// ----- Public method BeginEvent -----------------------------------------
820{
821 ;
822}
823// -------------------------------------------------------------------------
824
825
826// -------------------------------------------------------------------------
827
828// ----- Private method AddHit -----------------------------------------
829ecalPoint* ecal::AddHit(Int_t trackID, Int_t detID, TVector3 pos,
830 TVector3 mom, Double_t time, Double_t length,
831 Double_t eLoss, Int_t pdgcode)
832{
833 TClonesArray& clref = *fEcalCollection;
834 Int_t size = clref.GetEntriesFast();
835 return new(clref[size]) ecalPoint(trackID, detID, pos, mom,
836 time, length, eLoss, pdgcode);
837}
838// -------------------------------------------------------------------------
839
840// ----- Private method AddHit -----------------------------------------
841ecalPoint* ecal::AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss)
842{
843 TClonesArray& clref = *fLiteCollection;
844 Int_t size = clref.GetEntriesFast();
845 return new(clref[size]) ecalPoint(trackID, detID, time, eLoss);
846}
847// -------------------------------------------------------------------------
848
849// ----- Private method ConstructModule ----------------------------------
850void ecal::ConstructModule(Int_t type)
851{
852 if (fModules[type]!=NULL) return;
853 ConstructCell(type);
854
855 TString nm="EcalModule"; nm+=type;
856 TString nm1;
857 TString cellname="EcalCell"; cellname+=type;
858 Int_t i;
859 Int_t j;
860 Int_t n;
861 Float_t x;
862 Float_t y;
863 Float_t* buf=NULL;
864 Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
865 Double_t moduleth=thickness*fNLayers;
866 Double_t par[3]={fModuleSize/2.0, fModuleSize/2.0, moduleth/2.0};
867 if (fSteelTapes[0]==NULL)
868 {
869 TGeoBBox* st1=new TGeoBBox(fThicknessSteel/2.0, fModuleSize/2.0-fThicknessSteel, moduleth/2.0);
870 nm1="EcalModuleSteelTape1_"; //nm1+=type;
871 fSteelTapes[0]=new TGeoVolume(nm1.Data(), st1, gGeoManager->GetMedium("ECALSteel"));
872 }
873 if (fSteelTapes[1]==NULL)
874 {
875 TGeoBBox* st2=new TGeoBBox(fModuleSize/2.0-fThicknessSteel, fThicknessSteel/2.0, moduleth/2.0);
876 nm1="EcalModuleSteelTape2_"; //nm1+=type;
877 fSteelTapes[1]=new TGeoVolume(nm1.Data(), st2, gGeoManager->GetMedium("ECALSteel"));
878 }
879
880
881// TGeoVolume* modulev=new TGeoVolumeAssembly(nm);
882 TGeoVolume* modulev=gGeoManager->Volume(nm.Data(), "BOX", gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
883 modulev->SetLineColor(kYellow);
884
885 //Adding cells into module
886 for(i=0;i<type;i++)
887 for(j=0;j<type;j++)
888 {
889 x=(i-type/2.0+0.5)*(fXCell[type]+2.0*fEdging);
890 y=(j-type/2.0+0.5)*(fYCell[type]+2.0*fEdging);
891 n=i+j*type+1;
892 gGeoManager->Node(cellname.Data(), n, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
893 }
894 nm1="EcalModuleSteelTape1_"; //nm1+=type;
895 gGeoManager->Node(nm1.Data(), 1, nm.Data(), -fThicknessSteel/2.0+fModuleSize/2.0, 0.0, 0.0, 0, kTRUE, buf, 0);
896 gGeoManager->Node(nm1.Data(), 2, nm.Data(), +fThicknessSteel/2.0-fModuleSize/2.0, 0.0, 0.0, 0, kTRUE, buf, 0);
897 nm1="EcalModuleSteelTape2_"; //nm1+=type;
898 gGeoManager->Node(nm1.Data(), 1, nm.Data(), 0.0, -fThicknessSteel/2.0+fModuleSize/2.0, 0.0, 0, kTRUE, buf, 0);
899 gGeoManager->Node(nm1.Data(), 2, nm.Data(), 0.0, +fThicknessSteel/2.0-fModuleSize/2.0, 0.0, 0, kTRUE, buf, 0);
900 fModuleLenght=moduleth;
901}
902// -------------------------------------------------------------------------
903
904// ----- Private method ConstructModuleSimple-----------------------------
906{
907 if (fModules[type]!=NULL) return;
909
910 TString nm="EcalModule"; nm+=type;
911 TString nm1;
912 TString cellname="EcalCell"; cellname+=type;
913 Int_t i;
914 Int_t j;
915 Int_t n;
916 Float_t x;
917 Float_t y;
918 Float_t* buf=NULL;
919 Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
920 Double_t moduleth=thickness*fNLayers;
921 Double_t par[3]={fModuleSize/2.0, fModuleSize/2.0, moduleth/2.0};
922
923// TGeoVolume* modulev=new TGeoVolumeAssembly(nm);
924 TGeoVolume* modulev=gGeoManager->Volume(nm.Data(), "BOX", gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
925 modulev->SetLineColor(kYellow);
926
927 //Adding cells into module
928 for(i=0;i<type;i++)
929 for(j=0;j<type;j++)
930 {
931 x=(i-type/2.0+0.5)*fModuleSize/type;
932 y=(j-type/2.0+0.5)*fModuleSize/type;
933 n=i+j*type+1;
934 gGeoManager->Node(cellname.Data(), n, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
935 }
936 fModuleLenght=moduleth;
937}
938// -------------------------------------------------------------------------
939
940// ----- Private method ConstructCell ------------------------------------
941void ecal::ConstructCell(Int_t type)
942{
943 if (fCells[type]!=NULL) return;
944
945 ConstructTile(type, 0);
946 ConstructTile(type, 1);
947 if (fThicknessTyvk>0) ConstructTile(type, 2);
948
949 Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
950 Int_t i;
951 TString nm="EcalCell"; nm+=type;
952 TString scin="ScTile"; scin+=type; scin+="_edging";
953 TString lead="LeadTile"; lead+=type;
954 TString tyvek="TvTile"; tyvek+=type;
955 Double_t* buf=NULL;
956 Double_t moduleth=thickness*fNLayers;
957 Double_t par[3]={fXCell[type]/2.0+fEdging, fYCell[type]/2.0+fEdging, moduleth/2.0};
958// TGeoVolume* cellv=new TGeoVolumeAssembly(nm);
959 TGeoVolume* cellv=gGeoManager->Volume(nm.Data(),"BOX", gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
960 for(i=0;i<fNLayers;i++)
961 {
962 gGeoManager->Node(scin.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin/2.0+i*thickness, 0, kTRUE, buf, 0);
963 gGeoManager->Node(lead.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+fThicknessTyvk+fThicknessLead/2.0, 0, kTRUE, buf, 0);
964 if (fThicknessTyvk>0.0)
965 {
966 gGeoManager->Node(tyvek.Data(), 2*i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+1.5*fThicknessTyvk+fThicknessLead, 0, kTRUE, buf, 0);
967 gGeoManager->Node(tyvek.Data(), 2*i+2, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+0.5*fThicknessTyvk, 0, kTRUE, buf, 0);
968 }
969 }
970 fCells[type]=cellv;
971}
972// -------------------------------------------------------------------------
973
974// ----- Private method ConstructCellSimple ------------------------------
976{
977 if (fCells[type]!=NULL) return;
978
979 ConstructTileSimple(type, 0);
980 ConstructTileSimple(type, 1);
981 if (fThicknessTyvk>0) ConstructTileSimple(type, 2);
982
983 Double_t thickness=fThicknessLead+fThicknessScin+fThicknessTyvk*2;
984 Int_t i;
985 TString nm="EcalCell"; nm+=type;
986 TString scin="ScTile"; scin+=type;
987 TString lead="LeadTile"; lead+=type;
988 TString tyvek="TvTile"; tyvek+=type;
989 Double_t* buf=NULL;
990 Double_t moduleth=thickness*fNLayers;
991 Double_t par[3]={fModuleSize/type/2.0, fModuleSize/type/2.0, moduleth/2.0};
992// TGeoVolume* cellv=new TGeoVolumeAssembly(nm);
993 TGeoVolume* cellv=gGeoManager->Volume(nm.Data(),"BOX", gGeoManager->GetMedium("ECALAir")->GetId(), par, 3);
994 for(i=0;i<fNLayers;i++)
995 {
996 gGeoManager->Node(scin.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin/2.0+i*thickness, 0, kTRUE, buf, 0);
997 gGeoManager->Node(lead.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+fThicknessTyvk+fThicknessLead/2.0, 0, kTRUE, buf, 0);
998 if (fThicknessTyvk>0.0)
999 {
1000 gGeoManager->Node(tyvek.Data(), 2*i+1, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+1.5*fThicknessTyvk+fThicknessLead, 0, kTRUE, buf, 0);
1001 gGeoManager->Node(tyvek.Data(), 2*i+2, nm.Data(), 0.0, 0.0, -thickness*fNLayers/2.0+fThicknessScin+i*thickness+0.5*fThicknessTyvk, 0, kTRUE, buf, 0);
1002 }
1003 }
1004 fCells[type]=cellv;
1005}
1006// -------------------------------------------------------------------------
1007
1008// ----- Private method InitMedium ---------------------------------------
1009Int_t ecal::InitMedium(const char* name)
1010{
1011 static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
1012 static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
1013 static FairGeoMedia *media=geoFace->getMedia();
1014 static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
1015
1016 FairGeoMedium *CbmMedium=media->getMedium(name);
1017
1018 if (!CbmMedium)
1019 {
1020 Fatal("InitMedium","Material %s not defined in media file.", name);
1021 return -1111;
1022 }
1023 TGeoMedium* medium=gGeoManager->GetMedium(name);
1024 if (medium!=NULL)
1025 return CbmMedium->getMediumIndex();
1026
1027 return geoBuild->createMedium(CbmMedium);
1028}
1029// -------------------------------------------------------------------------
1030
1031// ----- Private method InitMedia ----------------------------------------
1033{
1034 Info("InitMedia", "Initializing media.");
1035 InitMedium("SensVacuum");
1036 InitMedium("ECALVacuum");
1037 InitMedium("Lead");
1038 InitMedium("Scintillator");
1039 InitMedium("Tyvek");
1040 InitMedium("ECALAir");
1041 InitMedium("ECALFiber");
1042 InitMedium("ECALSteel");
1043 InitMedium("ECALTileEdging");
1044}
1045// -------------------------------------------------------------------------
1046
1047// ----- Private method ConstructTile ------------------------------------
1048void ecal::ConstructTile(Int_t type, Int_t material)
1049{
1050 switch (material)
1051 {
1052 case 0: if (fScTiles[type]!=NULL) return; break;
1053 case 1: if (fPbTiles[type]!=NULL) return; break;
1054 case 2: if (fTvTiles[type]!=NULL) return; break;
1055 default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
1056 }
1057 Double_t thickness;
1058 TGeoVolume* hole;
1059 TGeoVolume* fiber;
1060 TGeoTranslation** tr;
1061 TGeoTranslation* tm;
1062 Int_t nh=fNH[type];
1063 Int_t i;
1064 Int_t j;
1065 TString nm;
1066 TString nm1;
1067 TString nm2;
1068 TString medium;
1069 Double_t x;
1070 Double_t y;
1071 TGeoBBox* tile;
1072 TGeoVolume* tilev;
1073 TGeoBBox* edging;
1074 TGeoVolume* edgingv;
1075 Double_t* buf=NULL;
1076
1077 switch (material)
1078 {
1079 case 0: thickness=fThicknessScin/2.0; break;
1080 case 1: thickness=fThicknessLead/2.0; break;
1081 case 2: thickness=fThicknessTyvk/2.0; break;
1082 default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
1083 }
1084
1085 if (thickness<=0.0) return;
1086 // Holes in the tiles
1087 if (fHoleRad>0)
1088 {
1089 nm1="ECALHole_"; nm1+=material;
1090 nm2="ECALFiber_"; nm2+=material;
1091 if (fHoleVol[material]==NULL)
1092 {
1093 TGeoTube* holetube=new TGeoTube(0, fHoleRad, thickness);
1094 fHoleVol[material]=new TGeoVolume(nm1.Data(), holetube, gGeoManager->GetMedium("ECALAir"));
1095 }
1096 hole=fHoleVol[material];
1097 // Fibers in holes
1098 if (fFiberRad>0)
1099 {
1100 if (fFiberVol[material]==NULL)
1101 {
1102 TGeoTube* fibertube=new TGeoTube(0, fFiberRad, thickness);
1103 fFiberVol[material]=new TGeoVolume(nm2.Data(), fibertube, gGeoManager->GetMedium("ECALFiber"));
1104 gGeoManager->Node(nm2.Data(), 1, nm1.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
1105 }
1106 fiber=fFiberVol[material];
1107 // TODO: Cerenkoff !!!
1108 //AddSensitiveVolume(fiber);
1109 }
1110 }
1111/*
1112 if (fHolePos[type]==NULL)
1113 {
1114 tr=new TGeoTranslation*[nh*nh];
1115 for(i=0;i<nh;i++)
1116 for(j=0;j<nh;j++)
1117 {
1118 nm="sh"; nm+=type; nm+="_"; nm+=j*nh+i;
1119 x=(i-nh/2+0.5)*fXCell[type]/nh;
1120 y=(j-nh/2+0.5)*fYCell[type]/nh;
1121
1122
1123 tm=new TGeoTranslation(nm, x, y, 0);
1124 gGeoManager->AddTransformation(tm);
1125 tr[j*nh+i]=tm;
1126 }
1127 fHolePos[type]=tr;
1128 }
1129 tr=fHolePos[type];
1130*/
1132 switch (material)
1133 {
1134 case 0: nm="ScTile"; medium="Scintillator"; break;
1135 case 1: nm="LeadTile"; medium="Lead"; break;
1136 case 2: nm="TvTile"; medium="Tyvek"; break;
1137 default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
1138 }
1139
1140 nm+=type;
1141 if (material==0)
1142 tile=new TGeoBBox(fXCell[type]/2.0, fYCell[type]/2.0, thickness);
1143 else
1144 tile=new TGeoBBox(fXCell[type]/2.0+fEdging, fYCell[type]/2.0+fEdging, thickness);
1145 tilev=new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
1146 if (fHoleRad>0)
1147 {
1148 nm1="ECALHole_"; nm1+=material;
1149 for(i=0;i<nh;i++)
1150 for(j=0;j<nh;j++)
1151 {
1152 x=(i-nh/2+0.5)*fXCell[type]/nh;
1153 y=(j-nh/2+0.5)*fYCell[type]/nh;
1154 gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
1155 }
1156 // clear fiber
1157 if (nh%2==0&&fCF[type]!=0)
1158 gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
1159
1160 }
1161/*
1162 if (fHoleRad>0)
1163 {
1164 for(i=0;i<nh;i++)
1165 for(j=0;j<nh;j++)
1166 tilev->AddNode(hole, j*nh+i+1, tr[j*nh+i]);
1167 // Clear Fiber
1168 if (nh%2==0)
1169 tilev->AddNode(hole, j*nh+i+1);
1170 }
1171*/
1173 if (material==0)
1174 {
1175 AddSensitiveVolume(tilev);
1176 edging=new TGeoBBox(fXCell[type]/2.0+fEdging, fYCell[type]/2.0+fEdging, thickness);
1177
1178 edgingv=new TGeoVolume(nm+"_edging", edging, gGeoManager->GetMedium("ECALTileEdging"));
1179 edgingv->AddNode(tilev, 1);
1180 fScTiles[cMaxModuleType-1]=tilev;
1181 fTileEdging[cMaxModuleType-1]=edgingv;
1182 }
1183 else
1184 {
1185 if (material==1) //Lead
1186 fPbTiles[type]=tilev;
1187 else
1188 fTvTiles[type]=tilev;
1189 return;
1190 }
1191}
1192// -------------------------------------------------------------------------
1193
1194// ----- Private method ConstructTileSimple ------------------------------
1195void ecal::ConstructTileSimple(Int_t type, Int_t material)
1196{
1197 switch (material)
1198 {
1199 case 0: if (fScTiles[type]!=NULL) return; break;
1200 case 1: if (fPbTiles[type]!=NULL) return; break;
1201 case 2: if (fTvTiles[type]!=NULL) return; break;
1202 default: Error("ConstructTileSimple", "Can't construct a tile of type %d.", material);
1203 }
1204 Double_t thickness;
1205 TGeoVolume* hole;
1206 TGeoVolume* fiber;
1207 TGeoTranslation** tr;
1208 TGeoTranslation* tm;
1209 Int_t nh=fNH[type];
1210 Int_t i;
1211 Int_t j;
1212 TString nm;
1213 TString nm1;
1214 TString nm2;
1215 TString medium;
1216 Double_t x;
1217 Double_t y;
1218 TGeoBBox* tile;
1219 TGeoVolume* tilev;
1220 TGeoBBox* edging;
1221 TGeoVolume* edgingv;
1222 Double_t* buf=NULL;
1223
1224 switch (material)
1225 {
1226 case 0: thickness=fThicknessScin/2.0; break;
1227 case 1: thickness=fThicknessLead/2.0; break;
1228 case 2: thickness=fThicknessTyvk/2.0; break;
1229 default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
1230 }
1231
1232 if (thickness<=0.0) return;
1234 switch (material)
1235 {
1236 case 0: nm="ScTile"; medium="Scintillator"; break;
1237 case 1: nm="LeadTile"; medium="Lead"; break;
1238 case 2: nm="TvTile"; medium="Tyvek"; break;
1239 default: Error("ConstructTile", "Can't construct a tile of type %d.", material);
1240 }
1241
1242 nm+=type;
1243 tile=new TGeoBBox(fModuleSize/type/2.0, fModuleSize/type/2.0, thickness);
1244 tilev=new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
1246 if (material==0)
1247 {
1248 AddSensitiveVolume(tilev);
1249 fScTiles[cMaxModuleType-1]=tilev;
1250 fTileEdging[cMaxModuleType-1]=tilev;
1251 }
1252 else
1253 {
1254 if (material==1) //Lead
1255 fPbTiles[type]=tilev;
1256 else
1257 fTvTiles[type]=tilev;
1258 return;
1259 }
1260}
1261// -------------------------------------------------------------------------
1262
1263// ----- Public method GetCellCoordInf ----------------------------------------
1264Bool_t ecal::GetCellCoordInf(Int_t fVolID, Float_t &x, Float_t &y, Int_t& tenergy)
1265{
1266 static ecalInf* inf=NULL;
1267 if (inf==NULL)
1268 {
1269 inf=ecalInf::GetInstance(NULL);
1270 if (inf==NULL)
1271 {
1272 cerr << "ecal::GetCellCoordInf(): Can't get geometry information." << endl;
1273 return kFALSE;
1274 }
1275 }
1276 Int_t volid=fVolID;
1277 Int_t cell=volid%100-1; volid=volid-cell-1; volid/=100;
1278 Int_t mx=volid%100; volid-=mx; volid/=100;
1279 Int_t my=volid%100; volid-=my; volid/=100;
1280 Int_t type=inf->GetType(mx, my);
1281 Int_t cx=cell%type;
1282 Int_t cy=cell/type;
1283// cout << "->" << mx << ", " << my << ", " << cell << endl;
1284 static Float_t modulesize=inf->GetVariableStrict("modulesize");
1285 static Float_t xcalosize=inf->GetEcalSize(0);
1286 static Float_t ycalosize=inf->GetEcalSize(1);
1287 static Float_t dx=inf->GetVariableStrict("xpos");
1288 static Float_t dy=inf->GetVariableStrict("ypos");
1289 x=mx*modulesize-xcalosize/2.0+cx*modulesize/type+1.0; x+=dx;
1290 y=my*modulesize-ycalosize/2.0+cy*modulesize/type+1.0; y+=dy;
1291 tenergy=0;
1292
1293// cerr << fVolID << " --- " << x << ", " << y << endl;
1294 return kFALSE;
1295}
1296
1297// ------------------------------------------------------------------------------
1298
1299Bool_t ecal::GetCellCoord(Int_t fVolID, Float_t &x, Float_t &y, Int_t& tenergy)
1300{
1301 return GetCellCoordInf(fVolID, x, y, tenergy);
1302}
1303
1304Bool_t ecal::GetCellCoordForPy(Int_t fVolID, TVector3 &all)
1305{
1306 Float_t x,y;
1307 Int_t tenergy;
1308 Bool_t rc = GetCellCoordInf(fVolID, x, y, tenergy);
1309 static ecalInf* inf=NULL;
1310 if (inf==NULL)
1311 {
1312 inf=ecalInf::GetInstance(NULL);
1313 if (inf==NULL)
1314 {
1315 cerr << "ecal::GetCellCoordInf(): Can't get geometry information." << endl;
1316 return kFALSE;
1317 }
1318 }
1319 all=TVector3(x,y,inf->GetZPos());
1320 return kTRUE;
1321}
1322
@ kecal
Int_t GetYSize() const
Definition ecalInf.h:46
Double_t GetHadronCut() const
Definition ecalInf.h:52
char GetType(Int_t x, Int_t y) const
Definition ecalInf.h:155
Double_t GetTyveec() const
Definition ecalInf.h:41
Double_t GetZPos() const
Definition ecalInf.h:34
Int_t GetXSize() const
Definition ecalInf.h:45
TString GetStringVariable(const char *key)
Definition ecalInf.cxx:103
Double_t GetScin() const
Definition ecalInf.h:40
void AddVariable(const char *key, const char *value)
Definition ecalInf.cxx:128
Double_t GetVariableStrict(const char *key)
Definition ecalInf.cxx:82
Double_t GetLead() const
Definition ecalInf.h:39
Double_t GetEcalSize(Int_t num) const
Definition ecalInf.h:54
Double_t GetElectronCut() const
Definition ecalInf.h:51
Int_t GetNLayers() const
Definition ecalInf.h:38
static ecalInf * GetInstance(const char *filename)
Definition ecalInf.cxx:35
Double_t Data(Double_t x, Double_t y)
Bool_t FillLitePoint(Int_t volnum)
Definition ecal.cxx:564
Double32_t fELoss
Definition ecal.h:130
virtual void Print() const
Definition ecal.cxx:635
virtual void Initialize()
Definition ecal.cxx:289
virtual void SetSpecialPhysicsCuts()
Definition ecal.cxx:355
Int_t fCF[cMaxModuleType]
Definition ecal.h:178
Int_t fYSize
Definition ecal.h:146
virtual void FinishPrimary()
Definition ecal.cxx:338
virtual void BeginEvent()
Definition ecal.cxx:819
Double32_t fLength
Definition ecal.h:128
std::list< std::pair< Int_t, TGeoVolume * > > fRawNumber
Number of mudules with type.
Definition ecal.h:241
Int_t InitMedium(const char *name)
Definition ecal.cxx:1009
void ConstructTile(Int_t type, Int_t material)
Definition ecal.cxx:1048
Float_t fEdging
Definition ecal.h:168
ecalLightMap * fLightMaps[cMaxModuleType]
Definition ecal.h:182
ecalInf * fInf
Definition ecal.h:110
TGeoVolume * fHoleVol[3]
Tyvek sheets.
Definition ecal.h:236
Int_t fSimpleGeo
Definition ecal.h:143
Option_t * fDebug
Definition ecal.h:111
Float_t fGeoScale
Definition ecal.h:188
Float_t fYCell[cMaxModuleType]
Definition ecal.h:175
Float_t fSemiY
Definition ecal.h:156
Float_t fThicknessTyvk
Definition ecal.h:162
Int_t fPosIndex
Definition ecal.h:132
Int_t fXSize
Definition ecal.h:145
void FillWallPoint()
Definition ecal.cxx:527
virtual Bool_t ProcessHits(FairVolume *vol=NULL)
Definition ecal.cxx:384
void ConstructCellSimple(Int_t type)
Definition ecal.cxx:975
TClonesArray * fLiteCollection
Definition ecal.h:137
virtual void Register()
Definition ecal.cxx:694
Int_t GetVolType(Int_t volnum)
Definition ecal.cxx:516
Float_t fModuleSize
Definition ecal.h:151
void ConstructCell(Int_t type)
Definition ecal.cxx:941
TGeoVolume * fTileEdging[cMaxModuleType]
Pb tiles.
Definition ecal.h:233
Float_t fFiberRad
Definition ecal.h:172
Float_t fEcalSize[3]
Definition ecal.h:140
virtual void ChangeHit(ecalPoint *oldHit=NULL)
Definition ecal.cxx:344
TGeoVolume * fSteelTapes[2]
Fiber volume.
Definition ecal.h:238
Float_t fThicknessLead
Definition ecal.h:158
TLorentzVector fMom
Definition ecal.h:124
Int_t fFirstNumber
Definition ecal.h:204
virtual void ConstructGeometry()
Definition ecal.cxx:703
Int_t fVolArr[kNumberOfECALSensitiveVolumes]
Definition ecal.h:213
TGeoTranslation ** fHolePos[cMaxModuleType]
Steel tapes.
Definition ecal.h:239
ecalPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgcode)
Definition ecal.cxx:829
Int_t fVolumeID
Definition ecal.h:120
Float_t fHoleRad
Definition ecal.h:170
Int_t fNLayers
Definition ecal.h:184
void InitMedia()
Definition ecal.cxx:1032
TGeoVolume * ConstructRaw(Int_t number)
Definition ecal.cxx:776
Float_t fZEcal
Definition ecal.h:153
Float_t fXCell[cMaxModuleType]
Definition ecal.h:174
TGeoVolume * fCells[cMaxModuleType]
Calorimeter Modules.
Definition ecal.h:231
Float_t fSemiX
Definition ecal.h:155
void ResetParameters()
Definition ecal.h:257
virtual void Reset()
Definition ecal.cxx:625
static Bool_t GetCellCoord(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t &tenergy)
Definition ecal.cxx:1299
TString fLightMapNames[cMaxModuleType]
Definition ecal.h:180
void ConstructModule(Int_t type)
Definition ecal.cxx:850
Float_t fThicknessScin
Definition ecal.h:160
void SetEcalCuts(Int_t medium)
Definition ecal.cxx:318
TGeoVolume * fPbTiles[cMaxModuleType]
Edging of scintillator tiles.
Definition ecal.h:234
TGeoVolume * fScTiles[cMaxModuleType]
Calorimeter Cells.
Definition ecal.h:232
Int_t fNH[cMaxModuleType]
Definition ecal.h:177
void ConstructTileSimple(Int_t type, Int_t material)
Definition ecal.cxx:1195
virtual ~ecal()
Definition ecal.cxx:302
Double32_t fTime
Definition ecal.h:126
Float_t fThicknessSteel
Definition ecal.h:166
Float_t fModuleLenght
Definition ecal.h:186
ecalPoint * AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss)
Definition ecal.cxx:841
TGeoVolume * fTvTiles[cMaxModuleType]
Scintillator tiles.
Definition ecal.h:235
virtual void EndOfEvent()
Definition ecal.cxx:605
Int_t fStructureId
List of constructed raws.
Definition ecal.h:244
TGeoVolume * fModules[cMaxModuleType]
Definition ecal.h:230
TGeoVolume * fFiberVol[3]
Hole volume.
Definition ecal.h:237
ecal()
Definition ecal.cxx:46
ecalPoint * FindHit(Int_t VolId, Int_t TrackId)
Definition ecal.cxx:553
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Definition ecal.cxx:659
Float_t fDX
Definition ecal.h:148
static Bool_t GetCellCoordInf(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t &tenergy)
Definition ecal.cxx:1264
void ConstructModuleSimple(Int_t type)
Definition ecal.cxx:905
Float_t fDY
Definition ecal.h:149
TClonesArray * fEcalCollection
Definition ecal.h:135
Int_t fTrackID
Definition ecal.h:118
Int_t fModulesWithType[cMaxModuleType]
Positions of holes.
Definition ecal.h:240
virtual TClonesArray * GetCollection(Int_t iColl) const
Definition ecal.cxx:616
static Bool_t GetCellCoordForPy(Int_t fVolID, TVector3 &all)
Definition ecal.cxx:1304
TLorentzVector fPos
Definition ecal.h:122
#define kN
Definition ecal.cxx:43
const Int_t cMaxModuleType
Definition ecal.h:30