Beispiel #1
0
void run_litqa(Int_t nEvents = 1000)
{
   TTree::SetMaxTreeSize(90000000000);

	TString script = TString(gSystem->Getenv("SCRIPT"));
	TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters");

	//gRandom->SetSeed(10);

    TString dir = "/hera/cbm/users/slebedev/mc/dielectron/sep13/25gev/trd/1.0field/nomvd/rho0/";
	TString mcFile = dir + "mc.auau.25gev.centr.00001.root";
	TString parFile = dir + "/params.auau.25gev.centr.00001.root";
	TString recoFile = dir + "/test.reco.test.auau.25gev.centr.00001.root";
	TString qaFile = dir + "/test.litqa.test.auau.25gev.centr.00001.root";

	TString delta = "no"; // if "yes" Delta electrons will be embedded
	TString deltaFile = "";

   TList *parFileList = new TList();
   TObjString stsDigiFile = parDir + "/sts/sts_v13c_std.digi.par"; // STS digi file
   TObjString trdDigiFile = parDir + "/trd/trd_v13p_3e.digi.par"; // TRD digi file
   TObjString tofDigiFile = parDir + "/tof/tof_v13b.digi.par"; // TRD digi file

   TString stsMatBudgetFileName = parDir + "/sts/sts_matbudget_v13c.root"; // Material budget file for L1 STS tracking

   TString resultDir = "results_litqa/";
   Double_t trdAnnCut = 0.85;
   Int_t minNofPointsTrd = 6;

	if (script == "yes") {
		mcFile = TString(gSystem->Getenv("MC_FILE"));
		parFile = TString(gSystem->Getenv("PAR_FILE"));
		recoFile = TString(gSystem->Getenv("RECO_FILE"));
		qaFile = TString(gSystem->Getenv("LITQA_FILE"));

		delta = TString(gSystem->Getenv("DELTA"));
		deltaFile = TString(gSystem->Getenv("DELTA_FILE"));

		stsDigiFile = TString(gSystem->Getenv("STS_DIGI"));
		trdDigiFile = TString(gSystem->Getenv("TRD_DIGI"));
		tofDigiFile = TString(gSystem->Getenv("TOF_DIGI"));

		resultDir = TString(gSystem->Getenv("RESULT_DIR"));

		stsMatBudgetFileName = TString(gSystem->Getenv("STS_MATERIAL_BUDGET_FILE"));
		trdAnnCut = TString(gSystem->Getenv("TRD_ANN_CUT")).Atof();
		minNofPointsTrd = TString(gSystem->Getenv("MIN_NOF_POINTS_TRD")).Atof();
	}

   parFileList->Add(&stsDigiFile);
   parFileList->Add(&trdDigiFile);
   parFileList->Add(&tofDigiFile);

   TStopwatch timer;
   timer.Start();

	// ----  Load libraries   -------------------------------------------------
   gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C");
	loadlibs();
	gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/determine_setup.C");

	// -----   Reconstruction run   -------------------------------------------
	FairRunAna *run= new FairRunAna();
	if (mcFile != "") run->SetInputFile(mcFile);
	if (recoFile != "") run->AddFriend(recoFile);
	if (qaFile != "") run->SetOutputFile(qaFile);

	CbmKF* kalman = new CbmKF();
	run->AddTask(kalman);
	CbmL1* l1 = new CbmL1();
	l1->SetMaterialBudgetFileName(stsMatBudgetFileName);
	run->AddTask(l1);

   // Reconstruction Qa
   CbmLitTrackingQa* trackingQa = new CbmLitTrackingQa();
   trackingQa->SetMinNofPointsSts(4);
   trackingQa->SetUseConsecutivePointsInSts(true);
   trackingQa->SetMinNofPointsTrd(minNofPointsTrd);
   trackingQa->SetMinNofPointsMuch(10);
   trackingQa->SetMinNofPointsTof(1);
   trackingQa->SetQuota(0.7);
   trackingQa->SetMinNofHitsTrd(minNofPointsTrd);
   trackingQa->SetMinNofHitsMuch(10);
   trackingQa->SetVerbose(0);
   trackingQa->SetMinNofHitsRich(7);
   trackingQa->SetQuotaRich(0.6);
   trackingQa->SetPRange(30, 0., 6.);
   trackingQa->SetOutputDir(std::string(resultDir));
   std::vector<std::string> trackCat, richCat;
   trackCat.push_back("All");
   trackCat.push_back("Electron");
   richCat.push_back("All");
   richCat.push_back("Electron");
   richCat.push_back("ElectronReference");
   trackingQa->SetTrackCategories(trackCat);
   trackingQa->SetRingCategories(richCat);
   trackingQa->SetTrdAnnCut(trdAnnCut);
   run->AddTask(trackingQa);

   CbmLitFitQa* fitQa = new CbmLitFitQa();
   fitQa->SetMvdMinNofHits(0);
   fitQa->SetStsMinNofHits(4);
   fitQa->SetMuchMinNofHits(10);
   fitQa->SetTrdMinNofHits(minNofPointsTrd);
   fitQa->SetPRange(30, 0., 3.);
   fitQa->SetOutputDir(std::string(resultDir));
   run->AddTask(fitQa);

  /* CbmLitClusteringQa* clusteringQa = new CbmLitClusteringQa();
   clusteringQa->SetMuchDigiFileName(muchDigiFile.Data());
   clusteringQa->SetOutputDir(std::string(resultDir));
   run->AddTask(clusteringQa);*/

   CbmLitTofQa* tofQa = new CbmLitTofQa();
   tofQa->SetOutputDir(std::string(resultDir));
   run->AddTask(tofQa);


    // -----  Parameter database   --------------------------------------------
   FairRuntimeDb* rtdb = run->GetRuntimeDb();
   FairParRootFileIo* parIo1 = new FairParRootFileIo();
   FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
   parIo1->open(parFile.Data());
   parIo2->open(parFileList, "in");
   rtdb->setFirstInput(parIo1);
   rtdb->setSecondInput(parIo2);
   rtdb->setOutput(parIo1);
   rtdb->saveOutput();

    run->Init();
    run->Run(0, nEvents);

    // -----   Finish   -------------------------------------------------------
    timer.Stop();
    std::cout << "Macro finished successfully." << std::endl;
    std::cout << "Output file is "    << recoFile << std::endl;
    std::cout << "Parameter file is " << parFile << std::endl;
    std::cout << "Real time " << timer.RealTime() << " s, CPU time " << timer.CpuTime() << " s" << std::endl;
    std::cout << " Test passed" << std::endl;
    std::cout << " All ok " << std::endl;
}
Beispiel #2
0
void run_trac_its(Int_t nEvents = 10, TString mcEngine = "TGeant3"){
        // Initialize logger
        FairLogger *logger = FairLogger::GetLogger();
        logger->SetLogVerbosityLevel("LOW");
        logger->SetLogScreenLevel("INFO");

        // Input and output file name
        std::stringstream inputfile, outputfile, paramfile;
        inputfile << "AliceO2_" << mcEngine << ".clus_" << nEvents << "_event.root";
        paramfile << "AliceO2_" << mcEngine << ".params_" << nEvents << ".root";
        outputfile << "AliceO2_" << mcEngine << ".trac_" << nEvents << "_event.root";

        // Setup timer
        TStopwatch timer;

        // Setup FairRoot analysis manager
        FairRunAna * fRun = new FairRunAna();
        FairFileSource *fFileSource = new FairFileSource(inputfile.str().c_str());
        fRun->SetSource(fFileSource);
        fRun->SetOutputFile(outputfile.str().c_str());

        // Setup Runtime DB
        FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
        FairParRootFileIo* parInput1 = new FairParRootFileIo();
        parInput1->open(paramfile.str().c_str());
        rtdb->setFirstInput(parInput1);

        // Setup tracker
        // To run with n threads call AliceO2::ITS::CookedTrackerTask(n)
        AliceO2::ITS::CookedTrackerTask *trac = new AliceO2::ITS::CookedTrackerTask;

        fRun->AddTask(trac);

        fRun->Init();

        AliceO2::Field::MagneticField* fld = (AliceO2::Field::MagneticField*)fRun->GetField();
      	if (!fld) {
      	  std::cout << "Failed to get field instance from FairRunAna" << std::endl;
      	  return;
      	}
      	trac->setBz(fld->solenoidField()); //in kG

        timer.Start();
        fRun->Run();

        std::cout << std::endl << std::endl;

        // Extract the maximal used memory an add is as Dart measurement
        // This line is filtered by CTest and the value send to CDash
        FairSystemInfo sysInfo;
        Float_t maxMemory=sysInfo.GetMaxMemory();
        std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
        std::cout << maxMemory;
        std::cout << "</DartMeasurement>" << std::endl;

        timer.Stop();
        Double_t rtime = timer.RealTime();
        Double_t ctime = timer.CpuTime();

        Float_t cpuUsage=ctime/rtime;
        cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
        cout << cpuUsage;
        cout << "</DartMeasurement>" << endl;
        cout << endl << endl;
        cout << "Macro finished succesfully." << endl;

        std::cout << endl << std::endl;
        std::cout << "Output file is "    << outputfile.str() << std::endl;
        //std::cout << "Parameter file is " << parFile << std::endl;
        std::cout << "Real time " << rtime << " s, CPU time " << ctime
                  << "s" << endl << endl;
}
Beispiel #3
0
void ana_Main_MC(TString ds="relval", TString physics="ttbar") {

	gSystem->Load("libSusyEvent.so");

	// Look ../jec/JetMETObjects/README
	gSystem->Load("../jec/lib/libJetMETObjects.so");

	// Printing utility for ntuple variables
	gROOT->LoadMacro("SusyEventPrinter.cc+");

	// Main analysis code
	gROOT->LoadMacro("SusyMainAna_MC.cc+");

	// chain of inputs
	TChain* chain = new TChain("susyTree");

	//////////////// MC files /////////////////
	cout<<"I survive this long1 "<< which_MC_to_use<< endl;
	MCpoint* thisMCpoint = setupMCpoint(which_MC_to_use);
	cout<<"I survive this long2"<<endl;
	chain->Add(thisMCpoint->filepath.c_str());
	cout<<"I survive this long"<<endl;


	//chain->Add("../susyEvents_AB_1M_ho200_v2.root");
	//chain->Add("../susyEvents_newNatural.root"); //last used!!
	//chain->Add("/eos/uscms/store/user/abarker/MC/newNat350_225/MC_AB_2500k_NEWnaturalHiggsinoNLSPout_mst_350_M3_5025_mu_225.root");//same thing as ../susyEvents_newNatural.root
	//chain->Add("/eos/uscms/store/user/abarker/MC/st_250_ho_150/MC_AB_2500k_st_250_ho_150.root");
	//chain->Add("/eos/uscms/store/user/abarker/MC/st_250_ho_200/MC_AB_2500k_st_250_ho_200.root");
	//chain->Add("/eos/uscms/store/user/abarker/MC/st_350_ho_200/MC_AB_2500k_mst_350_mu_200.root");
	//chain->Add("/eos/uscms/store/user/abarker/MC/ho_140/MC_AB_2500k_ho_140.root");
	//chain->Add("/eos/uscms/store/user/abarker/MC/ho_200/MC_AB_2500k_ho_200.root");


	//chain->Add("../susyEvents_newNatural.root");
	//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_NEWnaturalHiggsinoNLSPout_mst_350_M3_5025_mu_225.root");

	//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_st_250_ho_150.root");
	//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_st_250_ho_200.root");
	//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_mst_350_mu_200.root");
	//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_ho_140.root");
	//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_ho_200.root");


	SusyMainAna_MC* sea = new SusyMainAna_MC(chain);

	// configuration parameters
	// any values given here will replace the default values
	sea->SetDataset(physics+"_"+ds);        // dataset name
	sea->SetPrintInterval(1e4);             // print frequency
	sea->SetPrintLevel(0);                  // print level for event contents
	sea->SetUseTrigger(false);
	/*
	   sea->AddHltName("HLT_Photon36_CaloIdL_Photon22_CaloIdL");  // add HLT trigger path name 
	   sea->AddHltName("HLT_Photon32_CaloIdL_Photon26_CaloIdL");  // add HLT trigger path name
	   sea->AddHltName("HLT_Photon26_R9Id85_Photon18_R9Id85_Mass60");
	   sea->AddHltName("HLT_Photon26_R9Id85_Photon18_CaloId10_Iso50_Mass60");
	   sea->AddHltName("HLT_Photon26_CaloId10_Iso50_Photon18_R9Id85_Mass60");
	   sea->AddHltName("HLT_Photon26_CaloId10_Iso50_Photon18_CaloId10_Iso50_Mass60");
	   sea->AddHltName("HLT_Photon26_R9Id85_OR_CaloId10_Iso50_Photon18_R9Id85_OR_CaloId10_Iso50_Mass60");
	   sea->AddHltName("HLT_Photon26_R9Id85_OR_CaloId10_Iso50_Photon18_R9Id85_OR_CaloId10_Iso50_Mass70");
	   sea->AddHltName("HLT_Photon36_R9Id85_Photon22_R9Id85");
	   sea->AddHltName("HLT_Photon36_R9Id85_Photon22_CaloId10_Iso50");
	   sea->AddHltName("HLT_Photon36_CaloId10_Iso50_Photon22_R9Id85");
	   sea->AddHltName("HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50");
	   sea->AddHltName("HLT_Photon36_R9Id85_OR_CaloId10_Iso50_Photon22_R9Id85_OR_CaloId10_Iso50");
	 */
	sea->SetFilter(false);                  // filter events passing final cuts
	sea->SetProcessNEvents(-1);             // number of events to be processed

	// as an example -- add your favorite Json here.  More than one can be "Include"ed
	//  sea->IncludeAJson("Cert_161079-161352_7TeV_PromptReco_Collisions11_JSON_noESpbl_v2.txt");
	//sea->IncludeAJson("anotherJSON.txt");

	TStopwatch ts;

	ts.Start();

	sea->Loop();

	ts.Stop();

	std::cout << "RealTime : " << ts.RealTime()/60.0 << " minutes" << std::endl;
	std::cout << "CPUTime  : " << ts.CpuTime()/60.0 << " minutes" << std::endl;

}
Beispiel #4
0
void run_sim()
{
    TString transport = "TGeant4";
    Bool_t userPList = kFALSE; // option for TGeant4

    TString outFile = "sim.root";
    TString parFile = "par.root";

    Bool_t magnet = kTRUE;
    Float_t fieldScale = -0.68;

    TString generator1 = "box";
    TString generator2 = "ascii";
    TString generator3 = "r3b";
    TString generator = generator1;
    TString inputFile = "";

    Int_t nEvents = 1;
    Bool_t storeTrajectories = kTRUE;
    Int_t randomSeed = 335566; // 0 for time-dependent random numbers

    // Target type
    TString target1 = "LeadTarget";
    TString target2 = "Para";
    TString target3 = "Para45";
    TString target4 = "LiH";
    TString targetType = target4;

    // ------------------------------------------------------------------------
    // Stable part ------------------------------------------------------------

    TString dir = getenv("VMCWORKDIR");

    // ----    Debug option   -------------------------------------------------
    gDebug = 0;

    // -----   Timer   --------------------------------------------------------
    TStopwatch timer;
    timer.Start();

    // -----   Create simulation run   ----------------------------------------
    FairRunSim* run = new FairRunSim();
    run->SetName(transport);            // Transport engine
    run->SetOutputFile(outFile.Data()); // Output file
    FairRuntimeDb* rtdb = run->GetRuntimeDb();

    //  R3B Special Physics List in G4 case
    if ((userPList == kTRUE) && (transport.CompareTo("TGeant4") == 0))
    {
        run->SetUserConfig("g4R3bConfig.C");
        run->SetUserCuts("SetCuts.C");
    }

    // -----   Create media   -------------------------------------------------
    run->SetMaterials("media_r3b.geo"); // Materials

    // -----   Create R3B geometry --------------------------------------------
    // R3B Cave definition
    FairModule* cave = new R3BCave("CAVE");
    cave->SetGeometryFileName("r3b_cave.geo");
    run->AddModule(cave);

    // To skip the detector comment out the line with: run->AddModule(...

    // Target
    run->AddModule(new R3BTarget(targetType, "target_" + targetType + ".geo.root"));

    // GLAD
    //run->AddModule(new R3BGladMagnet("glad_v17_flange.geo.root")); // GLAD should not be moved or rotated

    // PSP
    run->AddModule(new R3BPsp("psp_v13a.geo.root", {}, -221., -89., 94.1));

    // R3B SiTracker Cooling definition
    //run->AddModule(new R3BVacVesselCool(targetType, "vacvessel_v14a.geo.root"));

    // STaRTrack
    //run->AddModule(new R3BSTaRTra("startra_v16-300_2layers.geo.root", { 0., 0., 20. }));

    // CALIFA
    R3BCalifa* califa = new R3BCalifa("califa_10_v8.11.geo.root");
    califa->SelectGeometryVersion(10);
    // Selecting the Non-uniformity of the crystals (1 means +-1% max deviation)
    califa->SetNonUniformity(1.0);
    //run->AddModule(califa);

    // Tof
    //run->AddModule(new R3BTof("tof_v17a.geo.root", { -417.359574, 2.400000, 960.777114 }, { "", -90., +31., 90. }));

    // mTof
    run->AddModule(new R3BmTof("mtof_v17a.geo.root", { -155.824045, 0.523976, 761.870346 }, { "", -90., +16.7, 90. }));

    // MFI
    //run->AddModule(new R3BMfi("mfi_v17a.geo.root", { -63.82, 0., 520.25 }, { "", 90., +13.5, 90. })); // s412

    // NeuLAND
    // run->AddModule(new R3BNeuland("neuland_test.geo.root", { 0., 0., 1400. + 12 * 5. }));

    // -----   Create R3B  magnetic field ----------------------------------------
    // NB: <D.B>
    // If the Global Position of the Magnet is changed
    // the Field Map has to be transformed accordingly
    R3BGladFieldMap* magField = new R3BGladFieldMap("R3BGladMap");
    magField->SetScale(fieldScale);

    if (magnet == kTRUE)
    {
        run->SetField(magField);
    }
    else
    {
        run->SetField(NULL);
    }

    // -----   Create PrimaryGenerator   --------------------------------------
    // 1 - Create the Main API class for the Generator
    FairPrimaryGenerator* primGen = new FairPrimaryGenerator();

    if (generator.CompareTo("box") == 0)
    {
        FairIonGenerator* boxGen = new FairIonGenerator(50, 128, 50, 1, 0., 0., 1.3, 0., 0., 0.);
        primGen->AddGenerator(boxGen);
    }

    if (generator.CompareTo("ascii") == 0)
    {
        R3BAsciiGenerator* gen = new R3BAsciiGenerator((dir + "/input/" + inputFile).Data());
        primGen->AddGenerator(gen);
    }

    run->SetGenerator(primGen);

    run->SetStoreTraj(storeTrajectories);

    FairLogger::GetLogger()->SetLogVerbosityLevel("LOW");
    FairLogger::GetLogger()->SetLogScreenLevel("INFO");

    // -----   Initialize simulation run   ------------------------------------
    run->Init();
    TVirtualMC::GetMC()->SetRandom(new TRandom3(randomSeed));

    // ------  Increase nb of step for CALO
    Int_t nSteps = -15000;
    TVirtualMC::GetMC()->SetMaxNStep(nSteps);

    // -----   Runtime database   ---------------------------------------------
    R3BFieldPar* fieldPar = (R3BFieldPar*)rtdb->getContainer("R3BFieldPar");
    if (NULL != magField)
    {
        fieldPar->SetParameters(magField);
        fieldPar->setChanged();
    }
    Bool_t kParameterMerged = kTRUE;
    FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
    parOut->open(parFile.Data());
    rtdb->setOutput(parOut);
    rtdb->saveOutput();
    rtdb->print();

    // -----   Start run   ----------------------------------------------------
    if (nEvents > 0)
    {
        run->Run(nEvents);
    }

    // -----   Finish   -------------------------------------------------------
    timer.Stop();
    Double_t rtime = timer.RealTime();
    Double_t ctime = timer.CpuTime();
    cout << endl << endl;
    cout << "Macro finished succesfully." << endl;
    cout << "Output file is " << outFile << endl;
    cout << "Parameter file is " << parFile << endl;
    cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;

    cout << " Test passed" << endl;
    cout << " All ok " << endl;

    // Snap a picture of the geometry
    // If this crashes, set "OpenGL.SavePicturesViaFBO: no" in your .rootrc
    /*gStyle->SetCanvasPreferGL(kTRUE);
    gGeoManager->GetTopVolume()->Draw("ogl");
    TGLViewer* v = (TGLViewer*)gPad->GetViewer3D();
    v->SetStyle(TGLRnrCtx::kOutline);
    v->RequestDraw();
    v->SavePicture("run_sim-side.png");
    v->SetPerspectiveCamera(TGLViewer::kCameraPerspXOZ, 25., 0, 0, -90. * TMath::DegToRad(), 0. * TMath::DegToRad());
    v->SavePicture("run_sim-top.png");*/
}
Beispiel #5
0
void Check_PFelecFix(int radius = 3,
		     char * algo = (char*)"PF",
		     char * bkgsub = (char*)"Pu"){

  
  TH1::SetDefaultSumw2();
  //gStyle->SetOptStat(0);
  
  TStopwatch timer;
  timer.Start();
  
  TDatime date;

  char * fileType[4][256] = {"badFile","Fix_1","Fix_2","Fix_3"};
  
  // get the input hiForest files, these are going to be in an array 0 - bad fine, 1 - fix_1, 2 - fix_2, 3 - fix_3; 
  TFile * fIn[4];

  // input the filen names
  fIn[0] = TFile::Open("");
  fIn[1] = TFile::Open("");
  fIn[2] = TFile::Open("");
  fIn[3] = TFile::Open("");
  
  // get the jet trees from the necessary files (these events already passed the event quality cuts so only hav to get the jet Tree).
  TTree * jet[4];
   
  // get the histograms from these files for the different centrality bins and the fixes. 
  TH1F * heMax[4][nbins_cent], * heSum[4][nbins_cent];
  TH2F * heMax_vs_jtpt[4][nbins_cent], * heMaxJtpt_vs_jtpt[4][nbins_cent], * heMaxSumcand_vs_jtpt[4][nbins_cent];


  for(int k = 0; k<4; ++k){

    jet[k] = (TTree*)fIn[k]->Get(Form("ak%s%d%sJetAnalyzer/t",bkgsub,radius,algo));

    for(int i = 0; i<nbins_cent; ++i){

      heMax[k][i] = new TH1F(Form("heMax_%s_cent%d",fileType,i),"",200,0,200);
      heMax_vs_jtpt[k][i] = new TH1F(Form("heMax_vs_jtpt_%s_cent0",fileType,i),"",400,0,400,100,0,200);
      heMaxJtpt_vs_jtpt[k][i] = new TH1F(Form("heMaxJtpt_vs_jtpt_%s_cent0",fileType,i),"",400,0,400,100,0,10);
      heMaxSumcand_vs_jtpt[k][i] = new TH1F(Form("heMaxSumcand_vs_jtpt_%s_cent0",fileType,i),"",400,0,400,100,0,10);

      jet[k]->Draw(Form("eMax>>heMax_%s_cent%d",fileType,i),Form("hiBin>=%d && hiBin<%d",5 * boundaries_cent[i], 5 * boundaries_cent[i+1]),"goff");
      jet[k]->Draw(Form("eMax:jtpt>>heMax_vs_jtpt_%s_cent%d",fileType,i),Form("hiBin>=%d && hiBin<%d",5 * boundaries_cent[i], 5 * boundaries_cent[i+1]),"goff");
      jet[k]->Draw(Form("eMax/jtpt:jtpt>>heMaxJtpt_vs_jtpt_%s_cent%d",fileType,i),Form("hiBin>=%d && hiBin<%d",5 * boundaries_cent[i], 5 * boundaries_cent[i+1]),"goff");
      jet[k]->Draw(Form("eMax/(chSum+neSum+muSum+phSum):jtpt>>heMaxSumcand_vs_jtpt_%s_cent%d",fileType,i),Form("hiBin>=%d && hiBin<%d",5 * boundaries_cent[i], 5 * boundaries_cent[i+1]),"goff");
    
    }

  }

  // now that we have the histograms, lets do the plotting part here.
  // we need one canvas for each plotted variable.
  // at the moment im only going to plot the most central events. 0 <= hiBin < 5

  TCanvas * ceMax, *ceMax_vs_jtpt, *ceMaxJtpt_vs_jtpt, *ceMaxSumcand_vs_jtpt;

  ceMax = new TCanvas("ceMax","",1200,1000);
  ceMax->Divide(4,1);
  ceMax_vs_jtpt = new TCanvas("ceMax_vs_jtpt","",1200,1000);
  ceMax_vs_jtpt->Divide(4,1);
  ceMaxJtpt_vs_jtpt = new TCanvas("ceMaxJtpt_vs_jtpt","",1200,1000);
  ceMaxJtpt_vs_jtpt->Divide(4,1);
  ceMaxSumcand_vs_jtpt = new TCanvas("ceMaxSumcand_vs_jtpt","",1200,1000);
  ceMaxSumcand_vs_jtpt->Divide(4,1);

  int cent = 0; // change this to draw other centrality classes 
  
  for(int k = 0; k<4; ++k){

    ceMax->cd(k+1);
    heMax[k][cent]->Draw();
    drawText(Form("%s %2.0f-%2.0f%",fileType,2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.2,0.2,14);

    ceMax_vs_jtpt->cd(k+1);
    heMax_vs_jtpt[k][cent]->Draw("colz");
    drawText(Form("%s %2.0f-%2.0f%",fileType,2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.2,0.2,14);

    ceMaxJtpt_vs_jtpt->cd(k+1);
    heMaxJtpt_vs_jtpt[k][cent]->Draw("colz");
    drawText(Form("%s %2.0f-%2.0f%",fileType,2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.2,0.2,14);

    ceMaxSumcand_vs_jtpt->cd(k+1);
    heMax_vs_jtpt[k][cent]->Draw("colz");
    drawText(Form("%s %2.0f-%2.0f%",fileType,2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.2,0.2,14);

  }

  ceMax->SaveAs(Form("PbPb_eMaxvariable_cent%d_ak%s%d%s_%d.pdf",cent,bkgsub,radius,algo,date.GetDate()),"RECREATE");
  ceMax_vs_jtpt->SaveAs(Form("PbPb_eMax_vs_jtpt_cent%d_ak%s%d%s_%d.pdf",cent,bkgsub,radius,algo,date.GetDate()),"RECREATE");
  ceMaxJtpt_vs_jtpt->SaveAs(Form("PbPb_eMaxOverJtpt_vs_jtpt_cent%d_ak%s%d%s_%d.pdf",cent,bkgsub,radius,algo,date.GetDate()),"RECREATE");
  ceMaxSumcand_vs_jtpt->SaveAs(Form("PbPb_eMaxOver_SumCandidates_without_eMax_vs_jtpt_cent%d_ak%s%d%s_%d.pdf",cent,bkgsub,radius,algo,date.GetDate()),"RECREATE");
  
  timer.Stop();
  cout<<"Macro finished: "<<endl;
  cout<<"CPU time (min)  = "<<(float)timer.CpuTime()/60<<endl;
  cout<<"Real time (min) = "<<(float)timer.RealTime()/60<<endl;



}
Beispiel #6
0
int main ( int argc, char ** argv )
{

  // load framework libraries
  gSystem->Load( "libFWCoreFWLite" );
  AutoLibraryLoader::enable();

  if ( argc < 2 ) {
    std::cout << "Usage : " << argv[0] << " [parameters.py]" << std::endl;
    return 0;
  }

  // Get the python configuration
  PythonProcessDesc builder(argv[1], argc, argv);
  edm::ParameterSet const& shyftParameters = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("shyftAnalysis");
  edm::ParameterSet const& inputs = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("inputs");
  edm::ParameterSet const& outputs = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("outputs");

  // book a set of histograms
  fwlite::TFileService fs = fwlite::TFileService( outputs.getParameter<std::string>("outputName") );
  TFileDirectory theDir = fs.mkdir( "histos" ); 
    
  // This object 'event' is used both to get all information from the
  // event as well as to store histograms, etc.
  fwlite::ChainEvent ev ( inputs.getParameter<std::vector<std::string> > ("fileNames") );

  //cout << "Making event selector" << endl;
  WPlusJetsEventSelector wPlusJets( shyftParameters );
  pat::strbitset ret = wPlusJets.getBitTemplate();
  

  unsigned int nEventsAnalyzed(0);

  // some timing
  TStopwatch timer;
  timer.Start();

  std::cout << "About to loop" << std::endl;
  //loop through each event
  for( ev.toBegin();
       ! ev.atEnd();
       ++ev) {
    ret.set(false);
    //bool passed = wPlusJets(ev, ret);

    ++nEventsAnalyzed;

  } //end event loop

  timer.Stop();

  // print some timing statistics
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  printf("Analyzed events: %d \n",nEventsAnalyzed);
  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
  printf("%4.2f events / RealTime second .\n", nEventsAnalyzed/rtime);
  printf("%4.2f events / CpuTime second .\n", nEventsAnalyzed/ctime);


  
  //cout << "Printing" << endl;
  wPlusJets.print(std::cout);
  //cout << "We're done!" << endl;

  
  return 0;
}
Beispiel #7
0
void CrapPhoAnalysis(TString outputName="analysis"){

  // REMOVE THE LINE BELOW IF NOT RUNNING IN CMSSW ENVIRONMENT
  //gSystem->Load("libCondFormatsJetMETObjects.so");

  //gSystem->Load("../../SUSYPhotonAnalysis/SusyNtuplizer/macro/libSusyEvent.so");

  //gSystem->AddIncludePath("-I" + TString(gSystem->Getenv("CMSSW_RELEASE_BASE")) + "/src");

  // Analysis macro
  //gROOT->LoadMacro("SusyEventAnalyzer.cc+");

  //gSystem->AddIncludePath("-I /Users/dmason/play/photons/SUSYPhotonAnalysis/SusyNtuplizer/src");
  //gSystem->AddIncludePath("-I /Users/dmason/play/photons/Crap");

  //gSystem->Load("/Users/dmason/play/photons/SUSYPhotonAnalysis/SusyNtuplizer/src/SusyEvent.h+");
  gROOT->ProcessLine(".L ../SusyEvent.h+");
  gROOT->ProcessLine(".L ../Crap.h+");
  
  gROOT->ProcessLine(".L CrapPhoAnalysis.h+");


  gSystem->Load("../lib/libCrapPhoAnalysis.so");
  
  //gROOT->LoadMacro("CrapPhoAnalysis.cc++");

  // chain of inputs
  TChain chain("susyTree");
  //chain.Add("susyEvents.root");
  chain.Add("root://cmseos.fnal.gov//eos/uscms/store/user/lpcpjm/SusyNtuples/cms538v1/Run2012D-22Jan2013-v1/DoublePhoton/susyEvents_361_1_fC3.root");

  // Disabling unused branches will speed up the processing significantly, but risks inconsistencies if wrong trees are turned off.
  // Make sure you know what you are doing.
  // Especially be careful when producing a skim - disabled branches will not be copied.
  // You can either enable all branches, or have two Event objects (one for event selection with reduced branch configuration, and the
  // other for event copying with branches fully enabled).
  //chain.SetBranchStatus("*", 0);
  //chain.SetBranchStatus("runNumber", 1);
  //chain.SetBranchStatus("luminosityBlockNumber", 1);
  //chain.SetBranchStatus("eventNumber", 1);
  //chain.SetBranchStatus("isRealData", 1);
  //chain.SetBranchStatus("metFilterBit", 1);
  //chain.SetBranchStatus("rho", 1);
  //chain.SetBranchStatus("rho25", 1);
  //chain.SetBranchStatus("hlt*", 1);
  //chain.SetBranchStatus("vertices*", 1);
  //chain.SetBranchStatus("photons_photons*", 1);
  //chain.SetBranchStatus("muons_muons*", 1);
  //chain.SetBranchStatus("electrons_gsfElectrons*", 1);
  //chain.SetBranchStatus("pfJets_ak5*", 1);
  //chain.SetBranchStatus("met_pfType01CorrectedMet*", 1);
  //chain.SetBranchStatus("pfParticles*", 1);

  if(chain.LoadTree(0) != 0){
    cerr << "Error with input chain. Do the files exist?" << endl;
    return;
  }

  CrapPhoAnalysis sea(chain);

  sea.SetOutput(outputName);
  sea.SetLogFile("cout"); // set to a full path to a file to output log to a file
  sea.SetPrintInterval(1000);
  sea.SetPrintLevel(0);
  sea.AddHltName("HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50");
  sea.CopyEvents(true);
  sea.SetProcessNEvents(-1);

  TStopwatch ts;

  ts.Start();

  sea.Run();

  ts.Stop();

  std::cout << "RealTime : " << ts.RealTime()/60.0 << " minutes" << std::endl;
  std::cout << "CPUTime  : " << ts.CpuTime()/60.0 << " minutes" << std::endl;

}
Beispiel #8
0
void r3ball_batch(Int_t nEvents = 1,
	    TObjArray& fDetList,
	    TString Target = "LeadTarget",
		Bool_t fVis=kFALSE,
		TString fMC="TGeant3",
	    TString fGenerator="box",
	    Bool_t fUserPList= kFALSE,
		Bool_t fR3BMagnet= kTRUE,
		Double_t fEnergyP=1.0,
		Int_t fMult=1, 
		Int_t fGeoVer=5, 
		Double_t fNonUni=1.0	
			)
{


  TString dir = getenv("VMCWORKDIR");
  TString r3bdir = dir + "/macros";

  TString r3b_geomdir = dir + "/geometry";
  gSystem->Setenv("GEOMPATH",r3b_geomdir.Data());

  TString r3b_confdir = dir + "gconfig";
  gSystem->Setenv("CONFIG_DIR",r3b_confdir.Data());

// Output files
  TString OutFile = "r3bsim.root";
  TString ParFile = "r3bpar.root";


  // In general, the following parts need not be touched
  // ========================================================================

  // ----    Debug option   -------------------------------------------------
  gDebug = 0;
  // ------------------------------------------------------------------------

  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;
  timer.Start();
  // ------------------------------------------------------------------------

 
  // -----   Create simulation run   ----------------------------------------
  FairRunSim* run = new FairRunSim();
  run->SetName(fMC.Data());                  // Transport engine
  run->SetOutputFile(OutFile.Data());        // Output file
  FairRuntimeDb* rtdb = run->GetRuntimeDb();

  //  R3B Special Physics List in G4 case
  if ( (fUserPList  == kTRUE ) &&
       (fMC.CompareTo("TGeant4")   == 0)
      ){
       run->SetUserConfig("g4R3bConfig.C");
       run->SetUserCuts("SetR3BCuts.C");
   }


  // -----   Create media   -------------------------------------------------
  run->SetMaterials("media_r3b.geo");       // Materials
  

  // Magnetic field map type
   Int_t fFieldMap = 0;


  // Global Transformations
  //- Two ways for a Volume Rotation are supported
  //-- 1) Global Rotation (Euler Angles definition)
  //-- This represent the composition of : first a rotation about Z axis with
  //-- angle phi, then a rotation with theta about the rotated X axis, and
  //-- finally a rotation with psi about the new Z axis.
  Double_t phi,theta,psi;

  //-- 2) Rotation in Ref. Frame of the Volume
  //-- Rotation is Using Local Ref. Frame axis angles
  Double_t thetaX,thetaY,thetaZ;


  //- Global Translation  Lab. frame.
  Double_t tx,ty,tz;

  // - Polar angular limits
  Double_t minTheta=35., maxTheta=55.;


  // -----   Create R3B geometry --------------------------------------------
  //R3B Cave definition
  FairModule* cave= new R3BCave("CAVE");
  cave->SetGeometryFileName("r3b_cave.geo");
  run->AddModule(cave);


  //R3B Target definition
  if (fDetList.FindObject("TARGET") ) {
      R3BModule* target= new R3BTarget(Target.Data());
      // Global Lab. Rotation
      phi    =  0.0; // (deg)
      theta  =  0.0; // (deg)
      psi    =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx    =  0.0; // (cm)
      ty    =  0.0; // (cm)
      tz    =  0.0; // (cm)
     //target->SetRotAnglesEuler(phi,theta,psi);
     target->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
     target->SetTranslation(tx,ty,tz);
      run->AddModule(target);
  }

  //R3B Magnet definition
  if (fDetList.FindObject("ALADIN") ) {
    fFieldMap = 0;
    R3BModule* mag = new R3BMagnet("AladinMagnet");
    mag->SetGeometryFileName("aladin_v13a.geo.root");
    run->AddModule(mag);
  }

    //R3B Magnet definition
  if (fDetList.FindObject("GLAD") ) {
      fFieldMap = 1;
      R3BModule* mag = new R3BGladMagnet("GladMagnet");
      // Global position of the Module
      phi   =  0.0; // (deg)
      theta =  0.0; // (deg)
      psi   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx    =  0.0; // (cm)
      ty    =  0.0; // (cm)
      tz    =  0.0; // (cm)
      //mag->SetRotAnglesEuler(phi,theta,psi);
      mag->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      mag->SetTranslation(tx,ty,tz);
      run->AddModule(mag);
  }

  if (fDetList.FindObject("CRYSTALBALL") ) {
      //R3B Crystal Calorimeter
      R3BDetector* xball = new R3BXBall("XBall", kTRUE);
      xball->SetGeometryFileName("cal_v13a.geo.root");
      run->AddModule(xball);
  }

  if (fDetList.FindObject("CALIFA") ) {
    // CALIFA Calorimeter
    R3BDetector* calo = new R3BCalo("Califa", kTRUE);
    ((R3BCalo *)calo)->SelectGeometryVersion(10);
    //Selecting the Non-uniformity of the crystals (1 means +-1% max deviation)
    ((R3BCalo *)calo)->SetNonUniformity(1.0);
    calo->SetGeometryFileName("califa_v13_811.geo.root");
    run->AddModule(calo);
  }

  // Tracker
  if (fDetList.FindObject("TRACKER")  ) {
      R3BDetector* tra = new R3BTra("Tracker", kTRUE);
      // Global position of the Module
      phi   =  0.0; // (deg)
      theta =  0.0; // (deg)
      psi   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx    =  0.0; // (cm)
      ty    =  0.0; // (cm)
      tz    =  0.0; // (cm)
      //tra->SetRotAnglesEuler(phi,theta,psi);
      tra->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      tra->SetTranslation(tx,ty,tz);
      // User defined Energy CutOff
      Double_t fCutOffSi = 1.0e-06;  // Cut-Off -> 10KeV only in Si
      ((R3BTra*) tra)->SetEnergyCutOff(fCutOffSi);
      run->AddModule(tra);
  }
  
  // DCH drift chambers
  if (fDetList.FindObject("DCH") ) {
      R3BDetector* dch = new R3BDch("Dch", kTRUE);
      ((R3BDch*) dch )->SetHeliumBag(kTRUE);
      // Global position of the Module
      phi   =  0.0; // (deg)
      theta =  0.0; // (deg)
      psi   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx    =  0.0; // (cm)
      ty    =  0.0; // (cm)
      tz    =  0.0; // (cm)
     //dch->SetRotAnglesEuler(phi,theta,psi);
      dch->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      dch->SetTranslation(tx,ty,tz);
      run->AddModule(dch);
  }

  // Tof
  if (fDetList.FindObject("TOF") ) {
      R3BDetector* tof = new R3BTof("Tof", kTRUE);
      // Global position of the Module
      thetaX   =  0.0; // (deg)
      thetaY   =  0.0; // (deg)
      thetaZ   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx       =  0.0; // (cm)
      ty       =  0.0; // (cm)
      tz       =  0.0; // (cm)
      tof->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      tof->SetTranslation(tx,ty,tz);
      // User defined Energy CutOff
      Double_t fCutOffSci = 1.0e-05;  // Cut-Off -> 10.KeV only in Sci.
      ((R3BTof*) tof)->SetEnergyCutOff(fCutOffSci);
      run->AddModule(tof);
  }

  // mTof
  if (fDetList.FindObject("MTOF") ) {
      R3BDetector* mTof = new R3BmTof("mTof", kTRUE);
      // Global position of the Module
      phi   =  0.0; // (deg)
      theta =  0.0; // (deg)
      psi   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx    =  0.0; // (cm)
      ty    =  0.0; // (cm)
      tz    =  0.0; // (cm)
      //mTof->SetRotAnglesEuler(phi,theta,psi);
      mTof->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      mTof->SetTranslation(tx,ty,tz);
      // User defined Energy CutOff
      Double_t fCutOffSci = 1.0e-05;  // Cut-Off -> 10.KeV only in Sci.
      ((R3BmTof*) mTof)->SetEnergyCutOff(fCutOffSci);
      run->AddModule(mTof);
  }

  // GFI detector
  if (fDetList.FindObject("GFI") ) {
      R3BDetector* gfi = new R3BGfi("Gfi", kTRUE);
      // Global position of the Module
      phi   =  0.0; // (deg)
      theta =  0.0; // (deg)
      psi   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx    =  0.0; // (cm)
      ty    =  0.0; // (cm)
      tz    =  0.0; // (cm)
      gfi->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      gfi->SetTranslation(tx,ty,tz);
      // User defined Energy CutOff
      Double_t fCutOffSci = 1.0e-05;  // Cut-Off -> 10.KeV only in Sci.
      ((R3BGfi*) gfi)->SetEnergyCutOff(fCutOffSci);
      run->AddModule(gfi);
  }

  // Land Detector
  if (fDetList.FindObject("LAND") ) {
      R3BDetector* land = new R3BLand("Land", kTRUE);
      land->SetGeometryFileName("land_v12a_10m.geo.root");
      run->AddModule(land);
  }

  // Chimera
  if (fDetList.FindObject("CHIMERA") ) {
      R3BDetector* chim = new R3BChimera("Chimera", kTRUE);
      chim->SetGeometryFileName("chimera.root");
      // Global position of the Module
      thetaX   =  0.0; // (deg)
      thetaY   =  0.0; // (deg)
      thetaZ   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx       =  0.0; // (cm)
      ty       =  0.0; // (cm)
      tz       =  0.0; // (cm)
      chim->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      chim->SetTranslation(tx,ty,tz);
      // User defined Energy CutOff
      //Double_t fCutOffSci = 1.0e-05;  // Cut-Off -> 10.KeV only in Sci.
      //((R3BChimera*) chim)->SetEnergyCutOff(fCutOffSci);
      run->AddModule(chim);
  }

  // Luminosity detector
  if (fDetList.FindObject("LUMON") ) {
      R3BDetector* lumon = new ELILuMon("LuMon", kTRUE);
      //lumon->SetGeometryFileName("lumon.root");
      // Global position of the Module
      thetaX   =  0.0; // (deg)
      thetaY   =  0.0; // (deg)
      thetaZ   =  0.0; // (deg)
      // Rotation in Ref. Frame.
      thetaX =  0.0; // (deg)
      thetaY =  0.0; // (deg)
      thetaZ =  0.0; // (deg)
      // Global translation in Lab
      tx       =  0.0; // (cm)
      ty       =  0.0; // (cm)
      tz       =  200.0; // (cm)
      lumon->SetRotAnglesXYZ(thetaX,thetaY,thetaZ);
      lumon->SetTranslation(tx,ty,tz);
      // User defined Energy CutOff
      //Double_t fCutOffSci = 1.0e-05;  // Cut-Off -> 10.KeV only in Sci.
      //((ELILuMon*) lumon)->SetEnergyCutOff(fCutOffSci);
      run->AddModule(lumon);
  }


  
  // -----   Create R3B  magnetic field ----------------------------------------
  Int_t typeOfMagneticField = 0;
  Int_t fieldScale = 1;
  Bool_t fVerbose = kFALSE;

  //NB: <D.B>
  // If the Global Position of the Magnet is changed
  // the Field Map has to be transformed accordingly

  if (fFieldMap == 0) {
    R3BFieldMap* magField = new R3BFieldMap(typeOfMagneticField,fVerbose);
    magField->SetPosition(0., 0., 0.);
    magField->SetScale(fieldScale);

    if ( fR3BMagnet == kTRUE ) {
	run->SetField(magField);
    } else {
	run->SetField(NULL);
    }
  } else if(fFieldMap == 1){
    R3BGladFieldMap* magField = new R3BGladFieldMap("R3BGladMap");
    magField->SetPosition(0., 0., +350-119.94);
    magField->SetScale(fieldScale);

    if ( fR3BMagnet == kTRUE ) {
	run->SetField(magField);
    } else {
	run->SetField(NULL);
    }
  }  //! end of field map section



  // -----   Create PrimaryGenerator   --------------------------------------

  // 1 - Create the Main API class for the Generator
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();


  if (fGenerator.CompareTo("box") == 0  ) {
  // 2- Define the BOX generator
  Double_t pdgId=211; // pion beam
  Double_t theta1= 0.;  // polar angle distribution
  Double_t theta2= 7.;
  Double_t momentum=.8; // 10 GeV/c
  FairBoxGenerator* boxGen = new FairBoxGenerator(pdgId, 50);
  boxGen->SetThetaRange (   theta1,   theta2);
  boxGen->SetPRange     (momentum,momentum*2.);
  boxGen->SetPhiRange   (0.,360.);
  boxGen->SetXYZ(0.0,0.0,-1.5);
  // add the box generator
  primGen->AddGenerator(boxGen);
  } 
	
  if (fGenerator.CompareTo("gammas") == 0  ) {
	// 2- Define the CALIFA Test gamma generator
	Double_t pdgId=22; // 22 for gamma emission, 2212 for proton emission 
	Double_t theta1=minTheta;  // polar angle distribution: lower edge
	Double_t theta2=maxTheta;  // polar angle distribution: upper edge	
	Double_t momentum=fEnergyP; // GeV/c 
	//Double_t momentum=0.808065; // 0.808065 GeV/c (300MeV Kin Energy for protons) 
	//Double_t momentum=0.31016124; // 0.31016124 GeV/c (50MeV Kin Energy for protons)
	//Double_t momentum=0.4442972; // 0.4442972 GeV/c (100MeV Kin Energy for protons)
	//Double_t momentum=0.5509999; // 0.5509999 GeV/c (150MeV Kin Energy for protons)
	//Double_t momentum=0.64405; // 0.64405 GeV/c (200MeV Kin Energy for protons) 
	Int_t multiplicity = fMult;
	R3BCALIFATestGenerator* gammasGen = new R3BCALIFATestGenerator(pdgId, multiplicity);
	gammasGen->SetThetaRange(theta1,theta2);
	gammasGen->SetCosTheta();
	gammasGen->SetPRange(momentum,momentum);
        gammasGen->SetPhiRange(0.,360.);

	gammasGen->SetBoxXYZ(-0.1,0.1,-0.1,0.1,-0.1,0.1);
	gammasGen->SetLorentzBoost(0.8197505718204776); //beta=0.81975 for 700 A MeV
	// add the gamma generator
	primGen->AddGenerator(gammasGen);
  } 
	

 if (fGenerator.CompareTo("r3b") == 0  ) {
  R3BSpecificGenerator *pR3bGen = new R3BSpecificGenerator();

  // R3bGen properties
  pR3bGen->SetBeamInteractionFlag("off");
  pR3bGen->SetBeamInteractionFlag("off");
  pR3bGen->SetRndmFlag("off");
  pR3bGen->SetRndmEneFlag("off");
  pR3bGen->SetBoostFlag("off");
  pR3bGen->SetReactionFlag("on");
  pR3bGen->SetGammasFlag("off");
  pR3bGen->SetDecaySchemeFlag("off");
  pR3bGen->SetDissociationFlag("off");
  pR3bGen->SetBackTrackingFlag("off");
  pR3bGen->SetSimEmittanceFlag("off");

  // R3bGen Parameters
  pR3bGen->SetBeamEnergy(1.); // Beam Energy in GeV
  pR3bGen->SetSigmaBeamEnergy(1.e-03); // Sigma(Ebeam) GeV
  pR3bGen->SetParticleDefinition(2212); // Use Particle Pdg Code
  pR3bGen->SetEnergyPrim(0.3); // Particle Energy in MeV
  Int_t fMultiplicity = 50;
  pR3bGen->SetNumberOfParticles(fMultiplicity); // Mult.

  // Reaction type
  //        1: "Elas"
  //        2: "iso"
  //        3: "Trans"
  pR3bGen->SetReactionType("Elas");

  // Target  type
  //        1: "LeadTarget"
  //        2: "Parafin0Deg"
  //        3: "Parafin45Deg"
  //        4: "LiH"

  pR3bGen->SetTargetType(Target.Data());
  Double_t thickness = (0.11/2.)/10.;  // cm
  pR3bGen->SetTargetHalfThicknessPara(thickness); // cm
  pR3bGen->SetTargetThicknessLiH(3.5); // cm
  pR3bGen->SetTargetRadius(1.); // cm

  pR3bGen->SetSigmaXInEmittance(1.); //cm
  pR3bGen->SetSigmaXPrimeInEmittance(0.0001); //cm

  // Dump the User settings
  pR3bGen->PrintParameters();  
  primGen->AddGenerator(pR3bGen);
  }


  run->SetGenerator(primGen);


  //-------Set visualisation flag to true------------------------------------
  if (fVis==kTRUE){
     run->SetStoreTraj(kTRUE);
  }else{
     run->SetStoreTraj(kFALSE);
  }   

  // -----   Initialize simulation run   ------------------------------------
  run->Init();

  // ------  Increase nb of step for CALO
  Int_t nSteps = -15000;
  gMC->SetMaxNStep(nSteps);

  // -----   Runtime database   ---------------------------------------------
  Bool_t kParameterMerged = kTRUE;
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
  parOut->open(ParFile.Data());
  rtdb->setOutput(parOut);
  rtdb->saveOutput();
  rtdb->print();
   
  // -----   Start run   ----------------------------------------------------
  if (nEvents>0) run->Run(nEvents);
  
  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished succesfully." << endl;
  cout << "Output file is "    << OutFile << endl;
  cout << "Parameter file is " << ParFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime 
       << "s" << endl << endl;
  // ------------------------------------------------------------------------

  cout << " Test passed" << endl;
  cout << " All ok " << endl;

}
Beispiel #9
0
sim_upto_emc(Int_t nEvents = 20000)
{
  
  //-----User Settings:-----------------------------------------------
  TString  OutputFile     ="sim_complete_20k_upto_emc.root";
  TString  ParOutputfile  ="simparams_20k_upto_emc.root";
  TString  MediaFile      ="media_pnd.geo";
  gDebug                  = 0;
  TString digiFile        = "all.par"; //The emc run the hit producer directly 

  double BeamMomentum   =15.0; // ** change HERE if you run Box generator

  TString  SimEngine ="TGeant4";
  
  //------------------------------------------------------------------
  TStopwatch timer;
  timer.Start();
  gRandom->SetSeed(); 

  // Create the Simulation run manager--------------------------------
  FairRunSim *fRun = new FairRunSim();
  fRun->SetName(SimEngine.Data() );
  fRun->SetOutputFile(OutputFile.Data());
  fRun->SetWriteRunInfoFile(kFALSE);
  fRun->SetBeamMom(BeamMomentum);
  fRun->SetMaterials(MediaFile.Data());

  fRun->SetRadLenRegister(true);
  //fRun->SetRadMapRegister(true);
  //fRun->SetRadGridRegister(true);

  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
  
  // Set the parameters 
  //-------------------------------
  TString allDigiFile = gSystem->Getenv("VMCWORKDIR");
  allDigiFile += "/macro/params/";
  allDigiFile += digiFile;
 
  //-------Set the parameter output --------------------
  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1->open(allDigiFile.Data(),"in");
  rtdb->setFirstInput(parIo1);        

  //---------------------Set Parameter output      ---------- 
  Bool_t kParameterMerged=kTRUE;
  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
  output->open(ParOutputfile.Data());
  rtdb->setOutput(output);

  // Create and add detectors

  //-------------------------  CAVE      -----------------
  FairModule *Cave= new PndCave("CAVE");
  Cave->SetGeometryFileName("pndcave.geo");
  fRun->AddModule(Cave); 
  
  //-------------------------  Magnet   ----------------- 
  FairModule *Magnet= new PndMagnet("MAGNET");
  //Magnet->SetGeometryFileName("FullSolenoid_V842.root");
  Magnet->SetGeometryFileName("FullSuperconductingSolenoid_v831.root");
  fRun->AddModule(Magnet);
  FairModule *Dipole= new PndMagnet("MAGNET");
  Dipole->SetGeometryFileName("dipole.geo");
  fRun->AddModule(Dipole);
  
  //-------------------------  Pipe     -----------------
  FairModule *Pipe= new PndPipe("PIPE");
  Pipe->SetGeometryFileName("beampipe_201309.root");
  fRun->AddModule(Pipe);

  //-------------------------  STT       -----------------
  FairDetector *Stt= new PndStt("STT", kTRUE);
  Stt->SetGeometryFileName("straws_skewed_blocks_35cm_pipe.geo");
  fRun->AddModule(Stt);
  
  //-------------------------  MVD       -----------------
  FairDetector *Mvd = new PndMvdDetector("MVD", kTRUE);
  Mvd->SetGeometryFileName("Mvd-2.1_FullVersion.root");
  fRun->AddModule(Mvd);
  
  //-------------------------  GEM       -----------------
  FairDetector *Gem = new PndGemDetector("GEM", kTRUE);
  Gem->SetGeometryFileName("gem_3Stations.root");
  fRun->AddModule(Gem);
  
  //-------------------------  EMC       -----------------
  PndEmc *Emc = new PndEmc("EMC",kTRUE);
  Emc->SetGeometryVersion(1);
  Emc->SetStorageOfData(kFALSE);
  fRun->AddModule(Emc);
  
  ////-------------------------  SCITIL    -----------------
  //FairDetector *SciT = new PndSciT("SCIT",kTRUE);
  //SciT->SetGeometryFileName("barrel-SciTil_07022013.root");
  //fRun->AddModule(SciT);
  //
  ////-------------------------  DRC       -----------------
  //PndDrc *Drc = new PndDrc("DIRC", kTRUE);
  //Drc->SetGeometryFileName("dirc_l0_p0_updated.root"); 
  //Drc->SetRunCherenkov(kFALSE);
  //fRun->AddModule(Drc); 
  //
  ////-------------------------  DISC      -----------------
  //PndDsk* Dsk = new PndDsk("DSK", kTRUE);
  //Dsk->SetStoreCerenkovs(kFALSE);
  //Dsk->SetStoreTrackPoints(kFALSE);
  //fRun->AddModule(Dsk);
  //
  ////-------------------------  MDT       -----------------
  //PndMdt *Muo = new PndMdt("MDT",kTRUE);
  //Muo->SetBarrel("fast");
  //Muo->SetEndcap("fast");
  //Muo->SetMuonFilter("fast");
  //Muo->SetForward("fast");
  //Muo->SetMdtMagnet(kTRUE);
  //Muo->SetMdtMFIron(kTRUE);
  //fRun->AddModule(Muo);
  //
  ////-------------------------  FTS       -----------------
  //FairDetector *Fts= new PndFts("FTS", kTRUE);
  //Fts->SetGeometryFileName("fts.geo");
  //fRun->AddModule(Fts); 
  //
  ////-------------------------  FTOF      -----------------
  //FairDetector *FTof = new PndFtof("FTOF",kTRUE);
  //FTof->SetGeometryFileName("ftofwall.root");
  //fRun->AddModule(FTof);
  //
  ////-------------------------  RICH       ----------------
  //FairDetector *Rich= new PndRich("RICH",kFALSE);
  //Rich->SetGeometryFileName("rich_v2_shift.geo");
  //fRun->AddModule(Rich);
  
  // Create and Set Event Generator
  //-------------------------------
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
  fRun->SetGenerator(primGen);

  FairBoxGenerator* boxGen = new FairBoxGenerator(0, 1);
  boxGen->SetPRange(2.0,2.0); // GeV/c
  boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
  boxGen->SetThetaRange(0., 180.); // Polar angle in lab system range [degree]
  boxGen->SetXYZ(0., 0., 0.); // cm
  primGen->AddGenerator(boxGen);

  //---------------------Create and Set the Field(s)---------- 
  PndMultiField *fField= new PndMultiField("FULL");
  fRun->SetField(fField);

  // EMC Hit producer
  //-------------------------------
  PndEmcHitProducer* emcHitProd = new PndEmcHitProducer();
  fRun->AddTask(emcHitProd);
  
  //-------------------------  Initialize the RUN  -----------------  
  fRun->Init();
  //-------------------------  Run the Simulation  -----------------   
  fRun->Run(nEvents);
  //-------------------------  Save the parameters ----------------- 
  rtdb->saveOutput();
  //------------------------Print some info and exit----------------     
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
  
  cout << " Test passed" << endl;
  cout << " All ok " << endl;
  
  //exit(0);

}  
Beispiel #10
0
void RAA_plot_HFVs_effect(){
  
  TStopwatch timer;
  timer.Start();

  TDatime date;

  gStyle->SetOptStat(0);

  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();

  
  const int nbins_cent = 6;
  double boundaries_cent[nbins_cent+1] = {0,2,4,12,20,28,36};
  double ncoll[nbins_cent+1] = {1660,1310,745,251,62.8,10.8,362.24};
  
  TFile *fin = TFile::Open("/Users/raghavke/WORK/RAA/Output/PbPb_HF_divergence_events_spectra_VsPF_20141207.root");
  
  TH1F *hpbpb_Jet80[2][2][nbins_cent+1];
  TH1F *hpbpb_Jet65[2][2][nbins_cent+1];
  TH1F *hpbpb_Jet55[2][2][nbins_cent+1];
  TH1F *hpbpb_JetComb[2][2][nbins_cent+1];  

  TH1F *hpbpb_FullJet80[nbins_cent+1];
  TH1F *hpbpb_FullJet65[nbins_cent+1];
  TH1F *hpbpb_FullJet55[nbins_cent+1];
  TH1F *hpbpb_FullJetComb[nbins_cent+1];

  //Get the ratio histograms w.r.t the full spectra. 
  TH1F *hpbpb_Jet80_Ratio[2][2][nbins_cent+1];
  TH1F *hpbpb_Jet65_Ratio[2][2][nbins_cent+1];
  TH1F *hpbpb_Jet55_Ratio[2][2][nbins_cent+1];

  for(int i = 0;i<nbins_cent+1;i++){

    for(int a = 0;a<2;a++){

      for(int b = 0;b<2;b++){

	hpbpb_Jet80[b][a][i] = (TH1F*)fin->Get(Form("hpbpb_Jet80_isDiverge_%d_isTightCut_%d_cent%d",b,a,i));
	hpbpb_Jet80[b][a][i] = (TH1F*)hpbpb_Jet80[b][a][i]->Rebin(nbins_pt,Form("hpbpb_Jet80_isDiverge_%d_isTightCut_%d_cent%d",b,a,i),boundaries_pt);
	divideBinWidth(hpbpb_Jet80[b][a][i]);
	hpbpb_Jet65[b][a][i] = (TH1F*)fin->Get(Form("hpbpb_Jet65_isDiverge_%d_isTightCut_%d_cent%d",b,a,i));
	hpbpb_Jet65[b][a][i] = (TH1F*)hpbpb_Jet65[b][a][i]->Rebin(nbins_pt,Form("hpbpb_Jet65_isDiverge_%d_isTightCut_%d_cent%d",b,a,i),boundaries_pt);
	divideBinWidth(hpbpb_Jet65[b][a][i]);
	hpbpb_Jet55[b][a][i] = (TH1F*)fin->Get(Form("hpbpb_Jet55_isDiverge_%d_isTightCut_%d_cent%d",b,a,i));
	hpbpb_Jet55[b][a][i] = (TH1F*)hpbpb_Jet55[b][a][i]->Rebin(nbins_pt,Form("hpbpb_Jet55_isDiverge_%d_isTightCut_%d_cent%d",b,a,i),boundaries_pt);
	divideBinWidth(hpbpb_Jet55[b][a][i]);

      }

    }

    hpbpb_FullJet80[i] = (TH1F*)fin->Get(Form("hpbpb_Jet80_cent%d",i));
    hpbpb_FullJet80[i] = (TH1F*)hpbpb_FullJet80[i]->Rebin(nbins_pt,Form("hpbpb_Jet80_cent%d",i),boundaries_pt);
    divideBinWidth(hpbpb_FullJet80[i]);
    hpbpb_FullJet65[i] = (TH1F*)fin->Get(Form("hpbpb_Jet65_cent%d",i));
    hpbpb_FullJet65[i] = (TH1F*)hpbpb_FullJet65[i]->Rebin(nbins_pt,Form("hpbpb_Jet65_cent%d",i),boundaries_pt);
    divideBinWidth(hpbpb_FullJet65[i]);
    hpbpb_FullJet55[i] = (TH1F*)fin->Get(Form("hpbpb_Jet55_cent%d",i));
    hpbpb_FullJet55[i] = (TH1F*)hpbpb_FullJet55[i]->Rebin(nbins_pt,Form("hpbpb_Jet55_cent%d",i),boundaries_pt);
    divideBinWidth(hpbpb_FullJet55[i]);

    for(int a = 0;a<2;a++){

      for(int b = 0;b<2;b++){

	hpbpb_Jet80_Ratio[b][a][i] = (TH1F*)hpbpb_Jet80[b][a][i]->Clone(Form("hpbpb_Jet80_isDiverge_%d_isTightCut_%d_cent%d_Ratio_with_fullSpectra_Jet80",b,a,i));
	hpbpb_Jet80_Ratio[b][a][i]->Divide(hpbpb_FullJet80[i]);
	hpbpb_Jet65_Ratio[b][a][i] = (TH1F*)hpbpb_Jet65[b][a][i]->Clone(Form("hpbpb_Jet65_isDiverge_%d_isTightCut_%d_cent%d_Ratio_with_fullSpectra_Jet65",b,a,i));
	hpbpb_Jet65_Ratio[b][a][i]->Divide(hpbpb_FullJet65[i]);
	hpbpb_Jet55_Ratio[b][a][i] = (TH1F*)hpbpb_Jet55[b][a][i]->Clone(Form("hpbpb_Jet80_isDiverge_%d_isTightCut_%d_cent%d_Ratio_with_fullSpectra_Jet55",b,a,i));
	hpbpb_Jet55_Ratio[b][a][i]->Divide(hpbpb_FullJet55[i]);
      }

    }
    
  }// cent bin
  
  // Lets start making the plots. These plots will all be a 3x3 panel plot for the different centrality bins. 
  // plots 1,2 and 3 - show the spectra for isdiverge 1 and with and without tight cut for each Jet80 and Jet65 and Jet55 in each centrality  
  // plots 4,5 and 6 - similarly show the ratio histogram for each Jet80 and Jet65 and Jet55 in each centrailty. 

  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // plot 1 - is diverge with and without tight cuts plus the whole events list. 

  TCanvas *cJet80_Spectra = new TCanvas("cJet80_Spectra","",800,600);
  makeMultiPanelCanvas(cJet80_Spectra,3,2,0.0,0.0,0.2,0.15,0.07);

  for(int i = 0;i<nbins_cent;i++){

    cJet80_Spectra->cd(nbins_cent-i);
    cJet80_Spectra->cd(nbins_cent-i)->SetLogy();
    
    hpbpb_FullJet80[i]->SetMarkerStyle(24);
    hpbpb_FullJet80[i]->SetMarkerColor(kBlack);
    hpbpb_FullJet80[i]->SetTitle(" ");
    hpbpb_FullJet80[i]->SetXTitle("Jet p_{T} (GeV/c)");
    hpbpb_FullJet80[i]->SetYTitle("#frac{dN}{dp_{T}}");
    hpbpb_FullJet80[i]->SetAxisRange(0,500,"X");
    hpbpb_FullJet80[i]->Draw();

    hpbpb_Jet80[1][0][i]->SetMarkerStyle(25);
    hpbpb_Jet80[1][0][i]->SetMarkerColor(kRed);
    hpbpb_Jet80[1][0][i]->Draw("same");

    hpbpb_Jet80[1][1][i]->SetMarkerStyle(33);
    hpbpb_Jet80[1][1][i]->SetMarkerColor(kBlue);
    hpbpb_Jet80[1][1][i]->Draw("same");
    
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.7,0.85,20);

  }

  cJet80_Spectra->cd(1);
  putCMSPrel();

  TLegend *Jet80_spectra = myLegend(0.5,0.55,0.9,0.8);
  Jet80_spectra->AddEntry(hpbpb_FullJet80[0],"Full Spectra","pl");
  Jet80_spectra->AddEntry(hpbpb_Jet80[1][0][0],"Diverging with Loose Cut","pl");
  Jet80_spectra->AddEntry(hpbpb_Jet80[1][1][0],"Diverging with Tight Cut","pl");
  Jet80_spectra->SetTextSize(0.04);
  Jet80_spectra->Draw();
  
  drawText("Jet80 Trigger",0.5,0.4,14);
  
  cJet80_Spectra->cd(2);
  drawText("pCES,HBHE,|vz|<15",0.2,0.8,14);
  
  cJet80_Spectra->cd(3);
  drawText("supernova diagonal cut",0.2,0.8,14);
  
  cJet80_Spectra->SaveAs(Form("/Users/raghavke/WORK/RAA/Plots/HFVS_RAA_Effect_Jet80_spectra_%d.pdf",date.GetDate()),"RECREATE");
  
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // plot 2 - is diverge with and without tight cuts plus the whole events list - Jet65

  TCanvas *cJet65_Spectra = new TCanvas("cJet65_Spectra","",800,600);
  makeMultiPanelCanvas(cJet65_Spectra,3,2,0.0,0.0,0.2,0.15,0.07);

  for(int i = 0;i<nbins_cent;i++){

    cJet65_Spectra->cd(nbins_cent-i);
    cJet65_Spectra->cd(nbins_cent-i)->SetLogy();
    
    hpbpb_FullJet65[i]->SetMarkerStyle(24);
    hpbpb_FullJet65[i]->SetMarkerColor(kBlack);
    hpbpb_FullJet65[i]->SetTitle(" ");
    hpbpb_FullJet65[i]->SetXTitle("Jet p_{T} (GeV/c)");
    hpbpb_FullJet65[i]->SetYTitle("#frac{dN}{dp_{T}}");
    hpbpb_FullJet65[i]->SetAxisRange(0,500,"X");
    hpbpb_FullJet65[i]->Draw();
    
    hpbpb_Jet65[1][0][i]->SetMarkerStyle(25);
    hpbpb_Jet65[1][0][i]->SetMarkerColor(kRed);
    hpbpb_Jet65[1][0][i]->Draw("same");
    
    hpbpb_Jet65[1][1][i]->SetMarkerStyle(33);
    hpbpb_Jet65[1][1][i]->SetMarkerColor(kBlue);
    hpbpb_Jet65[1][1][i]->Draw("same");
    
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.7,0.85,20);
    
  }

  cJet65_Spectra->cd(1);
  putCMSPrel();

  TLegend *Jet65_spectra = myLegend(0.5,0.55,0.9,0.8);
  Jet65_spectra->AddEntry(hpbpb_FullJet65[0],"Full Spectra","pl");
  Jet65_spectra->AddEntry(hpbpb_Jet65[1][0][0],"Diverging with Loose Cut","pl");
  Jet65_spectra->AddEntry(hpbpb_Jet65[1][1][0],"Diverging with Tight Cut","pl");
  Jet65_spectra->SetTextSize(0.04);
  Jet65_spectra->Draw();
  
  drawText("Jet65 Trigger",0.5,0.4,14);
  
  cJet65_Spectra->cd(2);
  drawText("pCES,HBHE,|vz|<15",0.2,0.8,14);
  
  cJet65_Spectra->cd(3);
  drawText("supernova diagonal cut",0.2,0.8,14);
  
  cJet65_Spectra->SaveAs(Form("/Users/raghavke/WORK/RAA/Plots/HFVS_RAA_Effect_Jet65_spectra_%d.pdf",date.GetDate()),"RECREATE");
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // plot 3 - is diverge with and without tight cuts plus the whole events list - Jet65

  TCanvas *cJet55_Spectra = new TCanvas("cJet55_Spectra","",800,600);
  makeMultiPanelCanvas(cJet55_Spectra,3,2,0.0,0.0,0.2,0.15,0.07);

  for(int i = 0;i<nbins_cent;i++){

    cJet55_Spectra->cd(nbins_cent-i);
    cJet55_Spectra->cd(nbins_cent-i)->SetLogy();
    
    hpbpb_FullJet55[i]->SetMarkerStyle(24);
    hpbpb_FullJet55[i]->SetMarkerColor(kBlack);
    hpbpb_FullJet55[i]->SetTitle(" ");
    hpbpb_FullJet55[i]->SetXTitle("Jet p_{T} (GeV/c)");
    hpbpb_FullJet55[i]->SetYTitle("#frac{dN}{dp_{T}}");
    hpbpb_FullJet55[i]->SetAxisRange(0,500,"X");
    hpbpb_FullJet55[i]->Draw();
    
    hpbpb_Jet55[1][0][i]->SetMarkerStyle(25);
    hpbpb_Jet55[1][0][i]->SetMarkerColor(kRed);
    hpbpb_Jet55[1][0][i]->Draw("same");
    
    hpbpb_Jet55[1][1][i]->SetMarkerStyle(33);
    hpbpb_Jet55[1][1][i]->SetMarkerColor(kBlue);
    hpbpb_Jet55[1][1][i]->Draw("same");
    
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.7,0.85,20);
    
  }

  cJet55_Spectra->cd(1);
  putCMSPrel();

  TLegend *Jet55_spectra = myLegend(0.5,0.55,0.9,0.8);
  Jet55_spectra->AddEntry(hpbpb_FullJet55[0],"Full Spectra","pl");
  Jet55_spectra->AddEntry(hpbpb_Jet55[1][0][0],"Diverging with Loose Cut","pl");
  Jet55_spectra->AddEntry(hpbpb_Jet55[1][1][0],"Diverging with Tight Cut","pl");
  Jet55_spectra->SetTextSize(0.04);
  Jet55_spectra->Draw();
  
  drawText("Jet55 Trigger",0.5,0.4,14);
  
  cJet55_Spectra->cd(2);
  drawText("pCES,HBHE,|vz|<15",0.2,0.8,14);
  
  cJet55_Spectra->cd(3);
  drawText("supernova diagonal cut",0.2,0.8,14);
  
  cJet55_Spectra->SaveAs(Form("/Users/raghavke/WORK/RAA/Plots/HFVS_RAA_Effect_Jet55_spectra_%d.pdf",date.GetDate()),"RECREATE");

  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // plot 4 - Ratio plot: is diverge with and without tight cuts plus the whole events list - Jet65

  TCanvas *cJet80_Ratio = new TCanvas("cJet80_Ratio","",800,600);
  makeMultiPanelCanvas(cJet80_Ratio,3,2,0.0,0.0,0.2,0.15,0.07);

  TLine *line80 = new TLine(0,1,500,1);
  line80->SetLineStyle(2);
  line80->SetLineWidth(2);

  for(int i = 0;i<nbins_cent;i++){

    cJet80_Ratio->cd(nbins_cent-i);
    //cJet80_Ratio->cd(nbins_cent-i)->SetLogy();
    
    hpbpb_Jet80_Ratio[1][0][i]->SetMarkerStyle(25);
    hpbpb_Jet80_Ratio[1][0][i]->SetMarkerColor(kRed);
    hpbpb_Jet80_Ratio[1][0][i]->SetXTitle("Jet p_{T} (GeV/c)");
    hpbpb_Jet80_Ratio[1][0][i]->SetYTitle("Ratio with full spectra");
    hpbpb_Jet80_Ratio[1][0][i]->SetTitle(" ");
    hpbpb_Jet80_Ratio[1][0][i]->SetAxisRange(0,500,"X");
    hpbpb_Jet80_Ratio[1][0][i]->SetAxisRange(0,1,"Y");
    hpbpb_Jet80_Ratio[1][0][i]->Draw("same");
    
    hpbpb_Jet80_Ratio[1][1][i]->SetMarkerStyle(33);
    hpbpb_Jet80_Ratio[1][1][i]->SetMarkerColor(kBlue);
    hpbpb_Jet80_Ratio[1][1][i]->Draw("same");
 
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.7,0.85,20);
    
    line80->Draw();
  }

  cJet80_Ratio->cd(1);
  putCMSPrel();

  TLegend *Jet80_ratio = myLegend(0.5,0.55,0.9,0.8);
  Jet80_ratio->AddEntry(hpbpb_Jet80[1][0][0],"Diverging with Loose Cut","pl");
  Jet80_ratio->AddEntry(hpbpb_Jet80[1][1][0],"Diverging with Tight Cut","pl");
  Jet80_ratio->SetTextSize(0.04);
  Jet80_ratio->Draw();
  
  drawText("Jet80 Trigger",0.5,0.4,14);
  
  cJet80_Ratio->cd(2);
  drawText("pCES,HBHE,|vz|<15",0.2,0.8,14);
  drawText("Ratio plots with full spectra",0.15,0.7,14);
  
  cJet80_Ratio->cd(3);
  drawText("supernova diagonal cut",0.2,0.8,14);
  
  cJet80_Ratio->SaveAs(Form("/Users/raghavke/WORK/RAA/Plots/HFVS_RAA_Effect_Jet80_ratio_%d.pdf",date.GetDate()),"RECREATE");
  
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  // plot 5 - Ratio plot: is diverge with and without tight cuts plus the whole events list - Jet65

  TCanvas *cJet65_Ratio = new TCanvas("cJet65_Ratio","",800,600);
  makeMultiPanelCanvas(cJet65_Ratio,3,2,0.0,0.0,0.2,0.15,0.07);

  TLine *line65 = new TLine(0,1,500,1);
  line65->SetLineStyle(2);
  line65->SetLineWidth(2);

  for(int i = 0;i<nbins_cent;i++){

    cJet65_Ratio->cd(nbins_cent-i);
    //cJet65_Ratio->cd(nbins_cent-i)->SetLogy();
    
    hpbpb_Jet65_Ratio[1][0][i]->SetMarkerStyle(25);
    hpbpb_Jet65_Ratio[1][0][i]->SetMarkerColor(kRed);
    hpbpb_Jet65_Ratio[1][0][i]->SetXTitle("Jet p_{T} (GeV/c)");
    hpbpb_Jet65_Ratio[1][0][i]->SetYTitle("Ratio with full spectra");
    hpbpb_Jet65_Ratio[1][0][i]->SetTitle(" ");
    hpbpb_Jet65_Ratio[1][0][i]->SetAxisRange(0,500,"X");
    hpbpb_Jet65_Ratio[1][0][i]->SetAxisRange(0,1,"Y");
    hpbpb_Jet65_Ratio[1][0][i]->Draw("same");
    
    hpbpb_Jet65_Ratio[1][1][i]->SetMarkerStyle(33);
    hpbpb_Jet65_Ratio[1][1][i]->SetMarkerColor(kBlue);
    hpbpb_Jet65_Ratio[1][1][i]->Draw("same");
 
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.7,0.85,20);
    
    line65->Draw();
  }

  cJet65_Ratio->cd(1);
  putCMSPrel();

  TLegend *Jet65_ratio = myLegend(0.5,0.55,0.9,0.8);
  Jet65_ratio->AddEntry(hpbpb_Jet65[1][0][0],"Diverging with Loose Cut","pl");
  Jet65_ratio->AddEntry(hpbpb_Jet65[1][1][0],"Diverging with Tight Cut","pl");
  Jet65_ratio->SetTextSize(0.04);
  Jet65_ratio->Draw();
  
  drawText("Jet65 Trigger",0.5,0.4,14);
  
  cJet65_Ratio->cd(2);
  drawText("pCES,HBHE,|vz|<15",0.2,0.8,14);
  drawText("Ratio plots with full spectra",0.15,0.7,14);
  
  cJet65_Ratio->cd(3);
  drawText("supernova diagonal cut",0.2,0.8,14);
  
  cJet65_Ratio->SaveAs(Form("/Users/raghavke/WORK/RAA/Plots/HFVS_RAA_Effect_Jet65_ratio_%d.pdf",date.GetDate()),"RECREATE");


  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  // plot 6 - Ratio plot: is diverge with and without tight cuts plus the whole events list - Jet55

  TCanvas *cJet55_Ratio = new TCanvas("cJet55_Ratio","",800,600);
  makeMultiPanelCanvas(cJet55_Ratio,3,2,0.0,0.0,0.2,0.15,0.07);

  TLine *line55 = new TLine(0,1,500,1);
  line55->SetLineStyle(2);
  line55->SetLineWidth(2);

  for(int i = 0;i<nbins_cent;i++){

    cJet55_Ratio->cd(nbins_cent-i);
    //cJet55_Ratio->cd(nbins_cent-i)->SetLogy();
    
    hpbpb_Jet55_Ratio[1][0][i]->SetMarkerStyle(25);
    hpbpb_Jet55_Ratio[1][0][i]->SetMarkerColor(kRed);
    hpbpb_Jet55_Ratio[1][0][i]->SetXTitle("Jet p_{T} (GeV/c)");
    hpbpb_Jet55_Ratio[1][0][i]->SetYTitle("Ratio with full spectra");
    hpbpb_Jet55_Ratio[1][0][i]->SetTitle(" ");
    hpbpb_Jet55_Ratio[1][0][i]->SetAxisRange(0,500,"X");
    hpbpb_Jet55_Ratio[1][0][i]->SetAxisRange(0,1.1,"Y");
    hpbpb_Jet55_Ratio[1][0][i]->Draw("same");
    
    hpbpb_Jet55_Ratio[1][1][i]->SetMarkerStyle(33);
    hpbpb_Jet55_Ratio[1][1][i]->SetMarkerColor(kBlue);
    hpbpb_Jet55_Ratio[1][1][i]->Draw("same");
 
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.7,0.85,20);
    
    line55->Draw();
  }

  cJet55_Ratio->cd(1);
  putCMSPrel();

  TLegend *Jet55_ratio = myLegend(0.5,0.55,0.9,0.8);
  Jet55_ratio->AddEntry(hpbpb_Jet55[1][0][0],"Diverging with Loose Cut","pl");
  Jet55_ratio->AddEntry(hpbpb_Jet55[1][1][0],"Diverging with Tight Cut","pl");
  Jet55_ratio->SetTextSize(0.04);
  Jet55_ratio->Draw();
  
  drawText("Jet55 Trigger",0.5,0.4,14);
  
  cJet55_Ratio->cd(2);
  drawText("pCES,HBHE,|vz|<15",0.2,0.8,14);
  drawText("Ratio plots with full spectra",0.15,0.7,14);
  
  cJet55_Ratio->cd(3);
  drawText("supernova diagonal cut",0.2,0.8,14);
  
  cJet55_Ratio->SaveAs(Form("/Users/raghavke/WORK/RAA/Plots/HFVS_RAA_Effect_Jet55_ratio_%d.pdf",date.GetDate()),"RECREATE");

  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  

  //
  timer.Stop();
  cout<<" Total time taken CPU(mins) = "<<(Float_t)timer.CpuTime()/60<<endl;
  cout<<" Total time taken Real(mins) = "<<(Float_t)timer.RealTime()/60<<endl;


}// macro main
int Analyzeforest_jec_pp2013(const char *ksp="pp")
{

    timer.Start();

    std::string inname="";
    int knj = kAlgos;
    if(strcmp(ksp,"pp")==0)inname="dijet_pp_mergedpthatbins_prod22v18MC.root";
    else {
        inname="dijet_pp_mergedpthatbins_embedpp.root";
        knj = 12;
    }
    TFile *fin = new TFile(inname.c_str(),"r");

    std::string outname="";
    if(strcmp(ksp,"pp")==0)outname="JetResponse_histos_prod22v81_pp.root";
    else outname="JetResponse_histos_JECv14_embeded_pp_cent.root";
    TFile *fout = new TFile(outname.c_str(),"RECREATE");

    std::cout<<"\t"<<std::endl;
    std::cout<<"\t"<<std::endl;
    std::cout<<"**************************************************** "<<std::endl;
    std::cout<<Form("Analyzeforest_jec : %s",ksp)<<std::endl;
    std::cout<<Form("eta cut for %0.3f ",ketacut)<<std::endl;
    std::cout<<"**************************************************** "<<std::endl;
    std::cout<<"\t"<<std::endl;
    std::cout<<"\t"<<std::endl;


    //!
    //! Define histograms here
    //   TH1::SetDefaultSumw2();
    //   TH2::SetDefaultSumw2();
    //   TH3::SetDefaultSumw2();
    //  TProfile::SetDefaultSumw2();

    ////////////////////////////////////////////////////////////////////////////////////////////////////////
    TH1F *hBin    = new TH1F("hBin","Centrality bin",200,-0.5,200-0.5);
    hBin->Sumw2();
    TH1F *hpthat  = new TH1F("hpthat","pt-hat distribution",500,0,1000);
    hpthat->Sumw2();

    TH2F *hrajptrpt [knj][ncent];

    //! Gen matched jets
    TH1F *hgenpt_genm [knj][ncent], *hrecopt_genm[knj][ncent], *hrawpt_genm[knj][ncent];
    TH1F *hjeteta     [knj][ncent], *hjetphi     [knj][ncent];
    TH2F *hjetpteta   [knj][ncent], *hjetptphi   [knj][ncent], *hjetetaphi [knj][ncent];

    //! Ratios of the pt distributions
    TProfile *hrecogen[knj][ncent], *hrecoraw[knj][ncent], *hrawgen[knj][ncent];

    //! Resposnse
    TH2F *hrescrpt_genm [knj][ncent], *hresrrpt_genm [knj][ncent], *hresrcrpt_genm [knj][ncent];
    TH3F *hrescreta_genm[knj][ncent], *hresrreta_genm[knj][ncent], *hresrcreta_genm[knj][ncent];
    TH3F *hrescrphi_genm[knj][ncent], *hresrrphi_genm[knj][ncent], *hresrcrphi_genm[knj][ncent];
    TH2F *hratiorawrefpt_eta[knj][ncent][2], *hratiocorrrefpt_eta[knj][ncent][2];

    TH2F *hratiocorrrefpt_genm[knj][ncent];

    TH2F *hpteta[knj][ncent][maxe] ;
    TH2F *hptphi[knj][ncent][maxph] ;

    TH2F *hgenjrecoj[knj][ncent];
    TH2F *hgenjrawj [knj][ncent];

    //! Background jet pt
    TH2F *hjbkgComb[knj][ncent];


    //! For comparison with data
    TH2F *hJetEnergyScale[knj][ncent];


    //! Efficency histos
    TH1F *hPtAll [knj][ncent], *hPtSel[knj][ncent];
    TH1F *hEtaAll[knj][ncent], *hEtaSel[knj][ncent];
    TH1F *hPhiAll[knj][ncent], *hPhiSel[knj][ncent];


    for(int nj=0; nj<knj; nj++) {
        for(int ic=0; ic<ncent; ic++) {

            hgenpt_genm [nj][ic] = new TH1F(Form("hgenpt_genm%d_%d",nj,ic),Form("Gen matched gen p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000);
            hgenpt_genm [nj][ic]->Sumw2();
            hrecopt_genm[nj][ic] = new TH1F(Form("hrecopt_genm%d_%d",nj,ic),Form("Gen matched reco p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000);
            hrecopt_genm[nj][ic]->Sumw2();
            hrawpt_genm [nj][ic] = new TH1F(Form("hrawpt_genm%d_%d",nj,ic),Form("Gen matched raw p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000);
            hrawpt_genm [nj][ic]->Sumw2();

            hjbkgComb[nj][ic] = new TH2F(Form("hjbkgComb%d_%d",nj,ic),Form("jet background distribution jet centb %d %s",ic,calgo[nj]),500,0,1000,500,0.,250.);
            hjbkgComb[nj][ic]->Sumw2();

            //! Ratios
            hrecogen[nj][ic] = new TProfile(Form("hrecogen%d_%d",nj,ic),Form("reco/gen p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000);
            hrecogen[nj][ic]->Sumw2();
            hrecoraw[nj][ic] = new TProfile(Form("hrecoraw%d_%d",nj,ic),Form("reco/raw p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000);
            hrecoraw[nj][ic]->Sumw2();
            hrawgen[nj][ic]  = new TProfile(Form("hrawgen%d_%d",nj,ic),Form("raw/gen p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000);
            hrawgen[nj][ic]->Sumw2();

            //! Gen matched Response and resolution
            hrescrpt_genm[nj][ic]= new TH2F(Form("hrescrpt_genm%d_%d",nj,ic),Form("Gen jet:(Reco/Gen) jet p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000,150,rbinl,rbinh);
            hrescrpt_genm[nj][ic]->Sumw2();
            hresrrpt_genm[nj][ic]= new TH2F(Form("hresrrpt_genm%d_%d",nj,ic),Form("Gen jet:(Raw/Gen) jet p_{T}  distribution jet centb %d %s",ic,calgo[nj]),500,0,1000,150,rbinl,rbinh);
            hresrrpt_genm[nj][ic]->Sumw2();
            hresrcrpt_genm[nj][ic]= new TH2F(Form("hresrcrpt_genm%d_%d",nj,ic),Form("Reco jet:(Reco/Raw) jet p_{T} distribution jet centb %d %s",ic,calgo[nj]),500,0,1000,150,rbinl,rbinh);
            hresrcrpt_genm[nj][ic]->Sumw2();

            //! Gen matched response and resolutions in different eta bins
            hrescreta_genm[nj][ic]  = new TH3F(Form("hrescreta_genm%d_%d",nj,ic),Form("Gen jet:(Reco/Gen) jet p_{T} distribution jet centb %d %s",ic,calgo[nj])  ,50,-2.5,2.5,500,0,1000,rbins,rbinl,rbinh);
            hrescreta_genm[nj][ic]->Sumw2();
            hresrreta_genm[nj][ic]  = new TH3F(Form("hresrreta_genm%d_%d",nj,ic),Form("Gen jet:(Raw/Gen) jet p_{T}  distribution jet centb %d %s",ic,calgo[nj])  ,50,-2.5,2.5,500,0,1000,rbins,rbinl,rbinh);
            hresrreta_genm[nj][ic]->Sumw2();
            hresrcreta_genm[nj][ic] = new TH3F(Form("hresrcreta_genm%d_%d",nj,ic),Form("Reco jet:(Reco/Raw) jet p_{T} distribution jet centb %d %s",ic,calgo[nj]),50,-2.5,2.5,500,0,1000,rbins,rbinl,rbinh);
            hresrcreta_genm[nj][ic]->Sumw2();

            //! Gen matched response and resolutions in different phi bins
            hrescrphi_genm[nj][ic]  = new TH3F(Form("hrescrphi_genm%d_%d",nj,ic),Form("Gen jet:(Reco/Gen) jet p_{T} distribution jet centb %d %s",ic,calgo[nj])  ,72,-pi,pi,500,0,1000,rbins,rbinl,rbinh);
            hrescrphi_genm[nj][ic]->Sumw2();
            hresrrphi_genm[nj][ic]  = new TH3F(Form("hresrrphi_genm%d_%d",nj,ic),Form("Gen jet:(Raw/Gen) jet p_{T}  distribution jet centb %d %s",ic,calgo[nj])  ,72,-pi,pi,500,0,1000,rbins,rbinl,rbinh);
            hresrrphi_genm[nj][ic]->Sumw2();
            hresrcrphi_genm[nj][ic] = new TH3F(Form("hresrcrphi_genm%d_%d",nj,ic),Form("Reco jet:(Reco/Raw) jet p_{T} distribution jet centb %d %s",ic,calgo[nj]),72,-pi,pi,500,0,1000,rbins,rbinl,rbinh);
            hresrcrphi_genm[nj][ic]->Sumw2();

            hjeteta[nj][ic] = new TH1F(Form("hjeteta%d_%d",nj,ic),Form("jet eta distribution jet centb %d %s",ic,calgo[nj]),72,-ketacut,ketacut);
            hjeteta[nj][ic]->Sumw2();
            hjetphi[nj][ic] = new TH1F(Form("hjetphi%d_%d",nj,ic),Form("jet phi distribution jet centb %d %s",ic,calgo[nj]),72,-pi,pi);
            hjetphi[nj][ic]->Sumw2();

            hjetetaphi[nj][ic] = new TH2F(Form("hjetetaphi%d_%d",nj,ic),Form("jet eta-phi distribution jet centb %d %s",ic,calgo[nj]),72,-ketacut,ketacut,72,-pi,pi);
            hjetetaphi[nj][ic] ->Sumw2();
            hjetpteta[nj][ic] = new TH2F(Form("hjetpteta%d_%d",nj,ic),Form("jet pt-eta distribution jet centb %d %s",ic,calgo[nj]),500,0,1000,72,-ketacut,ketacut);
            hjetpteta[nj][ic]->Sumw2();
            hjetptphi[nj][ic] = new TH2F(Form("hjetptphi%d_%d",nj,ic),Form("jet pt-phi distribution jet centb %d %s",ic,calgo[nj]),500,0,1000,72,-pi,pi);
            hjetptphi[nj][ic]->Sumw2();

            hratiocorrrefpt_genm[nj][ic]= new TH2F(Form("hratiocorrrefpt_genm%d_%d",nj,ic),Form("Gen matched jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",ic,calgo[nj]),
                                                   500,0,1000,rbins,rbinl,rbinh);
            hratiocorrrefpt_genm[nj][ic]->Sumw2();

            for(int ie=0; ie<2; ie++) {
                hratiorawrefpt_eta[nj][ic][ie]= new TH2F(Form("hratiorawrefpt_eta%d_%d_%d",nj,ic,ie),
                        Form("Raw jet / Gen jet p_{T} (raw) distribution jet centb %d %s etabin%d",ic,calgo[nj],ie),
                        500,0,1000,rbins,rbinl,rbinh);
                hratiorawrefpt_eta[nj][ic][ie]->Sumw2();
                hratiocorrrefpt_eta[nj][ic][ie]= new TH2F(Form("hratiocorrrefpt_eta%d_%d_%d",nj,ic,ie),
                        Form("Reco jet / Gen jet p_{T} (raw) distribution jet centb %d %s etabin%d",ic,calgo[nj],ie),
                        500,0,1000,rbins,rbinl,rbinh);
                hratiocorrrefpt_eta[nj][ic][ie]->Sumw2();
            }

            for(int m=0; m<maxe; m++) {
                hpteta[nj][ic][m] = new TH2F(Form("hpteta%d_%d_%d",nj,ic,m),Form("resolution  pt(eta) distribution cent %d jet %s etabin%d",ic,calgo[nj],m),
                                             500,0,1000,rbins,rbinl,rbinh);
                hpteta[nj][ic][m]->Sumw2();
            }

            for(int m=0; m<maxph; m++) {
                hptphi[nj][ic][m] = new TH2F(Form("hptphi%d_%d_%d",nj,ic,m),Form("resolution pt(phi) distribution cent %d jet %s phibin%d",ic,calgo[nj],m),
                                             500,0,1000,rbins,rbinl,rbinh);
                hptphi[nj][ic][m]->Sumw2();
            }

            hgenjrecoj[nj][ic] =new TH2F(Form("hgenjrecoj%d_%d",nj,ic),Form("gen jet2 : reco jet2 %s cent %d",calgo[nj],ic),500,0.,1000.,500,0.,1000.);
            hgenjrecoj[nj][ic]->Sumw2();


            hgenjrawj[nj][ic] =new TH2F(Form("hgenjrawj%d_%d",nj,ic),Form("gen jet2 : raw jet2 %s cent %d",calgo[nj],ic),500,0.,1000.,500,0.,1000.);
            hgenjrawj[nj][ic]->Sumw2();

            hrajptrpt[nj][ic] = new TH2F(Form("hrajptrpt%d_%d",nj,ic),Form("corr pT / jet(raw pt) p_{T} distribution %d jet %s",ic,calgo[nj]),500,0,1000,50,0,10);
            hrajptrpt[nj][ic]->Sumw2();

            hJetEnergyScale[nj][ic] = new TH2F(Form("hJetEnergyScale%d_%d",nj,ic),Form("hJetEnergyScale%d_%d",nj,ic),500,0,1000,50,-1.00,1.00);
            hJetEnergyScale[nj][ic]->Sumw2();

            //! efficcy histograms
            hPtAll [nj][ic] = new TH1F(Form("hPtAll%d_%d",nj,ic),Form("Denominator pT for algorithm %s cent %d",calgo[nj],ic),40,10,110);
            hEtaAll[nj][ic] = new TH1F(Form("hEtaAll%d_%d",nj,ic),Form("Denominator eta  for algorithm %s cent %d",calgo[nj],ic),20,-ketacut,ketacut);
            hPhiAll[nj][ic] = new TH1F(Form("hPhiAll%d_%d",nj,ic),Form("Denominator  phi  for algorithm %s cent %d",calgo[nj],ic),20,-pi,pi);

            hPtSel [nj][ic] = new TH1F(Form("hPtSel%d_%d",nj,ic),Form("Numerator pT for algorithm %s cent %d",calgo[nj],ic),40,10,110);
            hEtaSel[nj][ic] = new TH1F(Form("hEtaSel%d_%d",nj,ic),Form("Numerator eta  for algorithm %s cent %d",calgo[nj],ic),20,-ketacut,ketacut);
            hPhiSel[nj][ic] = new TH1F(Form("hPhiSel%d_%d",nj,ic),Form("Numerator  phi  for algorithm %s cent %d",calgo[nj],ic),20,-pi,pi);


        }//! ic
    }//! nj
    std::cout<<"Initialized the histograms " <<std::endl;
    /////////////////////////////////////////////////////////////////////////////////////////


    TTree *tr_in=0;
    std::vector<double> vJets;
    Long64_t nbytes=0;

    double nevt [kAlgos][ncent]= {{0}};
    double njets[kAlgos][ncent]= {{0}};

    for(int nj=0; nj<knj; nj++) {

        tr_in = (TTree*)fin->Get(Form("%sJetAnalyzer/t",calgo[nj]));
        Long64_t nentries = tr_in->GetEntries();
        std::cout<<Form("# of entries in TTree for %s %s : ",calgo[nj],ksp)<<nentries<<std::endl;
        std::cout<<std::endl;

        //Declaration of leaves types
        int hiBin;
        int   nref;
        float pthat;
        float weight;
        float corrpt[1000];
        float jtpt[1000];
        float rawpt[1000];
        float jteta[1000];
        float jtphi[1000];
        float refpt[1000];
        float refeta[1000];
        float refphi[1000];
        float refdrjt[1000];
        float chargedMax[1000];
        float chargedSum[1000];
        float photonSum [1000];
        float neutralSum[1000];
        float refparton_pt[1000];
        int subid[1000];

        tr_in->SetBranchAddress("hiBin",&hiBin);
        tr_in->SetBranchAddress("nref",&nref);
        tr_in->SetBranchAddress("pthat",&pthat);
        tr_in->SetBranchAddress("weight",&weight);
        tr_in->SetBranchAddress("rawpt",rawpt);
        tr_in->SetBranchAddress("corrpt",corrpt);
        tr_in->SetBranchAddress("jtpt",jtpt);  //! this is also raw pt
        tr_in->SetBranchAddress("jteta",jteta);
        tr_in->SetBranchAddress("jtphi",jtphi);
        tr_in->SetBranchAddress("refpt",refpt);
        tr_in->SetBranchAddress("refphi",refphi);
        tr_in->SetBranchAddress("refeta",refeta);
        tr_in->SetBranchAddress("refdrjt",refdrjt);
        tr_in->SetBranchAddress("refparton_pt",refparton_pt);
        tr_in->SetBranchAddress("subid",subid);
        if(strcmp(ksp,"pp")!=0) {
            tr_in->SetBranchAddress("chargedMax",chargedMax);
            tr_in->SetBranchAddress("chargedSum",chargedSum);
            tr_in->SetBranchAddress("photonSum",photonSum);
            tr_in->SetBranchAddress("neutralSum",neutralSum);
        }

        //! Load the jet energy correction factors on fly
//     string L2Name, L3Name;
//     JetCorrectorParameters *parHI_l2=0, *parHI_l3=0;
//     vector<JetCorrectorParameters> vpar_HI;
//     FactorizedJetCorrector *_JEC_HI = new FactorizedJetCorrector(vpar_HI);//JR


//      L2Name = "/net/hisrv0001/home/pawan/Validation/Track8_Jet19/combinePtHatBins/ppJEC2014/JECv14/HI_PythiaZ2_2760GeV_5316_v14_L2Relative_"+corrFileName[nj]+"_offline.txt";
//      cout<<"**** ++++++  L2Name "<<L2Name<<endl;
//      L3Name = "/net/hisrv0001/home/pawan/Validation/Track8_Jet19/combinePtHatBins/ppJEC2014/JECv14/HI_PythiaZ2_2760GeV_5316_v14_L3Absolute_"+corrFileName[nj]+"_offline.txt";
//      cout<<"**** ++++++  L3Name "<<L3Name<<endl;

//     L2Name = "/net/hisrv0001/home/pawan/Validation/Track8_Jet19/CMSSW_5_3_16/src/JEC_base/pp2014/txtfiles/JEC_STARTHI53_LV1_Track8_Jet22_dijet_L2Relative_"+corrFileName[nj]+".txt";
//     cout<<"**** ++++++  L2Name "<<L2Name<<endl;
//     L3Name = "/net/hisrv0001/home/pawan/Validation/Track8_Jet19/CMSSW_5_3_16/src/JEC_base/pp2014/txtfiles/JEC_STARTHI53_LV1_Track8_Jet22_dijet_L3Absolute_"+corrFileName[nj]+".txt";
//     cout<<"**** ++++++  L3Name "<<L3Name<<endl;



//     parHI_l2 = new JetCorrectorParameters(L2Name.c_str());
//     parHI_l3 = new JetCorrectorParameters(L3Name.c_str());

//     vpar_HI.push_back(*parHI_l2);
//     vpar_HI.push_back(*parHI_l3);
//     _JEC_HI = new FactorizedJetCorrector(vpar_HI);


        Int_t iEvent=0;
        for (Long64_t i=0; i<nentries; i++) {
            nbytes += tr_in->GetEntry(i);
            //return 0;

            int icent=-1;
            double wcen=1;
            double wvz=1;
            //! weight  for the merging of the samples for different pT hat bins
            double wxs = weight;

            if(strcmp(ksp,"pp")==0) {
                icent=0;
            } else {
                icent = GetCentBin(hiBin);
            }
            //! MinBias
            //icent=0;

            if(i%10000==0)std::cout<<" ********** Event # " <<i<<"\t weight  : "<<weight<<"\t pthat : "<<pthat<<std::endl;
            hBin->Fill(hiBin,wxs*wcen*wvz);

            //! Centrality
            if(icent<0 || icent>=ncent ) {
                //std::cout<<" Something wrong !!!!!  : "  << icent << "\t hiBin : "<< hiBin << " \t event " << i << std::endl;
                continue;
            }
            //! xsec-weight
            hpthat->Fill(pthat,wxs*wcen*wvz);
            nevt[nj][icent]++;

//       //! Jet energy scale comparison with data
//       vJets.clear();
//       for(int igen=0; igen<nref; igen++){
// 	int gj = igen;

// 	if(subid[gj] != 0 || refparton_pt[gj]==-999)continue;

// 	_JEC_HI->setJetEta(jteta[gj]);
// 	_JEC_HI->setJetPt (rawpt[gj]);

// 	//float recopt  = corrpt[gj];
// 	float recopt  = rawpt[gj]*_JEC_HI->getCorrection();  //! correction with JECv14
// 	if(recopt<80 && fabs(jteta[gj])>1.4 && fabs(refdrjt[gj])>kdRcut)continue;
// 	vJets.push_back(recopt);
//       }
//       if(vJets.size()>=2){
// 	std::sort(vJets.begin(),vJets.end());
// 	double B=-9999;
// 	double rn1 = gRandom->Rndm();
// 	double rn2 = gRandom->Rndm();
// 	double ptdij = (vJets[0] + vJets[1])/2.;
// 	if(rn1 > rn2){
// 	  B = (vJets[0] - vJets[1])/(vJets[0] + vJets[1]);
// 	}else{
// 	  B = (vJets[1] - vJets[0])/(vJets[1] + vJets[0]);
// 	}
// 	if(B!=-9999)hJetEnergyScale[nj][icent]->Fill(ptdij,B,wxs*wcen*wvz);
//       }


            //! Gen matched jets loop
            for(int igen=0; igen<nref; igen++) {
                int gj = igen;

                if(subid[gj] != 0)continue;

                //! Reconstruction
                if(fabs(refeta[gj]) < ketacut && refpt[gj]>15) {
                    //! Denominator for reconstruction efficiency
                    hPtAll [nj][icent]->Fill(refpt[gj],wxs*wcen*wvz);
                    hEtaAll[nj][icent]->Fill(refeta[gj],wxs*wcen*wvz);
                    hPhiAll[nj][icent]->Fill(refphi[gj],wxs*wcen*wvz);
                }


                //_JEC_HI->setJetEta(jteta[gj]);
                //_JEC_HI->setJetPt (rawpt[gj]);

                float recopt  = corrpt[gj];
                //float recopt  = rawpt[gj]*_JEC_HI->getCorrection();  //! correction with JECv14
                float recoeta = jteta[gj];
                float recophi = jtphi[gj];
                float delr    = refdrjt[gj];

                if(recopt<kptrecocut || refpt[gj]<kptgencut || refpt[gj]==0 || fabs(recoeta)>ketacut || fabs(delr)>kdRcut)continue;

                if(fabs(refeta[gj])<ketacut && refpt[gj]>15) {
                    //! Numerator for reconstrunction efficiency
                    hPtSel [nj][icent]->Fill(refpt [gj],wxs*wcen*wvz);
                    hEtaSel[nj][icent]->Fill(refeta[gj],wxs*wcen*wvz);
                    hPhiSel[nj][icent]->Fill(refphi[gj],wxs*wcen*wvz);
                }


                if(strcmp(ksp,"pp")!=0) {
                    double jetbkgd = (chargedSum[gj] + photonSum[gj] + neutralSum[gj]) - rawpt[gj];
                    hjbkgComb[nj][icent]->Fill(recopt,jetbkgd,wxs*wcen*wvz);
                }

                hgenjrecoj [nj][icent]->Fill(refpt[gj],recopt,wxs*wcen*wvz);
                hgenjrawj  [nj][icent]->Fill(refpt[gj],rawpt[gj],wxs*wcen*wvz);

                hratiocorrrefpt_genm[nj][icent]->Fill(refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                hrecogen[nj][icent]->Fill(refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                hrecoraw[nj][icent]->Fill(recopt,recopt/rawpt[gj],wxs*wcen*wvz);
                hrawgen [nj][icent]->Fill(refpt[gj],rawpt[gj]/refpt[gj],wxs*wcen*wvz);


                njets[nj][icent]++;


                int ieta=-1;
                if(fabs(recoeta)<1.3)ieta=0; //! barrel region
                else ieta=1; //! HCAL region


                //! Response in eta
                hratiocorrrefpt_eta[nj][icent][ieta]->Fill(refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                hratiorawrefpt_eta [nj][icent][ieta]->Fill(refpt[gj],rawpt[gj]/refpt[gj],wxs*wcen*wvz);

                //! Ratio of recopT / rawpT
                hrajptrpt[nj][icent] ->Fill(recopt,recopt/rawpt[gj],wxs*wcen*wvz);

                //! Jet eta, phi, pt, eta-pt, eta-phi and pt-phi
                hjeteta   [nj][icent]->Fill(jteta[gj],wxs*wcen*wvz);
                hjetphi   [nj][icent]->Fill(jtphi[gj],wxs*wcen*wvz);
                hjetpteta [nj][icent]->Fill(recopt,jteta[gj],wxs*wcen*wvz);
                hjetptphi [nj][icent]->Fill(jtpt[gj],jtphi[gj],wxs*wcen*wvz);
                hjetetaphi[nj][icent]->Fill(jteta[gj],jtphi[gj],wxs*wcen*wvz);

                hgenpt_genm [nj][icent]->Fill(refpt[gj],wxs*wcen*wvz);
                hrecopt_genm[nj][icent]->Fill(recopt,wxs*wcen*wvz);
                hrawpt_genm [nj][icent]->Fill(rawpt[gj],wxs*wcen*wvz);

                //! Very fine bin in ref pt used for response
                hrescrpt_genm [nj][icent]->Fill(refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                hresrrpt_genm [nj][icent]->Fill(refpt[gj],rawpt[gj]/refpt[gj],wxs*wcen*wvz);
                hresrcrpt_genm[nj][icent]->Fill(recopt,recopt/rawpt[gj],wxs*wcen*wvz);

                //! Very fine bin in ref eta used for response
                hrescreta_genm [nj][icent]->Fill(refeta[gj],refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                hresrreta_genm [nj][icent]->Fill(refeta[gj],refpt[gj],rawpt[gj]/refpt[gj],wxs*wcen*wvz);
                hresrcreta_genm[nj][icent]->Fill(recoeta,refpt[gj],recopt/rawpt[gj],wxs*wcen*wvz);

                //! Very fine bin in ref phi used for response
                hrescrphi_genm [nj][icent]->Fill(refphi[gj],refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                hresrrphi_genm [nj][icent]->Fill(refphi[gj],refpt[gj],rawpt[gj]/refpt[gj],wxs*wcen*wvz);
                hresrcrphi_genm[nj][icent]->Fill(recophi,refpt[gj],recopt/rawpt[gj],wxs*wcen*wvz);

                //! Response in different eta and phi bins
                int etabin = GetEtaBin(fabs(refeta[gj]));
                int phibin = GetPhiBin(refphi[gj]);

                //! Response in eta and phi bins
                if(etabin >= 0 && etabin<maxe) {
                    hpteta[nj][icent][etabin]->Fill(refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                }
                if(phibin >= 0 && phibin<maxph) {
                    hptphi[nj][icent][phibin]->Fill(refpt[gj],recopt/refpt[gj],wxs*wcen*wvz);
                }

            }//! igen loop


            iEvent++;
            //std::cout<<"Completed event #  "<<ievt<<std::endl;

        }//! event loop ends

        //delete parHI_l2;
        //delete parHI_l3;
        //delete _JEC_HI;

    }//! jet loop

    std::cout<<std::endl;
    for(int nj=0; nj<knj; nj++) {
        std::cout<<calgo[nj] << std::endl;
        if(strcmp(ksp,"pp")==0) {
            std::cout<<"\t # of events : "<< " pp " << "  " << nevt[nj][0] << "  " << njets[nj][0] << std::endl;
        }
        else {
            for(int ic=0; ic<ncent; ic++) {
                std::cout<<"\t # of events : "<< ccent[ic] << "  " << nevt[nj][ic] << "  " << njets[nj][ic] << std::endl;
            }
        }
        std::cout<<std::endl;
    }
    std::cout<<std::endl;



    //! Write to output file
    fout->cd();
    fout->Write();
    fout->Close();


    //! Check
    timer.Stop();
    double rtime  = timer.RealTime();
    double ctime  = timer.CpuTime();

    std::cout<<std::endl;
    std::cout<<Form("RealTime=%f seconds, CpuTime=%f seconds",rtime,ctime)<<std::endl;
    std::cout<<std::endl;
    std::cout<<"Good bye : " <<"\t"<<std::endl;
    return 1;
}
void relativeresponsept() {
  TStopwatch timer;
  timer.Start();
  for (int radius_counter = 0; radius_counter < number_of_radii; radius_counter++) { //RADIUS LOOP
    radius = radius_array[radius_counter];
    cout << "Radius = " << radius << endl;
    TFile *montecarlo1 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponsemc.root",radius), "Read"); // 100 TO 140 PT AVERAGE
    TFile *montecarlo2 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponsemc1.root",radius), "Read"); // 80 TO 100 PT AVERAGE
    TFile *montecarlo3 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponsemc12.root",radius), "Read"); // 140 TO 200 PT AVERAGE
    TFile *montecarlo4 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponsemc123.root",radius), "Read"); // 60 TO 80 PT AVERAGE
    TFile *montecarlo5 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponsemc1234.root",radius), "Read"); // 40 TO 60 PT AVEERAGE
    if (montecarlo1->IsOpen() && montecarlo2->IsOpen() && montecarlo3->IsOpen() && montecarlo4->IsOpen() && montecarlo5->IsOpen()) printf("MonteCarlo File Opened Successfully.\n");
    montecarlo1->ls();
    montecarlo2->ls();
    montecarlo3->ls();
    montecarlo4->ls();
    montecarlo5->ls();
    TGraphErrors *relrespmc1 = (TGraphErrors *)montecarlo1->Get("Graph;1 Relative Response");
    TGraphErrors *relrespmc2 = (TGraphErrors *)montecarlo2->Get("Graph;1 Relative Response");
    TGraphErrors *relrespmc3 = (TGraphErrors *)montecarlo3->Get("Graph;1 Relative Response");
    TGraphErrors *relrespmc4 = (TGraphErrors *)montecarlo4->Get("Graph;1 Relative Response");
    TGraphErrors *relrespmc5 = (TGraphErrors *)montecarlo5->Get("Graph;1 Relative Response");

    TFile *ppdata1 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponse.root",radius), "Read"); // 100 TO 140 PT AVERAGE
    TFile *ppdata2 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponse1.root",radius), "Read"); // 80 TO 100 PT AVERAGE
    TFile *ppdata3 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponse12.root",radius), "Read"); // 140 TO 200 PT AVERAGE
    TFile *ppdata4 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponse123.root",radius), "Read"); // 60 TO 80 PT AVERAGE
    TFile *ppdata5 = new TFile(Form("ak%iPFJetAnalyzer/relativeresponse1234.root",radius), "Read"); // 40 TO 60 PT AVERAGE
    if (ppdata1->IsOpen() && ppdata2->IsOpen() && ppdata3->IsOpen() && ppdata4->IsOpen() && ppdata5->IsOpen()) printf ("PP Data File Opened Successfully.\n");
    ppdata1->ls();
    ppdata2->ls();
    ppdata3->ls();
    ppdata4->ls();
    ppdata5->ls();
    TGraphErrors *relresp1 = (TGraphErrors *)ppdata1->Get("Graph;1 Relative Response");
    TGraphErrors *relresp2 = (TGraphErrors *)ppdata2->Get("Graph;1 Relative Response");
    TGraphErrors *relresp3 = (TGraphErrors *)ppdata3->Get("Graph;1 Relative Response");
    TGraphErrors *relresp4 = (TGraphErrors *)ppdata4->Get("Graph;1 Relative Response");
    TGraphErrors *relresp5 = (TGraphErrors *)ppdata5->Get("Graph;1 Relative Response");

    TFile *corr1 = new TFile(Form("ak%iPFJetAnalyzer/outputrelrespcasymplots.root",radius), "Read"); //100 TO 140 PT AVERAGE
    TFile *corr2 = new TFile(Form("ak%iPFJetAnalyzer/outputrelrespcasymplots1.root",radius), "Read"); // 80 TO 100 PT AVERAGE
    TFile *corr3 = new TFile(Form("ak%iPFJetAnalyzer/outputrelrespcasymplots12.root",radius), "Read"); // 140 TO 200 PT AVERAGE
    TFile *corr4 = new TFile(Form("ak%iPFJetAnalyzer/outputrelrespcasymplots123.root",radius), "Read"); // 60 TO 80 PT AVERAGE
    TFile *corr5 = new TFile(Form("ak%iPFJetAnalyzer/outputrelrespcasymplots1234.root",radius), "Read"); // 40 TO 60 PT AVERAGE
    if (corr1->IsOpen() && corr2->IsOpen() && corr3->IsOpen() && corr4->IsOpen() && corr5->IsOpen()) printf ("PP Corrected Data File Opened Successfully.\n");
    corr1->ls();
    corr2->ls();
    corr3->ls();
    corr4->ls();
    corr5->ls();
    TGraphErrors *relrespcorr1 = (TGraphErrors *)corr1->Get("Graph;1 Relative Response");
    TGraphErrors *relrespcorr2 = (TGraphErrors *)corr2->Get("Graph;1 Relative Response");
    TGraphErrors *relrespcorr3 = (TGraphErrors *)corr3->Get("Graph;1 Relative Response");
    TGraphErrors *relrespcorr4 = (TGraphErrors *)corr4->Get("Graph;1 Relative Response"); 
    TGraphErrors *relrespcorr5 = (TGraphErrors *)corr5->Get("Graph;1 Relative Response");

    TFile *casym1 = new TFile(Form("ak%iPFJetAnalyzer/casym_output_new.root",radius), "Read"); //100 TO 140 PT AVERAGE
    TFile *casym2 = new TFile(Form("ak%iPFJetAnalyzer/casym_output_new_1.root",radius), "Read"); // 80 TO 100 PT AVERAGE
    TFile *casym3 = new TFile(Form("ak%iPFJetAnalyzer/casym_output_new_12.root",radius), "Read"); // 140 TO 200 PT AVERAGE
    TFile *casym4 = new TFile(Form("ak%iPFJetAnalyzer/casym_output_new_123.root",radius), "Read"); // 60 TO 80 PT AVERAGE
    TFile *casym5 = new TFile(Form("ak%iPFJetAnalyzer/casym_output_new_1234.root",radius), "Read"); // 40 TO 60 PT AVERAGE
    if (casym1->IsOpen() && casym2->IsOpen() && casym3->IsOpen() && casym4->IsOpen() && casym5->IsOpen()) printf ("Asymmetry Correction File Opened Successfully.\n");
    casym1->ls();
    casym2->ls();
    casym3->ls();
    casym4->ls();
    casym5->ls();
    TGraphErrors *casymcorr1 = (TGraphErrors *)casym1->Get("Graph;1 C_Asym v. Eta");
    TGraphErrors *casymcorr2 = (TGraphErrors *)casym2->Get("Graph;1 C_Asym v. Eta");
    TGraphErrors *casymcorr3 = (TGraphErrors *)casym3->Get("Graph;1 C_Asym v. Eta");
    TGraphErrors *casymcorr4 = (TGraphErrors *)casym4->Get("Graph;1 C_Asym v. Eta"); 
    TGraphErrors *casymcorr5 = (TGraphErrors *)casym5->Get("Graph;1 C_Asym v. Eta");

  
    TFile *myfile = new TFile(Form("ak%iPFJetAnalyzer/separated_plots.root",radius), "Recreate");
  
    TCanvas *a = new TCanvas();
    relrespmc1->SetMarkerStyle(21);
    relrespmc1->SetMarkerColor(2);
    relrespmc1->SetLineColor(2);
    relrespmc2->SetMarkerStyle(22);
    relrespmc2->SetMarkerColor(3);
    relrespmc2->SetLineColor(3);
    relrespmc3->SetMarkerStyle(29);
    relrespmc3->SetMarkerColor(4);
    relrespmc3->SetLineColor(4);
    relrespmc4->SetMarkerStyle(33);
    relrespmc4->SetMarkerColor(1);
    relrespmc4->SetLineColor(1);
    relrespmc5->SetMarkerStyle(34);
    relrespmc5->SetMarkerColor(7);
    relrespmc5->SetLineColor(7);
    relrespmc1->Draw("AP");
    relrespmc2->Draw("P");
    relrespmc3->Draw("P");
    relrespmc4->Draw("P");
    relrespmc5->Draw("P");
    TLegend *legenda = new TLegend(0.4,0.6,0.89,0.89);
    legenda->AddEntry((TObject*)0, "Monte Carlo Relative Response", "");
    legenda->AddEntry((TObject*)0, Form("ak%iPFJetAnalyzer",radius), "");
    legenda->AddEntry(relrespmc5, "40 < p^{avg}_{T} < 60 GeV/c", "p");
    legenda->AddEntry(relrespmc4, "60 < p^{avg}_{T} < 80 GeV/c", "p");
    legenda->AddEntry(relrespmc2, "80 < p^{avg}_{T} < 100 GeV/c", "p");
    legenda->AddEntry(relrespmc1, "100 < p^{avg}_{T} < 140 GeV/c", "p");
    legenda->AddEntry(relrespmc3, "140 < p^{avg}_{T} < 200 GeV/c", "p");
    legenda->AddEntry((TObject*)0, "|#Delta#phi| > 2.5", "");
    legenda->AddEntry((TObject*)0, "#alpha = p^{third}_{T}/p^{avg}_{T} < 0.2", "");
    legenda->AddEntry((TObject*)0, "|#eta^{ref}| < 1.3", "");
    legenda->AddEntry((TObject*)0, "|#eta^{probe}| < 3.0", "");
    legenda->Draw();
    a->Update();

    TCanvas *b = new TCanvas();
    relresp1->SetMarkerStyle(21);
    relresp1->SetMarkerColor(2);
    relresp1->SetLineColor(2);
    relresp2->SetMarkerStyle(22);
    relresp2->SetMarkerColor(3);
    relresp2->SetLineColor(3);
    relresp3->SetMarkerStyle(29);
    relresp3->SetMarkerColor(4);
    relresp3->SetLineColor(4);
    relresp4->SetMarkerStyle(33);
    relresp4->SetMarkerColor(1);
    relresp4->SetLineColor(1);
    relresp5->SetMarkerStyle(34);
    relresp5->SetMarkerColor(7);
    relresp5->SetLineColor(7);
    relresp1->Draw("AP");
    relresp2->Draw("P");
    relresp3->Draw("P");
    relresp4->Draw("P");
    relresp5->Draw("P");
    TLegend *legendb = new TLegend(0.4,0.6,0.89,0.89);
    legendb->AddEntry((TObject*)0, "pp Data Relative Response", "");
    legendb->AddEntry((TObject*)0, Form("ak%iPFJetAnalyzer",radius), "");
    legendb->AddEntry(relresp5, "40 < p^{avg}_{T} < 60 GeV/c", "p");
    legendb->AddEntry(relresp4, "60 < p^{avg}_{T} < 80 GeV/c", "p");
    legendb->AddEntry(relresp2, "80 < p^{avg}_{T} < 100 GeV/c", "p");
    legendb->AddEntry(relresp1, "100 < p^{avg}_{T} < 140 GeV/c", "p");
    legendb->AddEntry(relresp3, "140 < p^{avg}_{T} < 200 GeV/c", "p");
    legendb->AddEntry((TObject*)0, "|#Delta#phi| > 2.5", "");
    legendb->AddEntry((TObject*)0, "#alpha = p^{third}_{T}/p^{avg}_{T} < 0.2", "");
    legendb->AddEntry((TObject*)0, "|#eta^{ref}| < 1.3", "");
    legendb->AddEntry((TObject*)0, "|#eta^{probe}| < 3.0", "");
    legendb->Draw();
    b->Update();

    TCanvas *c = new TCanvas();
    relrespcorr1->SetMarkerStyle(21);
    relrespcorr1->SetMarkerColor(2);
    relrespcorr1->SetLineColor(2);
    relrespcorr2->SetMarkerStyle(22);
    relrespcorr2->SetMarkerColor(3);
    relrespcorr2->SetLineColor(3);
    relrespcorr3->SetMarkerStyle(29);
    relrespcorr3->SetMarkerColor(4);
    relrespcorr3->SetLineColor(4);
    relrespcorr4->SetMarkerStyle(33);
    relrespcorr4->SetMarkerColor(1);
    relrespcorr4->SetLineColor(1);
    relrespcorr5->SetMarkerStyle(34);
    relrespcorr5->SetMarkerColor(7);
    relrespcorr5->SetLineColor(7);
    relrespcorr1->Draw("AP");
    relrespcorr2->Draw("P");
    relrespcorr3->Draw("P");
    relrespcorr4->Draw("P");
    relrespcorr5->Draw("P");
    TLegend *legendc = new TLegend(0.4,0.6,0.89,0.89);
    legendc->AddEntry((TObject*)0, "Corrected pp Data Relative Response", "");
    legendc->AddEntry((TObject*)0, Form("ak%iPFJetAnalyzer",radius), "");
    legendc->AddEntry(relrespcorr5, "40 < p^{avg}_{T} < 60 GeV/c", "p");
    legendc->AddEntry(relrespcorr4, "60 < p^{avg}_{T} < 80 GeV/c", "p");
    legendc->AddEntry(relrespcorr2, "80 < p^{avg}_{T} < 100 GeV/c", "p");
    legendc->AddEntry(relrespcorr1, "100 < p^{avg}_{T} < 140 GeV/c", "p");
    legendc->AddEntry(relrespcorr3, "140 < p^{avg}_{T} < 200 GeV/c", "p");
    legendc->AddEntry((TObject*)0, "|#Delta#phi| > 2.5", "");
    legendc->AddEntry((TObject*)0, "#alpha = p^{third}_{T}/p^{avg}_{T} < 0.2", "");
    legendc->AddEntry((TObject*)0, "|#eta^{ref}| < 1.3", "");
    legendc->AddEntry((TObject*)0, "|#eta^{probe}| < 3.0", "");
    legendc->Draw();
    c->Update();

    TCanvas *d = new TCanvas();
    casymcorr1->SetMarkerStyle(21);
    casymcorr1->SetMarkerColor(2);
    casymcorr1->SetLineColor(2);
    casymcorr2->SetMarkerStyle(22);
    casymcorr2->SetMarkerColor(3);
    casymcorr2->SetLineColor(3);
    casymcorr3->SetMarkerStyle(29);
    casymcorr3->SetMarkerColor(4);
    casymcorr3->SetLineColor(4);
    casymcorr4->SetMarkerStyle(33);
    casymcorr4->SetMarkerColor(1);
    casymcorr4->SetLineColor(1);
    casymcorr5->SetMarkerStyle(34);
    casymcorr5->SetMarkerColor(7);
    casymcorr5->SetLineColor(7);
    casymcorr1->Draw("AP");
    casymcorr2->Draw("P");
    casymcorr3->Draw("P");
    casymcorr4->Draw("P");
    casymcorr5->Draw("P");
    TLegend *legendd = new TLegend(0.4,0.6,0.89,0.89);
    legendd->AddEntry((TObject*)0, "Asymmetry Correction Factor", "");
    legendd->AddEntry((TObject*)0, Form("ak%iPFJetAnalyzer",radius), "");
    legendd->AddEntry(casymcorr5, "40 < p^{avg}_{T} < 60 GeV/c", "p");
    legendd->AddEntry(casymcorr4, "60 < p^{avg}_{T} < 80 GeV/c", "p");
    legendd->AddEntry(casymcorr2, "80 < p^{avg}_{T} < 100 GeV/c", "p");
    legendd->AddEntry(casymcorr1, "100 < p^{avg}_{T} < 140 GeV/c", "p");
    legendd->AddEntry(casymcorr3, "140 < p^{avg}_{T} < 200 GeV/c", "p");
    legendd->AddEntry((TObject*)0, "|#Delta#phi| > 2.5", "");
    legendd->AddEntry((TObject*)0, "#alpha = p^{third}_{T}/p^{avg}_{T} < 0.2", "");
    legendd->AddEntry((TObject*)0, "|#eta^{ref}| < 1.3", "");
    legendd->AddEntry((TObject*)0, "|#eta^{probe}| < 3.0", "");
    legendd->Draw();
    d->Update();


    myfile->cd();
    a->Write();
    b->Write();
    c->Write();
    d->Write();
    myfile->Close();
    montecarlo1->Close();
    montecarlo2->Close();
    montecarlo3->Close();
    montecarlo4->Close();
    montecarlo5->Close();
    ppdata1->Close();
    ppdata2->Close();
    ppdata3->Close();
    ppdata4->Close();
    ppdata5->Close();
    corr1->Close();
    corr2->Close();
    corr3->Close();
    corr4->Close();
    corr5->Close();
    casym1->Close();
    casym2->Close();
    casym3->Close();
    casym4->Close();
    casym5->Close();
  }//END RADIUS LOOP
  timer.Stop();
  cout << "End of Macro Reached" << endl;
  cout << "CPU Time (sec)  : " << timer.CpuTime() << endl;
  cout << "Real Time (sec) : " << timer.RealTime() << endl;
}
void ana_flatskim_data(TString ds="relval", TString physics="ttbar") {

  gSystem->Load("libSusyEvent.so");

  // Look ../jec/JetMETObjects/README
  gSystem->Load("../jec/lib/libJetMETObjects.so");

  // Printing utility for ntuple variables
  gROOT->LoadMacro("SusyEventPrinter.cc+");

  // Main analysis code
  gROOT->LoadMacro("SusySkimmer.cc+");


/*


DO NOT USE THIS!!!



*/


  // chain of inputs
  TChain* chain = new TChain("susyTree");
  //chain->Add("Susyskim2.root");

//////////////// controls //////////////////
bool useAB = false;
bool useC = false;
bool useMC = false;







//////////////// switches //////////////////
bool useA = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012A-PromptReco-v1/Photon/Runs190456-193621/
bool useB1 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012B-PromptReco-v1/DoublePhoton/Runs193834-195937/
bool useB2 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012B-PromptReco-v1/DoublePhoton/Runs195947-196203/
bool useB3 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012B-PromptReco-v1/DoublePhoton/Runs196218-196531/
bool useC1 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012C-PromptReco-v1/DoublePhoton/Runs198022-198903/
bool useC2 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012C-PromptReco-v2/DoublePhoton/Runs198941-199103/
//sea->IncludeAJson("Cert_190456-199429_8TeV_PromptReco_Collisions12_JSON.txt");

bool useC3 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012C-PromptReco-v2/DoublePhoton/Runs199275-200190/
bool useC4 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012C-PromptReco-v2/DoublePhoton/Runs200228-200601/
bool useC5 = false;// /eos/uscms/store/user/lpcpjm/SusyNtuples/cms525v3_jec2012/Run2012C-PromptReco-v2/DoublePhoton/Runs200781-202016/
//using Cert_190456-202016_8TeV_PromptReco_Collisions12_JSON.txt

if(useAB){
useA = true;
useB1 = true;
useB2 = true;
useB3 = true;
}
if(useC){
useC1 = true;
useC2 = true;
useC3 = true;
useC4 = true;
useC5 = true;
}


//////////////// data /////////////////



if(useMC){
//chain->Add("Susysignal_1030evt.root");
//chain->Add("../susyEvents_bydmason.root");
useA = false;
useB1 = false;
useB2 = false;
useB3 = false;
useC1 = false;
useC2 = false;
useC3 = false;
useC4 = false;
useC5 = false;
}






chain->Add("Tripathi_skim_data_pi05met202.root");
//chain->Add("Tripathi_events_data_mggPlot2.root");

if(useA){ //get rid of file 36 
chain->Add("looseSkims/SuperSkim_data_12A_0.root");
chain->Add("looseSkims/SuperSkim_data_12A_1.root");
chain->Add("looseSkims/SuperSkim_data_12A_10.root");
chain->Add("looseSkims/SuperSkim_data_12A_11.root");
chain->Add("looseSkims/SuperSkim_data_12A_12.root");
chain->Add("looseSkims/SuperSkim_data_12A_13.root");
chain->Add("looseSkims/SuperSkim_data_12A_14.root");
chain->Add("looseSkims/SuperSkim_data_12A_15.root");
chain->Add("looseSkims/SuperSkim_data_12A_16.root");
chain->Add("looseSkims/SuperSkim_data_12A_17.root");
chain->Add("looseSkims/SuperSkim_data_12A_18.root");
chain->Add("looseSkims/SuperSkim_data_12A_19.root");
chain->Add("looseSkims/SuperSkim_data_12A_2.root");
chain->Add("looseSkims/SuperSkim_data_12A_20.root");
chain->Add("looseSkims/SuperSkim_data_12A_21.root");
chain->Add("looseSkims/SuperSkim_data_12A_22.root");
chain->Add("looseSkims/SuperSkim_data_12A_23.root");
chain->Add("looseSkims/SuperSkim_data_12A_24.root");
chain->Add("looseSkims/SuperSkim_data_12A_25.root");
chain->Add("looseSkims/SuperSkim_data_12A_26.root");
chain->Add("looseSkims/SuperSkim_data_12A_27.root");
chain->Add("looseSkims/SuperSkim_data_12A_28.root");
chain->Add("looseSkims/SuperSkim_data_12A_29.root");
chain->Add("looseSkims/SuperSkim_data_12A_3.root");
chain->Add("looseSkims/SuperSkim_data_12A_30.root");
chain->Add("looseSkims/SuperSkim_data_12A_31.root");
chain->Add("looseSkims/SuperSkim_data_12A_32.root");
chain->Add("looseSkims/SuperSkim_data_12A_33.root");
chain->Add("looseSkims/SuperSkim_data_12A_34.root");
chain->Add("looseSkims/SuperSkim_data_12A_35.root");
//chain->Add("looseSkims/SuperSkim_data_12A_36.root");
chain->Add("looseSkims/SuperSkim_data_12A_37.root");
chain->Add("looseSkims/SuperSkim_data_12A_38.root");
chain->Add("looseSkims/SuperSkim_data_12A_39.root");
chain->Add("looseSkims/SuperSkim_data_12A_4.root");
chain->Add("looseSkims/SuperSkim_data_12A_40.root");
chain->Add("looseSkims/SuperSkim_data_12A_41.root");
chain->Add("looseSkims/SuperSkim_data_12A_42.root");
chain->Add("looseSkims/SuperSkim_data_12A_43.root");
chain->Add("looseSkims/SuperSkim_data_12A_44.root");
chain->Add("looseSkims/SuperSkim_data_12A_45.root");
chain->Add("looseSkims/SuperSkim_data_12A_46.root");
chain->Add("looseSkims/SuperSkim_data_12A_47.root");
chain->Add("looseSkims/SuperSkim_data_12A_48.root");
chain->Add("looseSkims/SuperSkim_data_12A_49.root");
chain->Add("looseSkims/SuperSkim_data_12A_5.root");
chain->Add("looseSkims/SuperSkim_data_12A_50.root");
chain->Add("looseSkims/SuperSkim_data_12A_51.root");
chain->Add("looseSkims/SuperSkim_data_12A_52.root");
chain->Add("looseSkims/SuperSkim_data_12A_53.root");
chain->Add("looseSkims/SuperSkim_data_12A_54.root");
chain->Add("looseSkims/SuperSkim_data_12A_55.root");
chain->Add("looseSkims/SuperSkim_data_12A_56.root");
chain->Add("looseSkims/SuperSkim_data_12A_57.root");
chain->Add("looseSkims/SuperSkim_data_12A_58.root");
chain->Add("looseSkims/SuperSkim_data_12A_59.root");
chain->Add("looseSkims/SuperSkim_data_12A_6.root");
chain->Add("looseSkims/SuperSkim_data_12A_60.root");
chain->Add("looseSkims/SuperSkim_data_12A_61.root");
chain->Add("looseSkims/SuperSkim_data_12A_62.root");
chain->Add("looseSkims/SuperSkim_data_12A_63.root");
chain->Add("looseSkims/SuperSkim_data_12A_64.root");
chain->Add("looseSkims/SuperSkim_data_12A_65.root");
chain->Add("looseSkims/SuperSkim_data_12A_66.root");
chain->Add("looseSkims/SuperSkim_data_12A_67.root");
chain->Add("looseSkims/SuperSkim_data_12A_7.root");
chain->Add("looseSkims/SuperSkim_data_12A_8.root");
chain->Add("looseSkims/SuperSkim_data_12A_9.root");
}


if(useB1){//don't use file 37 or 79
chain->Add("looseSkims/SuperSkim_data_12B1_0.root");
chain->Add("looseSkims/SuperSkim_data_12B1_1.root");
chain->Add("looseSkims/SuperSkim_data_12B1_10.root");
chain->Add("looseSkims/SuperSkim_data_12B1_100.root");
chain->Add("looseSkims/SuperSkim_data_12B1_101.root");
chain->Add("looseSkims/SuperSkim_data_12B1_102.root");
chain->Add("looseSkims/SuperSkim_data_12B1_11.root");
chain->Add("looseSkims/SuperSkim_data_12B1_12.root");
chain->Add("looseSkims/SuperSkim_data_12B1_13.root");
chain->Add("looseSkims/SuperSkim_data_12B1_14.root");
chain->Add("looseSkims/SuperSkim_data_12B1_15.root");
chain->Add("looseSkims/SuperSkim_data_12B1_16.root");
chain->Add("looseSkims/SuperSkim_data_12B1_17.root");
chain->Add("looseSkims/SuperSkim_data_12B1_18.root");
chain->Add("looseSkims/SuperSkim_data_12B1_19.root");
chain->Add("looseSkims/SuperSkim_data_12B1_2.root");
chain->Add("looseSkims/SuperSkim_data_12B1_20.root");
chain->Add("looseSkims/SuperSkim_data_12B1_21.root");
chain->Add("looseSkims/SuperSkim_data_12B1_22.root");
chain->Add("looseSkims/SuperSkim_data_12B1_23.root");
chain->Add("looseSkims/SuperSkim_data_12B1_24.root");
chain->Add("looseSkims/SuperSkim_data_12B1_25.root");
chain->Add("looseSkims/SuperSkim_data_12B1_26.root");
chain->Add("looseSkims/SuperSkim_data_12B1_27.root");
chain->Add("looseSkims/SuperSkim_data_12B1_28.root");
chain->Add("looseSkims/SuperSkim_data_12B1_29.root");
chain->Add("looseSkims/SuperSkim_data_12B1_3.root");
chain->Add("looseSkims/SuperSkim_data_12B1_30.root");
chain->Add("looseSkims/SuperSkim_data_12B1_31.root");
chain->Add("looseSkims/SuperSkim_data_12B1_32.root");
chain->Add("looseSkims/SuperSkim_data_12B1_33.root");
chain->Add("looseSkims/SuperSkim_data_12B1_34.root");
chain->Add("looseSkims/SuperSkim_data_12B1_35.root");
chain->Add("looseSkims/SuperSkim_data_12B1_36.root");
//chain->Add("looseSkims/SuperSkim_data_12B1_37.root");
chain->Add("looseSkims/SuperSkim_data_12B1_38.root");
chain->Add("looseSkims/SuperSkim_data_12B1_39.root");
chain->Add("looseSkims/SuperSkim_data_12B1_4.root");
chain->Add("looseSkims/SuperSkim_data_12B1_40.root");
chain->Add("looseSkims/SuperSkim_data_12B1_41.root");
chain->Add("looseSkims/SuperSkim_data_12B1_42.root");
chain->Add("looseSkims/SuperSkim_data_12B1_43.root");
chain->Add("looseSkims/SuperSkim_data_12B1_44.root");
chain->Add("looseSkims/SuperSkim_data_12B1_45.root");
chain->Add("looseSkims/SuperSkim_data_12B1_46.root");
chain->Add("looseSkims/SuperSkim_data_12B1_47.root");
chain->Add("looseSkims/SuperSkim_data_12B1_48.root");
chain->Add("looseSkims/SuperSkim_data_12B1_49.root");
chain->Add("looseSkims/SuperSkim_data_12B1_5.root");
chain->Add("looseSkims/SuperSkim_data_12B1_50.root");
chain->Add("looseSkims/SuperSkim_data_12B1_51.root");
chain->Add("looseSkims/SuperSkim_data_12B1_52.root");
chain->Add("looseSkims/SuperSkim_data_12B1_53.root");
chain->Add("looseSkims/SuperSkim_data_12B1_54.root");
chain->Add("looseSkims/SuperSkim_data_12B1_55.root");
chain->Add("looseSkims/SuperSkim_data_12B1_56.root");
chain->Add("looseSkims/SuperSkim_data_12B1_57.root");
chain->Add("looseSkims/SuperSkim_data_12B1_58.root");
chain->Add("looseSkims/SuperSkim_data_12B1_59.root");
chain->Add("looseSkims/SuperSkim_data_12B1_6.root");
chain->Add("looseSkims/SuperSkim_data_12B1_60.root");
chain->Add("looseSkims/SuperSkim_data_12B1_61.root");
chain->Add("looseSkims/SuperSkim_data_12B1_62.root");
chain->Add("looseSkims/SuperSkim_data_12B1_63.root");
chain->Add("looseSkims/SuperSkim_data_12B1_64.root");
chain->Add("looseSkims/SuperSkim_data_12B1_65.root");
chain->Add("looseSkims/SuperSkim_data_12B1_66.root");
chain->Add("looseSkims/SuperSkim_data_12B1_67.root");
chain->Add("looseSkims/SuperSkim_data_12B1_68.root");
chain->Add("looseSkims/SuperSkim_data_12B1_69.root");
chain->Add("looseSkims/SuperSkim_data_12B1_7.root");
chain->Add("looseSkims/SuperSkim_data_12B1_70.root");
chain->Add("looseSkims/SuperSkim_data_12B1_71.root");
chain->Add("looseSkims/SuperSkim_data_12B1_72.root");
chain->Add("looseSkims/SuperSkim_data_12B1_73.root");
chain->Add("looseSkims/SuperSkim_data_12B1_74.root");
chain->Add("looseSkims/SuperSkim_data_12B1_75.root");
chain->Add("looseSkims/SuperSkim_data_12B1_76.root");
chain->Add("looseSkims/SuperSkim_data_12B1_77.root");
chain->Add("looseSkims/SuperSkim_data_12B1_78.root");
chain->Add("looseSkims/SuperSkim_data_12B1_79.root");
chain->Add("looseSkims/SuperSkim_data_12B1_8.root");
chain->Add("looseSkims/SuperSkim_data_12B1_80.root");
chain->Add("looseSkims/SuperSkim_data_12B1_81.root");
chain->Add("looseSkims/SuperSkim_data_12B1_82.root");
chain->Add("looseSkims/SuperSkim_data_12B1_83.root");
chain->Add("looseSkims/SuperSkim_data_12B1_84.root");
chain->Add("looseSkims/SuperSkim_data_12B1_85.root");
chain->Add("looseSkims/SuperSkim_data_12B1_86.root");
chain->Add("looseSkims/SuperSkim_data_12B1_87.root");
chain->Add("looseSkims/SuperSkim_data_12B1_88.root");
chain->Add("looseSkims/SuperSkim_data_12B1_89.root");
chain->Add("looseSkims/SuperSkim_data_12B1_9.root");
chain->Add("looseSkims/SuperSkim_data_12B1_90.root");
chain->Add("looseSkims/SuperSkim_data_12B1_91.root");
chain->Add("looseSkims/SuperSkim_data_12B1_92.root");
chain->Add("looseSkims/SuperSkim_data_12B1_93.root");
chain->Add("looseSkims/SuperSkim_data_12B1_94.root");
chain->Add("looseSkims/SuperSkim_data_12B1_95.root");
chain->Add("looseSkims/SuperSkim_data_12B1_96.root");
chain->Add("looseSkims/SuperSkim_data_12B1_97.root");
chain->Add("looseSkims/SuperSkim_data_12B1_98.root");
chain->Add("looseSkims/SuperSkim_data_12B1_99.root");
}

if(useB2){
chain->Add("looseSkims/SuperSkim_data_12B2_0.root");
chain->Add("looseSkims/SuperSkim_data_12B2_1.root");
chain->Add("looseSkims/SuperSkim_data_12B2_2.root");
chain->Add("looseSkims/SuperSkim_data_12B2_3.root");
chain->Add("looseSkims/SuperSkim_data_12B2_4.root");
chain->Add("looseSkims/SuperSkim_data_12B2_5.root");
chain->Add("looseSkims/SuperSkim_data_12B2_6.root");
chain->Add("looseSkims/SuperSkim_data_12B2_7.root");
chain->Add("looseSkims/SuperSkim_data_12B2_8.root");
chain->Add("looseSkims/SuperSkim_data_12B2_9.root");
}

if(useB3){
chain->Add("looseSkims/SuperSkim_data_12B3_0.root");
chain->Add("looseSkims/SuperSkim_data_12B3_1.root");
chain->Add("looseSkims/SuperSkim_data_12B3_10.root");
chain->Add("looseSkims/SuperSkim_data_12B3_11.root");
chain->Add("looseSkims/SuperSkim_data_12B3_12.root");
chain->Add("looseSkims/SuperSkim_data_12B3_13.root");
chain->Add("looseSkims/SuperSkim_data_12B3_14.root");
chain->Add("looseSkims/SuperSkim_data_12B3_15.root");
chain->Add("looseSkims/SuperSkim_data_12B3_16.root");
chain->Add("looseSkims/SuperSkim_data_12B3_17.root");
chain->Add("looseSkims/SuperSkim_data_12B3_18.root");
chain->Add("looseSkims/SuperSkim_data_12B3_19.root");
chain->Add("looseSkims/SuperSkim_data_12B3_2.root");
chain->Add("looseSkims/SuperSkim_data_12B3_3.root");
chain->Add("looseSkims/SuperSkim_data_12B3_4.root");
chain->Add("looseSkims/SuperSkim_data_12B3_5.root");
chain->Add("looseSkims/SuperSkim_data_12B3_6.root");
chain->Add("looseSkims/SuperSkim_data_12B3_7.root");
chain->Add("looseSkims/SuperSkim_data_12B3_8.root");
chain->Add("looseSkims/SuperSkim_data_12B3_9.root");
}

if(useC1){
chain->Add("looseSkims/SuperSkim_data_12C1_0.root");
chain->Add("looseSkims/SuperSkim_data_12C1_1.root");
chain->Add("looseSkims/SuperSkim_data_12C1_10.root");
chain->Add("looseSkims/SuperSkim_data_12C1_11.root");
chain->Add("looseSkims/SuperSkim_data_12C1_12.root");
chain->Add("looseSkims/SuperSkim_data_12C1_13.root");
chain->Add("looseSkims/SuperSkim_data_12C1_2.root");
chain->Add("looseSkims/SuperSkim_data_12C1_3.root");
chain->Add("looseSkims/SuperSkim_data_12C1_4.root");
chain->Add("looseSkims/SuperSkim_data_12C1_5.root");
chain->Add("looseSkims/SuperSkim_data_12C1_6.root");
chain->Add("looseSkims/SuperSkim_data_12C1_7.root");
chain->Add("looseSkims/SuperSkim_data_12C1_8.root");
chain->Add("looseSkims/SuperSkim_data_12C1_9.root");
}

if(useC2){
chain->Add("looseSkims/SuperSkim_data_12C2_0.root");
chain->Add("looseSkims/SuperSkim_data_12C2_1.root");
chain->Add("looseSkims/SuperSkim_data_12C2_10.root");
chain->Add("looseSkims/SuperSkim_data_12C2_11.root");
chain->Add("looseSkims/SuperSkim_data_12C2_12.root");
chain->Add("looseSkims/SuperSkim_data_12C2_13.root");
chain->Add("looseSkims/SuperSkim_data_12C2_14.root");
chain->Add("looseSkims/SuperSkim_data_12C2_2.root");
chain->Add("looseSkims/SuperSkim_data_12C2_3.root");
chain->Add("looseSkims/SuperSkim_data_12C2_4.root");
chain->Add("looseSkims/SuperSkim_data_12C2_5.root");
chain->Add("looseSkims/SuperSkim_data_12C2_6.root");
chain->Add("looseSkims/SuperSkim_data_12C2_7.root");
chain->Add("looseSkims/SuperSkim_data_12C2_8.root");
chain->Add("looseSkims/SuperSkim_data_12C2_9.root");
}

if(useC3){
chain->Add("looseSkims/SuperSkim_data_12C3_0.root");
chain->Add("looseSkims/SuperSkim_data_12C3_1.root");
chain->Add("looseSkims/SuperSkim_data_12C3_10.root");
chain->Add("looseSkims/SuperSkim_data_12C3_11.root");
chain->Add("looseSkims/SuperSkim_data_12C3_12.root");
chain->Add("looseSkims/SuperSkim_data_12C3_13.root");
chain->Add("looseSkims/SuperSkim_data_12C3_14.root");
chain->Add("looseSkims/SuperSkim_data_12C3_15.root");
chain->Add("looseSkims/SuperSkim_data_12C3_16.root");
chain->Add("looseSkims/SuperSkim_data_12C3_17.root");
chain->Add("looseSkims/SuperSkim_data_12C3_18.root");
chain->Add("looseSkims/SuperSkim_data_12C3_19.root");
chain->Add("looseSkims/SuperSkim_data_12C3_2.root");
chain->Add("looseSkims/SuperSkim_data_12C3_20.root");
chain->Add("looseSkims/SuperSkim_data_12C3_21.root");
chain->Add("looseSkims/SuperSkim_data_12C3_22.root");
chain->Add("looseSkims/SuperSkim_data_12C3_23.root");
chain->Add("looseSkims/SuperSkim_data_12C3_24.root");
chain->Add("looseSkims/SuperSkim_data_12C3_25.root");
chain->Add("looseSkims/SuperSkim_data_12C3_26.root");
chain->Add("looseSkims/SuperSkim_data_12C3_27.root");
chain->Add("looseSkims/SuperSkim_data_12C3_28.root");
chain->Add("looseSkims/SuperSkim_data_12C3_29.root");
chain->Add("looseSkims/SuperSkim_data_12C3_3.root");
chain->Add("looseSkims/SuperSkim_data_12C3_30.root");
chain->Add("looseSkims/SuperSkim_data_12C3_31.root");
chain->Add("looseSkims/SuperSkim_data_12C3_32.root");
chain->Add("looseSkims/SuperSkim_data_12C3_33.root");
chain->Add("looseSkims/SuperSkim_data_12C3_34.root");
chain->Add("looseSkims/SuperSkim_data_12C3_35.root");
chain->Add("looseSkims/SuperSkim_data_12C3_36.root");
chain->Add("looseSkims/SuperSkim_data_12C3_37.root");
chain->Add("looseSkims/SuperSkim_data_12C3_38.root");
chain->Add("looseSkims/SuperSkim_data_12C3_39.root");
chain->Add("looseSkims/SuperSkim_data_12C3_4.root");
chain->Add("looseSkims/SuperSkim_data_12C3_40.root");
chain->Add("looseSkims/SuperSkim_data_12C3_41.root");
chain->Add("looseSkims/SuperSkim_data_12C3_42.root");
chain->Add("looseSkims/SuperSkim_data_12C3_43.root");
chain->Add("looseSkims/SuperSkim_data_12C3_44.root");
chain->Add("looseSkims/SuperSkim_data_12C3_45.root");
chain->Add("looseSkims/SuperSkim_data_12C3_46.root");
chain->Add("looseSkims/SuperSkim_data_12C3_47.root");
chain->Add("looseSkims/SuperSkim_data_12C3_48.root");
chain->Add("looseSkims/SuperSkim_data_12C3_49.root");
chain->Add("looseSkims/SuperSkim_data_12C3_5.root");
chain->Add("looseSkims/SuperSkim_data_12C3_50.root");
chain->Add("looseSkims/SuperSkim_data_12C3_51.root");
chain->Add("looseSkims/SuperSkim_data_12C3_52.root");
chain->Add("looseSkims/SuperSkim_data_12C3_53.root");
chain->Add("looseSkims/SuperSkim_data_12C3_54.root");
chain->Add("looseSkims/SuperSkim_data_12C3_55.root");
chain->Add("looseSkims/SuperSkim_data_12C3_56.root");
chain->Add("looseSkims/SuperSkim_data_12C3_57.root");
chain->Add("looseSkims/SuperSkim_data_12C3_58.root");
chain->Add("looseSkims/SuperSkim_data_12C3_59.root");
chain->Add("looseSkims/SuperSkim_data_12C3_6.root");
chain->Add("looseSkims/SuperSkim_data_12C3_60.root");
chain->Add("looseSkims/SuperSkim_data_12C3_61.root");
chain->Add("looseSkims/SuperSkim_data_12C3_62.root");
chain->Add("looseSkims/SuperSkim_data_12C3_63.root");
chain->Add("looseSkims/SuperSkim_data_12C3_64.root");
chain->Add("looseSkims/SuperSkim_data_12C3_65.root");
chain->Add("looseSkims/SuperSkim_data_12C3_66.root");
chain->Add("looseSkims/SuperSkim_data_12C3_67.root");
chain->Add("looseSkims/SuperSkim_data_12C3_68.root");
chain->Add("looseSkims/SuperSkim_data_12C3_69.root");
chain->Add("looseSkims/SuperSkim_data_12C3_7.root");
chain->Add("looseSkims/SuperSkim_data_12C3_70.root");
chain->Add("looseSkims/SuperSkim_data_12C3_71.root");
chain->Add("looseSkims/SuperSkim_data_12C3_72.root");
chain->Add("looseSkims/SuperSkim_data_12C3_8.root");
chain->Add("looseSkims/SuperSkim_data_12C3_9.root");
}


if(useC4){
chain->Add("looseSkims/SuperSkim_data_12C4_0.root");
chain->Add("looseSkims/SuperSkim_data_12C4_1.root");
chain->Add("looseSkims/SuperSkim_data_12C4_10.root");
chain->Add("looseSkims/SuperSkim_data_12C4_11.root");
chain->Add("looseSkims/SuperSkim_data_12C4_12.root");
chain->Add("looseSkims/SuperSkim_data_12C4_2.root");
chain->Add("looseSkims/SuperSkim_data_12C4_3.root");
chain->Add("looseSkims/SuperSkim_data_12C4_4.root");
chain->Add("looseSkims/SuperSkim_data_12C4_5.root");
chain->Add("looseSkims/SuperSkim_data_12C4_6.root");
chain->Add("looseSkims/SuperSkim_data_12C4_7.root");
chain->Add("looseSkims/SuperSkim_data_12C4_8.root");
chain->Add("looseSkims/SuperSkim_data_12C4_9.root");
}


if(useC5){
chain->Add("looseSkims/SuperSkim_data_12C5_0.root");
chain->Add("looseSkims/SuperSkim_data_12C5_1.root");
chain->Add("looseSkims/SuperSkim_data_12C5_10.root");
chain->Add("looseSkims/SuperSkim_data_12C5_11.root");
chain->Add("looseSkims/SuperSkim_data_12C5_12.root");
chain->Add("looseSkims/SuperSkim_data_12C5_13.root");
chain->Add("looseSkims/SuperSkim_data_12C5_14.root");
chain->Add("looseSkims/SuperSkim_data_12C5_15.root");
chain->Add("looseSkims/SuperSkim_data_12C5_16.root");
chain->Add("looseSkims/SuperSkim_data_12C5_17.root");
chain->Add("looseSkims/SuperSkim_data_12C5_18.root");
chain->Add("looseSkims/SuperSkim_data_12C5_19.root");
chain->Add("looseSkims/SuperSkim_data_12C5_2.root");
chain->Add("looseSkims/SuperSkim_data_12C5_20.root");
chain->Add("looseSkims/SuperSkim_data_12C5_21.root");
chain->Add("looseSkims/SuperSkim_data_12C5_22.root");
chain->Add("looseSkims/SuperSkim_data_12C5_23.root");
chain->Add("looseSkims/SuperSkim_data_12C5_24.root");
chain->Add("looseSkims/SuperSkim_data_12C5_25.root");
chain->Add("looseSkims/SuperSkim_data_12C5_26.root");
chain->Add("looseSkims/SuperSkim_data_12C5_27.root");
chain->Add("looseSkims/SuperSkim_data_12C5_28.root");
chain->Add("looseSkims/SuperSkim_data_12C5_29.root");
chain->Add("looseSkims/SuperSkim_data_12C5_3.root");
chain->Add("looseSkims/SuperSkim_data_12C5_30.root");
chain->Add("looseSkims/SuperSkim_data_12C5_31.root");
chain->Add("looseSkims/SuperSkim_data_12C5_32.root");
chain->Add("looseSkims/SuperSkim_data_12C5_33.root");
chain->Add("looseSkims/SuperSkim_data_12C5_4.root");
chain->Add("looseSkims/SuperSkim_data_12C5_5.root");
chain->Add("looseSkims/SuperSkim_data_12C5_6.root");
chain->Add("looseSkims/SuperSkim_data_12C5_7.root");
chain->Add("looseSkims/SuperSkim_data_12C5_8.root");
chain->Add("looseSkims/SuperSkim_data_12C5_9.root");
}
//if(useb1_dcache){
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/SusyLooseSkim_v2_2012/SuperSkim_data_12B1_37.root");
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/SusyLooseSkim_v2_2012/SuperSkim_data_12B1_79.root");
//}

  SusySkimmer* sea = new SusySkimmer(chain);

  // configuration parameters
  // any values given here will replace the default values
  sea->SetDataset(physics+"_"+ds);        // dataset name
  sea->SetPrintInterval(1e4);             // print frequency
  sea->SetPrintLevel(0);                  // print level for event contents
  sea->SetUseTrigger(true);
/*
  sea->AddHltName("HLT_Photon36_CaloIdL_Photon22_CaloIdL");  // add HLT trigger path name 
  sea->AddHltName("HLT_Photon32_CaloIdL_Photon26_CaloIdL");  // add HLT trigger path name
  sea->AddHltName("HLT_Photon26_R9Id85_Photon18_R9Id85_Mass60");
  sea->AddHltName("HLT_Photon26_R9Id85_Photon18_CaloId10_Iso50_Mass60");
  sea->AddHltName("HLT_Photon26_CaloId10_Iso50_Photon18_R9Id85_Mass60");
  sea->AddHltName("HLT_Photon26_CaloId10_Iso50_Photon18_CaloId10_Iso50_Mass60");
  sea->AddHltName("HLT_Photon26_R9Id85_OR_CaloId10_Iso50_Photon18_R9Id85_OR_CaloId10_Iso50_Mass60");
  sea->AddHltName("HLT_Photon26_R9Id85_OR_CaloId10_Iso50_Photon18_R9Id85_OR_CaloId10_Iso50_Mass70");
  sea->AddHltName("HLT_Photon36_R9Id85_Photon22_R9Id85");
  sea->AddHltName("HLT_Photon36_R9Id85_Photon22_CaloId10_Iso50");
  sea->AddHltName("HLT_Photon36_CaloId10_Iso50_Photon22_R9Id85");
  sea->AddHltName("HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50");
  sea->AddHltName("HLT_Photon36_R9Id85_OR_CaloId10_Iso50_Photon22_R9Id85_OR_CaloId10_Iso50");
*/
  sea->SetFilter(false);                  // filter events passing final cuts
  sea->SetProcessNEvents(-1);             // number of events to be processed

  // as an example -- add your favorite Json here.  More than one can be "Include"ed
  //sea->IncludeAJson("Cert_190456-199429_8TeV_PromptReco_Collisions12_JSON.txt");
  //sea->IncludeAJson("Cert_190456-202016_8TeV_PromptReco_Collisions12_JSON.txt");
  //sea->IncludeAJson("Cert_190456-203853_8TeV_PromptReco_Collisions12_JSON.txt");
  sea->IncludeAJson("Cert_190456-208686_8TeV_Collisions12_Abarker_Combined_JSON.txt");//combined 2012
  //sea->IncludeAJson("anotherJSON.txt");

  TStopwatch ts;

  ts.Start();

  sea->Loop();

  ts.Stop();

  std::cout << "RealTime : " << ts.RealTime()/60.0 << " minutes" << std::endl;
  std::cout << "CPUTime  : " << ts.CpuTime()/60.0 << " minutes" << std::endl;

}
Beispiel #14
0
/********************************************************************************
 *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
 *                                                                              *
 *              This software is distributed under the terms of the             * 
 *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
 *                  copied verbatim in the file "LICENSE"                       *
 ********************************************************************************/
void run_sim(Int_t nEvents=100, TString mcEngine="TGeant3")
{
  TStopwatch timer;
  timer.Start();
  gDebug=0;

  // Use non default gconfig and geometry directories
  TString dir = getenv("VMCWORKDIR");
  TString tutdir = dir + "/Tutorial6";

  TString ex_geomdir = dir + "/geometry";
  gSystem->Setenv("GEOMPATH",ex_geomdir.Data());

  TString ex_configdir = dir + "/gconfig";
  gSystem->Setenv("CONFIG_DIR",ex_configdir.Data());

  // create Instance of Run Manager class
  FairRunSim *fRun = new FairRunSim();
  
  // set the MC version used
  // ------------------------

  fRun->SetName(mcEngine);

  TString outfile = "data/testrun_";
  outfile = outfile + mcEngine + ".root";

  TString outparam = "data/testparams_";
  outparam = outparam + mcEngine + ".root";

  
  fRun->SetOutputFile(outfile);


  // -----   Magnetic field   -------------------------------------------
  // Constant Field
  FairConstField *fMagField = new FairConstField();
  fMagField->SetField(0., 10. ,0. ); // values are in kG
  fMagField->SetFieldRegion(-50, 50,-50, 50, 350, 450);// values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
  fRun->SetField(fMagField);
  // --------------------------------------------------------------------

 
  // Set Material file Name
  //-----------------------
  fRun->SetMaterials("media.geo");
  
  // Create and add detectors
  //-------------------------
  FairModule *Cave= new FairCave("CAVE");
  Cave->SetGeometryFileName("cave.geo");
  fRun->AddModule(Cave);

  FairModule *Magnet= new FairMagnet("MAGNET");
  Magnet->SetGeometryFileName("magnet.geo");
  fRun->AddModule(Magnet);

  FairDetector *Torino= new FairTestDetector("TORINO", kTRUE);
  Torino->SetGeometryFileName("torino.geo");
  fRun->AddModule(Torino);

  // Create and Set Event Generator
  //-------------------------------

  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
  fRun->SetGenerator(primGen);
  
  // Box Generator
  FairBoxGenerator* boxGen = new FairBoxGenerator(2212, 10); // 13 = muon; 1 = multipl.
  boxGen->SetPRange(2., 2.); // GeV/c //setPRange vs setPtRange
  boxGen->SetPhiRange(0, 360); // Azimuth angle range [degree]
  boxGen->SetThetaRange(3, 10); // Polar angle in lab system range [degree]
  boxGen->SetCosTheta();//uniform generation on all the solid angle(default)

  // boxGen->SetXYZ(0., 0.37, 0.); 
  primGen->AddGenerator(boxGen);
  
  fRun->SetStoreTraj(kTRUE);
  
  fRun->Init();


 // -Trajectories Visualization (TGeoManager Only )
 // -----------------------------------------------

 // Set cuts for storing the trajectpries
  /* FairTrajFilter* trajFilter = FairTrajFilter::Instance();
     trajFilter->SetStepSizeCut(0.01); // 1 cm
     trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.);
     trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV
     trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV
     trajFilter->SetStorePrimaries(kTRUE);
     trajFilter->SetStoreSecondaries(kTRUE);
   */


  // Fill the Parameter containers for this run
  //-------------------------------------------

  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
  Bool_t kParameterMerged=kTRUE;
  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
  output->open(outparam);
  rtdb->setOutput(output);

  rtdb->saveOutput();
  rtdb->print();

  // Transport nEvents
  // -----------------

  //  Int_t nEvents = 1;
  fRun->Run(nEvents);

  TString geoFile = tutdir + "/data/geofile_full.root";  
  fRun->CreateGeometryFile(geoFile.Data());


  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);

  cout << "Macro finished successfully." << endl;  

}  
Beispiel #15
0
void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant4")
{
    
  // Output file name
  TString outFile ="test.root";
    
  // Parameter file name
  TString parFile="params.root";
  
  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;
  timer.Start();
  // ------------------------------------------------------------------------

  // -----   Create simulation run   ----------------------------------------
  FairRunSim* run = new FairRunSim();
  run->SetName(mcEngine);              // Transport engine
  run->SetOutputFile(new FairRootFileSink(outFile));          // Output file
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
  // ------------------------------------------------------------------------
  
  // -----   Create media   -------------------------------------------------
  run->SetMaterials("media.geo");       // Materials
  // ------------------------------------------------------------------------
  
  // -----   Create geometry   ----------------------------------------------

  FairModule* cave= new MyCave("CAVE");
  cave->SetGeometryFileName("cave.geo");
  run->AddModule(cave);

  FairModule* magnet = new MyMagnet("Magnet");
  run->AddModule(magnet);

  FairModule* pipe = new MyPipe("Pipe");
  run->AddModule(pipe);
    
  FairDetector* NewDet = new NewDetector("TestDetector", kTRUE);
  run->AddModule(NewDet);

 // ------------------------------------------------------------------------


    // -----   Magnetic field   -------------------------------------------
    // Constant Field
    MyConstField  *fMagField = new MyConstField();
    fMagField->SetField(0., 20. ,0. ); // values are in kG
    fMagField->SetFieldRegion(-200, 200,-200, 200, -200, 200); // values are in cm
                          //  (xmin,xmax,ymin,ymax,zmin,zmax)
    run->SetField(fMagField);
    // --------------------------------------------------------------------

    
    
  // -----   Create PrimaryGenerator   --------------------------------------
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
  
    // Add a box generator also to the run
    FairBoxGenerator* boxGen = new FairBoxGenerator(13, 5); // 13 = muon; 1 = multipl.
    boxGen->SetPRange(20,25); // GeV/c
    boxGen->SetPhiRange(0., 360.); // Azimuth angle range [degree]
    boxGen->SetThetaRange(0., 90.); // Polar angle in lab system range [degree]
    boxGen->SetXYZ(0., 0., 0.); // cm
    primGen->AddGenerator(boxGen);
  
    
    run->SetGenerator(primGen);
// ------------------------------------------------------------------------
 
  //---Store the visualiztion info of the tracks, this make the output file very large!!
  //--- Use it only to display but not for production!
  run->SetStoreTraj(kTRUE);

    
    
  // -----   Initialize simulation run   ------------------------------------
  run->Init();
  // ------------------------------------------------------------------------

  // -----   Runtime database   ---------------------------------------------

  Bool_t kParameterMerged = kTRUE;
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
  parOut->open(parFile.Data());
  rtdb->setOutput(parOut);
  rtdb->saveOutput();
  rtdb->print();
  // ------------------------------------------------------------------------
   
  // -----   Start run   ----------------------------------------------------
   run->Run(nEvents);
    
  //You can export your ROOT geometry ot a separate file
  run->CreateGeometryFile("geofile_full.root");
  // ------------------------------------------------------------------------
  
  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished succesfully." << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime 
       << "s" << endl << endl;
  // ------------------------------------------------------------------------
}
void ana_standalone_single_photon_MC() {

  gSystem->Load("/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src/SusyAnalysis/SusyNtuplizer/macro/libSusy.so");

  // // Look ../jec/JetMETObjects/README
  gSystem->Load("/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src/SusyAnalysis/SusyNtuplizer/jec/lib/libJetMETObjects.so");

  //GMSBTools shared library (contains Categorizer class)
  gSystem->Load("/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src/GMSBTools/lib/libFilters.so");

  // Printing utility for ntuple variables
  gSystem->Load("/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src/SusyAnalysis/SusyNtuplizer/macro/SusyEventPrinter_cc.so");

  // Main analysis code
  gSystem->SetIncludePath("-I/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src");
  gSystem->Load("/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src/SusyAnalysis/SusyNtuplizer/macro/EventAnalyzer_cc.so");
  gSystem->Load("/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src/SusyAnalysis/SusyNtuplizer/macro/DongwookCategoryProducer_cc.so");

  /*now, ECAL/HCAL/track isolation cuts are meant to be matched with loose trigger cuts, so don't 
    use them (i.e. track isolation) to distinguish photon from fake!*/

  //configuration
  ParameterSet pars;
  pars.photonTag = "photons";
  pars.photon1ETMin = 40.0;
  pars.photon2ETMin = 30.0;
  pars.photonAbsEtaMax = 1.4442;
  pars.photonECALIsoMaxPTMultiplier = 0.012; /*https://twiki.cern.ch/twiki/bin/viewauth/CMS/
					       EgammaWorkingPointsv3, IsoVL, assuming dR = 0.3 
					       cone*/
  pars.photonECALIsoMaxConstant = 6.0; /*https://twiki.cern.ch/twiki/bin/viewauth/CMS/
					 EgammaWorkingPointsv3, IsoVL, assuming dR = 0.3 cone*/
  pars.photonECALIsoEffArea = 0.1474; /*https://twiki.cern.ch/twiki/bin/view/CMS/
					RA3IsolationConePileupCorrections, dR = 0.3 cone, 
					18-Oct-11*/
  pars.photonHCALIsoMaxPTMultiplier = 0.005; /*https://twiki.cern.ch/twiki/bin/viewauth/CMS/
					       EgammaWorkingPointsv3, IsoVL, assuming dR = 0.3 
					       cone*/
  pars.photonHCALIsoMaxConstant = 4.0; /*https://twiki.cern.ch/twiki/bin/viewauth/CMS/
					 EgammaWorkingPointsv3, IsoVL, assuming dR = 0.3 cone*/
  pars.photonHCALIsoEffArea = 0.0467; /*https://twiki.cern.ch/twiki/bin/view/CMS/
					RA3IsolationConePileupCorrections, dR = 0.3 cone, 
					18-Oct-11*/
  pars.photonHOverEMax = 0.05;
  pars.photonR9Max = 0.98;
  pars.photonTrackIsoMaxPTMultiplier = 0.002; /*https://twiki.cern.ch/twiki/bin/viewauth/CMS/
						EgammaWorkingPointsv3, IsoVL, assuming dR = 0.3 
						cone*/
  pars.photonTrackIsoMaxConstant = 4.0; /*https://twiki.cern.ch/twiki/bin/viewauth/CMS/
					  EgammaWorkingPointsv3, IsoVL, assuming dR = 0.3 cone*/
  pars.photonCombinedIsoMax = 6.0;
  pars.fakeCombinedIsoMax = 12.0;
  pars.isoConeHLT = DR03;
  pars.isoConeOffline = DR03;
  pars.photonSigmaIetaIetaMax = 0.011;
  pars.photonAbsSeedTimeMax = -1.0;
  pars.photonE2OverE9Max = -1.0;
  pars.photonDPhiMin = 0.05;
  pars.photonDRMin = 0.8;
  pars.pixelVetoOnFake = true;
  pars.treeName = "susyTree";
//   pars.input = VSTRING(1, "/data2/yohay/RA3/Data2011A_ToRun167913_Filter-JsonHLTtwo43-30GeVPhosWithR9HoverE_NoPileupCorr_Photon_NEW.root");
  pars.input = VSTRING();
FILES
  pars.HLT = vector<TString>();
  pars.HLT.push_back("HLT_Photon70_CaloIdL_HT300");
  pars.HLT.push_back("HLT_Photon70_CaloIdL_HT400");
  pars.HLT.push_back("HLT_Photon135");
  pars.HLT.push_back("HLT_Photon75_CaloIdVL_IsoL");
  pars.HLT.push_back("HLT_Photon125");
  pars.nEvts = -1;
  pars.JSON = "";
//   pars.JSON = "/afs/cern.ch/user/y/yohay/scratch0/CMSSW_4_2_4_patch2/src/SusyAnalysis/SusyNtuplizer/macro/JSON_160431-177878_May10ReReco_Run2011APromptRecov4v6_Aug5ReReco_Run2011BPromptRecov1.txt";
//   pars.outputFile = "/data2/yohay/RA3/Data2011A_ToRun167913_Filter-JsonHLTtwo43-30GeVPhosWithR9HoverE_NoPileupCorr_Photon_NEW_categorized_OR.root";
//   pars.outputFile = "/data2/yohay/RA3/1140pb-1_ff_categorized_new.root";
  pars.outputFile = "DATASET_JSON_HLT_PV_single_photon_skim.root";

  TStopwatch ts;

  ts.Start();

  DongwookCategoryProducer producer(pars);

  ts.Stop();

  std::cout << "RealTime : " << ts.RealTime()/60.0 << " minutes" << std::endl;
  std::cout << "CPUTime  : " << ts.CpuTime()/60.0 << " minutes" << std::endl;

}
Beispiel #17
0
void global_reco(Int_t nEvents = 100, Int_t seed = 555)
{
	gRandom->SetSeed(seed);

   TTree::SetMaxTreeSize(90000000000);
   TString script = TString(gSystem->Getenv("LIT_SCRIPT"));
   TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters");

   // Input and output data
   TString dir = "events/much_anna_omega_8gev_10k/"; // Output directory
   TString mcFile = dir + "mc.0000.root"; // MC transport file
   TString parFile = dir + "param.0000.root"; // Parameters file
   TString globalRecoFile = dir + "global.reco.0000.root"; // Output file with reconstructed tracks and hits

   // Digi files
   TList* parFileList = new TList();
   TObjString stsDigiFile = parDir + "/sts/sts_v12b_std.digi.par"; // STS digi file
   TObjString trdDigiFile = parDir + "/trd/trd_v13g.digi.par"; // TRD digi file
   TString muchDigiFile = parDir + "/much/much_v12c.digi.root"; // MUCH digi file
   TString stsMatBudgetFile = parDir + "/sts/sts_matbudget_v12b.root";
   TObjString tofDigiFile = parDir + "/tof/tof_v13b.digi.par";// TOF digi file

   // Reconstruction parameters
   TString globalTrackingType = "nn"; // Global tracking type
   TString trdHitProducerType = "smearing"; // TRD hit producer type: smearing, digi, clustering
   TString muchHitProducerType = "advanced"; // MUCH hit producer type: simple, advanced

   if (script == "yes") {
      mcFile = TString(gSystem->Getenv("LIT_MC_FILE"));
      parFile = TString(gSystem->Getenv("LIT_PAR_FILE"));
      globalRecoFile = TString(gSystem->Getenv("LIT_GLOBAL_RECO_FILE"));

      stsDigiFile = TString(gSystem->Getenv("LIT_STS_DIGI"));
      trdDigiFile = TString(gSystem->Getenv("LIT_TRD_DIGI"));
      muchDigiFile = TString(gSystem->Getenv("LIT_MUCH_DIGI"));
      tofDigiFile = TString(gSystem->Getenv("LIT_TOF_DIGI"));
      stsMatBudgetFile = TString(gSystem->Getenv("LIT_STS_MAT_BUDGET_FILE"));
   }

   parFileList->Add(&stsDigiFile);
   parFileList->Add(&trdDigiFile);
   parFileList->Add(&tofDigiFile);

	Int_t iVerbose = 1;
	TStopwatch timer;
	timer.Start();

	gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C");
	loadlibs();

	FairRunAna *run = new FairRunAna();
   run->SetInputFile(mcFile);
	run->SetOutputFile(globalRecoFile);


   // -----   STS  -------------------------------------------------
   Double_t threshold = 4;
   Double_t noiseWidth = 0.01;
   Int_t nofBits = 12;
   Double_t ElectronsPerAdc =  10.;
   Double_t StripDeadTime = 0.1;
   CbmStsDigitize* stsDigitize = new CbmStsDigitize("STS Digitiser", iVerbose);
   stsDigitize->SetRealisticResponse();
   stsDigitize->SetFrontThreshold(threshold);
   stsDigitize->SetBackThreshold(threshold);
   stsDigitize->SetFrontNoiseWidth(noiseWidth);
   stsDigitize->SetBackNoiseWidth(noiseWidth);
   stsDigitize->SetFrontNofBits(nofBits);
   stsDigitize->SetBackNofBits(nofBits);
   stsDigitize->SetFrontNofElPerAdc(ElectronsPerAdc);
   stsDigitize->SetBackNofElPerAdc(ElectronsPerAdc);
   stsDigitize->SetStripDeadTime(StripDeadTime);
   run->AddTask(stsDigitize);

   FairTask* stsClusterFinder = new CbmStsClusterFinder("STS Cluster Finder",iVerbose);
   run->AddTask(stsClusterFinder);

   FairTask* stsFindHits = new CbmStsFindHits("STS Hit Finder", iVerbose);
   run->AddTask(stsFindHits);

   FairTask* stsMatchHits = new CbmStsMatchHits("STS Hit Matcher", iVerbose);
   run->AddTask(stsMatchHits);

   FairTask* kalman = new CbmKF();
   run->AddTask(kalman);
   CbmL1* l1 = new CbmL1();
   //l1->SetExtrapolateToTheEndOfSTS(true);
   l1->SetMaterialBudgetFileName(stsMatBudgetFile);
   run->AddTask(l1);
   CbmStsTrackFinder* trackFinder = new CbmL1StsTrackFinder();
   FairTask* findTracks = new CbmStsFindTracks(iVerbose, trackFinder);
   run->AddTask(findTracks);

   FairTask* stsMatchTracks = new CbmStsMatchTracks("STSMatchTracks", iVerbose);
   run->AddTask(stsMatchTracks);
	// ------------------------------------------------------------------------

   if (IsMuch(parFile)) {
      // -------- MUCH digitization ------------
      CbmMuchDigitizeGem* digitize = new CbmMuchDigitizeGem(muchDigiFile.Data());
      if (muchHitProducerType == "simple") {
         digitize->SetAlgorithm(0);
      } else if (muchHitProducerType == "advanced") {
         digitize->SetAlgorithm(1);
      }
      run->AddTask(digitize);
      CbmMuchFindHitsGem* findHits = new CbmMuchFindHitsGem(muchDigiFile.Data());
      run->AddTask(findHits);

      CbmMuchDigitizeStraws* strawDigitize = new CbmMuchDigitizeStraws("MuchDigitizeStraws", muchDigiFile.Data(), iVerbose);
      run->AddTask(strawDigitize);
      CbmMuchFindHitsStraws* strawFindHits = new CbmMuchFindHitsStraws("MuchFindHitsStraws", muchDigiFile.Data(), iVerbose);
      strawFindHits->SetMerge(1);
      run->AddTask(strawFindHits);
      // -----------------------------------------------------------------
   }

   if (IsTrd(parFile)) {
      // ----- TRD reconstruction-----------------------------------------
      // Update of the values for the radiator F.U. 17.08.07
      Int_t trdNFoils = 130; // number of polyetylene foils
      Float_t trdDFoils = 0.0013; // thickness of 1 foil [cm]
      Float_t trdDGap = 0.02; // thickness of gap between foils [cm]
      Bool_t simpleTR = kTRUE; // use fast and simple version for TR production

      CbmTrdRadiator *radiator = new CbmTrdRadiator(simpleTR, trdNFoils, trdDFoils, trdDGap);

      if (trdHitProducerType == "smearing") {
         CbmTrdHitProducerSmearing* trdHitProd = new CbmTrdHitProducerSmearing(radiator);
         trdHitProd->SetUseDigiPar(false);
         run->AddTask(trdHitProd);
      } else if (trdHitProducerType == "digi") {
         CbmTrdDigitizer* trdDigitizer = new CbmTrdDigitizer(radiator);
         run->AddTask(trdDigitizer);

         CbmTrdHitProducerDigi* trdHitProd = new CbmTrdHitProducerDigi();
         run->AddTask(trdHitProd);
      } else if (trdHitProducerType == "clustering") {
         // ----- TRD clustering -----
         CbmTrdDigitizerPRF* trdClustering = new CbmTrdDigitizerPRF("TRD Clusterizer", "TRD task", radiator, false, true);
         run->AddTask(trdClustering);

         CbmTrdClusterFinderFast* trdClusterfindingfast = new CbmTrdClusterFinderFast(true, true, false, 5.0e-7);
         run->AddTask(trdClusterfindingfast);

         CbmTrdHitProducerCluster* trdClusterHitProducer = new CbmTrdHitProducerCluster();
         run->AddTask(trdClusterHitProducer);
         // ----- End TRD Clustering -----
      }
      // ------------------------------------------------------------------------
   }

   if (IsTof(parFile)) {
      // ------ TOF hits --------------------------------------------------------
      CbmTofHitProducerNew* tofHitProd = new CbmTofHitProducerNew("TOF HitProducerNew",iVerbose);
      tofHitProd->SetInitFromAscii(kFALSE);
      run->AddTask(tofHitProd);
      // ------------------------------------------------------------------------
   }

   // ------ Global track reconstruction -------------------------------------
   CbmLitFindGlobalTracks* finder = new CbmLitFindGlobalTracks();
   //CbmLitFindGlobalTracksParallel* finder = new CbmLitFindGlobalTracksParallel();
   // Tracking method to be used
   // "branch" - branching tracking
   // "nn" - nearest neighbor tracking
   // "nn_parallel" - nearest neighbor parallel tracking
   finder->SetTrackingType(std::string(globalTrackingType));

   // Hit-to-track merger method to be used
   // "nearest_hit" - assigns nearest hit to the track
   finder->SetMergerType("nearest_hit");

   run->AddTask(finder);

   if (IsTrd(parFile)) {
      CbmTrdMatchTracks* trdMatchTracks = new CbmTrdMatchTracks();
      run->AddTask(trdMatchTracks);
   }

   if (IsMuch(parFile)) {
      CbmMuchMatchTracks* muchMatchTracks = new CbmMuchMatchTracks();
      run->AddTask(muchMatchTracks);
   }

   // -----   Primary vertex finding   --------------------------------------
   CbmPrimaryVertexFinder* pvFinder = new CbmPVFinderKF();
   CbmFindPrimaryVertex* findVertex = new CbmFindPrimaryVertex(pvFinder);
   run->AddTask(findVertex);
   // -----------------------------------------------------------------------

	// -----  Parameter database   --------------------------------------------
	FairRuntimeDb* rtdb = run->GetRuntimeDb();
	FairParRootFileIo* parIo1 = new FairParRootFileIo();
	FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
	parIo1->open(parFile.Data());
	parIo2->open(parFileList, "in");
	rtdb->setFirstInput(parIo1);
	rtdb->setSecondInput(parIo2);
	rtdb->setOutput(parIo1);
	rtdb->saveOutput();
	// ------------------------------------------------------------------------

	// -----   Initialize and run   --------------------------------------------
	run->Init();
	run->Run(0, nEvents);
	// ------------------------------------------------------------------------

	// -----   Finish   -------------------------------------------------------
	timer.Stop();
 	cout << "Macro finished successfully." << endl;
   cout << "Test passed"<< endl;
   cout << " All ok " << endl;
	cout << "Output file is " << globalRecoFile << endl;
	cout << "Parameter file is " << parFile << endl;
	cout << "Real time " << timer.RealTime() << " s, CPU time "	<< timer.CpuTime() << " s" << endl;
	// ------------------------------------------------------------------------
}
void analysis_pbarp_Xi_test(int nevts=0){
  
  TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888);
  
  TStopwatch timer; 



  //Output File
  TString Path = "/private/puetz/mysimulations/analysis/pbarp_Xiplus_Ximinus/idealtracking/10000_events/";
  TString outPath = Path;
  TString OutputFile = outPath + "analysis_output_test.root";
  
  //Input simulation Files
  TString inPIDFile = Path + "pid_complete.root";
  TString inParFile = Path + "simparams.root";
  TString PIDParFile = TString( gSystem->Getenv("VMCWORKDIR")) + "/macro/params/all.par";
  
  //Initialization
  FairLogger::GetLogger()->SetLogToFile(kFALSE);
  FairRunAna* RunAna = new FairRunAna();
  FairRuntimeDb* rtdb = RunAna->GetRuntimeDb();
  RunAna->SetInputFile(inPIDFile);
  
  //setup parameter database
  FairParRootFileIo* parIo = new FairParRootFileIo();
  parIo->open(inParFile);
  FairParAsciiFileIo* parIoPID = new FairParAsciiFileIo();
  parIoPID->open(PIDParFile.Data(),"in");
  
  rtdb->setFirstInput(parIo);
  rtdb->setSecondInput(parIoPID);
  rtdb->setOutput(parIo);

  RunAna->SetOutputFile(OutputFile);
  RunAna->Init();

  //*** create tuples
  RhoTuple * ntpMC = new RhoTuple("ntpMC", "MCTruth info");
  RhoTuple * ntpPiMinus = new RhoTuple("ntpPiMinus", "PiMinus info");
  RhoTuple * ntpPiPlus = new RhoTuple("ntpPiPlus", "PiPlus info");
  RhoTuple * ntpProton = new RhoTuple("ntpProton", "Proton info");
  RhoTuple * ntpAntiProton = new RhoTuple("ntpAntiProton", "Antiproton info");
  RhoTuple * ntpLambda0 = new RhoTuple("ntpLambda0", "Lambda0 info");
  RhoTuple * ntpAntiLambda0 = new RhoTuple("ntpAntiLambda0", "AntiLambda0 info");
  RhoTuple * ntpXiMinus = new RhoTuple("ntpXiMinus", "XiMinus info");
  RhoTuple * ntpXiPlus = new RhoTuple("ntpXiPlus", "XiPlus info");
  RhoTuple * ntpXiSys = new RhoTuple("ntpXiSys", "XiMinus XiPlus system info");

  //Create output file 
  TFile *out = TFile::Open(outPath+"output_ana_test.root","RECREATE");

  // data reader Object
  PndAnalysis* theAnalysis = new PndAnalysis();
  if (nevts==0) nevts = theAnalysis->GetEntries();
  
  //RhoCandLists for analysis
  RhoCandList piplus, piminus, lambda0, antiLambda0, proton, antiProton, xiplus, ximinus, xiSys;
  RhoCandList NotCombinedPiMinus, CombinedPiMinus, CombinedPiPlus, NotCombinedPiPlus;
  RhoCandList SelectedProton, SelectedAntiProton, SelectedPiMinus, SelectedPiPlus;
  RhoCandList Lambda0Fit, AntiLambda0Fit, XiMinusFit, XiPlusFit;
  RhoCandList mclist, all;

  //Dummy RhoCandidate
  RhoCandidate * dummyCand = new RhoCandidate();


  //***Mass selector
  double m0_lambda0= TDatabasePDG::Instance()->GetParticle("Lambda0")->Mass();
  cout<<"Mass of Lambda0: "<<m0_lambda0<<endl;
  RhoMassParticleSelector * lambdaMassSelector = new RhoMassParticleSelector("lambda0", m0_lambda0, 0.3);
 
  double m0_Xi = TDatabasePDG::Instance()->GetParticle("Xi-")->Mass();
  cout<<"Mass of Xi-: "<<m0_Xi<<endl;
  RhoMassParticleSelector * xiMassSelector = new RhoMassParticleSelector("Xi-", m0_Xi, 0.3);

  double m0_pbarpsystem = TDatabasePDG::Instance()->GetParticle("pbarpSystem")->Mass();

  
  double pbarmom = 2.7;
  double p_m0 = TDatabasePDG::Instance()->GetParticle("proton")->Mass();
  TLorentzVector ini (0,0, pbarmom, sqrt(p_m0*p_m0+ pbarmom*pbarmom)+p_m0);
  TVector3 beamBoost = ini.BoostVector();
  
  PndRhoTupleQA qa(theAnalysis, pbarmom);
 
  int evt=-1;
  int index=0;

  while (theAnalysis->GetEvent() && ++evt<nevts){

    if ((evt%100)==0) cout << "evt "<< evt <<endl;
    cout << "Running event " << evt << endl;
		
    //***get MC list and store info
    theAnalysis->FillList(mclist, "McTruth");
    qa.qaMcList("", mclist, ntpMC);
    ntpMC->DumpData();
   	
		
	//if you want to print the hole MCTree uncomment the following
    /*
    for (int j=0;j<mclist.GetLength();++j)
    {
      RhoCandidate *mcmother = mclist[j]->TheMother();        // mother of mc particle         
      int muid = (mcmother==0x0) ? -1 : mcmother->GetTrackNumber(); // track ID of mother, if existing 
        
      cout << "Track "<< mclist[j]->GetTrackNumber()<<" (PDG:"<<mclist[j]->PdgCode() <<") has mother "<<muid;
      if (mclist[j]->NDaughters()>0) cout <<" and daughter(s) ";
	 for (k=0;k<mclist[j]->NDaughters();++k) cout <<mclist[j]->Daughter(k)->GetTrackNumber()<<"  ";
	cout<<endl;        
    }*/


    //***Setup event shape object
		
    TString PidSelection = "PidAlgoIdealCharged";//"PidAlgoMvd;PidAlgoStt;PidAlgoDrc";

    theAnalysis->FillList(all, "All", PidSelection);
    PndEventShape evsh(all, ini, 0.05, 0.1);
    
    //***Selection with no PID info
    theAnalysis->FillList(piminus, "PionAllMinus", PidSelection);
//    theAnalysis->FillList(NotCombinedPiMinus, "PionAllMinus", PidSelection);
//    theAnalysis->FillList(NotCombinedPiPlus, "PionAllPlus", PidSelection);
    theAnalysis->FillList(piplus, "PionAllPlus", PidSelection);
    theAnalysis->FillList(proton, "ProtonAllPlus", PidSelection);
    theAnalysis->FillList(antiProton, "ProtonAllMinus", PidSelection);



    for (int pip=0; pip<piplus.GetLength(); ++pip){
        ntpPiPlus->Column("ev",     (Float_t) evt);
        ntpPiPlus->Column("cand",    (Float_t) pip);
        ntpPiPlus->Column("ncand",   (Float_t) piplus.GetLength());
        ntpPiPlus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(piplus[pip]));


        qa.qaP4("PiPlus_", piplus[pip]->P4(), ntpPiPlus);
        qa.qaCand("PiPlus_", piplus[pip], ntpPiPlus);

        jenny::numberOfHitsInSubdetector("PiPlus_", piplus[pip], ntpPiPlus);
        jenny::tagNHits("PiPlus_", piplus[pip], ntpPiPlus);
        int tag = jenny::tagHits(piplus[pip]);


        RhoCandidate * mother_pip = piplus[pip]->GetMcTruth()->TheMother();
        int moth_pip = (0x0==mother_pip)? 88888 : mother_pip->PdgCode();

        ntpPiPlus->Column("Mother", (Float_t) moth_pip);
        ntpPiPlus->Column("PiPlus_CosTheta", (Float_t) piplus[pip]->GetMomentum().CosTheta());

        qa.qaP4("PiPlus_MC_", piplus[pip]->GetMcTruth()->P4(), ntpPiPlus);
        qa.qaCand("PiPlus_MC_", piplus[pip]->GetMcTruth(), ntpPiPlus);
        ntpPiPlus->Column("PiPlus_MC_CosTheta", (Float_t) piplus[pip]->GetMcTruth()->GetMomentum().CosTheta());

        if(tag==1){
        	SelectedPiPlus.Append(piplus[pip]);
        	NotCombinedPiPlus.Append(piplus[pip]);
        }

        ntpPiPlus->DumpData();
    }

    for (int pim=0; pim<piminus.GetLength(); ++pim){
        ntpPiMinus->Column("ev",     (Float_t) evt);
        ntpPiMinus->Column("cand",    (Float_t) pim);
        ntpPiMinus->Column("ncand",   (Float_t) piminus.GetLength());
        ntpPiMinus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(piminus[pim]));

        qa.qaP4("piminus_", piminus[pim]->P4(), ntpPiMinus);
        qa.qaCand("piminus_", piminus[pim], ntpPiMinus);

        jenny::numberOfHitsInSubdetector("piminus_", piminus[pim], ntpPiMinus);
        jenny::tagNHits("piminus_", piminus[pim], ntpPiMinus);
        int tag = jenny::tagHits(piminus[pim]);

        RhoCandidate * mother_pim = piminus[pim]->GetMcTruth()->TheMother();
        int moth_pim = (0x0==mother_pim)? 88888 : mother_pim->PdgCode();

        ntpPiMinus->Column("Mother", (Float_t) moth_pim);
        ntpPiMinus->Column("PiMinus_CosTheta", (Float_t) piminus[pim]->GetMomentum().CosTheta());

        qa.qaP4("piminus_MC_", piminus[pim]->GetMcTruth()->P4(), ntpPiMinus);
        qa.qaCand("piminus_MC_", piminus[pim]->GetMcTruth(), ntpPiMinus);
        ntpPiMinus->Column("piminus_MC_CosTheta", (Float_t) piminus[pim]->GetMcTruth()->GetMomentum().CosTheta());

        ntpPiMinus->DumpData();

        if(tag==1){
        	SelectedPiMinus.Append(piminus[pim]);
        	NotCombinedPiMinus.Append(piminus[pim]);
        }
    }

    for (int prot=0; prot<proton.GetLength(); ++prot){
        ntpProton->Column("ev",     (Float_t) evt);
        ntpProton->Column("cand",    (Float_t) prot);
        ntpProton->Column("ncand",   (Float_t) proton.GetLength());
        ntpProton->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(proton[prot]));

        qa.qaP4("proton_", proton[prot]->P4(), ntpProton);
        qa.qaCand("proton_", proton[prot], ntpProton);

        jenny::numberOfHitsInSubdetector("proton_", proton[prot], ntpProton);
//        jenny::tagNHits("proton_", proton[prot], ntpProton);

        int tag = jenny::tagHits(proton[prot]);

        RhoCandidate * mother_prot = proton[prot]->GetMcTruth()->TheMother();
        int moth_prot = (0x0==mother_prot)? 88888 : mother_prot->PdgCode();

        ntpProton->Column("Mother", (Float_t) moth_prot);
        ntpProton->Column("proton_CosTheta", (Float_t) proton[prot]->GetMomentum().CosTheta());

        qa.qaP4("proton_MC_", proton[prot]->GetMcTruth()->P4(), ntpProton);
        qa.qaCand("proton_", proton[prot]->GetMcTruth(), ntpProton);
        ntpProton->Column("proton_MC_CosTheta", (Float_t) proton[prot]->GetMcTruth()->GetMomentum().CosTheta());

        ntpProton->DumpData();

        if(tag==1) SelectedProton.Append(proton[prot]);

    }

    for (int aProt=0; aProt<antiProton.GetLength(); ++aProt){
        ntpAntiProton->Column("ev",     (Float_t) evt);
        ntpAntiProton->Column("cand",    (Float_t) aProt);
        ntpAntiProton->Column("ncand",   (Float_t) antiProton.GetLength());
        ntpAntiProton->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(antiProton[aProt]));

        qa.qaP4("antiProton_", antiProton[aProt]->P4(), ntpAntiProton);
        qa.qaCand("antiProton_", antiProton[aProt], ntpAntiProton);

        jenny::numberOfHitsInSubdetector("antiProton_", antiProton[aProt], ntpAntiProton);
//        jenny::tagNHits("antiProton_", antiProton[aProt], ntpAntiProton);
        int tag = jenny::tagHits(antiProton[aProt]);

        RhoCandidate * mother_aProt = antiProton[aProt]->GetMcTruth()->TheMother();
        int moth_aProt = (0x0==mother_aProt)? 88888 : mother_aProt->PdgCode();

        ntpAntiProton->Column("Mother", (Float_t) moth_aProt);
        ntpAntiProton->Column("antiProton_CosTheta", (Float_t) antiProton[aProt]->GetMomentum().CosTheta());


        qa.qaP4("antiProton_MC_", antiProton[aProt]->GetMcTruth()->P4(), ntpAntiProton);
        qa.qaCand("antiProton_", antiProton[aProt]->GetMcTruth(), ntpAntiProton);
        ntpAntiProton->Column("antiProton_MC_CosTheta", (Float_t) antiProton[aProt]->GetMcTruth()->GetMomentum().CosTheta());

        ntpAntiProton->DumpData();

        if(tag==1) SelectedAntiProton.Append(antiProton[aProt]);
    }





    //***Lambda0 -> PiMinus + Proton

    lambda0.Combine(SelectedPiMinus,SelectedProton);
	lambda0.Select(lambdaMassSelector);
    lambda0.SetType(kl0);

    std::map<int,int> bestVtxFitLambda0, bestMassFitLambda0;

    bestVtxFitLambda0 = jenny::VertexQaIndex(&lambda0);
    bestMassFitLambda0 = jenny::MassFitQaIndex(&lambda0, m0_lambda0);


    for (int j=0; j<lambda0.GetLength(); ++j){


      //general info about event
      ntpLambda0->Column("ev",     (Float_t) evt);
      ntpLambda0->Column("cand",    (Float_t) j);
      ntpLambda0->Column("ncand",   (Float_t) lambda0.GetLength());
      ntpLambda0->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(lambda0[j]));
      ntpLambda0->Column("Lambda0_Pdg", (Float_t) lambda0[j]->PdgCode());

	  RhoCandidate * mother = lambda0[j]->TheMother();
  	  int moth = (mother==0x0) ? 88888 : mother->PdgCode();

	  ntpLambda0->Column("Mother", (Float_t) moth);

      qa.qaP4("Lambda0_", lambda0[j]->P4(), ntpLambda0);
      qa.qaComp("Lambda0_", lambda0[j], ntpLambda0);


      // do vertex fit
      PndKinVtxFitter vertexfitterLambda0 (lambda0[j]);
	  vertexfitterLambda0.Fit();
      RhoCandidate * lambda0Fit = lambda0[j]->GetFit();


      // store info of vertex fit
      qa.qaFitter("VtxFit_", &vertexfitterLambda0, ntpLambda0);
      ntpLambda0->Column("VtxFit_HowGood", (Int_t) bestVtxFitLambda0[j]);
      qa.qaVtx("VtxFit_", lambda0Fit, ntpLambda0);

      // differenz to MCTruth
       qa.qaMcDiff("fvtxMcDiff_", lambda0Fit, ntpLambda0);


      // do mass fit
      PndKinFitter massFitterLambda0(lambda0Fit);
      massFitterLambda0.AddMassConstraint(m0_lambda0);
      massFitterLambda0.Fit();

      RhoCandidate * lambda0Fit_mass = lambda0Fit->GetFit();
      qa.qaFitter("MassFit_", &massFitterLambda0, ntpLambda0);

      ntpLambda0->Column("MassFit_HowGood", (Int_t) bestMassFitLambda0[j]);


      RhoCandidate * truth = lambda0[j]->GetMcTruth();
      RhoCandidate * truthDaughter = lambda0[j]->Daughter(0)->GetMcTruth();
      TLorentzVector l;
      TVector3 dl;

	    if(0x0 != truth){
	    	l = truth->P4();
	    	qa.qaVtx("McTruth_", truth, ntpLambda0);
	    	dl = truth->Daughter(0)->Pos();
	    }
	    else{
	    	qa.qaVtx("McTruth_", dummyCand, ntpLambda0);
	    }

      jenny::qaP3("McTruth_", dl, ntpLambda0);
      qa.qaP4("McTruth_", l, ntpLambda0);


      //*** use for Xi only bestChi2Cand

      if (bestVtxFitLambda0[j]==1 && bestMassFitLambda0[j]>0){
		  Lambda0Fit.Append(lambda0Fit);
		  jenny::CombinedList(lambda0Fit, &CombinedPiMinus, -211);
      }


      //***information of boosted particle
      lambda0Fit->Boost(-beamBoost);
      qa.qaComp("boost_", lambda0Fit, ntpLambda0);

      ntpLambda0->DumpData();


   }

    jenny::GetNotCombinedList(CombinedPiMinus, &NotCombinedPiMinus);


//     Lambda0Fit.Cleanup();
     CombinedPiMinus.Cleanup();
     SelectedPiMinus.Cleanup();
     SelectedProton.Cleanup();
//     NotCombinedPiMinus.Cleanup();
     bestVtxFitLambda0.clear();
     bestMassFitLambda0.clear();


    //***AntiLambda0 -> PiPlus + AntiProton
    antiLambda0.Combine(SelectedPiPlus,SelectedAntiProton);
	antiLambda0.Select(lambdaMassSelector);
    antiLambda0.SetType(kal0);

    std::map<int,int> bestVtxFitAntiLambda0, bestMassFitAntiLambda0;

    bestVtxFitAntiLambda0 = jenny::VertexQaIndex(&antiLambda0);
    bestMassFitAntiLambda0 = jenny::MassFitQaIndex(&antiLambda0, m0_lambda0);


    for (int j=0; j<antiLambda0.GetLength(); ++j){

      //general info about event
      ntpAntiLambda0->Column("ev",     (Float_t) evt);
      ntpAntiLambda0->Column("cand",    (Float_t) j);
      ntpAntiLambda0->Column("ncand",   (Float_t) antiLambda0.GetLength());
      ntpAntiLambda0->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(antiLambda0[j]));
      ntpAntiLambda0->Column("AntiLambda0_Pdg", (Float_t) antiLambda0[j]->PdgCode());

	  RhoCandidate * mother = antiLambda0[j]->TheMother();
	  int moth = (mother==0x0) ? 88888 : mother->PdgCode();
	  ntpAntiLambda0->Column("Mother", (Float_t) moth);

      qa.qaP4("AntiLambda0_", antiLambda0[j]->P4(), ntpAntiLambda0);
      qa.qaComp("AntiLambda0_", antiLambda0[j], ntpAntiLambda0);


      // do vertex fit
      PndKinVtxFitter vertexfitterAntiLambda0 (antiLambda0[j]);
      vertexfitterAntiLambda0.Fit();
      RhoCandidate * antiLambda0Fit = antiLambda0[j]->GetFit();



      // store info of vertex fit
      qa.qaFitter("VtxFit_", &vertexfitterAntiLambda0, ntpAntiLambda0);
      qa.qaVtx("VtxFit_", antiLambda0Fit, ntpAntiLambda0);

      ntpAntiLambda0->Column("VtxFit_HowGood", (Int_t) bestVtxFitAntiLambda0[j]);


      // do mass fit
      PndKinFitter massFitterAntiLambda0(antiLambda0Fit);
      massFitterAntiLambda0.AddMassConstraint(m0_lambda0);
      massFitterAntiLambda0.Fit();

      RhoCandidate * antiLambda0Fit_mass = antiLambda0Fit->GetFit();
      qa.qaFitter("MassFit_", &massFitterAntiLambda0, ntpAntiLambda0);
      ntpAntiLambda0->Column("MassFit_HowGood", (Int_t) bestMassFitAntiLambda0[j]);


      RhoCandidate * truth = antiLambda0[j]->GetMcTruth();

      TLorentzVector l;
      if(0x0 != truth){
				l = truth->P4();
				qa.qaVtx("MCTruth_", truth, ntpAntiLambda0);
      }
      else{
    	  qa.qaVtx("McTruth_", dummyCand, ntpAntiLambda0);
      }

      qa.qaP4("MCTruth_", l, ntpAntiLambda0);


      //***information of boosted particle
      antiLambda0Fit->Boost(-beamBoost);
      qa.qaComp("boost_", antiLambda0Fit, ntpAntiLambda0);



      if(bestVtxFitAntiLambda0[j]==1 && bestMassFitAntiLambda0[j]>0){
		  AntiLambda0Fit.Append(antiLambda0Fit);
		  jenny::CombinedList(antiLambda0Fit, &CombinedPiPlus, 211);
      }

      ntpAntiLambda0->DumpData();
    }

    jenny::GetNotCombinedList(CombinedPiPlus, &NotCombinedPiPlus);

	CombinedPiPlus.Cleanup();
	SelectedPiPlus.Cleanup();
	SelectedAntiProton.Cleanup();

    bestVtxFitAntiLambda0.clear();
    bestMassFitAntiLambda0.clear();



    //*** Xi- -> Lambda0 + Pi-
	ximinus.Combine(Lambda0Fit, NotCombinedPiMinus);
	ximinus.Select(xiMassSelector);
	ximinus.SetType(kXim);

	std::map<int,int> BestVtxFitXiMinus, BestMassFitXiMinus;

	BestVtxFitXiMinus = jenny::VertexQaIndex(&ximinus);
	BestMassFitXiMinus = jenny::MassFitQaIndex(&ximinus, m0_Xi);


    for (int j=0; j<ximinus.GetLength(); ++j){

      //general info about event
      ntpXiMinus->Column("ev",     (Float_t) evt);
      ntpXiMinus->Column("cand",    (Float_t) j);
      ntpXiMinus->Column("ncand",   (Float_t) ximinus.GetLength());
      ntpXiMinus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(ximinus[j]));
      ntpXiMinus->Column("XiMinus_Pdg", (Float_t) ximinus[j]->PdgCode());


	  RhoCandidate * mother = ximinus[j]->TheMother();
	  int moth = (mother==0x0) ? 88888 : mother->PdgCode();
	  ntpXiMinus->Column("Mother", (Float_t) moth);

      qa.qaP4("XiMinus_", ximinus[j]->P4(), ntpXiMinus);
      qa.qaComp("XiMinus_", ximinus[j], ntpXiMinus);
      qa.qaPoca("XiMinus_", ximinus[j], ntpXiMinus);



      // do vertex-fit

      PndKinVtxFitter vertexfitterXiMinus (ximinus[j]);
      vertexfitterXiMinus.Fit();
      RhoCandidate * ximinusFit = ximinus[j]->GetFit();


      // store info of vertex-fit

      qa.qaFitter("VtxFit_", &vertexfitterXiMinus, ntpXiMinus);
      ntpXiMinus->Column("VtxFit_HowGood", (Int_t) BestVtxFitXiMinus[j]);

      qa.qaVtx("VtxFit_", ximinusFit, ntpXiMinus);
//      qa.Cand("VtxFit_", ximinusFit, ntpXiMinus);


	  // difference to MCTruth
      qa.qaMcDiff("VtxFit_", ximinusFit, ntpXiMinus);




      // do mass fit
      PndKinFitter massFitterXiMinus(ximinusFit);
      massFitterXiMinus.AddMassConstraint(m0_lambda0);
      massFitterXiMinus.Fit();

      RhoCandidate * ximinusFit_mass = ximinusFit->GetFit();
      qa.qaFitter("MassFit_", &massFitterXiMinus, ntpXiMinus);
      ntpXiMinus->Column("MassFit_HowGood", (Int_t) BestMassFitXiMinus[j]);

      qa.qaMcDiff("MassFit_", ximinusFit_mass, ntpXiMinus);


      RhoCandidate * truth = ximinus[j]->GetMcTruth();
      TLorentzVector l;

      if(0x0 != truth){
				l = truth->P4();
				qa.qaVtx("MCTruth_", truth, ntpXiMinus);
      }
      else{
    	  qa.qaVtx("MCTruth_", dummyCand, ntpXiMinus);
      }

      qa.qaP4("MCTruth_", l, ntpXiMinus);

      if (BestVtxFitXiMinus[j]==1 && BestMassFitXiMinus[j]>0){
    	  XiMinusFit.Append(ximinusFit);
      }


      //***information of boosted particle
      ximinusFit->Boost(-beamBoost);
      qa.qaComp("boost_", ximinusFit, ntpXiMinus);

      ntpXiMinus->DumpData();


	}
    Lambda0Fit.Cleanup();
    NotCombinedPiMinus.Cleanup();

	BestVtxFitXiMinus.clear();
	BestMassFitXiMinus.clear();



	//*** Xi+ -> AntiLambda0 + Pi+
	xiplus.Combine(AntiLambda0Fit,piplus);
	xiplus.Select(xiMassSelector);
	xiplus.SetType(kaXip);

	std::map<int,int> BestVtxFitXiPlus, BestMassFitXiPlus;

	BestVtxFitXiPlus = jenny::VertexQaIndex(&xiplus);
	BestMassFitXiPlus = jenny::MassFitQaIndex(&xiplus, m0_Xi);

    for (int j=0; j<xiplus.GetLength(); ++j){

      //general info about event
      ntpXiPlus->Column("ev",     (Float_t) evt);
      ntpXiPlus->Column("cand",    (Float_t) j);
      ntpXiPlus->Column("ncand",   (Float_t) xiplus.GetLength());
      ntpXiPlus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(xiplus[j]));

      RhoCandidate * mother = xiplus[j]->TheMother();
      int moth = (mother==0x0) ? 88888 : mother->PdgCode();
      ntpXiPlus->Column("Mother", (Float_t) moth);

      qa.qaP4("Xiplus_", xiplus[j]->P4(), ntpXiPlus);
      qa.qaComp("Xiplus_", xiplus[j], ntpXiPlus);


//      int tag = 0;
//      int dtag[2] = {0,0};
//
//      for (int dau=0; dau<xiplus[j]->NDaughters(); dau++){
//
//    	  RhoCandidate * daughter = xiplus[j]->Daughter(dau);
//    	  if(daughter->IsComposite()){
//    		  int dtag1 = jenny::tagHits(daughter->Daughter(0));
//    		  int dtag2 = jenny::tagHits(daughter->Daughter(1));
//       		  if(dtag1==1 && dtag2==1) dtag[dau]=1;
//    	  }
//    	  else{
//    		  dtag[dau] = jenny::tagHits(daughter);
//    	  }
//	 }
//
//      if(dtag[0]==1 && dtag[1]==1) tag=1;
//
//      ntpXiPlus->Column("XiPlus_HitTag", (Int_t) tag);



      //******** do vertex-fit
      PndKinVtxFitter vertexfitterxiplus (xiplus[j]);
      vertexfitterxiplus.Fit();
      RhoCandidate * xiplusFit = xiplus[j]->GetFit();


      // store info of vertex-fit
      qa.qaFitter("VtxFit_", &vertexfitterxiplus, ntpXiPlus);
      ntpXiPlus->Column("VtxFit_HowGood", (Int_t) BestVtxFitXiPlus[j]);
      qa.qaVtx("VtxFit_", xiplusFit, ntpXiPlus);

	  // difference to MCTruth
      qa.qaMcDiff("VtxFit_", xiplusFit, ntpXiPlus);


      //****** do mass fit
      PndKinFitter massFitterxiplus(xiplusFit);
      massFitterxiplus.AddMassConstraint(m0_lambda0);
      massFitterxiplus.Fit();

      RhoCandidate * xiplusFit_mass = xiplusFit->GetFit();
      qa.qaFitter("MassFit_", &massFitterxiplus, ntpXiPlus);
      ntpXiPlus->Column("MassFit_HowGood", (float) BestMassFitXiPlus[j]);
      qa.qaVtx("MassFit_", xiplusFit_mass, ntpXiPlus);

      qa.qaMcDiff("MassFit_", xiplusFit_mass, ntpXiPlus);

      RhoCandidate * truth = xiplus[j]->GetMcTruth();
      TLorentzVector l;
      if(0x0 != truth){
				l = truth->P4();
				qa.qaVtx("MCTruth_", truth, ntpXiPlus);
      }
      else{
    	  qa.qaVtx("MCTruth_", dummyCand, ntpXiPlus);
      }

      qa.qaP4("MCTruth_", l, ntpXiPlus);


      if(BestVtxFitXiPlus[j]==1 && BestMassFitXiPlus[j]>0){
    	  XiPlusFit.Append(xiplusFit);
      }

      //***information of boosted particle
      xiplusFit->Boost(-beamBoost);
      qa.qaComp("boost_", xiplusFit, ntpXiPlus);

      ntpXiPlus->DumpData();
	 }

    AntiLambda0Fit.Cleanup();
//    BestCandAntiLambda0.Cleanup();
	BestVtxFitXiPlus.clear();
	BestMassFitXiPlus.clear();



    //******* Xi+ Xi- System*****************************

    xiSys.Combine(XiPlusFit, XiMinusFit);
    xiSys.SetType(88888);

    for (int syscand=0; syscand<xiSys.GetLength(); ++syscand){

		ntpXiSys->Column("ev",     (Float_t) evt);
		ntpXiSys->Column("cand",    (Float_t) j);
		ntpXiSys->Column("ncand",   (Float_t) ximinus.GetLength());
		ntpXiSys->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(xiSys[syscand]));

		RhoCandidate * mother = xiSys[syscand]->TheMother();
		int moth = (mother==0x0) ? 88888 : mother->PdgCode();
		ntpXiSys->Column("Mother", (Float_t) moth);

		qa.qaP4("XiSys_", xiSys[syscand]->P4(), ntpXiSys);
		qa.qaComp("XiSys_", xiSys[syscand], ntpXiSys);
		qa.qaPoca("XiSys_", xiSys[syscand], ntpXiSys);


		RhoCandidate *  truth = xiSys[syscand]->GetMcTruth();
		TLorentzVector l;

		if (truth != 0x0){
//			qa.qaComp("McTruth_", truth, ntpXiSys);
			qa.qaVtx("McTruth_", truth, ntpXiSys);
			l = truth->P4();
		}
		else{
//			qa.qaComp("McTruth_", dummyCand, ntpXiSys);
			qa.qaVtx("McTruth_", dummyCand, ntpXiSys);
		}
		qa.qaP4("McTruth_", l, ntpXiSys);


		//4C-Fitter

		PndKinFitter fitter4c (xiSys[syscand]);
		fitter4c.Add4MomConstraint(ini);
		fitter4c.Fit();

		RhoCandidate * xiSysFit4c = xiSys[syscand]->GetFit();

		qa.qaFitter("4CFit_", &fitter4c, ntpXiSys);
		qa.qaComp("4cFit_", xiSysFit4c, ntpXiSys);
		qa.qaVtx("4CFit_", xiSysFit4c, ntpXiSys);


		ntpXiSys->DumpData();


    }
    XiMinusFit.Cleanup();
    XiPlusFit.Cleanup();
  }



   

  //Write output
  out->cd();

  ntpMC -> GetInternalTree()->Write();
  ntpPiMinus ->GetInternalTree()->Write();
  ntpPiPlus->GetInternalTree()->Write();
  ntpProton->GetInternalTree()->Write();
  ntpAntiProton->GetInternalTree()->Write();
  ntpLambda0->GetInternalTree()->Write();
  ntpAntiLambda0->GetInternalTree()->Write();
  ntpXiMinus->GetInternalTree()->Write();
  ntpXiPlus->GetInternalTree()->Write();
  ntpXiSys->GetInternalTree()->Write();

  out->Save();
  

  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout<<endl<<endl;
  cout<<"Macro finisched successfully."<<endl;
  cout<<"Realtime: "<<rtime<<" s, CPU time: "<<ctime<<" s"<<endl;
  cout<<endl;

 
  exit(0);
 
}
sim_complete_boxgen_pions(Int_t nEvents = 100, TString pre="", Float_t mom = 6.231552,  TString  SimEngine ="TGeant3")
{
  //-----User Settings:-----------------------------------------------

  if(pre == ""){
	  TString  OutputFile		="sim_complete.root";
	  TString  ParOutputfile  	="simparams.root";
  }
  else{
	  TString  OutputFile 		= pre + "_sim_complete.root";
	  TString  ParOutputfile  	=pre + "_simparams.root";
  }


  TString  MediaFile      ="media_pnd.geo";
  gDebug                  = 0;
  TString digiFile        = "all.par"; //The emc run the hit producer directly
                                       // choose your event generator
  Bool_t UseEvtGenDirect      =kFALSE;
  Bool_t UseDpm 	      =kFALSE;
  Bool_t UseFtf 	      =kFALSE;
  Bool_t UseBoxGenerator      =kTRUE;
  
  TString evtPdlFile = "evt.pdl";

  Double_t BeamMomentum = 0.; // beam momentum ONLY for the scaling of the dipole field.
  if (UseBoxGenerator)
  {
    BeamMomentum   =mom; // ** change HERE if you run Box generator
  }
  else
  {
    BeamMomentum = mom;  // for DPM/EvtGen BeamMomentum is always = mom
  }
  //------------------------------------------------------------------
  TLorentzVector fIni(0, 0, mom, sqrt(mom*mom+9.3827203e-01*9.3827203e-01)+9.3827203e-01);
  TDatabasePDG::Instance()->AddParticle("pbarpSystem","pbarpSystem",fIni.M(),kFALSE,0.1,0, "",88888);
  //------------------------------------------------------------------
  TStopwatch timer;
  timer.Start();
  gRandom->SetSeed();
  
  // Create the Simulation run manager--------------------------------
  FairRunSim *fRun = new FairRunSim();
  fRun->SetName(SimEngine.Data() );
  fRun->SetOutputFile(OutputFile.Data());
  fRun->SetGenerateRunInfo(kFALSE);
  fRun->SetBeamMom(BeamMomentum);
  fRun->SetMaterials(MediaFile.Data());
  fRun->SetUseFairLinks(kTRUE);
  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
  
  // Set the parameters
  //-------------------------------
  TString allDigiFile = gSystem->Getenv("VMCWORKDIR");
  allDigiFile += "/macro/params/";
  allDigiFile += digiFile;
  
  
  //-------Set the parameter output --------------------
  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1->open(allDigiFile.Data(),"in");
  rtdb->setFirstInput(parIo1);
  
  //---------------------Set Parameter output      ----------
  Bool_t kParameterMerged=kTRUE;
  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
  output->open(ParOutputfile.Data());
  rtdb->setOutput(output);
  
  // Create and add detectors
  
  //-------------------------  CAVE      -----------------
  
  FairModule *Cave= new PndCave("CAVE");
  Cave->SetGeometryFileName("pndcave.geo");
  fRun->AddModule(Cave);
  //-------------------------  Magnet   -----------------
  //FairModule *Magnet= new PndMagnet("MAGNET");
  //Magnet->SetGeometryFileName("FullSolenoid_V842.root");
  //Magnet->SetGeometryFileName("FullSuperconductingSolenoid_v831.root");
  //fRun->AddModule(Magnet);
  FairModule *Dipole= new PndMagnet("MAGNET");
  Dipole->SetGeometryFileName("dipole.geo");
  fRun->AddModule(Dipole);
  //-------------------------  Pipe     -----------------
  FairModule *Pipe= new PndPipe("PIPE");
  Pipe->SetGeometryFileName("beampipe_201309.root");
  fRun->AddModule(Pipe);
  //-------------------------  STT       -----------------
  FairDetector *Stt= new PndStt("STT", kTRUE);
  Stt->SetGeometryFileName("straws_skewed_blocks_35cm_pipe.geo");
  fRun->AddModule(Stt);
  //-------------------------  MVD       -----------------
  FairDetector *Mvd = new PndMvdDetector("MVD", kTRUE);
  Mvd->SetGeometryFileName("Mvd-2.1_FullVersion.root");
  fRun->AddModule(Mvd);
  //-------------------------  GEM       -----------------
  FairDetector *Gem = new PndGemDetector("GEM", kTRUE);
  Gem->SetGeometryFileName("gem_3Stations_Tube.root");
  fRun->AddModule(Gem);
  //-------------------------  EMC       -----------------
  PndEmc *Emc = new PndEmc("EMC",kTRUE);
  Emc->SetGeometryVersion(1);
  Emc->SetStorageOfData(kFALSE);
  fRun->AddModule(Emc);
  //-------------------------  SCITIL    -----------------
  FairDetector *SciT = new PndSciT("SCIT",kTRUE);
  SciT->SetGeometryFileName("SciTil_201504.root");
  fRun->AddModule(SciT);
  //-------------------------  DRC       -----------------
  PndDrc *Drc = new PndDrc("DIRC", kTRUE);
  Drc->SetGeometryFileName("dirc_l0_p0_updated.root");
  Drc->SetRunCherenkov(kFALSE);
  fRun->AddModule(Drc);
  //-------------------------  DISC      -----------------
  PndDsk* Dsk = new PndDsk("DSK", kTRUE);
  Dsk->SetStoreCerenkovs(kFALSE);
  Dsk->SetStoreTrackPoints(kFALSE);
  fRun->AddModule(Dsk);
  //-------------------------  MDT       -----------------
  PndMdt *Muo = new PndMdt("MDT",kTRUE);
  Muo->SetBarrel("fast");
  Muo->SetEndcap("fast");
  Muo->SetMuonFilter("fast");
  Muo->SetForward("fast");
  Muo->SetMdtMagnet(kTRUE);
  Muo->SetMdtCoil(kTRUE);
  Muo->SetMdtMFIron(kTRUE);
  fRun->AddModule(Muo);
  //-------------------------  FTS       -----------------
  FairDetector *Fts= new PndFts("FTS", kTRUE);
  Fts->SetGeometryFileName("fts.geo");
  fRun->AddModule(Fts);
  //-------------------------  FTOF      -----------------
  FairDetector *FTof = new PndFtof("FTOF",kTRUE);
  FTof->SetGeometryFileName("ftofwall.root");
  fRun->AddModule(FTof);
  //-------------------------  RICH       ----------------
  FairDetector *Rich= new PndRich("RICH",kFALSE);
  Rich->SetGeometryFileName("rich_v2_shift.geo");
  fRun->AddModule(Rich);
  
  // Create and Set Event Generator
  //-------------------------------
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
  fRun->SetGenerator(primGen);
	 
  if(UseBoxGenerator){	// Box Generator
	  FairBoxGenerator* boxGenPiM = new FairBoxGenerator(-211, 1); // 13 = muon; 1 = multipl.
    boxGenPiM->SetPRange(0., 0.6); // GeV/c
    boxGenPiM->SetPhiRange(0., 360.); // Azimuth angle range [degree]
    boxGenPiM->SetThetaRange(0., 70); // Polar angle in lab system range [degree]
    boxGenPiM->SetXYZ(0., 0., 0.); // cm
    primGen->AddGenerator(boxGenPiM);

    FairBoxGenerator* boxGenPiP = new FairBoxGenerator(211, 1); // 13 = muon; 1 = multipl.
	boxGenPiP->SetPRange(0.,0.6); // GeV/c
	boxGenPiP->SetPhiRange(0., 360.); // Azimuth angle range [degree]
	boxGenPiP->SetThetaRange(0., 70); // Polar angle in lab system range [degree]
	boxGenPiP->SetXYZ(0., 0., 0.); // cm
	primGen->AddGenerator(boxGenPiP);

  }
  if(UseDpm){
    PndDpmDirect *Dpm= new PndDpmDirect(mom,1);
    primGen->AddGenerator(Dpm);
  }
  if(UseFtf){
    //          TString macfile = gSystem->Getenv("VMCWORKDIR");
    //	  macfile += "/pgenerators/FtfEvtGen/PbarP.mac";
    //	  PndFtfDirect *Ftf = new PndFtfDirect(macfile.Data());
    PndFtfDirect *Ftf = new PndFtfDirect("anti_proton", "G4_H", 1, "ftfp", mom, 123456);
    primGen->AddGenerator(Ftf);
  }
  if(UseEvtGenDirect){
//    TString  EvtInput =gSystem->Getenv("VMCWORKDIR");
//    EvtInput+="/macro/run/psi2s_Jpsi2pi_Jpsi_mumu.dec";
	  TString EvtInput="/home/ikp1/puetz/panda/mysimulations/analysis/XiMinus_1820_lambda0_K.dec";
//    PndEvtGenDirect *EvtGen = new PndEvtGenDirect("pbarpSystem", EvtInput.Data(), mom);
	  PndEvtGenDirect * EvtGen = new PndEvtGenDirect("pbarpSystem", EvtInput.Data(), mom, -1, "", evtPdlFile.Data());
    EvtGen->SetStoreTree(kTRUE);
    primGen->AddGenerator(EvtGen);
  }
  
  //---------------------Create and Set the Field(s)----------
  PndMultiField *fField= new PndMultiField("AUTO");
  fRun->SetField(fField);
  
  // EMC Hit producer
  //-------------------------------
  PndEmcHitProducer* emcHitProd = new PndEmcHitProducer();
  fRun->AddTask(emcHitProd);
  
  //-------------------------  Initialize the RUN  -----------------
  fRun->Init();
  //-------------------------  Run the Simulation  -----------------
  fRun->Run(nEvents);
  //-------------------------  Save the parameters -----------------
  rtdb->saveOutput();
  //------------------------Print some info and exit----------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
  
  cout << " Test passed" << endl;
  cout << " All ok " << endl;
  
  exit(0);
  
};
Beispiel #20
0
// Macro created 20/09/2006 by S.Spataro
// It creates a geant simulation file for emc
run_sim_tpc_dpm(Int_t nEvents=10, Float_t mom = 3.6772, Int_t mode =1, UInt_t seed=0){

  gRandom->SetSeed(seed);

  TStopwatch timer;
  timer.Start();
  gDebug=0;
  // Load basic libraries
  // If it does not work,  please check the path of the libs and put it by hands
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
  rootlogon();
  
  TString digiFile = "all.par";
  TString parFile = "dpm_params_tpc.root";
  TString mcMode = "TGeant3";
  FairRunSim *fRun = new FairRunSim();

  // set the MC version used
  // ------------------------

  fRun->SetName(mcMode);
  fRun->SetOutputFile("dpm_points_tpc.root");

  // Set the parameters
  //-------------------------------
  TString allDigiFile = gSystem->Getenv("VMCWORKDIR");
  allDigiFile += "/macro/params/";
  allDigiFile += digiFile;
 
  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1->open(allDigiFile.Data(),"in");
  rtdb->setFirstInput(parIo1);        
  Bool_t kParameterMerged=kTRUE;
	
  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
  output->open(parFile);
  rtdb->setOutput(output);
  
  // Set Material file Name
  //-----------------------
  fRun->SetMaterials("media_pnd.geo");

  // Create and add detectors
  //-------------------------
  FairModule *Cave= new PndCave("CAVE");
  Cave->SetGeometryFileName("pndcave.geo");
  fRun->AddModule(Cave); 

  FairModule *Magnet= new PndMagnet("MAGNET");
  //Magnet->SetGeometryFileName("FullSolenoid_V842.root");
  Magnet->SetGeometryFileName("FullSuperconductingSolenoid_v831.root");
  fRun->AddModule(Magnet);
  
  FairModule *Pipe= new PndPipe("PIPE");
  fRun->AddModule(Pipe);

  PndTpcDetector *Tpc = new PndTpcDetector("TPC", kTRUE);
  Tpc->SetGeometryFileName("TPC_V1.1.root");    //new ROOT geometry
  if(mcMode=="TGeant3")  Tpc->SetAliMC();
  fRun->AddModule(Tpc);

  FairDetector *Mvd = new PndMvdDetector("MVD", kTRUE);
  Mvd->SetGeometryFileName("Mvd-2.1_FullVersion.root");
  fRun->AddModule(Mvd);

  PndEmc *Emc = new PndEmc("EMC",kFALSE);
  Emc->SetGeometryVersion(19);
  Emc->SetStorageOfData(kFALSE);
  fRun->AddModule(Emc);

  //PndMdt *Muo = new PndMdt("MDT",kTRUE);
  //Muo->SetMdtMagnet(kTRUE);
//  Muo->SetMdtMFIron(kFALSE);
  //Muo->SetMdtCoil(kTRUE);
  //Muo->SetBarrel("muon_TS_barrel_strip_v1_noGeo.root");
  //Muo->SetEndcap("muon_TS_endcap_strip_v1_noGeo.root");
  //Muo->SetForward("muon_Forward_strip_v1_noGeo.root");
  //Muo->SetMuonFilter("muon_MuonFilter_strip_v1_noGeo.root");
  //fRun->AddModule(Muo);
  
  FairDetector *Gem = new PndGemDetector("GEM", kTRUE);
  Gem->SetGeometryFileName("gem_3Stations.root");
  fRun->AddModule(Gem);

  PndDsk* Dsk = new PndDsk("DSK", kFALSE);
  Dsk->SetGeometryFileName("dsk.root");
  Dsk->SetStoreCerenkovs(kFALSE);
  Dsk->SetStoreTrackPoints(kFALSE);
  fRun->AddModule(Dsk);

  PndDrc *Drc = new PndDrc("DIRC", kFALSE);
  Drc->SetGeometryFileName("dirc_l0_p0.root");
  Drc->SetRunCherenkov(kFALSE); // for fast sim Cherenkov -> kFALSE
  fRun->AddModule(Drc);
  
  // Create and Set Event Generator
  //-------------------------------

  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
  primGen->SetTarget(0., 0.5/2.355);
  primGen->SmearVertexZ(kTRUE);
  primGen->SmearGausVertexZ(kTRUE);
  primGen->SetBeam(0., 0., 0.1, 0.1);
  primGen->SmearVertexXY(kTRUE);
  fRun->SetGenerator(primGen);

  PndDpmDirect *dpmGen = new PndDpmDirect(mom,mode, gRandom->GetSeed());
  primGen->AddGenerator(dpmGen);

  // Create and Set Magnetic Field
  //-------------------------------
  fRun->SetBeamMom(mom);
  PndMultiField *fField= new PndMultiField("FULL");
  fRun->SetField(fField);

  /**Initialize the session*/
  fRun->Init();
  
  rtdb->setOutput(output);
  rtdb->saveOutput();
  rtdb->print();

  // Transport nEvents
  // -----------------
  fRun->Run(nEvents);

  timer.Stop();

  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);

}
Beispiel #21
0
void run_sim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Int_t fileId = 0)
{
  
  TString dir = getenv("VMCWORKDIR");
  TString tutdir = dir + "/MQ/9-PixelDetector";

  TString tut_geomdir = dir + "/common/geometry";
  gSystem->Setenv("GEOMPATH",tut_geomdir.Data());

  TString tut_configdir = dir + "/common/gconfig";
  gSystem->Setenv("CONFIG_DIR",tut_configdir.Data());

  TString partName[] = {"pions","eplus","proton"};
  Int_t   partPdgC[] = {    211,     11,    2212};
  Int_t chosenPart  = 0;
  

  TString outDir = "./";

  // Output file name
  TString outFile;
  if ( fileId == 0 )  outFile = Form("%s/pixel_%s.mc.root",
				     outDir.Data(),
				     mcEngine.Data());
  else                outFile = Form("%s/pixel_%s.mc.f%d.root",
				     outDir.Data(),
				     mcEngine.Data(),
				     fileId);
  
  // Parameter file name
  TString parFile = Form("%s/pixel_%s.params.root",
			 outDir.Data(),
			 mcEngine.Data());

  // In general, the following parts need not be touched
  // ========================================================================

  // ----    Debug option   -------------------------------------------------
  gDebug = 0;
  // ------------------------------------------------------------------------

  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;
  timer.Start();
  // ------------------------------------------------------------------------

  // -----   Create simulation run   ----------------------------------------
  FairRunSim* run = new FairRunSim();
  run->SetName(mcEngine);              // Transport engine
  run->SetOutputFile(outFile);          // Output file
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
  // ------------------------------------------------------------------------
  
  // -----   Create media   -------------------------------------------------
  run->SetMaterials("media.geo");       // Materials
  // ------------------------------------------------------------------------
  
  // -----   Create geometry   ----------------------------------------------

  FairModule* cave= new FairCave("CAVE");
  cave->SetGeometryFileName("cave_vacuum.geo");
  run->AddModule(cave);

  Pixel*  det = new Pixel("Tut9", kTRUE);
  det->SetGeometryFileName("pixel.geo");
//  det->SetMisalignDetector(kTRUE);
  run->AddModule(det);
  // ------------------------------------------------------------------------

  // -----   Create PrimaryGenerator   --------------------------------------
  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
  FairBoxGenerator* boxGen = new FairBoxGenerator(partPdgC[chosenPart], 5);
  boxGen->SetPRange(1,2);
  boxGen->SetThetaRange(0,40);
  boxGen->SetPhiRange(0,360);
  //  boxGen->SetDebug(kTRUE);

  primGen->AddGenerator(boxGen);

  
  run->SetGenerator(primGen);
  // ------------------------------------------------------------------------

  run->SetStoreTraj(kFALSE);
   
  // -----   Initialize simulation run   ------------------------------------
  run->Init();
  // ------------------------------------------------------------------------

  // -----   Runtime database   ---------------------------------------------

  Bool_t kParameterMerged = kTRUE;
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
  parOut->open(parFile.Data());
  rtdb->setOutput(parOut);
  rtdb->saveOutput();
  rtdb->print();
  // ------------------------------------------------------------------------

  // -----   Start run   ----------------------------------------------------
  run->Run(nEvents);
  run->CreateGeometryFile("geofile_full.root");
  // ------------------------------------------------------------------------
  
  // -----   Finish   -------------------------------------------------------

  cout << endl << endl;

  // Extract the maximal used memory an add is as Dart measurement
  // This line is filtered by CTest and the value send to CDash
  FairSystemInfo sysInfo;
  Float_t maxMemory=sysInfo.GetMaxMemory();
  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
  cout << maxMemory;
  cout << "</DartMeasurement>" << endl;

  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();

  Float_t cpuUsage=ctime/rtime;
  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
  cout << cpuUsage;
  cout << "</DartMeasurement>" << endl;

  cout << endl << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime
       << "s" << endl << endl;
  cout << "Macro finished successfully." << endl;

  // ------------------------------------------------------------------------
}
Beispiel #22
0
void run_unpack_alpha
(TString dataFile = "runfiles/NSCL/alphas/alpha_run_0100.txt",TString parameterFile = "ATTPC.alpha.par",
TString mappath="/data/ar46/run_0085/")
{

  // -----   Timer   --------------------------------------------------------
 TStopwatch timer;
 timer.Start();
 // ------------------------------------------------------------------------

  gSystem->Load("libXMLParser.so");
  // -----------------------------------------------------------------
  // Set file names
  TString scriptfile = "Lookup20150611.xml";
  TString dir = getenv("VMCWORKDIR");
  TString scriptdir = dir + "/scripts/"+ scriptfile;
  TString dataDir = dir + "/macro/data/";
  TString geomDir = dir + "/geometry/";
  gSystem -> Setenv("GEOMPATH", geomDir.Data());

  //TString inputFile   = dataDir + name + ".digi.root";
  //TString outputFile  = dataDir + "output.root";
  TString outputFile  = "output.root";
  //TString mcParFile   = dataDir + name + ".params.root";
  TString loggerFile  = dataDir + "ATTPCLog.log";
  TString digiParFile = dir + "/parameters/" + parameterFile;
  TString geoManFile  = dir + "/geometry/ATTPC_v1.2.root";

  TString inimap   = mappath + "inhib.txt";
  TString lowgmap  = mappath + "lowgain.txt";
  TString xtalkmap = mappath + "beampads_e15503b.txt";

  // -----------------------------------------------------------------
  // Logger
  FairLogger *fLogger = FairLogger::GetLogger();
  fLogger -> SetLogFileName(loggerFile);
  fLogger -> SetLogToScreen(kTRUE);
  fLogger -> SetLogToFile(kTRUE);
  fLogger -> SetLogVerbosityLevel("LOW");

  FairRunAna* run = new FairRunAna();
  run -> SetOutputFile(outputFile);
  //run -> SetGeomFile("../geometry/ATTPC_Proto_v1.0.root");
  run -> SetGeomFile(geoManFile);

  FairRuntimeDb* rtdb = run->GetRuntimeDb();
  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
  parIo1 -> open(digiParFile.Data(), "in");
  //FairParRootFileIo* parIo2 = new FairParRootFileIo();
  //parIo2 -> open("param.dummy_proto.root");
 // rtdb -> setFirstInput(parIo2);
  rtdb -> setSecondInput(parIo1);

  // Settings
  Bool_t fUseDecoder = kTRUE;
  if (dataFile.IsNull() == kTRUE)
    fUseDecoder = kFALSE;

  Bool_t fUseSeparatedData = kFALSE;
    if (dataFile.EndsWith(".txt"))
      fUseSeparatedData = kTRUE;

 /*
  *     Unpacking options:
  *         - SetUseSeparatedData:      To be used with 10 CoBo files without merging. Mainly for the ATTPC. Enabled if the input file is a txt.
  *         - SetPseudoTopologyFrame:   Used to force the graw file to have a Topology frame.
  *         - SetPersistance:           Save the unpacked data into the root file.
  *         - SetMap:                   Chose the lookup table.
  *         - SetMapOpt                 Chose the pad plane geometry. In addition forces the unpacker to use Basic Frames for 1 single file (p-ATTPC case) of Layered
  *                                     Frames for Merged Data (10 Cobos merged data).
  */
  ATDecoder2Task *fDecoderTask = new ATDecoder2Task();
  fDecoderTask -> SetUseSeparatedData(fUseSeparatedData);
  if(fUseSeparatedData) fDecoderTask -> SetPseudoTopologyFrame(kTRUE);//! This calls the method 10 times so for less than 10 CoBos ATCore2 must be modified
  //fDecoderTask -> SetPositivePolarity(kTRUE);
  fDecoderTask -> SetPersistence(kFALSE);
  fDecoderTask -> SetMap(scriptdir.Data());
  //fDecoderTask -> SetInhibitMaps(inimap,lowgmap,xtalkmap); // TODO: Only implemented for fUseSeparatedData!!!!!!!!!!!!!!!!!!!1
  fDecoderTask -> SetMapOpt(0); // ATTPC : 0  - Prototype: 1 |||| Default value = 0
  fDecoderTask -> SetNumCobo(9);
  fDecoderTask -> SetEventID(0);


  /*if (!fUseSeparatedData)
    fDecoderTask -> AddData(dataFile);
  else {
    std::ifstream listFile(dataFile.Data());
    TString dataFileWithPath;
    Int_t iCobo = 0;
    while (dataFileWithPath.ReadLine(listFile)) {
        if (dataFileWithPath.Contains(Form("CoBo%i",iCobo)) )
              fDecoderTask -> AddData(dataFileWithPath, iCobo);
        else{
          iCobo++;
          fDecoderTask -> AddData(dataFileWithPath, iCobo);
        }
    }
  }*/

  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo0_run_0100_11Dec14_22h03m15s.graw",0);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo1_run_0100_11Dec14_22h03m15s.graw",1);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo2_run_0100_11Dec14_22h03m15s.graw",2);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo2_run_0100_11Dec14_22h03m15s.1.graw",2);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo3_run_0100_11Dec14_22h03m16s.graw",3);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo4_run_0100_11Dec14_22h03m16s.graw",4);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo6_run_0100_11Dec14_22h03m16s.graw",5);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo7_run_0100_11Dec14_22h03m16s.graw",6);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo7_run_0100_11Dec14_22h03m16s.1.graw",6);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo8_run_0100_11Dec14_22h03m16s.graw",7);
  fDecoderTask -> AddData("/data/ND/2013/buffer/NSCL_Alpha/run_0100/CoBo9_run_0100_11Dec14_22h03m16s.graw",8);

  run -> AddTask(fDecoderTask);

  ATPSATask *psaTask = new ATPSATask();
  psaTask -> SetPersistence(kTRUE);
  psaTask -> SetThreshold(20);
  psaTask -> SetPSAMode(1); //NB: 1 is ATTPC - 2 is pATTPC
	//psaTask -> SetPeakFinder(); //NB: Use either peak finder of maximum finder but not both at the same time
	psaTask -> SetMaxFinder();
  psaTask -> SetBaseCorrection(kTRUE); //Directly apply the base line correction to the pulse amplitude to correct for the mesh induction. If false the correction is just saved
  psaTask -> SetTimeCorrection(kFALSE); //Interpolation around the maximum of the signal peak
  run -> AddTask(psaTask);

  ATHoughTask *HoughTask = new ATHoughTask();
	HoughTask ->SetPersistence();
	HoughTask ->SetLinearHough();
	//HoughTask ->SetCircularHough();
  HoughTask ->SetHoughThreshold(100.0); // Charge threshold for Hough
  HoughTask ->SetHoughDistance(5.0);//This is the distance to reject points from a given linear Hough Space
	run -> AddTask(HoughTask);


  run -> Init();

  //run -> RunOnTBData();
  run->Run(0,200);

  std::cout << std::endl << std::endl;
  std::cout << "Macro finished succesfully."  << std::endl << std::endl;
  std::cout << "- Output file : " << outputFile << std::endl << std::endl;
  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ------------------------------------------------------------------------

  //gApplication->Terminate();

}
Beispiel #23
0
void RAA_read_mb_data_pbpb(int startfile = 8,
			   int endfile = 9,
			   int radius = 3,
			   std::string kFoname="test_output.root",
			   int ptCut = 15){
  
  TStopwatch timer;
  timer.Start();
  
  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();

  gStyle->SetOptStat(0);

  bool printDebug = false;
  if(printDebug)cout<<"radius = "<<radius<<endl;
  
  TDatime date;

  std::string infile_Forest;
  std::string infile_Select;

  infile_Forest = "jetRAA_PbPb_MB_data_forest.txt";
  infile_Select = Form("jetRAA_PbPb_MB_data_akPu%d_select.txt",radius);
  std::ifstream instr_Forest(infile_Forest.c_str(),std::ifstream::in);
  std::string filename_Forest;
  std::ifstream instr_Select(infile_Select.c_str(),std::ifstream::in);
  std::string filename_Select;
  
  if(printDebug)cout<<"reading from "<<startfile<<" to "<<endfile<<endl;
  
  for(int ifile = 0;ifile<startfile;ifile++){
    instr_Forest>>filename_Forest;
    instr_Select>>filename_Select;
  }

  const int N = 5; //6

  TChain * jetpbpb[N];
  TChain * evt_select, * jet_select; 

  string dir[N];
  dir[0] = "hltanalysis";
  dir[1] = "skimanalysis";
  dir[2] = Form("akPu%dPFJetAnalyzer",radius);
  dir[3] = "akPu3CaloJetAnalyzer";
  dir[4] = "hiEvtAnalyzer";
  // dir[4] = "hltobject";

  string trees[N] = {
    "HltTree",
    "HltTree",
    "t",
    "t",
    "HiTree"
    // , "jetObjTree"
  };

  for(int t = 0;t<N;t++){
    jetpbpb[t] = new TChain(string(dir[t]+"/"+trees[t]).data());
  }//tree loop ends

  evt_select = new TChain(Form("akPu%dJetAnalyzer/evtTree",radius));
  jet_select = new TChain(Form("akPu%dJetAnalyzer/jetTree",radius));

  for(int ifile = startfile; ifile<endfile; ++ifile){

    instr_Forest>>filename_Forest;
    instr_Select>>filename_Select;

    if(printDebug)cout<<"HiForest filename = "<<filename_Forest.c_str()<<endl;

    jetpbpb[0]->Add(filename_Forest.c_str());
    jetpbpb[1]->Add(filename_Forest.c_str());
    jetpbpb[2]->Add(filename_Forest.c_str());
    jetpbpb[3]->Add(filename_Forest.c_str());
    jetpbpb[4]->Add(filename_Forest.c_str());
    jet_select->Add(filename_Select.c_str());
    evt_select->Add(filename_Select.c_str());
    
    if(printDebug)cout << "Tree loaded  " << string(dir[0]+"/"+trees[0]).data() << endl;
    if(printDebug)cout << "Entries : " << jetpbpb[0]->GetEntries() << endl;
    if(printDebug)cout << "Tree loaded  " << string(dir[1]+"/"+trees[1]).data() << endl;
    if(printDebug)cout << "Entries : " << jetpbpb[1]->GetEntries() << endl;
    if(printDebug)cout << "Tree loaded  " << string(dir[2]+"/"+trees[2]).data() << endl;
    if(printDebug)cout << "Entries : " << jetpbpb[2]->GetEntries() << endl;
    if(printDebug)cout << "Tree loaded  " << string(dir[3]+"/"+trees[3]).data() << endl;
    if(printDebug)cout << "Entries : " << jetpbpb[3]->GetEntries() << endl;
    if(printDebug)cout << "Tree loaded  " << string(dir[4]+"/"+trees[4]).data() << endl;
    if(printDebug)cout << "Entries : " << jetpbpb[4]->GetEntries() << endl;
    if(printDebug)cout << "jet selection file " << jet_select->GetEntries() << endl;
    if(printDebug)cout << "event selection file" << evt_select->GetEntries() << endl;

  }
  
  jetpbpb[2]->AddFriend(jetpbpb[0]);
  jetpbpb[2]->AddFriend(jetpbpb[1]);
  jetpbpb[2]->AddFriend(jetpbpb[4]);
  jetpbpb[3]->AddFriend(jetpbpb[0]);
  jetpbpb[3]->AddFriend(jetpbpb[1]);
  jetpbpb[3]->AddFriend(jetpbpb[4]);
  
  jetpbpb[2]->AddFriend(evt_select);
  jetpbpb[3]->AddFriend(evt_select);

  // Forest files 
  int nref_F;
  float pt_F[1000];
  float rawpt_F[1000];
  float eta_F[1000];
  float phi_F[1000];
  float chMax_F[1000];
  float trkMax_F[1000];
  float chSum_F[1000];
  float phSum_F[1000];
  float neSum_F[1000];
  float trkSum_F[1000];
  float phMax_F[1000];
  float neMax_F[1000];
  float eMax_F[1000];
  float muMax_F[1000];
  float eSum_F[1000];
  float muSum_F[1000];
  float jtpu_F[1000];
  int jetMB_F;
  int jetMB_p_F;
  int jet55_F;
  int jet65_F;
  int jet80_F;
  int L1_sj36_F;
  int L1_sj52_F;
  int L1_sj36_p_F;
  int L1_sj52_p_F;
  int jet55_p_F;
  int jet65_p_F;
  int jet80_p_F;
  float vz_F;
  int evt_F;
  int run_F;
  int lumi_F;
  int hiNpix_F;
  int hiBin_F;
  int pcollisionEventSelection_F;
  int pHBHENoiseFilter_F;

  float calopt_F[1000];
  jetpbpb[3]->SetBranchAddress("jtpt",&calopt_F);
  
  jetpbpb[4]->SetBranchAddress("evt",&evt_F);
  jetpbpb[4]->SetBranchAddress("run",&run_F);
  jetpbpb[4]->SetBranchAddress("lumi",&lumi_F);
  jetpbpb[4]->SetBranchAddress("hiBin",&hiBin_F);
  jetpbpb[4]->SetBranchAddress("hiNpix",&hiNpix_F);
  jetpbpb[4]->SetBranchAddress("vz",&vz_F);
  jetpbpb[1]->SetBranchAddress("pcollisionEventSelection",&pcollisionEventSelection_F);
  jetpbpb[1]->SetBranchAddress("pHBHENoiseFilter",&pHBHENoiseFilter_F);
  //jetpbpb[0]->SetBranchAddress("pprimaryvertexFilter",&pprimaryvertexFilter_F);
  //jetpbpb[0]->SetBranchAddress("pVertexFilterCutGplus",&pVertexFilterCutGplus_F);
  jetpbpb[2]->SetBranchAddress("nref",&nref_F);
  jetpbpb[2]->SetBranchAddress("jtpt",pt_F);
  jetpbpb[2]->SetBranchAddress("jteta",eta_F);
  jetpbpb[2]->SetBranchAddress("jtphi",phi_F);
  jetpbpb[2]->SetBranchAddress("rawpt",rawpt_F);
  jetpbpb[2]->SetBranchAddress("jtpu",jtpu_F);
  jetpbpb[2]->SetBranchAddress("chargedMax",chMax_F);
  jetpbpb[2]->SetBranchAddress("chargedSum",chSum_F);
  jetpbpb[2]->SetBranchAddress("trackMax",trkMax_F);
  jetpbpb[2]->SetBranchAddress("trackSum",trkSum_F);
  jetpbpb[2]->SetBranchAddress("photonMax",phMax_F);
  jetpbpb[2]->SetBranchAddress("photonSum",phSum_F);
  jetpbpb[2]->SetBranchAddress("neutralMax",neMax_F);
  jetpbpb[2]->SetBranchAddress("neutralSum",neSum_F);
  jetpbpb[2]->SetBranchAddress("eSum",eSum_F);
  jetpbpb[2]->SetBranchAddress("eMax",eMax_F);
  jetpbpb[2]->SetBranchAddress("muSum",muSum_F);
  jetpbpb[2]->SetBranchAddress("muMax",muMax_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIMinBiasHfOrBSC_v1",&jetMB_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIMinBiasHfOrBSC_v1_Prescl",&jetMB_p_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIJet55_v1",&jet55_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIJet55_v1_Prescl",&jet55_p_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIJet65_v1",&jet65_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIJet65_v1_Prescl",&jet65_p_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIJet80_v1",&jet80_F);
  jetpbpb[0]->SetBranchAddress("HLT_HIJet80_v1_Prescl",&jet80_p_F);
  jetpbpb[0]->SetBranchAddress("L1_SingleJet36_BptxAND",&L1_sj36_F);
  jetpbpb[0]->SetBranchAddress("L1_SingleJet36_BptxAND_Prescl",&L1_sj36_p_F);
  jetpbpb[0]->SetBranchAddress("L1_SingleJet52_BptxAND",&L1_sj52_F);
  jetpbpb[0]->SetBranchAddress("L1_SingleJet52_BptxAND_Prescl",&L1_sj52_p_F);

  // event tree selection file:
  int hiBin_eS;
  int run_eS;
  int evt_eS;
  int lumi_eS;
  float vz_eS; 
  int isGoodEvent_eS;
  int nref_eS;
  int isMiMatch_eS[1000];
  int isClMatch_eS[1000];
  int isPFElecCut_eS[1000];
  int isTrackCut_eS[1000];
  int isMuCut_eS[1000];
  int index_eS[1000];
  float pt_eS[1000];
  float calopt_eS[1000];
  Double_t weight_eS;

  evt_select->SetBranchAddress("hiBin",&hiBin_eS);
  evt_select->SetBranchAddress("run_value",&run_eS);
  evt_select->SetBranchAddress("evt_value",&evt_eS);
  evt_select->SetBranchAddress("lumi_value",&lumi_eS);
  evt_select->SetBranchAddress("vz",&vz_eS);
  evt_select->SetBranchAddress("weight", &weight_eS);  
  evt_select->SetBranchAddress("isGoodEvt",&isGoodEvent_eS);
  evt_select->SetBranchAddress("nref",&nref_eS);
  evt_select->SetBranchAddress("index", index_eS);
  evt_select->SetBranchAddress("isMlMatch",isMiMatch_eS);
  evt_select->SetBranchAddress("isClMatch",isClMatch_eS);
  evt_select->SetBranchAddress("isPFElecCut",isPFElecCut_eS);
  evt_select->SetBranchAddress("isTrackCut",isTrackCut_eS);
  evt_select->SetBranchAddress("isMuCut",isMuCut_eS);
  evt_select->SetBranchAddress("pfpt",pt_eS);
  evt_select->SetBranchAddress("calopt",calopt_eS);

  float pt_jS[1000];
  float rawpt_jS[1000];
  jet_select->SetBranchAddress("pfpt", pt_jS);  
  jet_select->SetBranchAddress("pfrawpt", rawpt_jS);  
  
  // Declare the output File and the necessary histograms after that:
  // std::string outdir="";
  // std::string outfile=outdir+kFoname;
  TFile *fout = new TFile(kFoname.c_str(),"RECREATE");
  fout->cd();

  TH1F * hNumerator_80[2][nbins_cent+1], * hNumerator_65[2][nbins_cent+1], * hNumerator_55[2][nbins_cent+1];
  TH1F * hDenominator[2][nbins_cent+1], * hNumerator_Sum[2][nbins_cent+1];

  TH1F * hcentrality_Jet55[nbins_cent];
  TH1F * hcentrality_Jet55not65not80[nbins_cent];
  TH1F * hcentrality_Jet65[nbins_cent];
  TH1F * hcentrality_Jet65not80[nbins_cent];
  TH1F * hcentrality_JetMB_Jet65not80[nbins_cent];
  TH1F * hcentrality_JetMB_Jet80[nbins_cent];
  TH1F * hcentrality_Jet80[nbins_cent];
  TH1F * hcentrality_Jet55_Prescl[nbins_cent];
  TH1F * hcentrality_Jet55not65not80_Prescl[nbins_cent];
  TH1F * hcentrality_Jet65_Prescl[nbins_cent];
  TH1F * hcentrality[nbins_cent];
  TH1F * hcentrality_JetMB[nbins_cent];
  TH1F * hcentrality_JetMB_Jet55[nbins_cent];
  TH1F * hcentrality_JetMB_Jet55_Prescl[nbins_cent];
  TH1F * hcentrality_JetMB_Jet55not65not80[nbins_cent];
  TH1F * hcentrality_JetMB_Jet55not65not80_Prescl[nbins_cent];
  TH1F * hcentrality_JetMB_Jet65[nbins_cent];
  TH1F * hcentrality_JetMB_Jet65_Prescl[nbins_cent];


  //TH1F * hNumerator_HLT80[2][nbins_cent+1], * hNumerator_HLT65[2][nbins_cent+1], * hNumerator_HLT55[2][nbins_cent+1];
  //TH1F * hDenominator[2][nbins_cent+1];

  for(int i = 0; i<nbins_cent+1; i++){

    if( i != nbins_cent ){

      hcentrality[i] = new TH1F(Form("hcentrality_cent%d",i),"",200, 0, 200);
      hcentrality_Jet55[i] = new TH1F(Form("hcentrality_Jet55_cent%d",i),"",200, 0, 200);
      hcentrality_Jet55_Prescl[i] = new TH1F(Form("hcentrality_Jet55_Prescl_cent%d",i),"",200, 0, 200);
      hcentrality_Jet55not65not80[i] = new TH1F(Form("hcentrality_Jet55not65not80_cent%d",i),"",200, 0, 200);
      hcentrality_Jet55not65not80_Prescl[i] = new TH1F(Form("hcentrality_Jet55not65not80_Prescl_cent%d",i),"",200, 0, 200);
      hcentrality_Jet65[i] = new TH1F(Form("hcentrality_Jet65_cent%d",i),"",200, 0, 200);
      hcentrality_Jet65_Prescl[i] = new TH1F(Form("hcentrality_Jet65_Prescl_cent%d",i),"",200, 0, 200);
      hcentrality_Jet65not80[i] = new TH1F(Form("hcentrality_Jet65not80_cent%d",i),"",200, 0, 200);
      hcentrality_Jet80[i] = new TH1F(Form("hcentrality_Jet80_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB[i] = new TH1F(Form("hcentrality_JetMB_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet55[i] = new TH1F(Form("hcentrality_JetMB_Jet55_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet55_Prescl[i] = new TH1F(Form("hcentrality_JetMB_Jet55_Prescl_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet55not65not80[i] = new TH1F(Form("hcentrality_JetMB_Jet55not65not80_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet55not65not80_Prescl[i] = new TH1F(Form("hcentrality_JetMB_Jet55not65not80_Prescl_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet65[i] = new TH1F(Form("hcentrality_JetMB_Jet65_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet65_Prescl[i] = new TH1F(Form("hcentrality_JetMB_Jet65_Prescl_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet65not80[i] = new TH1F(Form("hcentrality_JetMB_Jet65not80_cent%d",i),"",200, 0, 200);
      hcentrality_JetMB_Jet80[i] = new TH1F(Form("hcentrality_JetMB_Jet80_cent%d",i),"",200, 0, 200);
      
    }
    
    hNumerator_80[0][i] = new TH1F(Form("hNumerator_80_noCut_cent%d",i),"",140, 0, 140);
    hNumerator_65[0][i] = new TH1F(Form("hNumerator_65_noCut_cent%d",i),"",140, 0, 140);
    hNumerator_55[0][i] = new TH1F(Form("hNumerator_55_noCut_cent%d",i),"",140, 0, 140);
    hNumerator_Sum[0][i] = new TH1F(Form("hNumerator_Sum_noCut_cent%d",i),"",140, 0, 140);
    hDenominator[0][i] = new TH1F(Form("hDenominator_noCut_cent%d",i),"",140, 0, 140);
    //hRatio_Sum[0][1] = new TH1F(Form("hRatio_Sum_noCut_cent%d",i),"",140,0,140);

    hNumerator_80[1][i] = new TH1F(Form("hNumerator_80_Cut_cent%d",i),"",140, 0, 140);
    hNumerator_65[1][i] = new TH1F(Form("hNumerator_65_Cut_cent%d",i),"",140, 0, 140);
    hNumerator_55[1][i] = new TH1F(Form("hNumerator_55_Cut_cent%d",i),"",140, 0, 140);
    hNumerator_Sum[1][i] = new TH1F(Form("hNumerator_Sum_Cut_cent%d",i),"",140, 0, 140);
    hDenominator[1][i] = new TH1F(Form("hDenominator_Cut_cent%d",i),"",140, 0, 140);
    //hRatio_Sum[1][1] = new TH1F(Form("hRatio_Sum_noCut_cent%d",i),"",140,0,140);

  }
  
  //get the spectra with the specific trigger object from the different files. 
  TH1F *hpbpb_TrgObjMB[nbins_cent];
  TH1F *hpbpb_TrgObjMBwoLJ[nbins_cent];
  TH1F *hpbpb_TrgObjMBwoLJSbJ[nbins_cent];
  TH1F *hpbpb_TrgObjMBLJ[nbins_cent];
  // TH1F *hpbpb_TrgObjMBwoHT[nbins_cent];
  
  TH2F *hdphiptcent[nbins_cent];
  //TH2F *hdphiptMBwoHLTcent[nbins_cent];
  //  TH1F *hBin_[nbins_cent];
  TH1F *hEvent_Vz_[nbins_cent];

  TH2F * hpbpb_forest_jeccheck[nbins_cent];
  TH2F * hpbpb_trees_jeccheck[nbins_cent];
 
  TH1F * hEvent_Vz = new TH1F("hEvent_Vz","Primary Vertex Z",400,-20,20);
  //TH1F * hBin = new TH1F("hBin","Centrality Bins",200,0,200);

  //TH1F *heta = new TH1F("heta","eta distribution",100,-2.5,2.5);
  //TH1F *hphi = new TH1F("hphi","phi distribution",100,-3.5,3.5);
  TH1F *hdphi = new TH1F("hdphi","delta phi distribution",70,0,3.5);
  TH2F *hdphipt=new TH2F("hdphipt","pt vs delta phi distribution",100,0,200,70,0,3.5);
  //TH1F *hdptratio = new TH1F("hdptratio","pt ratio distribution",100,0,5);

    
  for(int i = 0;i<nbins_cent;++i){

    hpbpb_forest_jeccheck[i] = new TH2F(Form("hpbpb_forest_jeccheck_cent%d",i),"reco/raw vs raw pt",300,0,300,50,0,5);
    hpbpb_trees_jeccheck[i] = new TH2F(Form("hpbpb_trees_jeccheck_cent%d",i),"reco/raw vs raw pt",300,0,300,50,0,5);
    
    hEvent_Vz_[i] = new TH1F(Form("hVz_cent_%d",i),Form("HVz Values %2.0f - %2.0f cent",5*boundaries_cent[i],5*boundaries_cent[i+1]),400,-20,20);
      
   hpbpb_TrgObjMB[i] = new TH1F(Form("hpbpb_HLTMB_R%d_%s_cent%d",radius,etaWidth,i),Form("Spectra from MB R%d %s %2.0f - %2.0f cent",radius,etaWidth,5*boundaries_cent[i],5*boundaries_cent[i+1]),1000,0,1000);
    // hpbpb_TrgObjMBArray[i] = new TH1F(Form("hpbpb_HLTMBArray_R%d_%s_cent%d",radius,etaWidth,i),Form("Spectra from MB ArrayR%d %s %2.0f - %2.0f cent",radius,etaWidth,5*boundaries_cent[i],5*boundaries_cent[i+1]),1000,0,1000);
    hpbpb_TrgObjMBwoLJ[i] = new TH1F(Form("hpbpb_HLTMBwoLJ_R%d_%s_cent%d",radius,etaWidth,i),Form("Spectra from MB without LJ R%d %s %2.0f - %2.0f cent",radius,etaWidth,5*boundaries_cent[i],5*boundaries_cent[i+1]),1000,0,1000);
    hpbpb_TrgObjMBwoLJSbJ[i] = new TH1F(Form("hpbpb_HLTMBwoLJSbJ_R%d_%s_cent%d",radius,etaWidth,i),Form("Spectra from MB without LJ and SbJ R%d %s %2.0f - %2.0f cent",radius,etaWidth,5*boundaries_cent[i],5*boundaries_cent[i+1]),1000,0,1000);
    hpbpb_TrgObjMBLJ[i] = new TH1F(Form("hpbpb_HLTMBLJ_R%d_%s_cent%d",radius,etaWidth,i),Form("Spectra from MB Leading Jet R%d %s %2.0f - %2.0f cent",radius,etaWidth,5*boundaries_cent[i],5*boundaries_cent[i+1]),1000,0,1000);    
    // hpbpb_TrgObjMBwoHT[i] = new TH1F(Form("hpbpb_HLTMBwoHT_R%d_%s_cent%d",radius,etaWidth,i),Form("Spectra from MB without HT R%d %s %2.0f - %2.0f cent",radius,etaWidth,5*boundaries_cent[i],5*boundaries_cent[i+1]),400,0,400);
    hdphiptcent[i]=new TH2F(Form("hdphipt_cent%d",i),Form("hdphipt%2.0f - %2.0f cent",5*boundaries_cent[i],5*boundaries_cent[i+1]),100,0,200,160,0,3.2);
    // hdphiptwoHLTcent[i]=new TH2F(Form("hdphiptwoHLT_cent%d",i),Form("hdphipt%2.0f - %2.0f cent",5*boundaries_cent[i],5*boundaries_cent[i+1]),100,0,200,70,0,3.5);
  }// centrality bin loop
  
  // now start the event loop for each file. 
  
  if(printDebug) cout<<"Running through all the events now"<<endl;
  Long64_t nentries = jetpbpb[0]->GetEntries();
  Long64_t nGoodEvt = 0;
  if(printDebug) nentries = 10;
  TRandom rnd; 

  for(int nEvt = 0; nEvt < nentries; ++ nEvt) {

    if(nEvt%10000 == 0)cout<<nEvt<<"/"<<nentries<<endl;
    if(printDebug)cout<<"nEvt = "<<nEvt<<endl;
    
    jetpbpb[0]->GetEntry(nEvt);
    jetpbpb[1]->GetEntry(nEvt);
    jetpbpb[2]->GetEntry(nEvt);
    jetpbpb[4]->GetEntry(nEvt);
    jetpbpb[3]->GetEntry(nEvt);
    evt_select->GetEntry(nEvt);

    if(printDebug) cout<<"forest values = "<<hiBin_F<<", "<<evt_F<<", "<<run_F<<", "<<lumi_F<<", "<<vz_F<<endl;
    
    if(pcollisionEventSelection_F == 0 && pHBHENoiseFilter_F == 0) continue; 
    if(fabs(vz_F)>15) continue;
    // if(!isGoodEvent_eS) continue; 

    int jetCounter = 0;
    
    for(int g = 0;g<nref_F;g++){
      
      if(eta_F[g]>=-2 && eta_F[g]<2){ //to select inside 
	
	if(pt_F[g]>=50) jetCounter++;
	
      }//eta selection cut
      
    }// jet loop
    
    // apply the correct supernova selection cut rejection here: 
    if(hiNpix_F > 38000 - 500*jetCounter){
      if(printDebug) cout<<"removed this supernova event"<<endl;
      continue;
    }    

    // jet_select->GetEntry(nGoodEvt);
    // ++nGoodEvt;

    

    int cBin = findBin(hiBin_F);//tells us the centrality of the event. 
    if(cBin == -1) continue;

    hcentrality[cBin]->Fill(hiBin_F);
    if(jet55_F == 1) hcentrality_Jet55[cBin]->Fill(hiBin_F);
    if(jet55_F == 1) hcentrality_Jet55_Prescl[cBin]->Fill(hiBin_F, jet55_p_F);
    if(jet65_F == 1) hcentrality_Jet65[cBin]->Fill(hiBin_F);
    if(jet65_F == 1) hcentrality_Jet65_Prescl[cBin]->Fill(hiBin_F, jet65_p_F);
    if(jet80_F == 1) hcentrality_Jet80[cBin]->Fill(hiBin_F);
    if(jet55_F == 1 && jet65_F == 0 && jet80_F == 0) hcentrality_Jet55not65not80[cBin]->Fill(hiBin_F);
    if(jet55_F == 1 && jet65_F == 0 && jet80_F == 0) hcentrality_Jet55not65not80_Prescl[cBin]->Fill(hiBin_F, jet55_p_F);
    if(jet65_F == 1 && jet80_F == 0) hcentrality_Jet65not80[cBin]->Fill(hiBin_F);
    if(jetMB_F) {
      hcentrality_JetMB[cBin]->Fill(hiBin_F);
      if(jet55_F == 1) hcentrality_JetMB_Jet55[cBin]->Fill(hiBin_F);
      if(jet55_F == 1) hcentrality_JetMB_Jet55_Prescl[cBin]->Fill(hiBin_F, jet55_p_F);
      if(jet65_F == 1) hcentrality_JetMB_Jet65[cBin]->Fill(hiBin_F);
      if(jet65_F == 1) hcentrality_JetMB_Jet65_Prescl[cBin]->Fill(hiBin_F, jet65_p_F);
      if(jet80_F == 1) hcentrality_JetMB_Jet80[cBin]->Fill(hiBin_F);
      if(jet55_F == 1 && jet65_F == 0 && jet80_F == 0) hcentrality_JetMB_Jet55not65not80[cBin]->Fill(hiBin_F);
      if(jet55_F == 1 && jet65_F == 0 && jet80_F == 0) hcentrality_JetMB_Jet55not65not80_Prescl[cBin]->Fill(hiBin_F, jet55_p_F);
      if(jet65_F == 1 && jet80_F == 0) hcentrality_JetMB_Jet65not80[cBin]->Fill(hiBin_F);
    }

    if(cBin==nbins_cent) continue;

    if(jetMB_F == 0) continue; 

    //hBin->Fill(hiBin_F);
    hEvent_Vz->Fill(vz_F);
    hEvent_Vz_[cBin]->Fill(vz_F);
    
    Double_t weight_cent = getCentWeight(hiBin_F);
    
    // if(hiBin_eS != hiBin_F || evt_eS != evt_F || run_eS != run_F || lumi_eS != lumi_F || vz_eS != vz_F) cout<<"ERROR mismatch eS, F"<<endl;
    // if(hiBin_eS != hiBin_jS || evt_eS != evt_jS || run_eS != run_jS || lumi_eS != lumi_jS || vz_eS != vz_jS) cout<<"ERROR mismatch eS, jS"<<endl;
    // if(hiBin_F != hiBin_jS || evt_F != evt_jS || run_F != run_jS || lumi_F != lumi_jS || vz_F != vz_jS) cout<<"ERROR mismatch F, jS"<<endl;

    // if(printDebug) cout<<"hibin hiForest = "<<hiBin_F<<", evtTree = "<<hiBin_eS<<", jetTree = "<<hiBin_jS<<endl;
    // if(printDebug) cout<<"evt hiForest   = "<<evt_F<<", evtTree = "<<evt_eS<<", jetTree = "<<evt_jS<<endl;
    // if(printDebug) cout<<"lumi hiForest  = "<<lumi_F<<", evtTree = "<<lumi_eS<<", jetTree = "<<lumi_jS<<endl;
    // if(printDebug) cout<<"vz hiForest    = "<<vz_F<<", evtTree = "<<vz_eS<<", jetTree = "<<vz_jS<<endl;
    
    // if(printDebug) cout<<"nref_F = "<<nref_F<<", nref_eS = "<<nref_eS<<", nref_jS = "<<nref_jS<<endl;

    if(nref_F != nref_eS) cout<<"ERROR mismatch in jet counts"<<endl;
    std::vector < float > phi;
    std::vector < float > pt;
    
    // //! Sort the jetTree jets according to pT
    // std::vector < Jet > vJet;
    // for(int jet2 = 0; jet2<nref_jS; ++jet2){
    //   //cout <<"\t \t jetTree *** "<< jet2 <<  ", pT " << pt_jS[jet2] <<  ", chSum : "<< chSum_jS[jet2] << endl;
    //   Jet ijet;
    //   ijet.id = jet2;
    //   ijet.pt = pt_jS[jet2];
    //   vJet.push_back(ijet);
    // }
    // std::sort (vJet.begin(), vJet.end(), compare_pt);
    // std::vector < Jet >::const_iterator itr;

    // int jet=0;
    // for(itr=vJet.begin(); itr!=vJet.end(); ++itr, ++jet){

    //   int jetLoc = (*itr).id;
    //   if(isMultiMatch_jS[jetLoc]) {
    // 	++itr;
    // 	jetLoc = (*itr).id;
    // 	if(itr == vJet.end())  break;
    //   }
    //   if(fabs(eta_jS[jetLoc]) > 2) continue;
    //   //if(isPFElecCut_eS[jet] != 1) continue;
    //   // if(isMiMatch_eS[jet]) continue;
    //   if(pt_jS[jetLoc] <15) continue;

    //   bool PFElecCut = false;

    //   Float_t Sumcand = chSum_jS[jetLoc] + phSum_jS[jetLoc] + neSum_jS[jetLoc] + muSum_jS[jetLoc];
    //   if(isCaloMatch_jS[jetLoc] == 1){
    // 	if(calopt_jS[jetLoc]/pt_jS[jetLoc] > 0.5 && calopt_jS[jetLoc]/pt_jS[jetLoc] <= 0.85 && eMax_jS[jetLoc]/Sumcand < ((Float_t)18/7 *(Float_t)calopt_jS[jetLoc]/pt_jS[jetLoc] - (Float_t)9/7)) PFElecCut = true;
    // 	if(calopt_jS[jetLoc]/pt_jS[jetLoc] > 0.85) PFElecCut = true;
    // 	if(calopt_jS[jetLoc]/pt_jS[jetLoc] <= 0.5 && eMax_jS[jetLoc]/Sumcand < 0.05) PFElecCut = true;
    //   }
    //   if(isCaloMatch_jS[jetLoc] == 0)
    // 	if(eMax_jS[jetLoc]/Sumcand < 0.05 ) PFElecCut = true;

    // fill the trigger Turnon histograms
    //if(fabs(eta_F[0] < 2.0)){

      // do the jet ID cut]
      bool PFElecCut1 = false;
      Float_t Sumcand1 = chSum_F[0] + phSum_F[0] + neSum_F[0] + muSum_F[0];
      if(isClMatch_eS[0] == 1){
    	if(calopt_eS[0]/pt_F[0] > 0.5 && calopt_eS[0]/pt_F[0] <= 0.85 && eMax_F[0]/Sumcand1 < ((Float_t)18/7 *(Float_t)calopt_eS[0]/pt_F[0] - (Float_t)9/7)) PFElecCut1 = true;
    	if(calopt_eS[0]/pt_F[0] > 0.85) PFElecCut1 = true;
    	if(calopt_eS[0]/pt_F[0] <= 0.5 && eMax_F[0]/Sumcand1 < 0.05) PFElecCut1 = true;
      }
      if(isClMatch_eS[0] == 0)
    	if(eMax_F[0]/Sumcand1 < 0.05 ) PFElecCut1 = true;

      if(PFElecCut1){
	hDenominator[1][cBin]->Fill(pt_F[0]);
	if(jet55_F == 1 && jet65_F == 0 && jet80_F == 0) hNumerator_55[1][cBin]->Fill(pt_F[0], jet55_p_F);
	if(jet65_F == 1 && jet80_F == 0) hNumerator_65[1][cBin]->Fill(pt_F[0], jet65_p_F);
	if(jet80_F == 1) hNumerator_80[1][cBin]->Fill(pt_F[0], jet80_p_F);
      }
      
      //}// eta cut 
      
    for( int jet = 0; jet<nref_F; jet++ ){
      
      if( fabs(eta_F[jet]) > 2.0 ) continue;

      //if( chMax_F[jet] < 7 && trkMax_F[jet] < 7 && neMax_F[jet] < 8 ) continue;
      if( trkMax_F[jet] < 7 && neMax_F[jet] < 8 ) continue;

      //if( isPFElecCut_eS[jet] != 1 ) continue;

      bool PFElecCut = false;

      Float_t Sumcand = chSum_F[jet] + phSum_F[jet] + neSum_F[jet] + muSum_F[jet];
      if(isClMatch_eS[jet] == 1){
    	if(calopt_eS[jet]/pt_F[jet] > 0.5 && calopt_eS[jet]/pt_F[jet] <= 0.85 && eMax_F[jet]/Sumcand < ((Float_t)18/7 *(Float_t)calopt_eS[jet]/pt_F[jet] - (Float_t)9/7)) PFElecCut = true;
    	if(calopt_eS[jet]/pt_F[jet] > 0.85) PFElecCut = true;
    	if(calopt_eS[jet]/pt_F[jet] <= 0.5 && eMax_F[jet]/Sumcand < 0.05) PFElecCut = true;
      }
      if(isClMatch_eS[jet] == 0)
    	if(eMax_F[jet]/Sumcand < 0.05 ) PFElecCut = true;

      if(!PFElecCut) continue;

      hDenominator[0][cBin]->Fill(pt_F[jet]);
      if(jet55_F == 1 && jet65_F == 0 && jet80_F == 0) hNumerator_55[0][cBin]->Fill(pt_F[jet], jet55_p_F);
      if(jet65_F == 1 && jet80_F == 0) hNumerator_65[0][cBin]->Fill(pt_F[jet], jet65_p_F);
      if(jet80_F == 1) hNumerator_80[0][cBin]->Fill(pt_F[jet], jet80_p_F);
      
      // if(!PFElecCut) continue;
      
      // if(printDebug && (fabs(eta_jS[jet] > 2))) cout<<"jets with |eta| > 2 in jetTree"<<endl;
      // if(printDebug && (fabs(eta_F[jet] > 2)))  cout<<"jets with |eta| > 2 in Forest"<<endl;
      
      Float_t wght = weight_cent; 
      //if(printDebug && index_eS[jet] >= 0 )cout<<jet<<", hiForest pT = "<<pt_F[jet]<<", jetTree pT = "<<pt_jS[jetLoc]<<", electronCut = "<<isPFElecCut_eS[jetLoc]<<", Calo pT = "<<calopt_F[index_eS[jet]]<<", onFly flag calculation = "<<PFElecCut<<", eMax from hiForest = "<<eMax_F[jet]<<", eMax from jet Tree = "<<eMax_jS[jetLoc]<<endl;      // if(printDebug)cout<<jet<<", hiForest pT = "<<pt_F[jet]<<", jetTree pT = "<<pt_jS[jetLoc]<<", electronCut = "<<isPFElecCut_eS[jetLoc]<<", eMax from hiForest = "<<eMax_F[jet]<<", eMax from jet Tree = "<<eMax_jS[jetLoc]<<endl;

      float recpt = pt_F[jet];

      if(recpt <= ptCut) continue;

      hpbpb_forest_jeccheck[cBin]->Fill((Float_t)  rawpt_F[jet], recpt/rawpt_F[jet]);
      hpbpb_trees_jeccheck[cBin]->Fill((Float_t)  rawpt_jS[jet], pt_jS[jet]/rawpt_jS[jet]);

      pt.push_back(recpt);
      phi.push_back(phi_F[jet]);

      hpbpb_TrgObjMB[cBin]->Fill(recpt, wght);

      // if(jet > 0)
      // 	hpbpb_TrgObjMBwoLJ[cBin]->Fill(recpt, wght);
      // if(jet > 1)
      // 	hpbpb_TrgObjMBwoLJSbJ[cBin]->Fill(recpt, wght);
      
            
    }// jet loop

    Float_t wght = weight_cent;
    
    for(int j = 1; j<pt.size(); ++j){
      if(pt[j] < 35) continue; 
      float delphi = deltaphi (phi[0], phi[j]);
      hdphi->Fill(delphi, wght);
      hdphipt->Fill(pt[0], delphi, wght);
      hdphiptcent[cBin]->Fill(pt[0], delphi, wght);
    }
    
    if(pt.size() != 0){
      hpbpb_TrgObjMBLJ[cBin]->Fill(pt[0], wght);
      for(int j = 0; j<pt.size(); ++j){
	if(j >= 1) hpbpb_TrgObjMBwoLJ[cBin]->Fill(pt[j], wght);
	if(j >= 2) hpbpb_TrgObjMBwoLJSbJ[cBin]->Fill(pt[j], wght);      
      }
    }
    
    if(printDebug)cout<<endl;

    pt.clear();
    phi.clear();

  }// event loop

  fout->Write();
  
  timer.Stop();
  cout<<"Macro finished: "<<endl;
  cout<<"CPU time (min)  = "<<(Float_t)timer.CpuTime()/60<<endl;
  cout<<"Real time (min) = "<<(Float_t)timer.RealTime()/60<<endl;
  
}//macro end
Beispiel #24
0
void run_unpack_proto_v2(){


    // -----   Timer   --------------------------------------------------------
	TStopwatch timer;
	timer.Start();
  // ------------------------------------------------------------------------


   gSystem->Load("libXMLParser.so");

   TString scriptfile = "LookupProto20150331.xml";
   TString protomapfile = "proto.map";
   TString dir = getenv("VMCWORKDIR");
   TString scriptdir = dir + "/scripts/"+ scriptfile;
   TString protomapdir = dir + "/scripts/"+ protomapfile;
   TString geo = "proto_geo_hires.root";


   FairLogger *logger = FairLogger::GetLogger();
   logger -> SetLogFileName("ATTPCLog.log");
   logger -> SetLogToFile(kTRUE);
   logger -> SetLogToScreen(kTRUE);
   logger -> SetLogVerbosityLevel("MEDIUM");


   FairRunAna* run = new FairRunAna();
   //run -> SetInputFile("mc.dummy_proto.root");
   run -> SetOutputFile("output_proto.root");
   //run -> SetGeomFile("../geometry/ATTPC_Proto_v1.0.root");

   TString file = "../../parameters/AT.parameters.par";

   FairRuntimeDb* rtdb = run->GetRuntimeDb();
   FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
   parIo1 -> open(file.Data(), "in");
   //FairParRootFileIo* parIo2 = new FairParRootFileIo();
   //parIo2 -> open("param.dummy_proto.root");
  // rtdb -> setFirstInput(parIo2);
   rtdb -> setSecondInput(parIo1);

   ATDecoderTask *decoderTask = new ATDecoderTask();
   //decoderTask ->SetDebugMode(kTRUE);
   decoderTask ->SetMapOpt(1); // ATTPC : 0  - Prototype: 1 |||| Default value = 0
   //decoderTask -> AddData("/home/ayyadlim/Desktop/Yassid/ATTPC/Data/Notre_Dame_data/CoBo_AsAd0_2015-01-27T15_19_34.962_0000.graw");//12B
   //decoderTask -> AddData("/home/ayyadlim/Desktop/Yassid/ATTPC/Data/Notre_Dame_data/CoBo_AsAd0_2015-01-27T07_16_00.696_0000.graw");
   //decoderTask -> AddData("/Users/yassidayyad/Desktop/ATTPC/Data/Notre_Dame_data/CoBo_AsAd0_2015-01-27T15_19_34.962_0000.graw");
   //decoderTask ->AddData("/home/ayyadlim/Desktop/Yassid/ATTPC/Data/Notre_Dame_data/CoBo_AsAd0_2015-01-26T19_33_23.451_0003.graw"); //12N
   //decoderTask -> AddData("/home/ayyadlim/Desktop/Yassid/ATTPC/Data/Notre_Dame_data/CoBo_AsAd0_2015-01-28T07:02:50.291_0000.graw");//12B High Pressure
   //decoderTask -> AddData("/home/ayyadlim/Desktop/Yassid/ATTPC/Data/Notre_Dame_data/CoBo_AsAd0_2015-01-28T16:56:24.135_0000.graw");//12B Low Pressure
   decoderTask -> AddData("/home/ayyadlim/Desktop/Yassid/ATTPC/Data/TRIUMF/CoBo_AsAd0_2015-12-01T07_35_27.482_0009.graw");//8He TRIUMF
	//  decoderTask -> AddData("/home/ayyadlim/Desktop/Yassid/ATTPC/Data/Notre_Dame_data/10Be/CoBo_2013-02-21_12-52-57_0006.graw"); //10Be
   //decoderTask -> AddData("/home/s1257/fair_install_ROOT6/data/CoBo_AsAd0_2015-12-03T05:47:43.571_0001.graw");//12B Low Pressure
   //decoderTask -> AddData("/home/daq/Desktop/Data/run_0014/CoBo_AsAd0_2015-07-29T15_45_17.971_0000.graw");
   //decoderTask->AddData("/home/daq/Desktop/Data/run_0028/CoBo_AsAd0_2015-07-29T19_02_32.783_0000.graw");
   decoderTask ->SetGeo(geo.Data());
   decoderTask ->SetProtoMap(protomapdir.Data());
   decoderTask ->SetMap((Char_t const*) scriptdir.Data());
   decoderTask -> SetPositivePolarity(kTRUE);
   decoderTask -> SetFPNPedestal(6);
   //decoderTask->SetInternalPedestal();
   decoderTask -> SetNumTbs(512);
   //decoderTask -> SetPersistence();
   decoderTask -> SetGetRawEventMode(1);
   run -> AddTask(decoderTask);

   ATPSATask *psaTask = new ATPSATask();
   psaTask -> SetPersistence();
   psaTask -> SetBackGroundPeakFinder(kFALSE); // Suppress background of each pad for noisy data (Larger computing Time)
   psaTask -> SetThreshold(20);
   psaTask -> SetPeakFinder(); //Note: For the moment not affecting the prototype PSA Task
   run -> AddTask(psaTask);

   ATPhiRecoTask *phirecoTask = new ATPhiRecoTask();
   phirecoTask -> SetPersistence();
   run -> AddTask(phirecoTask);

   /*ATHoughTask *HoughTask = new ATHoughTask();
   HoughTask->SetPhiReco();
   HoughTask->SetPersistence();
   HoughTask->SetLinearHough();
	 HoughTask->SetRadiusThreshold(3.0); // Truncate Hough Space Calculation
   //HoughTask ->SetCircularHough();
   run ->AddTask(HoughTask);*/

   run->Init();

   run->Run(0,100); // Number must be lower than the number of events in dummy

 // -----   Finish   -------------------------------------------------------
	timer.Stop();
	Double_t rtime = timer.RealTime();
	Double_t ctime = timer.CpuTime();
	cout << endl << endl;
	cout << "Macro finished succesfully." << endl;
	cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
	cout << endl;
  // ------------------------------------------------------------------------


}
void califaAna_batch(Int_t nEvents=1, Int_t fGeoVer=1, Double_t fThres=0.000050, 
					 Double_t fExpRes=5., Double_t fDelPolar=3.2, Double_t fDelAzimuthal=3.2) {
	        
        cout << "Running califaAna_batch with arguments:" <<endl;
        cout << "Number of events: " << nEvents <<endl;
        cout << "CALIFA geo version: " << fGeoVer <<endl;
        cout << "Threshold: " << fThres <<endl<<endl;
	cout << "Experimental resolution: " << fExpRes <<endl<<endl;

	
	// In general, the following parts need not be touched
	// ========================================================================
	
	// ----    Debug option   -------------------------------------------------
	gDebug = 0;
	// ------------------------------------------------------------------------
	
	// -----   Timer   --------------------------------------------------------
	TStopwatch timer;
	timer.Start();
	// ------------------------------------------------------------------------
	
	
	// -----   Create analysis run   ----------------------------------------
	FairRunAna* fRun = new FairRunAna();
	
        FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
        FairParRootFileIo*  parIo1 = new FairParRootFileIo();
        parIo1->open("r3bpar.root");
        rtdb->setFirstInput(parIo1);
        rtdb->print();

	fRun->SetInputFile("r3bsim.root");
	fRun->SetOutputFile("califaAna.root");
	
	// -----  Analysis routines for CALIFA	
	
	R3BCaloHitFinder* caloHF = new R3BCaloHitFinder();
	//Selecting the geometry version
	// 0- CALIFA 5.0, including BARREL and ENDCAP.
	// 1- CALIFA 7.05, only BARREL
	// 2- CALIFA 7.07, only BARREL
	// 3- CALIFA 7.09, only BARREL (ongoing work)
	// 4- CALIFA 7.17, only ENDCAP (in CsI[Tl])
	// 5- CALIFA 7.07+7.17, 
	// 6- CALIFA 7.09+7.17, (ongoing work)
	// 10- CALIFA 8.11, only BARREL (ongoing work) 
	// ...
	caloHF->SelectGeometryVersion(fGeoVer);          
	//caloHF->SelectGeometryVersion(10);          
	caloHF->SetDetectionThreshold(fThres);             //50 KeV  [fThres in GeV]
	caloHF->SetExperimentalResolution(fExpRes);        //5% at 1 MeV
	caloHF->SetAngularWindow(fDelPolar,fDelAzimuthal); //[0.25 around 14.3 degrees, 3.2 for the complete calorimeter]

	fRun->AddTask(caloHF);
	
	fRun->Init();                     
	fRun->Run(0, nEvents);
	
	// -----   Finish   -------------------------------------------------------
	timer.Stop();
	Double_t rtime = timer.RealTime();
	Double_t ctime = timer.CpuTime();
	cout << endl << endl;
	cout << "Macro finished succesfully." << endl;
	cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
	cout << endl;
	// ------------------------------------------------------------------------
	
	
}
Beispiel #26
0
  // -----   STS track finder QA   ------------------------------------------
  CbmStsReconstructionQa* stsReconstructionQa = new CbmStsReconstructionQa(kTRUE,4, 0.7,iVerbose);
  stsReconstructionQa->SetShowStation1(4);
  fRun->AddTask(stsReconstructionQa);
  // ------------------------------------------------------------------------



  // -----   Intialise and run   --------------------------------------------
  fRun->Init();
  fRun->Run(0,nEvents);
  // ------------------------------------------------------------------------



  // -----   Finish   -------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished succesfully." << endl;
  cout << "Output file is "    << outFile << endl;
  cout << "Parameter file is " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ------------------------------------------------------------------------


}
Beispiel #27
0
void varsig0196_4()
{

  TStopwatch timer;
  timer.Start();
  // Define histogarams
  
  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(111111);
  
  TGraphErrors *g1 = new TGraphErrors(20);
  g1->SetName("Dilvsdm");
  g1->SetTitle("Dilution vs. dm");
  
  TGraph *g2 = new TGraph(20);
  g2->SetName("DilErrvsdm");
  g2->SetTitle("Dil Err vs. dm");
  
  for(Int_t i=0.;i<20.;i++){


    oscpar1_init = 0.5+(0.33*i);

    cout << "============== dm fixed at "<< oscpar1_init <<" ===================="<<endl;

    //TH1F *h1 = new TH1F("h1","Gaussian Dist",50, 4.8, 5.8);
    TH1F *h2 = new TH1F("h2","Lifetime Dist",nBins, min, max);
    TH1F *h3 = new TH1F("h3","Lifetime Dist tag=1",nBins, min, max);
    TH1F *h4 = new TH1F("h4","Lifetime Dist tag=-1",nBins, min, max);
    
    // Get data
    
    // Generate events
    
    mixmasta_mc();
    
    for (Int_t ja=0; ja<nEvts; ja++){
      h2->Fill(lifetime[ja]);
      if (tag[ja] == 1){
	h3->Fill(lifetime[ja]);
      }else if(tag[ja] == -1){
	h4->Fill(lifetime[ja]);
      }else{
	cout << "Tag value "<<tag[ja]<< " out of range, should be -1 or 1" << endl;
	break;
      }
    }
    
    // Do unbinned likelihood fit
    
    TF1 *f3 = new TF1("f3", lftmosc_plt_d, min, max, 5);
    TF1 *f4 = new TF1("f4", lftmosc_plt_d, min, max, 5);
    
    

    
    unbinFitosc_d();
    
    for (Int_t j=0; j<4; j++){
      f3->SetParameter(j,fitpar[j]);
      f4->SetParameter(j,fitpar[j]);
    }
    f3->SetParameter(4,1);
    f4->SetParameter(4,-1);
    
    g1->SetPoint(i,fitpar[1],-(1-2*fitpar[3])/dilfit);
    g1->SetPointError(i,fiterr[1],2*fiterr[3]/dilfit);
    
    g2->SetPoint(i,fitpar[1],1.65*2*fiterr[3]/dilfit);
    
    delete h2;
    delete h3;
    delete h4;
    delete f3;
    delete f4;
  }
  
  TCanvas *vardm = new TCanvas("vardm","varsig0196_4",800,400);
  vardm->Divide(2,1);
  
  vardm->cd(1);
  g1->GetXaxis()->SetTitle("dm");
  g1->GetXaxis()->CenterTitle();
  g1->GetYaxis()->SetTitle("Dilution (1-2alpha)");
  g1->GetYaxis()->CenterTitle();
  //g1->SetMarkerStyle(21);
  //g1->SetMarkerSize(1);
  g1->Draw("AP*"); 
  
  
  vardm->cd(2);
  
  gStyle->SetPadColor(10);
  gStyle->SetCanvasColor(10);
  vardm->SetGrid();
  
  g2->GetXaxis()->SetTitle("dm");
  g2->GetXaxis()->CenterTitle();
  g2->GetYaxis()->SetTitle("Dil. Err");
  g2->GetYaxis()->CenterTitle();
  //g2->SetMarkerStyle(21);
  //g2->SetMarkerSize(1);
  g2->Draw("AP*");  
  
  TObjArray a1(0);
  a1.Add(g1);
  a1.Add(g2);
  a1.Add(vardm);
  
  TFile var_dm("varsig0196_4.root", "recreate");
  a1.Write();
  var_dm.Close();
  
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  
  cout << "Real time " << rtime << endl;
  cout << "CPU time  " << ctime << endl;
  
}
void chi2_lambda_stack_mumue(){
  TStopwatch totaltime;
  totaltime.Start();
  int sample, isPU, ischi2;
  
  TChain *chain_mu[N_chain];
  TChain *chain_el[N_chain];
  TChain *chain_jet[N_chain];
  TChain *chain_event[N_chain];
  
  cout << "==========================" << endl
  << "40, 50, 60, 100(no gen lvl info) : signal" << endl
  << "==========================" << endl
  << "Run : ";
  cin >> sample;
  cout << endl;
  
  cout << "==========================" << endl
  << "PileUP? (0 = no, 1 = yes) : ";
  cin >> isPU;
  cout << "==========================" << endl
  << "chi2 fit? (0 = no, 1 = yes) :";
  cin >> ischi2;
  cout << endl;

  /*
  /// [0] = Signal ///
  chain_mu[0] = new TChain("Muon");
  chain_el[0] = new TChain("Electron");
  chain_event[0] = new TChain("Event");
  chain_mu[0]->Add("./files/signal/trilepton_mumue_SKHN"+TString::Itoa(sample, 10)+"_lep_5_3_14.root");
  chain_el[0]->Add("./files/signal/trilepton_mumue_SKHN"+TString::Itoa(sample, 10)+"_lep_5_3_14.root");
  chain_event[0]->Add("./files/signal/trilepton_mumue_SKHN"+TString::Itoa(sample, 10)+"_lep_5_3_14.root");
  */
  
  /// [1] = Data ///
  chain_mu[1] = new TChain("Muon");
  chain_el[1] = new TChain("Electron");
  chain_event[1] = new TChain("Event");
  chain_jet[1] = new TChain("Jet");
  chain_mu[1]->Add("./files/data/*.root");
  chain_el[1]->Add("./files/data/*.root");
  chain_event[1]->Add("./files/data/*.root");
  chain_jet[1]->Add("./files/data/*.root");
  
  /// [2]~ = Bkg ///
  TString chainlist[N_chain] = {"signal", "data",
                                "DY10to50", "DY50plus", "Zbb",  // DY
                                "WZtollln_mg", "WZtollqq_mg", "WZtoqqln_mg", "ZZtollll_mg", "ZZtollnn_mg", "ZZtollqq_mg", "WW_mg",  // VV
                                "Wbb", // Wjets
                                "topDIL", // Top
                                "TTG", "TTWW", "WWG", "WWW", "WWZ", "WZZ", "ZZZ", "ttZ", "HtoWW", "Wtollln"}; // others
  for(int i=2; i<N_chain; i++){
    chain_mu[i] = new TChain("Muon");
    chain_el[i] = new TChain("Electron");
    chain_event[i] = new TChain("Event");
    chain_jet[i] = new TChain("Jet");
    chain_mu[i]->Add("./files/bkg/trilepton_mumue_SK"+chainlist[i]+"_5_3_14.root");
    chain_el[i]->Add("./files/bkg/trilepton_mumue_SK"+chainlist[i]+"_5_3_14.root");
    chain_event[i]->Add("./files/bkg/trilepton_mumue_SK"+chainlist[i]+"_5_3_14.root");
    chain_jet[i]->Add("./files/bkg/trilepton_mumue_SK"+chainlist[i]+"_5_3_14.root");
  }
  
  Muon *mu[N_chain];
  Electron *el[N_chain];
  Event *evt[N_chain];
  Jet *jet[N_chain];
           
  double MET, METphi, nu_Pz, W_mass_fit, MET_fit, weight, PUweight_sum;
  int N_entry, HN_x_min=0, HN_x_max=100, HN_dx=10, W_x_min=70, W_x_max=120, W_dx=5, solution_selection, smaller;
  struct Fit fitresult[2];
  Color_t fillcolors[N_chain] = {0, kRed-5, // signal and data. data random color
    kAzure-5, kAzure-5, kAzure-5,
    kGreen-5, kGreen-5, kGreen-5, kGreen-5, kGreen-5, kGreen-5, kGreen-5,
    kYellow-5,
    kRed-5,
    kGreen-10, kGreen-10, kGreen-10, kGreen-10, kGreen-10, kGreen-10, kGreen-10, kGreen-10, kGreen-10, kOrange-4};
  double gamma_star_bin[16];
  TString gamma_star_bin_label[15];
  for(int i=0; i<15; i++){
    gamma_star_bin[i] = 0.5*i;
    if(i%2==0) gamma_star_bin_label[i] = "";
    else      gamma_star_bin_label[i] = "            "+TString::Itoa(i/2+1, 10)+".0";
    //cout << gamma_star_bin[i] << '\t' << gamma_star_bin_label[i] << endl;
  }
  gamma_star_bin[15] = 8;
  gamma_star_bin_label[14] = "        > 7.0 GeV";
  
  TH1D *hist_dimuon[N_chain];
  
  TH1D *hist_dimuon_err = new TH1D("hist_dimuon_err", "", (50.-0.)/1., 0., 50.);
  
  THStack *bkgstack_dimuon = new THStack("bkgstack_dimuon", "");
  
  TLorentzVector mu_4vec[2], el_4vec, W_real, HN, nu, gen_nu, gamma_star, z_candidate, selection_nu[2];

  for(int k=1; k<N_chain; k++){
    N_entry = 0;
    PUweight_sum=0;
    
    mu[k] = new Muon(chain_mu[k], 2);
    el[k] = new Electron(chain_el[k], 1);
    jet[k] = new Jet(chain_jet[k], 4);
    evt[k] = new Event(chain_event[k]);
 
    hist_dimuon[k] = new TH1D("hist_dimuon"+TString::Itoa(k,10), "", (50.-0.)/1., 0., 50.);

    
    cout << endl << "Running Sample : " << chainlist[k] << endl;
    
  
    for(int i=0; i<chain_mu[k]->GetEntries(); i++){
      
      printeventnumber(i, chain_mu[k]->GetEntries());
      
      chain_mu[k]->GetEntry(i);
      chain_el[k]->GetEntry(i);
      chain_jet[k]->GetEntry(i);
      chain_event[k]->GetEntry(i);
      
      if( mu[k]->isHNLooseMuon(0) && mu[k]->isHNLooseMuon(1)){
      //if( mu[k]->PassID("TightMuon", 0) && mu[k]->PassID("TightMuon", 1) && mu[k]->PassID("TightMuon", 2) ){
      //if( mu[k]->isHNTightMuon(0) && mu[k]->isHNTightMuon(1) && mu[k]->isHNTightMuon(2) ){
      //if( 1 ){ // NoHNLoose cut
        mu_4vec[0].SetPxPyPzE(mu[k]->Px[0],mu[k]->Py[0],mu[k]->Pz[0],mu[k]->E[0]);
        mu_4vec[1].SetPxPyPzE(mu[k]->Px[1],mu[k]->Py[1],mu[k]->Pz[1],mu[k]->E[1]);
        el_4vec.SetPxPyPzE(el[k]->Px[0],el[k]->Py[0],el[k]->Pz[0],el[k]->E[0]);

        MET = evt[k]->MET;
        METphi = evt[k]->METphi;
        nu.SetPxPyPzE(MET*TMath::Cos(METphi), MET*TMath::Sin(METphi), 0, 0);
        
        if(ischi2){
          fit(&fitresult[0], 3, 1000, mu_4vec[0]+mu_4vec[1]+el_4vec[0], MET, METphi, "m");
          fit(&fitresult[1], 3, 1000, mu_4vec[0]+mu_4vec[1]+el_4vec[0], MET, METphi, "p"); // 0 = minus, 1 = plus
          PutNuPz(&selection_nu[0], fitresult[0].Pz_fit);
          PutNuPz(&selection_nu[1], fitresult[1].Pz_fit);
        }
        else{
          PutNuPz(&selection_nu[0], solveqdeq(80.4, mu_4vec[0]+mu_4vec[1]+el_4vec[0], MET, METphi, "m"));
          PutNuPz(&selection_nu[1], solveqdeq(80.4, mu_4vec[0]+mu_4vec[1]+el_4vec[0], MET, METphi, "p")); // 0 = minus, 1 = plus
        }
        
        if( selection_nu[0].Pz() == selection_nu[1].Pz() ){
          solution_selection = 0; // 0, 1 상관 없으므로
        }
        else{
          if(fabs(selection_nu[0].Pz()) > fabs(selection_nu[1].Pz())){
            smaller = 1;
          }
          else{
            smaller = 0;
          }
          
          solution_selection = smaller;
        }
        
        if(!isPU) weight = evt[k]->weight;
        else      weight = evt[k]->weight * evt[k]->PU_reweight; // pileup weight
        
        if(mu[k]->Charge[0] != mu[k]->Charge[1] && evt[k]->n_bjet>=1 && jet[k]->n_Jet>=1){
        //if(mu[k]->Charge[0] != mu[k]->Charge[1] && mu[0].DeltaR(mu[1]) < 1.0){
          N_entry++;
          PUweight_sum+=evt[k]->PU_reweight;
          hist_dimuon[k]->Fill( (mu_4vec[0]+mu_4vec[1]).M(), weight );
          
        } // additional cuts
      } // Object Selection
    } // event loop
    
    cout << "weight = " << evt[k]->weight << endl
    << "entry = " << N_entry << endl
    << "PUweight = " << PUweight_sum/(double)N_entry << endl;
    
    /// apply weight after filling histogram ///
    //hist_HN[k]->Scale(weight);
    //hist_W_real[k]->Scale(weight);
    //hist_dR[k]->Scale(weight);
    //hist_gamma_star[k]->Scale(weight);
    
    /*
     if(k==4){ // Add two DY process
     hist_HN[4]->Add(hist_HN[3]);
     hist_W_real[4]->Add(hist_W_real[3]);
     }
     */
    
    hist_dimuon[k]->SetFillColor(fillcolors[k]);
    
    /// merging same-type histograms
    if(k>=15 && k<=22){
      hist_dimuon[14]->Add(hist_dimuon[k]);
    }
    if(k>=6 && k<=11){
      hist_dimuon[5]->Add(hist_dimuon[k]);
    }
    if(k==3 || k==4){
      hist_dimuon[2]->Add(hist_dimuon[k]);
    }
    if(k==14 || k==23 || k==5 || k==12 || k==13 || k==2){
      bkgstack_dimuon->Add(hist_dimuon[k]);
    }
    if(k>=2){
      hist_dimuon_err->Add(hist_dimuon[k]);
    }
  } // chain loop
  
  Double_t totalRuntime = totaltime.CpuTime();
  cout << "\n----------Total Runtime: " << totalRuntime << " seconds----------\n" << endl;
  
  gStyle->SetOptStat(0);
  
  /// dimuon ///
  TCanvas *c1 = new TCanvas("c1", "", 800, 600);
  c1->cd();
  ///bkg///
  bkgstack_dimuon->Draw("hist");
  bkgstack_dimuon->SetMaximum(100); // 100 for dR_W, 70 for chi2_lambda
  bkgstack_dimuon->SetTitle("Dimuon(OS) Invariant Mass");
  //bkgstack_dimuon->GetXaxis()->SetTitle("m(#mu_{2}#mu_{3}#nu) [GeV]");
  bkgstack_dimuon->GetYaxis()->SetTitle("Event / 1 GeV");
  ///data///
  hist_dimuon[1]->SetMarkerStyle(3);
  hist_dimuon[1]->SetMarkerSize(1);
  hist_dimuon[1]->Draw("APsameE1");
  ///signal///
  //hist_dimuon[0]->SetLineColor(kRed);
  //hist_dimuon[0]->Draw("histsame");
  ///err///
  //hist_dimuon_err->SetFillStyle(3004);
  //hist_dimuon_err->SetFillColor(kBlue);
  //hist_dimuon_err->Draw("sameE2");
  ///legend///
  TLegend *lg1 = new TLegend(0.65, 0.6, 0.9, 0.9);
  lg1->AddEntry(hist_dimuon[1], "data", "p");
  //lg1->AddEntry(hist_dimuon[0], "HN"+TString::Itoa(sample, 10)+", |V_{N#mu}|^{2}=10^{"+TString::Itoa(TMath::Log10(coupling_const), 10)+"}", "l");
  lg1->AddEntry(hist_dimuon[2], "DY", "f");
  lg1->AddEntry(hist_dimuon[13], "top", "f");
  lg1->AddEntry(hist_dimuon[5], "VV", "f");
  lg1->AddEntry(hist_dimuon[23], "Wtollln", "f");
  lg1->AddEntry(hist_dimuon[12], "Wjets", "f");
  lg1->AddEntry(hist_dimuon[14], "other", "f");
  lg1->Draw();
}
Beispiel #29
0
void r3blandreco(Int_t nNeutrons, Int_t beamE, Int_t Erel)
{
  Int_t d;
  if(Erel == 100){
    d = 35;
  }
  else{
    d = 14;
  }
  
  // ----- Files ---------------------------------------------------------------
  char strDir[] = ".";
  char str[100];
  char str2[100];
  sprintf(str, "%1dAMeV.%1dn.%1dkeV.%1dm.root", beamE,nNeutrons, Erel, d);
  sprintf(str2, "%1dAMeV.%1dkeV.%1dm", beamE, Erel, d);
  TString inFile  = TString(strDir) + "/r3bsim." + TString(str);
  TString digiFile  = TString(strDir) + "/r3bcalibr." + TString(str);
  TString parFile  = TString(strDir) + "/r3bpar." + TString(str);
  TString calibrFile  = TString(strDir) + "/r3bcalibr." + TString(str2) + ".txt";
  TString outFile  = TString(strDir) + "/r3breco." + TString(str);
  // ---------------------------------------------------------------------------



  // ----- Timer ---------------------------------------------------------------
  TStopwatch timer;
  timer.Start();
  // ---------------------------------------------------------------------------



  // ----- Digitization --------------------------------------------------------
  FairRunAna *fRun= new FairRunAna();
  fRun->SetInputFile(inFile);
  fRun->AddFriend(digiFile);
  fRun->SetOutputFile(outFile);
  // ---------------------------------------------------------------------------


  // ---------------------------------------------------------------------------
  Double_t beamEnergy;
  Double_t beamBeta;
  if(200 == beamE) {
    beamEnergy=200.;
    beamBeta=0.5676881;
  } else if(600 == beamE) {
    beamEnergy=600.;
    beamBeta=0.7937626;
  } else if(1000 == beamE) {
    beamEnergy=1000.;
    beamBeta=0.8760237;
  }
  // ---------------------------------------------------------------------------
  
  
  
  // ----- Connect the Tracking Task -------------------------------------------
  R3BNeutronTracker2D* tracker  = new R3BNeutronTracker2D();
  tracker->UseBeam(beamEnergy, beamBeta);
  tracker->ReadCalibrFile(calibrFile.Data());
  fRun->AddTask(tracker);
  // ---------------------------------------------------------------------------



  // ----- Runtime DataBase info -----------------------------------------------
  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo*  parIo1 = new FairParRootFileIo();
  parIo1->open(parFile.Data());
  rtdb->setFirstInput(parIo1);
  rtdb->setOutput(parIo1);
  rtdb->saveOutput();
  // ---------------------------------------------------------------------------



  // ----- Number of events to process -----------------------------------------
  Int_t nEvents = 10000;
  // ---------------------------------------------------------------------------


  
  // ----- Intialise and run ---------------------------------------------------
  fRun->Init();
  fRun->Run(0, nEvents);
  // ---------------------------------------------------------------------------



  // ----- Finish --------------------------------------------------------------
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  cout << endl << endl;
  cout << "Macro finished succesfully." << endl;
  cout << "Output file writen:  "    << outFile << endl;
  cout << "Parameter file writen " << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ---------------------------------------------------------------------------
}
Beispiel #30
0
int writetree_pp(char *ksp = "ppJet40"){

  timer.Start();
  LoadLib();

 
  TString inname="";
  if(strcmp(ksp,"ppJet40")==0)inname = "/hadoop/store/user/belt/hiForest2/PP2013_HiForest_PromptReco_JSon_Jet40Jet60_ppTrack_forestv84.root";
  else if(strcmp(ksp,"ppJet80")==0)inname = "/hadoop/store/user/belt/hiForest2/PP2013_HiForest_PromptReco_JsonPP_Jet80_PPReco_forestv82.root";
    
  //! Load Lib
  //gSystem->Load("/afs/cern.ch/user/p/pawan/scratch0/CMSSW_6_2_0/src/work/pPb/HiForest/V3/hiForest_h.so");
    
  //! Define the input file and HiForest
  //! CMSSW_5_3_3
  HiForest *c = new HiForest(inname,Form("Forest%s",ksp),cPP);
  cout<<"Loaded the hiforest tree : "<<c->GetName()<<endl;
  ShutoffBranches(c);
    

  TFile *fout = new TFile(Form("ntuple_2013_%s_v2.root",ksp),"RECREATE");
    
  std::cout<<"\t"<<std::endl;
  std::cout<<"\t"<<std::endl;
  std::cout<<"**************************************************** "<<std::endl;
  std::cout<<Form("Running for %s ",ksp)<<std::endl;
  std::cout<<Form("pT  cut for %0.3f ",kptrecocut)<<std::endl;
  std::cout<<Form("eta cut for %0.3f ",ketacut)<<std::endl;
  std::cout<<"My hiForest Tree : " <<c->GetName()<<"\t Entries "<<c->GetEntries()<<std::endl;
  std::cout<<"Output file  "<<fout->GetName()<<std::endl;
  std::cout<<"**************************************************** "<<std::endl;
  std::cout<<"\t"<<std::endl;
  std::cout<<"\t"<<std::endl;
    
  //! shut off jet trees
  //c->hasAk2CaloJetTree=0;
  //c->hasAk4CaloJetTree=0;
  //c->hasAk3CaloJetTree=0;
  //c->hasAk5CaloJetTree=0;
    
  c->hasAkPu2CaloJetTree=0;
  c->hasAkPu4CaloJetTree=0;
  c->hasAkPu3CaloJetTree=0;
  //c->hasAkPu5CaloJetTree=0;
    
  //c->hasAk2PFJetTree=0;
  //c->hasAk4PFJetTree=0;
  //c->hasAk5PFJetTree=0;
    
  //c->hasAkPu2PFJetTree=0;
  //c->hasAkPu4PFJetTree=0;
  //c->hasAkPu5PFJetTree=0;
    
  c->hasTrackTree=0;
    
  //! For jets
  //Jets *mJets2 = 0;
  Jets *mJets3 = 0;
  Jets *mJets4 = 0;
  Long64_t nentries = c->GetEntries();
  std::cout<<Form("# of entries in TTree for %s : ",ksp)<<nentries<<std::endl;

  //TTree *jetR2Tree = new TTree("jetR2","ak2PF");
  TTree *jetR3Tree = new TTree("jetR3","ak3PF");
  TTree *jetR4Tree = new TTree("jetR4","ak4PF");
  TTree *evtTree = new TTree("evt","evt");

  // declare the event variables.
  int evt;
  int run;
  float vx;
  float vy;
  float vz;
  int jet40;
  int jet60;
  int jet80;
  int jet100;
  int ntrk;

  // declare the jet variables
  /*
  int nrefe2;
  float pt2[1000];
  float raw2[1000];
  float eta2[1000];
  float phi2[1000];
  float chMax2[1000];
  float trkMax2[1000];
  float chSum2[1000];
  float phSum2[1000];
  float neSum2[1000];
  float trkSum2[1000];
  float phMax2[1000];
  float neMax2[1000];
  */

  int nrefe3;
  float pt3[1000];
  float raw3[1000];
  float eta3[1000];
  float phi3[1000];
  float chMax3[1000];
  float trkMax3[1000];
  float chSum3[1000];
  float phSum3[1000];
  float neSum3[1000];
  float trkSum3[1000];
  float phMax3[1000];
  float neMax3[1000];

  int nrefe4;
  float pt4[1000];
  float raw4[1000];
  float eta4[1000];
  float phi4[1000];
  float chMax4[1000];
  float trkMax4[1000];
  float chSum4[1000];
  float phSum4[1000];
  float neSum4[1000];
  float trkSum4[1000];
  float phMax4[1000];
  float neMax4[1000];
    
  //set the branches in the trees. 
  evtTree->Branch("evt",&evt,"evt/I");
  evtTree->Branch("run",&run,"run/I");
  evtTree->Branch("vx",&vx,"vx/F");
  evtTree->Branch("vy",&vy,"vy/F");
  evtTree->Branch("vz",&vz,"vz/F");
  evtTree->Branch("jet40",&jet40,"jet40/I");
  evtTree->Branch("jet60",&jet60,"jet60/I");
  evtTree->Branch("jet80",&jet80,"jet80/I");
  evtTree->Branch("jet100",&jet100,"jet100/I");
  evtTree->Branch("ntrk",&ntrk,"ntrk/I");
  /*
  jetR2Tree->Branch("nrefe",&nrefe2,"nrefe/I");
  jetR2Tree->Branch("pt",&pt2,"pt[nrefe]/F");
  jetR2Tree->Branch("raw",&raw2,"raw[nrefe]/F");
  jetR2Tree->Branch("eta",&eta2,"eta[nrefe]/F");
  jetR2Tree->Branch("phi",&phi2,"phi[nrefe]/F");
  jetR2Tree->Branch("chMax",&chMax2,"chMax[nrefe]/F");
  jetR2Tree->Branch("trkMax",&trkMax2,"trkMax[nrefe]/F");
  jetR2Tree->Branch("phMax",&phMax2,"phMax[nrefe]/F");
  jetR2Tree->Branch("neMax",&neMax2,"neMax[nrefe]/F");
  jetR2Tree->Branch("chSum",&chSum2,"chSum[nrefe]/F");
  jetR2Tree->Branch("phSum",&phSum2,"phSum[nrefe]/F");
  jetR2Tree->Branch("neSum",&neSum2,"neSum[nrefe]/F");
  jetR2Tree->Branch("trkSum",&trkSum2,"trkSum[nrefe]/F");
  */
  jetR3Tree->Branch("nrefe",&nrefe3,"nrefe/I");
  jetR3Tree->Branch("pt",&pt3,"pt[nrefe]/F");
  jetR3Tree->Branch("raw",&raw3,"raw[nrefe]/F");
  jetR3Tree->Branch("eta",&eta3,"eta[nrefe]/F");
  jetR3Tree->Branch("phi",&phi3,"phi[nrefe]/F");
  jetR3Tree->Branch("chMax",&chMax3,"chMax[nrefe]/F");
  jetR3Tree->Branch("trkMax",&trkMax3,"trkMax[nrefe]/F");
  jetR3Tree->Branch("phMax",&phMax3,"phMax[nrefe]/F");
  jetR3Tree->Branch("neMax",&neMax3,"neMax[nrefe]/F");
  jetR3Tree->Branch("chSum",&chSum3,"chSum[nrefe]/F");
  jetR3Tree->Branch("phSum",&phSum3,"phSum[nrefe]/F");
  jetR3Tree->Branch("neSum",&neSum3,"neSum[nrefe]/F");
  jetR3Tree->Branch("trkSum",&trkSum3,"trkSum[nrefe]/F");

  jetR4Tree->Branch("nrefe",&nrefe4,"nrefe/I");
  jetR4Tree->Branch("pt",&pt4,"pt[nrefe]/F");
  jetR4Tree->Branch("raw",&raw4,"raw[nrefe]/F");
  jetR4Tree->Branch("eta",&eta4,"eta[nrefe]/F");
  jetR4Tree->Branch("phi",&phi4,"phi[nrefe]/F");
  jetR4Tree->Branch("chMax",&chMax4,"chMax[nrefe]/F");
  jetR4Tree->Branch("trkMax",&trkMax4,"trkMax[nrefe]/F");
  jetR4Tree->Branch("phMax",&phMax4,"phMax[nrefe]/F");
  jetR4Tree->Branch("neMax",&neMax4,"neMax[nrefe]/F");
  jetR4Tree->Branch("chSum",&chSum4,"chSum[nrefe]/F");
  jetR4Tree->Branch("phSum",&phSum4,"phSum[nrefe]/F");
  jetR4Tree->Branch("neSum",&neSum4,"neSum[nrefe]/F");
  jetR4Tree->Branch("trkSum",&trkSum4,"trkSum[nrefe]/F");

     
  for (Long64_t ievt=0; ievt<nentries;ievt++) {//! event loop
  //for (Long64_t ievt=0; ievt<100;ievt++) {//! event loop
    //! load the hiForest event
    c->GetEntry(ievt);

    bool evSel = false;
    evSel = fabs(c->evt.vz)<15. && c->skim.pHBHENoiseFilter  && c->skim.pPAcollisionEventSelectionPA && (c->hlt.HLT_PAJet40_NoJetID_v1 || c->hlt.HLT_PAJet60_NoJetID_v1 || c->hlt.HLT_PAJet80_NoJetID_v1 || c->hlt.HLT_PAJet100_NoJetID_v1);
	
    if(!evSel)continue;
        
   
    run = c->evt.run;
    evt = c->evt.evt;
    vx = c->evt.vx;
    vy = c->evt.vy;
    vz = c->evt.vz;
    jet40  = c->hlt.HLT_PAJet40_NoJetID_v1;
    jet60  = c->hlt.HLT_PAJet60_NoJetID_v1;
    jet80  = c->hlt.HLT_PAJet80_NoJetID_v1;
    jet100 = c->hlt.HLT_PAJet100_NoJetID_v1;
    ntrk = c->evt.hiNtracks;

    if(ievt%10000 == 0) cout<<" ******** Event # "<< ievt <<"\t Run " <<run<<endl;
    /*
    mJets2 = &(c->ak2PF);
    nrefe2 = mJets2->nref;

    for (int i = 0; i<nrefe2; i++) {
      pt2[i]     = mJets2->jtpt[i];
      eta2[i]    = mJets2->jteta[i];
      phi2[i]    = mJets2->jtphi[i];
      raw2[i]    = mJets2->rawpt[i];
      chMax2[i]  = mJets2->chargedMax[i];
      trkMax2[i]  = mJets2->trackMax[i];
      chSum2[i]  = mJets2->chargedSum[i];
      phSum2[i]  = mJets2->photonSum[i];
      neSum2[i]  = mJets2->neutralSum[i];
      trkSum2[i] = mJets2->trackSum[i];
      phSum2[i]  = mJets2->photonMax[i];
      neMax2[i]  = mJets2->neutralMax[i];
    }
    */

    mJets3 = &(c->ak3PF);
    nrefe3 = mJets3->nref;

    for (int i = 0; i<nrefe3; i++) {
      pt3[i]     = mJets3->jtpt[i];
      eta3[i]    = mJets3->jteta[i];
      phi3[i]    = mJets3->jtphi[i];
      raw3[i]    = mJets3->rawpt[i];
      chMax3[i]  = mJets3->chargedMax[i];
      trkMax3[i]  = mJets3->trackMax[i];
      chSum3[i]  = mJets3->chargedSum[i];
      phSum3[i]  = mJets3->photonSum[i];
      neSum3[i]  = mJets3->neutralSum[i];
      trkSum3[i] = mJets3->trackSum[i];
      phSum3[i]  = mJets3->photonMax[i];
      neMax3[i]  = mJets3->neutralMax[i];
    }

    mJets4 = &(c->ak4PF);
    nrefe4 = mJets4->nref;

    for (int i = 0; i<nrefe4; i++) {
      pt4[i]     = mJets4->jtpt[i];
      eta4[i]    = mJets4->jteta[i];
      phi4[i]    = mJets4->jtphi[i];
      raw4[i]    = mJets4->rawpt[i];
      chMax4[i]  = mJets4->chargedMax[i];
      trkMax4[i]  = mJets4->trackMax[i];
      chSum4[i]  = mJets4->chargedSum[i];
      phSum4[i]  = mJets4->photonSum[i];
      neSum4[i]  = mJets4->neutralSum[i];
      trkSum4[i] = mJets4->trackSum[i];
      phSum4[i]  = mJets4->photonMax[i];
      neMax4[i]  = mJets4->neutralMax[i];
    }

    evtTree->Fill();
    //jetR2Tree->Fill();
    jetR3Tree->Fill();
    jetR4Tree->Fill();

  }  

  fout->cd();
  fout->Write();
  fout->Close();
    
  // time out:
  timer.Stop();
  float rtime  = timer.RealTime();
  float ctime  = timer.CpuTime();
    
  cout<<"\t"<<endl;
  cout<<Form("RealTime=%f seconds, CpuTime=%f seconds",rtime,ctime)<<endl;
  cout<<"\t"<<endl;
  cout<<"Good bye : " <<"\t"<<endl;
    
  return 0;

  
  




}