Exemplo n.º 1
0
void PhaseSpace() {

   if (!gROOT->GetClass("TGenPhaseSpace")) gSystem->Load("libPhysics");

   TLorentzVector target(0.0, 0.0, 0.0, 0.938);
   TLorentzVector beam(0.0, 0.0, .65, .65);
   TLorentzVector W = beam + target;

   //(Momentum, Energy units are Gev/C, GeV)
   Double_t masses[3] = { 0.938, 0.139, 0.139} ;

   TGenPhaseSpace event;
   event.SetDecay(W, 3, masses);

   TH2F *h2 = new TH2F("h2","h2", 50,1.1,1.8, 50,1.1,1.8);

   for (Int_t n=0;n<100000;n++) {
      Double_t weight = event.Generate();

      TLorentzVector *pProton = event.GetDecay(0);

      TLorentzVector *pPip    = event.GetDecay(1);
      TLorentzVector *pPim    = event.GetDecay(2);

      TLorentzVector pPPip = *pProton + *pPip;
      TLorentzVector pPPim = *pProton + *pPim;

      h2->Fill(pPPip.M2() ,pPPim.M2() ,weight);
   }
   h2->Draw();
}
Exemplo n.º 2
0
void RangeSensor::updateBeamsLookup(){
	for (unsigned int i=0; i<m_beams.size(); i++){
		RangeSensor::Beam& beam(m_beams[i]);
		beam.s=sin(m_beams[i].pose.theta);
		beam.c=cos(m_beams[i].pose.theta);
	}
}
Exemplo n.º 3
0
VisualizationNodePtr OSGVisualizationFactory::createLine(const Eigen::Matrix4f &from, const Eigen::Matrix4f &to, float width, float colorR, float colorG, float colorB)
{
	osg::Vec3 sp(from(0,3),from(1,3),from(2,3)); 
	osg::Vec3 ep(to(0,3),to(1,3),to(2,3)); 
	osg::ref_ptr<osg::Geometry> beam( new osg::Geometry); 
	osg::ref_ptr<osg::Vec3Array> points = new osg::Vec3Array; 
	points->push_back(sp); 
	points->push_back(ep); 
	osg::ref_ptr<osg::Vec4Array> color = new osg::Vec4Array; 
	color->push_back(osg::Vec4(colorR,colorG,colorB,1.0)); 
	beam->setVertexArray(points.get()); 
	beam->setColorArray(color.get()); 
	beam->setColorBinding(osg::Geometry::BIND_PER_VERTEX); // BIND_PER_PRIMITIVE
	beam->addPrimitiveSet(new osg::DrawArrays(GL_LINES,0,2));


	osg::Geode* bg = new osg::Geode();
	bg->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
	bg->addDrawable(beam);
	osg::Group* s = new osg::Group;
	s->addChild(bg);

	VisualizationNodePtr visualizationNode(new OSGVisualizationNode(s));
	return visualizationNode;
}
Exemplo n.º 4
0
void Trhythm::debug(const char* text) const {
  if (m_r == e_none)
    qDebug() << text << "no rhythm";
  else {
    qDebug() << text << xmlType() << "| rest" << isRest() << "| dot" << hasDot() << "| triplet" << isTriplet() << "| duration" << duration()
             << "| beam" << beam() << "| tie" << tie() << "| stem" << (stemDown() ? "down" : "up")
             << "|" << (m_prefs % 8) << m_prefs;
  }
}
Exemplo n.º 5
0
RangeSensor::RangeSensor(std::string name, unsigned int beams_num, double res, const OrientedPoint& position, double span, double maxrange):Sensor(name),
	m_pose(position), m_beams(beams_num){
	double angle=-.5*res*beams_num;
	for (unsigned int i=0; i<beams_num; i++, angle+=res){
		RangeSensor::Beam& beam(m_beams[i]);
		beam.span=span;
		beam.pose.x=0;
		beam.pose.y=0;
		beam.pose.theta=angle;
		beam.maxRange=maxrange;
	}
	newFormat=0;
	updateBeamsLookup();
}
Exemplo n.º 6
0
void ChordRest::writeBeam(Xml& xml)
      {
      Beam* b = beam();
#ifndef NDEBUG
      if (b && b->elements().front() == this && (MScore::testMode || !b->generated())) {
            b->setId(xml.beamId++);
            b->write(xml);
            }
#else
      if (b && !b->generated() && b->elements().front() == this) {
            b->setId(xml.beamId++);
            b->write(xml);
            }
#endif
      }
