Double_t fiber_width = .1; struct hit { hit() {} hit(Bool_t isTop_i, Int_t x_fiber_i, Int_t y_fiber_i, Double_t x_time_i, Double_t y_time_i) : isTop(isTop_i), x_fiber(x_fiber_i), y_fiber(y_fiber_i), x_time(x_time_i), y_time(y_time_i) { if ( isTop ) {x = (x_fiber + 1)*fiber_width; y = (y_fiber - 63)*fiber_width;} else {x = (x_fiber - 31)*fiber_width; y = (y_fiber - 95)*fiber_width;} delay = y_time - x_time; } ~hit(){} Bool_t isTop; Int_t x_fiber; Int_t y_fiber; Double_t x; Double_t y; Double_t x_time; Double_t y_time; Double_t delay; string TopBot() { if (isTop) return "top"; else return "bottom"; } void Show(); }; void hit::Show() { cout << "This is a hit on the " << TopBot() << " CRT. \n"; cout << "Fibers: (" << x_fiber << ", " << y_fiber << "). Position: (" << x << ", " << y << "). \n"; cout << "Time: (" << x_time << ", " << y_time << "). Delay: " << delay << ". \n"; } struct track { track(){} track(hit topHit_i, hit botHit_i) : topHit(topHit_i), botHit(botHit_i) { x_delay = botHit->x_time - topHit->x_time; y_delay = botHit->x_time - topHit->x_time; } ~track(){} hit * topHit; hit * botHit; Double_t topDelay() { return topHit->delay; } Double_t botDelay() { return botHit->delay; } Double_t x_delay; Double_t y_delay; void Show(); }; void track::Show(){ cout << "Showing track: \n"; cout << "-------------------------------------- \n"; cout << "This is the top hit: \n"; topHit->Show(); cout << "-------------------------------------- \n"; cout << "This is the bottom hit: \n"; botHit->Show(); cout << "-------------------------------------- \n"; cout << "The overall x delay is " << x_delay << ". \n"; cout << "The overall y delay is " << y_delay << ". \n"; } void test() { hit bruce(1,21,77,13,15); bruce.Show(); hit giles(0,52,99,14,17); giles.Show(); jerome = new track(bruce,giles); jerome->Show(); } |