SND@LHC Software
Loading...
Searching...
No Matches
strawtubes.cxx
Go to the documentation of this file.
1// First version of the strawtracker geometry, based on NA62 straws
2// 7/10/2015
3// E. van Herwijnen eric.van.herwijnen@cern.ch
4// Also contains (for the moment) the veto station
5
6#include "strawtubes.h"
7#include "strawtubesPoint.h"
8
9#include "FairVolume.h"
10#include "FairGeoVolume.h"
11#include "FairGeoNode.h"
12#include "FairRootManager.h"
13#include "FairGeoLoader.h"
14#include "FairGeoInterface.h"
15#include "FairGeoMedia.h"
16#include "FairGeoBuilder.h"
17#include "FairRun.h"
18#include "FairRuntimeDb.h"
19#include "ShipDetectorList.h"
20#include "ShipStack.h"
21
22#include "TClonesArray.h"
23#include "TVirtualMC.h"
24#include "TGeoManager.h"
25#include "TGeoBBox.h"
26#include "TGeoCompositeShape.h"
27#include "TGeoTube.h"
28#include "TGeoMaterial.h"
29#include "TGeoMedium.h"
30#include "TMath.h"
31#include "TParticle.h"
32#include "TVector3.h"
33
34#include <iostream>
35#include <sstream>
36using std::cout;
37using std::endl;
38
40 : FairDetector("strawtubes", kTRUE, kStraw),
41 fTrackID(-1),
42 fVolumeID(-1),
43 fPos(),
44 fMom(),
45 fTime(-1.),
46 fLength(-1.),
47 fELoss(-1),
48 fstrawtubesPointCollection(new TClonesArray("strawtubesPoint"))
49{
50}
51
52strawtubes::strawtubes(const char* name, Bool_t active)
53 : FairDetector(name, active, kStraw),
54 fTrackID(-1),
55 fVolumeID(-1),
56 fPos(),
57 fMom(),
58 fTime(-1.),
59 fLength(-1.),
60 fELoss(-1),
61 fstrawtubesPointCollection(new TClonesArray("strawtubesPoint"))
62{
63}
64
72
74{
75 FairDetector::Initialize();
76// FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
77// vetoGeoPar* par=(vetoGeoPar*)(rtdb->getContainer("vetoGeoPar"));
78}
79
80// ----- Private method InitMedium
81Int_t strawtubes::InitMedium(const char* name)
82{
83 static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
84 static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
85 static FairGeoMedia *media=geoFace->getMedia();
86 static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
87
88 FairGeoMedium *ShipMedium=media->getMedium(name);
89
90 if (!ShipMedium)
91 {
92 Fatal("InitMedium","Material %s not defined in media file.", name);
93 return -1111;
94 }
95 TGeoMedium* medium=gGeoManager->GetMedium(name);
96 if (medium!=NULL)
97 return ShipMedium->getMediumIndex();
98
99 return geoBuild->createMedium(ShipMedium);
100}
101
102Bool_t strawtubes::ProcessHits(FairVolume* vol)
103{
105 //Set parameters at entrance of volume. Reset ELoss.
106 if ( gMC->IsTrackEntering() ) {
107 fELoss = 0.;
108 fTime = gMC->TrackTime() * 1.0e09;
109 fLength = gMC->TrackLength();
110 gMC->TrackPosition(fPos);
111 gMC->TrackMomentum(fMom);
112 }
113 // Sum energy loss for all steps in the active volume
114 fELoss += gMC->Edep();
115
116 // Create strawtubesPoint at exit of active volume
117 if ( gMC->IsTrackExiting() ||
118 gMC->IsTrackStop() ||
119 gMC->IsTrackDisappeared() ) {
120 if (fELoss == 0. ) { return kFALSE; }
121 TParticle* p=gMC->GetStack()->GetCurrentTrack();
122 Int_t pdgCode = p->GetPdgCode();
123 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
124 Int_t straw_uniqueId;
125 gMC->CurrentVolID(straw_uniqueId);
126 if (fVolumeID == straw_uniqueId) {
127 //std::cout << pdgCode<< " same volume again ? "<< straw_uniqueId << " exit:" << gMC->IsTrackExiting() << " stop:" << gMC->IsTrackStop() << " disappeared:" << gMC->IsTrackDisappeared()<< std::endl;
128 return kTRUE; }
129 fVolumeID = straw_uniqueId;
130 // # d = |pq . u x v|/|u x v|
131 TVector3 bot,top;
132 StrawEndPoints(straw_uniqueId,bot,top);
133 TLorentzVector Pos;
134 gMC->TrackPosition(Pos);
135 Double_t xmean = (fPos.X()+Pos.X())/2. ;
136 Double_t ymean = (fPos.Y()+Pos.Y())/2. ;
137 Double_t zmean = (fPos.Z()+Pos.Z())/2. ;
138 TVector3 pq = TVector3(top.x()-xmean,top.y()-ymean,top.z()-zmean );
139 TVector3 u = TVector3(bot.x()-top.x(),bot.y()-top.y(),bot.z()-top.z() );
140 TVector3 v = TVector3(fPos.X()-Pos.X(),fPos.Y()-Pos.Y(),fPos.Z()-Pos.Z());
141 TVector3 uCrossv = u.Cross(v);
142 Double_t dist2Wire = fabs(pq.Dot(uCrossv))/(uCrossv.Mag()+1E-8);
143 Double_t deltaTrackLength = gMC->TrackLength() - fLength;
144 AddHit(fTrackID, straw_uniqueId, TVector3(xmean, ymean, zmean),
145 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, deltaTrackLength,
146 fELoss,pdgCode,dist2Wire);
147 if (dist2Wire>fInner_Straw_diameter/2){
148 std::cout << "addhit " << dist2Wire<< " straw id " << straw_uniqueId << " pdgcode " << pdgCode<< " dot prod " << pq.Dot(uCrossv)<< std::endl;
149 std::cout << " exit:" << gMC->IsTrackExiting() << " stop:" << gMC->IsTrackStop() << " disappeared:" << gMC->IsTrackDisappeared()<< std::endl;
150 std::cout << " entry:" << fPos.X()<< " " << fPos.Y()<< " " << fPos.Z() << std::endl;
151 std::cout << " exit:" << Pos.X()<< " " << Pos.Y()<< " " << Pos.Z() << std::endl;
152 std::cout << " mean:" << xmean<< " " << ymean << " " << zmean << std::endl;
153 std::cout << " bot:" << bot.x()<< " " << bot.y() << " " << bot.z() << std::endl;
154 std::cout << " top:" << top.x()<< " " << top.y() << " " << top.z() << std::endl;
155 pq.Print();
156 u.Print();
157 v.Print();
158 uCrossv.Print();
159 }
160 // Increment number of strawtubes det points in TParticle
161 ShipStack* stack = (ShipStack*) gMC->GetStack();
162 stack->AddPoint(kStraw);
163 }
164 return kTRUE;
165}
166
171
172
173
175{
176
183 FairRootManager::Instance()->Register("strawtubesPoint", "strawtubes",
185}
186
187
188TClonesArray* strawtubes::GetCollection(Int_t iColl) const
189{
190 if (iColl == 0) { return fstrawtubesPointCollection; }
191 else { return NULL; }
192}
193
195{
197}
198void strawtubes::SetZpositions(Double_t z0, Double_t z1, Double_t z2, Double_t z3, Double_t z4)
199{
200 fT0z = z0;
201 fT1z = z1;
202 fT2z = z2;
203 fT3z = z3;
204 fT4z = z4;
205}
206
207void strawtubes::SetStrawLength(Double_t strawlength)
208{
209 fStraw_length = strawlength;
210}
211
212void strawtubes::SetInnerStrawDiameter(Double_t innerstrawdiameter)
213{
214 fInner_Straw_diameter = innerstrawdiameter;
215}
216
217void strawtubes::SetOuterStrawDiameter(Double_t outerstrawdiameter)
218{
219 fOuter_Straw_diameter = outerstrawdiameter;
220}
221
222
223void strawtubes::SetStrawPitch(Double_t strawpitch,Double_t layer_offset, Double_t plane_offset)
224{
225 fStraw_pitch = strawpitch;
226 fOffset_layer12 = layer_offset;
227 fOffset_plane12 = plane_offset;
228}
229
230void strawtubes::SetDeltazLayer(Double_t deltazlayer)
231{
232 fDeltaz_layer12 = deltazlayer;
233}
234
235void strawtubes::SetDeltazPlane(Double_t deltazplane)
236{
237 fDeltaz_plane12 = deltazplane;
238}
239
240void strawtubes::SetStrawsPerLayer(Int_t strawsperlayer)
241{
242 fStraws_per_layer = strawsperlayer;
243}
244
245void strawtubes::SetStereoAngle(Int_t stereoangle)
246{
247 fView_angle = stereoangle;
248 fcosphi=cos(TMath::Pi()*fView_angle/180.);
249 fsinphi=sin(TMath::Pi()*fView_angle/180.);
250}
251
252void strawtubes::SetWireThickness(Double_t wirethickness)
253{
254 fWire_thickness = wirethickness;
255}
256
257void strawtubes::SetDeltazView(Double_t deltazview)
258{
259 fDeltaz_view = deltazview;
260}
261
262void strawtubes::SetDeltazFrame(Double_t deltazframe)
263{
264 fDeltaz_frame = deltazframe;
265}
266
267void strawtubes::SetFrameLateralWidth(Double_t framelateralwidth)
268{
269 fFrame_lateral_width = framelateralwidth;
270}
271
272void strawtubes::SetFrameMaterial(TString framematerial)
273{
274 fFrame_material = framematerial;
275}
276
277
278void strawtubes::SetStrawLength12(Double_t strawlength12)
279{
280 fStraw_length_12 = strawlength12;
281}
282
283void strawtubes::SetStrawLengthVeto(Double_t strawlengthveto)
284{
285 fStraw_length_veto = strawlengthveto;
286}
287
288
289void strawtubes::SetVacBox_x(Double_t vacbox_x)
290{
291 fVacBox_x = vacbox_x;
292}
293
294void strawtubes::SetVacBox_y(Double_t vacbox_y)
295{
296 fVacBox_y = vacbox_y;
297}
298
299void strawtubes::SetVetoYDim(Double_t vetoydim)
300{
301 fvetoydim = vetoydim;
303 //std::cout<<"fStraws_per_layer_veto "<<fStraws_per_layer_veto<<" fvetoydim "<< fvetoydim<<std::endl;
304}
305void strawtubes::SetTr12YDim(Double_t tr12ydim)
306{
307 ftr12ydim = tr12ydim;
309 //std::cout<<"fStraws_per_layer_tr12 "<<fStraws_per_layer_tr12<< " ftr12ydim "<< ftr12ydim <<std::endl;
310}
311void strawtubes::SetTr34YDim(Double_t tr34ydim)
312{
313 ftr34ydim = tr34ydim;
315 //std::cout<<"fStraws_per_layer_tr34 "<<fStraws_per_layer_tr34<<" ftr34ydim "<< ftr34ydim << std::endl;
316}
317
318
320{
325 TGeoVolume *top = gGeoManager->GetTopVolume();
326 InitMedium("air");
327 TGeoMedium *air = gGeoManager->GetMedium("air");
328 InitMedium("ShipSens");
329 TGeoMedium *Se = gGeoManager->GetMedium("ShipSens");
330 InitMedium("aluminium");
331 TGeoMedium *Al = gGeoManager->GetMedium("aluminium");
332 InitMedium("mylar");
333 TGeoMedium *mylar = gGeoManager->GetMedium("mylar");
334 InitMedium("STTmix9010_2bar");
335 TGeoMedium *sttmix9010_2bar = gGeoManager->GetMedium("STTmix9010_2bar");
336 InitMedium("tungsten");
337 TGeoMedium *tungsten = gGeoManager->GetMedium("tungsten");
339 TGeoMedium *FrameMatPtr = gGeoManager->GetMedium(fFrame_material);
340 InitMedium("vacuum");
341 TGeoMedium *med = gGeoManager->GetMedium("vacuum");
342
343 gGeoManager->SetVisLevel(4);
344 gGeoManager->SetTopVisible();
345
346 //epsilon to avoid overlapping volumes
347 //Double_t eps=0.1;
348 Double_t eps=0.0001;
349 Double_t epsS=0.0001;
350 //width of frame
351 Double_t framewidth = 40.;
352 //width of view
353 Double_t viewwidth = fDeltaz_view-eps;
354 //width of plane
355 Double_t planewidth = fOuter_Straw_diameter+fDeltaz_layer12-eps;
356 //width of layer
357 Double_t layerwidth = fOuter_Straw_diameter;
358
359 Double_t rmin, rmax, dx, dy, dz, z, density,a,w;
360 Double_t par[20];
361 Int_t nel,numed,isvol,ifield;
362 Double_t radl, absl, TStationz;
363
364 Double_t yDim = (fStraws_per_layer+1) * fStraw_pitch /2. ; // put everything inside vacbox
365 //arguments of box are half-lengths;
366 TGeoBBox *detbox1 = new TGeoBBox("detbox1", fStraw_length+fFrame_lateral_width, ftr34ydim+fFrame_lateral_width, fDeltaz_frame/2.);
367 TGeoBBox *detbox2 = new TGeoBBox("detbox2", fStraw_length+eps, ftr34ydim+eps, fDeltaz_frame/2.+eps);
368
369 TGeoBBox *detbox1_12 = new TGeoBBox("detbox1_12", fStraw_length_12+fFrame_lateral_width, ftr12ydim+fFrame_lateral_width, fDeltaz_frame/2.);
370 TGeoBBox *detbox2_12 = new TGeoBBox("detbox2_12", fStraw_length_12+eps, ftr12ydim+eps, fDeltaz_frame/2.+eps);
371 TGeoCompositeShape *detcomp1 = new TGeoCompositeShape("detcomp1", "detbox1-detbox2");
372 TGeoCompositeShape *detcomp1_12 = new TGeoCompositeShape("detcomp1_12", "detbox1_12-detbox2_12");
373 TGeoBBox *vetovacbox;
374 TGeoCompositeShape *detcomp1_veto;
375 if (fStraw_length_veto>1){
376 TGeoBBox *detbox1_veto = new TGeoBBox("detbox1_veto", fStraw_length_veto+1., fvetoydim+1., fDeltaz_view/2.);
377 TGeoBBox *detbox2_veto = new TGeoBBox("detbox2_veto", fStraw_length_veto+eps, fvetoydim+eps, fDeltaz_view/2.+eps);
378
379 //the station sits inside a vacuum box
380 //TGeoBBox *vetovacbox = new TGeoBBox("Vetovacbox", fVacBox_x, fVacBox_y, fDeltaz_view );
381 vetovacbox = new TGeoBBox("Vetovacbox", fStraw_length_veto+75., fvetoydim+75., fDeltaz_view );
382 detcomp1_veto = new TGeoCompositeShape("detcomp1_veto", "detbox1_veto-detbox2_veto");
383 }
384 // Volume: straw
385 rmin = fInner_Straw_diameter/2.;
386 rmax = fOuter_Straw_diameter/2.;
387 //third argument is halflength of tube
388 TGeoTube *straw_tube = new TGeoTube("straw",rmin,rmax,fStraw_length-4.*eps);
389 TGeoVolume *straw = new TGeoVolume("straw",straw_tube, mylar);
390 straw->SetLineColor(4);
391 straw->SetVisibility(kTRUE);
392 TGeoTube *straw_tube_12 = new TGeoTube("straw_12",rmin,rmax,fStraw_length_12-4.*eps);
393 TGeoVolume *straw_12 = new TGeoVolume("straw_12",straw_tube_12, mylar);
394 straw_12->SetLineColor(4);
395 straw_12->SetVisibility(kTRUE);
396 TGeoVolume *straw_veto;
397 if (fStraw_length_veto>1){
398 TGeoTube *straw_tube_veto = new TGeoTube("straw_veto",rmin,rmax,fStraw_length_veto-4.*eps);
399 straw_veto = new TGeoVolume("straw_veto",straw_tube_veto, mylar);
400 straw_veto->SetLineColor(4);
401 straw_veto->SetVisibility(kTRUE);
402 }
403 // Volume: gas
404 rmin = fWire_thickness/2.+epsS;
405 rmax = fInner_Straw_diameter/2.-epsS;
406 TGeoTube *gas_tube = new TGeoTube("gas",rmin,rmax,fStraw_length-6.*eps);
407 TGeoVolume *gas = new TGeoVolume("gas",gas_tube, sttmix9010_2bar);
408 gas->SetLineColor(5); //only the gas is sensitive
409 AddSensitiveVolume(gas);
410 TGeoTube *gas_tube_12 = new TGeoTube("gas_12",rmin,rmax,fStraw_length_12-6.*eps);
411 TGeoVolume *gas_12 = new TGeoVolume("gas_12",gas_tube_12, sttmix9010_2bar);
412 gas_12->SetLineColor(5); //only the gas is sensitive
413 AddSensitiveVolume(gas_12);
414 TGeoVolume *gas_veto;
415 TGeoBBox *layer_veto;
416 if (fStraw_length_veto>1){
417 TGeoTube *gas_tube_veto = new TGeoTube("gas_veto",rmin,rmax,fStraw_length_veto-6.*eps);
418 gas_veto = new TGeoVolume("gas_veto",gas_tube_veto, sttmix9010_2bar);
419 gas_veto->SetLineColor(5); //only the gas is sensitive
420 AddSensitiveVolume(gas_veto);
421 }
422
423 // Volume: wire
424 rmin=0.;
425 rmax = fWire_thickness/2.;
426 TGeoTube *wire_tube = new TGeoTube("wire",rmin,rmax,fStraw_length-8.*eps);
427 TGeoVolume *wire = new TGeoVolume("wire",wire_tube, tungsten);
428 wire->SetLineColor(6);
429 TGeoTube *wire_tube_12 = new TGeoTube("wire_12",rmin,rmax,fStraw_length_12-8.*eps);
430 TGeoVolume *wire_12 = new TGeoVolume("wire_12",wire_tube_12, tungsten);
431 wire_12->SetLineColor(6);
432 Int_t statnb;
433 if (fStraw_length_veto>1){
434 TGeoTube *wire_tube_veto = new TGeoTube("wire_veto",rmin,rmax,fStraw_length_veto-8.*eps);
435 TGeoVolume *wire_veto = new TGeoVolume("wire_veto",wire_tube_veto, tungsten);
436 wire_veto->SetLineColor(6);
437 statnb=5;
438 // statnb = station number. 1,2,3,4 tracking stations, 5 veto station
439 TGeoVolume *vetovac = new TGeoVolume("Veto", vetovacbox, med);
440
441 top->AddNode(vetovac, statnb, new TGeoTranslation(0,0,fT0z));
442 //vetovac->SetVisDaughters(kTRUE);
443 //vetovac->SetTransparency(80);
444
445 //Veto station
446 //vnb=view number; pnb=plane number; lnb=layer number; snb=straw number
447 TString nmveto = "Veto";
448 TStationz=fT0z;
449 for (Int_t vnb=0; vnb<2; vnb++) {
450 //view loop
451 Double_t angle;
452 TGeoRotation r5;
453 TGeoTranslation t5;
454 nmveto = "Veto";
455 switch (vnb) {
456 case 0:
457 angle=0.;
458 nmveto = nmveto+"_x";
459 break;
460 case 1:
461 angle=fView_angle;
462 nmveto = nmveto+"_u";
463 break;
464 default:
465 angle=0.;
466 nmveto = nmveto+"_x";
467 }
468
469 TGeoVolume *viewframe_veto = new TGeoVolume(nmveto, detcomp1_veto, Al);
470 //z-translate the viewframe_veto from station z pos
471 t5.SetTranslation(0, 0,(vnb-1./2.)*fDeltaz_view);
472 //rotate the frame box by angle degrees around the z axis (0 if it isn't a stereo view)
473 r5.SetAngles(angle,0,0);
474 TGeoCombiTrans c5(t5, r5);
475 TGeoHMatrix *h5 = new TGeoHMatrix(c5);
476 vetovac->AddNode(viewframe_veto, statnb*10000000+vnb*1000000,h5);
477 viewframe_veto->SetLineColor(kRed);
478
479 TGeoTranslation t5p;
480
481 for (Int_t pnb=0; pnb<2; pnb++) {
482 //plane loop
483 TString nmplane_veto = nmveto+"_plane_"; nmplane_veto += pnb;
484 //width of the planes: z distance between layers + outer straw diameter
485 TGeoBBox *plane_veto = new TGeoBBox("plane box", fStraw_length_veto+eps/2., fvetoydim+eps/2., planewidth/2.+3.*eps/2.);
486 TGeoVolume *planebox_veto = new TGeoVolume(nmplane_veto, plane_veto, med);
487 //the planebox sits in the viewframe
488 //hence z translate the plane wrt to the view
489
490 t5.SetTranslation(0, 0,(vnb-1./2.)*fDeltaz_view+(pnb-1./2.)*fDeltaz_plane12);
491 TGeoCombiTrans d5(t5, r5);
492 TGeoHMatrix *j5 = new TGeoHMatrix(d5);
493 vetovac->AddNode(planebox_veto, statnb*10000000+vnb*1000000+pnb*100000,j5);
494
495 for (Int_t lnb=0; lnb<2; lnb++) {
496 TString nmlayer_veto = nmplane_veto+"_layer_"; nmlayer_veto += lnb;
497 //width of the layer: (plane width-2eps)/2
498 layer_veto = new TGeoBBox("layer box_veto", fStraw_length_veto+eps/4., fvetoydim+eps/4., layerwidth/2.+eps/4.);
499 TGeoVolume *layerbox_veto = new TGeoVolume(nmlayer_veto, layer_veto, med);
500 //z translate the layerbox wrt the plane box (which is already rotated)
501 planebox_veto->AddNode(layerbox_veto, statnb*10000000+vnb*1000000+pnb*100000+lnb*10000,new TGeoTranslation(0,0,(lnb-1./2.)*fDeltaz_layer12));
502 //layer loop
503 TGeoRotation r6v;
504 TGeoTranslation t6v;
505 Int_t nr = statnb*10000000+vnb*1000000+pnb*100000+lnb*10000;
506 for (Int_t snb=1; snb<fStraws_per_layer_veto; snb++) {
507 //straw loop
508 t6v.SetTranslation(0,fvetoydim-fStraw_pitch*snb-fOffset_plane12*pnb+lnb*fOffset_layer12,0);
509 r6v.SetAngles(90,90,0);
510 TGeoCombiTrans c6v(t6v, r6v);
511 TGeoHMatrix *h6v = new TGeoHMatrix(c6v);
512
513 layerbox_veto->AddNode(straw_veto,nr+1000+snb,h6v);
514 layerbox_veto->AddNode(gas_veto, nr+2000+snb,h6v);
515 layerbox_veto->AddNode(wire_veto, nr+3000+snb,h6v);
516 //end of straw loop
517 }
518 //end of layer loop
519 }
520 //end of plane loop
521 }
522 //end of view loop
523 } }
524 // end of veto station loop
525 //Tracking stations
526 //statnb=station number; vnb=view number; pnb=plane number; lnb=layer number; snb=straw number
527
528 //New scalable endpoints of vacuum boxes which cover rotated view frames
529
530 Double_t x_prime = (fVacBox_x+0.6*fFrame_lateral_width+2*eps)*TMath::Cos(fView_angle*TMath::Pi()/180.0) + (ftr34ydim+fFrame_lateral_width+2*eps)*TMath::Sin(fView_angle*TMath::Pi()/180.0);
531 Double_t y_prime = (fVacBox_x+0.6*fFrame_lateral_width+2*eps)*TMath::Sin(fView_angle*TMath::Pi()/180.0) + (ftr34ydim+fFrame_lateral_width+2*eps)*TMath::Cos(fView_angle*TMath::Pi()/180.0);
532 Double_t x_prime_12 = (fStraw_length_12+fFrame_lateral_width+2*eps)*TMath::Cos(fView_angle*TMath::Pi()/180.0) + (ftr12ydim+fFrame_lateral_width+2*eps)*TMath::Sin(fView_angle*TMath::Pi()/180.0);
533 Double_t y_prime_12 = (fStraw_length_12+fFrame_lateral_width+2*eps)*TMath::Sin(fView_angle*TMath::Pi()/180.0) + (ftr12ydim+fFrame_lateral_width+2*eps)*TMath::Cos(fView_angle*TMath::Pi()/180.0);
534
535 TGeoBBox *vacbox = new TGeoBBox("vacbox", x_prime+eps, y_prime+eps, 2.*fDeltaz_view);
536 TGeoBBox *vacbox_12 = new TGeoBBox("vacbox_12", x_prime_12+eps, y_prime_12+eps, 2.*fDeltaz_view);
537
538 fFrame_material.ToLower();
539
540 for (statnb=1;statnb<5;statnb++) {
541 // tracking station loop
542 TString nmstation = "Tr";
543 std::stringstream ss;
544 ss << statnb;
545 nmstation = nmstation + ss.str();
546 TGeoVolume *vac;
547 TGeoVolume *vac_12;
548 switch (statnb) {
549 case 1:
550 TStationz=fT1z;
551 vac_12 = new TGeoVolume(nmstation, vacbox_12, med);
552 top->AddNode(vac_12, statnb, new TGeoTranslation(0,0,TStationz));
553 break;
554 case 2:
555 TStationz=fT2z;
556 vac_12 = new TGeoVolume(nmstation, vacbox_12, med);
557 top->AddNode(vac_12, statnb, new TGeoTranslation(0,0,TStationz));
558 break;
559 case 3:
560 TStationz=fT3z;
561 vac = new TGeoVolume(nmstation, vacbox, med);
562 top->AddNode(vac, statnb, new TGeoTranslation(0,0,TStationz));
563 break;
564 case 4:
565 TStationz=fT4z;
566 vac = new TGeoVolume(nmstation, vacbox, med);
567 top->AddNode(vac, statnb, new TGeoTranslation(0,0,TStationz));
568 break;
569 default:
570 break;
571 }
572
573 if ((statnb==1)||(statnb==2)) {
574 for (Int_t vnb=0; vnb<4; vnb++) {
575 //view loop
576 TString nmview_12;
577
578 Double_t angle;
579 TGeoRotation r5;
580 TGeoTranslation t5;
581
582 switch (vnb) {
583 case 0:
584 angle=0.;
585 nmview_12 = nmstation+"_x1";
586 break;
587 case 1:
588 angle=fView_angle;
589 nmview_12 = nmstation+"_u";
590 break;
591 case 2:
592 angle=-fView_angle;
593 nmview_12 = nmstation+"_v";
594 break;
595 case 3:
596 angle=0.;
597 nmview_12 = nmstation+"_x2";
598 break;
599 default:
600 angle=0.;
601 nmview_12 = nmstation+"_x1";
602 }
603
604 TGeoVolume *viewframe_12;
605 if (fFrame_material.Contains("aluminium")) {
606 viewframe_12 = new TGeoVolume(nmview_12, detcomp1_12, Al);
607 }
608 else {
609 viewframe_12 = new TGeoVolume(nmview_12, detcomp1_12, FrameMatPtr);
610 }
611
612
613 //z-translate the viewframe from station z pos
614 t5.SetTranslation(0, 0,(vnb-3./2.)*(fDeltaz_view));
615 //rotate the frame box by angle degrees around the z axis (0 if it isn't a stereo view)
616 r5.SetAngles(angle,0,0);
617 TGeoCombiTrans c5(t5, r5);
618 TGeoHMatrix *h5 = new TGeoHMatrix(c5);
619
620 vac_12->AddNode(viewframe_12, statnb*10000000+vnb*1000000,h5);
621 viewframe_12->SetLineColor(kRed);
622
623 for (Int_t pnb=0; pnb<2; pnb++) {
624 //plane loop
625 TString nmplane_12 = nmview_12+"_plane_";
626 nmplane_12 += pnb;
627 TGeoBBox *plane_12 = new TGeoBBox("plane box_12", fStraw_length_12+eps/2, ftr12ydim+eps/2, planewidth/2.+3.*eps/2);
628 TGeoVolume *planebox_12 = new TGeoVolume(nmplane_12, plane_12, med);
629
630 //the planebox sits in the viewframe
631 //hence z translate the plane wrt to the view
632 TGeoTranslation t3;
633 t3.SetTranslation(0, 0,(vnb-3./2.)*(fDeltaz_view)+(pnb-1./2.)*fDeltaz_plane12);
634 TGeoCombiTrans d3(t3, r5);
635 TGeoHMatrix *j3 = new TGeoHMatrix(d3);
636 vac_12->AddNode(planebox_12, statnb*10000000+vnb*1000000+pnb*100000,j3);
637
638 for (Int_t lnb=0; lnb<2; lnb++) {
639
640 //width of the layer: (plane width-2*eps)/2
641
642 //z translate the layerbox wrt the plane box (which is already rotated)
643 TString nmlayer_12 = nmplane_12+"_layer_"; nmlayer_12 += lnb;
644 TGeoBBox *layer_12 = new TGeoBBox("layer box_12", fStraw_length_12+eps/4, ftr12ydim+eps/4, layerwidth/2.+eps/4);
645 TGeoVolume *layerbox_12 = new TGeoVolume(nmlayer_12, layer_12, med);
646 planebox_12->AddNode(layerbox_12, statnb*10000000+vnb*1000000+pnb*100000+lnb*10000,new TGeoTranslation(0,0,(lnb-1./2.)*fDeltaz_layer12));
647
648 //layer loop
649 TGeoRotation r6s;
650 TGeoTranslation t6s;
651 for (Int_t snb=1; snb<fStraws_per_layer_tr12; snb++) {
652 //straw loop
653 t6s.SetTranslation(0,ftr12ydim-fStraw_pitch*snb-fOffset_plane12*pnb+lnb*fOffset_layer12,0);
654 r6s.SetAngles(90,90,0);
655 TGeoCombiTrans c6s(t6s, r6s);
656 TGeoHMatrix *h6s = new TGeoHMatrix(c6s);
657 layerbox_12->AddNode(straw_12,statnb*10000000+vnb*1000000+pnb*100000+lnb*10000+1000+snb,h6s);
658 layerbox_12->AddNode(gas_12,statnb*10000000+vnb*1000000+pnb*100000+lnb*10000+2000+snb,h6s);
659 layerbox_12->AddNode(wire_12,statnb*10000000+vnb*1000000+pnb*100000+lnb*10000+3000+snb,h6s);
660
661 //end of straw loop
662 }
663 //end of layer loop
664 }
665 //end of plane loop
666 }
667 //end of view loop
668 }
669 //end of station1/2
670 }
671 if ((statnb==3)||(statnb==4)) {
672 for (Int_t vnb=0; vnb<4; vnb++) {
673 //view loop
674 TString nmview;
675 Double_t angle;
676 TGeoRotation r5;
677 TGeoTranslation t5;
678
679 switch (vnb) {
680 case 0:
681 angle=0.;
682 nmview = nmstation+"_x1";
683 break;
684 case 1:
685 angle=fView_angle;
686 nmview = nmstation+"_u";
687 break;
688 case 2:
689 angle=-fView_angle;
690 nmview = nmstation+"_v";
691 break;
692 case 3:
693 angle=0.;
694 nmview = nmstation+"_x2";
695 break;
696 default:
697 angle=0.;
698 nmview = nmstation+"_x1";
699 }
700
701 TGeoVolume *viewframe;
702 if (fFrame_material.Contains("aluminium")) {
703 viewframe = new TGeoVolume(nmview, detcomp1, Al);
704 }
705 else {
706 viewframe = new TGeoVolume(nmview, detcomp1, FrameMatPtr);
707 }
708
709
710 //z-translate the viewframe from station z pos
711 t5.SetTranslation(0, 0,(vnb-3./2.)*(fDeltaz_view));
712 //rotate the frame box by angle degrees around the z axis (0 if it isn't a stereo view)
713 r5.SetAngles(angle,0,0);
714 TGeoCombiTrans c5(t5, r5);
715 TGeoHMatrix *h5 = new TGeoHMatrix(c5);
716
717 vac->AddNode(viewframe, statnb*10000000+vnb*1000000,h5);
718 viewframe->SetLineColor(kRed);
719
720 for (Int_t pnb=0; pnb<2; pnb++) {
721 //plane loop
722 TString nmplane = nmview+"_plane_";
723 nmplane += pnb;
724 TGeoBBox *plane = new TGeoBBox("plane box", fStraw_length+eps/2, ftr34ydim+eps/2, planewidth/2.+3.*eps/2);
725 TGeoVolume *planebox = new TGeoVolume(nmplane, plane, med);
726
727 //the planebox sits in the viewframe
728 //hence z translate the plane wrt to the view
729 TGeoTranslation t3;
730 t3.SetTranslation(0, 0,(vnb-3./2.)*(fDeltaz_view)+(pnb-1./2.)*fDeltaz_plane12);
731 TGeoCombiTrans d3(t3, r5);
732 TGeoHMatrix *j3 = new TGeoHMatrix(d3);
733 vac->AddNode(planebox, statnb*10000000+vnb*1000000+pnb*100000,j3);
734
735 for (Int_t lnb=0; lnb<2; lnb++) {
736
737 //width of the layer: (plane width-2*eps)/2
738
739 //z translate the layerbox wrt the plane box (which is already rotated)
740 TString nmlayer = nmplane+"_layer_"; nmlayer += lnb;
741 TGeoBBox *layer = new TGeoBBox("layer box", fStraw_length+eps/4, ftr34ydim+eps/4, layerwidth/2.+eps/4);
742 TGeoVolume *layerbox = new TGeoVolume(nmlayer, layer, med);
743 planebox->AddNode(layerbox, statnb*10000000+vnb*1000000+pnb*100000+lnb*10000,new TGeoTranslation(0,0,(lnb-1./2.)*fDeltaz_layer12));
744
745 //layer loop
746 TGeoRotation r6s;
747 TGeoTranslation t6s;
748 for (Int_t snb=1; snb<fStraws_per_layer_tr34; snb++) {
749 //straw loop
750 t6s.SetTranslation(0,ftr34ydim-fStraw_pitch*snb-fOffset_plane12*pnb+lnb*fOffset_layer12,0);
751 r6s.SetAngles(90,90,0);
752 TGeoCombiTrans c6s(t6s, r6s);
753 TGeoHMatrix *h6s = new TGeoHMatrix(c6s);
754 layerbox->AddNode(straw,statnb*10000000+vnb*1000000+pnb*100000+lnb*10000+1000+snb,h6s);
755 layerbox->AddNode(gas,statnb*10000000+vnb*1000000+pnb*100000+lnb*10000+2000+snb,h6s);
756 layerbox->AddNode(wire,statnb*10000000+vnb*1000000+pnb*100000+lnb*10000+3000+snb,h6s);
757
758 //end of straw loop
759 }
760 //end of layer loop
761 }
762 //end of plane loop
763 }
764 //end of view loop
765 }
766 //end of station1/2
767 }
768
769
770 //end of station
771 }
772 std::cout << "tracking stations added" << std::endl;
773}
774// ----- Public method StrawDecode -------------------------------------------
775// ----- returns station layer ... numbers -----------------------------------
776void strawtubes::StrawDecode(Int_t detID,int &statnb,int &vnb,int &pnb,int &lnb, int &snb)
777{
778 statnb = detID/10000000;
779 vnb = (detID - statnb*10000000)/1000000;
780 pnb = (detID - statnb*10000000 - vnb*1000000)/100000;
781 lnb = (detID - statnb*10000000 - vnb*1000000 - pnb*100000)/10000;
782 snb = detID - statnb*10000000 - vnb*1000000 - pnb*100000 - lnb*10000 - 2000;
783}
784// ----- Public method StrawEndPoints -------------------------------------------
785// ----- returns top(left) and bottom(right) coordinate of straw -----------------------------------
786void strawtubes::StrawEndPoints(Int_t fDetectorID, TVector3 &vbot, TVector3 &vtop)
787// method to get end points from TGeoNavigator
788{
789 Int_t statnb = fDetectorID/10000000;
790 Int_t vnb = (fDetectorID - statnb*10000000)/1000000;
791 Int_t pnb = (fDetectorID- statnb*10000000 - vnb*1000000)/100000;
792 Int_t lnb = (fDetectorID - statnb*10000000 - vnb*1000000 - pnb*100000)/10000;
793 TString stat = "Tr";stat+=+statnb;stat+="_";stat+=statnb;
794 if (statnb==5){stat="Veto_5";}
795 TString view;
796 switch (vnb) {
797 case 0:
798 view = "_x1";
799 if (statnb==5){view = "_x";}
800 break;
801 case 1:
802 view = "_u";
803 break;
804 case 2:
805 view = "_v";
806 break;
807 case 3:
808 view = "_x2";
809 break;
810 default:
811 view = "_x1";}
812 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
813 TString prefix = "Tr";
814 if (statnb==5){prefix="Veto";}
815 else{prefix+=statnb;}
816 prefix+=view;prefix+="_plane_";prefix+=pnb;prefix+="_";
817 TString plane = prefix;plane+=statnb;plane+=vnb;plane+=+pnb;plane+="00000";
818 TString layer = prefix+"layer_";layer+=lnb;layer+="_";layer+=statnb;layer+=vnb;layer+=pnb;layer+=lnb;layer+="0000";
819 TString wire = "wire_";
820 if (statnb==5){wire+="veto_";}
821 wire+=(fDetectorID+1000);
822 if (statnb<3){wire = "wire_12_";wire+=(fDetectorID+1000);}
823 TString path = "/";path+=stat;path+="/";path+=plane;path+="/";path+=layer;path+="/";path+=wire;
824 Bool_t rc = nav->cd(path);
825 if (not rc){
826 cout << "strawtubes::StrawDecode, TgeoNavigator failed "<<path<<endl;
827 return;
828 }
829 TGeoNode* W = nav->GetCurrentNode();
830 TGeoTube* S = dynamic_cast<TGeoTube*>(W->GetVolume()->GetShape());
831 Double_t top[3] = {0,0,S->GetDZ()};
832 Double_t bot[3] = {0,0,-S->GetDZ()};
833 Double_t Gtop[3],Gbot[3];
834 nav->LocalToMaster(top, Gtop); nav->LocalToMaster(bot, Gbot);
835 vtop.SetXYZ(Gtop[0],Gtop[1],Gtop[2]);
836 vbot.SetXYZ(Gbot[0],Gbot[1],Gbot[2]);
837}
838void strawtubes::StrawEndPointsOriginal(Int_t detID, TVector3 &bot, TVector3 &top)
839// method to get end points by emulating the geometry
840{
841 Double_t sinangle,cosangle;
842 Int_t statnb,vnb,pnb,lnb,snb;
843 StrawDecode(detID,statnb,vnb,pnb,lnb,snb);
844 switch (vnb) {
845 case 0:
846 sinangle=0.;
847 cosangle=1.;
848 break;
849 case 1:
850 sinangle=fsinphi;
851 cosangle=fcosphi;
852 break;
853 case 2:
854 sinangle=-fsinphi;
855 cosangle=fcosphi;
856 break;
857 case 3:
858 sinangle=0.;
859 cosangle=1.;
860 break;
861 default:
862 sinangle=0.;
863 cosangle=1.;
864 }
865
866 //cout << "DetID" << detID << " statnb "<<statnb<<" vnb " << vnb << " pnb " << pnb <<" lnb "<< lnb << " snb " << snb << endl;
867 // from ConstructGeometry above
868 Double_t yDim = (fStraws_per_layer+1) * fStraw_pitch /2. ;
869 Double_t ypos = 0.;
870 Double_t xtop = 0.;
871 Double_t ytop = 0.;
872 Double_t xbot = 0.;
873 Double_t ybot = 0.;
874 if ((statnb==1)|| (statnb==2)) {
876 xtop = -fStraw_length_12*cosangle - ypos*sinangle;
877 ytop = -fStraw_length_12*sinangle + ypos*cosangle;
878 xbot = fStraw_length_12*cosangle - ypos*sinangle;
879 ybot = fStraw_length_12*sinangle + ypos*cosangle;}
880 if ((statnb==3)|| (statnb==4)) {
882 xtop = -fStraw_length*cosangle - ypos*sinangle;
883 ytop = -fStraw_length*sinangle + ypos*cosangle;
884 xbot = fStraw_length*cosangle - ypos*sinangle;
885 ybot = fStraw_length*sinangle + ypos*cosangle; }
886 if (statnb==5) {
888 xtop = -fStraw_length_veto*cosangle - ypos*sinangle;
889 ytop = -fStraw_length_veto*sinangle + ypos*cosangle;
890 xbot = fStraw_length_veto*cosangle - ypos*sinangle;
891 ybot = fStraw_length_veto*sinangle + ypos*cosangle; }
892
893 Double_t TStationz;
894 switch (statnb) {
895 case 1:
896 TStationz = fT1z;
897 break;
898 case 2:
899 TStationz = fT2z;
900 break;
901 case 3:
902 TStationz = fT3z;
903 break;
904 case 4:
905 TStationz = fT4z;
906 break;
907 case 5:
908 TStationz = fT0z;
909 break;
910 default:
911 TStationz = fT0z;
912 }
913 Double_t zpos;
914 if (statnb < 5){
915 zpos = TStationz+(vnb-3./2.)*fDeltaz_view+(pnb-1./2.)*fDeltaz_plane12+(lnb-1./2.)*fDeltaz_layer12;
916 }else{
917 zpos = TStationz+(vnb-1./2.)*fDeltaz_view+(pnb-1./2.)*fDeltaz_plane12+(lnb-1./2.)*fDeltaz_layer12;
918 }
919 top = TVector3(xtop,ytop,zpos);
920 bot = TVector3(xbot,ybot,zpos);
921 //cout << "dets="<< xtop << " "<< xbot << " "<< ytop << " "<< ybot<< " "<< ypos<< " "<< fStraw_length<< " "<<detID<<endl;
922 //cout << "top/bot="<< snb << " "<< vnb << " "<< pnb << " "<< lnb << " "<< ypos<< " "<< fOffset_layer12<< " "<<fOffset_plane12<<endl;
923}
924strawtubesPoint* strawtubes::AddHit(Int_t trackID, Int_t detID,
925 TVector3 pos, TVector3 mom,
926 Double_t time, Double_t length,
927 Double_t eLoss, Int_t pdgCode, Double_t dist2Wire)
928{
929 TClonesArray& clref = *fstrawtubesPointCollection;
930 Int_t size = clref.GetEntriesFast();
931 //std::cout << "adding hit detid " <<detID<<std::endl;
932 return new(clref[size]) strawtubesPoint(trackID, detID, pos, mom,
933 time, length, eLoss, pdgCode, dist2Wire);
934}
935
@ kStraw
Double_t fT2z
z-position of tracking station 1
Definition strawtubes.h:118
Int_t fVolumeID
track index
Definition strawtubes.h:110
virtual void EndOfEvent()
strawtubesPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgCode, Double_t dist2Wire)
void SetDeltazPlane(Double_t deltazplane)
void SetZpositions(Double_t z0, Double_t z1, Double_t z2, Double_t z3, Double_t z4)
void SetVacBox_x(Double_t vacbox_x)
TLorentzVector fMom
position at entrance
Definition strawtubes.h:112
Double_t fDeltaz_view
Material of the view frame.
Definition strawtubes.h:139
Int_t fStraws_per_layer_tr34
Number of straws in one tr12 layer.
Definition strawtubes.h:147
TLorentzVector fPos
volume id
Definition strawtubes.h:111
Double_t fStraw_length_12
Length (y) of a straw.
Definition strawtubes.h:122
Int_t fStraws_per_layer
Offset (x) between straws of plane1&2.
Definition strawtubes.h:131
TClonesArray * fstrawtubesPointCollection
spatial resolution
Definition strawtubes.h:152
Double_t fStraw_length_veto
strawlength for tracking station 1 & 2
Definition strawtubes.h:123
Double_t fInner_Straw_diameter
strawlength for veto station
Definition strawtubes.h:124
Double_t ftr34ydim
y size of tr12 stations
Definition strawtubes.h:144
void SetInnerStrawDiameter(Double_t innerstrawdiameter)
void StrawEndPoints(Int_t detID, TVector3 &top, TVector3 &bot)
void ConstructGeometry()
Double_t fDeltaz_plane12
Distance (z) between layer 1&2.
Definition strawtubes.h:128
void StrawDecode(Int_t detID, int &statnb, int &vnb, int &pnb, int &lnb, int &snb)
virtual void Reset()
Double_t fvetoydim
y size of station vacuumbox
Definition strawtubes.h:142
virtual void Initialize()
TString fFrame_material
Width (x and y) of the material frame.
Definition strawtubes.h:138
void SetStrawsPerLayer(Int_t strawsperlayer)
Double_t fcosphi
Stereo angle of layers in a view.
Definition strawtubes.h:133
Double_t fOffset_layer12
Distance (z) between plane 1&2.
Definition strawtubes.h:129
void SetStrawLengthVeto(Double_t strawlengthveto)
void SetStereoAngle(Int_t stereoangle)
virtual TClonesArray * GetCollection(Int_t iColl) const
Double_t fWire_thickness
Definition strawtubes.h:135
Int_t InitMedium(const char *name)
Double_t fsinphi
Definition strawtubes.h:134
Double_t fStraw_length
z-position of tracking station 4
Definition strawtubes.h:121
Double_t fT3z
z-position of tracking station 2
Definition strawtubes.h:119
void SetStrawLength(Double_t strawlength)
virtual void Register()
Double_t fFrame_lateral_width
Thickness (z) of the meterial frame.
Definition strawtubes.h:137
void SetTr34YDim(Double_t tr34ydim)
Double_t fELoss
length
Definition strawtubes.h:115
void SetVetoYDim(Double_t vetoydim)
virtual ~strawtubes()
Double_t fT1z
z-position of veto station
Definition strawtubes.h:117
void StrawEndPointsOriginal(Int_t detID, TVector3 &top, TVector3 &bot)
Double_t fStraw_pitch
Outer Straw diameter.
Definition strawtubes.h:126
Double_t fDeltaz_layer12
Distance (x) between straws in one layer.
Definition strawtubes.h:127
Double_t fOffset_plane12
Offset (x) between straws of layer2&1.
Definition strawtubes.h:130
Double_t fT0z
energy loss
Definition strawtubes.h:116
void SetStrawLength12(Double_t strawlength12)
Double_t fTime
momentum at entrance
Definition strawtubes.h:113
Double_t ftr12ydim
y size of veto station
Definition strawtubes.h:143
void SetOuterStrawDiameter(Double_t outerstrawdiameter)
void SetWireThickness(Double_t wirethickness)
void SetStrawPitch(Double_t strawpitch, Double_t layer_offset, Double_t plane_offset)
Double_t fLength
time
Definition strawtubes.h:114
void SetDeltazFrame(Double_t deltazframe)
Int_t fTrackID
Definition strawtubes.h:109
void SetDeltazLayer(Double_t deltazlayer)
void SetTr12YDim(Double_t tr12ydim)
virtual Bool_t ProcessHits(FairVolume *v=0)
Int_t fStraws_per_layer_veto
y size of tr34 stations
Definition strawtubes.h:145
Double_t fVacBox_x
Distance (z) between views.
Definition strawtubes.h:140
void SetDeltazView(Double_t deltazview)
Double_t fVacBox_y
x size of station vacuumbox
Definition strawtubes.h:141
void SetFrameLateralWidth(Double_t framelateralwidth)
Double_t fView_angle
Number of straws in one layer.
Definition strawtubes.h:132
Double_t fOuter_Straw_diameter
Inner Straw diameter.
Definition strawtubes.h:125
Int_t fStraws_per_layer_tr12
Number of straws in one veto layer.
Definition strawtubes.h:146
void SetVacBox_y(Double_t vacbox_y)
Double_t fT4z
z-position of tracking station 3
Definition strawtubes.h:120
Double_t fDeltaz_frame
Thickness of the wire.
Definition strawtubes.h:136
void SetFrameMaterial(TString framematerial)
ClassImp(ecalContFact) ecalContFact