Example #1
0
		std::string MessagesLibraryLog::getObjectName(
			RegistryKeyType id,
			const server::Request& searchRequest
		) const	{
			try
			{
				RegistryTableType tableId = decodeTableId(id);
				Env env;
				if (tableId == ScenarioTableSync::TABLE.ID)
				{
					boost::shared_ptr<const Scenario> scenario(ScenarioTableSync::Get(id, env, FIELDS_ONLY_LOAD_LEVEL));
					return scenario->getName();
				}
				else if (tableId == AlarmTableSync::TABLE.ID)
				{
					boost::shared_ptr<const Alarm> alarm(AlarmTableSync::Get(id, env, FIELDS_ONLY_LOAD_LEVEL));
					return alarm->getShortMessage();
				}
				else if (tableId == TextTemplateTableSync::TABLE.ID)
				{
					boost::shared_ptr<const TextTemplate> text(TextTemplateTableSync::Get(id, env, FIELDS_ONLY_LOAD_LEVEL));
					return text->getName();
				}
				else if (tableId == ScenarioFolderTableSync::TABLE.ID)
				{
					boost::shared_ptr<const ScenarioFolder> folder(ScenarioFolderTableSync::Get(id, env));
					return folder->getFullName();
				}
			}
			catch (...)
			{
			}
			return DBLog::getObjectName(id,searchRequest);
		}
	TEST( testGetFunctions, testScenarioDefinition ) {
		int seed = 42;
		std::srand( seed );

		for ( int ii = 0; ii < 100; ii++ ) {
			int rNumI = std::rand();
			int rNumI1 = std::rand();
			double rNumD = ( static_cast<double>( std::rand() ) / static_cast<double>( std::rand() ) );
			emilib::ScenarioDefinition scenario( rNumI, rNumI1, rNumD );
			ASSERT_EQ( rNumI, scenario.getNumberOfParticles() );
			ASSERT_EQ( rNumI1, scenario.getNumberOfSteps() );
			ASSERT_DOUBLE_EQ( rNumD, scenario.getTimeStep() );
		}
	}
