10 #include <TClonesArray.h>
11 #include <TPolyLine3D.h>
12 #include <TPolyMarker3D.h>
16 #include <TGeoGlobalMagField.h>
19 #include <AliCDBManager.h>
20 #include <AliTPCParam.h>
21 #include <AliGeomManager.h>
22 #include <AliTPCcalibDB.h>
23 #include <AliTrackPointArray.h>
24 #include <AliCluster.h>
26 #include <AliTPCLaserTrack.h>
29 #include "AliToyMCDrawer.h"
30 #include "AliToyMCEvent.h"
31 #include "AliToyMCTrack.h"
33 // Visualization class. To use
35 // AliToyMCDrawer* draw = new AliToyMCDrawer()
36 // draw->SetFileName("path/to/toyMC.root")
38 // draw->FillEventArray(Int_t centerEventNumber)
40 // draw->FillEventArray(Double_t time)
41 // to display with a certain event in the center or at a certain time
43 // draw->DrawEvents(Bool_t both, Bool_t before)
44 // where "both" will display events before and after the middle event and
45 // before will show also events before (after) the middle event if true (false)
46 // when "both" is false
49 ClassImp(AliToyMCDrawer);
51 AliToyMCDrawer::AliToyMCDrawer()
66 ,fRoc(AliTPCROC::Instance())
69 ,fProjectionType("XYT")
77 fEventArray = new TClonesArray("AliToyMCEvent");
79 fTPCParam = AliTPCcalibDB::Instance()->GetParameters();
80 fTPCParam->ReadGeoMatrices();
81 fDriftVel = fTPCParam->GetDriftV();
82 fMaxZ0 =fTPCParam->GetZLength();
83 fTimeRange = 2*fMaxZ0/fDriftVel;
85 fPoints = new TClonesArray("TPolyMarker3D");
86 fDistPoints = new TClonesArray("TPolyMarker3D");
88 //________________________________________________________________
89 AliToyMCDrawer::AliToyMCDrawer(const AliToyMCDrawer &drawer)
91 ,fInputTree(drawer.fInputTree)
92 ,fInFile(drawer.fInFile)
93 ,fFileName(drawer.fFileName)
94 ,fEvent(drawer.fEvent)
95 ,fEventArray(drawer.fEventArray)
96 ,fDispHist(drawer.fDispHist)
97 , fCenterTime(drawer.fCenterTime)
98 ,fDriftVel(drawer.fDriftVel)
99 ,fTPCParam(drawer.fTPCParam)
100 ,fMaxZ0(drawer.fMaxZ0)
101 ,fIFCRadius(drawer.fIFCRadius)
102 ,fOFCRadius(drawer.fOFCRadius)
103 ,fTimeRange(drawer.fTimeRange)
105 ,fPoints(drawer.fPoints)
106 ,fDistPoints(drawer.fDistPoints)
107 ,fProjectionType("XYT")
117 //_____________________________________________________
118 AliToyMCDrawer& AliToyMCDrawer::operator = (const AliToyMCDrawer &drawer)
120 //assignment operator
121 if (&drawer == this) return *this;
122 new (this) AliToyMCDrawer(drawer);
127 //________________________________________________________________
128 AliToyMCDrawer::~AliToyMCDrawer()
137 //________________________________________________________________
138 Int_t AliToyMCDrawer::FillEventArray(Double_t snapShotTime)
140 if(fFileName.IsNull()) {
141 std::cout << "no input file provided, using default (toyMC.root)" << std::endl;
142 fFileName = "toyMC.root";
145 fInFile = new TFile(fFileName.Data(),"read");
147 fInputTree = dynamic_cast<TTree*> (fInFile->Get("toyMCtree"));
148 fInputTree->SetBranchAddress("event",&fEvent);
149 fEventArray->Clear();
151 Int_t leftSearchIndex = Int_t(snapShotTime/2e-5);
152 if(leftSearchIndex>fInputTree->GetEntries()) {
153 leftSearchIndex = fInputTree->GetEntries()-1;
154 fInputTree->GetEvent(leftSearchIndex);
155 snapShotTime = fEvent->GetT0();
156 std::cout << "input time too large, setting time to time of last event" << std::endl;
158 if(leftSearchIndex<0) leftSearchIndex = 0;
160 //fCenterTime = snapShotTime;
162 fInputTree->GetEvent(leftSearchIndex);
163 Double_t leftTime = fEvent ->GetT0();
164 Int_t firstEventIndex;
165 //if fEvent exactly at snapShotTime, check if there are more events at the same time but with lower indices
166 if( TMath::Abs(leftTime - snapShotTime)<5e-9)
168 // printf("close from start, lefttime = %2.2f\n",leftTime);
169 firstEventIndex = leftSearchIndex+1;
170 while( TMath::Abs(leftTime- snapShotTime) < 5e-9){
172 // printf("close from start, lefttime = %2.2f\n",leftTime);
173 if(fInputTree->GetEvent(firstEventIndex-1))
175 leftTime=fEvent->GetT0();
176 // printf("close from start, lefttime = %2.2f\n",leftTime);
185 Int_t rightSearchIndex = leftSearchIndex;
188 Int_t direction = 1; //go right
189 if(leftTime > snapShotTime) {
192 rightSearchIndex+= direction;
193 if(!fInputTree->GetEvent(rightSearchIndex)) return FillEventArray(leftSearchIndex);
194 rightTime = fEvent->GetT0();
195 // std::cout << "bef search " << leftTime << " " << rightTime<< " " << " " << snapShotTime << " "<< (leftTime-snapShotTime)*(rightTime-snapShotTime) << std::endl;
198 while ( (leftTime-snapShotTime)*(rightTime-snapShotTime)>0 ){
199 // printf("searching, leftime %f, righttim %f\n",leftTime,rightTime);
200 rightSearchIndex += direction;
201 leftSearchIndex +=direction;
202 fInputTree->GetEvent(leftSearchIndex);
203 leftTime = fEvent->GetT0();
204 if(!fInputTree->GetEvent(rightSearchIndex)) {
205 rightSearchIndex-=direction;
209 rightTime = fEvent->GetT0();
210 printf("searching, leftime %f, righttim %f\n",leftTime,rightTime);
212 if (direction==-1) rightSearchIndex = leftSearchIndex;
213 firstEventIndex = rightSearchIndex;
216 // fInputTree->GetEvent(firstEventIndex);
217 //std::cout <<"first event after sn time: " << fEvent->GetT0() << std::endl;
218 return FillEventArray(firstEventIndex, snapShotTime);
221 //________________________________________________________________
222 Int_t AliToyMCDrawer::FillEventArray(Int_t middleEventNbr, Double_t snapShotTime)
224 if(fFileName.IsNull()) {
225 std::cout << "no input file provided, using default (toyMC.root)" << std::endl;
226 fFileName = "toyMC.root";
228 if(!fInFile) fInFile = new TFile(fFileName.Data(),"read");
232 fInputTree = dynamic_cast<TTree*> (fInFile->Get("toyMCtree"));
233 // fInputTree->Add(fileName);
234 fInputTree->SetBranchAddress("event",&fEvent);
236 Double_t centerEventTime;
237 if(fInputTree->GetEvent(middleEventNbr))
239 centerEventTime = fEvent->GetT0();
244 if(snapShotTime<0) fCenterTime = centerEventTime;
245 else fCenterTime = snapShotTime;
247 fEventArray->Clear();
248 if(fInputTree->GetEvent(middleEventNbr)){
249 new((*fEventArray)[fEventArray->GetEntriesFast()]) AliToyMCEvent(*fEvent);
251 //add events after middle event
252 Int_t eventIndex = middleEventNbr + 1;
253 Double_t currentTime = centerEventTime;
254 if(fInputTree->GetEvent(eventIndex)) {
255 currentTime = fEvent->GetT0();
256 while(currentTime - centerEventTime < fTimeRange/2) {
257 new((*fEventArray)[fEventArray->GetEntriesFast()]) AliToyMCEvent(*fEvent);
259 if(!fInputTree->GetEvent(eventIndex)) break;
260 currentTime = fEvent->GetT0();
263 //add events before middle event
264 eventIndex = middleEventNbr - 1;
265 if(fInputTree->GetEvent(eventIndex)){
266 currentTime = fEvent->GetT0();
267 while(centerEventTime-currentTime < fTimeRange/2) {
269 new((*fEventArray)[fEventArray->GetEntriesFast()]) AliToyMCEvent(*fEvent);
271 if(!fInputTree->GetEvent(eventIndex)) break;
272 currentTime = fEvent->GetT0();
276 std::cout << " end fill" << std::endl;
281 printf("Selected event number (%d) out of range!\n",middleEventNbr);
286 //________________________________________________________________
287 void AliToyMCDrawer::DrawEvents(Bool_t both, Bool_t before)
291 fDistPoints->Clear();
295 Double_t phiCut = 1.;
296 TLegend *leg = new TLegend(0.1,0.75,0.6,1,Form("Snapshot of TPC at %f micros after sim start, freq. = , bunchcr.rate = .",1000000*fCenterTime));
297 leg->AddEntry((TObject*)0,Form("%2.2f<#phi<#pi-%2.2f && #pi+%2.2f<#phi<2#pi-%2.2f",phiCut,phiCut,phiCut,phiCut),"");
302 for(Int_t iEvent = 0; iEvent<fEventArray->GetEntriesFast(); iEvent++){
305 AliToyMCEvent *currentEvent = static_cast<AliToyMCEvent*> (fEventArray->At(iEvent));
306 Double_t currentEventTime = currentEvent->GetT0();
308 if((1000000*currentEventTime)>((1000000*fCenterTime)+0.05 )) {
309 printf("larger iEvent: %d, current %f, center %f, ntracks: %d\n",iEvent, currentEventTime,fCenterTime, currentEvent->GetNumberOfTracks());
311 if ( !(both || !before)) continue;
314 if( currentEventTime<=fCenterTime)// && !(currentEventTime==fCenterTime &&both ))
316 printf("smaller iEvent: %d, current %f, center %f, ntracks: %d\n",iEvent, currentEventTime,fCenterTime, currentEvent->GetNumberOfTracks());
318 if ( !(both || before)) continue;
321 //std:: cout << "iev " << iEvent << " " << color << std::endl;
322 Double_t currentEventTimeRelToCentral = fCenterTime - currentEventTime;
324 Int_t color = ((currentEvent->GetEventNumber())%10);
325 if(color == 0||color ==1) {
326 color==0?color=2:color=3;
327 // if(iEvent==0) color = 8;
328 // if(iEvent==1) color = 9;
332 char bef[] = "before snapshot time";
333 char aft[] = "after snapshot time";
336 if( 1000000*(currentEventTime-fCenterTime) > 0.5) {when = aft;
340 TGraph *temp = new TGraph();
341 temp->SetName(Form("temp%d",currentEvent->GetEventNumber()));
342 temp->SetLineColor(color);
343 temp->SetLineWidth(10);
345 leg->AddEntry(temp,Form(" %2.2f microseconds %s (global time %2.2f) at z_vertex = %2.2f, centr = ., eventNr: %d", 1000000*sign*currentEventTimeRelToCentral, when, 1000000*currentEvent->GetT0(), currentEvent->GetZ() ,currentEvent->GetEventNumber() ),"l");
348 DrawEvent(currentEvent, fCenterTime, color);
358 //________________________________________________________________
360 void AliToyMCDrawer::DrawEvent(AliToyMCEvent *currentEvent, Double_t centerTime, Int_t color){
361 if(!fDispHist) DrawGeometry();
363 for(Int_t iTrack = 0; iTrack < currentEvent->GetNumberOfTracks(); iTrack++){
365 //Double_t alpha = TMath::ATan2(currentEvent->GetTrack(iTrack)->GetSpacePoint(0)->GetY(),currentEvent->GetTrack(iTrack)->GetSpacePoint(0)->GetX());
366 // if( ( ( !(abs(alpha)>phiCut && abs(alpha) < TMath::Pi() - phiCut) ) ) )continue;
372 //if(currentEvent->GetTrack(iTrack)->GetSpacePoint(0)->GetY()<0) alpha +=TMath::Pi();
373 //if( ( (alpha>phiCut && alpha < TMath::Pi() - phiCut) || ( alpha>TMath::Pi() + phiCut && alpha < TMath::TwoPi() - phiCut)) )continue;
375 // if(alpha > 0) continue;
377 //std::cout << TMath::ASin(tempTrack->GetParameter()[2]) << std::endl;
378 // Double_t x = currentEvent->GetX();
379 // Double_t y = currentEvent->GetY();
380 // Double_t hlxpar[6];
381 // currentEvent->GetTrack(iTrack)->GetHelixParameters(hlxpar,0);
382 // Double_t trackPhi = hlxpar[2];
383 // Double_t phiCut = 1.47;
384 // std::cout << "bef phi cut "<< trackPhi<< std::endl;
386 // std::cout << "aft phi cut " << std::endl;
387 // Double_t trackEta = currentEvent->GetTrack(iTrack)->GetEta();
388 // Double_t z = currentEvent->GetZ();
394 const AliToyMCTrack *tempTrack = currentEvent->GetTrack(iTrack);
395 //AliToyMCTrack *tempTrack = new AliToyMCTrack(*currentEvent->GetTrack(iTrack));
396 DrawTrack(tempTrack, centerTime, currentEvent->GetT0(),color);
414 //________________________________________________________________
415 void AliToyMCDrawer::DrawLaserEvent(Int_t nLaserEvents, Int_t side, Int_t rod, Int_t bundle, Int_t beam)
422 fDistPoints->Clear();
423 if (!ConnectInputTree()) return;
425 AliTPCLaserTrack::LoadTracks();
426 TObjArray *arr=AliTPCLaserTrack::GetTracks();
431 for (Int_t iev=0;iev<fInputTree->GetEntries();++iev) {
432 fInputTree->GetEntry(iev);
433 if (fEvent->GetEventType()!=AliToyMCEvent::kLaser) continue;
434 if (fEvent->GetNumberOfTracks()!=arr->GetEntriesFast()) {
435 AliError(Form("Wrong number of tracks in the laser event: %d!=%d",fEvent->GetNumberOfTracks(),arr->GetEntriesFast()));
439 for (Int_t iTrack=0; iTrack<fEvent->GetNumberOfTracks();++iTrack){
440 AliTPCLaserTrack *laserTrack = (AliTPCLaserTrack*)arr->UncheckedAt(iTrack);
441 if (side >-1 && laserTrack->GetSide() != side ) continue;
442 if (rod >-1 && laserTrack->GetRod() != rod ) continue;
443 if (bundle>-1 && laserTrack->GetBundle() != bundle ) continue;
444 if (beam >-1 && laserTrack->GetBeam() != beam ) continue;
445 const AliToyMCTrack *track = fEvent->GetTrack(iTrack);
446 DrawTrack(track,0,fEvent->GetT0(),kRed);
450 if (laserEvents==nLaserEvents) break;
456 //________________________________________________________________
457 void AliToyMCDrawer::DrawTrack(const AliToyMCTrack *track, Double_t centerTime, Double_t currentEventTime, Int_t color){
458 if(!fDispHist) DrawGeometry();
460 TPolyMarker3D *disttrackpoints = new((*fDistPoints)[fDistPoints->GetEntriesFast()]) TPolyMarker3D();
461 TPolyMarker3D *trackpoints = new((*fPoints)[fPoints->GetEntriesFast()]) TPolyMarker3D();
463 Double_t currentEventTimeRelToCentral = centerTime - currentEventTime;
464 Int_t nDistPoints = track->GetNumberOfDistSpacePoints();
465 Int_t nPoints = track->GetNumberOfSpacePoints();
467 for(Int_t iITSPoint = 0; iITSPoint< track->GetNumberOfITSPoints();iITSPoint++){
469 Double_t xp = track->GetITSPoint(iITSPoint)->GetX();
470 Double_t yp = track->GetITSPoint(iITSPoint)->GetY();
471 Double_t zp = track->GetITSPoint(iITSPoint)->GetZ();
472 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
473 trackpoints->SetNextPoint(zDrifted,xp,yp);
476 for(Int_t iPoint = 0; iPoint< (nDistPoints<nPoints?nPoints:nDistPoints);iPoint++){
480 Double_t xp = track->GetSpacePoint(iPoint)->GetX();
481 Double_t yp = track->GetSpacePoint(iPoint)->GetY();
482 Double_t zp = track->GetSpacePoint(iPoint)->GetZ();
483 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
484 //Double_t zDrifted = (zp/TMath::Abs(zp))*fMaxZ0 -(zp/TMath::Abs(zp))* fDriftVel*(track->GetSpacePoint(iPoint)->GetTimeBin() -centerTime );
485 Float_t xyzp[3] = {xp,yp,zp};
488 Float_t tempcov[6] = {0};
490 Int_t sec = track->GetSpacePoint(iPoint)->GetDetector();
491 Double_t angle=((sec%18)*20.+10.)/TMath::RadToDeg();
492 AliTrackPoint prot = p.Rotate(-angle);
496 Double_t ztime=zDrifted;
503 if(track->GetSpacePoint(iPoint)->GetRow()!=255) {
504 if(TMath::Abs(zDrifted)<fMaxZ0 && zDrifted*zp >=0 /*&&TMath::Sqrt(xp*xp + yp*yp)<fIFCRadius*/) trackpoints->SetNextPoint(zDrifted,xp,yp);
507 else std::cout << "row == " << track->GetSpacePoint(iPoint)->GetRow() << std::endl;
510 if(iPoint<nDistPoints) {
511 Double_t xpdist = track->GetDistortedSpacePoint(iPoint)->GetX();
512 Double_t ypdist = track->GetDistortedSpacePoint(iPoint)->GetY();
513 Double_t zpdist = track->GetDistortedSpacePoint(iPoint)->GetZ();
514 //std::cout << zpdist << std::endl;
516 Float_t xyzpdist[3] = {xpdist,ypdist,zpdist};
518 pdist.SetXYZ(xyzpdist);
519 Float_t tempcovdist[6] = {0};
520 pdist.SetCov(tempcovdist);
521 Int_t secdist = track->GetDistortedSpacePoint(iPoint)->GetDetector();
522 Double_t angledist=((secdist%18)*20.+10.)/TMath::RadToDeg();
523 AliTrackPoint protdist = pdist.Rotate(-angledist);
524 xpdist = protdist.GetX();
525 ypdist = protdist.GetY();
528 UInt_t sector = track->GetDistortedSpacePoint(iPoint)->GetDetector();
529 UInt_t row = track->GetDistortedSpacePoint(iPoint)->GetRow();
530 UInt_t pad = track->GetDistortedSpacePoint(iPoint)->GetPad();
532 Int_t nPads = fTPCParam->GetNPads(sector,row);
533 Int_t intPad = TMath::Nint(Float_t(pad+nPads/2));
536 //std::cout <<"sector: " << sector << " row: " << row << " pad: " <<pad<< std::endl;
537 fRoc->GetPositionGlobal(sector,row,intPad,xyz);
539 Double_t zDrifteddist = (zpdist/TMath::Abs(zpdist))*fMaxZ0 -(zpdist/TMath::Abs(zpdist))* fDriftVel*(track->GetDistortedSpacePoint(iPoint)->GetTimeBin() -centerTime );
542 if(TMath::Abs(zDrifteddist)<fMaxZ0 && zDrifteddist*zpdist>=0 /*&&TMath::Sqrt(xpdist*xpdist + ypdist*ypdist)<fIFCRadius*/) {
544 disttrackpoints->SetNextPoint(zDrifteddist,xpdist,ypdist);
545 //if(TMath::Sqrt(xpdist*xpdist + ypdist*ypdist)<fIFCRadius) std::cout << "fMaxZ0 " << fMaxZ0 <<" inside " << xpdist << " " << "zpdist " << zpdist << " " << "zDrifteddist "<< zDrifteddist << " " << zDrifteddist*zpdist << std::endl;
548 else std::cout << "row == " << row << std::endl;
549 //Double_t zDrifteddist =(zpdist/TMath::Abs(zpdist))*fMaxZ0 -(zpdist/TMath::Abs(zpdist))*(currentEvent->GetTrack(iTrack)->GetDistortedSpacePoint(iPoint)->GetTimeBin()- currentEvent->GetT0() )* fDriftVel;
553 // if( ( (trackPhi>phiCut && trackPhi < TMath::Pi() - phiCut) || ( trackPhi>TMath::Pi() + phiCut && trackPhi < TMath::TwoPi() - phiCut)) ) {
561 for(Int_t iTRDPoint = 0; iTRDPoint< track->GetNumberOfTRDPoints();iTRDPoint++){
563 Double_t xp = track->GetTRDPoint(iTRDPoint)->GetX();
564 Double_t yp = track->GetTRDPoint(iTRDPoint)->GetY();
565 Double_t zp = track->GetTRDPoint(iTRDPoint)->GetZ();
566 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
567 trackpoints->SetNextPoint(zDrifted,xp,yp);
571 if(trackpoints && trackpoints->GetN()>0) {
572 // trackpoints->SetMarkerColor(1+currentEvent->GetEventNumber()%9);
573 //trackpoints->SetMarkerStyle(6);
574 trackpoints->Draw("same");
576 if(disttrackpoints && disttrackpoints->GetN()>0) {
578 //disttrackpoints->SetMarkerStyle(6);
579 disttrackpoints->SetMarkerColor(color);
582 disttrackpoints->Draw("same");
593 //________________________________________________________________
594 void AliToyMCDrawer::DrawGeometry() {
598 //fDispGraph = new TGraph2D();
601 Double_t timeZmin=-fMaxZ0;
602 Double_t timeZmax= fMaxZ0;
603 Double_t globXmin=-(fOFCRadius +10);
604 Double_t globXmax= fOFCRadius +10 ;
605 Double_t globYmin=-(fOFCRadius +10);
606 Double_t globYmax= fOFCRadius +10 ;
608 const Double_t epsilon=.001;
611 if (fTimeZmax>fTimeZmin) {
615 if (fGlobalXmax>fGlobalXmin) {
616 globXmin=fGlobalXmin;
617 globXmax=fGlobalXmax;
619 if (fGlobalYmax>fGlobalYmin) {
620 globYmin=fGlobalYmin;
621 globYmax=fGlobalYmax;
623 if (fProjectionType=="XYT"){
624 fDispHist = new TH3F("fDispHist",";#it{z} [cm]; #it{x} [cm]; #it{y} [cm]",
625 100, timeZmin-10, timeZmax+10,
626 100, globXmin, globXmax ,
627 100, globYmin, globYmax);
628 } else if (fProjectionType=="XT"){
629 fDispHist = new TH2F("fDispHist",";#it{z} [cm]; #it{x} [cm]",
630 100, timeZmin-10, timeZmax+10,
631 100, globXmin, globXmax);
632 } else if (fProjectionType=="YT"){
633 fDispHist = new TH2F("fDispHist",";#it{z} [cm]; #it{y} [cm]",
634 100, timeZmin-10, timeZmax+10,
635 100, globYmin, globYmax);
636 } else if (fProjectionType=="RT"){
637 fDispHist = new TH2F("fDispHist",";#it{z} [cm]; #it{r} [cm]",
638 100, timeZmin-10, timeZmax+10,
639 100, globYmin, globYmax);
641 AliError(Form("Display Format not known: %s",fProjectionType.Data()));
647 //if(!fDispGraph) fDispGraph = new TGraph();
649 //fDispGraph->Clear();
650 fDispHist->SetStats(0);
655 TPolyLine3D *endCap1 = 0x0;
656 if (timeZmin-epsilon<-fMaxZ0)
657 endCap1=new TPolyLine3D();
658 printf("time: %p, %.2f,, %.2f, %.2f, %.2f, %d\n",endCap1,fTimeZmin,fTimeZmax,timeZmin-epsilon,fMaxZ0, timeZmin-epsilon<-fMaxZ0);
659 TPolyLine3D *endCap2 = 0x0;
660 if (timeZmax+epsilon> fMaxZ0)
661 endCap2=new TPolyLine3D();
663 TPolyLine3D *outerCE = 0x0;
664 if (timeZmin<0 && timeZmax>0 )
665 outerCE=new TPolyLine3D();
667 TPolyLine3D *cage[18] ={0x0};
669 TPolyLine3D *innerCage[18] ={0x0};
671 TPolyLine3D *innerEndCap1 = 0x0;
672 if (timeZmin-epsilon<-fMaxZ0)
673 innerEndCap1=new TPolyLine3D();
675 TPolyLine3D *innerEndCap2 = 0x0;
676 if (timeZmax+epsilon> fMaxZ0)
677 innerEndCap2=new TPolyLine3D();
679 TPolyLine3D *innerCE = 0x0;
680 if (timeZmin<0 && timeZmax>0 )
681 innerCE=new TPolyLine3D();
685 Double_t globalX = 0.;
686 Double_t globalY = 0.;
687 Double_t globalXi = 0.;
688 Double_t globalYi = 0.;
690 for(Int_t i = 0; i<18; i++){
691 angle = i*TMath::TwoPi()/18;
692 globalX = fOFCRadius*TMath::Cos(angle);
693 globalY = fOFCRadius*TMath::Sin(angle);
694 globalXi = fIFCRadius*TMath::Cos(angle);
695 globalYi = fIFCRadius*TMath::Sin(angle);
697 cage[iPoint] = new TPolyLine3D();
698 cage[iPoint]->SetPoint(0,timeZmin,globalX ,globalY) ;
699 cage[iPoint]->SetPoint(1, timeZmax,globalX ,globalY) ;
700 innerCage[iPoint] = new TPolyLine3D();
701 innerCage[iPoint]->SetPoint(0,timeZmin,globalXi ,globalYi) ;
702 innerCage[iPoint]->SetPoint(1, timeZmax,globalXi ,globalYi) ;
704 // only draw if inside range
705 if (endCap1) { endCap1->SetPoint(i,timeZmax, globalX, globalY); }
706 if (endCap2) { endCap2->SetPoint(i,timeZmin, globalX, globalY); }
707 if (outerCE) { outerCE->SetPoint(i, 0., globalX, globalY); }
709 if (innerEndCap1) { innerEndCap1->SetPoint(i, timeZmax, globalXi, globalYi); }
710 if (innerEndCap2) { innerEndCap2->SetPoint(i, timeZmin, globalXi, globalYi); }
711 if (innerCE) { innerCE->SetPoint(i, 0., globalXi, globalYi); }
713 innerCage[iPoint]->Draw("same");
716 cage[iPoint]->Draw("same");
722 // close endplate and CE polygons
725 angle = i*TMath::TwoPi()/18;
726 globalX = fOFCRadius*TMath::Cos(angle);
727 globalY = fOFCRadius*TMath::Sin(angle);
728 globalXi = fIFCRadius*TMath::Cos(angle);
729 globalYi = fIFCRadius*TMath::Sin(angle);
731 // only draw if inside range
732 if (endCap1) { endCap1->SetPoint(i, timeZmax, globalX, globalY); }
733 if (endCap2) { endCap2->SetPoint(i, timeZmin, globalX, globalY); }
734 if (outerCE) { outerCE->SetPoint(i, 0., globalX, globalY); }
736 if (innerEndCap1) { innerEndCap1->SetPoint(i, timeZmax, globalXi, globalYi); }
737 if (innerEndCap2) { innerEndCap2->SetPoint(i, timeZmin, globalXi, globalYi); }
738 if (innerCE) { innerCE ->SetPoint(i, 0., globalXi, globalYi); }
740 if (endCap1) { endCap1->Draw("same"); }
741 if (endCap2) { endCap2->Draw("same"); }
742 if (outerCE) { outerCE->Draw("same"); }
744 if (innerEndCap1) { innerEndCap1->Draw("same"); }
745 if (innerEndCap2) { innerEndCap2->Draw("same"); }
746 if (innerCE) { innerCE ->Draw("same"); }
750 //________________________________________________________________
751 Bool_t AliToyMCDrawer::ConnectInputTree()
757 if(fFileName.IsNull()) {
758 AliError("no input file provided, using default (toyMC.root)");
759 fFileName = "toyMC.root";
761 if (fInFile && fInFile->GetName()==fFileName) return kTRUE;
767 fInFile = new TFile(fFileName.Data(),"read");
768 if (!fInFile || !fInFile->IsOpen() || fInFile->IsZombie() ) {
775 fInputTree = dynamic_cast<TTree*> (fInFile->Get("toyMCtree"));
778 AliError("Could not connect tree!\n");
784 fInputTree->SetBranchAddress("event",&fEvent);