void TGo4LoadedLibraries::RefreshLibs() { LoadedLibsD->clear(); TObjArray* libs = TString(gInterpreter->GetSharedLibs()).Tokenize(" ,\t\n"); if (libs!=0) for (int n=0; n<=libs->GetLast(); n++) { QFileInfo fi(libs->At(n)->GetName()); QStringList columns; columns << fi.fileName() << QString::number(fi.size()) << fi.lastModified().toString() << fi.owner() << fi.group(); LoadedLibsD->addTopLevelItem(new QTreeWidgetItem(columns)); } delete libs; LoadedLibsS->clear(); libs = TString(gSystem->GetLinkedLibs()).Tokenize(" ,\t\n"); if (libs!=0) for (int n=0; n<=libs->GetLast(); n++) { QStringList columns; columns << libs->At(n)->GetName(); LoadedLibsS->addTopLevelItem(new QTreeWidgetItem(columns)); } delete libs; }
//_____________________________________________________ TLegendEntry* GFHistManager::AddHistSame(TH1* hist, Int_t layer, Int_t histNum, const char* legendTitle, const char* legOpt) { // adds hist to layer to draw it in the same pad as histNum's histo of that layer if(!hist){ this->Warning("AddHistSame", "adding NULL pointer will be ignored!"); return NULL; } if (histNum > 0 && this->CheckDepth("AddHistSame", layer, kTRUE) //maybe added layer? && !this->GetHistsOf(layer, histNum-1)) { this->Error("AddHistSame", "usage as AddHist only for next free histNum, not %d", histNum); return NULL; } GFHistArray *histsArray = this->GetHistsOf(layer, histNum, kTRUE);// expand! TLegendEntry* result = NULL; if(histsArray) { histsArray->Add(hist); if(legendTitle && strlen(legendTitle)){ TObjArray* legends = this->MakeLegends(layer); TLegend* legend = NULL; if(legends->GetLast() >= histNum && legends->At(histNum)){ legend = static_cast<TLegend*>(legends->At(histNum)); } else { legend = new TLegend(fLegendX1, fLegendY1, fLegendX2, fLegendY2); #if ROOT_VERSION_CODE < ROOT_VERSION(5,6,0) if (TString(gStyle->GetName()) == "Plain") legend->SetBorderSize(1); #endif legends->AddAtAndExpand(legend, histNum); } result = legend->AddEntry(hist,legendTitle, legOpt ? legOpt : fgLegendEntryOption.Data()); } } return result; }
//______________________________________________________________________________ void ChangeRecoParam(Int_t startRun,const char* fromURI,const char* toURI) { AliCDBManager::Instance()->SetDefaultStorage(fromURI); AliCDBManager::Instance()->SetRun(startRun); AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam"); AliMpCDB::LoadAll(); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get recoparams ? Oups" << endl; return; } if ( o->IsA() != TObjArray::Class() ) { cout << "This code only works with TObjArray recoparams. Sorry" << endl; return; } TObjArray* array = static_cast<TObjArray*>(o); for ( Int_t i = 0; i <= array->GetLast(); ++i ) { AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i)); // if (AliRecoParam::Convert(p->GetEventSpecie())==AliRecoParam::kLowMult) // { // cout << Form("array[%d]=%s %s %s",i, // p ? p->ClassName() : "", // p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"", // p ? ( p->IsDefault() ? "default" : "") : "" ) << endl; // p->Print(""); AliMUONRecoParam* rp = dynamic_cast<AliMUONRecoParam*>(p); if (!rp) { cout << "OUPS. OUPS" << endl; return; } // rp->SetHVLimit(2,1580); UInt_t mask = rp->PadGoodnessMask(); mask |= ( (1<<7) << 24 ); rp->SetPadGoodnessMask(mask); rp->Print(""); } AliCDBManager::Instance()->SetDefaultStorage(toURI); AliMUONCDB::WriteToCDB(array, "MUON/Calib/RecoParam", startRun, AliCDBRunRange::Infinity(), "reconstruction parameters for MUON, patched to take into account the bit for bus patch removed online by PAR", "L. Aphecetche"); }
//________________________________________________________ void GFHistManager::DrawLegend(Int_t layer, Int_t histNo) { // histNo starting at '0' // We must already be in the correct pad, layer and histNo must exist if(fLegendArrays && layer <= fLegendArrays->GetLast() && fLegendArrays->At(layer)){ TObjArray* legends = static_cast<TObjArray*>(fLegendArrays->At(layer)); TObject* legend = (histNo <= legends->GetLast() ? legends->At(histNo) : NULL); if(legend) legend->Draw(); } }
//______________________________________________________________________________ void ChangeRecoParam(Int_t startRun=195767,const char* outputOCDB="alien://folder=/alice/cern.ch/user/l/laphecet/OCDB") { AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(99999999); AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam"); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get recoparams ? Oups" << endl; return; } if ( o->IsA() != TObjArray::Class() ) { cout << "This code only works with TObjArray recoparams. Sorry" << endl; return; } TObjArray* array = static_cast<TObjArray*>(o); for ( Int_t i = 0; i <= array->GetLast(); ++i ) { AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i)); if (AliRecoParam::Convert(p->GetEventSpecie())==AliRecoParam::kLowMult) { cout << Form("array[%d]=%s %s %s",i, p ? p->ClassName() : "", p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"", p ? ( p->IsDefault() ? "default" : "") : "" ) << endl; p->Print(""); AliMUONRecoParam* rp = dynamic_cast<AliMUONRecoParam*>(p); if (!rp) { cout << "OUPS. OUPS" << endl; return; } rp->SetHVLimit(1,-99999); rp->SetPadGoodnessMask(0x400be93); rp->Print(""); } } AliCDBManager::Instance()->SetDefaultStorage(outputOCDB); AliMUONCDB::WriteToCDB(array, "MUON/Calib/RecoParam", startRun, AliCDBRunRange::Infinity(), "reconstruction parameters for MUON, patched for event size limits (for DQM)", "L. Aphecetche"); }
//________________________________________________________ TList* GFHistManager::GetObjectsOf(Int_t layer, Int_t histNo) { if(!this->CheckHistNum("GetObjectsOf", layer, histNo, kFALSE)) return NULL; if(fObjLists && layer <= fObjLists->GetLast() && fObjLists->At(layer)){ TObjArray* layerLists = static_cast<TObjArray*>(fObjLists->At(layer)); if(histNo <= layerLists->GetLast() && layerLists->At(histNo)){ return static_cast<TList*>(layerLists->At(histNo)); } } return NULL; }
void DrawRays() { for(int i = 0; i < kNtheta; i++){ TObjArray* focused = gArray[i]->GetFocused(); for(Int_t j = 0; j <= focused->GetLast(); j++){ ARay* ray = (ARay*)(*focused)[j]; TPolyLine3D* pol = ray->MakePolyLine3D(); pol->SetLineColor(i + 2); pol->Draw(); } // j } // i }
//______________________________________________________________________________ void ChangeITSRecoParam(Int_t startRun=157560,const char* outputOCDB="alien://folder=/alice/cern.ch/user/l/laphecet/OCDB") { AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetRun(startRun); AliCDBEntry* entry = AliCDBManager::Instance()->Get("ITS/Calib/RecoParam"); if (!entry) return; TObject* o = entry->GetObject(); if (!o) { cout << "Could not get recoparams ? Oups" << endl; return; } if ( o->IsA() != TObjArray::Class() ) { cout << "This code only works with TObjArray recoparams. Sorry" << endl; return; } TObjArray* array = static_cast<TObjArray*>(o); for ( Int_t i = 0; i <= array->GetLast(); ++i ) { AliDetectorRecoParam* p = static_cast<AliDetectorRecoParam*>(array->At(i)); if (AliRecoParam::Convert(p->GetEventSpecie())==AliRecoParam::kLowMult) { cout << Form("array[%d]=%s %s %s",i, p ? p->ClassName() : "", p ? AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(p->GetEventSpecie())) :"", p ? ( p->IsDefault() ? "default" : "") : "" ) << endl; AliITSRecoParam* rp = dynamic_cast<AliITSRecoParam*>(p); if (!rp) { cout << "OUPS. OUPS" << endl; return; } rp->SetVertexer(4); // should be fast (i.e. MC) vertexer (an enum would be better for sure) } } AliCDBManager::Instance()->SetDefaultStorage(outputOCDB); AliMUONCDB::WriteToCDB(array, "ITS/Calib/RecoParam", startRun, AliCDBRunRange::Infinity(), "reconstruction parameters for ITS, patched for fake vertex finder", "L. Aphecetche"); }
//________________________________________________________ void GFHistManager::DrawObjects(Int_t layer, Int_t histNo) { // histNo starting at '0' // We must already be in the correct pad, layer and histNo must exist if(fObjLists && layer <= fObjLists->GetLast() && fObjLists->At(layer)){ TObjArray* layerLists = static_cast<TObjArray*>(fObjLists->At(layer)); if(histNo <= layerLists->GetLast() && layerLists->At(histNo)){ TObjLink *lnk = static_cast<TList*>(layerLists->At(histNo))->FirstLink(); while (lnk) { lnk->GetObject()->Draw(lnk->GetOption()); lnk = lnk->Next(); } } } }
void DrawPSF() { TCanvas* can = new TCanvas("can", "can", 1200, 400); can->Divide(3, 1, 1e-10, 1e-10); TGraph* graph[kNtheta]; for(int i = 0; i < kNtheta; i++){ TH2D tmp("", "", 1, 0, 0, 1, 0, 0); TObjArray* focused = gArray[i]->GetFocused(); for(Int_t j = 0; j <= focused->GetLast(); j++){ ARay* ray = (ARay*)(*focused)[j]; Double_t p[4]; ray->GetLastPoint(p); tmp.Fill(p[0], p[1]); } // j double meany = tmp.GetMean(2); graph[i] = new TGraph(); for(Int_t j = 0; j <= focused->GetLast(); j++){ ARay* ray = (ARay*)(*focused)[j]; Double_t p[4]; ray->GetLastPoint(p); graph[i]->SetPoint(j, p[0]/um, (p[1] - meany)/um); } // j can->cd(i + 1); gPad->DrawFrame(-300, -300, 300, 300, Form("%.1f (deg);X (#it{#mu}m);Y (#it{#mu}m)", kTheta[i])); graph[i]->SetMarkerColor(2); graph[i]->SetMarkerStyle(5); graph[i]->SetMarkerSize(0.5); graph[i]->Draw("p same"); } // i }
//________________________________________________________ TList* GFHistManager::MakeObjList(Int_t layer, Int_t histoNum) { // return list of objects to be drawn upon hists in pad histoNum of 'layer' // (to be called if 'layer' really exist!) if(!fObjLists) fObjLists = new TObjArray(fDepth); if(layer > fObjLists->GetLast() || !fObjLists->At(layer)){ fObjLists->AddAtAndExpand(new TObjArray(this->GetNumHistsOf(layer)),layer); } TObjArray* layerLists = static_cast<TObjArray*>(fObjLists->At(layer)); if(histoNum > layerLists->GetLast() || !layerLists->At(histoNum)){ layerLists->AddAtAndExpand(new TList, histoNum); } return static_cast<TList*>(layerLists->At(histoNum)); }
double GetSpotSize(ARayArray* array) { // Returns standard deviation of a spot TObjArray* focused = array->GetFocused(); TH2D h("", "", 1, 0, 0, 1, 0, 0); for(int i = 0; i < focused->GetLast(); i++){ ARay* ray = (ARay*)(*focused)[i]; double p[4]; ray->GetLastPoint(p); h.Fill(p[0], p[1]); } // i double sx = h.GetStdDev(1); double sy = h.GetStdDev(2); return TMath::Sqrt(sx*sx + sy*sy); }
Bool_t h10looper::Notify() { // The Notify() function is called when a new file is opened. This // can be either for a new TTree in a TChain or when when a new TTree // is started when using PROOF. It is normally not necessary to make changes // to the generated code, but the routine can be extended by the // user if needed. The return value is currently not used. int tn = fChain->GetTreeNumber(); if (tn != fTreeNumber) { TString fullfn = ((TChain*)fChain)->GetFile()->GetName(); TObjArray *tokens = fullfn.Tokenize("/"); TObjString *tok = (TObjString*)tokens->At(tokens->GetLast()); TString fn = tok->GetString(); data->run = ((TString)fn(*fRegExp_run)).Atoi(); data->file_anum = ((TString)((TString)fn(*fRegExp_Anum))(1,2)).Atoi(); data->filename = fn.Data(); delete tokens; } return kTRUE; }
//------------------------------------------------------------------------------------------------------------------------------------------- void BeautifyGraphs(TObjArray& array, const char* yAxisName) // Is differrent from the one in RealEfficiency.C since now the xaxis name is set in CreateRatioGraph { TGraphAsymmErrors* g; for ( Int_t i = 0 ; i <= array.GetLast() ; ++ i ) { g = static_cast<TGraphAsymmErrors*>(array.At(i)); g->SetLineStyle(1); g->SetLineColor(1); g->SetMarkerStyle(20); g->SetMarkerSize(0.7); g->SetMarkerColor(2); g->GetXaxis()->CenterTitle(kTRUE); g->GetXaxis()->SetLabelFont(22); g->GetXaxis()->SetTitleFont(22); g->GetYaxis()->SetTitle(yAxisName); g->GetYaxis()->CenterTitle(kTRUE); g->GetYaxis()->SetLabelFont(22); g->GetYaxis()->SetTitleFont(22); } }
void splitSignal_SMaTGC(TString inputFile){ ifstream input(inputFile); const int linesize=1024; char inbuf[linesize]; char inbufChain[linesize]; const int max_files = 200; int nfiles=0; while (input.getline(inbuf,linesize)) { // cout << "read line: " << inbuf << endl; if (inbuf[0] == '#') { // cout << "comment \n"; continue; } istrstream istline(inbuf); TString file_name; TString file_withCorrHisto_name; TString CorrHisto_name; // vector<TString> errNames; TString errNames; TString signal_file_name; TString channel_name_old; TString channel_name_new; istline >> file_name >> file_withCorrHisto_name >> CorrHisto_name >> errNames >> signal_file_name >> channel_name_old >> channel_name_new ; cout <<"reading file: "<<file_name<< "\t and correcting SM histo by "<< file_withCorrHisto_name<<":"<< CorrHisto_name <<"\t err anmes: "<<errNames<< endl; std::vector<TString> histos_updown_v; if (errNames!="0"){ TObjArray *strL = errNames.Tokenize(","); for (int k=0;k<strL->GetLast()+1;k++){ TString histo=((TObjString *)strL->At(k))->GetString(); histos_updown_v.push_back(histo); } delete strL; } // correcting SM histo with file_withCorrHisto:CorrHisto_name bool do_corr=false; TH1D * histo_corr=new TH1D(); if (file_withCorrHisto_name!="0" && CorrHisto_name!="0"){ cout <<" -> correcting SM histo by "<< file_withCorrHisto_name<<":"<< CorrHisto_name << endl; TFile * file_withCorrHisto=new TFile(file_withCorrHisto_name,"read"); file_withCorrHisto->cd(); histo_corr=(TH1D*)(file_withCorrHisto->Get(CorrHisto_name)->Clone("clone_name")); do_corr=true; } TH1D * plot_SM=new TH1D("plot_SM","plot_SM",10,0.,10.); TFile * file_in=new TFile(file_name,"read"); file_in->cd(); // file_in->ls(); TList * list_histos=file_in->GetListOfKeys(); TString file_out=file_name; file_out=file_out.ReplaceAll(channel_name_old,channel_name_new); cout <<" ----> output: "<< file_out<<"\n" << endl; TFile *outFile=new TFile(file_out,"recreate"); outFile->cd(); for (int i=0;i<list_histos->GetEntries();i++){ // read histos one by one TString histo_name= list_histos->At(i)->GetName(); cout <<"\treading histo \""<< histo_name <<"\""<< endl; // from "diboson" make: "dibosonSM"="diboson" and "diboson"=histo with all bin contents equal to 1! // check if this is one of syst up/down histos affecting signal bool signal_syst=false; // int signal_syst=false; for (int j=0;j<histos_updown_v.size();j++){ TString name=histo_name; name.ReplaceAll("Up",""); name.ReplaceAll("Down",""); if (histos_updown_v[j]==name) signal_syst=true; } if (histo_name=="diboson"){ cout << "\t -> reading diboson"<< endl; // save "diboson" as "dibosonSM" TH1D * plot_diboson=(TH1D*)(file_in->Get(histo_name)->Clone("namec")); plot_SM=(TH1D*)(file_in->Get(histo_name)->Clone("somename")); plot_diboson=(TH1D*)(file_in->Get(histo_name)->Clone("namej")); plot_diboson->SetName("dibosonSM"); // correcting with histo file_withCorrHisto:CorrHisto_name if(do_corr){ plot_diboson->Multiply(histo_corr); } plot_diboson->Write(); plot_SM->Write("dibosonSM_origi"); // create "diboson" histo with all bin contents equal to 1! TH1D * plot_aTGC=(TH1D*)(file_in->Get(histo_name)->Clone("name_histo_atgc")); plot_aTGC->SetName("diboson"); int N_bins=plot_aTGC->GetNbinsX(); for (int j=1;j<=N_bins;j++) plot_aTGC->SetBinContent(j,1.); plot_aTGC->Write(); // make corr_err histos on SM and aTGC -> relative error from correction histo if(do_corr){ // SM: TH1D * plot_SM_up=(TH1D*)(plot_diboson->Clone("name_histo_atgcX")); for (int j=1;j<=N_bins;j++){ plot_SM_up->SetBinContent(j,plot_SM_up->GetBinContent(j)*(1.+histo_corr->GetBinError(j)/histo_corr->GetBinContent(j))); } plot_SM_up->Write("CMS_hzz2l2v_ewkUp"); TH1D * plot_SM_down=(TH1D*)(plot_diboson->Clone("name_histo_atgcX")); for (int j=1;j<=N_bins;j++){ plot_SM_down->SetBinContent(j,plot_SM_down->GetBinContent(j)*(1.-histo_corr->GetBinError(j)/histo_corr->GetBinContent(j))); } plot_SM_down->Write("CMS_hzz2l2v_ewkDown"); // aTGC: TH1D * plot_aTGC_up=(TH1D*)(plot_aTGC->Clone("name_histo_atgcX")); for (int j=1;j<=N_bins;j++){ plot_aTGC_up->SetBinContent(j,plot_aTGC_up->GetBinContent(j)*(1.+histo_corr->GetBinError(j)/histo_corr->GetBinContent(j))); } plot_aTGC_up->Write("diboson_corrUp"); TH1D * plot_aTGC_down=(TH1D*)(plot_aTGC->Clone("name_histo_atgcX2")); for (int j=1;j<=N_bins;j++){ plot_aTGC_down->SetBinContent(j,plot_aTGC_down->GetBinContent(j)*(1.-histo_corr->GetBinError(j)/histo_corr->GetBinContent(j))); } plot_aTGC_down->Write("diboson_corrDown"); } } else if (signal_syst) { // if this is signal syst then save this and create aTGC syst plot with the same relative error cout << "\t -> reading signal unc"<< endl; TH1D* plot_unc=(TH1D*)(file_in->Get(histo_name)->Clone("name_histo_atgc2")); int N_bins=plot_unc->GetNbinsX(); TString name_origi_syst=histo_name; name_origi_syst=name_origi_syst.ReplaceAll("Up","origiUp"); name_origi_syst=name_origi_syst.ReplaceAll("Down","origiDown"); plot_unc->Write(name_origi_syst); plot_unc->Multiply(histo_corr); TString name_SM_syst=histo_name; name_SM_syst=name_SM_syst.ReplaceAll("Up","SMUp"); name_SM_syst=name_SM_syst.ReplaceAll("Down","SMDown"); plot_unc->Write(name_SM_syst); TH1D * plotSM=(TH1D*)(file_in->Get("diboson")->Clone("name_histo_atgc3")); for (int j=1;j<=N_bins;j++){ plot_unc->SetBinContent(j,plot_unc->GetBinContent(j)/plot_diboson->GetBinContent(j)); } TString name_atgc_syst=histo_name; name_atgc_syst=name_atgc_syst.ReplaceAll("Up","aTGCUp"); name_atgc_syst=name_atgc_syst.ReplaceAll("Down","aTGCDown"); plot_unc->Write(histo_name); cout << "\t\t -> saving as: "<< name_atgc_syst<< endl; } else{ // simply save histo TH1D * plot=(TH1D*)(file_in->Get(histo_name)->Clone("name_histo_atgc4")); int N_bins=plot->GetNbinsX(); plot->Write(histo_name); } } cout <<" ---> reading signal file: "<< signal_file_name << endl; TFile * file_in_signal=new TFile(signal_file_name,"read"); file_in_signal->cd(); // file_in_signal->ls(); TList * list_histos_signal=file_in_signal->GetListOfKeys(); TString file_out_signal=signal_file_name; file_out_signal=file_out_signal.ReplaceAll(channel_name_old,channel_name_new); cout <<" ----> output: "<< file_out_signal<<"\n" << endl; TFile *outFile_signal=new TFile(file_out_signal,"recreate"); outFile_signal->cd(); TH2D * histo_1=new TH2D(); histo_1=(TH2D*)(file_in_signal->Get("bin_content_lam_dk_1")->Clone("something")); for (int i=1;i<=histo_1->GetNbinsX();i++) for (int j=1;j<=histo_1->GetNbinsY();j++) histo_1->SetBinContent(i,j,-1.); int N_signal_histos=0; for (int i=0;i<list_histos_signal->GetEntries();i++){ // read histos one by one TString histo_name= list_histos_signal->At(i)->GetName(); cout <<"\treading histo \""<< histo_name <<"\""<< endl; if (!histo_name.Contains("_lam_dk_")) continue; N_signal_histos++; TH2D * plot_signal=(TH2D*)(file_in_signal->Get(histo_name)->Clone("namec2")); plot_signal->Add(histo_1); plot_signal->Scale(plot_SM->GetBinContent(N_signal_histos)); // check if signal<0->setTo0! for (int ii=1;ii<=histo_1->GetNbinsX();ii++){ for (int jj=1;jj<=histo_1->GetNbinsY();jj++){ if (plot_signal->GetBinContent(ii,jj)<0.){ // cout <<"~~~~~~~~~~~~~~~~~ found bin with signal<0 -> setTo0! "<< histo_name<<" bin: "<< i<<","<<j << endl; plot_signal->SetBinContent(ii,jj,0.); } } } plot_signal->Write(histo_name); delete plot_signal; } } outFile->Close(); outFile_signal->Close(); file_in->Close(); }
void RayTrace(AOpticsManager* manager, TCanvas* can3D) { const int kNdeg = 8; TH2D* h2[kNdeg]; TGraph* graph = new TGraph(); TCanvas* can = new TCanvas("can", "can", 900, 900); TCanvas* can2= new TCanvas("can2", "can2", 900, 900); can->Divide(3, 3, 1e-10, 1e-10); TH2D* hMirror = new TH2D("hMirror", ";X (mm);Y (mm)", 1000, -7, 7, 1000, -7, 7); for(int i = 0; i < kNdeg; i++){ double deg = i*0.5; TGeoTranslation raytr("raytr", -2*kF*TMath::Sin(deg*TMath::DegToRad()), 0, 2*kF*TMath::Cos(deg*TMath::DegToRad())); TVector3 dir; dir.SetMagThetaPhi(1, TMath::Pi() - deg*TMath::DegToRad(), 0); double lambda = 400*nm; // dummy ARayArray* array = ARayShooter::Square(lambda, 14*m, 401, 0, &raytr, &dir); manager->TraceNonSequential(*array); h2[i] = new TH2D("", Form("#it{#theta} = %3.1f#circ;x (mm); y (mm)", deg), 200, -40, 100, 200, -70, 70); TH2D tmp("", "", 100, -1e5, 1e5, 100, -1e5, 1e5); TObjArray* focused = array->GetFocused(); for(Int_t j = 0; j <= focused->GetLast(); j++){ ARay* ray = (ARay*)(*focused)[j]; Double_t p[4]; ray->GetLastPoint(p); tmp.Fill(p[0], p[1]); if (i == 0) { int n = ray->FindNodeNumberStartWith("mirror"); const double* pn = ray->GetPoint(n); hMirror->Fill(pn[0]/m, pn[1]/m); } // if if (i == kNdeg - 1 && gRandom->Uniform() < 0.001) { TPolyLine3D* pol = ray->MakePolyLine3D(); pol->SetLineColor(2); can3D->cd(); pol->Draw(); } // if } // j double meanx = tmp.GetMean(); for(Int_t j = 0; j <= focused->GetLast(); j++){ ARay* ray = (ARay*)(*focused)[j]; Double_t p[4]; ray->GetLastPoint(p); h2[i]->Fill((p[0] - meanx)/mm, p[1]/mm); } // j can->cd(i + 1); h2[i]->Draw("colz"); if(i == 0){ can2->cd(); hMirror->Draw("colz"); } // i delete array; } // i }
int main(int argc, char* argv[]){ if (argc != 6){ std::cout << "wrong number of arguments: usage ./topDataClass_doAnalysis <file name> <mod #> <row #> <col #> <ch #>" << std::endl; return 0; } //define application object theApp = new TApplication("App", &argc, argv); TString inputFileName = theApp->Argv()[1]; std::cout << "Input file name " << inputFileName << std::endl; //create target6 interface object topDataClass *data = new topDataClass(); //specify channel of interest int inMod = atoi(theApp->Argv()[2]); int inRow = atoi(theApp->Argv()[3]); int inCol = atoi(theApp->Argv()[4]); int inCh = atoi(theApp->Argv()[5]); data->setAnalysisChannel( inMod, inRow, inCol, inCh ); //specify timing marker channel data->setTimingMarkerChannel( 0, 0, 1, 2 ); //specify time window data->windowTime = windowTime; //open summary tree file data->openSummaryTree(inputFileName); //create output file TObjArray* strings = inputFileName.Tokenize("/"); TObjString* objstring = (TObjString*) strings->At(strings->GetLast()); TString inputFileNameBase(objstring->GetString()); TString outputFileName = "output_topDataClass_doAnalysis_doublePulseSampleDTFit_"; outputFileName += inMod; outputFileName += "_"; outputFileName += inRow; outputFileName += "_"; outputFileName += inCol; outputFileName += "_"; outputFileName += inCh; outputFileName += "_"; outputFileName += inputFileNameBase; //outputFileName += ".root"; std::cout << " outputFileName " << outputFileName << std::endl; outputFile = new TFile( outputFileName , "RECREATE"); //initialize histograms initializeGlobalHistograms(); //initialize tree branches data->setTreeBranches(); //load pulse info into arrays data->selectPulsesForArray(); //loop over selected events, apply corrections histogram pulse time distributions //monitor pulse time vs event # gPulseTimeVsEventNum = new TGraphErrors(); for(int entry = 0; entry < data->numUsed; entry++) { //skip events not in arrays if( entry >= maxNumEvt ) continue; double pulseTime = data->measurePulseTimeArrayEntry(entry,1); double pulseHeight = data->adc_0_A[entry]; int smpBinNumIn128Array = data->getSmpBinNumIn128Array(entry); double smpPos = data->getSmpPos(entry); //apply analysis cuts //if( smpBinNumIn128Array >= 127 ) // continue; //measure pulse time vs event # gPulseTimeVsEventNum->SetPoint( gPulseTimeVsEventNum->GetN() , data->eventNum_A[entry], pulseTime ); //cut on event # if( data->eventNum_A[entry] < 0 ) continue; //histogram selected pulse distributions hPulseHeightInitial->Fill( data->adc_0_A[entry] ); hPulseTimeInitial->Fill( pulseTime ); hPulseSampleInitial->Fill(data->smp_0_A[entry]); hPulseSmp128Initial->Fill(smpBinNumIn128Array); hPulseTimeVsSmp128Initial->Fill(smpBinNumIn128Array, pulseTime ); hPulseTimeVsSmp128PosInitial->Fill(smpBinNumIn128Array + smpPos, pulseTime ); hPulseTimeVsHeightInitial->Fill(pulseHeight, pulseTime ); hPulseTimeVsFTSWInitial->Fill(data->ftsw_A[entry], pulseTime ); hFTSWVsSmp128Initial->Fill(smpBinNumIn128Array, data->ftsw_A[entry]); } //loop over selected events, measure time difference between timing marker and selected channel pulses gTest = new TGraphErrors(); data->measurePulseMarkerTimeDifferenceDistribution(hPulseTimeMarkTimeDiffInitial,hPulseTimeMarkTimeDiffVsMarkSmpBinNumInitial ); //run fit analysis doDoublePulseFit(data); //write output file writeOutputFile(); //delete target6 data object delete data; return 1; }
void SkimChain(TChain* chain, const TString DataDir, TString SkimDir, TString skimname){ TObjArray *listOfFiles = chain->GetListOfFiles(); TIter fileIter(listOfFiles); TPRegexp fileNameMatchPattern("(.*?)/([^/]*)$"); TPRegexp dataDirMatchPattern(DataDir); unsigned int nEventsTotal = 0; unsigned int nEventsSelectedTotal = 0; std::vector<FileEntry> files; while (TChainElement *currentFile = (TChainElement*)fileIter.Next()) { FileEntry file; TObjArray* matches = fileNameMatchPattern.MatchS(currentFile->GetTitle()); assert(matches); assert(matches && matches->GetLast()==2); TString inputFileName(currentFile->GetTitle()); TString fileName(((TObjString*)matches->At(2))->GetString()); file.fileName = fileName.Data(); TString outputDirectory(((TObjString*)matches->At(1))->GetString()); file.inputDir = outputDirectory.Data(); dataDirMatchPattern.Substitute(outputDirectory,SkimDir); outputDirectory += "/" + skimname; file.outputDir = outputDirectory.Data(); // make output directory if it doesn't exist yet if ( gSystem->AccessPathName(outputDirectory.Data()) ){ gSystem->mkdir(outputDirectory.Data(),true); assert( !gSystem->AccessPathName(outputDirectory.Data()) ); } TString outputFileName(outputDirectory+"/"+fileName); cout << "Skimming " << inputFileName << " -> " << outputFileName << endl; TFile *output = TFile::Open(outputFileName.Data(), "RECREATE"); assert(output); TFile *input = TFile::Open(inputFileName.Data()); assert(input); TTree *tree = (TTree*)input->Get("Events"); TTree *newtree = tree->CloneTree(0); newtree->SetDirectory(output); cms2.Init(newtree); cms2.Init(tree); // Event Loop const unsigned int nEvents = tree->GetEntries(); unsigned int nEventsSelected = 0; int i_permille_old = 0; for (unsigned int event = 0; event < nEvents; ++event, ++nEventsTotal) { int i_permille = (int)floor(10000 * event / float(nEvents)); if (i_permille != i_permille_old) { // xterm magic from L. Vacavant and A. Cerri if (isatty(1)) { printf("\015\033[32m ---> \033[1m\033[31m%5.2f%%" "\033[0m\033[32m <---\033[0m\015", i_permille/100.); fflush(stdout); } i_permille_old = i_permille; } cms2.GetEntry(event); //set condition to skip event if ( not passedSkimSelection() ) continue; ++nEventsSelected; cms2.LoadAllBranches(); // fill the new tree newtree->Fill(); } file.nIn = nEvents; file.nOut = nEventsSelected; files.push_back(file); nEventsSelectedTotal += nEventsSelected; output->cd(); newtree->Write(); output->Close(); input->Close(); } cout << Form("Processed events: %u, \tselected: %u\n",nEventsTotal,nEventsSelectedTotal) << endl; }