Example #3
0
//------------------------------------------------------------------------------
void Engine::setup()
{
//   renderWindow_ = new sf::RenderWindow(sf::VideoMode(384 - (48 + 96) + 296, 96*2 - (24 + 48)), "freeaoe");
  renderWindow_ = new sf::RenderWindow(sf::VideoMode(800, 600), "freeaoe");
  renderWindow_->setFramerateLimit(60);
  
  renderTarget_ = IRenderTargetPtr(new SfmlRenderTarget(*renderWindow_));
  
  GameState *gameState = new GameState(renderTarget_);
  
  std::string scnFile = Config::Inst()->getScenarioFile();
  
  if (!scnFile.empty())
  {
    boost::shared_ptr<genie::ScnFile> scenario(new genie::ScnFile());
    scenario->load(scnFile.c_str());
    gameState->setScenario(scenario);
  }
  state_manager_.addActiveState(gameState);

  fps_label_.setPosition(sf::Vector2f(10,10));
  fps_label_.setColor(sf::Color::Green);
}
void packExpectedJuneMass(const int iMass) {
  // This Root macro is for the purpose of providing input for expected limit computation
  // It packs predicted background and a set of signal samples into a root file per Higgs mass
  // 
  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();
  canvas = new TCanvas ("cg1","PadX",10,10,800,600);
  gStyle->SetPadColor(0);
  canvas->SetFillColor(0);
  
  //   const int nbtag = 4;
  const int nbtag = 1;
  //const std::string sbtag[nbtag] = { "TCHPT", "TCHP6", "CSVT", "SSVHPT" };
  const std::string sbtag[nbtag] = { "CSVT" };

  std::string L1L2Mode("Weight");
  std::string signalMode("PU_WEIGHTED-NEW");
  //   std::string L1L2Mode("Cut");
  //   std::string signalMode("CUT_BASED");
  std::string scenario("LowMass2011");
  
  string IgorVersion("V6");
#include "Analysis/Utilities/interface/HbbMass.h"

  if (iMass >= nSignal) {
    std::cout << "Bad iMass=" << iMass << std::endl;
    return;
  }

  //   const int nSignal=7;
  //   int signalMass[nSignal] = { 90, 100, 120, 140, 180, 250, 350 };
  //   double efficiency[nSignal] = { 0.0022081, 0.00324694, 0.00600146, 0.00918135,
  // 				0.0138382, 0.0189684, 0.0206572 };
  double efficiency[nSignal][nbtag];
  double intLumi = 0;
  string IgorScen("");
  string spacer("");
  string SashaPath("");
  string IgorPath("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production");

  if (IgorVersion == "V4") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-4");
  } else if (IgorVersion == "V6") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production2");
  }


  if (scenario == "LowMass2011") {
    //intLumi = 2.66794; // in fb-1
    intLumi = 2.692643;  // with new method
    IgorScen.assign("low");
    spacer.assign("");
    SashaPath.assign("Data-Run2011AB");
  } else if (scenario == "MediumMass2011") {
    //intLumi = 3.99983; // in fb-1
    intLumi = 4.040802;
    IgorScen.assign("medium");
    spacer.assign("/MEDIUM");
    SashaPath.assign("Data-Run2011AB-Medium");
  } else {
    std::cout << "Bad scenario" << std::endl;
    return;
  }
  string signalHistPattern("massEvBtag/mjjEvBTag_%s");
  if (L1L2Mode == "Weight") {
    signalHistPattern.assign("massEvBtagTW/mjjEvBTagTW_%s");
  }
  
  double fScal[nSignal][nbtag];
  
  // signal templates
  const int nSyst = 4;
  const int nUpDown = 2;
  std::string signalFile( "" );
  std::string signalSystFiles[nSyst][nUpDown];
  std::string systName[nSyst] = { "JES", "SFbc", "SFudsg", "JER" };
  bool realDataNuisance[nSyst] = { false, true, true, false }; // indicate if relevant for real data

  std::string upDownName[nUpDown] = { "Up", "Down" };
  TH2F* hSignalSyst[nSyst][nUpDown][nbtag];

    // signal templates
  if (IgorVersion != "V3") {
    std::cout << "Using signal files " << IgorVersion << std::endl;
    signalFile.assign( Form("%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",IgorPath.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  } else {
    std::cout << "Using V3 signal files" << std::endl;
    signalFile.assign( Form("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",signalMode.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  }

  // output file
  TFile* hout = new TFile(Form("ExpectedLimitJune-M-%d.root",signalMass[iMass]),"recreate");
  hout->cd();
  TH2::AddDirectory(true);

  TFile* fSig = new TFile( signalFile.c_str() );
  if ( fSig == NULL ) {
    std::cout << "Could not open signal central file " << signalFile.c_str() << std::endl;
    return;
  } else {
    std::cout << "Open signal file " << signalFile.c_str() << std::endl;
  }

  TH2F* hSignalCentral[nbtag];

  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    hSignalCentral[ibtag] = mergeSignal(fSig,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
					"bbH");
    // read the efficiency
    TH1F* histEffMerged = (TH1F*) fSig->Get(Form("TrigEff/EffMerged%s",sbtag[ibtag].c_str()));
    if ( histEffMerged == NULL) {
      std::cout << "Efficiency histo not found" << std::endl;
      return;
    }
    double newEff = histEffMerged->GetBinContent(1);
    std::cout << "Mass= " << signalMass[iMass] 
	      << " btag= " << sbtag[ibtag]
	      << " Efficiency = " << newEff << std::endl;
    efficiency[iMass][ibtag] = newEff;
    
    double normShould = 1000 * intLumi * efficiency[iMass][ibtag];
    double normIs = hSignalCentral[ibtag]->GetSum();
    std::cout << hSignalCentral[ibtag]->GetName() << " TotalContents=" << hSignalCentral[ibtag]->GetSum()
	      << std::endl;
    fScal[iMass][ibtag] = normShould / normIs;
    std::cout << "normShould = " << normShould << " normIs " << normIs
	      << " rescale by " << fScal[iMass][ibtag] << std::endl;
    hSignalCentral[ibtag]->Scale( fScal[iMass][ibtag] );
    hout->cd();
    hSignalCentral[ibtag]->Write();

    // create empty file just as marker
    ofstream markerFile;
    markerFile.open(Form("pack-%s-%s.txt",sbtag[ibtag].c_str(),scenario.c_str()),ios::app);
    markerFile << "Template for mass " << signalMass[iMass] << std::endl;
    markerFile.close();
  }


  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
      if (IgorVersion != "V3") {
	signalSystFiles[iSyst][iUpDown] = Form( "%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						IgorPath.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      } else {	
	signalSystFiles[iSyst][iUpDown] = Form( "/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						signalMode.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      }
      std::cout << "Signal systematics file " << signalSystFiles[iSyst][iUpDown] << std::endl;
      TFile* fSigSys = new TFile( signalSystFiles[iSyst][iUpDown].c_str() );
      if ( fSigSys == NULL ) {
	std::cout << "Could not open signal syst file " << signalSystFiles[iSyst][iUpDown].c_str() << std::endl;
	return;
      }
      for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	hSignalSyst[iSyst][iUpDown][ibtag] = mergeSignal(fSigSys,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
							 Form("bbH_%s_%s",systName[iSyst].c_str(),upDownName[iUpDown].c_str()));
	std::cout << "The merged hist has name " << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << std::endl;
	std::cout << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << " TotalContents=" << hSignalSyst[iSyst][iUpDown][ibtag]->GetSum()
		  << std::endl;

	hSignalSyst[iSyst][iUpDown][ibtag]->Scale( fScal[iMass][ibtag] );
	hout->cd();
	hSignalSyst[iSyst][iUpDown][ibtag]->Write();
      }
      fSigSys->Close();
    }
  }

  // backgrounds
  std::string backgroundFile( Form("/afs/naf.desy.de/user/s/spiridon/scratch/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_SFzero/TripleBtagAnalysis.root",SashaPath.c_str()) );
  std::cout << "Background central file : " << backgroundFile << std::endl;
  TFile* fBac = new TFile( backgroundFile.c_str() );
  if ( fBac == NULL ) {
    std::cout << "Could not open background central file " << signalFile.c_str() << std::endl;
    return;
  }
  TH2F* hBackgroundCentral[nbtag];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    hBackgroundCentral[ibtag] = mergeBackground(fBac,"bgPredict/MassBTagPred_%s_%s_Cat%dTpat%d",sbtag[ibtag].c_str(),"BBB",scenario);
    hout->cd();
    hBackgroundCentral[ibtag]->Write();
  }

  std::string backgroundSystFiles[nSyst][nUpDown];
  std::string systNameSasha[nSyst] = { "JES", "SFbc", "SFq" };
  std::string upDownNameSasha[nUpDown] = { "plus2", "minus2" };
  TH2F* hBackgroundSyst[nSyst][nUpDown][nbtag];

  // for nuisances like JEC, the up/down templates are just copies of the central templates
  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    
    if (realDataNuisance[iSyst]) {
      std::cout << "Real data relevant nuisance: " << systName[iSyst].c_str() << std::endl;
      for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
	backgroundSystFiles[iSyst][iUpDown] = Form( "/afs/naf.desy.de/user/s/spiridon/scratch/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_%s%s/TripleBtagAnalysis.root",SashaPath.c_str(),systNameSasha[iSyst].c_str(),upDownNameSasha[iUpDown].c_str() );
	TFile* fBacSys = new TFile( backgroundSystFiles[iSyst][iUpDown].c_str() );
	std::cout << "Background systematics file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	if ( fBacSys == NULL ) {
	  std::cout << "Could not open background syst file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	  return;
	}
	for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	  hBackgroundSyst[iSyst][iUpDown][ibtag] = mergeBackground(fBacSys,
								   "bgPredict/MassBTagPred_%s_%s_Cat%dTpat%d",
								   sbtag[ibtag].c_str(),Form("BBB_%s_%s",systName[iSyst].c_str(),
											     upDownName[iUpDown].c_str()),scenario);
	  hout->cd();
	  hBackgroundSyst[iSyst][iUpDown][ibtag]->Write();
	}
	fBacSys->Close();
      }
    }
  }
 
  hout->Write();
  hout->Close();
  fSig->Close();
  
  return;
}
Example #5
0
int main(int argc, char** argv)
{
    // Parse command line parameters
    tools::Args args(argc, argv);

    // Scenario
    scenarios::DamBreak scenario(args.size());

    // Allocate memory
    // Water height
    T *h = new T[args.size()+2];
    // Momentum
    T *hu = new T[args.size()+2];

    // Initialize water height and momentum
    for (unsigned int i = 0; i < args.size()+2; i++)
        h[i] = scenario.getHeight(i);
    memset(hu, 0, sizeof(T)*(args.size()+2));

    // Create a writer that is responsible printing out values
    //writer::ConsoleWriter writer;
    writer::VtkWriter writer("swe1d", scenario.getCellSize());

    // Helper class computing the wave propagation
    WavePropagation wavePropagation(h, hu, args.size(), scenario.getCellSize());

    // Write initial data
    tools::Logger::logger.info("Initial data");

    // Current time of simulation
    T t = 0;

    writer.write(t, h, hu, args.size());

    for (unsigned int i = 0; i < args.timeSteps(); i++) {
        // Do one time step
        tools::Logger::logger << "Computing timestep " << i
                              << " at time " << t << std::endl;

        // Update boundaries
        wavePropagation.setOutflowBoundaryConditions();

        // Compute numerical flux on each edge
        T maxTimeStep = wavePropagation.computeNumericalFluxes();

        // Update unknowns from net updates
        wavePropagation.updateUnknowns(maxTimeStep);

        // Update time
        t += maxTimeStep;

        // Write new values
        writer.write(t, h, hu, args.size());
    }

    // Free allocated memory
    delete [] h;
    delete [] hu;

    return 0;
}
Example #6
0
void Boss::update() {
    if (active) {
        animation.sprite.setPosition(getPosition().x, getPosition().y);
        shadow.sprite.setPosition(getPosition().x, getPosition().y + 10);
        animation.update();
        shadow.update();

        movementManager();
        if (GameTime::Instance()->getElapsedTime().asMilliseconds() > startTime) {
            if (sprite.getPosition().y < 200 && !activeMovement)
                sprite.move(0, speed);
            else if (!inZone)
                inZone = true;
            else if (!activeDead) {

                // rect[0] = partie centrale
                // rect[1] = partie arrière
                // rect[2] = partie du bas gauche
                // rect[3] = partie du bas droite
                // rect[4] = canon gauche
                // rect[5] = canon droit

                scenario(stage);

                if (stage == 1) {
                    rect[0] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 20, (int) (sprite.getPosition().y - (getSize().y / 2)), (int) 175, (int) 50);
                    rect[1] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 20, (int) (sprite.getPosition().y - (getSize().y / 2) - 40), (int) 175, (int) 30);
                    rect[2] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 20, (int) sprite.getPosition().y + 15, (int) 64, (int) 50);
                    rect[3] = IntRect((int) sprite.getPosition().x + 24, (int) sprite.getPosition().y + 15, (int) 64, (int) 50);
                    rect[4] = IntRect((int) sprite.getPosition().x - (getSize().x / 2) - 60, (int) (sprite.getPosition().y - (getSize().y / 2) - 20), (int) 40, (int) 100);
                    rect[5] = IntRect((int) sprite.getPosition().x + 88, (int) (sprite.getPosition().y - (getSize().y / 2) - 20), (int) 40, (int) 100);
                } else if (stage == 2) {
                    rect[0] = IntRect((int) sprite.getPosition().x - 39, (int) sprite.getPosition().y - 70, (int) 80, (int) 130);
                    rect[1] = IntRect((int) sprite.getPosition().x - 30, (int) sprite.getPosition().y + 60, (int) 60, (int) 10);
                    rect[2] = IntRect((int) sprite.getPosition().x - 90, (int) sprite.getPosition().y - 55, (int) 60, (int) 70);
                    rect[3] = IntRect((int) sprite.getPosition().x + 30, (int) sprite.getPosition().y - 55, (int) 60, (int) 70);
                    rect[4] = IntRect((int) sprite.getPosition().x - 107, (int) sprite.getPosition().y - 20, (int) 45, (int) 80);
                    rect[5] = IntRect((int) sprite.getPosition().x + 63, (int) sprite.getPosition().y - 20, (int) 45, (int) 80);
                } else if (stage == 3) {
                    rect[0] = IntRect((int) sprite.getPosition().x - 150, (int) sprite.getPosition().y - 70, (int) 300, (int) 140);
                    rect[1] = IntRect((int) sprite.getPosition().x - 5, (int) sprite.getPosition().y + 40, (int) 20, (int) 70);
                    rect[2] = IntRect((int) sprite.getPosition().x - 180, (int) sprite.getPosition().y + 10, (int) 35, (int) 55);
                    rect[3] = IntRect((int) sprite.getPosition().x + 150, (int) sprite.getPosition().y + 10, (int) 35, (int) 55);

                } else if (stage == 4) {

                }

                // Changement des couleurs selon la collision

                for (unsigned char i = 0; i < 6; i++) {
                    if (collision[i] == 1) {
                        if (lastCollision == 0)
                            lastCollision = GameTime::Instance()->getElapsedTime().asMilliseconds();

                        if (i < 4)
                            sprite.setColor(color[1]);
                        else if (i > 3)
                            sprite.setColor(color[2]);

                        if (GameTime::Instance()->getElapsedTime().asMilliseconds() - lastCollision > 100) {
                            sprite.setColor(color[0]);
                            collision[i] = 0;
                            lastCollision = 0;
                        }
                    }
                }

                if (stage == 1 || stage == 2) {
                    for (unsigned char i = 0; i < 3; i++) {

                        if (health[i] < 0) {
                            health[i] = 0;

                        }
                    }

                    if (!activeCanonA) {
                        if (lastTimeA == 0)
                            lastTimeA = GameTime::Instance()->getElapsedTime().asMilliseconds();
                        else if (GameTime::Instance()->getElapsedTime().asMilliseconds() - lastTimeA > 10000) {
                            if (gameDifficulty == 2)
                                health[1] = 1000;
                            else if (gameDifficulty == 1)
                                health[1] = 2000;
                            else if (gameDifficulty == 2)
                                health[1] = 3000;

                            activeCanonA = true;
                            lastTimeA = 0;
                        }
                    }

                    if (!activeCanonB) {
                        if (lastTimeB == 0)
                            lastTimeB = GameTime::Instance()->getElapsedTime().asMilliseconds();
                        else if (GameTime::Instance()->getElapsedTime().asMilliseconds() - lastTimeB > 10000) {
                            if (gameDifficulty == 2)
                                health[2] = 1000;
                            else if (gameDifficulty == 1)
                                health[2] = 2000;
                            else if (gameDifficulty == 2)
                                health[2] = 3000;
                            activeCanonB = true;
                            lastTimeB = 0;
                        }
                    }
                }

#ifdef _DEBUG
                if (showRectangle)
                    for (unsigned char i = 0; i < 6; i++) {
                        rectShape[i].setPosition(rect[i].left, rect[i].top);
                        rectShape[i].setSize(Vector2f(rect[i].width, rect[i].height));
                    }

                rectOrigin.setPosition(getPosition());

#endif
            }
        }

        if (health[0] <= 0)
            dead();
        else {
            portionEnergy = (health[0] * 100) / energyfix;
            portionEnergy = portionEnergy / 10;
            if (portionEnergy < 1)
                portionEnergy = 1;

        }
    }

    redShape.update();
    animation.sprite.setColor(sprite.getColor());
}
Example #7
0
int main(int argc, const char * argv[])
{
    // parsing arguments (ignoring the first)
    TTValue args;
    for (TTUInt8 i = 1; i < argc; i++)
    {
        TTSymbol arg(argv[i]);
        args.append(arg);
    }

    // check for file path
    if (args.size() == 1)
    {
        if (args[0].type() == kTypeSymbol)
        {
            TTSymbol filepath = args[0];    // .score file to load

            // initialisation of Modular environnement (passing the folder path where all the dylibs are)
            TTModularInit("/usr/local/jamoma", true);

            // create an application manager
            TTObject applicationManager("ApplicationManager");

            // create a local application named i-score
            TTObject applicationLocal = applicationManager.send("ApplicationInstantiateLocal", "i-score");

            // loads protocol unit
            // TODO : when parsing project file
            {
                // create Minuit protocol unit
                TTObject protocolMinuit = applicationManager.send("ProtocolInstantiate", "Minuit");

                // create OSC protocol unit
                TTObject protocolOSC = applicationManager.send("ProtocolInstantiate", "OSC");

                // create WebSocket protocol unit
                TTObject protocolWebSocket = applicationManager.send("ProtocolInstantiate", "WebSocket");
            }

            // initialisation of Score environnement (passing the folder path where all the dylibs are)
            TTScoreInit("/usr/local/jamoma");

            // create a scenario
            TTObject scenario("Scenario");

            // load project file
            TTObject xmlHandler("XmlHandler");
            xmlHandler.set("object", TTValue(applicationManager, scenario));
            xmlHandler.send("Read", filepath);

            // run scenario
            scenario.send("Start");

            // wait for scenario
            TTBoolean running;
            do
            {
                sleep(1);
                scenario.get("running", running);
            }
            while (running);

            return EXIT_SUCCESS;
        }
    }

    return EXIT_FAILURE;
}
void loop() {

    clock_update();

    if(pulse_100ms){

        main_prev_millis=millis();

        main_period_actual=millis()-main_period_prev_millis;
        main_period_prev_millis=millis();

        if(main_period_actual>main_period_max)
            main_period_max=main_period_actual;

        //~ Serial.print("1");
        /* recupere les valeurs des cartes d'entrees si changement détecté*/

        if(NumberOfBoardIn4Dimmer4 && !digitalRead(int_i2c))
            BoardIn4Dimmer4_pre();

        if(NumberOfBoardIn16 && !digitalRead(int_i2c))
            BoardIn16_pre();

        if(NumberOfBoardIn8R8 && !digitalRead(int_i2c))
            BoardIn8R8_pre();

		if(NumberOfRFDevice)
            RFDevice_pre();  

        /* update all the preliminary condition */
        pre_update();  // cf custom.ino

        scenario(); // cf custom.ino


        /* update the status of the shutters */
        if (NumberOfShutter)
            shutter_post();

        /* update the post conditions */
        post_update(); // cf custom.ino

        /* update the output of the boards */
        if(NumberOfBoardIn4Dimmer4)
            BoardIn4Dimmer4_post();

        if(NumberOfBoardR8)
            BoardR8_post();

        if(NumberOfBoardIn8R8)
            BoardIn8R8_post();

		if(NumberOfRFDevice)
            RFDevice_post(); 

        main_actual=millis()-main_prev_millis;
        if(main_actual>main_max)
            main_max=main_actual;


    digitalWrite(STATUS_LED, LOW);
/**/


   }

    other_prev_millis=millis();


    if(pulse_1000ms){

        hbeat++;

        RTC.getTime(); /// update time should be every 500ms or 1s

        if(NumberOfBoardIn4Dimmer4)
            BoardIn4Dimmer4_hbeat();

        if(NumberOfBoardIn8R8)
            BoardIn8R8_hbeat();

        if(NumberOfBoardIn16)
            BoardIn16_hbeat();

        if(NumberOfBoardR8)
            BoardR8_hbeat();


        #ifdef WITH_LIGHTING
        if (NumberOfLighting)
            lighting_hard_status();
        #endif
        //~ Serial.print("1");
        if(NumberOfShutter)
            shutter_hard_status();
        //~ Serial.print("2");
        if(NumberOfTemp){
            //~ Serial.print("3");
         Read_DS2482_Temp(true); //lecture des temperature sur les sodes OneWire en mode seconde
        }
        temperature_sendXPL(); /// temporaire

        TeleInfo.read();

    }

    if(pulse_1mn){

        if(minutes == 59){
            minutes =0;
            heure++;
        }else{
            minutes++;
        }

        TeleInfoSendXPL();  //envois de toutes les trame OneWire en XPL

    }

    loop_Udp();

    runBitlash();

    other_actual=millis()-other_prev_millis;
    //~ other_prev_millis=millis();

    if(other_actual>other_max)
        other_max=other_actual;

}
Example #9
0
void packTemplatesMass(const int iMass) {
  // This Root macro is for the purpose of providing input for expected limit computation
  // It packs predicted background and a set of signal samples into a root file per Higgs mass
  // 
  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();
  canvas = new TCanvas ("cg1","PadX",10,10,800,600);
  gStyle->SetPadColor(0);
  canvas->SetFillColor(0);

//   const int nbtag = 4;
  const int nbtag = 1;
  //const std::string sbtag[nbtag] = { "TCHPT", "TCHP6", "CSVT", "SSVHPT" };
  const std::string sbtag[nbtag] = { "CSVT" };

  const int nfc=3;
  const int ncateg=3;
  string sfc[nfc] = { "q", "c", "b" };

  // this is for the combination of triggers in real data
  const int nTCombData = 4;
  std::string tCombData[nTCombData] = {"Trig0", "Trig1", "Trig2", "Trig3"};

  std::string L1L2Mode("Weight");
  std::string signalMode("PU_WEIGHTED-NEW");
//   std::string L1L2Mode("Cut");
//   std::string signalMode("CUT_BASED");
  std::string scenario("LowMass2011");


  const int nSignal=7;
  int signalMass[nSignal] = { 90, 100, 120, 140, 180, 250, 350 };
//   double efficiency[nSignal] = { 0.0022081, 0.00324694, 0.00600146, 0.00918135,
// 				0.0138382, 0.0189684, 0.0206572 };
  double efficiency[nSignal][nbtag];
  double intLumi = 0;
  string IgorScen("");
  string spacer("");
  string SashaPath("");

  if (scenario == "LowMass2011") {
    //intLumi = 2.66794; // in fb-1
    intLumi = 2.692643;  // with new method
    IgorScen.assign("low");
    spacer.assign("");
    SashaPath.assign("Data-Run2011AB");
  } else if (scenario == "MediumMass2011") {
    //intLumi = 3.99983; // in fb-1
    intLumi = 4.040802;
    IgorScen.assign("medium");
    spacer.assign("/MEDIUM");
    SashaPath.assign("Data-Run2011AB-Medium");
  } else {
    std::cout << "Bad scenario" << std::endl;
    return;
  }
  string signalHistPattern("massEvBtag/mjjEvBTag_%s");
  if (L1L2Mode == "Weight") {
    signalHistPattern.assign("massEvBtagTW/mjjEvBTagTW_%s");
  }

  double fScal[nSignal][nbtag];
  
  // signal templates
  const int nSyst = 3;
  const int nUpDown = 2;
  std::string signalFile( Form("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",signalMode.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  std::string signalSystFiles[nSyst][nUpDown];
  std::string systName[nSyst] = { "JES", "SFbc", "SFudsg" };
  std::string upDownName[nUpDown] = { "Up", "Down" };
  TH2F* hSignalSyst[nSyst][nUpDown][nbtag];

  

  // output file
  TFile* hout = new TFile(Form("packedTemplates-M-%d.root",signalMass[iMass]),"recreate");
  hout->cd();
  TH2::AddDirectory(true);

  TFile* fSig = new TFile( signalFile.c_str() );
  if ( fSig == NULL ) {
    std::cout << "Could not open signal central file " << signalFile.c_str() << std::endl;
    return;
  } else {
    std::cout << "Open signal file " << signalFile.c_str() << std::endl;
  }

  TH2F* hSignalCentral[nbtag];

  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    hSignalCentral[ibtag] = mergeSignal(fSig,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
					Form("bbH_%s",sbtag[ibtag].c_str()));
    // read the efficiency
    TH1F* histEffMerged = (TH1F*) fSig->Get(Form("TrigEff/EffMerged%s",sbtag[ibtag].c_str()));
    if ( histEffMerged == NULL) {
      std::cout << "Efficiency histo not found" << std::endl;
      return;
    }
    double newEff = histEffMerged->GetBinContent(1);
    std::cout << "Mass= " << signalMass[iMass] 
	      << " btag= " << sbtag[ibtag]
	      << " Efficiency = " << newEff << std::endl;
    efficiency[iMass][ibtag] = newEff;

    double normShould = 1000 * intLumi * efficiency[iMass][ibtag];
    double normIs = hSignalCentral[ibtag]->GetSumOfWeights();
    std::cout << hSignalCentral[ibtag]->GetName() << " TotalContents=" << hSignalCentral[ibtag]->GetSumOfWeights()
	      << std::endl;
    fScal[iMass][ibtag] = normShould / normIs;
    std::cout << "normShould = " << normShould << " normIs " << normIs
	      << " rescale by " << fScal[iMass][ibtag] << std::endl;
    hSignalCentral[ibtag]->Scale( fScal[iMass][ibtag] );
    hout->cd();
    hSignalCentral[ibtag]->Write();
    histEffMerged->Write();

    // create empty file just as marker
    ofstream markerFile;
    markerFile.open(Form("pack-%s-%s.txt",sbtag[ibtag].c_str(),scenario.c_str()),ios::app);
    markerFile << "Template for mass " << signalMass[iMass] << std::endl;
    markerFile.close();
  }

  // read the nominal cross section
  TH1F* histXSect = (TH1F*) fSig->Get("xsection/xsect");
  if ( histXSect == NULL) {
    std::cout << "xsection/xsect" << " not found" << std::endl;
    return;
  }
  histXSect->Write();

  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
      signalSystFiles[iSyst][iUpDown] = Form( "/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
					      signalMode.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
					      upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      std::cout << "Signal systematics file " << signalSystFiles[iSyst][iUpDown] << std::endl;
      TFile* fSigSys = new TFile( signalSystFiles[iSyst][iUpDown].c_str() );
      if ( fSigSys == NULL ) {
	std::cout << "Could not open signal syst file " << signalSystFiles[iSyst][iUpDown].c_str() << std::endl;
	return;
      }
      for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	hSignalSyst[iSyst][iUpDown][ibtag] 
	  = mergeSignal(fSigSys,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
			Form("bbH_%s_%s_%s",systName[iSyst].c_str(),
			     upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()));
	std::cout << "The merged hist has name " << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << std::endl;
	std::cout << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << " TotalContents=" << hSignalSyst[iSyst][iUpDown][ibtag]->GetSumOfWeights()
	      << std::endl;

	hSignalSyst[iSyst][iUpDown][ibtag]->Scale( fScal[iMass][ibtag] );
	hout->cd();
	hSignalSyst[iSyst][iUpDown][ibtag]->Write();
      }
      fSigSys->Close();
    }
  }

  // real data
  std::string backgroundFile( Form("/afs/naf.desy.de/user/r/rmankel/scratch/HbbPat/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_CR3_SF7/TripleBtagAnalysis_SF/TripleBtagAnalysis.root",SashaPath.c_str()) );
  std::cout << "Background central file : " << backgroundFile << std::endl;
  TFile* fBac = new TFile( backgroundFile.c_str() );
  if ( fBac == NULL ) {
    std::cout << "Could not open background central file " << signalFile.c_str() << std::endl;
    return;
  }

  // hist-to-be-fitted
  TH2F* mjjEbtdata[nbtag];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    mjjEbtdata[ibtag] = getTrigsAndMerge(fBac,Form("massEvBtag/mjjEvBTag_%s",sbtag[ibtag].c_str()),nTCombData,tCombData);

    if (mjjEbtdata[ibtag] == NULL) {
      std::cout << "Histogram not found: " << Form("massEvBtag/mjjEvBTag_%s",sbtag[ibtag].c_str()) << std::endl;
      return;
    }
    // rename
    mjjEbtdata[ibtag]->SetName( Form("Data_%s",sbtag[ibtag].c_str() ) );
    hout->cd();
    mjjEbtdata[ibtag]->Write();
  }

  TH2F* hBackgroundCentral[nbtag][ncateg][nfc];
  TH2F* hBackgroundCentralError[nbtag][ncateg][nfc];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    for (int icateg=0; icateg<ncateg; ++icateg) {
      for (int ifc=0; ifc<nfc; ++ifc) {
	string templateCore("massBTagTemplatesCld/MassBTagTemplateCld");
	string hbSystName( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,3) );
	hBackgroundCentral[ibtag][icateg][ifc] = getTrigsAndMerge(fBac,Form("%s_%s_%s_Cat%dTpat%d",
									   templateCore.c_str(),
									   sfc[ifc].c_str(),
									   sbtag[ibtag].c_str(),icateg,3),nTCombData,tCombData);

	if ( hBackgroundCentral[ibtag][icateg][ifc] == NULL ) {
	  std::cout << "Hist not found: " << hbSystName << std::endl;
	  return;
	}
	// rename
	templateId tName(ifc,icateg);
	hBackgroundCentral[ibtag][icateg][ifc]->SetName( Form("%s_%s",tName.name().c_str(),sbtag[ibtag].c_str()) );
	// read the template errors
	templateCore.assign("errorMassBTagTemplates/ErrorMassBTagTemplate");
	string hbSystNameError( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,3) );
	hBackgroundCentralError[ibtag][icateg][ifc] 
	  = getTrigsAndMerge(fBac,Form("%s_%s_%s_Cat%dTpat%d",
				       templateCore.c_str(),
				       sfc[ifc].c_str(),
				       sbtag[ibtag].c_str(),icateg,3),nTCombData,tCombData);
	if ( hBackgroundCentralError[ibtag][icateg][ifc] == NULL ) {
	  std::cout << "Hist not found: " << hbSystNameError << std::endl;
	  return;
	}
	// add the template error
	std::cout << " ==== Adding Btag Errors ==== " << hBackgroundCentral[ibtag][icateg][ifc]->GetName() << std::endl;
	for (int ibinx=1; ibinx<= (hBackgroundCentral[ibtag][icateg][ifc]->GetXaxis()->GetNbins()); ++ibinx) {
	  for (int ibiny=1; ibiny<= (hBackgroundCentral[ibtag][icateg][ifc]->GetYaxis()->GetNbins()); ++ibiny) {
	    float oldError = hBackgroundCentral[ibtag][icateg][ifc]->GetBinError(ibinx,ibiny);
	    float addError = hBackgroundCentralError[ibtag][icateg][ifc]->GetBinContent(ibinx,ibiny);
	    float newError = sqrt( oldError * oldError + addError * addError );
	    hBackgroundCentral[ibtag][icateg][ifc]->SetBinError(ibinx,ibiny,newError);
	  }
	}
	hout->cd();
	hBackgroundCentral[ibtag][icateg][ifc]->Write();
      }
    }
  }

  std::string backgroundSystFiles[nSyst][nUpDown];
  std::string systNameSasha[nSyst] = { "JES", "SFbc", "SFq" };
  std::string upDownNameSasha[nUpDown] = { "plus2", "minus2" };
  TH2F* hBackgroundSyst[nSyst][nUpDown][nbtag][ncateg][nfc];
  TH2F* hBackgroundSystError[nSyst][nUpDown][nbtag][ncateg][nfc];

  // for JEC, the up/down templates are just copies of the central templates
  for (int iSyst=0; iSyst<1; ++iSyst) {
    for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
      for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	for (int icateg=0; icateg<ncateg; ++icateg) {
	  for (int ifc=0; ifc<nfc; ++ifc) {
	    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
	      = new TH2F( *hBackgroundCentral[ibtag][icateg][ifc] );
	    // rename
	    templateId tName(ifc,icateg);
	    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
	      ->SetName( Form("%s_%s_%s_%s",
			      tName.name().c_str(),systName[iSyst].c_str(),
			      upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()) );
	    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->Write();
	  }
	}
      }
    }
  }
  fBac->Close();


  for (int iSyst=1; iSyst<nSyst; ++iSyst) {
    for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
      backgroundSystFiles[iSyst][iUpDown] = Form( "/afs/naf.desy.de/user/r/rmankel/scratch/HbbPat/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_CR3_SF7/TripleBtagAnalysis_%s%s/TripleBtagAnalysis.root",SashaPath.c_str(),systNameSasha[iSyst].c_str(),upDownNameSasha[iUpDown].c_str() );
      TFile* fBacSys = new TFile( backgroundSystFiles[iSyst][iUpDown].c_str() );
      std::cout << "Background systematics file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
      if ( fBacSys == NULL ) {
	std::cout << "Could not open background syst file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	return;
      }
      for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	for (int icateg=0; icateg<ncateg; ++icateg) {
	  for (int ifc=0; ifc<nfc; ++ifc) {
	    string templateCore("massBTagTemplatesCld/MassBTagTemplateCld");
	    string hbSystName( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				   sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,3) );
	    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc] 
	      = getTrigsAndMerge(fBacSys,Form("%s_%s_%s_Cat%dTpat%d",
					   templateCore.c_str(),
					   sfc[ifc].c_str(),
					   sbtag[ibtag].c_str(),icateg,3),nTCombData,tCombData);
	    if ( hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc] == NULL ) {
	      std::cout << "Hist not found: " << hbSystName << std::endl;
	      return;
	    }
	    // rename
	    templateId tName(ifc,icateg);
	    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
	      ->SetName( Form("%s_%s_%s_%s",
			      tName.name().c_str(),systName[iSyst].c_str(),
			      upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()) );

	    // read template errors
	    templateCore.assign("errorMassBTagTemplates/ErrorMassBTagTemplate");
	    string hbSystNameError( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
					 sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,3) );
	    hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc] 
	      = getTrigsAndMerge(fBacSys,Form("%s_%s_%s_Cat%dTpat%d",
					      templateCore.c_str(),
					      sfc[ifc].c_str(),
					      sbtag[ibtag].c_str(),icateg,3),nTCombData,tCombData);
	    if ( hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc] == NULL ) {
	      std::cout << "Hist not found: " << hbSystNameError << std::endl;
	      return;
	    }
	    // add the template error
	    std::cout << " ==== ErrorAdd ==== " << hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName() << std::endl;
	    for (int ibinx=1; ibinx<= (hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetXaxis()->GetNbins()); ++ibinx) {
	      for (int ibiny=1; ibiny<= (hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetYaxis()->GetNbins()); ++ibiny) {
		float oldError = hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetBinError(ibinx,ibiny);
		float addError = hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc]->GetBinContent(ibinx,ibiny);
		float newError = sqrt( oldError * oldError + addError * addError );
		hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->SetBinError(ibinx,ibiny,newError);
	      }
	    }
	    hout->cd();
	    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->Write();
	  }
	}
      }
      fBacSys->Close();
    }
  }

  std::cout << "Everything done " << std::endl;

