]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/Upgrade/AliToyMCDrawer.cxx
Nicer plots
[u/mrichter/AliRoot.git] / TPC / Upgrade / AliToyMCDrawer.cxx
CommitLineData
e2d1174f 1#include <iostream>
0403120d 2#include <TROOT.h>
e2d1174f 3#include <TChain.h>
4#include <TMath.h>
5#include <TTree.h>
6#include <TFile.h>
7#include <TGraph2D.h>
8#include <TH3F.h>
c484014f 9#include <TH2F.h>
e2d1174f 10#include <TClonesArray.h>
11#include <TPolyLine3D.h>
cdf56507 12#include <TPolyLine.h>
e2d1174f 13#include <TPolyMarker3D.h>
cdf56507 14#include <TPolyMarker.h>
e2d1174f 15#include <TAxis.h>
16#include <TLegend.h>
17#include <TPad.h>
0403120d 18#include <TGeoGlobalMagField.h>
cdf56507 19#include <TCanvas.h>
0403120d 20
21#include <AliMagF.h>
22#include <AliCDBManager.h>
23#include <AliTPCParam.h>
24#include <AliGeomManager.h>
25#include <AliTPCcalibDB.h>
e2d1174f 26#include <AliTrackPointArray.h>
1e62e876 27#include <AliCluster.h>
0403120d 28#include <AliLog.h>
29#include <AliTPCLaserTrack.h>
30
31
e2d1174f 32#include "AliToyMCDrawer.h"
33#include "AliToyMCEvent.h"
34#include "AliToyMCTrack.h"
e2d1174f 35
33260805 36// Visualization class. To use
37
38// AliToyMCDrawer* draw = new AliToyMCDrawer()
39// draw->SetFileName("path/to/toyMC.root")
40
41// draw->FillEventArray(Int_t centerEventNumber)
42// or
43// draw->FillEventArray(Double_t time)
44// to display with a certain event in the center or at a certain time
45
46// draw->DrawEvents(Bool_t both, Bool_t before)
47// where "both" will display events before and after the middle event and
48// before will show also events before (after) the middle event if true (false)
49// when "both" is false
50
e2d1174f 51
52ClassImp(AliToyMCDrawer);
53
54AliToyMCDrawer::AliToyMCDrawer()
0403120d 55 : TObject()
56 ,fInputTree(0x0)
57 ,fInFile(0x0)
58 ,fFileName()
59 ,fEvent(0x0)
60 ,fEventArray(0x0)
61 ,fDispHist(0x0)
62 ,fCenterTime(-1.)
63 ,fDriftVel(-1.)
64 ,fTPCParam(0x0)
65 ,fMaxZ0(0.)
66 ,fIFCRadius(83.5)
67 ,fOFCRadius(254.5)
68 ,fTimeRange(0)
69 ,fRoc(AliTPCROC::Instance())
70 ,fPoints(0x0)
71 ,fDistPoints(0x0)
c484014f 72 ,fProjectionType("XYT")
73 ,fTimeZmin(0.)
74 ,fTimeZmax(0.)
75 ,fGlobalXmin(0.)
76 ,fGlobalXmax(0.)
77 ,fGlobalYmin(0.)
78 ,fGlobalYmax(0.)
0403120d 79 {
e2d1174f 80 fEventArray = new TClonesArray("AliToyMCEvent");
81
82 fTPCParam = AliTPCcalibDB::Instance()->GetParameters();
83 fTPCParam->ReadGeoMatrices();
0403120d 84 fDriftVel = fTPCParam->GetDriftV();
85 fMaxZ0 =fTPCParam->GetZLength();
e2d1174f 86 fTimeRange = 2*fMaxZ0/fDriftVel;
e2d1174f 87 }
88//________________________________________________________________
89AliToyMCDrawer::AliToyMCDrawer(const AliToyMCDrawer &drawer)
90 : TObject(drawer)
91 ,fInputTree(drawer.fInputTree)
0403120d 92 ,fInFile(drawer.fInFile)
e2d1174f 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)
e2d1174f 101 ,fIFCRadius(drawer.fIFCRadius)
0403120d 102 ,fOFCRadius(drawer.fOFCRadius)
e2d1174f 103 ,fTimeRange(drawer.fTimeRange)
104 ,fRoc(drawer.fRoc)
105 ,fPoints(drawer.fPoints)
106 ,fDistPoints(drawer.fDistPoints)
c484014f 107 ,fProjectionType("XYT")
108 ,fTimeZmin(0.)
109 ,fTimeZmax(0.)
110 ,fGlobalXmin(0.)
111 ,fGlobalXmax(0.)
112 ,fGlobalYmin(0.)
113 ,fGlobalYmax(0.)
114 {
e2d1174f 115 //
116}
117//_____________________________________________________
118AliToyMCDrawer& AliToyMCDrawer::operator = (const AliToyMCDrawer &drawer)
119{
120 //assignment operator
121 if (&drawer == this) return *this;
122 new (this) AliToyMCDrawer(drawer);
123
124 return *this;
125}
126
127//________________________________________________________________
128AliToyMCDrawer::~AliToyMCDrawer()
129{
130 //destructor
131 delete fEvent;
132 delete fEventArray;
e2d1174f 133 delete fPoints;
134 delete fDistPoints;
0403120d 135 delete fDispHist;
e2d1174f 136}
137//________________________________________________________________
138Int_t AliToyMCDrawer::FillEventArray(Double_t snapShotTime)
139{
0403120d 140 if(fFileName.IsNull()) {
e2d1174f 141 std::cout << "no input file provided, using default (toyMC.root)" << std::endl;
142 fFileName = "toyMC.root";
143 }
144
0403120d 145 fInFile = new TFile(fFileName.Data(),"read");
146 gROOT->cd();
147 fInputTree = dynamic_cast<TTree*> (fInFile->Get("toyMCtree"));
e2d1174f 148 fInputTree->SetBranchAddress("event",&fEvent);
149 fEventArray->Clear();
33260805 150
e2d1174f 151 Int_t leftSearchIndex = Int_t(snapShotTime/2e-5);
33260805 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;
157 }
e2d1174f 158 if(leftSearchIndex<0) leftSearchIndex = 0;
159
33260805 160 //fCenterTime = snapShotTime;
161
e2d1174f 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)
167 {
168 // printf("close from start, lefttime = %2.2f\n",leftTime);
169 firstEventIndex = leftSearchIndex+1;
170 while( TMath::Abs(leftTime- snapShotTime) < 5e-9){
171 firstEventIndex--;
172 // printf("close from start, lefttime = %2.2f\n",leftTime);
173 if(fInputTree->GetEvent(firstEventIndex-1))
174 {
175 leftTime=fEvent->GetT0();
176 // printf("close from start, lefttime = %2.2f\n",leftTime);
177 }
178 else break;
179 }
180
181
182 }
183 else
184 {
185 Int_t rightSearchIndex = leftSearchIndex;
186 Double_t rightTime;
187
188 Int_t direction = 1; //go right
189 if(leftTime > snapShotTime) {
190 direction = -1;
191 }
192 rightSearchIndex+= direction;
33260805 193 if(!fInputTree->GetEvent(rightSearchIndex)) return FillEventArray(leftSearchIndex);
e2d1174f 194 rightTime = fEvent->GetT0();
33260805 195 // std::cout << "bef search " << leftTime << " " << rightTime<< " " << " " << snapShotTime << " "<< (leftTime-snapShotTime)*(rightTime-snapShotTime) << std::endl;
196 // Int_t b;
197
e2d1174f 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();
33260805 204 if(!fInputTree->GetEvent(rightSearchIndex)) {
205 rightSearchIndex-=direction;
206 break;
207
208 }
e2d1174f 209 rightTime = fEvent->GetT0();
33260805 210 printf("searching, leftime %f, righttim %f\n",leftTime,rightTime);
e2d1174f 211 }
212 if (direction==-1) rightSearchIndex = leftSearchIndex;
213 firstEventIndex = rightSearchIndex;
214
215 }
33260805 216 // fInputTree->GetEvent(firstEventIndex);
e2d1174f 217 //std::cout <<"first event after sn time: " << fEvent->GetT0() << std::endl;
33260805 218 return FillEventArray(firstEventIndex, snapShotTime);
e2d1174f 219
220}
221//________________________________________________________________
33260805 222Int_t AliToyMCDrawer::FillEventArray(Int_t middleEventNbr, Double_t snapShotTime)
e2d1174f 223{
0403120d 224 if(fFileName.IsNull()) {
e2d1174f 225 std::cout << "no input file provided, using default (toyMC.root)" << std::endl;
226 fFileName = "toyMC.root";
227 }
0403120d 228 if(!fInFile) fInFile = new TFile(fFileName.Data(),"read");
229 gROOT->cd();
e2d1174f 230 if(!fInputTree)
231 {
0403120d 232 fInputTree = dynamic_cast<TTree*> (fInFile->Get("toyMCtree"));
e2d1174f 233 // fInputTree->Add(fileName);
234 fInputTree->SetBranchAddress("event",&fEvent);
e2d1174f 235 }
236 Double_t centerEventTime;
237 if(fInputTree->GetEvent(middleEventNbr))
238 {
239 centerEventTime = fEvent->GetT0();
240
241 }
242 else return 0;
33260805 243
244 if(snapShotTime<0) fCenterTime = centerEventTime;
245 else fCenterTime = snapShotTime;
246
e2d1174f 247 fEventArray->Clear();
248 if(fInputTree->GetEvent(middleEventNbr)){
249 new((*fEventArray)[fEventArray->GetEntriesFast()]) AliToyMCEvent(*fEvent);
250
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);
258 eventIndex++;
259 if(!fInputTree->GetEvent(eventIndex)) break;
260 currentTime = fEvent->GetT0();
261 }
262 }
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) {
268
269 new((*fEventArray)[fEventArray->GetEntriesFast()]) AliToyMCEvent(*fEvent);
270 eventIndex--;
271 if(!fInputTree->GetEvent(eventIndex)) break;
272 currentTime = fEvent->GetT0();
273 }
274 }
33260805 275
276 std::cout << " end fill" << std::endl;
277
e2d1174f 278 return 1;
279 }
280 else {
281 printf("Selected event number (%d) out of range!\n",middleEventNbr);
33260805 282 return 0;
e2d1174f 283 }
33260805 284
e2d1174f 285}
286//________________________________________________________________
287void AliToyMCDrawer::DrawEvents(Bool_t both, Bool_t before)
288{
cdf56507 289
290 if (fPoints){
291 fPoints->Clear();
292 fDistPoints->Clear();
293 }
e2d1174f 294 DrawGeometry();
295
296
297 Double_t phiCut = 1.;
298 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));
299 leg->AddEntry((TObject*)0,Form("%2.2f<#phi<#pi-%2.2f && #pi+%2.2f<#phi<2#pi-%2.2f",phiCut,phiCut,phiCut,phiCut),"");
300
301
302
303
304 for(Int_t iEvent = 0; iEvent<fEventArray->GetEntriesFast(); iEvent++){
305
306
307 AliToyMCEvent *currentEvent = static_cast<AliToyMCEvent*> (fEventArray->At(iEvent));
308 Double_t currentEventTime = currentEvent->GetT0();
309
310 if((1000000*currentEventTime)>((1000000*fCenterTime)+0.05 )) {
33260805 311 printf("larger iEvent: %d, current %f, center %f, ntracks: %d\n",iEvent, currentEventTime,fCenterTime, currentEvent->GetNumberOfTracks());
e2d1174f 312 printf("after\n");
313 if ( !(both || !before)) continue;
314
315 }
316 if( currentEventTime<=fCenterTime)// && !(currentEventTime==fCenterTime &&both ))
317 {
33260805 318 printf("smaller iEvent: %d, current %f, center %f, ntracks: %d\n",iEvent, currentEventTime,fCenterTime, currentEvent->GetNumberOfTracks());
e2d1174f 319 printf("before\n");
320 if ( !(both || before)) continue;
321 }
322
323 //std:: cout << "iev " << iEvent << " " << color << std::endl;
324 Double_t currentEventTimeRelToCentral = fCenterTime - currentEventTime;
325
326 Int_t color = ((currentEvent->GetEventNumber())%10);
327 if(color == 0||color ==1) {
328 color==0?color=2:color=3;
329 // if(iEvent==0) color = 8;
330 // if(iEvent==1) color = 9;
331
332 }
333
334 char bef[] = "before snapshot time";
335 char aft[] = "after snapshot time";
336 char *when;
337 Int_t sign = 1;
338 if( 1000000*(currentEventTime-fCenterTime) > 0.5) {when = aft;
339 sign = -1;
340 }
341 else when = bef;
342 TGraph *temp = new TGraph();
343 temp->SetName(Form("temp%d",currentEvent->GetEventNumber()));
344 temp->SetLineColor(color);
345 temp->SetLineWidth(10);
346
347 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
349
350 DrawEvent(currentEvent, fCenterTime, color);
351
352
353
354
355
356 }
357 leg->Draw("same");
358
359}
360//________________________________________________________________
361
362void AliToyMCDrawer::DrawEvent(AliToyMCEvent *currentEvent, Double_t centerTime, Int_t color){
363 if(!fDispHist) DrawGeometry();
364
365 for(Int_t iTrack = 0; iTrack < currentEvent->GetNumberOfTracks(); iTrack++){
366
367 //Double_t alpha = TMath::ATan2(currentEvent->GetTrack(iTrack)->GetSpacePoint(0)->GetY(),currentEvent->GetTrack(iTrack)->GetSpacePoint(0)->GetX());
368 // if( ( ( !(abs(alpha)>phiCut && abs(alpha) < TMath::Pi() - phiCut) ) ) )continue;
369 // if(alpha<0) {
370 // continue;
371 // delete tempTrack;
372 // }
373
374 //if(currentEvent->GetTrack(iTrack)->GetSpacePoint(0)->GetY()<0) alpha +=TMath::Pi();
375 //if( ( (alpha>phiCut && alpha < TMath::Pi() - phiCut) || ( alpha>TMath::Pi() + phiCut && alpha < TMath::TwoPi() - phiCut)) )continue;
376
377 // if(alpha > 0) continue;
378
379 //std::cout << TMath::ASin(tempTrack->GetParameter()[2]) << std::endl;
380 // Double_t x = currentEvent->GetX();
381 // Double_t y = currentEvent->GetY();
382 // Double_t hlxpar[6];
383 // currentEvent->GetTrack(iTrack)->GetHelixParameters(hlxpar,0);
384 // Double_t trackPhi = hlxpar[2];
385 // Double_t phiCut = 1.47;
386 // std::cout << "bef phi cut "<< trackPhi<< std::endl;
387
388 // std::cout << "aft phi cut " << std::endl;
389 // Double_t trackEta = currentEvent->GetTrack(iTrack)->GetEta();
390 // Double_t z = currentEvent->GetZ();
391
392
393
394
395
396 const AliToyMCTrack *tempTrack = currentEvent->GetTrack(iTrack);
397 //AliToyMCTrack *tempTrack = new AliToyMCTrack(*currentEvent->GetTrack(iTrack));
cdf56507 398 if (fProjectionType.Length()==3){
399 DrawTrack(tempTrack, centerTime, currentEvent->GetT0(),color);
400 } else if (fProjectionType.Length()==2){
401 DrawTrack2D(tempTrack, centerTime, currentEvent->GetT0(),color);
402 }
e2d1174f 403
e2d1174f 404 }
0403120d 405}
406
407//________________________________________________________________
408void AliToyMCDrawer::DrawLaserEvent(Int_t nLaserEvents, Int_t side, Int_t rod, Int_t bundle, Int_t beam)
409{
410 //
411 //
412 //
413
cdf56507 414 if (fPoints) {
415 fPoints->Clear();
416 fDistPoints->Clear();
417 }
0403120d 418 if (!ConnectInputTree()) return;
419
420 AliTPCLaserTrack::LoadTracks();
421 TObjArray *arr=AliTPCLaserTrack::GetTracks();
422
cdf56507 423 if (fProjectionType.Length()==3){
424 DrawGeometry();
425 } else if (fProjectionType.Length()==2){
426 DrawGeometry2D();
427 }
428
0403120d 429 Int_t laserEvents=0;
430 for (Int_t iev=0;iev<fInputTree->GetEntries();++iev) {
431 fInputTree->GetEntry(iev);
432 if (fEvent->GetEventType()!=AliToyMCEvent::kLaser) continue;
433 if (fEvent->GetNumberOfTracks()!=arr->GetEntriesFast()) {
434 AliError(Form("Wrong number of tracks in the laser event: %d!=%d",fEvent->GetNumberOfTracks(),arr->GetEntriesFast()));
435 continue;
436 }
437
438 for (Int_t iTrack=0; iTrack<fEvent->GetNumberOfTracks();++iTrack){
439 AliTPCLaserTrack *laserTrack = (AliTPCLaserTrack*)arr->UncheckedAt(iTrack);
440 if (side >-1 && laserTrack->GetSide() != side ) continue;
441 if (rod >-1 && laserTrack->GetRod() != rod ) continue;
442 if (bundle>-1 && laserTrack->GetBundle() != bundle ) continue;
443 if (beam >-1 && laserTrack->GetBeam() != beam ) continue;
444 const AliToyMCTrack *track = fEvent->GetTrack(iTrack);
cdf56507 445 if (fProjectionType.Length()==3){
446 DrawTrack(track,0,fEvent->GetT0(),kRed);
447 } else if (fProjectionType.Length()==2){
448 DrawTrack2D(track,0,fEvent->GetT0(),kRed);
449 }
450
0403120d 451 }
452
453 ++laserEvents;
454 if (laserEvents==nLaserEvents) break;
455 }
456
457
e2d1174f 458}
459
460//________________________________________________________________
461void AliToyMCDrawer::DrawTrack(const AliToyMCTrack *track, Double_t centerTime, Double_t currentEventTime, Int_t color){
462 if(!fDispHist) DrawGeometry();
cdf56507 463 if (!fPoints) {
464 fPoints = new TClonesArray("TPolyMarker3D");
465 fDistPoints = new TClonesArray("TPolyMarker3D");
466 }
e2d1174f 467
468 TPolyMarker3D *disttrackpoints = new((*fDistPoints)[fDistPoints->GetEntriesFast()]) TPolyMarker3D();
469 TPolyMarker3D *trackpoints = new((*fPoints)[fPoints->GetEntriesFast()]) TPolyMarker3D();
470
471 Double_t currentEventTimeRelToCentral = centerTime - currentEventTime;
472 Int_t nDistPoints = track->GetNumberOfDistSpacePoints();
473 Int_t nPoints = track->GetNumberOfSpacePoints();
474
1e62e876 475 for(Int_t iITSPoint = 0; iITSPoint< track->GetNumberOfITSPoints();iITSPoint++){
476
477 Double_t xp = track->GetITSPoint(iITSPoint)->GetX();
478 Double_t yp = track->GetITSPoint(iITSPoint)->GetY();
479 Double_t zp = track->GetITSPoint(iITSPoint)->GetZ();
480 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
481 trackpoints->SetNextPoint(zDrifted,xp,yp);
482 }
483
e2d1174f 484 for(Int_t iPoint = 0; iPoint< (nDistPoints<nPoints?nPoints:nDistPoints);iPoint++){
485 if(iPoint<nPoints) {
486
487
488 Double_t xp = track->GetSpacePoint(iPoint)->GetX();
489 Double_t yp = track->GetSpacePoint(iPoint)->GetY();
490 Double_t zp = track->GetSpacePoint(iPoint)->GetZ();
491 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
492 //Double_t zDrifted = (zp/TMath::Abs(zp))*fMaxZ0 -(zp/TMath::Abs(zp))* fDriftVel*(track->GetSpacePoint(iPoint)->GetTimeBin() -centerTime );
493 Float_t xyzp[3] = {xp,yp,zp};
494 AliTrackPoint p;
495 p.SetXYZ(xyzp);
496 Float_t tempcov[6] = {0};
497 p.SetCov(tempcov);
498 Int_t sec = track->GetSpacePoint(iPoint)->GetDetector();
499 Double_t angle=((sec%18)*20.+10.)/TMath::RadToDeg();
500 AliTrackPoint prot = p.Rotate(-angle);
501 xp = prot.GetX();
502 yp = prot.GetY();
503
cdf56507 504// Double_t ztime=zDrifted;
505// Double_t globx=xp;
506// Double_t globy=yp;
c484014f 507
508// if (fProje)
e2d1174f 509
510
511 if(track->GetSpacePoint(iPoint)->GetRow()!=255) {
512 if(TMath::Abs(zDrifted)<fMaxZ0 && zDrifted*zp >=0 /*&&TMath::Sqrt(xp*xp + yp*yp)<fIFCRadius*/) trackpoints->SetNextPoint(zDrifted,xp,yp);
513
514 }
515 else std::cout << "row == " << track->GetSpacePoint(iPoint)->GetRow() << std::endl;
516
517 }
518 if(iPoint<nDistPoints) {
519 Double_t xpdist = track->GetDistortedSpacePoint(iPoint)->GetX();
520 Double_t ypdist = track->GetDistortedSpacePoint(iPoint)->GetY();
521 Double_t zpdist = track->GetDistortedSpacePoint(iPoint)->GetZ();
522 //std::cout << zpdist << std::endl;
523
524 Float_t xyzpdist[3] = {xpdist,ypdist,zpdist};
525 AliTrackPoint pdist;
526 pdist.SetXYZ(xyzpdist);
527 Float_t tempcovdist[6] = {0};
528 pdist.SetCov(tempcovdist);
529 Int_t secdist = track->GetDistortedSpacePoint(iPoint)->GetDetector();
530 Double_t angledist=((secdist%18)*20.+10.)/TMath::RadToDeg();
531 AliTrackPoint protdist = pdist.Rotate(-angledist);
532 xpdist = protdist.GetX();
533 ypdist = protdist.GetY();
534
535
536 UInt_t sector = track->GetDistortedSpacePoint(iPoint)->GetDetector();
537 UInt_t row = track->GetDistortedSpacePoint(iPoint)->GetRow();
538 UInt_t pad = track->GetDistortedSpacePoint(iPoint)->GetPad();
539
540 Int_t nPads = fTPCParam->GetNPads(sector,row);
541 Int_t intPad = TMath::Nint(Float_t(pad+nPads/2));
542
543 Float_t xyz[3];
544 //std::cout <<"sector: " << sector << " row: " << row << " pad: " <<pad<< std::endl;
545 fRoc->GetPositionGlobal(sector,row,intPad,xyz);
546
547 Double_t zDrifteddist = (zpdist/TMath::Abs(zpdist))*fMaxZ0 -(zpdist/TMath::Abs(zpdist))* fDriftVel*(track->GetDistortedSpacePoint(iPoint)->GetTimeBin() -centerTime );
548 if(row!=255){
549
550 if(TMath::Abs(zDrifteddist)<fMaxZ0 && zDrifteddist*zpdist>=0 /*&&TMath::Sqrt(xpdist*xpdist + ypdist*ypdist)<fIFCRadius*/) {
551
552 disttrackpoints->SetNextPoint(zDrifteddist,xpdist,ypdist);
553 //if(TMath::Sqrt(xpdist*xpdist + ypdist*ypdist)<fIFCRadius) std::cout << "fMaxZ0 " << fMaxZ0 <<" inside " << xpdist << " " << "zpdist " << zpdist << " " << "zDrifteddist "<< zDrifteddist << " " << zDrifteddist*zpdist << std::endl;
554 }
555 }
556 else std::cout << "row == " << row << std::endl;
557 //Double_t zDrifteddist =(zpdist/TMath::Abs(zpdist))*fMaxZ0 -(zpdist/TMath::Abs(zpdist))*(currentEvent->GetTrack(iTrack)->GetDistortedSpacePoint(iPoint)->GetTimeBin()- currentEvent->GetT0() )* fDriftVel;
558
559
560 }
561 // if( ( (trackPhi>phiCut && trackPhi < TMath::Pi() - phiCut) || ( trackPhi>TMath::Pi() + phiCut && trackPhi < TMath::TwoPi() - phiCut)) ) {
562
563
564
565
566
567 }
1e62e876 568 if(0){
569 for(Int_t iTRDPoint = 0; iTRDPoint< track->GetNumberOfTRDPoints();iTRDPoint++){
570
571 Double_t xp = track->GetTRDPoint(iTRDPoint)->GetX();
572 Double_t yp = track->GetTRDPoint(iTRDPoint)->GetY();
573 Double_t zp = track->GetTRDPoint(iTRDPoint)->GetZ();
574 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
575 trackpoints->SetNextPoint(zDrifted,xp,yp);
576 }
577}
e2d1174f 578 if(1){
579 if(trackpoints && trackpoints->GetN()>0) {
580 // trackpoints->SetMarkerColor(1+currentEvent->GetEventNumber()%9);
1e62e876 581 //trackpoints->SetMarkerStyle(6);
e2d1174f 582 trackpoints->Draw("same");
583 }
584 if(disttrackpoints && disttrackpoints->GetN()>0) {
585 //
1e62e876 586 //disttrackpoints->SetMarkerStyle(6);
e2d1174f 587 disttrackpoints->SetMarkerColor(color);
588
589
590 disttrackpoints->Draw("same");
591
592 }
593
594 }
595
596
597
598
cdf56507 599}
600
601//________________________________________________________________
602void AliToyMCDrawer::DrawTrack2D(const AliToyMCTrack *track, Double_t centerTime, Double_t currentEventTime, Int_t color){
603 if(!fDispHist) DrawGeometry2D();
604 if (!fPoints) {
605 fPoints = new TClonesArray("TPolyMarker");
606 fDistPoints = new TClonesArray("TPolyMarker");
607 }
608
609 Double_t timeZmin=-fMaxZ0;
610 Double_t timeZmax= fMaxZ0;
611 Double_t globXmin=-(fOFCRadius +10);
612 Double_t globXmax= fOFCRadius +10 ;
613 Double_t globYmin=-(fOFCRadius +10);
614 Double_t globYmax= fOFCRadius +10 ;
615
616// const Double_t epsilon=.001;
617
618 TString title;
619 if (fTimeZmax>fTimeZmin) {
620 timeZmin=fTimeZmin;
621 timeZmax=fTimeZmax;
622 }
623 if (fGlobalXmax>fGlobalXmin) {
624 globXmin=fGlobalXmin;
625 globXmax=fGlobalXmax;
626 }
627 if (fGlobalYmax>fGlobalYmin) {
628 globYmin=fGlobalYmin;
629 globYmax=fGlobalYmax;
630 }
631
632 TPolyMarker *disttrackpoints = new((*fDistPoints)[fDistPoints->GetEntriesFast()]) TPolyMarker();
633 TPolyMarker *trackpoints = new((*fPoints)[fPoints->GetEntriesFast()]) TPolyMarker();
634
635 Double_t currentEventTimeRelToCentral = centerTime - currentEventTime;
636 Int_t nDistPoints = track->GetNumberOfDistSpacePoints();
637 Int_t nPoints = track->GetNumberOfSpacePoints();
638
639 for(Int_t iITSPoint = 0; iITSPoint< track->GetNumberOfITSPoints();iITSPoint++){
640
641 Double_t xp = track->GetITSPoint(iITSPoint)->GetX();
642 Double_t yp = track->GetITSPoint(iITSPoint)->GetY();
643 Double_t zp = track->GetITSPoint(iITSPoint)->GetZ();
644 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
645
646 if ( xp<globXmin || xp>globXmax || yp<globYmin || yp>globYmax || zDrifted<timeZmin || zDrifted>timeZmax ) continue;
647
648 Double_t x=0.;
649 Double_t y=0.;
650 if (fProjectionType=="XT"){
651 x=zDrifted;
652 y=xp;
653 } else if (fProjectionType=="YT"){
654 x=zDrifted;
655 y=yp;
656 } else if (fProjectionType=="RT"){
657 x=zDrifted;
658 y=TMath::Sqrt(xp*xp+yp*yp);
659 } else if (fProjectionType=="XY" || fProjectionType=="YX") {
660 x=xp;
661 y=yp;
662 }
663 trackpoints->SetNextPoint(x,y);
664 }
665
666 for(Int_t iPoint = 0; iPoint< (nDistPoints<nPoints?nPoints:nDistPoints);iPoint++){
667 if(iPoint<nPoints) {
668
669
670 Double_t xp = track->GetSpacePoint(iPoint)->GetX();
671 Double_t yp = track->GetSpacePoint(iPoint)->GetY();
672 Double_t zp = track->GetSpacePoint(iPoint)->GetZ();
673 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
674
675 //Double_t zDrifted = (zp/TMath::Abs(zp))*fMaxZ0 -(zp/TMath::Abs(zp))* fDriftVel*(track->GetSpacePoint(iPoint)->GetTimeBin() -centerTime );
676 Float_t xyzp[3] = {xp,yp,zp};
677 AliTrackPoint p;
678 p.SetXYZ(xyzp);
679 Float_t tempcov[6] = {0};
680 p.SetCov(tempcov);
681 Int_t sec = track->GetSpacePoint(iPoint)->GetDetector();
682 Double_t angle=((sec%18)*20.+10.)/TMath::RadToDeg();
683 AliTrackPoint prot = p.Rotate(-angle);
684 xp = prot.GetX();
685 yp = prot.GetY();
686
687 if ( xp<globXmin || xp>globXmax || yp<globYmin || yp>globYmax || zDrifted<timeZmin || zDrifted>timeZmax ) continue;
688
689// Double_t ztime=zDrifted;
690// Double_t globx=xp;
691// Double_t globy=yp;
692
693 Double_t x=0.;
694 Double_t y=0.;
695 if (fProjectionType=="XT"){
696 x=zDrifted;
697 y=xp;
698 } else if (fProjectionType=="YT"){
699 x=zDrifted;
700 y=yp;
701 } else if (fProjectionType=="RT"){
702 x=zDrifted;
703 y=TMath::Sqrt(xp*xp+yp*yp);
704 } else if (fProjectionType=="XY" || fProjectionType=="YX") {
705 x=xp;
706 y=yp;
707 }
708
709 if(track->GetSpacePoint(iPoint)->GetRow()!=255) {
710 if(TMath::Abs(zDrifted)<fMaxZ0 && zDrifted*zp >=0 /*&&TMath::Sqrt(xp*xp + yp*yp)<fIFCRadius*/) trackpoints->SetNextPoint(x,y);
711
712 }
713 else std::cout << "row == " << track->GetSpacePoint(iPoint)->GetRow() << std::endl;
714
715 }
716 if(iPoint<nDistPoints) {
717 Double_t xpdist = track->GetDistortedSpacePoint(iPoint)->GetX();
718 Double_t ypdist = track->GetDistortedSpacePoint(iPoint)->GetY();
719 Double_t zpdist = track->GetDistortedSpacePoint(iPoint)->GetZ();
720
721 //std::cout << zpdist << std::endl;
722
723 Float_t xyzpdist[3] = {xpdist,ypdist,zpdist};
724 AliTrackPoint pdist;
725 pdist.SetXYZ(xyzpdist);
726 Float_t tempcovdist[6] = {0};
727 pdist.SetCov(tempcovdist);
728 Int_t secdist = track->GetDistortedSpacePoint(iPoint)->GetDetector();
729 Double_t angledist=((secdist%18)*20.+10.)/TMath::RadToDeg();
730 AliTrackPoint protdist = pdist.Rotate(-angledist);
731 xpdist = protdist.GetX();
732 ypdist = protdist.GetY();
733
734 UInt_t sector = track->GetDistortedSpacePoint(iPoint)->GetDetector();
735 UInt_t row = track->GetDistortedSpacePoint(iPoint)->GetRow();
736 UInt_t pad = track->GetDistortedSpacePoint(iPoint)->GetPad();
737
738 Int_t nPads = fTPCParam->GetNPads(sector,row);
739 Int_t intPad = TMath::Nint(Float_t(pad+nPads/2));
740
741 Float_t xyz[3];
742 //std::cout <<"sector: " << sector << " row: " << row << " pad: " <<pad<< std::endl;
743 fRoc->GetPositionGlobal(sector,row,intPad,xyz);
744
745 Double_t zDrifteddist = (zpdist/TMath::Abs(zpdist))*fMaxZ0 -(zpdist/TMath::Abs(zpdist))* fDriftVel*(track->GetDistortedSpacePoint(iPoint)->GetTimeBin() -centerTime );
746
747 if ( xpdist<globXmin || xpdist>globXmax || ypdist<globYmin || ypdist>globYmax || zDrifteddist<timeZmin || zDrifteddist>timeZmax ) continue;
748
749 Double_t x=0.;
750 Double_t y=0.;
751 if (fProjectionType=="XT"){
752 x=zDrifteddist;
753 y=xpdist;
754 } else if (fProjectionType=="YT"){
755 x=zDrifteddist;
756 y=ypdist;
757 } else if (fProjectionType=="RT"){
758 x=zDrifteddist;
759 y=TMath::Sqrt(xpdist*xpdist+ypdist*ypdist);
760 } else if (fProjectionType=="XY" || fProjectionType=="YX") {
761 x=xpdist;
762 y=ypdist;
763 }
764
765 if(row!=255){
766
767 if(TMath::Abs(zDrifteddist)<fMaxZ0 && zDrifteddist*zpdist>=0 /*&&TMath::Sqrt(xpdist*xpdist + ypdist*ypdist)<fIFCRadius*/) {
768
769 disttrackpoints->SetNextPoint(x,y);
770 //if(TMath::Sqrt(xpdist*xpdist + ypdist*ypdist)<fIFCRadius) std::cout << "fMaxZ0 " << fMaxZ0 <<" inside " << xpdist << " " << "zpdist " << zpdist << " " << "zDrifteddist "<< zDrifteddist << " " << zDrifteddist*zpdist << std::endl;
771 }
772 }
773 else std::cout << "row == " << row << std::endl;
774 //Double_t zDrifteddist =(zpdist/TMath::Abs(zpdist))*fMaxZ0 -(zpdist/TMath::Abs(zpdist))*(currentEvent->GetTrack(iTrack)->GetDistortedSpacePoint(iPoint)->GetTimeBin()- currentEvent->GetT0() )* fDriftVel;
775
776
777 }
778 // if( ( (trackPhi>phiCut && trackPhi < TMath::Pi() - phiCut) || ( trackPhi>TMath::Pi() + phiCut && trackPhi < TMath::TwoPi() - phiCut)) ) {
779
780
781
782
783
784 }
785 if(0){
786 for(Int_t iTRDPoint = 0; iTRDPoint< track->GetNumberOfTRDPoints();iTRDPoint++){
787
788 Double_t xp = track->GetTRDPoint(iTRDPoint)->GetX();
789 Double_t yp = track->GetTRDPoint(iTRDPoint)->GetY();
790 Double_t zp = track->GetTRDPoint(iTRDPoint)->GetZ();
791 Double_t zDrifted = zp+(zp/TMath::Abs(zp))*currentEventTimeRelToCentral * fDriftVel;
792
793 if ( xp<globXmin || xp>globXmax || yp<globYmin || yp>globYmax || zDrifted<timeZmin || zDrifted>timeZmax ) continue;
794
795 Double_t x=0.;
796 Double_t y=0.;
797 if (fProjectionType=="XT"){
798 x=zDrifted;
799 y=xp;
800 } else if (fProjectionType=="YT"){
801 x=zDrifted;
802 y=yp;
803 } else if (fProjectionType=="RT"){
804 x=zDrifted;
805 y=TMath::Sqrt(xp*xp+yp*yp);
806 } else if (fProjectionType=="XY" || fProjectionType=="YX") {
807 x=xp;
808 y=yp;
809 }
810 trackpoints->SetNextPoint(x,y);
811 }
812 }
813 if(1){
814 if(trackpoints && trackpoints->GetN()>0) {
815 // trackpoints->SetMarkerColor(1+currentEvent->GetEventNumber()%9);
816 //trackpoints->SetMarkerStyle(6);
817 trackpoints->Draw("same");
818 }
819 if(disttrackpoints && disttrackpoints->GetN()>0) {
820 //
821 //disttrackpoints->SetMarkerStyle(6);
822 disttrackpoints->SetMarkerColor(color);
823
824
825 disttrackpoints->Draw("same");
826
827 }
828
829 }
830
831
832
833
e2d1174f 834}
835
836//________________________________________________________________
837void AliToyMCDrawer::DrawGeometry() {
838
839
840 //delete fDispGraph;
841 //fDispGraph = new TGraph2D();
842 delete fDispHist;
c484014f 843
844 Double_t timeZmin=-fMaxZ0;
845 Double_t timeZmax= fMaxZ0;
846 Double_t globXmin=-(fOFCRadius +10);
847 Double_t globXmax= fOFCRadius +10 ;
848 Double_t globYmin=-(fOFCRadius +10);
849 Double_t globYmax= fOFCRadius +10 ;
850
851 const Double_t epsilon=.001;
852
853 TString title;
854 if (fTimeZmax>fTimeZmin) {
855 timeZmin=fTimeZmin;
856 timeZmax=fTimeZmax;
857 }
858 if (fGlobalXmax>fGlobalXmin) {
859 globXmin=fGlobalXmin;
860 globXmax=fGlobalXmax;
861 }
862 if (fGlobalYmax>fGlobalYmin) {
863 globYmin=fGlobalYmin;
864 globYmax=fGlobalYmax;
865 }
27fe734c 866 fDispHist = new TH3F("fDispHist",";#it{z} (cm); #it{x} (cm); #it{y} (cm)",
cdf56507 867 100, timeZmin-10, timeZmax+10,
868 100, globXmin, globXmax ,
869 100, globYmin, globYmax);
c484014f 870
e2d1174f 871 //if(!fDispGraph) fDispGraph = new TGraph();
872
873 //fDispGraph->Clear();
874 fDispHist->SetStats(0);
e2d1174f 875 fDispHist->Draw();
876 gPad->SetPhi(0);
877 gPad->SetTheta(0);
c484014f 878
879 TPolyLine3D *endCap1 = 0x0;
880 if (timeZmin-epsilon<-fMaxZ0)
881 endCap1=new TPolyLine3D();
882 printf("time: %p, %.2f,, %.2f, %.2f, %.2f, %d\n",endCap1,fTimeZmin,fTimeZmax,timeZmin-epsilon,fMaxZ0, timeZmin-epsilon<-fMaxZ0);
883 TPolyLine3D *endCap2 = 0x0;
884 if (timeZmax+epsilon> fMaxZ0)
885 endCap2=new TPolyLine3D();
886
887 TPolyLine3D *outerCE = 0x0;
888 if (timeZmin<0 && timeZmax>0 )
889 outerCE=new TPolyLine3D();
890
891 TPolyLine3D *cage[18] ={0x0};
892
893 TPolyLine3D *innerCage[18] ={0x0};
894
895 TPolyLine3D *innerEndCap1 = 0x0;
896 if (timeZmin-epsilon<-fMaxZ0)
897 innerEndCap1=new TPolyLine3D();
898
899 TPolyLine3D *innerEndCap2 = 0x0;
900 if (timeZmax+epsilon> fMaxZ0)
901 innerEndCap2=new TPolyLine3D();
902
903 TPolyLine3D *innerCE = 0x0;
904 if (timeZmin<0 && timeZmax>0 )
905 innerCE=new TPolyLine3D();
906
907 Int_t iPoint=0;
908 Double_t angle = 0.;
909 Double_t globalX = 0.;
910 Double_t globalY = 0.;
911 Double_t globalXi = 0.;
912 Double_t globalYi = 0.;
913
914 for(Int_t i = 0; i<18; i++){
915 angle = i*TMath::TwoPi()/18;
916 globalX = fOFCRadius*TMath::Cos(angle);
917 globalY = fOFCRadius*TMath::Sin(angle);
918 globalXi = fIFCRadius*TMath::Cos(angle);
919 globalYi = fIFCRadius*TMath::Sin(angle);
e2d1174f 920
c484014f 921 cage[iPoint] = new TPolyLine3D();
922 cage[iPoint]->SetPoint(0,timeZmin,globalX ,globalY) ;
923 cage[iPoint]->SetPoint(1, timeZmax,globalX ,globalY) ;
924 innerCage[iPoint] = new TPolyLine3D();
925 innerCage[iPoint]->SetPoint(0,timeZmin,globalXi ,globalYi) ;
926 innerCage[iPoint]->SetPoint(1, timeZmax,globalXi ,globalYi) ;
927
928 // only draw if inside range
929 if (endCap1) { endCap1->SetPoint(i,timeZmax, globalX, globalY); }
930 if (endCap2) { endCap2->SetPoint(i,timeZmin, globalX, globalY); }
931 if (outerCE) { outerCE->SetPoint(i, 0., globalX, globalY); }
e2d1174f 932
c484014f 933 if (innerEndCap1) { innerEndCap1->SetPoint(i, timeZmax, globalXi, globalYi); }
934 if (innerEndCap2) { innerEndCap2->SetPoint(i, timeZmin, globalXi, globalYi); }
935 if (innerCE) { innerCE->SetPoint(i, 0., globalXi, globalYi); }
e2d1174f 936
c484014f 937 innerCage[iPoint]->Draw("same");
938
939 if(!(i%2))
940 cage[iPoint]->Draw("same");
e2d1174f 941
c484014f 942 ++iPoint;
943 }
e2d1174f 944
c484014f 945 //
946 // close endplate and CE polygons
947 //
948 Int_t i=18;
949 angle = i*TMath::TwoPi()/18;
950 globalX = fOFCRadius*TMath::Cos(angle);
951 globalY = fOFCRadius*TMath::Sin(angle);
952 globalXi = fIFCRadius*TMath::Cos(angle);
953 globalYi = fIFCRadius*TMath::Sin(angle);
e2d1174f 954
c484014f 955 // only draw if inside range
956 if (endCap1) { endCap1->SetPoint(i, timeZmax, globalX, globalY); }
957 if (endCap2) { endCap2->SetPoint(i, timeZmin, globalX, globalY); }
958 if (outerCE) { outerCE->SetPoint(i, 0., globalX, globalY); }
959
960 if (innerEndCap1) { innerEndCap1->SetPoint(i, timeZmax, globalXi, globalYi); }
961 if (innerEndCap2) { innerEndCap2->SetPoint(i, timeZmin, globalXi, globalYi); }
962 if (innerCE) { innerCE ->SetPoint(i, 0., globalXi, globalYi); }
963
964 if (endCap1) { endCap1->Draw("same"); }
965 if (endCap2) { endCap2->Draw("same"); }
966 if (outerCE) { outerCE->Draw("same"); }
e2d1174f 967
c484014f 968 if (innerEndCap1) { innerEndCap1->Draw("same"); }
969 if (innerEndCap2) { innerEndCap2->Draw("same"); }
970 if (innerCE) { innerCE ->Draw("same"); }
971
e2d1174f 972}
973
cdf56507 974//________________________________________________________________
975void AliToyMCDrawer::DrawGeometry2D() {
976
977
978 //delete fDispGraph;
979 //fDispGraph = new TGraph2D();
980 delete fDispHist;
981
982 Double_t timeZmin=-fMaxZ0;
983 Double_t timeZmax= fMaxZ0;
984 Double_t globXmin=-(fOFCRadius +10);
985 Double_t globXmax= fOFCRadius +10 ;
986 Double_t globYmin=-(fOFCRadius +10);
987 Double_t globYmax= fOFCRadius +10 ;
988
989 const Double_t epsilon=.001;
990
991 TString title;
992 if (fTimeZmax>fTimeZmin) {
993 timeZmin=fTimeZmin;
994 timeZmax=fTimeZmax;
995 }
996 if (fGlobalXmax>fGlobalXmin) {
997 globXmin=fGlobalXmin;
998 globXmax=fGlobalXmax;
999 }
1000 if (fGlobalYmax>fGlobalYmin) {
1001 globYmin=fGlobalYmin;
1002 globYmax=fGlobalYmax;
1003 }
1004 TCanvas *c=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("cDrawer");
1005
1006 if (fProjectionType=="XT"){
1007 if (!c) c=new TCanvas("cDrawer","Toy Drawer");
27fe734c 1008 fDispHist = new TH2F("fDispHist",";#it{z} (cm); #it{x} (cm)",
cdf56507 1009 100, timeZmin-10, timeZmax+10,
1010 100, globXmin, globXmax);
1011 } else if (fProjectionType=="YT"){
1012 if (!c) c=new TCanvas("cDrawer","Toy Drawer");
27fe734c 1013 fDispHist = new TH2F("fDispHist",";#it{z} (cm); #it{y} (cm)",
cdf56507 1014 100, timeZmin-10, timeZmax+10,
1015 100, globYmin, globYmax);
1016 } else if (fProjectionType=="RT"){
1017 if (!c) c=new TCanvas("cDrawer","Toy Drawer");
27fe734c 1018 fDispHist = new TH2F("fDispHist",";#it{z} (cm); #it{r} (cm)",
cdf56507 1019 100, timeZmin-10, timeZmax+10,
1020 100, globYmin, globYmax);
1021 } else if (fProjectionType=="YX"||fProjectionType=="XY"){
1022 if (!c) c=new TCanvas("cDrawer","Toy Drawer",800,800);
1023 c->SetLeftMargin(0.15);
1024 c->SetRightMargin(0.05);
27fe734c 1025 fDispHist = new TH2F("fDispHist",";#it{x} (cm); #it{y} (cm)",
cdf56507 1026 100, globXmin, globXmax,
1027 100, globYmin, globYmax);
1028 fDispHist->GetYaxis()->SetTitleOffset(1.5);
1029 } else {
1030 AliError(Form("Display Format not known: %s",fProjectionType.Data()));
1031 return;
1032 }
1033
1034 c->Clear();
1035
1036 //if(!fDispGraph) fDispGraph = new TGraph();
1037
1038 //fDispGraph->Clear();
1039 fDispHist->SetStats(0);
1040 fDispHist->Draw();
1041 gPad->SetPhi(0);
1042 gPad->SetTheta(0);
1043
1044 TPolyLine *endCap1 = 0x0;
1045 if (timeZmin-epsilon<-fMaxZ0)
1046 endCap1=new TPolyLine();
1047 printf("time: %p, %.2f,, %.2f, %.2f, %.2f, %d\n",endCap1,fTimeZmin,fTimeZmax,timeZmin-epsilon,fMaxZ0, timeZmin-epsilon<-fMaxZ0);
1048 TPolyLine *endCap2 = 0x0;
1049 if (timeZmax+epsilon> fMaxZ0)
1050 endCap2=new TPolyLine();
1051
1052 TPolyLine *outerCE = 0x0;
1053 if (timeZmin<0 && timeZmax>0 )
1054 outerCE=new TPolyLine();
1055
1056 TPolyLine *cage[18] ={0x0};
1057
1058 TPolyLine *innerCage[18] ={0x0};
1059
1060 TPolyLine *innerEndCap1 = 0x0;
1061 if (timeZmin-epsilon<-fMaxZ0)
1062 innerEndCap1=new TPolyLine();
1063
1064 TPolyLine *innerEndCap2 = 0x0;
1065 if (timeZmax+epsilon> fMaxZ0)
1066 innerEndCap2=new TPolyLine();
1067
1068 TPolyLine *innerCE = 0x0;
1069 if (timeZmin<0 && timeZmax>0 )
1070 innerCE=new TPolyLine();
1071
1072 Int_t iPoint=0;
1073 Double_t angle = 0.;
1074 Double_t globalX = 0.;
1075 Double_t globalY = 0.;
1076 Double_t globalXi = 0.;
1077 Double_t globalYi = 0.;
1078 Double_t globalXi2= 0.;
1079 Double_t globalYi2= 0.;
1080
1081
1082 if (fProjectionType=="YX"||fProjectionType=="XY") {
1083 for(Int_t i = 0; i<18; i++){
1084 angle = i*TMath::TwoPi()/18;
1085 globalX = fOFCRadius*TMath::Cos(angle);
1086 globalY = fOFCRadius*TMath::Sin(angle);
1087 globalXi = fIFCRadius*TMath::Cos(angle);
1088 globalYi = fIFCRadius*TMath::Sin(angle);
1089 globalXi = fIFCRadius*TMath::Cos(angle);
1090 globalYi = fIFCRadius*TMath::Sin(angle);
1091 globalXi2= 135.5*TMath::Cos(angle);
1092 globalYi2= 135.5*TMath::Sin(angle);
1093
1094 if ( globalX<globXmin || globalX>globXmax || globalY<globYmin || globalY>globYmax ) {
1095 continue;
1096 }
1097 // in xy, abuse for sector boundaries
1098 cage[iPoint] = new TPolyLine();
1099 cage[iPoint]->SetPoint(0, globalX ,globalY) ;
1100 cage[iPoint]->SetPoint(1, globalXi ,globalYi) ;
1101 // only draw if inside range
1102 if (endCap1) { endCap1->SetPoint(iPoint, globalX, globalY); }
1103
1104 if (innerEndCap1) { innerEndCap1->SetPoint(iPoint, globalXi, globalYi); }
1105 if (innerEndCap2) { innerEndCap2->SetPoint(iPoint, globalXi2, globalYi2); }
1106
1107 cage[iPoint]->Draw("same");
1108
1109 ++iPoint;
1110 }
1111 }
1112
1113 angle = 5*TMath::TwoPi()/18;
1114 globalX = fOFCRadius*TMath::Cos(angle);
1115 globalY = fOFCRadius*TMath::Sin(angle);
1116 globalXi = fIFCRadius*TMath::Cos(angle);
1117 globalYi = fIFCRadius*TMath::Sin(angle);
1118 globalXi = fIFCRadius*TMath::Cos(angle);
1119 globalYi = fIFCRadius*TMath::Sin(angle);
1120 globalXi2= 135.5*TMath::Cos(angle);
1121 globalYi2= 135.5*TMath::Sin(angle);
1122 if (endCap1) { endCap1->SetPoint(iPoint, 0, globalY); }
1123
1124 if (innerEndCap1) { innerEndCap1->SetPoint(iPoint, 0, globalYi); }
1125 if (innerEndCap2) { innerEndCap2->SetPoint(iPoint, 0, globalYi2); }
1126 ++iPoint;
1127 //
1128 // close endplate and CE polygons
1129 //
1130 Int_t i=18;
1131 angle = i*TMath::TwoPi()/18;
1132 globalX = fOFCRadius*TMath::Cos(angle);
1133 globalY = fOFCRadius*TMath::Sin(angle);
1134 globalXi = fIFCRadius*TMath::Cos(angle);
1135 globalYi = fIFCRadius*TMath::Sin(angle);
1136 globalXi2= 135.5*TMath::Cos(angle);
1137 globalYi2= 135.5*TMath::Sin(angle);
1138
1139 // only draw if inside range
1140 if ( !(globalX<globXmin || globalX>globXmax || globalY<globYmin || globalY>globYmax) ) {
1141 if (endCap1) { endCap1->SetPoint(i, globalX, globalY); }
1142// if (endCap2) { endCap2->SetPoint(i, globalX, globalY); }
1143// if (outerCE) { outerCE->SetPoint(i, globalX, globalY); }
1144
1145 if (innerEndCap1) { innerEndCap1->SetPoint(i, globalXi, globalYi); }
1146 if (innerEndCap2) { innerEndCap2->SetPoint(i, globalXi2, globalYi2); }
1147// if (innerCE) { innerCE ->SetPoint(i, globalXi, globalYi); }
1148
1149 }
1150
1151 if (endCap1) { endCap1->Draw("same"); }
1152 // if (endCap2) { endCap2->Draw("same"); }
1153 // if (outerCE) { outerCE->Draw("same"); }
1154
1155 if (innerEndCap1) { innerEndCap1->Draw("same"); }
1156 if (innerEndCap2) { innerEndCap2->Draw("same"); }
1157 // if (innerCE) { innerCE ->Draw("same"); }
1158}
1159
0403120d 1160//________________________________________________________________
1161Bool_t AliToyMCDrawer::ConnectInputTree()
1162{
1163 //
1164 //
1165 //
1166
1167 if(fFileName.IsNull()) {
1168 AliError("no input file provided, using default (toyMC.root)");
1169 fFileName = "toyMC.root";
1170 }
1171 if (fInFile && fInFile->GetName()==fFileName) return kTRUE;
1172 delete fInFile;
1173 fInFile=0x0;
1174 delete fInputTree;
1175 fInputTree=0x0;
1176
1177 fInFile = new TFile(fFileName.Data(),"read");
1178 if (!fInFile || !fInFile->IsOpen() || fInFile->IsZombie() ) {
1179 delete fInFile;
1180 return kFALSE;
1181 }
1182
1183 gROOT->cd();
1184
1185 fInputTree = dynamic_cast<TTree*> (fInFile->Get("toyMCtree"));
1186
1187 if (!fInputTree){
1188 AliError("Could not connect tree!\n");
1189 delete fInFile;
1190 fInFile=0x0;
1191 return kFALSE;
1192 }
1193
1194 fInputTree->SetBranchAddress("event",&fEvent);
1195 return kTRUE;
1196}