Exemplo n.º 7
0
bool scene::occluded(float *vectA, float *vectB)
{
	bool result;
	float *tempA;
	float dist;

	tempA = new float[3];
	vectorSub(tempA, vectB, vectA);
	dist = vectorMod(tempA);
	vectorNorm(tempA, tempA);
	if (beam(vectA, tempA, dist) != -1)
		result = true;
	else
		result = false;
	delete []tempA;
	return result;
}
Exemplo n.º 8
0
unit* DebufBeam(int spell_length_, unit* order, coord_def target)
{

	beam_iterator beam(order->position,order->position);
	if(CheckThrowPath(order->position,target,beam))
	{
		beam.init();
		int length = spell_length_;
		unit *hit_mon = NULL;
		while(env[current_level].isMove(*(beam),true) && length>0)
		{
			for(vector<monster>::iterator it=env[current_level].mon_vector.begin();it!=env[current_level].mon_vector.end();it++)
			{
				if((*it).isLive() && (*it).position.x == (*beam).x && (*it).position.y == (*beam).y)
				{
					hit_mon = &(*it);
				}
			}
			if( you.position.x == (*beam).x && you.position.y == (*beam).y)
			{				
				hit_mon = &you;
			}
			length--;
			beam++;
			if(hit_mon)
			{
				if(hit_mon == order && target != hit_mon->position)
				{
					hit_mon = NULL;
					continue;
				}
				return hit_mon;
			}
		}
	}
	return NULL;
}
Exemplo n.º 9
0
void Player::think()
{    
  static int count=0;
  static int counter=0;
  if(mustBeam())
  {
    
   if( (count % 10)==0 )
       beam();
   
   count++;
   if(count>10)
       count=0;
  }
  
  if(mustBeforKickOfBeam())
  {  
       if( (counter % 10)==0 )
          beforKickOfBeam();
   
       counter++;
       if(counter>10)
           counter=0;
  }
  
  
    switch ( WorldModel::instance().getPlayMode() )
    {
        case PM_BeforeKickOff :
            return playBeforeKickOff();
            break;
        case PM_KickOff_Left:
        case PM_KickOff_Right:
            return playKickOff();
            break;
        case PM_PlayOn:
            return playPlayOn();
            break;
        case PM_KickIn_Left:
        case PM_KickIn_Right:
            return playKickIn();
            break;
        case PM_CORNER_KICK_LEFT:
        case PM_CORNER_KICK_RIGHT:
            return playCornerKick();
            break;
        case PM_GOAL_KICK_LEFT:
        case PM_GOAL_KICK_RIGHT:
            return playGoalKick();
            break;
        case PM_OFFSIDE_LEFT:
        case PM_OFFSIDE_RIGHT:
            return playOffSide();
            break;       
        case PM_GameOver:
            return playGameOver();
            break;
        case PM_Goal_Left:
        case PM_Goal_Right:
            return playGoal();
            break;
        case PM_FREE_KICK_LEFT:
        case PM_FREE_KICK_RIGHT:
            return playFreeKick();
            break;
        default:
            cerr<<"[WARNING] Player can not handle this Play Mode!\n";
            break;
    }
}
Exemplo n.º 10
0
static void makemoves(void) {
	int i, hitme;
	char ch;
	while (TRUE) { /* command loop */
		hitme = FALSE;
		justin = 0;
		Time = 0.0;
		i = -1;
		while (TRUE)  { /* get a command */
			chew();
			skip(1);
			proutn("COMMAND> ");
			if (scan() == IHEOL) continue;
			for (i=0; i < 29; i++) // Abbreviations allowed for the first 29 commands, only.
				if (isit(commands[i]))
					break;
			if (i < 29) break;
			for (; i < NUMCOMMANDS; i++)
				if (strcmp(commands[i], citem) == 0) break;
			if (i < NUMCOMMANDS
#ifndef CLOAKING
			    && i != 26 // ignore the CLOAK command
#endif
#ifndef CAPTURE
			    && i != 27 // ignore the CAPTURE command
#endif
#ifndef SCORE
			    && i != 28 // ignore the SCORE command
#endif
#ifndef DEBUG
			    && i != 33 // ignore the DEBUG command
#endif
			   ) break;

			if (skill <= SFAIR)  {
				prout("UNRECOGNIZED COMMAND. LEGAL COMMANDS ARE:");
				listCommands(TRUE);
			}
			else prout("UNRECOGNIZED COMMAND.");
		}
		switch (i) { /* command switch */
			case 0:			// srscan
				srscan(1);
				break;
			case 1:			// lrscan
				lrscan();
				break;
			case 2:			// phasers
				phasers();
                if (ididit) {
#ifdef CLOAKING
                    if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) {
                        prout("The Romulan ship discovers you are breaking the Treaty of Algeron!");
                        ncviol++;
                        isviolreported = TRUE;
                    }
#endif
                    hitme = TRUE;
                }
				break;
			case 3:			// photons
				photon();
                if (ididit) {
#ifdef CLOAKING
                    if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) {
                        prout("The Romulan ship discovers you are breaking the Treaty of Algeron!");
                        ncviol++;
                        isviolreported = TRUE;
                    }
#endif
                    hitme = TRUE;
                }
				break;
			case 4:			// move
				warp(1);
				break;
			case 5:			// shields
				sheild(1);
				if (ididit) {
					attack(2);
					shldchg = 0;
				}
				break;
			case 6:			// dock
				dock();
				break;
			case 7:			// damages
				dreprt();
				break;
			case 8:			// chart
				chart(0);
				break;
			case 9:			// impulse
				impuls();
				break;
			case 10:		// rest
				waiting();
				if (ididit) hitme = TRUE;
				break;
			case 11:		// warp
				setwrp();
				break;
			case 12:		// status
				srscan(3);
				break;
			case 13:			// sensors
				sensor();
				break;
			case 14:			// orbit
				orbit();
				if (ididit) hitme = TRUE;
				break;
			case 15:			// transport "beam"
				beam();
				break;
			case 16:			// mine
				mine();
				if (ididit) hitme = TRUE;
				break;
			case 17:			// crystals
				usecrystals();
				break;
			case 18:			// shuttle
				shuttle();
				if (ididit) hitme = TRUE;
				break;
			case 19:			// Planet list
				preport();
				break;
			case 20:			// Status information
				srscan(2);
				break;
			case 21:			// Game Report 
				report(0);
				break;
			case 22:			// use COMPUTER!
				eta();
				break;
			case 23:
				listCommands(TRUE);
				break;
			case 24:		// Emergency exit
				clearscreen();	// Hide screen
				freeze(TRUE);	// forced save
				exit(1);		// And quick exit
				break;
			case 25:
				probe();		// Launch probe
				break;
#ifdef CLOAKING
			case 26:
				cloak();        // turn on/off cloaking
				if (iscloaking) {
					attack(2); // We will be seen while we cloak
					iscloaking = FALSE;
					iscloaked = TRUE;
				}
				break;
#endif
#ifdef CAPTURE
			case 27:
				capture();      // Attempt to get Klingon ship to surrender
				if (ididit) hitme = TRUE;
				break;
#endif
#ifdef SCORE
			case 28:
				score(1);    // get the score
				break;
#endif
			case 29:			// Abandon Ship
				abandn();
				break;
			case 30:			// Self Destruct
				dstrct();
				break;
			case 31:			// Save Game
				freeze(FALSE);
				if (skill > SGOOD)
					prout("WARNING--Frozen games produce no plaques!");
				break;
			case 32:			// Try a desparation measure
				deathray();
				if (ididit) hitme = TRUE;
				break;
#ifdef DEBUG
			case 33:			// What do we want for debug???
				debugme();
				break;
#endif
			case 34:		// Call for help
				help();
				break;
			case 35:
				alldone = 1;	// quit the game
#ifdef DEBUG
				if (idebug) score(0);
#endif
				break;
			case 36:
				helpme();	// get help
				break;
		}
		for (;;) {
			if (alldone) break;		// Game has ended
#ifdef DEBUG
			if (idebug) prout("2500");
#endif
			if (Time != 0.0) {
				events();
				if (alldone) break;		// Events did us in
			}
			if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!
				atover(0);
				continue;
			}
			if (nenhere == 0) movetho();
			if (hitme && justin==0) {
				attack(2);
				if (alldone) break;
				if (d.galaxy[quadx][quady] == 1000) {	// went NOVA! 
					atover(0);
					hitme = TRUE;
					continue;
				}
			}
			break;
		}
		if (alldone) break;
	}
}
Exemplo n.º 11
0
void ChordRest::layoutArticulations()
      {
      if (parent() == 0 || _articulations.isEmpty())
            return;
      qreal _spatium  = spatium();
      qreal _spStaff  = _spatium * staff()->lineDistance(); // scaled to staff line distance for vert. pos. within a staff

      if (type() == Element::Type::CHORD) {
            if (_articulations.size() == 1) {
                  static_cast<Chord*>(this)->layoutArticulation(_articulations[0]);
                  return;
                  }
            if (_articulations.size() == 2) {
                  //
                  // staccato | tenuto + marcato
                  //
                  Articulation* a1 = _articulations[0];
                  Articulation* a2 = _articulations[1];
                  ArticulationType st1 = a1->articulationType();
                  ArticulationType st2 = a2->articulationType();

                  if ((st2 == ArticulationType::Tenuto || st2 == ArticulationType::Staccato)
                     && (st1 == ArticulationType::Marcato)) {
                        qSwap(a1, a2);
                        qSwap(st1, st2);
                        }
                  if ((st1 == ArticulationType::Tenuto || st1 == ArticulationType::Staccato)
                     && (st2 == ArticulationType::Marcato)) {
                        QPointF pt = static_cast<Chord*>(this)->layoutArticulation(a1);
                        pt.ry() += a1->up() ? -_spStaff * .5 : _spStaff * .5;
                        a2->layout();
                        a2->setUp(a1->up());
                        a2->setPos(pt);
                        a2->adjustReadPos();
                        return;
                        }
                  //
                  // staccato | tenuto + sforzato
                  //
                  if ((st2 == ArticulationType::Tenuto || st2 == ArticulationType::Staccato)
                     && (st1 == ArticulationType::Sforzatoaccent)) {
                        qSwap(a1, a2);
                        qSwap(st1, st2);
                        }
                  if ((st1 == ArticulationType::Tenuto || st1 == ArticulationType::Staccato)
                     && (st2 == ArticulationType::Sforzatoaccent)) {
                        QPointF pt = static_cast<Chord*>(this)->layoutArticulation(a1);
                        pt.ry() += a1->up() ? -_spStaff * .7 : _spStaff * .7;
                        a2->layout();
                        a2->setUp(a1->up());
                        a2->setPos(pt);
                        a2->adjustReadPos();
                        return;
                        }
                  }
            }

      qreal x         = centerX();
      qreal distance0 = score()->styleS(StyleIdx::propertyDistance).val()     * _spatium;
      qreal distance1 = score()->styleS(StyleIdx::propertyDistanceHead).val() * _spatium;
      qreal distance2 = score()->styleS(StyleIdx::propertyDistanceStem).val() * _spatium;

      qreal chordTopY = upPos();    // note position of highest note
      qreal chordBotY = downPos();  // note position of lowest note

      qreal staffTopY = -distance2;
      qreal staffBotY = staff()->height() + distance2;

      // avoid collisions of staff articulations with chord notes:
      // gap between note and staff articulation is distance0 + 0.5 spatium

      if (type() == Element::Type::CHORD) {
            Chord* chord = static_cast<Chord*>(this);
            Stem* stem   = chord->stem();
            if (stem) {
                  qreal y = stem->pos().y() + pos().y();
                  if (up() && stem->stemLen() < 0.0)
                        y += stem->stemLen();
                  else if (!up() && stem->stemLen() > 0.0)
                        y -= stem->stemLen();

                  if (beam()) {
                        qreal bw = score()->styleS(StyleIdx::beamWidth).val() * _spatium;
                        y += up() ? -bw : bw;
                        }
                  if (up())
                        staffTopY = qMin(staffTopY, qreal(y - 0.5 * _spatium));
                  else
                        staffBotY = qMax(staffBotY, qreal(y + 0.5 * _spatium));
                  }
            }

      staffTopY = qMin(staffTopY, qreal(chordTopY - distance0 - 0.5 * _spatium));
      staffBotY = qMax(staffBotY, qreal(chordBotY + distance0 + 0.5 * _spatium));

      qreal dy = 0.0;

      int n = _articulations.size();
      for (int i = 0; i < n; ++i) {
            Articulation* a = _articulations.at(i);
            //
            // determine MScore::Direction
            //
            if (a->direction() != MScore::Direction::AUTO) {
                  a->setUp(a->direction() == MScore::Direction::UP);
                  }
            else {
                  if (a->anchor() == ArticulationAnchor::CHORD)
                        a->setUp(!up());
                  else
                        a->setUp(a->anchor() == ArticulationAnchor::TOP_STAFF || a->anchor() == ArticulationAnchor::TOP_CHORD);
                  }
            }

      //
      //    pass 1
      //    place tenuto and staccato
      //

      for (int i = 0; i < n; ++i) {
            Articulation* a = _articulations.at(i);
            a->layout();
            ArticulationAnchor aa = a->anchor();

            if ((a->articulationType() != ArticulationType::Tenuto)
               && (a->articulationType() != ArticulationType::Staccato))
                  continue;

            if (aa != ArticulationAnchor::CHORD && aa != ArticulationAnchor::TOP_CHORD && aa != ArticulationAnchor::BOTTOM_CHORD)
                  continue;

            bool bottom;
            if ((aa == ArticulationAnchor::CHORD) && measure()->hasVoices(a->staffIdx()))
                  bottom = !up();
            else
                  bottom = (aa == ArticulationAnchor::BOTTOM_CHORD) || (aa == ArticulationAnchor::CHORD && up());
            bool headSide = bottom == up();

            dy += distance1;
            qreal y;
            Chord* chord = static_cast<Chord*>(this);
            if (bottom) {
                  int line = downLine();
                  y = chordBotY + dy;
                  if (!headSide && type() == Element::Type::CHORD && chord->stem()) {
                        Stem* stem = chord->stem();
                        y          = chordTopY + stem->stemLen();
                        if (chord->beam())
                              y += score()->styleS(StyleIdx::beamWidth).val() * _spatium * .5;
                        x          = stem->pos().x();
                        int line   = lrint((y+0.5*_spatium) / _spatium);
                        if (line <= 4)    // align between staff lines
                              y = line * _spatium + _spatium * .5;
                        else
                              y += _spatium;
                        }
                  else {
                        int lines = (staff()->lines() - 1) * 2;
                        if (line < lines)
                              y = (line & ~1) + 3;
                        else
                              y = line + 2;
                        y *= _spatium * .5;
                        }
                  }
            else {
                  int line = upLine();
                  y = chordTopY - dy;
                  if (!headSide && type() == Element::Type::CHORD && chord->stem()) {
                        Stem* stem = chord->stem();
                        y          = chordBotY + stem->stemLen();
                        if (chord->beam())
                              y -= score()->styleS(StyleIdx::beamWidth).val() * _spatium * .5;
                        x          = stem->pos().x();
                        int line   = lrint((y-0.5*_spatium) / _spatium);
                        if (line >= 0)    // align between staff lines
                              y = line * _spatium - _spatium * .5;
                        else
                              y -= _spatium;
                        }
                  else {
                        if (line > 0)
                              y = ((line+1) & ~1) - 3;
                        else
                              y = line - 2;
                        y *= _spatium * .5;
                        }
                  }
            dy += _spatium * .5;
            a->setPos(x, y);
            }

      // reserve space for slur
      bool botGap = false;
      bool topGap = false;

#if 0 // TODO-S: optimize
      for (Spanner* sp = _spannerFor; sp; sp = sp->next()) {
            if (sp->type() != SLUR)
                  continue;
            Slur* s = static_cast<Slur*>(sp);
            if (s->up())
                  topGap = true;
            else
                  botGap = true;
            }
      for (Spanner* sp = _spannerBack; sp; sp = sp->next()) {
            if (sp->type() != SLUR)
                  continue;
            Slur* s = static_cast<Slur*>(sp);
            if (s->up())
                  topGap = true;
            else
                  botGap = true;
            }
#endif
      if (botGap)
            chordBotY += _spatium;
      if (topGap)
            chordTopY -= _spatium;

      //
      //    pass 2
      //    place all articulations with anchor at chord/rest
      //
      n = _articulations.size();
      for (int i = 0; i < n; ++i) {
            Articulation* a = _articulations.at(i);
            a->layout();
            ArticulationAnchor aa = a->anchor();
            if ((a->articulationType() == ArticulationType::Tenuto)
               || (a->articulationType() == ArticulationType::Staccato))
                  continue;

            if (aa != ArticulationAnchor::CHORD && aa != ArticulationAnchor::TOP_CHORD && aa != ArticulationAnchor::BOTTOM_CHORD)
                  continue;

            // for tenuto and staccate check for staff line collision
            bool staffLineCT = a->articulationType() == ArticulationType::Tenuto
                               || a->articulationType() == ArticulationType::Staccato;

//            qreal sh = a->bbox().height() * mag();
            bool bottom = (aa == ArticulationAnchor::BOTTOM_CHORD) || (aa == ArticulationAnchor::CHORD && up());

            dy += distance1;
            if (bottom) {
                  qreal y = chordBotY + dy;
                  if (staffLineCT && (y <= staffBotY -.1 - dy)) {
                        qreal l = y / _spatium;
                        qreal delta = fabs(l - round(l));
                        if (delta < 0.4) {
                              y  += _spatium * .5;
                              dy += _spatium * .5;
                              }
                        }
                  a->setPos(x, y); // - a->bbox().y() + a->bbox().height() * .5);
                  }
            else {
                  qreal y = chordTopY - dy;
                  if (staffLineCT && (y >= (staffTopY +.1 + dy))) {
                        qreal l = y / _spatium;
                        qreal delta = fabs(l - round(l));
                        if (delta < 0.4) {
                              y  -= _spatium * .5;
                              dy += _spatium * .5;
                              }
                        }
                  a->setPos(x, y); // + a->bbox().y() - a->bbox().height() * .5);
                  }
            }

      //
      //    pass 3
      //    now place all articulations with staff top or bottom anchor
      //
      qreal dyTop = staffTopY;
      qreal dyBot = staffBotY;

/*      if ((upPos() - _spatium) < dyTop)
            dyTop = upPos() - _spatium;
      if ((downPos() + _spatium) > dyBot)
            dyBot = downPos() + _spatium;
  */
      for (int i = 0; i < n; ++i) {
            Articulation* a = _articulations.at(i);
            ArticulationAnchor aa = a->anchor();
            if (aa == ArticulationAnchor::TOP_STAFF || aa == ArticulationAnchor::BOTTOM_STAFF) {
                  if (a->up()) {
                        a->setPos(x, dyTop);
                        dyTop -= distance0;
                        }
                  else {
                        a->setPos(x, dyBot);
                        dyBot += distance0;
                        }
                  }
            a->adjustReadPos();
            }
      }