#ifdef PROJECTIONS
  // loop over background templates
  //TH1D* bgProX[nbtag][ncateg][nfc];
  TH1D* bgSystProX[nSyst][nUpDown][nbtag][ncateg][nfc];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    for (int icateg=0; icateg<ncateg; ++icateg) {
      for (int ifc=0; ifc<nfc; ++ifc) {
	TH2F* theTemp = hBackgroundCentral[ibtag][icateg][ifc];
	TH1D* theTempProX = theTemp->ProjectionX(Form("%sProX",theTemp->GetName()),0,-1,"e");
	theTempProX->SetName( Form("%sProX",theTemp->GetName()) );
	TH1D* theTempProY = theTemp->ProjectionY(Form("%sProY",theTemp->GetName()),0,-1,"e");
	std::cout << "Made projection " << theTempProX->GetName() << std::endl;

	if ( (icateg == 0) && (ifc == 0) ) {
	  for (int ibinx=1; ibinx<= theTempProX->GetXaxis()->GetNbins(); ++ibinx) {
	    std::cout << ibinx << " content " << theTempProX->GetBinContent(ibinx)
		      << " error " << theTempProX->GetBinError(ibinx) << std::endl;
	  }
	}
	theTempProX->SetMarkerStyle(20);
	theTempProX->SetMarkerColor(1);
	theTempProX->SetLineColor(1);
	theTempProX->SetMarkerSize(1);
	std::cout << "Draw" << std::endl;
	theTempProX->Draw("EP");
	//theTempProX->Draw("LP,SAME");
	// draw the SFbc systematics
	int colSyst[3] = {1, 2, 4};
	int lstyleUpDown[2] = {1, 1};
	for (int iSyst=1; iSyst<nSyst; ++iSyst) {
	  for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
	    bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc] =  hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->ProjectionX(Form("%sProXX",hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName()),0,-1,"e");
	    bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->SetName( Form("%sProXX",hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName()) );
	    std::cout << "Made projection " << bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->GetName() << std::endl;
	     bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->SetLineColor( colSyst[iSyst] );
	     bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->Draw("HIST,SAME");


// 	    TH2F* theTemp = hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc];
// 	    TH1D* theTempProX = theTemp->ProjectionX(Form("%sProX",theTemp->GetName()),0,-1,"e");
// 	    theTempProX->SetLineColor( colSyst[iSyst] );
// 	    TH1D* theTempProY = theTemp->ProjectionY(Form("%sProY",theTemp->GetName()),0,-1,"e");
// 	    theTempProY->SetLineColor( colSyst[iSyst] );
// 	    //theTempProX->Draw("HIST");
	  }
	}

	canvas->Print(Form("Template_%s_%s_Cat%d_ProX.png",sbtag[ibtag].c_str(),sfc[ifc].c_str(),icateg));
      }
    }
  }
#endif

  //hout->Write();
  hout->Close();

  // close the signal central file
  fSig->Close();

  return;
}