void DataInterface::getDataProfile(TH2F *hProfile, TH2F *hProjection, Int_t energy) { if (!existsEnergyFile(energy)) { cout << "There are no data files with energy " << energy << endl; return; } TString fn = Form("Data/ExperimentalData/DataFrame_%i_MeV.root", energy); TFile *f = new TFile(fn); TTree *tree = (TTree*) f->Get("tree"); Int_t nentries = tree->GetEntries(); printf("Found %d frames in the DataFrame.\n", nentries); TLeaf *lX = tree->GetLeaf("fDataFrame.fX"); TLeaf *lY = tree->GetLeaf("fDataFrame.fY"); TLeaf *lLayer = tree->GetLeaf("fDataFrame.fLayer"); Float_t x, y, layer; for (Int_t i=0; i<nentries; i++) { tree->GetEntry(i); for (Int_t j=0; j<lY->GetLen(); j++) { x = lX->GetValue(j) + nx/2; y = lY->GetValue(j) + ny/2; layer = lLayer->GetValue(j); hProfile->Fill(y, layer); hProjection->Fill(x, y); } } }
/// \brief Cache MC production trees, store summary information in formated text files -> root trees /// \param dataType - /// \param fileList void CacheTestMCProductions(TString dataType, const char *fileList=NULL){ AliExternalInfo info; info.fLoadMetadata=kFALSE; TObjArray* periodList = NULL; TArrayI nRuns; if (fileList!=NULL) { periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n"); nRuns.Set(periodList->GetEntries()); }else{ TTree * tree = info.GetTree("MonALISA.ProductionMC","",""); Int_t nProd=tree->GetEntries(); periodList = new TObjArray(nProd); nRuns.Set(nProd); TLeaf *leaf = tree->GetLeaf("Tag"); TLeaf *leafRuns = tree->GetLeaf("Number_of_runs"); for (Int_t iProd=0; iProd<nProd; iProd++){ tree->GetEntry(iProd); TString prodName=((char*)leaf->GetValuePointer()); if (prodName.Contains("LHC")==0) continue; periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd); nRuns[iProd]=leafRuns->GetValue(); } delete tree; } for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){ TObjString * pName= (TObjString*)periodList->At(iPeriod); if (pName==NULL) continue; TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC"); if (tree){ Int_t entries=tree->Draw("run","1","goff"); TString sInfo=periodList->At(iPeriod)->GetName(); sInfo+="\t"; sInfo+=dataType; sInfo+="\t"; sInfo+=TString::Format("%d\t",entries); sInfo+=TString::Format("%d\t",nRuns[iPeriod]); for (Int_t j=0; j<entries; j++) { sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]); ::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]); } sInfo+="0"; ::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data()); delete tree; }else{ ::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]); } } }
void fillGraphsFromFilesAsymp( const TString& par1, const TString& par2, const vector<TString>& fnames, vector<string>& keys, map<string,TGraph2D *>& m_graphs) { keys.push_back("-2s"); keys.push_back("-1s"); keys.push_back("median"); keys.push_back("+1s"); keys.push_back("+2s"); keys.push_back("obs"); for (int i=0; i<6; i++) { m_graphs[keys[i]] = new TGraph2D(); m_graphs[keys[i]]->SetName(Form("graph2D%s",keys[i].c_str())); } for( size_t i=0; i<fnames.size(); i++) { double par1val = extractParValue(par1,fnames[i]); double par2val = extractParValue(par2,fnames[i]); //cout << par1val << "\t" << par2val << endl; if (par1val == -9e99 || par2val == -9e99) continue; TFile *f = new TFile(fnames[i]); TTree *lTree = (TTree *)f->Get("limit"); if (!lTree) { f->Close(); delete f; cerr << "didn't find tree limit in file " << fnames[i] << endl; continue; } for (int j=0; j<6; j++) { lTree->GetEntry(j); double rval = lTree->GetLeaf("limit")->GetValue(); m_graphs[keys[j]]->SetPoint(i,par1val,par2val,rval); } f->Close(); delete f; //if (!(i%10)) cout << i << " " << std::flush; } // file loop } // fillGraphsFromFilesAsymp
void DataInterface::getDataFrame(Int_t runNo, CalorimeterFrame * cf, Int_t energy) { if (!existsEnergyFile(energy)) { cout << "There are no data files with energy " << energy << endl; return; } Int_t eventIdFrom = runNo * kEventsPerRun; Int_t eventIdTo = eventIdFrom + kEventsPerRun; TString fn = Form("Data/ExperimentalData/DataFrame_%i_MeV.root", energy); TFile *f = new TFile(fn); TTree *tree = (TTree*) f->Get("tree"); Int_t nentries = tree->GetEntries(); if (eventIdTo > nentries) { eventIdTo = nentries; } cout << "Found " << nentries << " frames in the DataFrame.\n"; TLeaf *lX = tree->GetLeaf("fDataFrame.fX"); TLeaf *lY = tree->GetLeaf("fDataFrame.fY"); TLeaf *lLayer = tree->GetLeaf("fDataFrame.fLayer"); Int_t counter = 0; for (Int_t i=eventIdFrom; i<eventIdTo; i++) { tree->GetEntry(i); for (Int_t j=0; j<lX->GetLen(); j++) { Int_t x = lX->GetValue(j) + nx/2; Int_t y = lY->GetValue(j) + ny/2; Int_t z = lLayer->GetValue(j); cf->fillAt(z, x, y); } counter++; } delete f; }
void DalitzplotXi1820_XiPlus_lambda_k(){ //*** Data input TString inputFile = "/home/ikp1/puetz/panda/mysimulations/analysis/XiPlus_Lambda_K/output_ana.root"; TFile * data = new TFile(inputFile, "READ"); TString outPath = "/home/ikp1/puetz/panda/mysimulations/analysis/XiPlus_Lambda_K/plots"; TFile * out = new TFile(outPath+"/root-files/Dalitzplot_MC.root", "RECREATE"); TTree * sim = (TTree*) data->Get("ntpMC"); int nevents = sim->GetEntriesFast(); TH2D * dalitz_Xilk = new TH2D("dalitz_Xilk", "Dalitz plot for MC; m^{2}(#Lambda^{0},K^{-})/GeV^{2}/c^{4}; m^{2}(#bar{#Xi}, K^{-})/GeV^{2}/c^{4}", 150,2.5,3.8,150,3.2,4.8); gStyle->SetOptStat(0); TLorentzVector lXi, lk, lla, lXi1820; TLorentzVector PXiK, PlaK, PXil; for (int n=0; n<nevents; n++){ sim->GetEntry(n); double Eaxi = sim->GetLeaf("e")->GetValue(xi); double Ek = sim->GetLeaf("e")->GetValue(kaon); double Ela = sim->GetLeaf("e")->GetValue(lambda0); double Pxaxi = sim->GetLeaf("px")->GetValue(xi); double Pxk = sim->GetLeaf("px")->GetValue(kaon); double Pxla = sim->GetLeaf("px")->GetValue(lambda0); double Pyaxi = sim->GetLeaf("py")->GetValue(xi); double Pyk = sim->GetLeaf("py")->GetValue(kaon); double Pyla = sim->GetLeaf("py")->GetValue(lambda0); double Pzaxi = sim->GetLeaf("pz")->GetValue(xi); double Pzk = sim->GetLeaf("pz")->GetValue(kaon); double Pzla = sim->GetLeaf("pz")->GetValue(lambda0); lXi.SetPxPyPzE(Pxaxi, Pyaxi, Pzaxi, Eaxi); lk.SetPxPyPzE(Pxk, Pyk, Pzk, Ek); lla.SetPxPyPzE(Pxla, Pyla, Pzla, Ela); PXiK = lXi + lk; PlaK = lla + lk; PXil = lXi + lla; dalitz_Xilk->Fill(PlaK.M2(),PXiK.M2()); } setPandaStyle(); out->cd(); dalitz_Xilk->Write(); out->Save(); TCanvas * c = new TCanvas("c", "Dalitz plot PHSP model", 0,0,1500,1000); dalitz_Xilk->Draw("COLZ"); PandaSmartLabel("L"); //****write histograms c->Print(outPath+"/png-files/Dalitzplots_MC.png"); c->Print(outPath+"/pdf-files/Dalitzplots_MC.pdf"); }
void plotDeadChannelsRun(const char * fileName, const Int_t nEvents) { TCanvas can("can","can",1200,800); gStyle->SetOptStat(0); gStyle->SetErrorX(0.0001); gStyle->SetLegendBorderSize(0); string rootFileName; ifstream file(fileName); TTree *tree; TFile *f = 0; Int_t fileCount = 0; vector<TTree*> eventTrees(nEvents); vector<TFile*> eventFiles(nEvents); vector<Int_t> run(nEvents), subrun(nEvents), event(nEvents); //Save trees to eventTrees if(file.is_open()){ while(!file.eof() && fileCount<nEvents){ getline(file,rootFileName); eventFiles.at(fileCount) = TFile::Open(rootFileName.c_str(),"update"); tree = (TTree*)eventFiles.at(fileCount)->Get("RMS"); eventTrees.at(fileCount) = tree; if(eventTrees.at(fileCount)->GetEntry(0) == -1) cerr<<"Could not read TTree RMS in file "<<rootFileName.c_str()<<endl; tree = (TTree*)eventFiles.at(fileCount)->Get("Trun"); tree->Draw("runNo");tree->Draw("subRunNo");tree->Draw("eventNo"); run.at(fileCount) = tree->GetLeaf("runNo")->GetValue(); subrun.at(fileCount) = tree->GetLeaf("subRunNo")->GetValue(); event.at(fileCount) = tree->GetLeaf("eventNo")->GetValue(); eventTrees.at(fileCount)->SetDirectory(0); delete eventFiles.at(fileCount++); } file.close(); } if(fileCount != nEvents) cerr<<"Mismatch: number of events and number of input root files"<<endl; //Create and set branch addresses Double_t rms; UShort_t chid; Bool_t chstat, outlier_flag, chirping_flag; for(Int_t i = 0; i < nEvents; i++){ eventTrees.at(i)->SetBranchAddress("rms",&rms); eventTrees.at(i)->SetBranchAddress("chid",&chid); eventTrees.at(i)->SetBranchAddress("chstat",&chstat); eventTrees.at(i)->SetBranchAddress("outlier_flag",&outlier_flag); //eventTrees.at(i)->SetBranchAddress("chirping_flag",&chirping_flag); } //Declare relevant plots and parameters Int_t firstRun = *min_element(run.begin(),run.end()), lastRun = *max_element(run.begin(),run.end()); vector<TH1F*> deadChannels(3); deadChannels.at(0) = new TH1F("deadChannelsU","Dead Channels in U Plane",(lastRun-firstRun+1),firstRun,lastRun+1); deadChannels.at(1) = new TH1F("deadChannelsV","Dead Channels in V Plane",(lastRun-firstRun+1),firstRun,lastRun+1); deadChannels.at(2) = new TH1F("deadChannelsW","Dead Channels in W Plane",(lastRun-firstRun+1),firstRun,lastRun+1); Double_t norm = 0; //Fill Plots for(Int_t n = 0; n < nEvents; n++){ norm = count(run.begin(),run.end(),run.at(n)); if (norm == 0.0) cout<<n<<" : "<<run.at(n)<<endl; deadChannels.at(0)->Fill(run.at(n), eventTrees.at(n)->Draw("","chstat==0&&chid<2401")/norm); deadChannels.at(1)->Fill(run.at(n), eventTrees.at(n)->Draw("","chstat==0&&chid<4801&&chid>2400")/norm); deadChannels.at(2)->Fill(run.at(n), eventTrees.at(n)->Draw("","chstat==0&&chid>4800")/norm); /*for(Int_t c = 0; c < 8256; c++){ chstat = 1; eventTrees.at(n)->GetEntry(c); if(chstat == 1 || norm == 0) continue; if(c < 2401) deadChannels.at(0)->Fill(run.at(n), 1/norm); if(c>2400 && c<4801) deadChannels.at(1)->Fill(run.at(n), 1/norm); if(c>4800) deadChannels.at(2)->Fill(run.at(n), 1/norm); }*/ } deadChannels.at(0)->SetMarkerStyle(kFullDotMedium); deadChannels.at(1)->SetMarkerStyle(kFullDotMedium); deadChannels.at(2)->SetMarkerStyle(kFullDotMedium); deadChannels.at(0)->SetMarkerColor(kBlue); deadChannels.at(1)->SetMarkerColor(kRed); deadChannels.at(2)->SetMarkerColor(kCyan); deadChannels.at(0)->SetTitle(";Run Number;Number of Dead Channels"); deadChannels.at(0)->SetMaximum(850); deadChannels.at(0)->GetYaxis()->SetTitleOffset(1.5); deadChannels.at(0)->Draw("P HIST"); deadChannels.at(1)->Draw("P HIST same"); deadChannels.at(2)->Draw("P HIST same"); TLegend *leg = new TLegend(0.7,0.75,0.89,0.89); leg->AddEntry(deadChannels.at(0),"U Plane","p"); leg->AddEntry(deadChannels.at(1),"V Plane","p"); leg->AddEntry(deadChannels.at(2),"Y Plane","p"); leg->Draw(); can.Print(Form("deadChannels_%i-%i_%i.png",firstRun,lastRun,nEvents)); TFile outF(Form("deadChannels_%i-%i_%i.root",firstRun,lastRun,nEvents),"RECREATE"); deadChannels.at(0)->Write(); deadChannels.at(1)->Write(); deadChannels.at(2)->Write(); outF.Close(); }
void plotFFTMetrics(const char * FFTfileName) { TCanvas can("can","can",1200,800); gStyle->SetOptStat(0); gStyle->SetLegendBorderSize(0); TFile f(FFTfileName); vector<TTree*> trees(6); trees.at(0) = (TTree*)f.Get("UFFT_mag"); trees.at(1) = (TTree*)f.Get("UlongwireFFT_mag"); trees.at(2) = (TTree*)f.Get("UFFT_mag_misconf"); trees.at(3) = (TTree*)f.Get("VFFT_mag"); trees.at(4) = (TTree*)f.Get("VlongwireFFT_mag"); trees.at(5) = (TTree*)f.Get("WFFT_mag"); TTree *stats = (TTree*)f.Get("runStats"); nEvents = (Int_t)stats->GetEntries(); Double_t mlow, mmid, mhigh, mco, m36, m108, m900; for(Int_t i = 0; i<6; i++) { trees.at(i)->SetBranchAddress("mlow",&mlow); trees.at(i)->SetBranchAddress("mmid",&mmid); trees.at(i)->SetBranchAddress("mhigh",&mhigh); trees.at(i)->SetBranchAddress("mco",&mco); trees.at(i)->SetBranchAddress("m36",&m36); trees.at(i)->SetBranchAddress("m108",&m108); trees.at(i)->SetBranchAddress("m900",&m900); } stats->GetEntry(0); Int_t firstRun = stats->GetLeaf("run")->GetValue(0); stats->GetEntry(nEvents-1); Int_t lastRun = stats->GetLeaf("run")->GetValue(0); Int_t run = 0; stats->SetBranchAddress("run",&run); vector<TH1F*> hlow(6); vector<TH1F*> hmid(6); vector<TH1F*> hhigh(6); vector<TH1F*> hco(6); vector<TH1F*> h36(6); vector<TH1F*> h108(6); vector<TH1F*> h900(6); for(Int_t i = 0; i<6; i++) { hlow.at(i) = new TH1F(Form("hlow%i",i),"",lastRun-firstRun+1,firstRun,lastRun); hmid.at(i) = new TH1F(Form("hmid%i",i),"",lastRun-firstRun+1,firstRun,lastRun); hhigh.at(i) = new TH1F(Form("hhigh%i",i),"",lastRun-firstRun+1,firstRun,lastRun); hco.at(i) = new TH1F(Form("hco%i",i),"",lastRun-firstRun+1,firstRun,lastRun); h36.at(i) = new TH1F(Form("h36%i",i),"",lastRun-firstRun+1,firstRun,lastRun); h108.at(i) = new TH1F(Form("h108%i",i),"",lastRun-firstRun+1,firstRun,lastRun); h900.at(i) = new TH1F(Form("h900%i",i),"",lastRun-firstRun+1,firstRun,lastRun); } Int_t Nrun, r; for(Int_t n = 0; n<nEvents; n++) { stats->GetEntry(n); r = run; Nrun = stats->Draw("",Form("run==%i",r),"goff"); for(Int_t i = 0; i< 6; i++) { trees.at(i)->GetEntry(n); hlow.at(i)->Fill(r,mlow/Nrun); hmid.at(i)->Fill(r,mmid/Nrun); hhigh.at(i)->Fill(r,mhigh/Nrun); hco.at(i)->Fill(r,mco/Nrun); h36.at(i)->Fill(r,m36/Nrun); h108.at(i)->Fill(r,m108/Nrun); h900.at(i)->Fill(r,m900/Nrun); } } hlow.at(0)->SetMarkerColor(kBlue);hlow.at(0)->SetFillColor(kBlue);hlow.at(0)->SetLineColor(kBlue); hmid.at(0)->SetMarkerColor(kBlue);hmid.at(0)->SetFillColor(kBlue);hmid.at(0)->SetLineColor(kBlue); hhigh.at(0)->SetMarkerColor(kBlue);hhigh.at(0)->SetFillColor(kBlue);hhigh.at(0)->SetLineColor(kBlue); hco.at(0)->SetMarkerColor(kBlue);hco.at(0)->SetFillColor(kBlue);hco.at(0)->SetLineColor(kBlue); h36.at(0)->SetMarkerColor(kBlue);h36.at(0)->SetFillColor(kBlue);h36.at(0)->SetLineColor(kBlue); h108.at(0)->SetMarkerColor(kBlue);h108.at(0)->SetFillColor(kBlue);h108.at(0)->SetLineColor(kBlue); h900.at(0)->SetMarkerColor(kBlue);h900.at(0)->SetFillColor(kBlue);h900.at(0)->SetLineColor(kBlue); hlow.at(1)->SetMarkerColor(kViolet);hlow.at(1)->SetFillColor(kViolet);hlow.at(1)->SetLineColor(kViolet); hmid.at(1)->SetMarkerColor(kViolet);hmid.at(1)->SetFillColor(kViolet);hmid.at(1)->SetLineColor(kViolet); hhigh.at(1)->SetMarkerColor(kViolet);hhigh.at(1)->SetFillColor(kViolet);hhigh.at(1)->SetLineColor(kViolet); hco.at(1)->SetMarkerColor(kViolet);hco.at(1)->SetFillColor(kViolet);hco.at(1)->SetLineColor(kViolet); h36.at(1)->SetMarkerColor(kViolet);h36.at(1)->SetFillColor(kViolet);h36.at(1)->SetLineColor(kViolet); h108.at(1)->SetMarkerColor(kViolet);h108.at(1)->SetFillColor(kViolet);h108.at(1)->SetLineColor(kViolet); h900.at(1)->SetMarkerColor(kViolet);h900.at(1)->SetFillColor(kViolet);h900.at(1)->SetLineColor(kViolet); hlow.at(2)->SetMarkerColor(kGreen);hlow.at(2)->SetFillColor(kGreen);hlow.at(2)->SetLineColor(kGreen); hmid.at(2)->SetMarkerColor(kGreen);hmid.at(2)->SetFillColor(kGreen);hmid.at(2)->SetLineColor(kGreen); hhigh.at(2)->SetMarkerColor(kGreen);hhigh.at(2)->SetFillColor(kGreen);hhigh.at(2)->SetLineColor(kGreen); hco.at(2)->SetMarkerColor(kGreen);hco.at(2)->SetFillColor(kGreen);hco.at(2)->SetLineColor(kGreen); h36.at(2)->SetMarkerColor(kGreen);h36.at(2)->SetFillColor(kGreen);h36.at(2)->SetLineColor(kGreen); h108.at(2)->SetMarkerColor(kGreen);h108.at(2)->SetFillColor(kGreen);h108.at(2)->SetLineColor(kGreen); h900.at(2)->SetMarkerColor(kGreen);h900.at(2)->SetFillColor(kGreen);h900.at(2)->SetLineColor(kGreen); hlow.at(3)->SetMarkerColor(kRed);hlow.at(3)->SetFillColor(kRed);hlow.at(3)->SetLineColor(kRed); hmid.at(3)->SetMarkerColor(kRed);hmid.at(3)->SetFillColor(kRed);hmid.at(3)->SetLineColor(kRed); hhigh.at(3)->SetMarkerColor(kRed);hhigh.at(3)->SetFillColor(kRed);hhigh.at(3)->SetLineColor(kRed); hco.at(3)->SetMarkerColor(kRed);hco.at(3)->SetFillColor(kRed);hco.at(3)->SetLineColor(kRed); h36.at(3)->SetMarkerColor(kRed);h36.at(3)->SetFillColor(kRed);h36.at(3)->SetLineColor(kRed); h108.at(3)->SetMarkerColor(kRed);h108.at(3)->SetFillColor(kRed);h108.at(3)->SetLineColor(kRed); h900.at(3)->SetMarkerColor(kRed);h900.at(3)->SetFillColor(kRed);h900.at(3)->SetLineColor(kRed); hlow.at(4)->SetMarkerColor(kOrange);hlow.at(4)->SetFillColor(kOrange);hlow.at(4)->SetLineColor(kOrange); hmid.at(4)->SetMarkerColor(kOrange);hmid.at(4)->SetFillColor(kOrange);hmid.at(4)->SetLineColor(kOrange); hhigh.at(4)->SetMarkerColor(kOrange);hhigh.at(4)->SetFillColor(kOrange);hhigh.at(4)->SetLineColor(kOrange); hco.at(4)->SetMarkerColor(kOrange);hco.at(4)->SetFillColor(kOrange);hco.at(4)->SetLineColor(kOrange); h36.at(4)->SetMarkerColor(kOrange);h36.at(4)->SetFillColor(kOrange);h36.at(4)->SetLineColor(kOrange); h108.at(4)->SetMarkerColor(kOrange);h108.at(4)->SetFillColor(kOrange);h108.at(4)->SetLineColor(kOrange); h900.at(4)->SetMarkerColor(kOrange);h900.at(4)->SetFillColor(kOrange);h900.at(4)->SetLineColor(kOrange); hlow.at(5)->SetMarkerColor(kCyan);hlow.at(5)->SetFillColor(kCyan);hlow.at(5)->SetLineColor(kCyan); hmid.at(5)->SetMarkerColor(kCyan);hmid.at(5)->SetFillColor(kCyan);hmid.at(5)->SetLineColor(kCyan); hhigh.at(5)->SetMarkerColor(kCyan);hhigh.at(5)->SetFillColor(kCyan);hhigh.at(5)->SetLineColor(kCyan); hco.at(5)->SetMarkerColor(kCyan);hco.at(5)->SetFillColor(kCyan);hco.at(5)->SetLineColor(kCyan); h36.at(5)->SetMarkerColor(kCyan);h36.at(5)->SetFillColor(kCyan);h36.at(5)->SetLineColor(kCyan); h108.at(5)->SetMarkerColor(kCyan);h108.at(5)->SetFillColor(kCyan);h108.at(5)->SetLineColor(kCyan); h900.at(5)->SetMarkerColor(kCyan);h900.at(5)->SetFillColor(kCyan);h900.at(5)->SetLineColor(kCyan); for(Int_t i = 0;i<6;i++){ hlow.at(i)->SetMarkerStyle(kFullDotMedium); hmid.at(i)->SetMarkerStyle(kFullDotMedium); hhigh.at(i)->SetMarkerStyle(kFullDotMedium); hco.at(i)->SetMarkerStyle(kFullDotMedium); h36.at(i)->SetMarkerStyle(kFullDotMedium); h108.at(i)->SetMarkerStyle(kFullDotMedium); h900.at(i)->SetMarkerStyle(kFullDotMedium); } TLegend *leg = new TLegend(0.7,0.7,0.89,0.89); leg->AddEntry(hlow.at(0),"U","l"); leg->AddEntry(hlow.at(1),"U (Long Wires)","l"); leg->AddEntry(hlow.at(2),"U (Misconfigured)","l"); leg->AddEntry(hlow.at(3),"V","l"); leg->AddEntry(hlow.at(4),"V (Long Wires)","l"); leg->AddEntry(hlow.at(5),"Y","l"); leg->SetFillStyle(0); vector<Int_t> mlowMax(6), mmidMax(6), mhighMax(6), mcoMax(6), m36Max(6), m108Max(6), m900Max(6); for(Int_t i = 0; i<6;i++) { mlowMax.at(i) = hlow.at(i)->GetMaximum(); mmidMax.at(i) = hmid.at(i)->GetMaximum(); mhighMax.at(i) = hhigh.at(i)->GetMaximum(); mcoMax.at(i) = hco.at(i)->GetMaximum(); m36Max.at(i) = h36.at(i)->GetMaximum(); m108Max.at(i) = h108.at(i)->GetMaximum(); m900Max.at(i) = h900.at(i)->GetMaximum(); } //hlow.at(0)->SetMaximum(*max_element(mlowMax.begin(),mlowMax.end())); hlow.at(0)->SetMaximum(40); hlow.at(0)->SetTitle(";Run Number;Average of 42-104 kHz Magnitude"); hlow.at(0)->Draw("P HIST"); for(Int_t i = 1; i<6; i++) hlow.at(i)->Draw("P HIST SAME"); leg->Draw(); can.Print(Form("hlow_%i-%i_%i.png",firstRun,lastRun,nEvents)); //hmid.at(0)->SetMaximum(*max_element(mmidMax.begin(),mmidMax.end())); hmid.at(0)->SetMaximum(20); hmid.at(0)->SetTitle(";Run Number;Average of 108-208 kHz Magnitude"); hmid.at(0)->Draw("P HIST"); for(Int_t i = 1; i<6; i++) hmid.at(i)->Draw("P HIST SAME"); leg->Draw(); can.Print(Form("hmid_%i-%i_%i.png",firstRun,lastRun,nEvents)); //hhigh.at(0)->SetMaximum(*max_element(mhighMax.begin(),mhighMax.end())); hhigh.at(0)->SetMaximum(3); hhigh.at(0)->SetTitle(";Run Number;Average of 667-833 kHz Magnitude"); hhigh.at(0)->Draw("P HIST"); for(Int_t i = 1; i<6; i++) hhigh.at(i)->Draw("P HIST SAME"); leg->Draw(); can.Print(Form("hhigh_%i-%i_%i.png",firstRun,lastRun,nEvents)); //hco.at(0)->SetMaximum(*max_element(mcoMax.begin(),mcoMax.end())); hco.at(0)->SetMaximum(80); hco.at(0)->SetTitle(";Run Number;Average of 10-30 kHz Magnitude"); hco.at(0)->Draw("P HIST"); for(Int_t i = 1; i<6; i++) hco.at(i)->Draw("P HIST SAME"); leg->Draw(); can.Print(Form("hco_%i-%i_%i.png",firstRun,lastRun,nEvents)); //h36.at(0)->SetMaximum(*max_element(m36Max.begin(),m36Max.end())); h36.at(0)->SetMaximum(100); h36.at(0)->SetTitle(";Run Number;Average of 36+/-0.83 kHz Magnitude"); h36.at(0)->Draw("P HIST"); for(Int_t i = 1; i<6; i++) h36.at(i)->Draw("P HIST SAME"); leg->Draw(); can.Print(Form("h36_%i-%i_%i.png",firstRun,lastRun,nEvents)); //h108.at(0)->SetMaximum(*max_element(m108Max.begin(),m108Max.end())); h108.at(0)->SetMaximum(35); h108.at(0)->SetTitle(";Run Number;Average of 108+/-0.83 kHz Magnitude"); h108.at(0)->Draw("P HIST"); for(Int_t i = 1; i<6; i++) h108.at(i)->Draw("P HIST SAME"); leg->Draw(); can.Print(Form("h108_%i-%i_%i.png",firstRun,lastRun,nEvents)); //h900.at(0)->SetMaximum(*max_element(m900Max.begin(),m900Max.end())); h900.at(0)->SetMaximum(5); h900.at(0)->SetTitle(";Run Number;Average of 900+/-42 kHz Magnitude"); h900.at(0)->Draw("P HIST"); for(Int_t i = 1; i<6; i++) h900.at(i)->Draw("P HIST SAME"); leg->Draw(); can.Print(Form("h900_%i-%i_%i.png",firstRun,lastRun,nEvents)); f.Close(); }
void plotTotDeadChannels(const char * fileName, const Int_t nEvents) { TCanvas can("can","can",1200,800); gStyle->SetOptStat(0); gStyle->SetErrorX(0.0001); string rootFileName; ifstream file(fileName); TTree *tree; TFile *f = 0; Int_t fileCount = 0; vector<TTree*> eventTrees(nEvents); vector<TFile*> eventFiles(nEvents); vector<Int_t> run(nEvents), subrun(nEvents), event(nEvents); //Save trees to eventTrees if(file.is_open()){ while(!file.eof() && fileCount<nEvents){ getline(file,rootFileName); eventFiles.at(fileCount) = TFile::Open(rootFileName.c_str(),"update"); tree = (TTree*)eventFiles.at(fileCount)->Get("RMS"); eventTrees.at(fileCount) = tree; if(eventTrees.at(fileCount)->GetEntry(0) == -1) cerr<<"Could not read TTree RMS in file "<<rootFileName.c_str()<<endl; tree = (TTree*)eventFiles.at(fileCount)->Get("Trun"); tree->Draw("runNo");tree->Draw("subRunNo");tree->Draw("eventNo"); run.at(fileCount) = tree->GetLeaf("runNo")->GetValue(); subrun.at(fileCount) = tree->GetLeaf("subRunNo")->GetValue(); event.at(fileCount) = tree->GetLeaf("eventNo")->GetValue(); eventTrees.at(fileCount)->SetDirectory(0); delete eventFiles.at(fileCount++); } file.close(); } if(fileCount != nEvents) cerr<<"Mismatch: number of events and number of input root files"<<endl; //Create and set branch addresses Double_t rms; UShort_t chid; Bool_t chstat, outlier_flag, chirping_flag; for(Int_t i = 0; i < nEvents; i++){ eventTrees.at(i)->SetBranchAddress("rms",&rms); eventTrees.at(i)->SetBranchAddress("chid",&chid); eventTrees.at(i)->SetBranchAddress("chstat",&chstat); eventTrees.at(i)->SetBranchAddress("outlier_flag",&outlier_flag); //eventTrees.at(i)->SetBranchAddress("chirping_flag",&chirping_flag); } //Declare relevant plots and parameters Int_t firstRun = *min_element(run.begin(),run.end()), lastRun = *max_element(run.begin(),run.end()); TH1F *deadChannels = new TH1F("deadChannels","Dead Channels",(lastRun-firstRun+1),firstRun,lastRun+1); Double_t norm = 0; //Fill Plots for(Int_t n = 0; n < nEvents; n++){ norm = count(run.begin(),run.end(),run.at(n)); for(Int_t c = 0; c < 8256; c++){ eventTrees.at(n)->GetEntry(c); deadChannels->Fill(run.at(n), deadChannels->GetBinContent(run.at(n))+(1-chstat)/norm); } } deadChannels->SetMarkerStyle(kFullDotMedium); deadChannels->SetTitle(";Run Number;Average Total Number of Dead Channels"); deadChannels->GetYaxis()->SetTitleOffset(1.5); deadChannels->SetMinimum(1400); deadChannels->Draw("P HIST"); can.Print(Form("totalDeadChannels_%i-%i_%i.png",firstRun,lastRun,nEvents)); }
void plotDeadChannelsTime(const char * fileName, const Int_t nEvents) { TCanvas can("can","can",1200,800); gStyle->SetOptStat(0); gStyle->SetErrorX(0.0001); gStyle->SetLegendBorderSize(0); string rootFileName; ifstream file(fileName); TTree *tree; TFile *f = 0; Int_t fileCount = 0; vector<TTree*> eventTrees(nEvents); vector<TFile*> eventFiles(nEvents); vector<Int_t> run(nEvents), subrun(nEvents), event(nEvents), eventTime(nEvents); //Save trees to eventTrees if(file.is_open()){ while(!file.eof() && fileCount<nEvents){ getline(file,rootFileName); eventFiles.at(fileCount) = TFile::Open(rootFileName.c_str(),"update"); tree = (TTree*)eventFiles.at(fileCount)->Get("RMS"); eventTrees.at(fileCount) = tree; if(eventTrees.at(fileCount)->GetEntry(0) == -1) cerr<<"Could not read TTree RMS in file "<<rootFileName.c_str()<<endl; tree = (TTree*)eventFiles.at(fileCount)->Get("Trun"); tree->Draw("runNo");tree->Draw("subRunNo");tree->Draw("eventNo");tree->Draw("eventTime"); run.at(fileCount) = tree->GetLeaf("runNo")->GetValue(); subrun.at(fileCount) = tree->GetLeaf("subRunNo")->GetValue(); event.at(fileCount) = tree->GetLeaf("eventNo")->GetValue(); eventTime.at(fileCount) = tree->GetLeaf("eventTime")->GetValue(); eventTrees.at(fileCount)->SetDirectory(0); delete eventFiles.at(fileCount++); } file.close(); } if(fileCount != nEvents) cerr<<"Mismatch: number of events and number of input root files"<<endl; //Create and set branch addresses Double_t rms; UShort_t chid; Bool_t chstat, outlier_flag, chirping_flag; for(Int_t i = 0; i < nEvents; i++){ eventTrees.at(i)->SetBranchAddress("rms",&rms); eventTrees.at(i)->SetBranchAddress("chid",&chid); eventTrees.at(i)->SetBranchAddress("chstat",&chstat); eventTrees.at(i)->SetBranchAddress("outlier_flag",&outlier_flag); //eventTrees.at(i)->SetBranchAddress("chirping_flag",&chirping_flag); } //Declare relevant plots and parameters // 2/10/16 @ 5:30 (UTC) Int_t firstRun = *min_element(run.begin(),run.end()), lastRun = *max_element(run.begin(),run.end()); Double_t firstTime = *min_element(eventTime.begin(),eventTime.end()), lastTime = *max_element(eventTime.begin(),eventTime.end()); vector<TH1F*> deadChannels(3); deadChannels.at(0) = new TH1F("deadChannelsU","Dead Channels in U Plane",(lastTime-firstTime+1),0,lastTime-firstTime+1); deadChannels.at(1) = new TH1F("deadChannelsV","Dead Channels in V Plane",(lastTime-firstTime+1),0,lastTime-firstTime+1); deadChannels.at(2) = new TH1F("deadChannelsW","Dead Channels in W Plane",(lastTime-firstTime+1),0,lastTime-firstTime+1); vector<TH1F*> deadChannelsFeb(3), deadChannelsAp(3), deadChannelsJun(3); Double_t norm = 0; //Fill Plots for(Int_t n = 0; n < nEvents; n++){ for(Int_t c = 0; c < 8256; c++){ eventTrees.at(n)->GetEntry(c); if(c < 2401) deadChannels.at(0)->Fill(eventTime.at(n)-firstTime, deadChannels.at(0)->GetBinContent(eventTime.at(n)-firstTime)+(1-chstat)/2400); if(c>2400 && c<4801) deadChannels.at(1)->Fill(eventTime.at(n)-firstTime, deadChannels.at(1)->GetBinContent(eventTime.at(n)-firstTime)+(1-chstat)/2400); if(c>4800) deadChannels.at(2)->Fill(eventTime.at(n)-firstTime, deadChannels.at(2)->GetBinContent(eventTime.at(n)-firstTime)+(1-chstat)/3456); } } deadChannels.at(0)->SetMarkerStyle(kFullDotMedium); deadChannels.at(1)->SetMarkerStyle(kFullDotMedium); deadChannels.at(2)->SetMarkerStyle(kFullDotMedium); deadChannels.at(0)->SetMarkerColor(kBlue); deadChannels.at(1)->SetMarkerColor(kRed); deadChannels.at(2)->SetMarkerColor(kCyan); deadChannels.at(0)->SetTitle(";Time Since 2-10-16 @ 5:30 (UTC);Average Proportion of Dead Channels"); deadChannels.at(0)->SetMaximum(0.5); deadChannels.at(0)->GetYaxis()->SetTitleOffset(1.5); deadChannels.at(0)->Draw("P HIST"); deadChannels.at(1)->Draw("P HIST same"); deadChannels.at(2)->Draw("P HIST same"); deadChannelsFeb.at(0) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsAp.at(0) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsJun.at(0) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsFeb.at(1) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsAp.at(1) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsJun.at(1) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsFeb.at(2) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsAp.at(2) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsJun.at(2) = (TH1F*)deadChannels.at(0)->Clone(); deadChannelsFeb.at(0)->SetFillColor(33); deadChannelsAp.at(0)->SetFillColor(33); deadChannelsJun.at(0)->SetFillColor(33); deadChannelsFeb.at(1)->SetFillColor(33); deadChannelsAp.at(1)->SetFillColor(33); deadChannelsJun.at(1)->SetFillColor(33); deadChannelsFeb.at(2)->SetFillColor(33); deadChannelsAp.at(2)->SetFillColor(33); deadChannelsJun.at(2)->SetFillColor(33); deadChannelsFeb.at(0)->GetXaxis()->SetRange(0,1456790400); deadChannelsAp.at(0)->GetXaxis()->SetRange(1459468800,1462060800); deadChannelsJun.at(0)->GetXaxis()->SetRange(1464739200,1467331200); deadChannelsFeb.at(1)->GetXaxis()->SetRange(0,1456790400); deadChannelsAp.at(1)->GetXaxis()->SetRange(1459468800,1462060800); deadChannelsJun.at(1)->GetXaxis()->SetRange(1464739200,1467331200); deadChannelsFeb.at(2)->GetXaxis()->SetRange(0,1456790400); deadChannelsAp.at(2)->GetXaxis()->SetRange(1459468800,1462060800); deadChannelsJun.at(2)->GetXaxis()->SetRange(1464739200,1467331200); deadChannelsFeb.at(0)->Draw("P HIST same"); deadChannelsFeb.at(1)->Draw("P HIST same"); deadChannelsFeb.at(2)->Draw("P HIST same"); deadChannelsAp.at(0)->Draw("P HIST same"); deadChannelsAp.at(1)->Draw("P HIST same"); deadChannelsAp.at(2)->Draw("P HIST same"); deadChannelsAp.at(0)->Draw("P HIST same"); deadChannelsAp.at(1)->Draw("P HIST same"); deadChannelsAp.at(2)->Draw("P HIST same"); TLegend *leg = new TLegend(0.7,0.7,0.89,0.89); leg->AddEntry(deadChannels.at(0),"U Plane","p"); leg->AddEntry(deadChannels.at(1),"V Plane","p"); leg->AddEntry(deadChannels.at(2),"Y Plane","p"); leg->Draw(); can.Print(Form("deadChannelsT_%i-%i_%i.png",firstRun,lastRun,nEvents)); TFile outF(Form("deadChannelsT_%i-%i_%i.root",firstRun,lastRun,nEvents),"RECREATE"); deadChannels.at(0)->Write(); deadChannels.at(1)->Write(); deadChannels.at(2)->Write(); outF.Close(); }
/// Cache MC production information void CacheTrendingProductions(TString dataType){ AliExternalInfo info; info.fLoadMetadata=kFALSE; TObjArray* periodList = NULL, *idList=NULL; // TTree * tree = info.GetTree("MonALISA.ProductionCycle","",""); Int_t nProd=tree->GetEntries(); periodList = new TObjArray(nProd); idList= new TObjArray(nProd); TLeaf *leafTag = tree->GetLeaf("Tag"); TLeaf *leafID = tree->GetLeaf("ID"); for (Int_t iProd=0; iProd<nProd; iProd++){ tree->GetEntry(iProd); TString prodName=((char*)leafTag->GetValuePointer()); TString idName =TString::Format("%d",TMath::Nint(leafID->GetValue())); if (prodName.Contains("LHC")==0) continue; periodList->AddAt(new TObjString(prodName),iProd); idList->AddAt(new TObjString(idName),iProd); } delete tree; // for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++) { TObjString * pName= (TObjString*)idList->At(iPeriod); if (pName==NULL) continue; TTree* treeP = info.GetTreeProdCycleByID(idList->At(iPeriod)->GetName()); if (treeP==NULL) continue; TLeaf *leafOutput = treeP->GetLeaf("outputdir"); Int_t nRuns= treeP->GetEntries(); treeP->GetEntry(0); TString path=((char*)leafOutput->GetValuePointer()); TObjArray *pArray = path.Tokenize("/"); if (pArray==NULL) continue; Int_t nElems=pArray->GetEntries(); if (nElems<4) continue; TString aperiod=pArray->At(3)->GetName(); TString apass =pArray->At(nElems-1)->GetName(); delete pArray; ::Info("CacheTrendingProductions","%s\t%s\t%s\t%s\t%d",idList->At(iPeriod)->GetName(),path.Data(), aperiod.Data(),apass.Data(),nRuns); delete treeP; TTree* treeQA = info.GetTree(dataType.Data(),aperiod.Data(),apass.Data()); if (treeQA){ Int_t entries=treeQA->Draw("run","1","goff"); TString sInfo=aperiod; sInfo+="\t"; sInfo+=apass; sInfo+="\t"; sInfo+=dataType; sInfo+="\t"; sInfo+=TString::Format("%d\t",entries); sInfo+=TString::Format("%d\t",nRuns); for (Int_t j=0; j<entries; j++) { sInfo+=TString::Format("%2.0f,",treeQA->GetV1()[j]); ::Info("CacheTrendingProductionsRun:","%s\t%s\t%s\t%d\t%d\t%2.0f",aperiod.Data(),apass.Data(),dataType.Data(),entries,nRuns,treeQA->GetV1()[j]); } sInfo+="0"; ::Info("CacheTrendingProductionsPeriod:","%s\n",sInfo.Data()); delete treeQA; }else{ ::Error("CacheTrendingProductionsPeriod:","%s\t%s\t%s\t-1\t%d\t0",aperiod.Data(),apass.Data(), dataType.Data(),nRuns); } } }
void Example_tags(TString topDir = "/star/rcf/GC/daq/tags") { ////////////////////////////////////////////////////////////////////////// // // // Example_tags.C // // // // shows how to use the STAR tags files // // Input: top level directory // // // // what it does: // // 1. creates TChain from all tags files down from the topDir // // 2. loops over all events in the chain // // // // owner: Alexandre V. Vaniachine <*****@*****.**> // ////////////////////////////////////////////////////////////////////////// gSystem->Load("libTable"); gSystem->Load("St_base"); // start benchmarks gBenchmark = new TBenchmark(); gBenchmark->Start("total"); // set loop optimization level gROOT->ProcessLine(".O4"); // gather all files from the same top directory into one chain // topDir must end with "/" topDir +='/'; St_FileSet dirs(topDir); St_DataSetIter next(&dirs,0); St_DataSet *set = 0; TChain chain("Tag"); while ( (set = next()) ) { if (strcmp(set->GetTitle(),"file") || !(strstr(set->GetName(),".tags.root"))) continue; chain.Add(gSystem->ConcatFileName(topDir,set->Path())); } UInt_t nEvents = chain->GetEntries(); cout<<"chained "<<nEvents<<" events "<<endl; TObjArray *files = chain.GetListOfFiles(); UInt_t nFiles = files->GetEntriesFast(); cout << "chained " << nFiles << " files from " << topDir << endl; TObjArray *leaves = chain.GetListOfLeaves(); Int_t nleaves = leaves->GetEntriesFast(); TString tableName = " "; TObjArray *tagTable = new TObjArray; Int_t tableCount = 0; Int_t *tableIndex = new Int_t[nleaves]; Int_t tagCount = 0; // decode tag table names for (Int_t l=0;l<nleaves;l++) { TLeaf *leaf = (TLeaf*)leaves->UncheckedAt(l); tagCount+=leaf->GetNdata(); TBranch *branch = leaf->GetBranch(); // new tag table name if ( strstr(branch->GetName(), tableName.Data()) == 0 ) { tableName = branch->GetName(); // the tableName is encoded in the branch Name before the "." tableName.Resize(tableName->Last('.')); tagTable->AddLast(new TObjString(tableName.Data())); tableCount++; } tableIndex[l]=tableCount-1; } cout << " tot num tables, tags = " << tableCount << " " << tagCount << endl << endl; //EXAMPLE 1: how to print out names of all tags and values for first event for (l=0;l<nleaves;l++) { leaf = (TLeaf*)leaves->UncheckedAt(l); branch = leaf->GetBranch(); branch->GetEntry(); // tag comment is in the title TString Title = leaf->GetTitle(); Int_t dim = leaf->GetNdata(); if (dim==1) { Title.ReplaceAll('['," '"); Title.ReplaceAll(']',"'"); } cout << "\n Table: "; cout.width(10); cout << ((TObjString*)tagTable->UncheckedAt(tableIndex[l]))->GetString() <<" -- has tag: " << Title << endl; for (Int_t i=0;i<dim;i++) { cout <<" "<< leaf->GetName(); if (dim>1) cout << '['<<i<<']'; cout << " = " << leaf->GetValue(i) << endl; } } // EXAMPLE 2: how to make a plot c1 = new TCanvas("c1","Beam-Gas Rejection",600,1000); gStyle->SetMarkerStyle(8); chain->Draw("n_trk_tpc[0]:n_trk_tpc[1]"); // EXAMPLE 3: how to make a selection (write selected event numbers on the plot) Int_t ncoll=0; char aevent[10]; TText t(0,0,"a"); t.SetTextFont(52); t.SetTextSize(0.02); Float_t cut = 0.35; cout <<"\n Events with ntrk>400 and |asim|<"<<cut<<endl; //loop over all events: READ ONLY n_trk_tpc AND mEventNumber BRANCHES! gBenchmark->Start("loop"); for (Int_t i=0;i<nFiles;i++) { chain.LoadTree(*(chain.GetTreeOffset()+i)); TTree *T = chain.GetTree(); //must renew leaf pointer for each tree TLeaf *ntrk = T->GetLeaf("n_trk_tpc"); TLeaf *run = T->GetLeaf("mRunNumber"); TLeaf *event = T->GetLeaf("mEventNumber"); for (Int_t j=0; j<T->GetEntries(); j++){ ntrk->GetBranch()->GetEntry(j); event->GetBranch()->GetEntry(j); run->GetBranch()->GetEntry(j); Int_t Nm=ntrk->GetValue(0); Int_t Np=ntrk->GetValue(1); Int_t Ntrk = Np+Nm; // avoid division by 0 Float_t asim = Np-Nm; if (Ntrk>0) asim /= Ntrk; if (-cut < asim&&asim < cut && Ntrk>400) { cout<<" Run "<<(UInt_t)run->GetValue() <<", Event "<<event->GetValue() <<endl; ncoll++; sprintf(aevent,"%d",event->GetValue()); t.DrawText(Np+10,Nm+10,aevent); } } } gBenchmark->Stop("loop"); t.SetTextSize(0.05); t.DrawText(50,2550,"ntrk>400 and |(Np-Nm)/(Np+Nm)| < 0.35 "); t.DrawText(500,-300,"Ntrk with tanl<0 "); cout << " Selected " << ncoll << " collision candidates out of " << nEvents << " events" << endl; // stop timer and print benchmarks gBenchmark->Print("loop"); gBenchmark->Stop("total"); gBenchmark->Print("total"); }
// analisi Bool_t CheckSingle(const char* esdFileName,Bool_t kGRID){ //inizializzo a zero ncluster (di tree T) //for (int ifc=0;ifc<10000;ifc++) ncluster[ifc]=0; // check the content of the ESD AliPIDResponse *pidr = new AliPIDResponse(); // open the ESD file TFile* esdFile = TFile::Open(esdFileName); if (!esdFile || !esdFile->IsOpen()){ Error("CheckESD", "opening ESD file %s failed", esdFileName); return kFALSE; } TString mctrkref(esdFileName); mctrkref.ReplaceAll("AliESDs.root","TrackRefs.root"); TString fgal(esdFileName); fgal.ReplaceAll("AliESDs.root","galice.root"); if(kGRID){ fgal.Insert(0,"alien://"); mctrkref.Insert(0,"alien://"); } TTree *trkref; printf("ESD = %s\n",esdFileName); TFile *ftrkref; if(isMC) ftrkref = TFile::Open(mctrkref.Data()); AliHeader *h = new AliHeader(); TFile *fgalice; if(isMC) fgalice = TFile::Open(fgal.Data()); TTree *tgalice; if(isMC){ tgalice = (TTree *) fgalice->Get("TE"); tgalice->SetBranchAddress("Header",&h); } AliRunLoader* runLoader = NULL; AliRun *gAlice; if(isMC) runLoader = AliRunLoader::Open(fgal.Data()); if(runLoader){ runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); if (!gAlice) { Error("CheckESD", "no galice object found"); return kFALSE; } runLoader->LoadKinematics(); runLoader->LoadHeader(); } AliESDEvent * esd = new AliESDEvent; // printf("esd object = %x\n",esd); TTree* tree = (TTree*) esdFile->Get("esdTree"); if (!tree){ Error("CheckESD", "no ESD tree found"); return kFALSE; } esd->ReadFromTree(tree); // crea link tra esd e tree TClonesArray* tofcl; // array dinamico TClonesArray* tofhit; TClonesArray* tofmatch; Int_t nev = tree->GetEntries(); //ogni entries evento Float_t mag; printf("nev = %i\n",nev); //azzero il contatore delle tracce del TTree T //ntracks=0; AliStack* stack=NULL; Int_t trkassociation[1000000]; for(Int_t ie=0;ie < nev;ie++){ if(runLoader){ runLoader->GetEvent(ie); // select simulated primary particles, V0s and cascades stack = runLoader->Stack(); } if(isMC) trkref = (TTree *) ftrkref->Get(Form("Event%i/TreeTR",ie)); tree->GetEvent(ie); if(isMC) tgalice->GetEvent(ie); if(isMC) interactiontime = h->GenEventHeader()->InteractionTime()*1E+12; mag = esd->GetMagneticField(); AliTOFHeader *tofh = esd->GetTOFHeader(); ntofcl = tofh->GetNumberOfTOFclusters(); esd->ConnectTracks(); // Deve essere sempre chiamato dopo aver letto l'evento (non troverebbe l'ESDevent). Scrivo in tutte le tracce l origine dell evento così poi da arrivare ovunque(tipo al cluster e al tempo quindi). //Riempio variabile del tree "T" //nevento=ie; if(! esd->GetVertex()){ esd->ResetStdContent(); continue;// una volta fatto il connect manda un flag ; siccome qua c'era un continue(non si arriva in fondo al ciclo) bisogna resettarlo altrimenti lo trova già attivo. } tofcl = esd->GetESDTOFClusters(); // AliESDTOFCluster *cltof = tofcl->At(i); if(tofcl->GetEntries() == 0){ esd->ResetStdContent(); continue; } tofhit = esd->GetESDTOFHits(); // AliESDTOFHit *hittof = tofhit->At(i); tofmatch = esd->GetESDTOFMatches(); // AliESDTOFHit *mathctof = tofmatch->At(i); // loop over tracks pidr->SetTOFResponse(esd,AliPIDResponse::kTOF_T0); //per recuperare lo start time ("esd", "tipo start time"), tipo cioè o il TOF stesso o il T0 o il best, ovvero la combinazione dei 2 Int_t ntrk = esd->GetNumberOfTracks(); //printf("%i) TPC tracks = %i -- TOF cluster = %i - TOF hit = %i -- matchable info = %i\n",ie,ntrk,tofcl->GetEntries(),tofhit->GetEntries(),tofmatch->GetEntries()); Double_t time[AliPID::kSPECIESC]; if(isMC && stack){// create association trackref printf("nMC track = %i\n",stack->GetNtrack()); for(Int_t ist=0;ist < stack->GetNtrack();ist++){ trkassociation[ist]=-1; } for(Int_t iref=0;iref < trkref->GetEntries();iref++){ trkref->GetEvent(iref); Int_t trkreference = trkref->GetLeaf("TrackReferences.fTrack")->GetValue(); if(trkreference > -1 && trkreference < 1000000){ trkassociation[trkreference] = iref; } } } for (Int_t iTrack = 0; iTrack < ntrk; iTrack++){ AliESDtrack* track = esd->GetTrack(iTrack); // select tracks of selected particles if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;//almeno un hit nell ITS if (track->GetConstrainedChi2() > 4) continue; //se brutto X^2 if ((track->GetStatus() & AliESDtrack::kTOFout) == 0) continue; //se traccia matchata con tof if(track->GetNumberOfTPCClusters() < 70) continue; Float_t p =track->P(); itrig = 0; timetrig = 0; if(p > 0.9 && p < 1.1){ track->GetIntegratedTimes(time); itrig = iTrack; timetrig = track->GetTOFsignal() - time[2]; iTrack = ntrk; } } printf("real loop, ntrk = %i\n",ntrk); for (Int_t iTrack = 0; iTrack < ntrk; iTrack++){ AliESDtrack* track = esd->GetTrack(iTrack); // select tracks of selected particles if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;//almeno un hit nell ITS if (track->GetConstrainedChi2() > 4) continue; //se brutto X^2 //if ((track->GetStatus() & AliESDtrack::kTOFout) == 0) continue; //se traccia matchata con tof if(track->GetNumberOfTPCClusters() < 70) continue; TOFout = (track->GetStatus() & AliESDtrack::kTOFout) > 0; track->GetIntegratedTimes(time); Float_t dx = track->GetTOFsignalDx(); //leggo i residui tra traccia e canale tof acceso Float_t dz = track->GetTOFsignalDz(); mism = 0; dedx = track->GetTPCsignal(); Int_t label = TMath::Abs(track->GetLabel()); if(stack){ TParticle *part=stack->Particle(label); pdg = part->GetPdgCode(); } Int_t TOFlabel[3]; track->GetTOFLabel(TOFlabel); // printf("%i %i %i %i\n",label,TOFlabel[0],TOFlabel[1],TOFlabel[2]); ChannelTOF[0] = track->GetTOFCalChannel(); // printf("geant time = %f\n",gtime); //getchar(); // if(TMath::Abs(dx) > 1.25 || TMath::Abs(dz) > 1.75) continue; // is inside the pad //riempio il numro di cludter e impulso trasverso per traccia del TTree T ncluster=track->GetNTOFclusters(); impulso_trasv=track->Pt(); impulso=track->P(); StartTime = pidr->GetTOFResponse().GetStartTime(track->P()); StartTimeRes = pidr->GetTOFResponse().GetStartTimeRes(track->P()); if(track->Pt() > 0.9 && track->Pt() < 1.5){ //impulso non troppo alto per separazione tra particelle Float_t dt = track->GetTOFsignal() - time[2] - pidr->GetTOFResponse().GetStartTime(track->P());//tempo TOF(è lo stesso di Gettime, solo che lo prendo dale tracce)(già calibrato) -ip del PI (posizione 0 e, posizione 1 mu, pos 2 PI, pos 3 K,pos 4 p) -start time Float_t dtKa = track->GetTOFsignal() - time[3] - pidr->GetTOFResponse().GetStartTime(track->P()); Float_t dtPr = track->GetTOFsignal() - time[4] - pidr->GetTOFResponse().GetStartTime(track->P()); hdt->Fill(dt); hdtKa->Fill(dtKa); hdtPr->Fill(dtPr); } charge = track->Charge(); phi = track->Phi(); eta = track->Eta(); GetPositionAtTOF(track,mag,coord); phiExt = TMath::ATan2(coord[1],coord[0]); etaExt = -TMath::Log(TMath::Tan(0.5*TMath::ATan2(sqrt(coord[0]*coord[0]+coord[1]*coord[1]),coord[2]))); for (int i=0;i<(track->GetNTOFclusters());i++){ int idummy=track->GetTOFclusterArray()[i]; AliESDTOFCluster *cl = (AliESDTOFCluster *) tofcl->At(idummy); tempo[i]=cl->GetTime(); tot[i]=cl->GetTOT(); ChannelTOF[i]=cl->GetTOFchannel(); if(i==0){ GetResolutionAtTOF(track,mag,ChannelTOF[i],res); } for(int im=cl->GetNMatchableTracks();im--;){ //o così o da n-1 a 0 //for(int im=cl->GetNMatchableTracks();im>0;im--) non andava bene perchè non prendeva mai lo 0 // if(track->GetNTOFclusters()==2) printf("-- %i) %f %f\n",im,cl->GetLength(im),cl->GetIntegratedTime(2,im)); if(cl->GetTrackIndex(im) == track->GetID()){ exp_time_el[i] = cl->GetIntegratedTime(0,im); // pi = 2 exp_time_mu[i] = cl->GetIntegratedTime(1,im); // pi = 2 exp_time_pi[i] = cl->GetIntegratedTime(2,im); // pi = 2 exp_time_ka[i] = cl->GetIntegratedTime(3,im); // pi = 2 exp_time_pr[i] = cl->GetIntegratedTime(4,im); // pi = 2 L[i] = cl->GetLength(im); // if(track->GetNTOFclusters()==2)printf("%i) %f %f\n",i,L[i],exp_time_pi[i]); DeltaX[i]=cl->GetDx(im); // mettendolo dentro questo if dovrei prendere i residui di una stessa traccia DeltaZ[i]=cl->GetDz(im); } } } //ReMatch(); Int_t jref=0; if(isMC){ if(TOFlabel[0] > -1 && TOFlabel[0] < 1000000){ trkref->GetEvent(trkassociation[TOFlabel[0]]); if(TOFlabel[0] == trkref->GetLeaf("TrackReferences.fTrack")->GetValue()){ // printf("trk -> %i (%i)\n",trkref->GetLeaf("TrackReferences.fTrack")->GetValue(),trkref->GetLeaf("TrackReferences.fTrack")->GetValue(jref)); while(jref > -1 && trkref->GetLeaf("TrackReferences.fTrack")->GetValue(jref) != 0){ //printf("det = %i\n",trkref->GetLeaf("TrackReferences.fDetectorId")->GetValue(jref)); if(trkref->GetLeaf("TrackReferences.fDetectorId")->GetValue(jref) == 4){ gtime=trkref->GetLeaf("TrackReferences.fTime")->GetValue(jref)*1E+12; xgl = trkref->GetLeaf("TrackReferences.fX")->GetValue(jref); ygl = trkref->GetLeaf("TrackReferences.fY")->GetValue(jref); zgl = trkref->GetLeaf("TrackReferences.fZ")->GetValue(jref); MakeTrueRes(); jref = 100; } jref++; } } } } if(TMath::Abs(label) != TOFlabel[0] && stack){ mism=2; while(TOFlabel[0] != -1 && TOFlabel[0] != label){ TOFlabel[0] = stack->Particle(TOFlabel[0])->GetMother(0); } if(label == TOFlabel[0]) mism=1; } //AddDelay(); T->Fill(); //cout<<"riempio il tree "<<endl; //Riempio tree "T" //incremento il contatore delle tracce del TTree T matchate e che superano i tagli //ntracks++; }//end of for(tracks) esd->ResetStdContent(); } //end of for(events) if(runLoader){ runLoader->UnloadHeader(); runLoader->UnloadKinematics(); delete runLoader; } esdFile->Close(); if(isMC) ftrkref->Close(); if(isMC) fgalice->Close(); }
int macroanalysis(char* filename) { // char* filename = "combined.root"; // Read in the file TFile* f = new TFile(filename); // TDirectory* hists = f->GetDirectory("hists;1"); // TDirectory* tuples = f->GetDirectory("tuples;1"); TTree* accum = (TTree*) f->GetObjectUnchecked("AccumulatedEnergy;1"); TLeaf* einit = (TLeaf*) accum->GetLeaf("Einit"); TLeaf* edepo = (TLeaf*) accum->GetLeaf("Edep"); TTree* edeps = (TTree*) f->GetObjectUnchecked("EnergyDepositions;1"); TLeaf* individualdepos = (TLeaf*) edeps->GetLeaf("Edep"); TTree* secs = (TTree*) f->GetObjectUnchecked("SecondarySpectrum;1"); TLeaf* secsenergy = (TLeaf*) secs->GetLeaf("KineticEnergy"); double ein = 0; double eout = 0; int nevents = accum->GetEntries(); for (int ii = 0; ii<nevents; ii++) { accum->GetEntry(ii); ein+=einit->GetValue(); eout+=edepo->GetValue(); } int ndepos = edeps->GetEntries(); double deposum = 0; for (int ii = 0; ii<ndepos; ii++) { edeps->GetEntry(ii); deposum+=individualdepos->GetValue(); } int nsecs = secs->GetEntries(); double secsum = 0; for (int ii = 0; ii<nsecs; ii++) { secs->GetEntry(ii); secsum+=secsenergy->GetValue(); } cout << "Making Summary\n"; FILE* summary = fopen("macro_summ.txt", "a+"); time_t t = time(NULL); char* c_time_string = std::ctime(&t); char mytime[20]; std::strncpy(mytime, c_time_string, 19); mytime[ std::strlen(mytime) - 1 ] = '\0'; std::fprintf(summary, "%s,%s,%i,%e,%e,%i,%e,%i,%e\n", mytime, filename, nevents, ein, eout, ndepos, deposum, nsecs, secsum); fclose(summary); cout << "Making Histogram\n"; nevents = secs->GetEntries(); TH1F* secondarieslow = new TH1F("secondarieslow", "Secondary Electrons <1 keV", 900, 0.000100, 0.001000); TH1F* secondariesmid = new TH1F("secondariesmid", "Secondary Electrons 1<E<10 keV", 900, 0.001, 0.010); TH1F* secondarieshigh = new TH1F("secondarieshigh", "Secondary Electrons 10<E<100 keV", 900, 0.010, 0.100); TH1F* secondariesveryhigh = new TH1F("secondariesveryhigh", "Secondary Electrons 100keV<E<3 MeV", 2902, 0.100, 3.002); for (int ii = 0; ii<nevents; ii++) { secs->GetEntry(ii); double en = secsenergy->GetValue(); if (en < 0.001) secondarieslow->Fill(en, 1); else if (en < 0.01) secondariesmid->Fill(en, 0.1); else if (en < 0.1) secondarieshigh->Fill(en, 0.01); else secondariesveryhigh->Fill(en, 0.001); } char suffix[] = ".secondaryhisto"; cout << "Making Filenames\n"; char* outfilename = (char*) malloc(std::strlen(filename) + std::strlen(suffix) + 1); std::strcpy(outfilename, filename); std::strcat(outfilename, suffix); std::printf("Saving Histogram: %s \n", outfilename); h12ascii(secondarieslow, secondariesmid, secondarieshigh, secondariesveryhigh, outfilename); return 0; }
void merge(char* prefix,char* mergePrefix,Int_t skip1, Int_t skip2, Int_t skipcalo) { TFile *fgp1 = new TFile(Form("%s_1.root",prefix),"read"); TFile *fgp2 = new TFile(Form("%s_2.root",prefix),"read"); TFile *fcalo = new TFile(Form("%s_calo.root",prefix),"read"); TFile *fmerge = new TFile(Form("%s.root",mergePrefix),"recreate"); TTree *tmerge = new TTree("data","data"); TTree *tgp1 = fgp1->Get("gridpix"); TTree *tgp2 = fgp2->Get("gridpix"); TTree *tcalo = fcalo->Get("calo"); unsigned short x1[512*256],y1[512*256],z1[512*256],x2[512*256],y2[512*256],z2[512*256]; unsigned int hits1,hits2,time1,time2,timecalo; int len = tcalo->GetLeaf("calo_data")->GetLen(); cout << "len" << len << endl; //unsigned short *calo_data = new unsigned short[len]; unsigned short calo_data[1602]; tgp1->SetBranchAddress("hits",&hits1); tgp1->SetBranchAddress("x",x1); tgp1->SetBranchAddress("y",y1); tgp1->SetBranchAddress("z",z1); tgp1->SetBranchAddress("time",&time1); tgp2->SetBranchAddress("hits",&hits2); tgp2->SetBranchAddress("x",x2); tgp2->SetBranchAddress("y",y2); tgp2->SetBranchAddress("z",z2); tgp2->SetBranchAddress("time",&time2); tcalo->SetBranchAddress("calo_data",calo_data); tcalo->SetBranchAddress("time",&timecalo); tmerge->Branch("cam1_hits",&hits1,"cam1_hits/i"); tmerge->Branch("cam1_x",&x1,"cam1_x[cam1_hits]/s"); tmerge->Branch("cam1_y",&y1,"cam1_y[cam1_hits]/s"); tmerge->Branch("cam1_z",&z1,"cam1_z[cam1_hits]/s"); tmerge->Branch("cam1_time",&time1,"cam1_time/i"); tmerge->Branch("cam2_hits",&hits2,"cam2_hits/i"); tmerge->Branch("cam2_x",&x2,"cam2_x[cam2_hits]/s"); tmerge->Branch("cam2_y",&y2,"cam2_y[cam2_hits]/s"); tmerge->Branch("cam2_z",&z2,"cam2_z[cam2_hits]/s"); tmerge->Branch("cam2_time",&time2,"cam2_time/i"); tmerge->Branch("calo_data",&calo_data,Form("calo_data[%i]/s",len)); tmerge->Branch("calo_time",&timecalo,"calo_time/i"); Int_t ev1 = tgp1->GetEntries()-skip1; Int_t ev2 = tgp2->GetEntries()-skip2; Int_t evcalo = tcalo->GetEntries()-skipcalo; for (Int_t i=0;i<min3(ev1,ev2,evcalo);i++){ tgp1->GetEntry(i+skip1); tgp2->GetEntry(i+skip2); tcalo->GetEntry(i+skipcalo); tmerge->Fill(); // cout << i << endl; } fgp1->Close(); fgp2->Close(); fcalo->Close(); fmerge->Write(); fmerge->Close(); }
void DalitzplotXi1820_reco_withoutFits(){ //*** Data input TString inputFile = "/home/ikp1/puetz/panda/mysimulations/analysis/cascade_1820_lambda0_K/branching/spin_3half/output_ana.root"; TFile * data = new TFile(inputFile, "READ"); TString outPath = "/home/ikp1/puetz/panda/mysimulations/analysis/cascade_1820_lambda0_K/best/plots"; // TFile * out = new TFile(outPath+"/root-files/Dalitzplot_reco.root", "RECREATE"); TTree * xi = (TTree*) data->Get("ntpXiPlus"); TTree * xi1820 = (TTree*) data->Get("ntpXiMinus1820"); int nevents = xi1820->GetEntriesFast(); TH2D * dalitz_Xilk = new TH2D("dalitz_Xilk", "Dalitz plot for reco; m^{2}(#Lambda^{0},K^{-})/GeV^{2}/c^{4}; m^{2}(#bar{#Xi}, K^{-})/GeV^{2}/c^{4}", 150,2.5,3.8,150,3.2,4.6); gStyle->SetOptStat(0); TLorentzVector lXi, lk, lla ; TLorentzVector PXiK, PlaK, PXil; for (int n=0; n<10000; n++){ xi1820->GetEntry(n); double Ek = xi1820->GetLeaf("XiMinus_d1e")->GetValue(0); double Ela = xi1820->GetLeaf("XiMinus_d0e")->GetValue(0); double Pyk = xi1820->GetLeaf("XiMinus_d1py")->GetValue(0); double Pyla = xi1820->GetLeaf("XiMinus_d0py")->GetValue(0); double Pzk = xi1820->GetLeaf("XiMinus_d1pz")->GetValue(0); double Pzla = xi1820->GetLeaf("XiMinus_d0pz")->GetValue(0); double Pxk = xi1820->GetLeaf("XiMinus_d1px")->GetValue(0); double Pxla = xi1820->GetLeaf("XiMinus_d0px")->GetValue(0); xi->GetEntry(n); double Eaxi = xi ->GetLeaf("xiplus_e")->GetValue(0); double Pxaxi = xi->GetLeaf("xiplus_px")->GetValue(0); double Pyaxi = xi->GetLeaf("xiplus_py")->GetValue(0); double Pzaxi = xi->GetLeaf("xiplus_pz")->GetValue(0); lXi.SetPxPyPzE(Pxaxi, Pyaxi, Pzaxi, Eaxi); lk.SetPxPyPzE(Pxk, Pyk, Pzk, Ek); lla.SetPxPyPzE(Pxla, Pyla, Pzla, Ela); PXiK = lXi + lk; PlaK = lla + lk; PXil = lXi + lla; dalitz_Xilk->Fill(PlaK.M2(),PXiK.M2()); } // out->cd(); // // dalitz_Xilk->Write(); // // out->Save(); // // TCanvas * c = new TCanvas("c", "Dalitz plot PHSP model", 0,0,1500,1000); // dalitz_Xilk->GetZaxis()->SetRangeUser(0,40); dalitz_Xilk->Draw("COLZ"); // // //****write histograms // c->Print(outPath+"/png-files/Dalitzplots.png"); }
/** @ingroup FMD_xsec_script @param scale @param filename @param var @param medName @param thick @param pdgName */ void DrawXsection(Bool_t scale=kFALSE, const char* filename="xsec.root", const char* var="LOSS", const char* medName="FMD_Si$", Double_t thick=.03, const char* pdgName="pi+") { TFile* file = TFile::Open(filename, "READ"); TTree* tree = static_cast<TTree*>(file->Get(Form("%s_%s",medName, pdgName))); TLeaf* tb = tree->GetLeaf("T"); TLeaf* vb = tree->GetLeaf(var); if (!vb) { std::cerr << "Leaf " << var << " not found" << std::endl; return; } Float_t tkine, value; tb->SetAddress(&tkine); vb->SetAddress(&value); Int_t n = tree->GetEntries(); Float_t xscale = 1; Float_t yscale = 1; if (scale) { TDatabasePDG* pdgDb = TDatabasePDG::Instance(); TParticlePDG* pdgP = pdgDb->GetParticle(pdgName); if (!pdgP) { std::cerr << "Couldn't find particle " << pdgName << std::endl; return; } Double_t m = pdgP->Mass(); Double_t q = pdgP->Charge() / 3; if (m == 0 || q == 0) { std::cerr << "Mass is 0" << std::endl; return; } xscale = 1 / m; yscale = 1 / (q * q); } TGraphErrors* graph = new TGraphErrors(n); for (Int_t i = 0; i < n; i++) { tree->GetEntry(i); Double_t x = tkine*xscale; Double_t y = value*yscale; graph->SetPoint(i, x, y); // 5 sigma graph->SetPointError(i, 0, 5 * .1 * y); } TCanvas* c = new TCanvas("c","c"); c->SetLogx(); c->SetLogy(); graph->SetLineWidth(2); graph->SetFillStyle(3001); graph->SetFillColor(6); graph->Draw("L"); graph->DrawClone("AL3"); c->Modified(); c->Update(); c->cd(); c->SaveAs("xsec.C"); }
void analyze(Int_t step){ // TOF propagation factors (TOF efficiencies) fEfficiencyPiTOF = new TF1("fEfficiencyPiTOF","(x > 0.3)*0.7",0,10); fEfficiencyKaTOF = new TF1("fEfficiencyKaTOF","(x > 0.3)*(x-0.3)*(x<1) + (x>1)*0.7",0,10); fEfficiencyPrTOF = new TF1("fEfficiencyPrTOF","(x > 0.3)*(x-0.3)*(x<1) + (x>1)*0.7",0,10); // teoretical separation (perfect if equal to the one simualted in sim.C) fseparation = new TF1("f","[0]+[1]/x",0,100); fseparation->SetParameter(0,0.); fseparation->SetParameter(1,7.); fseparationPiKa = new TF1("fPiKa","[0]+[1]/TMath::Power(x,2.5)",0,100); fseparationPiKa->SetParameter(0,2.34); fseparationPiKa->SetParameter(1,10); fseparationKaPr = new TF1("fKaPr","[0]+[1]/TMath::Power(x,2.5)",0,100); fseparationKaPr->SetParameter(0,1); fseparationKaPr->SetParameter(1,56); // x=p, y=pt/p (normalized at the number of sigma assuming 80 ps resolution) fTOFpi = new TF2("fTOFpi","3.7/y*(sqrt(x*x+0.0193210)/x-1)*37.47405725",0.3,10,0.5,1); fTOFka = new TF2("fTOFka","3.7/y*(sqrt(x*x+0.243049)/x-1)*37.47405725",0.3,10,0.5,1); fTOFpr = new TF2("fTOFpr","3.7/y*(sqrt(x*x+0.879844)/x-1)*37.47405725",0.3,10,0.5,1); // x=p, already normalized in number of sigma (sigma assumed 3.5=7% of the MIP) fTPCpi = new TF1("fTPCpi",BetheBlochAleph,0,10,6); fTPCpi->SetParameter(0,fKp1); fTPCpi->SetParameter(1,fKp2); fTPCpi->SetParameter(2,fKp3); fTPCpi->SetParameter(3,fKp4); fTPCpi->SetParameter(4,fKp5); fTPCpi->SetParameter(5,0.139); fTPCka = new TF1("fTPCka",BetheBlochAleph,0,10,6); fTPCka->SetParameter(0,fKp1); fTPCka->SetParameter(1,fKp2); fTPCka->SetParameter(2,fKp3); fTPCka->SetParameter(3,fKp4); fTPCka->SetParameter(4,fKp5); fTPCka->SetParameter(5,0.493); fTPCpr = new TF1("fTPCpr",BetheBlochAleph,0,10,6); fTPCpr->SetParameter(0,fKp1); fTPCpr->SetParameter(1,fKp2); fTPCpr->SetParameter(2,fKp3); fTPCpr->SetParameter(3,fKp4); fTPCpr->SetParameter(4,fKp5); fTPCpr->SetParameter(5,0.938); Float_t width = 1.0; addshift =0; invwidth = 1./width; Float_t widthTOF = 1.0; addshiftTOF =0; invwidthTOF = 1./widthTOF; TH1D *priorsPt[6]; TH1D *newpriorsPt[6]; TH1D *truePt[6]; TH1D *allPtPos = new TH1D("allPtP","All positive;p_{T} (GeV/#it{c});N",100,0,10); TH1D *allPtNeg = new TH1D("allPtN","All negative;p_{T} (GeV/#it{c});N",100,0,10); TH3D *priorsKs[3][3]; TH3D *newpriorsKs[3][3]; TH3D *truePidKs[3][3]; TH3D *trueKs; TH2D *priorsPhi[3][3]; TH2D *newpriorsPhi[3][3]; TH2D *truePidPhi[3][3]; TH2D *truePhi; TH3D *priorsLc[3][3][3]; TH3D *newpriorsLc[3][3][3]; TH3D *truePidLc[3][3][3]; TH3D *trueLc,*mypidLc; TH3D *priorsLcbar[3][3][3]; TH3D *newpriorsLcbar[3][3][3]; TH3D *truePidLcbar[3][3][3]; TH3D *trueLcbar,*mypidLcbar; Int_t nbinPtFrKa = 8; Int_t nbinPtFrPi = 8; Int_t nbinY = 1; Int_t nbinpol=nbinPtFrKa*nbinPtFrPi*nbinY; Double_t normbin = 1./nbinpol; Int_t nbinmlc = 100; Int_t nbinptlc = 10; const char *spec[3] = {"Pi","Ka","Pr"}; if(step==0){ priorsPt[0] = new TH1D("oldpriorsPtPiP","Pion (+) priors;p_{T} (GeV/#it{c});N",100,0,10); for(Int_t i=1;i<=100;i++) priorsPt[0]->SetBinContent(i,1); priorsPt[1] = new TH1D("oldpriorsPtKaP","Kaon (+) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[2] = new TH1D("oldpriorsPtPrP","Proton (+) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[3] = new TH1D("oldpriorsPtPiM","Pion (-) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[4] = new TH1D("oldpriorsPtKaM","Kaon (-) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[5] = new TH1D("oldpriorsPtPrM","Proton (-) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[1]->Add(priorsPt[0]); priorsPt[2]->Add(priorsPt[0]); priorsPt[3]->Add(priorsPt[0]); priorsPt[4]->Add(priorsPt[0]); priorsPt[5]->Add(priorsPt[0]); // Ks and phi priors for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ priorsKs[i][j] = new TH3D(Form("oldpriorsKs%s%s",spec[i],spec[j]),Form("K^{0*} priors for %s-%s;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); priorsPhi[i][j] = new TH2D(Form("oldpriorsPhi%s%s",spec[i],spec[j]),Form("#phi priors for %s-%s;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),100,0.98,1.05,40,0,10); if(i==0 && j==0){ for(Int_t ibx=1;ibx<=200;ibx++) for(Int_t iby=1;iby<=40;iby++){ for(Int_t ibz=1;ibz <= nbinpol;ibz++) priorsKs[i][j]->SetBinContent(ibx,iby,ibz,1); priorsPhi[i][j]->SetBinContent(ibx,iby,1); } } else{ priorsKs[i][j]->Add(priorsKs[0][0]); priorsPhi[i][j]->Add(priorsPhi[0][0]); } for(Int_t k=0; k< 3;k++){ priorsLc[i][j][k] = new TH3D(Form("oldpriorsLc%s%s%s",spec[i],spec[j],spec[k]),Form("#Lambda_{c}^{+} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); priorsLcbar[i][j][k] = new TH3D(Form("oldpriorsLcbar%s%s%s",spec[i],spec[j],spec[k]),Form("#overline{#Lambda}_{c}^{-} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); if(i==0 && j==0 && k==0){ for(Int_t ibx=1;ibx<=nbinmlc;ibx++) for(Int_t iby=1;iby<=nbinptlc;iby++){ for(Int_t ibz=1;ibz <= nbinpol;ibz++){ priorsLc[i][j][k]->SetBinContent(ibx,iby,ibz,1); priorsLcbar[i][j][k]->SetBinContent(ibx,iby,ibz,1); } } } else{ priorsLc[i][j][k]->Add(priorsLc[0][0][0]); priorsLcbar[i][j][k]->Add(priorsLc[0][0][0]); } } } } } else{ TFile *fin = new TFile(Form("step%i.root",step)); priorsPt[0] = (TH1D *) fin->Get("priorsPtPiP"); priorsPt[0]->SetName("oldpriorsPtPiP"); priorsPt[1] = (TH1D *) fin->Get("priorsPtKaP"); priorsPt[1]->SetName("oldpriorsPtPiP"); priorsPt[2] = (TH1D *) fin->Get("priorsPtPrP"); priorsPt[2]->SetName("oldpriorsPtPiP"); priorsPt[3] = (TH1D *) fin->Get("priorsPtPiM"); priorsPt[3]->SetName("oldpriorsPtPiM"); priorsPt[4] = (TH1D *) fin->Get("priorsPtKaM"); priorsPt[4]->SetName("oldpriorsPtKaM"); priorsPt[5] = (TH1D *) fin->Get("priorsPtPrM"); priorsPt[5]->SetName("oldpriorsPtPrM"); // Ks and phi priors for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ priorsKs[i][j] = (TH3D *) fin->Get(Form("priorsKs%s%s",spec[i],spec[j])); priorsKs[i][j]->SetName(Form("oldpriorsKs%s%s",spec[i],spec[j])); priorsPhi[i][j] = (TH2D *) fin->Get(Form("priorsPhi%s%s",spec[i],spec[j])); priorsPhi[i][j]->SetName(Form("oldpriorsPhi%s%s",spec[i],spec[j])); for(Int_t k=0; k< 3;k++){ priorsLc[i][j][k] = (TH3D *) fin->Get(Form("priorsLc%s%s%s",spec[i],spec[j],spec[k])); priorsLc[i][j][k]->SetName(Form("oldpriorsLc%s%s%s",spec[i],spec[j],spec[k])); priorsLcbar[i][j][k] = (TH3D *) fin->Get(Form("priorsLcbar%s%s%s",spec[i],spec[j],spec[k])); priorsLcbar[i][j][k]->SetName(Form("oldpriorsLcbar%s%s%s",spec[i],spec[j],spec[k])); } } } } newpriorsPt[0] = new TH1D("priorsPtPiP","Pion (+) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[1] = new TH1D("priorsPtKaP","Kaon (+) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[2] = new TH1D("priorsPtPrP","Proton (+) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[3] = new TH1D("priorsPtPiM","Pion (-) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[4] = new TH1D("priorsPtKaM","Kaon (-) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[5] = new TH1D("priorsPtPrM","Proton (-) priors;p_{T} (GeV/#it{c});N",100,0,10); // Ks and phi priors distributions for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ newpriorsKs[i][j] = new TH3D(Form("priorsKs%s%s",spec[i],spec[j]),Form("K^{0*} priors for %s-%s;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); newpriorsPhi[i][j] = new TH2D(Form("priorsPhi%s%s",spec[i],spec[j]),Form("#phi priors for %s-%s;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),100,0.98,1.05,40,0,10); for(Int_t k=0; k< 3;k++){ newpriorsLc[i][j][k] = new TH3D(Form("priorsLc%s%s%s",spec[i],spec[j],spec[k]),Form("#Lambda_{c}^{+} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); newpriorsLcbar[i][j][k] = new TH3D(Form("priorsLcbar%s%s%s",spec[i],spec[j],spec[k]),Form("#overline{#Lambda}_{c}^{-} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); } } } truePt[0] = new TH1D("truePtPiP","Pion (+) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[1] = new TH1D("truePtKaP","Kaon (+) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[2] = new TH1D("truePtPrP","Proton (+) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[3] = new TH1D("truePtPiM","Pion (-) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[4] = new TH1D("truePtKaM","Kaon (-) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[5] = new TH1D("truePtPrM","Proton (-) truth;p_{T} (GeV/#it{c});N",100,0,10); // Ks and phi truePid distributions for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ truePidKs[i][j] = new TH3D(Form("truePidKs%s%s",spec[i],spec[j]),Form("K^{0*} truePid for %s-%s;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); truePidPhi[i][j] = new TH2D(Form("truePidPhi%s%s",spec[i],spec[j]),Form("#phi truePid for %s-%s;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),100,0.98,1.05,40,0,10); for(Int_t k=0; k< 3;k++){ truePidLc[i][j][k] = new TH3D(Form("truePidLc%s%s%s",spec[i],spec[j],spec[k]),Form("#Lambda_{c}^{+} truePid for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); truePidLcbar[i][j][k] = new TH3D(Form("truePidLcbar%s%s%s",spec[i],spec[j],spec[k]),Form("#overline{#Lambda}_{c}^{-} truePid for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); } } } trueKs = new TH3D(Form("trueKs"),Form("K^{0*} true;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); truePhi = new TH2D(Form("truePhi"),Form("#phi true;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),100,0.98,1.05,40,0,10); trueLc = new TH3D(Form("trueLc"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); trueLcbar = new TH3D(Form("trueLcbar"),Form("#overline{#Lambda}_{c}^{-} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1); mypidLc = new TH3D(Form("mypidLc"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); mypidLcbar = new TH3D(Form("mypidLcbar"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); // define particle types (particle type array) particle::AddParticleType("pi+",0.139,1); // 0 particle::AddParticleType("pi-",0.139,-1); // 1 particle::AddParticleType("K+",0.493,1); // 2 particle::AddParticleType("K-",0.493,-1); // 3 particle::AddParticleType("p+",0.938,1); // 4 particle::AddParticleType("p-",0.938,-1); // 5 particle::AddParticleType("K0*",0.896,0,5.05e-02); // 6 particle::AddParticleType("K0bar*",0.896,0,5.05e-02); // 7 particle::AddParticleType("Phi",1.02,0,0.00426); // 8 particle::AddParticleType("Delta++",1.232,2,0.118); // 9 particle::AddParticleType("Delta--",1.232,-2,0.118); // 10 particle::AddParticleType("Lambdac+",2.28646,1,0.008); // 11 particle::AddParticleType("Lambdacbar-",2.28646,-1,0.008); // 12 particle::AddParticleType("Lambda1520",1.5195,-1,0.0000156); // 12 particle d1("pi+"); particle d2("K+"); particle d3("p+"); particle d4("pi-"); particle d5("K-"); particle d6("p-"); particle prong1; particle prong2; particle prong3; particle polarKs("K0*"); particle polarLc("Lambdac+"); Int_t charge[] = {1,-1,1,-1,1,-1,0,0,0,2,-2,1,-1}; particle ppos[20000]; particle pneg[20000]; Float_t weightsPos[20000][3]; Float_t weightsNeg[20000][3]; Int_t passMyPIDPos[20000][3]; Int_t passMyPIDNeg[20000][3]; Int_t npos=0; Int_t nneg=0; Float_t signal,signalTOF,signalTPC,pt,pz,phi,ptComb,ptComb3prong,invmass; Float_t ptd,pzd,phid; Float_t priors[3],prob[3]; Float_t priors2[3][3],prob2[3][3]; Float_t priors3[3][3][3],prob3[3][3][3]; Int_t iev=-1,id,mother; Int_t cev; TFile *fout = new TFile(Form("step%i.root",step+1),"RECREATE"); // TTree *treeKs = new TTree("treeKs","treeKs"); // Float_t ptPair,massPair,ptD1,ptD2,weightD1[3],weightD2[3],weightFill; // Int_t isTrue,isTruePid; // treeKs->Branch("ptPair",&ptPair,"ptPair/F"); // treeKs->Branch("massPair",&massPair,"massPair/F"); // treeKs->Branch("ptPi",&ptD1,"ptPi/F"); // treeKs->Branch("ptKa",&ptD2,"ptKa/F"); // treeKs->Branch("weightPi",weightD1,"wightPi[3]/F"); // treeKs->Branch("weightKa",weightD2,"wightKa[3]/F"); // treeKs->Branch("weightFill",&weightFill,"wightFill/F"); // treeKs->Branch("isTruePid",&isTruePid,"isTruePid/I"); // treeKs->Branch("isTrue",&isTrue,"isTrue/I"); TH1F *hcentr = new TH1F("hcentr","",100,0,100); FILE *flist = fopen("lista","r"); char namefile[100]; Float_t weight1[3],weight2[3],weight3[3]; Float_t ptPi,ptKa,ptPr; TH1F *htemp; while(fscanf(flist,"%s",namefile)==1){ TFile *fin = new TFile(namefile); printf("file = %s\n",namefile); TList *l = (TList *) fin->Get("TOFpid"); htemp = (TH1F *) l->At(0); if(!hcentr) hcentr = new TH1F(*htemp); else hcentr->Add(htemp); TTree *t = (TTree *) l->At(1); Int_t n = t->GetEntries(); for(Int_t i=0;i < n;i++){ t->GetEvent(i); ptPi = t->GetLeaf("ptPi")->GetValue(); ptKa = t->GetLeaf("ptPi")->GetValue(); ptPr = t->GetLeaf("ptPi")->GetValue(); pt = t->GetLeaf("pt")->GetValue(); invmass = t->GetLeaf("mass")->GetValue(); weight1[0] = t->GetLeaf("weightPi")->GetValue(0); weight1[1] = t->GetLeaf("weightPi")->GetValue(1); weight1[2] = t->GetLeaf("weightPi")->GetValue(2); weight2[0] = t->GetLeaf("weightKa")->GetValue(0); weight2[1] = t->GetLeaf("weightKa")->GetValue(1); weight2[2] = t->GetLeaf("weightKa")->GetValue(2); weight3[0] = t->GetLeaf("weightPr")->GetValue(0); weight3[1] = t->GetLeaf("weightPr")->GetValue(1); weight3[2] = t->GetLeaf("weightPr")->GetValue(2); Float_t pt1 = Int_t(ptPi/(ptPi+ptKa+ptPr)*nbinPtFrPi); Float_t pt2 = Int_t(ptKa/(ptPi+ptKa+ptPr)*nbinPtFrKa); Float_t polar = 0;//TMath::Abs(polarLc.GetY());//ptComb3prong/ptot;//(pt2*nbinpol + pt1)*invpollc; polar = ((pt1*nbinPtFrKa + pt2 + polar)*nbinY)*normbin; Int_t ibinx = priorsLc[0][0][0]->GetXaxis()->FindBin(invmass); Int_t ibiny = priorsLc[0][0][0]->GetYaxis()->FindBin(pt); Int_t ibinz = priorsLc[0][0][0]->GetZaxis()->FindBin(polar); for(Int_t ipr=0;ipr<3;ipr++) for(Int_t jpr=0;jpr<3;jpr++) for(Int_t kpr=0;kpr<3;kpr++) priors3[ipr][jpr][kpr] = priorsLc[ipr][jpr][kpr]->GetBinContent(ibinx,ibiny,ibinz); GetProb3(weight1,weight2,weight3,priors3,prob3); for(Int_t ipr=0;ipr<3;ipr++) for(Int_t jpr=0;jpr<3;jpr++) for(Int_t kpr=0;kpr<3;kpr++){ newpriorsLc[ipr][jpr][kpr]->Fill(invmass,pt,polar,prob3[ipr][jpr][kpr]); } } t->Delete(); fin->Close(); } printf("Write output\n"); fout->cd(); hcentr->Write(); //if(step==0) treeKs->Write(); for(Int_t i=0;i<6;i++){ newpriorsPt[i]->Write(); truePt[i]->Write(); } for(Int_t i=0;i<3;i++){ for(Int_t j=0;j<3;j++){ priorsPhi[i][j]->Write(); newpriorsKs[i][j]->Write(); newpriorsPhi[i][j]->Write(); truePidKs[i][j]->Write(); truePidPhi[i][j]->Write(); for(Int_t k=0;k<3;k++){ newpriorsLc[i][j][k]->Write(); truePidLc[i][j][k]->Write(); newpriorsLcbar[i][j][k]->Write(); truePidLcbar[i][j][k]->Write(); } } } trueKs->Write(); truePhi->Write(); trueLc->Write(); trueLcbar->Write(); mypidLc->Write(); mypidLcbar->Write(); fout->Close(); }
Float_t doCoinc(const char *fileIn="coincCERN_0102n.root",TCanvas *cout=NULL,Float_t &rate,Float_t &rateErr){ // Print settings printf("SETTINGS\nAnalyze output from new Analyzer\n"); printf("Input file = %s\n",fileIn); printf("School distance = %f m, angle = %f deg\n",distance,angle); printf("School orientation: tel1=%f deg, tel2=%f deg\n",phi1Corr,phi2Corr); printf("Max Chi2 = %f\n",maxchisquare); printf("Theta Rel Range = %f - %f deg\n",minthetarel,maxthetarel); printf("Range for N sattellite in each run = (tel1) %f - %f, (tel2) %f - %f \n",minAvSat[0],maxAvSat[0],minAvSat[1],maxAvSat[1]); printf("Min N satellite in a single event = %i\n",satEventThr); Int_t adayMin = (yearRange[0]-2014) * 1000 + monthRange[0]*50 + dayRange[0]; Int_t adayMax = (yearRange[1]-2014) * 1000 + monthRange[1]*50 + dayRange[1]; Float_t nsigPeak=0; Float_t nbackPeak=0; angle *= TMath::DegToRad(); // define some histos TH1F *hDeltaTheta = new TH1F("hDeltaTheta","#Delta#theta below the peak (500 ns);#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhi = new TH1F("hDeltaPhi","#Delta#phi below the peak (500 ns);#Delta#phi (#circ)",200,-360,360); TH1F *hDeltaThetaBack = new TH1F("hDeltaThetaBack","#Delta#theta out of the peak (> 1000 ns) - normalized;#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhiBack = new TH1F("hDeltaPhiBack","#Delta#phi out of the peak (> 1000 ns) - normalized;#Delta#phi (#circ)",200,-360,360); TH1F *hThetaRel = new TH1F("hThetaRel","#theta_{rel} below the peak (500 ns);#theta_{rel} (#circ)",100,0,120); TH1F *hThetaRelBack = new TH1F("hThetaRelBack","#theta_{rel} out of the peak (> 1000 ns) - normalized;#theta_{rel} (#circ)",100,0,120); TH2F *hAngle = new TH2F("hAngle",";#Delta#theta (#circ);#Delta#phi (#circ}",20,-60,60,20,-360,360); TH2F *hAngleBack = new TH2F("hAngleBack",";#Delta#theta (#circ);#Delta#phi (#circ}",20,-60,60,20,-360,360); TProfile *hModulation = new TProfile("hModulation","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulation2 = new TProfile("hModulation2","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulationAv = new TProfile("hModulationAv","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulationAvCorr = new TProfile("hModulationAvCorr","#theta^{rel} < 10#circ;#phi - #alpha;diff (ns)",50,0,360); TH1F *hnsigpeak = new TH1F("hnsigpeak","",50,0,360); TH1F *hnbackpeak = new TH1F("hnbackpeak","",50,0,360); TProfile *hSinTheta = new TProfile("hSinTheta",";#phi - #alpha;sin(#theta)",50,0,360); TProfile *hSinTheta2 = new TProfile("hSinTheta2",";#phi - #alpha;sin(#theta)",50,0,360); TH1F *hRunCut[2]; hRunCut[0] = new TH1F("hRunCut1","Reason for Run Rejection Tel-1;Reason;runs rejected",11,0,11); hRunCut[1] = new TH1F("hRunCut2","Reason for Run Rejection Tel-2;Reason;runs rejected",11,0,11); for(Int_t i=0;i<2;i++){ hRunCut[i]->Fill("DateRange",0); hRunCut[i]->Fill("LowFractionGT",0); hRunCut[i]->Fill("TimeDuration",0); hRunCut[i]->Fill("rateGT",0); hRunCut[i]->Fill("RunNumber",0); hRunCut[i]->Fill("MissingHitFrac",0); hRunCut[i]->Fill("DeadStripBot",0); hRunCut[i]->Fill("DeadStripMid",0); hRunCut[i]->Fill("DeadStripTop",0); hRunCut[i]->Fill("NSatellites",0); hRunCut[i]->Fill("NoGoodWeather",0); } TFile *f = new TFile(fileIn); TTree *t = (TTree *) f->Get("tree"); TTree *tel[2]; tel[0] = (TTree *) f->Get("treeTel1"); tel[1] = (TTree *) f->Get("treeTel2"); TTree *telC = (TTree *) f->Get("treeTimeCommon"); // quality info of runs const Int_t nyearmax = 5; Bool_t runstatus[2][nyearmax][12][31][500]; //#telescope, year-2014, month, day, run Float_t effTel[2][nyearmax][12][31][500]; Int_t nStripDeadBot[2][nyearmax][12][31][500]; Int_t nStripDeadMid[2][nyearmax][12][31][500]; Int_t nStripDeadTop[2][nyearmax][12][31][500]; Float_t nstripDeadB[2]={0,0},nstripDeadM[2]={0,0},nstripDeadT[2]={0,0}; // sat info Float_t NsatAv[2][nyearmax][12][31][500]; // weather info Float_t pressureTel[2][nyearmax][12][31][500]; Float_t TempInTel[2][nyearmax][12][31][500]; Float_t TempOutTel[2][nyearmax][12][31][500]; Float_t timeWeath[2][nyearmax][12][31][500]; Float_t rateGT; Float_t phirelative; Float_t phirelative2; Float_t phirelativeAv; printf("Check Run quality\n"); if(tel[0] && tel[1]){ for(Int_t i=0;i < 2;i++){ // loop on telescopes printf("Tel-%i\n",i+1); for(Int_t j=0;j < tel[i]->GetEntries();j++){ // loop on runs tel[i]->GetEvent(j); rateGT = tel[i]->GetLeaf("FractionGoodTrack")->GetValue()*tel[i]->GetLeaf("rateHitPerRun")->GetValue(); Int_t aday = (tel[i]->GetLeaf("year")->GetValue()-2014) * 1000 + tel[i]->GetLeaf("month")->GetValue()*50 + tel[i]->GetLeaf("day")->GetValue(); if(i==1) printf("%f %f\n",rateGT , rateMin[i]); if(aday < adayMin || aday > adayMax){ hRunCut[i]->Fill("DateRange",1); continue;} if(tel[i]->GetLeaf("FractionGoodTrack")->GetValue() < fracGT[i]){ hRunCut[i]->Fill("LowFractionGT",1); continue;} // cut on fraction of good track if(tel[i]->GetLeaf("timeduration")->GetValue()*tel[i]->GetLeaf("rateHitPerRun")->GetValue() < hitevents[i]){ hRunCut[i]->Fill("TimeDuration",1); continue;} // cut on the number of event if(rateGT < rateMin[i] || rateGT > rateMax[i]){ hRunCut[i]->Fill("rateGT",1); continue;} // cut on the rate if(tel[i]->GetLeaf("run")->GetValue() > 499){ hRunCut[i]->Fill("RunNumber",1); continue;} // run < 500 if(i==1) printf("GR\n"); Float_t missinghitfrac = (tel[i]->GetLeaf("ratePerRun")->GetValue()-tel[i]->GetLeaf("rateHitPerRun")->GetValue()-2)/(tel[i]->GetLeaf("ratePerRun")->GetValue()-2); if(missinghitfrac < minmissingHitFrac[i] || missinghitfrac > maxmissingHitFrac[i]){ hRunCut[i]->Fill("MissingHitFrac",1); continue;} // active strip maps if(tel[i]->GetLeaf("maskB")) nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskB")->GetValue())); if(tel[i]->GetLeaf("maskM")) nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskM")->GetValue())); if(tel[i]->GetLeaf("maskT")) nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskT")->GetValue())); if(nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadBotMax[i] || nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadBotMin[i]) { hRunCut[i]->Fill("DeadStripBot",1); continue;} if(nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadMidMax[i] || nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadMidMin[i]){ hRunCut[i]->Fill("DeadStripMid",1); continue;} if(nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadTopMax[i] || nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadTopMin[i]){ hRunCut[i]->Fill("DeadStripTop",1); continue;} // nsat averaged per run if(tel[i]->GetLeaf("nSat")) NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("nSat")->GetValue(); if(NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < minAvSat[i] || NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > maxAvSat[i]){ hRunCut[i]->Fill("NSatellites",1); continue;} // weather info if(tel[i]->GetLeaf("Pressure")) pressureTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("Pressure")->GetValue(); if(tel[i]->GetLeaf("IndoorTemperature")) TempInTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("IndoorTemperature")->GetValue(); if(tel[i]->GetLeaf("OutdoorTemperature")) TempOutTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("OutdoorTemperature")->GetValue(); if(tel[i]->GetLeaf("TimeWeatherUpdate")) timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("TimeWeatherUpdate")->GetValue(); if(timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < minWeathTimeDelay[i] || timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > maxWeathTimeDelay[i]){ hRunCut[i]->Fill("NoGoodWeather",1); continue; } // Set good runs runstatus[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = kTRUE; effTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = 1;//rateGT/refRate[i]; } } } else{ telC = NULL; } printf("Start to process correlations\n"); Int_t n = t->GetEntries(); // counter for seconds Int_t nsec = 0; Int_t nsecGR = 0; // for good runs Int_t isec = -1; // used only in case the tree with time info is not available Float_t neventsGR = 0; Float_t neventsGRandSat = 0; if(telC){ for(Int_t i=0; i < telC->GetEntries();i++){ telC->GetEvent(i); nsec += telC->GetLeaf("timeduration")->GetValue(); if(telC->GetLeaf("run")->GetValue() > 499 || telC->GetLeaf("run2")->GetValue() > 499) continue; if(!runstatus[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())]) continue; if(!runstatus[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run2")->GetValue())]) continue; nsecGR += telC->GetLeaf("timeduration")->GetValue(); nstripDeadB[0] += countBits(nStripDeadBot[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadM[0] += countBits(nStripDeadMid[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadT[0] += countBits(nStripDeadTop[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadB[1] += countBits(nStripDeadBot[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadM[1] += countBits(nStripDeadMid[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadT[1] += countBits(nStripDeadTop[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); } nstripDeadB[0] /= nsecGR; nstripDeadM[0] /= nsecGR; nstripDeadT[0] /= nsecGR; nstripDeadB[1] /= nsecGR; nstripDeadM[1] /= nsecGR; nstripDeadT[1] /= nsecGR; printf("Dead channel tel1 = %f - %f - %f\n",nstripDeadB[0],nstripDeadM[0],nstripDeadT[0]); printf("Dead channel tel2 = %f - %f - %f\n",nstripDeadB[1],nstripDeadM[1],nstripDeadT[1]); } char title[300]; TH1F *h; sprintf(title,"correction assuming #Delta#phi = %4.2f, #DeltaL = %.1f m;#Deltat (ns);entries",angle,distance); h = new TH1F("hCoinc",title,nbint,tmin,tmax); Float_t DeltaT; Float_t phiAv,thetaAv,corr; Float_t Theta1,Theta2; Float_t Phi1,Phi2; Int_t nsatel1cur,nsatel2cur,ntrack1,ntrack2; Float_t v1[3],v2[3],vSP; // variable to recompute ThetaRel on the fly Float_t eff = 1; for(Int_t i=0;i<n;i++){ t->GetEvent(i); if(t->GetLeaf("RunNumber1") && (t->GetLeaf("RunNumber1")->GetValue() > 499 || t->GetLeaf("RunNumber2")->GetValue() > 499)) continue; if(tel[0] && !runstatus[0][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber1")->GetValue())]) continue; if(tel[1] && !runstatus[1][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]) continue; eff = effTel[0][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber1")->GetValue())]; eff *= effTel[1][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]; Int_t timec = t->GetLeaf("ctime1")->GetValue(); if(! telC){ if(isec == -1) isec = timec; if(timec != isec){ if(timec - isec < 20){ // printf("diff = %i\n",timec-isec); nsec +=(timec - isec); nsecGR +=(timec - isec); } isec = timec; } } Float_t thetarel = t->GetLeaf("ThetaRel")->GetValue(); Theta1 = (t->GetLeaf("Theta1")->GetValue())*TMath::DegToRad(); Theta2 = t->GetLeaf("Theta2")->GetValue()*TMath::DegToRad(); Phi1 = t->GetLeaf("Phi1")->GetValue()*TMath::DegToRad(); Phi2 = t->GetLeaf("Phi2")->GetValue()*TMath::DegToRad(); nsatel1cur = t->GetLeaf("Nsatellite1")->GetValue(); nsatel2cur = t->GetLeaf("Nsatellite2")->GetValue(); ntrack1 = t->GetLeaf("Ntracks1")->GetValue(); ntrack2 = t->GetLeaf("Ntracks2")->GetValue(); if(recomputeThetaRel){ // recompute ThetaRel applying corrections Phi1 += phi1Corr*TMath::DegToRad(); Phi2 += phi2Corr*TMath::DegToRad(); if(Phi1 > 2*TMath::Pi()) Phi1 -= 2*TMath::Pi(); if(Phi1 < 0) Phi1 += 2*TMath::Pi(); if(Phi2 > 2*TMath::Pi()) Phi2 -= 2*TMath::Pi(); if(Phi2 < 0) Phi2 += 2*TMath::Pi(); v1[0] = TMath::Sin(Theta1)*TMath::Cos(Phi1); v1[1] = TMath::Sin(Theta1)*TMath::Sin(Phi1); v1[2] = TMath::Cos(Theta1); v2[0] = TMath::Sin(Theta2)*TMath::Cos(Phi2); v2[1] = TMath::Sin(Theta2)*TMath::Sin(Phi2); v2[2] = TMath::Cos(Theta2); v1[0] *= v2[0]; v1[1] *= v2[1]; v1[2] *= v2[2]; vSP = v1[0] + v1[1] + v1[2]; thetarel = TMath::ACos(vSP)*TMath::RadToDeg(); } // cuts if(thetarel < minthetarel) continue; if(thetarel > maxthetarel) continue; if(t->GetLeaf("ChiSquare1")->GetValue() > maxchisquare) continue; if(t->GetLeaf("ChiSquare2")->GetValue() > maxchisquare) continue; neventsGR++; // reject events with not enough satellites if(nsatel1cur < satEventThr || nsatel1cur < satEventThr) continue; neventsGRandSat++; DeltaT = t->GetLeaf("DiffTime")->GetValue(); // get primary direction if(TMath::Abs(Phi1-Phi2) < TMath::Pi()) phiAv = (Phi1+Phi2)*0.5; else phiAv = (Phi1+Phi2)*0.5 + TMath::Pi(); thetaAv = (Theta1+Theta2)*0.5; // extra cuts if needed // if(TMath::Cos(Phi1-Phi2) < 0.) continue; Float_t resFactor = 1; if(thetarel > 10 ) resFactor *= 0.5; if(thetarel > 20 ) resFactor *= 0.5; if(thetarel > 30 ) resFactor *= 0.5; corr = distance * TMath::Sin(thetaAv)*TMath::Cos(phiAv-angle)/2.99792458000000039e-01 + deltatCorr; phirelative = (Phi1-angle)*TMath::RadToDeg(); if(phirelative < 0) phirelative += 360; if(phirelative < 0) phirelative += 360; if(phirelative > 360) phirelative -= 360; if(phirelative > 360) phirelative -= 360; phirelative2 = (Phi2-angle)*TMath::RadToDeg(); if(phirelative2 < 0) phirelative2 += 360; if(phirelative2 < 0) phirelative2 += 360; if(phirelative2 > 360) phirelative2 -= 360; if(phirelative2 > 360) phirelative2 -= 360; phirelativeAv = (phiAv-angle)*TMath::RadToDeg(); if(phirelativeAv < 0) phirelativeAv += 360; if(phirelativeAv < 0) phirelativeAv += 360; if(phirelativeAv > 360) phirelativeAv -= 360; if(phirelativeAv > 360) phirelativeAv -= 360; // if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment){ // } if(thetarel < 10){//cos(thetarel*TMath::DegToRad())>0.98 && sin(thetaAv)>0.1){ if(TMath::Abs(DeltaT- corr) < windowAlignment) hModulationAvCorr->Fill(phirelativeAv,DeltaT-corr); if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment){ hModulation->Fill(phirelative,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hModulation2->Fill(phirelative2,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hModulationAv->Fill(phirelativeAv,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hSinTheta->Fill(phirelative,sin(thetaAv)); hSinTheta2->Fill(phirelative2,sin(thetaAv)); nsigPeak++; hnsigpeak->Fill(phirelativeAv); } else if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment*10){ nbackPeak++; hnbackpeak->Fill(phirelativeAv); } } h->Fill(DeltaT-corr,1./eff); if(TMath::Abs(DeltaT-corr) < windowAlignment){ hDeltaTheta->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhi->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRel->Fill(thetarel); hAngle->Fill((Theta1-Theta2)*TMath::RadToDeg(),(Phi1-Phi2)*TMath::RadToDeg()); } else if(TMath::Abs(DeltaT-corr) > windowAlignment*2 && TMath::Abs(DeltaT-corr) < windowAlignment*12){ hDeltaThetaBack->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhiBack->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRelBack->Fill(thetarel); hAngleBack->Fill((Theta1-Theta2)*TMath::RadToDeg(),(Phi1-Phi2)*TMath::RadToDeg()); } } // compute (S+B)/S for(Int_t i=1;i<=50;i++){ Float_t corrfactorPeak = 1; if(nsigPeak-nbackPeak*0.1 > 0) corrfactorPeak = hnsigpeak->GetBinContent(i)/(hnsigpeak->GetBinContent(i)-hnbackpeak->GetBinContent(i)*0.1); else printf("bin %i) not enough statistics\n",i); hnsigpeak->SetBinContent(i,corrfactorPeak); } TF1 *fpol0 = new TF1("fpol0","pol0"); hnsigpeak->Fit(fpol0); hModulation->Scale(fpol0->GetParameter(0)); hModulation2->Scale(fpol0->GetParameter(0)); hModulationAv->Scale(fpol0->GetParameter(0)); hModulationAvCorr->Scale(fpol0->GetParameter(0)); TF1 *fmod = new TF1("fmod","[0] + [1]*cos((x-[2])*TMath::DegToRad())"); hModulationAv->Fit(fmod); printf("Estimates from time delay: Distance = %f +/- %f m -- Angle = %f +/- %f deg\n",fmod->GetParameter(1),fmod->GetParError(1),fmod->GetParameter(2),fmod->GetParError(2)); h->SetStats(0); hDeltaThetaBack->Sumw2(); hDeltaPhiBack->Sumw2(); hThetaRelBack->Sumw2(); hDeltaThetaBack->Scale(0.1); hDeltaPhiBack->Scale(0.1); hThetaRelBack->Scale(0.1); hAngleBack->Scale(0.1); hAngle->Add(hAngleBack,-1); printf("bin counting: SIGNAL = %f +/- %f\n",hDeltaPhi->Integral()-hDeltaPhiBack->Integral(),sqrt(hDeltaPhi->Integral())); rate = (hDeltaPhi->Integral()-hDeltaPhiBack->Integral())/nsecGR*86400; rateErr = sqrt(hDeltaPhi->Integral())/nsecGR*86400; Float_t val,eval; TCanvas *c1=new TCanvas(); TF1 *ff = new TF1("ff","[0]*[4]/[2]/sqrt(2*TMath::Pi())*TMath::Exp(-(x-[1])*(x-[1])*0.5/[2]/[2]) + [3]*[4]/6/[2]"); ff->SetParName(0,"signal"); ff->SetParName(1,"mean"); ff->SetParName(2,"sigma"); ff->SetParName(3,"background"); ff->SetParName(4,"bin width"); ff->SetParameter(0,42369); ff->SetParameter(1,0); ff->SetParLimits(2,10,maxwidth); ff->SetParameter(2,350); // fix witdh if needed ff->SetParameter(3,319); ff->FixParameter(4,(tmax-tmin)/nbint); // bin width ff->SetNpx(1000); if(cout) cout->cd(); h->Fit(ff,"EI","",-10000,10000); val = ff->GetParameter(2); eval = ff->GetParError(2); printf("significance = %f\n",ff->GetParameter(0)/sqrt(ff->GetParameter(0) + ff->GetParameter(3))); h->Draw(); new TCanvas; TF1 *func1 = (TF1 *) h->GetListOfFunctions()->At(0); func1->SetLineColor(2); h->SetLineColor(4); TPaveText *text = new TPaveText(1500,(h->GetMinimum()+(h->GetMaximum()-h->GetMinimum())*0.6),9500,h->GetMaximum()); text->SetFillColor(0); sprintf(title,"width = %5.1f #pm %5.1f",func1->GetParameter(2),func1->GetParError(2)); text->AddText(title); sprintf(title,"signal (S) = %5.1f #pm %5.1f",func1->GetParameter(0),func1->GetParError(0)); text->AddText(title); sprintf(title,"background (B) (3#sigma) = %5.1f #pm %5.1f",func1->GetParameter(3),func1->GetParError(3)); text->AddText(title); sprintf(title,"significance (S/#sqrt{S+B}) = %5.1f",func1->GetParameter(0)/sqrt(func1->GetParameter(0)+func1->GetParameter(3))); text->AddText(title); text->SetFillStyle(0); text->SetBorderSize(0); text->Draw("SAME"); // correct nsecGR for the event rejected because of the number of satellites (event by event cut) nsecGR *= neventsGRandSat/neventsGR; printf("n_day = %f\nn_dayGR = %f\n",nsec*1./86400,nsecGR*1./86400); text->AddText(Form("rate = %f #pm %f per day",func1->GetParameter(0)*86400/nsecGR,func1->GetParError(0)*86400/nsecGR)); TFile *fo = new TFile("outputCERN-01-02.root","RECREATE"); h->Write(); hDeltaTheta->Write(); hDeltaPhi->Write(); hThetaRel->Write(); hDeltaThetaBack->Write(); hDeltaPhiBack->Write(); hThetaRelBack->Write(); hAngle->Write(); hModulation->Write(); hModulation2->Write(); hModulationAv->Write(); hModulationAvCorr->Write(); hSinTheta->Write(); hSinTheta2->Write(); hnsigpeak->Write(); hRunCut[0]->Write(); hRunCut[1]->Write(); fo->Close(); return nsecGR*1./86400; }
int analysis(char* filename) { // char* filename = "combined.root"; // Read in the file TFile* f = new TFile(filename); TDirectory* hists = f->GetDirectory("hists;1"); TDirectory* tuples = f->GetDirectory("tuples;1"); TTree* accum = tuples->GetObjectUnchecked("AccumulatedEnergy;1"); TLeaf* einit = accum->GetLeaf("Einit"); TLeaf* edepo = accum->GetLeaf("Edep"); TTree* edeps = tuples->GetObjectUnchecked("EnergyDepositions;1"); TTree* secs = tuples->GetObjectUnchecked("SecondarySpectrum;1"); TLeaf* secsenergy = secs->GetLeaf("KineticEnergy"); double ein = 0; double eout = 0; int nevents = accum->GetEntries(); cout << "Making Summary\n"; FILE* summary = fopen("summ.txt", "a+"); for (int ii = 0; ii<nevents; ii++) { accum->GetEntry(ii); ein+=einit->GetValue(); eout+=edepo->GetValue(); } FILE* summary = fopen("summ.txt", "a+"); time_t t = time(NULL); char* c_time_string = ctime(&t); char* mytime[20]; strncpy(mytime, c_time_string, 19); mytime[ strlen(mytime) - 1 ] = '\0'; fprintf(summary, "%s,%s,%e,%e\n", mytime, filename, ein, eout);//*c_time_string, *filename, ein, eout); //cout << *c_time_string << "," << *filename << "," << ein << "," << eout << "\n"; fclose(summary); // Print out or save these values cout << "Making Histogram\n"; nevents = secs->GetEntries(); TH1F* secondaries = new TH1F("secondaries", "Secondary Electrons <100 keV", 92, 0.010, 0.102); for (int ii = 0; ii<nevents; ii++) { secs->GetEntry(ii); secondaries->Fill(secsenergy->GetValue()); } char* suffix = ".secondaryhisto"; cout << "Making Filenames\n"; char* outfilename = malloc(strlen(filename) + strlen(suffix) + 1); strcpy(outfilename, filename); strcat(outfilename, suffix); printf("Saving Histogram: %s \n", outfilename); h12ascii(secondaries, outfilename); return 0; }
void doCoinc3(const char *fileIn="SAVO-01-SAVO-02-SAVO-03-2016-01-26.root"){ Int_t adayMin = (yearRange[0]-2007) * 1000 + monthRange[0]*50 + dayRange[0]; Int_t adayMax = (yearRange[1]-2007) * 1000 + monthRange[1]*50 + dayRange[1]; // define some histos TH1F *hDeltaTheta12 = new TH1F("hDeltaTheta12","#Delta#theta_{12} below the peak (500 ns);#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhi12 = new TH1F("hDeltaPhi12","#Delta#phi_{12} below the peak (500 ns);#Delta#phi (#circ)",200,-360,360); TH1F *hDeltaThetaBack12 = new TH1F("hDeltaThetaBack12","#Delta#theta_{12} out of the peak (> 1000 ns) - normalized;#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhiBack12 = new TH1F("hDeltaPhiBack12","#Delta#phi_{12} out of the peak (> 1000 ns) - normalized;#Delta#phi (#circ)",200,-360,360); TH1F *hThetaRel12 = new TH1F("hThetaRel12","#theta_{rel}_{12} below the peak (500 ns);#theta_{rel} (#circ)",100,0,120); TH1F *hThetaRelBack12 = new TH1F("hThetaRelBack12","#theta_{rel}_{12} out of the peak (> 1000 ns) - normalized;#theta_{rel} (#circ)",100,0,120); TH1F *hDeltaTheta13 = new TH1F("hDeltaTheta13","#Delta#theta_{13} below the peak (500 ns);#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhi13 = new TH1F("hDeltaPhi13","#Delta#phi_{13} below the peak (500 ns);#Delta#phi (#circ)",200,-360,360); TH1F *hDeltaThetaBack13 = new TH1F("hDeltaThetaBack13","#Delta#theta_{13} out of the peak (> 1000 ns) - normalized;#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhiBack13 = new TH1F("hDeltaPhiBack13","#Delta#phi_{13} out of the peak (> 1000 ns) - normalized;#Delta#phi (#circ)",200,-360,360); TH1F *hThetaRel13 = new TH1F("hThetaRel13","#theta_{rel}_{13} below the peak (500 ns);#theta_{rel} (#circ)",100,0,120); TH1F *hThetaRelBack13 = new TH1F("hThetaRelBack13","#theta_{rel}_{13} out of the peak (> 1000 ns) - normalized;#theta_{rel} (#circ)",100,0,120); TFile *f = new TFile(fileIn); TTree *t = (TTree *) f->Get("tree"); TTree *tel[3]; tel[0] = (TTree *) f->Get("treeTel1"); tel[1] = (TTree *) f->Get("treeTel2"); tel[2] = (TTree *) f->Get("treeTel3"); TTree *telC = (TTree *) f->Get("treeTimeCommon"); // quality info of runs Bool_t runstatus[3][10][12][31][500]; //#telescope, year-2007, month, day, run if(tel[0] && tel[1] && tel[2]){ for(Int_t i=0;i < 3;i++){ // loop on telescopes for(Int_t j=0;j < tel[i]->GetEntries();j++){ // loop on runs tel[i]->GetEvent(j); Int_t aday = (tel[i]->GetLeaf("year")->GetValue()-2007) * 1000 + tel[i]->GetLeaf("month")->GetValue()*50 + tel[i]->GetLeaf("day")->GetValue(); if(aday < adayMin || aday > adayMax) continue; if(tel[i]->GetLeaf("FractionGoodTrack")->GetValue() < fracGT[i]) continue; // cut on fraction of good track if(tel[i]->GetLeaf("timeduration")->GetValue()*tel[i]->GetLeaf("rateHitPerRun")->GetValue() < hitevents[i]) continue; // cut on the number of event if(tel[i]->GetLeaf("ratePerRun")->GetValue() < rateMin[i] || tel[i]->GetLeaf("ratePerRun")->GetValue() > rateMax[i]) continue; // cut on the rate if(tel[i]->GetLeaf("run")->GetValue() > 499) continue; // run < 500 Float_t missinghitfrac = (tel[i]->GetLeaf("ratePerRun")->GetValue()-tel[i]->GetLeaf("rateHitPerRun")->GetValue()-2)/(tel[i]->GetLeaf("ratePerRun")->GetValue()-2); if(missinghitfrac < minmissingHitFrac[i] || missinghitfrac > maxmissingHitFrac[i]) continue; runstatus[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2007][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = kTRUE; } } } else{ telC = NULL; } Int_t n = t->GetEntries(); // counter for seconds Int_t nsec = 0; Int_t nsecGR = 0; // for good runs Int_t isec = -1; // used only in case the tree with time info is not available if(telC){ for(Int_t i=0; i < telC->GetEntries();i++){ telC->GetEvent(i); nsec += telC->GetLeaf("timeduration")->GetValue(); if(telC->GetLeaf("run")->GetValue() > 499 || telC->GetLeaf("run2")->GetValue() > 499 || telC->GetLeaf("run3")->GetValue() > 499) continue; if(!runstatus[0][Int_t(telC->GetLeaf("year")->GetValue())-2007][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())]) continue; if(!runstatus[1][Int_t(telC->GetLeaf("year")->GetValue())-2007][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run2")->GetValue())]) continue; if(!runstatus[2][Int_t(telC->GetLeaf("year")->GetValue())-2007][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run2")->GetValue())]) continue; nsecGR += telC->GetLeaf("timeduration")->GetValue(); } } char title[600]; TH1F *h; TH2F *h2; sprintf(title,"correction assuming #Delta#phi_{12} = %4.2f, #DeltaL_{12} = %.1f m, #Delta#phi_{13} = %4.2f, #DeltaL_{13} = %.1f m;#Deltat_{13} (ns) when |#Deltat_{12}| < %i ns;entries",angle12,distance12,angle13,distance13,timeCutOn12); h = new TH1F("hCoinc",title,nbint,tmin,tmax); sprintf(title,"correction assuming #Delta#phi_{12} = %4.2f, #DeltaL_{12} = %.1f m, #Delta#phi_{13} = %4.2f, #DeltaL_{13} = %.1f m;#Deltat_{12} (ns);#Deltat_{13} (ns);entries",angle12,distance12,angle13,distance13,timeCutOn12); h2 = new TH2F("hCoinc2D",title,nbint,tmin,tmax,nbint,tmin,tmax); Float_t DeltaT12,DeltaT13; Float_t phiAv,thetaAv,corr12,corr13; Float_t Theta1,Theta2,Theta3; Float_t Phi1,Phi2,Phi3; Float_t v1[3],v2[3],v3[3],vSP12,vSP13; // variable to recompute ThetaRel on the fly for(Int_t i=0;i<n;i++){ t->GetEvent(i); // if(t->GetLeaf("RunNumber1") && (t->GetLeaf("RunNumber1")->GetValue() > 499 || t->GetLeaf("RunNumber2")->GetValue() > 499) || t->GetLeaf("RunNumber3")->GetValue() > 499)) continue; // if(tel[0] && !runstatus[0][Int_t(t->GetLeaf("year")->GetValue())-2007][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber1")->GetValue())]) continue; // if(tel[1] && !runstatus[1][Int_t(t->GetLeaf("year")->GetValue())-2007][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]) continue; // if(tel[2] && !runstatus[2][Int_t(t->GetLeaf("year")->GetValue())-2007][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]) continue; Int_t timec = t->GetLeaf("ctime1")->GetValue(); if(! telC){ if(isec == -1) isec = timec; if(timec != isec){ if(timec - isec < 20){ // printf("diff = %i\n",timec-isec); nsec +=(timec - isec); nsecGR +=(timec - isec); } isec = timec; } } Float_t thetarel12 = t->GetLeaf("ThetaRel12")->GetValue(); Float_t thetarel13 = t->GetLeaf("ThetaRel13")->GetValue(); Theta1 = t->GetLeaf("Theta1")->GetValue()*TMath::DegToRad(); Theta2 = t->GetLeaf("Theta2")->GetValue()*TMath::DegToRad(); Theta3 = t->GetLeaf("Theta3")->GetValue()*TMath::DegToRad(); Phi1 = t->GetLeaf("Phi1")->GetValue()*TMath::DegToRad(); Phi2 = t->GetLeaf("Phi2")->GetValue()*TMath::DegToRad(); Phi3 = t->GetLeaf("Phi3")->GetValue()*TMath::DegToRad(); if(recomputeThetaRel){ // recompute ThetaRel applying corrections Phi1 -= phi1Corr*TMath::DegToRad(); Phi2 -= phi2Corr*TMath::DegToRad(); Phi3 -= phi3Corr*TMath::DegToRad(); if(Phi1 > 2*TMath::Pi()) Phi1 -= 2*TMath::Pi(); if(Phi1 < 0) Phi1 += 2*TMath::Pi(); if(Phi2 > 2*TMath::Pi()) Phi2 -= 2*TMath::Pi(); if(Phi2 < 0) Phi2 += 2*TMath::Pi(); if(Phi3 > 2*TMath::Pi()) Phi3 -= 2*TMath::Pi(); if(Phi3 < 0) Phi3 += 2*TMath::Pi(); v1[0] = TMath::Sin(Theta1)*TMath::Cos(Phi1); v1[1] = TMath::Sin(Theta1)*TMath::Sin(Phi1); v1[2] = TMath::Cos(Theta1); v2[0] = TMath::Sin(Theta2)*TMath::Cos(Phi2); v2[1] = TMath::Sin(Theta2)*TMath::Sin(Phi2); v2[2] = TMath::Cos(Theta2); v3[0] = TMath::Sin(Theta3)*TMath::Cos(Phi3); v3[1] = TMath::Sin(Theta3)*TMath::Sin(Phi3); v3[2] = TMath::Cos(Theta3); v2[0] *= v1[0]; v2[1] *= v1[1]; v2[2] *= v1[2]; v3[0] *= v1[0]; v3[1] *= v1[1]; v3[2] *= v1[2]; vSP12 = v2[0] + v2[1] + v2[2]; vSP13 = v3[0] + v3[1] + v3[2]; thetarel12 = TMath::ACos(vSP12)*TMath::RadToDeg(); thetarel13 = TMath::ACos(vSP13)*TMath::RadToDeg(); } // cuts if(thetarel12 > maxthetarel) continue; if(thetarel13 > maxthetarel) continue; if(t->GetLeaf("ChiSquare1")->GetValue() > maxchisquare) continue; if(t->GetLeaf("ChiSquare2")->GetValue() > maxchisquare) continue; if(t->GetLeaf("ChiSquare3")->GetValue() > maxchisquare) continue; DeltaT12 = t->GetLeaf("DiffTime12")->GetValue(); DeltaT13 = t->GetLeaf("DiffTime13")->GetValue(); // get primary direction if(TMath::Abs(Phi1-Phi2) < TMath::Pi()) phiAv = (Phi1+Phi2)*0.5; else phiAv = (Phi1+Phi2)*0.5 + TMath::Pi(); if(TMath::Abs(phiAv-Phi3) < TMath::Pi()) phiAv = (phiAv*2+Phi2)*0.33333333333; else if(phiAv > Phi3) phiAv = (phiAv*2+Phi3+2*TMath::Pi())*0.33333333333; else phiAv = (phiAv*2+4*TMath::Pi()+Phi3)*0.33333333333; thetaAv = (Theta1+Theta2+Theta3)*0.333333333333; // extra cuts if needed // if(TMath::Cos(Phi1-Phi2) < 0.) continue; corr12 = distance12 * TMath::Sin(thetaAv)*TMath::Cos(phiAv-angle12)/2.99792458000000039e-01 + deltatCorr12; corr13 = distance13 * TMath::Sin(thetaAv)*TMath::Cos(phiAv-angle13)/2.99792458000000039e-01 + deltatCorr13; if(TMath::Abs(DeltaT12-corr12) < timeCutOn12) h->Fill(DeltaT13-corr13); h2->Fill(DeltaT12-corr12,DeltaT13-corr13); if(TMath::Abs(DeltaT12-corr12) < 500){ hDeltaTheta12->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhi12->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRel12->Fill(thetarel12); } else if(TMath::Abs(DeltaT12-corr12) > 1000 && TMath::Abs(DeltaT12-corr12) < 6000){ hDeltaThetaBack12->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhiBack12->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRelBack12->Fill(thetarel12); } if(TMath::Abs(DeltaT13-corr13) < 500){ hDeltaTheta13->Fill((Theta1-Theta3)*TMath::RadToDeg()); hDeltaPhi13->Fill((Phi1-Phi3)*TMath::RadToDeg()); hThetaRel13->Fill(thetarel13); } else if(TMath::Abs(DeltaT13-corr13) > 1000 && TMath::Abs(DeltaT13-corr13) < 6000){ hDeltaThetaBack13->Fill((Theta1-Theta3)*TMath::RadToDeg()); hDeltaPhiBack13->Fill((Phi1-Phi3)*TMath::RadToDeg()); hThetaRelBack13->Fill(thetarel13); } } h->SetStats(0); hDeltaThetaBack12->Sumw2(); hDeltaPhiBack12->Sumw2(); hThetaRelBack12->Sumw2(); hDeltaThetaBack12->Scale(0.1); hDeltaPhiBack12->Scale(0.1); hThetaRelBack12->Scale(0.1); hDeltaThetaBack13->Sumw2(); hDeltaPhiBack13->Sumw2(); hThetaRelBack13->Sumw2(); hDeltaThetaBack13->Scale(0.1); hDeltaPhiBack13->Scale(0.1); hThetaRelBack13->Scale(0.1); Float_t val,eval; TCanvas *c1=new TCanvas(); TF1 *ff = new TF1("ff","[0]*[4]/[2]/sqrt(2*TMath::Pi())*TMath::Exp(-(x-[1])*(x-[1])*0.5/[2]/[2]) + [3]*[4]/6/[2]"); ff->SetParName(0,"signal"); ff->SetParName(1,"mean"); ff->SetParName(2,"sigma"); ff->SetParName(3,"background"); ff->SetParName(4,"bin width"); ff->SetParameter(0,42369); ff->SetParameter(1,0); ff->SetParLimits(2,10,1000); ff->SetParameter(2,150); // fix witdh if needed ff->SetParameter(3,319); ff->FixParameter(4,20000./nbint); // bin width ff->SetNpx(1000); h->Fit(ff); val = ff->GetParameter(2); eval = ff->GetParError(2); printf("significance = %f\n",ff->GetParameter(0)/sqrt(ff->GetParameter(0) + ff->GetParameter(3))); h->Draw(); TF1 *func1 = (TF1 *) h->GetListOfFunctions()->At(0); func1->SetLineColor(2); h->SetLineColor(4); TPaveText *text = new TPaveText(1500,(h->GetMinimum()+(h->GetMaximum()-h->GetMinimum())*0.6),9500,h->GetMaximum()); text->SetFillColor(0); sprintf(title,"width = %5.1f #pm %5.1f",func1->GetParameter(2),func1->GetParError(2)); text->AddText(title); sprintf(title,"signal (S) = %5.1f #pm %5.1f",func1->GetParameter(0),func1->GetParError(0)); text->AddText(title); sprintf(title,"background (B) (3#sigma) = %5.1f #pm %5.1f",func1->GetParameter(3),func1->GetParError(3)); text->AddText(title); sprintf(title,"significance (S/#sqrt{S+B}) = %5.1f",func1->GetParameter(0)/sqrt(func1->GetParameter(0)+func1->GetParameter(3))); text->AddText(title); text->SetFillStyle(0); text->SetBorderSize(0); text->Draw("SAME"); printf("n_day = %f\nn_dayGR = %f\n",nsec*1./86400,nsecGR*1./86400); text->AddText(Form("rate = %f #pm %f per day",func1->GetParameter(0)*86400/nsecGR,func1->GetParError(0)*86400/nsecGR)); TFile *fo = new TFile("output-SAVO-010203.root","RECREATE"); h->Write(); h2->Write(); hDeltaTheta12->Write(); hDeltaPhi12->Write(); hThetaRel12->Write(); hDeltaThetaBack12->Write(); hDeltaPhiBack12->Write(); hThetaRelBack12->Write(); hDeltaTheta13->Write(); hDeltaPhi13->Write(); hThetaRel13->Write(); hDeltaThetaBack13->Write(); hDeltaPhiBack13->Write(); hThetaRelBack13->Write(); fo->Close(); }