Exemplo n.º 12
0
static void ferris_wheel(double x, double y , double z, double size)
{
    double pi = M_PI;
    double step = 2*pi/10;
    double r = 3;
    int i;
    //  Draw passenger_boxes
    glPushMatrix();
    glTranslated(x,y,z);
    glScaled(size,size,size);
    for (i=0;i<10;i++)
    {
        double passenger_box_x = r * cos(i*step+rotation);
        double passenger_box_y = r * sin(i*step+rotation);
        passenger_box(passenger_box_x, passenger_box_y,0 , 0.3,0.3,0.3 , 0);
    }
    
    // Draw Circle
    outer_frame(0, 0, -0.31, r, 10, step);
    outer_frame(0, 0, 0.31, r, 10, step);
    
    
    // Draw the spokes
    glColor3f(0.5,0.5,0.5);
    double conversion = 180/pi;
    int current_spoke;
    int num_spokes = spokes;
    
    double offset = 0;
    for(current_spoke = 0; current_spoke < num_spokes; current_spoke++)
    {
        offset = current_spoke*(180/num_spokes);
        beam(0,0,-0.3, r-0.1, 0.1, 0.1,offset + conversion*rotation, offset+conversion*rotation, 0);
        beam(0,0,0.3, r-0.1, 0.1, 0.1,offset + conversion*rotation, offset+conversion*rotation, 0);
    }
    
    // center axis
    glColor3f(0.2,0.5,0.2);
    beam(0,0,0, 1, 0.1, 0.1, 90, 0, 0);
    
    // braces
    glColor3f(0.2,0.2,0.5);
    beam(1.7,-1.7,-1, 2.5, 0.1, 0.1, 135, 135, 0);
    beam(-1.7,-1.7,-1, 2.5, 0.1, 0.1, 45, 45, 0);
    beam(1.7,-1.7,1, 2.5, 0.1, 0.1, 135, 135, 0);
    beam(-1.7,-1.7,1, 2.5, 0.1, 0.1, 45, 45, 0);
    
    
    if(num_lights){
        int spacing;
        r = r-0.1;
        num_spokes = num_spokes*2;
        double x_angle, y_angle, radius;
        for(current_spoke = 0; current_spoke < num_spokes; current_spoke++)
        {
            offset = current_spoke*2*pi/num_spokes;
            for(spacing = 1; spacing < num_lights+1; spacing++)
            {
                // light(spacing*r*cos(offset + rotation)/num_lights,
                //       spacing*r*sin(offset + rotation)/num_lights, 0.35, 0.1, 90, 270);
                radius = spacing*r/num_lights;
                x_angle = cos(offset + rotation);
                y_angle = sin(offset + rotation);
                
                light(radius*x_angle, radius*y_angle, 0.35, 0.1, 0, 180);
                light(radius*x_angle, radius*y_angle, -0.35, 0.1, -180, 0);
            }
        }
    }
    glPopMatrix();
    
}
Exemplo n.º 13
0
void anatup( Double_t pBeam=3.3077729, Int_t Did=19)

