Example #1
0
TCanvas *plot_adc_fit(Int_t pmt=1, Int_t tdc_min=750, Int_t tdc_width=400, Int_t adc_neighbor_cut=10, Int_t adc_cut=50){

        TString cut, draw, draw1, title, grtitle;
        title.Form("run_%d_ADC_Fit",run);
        TCanvas *cADCFit = new TCanvas("cADCFit",title,xcanvas,ycanvas);
	title.Form("run_%d_ADC_Mean_Fit",run);
	TCanvas *cADCMeanFit= new TCanvas("cADCMeanFit",title,xcanvas,ycanvas);

	// Setting up different arrays and objects used to create the two canvases.

	TH1D *htmp[NUMPIXEL];
	TF1 *function;
	TF1 *function1;
	Int_t histmax_cut[16], gaus_cut_plus[16];
	Float_t gaus_cut_minus[16];

	Double_t upixel[NUMPIXEL]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
	Double_t epixel[NUMPIXEL]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	Double_t errors[NUMPIXEL]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

	Double_t constants[16], means[16], sigmas[16];

	TString tmpentry;
	MyStyle->SetStatX(0.9);
        MyStyle->SetStatY(0.6);
        MyStyle->SetStatY(0.4);

	setPaddleIndices(); //Setting the geometric paddle locations

	Int_t nbin=90;
	Int_t min=-100, max=800; // change max to 1500 for PMT 9

	for(Int_t i = 1; i <= NUMPIXEL; i++)
	  {
	    tmpentry.Form("htmp%d",i);
	    htmp[i-1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
	    htmp[i-1]->SetLineColor(kRed);
	    title.Form("Run %d ADC Fit pmt %d, paddle %d: %d < tdc < %d",run,pmt,i,tdc_min,tdc_min+tdc_width);
	    htmp[i-1]->SetTitle(title);
	  }

	// Filling the histograms using only adc data with good tdc and good adc neighbor cut.

	Int_t nentries=n_events_to_analyze;

	for (Int_t id=1;id<=nentries;id++)
	  {
	    T->GetEntry(id);
	    Int_t ipaddle = (pmt)*NUMPADDLE+1;
	    for (Int_t pixel=0; pixel < NUMPIXEL; pixel++)
	    {
		Int_t index = (pmt-1)*NUMPIXEL+pixel;
		if (pixel!=pixel1[pmt-1]-1 && pixel!=pixel2[pmt-1]-1)
		{
		  ipaddle--;
		  // if(tdcl[index] > tdc_min && tdcl[index] < tdc_min+tdc_width)
		  //  {
		    if (ipaddle < 2) 
		    {
			if (adc_c[paddleindex[ipaddle+1]] < adc_neighbor_cut)
			{
			  htmp[pixel]->Fill(adc_c[index]);
			}
		    }
		    else if (ipaddle > NUMPMT*NUMPADDLE) // should this be > or = ?
		    {
			if (adc_c[paddleindex[ipaddle-1]] < adc_neighbor_cut)
			{
			    htmp[pixel]->Fill(adc_c[index]);
			}
		    }
		    else
		    {
			if (adc_c[paddleindex[ipaddle-1]] < adc_neighbor_cut && adc_c[paddleindex[ipaddle+1]] < adc_neighbor_cut)
			{
			  htmp[pixel]->Fill(adc_c[index]);
			}
		        }
		    // }
		}
	    }
	  }


	// Creating the canvas of adc data with good tdc and fitting the adc with a gaussian or "landau" function.

	cADCFit->Clear();
	cADCMeanFit->Clear();
	cADCFit->Divide(4,4);

        Int_t count = 0;
        for (Int_t i=0; i<NUMPIXEL; i++)
	  {
	    if(i != pixel1[pmt-1]-1 && i != pixel2[pmt-1]-1) 
	      {
         //       means[i]=0.0;
	//	int check = 0;
		cADCFit->cd(count+1);
		 gPad->SetLogy();
		cADCFit->Update();
                
		Int_t entries = htmp[i]->GetEntries();
		//float mean = htmp[i]->GetMean(1);
		//float RMS = htmp[i]->GetRMS(1);
                
		htmp[i]->SetStats(0);
		htmp[i]->Draw();

		Double_t bc =0.0;
		Double_t bn = 0.0;

	    	for (Int_t j=15; j<100 ;j++){
		  bc = htmp[i]->GetBinContent(j);
		  if( bc == 0.0 || (bc <htmp[i]->GetBinContent(j+1) && bc < htmp[i]->GetBinContent(j+2) && bc <htmp[i]->GetBinContent(j-1) && bc <htmp[i]->GetBinContent(j-2) && bc <htmp[i]->GetBinContent(j-3) && bc <htmp[i]->GetBinContent(j-4))  ){
		    bn = htmp[i]->GetBinCenter(j);
		    htmp[i]->Fit("gaus","","",bn,bn+600);
		    break;
		  }
		}       

		//htmp[i]->Fit("landau","","", 0, 250);
		function = htmp[i]->GetFunction("gaus");
		function->SetLineColor(1);

		constants[i] = function->GetParameter(0);
		means[i] = function->GetParameter(1);
		sigmas[i] = function->GetParameter(2);
              
	count++;
	      
	      }
	  }
	  

	// Printing out means and sigmas to screen with corresponding pixel number.

	for (Int_t i=0; i<NUMPIXEL; i++)
	  {
	    cout << "Pixel number: " << i+1 << "   \t mean = " << means[i] << "    \t sigma = " << sigmas[i] << endl;
	  }

        title.Form("run_%d_ADC_pmt_%d_tdc_min_%d_max_%d.png",run,pmt,tdc_min,tdc_min+tdc_width);
        cADCFit->Print(title);
        cADCFit->cd(0);

	// End of work on canvas with adc data fitted with a function

	// Creating the canvas of mean adc data with good tdc data.

	cADCMeanFit->cd();

	Double_t mmean[2]={0,0};
	Double_t merror[2]={1,1};
	Double_t mpixel[2]={0,0};
	Double_t mepixel[2]={0,0};
	mpixel[0]=pixel1[pmt-1];
	mpixel[1]=pixel2[pmt-1];

	Double_t yline[2]={100,100};
	Double_t xline[2]={0,17};

	// Calculating errors on the mean adc data and printing out number of entries, means, and errors
	// to screen with corresponding pixel number.

	count = 0;
	for (Int_t i = 0; i < NUMPIXEL; i++)
	{
	    if(i != pixel1[pmt-1]-1 && i != pixel2[pmt-1]-1) 
	    {
		Int_t entries = htmp[i]->GetEntries();
		errors[i] = sigmas[i]/sqrt(entries);
		if(means[i] > 1)
		{
		    cout << "Pixel number: " <<  i+1 << "  \t entries: " << entries << "\t mean: " 
			 << means[i] << "\t error: " << errors[i] << endl;
		}
               	count++;
	    }
	}

	// Creating three different graphs for used pixels, missing pixels, and general formatting.

	gr = new TGraphErrors(NUMPIXEL,upixel,means,epixel,errors);
	gr->SetMarkerStyle(21);
	gr->GetXaxis()->SetTitle("Pixel Number");
	gr->GetYaxis()->SetTitle("Mean ADC Fit (Good TDC)");
	gr->GetYaxis()->SetTitleOffset(1.4);
	grtitle.Form("run_%d_pmt_%d_adc_mean",run,pmt);
	gr->SetTitle(grtitle);
	gr2 = new TGraphErrors(2,mpixel,mmean,mepixel,merror);
	gr2->SetMarkerStyle(21);
	gr2->SetMarkerColor(2);
	gr2->SetTitle("");
	gr3 = new TGraph(2,xline,yline);
	gr3->SetLineColor(2);
	gr3->SetLineWidth(2);
	gr3->SetLineStyle(2);
	gr3->SetTitle("");

	// Drawing the three different graphs to the adc mean values canvas.

	gr->Draw("AP");
	gr2->Draw("P");
	gr3->Draw("L");
            
        cADCMeanFit->Update();
	cADCMeanFit->cd(0);

	// End of work on canvas with adc mean data.

	// Creating a file to output parameters of function fitted to the ADC data with good TDC.
        TString filename;
        filename.Form("run_%d_pmt_%d_adc_fitresults.txt", run, pmt);
	ofstream outfile(filename);

	outfile << "Run #: " << run << "\t PMT #: " << pmt << " \t  Paramters of fitted ADC data with good TDC. \n";
	outfile << "Pixel # \t Mean Value \t Error \t Sigma \n" << endl;
	for(Int_t i = 0; i < NUMPIXEL; i++)
	  {
	    outfile << i+1 << "\t" << means[i] << "\t" << errors[i] << "\t" << sigmas[i] << endl;
	  }
	cout << "Created output file for parameters." << endl;
	outfile.close();
	
	return cADCMeanFit;
	return cADCFit;
}
Example #2
0
//Usage: .x DeadXtal.C+("root://eoscms//eos/cms/store/group/alca_ecalcalib/lpernie/ALL_2012C_pi0_NewTag_01/iter_0/2012C_epsilonPlots.root","plots/")
void DeadXtal( TString Path, TString OutDir ){

  //Starting
  cout<<"Starting with: DeadXtal.C"<<endl;
  TFile* fin = TFile::Open( Path.Data() );
  if(!fin) { cout << "Invalid file: " << Path.Data() << " .. try again" << endl; return; }
  std::string calibMapFileName = string(Path.Data());
  std::string strToReplace = "epsilonPlots";
  calibMapFileName.replace(calibMapFileName.find(strToReplace.c_str()),strToReplace.size(),"calibMap");

  TFile* MapFile = TFile::Open( calibMapFileName.c_str() );
  TTree *calibEB = (TTree*) MapFile->Get("calibEB");
  TTree *calibEE = (TTree*) MapFile->Get("calibEE");
  if(!MapFile) { cout << "Invalid file: MapFile .. try again" << endl; return; }
  system( (string("mkdir -p ") + OutDir.Data() ).c_str() );
  TString nameFile = OutDir + "/h_DeadXtal.root";
  TFile* output = new TFile( nameFile.Data(), "RECREATE" );
  output->cd();
  TH2F* rms_EB  = new TH2F("rms_EB","DeadXtal #phi on x #eta on y",MAX_IPHI, MIN_IPHI, MAX_IPHI, 2*MAX_IETA+1, -MAX_IETA-0.5, MAX_IETA+0.5 );
  TH2F* rms_EB_r= new TH2F("rms_EB_r","DeadXtal #eta on x #phi on y", 2*MAX_IETA+1, -MAX_IETA-0.5, MAX_IETA+0.5, MAX_IPHI, MIN_IPHI, MAX_IPHI);
  TH2F* rms_EEp = new TH2F("rms_EEp","DeadXtal iX on x iY on y (EEp)",100,0.5,100.5,100,0.5,100.5);
  TH2F* rms_EEm = new TH2F("rms_EEm","DeadXtal iY on x iY on y (EEm)",100,0.5,100.5,100,0.5,100.5);

  //EB
  cout<<"Now EB..."<<endl;
  std::vector<int> Xtal_EB; Xtal_EB.clear();
  for(int nEB=0; nEB<61200; nEB++){
    //ostringstream convert; convert << nEB;
    string convert = std::to_string(nEB);
    TString name = "Barrel/epsilon_EB_iR_" + convert;
    TH1F * h1 = (TH1F*) fin->Get( name.Data() );
    if(h1->GetEntries()==0){
	Xtal_EB.push_back( nEB );
    }
  }
  //EE
  cout<<"Now EE..."<<endl;
  std::vector<int> Xtal_EE; Xtal_EE.clear();
  for(int nEE=0; nEE<14648; nEE++){
    //ostringstream convert; convert << nEE;
    string convert = std::to_string(nEE);
    TString name = "Endcap/epsilon_EE_iR_" + convert;
    TH1F * h1 = (TH1F*) fin->Get( name.Data() );
    if(h1->GetEntries()==0){
	Xtal_EE.push_back( nEE );
    }
  }
  //DrawPlots
  cout<<"Drawing EB."<<endl;
  Int_t ieta, iphi, hashedIndex; 
  calibEB->SetBranchAddress( "ieta_", &ieta);
  calibEB->SetBranchAddress( "iphi_", &iphi);
  calibEB->SetBranchAddress( "hashedIndex_", &hashedIndex);
  std::map<int,std::vector<int>> EBMap; EBMap.clear();
  Long64_t nentriesEB = calibEB->GetEntriesFast();
  for(Long64_t iEntry=0; iEntry<nentriesEB; iEntry++){
    calibEB->GetEntry(iEntry);
    std::vector<int> EtaPhi; EtaPhi.clear();
    EtaPhi.push_back( ieta ); EtaPhi.push_back( iphi );
    EBMap[hashedIndex] = EtaPhi;
  }
  for(int i=0; i<int(Xtal_EB.size()); i++){
    int BinEta = EBMap[Xtal_EB[i]][0] + 86;
    int BinPhi = EBMap[Xtal_EB[i]][1] + 1;
    rms_EB->SetBinContent( BinPhi, BinEta, 1 );
    rms_EB_r->SetBinContent( BinEta, BinPhi, 1 );
  }
  cout<<"And finally drawing EE."<<endl;
  Int_t ix, iy, zside, hashedIndex2; 
  calibEE->SetBranchAddress( "ix_", &ix);
  calibEE->SetBranchAddress( "iy_", &iy);
  calibEE->SetBranchAddress( "zside_", &zside);
  calibEE->SetBranchAddress( "hashedIndex_", &hashedIndex2);
  std::map<int,std::vector<int>> EEMap; EEMap.clear();
  Long64_t nentriesEE = calibEE->GetEntriesFast();
  for(Long64_t iEntry=0; iEntry<nentriesEE; iEntry++){
    calibEE->GetEntry(iEntry);
    std::vector<int> XYeZ; XYeZ.clear();
    XYeZ.push_back( ix ); XYeZ.push_back( iy ); XYeZ.push_back( zside );
    EEMap[hashedIndex2] = XYeZ;
  }
  for(int i=0; i<int(Xtal_EE.size()); i++){
    int BinX = EEMap[Xtal_EE[i]][0]+1;
    int BinY = EEMap[Xtal_EE[i]][1]+1;
    if( EEMap[Xtal_EE[i]][2]<0 ) rms_EEm->SetBinContent( BinX, BinY, 1 );
    if( EEMap[Xtal_EE[i]][2]>0 ) rms_EEp->SetBinContent( BinX, BinY, 1 );
  }
  //END
  cout<<"Done!!"<<endl;
  output->cd();
  rms_EB->Write();
  rms_EB_r->Write();
  rms_EEp->Write();
  rms_EEm->Write();
  output->Close();
}
 void print()
 {
    printf("%s \t:  N=%8.2f/sec. \t <E>=%7.1f MeV \t fluence=%9.3E/sec./cm**2 \t dissip.=%9.3E MeV/sec./cm**2\n",
           detector.Data(), counts, energy, fluence, dissipation);
 }
Example #4
0
AliAnalysisTaskJetHBOM *AddTaskJetHBOM(char* bRec,char* bGen ,UInt_t filterMask,UInt_t iPhysicsSelectionFlag,Char_t *jf,Float_t radius,Int_t kWriteAOD,char *deltaFile,Float_t ptTrackCut,Float_t etaTrackWindow,Float_t vertexWindow,TString effLoc,Int_t fNHBOM, Int_t constCone, Float_t constConePhi,Float_t constConeEta)
 {
   //if constCone is true, the random Cone positon is set to constConePhi and constConeEta. Else the cone is random set and the parameters constConePhi and constConeEta are irrelevant

 // Creates a jet fider task, configures it and adds it to the analysis manager.
   kPtTrackCutCl = ptTrackCut;
   kTrackEtaWindowCl = etaTrackWindow;
   kVertexWindowCl = vertexWindow;

   TString outputFile(deltaFile);
    // Get the pointer to the existing analysis manager via the static access method.
    //==============================================================================
    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
    if (!mgr) {
       ::Error("AddTaskJetHBOM", "No analysis manager to connect to.");
       return NULL;
    }  

    // Check the analysis type using the event handlers connected to the analysis manager.
    //==============================================================================
    if (!mgr->GetInputEventHandler()) {
      ::Error("AddTaskJetHBOM", "This task requires an input event handler");
       return NULL;
    }

    TString type = mgr->GetInputEventHandler()->GetDataType();
    TString typeRec(bRec);
    TString typeGen(bGen);
    if(!typeRec.Contains("AODextra")) {
      typeGen.ToUpper();
      typeRec.ToUpper();
    }
    cout << "typeRec: " << typeRec << endl;
    // Create the task and configure it.
    //===========================================================================


    TString cAdd = "";
    cAdd += Form("%02d_",(int)((radius+0.01)*10.));
    cAdd += Form("B%d",(int)kBackgroundModeCl);
    cAdd += Form("_Filter%05d",filterMask);
    cAdd += Form("_Cut%05d",(int)(1000.*kPtTrackCutCl));
    cAdd += Form("_hbom%02d",fNHBOM);
    if(constCone){
      cAdd += Form("_constConePhi%02dEta%02d",constConePhi,constConeEta);
    }
    Printf("%s %E",cAdd.Data(),kPtTrackCutCl);
    AliAnalysisTaskJetHBOM* hbom = new  AliAnalysisTaskJetHBOM(Form("JetHBOM%s_%s%s",bRec,jf,cAdd.Data()));
      
   hbom->SetFilterMask(filterMask); 
   //   hbom->SetUseGlobalSelection(kTRUE); 
   hbom->SetVtxCuts(kVertexWindowCl,1);//sets fVtxZCut and fVtxR2Cut
   if(type == "AOD"){
     // Assume all jet are produced already
     hbom->SetAODTrackInput(kTRUE);
     hbom->SetAODMCInput(kTRUE);
   }

   if(typeRec.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD
     hbom->SetTrackTypeRec(AliAnalysisTaskJetHBOM::kTrackAODMCChargedAcceptance);
     hbom->SetTrackPtCut(kPtTrackCutCl);
     hbom->SetTrackEtaWindow(kTrackEtaWindowCl);
   }
   else if (typeRec.Contains("AODMC2")){
     hbom->SetTrackTypeRec(AliAnalysisTaskJetHBOM::kTrackAODMCCharged);
     hbom->SetTrackPtCut(kPtTrackCutCl);
     hbom->SetTrackEtaWindow(5);
   }
   else if (typeRec.Contains("AODMC")){
     hbom->SetTrackTypeRec(AliAnalysisTaskJetHBOM::kTrackAODMCAll);
     hbom->SetTrackPtCut(kPtTrackCutCl);
     hbom->SetTrackEtaWindow(5);
   }
   else if (typeRec.Contains("AODextraonly")) {
     hbom->SetTrackTypeRec(AliAnalysisTaskJetHBOM::kTrackAODextraonly);
     hbom->SetTrackPtCut(kPtTrackCutCl);
     hbom->SetTrackEtaWindow(kTrackEtaWindowCl);
   }
   else if (typeRec.Contains("AODextra")) {
     cout << "AliAnalysisTaskJetHBOM::kTrackAODextra: " << AliAnalysisTaskJetHBOM::kTrackAODextra << endl;
     hbom->SetTrackTypeRec(AliAnalysisTaskJetHBOM::kTrackAODextra);
     hbom->SetTrackPtCut(kPtTrackCutCl);
     hbom->SetTrackEtaWindow(kTrackEtaWindowCl);
   }
   else if (typeRec.Contains("AOD")) {
     hbom->SetTrackTypeRec(AliAnalysisTaskJetHBOM::kTrackAOD);
     hbom->SetTrackPtCut(kPtTrackCutCl);
     hbom->SetTrackEtaWindow(kTrackEtaWindowCl);
   }

   hbom->SetRparam(radius);
   hbom->SetGhostArea(0.005);
   hbom->SetGhostEtamax(kTrackEtaWindowCl);

   switch (jf) {
   case "ANTIKT":
     hbom->SetAlgorithm(2); // antikt from fastjet/JetDefinition.hh
     break;
   case "CA":
     hbom->SetAlgorithm(1); // CA from fastjet/JetDefinition.hh
     break;
   case "KT":
     hbom->SetAlgorithm(0); // kt from fastjet/JetDefinition.hh
     break;
   default:
     ::Error("AddTaskJetHBOM", "Wrong jet finder selected\n");
     return 0;
   }

   //Constant Cone analysis
   if(constCone){
     hbom->SetRandConePos(constConeEta,constConePhi);
   }

   
   if(kWriteAOD){
     if(outputFile.Length())hbom->SetJetOutputFile(outputFile);
     hbom->SetJetOutputBranch(Form("hbom%s_%s%s",bRec,jf,cAdd.Data()));
     hbom->SetJetOutputMinPt(0); // store only jets above a certain threshold
   }

   //sets number of detector hits
   hbom->SetfNHBOM(fNHBOM);

   //physics Selection
   if(iPhysicsSelectionFlag)hbom->SelectCollisionCandidates(iPhysicsSelectionFlag);

   mgr->AddTask(hbom);

   // Create ONLY the output containers for the data produced by the task.
   // Get and connect other common input/output containers via the manager as below
   //==============================================================================
   AliAnalysisDataContainer *coutput1_Spec = mgr->CreateContainer(Form("hbom_%s_%s_%s%s",bRec,bGen,jf,cAdd.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWGJE_hbom_%s_%s_%s%s",AliAnalysisManager::GetCommonFileName(),bRec,bGen,jf,cAdd.Data()));

   mgr->ConnectInput  (hbom, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput (hbom, 0, mgr->GetCommonOutputContainer());
   mgr->ConnectOutput (hbom,  1, coutput1_Spec );
   
   //loads efficiencies
   hbom->SetEfficiencyPt(GetEfficiencyPt(effLoc));
   hbom->SetEfficiencyPhi(GetEfficiencyPhi(effLoc));
   
   return hbom;
}
Example #5
0
void runTask(Float_t etamax=0.5,const char * incollection = 0, const char * outfile = "dndeta.root", Bool_t skipNorm = kFALSE)
{
  // for running with root only
  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libSTEERBase");
  gSystem->Load("libESD");
  gSystem->Load("libAOD");

  // load analysis framework
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");


  TChain * chain = new TChain ("TE");
  if (incollection == 0) {
    chain->Add("galice.root");
  }
  else if (TString(incollection).Contains("xml")){
    TGrid::Connect("alien://");
    TAlienCollection * coll = TAlienCollection::Open (incollection);
    while(coll->Next()){
      chain->Add(TString("alien://")+coll->GetLFN());
    }
  } else {
    ifstream file_collect(incollection);
    TString line;
    while (line.ReadLine(file_collect) ) {
      chain->Add(line.Data());
    }
  }
  chain->GetListOfFiles()->Print();

  // for includes use either global setting in $HOME/.rootrc
  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
  // or in each macro
  gSystem->AddIncludePath("-I$ALICE_ROOT/include");

  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("dNdeta");

  AliVEventHandler* esdH = new AliESDInputHandler;
  ((AliESDInputHandler*)esdH)->SetReadFriends(kFALSE);
  mgr->SetInputEventHandler(esdH);

  // Create tasks
  gROOT->LoadMacro("AliAnalysisTaskdNdetaMC.cxx++g");

  AliAnalysisTask *task1 = new AliAnalysisTaskdNdetaMC("TaskdNdeta");
  ((AliAnalysisTaskdNdetaMC*)task1)->SetEtaMax(etamax);
  if (skipNorm) ((AliAnalysisTaskdNdetaMC*)task1)->SkipNormalization();
  // Enable MC event handler

  AliMCEventHandler* handler = new AliMCEventHandler;
  handler->SetReadTR(kFALSE);
  mgr->SetMCtruthEventHandler(handler);

  // Add tasks
  mgr->AddTask(task1);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("coutput", TList::Class(),    AliAnalysisManager::kOutputContainer, outfile);

  // Connect input/output
  mgr->ConnectInput(task1, 0, cinput);
  mgr->ConnectOutput(task1, 1, coutput1);

  // Enable debug printouts
  mgr->SetDebugLevel(0);

  if (!mgr->InitAnalysis()) return;

  mgr->PrintStatus();

  mgr->StartAnalysis("local", chain);
}
Example #6
0
void MakeCutLog(const char *inputRootFile = "AnalysisResults",const char *path = "./", const char* outputDir="./Output/"){

  fstream outputFile(Form("%sCutSelection.log",outputDir),ios::out);
  if(!outputFile.is_open()){
    cout<<"Problem opening file"<<endl;
    return;
  }

  //  Char_t filename_input1[200] = (Form("%s%s",path,input1));	
  TString filename = Form("%s%s.root",path,inputRootFile);	
  TFile f(filename.Data());  

  TList *directories = f.GetListOfKeys(); // get the list of directories in the file
  
  for(Int_t entFile=0;entFile<directories->GetEntries();entFile++){

    TObject * o = f.Get(directories->At(entFile)->GetName()); // get the object in the base directory

    if(TString(o->IsA()->GetName())=="TDirectoryFile"){ // means that this is a directory (PWGGA......)
      
      TDirectory *pwg4dir =(TDirectory*)o;
 
      TString baseDirName = pwg4dir->GetName();
      
      TString reconstructionFlagString = ""; // this is for new scheme where also the flags are coded in numbers in the PWGGA.... name

      if(baseDirName.Length()>31){
	reconstructionFlagString = baseDirName(baseDirName.Index("GammaConversion_")+16,8);
      }
      
      TList *pwg4list = pwg4dir->GetListOfKeys(); // list of the yeys inside the base directory

      for(Int_t entHist=0;entHist<pwg4list->GetEntries();entHist++){
	TString name = pwg4list->At(entHist)->GetName();

	if(name.Contains("container")==0){ // does not try to read the container (get errors if tried)
	  TObject * oHist = pwg4dir->Get(pwg4list->At(entHist)->GetName()); // get the object 
	  
	  if(TString(oHist->IsA()->GetName())=="TList"){ // check if the object is a TList
	    
	    TString listname = oHist->GetName();
	    cout<<"Reading: "<<listname.Data()<<endl;
	    
	    TString cutString = listname(listname.Index("_")+1,listname.Length()) + "\n";// get the Cut string from the name


	    outputFile << cutString.Data();
	  }
	}
      }
    }
  }
  outputFile.close();
}
Example #7
0
void Pi0Hist4( TString hist = "MMiss", UInt_t lo = 308, UInt_t tbin = 0,
		Bool_t save = kFALSE)
{
	UInt_t i, j, rebin;
	Int_t th, dth;
	Double_t eg, deg;
	Double_t x1, x2, x3, left, right;
	Double_t x[2], y[2];
	Double_t q_pi, T_pi;
	Double_t TggCutOffset;
	TString name;

	TggCutOffset = 3;

	gStyle->SetOptStat( 0);

	if ( !gROOT->GetListOfCanvases()->IsEmpty()) {
		delete c1;
	}
	TCanvas *c1 = new TCanvas ( "c1", "Subtraction", 300, 20, 1200, 600);
   c1->SetGrid();
   c1->GetFrame()->SetFillColor( 21);
   c1->GetFrame()->SetBorderSize( 12);
	c1->Divide( 5, 2);

	th = theta[tbin].mid;
	dth = 20;

	j = 1;
	for ( i = lo; i > lo-5; i--)
	{
		eg = tcd[i].energy;
		deg = tcd[i].denergy;

		if ( hist == "MMiss")
		{
			x1 = Linear( 145, 933, 400, 880, eg);
			x2 = Linear( 145, 945, 400, 1000, eg);
			x3 = Linear( 145, 918, 400, 880, eg);

			left = x1 - 30;
			right = x2 + 20;

			rebin = 1;
		}
		else if ( hist == "TGG")
		{
			// Proton Opening Angle
			q_pi = qp_thcm( eg, kMP_MEV, theta[j].lo, kMPI0_MEV);
			T_pi = Energy( q_pi, kMPI0_MEV) - kMPI0_MEV;
			x1 = Tgg_Min( T_pi, kMPI0_MEV)/kD2R - TggCutOffset;

			// 12-C Opening Angle
			q_pi = qp_thcm( eg, kM_C12_MEV, theta[j].lo, kMPI0_MEV);
			T_pi = Energy( q_pi, kMPI0_MEV) - kMPI0_MEV;
			x2 = Tgg_Min( T_pi, kMPI0_MEV)/kD2R;

			x3 = -1;

			left = 0;
			right = 180;

			rebin = 4;
		}
		else if ( hist == "KECM")
		{
			// Proton
			q_pi = qp_thcm( eg, kMP_MEV, theta[j].lo, kMPI0_MEV);
			T_pi = Energy( q_pi, kMPI0_MEV) - kMPI0_MEV;
			x1 = T_pi;

			// 12-C
			q_pi = qp_thcm( eg, kM_C12_MEV, theta[j].lo, kMPI0_MEV);
			T_pi = Energy( q_pi, kMPI0_MEV) - kMPI0_MEV;
			x2 = T_pi;

			x3 = -1;

			left = 0;
			right = x2 + 20;

			rebin = 1;
		}

		l = new TLine( left, 0, right, 0);
		l->SetLineStyle( 2);

		Pi0Hist3D( i, tbin, hist);

		c1->cd( j);
		name = Form( "full%d", i);
		TH1D *h1 = (TH1D*) fhist->Clone( name);
		h1->SetMarkerStyle( 21);
		h1->SetMarkerColor( 2);
		h1->SetLineWidth( 3);
		h1->SetLineColor( 2);
		h1->SetTitle();
		h1->GetXaxis()->SetTitleOffset( 1.1);
		h1->GetXaxis()->SetLabelSize( 0.03);
		h1->GetXaxis()->CenterTitle();
		if ( hist == "MMiss") name = "M_{miss} (MeV)";
		else if ( hist == "TGG") name = "#theta_{#gamma#gamma} (deg)";
		else if ( hist == "KECM") name = "CM T_{#pi} (MeV)";
		h1->GetXaxis()->SetTitle( name);
		h1->Rebin( rebin);
		h1->GetXaxis()->SetRangeUser( left, right);
		Double_t max = h1->GetMaximum();
		max *= 1.4;
		h1->SetMaximum( max);
		h1->Draw();

		l1 = new TLine( x1, 0, x1, max);
		l1->SetLineStyle( 2);
		l1->Draw();
		l2 = new TLine( x2, 0, x2, max);
		l2->SetLineStyle( 2);
		l2->Draw();
		l3 = new TLine( x3, 0, x3, max);
		l3->SetLineStyle( 2);
//		l3->Draw();

		l->Draw();
		name = Form( "E_{#gamma} = %5.1f #pm %3.1f MeV", eg, deg/2);
		pl = new TPaveLabel( 0.15, 0.90, 0.45, 1.00, name, "NDC");
		pl->SetFillStyle( 0);
		pl->SetBorderSize( 0);
		pl->SetTextSize( 0.5);
		pl->SetTextFont( 132);
		pl->Draw();
		if ( tbin == 0) name = "#theta_{CM} = 0 - 180 deg";
		else name = Form( "#theta_{CM} = %d #pm %d deg", th, dth/2);
		pl2 = new TPaveLabel( 0.15, 0.90, 0.45, 1.00, name, "NDC");
		pl2->SetFillStyle( 0);
		pl2->SetBorderSize( 0);
		pl2->SetTextSize( 0.5);
		pl2->SetTextFont( 132);
		if ( j == 6) pl2->Draw();

		name = Form( "empty%d", i);
		TH1D *h2 = (TH1D*) ehist->Clone( name);
		h2->SetMarkerStyle( 22);
		h2->SetMarkerColor( 4);
		h2->SetLineWidth( 3);
		h2->SetLineColor( 4);
		h2->Rebin( rebin);
		h2->Draw( "same");

		x[0] = 0.15;
		x[1] = 0.40;
		y[0] = 0.6;
		y[1] = 0.75;
		tl = new TLegend( x[0], y[0], x[1], y[1]);
		tl->SetFillStyle( 0);
		tl->SetBorderSize( 0);
		tl->SetTextSize( 0.06);
		tl->SetTextFont( 132);
		tl->AddEntry( h1, "Full");
		tl->AddEntry( h2, "Empty");
		if ( j == 1) tl->Draw();

		c1->cd( j+5);
		name = Form( "subt%d", i);
		TH1D *h3 = (TH1D*) shist->Clone( name);
		h3->SetMarkerStyle( 20);
		h3->SetLineWidth( 3);
		h3->SetTitle();
		h3->GetXaxis()->SetTitleOffset( 1.1);
		h3->GetXaxis()->SetLabelSize( 0.03);
		h3->GetXaxis()->CenterTitle();
		if ( hist == "MMiss") name = "M_{miss} (MeV)";
		else if ( hist == "TGG") name = "#theta_{#gamma#gamma} (deg)";
		else if ( hist == "KECM") name = "CM T_{#pi} (MeV)";
		h3->GetXaxis()->SetTitle( name);
		h3->Rebin( rebin);
		h3->GetXaxis()->SetRangeUser( left, right);
		Double_t max = h3->GetMaximum();
		max *= 1.4;
		h3->SetMaximum( max);
		h3->Draw();

		l1 = new TLine( x1, 0, x1, max);
		l1->SetLineStyle( 2);
		l1->Draw();
		l2 = new TLine( x2, 0, x2, max);
		l2->SetLineStyle( 2);
		l2->Draw();
		l3 = new TLine( x3, 0, x3, max);
		l3->SetLineStyle( 2);
//		l3->Draw();

		l->Draw();
		tl = new TLegend( x[0], y[0], x[1], y[1]);
		tl->SetFillStyle( 0);
		tl->SetBorderSize( 0);
		tl->SetTextSize( 0.06);
		tl->SetTextFont( 132);
		tl->AddEntry( h3, "Subtracted");
		if ( j == 1) tl->Draw();

		j++;
	}

	name = Form( "plots/Pi0_%s_chan%d-%d_t%d", (const char*) hist, lo,
			lo-4, theta[tbin].mid);
//	name.Append( ".pdf");
	name.Append( ".eps");
	if ( save == kTRUE) c1->Print( name);
}
void compareThree(TTree* t1, TTree* t2,  TTree* t3, TString var, int nBins, double xMin, double xMax, TCut cut1, TCut cut2,TCut cut3, const string cap)  {
    SetHistTitleStyle();
    SetyjPadStyle();
    gStyle->SetOptStat(0);
    TH1::SetDefaultSumw2();
    static int j = 1;
    TCanvas* c =new TCanvas(Form("c_%s_%d",var.Data(),j),"", 400,400);
    //c->Divide(1,2);
    //c->cd(1);
    gPad->SetLogy();
    double ptbin[] = {60,70,80,90,100,110,120,130,140,150,170,200,250};
    int nptbin = sizeof(ptbin)/sizeof(double) -1;
    TH1D* h[3];
    //if(var=="phoEt") h[0] = new TH1D(Form("h1_%s_%d",var.Data(),j), Form(";%s;",var.Data()),nptbin, ptbin);
    //else h[0] = new TH1D(Form("h1_%s_%d",var.Data(),j), Form(";%s;",var.Data()), nBins,xMin,xMax);
    h[0] = new TH1D(Form("h1_%s_%d",var.Data(),j), Form(";%s;",var.Data()), nBins,xMin,xMax);
    h[1] = (TH1D*)h[0]->Clone(Form("h2_%s_%d",var.Data(),j));
    h[2] = (TH1D*)h[0]->Clone(Form("h3_%s_%d",var.Data(),j));

    for(int i=0;i<3;i++){
        h[i]->Sumw2();
        h[i]->SetMarkerStyle(20);
        h[i]->SetMarkerSize(0.8);
        h[i]->SetMarkerColor(i+1);
        h[i]->SetLineColor(i+1);
    } 
    t1->Draw(Form("%s>>%s",var.Data(),h[0]->GetName()), cut1);
    t2->Draw(Form("%s>>%s",var.Data(),h[1]->GetName()), cut2);	
    t3->Draw(Form("%s>>%s",var.Data(),h[2]->GetName()), cut3);

    for(int i=0;i<3;i++){
        h[i]->Scale( 1. / h[i]->Integral());
        h[i]->SetAxisRange(1e-6,1.0,"Y");
        //h[i]->Scale( 1. / h[i]->Integral(),"width");
        if(var=="pho_ecalClusterIsoR4+pho_hcalRechitIsoR4+pho_trackIsoR4PtCut20") h[i]->SetTitle(Form(";%s;","sumIsoR4"));
        else if(var=="pfpIso4+pfnIso4+pfcIso4") h[i]->SetTitle(Form(";%s;","pfSumIsoR4"));
        else if(var=="pfpVsIso4+pfnVsIso4+pfcVsIso4") h[i]->SetTitle(Form(";%s;","pfVsSumIsoR4"));
        else if(var=="pfpVsIso4th1+pfnVsIso4th1+pfcVsIso4th1") h[i]->SetTitle(Form(";%s;","pfVsSumIsoR4th1"));
        else if(var=="pfpVsIso4th2+pfnVsIso4th2+pfcVsIso4th2") h[i]->SetTitle(Form(";%s;","pfVsSumIsoR4th2"));
    }

    h[0]->DrawCopy("hist e");
    h[1]->DrawCopy("hist e same");
    h[2]->DrawCopy("hist e same");
    TLegend* l1 = new TLegend(0.65,0.75,0.95,0.9);
    legStyle(l1);
    l1->AddEntry(h[0],"DATA","p");
    l1->AddEntry(h[1],"AllQCDPhoton","pl");
    l1->AddEntry(h[2],"EmEnrichedDijet","pl");
    l1->Draw();

    drawText(cap.data(),0.2,0.2);
    c-> SaveAs(Form("pdf/isolationComparison_%s_%s_noHotspot_addMomPID_v2.pdf",var.Data(),cap.data()));
    j++;
    /*
     *
     c->cd(2);
     h1->Divide(h2);
     h1->SetYTitle("DATA / MC");
     double ratioRange = getCleverRange(h1);
     if(ratioRange > 5) h1->SetAxisRange(0,5,"Y");
     else h1->SetAxisRange(0,2,"Y");
     h1->DrawCopy("le1");
     jumSun(xMin,1,xMax,1);
     i++;
     */
}
TreeAndHist::TreeAndHist(TTree *t, TString var, int nBins, double xMin, double xMax, TCut cut)
{
    hist = new TH1D(Form("%s_%s",t->GetName(),var.Data()),"",nBins, xMin, xMax);
    t->Draw(Form("%s>>%s",var.Data(),hist->GetName()),cut);
}
Example #10
0
void run_test
(TString dataFile = "ar46_run_0113.txt",TString parameterFile = "ATTPC.e15503b.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


  /*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("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo0_run_0113_13-09-15_20h35m58s.graw",0);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo1_run_0113_13-09-15_20h35m58s.graw",1);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo2_run_0113_13-09-15_20h35m58s.graw",2);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo2_run_0113_13-09-15_20h35m58s.1.graw",2);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo3_run_0113_13-09-15_20h35m58s.graw",3);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo4_run_0113_13-09-15_20h35m58s.graw",4);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo5_run_0113_13-09-15_20h35m58s.graw",5);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo6_run_0113_13-09-15_20h35m58s.graw",6);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo7_run_0113_13-09-15_20h35m58s.graw",7);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo7_run_0113_13-09-15_20h35m58s.1.graw",7);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo8_run_0113_13-09-15_20h35m58s.graw",8);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo9_run_0113_13-09-15_20h35m58s.graw",9);
  fDecoderTask -> AddData("/Users/Yassid/Desktop/ATTPC/Data/46Ar/run_0113/CoBo9_run_0113_13-09-15_20h35m58s.1.graw",9);

  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 ->SetEnableMap(); //Enables an instance of the ATTPC map
  HoughTask ->SetMap(scriptdir.Data());
	run -> AddTask(HoughTask);


  run -> Init();

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

  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;
  // ------------------------------------------------------------------------

}
Example #11
0
File: Draweff.C Project: XuQiao/HI
void Draweff(){
	int sth=0, Gth=0;
	TFile *f = TFile::Open(outG);
	if(sth==0){TString dirname = "std";}
        else if(sth==1){TString dirname ="Gri055";}
        else {TString dirname ="Gri101";}
	gStyle->SetErrorX(0);
	TString name;
        TObjString* dataname = (TObjString*)f->Get(Form("dataname"));
        TObjString* histoname = (TObjString*)f->Get(Form("histoname"));
        if(Gth==0)
                name = "G0";
        else if(Gth<nGlau)
                name = Form("Glau_%d",Gth);
        else
                name = Form("bin_%d",Gth-nGlau+1);
        TObjString* Glaubername = (TObjString*)f->Get(Form("%s/%s/Glaubername",dirname.Data(),name.Data()));
        TVectorD* xmin = (TVectorD*)f->Get(Form("%s/%s/xmin",dirname.Data(),name.Data()));
        TVectorD* xmax = (TVectorD*)f->Get(Form("%s/%s/xmax",dirname.Data(),name.Data()));
        TVectorD* mubest = (TVectorD*)f->Get(Form("%s/%s/mubest",dirname.Data(),name.Data()));
        TVectorD* kbest = (TVectorD*)f->Get(Form("%s/%s/kbest",dirname.Data(),name.Data()));
        TVectorD* Ndf = (TVectorD*)f->Get(Form("%s/%s/Ndf",dirname.Data(),name.Data()));
        TVectorD* chis = (TVectorD*)f->Get(Form("%s/%s/chis",dirname.Data(),name.Data()));
	TVectorD *kpoint = (TVectorD*)f->Get(Form("%s/%s/kpoint",dirname.Data(),name.Data()));
	TFile *fdata = TFile::Open(dataname->GetString());
	TH1D *histo_obs = (TH1D*)fdata->Get(histoname->GetString());
	histo_obs->Sumw2();
	TFile *fGlauber = TFile::Open(Glaubername->GetString());
        int binnum = histo_obs->GetNbinsX();
        double Minx = histo_obs->GetXaxis()->GetXmin();
        double Maxx = histo_obs->GetXaxis()->GetXmax();
	double binsize = (Double_t)(Maxx-Minx)/binnum;
        int xbinmin=(int)(((*xmin)[0]-Minx)/binsize);
        int xbinmax=(int)(((*xmax)[0]-Minx)/binsize);
	TH1D *histo_exp = new TH1D("histo_exp","Simulated distribution;Multiplicity;Event Fraction",binnum,Minx,Maxx);
	histo_exp->Sumw2();
	Int_t ibin;
		
	TH1D *histo_obs_norm = (TH1D*)histo_obs->Clone();
        histo_obs_norm->Scale(1/histo_obs->Integral(xbinmin,xbinmax));

	TF1 *NBD_fun = new 
	TF1("NBD_fun","[0]*TMath::Gamma(x+[1])/(TMath::Gamma(x+1)*TMath::Gamma([1]))*TMath::Power([2]/[1],x)/TMath::Power([2]/[1]+1,x+[1])",0,100);
	NBD_fun->SetParameter(0,1);	//[0]: Normalized constant
	NBD_fun->SetParameter(1,(*kbest)[0]);	//[1]: k value
	NBD_fun->SetParameter(2,(*mubest)[0]);	//[2]: mu value
		
	TTree *t = (TTree*) fGlauber->Get("nt_Pb_Pb");
	Long_t Nevent;

	Nevent = (Long_t) t->GetEntries();

	Long_t Ev;	Int_t Bino;	Double_t Para, Bi_Para, Mult;
	Float_t Ncoll;
	t->SetBranchAddress("Ncoll",&Ncoll);

	for(Ev=0; Ev<Nevent; Ev++){
		if(Ev%100000==0)	 cout<<"Have run "<<Ev<<" events"<<endl;
		t->GetEntry(Ev);
		Para = 0; //make sure that Para doesn't accumulate through loops
		for(Bino=0; Bino<Ncoll; Bino++){
                         Bi_Para = NBD_fun->GetRandom();
                         Para += Bi_Para;
		}	
		histo_exp->Fill(Para);
	}
	Double_t SumEvent, scale;
	SumEvent = histo_exp->Integral(xbinmin,xbinmax);
	scale = 1/SumEvent;
	TH1D *histo_exp_norm = (TH1D*) histo_exp->Clone();
	histo_exp_norm->Scale(scale);

	TCanvas *c1 = new TCanvas();
        gStyle->SetOptStat(kFALSE);

	double hfbin[]={0,1,2,3,4,6,8,10,13,16,20,25,30,40,55,70,90};
	int nhfbin = 16;
	rehisto_obs_norm = (TH1D*)histo_obs_norm->Rebin(nhfbin,"rehisto_obs_norm",hfbin);
	normalizeByBinWidth(rehisto_obs_norm);
	rehisto_exp_norm = (TH1D*)histo_exp_norm->Rebin(nhfbin,"rehisto_exp_norm",hfbin);
	normalizeByBinWidth(rehisto_exp_norm);
	TH1D* ratio = (TH1D*)rehisto_obs_norm->Clone("ratio");
	ratio->Divide(rehisto_exp_norm);
        ratio->SetMaximum(1.2);
        ratio->SetMinimum(0);
        ratio->GetXaxis()->SetTitle("HF #Sigma E_{T}");
       	ratio->GetYaxis()->SetTitle("ratio");
/*
Example #12
0
TCanvas *plot_mean_ratio(Int_t pmt=1, Int_t tdc_min=750, Int_t tdc_width=200){

        TString cut, draw, draw1, title;
        title.Form("run_%d_ADCMEANRATIO",run);
        TCanvas *cADCMEANRATIO= new TCanvas("cADCMEANRATIO",title,xcanvas,ycanvas);

        TH1D *htmpa[NUMPIXEL];//=new TH1D("htmp","htmp",nbin,min,max);
        TH1D *htmpb[NUMPIXEL];//=new TH1D("htmp1","htmp1",nbin,min,max);
        TH1D *htmpc[NUMPIXEL];//=new TH1D("htmp1","htmp1",nbin,min,max);

        TString tmpentry;
        MyStyle->SetStatX(0.9);
        MyStyle->SetStatY(0.6);
        MyStyle->SetStatW(0.4);

        Int_t nbin=25;
        Int_t min=0, max=100;
        for(Int_t icounter=1;icounter<=NUMPIXEL;icounter++){
                tmpentry.Form("htmpa%d", icounter);
                htmpa[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                tmpentry.Form("htmpb%d", icounter);
                htmpb[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                tmpentry.Form("htmpc%d", icounter);
                htmpc[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                htmpa[icounter - 1]->SetLineColor(kBlue);
                htmpb[icounter - 1]->SetLineColor(kRed);
                htmpc[icounter - 1]->SetLineColor(kRed);
                title.Form("Run %d ADC pmt %d, paddle %d: %d < tdc < %d",run,pmt,icounter,tdc_min,tdc_min+tdc_width);
                htmpa[icounter - 1]->SetTitle(title);
                htmpb[icounter - 1]->SetTitle(title);
                htmpc[icounter - 1]->SetTitle(title);
        }

        Int_t nentries=n_events_to_analyze;

        for (Int_t id=1;id<=nentries;id++){
	  T->GetEntry(id);
	 
	  for (Int_t index=1; index<=NUMPIXEL; index++){
	    Int_t ipaddle = (pmt-1)*NUMPIXEL+index-1;
	    htmpa[index-1]->Fill(adc_c[ipaddle]);
	    if(tdcl[ipaddle]>tdc_min&&tdcl[ipaddle]<tdc_min+tdc_width){
		htmpb[index-1]->Fill(adc_c[ipaddle]);
	    }
	  }
	}

	cADCMEANRATIO->Clear();

        //plot histos
        Int_t icount=0;
	cADCMEANRATIO->cd();

        Double_t mean[NUMPADDLE]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        Double_t sigma[NUMPADDLE]={1,1,1,1,1,1,1,1,1,1,1,1,1,1};
        Double_t paddle[NUMPADDLE]={1,2,3,4,5,6,7,8,9,10,11,12,13,14};
        Double_t epaddle[NUMPADDLE]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};

        TF1 *myfit = new TF1("myfit","1.0-0.5*ROOT::Math::erfc((x-[0])/[1])",0,1);
        myfit->SetParName(0,"Mean");
        myfit->SetParName(1,"Width");

        for (Int_t i=0; i<NUMPIXEL; i++){

          if(i != pixel1[pmt-1]-1 && i != pixel2[pmt-1]-1) {

            htmpb[i]->SetStats(0);

            myfit->SetParameter(0,40.0);
            myfit->SetParameter(1,10.0);
            htmpc[i] = (TH1D*)htmpb[i]->Clone();
            htmpc[i]->Divide(htmpa[i]);
            htmpc[i]->Fit("myfit");

	    Int_t numentries = htmpc[i]->GetEntries();
	    mean[icount]=myfit->GetParameter(0);
	    //sigma[icount]=myfit->GetParameter(1)/sqrt(numentries);
	    sigma[icount]=myfit->GetParameter(1);

            icount++;
          
	  }
        }

        gr = new TGraphErrors(NUMPADDLE,paddle,mean,epaddle,sigma);
        gr->SetMarkerStyle(21);
        gr->GetXaxis()->SetTitle("Paddle Number");
        gr->GetYaxis()->SetTitle("50% Threshold (Good TDC)");
	gr->GetHistogram()->SetMaximum(100);
	gr->GetHistogram()->SetMinimum(0);

        gr->Draw("AP");

        cADCMEANRATIO->Update();

        title.Form("run_%d_ADCMEANRATIO_pmt_%d_tdc_min_%d_max_%d.png",
                   run,pmt,tdc_min,tdc_min+tdc_width);
        cADCMEANRATIO->Print(title);
        cADCMEANRATIO->cd();
        return cADCMEANRATIO;

}
Example #13
0
TCanvas *plot_ratio(Int_t pmt=1, Int_t tdc_min=750, Int_t tdc_width=300){

        TString cut, draw, draw1, title;
        title.Form("run_%d_ADCRATIO",run);
        TCanvas *cADCRATIO= new TCanvas("cADCRATIO",title,xcanvas,ycanvas);

        TH1D *htmpa[NUMPIXEL];//=new TH1D("htmp","htmp",nbin,min,max);
        TH1D *htmpb[NUMPIXEL];//=new TH1D("htmp1","htmp1",nbin,min,max);
        TH1D *htmpc[NUMPIXEL];//=new TH1D("htmp1","htmp1",nbin,min,max);

        TString tmpentry;
        MyStyle->SetStatX(0.9);
        MyStyle->SetStatY(0.6);
        MyStyle->SetStatW(0.4);

        Int_t nbin=100;
        Int_t min=0, max=200;
        for(Int_t icounter=1;icounter<=NUMPIXEL;icounter++){
                tmpentry.Form("htmpa%d", icounter);
                htmpa[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                tmpentry.Form("htmpb%d", icounter);
                htmpb[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                tmpentry.Form("htmpc%d", icounter);
                htmpc[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                htmpa[icounter - 1]->SetLineColor(kBlue);
                htmpb[icounter - 1]->SetLineColor(kRed);
                htmpc[icounter - 1]->SetLineColor(kRed);
                title.Form("Run %d ADC pmt %d, paddle %d: %d < tdc < %d",run,pmt,icounter,tdc_min,tdc_min+tdc_width);
                htmpa[icounter - 1]->SetTitle(title);
                htmpb[icounter - 1]->SetTitle(title);
                htmpc[icounter - 1]->SetTitle(title);
        }

        Int_t nentries=n_events_to_analyze;

        for (Int_t id=1;id<=nentries;id++){
          T->GetEntry(id);
	  for (Int_t index=1; index<=NUMPIXEL; index++){
	    Int_t ipaddle = (pmt-1)*NUMPIXEL+index-1;
	    htmpa[index-1]->Fill(adc_c[ipaddle]);
	    if(tdcl[ipaddle]>tdc_min&&tdcl[ipaddle]<tdc_min+tdc_width){
		htmpb[index-1]->Fill(adc_c[ipaddle]);
	    }
	  }
	}

	cADCRATIO->Clear();
        cADCRATIO->Divide(4,4);

        //plot histos
        Int_t icount=0;
        TF1 *myfit = new TF1("myfit","1.0-0.5*ROOT::Math::erfc((x-[0])/[1])",0,1);
        myfit->SetParName(0,"Mean");
        myfit->SetParName(1,"Width");

        for (Int_t i=0; i<NUMPIXEL; i++){

          if(i != pixel1[pmt-1]-1 && i != pixel2[pmt-1]-1) {

            //cout<<"into loop 2, i = " << i << endl;

            cADCRATIO->cd( icount + 1 );
            //gPad->SetLogy();

            //cADC->Update();
                
            Int_t entries = htmpa[i]->GetEntries();
            float mean = htmpa[i]->GetMean(1);
            float RMS = htmpa[i]->GetRMS(1);
            //cout << entries <<" "<< mean <<" "<< RMS <<endl;
                
            htmpb[i]->SetStats(0);
            //current->Modified();

            myfit->SetParameter(0,40.0);
            myfit->SetParameter(1,10.0);
            htmpc[i] = (TH1D*)htmpb[i]->Clone();
            htmpc[i]->Divide(htmpa[i]);
            htmpc[i]->Fit("myfit");

	    // write the mean and sigma of the fit 
	    // on the canvas itself

	    float fitmean = myfit->GetParameter(0);
	    float fitsig = myfit->GetParameter(1);

	    // create strings to write on plot
	    TString lmean = Form("mean = %1.1f",fitmean);
	    TString lsig = Form("sigma = %1.1f",fitsig);
	    
	    // create the latex object to write
	    TLatex tl;
	    tl->SetTextSize(0.07);
	    tl->SetTextAngle(0);
	    tl->SetTextColor(1);

	    // NOTE: first two numbers are the x and y VALUES
	    // on the individual graph/histogram
	    tl->DrawLatex(30,0.85,lmean);
	    tl->DrawLatex(30,0.75,lsig);
	    
            icount++;
          
	  }
        }

        title.Form("run_%d_ADCRATIO_pmt_%d_tdc_min_%d_max_%d.png",
                   run,pmt,tdc_min,tdc_min+tdc_width);
        cADCRATIO->Print(title);
        cADCRATIO->cd(0);
        return cADCRATIO;
}
Example #14
0
TCanvas *plot_tdc_diff(Int_t pmt=1, Int_t adc_cut=30, Int_t tdc_min=1, Int_t tdc_width=100){

        TString cut, draw, draw1, title;
        title.Form("run_%d_TDC",run);
        TCanvas *cTDCT= new TCanvas("cTDCT",title,xcanvas,ycanvas);

        TH1D *htmpa[NUMPIXEL];//=new TH1D("htmp","htmp",nbin,min,max);
        TH1D *htmpb[NUMPIXEL];//=new TH1D("htmp1","htmp1",nbin,min,max);

        TString tmpentry;
        MyStyle->SetStatX(0.9);
        MyStyle->SetStatY(0.6);
        MyStyle->SetStatW(0.4);

        Int_t nbin=tdc_width;
        Int_t min=tdc_min, max=tdc_min+tdc_width;
        for(Int_t icounter=1;icounter<=NUMPIXEL;icounter++){
                tmpentry.Form("htmpa%d", icounter);
                htmpa[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                tmpentry.Form("htmpb%d", icounter);
                htmpb[icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                htmpa[icounter - 1]->SetLineColor(kBlue);
                htmpb[icounter - 1]->SetLineColor(kRed);
                title.Form("Run %d ADC pmt %d, paddle %d: %d < tdc < %d",run,pmt,icounter,tdc_min,tdc_min+tdc_width);
                htmpa[icounter - 1]->SetTitle(title);
                htmpb[icounter - 1]->SetTitle(title);
        }

        Int_t nentries = n_events_to_analyze;

        for (Int_t id=1;id<=nentries;id++){
          T->GetEntry(id);
	  for (Int_t index=1; index<=NUMPIXEL; index++){
	    Int_t ipaddle = (pmt-1)*NUMPIXEL+index-1;
	    htmpa[index-1]->Fill(tdcl[ipaddle]-tdct[ipaddle]);
	    if(adc_c[ipaddle]>adc_cut){
		htmpb[index-1]->Fill(tdcl[ipaddle]-tdct[ipaddle]);
	    }
	  }
	}

	cTDCT->Clear();
        cTDCT->Divide(4,4);

        //plot histos
        Int_t icount=0;
        for (Int_t i=0; i<NUMPIXEL; i++){

          if(i != pixel1[pmt-1]-1 && i != pixel2[pmt-1]-1) {

            //cout<<"into loop 2, i = " << i << endl;

            cTDCT->cd( icount + 1 );
            //gPad->SetLogy();

            cTDCT->Update();
                
            Int_t entries = htmpa[i]->GetEntries();
            float mean = htmpa[i]->GetMean(1);
            float RMS = htmpa[i]->GetRMS(1);
            //cout << entries <<" "<< mean <<" "<< RMS <<endl;
                
            htmpa[i]->SetStats(0);
            //current->Modified();
            htmpa[i]->Draw();
            htmpb[i]->Draw("same");

            icount++;
          
	  }
        }

        title.Form("run_%d_TDC_pmt_%d_adc_cut_%d.png",
                   run,pmt,adc_cut);
        cTDCT->Print(title);
        cTDCT->cd(0);
        return cTDCT;
}
Example #15
0
plotLimits(string filename, TString name, TString channel, TString lepton){



TGraph * limit_obs = new TGraph();
  TGraph * limit_exp = new TGraph();
  TGraphAsymmErrors * band_exp1 = new TGraphAsymmErrors();
  TGraphAsymmErrors * band_exp2 = new TGraphAsymmErrors();

TGraph *theory = new TGraph();
theory->SetPoint(0, 1000, 1.3*3.02095);
theory->SetPoint(1, 1500, 1.3*0.58069);
theory->SetPoint(2, 2000, 1.3*0.14501);
theory->SetPoint(3, 2500, 1.3*0.04234);
theory->SetPoint(4, 3000, 1.3*0.01384);
theory->SetPoint(5, 4000, 1.3*0.00184);

ifstream infile(filename.c_str());

gROOT->LoadMacro("CMS_lumi.C");

double mass, exp, obs, up1, up2, dn1, dn2;
int point = 0;

while (!infile.eof()){

	infile >> mass >> obs >> exp >>  dn2 >> up2 >> dn1 >> up1;


        cout << mass << " & " << obs << " & " << exp << " & " << "["<<dn1<<", "<<up1<<"] & ["<<dn2<<", "<<up2<<"] \\" << endl;


	limit_obs->SetPoint(point, mass, obs);
    limit_exp->SetPoint(point, mass, exp);
    band_exp1->SetPoint(point, mass, exp);
    band_exp2->SetPoint(point, mass, exp);

    band_exp1->SetPointEYhigh(point, up1 - exp);
    band_exp1->SetPointEYlow(point, exp - dn1);
    band_exp2->SetPointEYhigh(point, up2 - exp);
    band_exp2->SetPointEYlow(point, exp - dn2);
    point++;

}

double max = 200000.0; //band_exp2->GetHistogram()->GetMaximum()*50;

  TCanvas *canvas = new TCanvas(Form("limit set %s",name.Data()),Form("limit set %s",name.Data()), 500,500);

  limit_exp->SetMinimum(0.01);
  limit_exp->Draw("AL");
  limit_exp->GetXaxis()->SetTitle("M_{Z'} [GeV]");
  limit_exp->GetYaxis()->SetTitle("95 % CL limit on #sigma(Z') [pb]");
  limit_exp->GetYaxis()->SetRangeUser(0.01,2000);

  band_exp2->SetFillColor(5);
  band_exp2->SetLineColor(0);
  //band_exp2->SetFillStyle(4000);
  band_exp2->Draw("3same");

  band_exp1->SetFillColor(3);
  band_exp1->SetLineColor(0);
  //band_exp1->SetFillStyle(4000);
  band_exp1->Draw("3same");

  limit_obs->Draw("Lsame");
  limit_obs->SetLineWidth(2);
  limit_obs->SetMarkerSize(1.0);
  limit_obs->SetMarkerStyle(20);
   
  limit_exp->Draw("Lsame");
  limit_exp->SetLineStyle(2);
  limit_exp->SetLineWidth(2);
  limit_exp->SetMarkerSize(1.0);
  limit_exp->SetMaximum(max);
  limit_exp->SetMinimum(0.001);
  limit_exp->SetMarkerStyle(20);

  double x1 = 595; 
  double y1 = 1.0;
  double x2 = 905;
  double y2 = 1.0;
  TLine * line = new TLine(x1, y1, x2, y2);
  theory->SetLineColor(2);
  theory->SetLineWidth(2);
  theory->Draw("same");

  



  //Legend
  TLegend *l = new TLegend(0.57,0.62,0.88,0.88);
  l->AddEntry(limit_obs,"Observed", "L");
  l->AddEntry(limit_exp,"Expected", "L");
  l->AddEntry(band_exp1,"#pm1 #sigma Exp.", "F");
  l->AddEntry(band_exp2,"#pm2 #sigma Exp.", "F");
  l->AddEntry(theory, " Z', 1% Width", "L");
  l->SetFillColor(0);
  l->SetLineColor(0);
  l->Draw();

  TLatex * label = new TLatex();
  label->SetNDC();
  //label->DrawLatex(0.2,0.86,"CMS Preliminary, 19.7 fb^{-1}");
  //label->DrawLatex(0.2,0.80,"#sqrt{s} = 8 TeV");
  //label->DrawLatex(0.6,0.80, Form("BR(b'#rightarrow %s) = 1", channel.Data()));
  //label->DrawLatex(0.55,0.80, "BR(b'#rightarrow tW) = 0.5");
  //label->DrawLatex(0.55,0.74, "BR(b'#rightarrow bH) = 0.25");
  //label->DrawLatex(0.55,0.68, "BR(b'#rightarrow bZ) = 0.25");
  //label->DrawLatex(0.2,0.74, lepton.Data());

  canvas->SetLogy(1);
  CMS_lumi(canvas, 4, 10);

  canvas->Print(Form("%s_limit.pdf",name.Data()));
  //canvas->Print(Form("%s_limit.png",name.Data()));

}
void temp_noHotspot_isolationComparison(TString coll="pbpb"){

    const int nFile =3;
    const char* fname[nFile];
    if(coll=="pp"){ 
        fname[0]="/home/goyeonju/CMS/Files/photon2016/2015-Data-promptRECO-photonSkims_pp-photonHLTFilter-v0-HiForest.root";
        fname[1]="/home/goyeonju/CMS/Files/photon2016/gsfs-Pythia8_Photon_pp_RECO_forest_v28/gsfs-Pythia8_Photon15_30_50_80_120_pp_RECO_forest_v28_with_pthatWeight.root";
        fname[2]="/home/goyeonju/CMS/Files/photon2016/2015-PP-MC_Pythia8_EmEnrDijet30_pp502_TuneCUETP8M1.root";
    } else if(coll=="pbpb"){
        fname[0]="/home/goyeonju/CMS/Files/photon2016/forestSkimed_photonSkim_pbpb_2015data.root";
        fname[1]="/home/goyeonju/CMS/Files/photon2016/Pythia8_Photon_Hydjet_RECO_20160306_forest_v28_2/Pythia8_Photon15_30_50_80_120_Hydjet_RECO_20160306_forest_v28_2_with_pthatWeight.root";
        fname[2]="/home/goyeonju/CMS/Files/photon2016/2015-PbPb-MC_Pythia8_EmEnrichedDijet/2015-PbPb-MC_Pythia8_EmEnrichedDijet30_50_80_120_170_with_pthatWeight.root";
    }
    TFile* f[nFile];
    TTree* t[nFile];
    TTree* t_hi[nFile];
    TTree* t_skim[nFile];
    for(int i=0;i<nFile;i++){
        f[i] = new TFile(fname[i]);
        if(coll=="pp" && (i==0 || i==2)) {
            t[i] = (TTree*) f[i] -> Get("ggHiNtuplizerGED/EventTree");
            if(i==1) t_skim[i] = (TTree*) f[i] -> Get("HltTree");
            else t_skim[i] = (TTree*) f[i] -> Get("skimanalysis/HltTree");
            t_hi[i] = (TTree*) f[i] -> Get("hiEvtAnalyzer/HiTree");
        } else{ 
            t[i] = (TTree*) f[i] -> Get("EventTree");
            t_skim[i] = (TTree*) f[i] -> Get("HltTree");
            t_hi[i] = (TTree*) f[i] -> Get("HiTree");
        }
        t[i]->AddFriend(t_hi[i]);
        t[i]->AddFriend(t_skim[i]);
    }

    for(Int_t i = 0; i < 1; ++i) {
        //for(Int_t i = 0; i < nPtBin; ++i) {}
        //TCut ptCut = Form("(phoEt >= %f) && (phoEt < %f)", ptBins[i], ptBins[i+1]);
        TCut ptCut = Form("(phoEt >= %f) && (phoEt < %f)",50.0,9999.0);
        TCut etaCut = Form("(abs(phoEta) >= %f) && (abs(phoEta) < %f)", etaBins[0], etaBins[1]);
        TCut filterCut = evtSelFilterCut;
        if(coll=="pp") filterCut = evtSelFilterCut_pp;
        TCut dataTotCut = filterCut && spikeRejection && hotspotCut && ptCut && etaCut;
        TCut mcTotCut_bkg = mcBkgIsolation && ptCut && etaCut;
        TCut mcTotCut_sig = mcIsolation && ptCut && etaCut;

        cout << dataTotCut.GetTitle() << endl;
        cout << mcTotCut_bkg.GetTitle() << endl;
        cout << mcTotCut_sig.GetTitle() << endl;

        const int nBins = 50;
        const string cap_ = Form("%s_pt%dto%d_barrel",coll.Data(),50,9999);
        //const char* cap_ = Form("%s_pt%dto%d",coll.Data(),(int)ptBins[i],(int)ptBins[i+1]);
        if(coll=="pp") {
            compareThree(t[0], t[1], t[2], "phoSigmaIEtaIEta_2012",nBins, 0, 0.025, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_ecalClusterIsoR4",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_hcalRechitIsoR4",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_trackIsoR4PtCut20",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_ecalClusterIsoR4+pho_hcalRechitIsoR4+pho_trackIsoR4PtCut20",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(%s)",mcTotCut_bkg.GetTitle()), cap_);

        } else if(coll=="pbpb") {
            compareThree(t[0], t[1], t[2], "phoEt",nBins, 0, 300, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoEta",nBins, -3, 3, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoPhi",nBins, -3.14, 3.14, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
           
            compareThree(t[0], t[1], t[2], "phoSCE",nBins, 0, 1500, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoSCEtaWidth",nBins, 0, 0.1, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoSCPhiWidth",nBins, 0, 0.3, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoSCBrem",nBins, 0, 50, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoR9",nBins, 0, 1, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoHoverE",nBins, 0, 3., dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoHadTowerOverEm",nBins, 0, 3., dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoMaxEnergyXtal",nBins, 0, 1400, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoSigmaIEtaIEta",nBins, 0, 0.03, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoSigmaIEtaIEta_2012",nBins, 0, 0.03, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            
            compareThree(t[0], t[1], t[2], "pho_ecalClusterIsoR4",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_hcalRechitIsoR4",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_trackIsoR4PtCut20",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_ecalClusterIsoR4+pho_hcalRechitIsoR4+pho_trackIsoR4PtCut20",nBins, -10, 120, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);

            compareThree(t[0], t[1], t[2], "phoE1x5",nBins, 0, 1200, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoE2x5",nBins, 0, 1200, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoE5x5",nBins, 0, 1200, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoE3x3",nBins, 0, 1200, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoE3x3_2012",nBins, 0, 1200, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);

            compareThree(t[0], t[1], t[2], "phoSigmaEtaEta",nBins, 0, 0.12, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoR1x5",nBins, 0, 1, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "phoR2x5",nBins, 0, 1, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_swissCrx",nBins, -3, 1, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pho_seedTime",nBins, -4, 4, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);

            compareThree(t[0], t[1], t[2], "pfcIso4",nBins, 0, 400, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfcVsIso4",nBins, -200, 600, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfcVsIso4th1",nBins, -100, 600, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfcVsIso4th2",nBins, -100, 600, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            
            compareThree(t[0], t[1], t[2], "pfnIso4",nBins, 0, 400, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfnVsIso4",nBins, -100, 300, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfnVsIso4th1",nBins, -100, 300, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfnVsIso4th2",nBins, -100, 300, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
           
            compareThree(t[0], t[1], t[2], "pfpIso4",nBins, 0, 400, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfpVsIso4",nBins, -100, 500, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfpVsIso4th1",nBins, -100, 500, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfpVsIso4th2",nBins, -100, 500, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);

            compareThree(t[0], t[1], t[2], "pfpIso4+pfnIso4+pfcIso4",nBins, 0, 400, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfpVsIso4+pfnVsIso4+pfcVsIso4",nBins, -100, 500, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfpVsIso4th1+pfnVsIso4th1+pfcVsIso4th1",nBins, -100, 500, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            compareThree(t[0], t[1], t[2], "pfpVsIso4th2+pfnVsIso4th2+pfcVsIso4th2",nBins, -100, 500, dataTotCut, Form("(pthatWeight)*(%s)",mcTotCut_sig.GetTitle()), Form("(pthatWeight)*(%s)",mcTotCut_bkg.GetTitle()), cap_);
            }
    }  
} // main function
Example #17
0
void CTable::setCell(const TString& entryTS, size_t r, size_t c){
  setCell(std::string(entryTS.Data()),r,c);
}
Example #18
0
Bool_t RunALICE(TString anSrc = "grid",
                TString anMode = "terminate",
                TString input="aod" /*or "esd"*/,
                TString inputMC="" /*or "mc"*/,
                Long64_t nEvents = 1e10,
                Long64_t nSkip = 0,
                TString dsName="",
                TString alirsnliteManagers ="AddAMRsn",
                Bool_t useMultiHandler=kFALSE,
                TString alirsnlitesrc ="$ALICE_PHYSICS",
                TString alirsnlitetasks =""
               ) {

   // some init work
   anSrc.ToLower(); anMode.ToLower(); input.ToLower(); inputMC.ToLower();

//   TGrid::Connect("alien://");
   // loads libs and setup include paths
   if (LoadLibsBase(alirsnlitesrc)) return kFALSE;

   // reset manager if already exists
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (mgr) delete mgr;
   mgr = new AliAnalysisManager("AliRsnLiteAM","AliRsnLite Analysis Manager");

   Bool_t useAODOut = kFALSE;
   CreateInputHandlers(input,inputMC,useAODOut,useMultiHandler);

   // add default grid handler
   gROOT->LoadMacro("SetupAnalysisPlugin.C");
   AliAnalysisGrid *analysisPlugin = SetupAnalysisPlugin(anMode.Data());
   if (!analysisPlugin) { Printf("Error : analysisPlugin is null !!!"); return kFALSE; }
   mgr->SetGridHandler(analysisPlugin);
   if (!dsName.IsNull()) {
      if (!anSrc.CompareTo("proof") && !anMode.CompareTo("full")) {
         analysisPlugin->SetProofDataSet(dsName.Data());
         Printf(Form("Using DataSet %s ...",dsName.Data()));
      } else {
         analysisPlugin->SetFileForTestMode(dsName.Data());
         Printf(Form("Using Test file %s ...",dsName.Data()));
      }
   }

   TList *listManagers = CreateListOfManagersFromDir(alirsnliteManagers,alirsnlitetasks);
   if (!listManagers) { Printf("Error : CreateListOfManagersFromDir failed !!!"); return kFALSE;}

   // adds all tasks
   if (!AddAllManagers(listManagers, anSrc, anMode,input,inputMC)) { Printf("Error : AddAllManagers failed !!!"); return kFALSE;}

   TStopwatch timer;
   timer.Start();
   // runs analysis
   if (!RunAnalysisManager(anSrc, anMode.Data(), nEvents, nSkip)) { Printf("Error : RunAnalysisManager failed !!!"); return kFALSE;}

   timer.Stop();
   timer.Print();
   Printf("Working directory is %s ...", gSystem->WorkingDirectory());
   TString outputDir =  gSystem->WorkingDirectory();
   outputDir.ReplaceAll("alirsnlite","alirsnlite-out");
   gSystem->Exec(TString::Format("mkdir -p %s",outputDir.Data()).Data());
   gSystem->Exec(TString::Format("mv *.root %s/ > /dev/null 2>&1",outputDir.Data()).Data());
//   gSystem->cd(outputDir.Data());
   Printf("Done OK");
   return kTRUE;

}
Example #19
0
bool wxPtrButtonEditor::OnEvent( wxPropertyGrid* propGrid,
                                wxPGProperty* property,
                                wxWindow* ctrl,
                                wxEvent& event ) const
{
    if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED )
    {
        wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary();
        CWxwidgetsPropertyBase* pPropertyDescription = static_cast<CWxwidgetsPropertyBase*>(property->GetClientData());
        CEnginePropertyGirdManager* pManager = static_cast<CEnginePropertyGirdManager*>(static_cast<CEnginePropertyGrid*>(propGrid)->GetManager());
        const wxWindow* pButton = NULL;
        for (size_t i = 0; i < buttons->GetCount(); ++i)
        {
            if (event.GetId() == buttons->GetButtonId(i))
            {
                pButton = buttons->GetButton(i);
                break;
            }
        }
        if (pButton != NULL)
        {
            if (pPropertyDescription->GetType() == eRPT_Ptr)
            {
                CPtrPropertyDescription* pPtrPropertyDescription = static_cast<CPtrPropertyDescription*>(pPropertyDescription);
                wxString valueStr = property->GetValueAsString();
                bool bValueChanged = false;
                if (pButton->GetLabel().CmpNoCase(_T("+")) == 0)
                {
                    size_t ptrGuid = pPtrPropertyDescription->GetPtrGuid();
                    std::vector<size_t> derivedClassGuid;
                    CComponentProxyManager::GetInstance()->QueryDerivedClass(ptrGuid, derivedClassGuid, true);
                    CComponentBase* pBase = CComponentProxyManager::GetInstance()->GetComponentTemplate(ptrGuid);
                    bValueChanged = derivedClassGuid.size() == 0;
                    if (!bValueChanged)
                    {
                        wxPGChoices choice;
                        if (pBase != NULL)
                        {
                            choice.Add(pBase->GetClassStr(), pBase->GetGuid());
                        }
                        for (auto i : derivedClassGuid)
                        {
                            pBase = CComponentManager::GetInstance()->GetComponentTemplate(i);
                            choice.Add(pBase->GetClassStr(), pBase->GetGuid());
                        }
                        wxString strSelectItem = ::wxGetSingleChoice(wxT("TypeChoice"), wxT("Caption"), choice.GetLabels(),
                            NULL, wxDefaultCoord, wxDefaultCoord, false, wxCHOICE_WIDTH, wxCHOICE_HEIGHT);
                        if ( !strSelectItem.empty() )
                        {
                            int nSelectIndex = choice.Index(strSelectItem);
                            size_t uDerivedGuid = choice.GetValue(nSelectIndex);
                            pPtrPropertyDescription->SetDerivedGuid(uDerivedGuid);
                            bValueChanged = true;
                        }
                    }
                    if (bValueChanged)
                    {
                        bool bCreateInstance = pPtrPropertyDescription->CreateInstance();
                        bCreateInstance;
                        BEATS_ASSERT(bCreateInstance);
                        CComponentEditorProxy* pCompBase = static_cast<CComponentEditorProxy*>(pPtrPropertyDescription->GetInstanceComponent());
                        BEATS_ASSERT(pCompBase != NULL);
                        BEATS_ASSERT(pManager != NULL);
                        TString* pStrValue = (TString*)pPtrPropertyDescription->GetValue(eVT_CurrentValue);
                        property->SetValueFromString(pStrValue->c_str());
                        pManager->RefreshProperty(property);
                        pManager->InsertComponentsInPropertyGrid(pCompBase, property);
                        buttons->GetButton(0)->SetLabel(_T("-"));
                        valueStr.insert(0, _T("+"));
                    }
                }
                else if (pButton->GetLabel().CmpNoCase(_T("-")) == 0)
                {
                    property->DeleteChildren();
                    bool bDeleteInstance = pPtrPropertyDescription->DestroyInstance();
                    bDeleteInstance;
                    BEATS_ASSERT(bDeleteInstance);
                    // Destroy instance may cause the value changed, so we fetch it again.
                    char szTmp[MAX_PATH];
                    pPtrPropertyDescription->GetValueAsChar(eVT_CurrentValue, szTmp);
                    valueStr = szTmp;
                    pPtrPropertyDescription->GetChildren().clear();
                    buttons->GetButton(0)->SetLabel(_T("+"));
                    valueStr.Remove(0, 1); // Remove the "+" prefix
                    bValueChanged = true;
                }
                if (bValueChanged)
                {
                    wxVariant newValue(valueStr);
                    pPtrPropertyDescription->SetValue(newValue, false);
                    property->SetValue(newValue);
                    propGrid->Refresh();
                }
            }
            if (pPropertyDescription->IsContainerProperty())
            {
                if (pButton->GetLabel().CmpNoCase(_T("+")) == 0)
                {
                    CPropertyDescriptionBase* pNewChild = pPropertyDescription->AddChild(NULL);
                    if (pNewChild != NULL)
                    {
                        std::vector<CPropertyDescriptionBase*> value;
                        value.push_back(pNewChild);
                        pManager->InsertInPropertyGrid(value, property);
                    }
                }
                else if (pButton->GetLabel().CmpNoCase(_T("-")) == 0)
                {
                    pPropertyDescription->DeleteAllChild();
                    property->DeleteChildren();
                }
                char valueStr[256];
                pPropertyDescription->GetValueAsChar(eVT_CurrentValue, valueStr);
                property->SetValue(valueStr);
                property->SetModifiedStatus(pPropertyDescription->GetChildrenCount() > 0);
                property->RecreateEditor();
            }

            if (pButton->GetLabel().CmpNoCase(_T("x")) == 0)
            {
                BEATS_ASSERT(pPropertyDescription->GetParent() != NULL);
                CPropertyDescriptionBase* pParent = pPropertyDescription->GetParent();
                pParent->DeleteChild(pPropertyDescription);
                // NOTICE: We have deleted this already!
                pPropertyDescription = NULL;

                property->SetClientData(NULL);
                char valueStr[256];
                pParent->GetValueAsChar(eVT_CurrentValue, valueStr);
                property->GetParent()->SetValue(valueStr);
                //TODO: I can't refresh property here, because we are trying to delete property of which callback we are in.
                pManager->SetUpdateFlag(true);
            }
            return true;
        }
    }
    return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
}
Example #20
0
Bool_t AddAnalysisManager(TString managerMacro, TString anSrc, TString anMode,TString input,TString inputMC, TString postfix,TString idStr) {
   gROOT->LoadMacro(Form("%s.C", managerMacro.Data()));
   return gROOT->ProcessLine(Form("%s\(\"%s\",\"%s\",\"%s\"\,\"%s\",\"%s\",\"%s\"\);", managerMacro.Data(), anSrc.Data(), anMode.Data(),input.Data(),inputMC.Data(), postfix.Data(),idStr.Data()));
}
Example #21
0
void Pi0HistSimComp( TString tgt = "subt", TString hist = "MMiss",
		UInt_t i = 308, UInt_t j = 0, Bool_t save = kFALSE)
{
	UInt_t tbin_lo, tbin_hi, rebin;
	Int_t th, dth;
	Double_t eg, deg;
	Double_t x1, x2, x3, left, right;
	Double_t x[2], y[2];
	Double_t q_pi, T_pi;
	Double_t TggCutOffset;
	Char_t tchar;
	TString name;

	TggCutOffset = 3;

	gStyle->SetOptStat( 0);

	if ( !gROOT->GetListOfCanvases()->IsEmpty()) {
		delete c1;
	}
	TCanvas *c1 = new TCanvas ( "c1", "Subtraction", 300, 20, 700, 500);
   c1->GetFrame()->SetFillColor( 21);
   c1->GetFrame()->SetBorderSize( 12);

	eg = tcd[i].energy;
	deg = tcd[i].denergy;

	th = theta[j].mid;
	dth = 20;

	if ( hist == "MMiss")
	{
		x1 = Linear( 145, 933, 400, 880, eg);
		x2 = Linear( 145, 945, 400, 1000, eg);
		x3 = Linear( 145, 918, 400, 880, eg);

		left = x1 - 30;
		right = x2 + 20;

		rebin = 1;
	}
	else if ( hist == "TGG")
	{
		// Proton Opening Angle
		q_pi = qp_thcm( eg, kMP_MEV, theta[j].lo, kMPI0_MEV);
		T_pi = Energy( q_pi, kMPI0_MEV) - kMPI0_MEV;
		x1 = Tgg_Min( T_pi, kMPI0_MEV)/kD2R;
		cout << "tgg_min = " << x1;
		x1 += TggCutOffset;
		cout << " tgg_cut = " << x1;
		cout << endl;

		// 12-C Opening Angle
		q_pi = qp_thcm( eg, kM_C12_MEV, theta[j].lo, kMPI0_MEV);
		T_pi = Energy( q_pi, kMPI0_MEV) - kMPI0_MEV;
		x3 = Tgg_Min( T_pi, kMPI0_MEV)/kD2R;

		x2 = 180;

		left = 0;
		right = 180;

		rebin = 4;
	}
	else if ( hist == "KECM")
	{
		if ( tgt == "subt")
			q_pi = qp_thcm( eg, kMP_MEV, theta[j].lo, kMPI0_MEV);
		else if ( tgt == "empty")
			q_pi = qp_thcm( eg, kM_C12_MEV, theta[j].lo, kMPI0_MEV);

		T_pi = Energy( q_pi, kMPI0_MEV) - kMPI0_MEV;

		x1 = 0;
		x2 = T_pi + 20;
		x3 = T_pi;

		left = 0;
		right = x2;

		rebin = 1;
	}

	l = new TLine( left, 0, right, 0);
	l->SetLineStyle( 2);

	Pi0Hist3D( i, j, hist);

	l->Draw();

	name = Form( "%s%d", (const char*) tgt, i);
	if ( tgt == "subt") TH1D *h3 = (TH1D*) shist->Clone( name);
	else if ( tgt == "empty") TH1D *h3 = (TH1D*) ehist->Clone( name);
	h3->SetMarkerStyle( 20);
	h3->SetMarkerSize( 1.5);
	h3->SetLineWidth( 4);
	h3->SetTitle();
	h3->GetXaxis()->SetTitleOffset( 1.2);
	h3->GetXaxis()->SetLabelSize( 0.03);
	h3->GetXaxis()->CenterTitle();
	if ( hist == "MMiss") name = "M_{miss} (MeV)";
	else if ( hist == "TGG") name = "#theta_{#gamma#gamma} (deg)";
	else if ( hist == "KECM") name = "CM T_{#pi} (MeV)";
	h3->GetXaxis()->SetTitle( name);
	h3->Rebin( rebin);
	h3->GetXaxis()->SetRangeUser( left, right);
	Double_t max = h3->GetMaximum();
	max *= 1.4;
	h3->SetMaximum( max);
	if ( ( hist == "TGG") && ( i > 306)) h3->SetMinimum( -50);
	h3->Draw();

	l1 = new TLine( x1, 0, x1, max);
	l1->SetLineStyle( 2);
	l1->Draw();
	l2 = new TLine( x2, 0, x2, max);
	l2->SetLineStyle( 2);
	if ( hist == "MMiss") l2->Draw();
	l3 = new TLine( x3, 0, x3, max);
	l3->SetLineStyle( 2);
//	if ( hist == "MMiss") l3->Draw();

	l->Draw();

	if ( hist == "KECM")
	{
		x[0] = 0.50;
		x[1] = 0.75;
	}
	else
	{
		x[0] = 0.15;
		x[1] = 0.40;
	}
	y[0] = 0.7;
	y[1] = 0.85;
	tl = new TLegend( x[0], y[0], x[1], y[1]);
	tl->SetFillStyle( 0);
	tl->SetBorderSize( 0);
	tl->SetTextSize( 0.06);
	tl->SetTextFont( 132);
	tl->AddEntry( h3, "Data");

	name = Form( "E_{#gamma} = %5.1f #pm %3.1f MeV", eg, deg/2);
	pl = new TPaveLabel( 0.15, 0.90, 0.45, 1.00, name, "NDC");
	pl->SetFillStyle( 0);
	pl->SetBorderSize( 0);
	pl->SetTextSize( 0.5);
	pl->SetTextFont( 132);
	pl->Draw();

	if ( j == 0) name = "#theta_{CM} = 0 - 180 deg";
	else name = Form( "#theta_{CM} = %d #pm %d deg", th, dth/2);
	pl2 = new TPaveLabel( 0.55, 0.90, 0.85, 1.00, name, "NDC");
	pl2->SetFillStyle( 0);
	pl2->SetBorderSize( 0);
	pl2->SetTextSize( 0.5);
	pl2->SetTextFont( 132);
	pl2->Draw();

	UInt_t bin_lo;
	UInt_t bin_hi;

	if ( ( hist == "MMiss") && ( tgt == "empty")) {
		bin_lo = h3->GetXaxis()->FindBin( left);
		bin_hi = h3->GetXaxis()->FindBin( right);
	}
	else {
		bin_lo = h3->GetXaxis()->FindBin( x1);
		bin_hi = h3->GetXaxis()->FindBin( x2);
	}
	Double_t cts1 = h3->Integral( bin_lo, bin_hi);

	if ( tgt == "subt") tchar = 'p';
	else if ( tgt == "empty") tchar = 'w';
	name = Form( "histograms/MonteCarlo/pi0/LH2_10cm/pi0_%c_chan%d.root", tchar,
			i);
	sim = new TFile( name);
	name = "THR_" + hist + "P_v_ThetaCMP";
	TH2D *h2sim = (TH2D*)sim->Get( name);
	tbin_lo = h2sim->GetXaxis()->FindBin( theta[j].lo);
	tbin_hi = h2sim->GetXaxis()->FindBin( theta[j].hi)-1;
	h2sim->GetXaxis()->SetRange( tbin_lo, tbin_hi);
	TH1D *h1sim = h2sim->ProjectionY( "simhist");
	h1sim->Rebin( rebin);

	Double_t cts2 = h1sim->Integral( bin_lo, bin_hi);

	Double_t fact = cts1/cts2;

	h1sim->Scale( fact);
	h1sim->SetFillStyle( 3004);
	h1sim->SetFillColor( 16);
	h1sim->SetLineWidth( 2);
	h1sim->Draw( "same");

	tl->AddEntry( h1sim, "Monte Carlo");
	tl->Draw();

	name = Form( "plots/Pi0_%c_%s_SimComp_chan%d_t%d", tchar,
			(const char*) hist, i, th);
//	name.Append( ".pdf");
	name.Append( ".eps");
	if ( save == kTRUE) c1->Print( name);
}
void Plot_AM_events_07Sep_Susy_1_auto() {
 TString cutNameBefore = Form("Data/");

 //                            cut_variable 
 TString cutNameAfter  = Form("_1_6_Tot_temp");

 gROOT->LoadMacro("PlotVHqqHggH.C+");
 gInterpreter->ExecuteMacro("LatinoStyle2.C");

 TCanvas* c1 = new TCanvas("events","events",500,600);
 TFile* f = new TFile("~/Cern/Code/VBF/qqHWW/AnalysisPackage_qqHWWlnulnu/out_test_Latinos_07Sep2012_2000_Run2012AB_8TeV_SUSY.root");


 PlotVHqqHggH* hs = new PlotVHqqHggH();

 hs->setLumi(5.063);
 hs->setLabel("event");
 hs->addLabel("    #sqrt{s} = 8 TeV");

 TString name;

 std::vector<int> vectColourBkg;        
 std::vector<double> vectSystBkg;       
 std::vector<std::string> vectNameBkg;  
 std::vector<TH1F*> vectTHBkg;          

 std::vector<int> vectColourSig;      
 std::vector<double> vectSystSig;       
 std::vector<std::string> vectNameSig;  
 std::vector<TH1F*> vectTHSig;          

 ///==== signal (begin) ====

 name = Form("%sT2tt-350-70%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHSig.push_back ( (TH1F*) f->Get(name) );
 vectNameSig.push_back ("T2tt-stop350-lsp70");
 vectColourSig.push_back(6);

 name = Form("%sT2tt-500-70%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHSig.push_back ( (TH1F*) f->Get(name) );
 vectNameSig.push_back ("T2tt-stop500-lsp70");
 vectColourSig.push_back(97);

 name = Form("%sT2tt-350-100%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHSig.push_back ( (TH1F*) f->Get(name) );
 vectNameSig.push_back ("T2tt-stop350-lsp100");
 vectColourSig.push_back(70);

 name = Form("%sT2tt-500-100%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHSig.push_back ( (TH1F*) f->Get(name) );
 vectNameSig.push_back ("T2tt-stop500-lsp100");
 vectColourSig.push_back(65);

 name = Form("%sT2tt-500-200%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHSig.push_back ( (TH1F*) f->Get(name) );
 vectNameSig.push_back ("T2tt-stop500-lsp200");
 vectColourSig.push_back(5);

 name = Form("%sT2tt-200-0%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHSig.push_back ( (TH1F*) f->Get(name) );
 vectNameSig.push_back ("T2tt-stop200-lsp0");
 vectColourSig.push_back(7);

 ///==== signal (end)  ====

 name = Form("%sDATA%s",cutNameBefore.Data(),cutNameAfter.Data());
 hs->setDataHist ((TH1F*)f->Get(name));



 hs->setBlindBinSx(0);
 hs->setBlindBinDx(0);

 hs->setCutSx(-999,">");
 hs->setCutDx(-999,"<");


 ///==== background (begin)  ====

 name = Form("%sH-125%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHBkg.push_back ( (TH1F*) f->Get(name) );
 vectNameBkg.push_back ("H-125");
 vectColourBkg.push_back(633);
 vectSystBkg.push_back(0.00);


 name = Form("%sVV%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHBkg.push_back ( (TH1F*) f->Get(name) );
 vectNameBkg.push_back ("WZ/ZZ");
 vectColourBkg.push_back(858);
 vectSystBkg.push_back(0.00);

 name = Form("%sWJets%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHBkg.push_back ( (TH1F*) f->Get(name) );
 vectNameBkg.push_back ("W+jets");
 vectColourBkg.push_back(921);
 vectSystBkg.push_back(0.36);

 name = Form("%sTop%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHBkg.push_back ( (TH1F*) f->Get(name) );
 vectNameBkg.push_back ("top");
 vectColourBkg.push_back(400);
 vectSystBkg.push_back(0.00);

 name = Form("%sZJets%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHBkg.push_back ( (TH1F*) f->Get(name) );
 vectNameBkg.push_back ("DY+jets");
 vectColourBkg.push_back(418);
 vectSystBkg.push_back(0.00);
 name = Form("%sWW%s",cutNameBefore.Data(),cutNameAfter.Data());
 vectTHBkg.push_back ( (TH1F*) f->Get(name) );
 vectNameBkg.push_back ("WW");
 vectColourBkg.push_back(851);
 vectSystBkg.push_back(0.00);




 ///==== background (end)  ====


 hs->set_vectTHBkg     (vectTHBkg);      
 hs->set_vectNameBkg   (vectNameBkg);    
 hs->set_vectColourBkg (vectColourBkg);  
 hs->set_vectSystBkg   (vectSystBkg);    

 hs->set_vectTHSig     (vectTHSig);      
 hs->set_vectNameSig   (vectNameSig);    
 hs->set_vectColourSig (vectColourSig);  
 //  hs->set_vectSystSig   (vectSystSig);



 hs->set_addSignal (0); //---- stack signal = 1, no stack signal = 0  


 hs->prepare();


 ///==== draw ====



 hs->Draw(c1,1,true);

 c1->Print("07Sep_Susy_1/events.pdf");
 c1->Print("07Sep_Susy_1/events.png");

 c1->SetLogy();
 hs->Draw(c1,1,true);
 c1->Print("07Sep_Susy_1/events_logy.pdf");
 c1->Print("07Sep_Susy_1/events_logy.png");
}
//.x Skimming.C+("Input_2015D_v3_ONE.txt","BB_reduced.root")
void Skimming( TString fileList, TString outName ){

  //Doing the chain
  cout<<"Starting... "<<endl;
  TChain chain_data("cutFlowAnalyzer/Events");
  TChain chain_databb("cutFlowAnalyzer/Events_orphan");
  std::ifstream Myfile( fileList.Data() );
  std::string Line;
  if( !Myfile ) std::cout<<"ERROR opening "<<fileList<<std::endl;
  while (std::getline(Myfile, Line)){
    TString Line2(Line);
    if( Line2.Contains("root") ){
	chain_data.Add(Line2.Data());
	chain_databb.Add(Line2.Data());
    }
  }
  cout<<"Chain done!"<<endl;
  //Variables needed
  bool orph_passOffLineSel_bb, orph_passOffLineSelPt_bb, orph_passOffLineSelPt1788_bb, orph_FiredTrig_bb, orph_FiredTrig_pt_bb, orph_FiredTrig_ptColl_bb;
  int containstrig2_bb, containstrig_bb;
  float orph_dimu_mass_bb, orph_dimu_isoTk_bb;
  chain_databb.SetBranchAddress("orph_passOffLineSel",&orph_passOffLineSel_bb);
  chain_databb.SetBranchAddress("orph_passOffLineSelPt",&orph_passOffLineSelPt_bb);
  chain_databb.SetBranchAddress("orph_passOffLineSelPt1788",&orph_passOffLineSelPt1788_bb);
  chain_databb.SetBranchAddress("orph_FiredTrig",&orph_FiredTrig_bb);
  chain_databb.SetBranchAddress("orph_FiredTrig_pt",&orph_FiredTrig_pt_bb);
  chain_databb.SetBranchAddress("orph_FiredTrig_ptColl",&orph_FiredTrig_ptColl_bb);
  chain_databb.SetBranchAddress("orph_FiredTrig",&orph_FiredTrig_bb);
  chain_databb.SetBranchAddress("orph_dimu_isoTk",&orph_dimu_isoTk_bb);
  chain_databb.SetBranchAddress("containstrig2",&containstrig2_bb);
  chain_databb.SetBranchAddress("orph_dimu_mass",&orph_dimu_mass_bb);
  chain_databb.SetBranchAddress("containstrig",&containstrig_bb);
  float massC_mu, massF_mu, isoC_1mm_mu, isoF_1mm_mu;
  chain_data.SetBranchAddress("massC",&massC_mu);
  chain_data.SetBranchAddress("massF",&massF_mu);
  chain_data.SetBranchAddress("isoC_1mm",&isoC_1mm_mu);
  chain_data.SetBranchAddress("isoF_1mm",&isoF_1mm_mu);
  //My file
  TFile *f = new TFile(outName.Data(),"RECREATE");
  f->cd();
  TTree Events("Events","");
  float massC, massF, isoC_1mm, isoF_1mm;
  Events.Branch("massC",&massC,"massC/F");
  Events.Branch("massF",&massF,"massF/F");
  Events.Branch("isoC_1mm",&isoC_1mm,"isoC_1mm/F");
  Events.Branch("isoF_1mm",&isoF_1mm,"isoF_1mm/F");
  bool orph_passOffLineSel, orph_passOffLineSelPt, orph_passOffLineSelPt1788, orph_FiredTrig, orph_FiredTrig_pt, orph_FiredTrig_ptColl;
  int containstrig2, containstrig;
  float orph_dimu_mass, orph_dimu_isoTk;
  TTree Events_orphan("Events_orphan","");
  Events_orphan.Branch("orph_passOffLineSel",&orph_passOffLineSel,"orph_passOffLineSel/O");
  Events_orphan.Branch("orph_passOffLineSelPt",&orph_passOffLineSelPt,"orph_passOffLineSelPt/O");
  Events_orphan.Branch("orph_passOffLineSelPt1788",&orph_passOffLineSelPt1788,"orph_passOffLineSelPt1788/O");
  Events_orphan.Branch("orph_FiredTrig",&orph_FiredTrig,"orph_FiredTrig/O");
  Events_orphan.Branch("orph_FiredTrig_pt",&orph_FiredTrig_pt,"orph_FiredTrig_pt/O");
  Events_orphan.Branch("orph_FiredTrig_ptColl",&orph_FiredTrig_ptColl,"orph_FiredTrig_ptColl/O");
  Events_orphan.Branch("containstrig2",&containstrig2,"containstrig2/I");
  Events_orphan.Branch("containstrig",&containstrig,"containstrig/I");
  Events_orphan.Branch("orph_dimu_isoTk",&orph_dimu_isoTk,"orph_dimu_isoTk/F");
  Events_orphan.Branch("orph_dimu_mass",&orph_dimu_mass,"orph_dimu_mass/F");
  //Loops
  cout<<"Now starting loop on bb."<<endl;
  Long64_t entries = chain_databb.GetEntries(); 
  for(Long64_t i=0; i<entries; i++){ 
    if(i%10000==0) cout<<"i = "<<i<<" / "<<entries<<endl;
    chain_databb.GetEntry(i);
    if(orph_dimu_mass>-999.){
	orph_passOffLineSel = orph_passOffLineSel_bb;
	orph_passOffLineSelPt = orph_passOffLineSelPt_bb;
	orph_passOffLineSelPt1788 = orph_passOffLineSelPt1788_bb;
	orph_FiredTrig = orph_FiredTrig_bb;
	orph_FiredTrig_pt = orph_FiredTrig_pt_bb;
	orph_FiredTrig_ptColl = orph_FiredTrig_ptColl_bb;
	containstrig2 = containstrig2_bb;
	containstrig = containstrig_bb;
	orph_dimu_isoTk = orph_dimu_isoTk_bb;
	orph_dimu_mass = orph_dimu_mass_bb;
	Events_orphan.Fill();
    }
  }
  cout<<"Now starting loop on mu."<<endl;
  entries = chain_data.GetEntries(); 
  for(Long64_t i=0; i<entries; i++){ 
    if(i%10000==0) cout<<"i = "<<i<<" / "<<entries<<endl;
    chain_data.GetEntry(i);
    if(massC_mu>-999. || massF_mu>-999.){
	massC = massC_mu;
	massF = massF_mu;
	isoC_1mm = isoC_1mm_mu;
	isoF_1mm = isoF_1mm_mu;
	Events.Fill();
    }
  }
  cout<<"CLosing files"<<endl;
  f->Write();
  f->Close();
  cout<<"The end."<<endl;
}
Example #24
0
void rec(Int_t file_nr=0, Int_t nEvents=1, Int_t s=0){
  Char_t filenr[4];
  sprintf(filenr,"%04d",file_nr);
  printf("Filenr: %s\n", filenr);

  TString signal;
  if (s!=3312 && s!=3334) signal = "la";
  else if (s==3312) signal = "xi";
  else if (s==3334) signal = "om";

  // ----- Paths and file names  --------------------------------------------
  TString inDir = TString(filenr);
  inDir+="/";
  TString mcFile   = inDir+signal+".mc.root";
  TString parFile  = inDir+signal+".par.root";
  TString rcFile   = inDir+signal+".rc.root";
  TString digiFile = "sts_Standard_s3055AAFK5.SecD.digi.par";

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

  // ----  Load libraries   -------------------------------------------------
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  basiclibs();
  gROOT->LoadMacro("$VMCWORKDIR/analysis/hyperon/analysislibs.C");
  analysislibs();
  // ------------------------------------------------------------------------

  // -----   Reconstruction run   -------------------------------------------
  FairRunAna* run= new FairRunAna();
  run->SetInputFile(mcFile);
  run->SetOutputFile(rcFile);
  // ------------------------------------------------------------------------

  // -----   STS digitiser   ------------------------------------------------
  FairTask* stsDigitize = new CbmStsDigitize("STSDigitize", iVerbose);
  run->AddTask(stsDigitize);
  // ------------------------------------------------------------------------

  // ---  STS hit finding   -------------------------------------------------
  FairTask* findHits = new CbmStsFindHits("STSFindHits", iVerbose);
  run->AddTask(findHits);
  // ------------------------------------------------------------------------

  // ---  STS hit matching   ------------------------------------------------
  FairTask* matchHits = new CbmStsMatchHits("STSMatchHits",
          iVerbose);
  run->AddTask(matchHits);
  // ------------------------------------------------------------------------


  // -----   STS track finding   --------------------------------------------
  FairTask* kalman= new CbmKF();
  run->AddTask(kalman);
  FairTask* l1 = new CbmL1();
  run->AddTask(l1);
  CbmStsTrackFinder* trackFinder    = new CbmL1StsTrackFinder();
  FairTask* findTracks = new CbmStsFindTracks(iVerbose, trackFinder);
  run->AddTask(findTracks);
  // ------------------------------------------------------------------------


  // -----   STS track matching   -------------------------------------------
  FairTask* matchTracks = new CbmStsMatchTracks("Match tracks", iVerbose);
  run->AddTask(matchTracks);
  // ------------------------------------------------------------------------

  // -----   STS track fitting   --------------------------------------------
  CbmStsTrackFitter* trackFitter = new CbmStsKFTrackFitter();
  FairTask* fitTracks = new CbmStsFitTracks("STS Track Fitter", trackFitter, iVerbose);
  run->AddTask(fitTracks);
  // ------------------------------------------------------------------------

  // -----   Primary vertex finder   ----------------------------------------
  CbmPVFinderKF *vfinder = new CbmPVFinderKF();
  FairTask *vTask = new CbmFindPrimaryVertex("PV finder", "FairTask", vfinder);
  run->AddTask(vTask);
  // ------------------------------------------------------------------------


  // -----  Parameter database   --------------------------------------------
  TString stsDigiFile = gSystem->Getenv("VMCWORKDIR");
  stsDigiFile += "/parameters/sts/";
  stsDigiFile += digiFile;
  FairRuntimeDb* rtdb = run->GetRuntimeDb();
  FairParRootFileIo*  parIo1 = new FairParRootFileIo();
  FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
  parIo1->open(parFile.Data());
  parIo2->open(stsDigiFile.Data(),"in");
  rtdb->setFirstInput(parIo1);
  rtdb->setSecondInput(parIo2);
  rtdb->setOutput(parIo1);
  rtdb->saveOutput();
  // ------------------------------------------------------------------------

  // -----   Initialise and run   -------------------------------------------
  run->LoadGeometry();
  run->Init();
  run->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 "         << rcFile << endl;
  cout << "Parameter file is "      << parFile << endl;
  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
  cout << endl;
  // ------------------------------------------------------------------------
}
void plot(const std::string& inputFileName)
{
  gStyle->SetPalette(1);
  
  std::ifstream ifile(inputFileName.data());
  if(!(ifile.is_open())){
    std::cerr<<"ERROR! Requested file not found, file name: "<<inputFileName
             <<"\n...break\n"<<std::endl;
    exit(321);
  }
   
  TGraph *gr1 = new TGraph();
  gr1->SetMarkerStyle(25);
  
  int nPoints1 = 0;
  double x, y, px, py, dx, dy, dxy, corrx, corry;
  int i, ix, iy;
  int a1, a2;
  int maxIx(-9999);
  int minIx(9999);
  int maxIy(-9999);
  int minIy(9999);
  float summinX(0.);
  float summaxX(0.);
  float summinY(0.);
  float summaxY(0.);

  TString dummy;
  dummy.ReadLine(ifile);

  std::map<int,double> minX, maxX, minY, maxY;
 
  // Gehe ueber alle Punkte und fuelle sie in 1D-Graphen laengs y
  while (ifile >> ix >> iy >> x >> y >> px >> py >> dx >> a1 >> dy >> a2 >> dxy >> corrx >> corry) {

    if (minX.find(iy)==minX.end()) minX[iy] = x;
    if (maxX.find(iy)==maxX.end()) maxX[iy] = x;
    if (minY.find(ix)==minY.end()) minY[ix] = y;
    if (maxY.find(ix)==maxX.end()) maxY[ix] = y;

    minX[iy] = std::min(x, minX[iy]);
    maxX[iy] = std::max(x, maxX[iy]);
    minY[ix] = std::min(y, minY[ix]);
    maxY[ix] = std::max(y, maxY[ix]);
    
    gr1->SetPoint(nPoints1++, x, y);
    
    if(ix > maxIx) maxIx = ix;
    if(ix < minIx) minIx = ix;
    if(iy > maxIy) maxIy = iy;
    if(iy < minIy) minIy = iy;
  }
  ifile.close();
  
    
   TH1F * dX = new TH1F("dX", "dX", 4*(240-120), 120, 240);
  for (std::map<int,double>::iterator it = minX.begin();
       it != minX.end();
       ++it) {
    //std::cout << it->first << ":" << it->second << " - " << maxX[it->first] << std::endl;
    dX->Fill(maxX[it->first]-it->second);
  }

  TH1F * dY = new TH1F("dY", "dY", 4*(290-170), 170, 290);
  for (std::map<int,double>::iterator it = minY.begin();
       it != minY.end();
       ++it) {
    //std::cout << it->first << ":" << it->second << " - " << maxY[it->first] << std::endl;
    dY->Fill(maxY[it->first]-it->second);
  }

  double AnzIx = maxIx-minIx;
  double AnzIy = maxIy-minIy;
  //cout<<"AnzIx="<<AnzIx<<endl;
  //cout<<"AnzIy="<<AnzIy<<endl;
  //cout<<"minIy="<<minIy<<endl;
  //cout<<"maxIy="<<maxIy<<endl;
  
  for(i=minIy; i<=maxIy; i++){
      summinX=minX[i]+summinX;
  }
  //cout<<"summinX="<<summinX/(AnzIy+1)<<endl;
  
  for(i=minIy; i<=maxIy; i++){
      summaxX=maxX[i]+summaxX;
  }
  //cout<<"summaxX="<<summaxX/(AnzIy+1)<<endl;
  
  for(i=minIx; i<=maxIx; i++){
      summinY=minY[i]+summinY;
  }
  //cout<<"summinY="<<summinY/(AnzIx+1)<<endl;
  
  for(i=minIx; i<=maxIx; i++){
      summaxY=maxY[i]+summaxY;
  }
  //cout<<"summaxY="<<summaxY/(AnzIx+1)<<endl;
  
  float calibrationX = (190.)/((summaxX/(AnzIy+1))-(summinX/(AnzIy+1)));
  float calibrationY = (260.)/((summaxY/(AnzIx+1))-(summinY/(AnzIx+1)));
  const char* Title = ("Calibration Points");
  cout<<setprecision(15)<<"\nCalibration Faktor cx="<<calibrationX<<endl;
  cout<<setprecision(15)<<"\nCalibration Faktor cy="<<calibrationY<<endl<<endl;
  TCanvas * canvas;
  canvas = new TCanvas("CalibrationPoints", "CalibrationPoints", 500, 700);
  gr1->Draw("AP");
  
  gr1->GetHistogram()->GetXaxis()->SetTitle("x [mm]");
  gr1->GetYaxis()->SetTitleOffset(1.3);
  gr1->GetHistogram()->GetYaxis()->SetTitle("y [mm]");
  gr1->SetTitle(Title);
  
  canvas->Print("CalibrationPoints.pdf");

  return;
}
Example #26
0
#include "utilities.h"

//int inclusive=0;
int inclusive=1;

double luminosity=34.8*1e-3;
double setparam0=100.;
double setparam1=5.28;
double setparam2=0.05;
double setparam3=0.03;
double fixparam1=5.279;

//svmithi2
TString inputdata="/afs/cern.ch/work/w/wangj/public/nt_20140727_PAMuon_HIRun2013_Merged_y24_Using03090319Bfinder.root";
TString inputmc="/afs/cern.ch/work/w/wangj/nt_20140801_mixed_fromQMBFinder_Kp.root";
//TString inputdata="/data/bmeson/data/nt_20140727_PAMuon_HIRun2013_Merged_y24_Using03090319Bfinder.root";
//TString inputmc="/data/bmeson/MC/nt_20140801_mixed_fromQMBFinder_Kp.root";

//tk pt, chi2
TString cut="abs(y)<2.4&&(HLT_PAMu3_v1)&&abs(mumumass-3.096916)<0.15&&mass>5&&mass<6&& isbestchi2&&trk1Pt>0.9&&chi2cl>1.32e-02&&(d0/d0Err)>3.41&&cos(dtheta)>-3.46e01&&mu1pt>1.5&&mu2pt>1.5";
//TString cut="abs(y)<2.4&&(HLT_PAMu3_v1)&&abs(mumumass-3.096916)<0.15&&mass>5&&mass<6&&trk1Pt>0.9&&chi2cl>1.32e-02&&(d0/d0Err)>3.41&&cos(dtheta)>-3.46e01";

TString seldata_2y=Form("%s",cut.Data());
TString selmc=Form("abs(y)<2.4&&gen==23333&&%s",cut.Data());
TString selmcgen="abs(y)<2.4&&abs(pdgId)==521&&isSignal==1";

TString weight = "(27.493+pt*(-0.218769))";

void clean0(TH1D *h){
  for (int i=1;i<=h->GetNbinsX();i++){
    if (h->GetBinContent(i)==0) h->SetBinError(i,1);
Example #27
0
void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node)
{
    bool visit = true;

    TIntermSequence *sequence = node->getSequence();
    switch (node->getOp())
    {
        case EOpFunction:
        {
            TIntermAggregate *params = sequence->front()->getAsAggregate();
            ASSERT(params != nullptr);
            ASSERT(params->getOp() == EOpParameters);
            addToFunctionMap(node->getName(), params->getSequence());
            break;
        }
        case EOpPrototype:
            addToFunctionMap(node->getName(), sequence);
            break;
        default:
            break;
    }

    if (preVisit)
        visit = visitAggregate(PreVisit, node);

    if (visit)
    {
        bool inFunctionMap = false;
        if (node->getOp() == EOpFunctionCall)
        {
            inFunctionMap = isInFunctionMap(node);
            if (!inFunctionMap)
            {
                // The function is not user-defined - it is likely built-in texture function.
                // Assume that those do not have out parameters.
                setInFunctionCallOutParameter(false);
            }
        }

        incrementDepth(node);

        if (inFunctionMap)
        {
            TIntermSequence *params             = getFunctionParameters(node);
            TIntermSequence::iterator paramIter = params->begin();
            for (auto *child : *sequence)
            {
                ASSERT(paramIter != params->end());
                TQualifier qualifier = (*paramIter)->getAsTyped()->getQualifier();
                setInFunctionCallOutParameter(qualifier == EvqOut || qualifier == EvqInOut);

                child->traverse(this);
                if (visit && inVisit)
                {
                    if (child != sequence->back())
                        visit = visitAggregate(InVisit, node);
                }

                ++paramIter;
            }

            setInFunctionCallOutParameter(false);
        }
        else
        {
            if (node->getOp() == EOpSequence)
                pushParentBlock(node);

            // Find the built-in function corresponding to this op so that we can determine the
            // in/out qualifiers of its parameters.
            TFunction *builtInFunc = nullptr;
            TString opString = GetOperatorString(node->getOp());
            if (!node->isConstructor() && !opString.empty())
            {
                // The return type doesn't affect the mangled name of the function, which is used
                // to look it up from the symbol table.
                TType dummyReturnType;
                TFunction call(&opString, &dummyReturnType, node->getOp());
                for (auto *child : *sequence)
                {
                    TType *paramType = child->getAsTyped()->getTypePointer();
                    TConstParameter p(paramType);
                    call.addParameter(p);
                }

                TSymbol *sym = mSymbolTable.findBuiltIn(call.getMangledName(), mShaderVersion);
                if (sym != nullptr && sym->isFunction())
                {
                    builtInFunc = static_cast<TFunction *>(sym);
                    ASSERT(builtInFunc->getParamCount() == sequence->size());
                }
            }

            size_t paramIndex = 0;

            for (auto *child : *sequence)
            {
                TQualifier qualifier = EvqIn;
                if (builtInFunc != nullptr)
                    qualifier = builtInFunc->getParam(paramIndex).type->getQualifier();
                setInFunctionCallOutParameter(qualifier == EvqOut || qualifier == EvqInOut);
                child->traverse(this);

                if (visit && inVisit)
                {
                    if (child != sequence->back())
                        visit = visitAggregate(InVisit, node);
                }

                if (node->getOp() == EOpSequence)
                    incrementParentBlockPos();

                ++paramIndex;
            }

            setInFunctionCallOutParameter(false);

            if (node->getOp() == EOpSequence)
                popParentBlock();
        }

        decrementDepth();
    }

    if (visit && postVisit)
        visitAggregate(PostVisit, node);
}
Example #28
0
TF1 *fit(TTree *nt,TTree *ntMC,double ptmin,double ptmax){   
   //cout<<cut.Data()<<endl;
   static int count=0;
   count++;
   TCanvas *c= new TCanvas(Form("c%d",count),"",600,600);
   TH1D *h = new TH1D(Form("h%d",count),"",50,5,6);
   TH1D *hMC = new TH1D(Form("hMC%d",count),"",50,5,6);

   TString iNP="7.26667e+00*Gaus(x,5.10472e+00,2.63158e-02)/(sqrt(2*3.14159)*2.63158e-02)+4.99089e+01*Gaus(x,4.96473e+00,9.56645e-02)/(sqrt(2*3.14159)*9.56645e-02)+3.94417e-01*(3.74282e+01*Gaus(x,5.34796e+00,3.11510e-02)+1.14713e+01*Gaus(x,5.42190e+00,1.00544e-01))";
   TF1 *f = new TF1(Form("f%d",count),"[0]*([7]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]+[4]*x+[5]*("+iNP+")");
   nt->Project(Form("h%d",count),"mass",Form("%s&&pt>%f&&pt<%f",seldata_2y.Data(),ptmin,ptmax));   
   ntMC->Project(Form("hMC%d",count),"mass",Form("%s&&pt>%f&&pt<%f",seldata_2y.Data(),ptmin,ptmax));   
   clean0(h);
   h->Draw();
   f->SetParLimits(4,-1000,0);
   f->SetParLimits(2,0.01,0.05);
   f->SetParLimits(8,0.01,0.05);
   f->SetParLimits(7,0,1);
   f->SetParLimits(5,0,1000);

   f->SetParameter(0,setparam0);
   f->SetParameter(1,setparam1);
   f->SetParameter(2,setparam2);
   f->SetParameter(8,setparam3);
   f->FixParameter(1,fixparam1);
   h->GetEntries();

   hMC->Fit(Form("f%d",count),"q","",5,6);
   hMC->Fit(Form("f%d",count),"q","",5,6);
   f->ReleaseParameter(1);
   hMC->Fit(Form("f%d",count),"L q","",5,6);
   hMC->Fit(Form("f%d",count),"L q","",5,6);
   hMC->Fit(Form("f%d",count),"L q","",5,6);
   hMC->Fit(Form("f%d",count),"L m","",5,6);

   cout<<"======= MC ======="<<endl;
   cout<<f->GetParameter(2)<<"  "<<f->GetParameter(8)<<endl;
   cout<<"===== MC end ====="<<endl;
   cout<<endl;

   f->FixParameter(1,f->GetParameter(1));
   //f->FixParameter(2,f->GetParameter(2));
   f->FixParameter(7,f->GetParameter(7));
   //f->FixParameter(8,f->GetParameter(8));
   
   h->Fit(Form("f%d",count),"q","",5,6);
   h->Fit(Form("f%d",count),"q","",5,6);
   f->ReleaseParameter(1);
   h->Fit(Form("f%d",count),"L q","",5,6);
   h->Fit(Form("f%d",count),"L q","",5,6);
   h->Fit(Form("f%d",count),"L q","",5,6);
   h->Fit(Form("f%d",count),"L m","",5,6);
   h->SetMarkerSize(0.8);
   h->SetMarkerStyle(20);
   cout <<h->GetEntries()<<endl;

   cout<<"======= data ======="<<endl;
   cout<<f->GetParameter(2)<<"  "<<f->GetParameter(8)<<endl;
   cout<<"===== data end ====="<<endl;
   cout<<endl;
   cout<<"======= chi2 ======="<<endl;
   cout<<f->GetChisquare()<<endl;
   cout<<"===== chi2 end ====="<<endl;

   // function for background shape plotting. take the fit result from f
   TF1 *background = new TF1(Form("background%d",count),"[0]+[1]*x");
   background->SetParameter(0,f->GetParameter(3));
   background->SetParameter(1,f->GetParameter(4));
   background->SetParameter(2,f->GetParameter(5));
   background->SetParameter(3,f->GetParameter(6));
   background->SetLineColor(4);
   background->SetRange(5,6);
   background->SetLineStyle(2);
   
   // function for signal shape plotting. take the fit result from f
   TF1 *Bkpi = new TF1(Form("fBkpi",count),"[0]*("+iNP+")");
   Bkpi->SetParameter(0,f->GetParameter(5));
   Bkpi->SetLineColor(kGreen+1);
   Bkpi->SetFillColor(kGreen+1);
//   Bkpi->SetRange(5.00,5.28);
   Bkpi->SetRange(5.00,6.00);
   Bkpi->SetLineStyle(1);
   Bkpi->SetFillStyle(3004);

   // function for signal shape plotting. take the fit result from f
   TF1 *mass = new TF1(Form("fmass",count),"[0]*([3]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[3])*Gaus(x,[1],[4])/(sqrt(2*3.14159)*[4]))");
   mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(8));
   mass->SetParError(0,f->GetParError(0));
   mass->SetParError(1,f->GetParError(1));
   mass->SetParError(2,f->GetParError(2));
   mass->SetParError(7,f->GetParError(7));
   mass->SetParError(8,f->GetParError(8));
   mass->SetLineColor(2);
   mass->SetLineStyle(2);

//   cout <<mass->Integral(0,1.2)<<" "<<mass->IntegralError(0,1.2)<<endl;
   h->SetMarkerStyle(24);
   h->SetStats(0);
   h->Draw("e");
   h->SetXTitle("M_{B} (GeV/c^{2})");
   h->SetYTitle("Entries / (20 MeV/c^{2})");
   h->GetXaxis()->CenterTitle();
   h->GetYaxis()->CenterTitle();
   h->SetTitleOffset(1.5,"Y");
   h->SetAxisRange(0,h->GetMaximum()*1.2,"Y");
   Bkpi->Draw("same");
   background->Draw("same");   
   mass->SetRange(5,6);
   mass->Draw("same");
   mass->SetLineStyle(2);
   mass->SetFillStyle(3004);
   mass->SetFillColor(2);
   f->Draw("same");

   double yield = mass->Integral(5,6)/0.02;
   double yieldErr = mass->Integral(5,6)/0.02*mass->GetParError(0)/mass->GetParameter(0);


   // Draw the legend:)   
   TLegend *leg = myLegend(0.50,0.5,0.86,0.89);
   leg->AddEntry(h,"CMS Preliminary","");
   leg->AddEntry(h,"p+Pb #sqrt{s_{NN}}= 5.02 TeV","");
   leg->AddEntry(h,Form("%.0f<p_{T}^{B}<%.0f GeV/c",ptmin,ptmax),"");
   leg->AddEntry(h,"Data","pl");
   leg->AddEntry(f,"Fit","l");
   leg->AddEntry(mass,"Signal","f");
   leg->AddEntry(background,"Combinatorial Background","l");
   leg->AddEntry(Bkpi,"Non-prompt J/#psi","f");
   leg->Draw();
   TLegend *leg2 = myLegend(0.44,0.33,0.89,0.50);
   leg2->AddEntry(h,"B meson","");
   leg2->AddEntry(h,Form("M_{B}=%.2f #pm %.2f MeV/c^{2}",mass->GetParameter(1)*1000.,mass->GetParError(1)*1000.),"");
   leg2->AddEntry(h,Form("N_{B}=%.0f #pm %.0f", yield, yieldErr),"");
   leg2->Draw();

   if(inclusive==0) c->SaveAs(Form("PDFVariation/data/width-float/ResultsBplus/BMass-%d.pdf",count));
   else c->SaveAs(Form("PDFVariation1Bin/data/width-float/ResultsBplus/BMass-%d.pdf",count));

   return mass;
}
Example #29
0
void getPUWeight::getResultsPU( TString PUScheme, TString JsonDir, double topvalue, TString npu ){
  TH1D *datah=getDataPU( PUScheme, JsonDir, npu );
  TH1D *mchhh=getMCPU( PUScheme );
  TH1D *ratio=getWeightPU( PUScheme, JsonDir, topvalue, npu );
  TH1D *rationotopvalue=getWeightPU( PUScheme, JsonDir, -1., npu );

  TCanvas *c1=new TCanvas();
  datah->Draw("Hist");
  c1->SetLogy(0);
  c1->RedrawAxis();
  c1->SaveAs(Form("DataPU_%s%s.%s", JsonDir.Data(), npu.Data(), epspng_.Data() ) );
  c1->SetLogy(1);
  c1->RedrawAxis();
  c1->SaveAs(Form("DataPU_%s%s_log.%s", JsonDir.Data(), npu.Data(), epspng_.Data() ) );

  mchhh->Draw("Hist");
  c1->SetLogy(0);
  c1->RedrawAxis();
  c1->SaveAs(Form("MCPU_%s.%s", PUScheme.Data(), epspng_.Data() ) );
  c1->SetLogy(1);
  c1->RedrawAxis();
  c1->SaveAs(Form("MCPU_%s_log.%s", PUScheme.Data(), epspng_.Data() ) );

  rationotopvalue->Draw("Hist");
  c1->SetLogy(0);
  c1->RedrawAxis();
  c1->SaveAs(Form("WeightPU_%s_%s%s.%s", PUScheme.Data(), JsonDir.Data(), npu.Data(), epspng_.Data() ) );
  c1->SetLogy(1);
  c1->RedrawAxis();
  c1->SaveAs(Form("WeightPU_%s_%s%s_log.%s", PUScheme.Data(), JsonDir.Data(), npu.Data(), epspng_.Data() ) );


  TH1D *mch=(TH1D*)(mchhh->Clone("mch"));
  for( unsigned int i=1; i< rationotopvalue->GetNbinsX(); i++ ){
    if( rationotopvalue->GetBinContent(i) > topvalue ){
      mch->SetBinContent(i, rationotopvalue->GetBinContent(i)*0.2 * (mchhh->GetBinContent( i )));
    }
  }

  double ne=mch->Integral(0, mch->GetNbinsX());
  mch->Scale(1./ne);

  TH1D *ratiorenorm=(TH1D*)(datah->Clone("ratiorenorm"));
  ratiorenorm->Divide(datah, mch);


  double PU_2012[60] ={4.4440324532443709, 5.0061997829657203, 5.0061996586548734, 5.006199730725899, 5.0061996689281889, 5.0061994854927798, 4.0672442248759362, 2.0995433023763157, 1.7668637821307882, 1.7950673109957458, 1.8627517697417355, 1.834770739737478, 1.686482479322343, 1.4748693479651933, 1.2554610300850375, 1.089054470747572, 1.0026119696059284, 0.9750422459436342, 0.98407767292040893, 1.0114532670582539, 1.0303301567810361, 1.0268173086887269, 1.0040757158845171, 0.96910452350915, 0.92716904039504988, 0.88241133749856104, 0.8371193498509405, 0.79219665525452099, 0.74755192109117341, 0.70338182696593943, 0.65986497977508463, 0.61705628737949181, 0.57474946338748345, 0.53356806897611164, 0.49387885322588121, 0.45529765803168221, 0.41839857133635083, 0.38347230823418088, 0.3502872753475309, 0.31907191570812243, 0.28987509057216743, 0.26271781160021057, 0.23754816698443884, 0.21422666421667369, 0.19294111373486914, 0.17340191422834478, 0.15551648383287822, 0.13928129392117955, 0.12457648076876855, 0.11126217580292462, 0.099267654572039801, 0.088438949331281713, 0.07874206577404029, 0.070088693766009583, 0.062330121818411514, 0.055417930986005691, 0.049265883726412496, 0.043804241590539222, 0.03894116562378433, 0.072800352977050703};

  TH1D *darren=new TH1D("darren","darren",60, 0, 60);
  for( unsigned int i=1; i<=60; i++){
    darren->SetBinContent(i, PU_2012[i-1]);
  }

  darren->Divide(darren, ratiorenorm );
  darren->Draw("Hist");
  darren->GetYaxis()->SetRangeUser(0.8, 1.2);
  c1->SaveAs("Weight_DarrenOverZhaoxia.png");

  FILE * outputfile;
  char buffer[100];
  sprintf (buffer, "ReW.txt");
  outputfile = fopen (buffer,"w");


  fprintf(outputfile, "Data:/n");
  fprintf(outputfile, "[");
  for( unsigned int i=1; i<=datah->GetNbinsX(); i++){
    fprintf(outputfile, "%.12f, ", datah->GetBinContent(i));
  }
  fprintf(outputfile, "];\n\n");


  fprintf(outputfile, "MC:/n");
  fprintf(outputfile, "[");
  for( unsigned int i=1; i<=mchhh->GetNbinsX(); i++){
    fprintf(outputfile, "%.12f, ", mchhh->GetBinContent(i));
  }
  fprintf(outputfile, "];\n\n");


  fprintf(outputfile, "no top limit [");
  for( unsigned int i=1; i<=rationotopvalue->GetNbinsX(); i++){
    fprintf(outputfile, "%.12f, ", rationotopvalue->GetBinContent(i));
  }
  fprintf(outputfile, "];\n\n");


  fprintf(outputfile, "[");
  for( unsigned int i=1; i<=ratiorenorm->GetNbinsX(); i++){
    fprintf(outputfile, "%.12f, ", ratiorenorm->GetBinContent(i));
  }
  fprintf(outputfile, "];\n\n");


  fprintf(outputfile, "Darren/Zhaoxis [");
  for( unsigned int i=1; i<=darren->GetNbinsX(); i++){
    fprintf(outputfile, "%.12f, ", darren->GetBinContent(i));
  }
  fprintf(outputfile, "];\n\n");



  fprintf(outputfile, "[");
  for( unsigned int i=1; i<=ratiorenorm->GetNbinsX(); i++){
    fprintf(outputfile, "nvtx[ %i ]=%.12f, \n", i-1, ratiorenorm->GetBinContent(i));
  }
  fprintf(outputfile, "];\n");




  fclose( outputfile );
}
Example #30
0
TCanvas *calibrate_adc(Int_t ped = 1, Int_t tdc_min=750, Int_t tdc_width=200){

        TString cut, draw, draw1, title;
        title.Form("run_%d_ADCCalibrate",run);
        TCanvas *cADCCalib= new TCanvas("cADCCalib",title,xcanvas,ycanvas);

        TH1D *htmpa[NUMPMT][NUMPIXEL];//=new TH1D("htmp","htmp",nbin,min,max);
        TH1D *htmpb[NUMPMT][NUMPIXEL];//=new TH1D("htmp1","htmp1",nbin,min,max);
        TH1D *htmpc[NUMPMT][NUMPIXEL];//=new TH1D("htmp1","htmp1",nbin,min,max);

        TString tmpentry;
        MyStyle->SetStatX(0.9);
        MyStyle->SetStatY(0.6);
        MyStyle->SetStatW(0.4);

        Int_t nbin=600;
        Int_t min=-100, max=1000;
	for (Int_t pmt=1; pmt<=NUMPMT; pmt++){
         for(Int_t icounter=1;icounter<=NUMPIXEL;icounter++){
                tmpentry.Form("htmpa_%d_%d", pmt,icounter);
                htmpa[pmt-1][icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                tmpentry.Form("htmpb_%d_%d", pmt,icounter);
                htmpb[pmt-1][icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                tmpentry.Form("htmpc_%d_%d", pmt,icounter);
                htmpc[pmt-1][icounter - 1] = new TH1D(tmpentry,tmpentry,nbin,min,max);
                htmpa[pmt-1][icounter - 1]->SetLineColor(kBlue);
                htmpb[pmt-1][icounter - 1]->SetLineColor(kRed);
                htmpc[pmt-1][icounter - 1]->SetLineColor(kGreen);
                title.Form("Run %d ADC pmt %d, paddle %d: %d < tdc < %d",run,pmt,icounter,tdc_min,tdc_min+tdc_width);
                htmpa[pmt-1][icounter - 1]->SetTitle(title);
                htmpb[pmt-1][icounter - 1]->SetTitle(title);
                htmpc[pmt-1][icounter - 1]->SetTitle(title);
         }
	}

        Int_t nentries=n_events_to_analyze;

        for (Int_t id=1;id<=nentries;id++){
          T->GetEntry(id);
	  for (Int_t pmt=1; pmt<=NUMPMT; pmt++){
	   for (Int_t index=1; index<=NUMPIXEL; index++){
	    Int_t ipaddle = (pmt-1)*NUMPIXEL+index-1;
	    htmpa[pmt-1][index-1]->Fill(adc[ipaddle]);
	    if(tdcl[ipaddle]<tdc_min||tdcl[ipaddle]>tdc_min+tdc_width){
		htmpb[pmt-1][index-1]->Fill(adc[ipaddle]);
	    }else{
		htmpc[pmt-1][index-1]->Fill(adc[ipaddle]);
	    }
	   }
	  }
	}

	cADCCalib->Clear();
        cADCCalib->Divide(4,4);

        //plot histos
	for (Int_t pmt=1; pmt<=NUMPMT; pmt++){
         Int_t icount=0;
         for (Int_t i=0; i<NUMPIXEL; i++){

          //if(i != pixel1[pmt-1]-1 && i != pixel2[pmt-1]-1) {

            //cout<<"into loop 2, i = " << i << endl;

            cADCCalib->cd( icount + 1 );
            gPad->SetLogy();

            cADCCalib->Update();
                
            Int_t entries = htmpb[pmt-1][i]->GetEntries();
            float mean = htmpb[pmt-1][i]->GetMean(1);
            float RMS = htmpb[pmt-1][i]->GetRMS(1);
	    Int_t imean = mean;
            float mean2 = htmpc[pmt-1][i]->GetMean(1);
   	    float gain;
	    if (mean2-mean > 2.0){
	    	gain = 100.0/(mean2-mean);
	    }else{
		gain = 1.0;
	    }
            //cout << entries <<" "<< mean <<" "<< RMS <<endl;
            if (ped == 1){
		if(pmt==1&&i==0) cout << "C.cdetm1r.ped = ";
	    	cout << imean << " ";
	    }else{
		if(pmt==1&&i==0) cout << "C.cdetm1r.gain = ";
	    	cout << gain << " ";
	    }
		
                
            htmpa[pmt-1][i]->SetStats(0);
            //current->Modified();
            htmpa[pmt-1][i]->Draw();
            htmpb[pmt-1][i]->Draw("same");
            htmpc[pmt-1][i]->Draw("same");

            icount++;
          
	  //}
         }
	cout << endl;
	}

        title.Form("run_%d_ADCCalib_tdc_min_%d_max_%d.png",
                   run,tdc_min,tdc_min+tdc_width);
        cADCCalib->Print(title);
        cADCCalib->cd(0);
        return cADCCalib;
}