// Analyse ee events, and write tuples
{
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
  rootlogon();

  FILE *fp;
  Int_t NTmax=100000;
  //   Int_t NFmax=10;   // max number of files
  //   Int_t NTmax=100;   // max number per file
  Int_t NEVcount=0;   // max number per file
  //   Int_t NTmax=10000;
  //   Int_t NTmax=200;
  Int_t ip=0;
  Int_t iPart=3;

  Double_t mProt= 0.938272;
  Double_t mElec= 0.000511;
  Double_t mMuon= 0.105658;
  Double_t mPion= 0.139570;
  Double_t mZero= 0.134977;
  Double_t mZeroFit= 0.13;
  //  Double_t mZeroCut= 0.06;
  Double_t mZeroCut= 0.02;
  //  Double_t pBeam=4.00000;
  Double_t eBeam=sqrt(pBeam*pBeam+mProt*mProt);
  Double_t eSystem=eBeam+mProt;
  Double_t mElec2 = mElec*mElec;
  Double_t mZero2= mZero*mZero;
  Double_t radeg=180./3.1415926535;

  // electroncuts
  //   Double_t EmcCUT=0.8;
  //   Double_t SttCUT=0.5;
  Double_t EmcCUT=0.5;
  Double_t SttCUT=0.5;
  Double_t DiscCUT=0.5;
  Double_t DrcCUT=0.5;
  Double_t MuonCUT=0.5;
  Double_t MvdCUT=0.5;
  Double_t TOTCUT=0.50;
  Double_t TOT90CUT=0.90;
  Double_t TOT95CUT=0.95;
  Double_t TOT98CUT=0.98;
  Double_t TOT99CUT=0.99;


  // Set up the Lorentzvectors of the system
  TLorentzVector target(0.0, 0.0, 0.0, mProt);
  Double_t eBeam=sqrt(pBeam*pBeam+mProt*mProt);
  TLorentzVector beam(0.0, 0.0, pBeam, eBeam);
  TLorentzVector W = beam + target;
  TVector3 bSigma(0,0,-W.Pz()/W.E());

  // Construct filenames
  TString Directory[]={"rfiles3/","rootfiles/"      // vandewie
		       ,"ee01/","ee02/","ee03/","ee04/","ee05/"    // gosia + photos
		       ,"ee06/","ee07/","ee08/","ee09/","ee10/"
		       ,"ee11/","ee12/","ee13/","ee14/","ee15/"
		       ,"ee16/","ee17/"
		       ,"eeno01/","eeno02/","eeno03/","eeno04/"    // gosia + nophotos
  };

  TString name = "_complete.root";
  TString inRecoFile   = Directory[Did]+"reco"+name;
  TString inDigiFile   = Directory[Did]+"digi"+name;
  TString inSimFile    = Directory[Did]+"sim"+name;
  TString inPidFile    = Directory[Did]+"pid"+name;

  TString outAnaFile   = Directory[Did]+"ana"+name;
  TFile *out = TFile::Open(outAnaFile,"RECREATE");

  TNtuple* NTev = new TNtuple("NTev","NTev",
			      "p1MC:th1MC:ph1MC:p2MC:th2MC:ph2MC:costhMC:Q2:p1:th1:ph1:EMC1:NX1:pEMC1:pSTT1:pDIS1:pDRC1:pMVD1:pCOM1:p2:th2:ph2:EMC2:NX2:pEMC2:pSTT2:pDIS2:pDRC2:pMVD2:pCOM2:bestTH:bestPH:bestCOST",68000);

  Float_t atuple[33];

  cout << "filename:" << inPidFile << endl;
  TFile *inFile = TFile::Open(inPidFile,"READ");
  TTree *lhe=(TTree *) inFile->Get("cbmsim") ;
  TFile *outFile = TFile::Open(outAnaFile,"new");

  // adding other files as friends
  lhe->AddFriend("cbmsim",inSimFile);
  lhe->AddFriend("cbmsim",inDigiFile);

  PndEmcMapper::Init(6);
  // get the data  (correspondage with Inspect in TBrowser)

  TClonesArray* cCand_array=new TClonesArray("PndPidCandidate");
  lhe->SetBranchAddress("PidChargedCand", &cCand_array);

  TClonesArray* nCand_array=new TClonesArray("PndPidCandidate");
  lhe->SetBranchAddress("PidNeutralCand", &nCand_array);

  TClonesArray* mc_array=new TClonesArray("PndMCTrack");
  lhe->SetBranchAddress("MCTrack", &mc_array);

  TClonesArray* stthit_array=new TClonesArray("PndSttHit");
  lhe->SetBranchAddress("STTHit", &stthit_array);

  TClonesArray* sttpoint_array=new TClonesArray("PndSttPoint");
  lhe->SetBranchAddress("STTPoint", &sttpoint_array);

  TClonesArray* cluster_array=new TClonesArray("PndEmcCluster");
  lhe->SetBranchAddress("EmcCluster",&cluster_array);

  TClonesArray* digi_array=new TClonesArray("PndEmcSharedDigi");
  lhe->SetBranchAddress("EmcSharedDigi",&digi_array);

  TClonesArray* bump_array=new TClonesArray("PndEmcBump");
  lhe->SetBranchAddress("EmcBump",&bump_array);

  TClonesArray* drc_array=new TClonesArray("PndPidProbability");
  lhe->SetBranchAddress("PidAlgoDrc", &drc_array);

  TClonesArray* disc_array=new TClonesArray("PndPidProbability");
  lhe->SetBranchAddress("PidAlgoDisc", &disc_array);

  TClonesArray* mvd_array=new TClonesArray("PndPidProbability");
  lhe->SetBranchAddress("PidAlgoMvd", &mvd_array);

  TClonesArray* stt_array=new TClonesArray("PndPidProbability");
  lhe->SetBranchAddress("PidAlgoStt", &stt_array);

  TClonesArray* emcb_array=new TClonesArray("PndPidProbability");
  lhe->SetBranchAddress("PidAlgoEmcBayes", &emcb_array);

  // canvas and stuff
  gStyle->SetLabelSize(0.05,"X");
  gStyle->SetLabelSize(0.05,"Y");
  gStyle->SetLineWidth(2);
  gStyle->SetHistLineWidth(2);
  gStyle->SetLabelSize(0.05,"X");
  gStyle->SetLabelSize(0.05,"Y");
  gStyle->SetPalette(1);

  int off=32;
  int start=250;

  cMA = new TCanvas("cMA","cMA",200,0, 1000, 1000);
  cMA->Divide(3,3);

  //  cMCelec1 = new TCanvas("cMCelec1","cMCelec1",250,0, 1200, 1000);
  //  cMCelec1->Divide(3,2);

  // histos
  TH1F *h_costheta_mc = new TH1F("h_costheta_mc","cos_theta_ep",20,-1,1);
  TH1F *h_costheta = new TH1F("h_costheta","cos_theta_ep",20,-1,1);
  TH1F *h_costheta_sel = new TH1F("h_costheta_sel","cos_theta_ep",20,-1,1);
  TH1F *h_efficiency = new TH1F("h_efficiency","efficiency",20,-1,1);
  TH1F *h_theta = new TH1F("h_theta","theta_ep",400,-400,400);
  TH1F *h_dtheta = new TH1F("h_dtheta","dtheta_ep",100,170,190);
  TH1F *h_dphi = new TH1F("h_dphi","dphi_ep",100,170,190);

  TH1D* hcutE   = new TH1D("hcutE"  ,"hcutE",50,-eSystem,eSystem);
  TH1D* hcutx   = new TH1D("hcutx"  ,"hcutx",50,-1,1);
  TH1D* hcuty   = new TH1D("hcuty"  ,"hcuty",50,-1,1);
  TH1D* hcutz   = new TH1D("hcutz"  ,"hcutz",50,-1,1);
  TH1D* hMCz    = new TH1D("hMCz"  ,"hMCz",50,0,eSystem);
  TH1D* hpt2    = new TH1D("hpt2"  ,"hpt2",50,0,4);
  TH1D* hpair   = new TH1D("hpair"  ,"hpair",11,-0.5,10.5);

  cout << " finished histos " << endl;

  // process the data
  // Lorentz vectors MV
  TLorentzVector mcTrack[4];
  TLorentzVector QQ_MC;

  // loop over  events
  Double_t MCEnergy, MCTheta, MCPhi;
  Double_t MC1Energy, MC1Theta, MC1Phi;
  Double_t MC2Energy, MC2Theta, MC2Phi;

  NTevents=lhe->GetEntriesFast();
  cout << "NTevents: " << NTevents << endl;
  if(NTevents>NTmax) NTevents=NTmax;
  for (Int_t j=0; j< NTevents ; j++) {
    lhe->GetEntry(j);   // kinematics
    NEVcount++;
    if(j%1000 == 0) cout << "event: " << j << endl;
    //       cout << "processing event: " << j<< endl ;
    Int_t nmc      = mc_array->GetEntriesFast();
    Int_t ncCand=cCand_array->GetEntriesFast();
    Int_t nnCand=nCand_array->GetEntriesFast();
    if(j<5) {
      cout << " nMC: " << mc_array->GetEntriesFast() ;
      cout << " ncCand: " << cCand_array->GetEntriesFast() << endl;
      cout << " nnCand: " << nCand_array->GetEntriesFast() << endl;
    }
    // Loop over electron tracks, store in mcTrack[0,1], pizero_MC, QQ_MC
    Float_t mc_pp = 0, mc_E = 0, mc_mass = 0;
    Float_t mc_px = 0, mc_py = 0, mc_pz = 0;
    Int_t mc_pdg;
    Int_t nepi=0;
    Int_t mc0=0, mc1=1;
    if(Did>1) {mc0=1; mc1=2;}
    // positron
    PndMCTrack *mctrack = (PndMCTrack*)mc_array->At(mc0);
    //       Int_t MotherID = mctrack->GetMotherID();
    //       mc_pdg = (int) (mctrack->GetPdgCode());

    mc_pp = mctrack->GetMomentum().Mag();
    mc_px = mctrack->GetMomentum().Px();
    mc_py = mctrack->GetMomentum().Py();
    mc_pz = mctrack->GetMomentum().Pz();
    mc_E=TMath::Sqrt(mc_pp*mc_pp+mElec2);
    mcTrack[0].SetPxPyPzE(mc_px,mc_py,mc_pz,mc_E);
    // electron
    PndMCTrack *mctrack = (PndMCTrack*)mc_array->At(mc1);
    //       Int_t MotherID = mctrack->GetMotherID();
    //       mc_pdg = (int) (mctrack->GetPdgCode());

    mc_pp = mctrack->GetMomentum().Mag();
    mc_px = mctrack->GetMomentum().Px();
    mc_py = mctrack->GetMomentum().Py();
    mc_pz = mctrack->GetMomentum().Pz();
    mc_E=TMath::Sqrt(mc_pp*mc_pp+mElec2);
    mcTrack[1].SetPxPyPzE(mc_px,mc_py,mc_pz,mc_E);

    // elec1
    MC1Energy = mcTrack[0].E();
    MC1Theta  = radeg*(mcTrack[0].Theta());
    MC1Phi    = radeg*(mcTrack[0].Phi());
    //       hmc1E->Fill(MC1Energy);
    //       hmc1TH->Fill(MC1Theta);
    //       hmc1PH->Fill(MC1Phi);
    // elec2
    MC2Energy = mcTrack[1].E();
    MC2Theta  = radeg*(mcTrack[1].Theta());
    MC2Phi    = radeg*(mcTrack[1].Phi());
    //       hmc1E->Fill(MC2Energy);
    //       hmc1TH->Fill(MC2Theta);
    //       hmc1PH->Fill(MC2Phi);

    // quadrivecteur
    double elecMC=mcTrack[0].Angle(mcTrack[1].Vect());
    //       double Q2=4*mcTrack[0].E()*mcTrack[1].E()*(sin(elecMC/2))*(sin(elecMC/2));
    QQ_MC=mcTrack[0]+mcTrack[1];
    double Q2=QQ_MC.M2();
    //       hmcQ2->Fill(Q2);
    TLorentzVector *elecMC0 = new TLorentzVector(mcTrack[0].Px(),
						 mcTrack[0].Py(),
						 mcTrack[0].Pz(),
						 mcTrack[0].E());
    TLorentzVector *elecMC1 = new TLorentzVector(mcTrack[1].Px(),
						 mcTrack[1].Py(),
						 mcTrack[1].Pz(),
						 mcTrack[1].E());
    // boost
    elecMC0->Boost(bSigma);
    elecMC1->Boost(bSigma);
    Double_t THMC0=radeg*(elecMC0->Theta());
    Double_t THMC1=radeg*(elecMC1->Theta());
    Double_t THtot=THMC0+THMC1;
    Double_t COSTMC=TMath::Cos(elecMC0->Theta());
    h_costheta_mc-> Fill(COSTMC);
    // print some event data
    if(j<5) {
      cout << "event:" << j << endl;
      cout << "MC-eepi:" << MC1Energy << " " << MC2Energy << endl;
      cout << "theta:" << MC1Theta << " " << MC2Theta  << endl;
      cout << "phi:" << MC1Phi << " " << MC2Phi << endl;
      cout << "THMC0:" << THMC0 << "THMC1:" << THMC1 << endl;
      cout << "THtot:" << THtot << " Q2:" << Q2 << endl;
    }

    // fill tuple
    atuple[0]=MC1Energy;
    atuple[1]=MC1Theta;
    atuple[2]=MC1Phi;
    atuple[3]=MC2Energy;
    atuple[4]=MC2Theta;
    atuple[5]=MC2Phi;
    atuple[6]=COSTMC;
    atuple[7]=Q2;

    // print some event data
    if(j<5) {
      cout << "event:" << j << endl;
      cout << "MC-eepi:" << MC1Energy << " " << MC2Energy << " " << MCEnergy << endl;
      cout << "theta:" << MC1Theta << " " << MC2Theta << " " << MCTheta << endl;
      cout << "phi:" << MC1Phi << " " << MC2Phi << " " << MCPhi << endl;
      cout << "COSTMC:" << COSTMC << " Q2:" << Q2 << endl;
    }

    // Analysis starts here
    // loop over charged candidate tracks
    Float_t cc_pp = 0, cc_E = 0, cc_mass = 0, cc_TH = 0;
    Float_t cc_px = 0, cc_py = 0, cc_pz = 0;

    TLorentzVector reTrack[4], QQ_RE;

    Int_t nelec_pair = 0;
    Double_t bestTH=-999;
    Double_t bestPH=-999;
    Double_t bestCOST=-999;
    Int_t ix=-1, iy=-1;

    for (Int_t nc1 = 0; nc1 < ncCand; nc1++) {
      PndPidCandidate *pc1 = (PndPidCandidate*)cCand_array->At(nc1);
      Int_t Charge1 = pc1->GetCharge();
      if (Charge1<0) continue;
      cc_pp = pc1->GetMomentum().Mag();
      //         if (cc_pp>eSystem) continue;
      cc_px = pc1->GetMomentum().Px();
      cc_py = pc1->GetMomentum().Py();
      cc_pz = pc1->GetMomentum().Pz();
      cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2);
      reTrack[0].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E);
      for (Int_t nc2 = 0; nc2 < ncCand; nc2++) {
	PndPidCandidate *pc2 = (PndPidCandidate*)cCand_array->At(nc2);
	Int_t Charge2 = pc2->GetCharge();
	if (Charge2>0) continue;
	cc_pp = pc2->GetMomentum().Mag();
	//           if (cc_pp>eSystem) continue;
	cc_px = pc2->GetMomentum().Px();
	cc_py = pc2->GetMomentum().Py();
	cc_pz = pc2->GetMomentum().Pz();
	cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2);
	reTrack[1].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E);
	nelec_pair++;
	// selection on best kinematics
	// elec1
	RE1Energy = reTrack[0].E();
	RE1Theta  = radeg*(reTrack[0].Theta());
	RE1Phi    = radeg*(reTrack[0].Phi());
	// elec2
	RE2Energy = reTrack[1].E();
	RE2Theta  = radeg*(reTrack[1].Theta());
	RE2Phi    = radeg*(reTrack[1].Phi());
	// quadrivecteur
	double elecRE=reTrack[0].Angle(reTrack[1].Vect());
	//       double Q2=4*mcTrack[0].E()*mcTrack[1].E()*(sin(elecMC/2))*(sin(elecMC/2));
	QQ_RE=reTrack[0]+reTrack[1];
	double Q2=QQ_RE.M2();
	// Center of mass angle of electrons
	// boost vector
	TLorentzVector *elecRE0 = new TLorentzVector(reTrack[0].Px(),
						     reTrack[0].Py(),
						     reTrack[0].Pz(),
						     reTrack[0].E());
	TLorentzVector *elecRE1 = new TLorentzVector(reTrack[1].Px(),
						     reTrack[1].Py(),
						     reTrack[1].Pz(),
						     reTrack[1].E());
	elecRE0->Boost(bSigma);
	elecRE1->Boost(bSigma);
	Double_t THRE0=radeg*(elecRE0->Theta());
	Double_t COSTRE=TMath::Cos(elecRE0->Theta());
	Double_t THRE1=radeg*(elecRE1->Theta());
	Double_t PHRE0=radeg*(elecRE0->Phi());
	Double_t PHRE1=radeg*(elecRE1->Phi());
	Double_t THtot=THRE0+THRE1;
	Double_t PHtot=PHRE0-PHRE1;
	if(PHtot< -90) PHtot+360;
	if(abs(THtot-180) < abs(bestTH-180)) {
	  bestTH=THtot;
	  bestPH=PHtot;
	  bestCOST=COSTRE;
	  ix=nc1;
	  iy=nc2;
	}
	// print some event data
	if(j<5) {
	  cout << "event:" << j << endl;
	  cout << "RE-eepi:" << RE1Energy << " " << RE2Energy << endl;
	  cout << "theta:" << RE1Theta << " " << RE2Theta  << endl;
	  cout << "phi:" << RE1Phi << " " << RE2Phi << endl;
	  cout << "THRE0:" << THRE0 << "THRE1:" << THRE1 << endl;
	  cout << "THtot:" << THtot << " Q2:" << Q2 << endl;
	  cout << "PHtot:" << PHtot << endl;
	}
      }       // nc2
    }       // nc1
    h_costheta-> Fill(COSTRE);
    h_dtheta->Fill(bestTH);
    h_dphi->Fill(bestPH);
    hpair->Fill((double) nelec_pair);
    // Rebelotte with the best solution
    if(nelec_pair<1) continue;
    //
    PndPidCandidate *pc1 = (PndPidCandidate*)cCand_array->At(ix);
    PndPidCandidate *pc2 = (PndPidCandidate*)cCand_array->At(iy);
    // positron
    cc_pp = pc1->GetMomentum().Mag();
    cc_px = pc1->GetMomentum().Px();
    cc_py = pc1->GetMomentum().Py();
    cc_pz = pc1->GetMomentum().Pz();
    cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2);
    reTrack[0].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E);
    // electron
    cc_pp = pc2->GetMomentum().Mag();
    cc_px = pc2->GetMomentum().Px();
    cc_py = pc2->GetMomentum().Py();
    cc_pz = pc2->GetMomentum().Pz();
    cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2);
    reTrack[1].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E);

    // elec1
    // detector data
    PndPidProbability *drc_ele = (PndPidProbability *)drc_array->At(ix);
    PndPidProbability *disc_ele = (PndPidProbability *)disc_array->At(ix);
    PndPidProbability *mvd_ele = (PndPidProbability *)mvd_array->At(ix);
    PndPidProbability *stt_ele = (PndPidProbability *)stt_array->At(ix);
    PndPidProbability *emcb_ele = (PndPidProbability *)emcb_array->At(ix);
    Double_t k_drc_e = drc_ele->GetElectronPidProb();
    Double_t k_disc_e = disc_ele->GetElectronPidProb();
    Double_t k_mvd_e = mvd_ele->GetElectronPidProb();
    Double_t k_stt_e = stt_ele->GetElectronPidProb();
    Double_t k_emcb_e = emcb_ele->GetElectronPidProb();
    Double_t xx_e = (k_drc_e/(1-k_drc_e))*(k_disc_e/(1-k_disc_e))
      *(k_mvd_e/(1-k_mvd_e))*(k_stt_e/(1-k_stt_e))
      *(k_emcb_e/(1-k_emcb_e));
    Double_t k_comb_e = xx_e/(xx_e+1);
    atuple[ 8]=reTrack[0].P();
    atuple[ 9]=reTrack[0].Theta();
    atuple[10]=reTrack[0].Phi();
    atuple[11]=pc1->GetEmcRawEnergy();
    atuple[12]=pc1->GetEmcNumberOfCrystals();
    atuple[13]=k_emcb_e;
    atuple[14]=k_stt_e;
    atuple[15]=k_disc_e;
    atuple[16]=k_drc_e;
    atuple[17]=k_mvd_e;
    atuple[18]=k_comb_e;

    // elec2
    PndPidProbability *drc_posi = (PndPidProbability *)drc_array->At(iy);
    PndPidProbability *disc_posi = (PndPidProbability *)disc_array->At(iy);
    PndPidProbability *mvd_posi = (PndPidProbability *)mvd_array->At(iy);
    PndPidProbability *stt_posi = (PndPidProbability *)stt_array->At(iy);
    PndPidProbability *emcb_posi = (PndPidProbability *)emcb_array->At(iy);
    Double_t k_drc_p = drc_posi->GetElectronPidProb();
    Double_t k_disc_p = disc_posi->GetElectronPidProb();
    Double_t k_mvd_p = mvd_posi->GetElectronPidProb();
    Double_t k_stt_p = stt_posi->GetElectronPidProb();
    Double_t k_emcb_p = emcb_posi->GetElectronPidProb();
    Double_t xx_p = (k_drc_p/(1-k_drc_p))*(k_disc_p/(1-k_disc_p))
      *(k_mvd_p/(1-k_mvd_p))*(k_stt_p/(1-k_stt_p))
      *(k_emcb_p/(1-k_emcb_p));
    Double_t k_comb_p = xx_p/(xx_p+1);

    atuple[19]=reTrack[1].P();
    atuple[20]=reTrack[1].Theta();
    atuple[21]=reTrack[1].Phi();
    atuple[22]=pc2->GetEmcRawEnergy();
    atuple[23]=pc2->GetEmcNumberOfCrystals();
    atuple[24]=k_emcb_p;
    atuple[25]=k_stt_p;
    atuple[26]=k_disc_p;
    atuple[27]=k_drc_p;
    atuple[28]=k_mvd_p;
    atuple[29]=k_comb_p;
    atuple[30]=bestTH;
    atuple[31]=bestPH;
    atuple[32]=bestCOST;

    NTev->Fill(atuple);
    if(j<5) {
      cout << "k_comb_e:" << k_comb_e<< " k_comb_p:" << k_comb_p << endl;
    }

    // standard cuts for histos
    Bool_t com_ele_1 = drc_ele->GetElectronPidProb() > 0.05 &&
      disc_ele->GetElectronPidProb() > 0.05 &&
      mvd_ele->GetElectronPidProb() > 0.05 &&
      stt_ele->GetElectronPidProb() > 0.05 &&
      emcb_ele->GetElectronPidProb() > 0.05;
    Bool_t com_ele_2 = k_comb_e > 0.9;
    Bool_t com_ele_3 = pc1->GetEmcNumberOfCrystals() > 5;
    Bool_t com_ele_4 = bestTH >=178. && bestTH <= 182.;
    Bool_t com_ele_5 = bestPH >=178. && bestPH <= 182.;
    Bool_t com_posi_1 = drc_posi->GetElectronPidProb() > 0.05 &&
      disc_posi->GetElectronPidProb() > 0.05 &&
      mvd_posi->GetElectronPidProb() > 0.05 &&
      stt_posi->GetElectronPidProb() > 0.05 &&
      emcb_posi->GetElectronPidProb() > 0.05;
    Bool_t com_posi_2 =  k_comb_p > 0.9;
    Bool_t com_posi_3 = pc2->GetEmcNumberOfCrystals() > 5;

    if(j<5) {
      cout << com_ele_1 << com_ele_2 << com_ele_3 << com_ele_4
	   << com_ele_4 << com_posi_1 << com_posi_2 << com_posi_3 << endl;
    }
    if (com_ele_1&&com_ele_2&&com_ele_3&&com_ele_4
        &&com_ele_5&&com_posi_1&&com_posi_2&&com_posi_3) {
      h_costheta_sel->Fill(bestCOST);

    }
  }  // loop j over events

  cout << " NEVcount: " << NEVcount << endl;
  h_efficiency->Divide(h_costheta_sel,h_costheta_mc,1,1,"B");

  // output
  cMA->cd(1);gPad->SetLogy(); h_costheta_mc->Draw();
  cMA->cd(2);gPad->SetLogy(); h_costheta->Draw();
  cMA->cd(3);gPad->SetLogy(); h_costheta_sel->Draw();
  cMA->cd(4);gPad->SetLogy(); h_efficiency->Draw();
  cMA->cd(5);gPad->SetLogy(); h_dtheta->Draw();
  cMA->cd(6);gPad->SetLogy(); h_dphi->Draw();
  cMA->cd(7); hpair->Draw();
  cMA->cd(0);

  out->cd();

  hpair->Write();
  h_costheta_mc->Write();
  h_costheta->Write();
  h_costheta_sel->Write();
  h_efficiency->Write();
  h_dtheta->Write();
  h_dphi->Write();

  NTev->Write();

  out->Save();

  cout << " Yahoo! " << endl;

}
Exemplo n.º 14
0
Arquivo: sst.c Projeto: aichao/sst
static void makemoves(void) {
	int i, hitme;
	char ch;
	while (TRUE) { /* command loop */
		hitme = FALSE;
		justin = 0;
		Time = 0.0;
		i = -1;
		while (TRUE)  { /* get a command */
			chew();
			skip(1);
			proutn("COMMAND> ");
      // Use of scan() here (after chew) will get a new line of input
      // and will return IHEOL iff new line of input contains nothing
      // or a numeric input is detected but conversion fails.
			if (scan() == IHEOL) continue;
			for (i=0; i < 26; i++)
				if (isit(commands[i]))
					break;
			if (i < 26) break;
			for (; i < NUMCOMMANDS; i++)
				if (strcmp(commands[i], citem) == 0) break;
			if (i < NUMCOMMANDS) break;
      // we get here iff the first parsed input from the line does not 
      // match one of the commands. In this case, the rest of the line
      // is discarded, the below message is printed, and we go back to 
      // get a new command.
			if (skill <= 2)  {
				prout("UNRECOGNIZED COMMAND. LEGAL COMMANDS ARE:");
				listCommands(TRUE);
			}
			else prout("UNRECOGNIZED COMMAND.");
		} // end get command loop
    // we get here iff the first parsed input from the line matches one
    // of the commands (i.e., command i). We use i to dispatch the 
    // handling of the command. The line may still contain additional
    // inputs (i.e., parameters of the command) that is to be parsed by
    // the dispatched command handler. If the line does not contain
    // all the necessary parameters, the dispatched command handler is 
    // responsible to get additional input(s) interactively using scan().
    // The dispatched command handler is also responsible to handle any 
    // input errors.
		switch (i) { /* command switch */
			case 0:			// srscan
				srscan(1);
				break;
			case 1:			// lrscan
				lrscan();
				break;
			case 2:			// phasers
				phasers();
				if (ididit) hitme = TRUE;
				break;
			case 3:			// photons
				photon();
				if (ididit) hitme = TRUE;
				break;
			case 4:			// move
				warp(1);
				break;
			case 5:			// shields
				sheild(1);
				if (ididit) {
					attack(2);
					shldchg = 0;
				}
				break;
			case 6:			// dock
				dock();
				break;
			case 7:			// damages
				dreprt();
				break;
			case 8:			// chart
				chart(0);
				break;
			case 9:			// impulse
				impuls();
				break;
			case 10:		// rest
				waiting();
				if (ididit) hitme = TRUE;
				break;
			case 11:		// warp
				setwrp();
				break;
			case 12:		// status
				srscan(3);
				break;
			case 13:			// sensors
				sensor();
				break;
			case 14:			// orbit
				orbit();
				if (ididit) hitme = TRUE;
				break;
			case 15:			// transport "beam"
				beam();
				break;
			case 16:			// mine
				mine();
				if (ididit) hitme = TRUE;
				break;
			case 17:			// crystals
				usecrystals();
				break;
			case 18:			// shuttle
				shuttle();
				if (ididit) hitme = TRUE;
				break;
			case 19:			// Planet list
				preport();
				break;
			case 20:			// Status information
				srscan(2);
				break;
			case 21:			// Game Report 
				report(0);
				break;
			case 22:			// use COMPUTER!
				eta();
				break;
			case 23:
				listCommands(TRUE);
				break;
			case 24:		// Emergency exit
				clearscreen();	// Hide screen
				freeze(TRUE);	// forced save
				exit(1);		// And quick exit
				break;
			case 25:
				probe();		// Launch probe
				break;
			case 26:			// Abandon Ship
				abandn();
				break;
			case 27:			// Self Destruct
				dstrct();
				break;
			case 28:			// Save Game
				freeze(FALSE);
				if (skill > 3)
					prout("WARNING--Frozen games produce no plaques!");
				break;
			case 29:			// Try a desparation measure
				deathray();
				if (ididit) hitme = TRUE;
				break;
			case 30:			// What do we want for debug???
#ifdef DEBUG
				debugme();
#endif
				break;
			case 31:		// Call for help
				help();
				break;
			case 32:
				alldone = 1;	// quit the game
#ifdef DEBUG
				if (idebug) score();
#endif
				break;
			case 33:
				helpme();	// get help
				break;
		} // end command switch
		for (;;) {
			if (alldone) break;		// Game has ended
#ifdef DEBUG
			if (idebug) prout("2500");
#endif
			if (Time != 0.0) {
				events();
				if (alldone) break;		// Events did us in
			}
			if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!
				atover(0);
				continue;
			}
			if (nenhere == 0) movetho();
			if (hitme && justin==0) {
				attack(2);
				if (alldone) break;
				if (d.galaxy[quadx][quady] == 1000) {	// went NOVA! 
					atover(0);
					hitme = TRUE;
					continue;
				}
			}
			break;
		} // end event loop
		if (alldone) break;
	} // end command loop
}