//___________________________________________________________ void DecodeDataString(const TString &datastring, TString &sample, TArrayI &listofruns){ TObjArray *toks = datastring.Tokenize(":"); sample = (dynamic_cast<TObjString *>(toks->At(0)))->String(); TString &listrunstring = (dynamic_cast<TObjString *>(toks->At(1)))->String(); TObjArray *runstrings = listrunstring.Tokenize(","); TIter runiter(runstrings); listofruns.Set(runstrings->GetEntriesFast()); TObjString *myrunstring = NULL; Int_t counter = 0; while((myrunstring = dynamic_cast<TObjString *>(runiter()))) listofruns[counter++] = myrunstring->String().Atoi(); // Print summary: printf("Selected sample: %s\n", sample.Data()); printf("========================================\n"); for(Int_t irun = 0; irun < listofruns.GetSize(); irun++){ printf("\trun %d\n", listofruns[irun]); } printf("\n"); delete toks; delete runstrings; }
void DrawNetworkMovie( TFile* file, const TString& methodType, const TString& methodTitle ) { TString dirname = methodType + "/" + methodTitle + "/" + "EpochMonitoring"; TDirectory *epochDir = (TDirectory*)file->Get( dirname ); if (!epochDir) { cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl; exit(1); } epochDir->cd(); // loop over all epoch-wise monitoring histograms TIter keyIt(epochDir->GetListOfKeys()); TKey *key; vector<TString> epochList; Int_t ic = 0; while ((key = (TKey*)keyIt())) { if (!gROOT->GetClass(key->GetClassName())->InheritsFrom("TH2F")) continue; TString name = key->GetName(); if (!name.BeginsWith("epochmonitoring___")) continue; // extract epoch TObjArray* tokens = name.Tokenize("_"); TString es = ((TObjString*)tokens->At(2))->GetString(); // check if done already Bool_t isOld = kFALSE; for (vector<TString>::const_iterator it = epochList.begin(); it < epochList.end(); it++) { if (*it == es) isOld = kTRUE; } if (isOld) continue; epochList.push_back( es ); // create bulk file name TString bulkname = Form( "epochmonitoring___epoch_%s_weights_hist", es.Data() ); // draw the network if (ic <= 60) draw_network( file, epochDir, bulkname, kTRUE, es ); ic++; } }
void TGo4TreeViewer::ProcessDropEvent(QGo4LineEdit* edt, bool caninit) { QString value = edt->text(); TGo4BrowserProxy* br = Browser(); if (br==0) return; if (fxTreeName.length()==0) { if (!caninit) { StatusMessage("First drop something on X, Y or Z field"); edt->setText(""); return; } TString treename; if (!br->DefineTreeName(value.toLatin1().constData(), treename)) { StatusMessage(QString("Invalid tree ") + value); edt->setText(""); return; } fxTreeName = treename.Data(); setToolTip(QString("Selected tree: ") + fxTreeName); TreeDrawBtn->setEnabled(true); AddLink(treename.Data(), "Tree"); } TString leafname; if (!br->DefineLeafName(value.toLatin1().constData(), fxTreeName.toLatin1().constData(), leafname)) { edt->setText(""); StatusMessage(QString("Invalid leaf name ") + value); return; } // count number of [ and replace by [] // this means, by default accumulate over all members TObjArray* it=leafname.Tokenize("["); leafname=((TObjString *)it->First())->GetName(); for(Int_t i=1;i<it->GetEntriesFast();i++) leafname.Append("[]"); edt->setText(leafname.Data()); edt->setFocus(); it->Delete(); }
//_______________________________________ TObjArray* GetTerminateOptions ( TString taskOpt, Bool_t isMC ) { TObjArray* terminateList = 0x0; if ( ! taskOpt.IsNull() ) { TObjArray* optList = taskOpt.Tokenize(";"); for ( Int_t iopt=0; iopt<optList->GetEntries(); iopt++ ) { TString currOpt = (static_cast<TObjString*>(optList->At(iopt)))->GetString(); if ( ! currOpt.Contains("@") ) continue; TObjArray* tmpList = currOpt.Tokenize("@"); if ( tmpList->GetEntries() == 4 ) { terminateList = tmpList; break; } delete tmpList; } delete optList; } else { terminateList = new TObjArray(4); terminateList->SetOwner(); TString physSel = "", trigClasses = "", centr = "", furtherOpt = ""; if ( isMC ) { physSel = "PhysSelPass,PhysSelReject"; trigClasses = "ANY"; centr = "-5_105"; furtherOpt = "MC verbose"; } //TString GetPeriod(opt); terminateList->AddAt(new TObjString(physSel),0); terminateList->AddAt(new TObjString(trigClasses),1); terminateList->AddAt(new TObjString(centr),2); terminateList->AddAt(new TObjString(furtherOpt),3); } // if ( terminateList ) { // printf("Printing terminate list\n"); // REMEMBER TO CUT // PrintNames("Terminate options", terminateList); // printf(" ***************:\n"); // } return terminateList; }
void MakeSpinPlots::PlotSignalFits(TString tag, TString mcName,TString cosThetaBin){ TCanvas cv; TString cat=tag; if(cosThetaBin!="") tag = tag+"_"+cosThetaBin; float mean = ws->var(Form("%s_FIT_%s_mean",mcName.Data(),tag.Data()))->getVal(); RooPlot *frame = ws->var("mass")->frame(105,140,70);//mean-10,mean+10,40); RooAbsData *d = ws->data(mcName+"_Combined")->reduce(TString("evtcat==evtcat::")+cat); if(cosThetaBin!=""){ TObjArray *arr = cosThetaBin.Tokenize("_"); float low = atof(arr->At(1)->GetName()); float high = atof(arr->At(2)->GetName()); d = d->reduce( Form("cosT < %0.2f && cosT >= %0.2f",high,low) ); delete arr; } d->plotOn(frame); RooFitResult *res = (RooFitResult*)ws->obj(Form("%s_FIT_%s_fitResult",mcName.Data(),tag.Data())); RooAbsPdf * pdf = ws->pdf(Form("%s_FIT_%s",mcName.Data(),tag.Data())); //signal model std::cout << pdf << "\t" << res << std::endl; pdf->plotOn(frame,RooFit::FillColor(kGreen),RooFit::VisualizeError(*res,2.0)); pdf->plotOn(frame,RooFit::FillColor(kYellow),RooFit::VisualizeError(*res,1.0)); pdf->plotOn(frame,RooFit::LineColor(kRed)); d->plotOn(frame); //data tPair lbl(mcName,tag); TLatex *prelim = new TLatex(0.18,0.9,"CMS Preliminary Simulation"); TLatex *sigL = new TLatex(0.18,0.6,Form("#sigma_{eff} = %0.2f GeV",fitSigEff[lbl].first,fitSigEff[lbl].second)); prelim->SetNDC(); sigL->SetNDC(); prelim->SetTextSize(0.05); sigL->SetTextSize(0.05); frame->addObject(prelim); frame->addObject(sigL); frame->Draw(); cv.SaveAs(basePath+Form("/signalModels/sig_%s_%s_%s.png",mcName.Data(),outputTag.Data(),tag.Data())); cv.SaveAs(basePath+Form("/signalModels/C/sig_%s_%s_%s.C",mcName.Data(),outputTag.Data(),tag.Data())); cv.SaveAs(basePath+Form("/signalModels/sig_%s_%s_%s.pdf",mcName.Data(),outputTag.Data(),tag.Data())); }
void DrawSysWatchTime(){ TString prefix="/hera/alice/marsland/MAF/MAFbenchmark/mcmaker/workdir/test_6_375000_25_20140713_20/"; TString listSyswatch = gSystem->GetFromPipe(Form("ls %s/*/mult_10000/event_1/simwatch.log",prefix.Data())); TObjArray * arraySyswatch= listSyswatch.Tokenize("\n"); Int_t nfiles= arraySyswatch->GetEntries(); TTree * treeSyswatch[] = new TTree*[nfiles]; for (Int_t ifile=0; ifile<nfiles; ifile++){ treeSyswatch[ifile] = AliSysInfo::MakeTree(arraySyswatch->At(ifile)->GetName()); treeSyswatch[0]->AddFriend( treeSyswatch[ifile],Form("T%d",ifile)); } treeSyswatch[0]->Draw("deltaT:sname","deltaT>1",""); for (Int_t ifile=1; ifile<nfiles; ifile++){ treeSyswatch[0]->SetMarkerStyle(25); treeSyswatch[0]->SetMarkerColor(1+ifile); treeSyswatch[0]->Draw(Form("T%d.stampSec-T%d.stampOldSec:sname",ifile,ifile),"deltaT>1","same"); } }
//_____________________________________________________________________________ void ProofSimpleFile::Begin(TTree * /*tree*/) { // The Begin() function is called at the start of the query. // When running with PROOF Begin() is only called on the client. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // Number of histograms (needed in terminate) Ssiz_t iopt = kNPOS; if (fInput->FindObject("ProofSimpleFile_NHist")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimpleFile_NHist")); fNhist = (p) ? (Int_t) p->GetVal() : fNhist; } else if ((iopt = option.Index("nhist=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi(); } }
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 cacheGeometry( const Char_t *tag, const Char_t *addons ) { TFile *file = new TFile(Form("%s.root",tag)); if ( file->IsZombie() || nocache ) { delete file; const Char_t *path = ".:./StarVMC/Geometry/macros/:$STAR/StarVMC/Geometry/macros/"; Char_t *file = gSystem->Which(path,"loadStarGeometry.C",kReadPermission); cout << "Loading macro: " << file << endl; gROOT -> ProcessLine(Form(".L %s",file)); // Load development geometry // loadDevStarGeometry(tag); loadStarGeometry(tag); TString addOns = addons; TObjArray *array = addOns.Tokenize(" ,;"); for ( Int_t i = 0; i<array->GetEntries(); i++ ) { TObjString *str = (TObjString *)array->At(i); cout << "Adding module " << str->String().Data() << endl; addModule ( str->String() ); } // Close the geometry gGeoManager->CloseGeometry(); ColorScheme(); gGeoManager->Export(Form("%s.root",tag)); } delete file; // gROOT -> Reset(); }
void ProcYields::Proc_hYW(){ Info("Proc_hYW()", ""); TDirectory* dirhYW = _fout->mkdir("hYW"); TH1F* hYW[nVARSET]; TDirectory* dirVarset=NULL; for(Int_t iVarset=0;iVarset<nVARSET;iVarset++){ Info("Proc_hYW()","Varset = Varset%d", iVarset+1); dirVarset=dirhYW->mkdir(TString::Format("Varset%d",iVarset+1)); dirVarset->cd(); hYW[iVarset] = new TH1F("hYW","hYW", _user.nWbins, _user.Wmin, _user.Wmax); hYW[iVarset]->SetXTitle("W[GeV]"); //!Loop over Q2W dirs, get h5Ds and their yields TIter nextkey(_fout->GetListOfKeys()); TKey *key; while (key = (TKey*)nextkey()) { TString Q2Wdirname = key->GetName(); if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue; Info("Proc_hYW()","Q2Wdir = %s", Q2Wdirname.Data()); TString wrange = Q2Wdirname.Tokenize("_")->At(1)->GetName(); TString wlow = wrange.Tokenize(",")->At(0)->GetName(); wlow.Remove(0,1); //remove "[" //Float_t w = wlow.Atof(); Double_t w = wlow.Atof(); sprintf(_hname, "%s/hY5D/Varset%d/hY5D_FULL", Q2Wdirname.Data(),iVarset+1); THnSparse* hY5D_FULL = (THnSparse*)_fout->Get(_hname); if (hY5D_FULL == NULL) cout <<"could not get h5D" << endl; //Float_t yield = getIntegral(hY5D_FULL); Double_t yield = getIntegral(hY5D_FULL); //hYW[iVarset]->Fill(w, yield); hYW[iVarset]->SetBinContent(hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield); Info("Proc_hYW()","W = %f, bin# = %d, yield = %f\n", w, hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield); } } Info("Proc_hYW()", "done\n"); }
/** * Function to run a train. * * @param name Name of the train. * @param cls class name of train setup * @param uri Exection URI * @param opts Optons * * @return true on success * * @ingroup pwglf_forward_trains */ Bool_t RunTrain(const TString& name, const TString& cls, const TUrl& uri, const TString& opts) { // Check for help if (name.IsNull() || name.EqualTo("help", TString::kIgnoreCase) || cls.IsNull() || cls.EqualTo("help", TString::kIgnoreCase) || !uri.IsValid()) { PlainUsage(); return true; } Bool_t verb = opts.Contains("verbose"); // Build our helpers if (!BuildRailways(verb, false, true)) return false; // Tokenize options if (!opts.EndsWith(",")) opts.Append(","); opts.Append("url="); opts.Append(uri.GetUrl()); TObjArray* optList = opts.Tokenize(","); return TrainSetup::Main(name, cls, optList, false); }
bool getFileMultiStringValue( const char* inFile, const char* parameterName, int& nvals, char returnVals[][1000] ) { // Include a blank space at the end to avoid multiple // matches in grep when target is a substring found in other lines. char command[10000] ; sprintf( command, "grep \"%s \" %s\n", parameterName, inFile ) ; TString commandOutput = gSystem->GetFromPipe( command ) ; /// printf( " Output of command is : %s\n", commandOutput.Data() ) ; char label[1000] ; sscanf( commandOutput.Data(), "%s", label ) ; if ( strcmp( label, parameterName ) == 0 ) { printf(" Found %s. \n", parameterName ) ; TObjArray* strings = commandOutput.Tokenize(" ") ; printf(" Breaks into %d tokens.\n", strings -> GetEntries() ) ; nvals = strings -> GetEntries() - 1 ; for ( int i=0; i<nvals; i++ ) { TObjString* str = (TObjString*) (strings->At(i+1)) ; printf( " string %d : %s\n", i, str->GetString().Data() ) ; sprintf( returnVals[i], "%s", str->GetString().Data() ) ; } return true ; } printf("\n\n *** Could not find parameter %s in file %s.\n\n", parameterName, inFile ) ; return false ; }
void KVNumberList::ParseAndFindLimits(TString & string, const Char_t delim) { //Takes a string and breaks it up into its constituent parts, //which were initially separated by white space or a comma. //Any part which contains "-" will be sent to AddLimits(). TObjArray *toks1 = string.Tokenize(delim); Int_t n_toks = toks1->GetEntries(); for (register int i = 0; i < n_toks; i++) { TString tok = ((TObjString *) (*toks1)[i])->GetString(); KVString kvtok(tok); if (tok.Contains(',')) ParseAndFindLimits(tok, ','); else if (tok.Contains(' ')) ParseAndFindLimits(tok, ' '); else if (tok.Contains('-')) { AddLimits(tok); } else if (kvtok.IsDigit()) { Int_t val = kvtok.Atoi(); AddLimits(val, val); } } delete toks1; }
//################################################## bool LoadLibList ( const TString& list, TString& listlibs, TString& listlibsextra ) { TObjArray* arr = list.Tokenize(" "); TObjString *objstr = NULL; cout << "Loading library list (-2 = version mismatch, -1 = not found or error, 0 = success, 1 = already loaded) :" << endl; TIter next(arr); while ( (objstr=(TObjString*)next()) ) { TString module = objstr->GetString(); if (module.IsNull()) { continue; } module.Prepend("lib"); if(module.EndsWith(".so")) { module.Remove( module.Index(".so")); } std::cout << "loading module :" << module.Data() << " ... " ; int result = gSystem->Load(module.Data(), "", kTRUE); std::cout << result << std::endl; ; if (result < 0) { std::cout << "EmcalJetCDF::LoadLibList - Could not load library >>>" << module.Data() << "<<< ; Error = " << result << std::endl; return false; } TString lib_in_list = module + ".so "; // blank after .so listlibs += lib_in_list; listlibsextra += lib_in_list; } delete arr; return true; }
//______________________________________________________________________________ void AODmerge() { // Merging method. No staging and no terminate phase. TStopwatch timer; timer.Start(); TString outputDir = "wn.xml"; TString outputFiles = "EventStat_temp.root,AODQA.root,AliAOD.root,AliAOD.VertexingHF.root,AliAODGammaConversion.root,FilterEvents_Trees.root,AliAOD.Muons.root"; TString mergeExcludes = ""; TObjArray *list = outputFiles.Tokenize(","); TIter *iter = new TIter(list); TObjString *str; TString outputFile; Bool_t merged = kTRUE; while((str=(TObjString*)iter->Next())) { outputFile = str->GetString(); // Skip already merged outputs if (!gSystem->AccessPathName(outputFile)) { printf("Output file <%s> found. Not merging again.",outputFile.Data()); continue; } if (mergeExcludes.Contains(outputFile.Data())) continue; merged = AliAnalysisAlien::MergeOutput(outputFile, outputDir, 10, 0); if (!merged) { printf("ERROR: Cannot merge %s\n", outputFile.Data()); continue; } } // all outputs merged, validate AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); mgr->InitAnalysis(); mgr->SetGridHandler(new AliAnalysisAlien); mgr->StartAnalysis("gridterminate",0); ofstream out; out.open("outputs_valid", ios::out); out.close(); timer.Print(); }
void myAna::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); string JSONPATH = ""; cout<<"option = "<<option.Data()<<endl; TObjArray *args = (TObjArray*)option.Tokenize(" "); if (args->GetSize()>1) JSONPATH = (string)((TObjString*)args->At(0))->GetString(); // Will count events passing by each pad separately. // Now, set them all to zero: for (size_t n=0; n<nC; n++){ nEvents[static_cast<UInt_t>(PadsEnum::SiPad1)][n]=0; nEvents[static_cast<UInt_t>(PadsEnum::SiPad2)][n]=0; nEvents[static_cast<UInt_t>(PadsEnum::SiPad3)][n]=0; nEvents[static_cast<UInt_t>(PadsEnum::SiPad4)][n]=0; nEvents[static_cast<UInt_t>(PadsEnum::SiPad5)][n]=0; nEvents[static_cast<UInt_t>(PadsEnum::SiPad6)][n]=0; nEvents[0][n]=0; } pt::read_json(JSONPATH, TB_RUNS_DATA); fProofFile = new TProofOutputFile("TB_2016_myHistograms.root"); fOutput->Add(fProofFile); // Open the file histoFile = fProofFile->OpenFile("RECREATE"); TH1::SetDefaultSumw2(kTRUE); hists = new HistManager(histoFile); }
//_______________________________________________________________________________________________ // // Initialize plugin with all its common values // Bool_t CreatePlugin() { // create object plugin = new AliAnalysisAlien; // framework version plugin->SetROOTVersion(rootVersion.Data()); plugin->SetAliROOTVersion(aliVersion.Data()); // additional libraries/includes if (addLibs.Length() > 0) plugin->SetAdditionalLibs(addLibs.Data()); if (addIncludes.Length() > 0) plugin->AddIncludePath(addIncludes.Data()); // runtime tasks if (addTaskRuntime.Length() > 0) { TObjArray *list = addTaskRuntime.Tokenize(" "); TObjArrayIter next(list); TObjString *os = 0x0; TString sources(""); while ( (os = (TObjString*)next()) ) { const char *taskName = os->GetString().Data(); addLibs.Append(Form("%s.h %s.cxx", taskName, taskName)); sources.Append(Form("%s.cxx", taskName)); } plugin->SetAnalysisSource(sources.Data()); } // specific setups if (targetAlien) { ::Info("SetupPlugin::CreatePlugin()", "Setting up for ALIEN"); return SetupForAlien(); } else { ::Info("SetupPlugin::CreatePlugin()", "Setting up for PROOF"); return SetupForProof(); } }
void IRODS::ExtractFileInfos(TString& s, DMSFile_t* f) const { // extract info (name, size, modification date) from listing line // such as : // indramgr 0 diskcache2 208207872 2009-10-06.16:56 & run_0002.dat.15-Feb-07.18:00:58 // indramgr 1 HPSS2 208207872 2009-10-06.16:56 & run_0002.dat.15-Feb-07.18:00:58 // indramgr 0 diskcache2 208224256 2009-10-06.16:56 & run_0003.dat.15-Feb-07.20:21:50 // indramgr 1 HPSS2 208224256 2009-10-06.16:56 & run_0003.dat.15-Feb-07.20:21:50 // // note that when used outside of CCIN2P3, only 'ils' works, not 'ils -l', so the listing looks like: // run_0002.dat.15-Feb-07.18:00:58 // run_0003.dat.15-Feb-07.20:21:50 #ifdef CCIN2P3_BUILD TObjArray* fstats = s.Tokenize(" "); f->SetName(((TObjString*)(*fstats)[fstats->GetEntries() - 1])->String().Remove(TString::kBoth, ' ').Data()); f->SetSize((UInt_t)((TObjString*)(*fstats)[3])->String().Remove(TString::kBoth, ' ').Atoi()); KVDatime mt(((TObjString*)(*fstats)[4])->String().Remove(TString::kBoth, ' ').Data(), KVDatime::kIRODS); f->SetModTime(mt); delete fstats; #else f->SetName(s.Remove(TString::kBoth, ' ')); #endif }
TGraph *getScopeFFTNormToArea(char *fileName) { ifstream CsvFile(fileName); int numLines=0; int numLines2=0; TString line; Double_t xVals[100000]; Double_t yVals[100000]; while(line.ReadLine(CsvFile)) { // cout << line.Data() << endl; TObjArray *vals = (TObjArray*) line.Tokenize(","); // vals.Dump(); TObjString *x=vals->At(0); TObjString *y=vals->At(1); // cout << vals[0].Data() << "\t" << vals[1].Data() << endl; // cout << x->GetString()->Data() << "\t" << y->GetString()->Data() << endl; xVals[numLines]=x->GetString().Atof(); yVals[numLines]=y->GetString().Atof(); numLines++; } Double_t N=numLines*2; Double_t deltaF=(xVals[1]-xVals[0])/1e6; Double_t deltaT=1e-6./(N*deltaF); // cout << deltaT << endl; for(int i=0;i<numLines;i++) { xVals[i]=i*deltaF; yVals[i]=TMath::Power(10,yVals[i]/10.)*N*deltaT/deltaF; } // cout << xVals[0] << "\t" << xVals[numLines-1] << "\t" << xVals[1]-xVals[0] << "\n"; TGraph *grWave = new TGraph(numLines,xVals,yVals); return grWave; }
//************************************************************* void AutoFitResiduals_forApproval(TString namesandlabels,bool stdres){ //************************************************************* gROOT->ProcessLine(".L TkAlStyle.cc+"); TkAlStyle::set(PRELIMINARY); // set publication status //Int_t colors[10]={kBlack,kRed,kBlue,kMagenta,kBlack,kRed,kBlue,kGreen}; Int_t colors[8]={0,1,2,3,4,5,6,7}; setStyle(); TList *FileList = new TList(); TList *LabelList = new TList(); TObjArray *nameandlabelpairs = namesandlabels.Tokenize(","); for (Int_t i = 0; i < nameandlabelpairs->GetEntries(); ++i) { TObjArray *aFileLegPair = TString(nameandlabelpairs->At(i)->GetName()).Tokenize("="); if(aFileLegPair->GetEntries() == 2) { FileList->Add( TFile::Open(aFileLegPair->At(0)->GetName()) ); // 2 LabelList->Add( aFileLegPair->At(1) ); } else { std::cout << "Please give file name and legend entry in the following form:\n" << " filename1=legendentry1,filename2=legendentry2\n"; } } const Int_t nFiles_ = FileList->GetSize(); TString LegLabels[10]; TFile *fins[nFiles_]; for(Int_t j=0; j < nFiles_; j++) { // Retrieve files fins[j] = (TFile*)FileList->At(j); // Retrieve labels TObjString* legend = (TObjString*)LabelList->At(j); LegLabels[j] = legend->String(); cout<<"AutoFitResiduals_forApproval::AutoFitResiduals_forApproval(): label["<<j<<"]"<<LegLabels[j]<<endl; } const Int_t nBins_ =24; // dca absolute residuals TH1F* dxyPhiResiduals[nFiles_][nBins_]; TH1F* dxyEtaResiduals[nFiles_][nBins_]; TH1F* dzPhiResiduals[nFiles_][nBins_]; TH1F* dzEtaResiduals[nFiles_][nBins_]; // dca normalized residuals TH1F* dxyNormPhiResiduals[nFiles_][nBins_]; TH1F* dxyNormEtaResiduals[nFiles_][nBins_]; TH1F* dzNormPhiResiduals[nFiles_][nBins_]; TH1F* dzNormEtaResiduals[nFiles_][nBins_]; for(Int_t i=0;i<nFiles_;i++){ for(Int_t j=0;j<nBins_;j++){ if(stdres){ // DCA absolute residuals dxyPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Phi_Residuals/histo_dxy_phi_plot%i",j)); dxyEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Eta_Residuals/histo_dxy_eta_plot%i",j)); dzPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Phi_Residuals/histo_dz_phi_plot%i",j)); dzEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Eta_Residuals/histo_dz_eta_plot%i",j)); // DCA normalized residuals dxyNormPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Phi_Residuals/histo_norm_dxy_phi_plot%i",j)); dxyNormEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Eta_Residuals/histo_norm_dxy_eta_plot%i",j)); dzNormPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Phi_Residuals/histo_norm_dz_phi_plot%i",j)); dzNormEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Eta_Residuals/histo_norm_dz_eta_plot%i",j)); } else { // DCA absolute residuals dxyPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Phi_Residuals/histo_IP2D_phi_plot%i",j)); dxyEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Transv_Eta_Residuals/histo_IP2D_eta_plot%i",j)); dzPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Phi_Residuals/histo_resz_phi_plot%i",j)); dzEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Abs_Long_Eta_Residuals/histo_resz_eta_plot%i",j)); // DCA normalized residuals dxyNormPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Phi_Residuals/histo_norm_IP2D_phi_plot%i",j)); dxyNormEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Transv_Eta_Residuals/histo_norm_IP2D_eta_plot%i",j)); dzNormPhiResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Phi_Residuals/histo_norm_resz_phi_plot%i",j)); dzNormEtaResiduals[i][j] = (TH1F*)fins[i]->Get(Form("PVValidation/Norm_Long_Eta_Residuals/histo_norm_resz_eta_plot%i",j)); } } } Double_t highedge=nBins_-0.5; Double_t lowedge=-0.5; // DCA absolute TH1F* dxyPhiMeanTrend[nFiles_]; TH1F* dxyPhiWidthTrend[nFiles_]; TH1F* dzPhiMeanTrend[nFiles_]; TH1F* dzPhiWidthTrend[nFiles_]; TH1F* dxyEtaMeanTrend[nFiles_]; TH1F* dxyEtaWidthTrend[nFiles_]; TH1F* dzEtaMeanTrend[nFiles_]; TH1F* dzEtaWidthTrend[nFiles_]; // DCA normalized TH1F* dxyNormPhiMeanTrend[nFiles_]; TH1F* dxyNormPhiWidthTrend[nFiles_]; TH1F* dzNormPhiMeanTrend[nFiles_]; TH1F* dzNormPhiWidthTrend[nFiles_]; TH1F* dxyNormEtaMeanTrend[nFiles_]; TH1F* dxyNormEtaWidthTrend[nFiles_]; TH1F* dzNormEtaMeanTrend[nFiles_]; TH1F* dzNormEtaWidthTrend[nFiles_]; for(Int_t i=0;i<nFiles_;i++){ // DCA trend plots dxyPhiMeanTrend[i] = new TH1F(Form("means_dxy_phi_%i",i),"#LT d_{xy} #GT vs #phi sector;track #phi [rad];#LT d_{xy} #GT [#mum]",nBins_,lowedge,highedge); dxyPhiWidthTrend[i] = new TH1F(Form("widths_dxy_phi_%i",i),"#sigma(d_{xy}) vs #phi sector;track #phi [rad];#sigma(d_{xy}) [#mum]",nBins_,lowedge,highedge); dzPhiMeanTrend[i] = new TH1F(Form("means_dz_phi_%i",i),"#LT d_{z} #GT vs #phi sector;track #phi [rad];#LT d_{z} #GT [#mum]",nBins_,lowedge,highedge); dzPhiWidthTrend[i] = new TH1F(Form("widths_dz_phi_%i",i),"#sigma(d_{z}) vs #phi sector;track #phi [rad];#sigma(d_{z}) [#mum]",nBins_,lowedge,highedge); dxyEtaMeanTrend[i] = new TH1F(Form("means_dxy_eta_%i",i),"#LT d_{xy} #GT vs #eta sector;track #eta;#LT d_{xy} #GT [#mum]",nBins_,lowedge,highedge); dxyEtaWidthTrend[i] = new TH1F(Form("widths_dxy_eta_%i",i),"#sigma(d_{xy}) vs #eta sector;track #eta;#sigma(d_{xy}) [#mum]",nBins_,lowedge,highedge); dzEtaMeanTrend[i] = new TH1F(Form("means_dz_eta_%i",i),"#LT d_{z} #GT vs #eta sector;track #eta;#LT d_{z} #GT [#mum]",nBins_,lowedge,highedge); dzEtaWidthTrend[i] = new TH1F(Form("widths_dz_eta_%i",i),"#sigma(d_{xy}) vs #eta sector;track #eta;#sigma(d_{z}) [#mum]",nBins_,lowedge,highedge); dxyNormPhiMeanTrend[i] = new TH1F(Form("means_dxyNorm_phi_%i",i),"#LT d_{xy}/#sigma_{d_{xy}} #GT vs #phi sector;track #phi [rad];#LT d_{xy}/#sigma_{d_{xy}} #GT [#mum]",nBins_,lowedge,highedge); dxyNormPhiWidthTrend[i]= new TH1F(Form("widths_dxyNorm_phi_%i",i),"#sigma(d_{xy}/#sigma_{d_{xy}}) vs #phi sector;track #phi [rad];#sigma(d_{xy}/#sigma_{d_{xy}}) [#mum]",nBins_,lowedge,highedge); dzNormPhiMeanTrend[i] = new TH1F(Form("means_dzNorm_phi_%i",i),"#LT d_{z}/#sigma_{d_{z}} #GT vs #phi sector;track #phi [rad];#LT d_{z}/#sigma_{d_{z}} #GT [#mum]",nBins_,lowedge,highedge); dzNormPhiWidthTrend[i] = new TH1F(Form("widths_dzNorm_phi_%i",i),"#sigma(d_{z}/#sigma_{d_{z}}) vs #phi sector;track #phi [rad];#sigma(d_{z}/#sigma_{d_{z}}) [#mum]",nBins_,lowedge,highedge); dxyNormEtaMeanTrend[i] = new TH1F(Form("means_dxyNorm_eta_%i",i),"#LT d_{xy}/#sigma_{d_{xy}} #GT vs #eta sector;track #eta;#LT d_{xy}/#sigma_{d_{xy}} #GT [#mum]",nBins_,lowedge,highedge); dxyNormEtaWidthTrend[i]= new TH1F(Form("widths_dxyNorm_eta_%i",i),"#sigma(d_{xy}/#sigma_{d_{xy}}) vs #eta sector;track #eta;#sigma(d_{xy}/#sigma_{d_{xy}}) [#mum]",nBins_,lowedge,highedge); dzNormEtaMeanTrend[i] = new TH1F(Form("means_dzNorm_eta_%i",i),"#LT d_{z}/#sigma_{d_{z}} #GT vs #eta sector;track #eta;#LT d_{z}/#sigma_{d_{z}} #GT [#mum]",nBins_,lowedge,highedge); dzNormEtaWidthTrend[i] = new TH1F(Form("widths_dzNorm_eta_%i",i),"#sigma(d_{z}/#sigma_{d_{z}}) vs #eta sector;track #eta;#sigma(d_{z}/#sigma_{d_{z}}) [#mum]",nBins_,lowedge,highedge); // DCA absolute FillTrendPlot(dxyPhiMeanTrend[i] ,dxyPhiResiduals[i],"mean","phi",nBins_); FillTrendPlot(dxyPhiWidthTrend[i],dxyPhiResiduals[i],"width","phi",nBins_); FillTrendPlot(dzPhiMeanTrend[i] ,dzPhiResiduals[i] ,"mean","phi",nBins_); FillTrendPlot(dzPhiWidthTrend[i] ,dzPhiResiduals[i] ,"width","phi",nBins_); FillTrendPlot(dxyEtaMeanTrend[i] ,dxyEtaResiduals[i],"mean","eta",nBins_); FillTrendPlot(dxyEtaWidthTrend[i],dxyEtaResiduals[i],"width","eta",nBins_); FillTrendPlot(dzEtaMeanTrend[i] ,dzEtaResiduals[i] ,"mean","eta",nBins_); FillTrendPlot(dzEtaWidthTrend[i] ,dzEtaResiduals[i] ,"width","eta",nBins_); MakeNiceTrendPlotStyle(dxyPhiMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dxyPhiWidthTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzPhiMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzPhiWidthTrend[i],colors[i]); MakeNiceTrendPlotStyle(dxyEtaMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dxyEtaWidthTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzEtaMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzEtaWidthTrend[i],colors[i]); // DCA normalized FillTrendPlot(dxyNormPhiMeanTrend[i] ,dxyNormPhiResiduals[i],"mean","phi",nBins_); FillTrendPlot(dxyNormPhiWidthTrend[i],dxyNormPhiResiduals[i],"width","phi",nBins_); FillTrendPlot(dzNormPhiMeanTrend[i] ,dzNormPhiResiduals[i] ,"mean","phi",nBins_); FillTrendPlot(dzNormPhiWidthTrend[i] ,dzNormPhiResiduals[i] ,"width","phi",nBins_); FillTrendPlot(dxyNormEtaMeanTrend[i] ,dxyNormEtaResiduals[i],"mean","eta",nBins_); FillTrendPlot(dxyNormEtaWidthTrend[i],dxyNormEtaResiduals[i],"width","eta",nBins_); FillTrendPlot(dzNormEtaMeanTrend[i] ,dzNormEtaResiduals[i] ,"mean","eta",nBins_); FillTrendPlot(dzNormEtaWidthTrend[i] ,dzNormEtaResiduals[i] ,"width","eta",nBins_); MakeNiceTrendPlotStyle(dxyNormPhiMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dxyNormPhiWidthTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzNormPhiMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzNormPhiWidthTrend[i],colors[i]); MakeNiceTrendPlotStyle(dxyNormEtaMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dxyNormEtaWidthTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzNormEtaMeanTrend[i],colors[i]); MakeNiceTrendPlotStyle(dzNormEtaWidthTrend[i],colors[i]); } // DCA absolute TCanvas *dxyPhiTrend = new TCanvas("dxyPhiTrend","dxyPhiTrend",1200,600); arrangeCanvas(dxyPhiTrend,dxyPhiMeanTrend,dxyPhiWidthTrend,nFiles_,LegLabels); dxyPhiTrend->SaveAs("dxyPhiTrend.pdf"); dxyPhiTrend->SaveAs("dxyPhiTrend.png"); TCanvas *dzPhiTrend = new TCanvas("dzPhiTrend","dzPhiTrend",1200,600); arrangeCanvas(dzPhiTrend,dzPhiMeanTrend,dzPhiWidthTrend,nFiles_,LegLabels); dzPhiTrend->SaveAs("dzPhiTrend.pdf"); dzPhiTrend->SaveAs("dzPhiTrend.png"); TCanvas *dxyEtaTrend = new TCanvas("dxyEtaTrend","dxyEtaTrend",1200,600); arrangeCanvas(dxyEtaTrend,dxyEtaMeanTrend,dxyEtaWidthTrend,nFiles_,LegLabels); dxyEtaTrend->SaveAs("dxyEtaTrend.pdf"); dxyEtaTrend->SaveAs("dxyEtaTrend.png"); TCanvas *dzEtaTrend = new TCanvas("dzEtaTrend","dzEtaTrend",1200,600); arrangeCanvas(dzEtaTrend,dzEtaMeanTrend,dzEtaWidthTrend,nFiles_,LegLabels); dzEtaTrend->SaveAs("dzEtaTrend.pdf"); dzEtaTrend->SaveAs("dzEtaTrend.png"); // DCA normalized TCanvas *dxyNormPhiTrend = new TCanvas("dxyNormPhiTrend","dxyNormPhiTrend",1200,600); arrangeCanvas(dxyNormPhiTrend,dxyNormPhiMeanTrend,dxyNormPhiWidthTrend,nFiles_,LegLabels); dxyNormPhiTrend->SaveAs("dxyPhiTrendNorm.pdf"); dxyNormPhiTrend->SaveAs("dxyPhiTrendNorm.png"); TCanvas *dzNormPhiTrend = new TCanvas("dzNormPhiTrend","dzNormPhiTrend",1200,600); arrangeCanvas(dzNormPhiTrend,dzNormPhiMeanTrend,dzNormPhiWidthTrend,nFiles_,LegLabels); dzNormPhiTrend->SaveAs("dzPhiTrendNorm.pdf"); dzNormPhiTrend->SaveAs("dzPhiTrendNorm.png"); TCanvas *dxyNormEtaTrend = new TCanvas("dxyNormEtaTrend","dxyNormEtaTrend",1200,600); arrangeCanvas(dxyNormEtaTrend,dxyNormEtaMeanTrend,dxyNormEtaWidthTrend,nFiles_,LegLabels); dxyNormEtaTrend->SaveAs("dxyEtaTrendNorm.pdf"); dxyNormEtaTrend->SaveAs("dxyEtaTrendNorm.png"); TCanvas *dzNormEtaTrend = new TCanvas("dzNormEtaTrend","dzNormEtaTrend",1200,600); arrangeCanvas(dzNormEtaTrend,dzNormEtaMeanTrend,dzNormEtaWidthTrend,nFiles_,LegLabels); dzNormEtaTrend->SaveAs("dzEtaTrendNorm.pdf"); dzNormEtaTrend->SaveAs("dzEtaTrendNorm.png"); // Bias plots TCanvas *BiasesCanvas = new TCanvas("BiasCanvas","BiasCanvas",1200,1200); arrangeBiasCanvas(BiasesCanvas,dxyPhiMeanTrend,dzPhiMeanTrend,dxyEtaMeanTrend,dzEtaMeanTrend,nFiles_,LegLabels); BiasesCanvas->SaveAs("BiasesCanvas.pdf"); BiasesCanvas->SaveAs("BiasesCanvas.png"); TCanvas *dxyPhiBiasCanvas = new TCanvas("dxyPhiBiasCanvas","dxyPhiBiasCanvas",600,600); TCanvas *dxyEtaBiasCanvas = new TCanvas("dxyEtaBiasCanvas","dxyEtaBiasCanvas",600,600); TCanvas *dzPhiBiasCanvas = new TCanvas("dzPhiBiasCanvas","dzPhiBiasCanvas",600,600); TCanvas *dzEtaBiasCanvas = new TCanvas("dzEtaBiasCanvas","dzEtaBiasCanvas",600,600); arrangeCanvas(dxyPhiBiasCanvas,dxyPhiMeanTrend,dxyPhiWidthTrend,nFiles_,LegLabels,true); arrangeCanvas(dzPhiBiasCanvas,dzPhiMeanTrend,dzPhiWidthTrend,nFiles_,LegLabels,true); arrangeCanvas(dxyEtaBiasCanvas,dxyEtaMeanTrend,dxyEtaWidthTrend,nFiles_,LegLabels,true); arrangeCanvas(dzEtaBiasCanvas,dzEtaMeanTrend,dzEtaWidthTrend,nFiles_,LegLabels,true); dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.pdf"); dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.pdf"); dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.pdf"); dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.pdf"); dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.png"); dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.png"); dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.png"); dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.png"); dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.eps"); dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.eps"); dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.eps"); dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.eps"); dxyPhiBiasCanvas->SaveAs("dxyPhiBiasCanvas.root"); dxyEtaBiasCanvas->SaveAs("dxyEtaBiasCanvas.root"); dzPhiBiasCanvas->SaveAs("dzPhiBiasCanvas.root"); dzEtaBiasCanvas->SaveAs("dzEtaBiasCanvas.root"); }
//__________________________________________________________________________________________________________________ void KVAvailableRunsFile::UpdateInfos(Int_t run, const Char_t * filename, const Char_t* kvversion, const Char_t* username) { // Call this mehod to update informations on the file "filename" corresponding to run, // by adding/replacing the KV version and username read from the file itself (not necessarily // corresponding to current KV version and username) //does runlist exist ? if (!OpenAvailableRunsFile()) { Error("UpdateInfos", "Error opening available runs file"); return; } //open temporary file TString tmp_file_path(GetFileName()); ofstream tmp_file; KVBase::OpenTempFile(tmp_file_path, tmp_file); TString FileName(filename); //loop over lines in fRunlist file //all lines which do not begin with 'run'| are directly copied to temp file TString line; line.ReadLine(fRunlist); while (fRunlist.good()) { //filename was specified: we copy everything up to the line //with the right filename & number if (line.BeginsWith(Form("%d|", run))) { TObjArray *toks = line.Tokenize('|'); // split into fields TString ReadFileName; //backwards compatibility //an old available_runs file will not have the filename field //in this case we assume that the name of the file is given by the //dataset's base file name (i.e. with no date/time suffix) if (toks->GetEntries() > 2) { ReadFileName = ((TObjString *) toks->At(2))->String(); } else { ReadFileName = fDataSet->GetBaseFileName(GetDataType(), run); } if (ReadFileName != FileName) { //copy line tmp_file << line.Data() << endl; } else { // replace existing infos tmp_file << run << "|" << ((TObjString *) toks->At(1))->String() << "|" << filename << "|" << kvversion << "|" << username << endl; } delete toks; } else { //copy line tmp_file << line.Data() << endl; } line.ReadLine(fRunlist); } CloseAvailableRunsFile(); TString fRunlist_path; AssignAndDelete(fRunlist_path, gSystem->ConcatFileName(fDataSet->GetDataSetDir(), GetFileName())); //keep lock on runsfile if( !runlist_lock.Lock( fRunlist_path.Data() ) ) return; //close temp file tmp_file.close(); //copy temporary file to KVFiles directory, overwrite previous gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE); //set access permissions to 664 gSystem->Chmod(fRunlist_path.Data(), CHMODE(6,6,4)); //delete temp file gSystem->Unlink(tmp_file_path); //unlock runsfile runlist_lock.Release(); }
//__________________________________________________________________________________________________________________ void KVAvailableRunsFile::Remove(Int_t run, const Char_t * filename) { //Remove from the file the entry corresponding to this run //By default, the first occurrence of the run number in the file will be removed. //If "filename" is given, we look for a line corresponding to both the run number //and the filename (important if run appears more than once !!!) ;-) //does runlist exist ? if (!OpenAvailableRunsFile()) { Error("Remove", "Error opening available runs file"); return; } //open temporary file TString tmp_file_path(GetFileName()); ofstream tmp_file; KVBase::OpenTempFile(tmp_file_path, tmp_file); TString FileName(filename); Bool_t withFileName = (FileName != ""); //loop over lines in fRunlist file //all lines which do not begin with 'run'| are directly copied to temp file TString line; line.ReadLine(fRunlist); while (fRunlist.good()) { if (!withFileName) { //filename not specified : we copy everything up to the first line //which begins with the run number we want if (!line.BeginsWith(Form("%d|", run))) { //copy line tmp_file << line.Data() << endl; } } else { //filename was specified: we copy everything up to the line //with the right filename & number if (line.BeginsWith(Form("%d|", run))) { TObjArray *toks = line.Tokenize('|'); // split into fields TString ReadFileName; //backwards compatibility //an old available_runs file will not have the filename field //in this case we assume that the name of the file is given by the //dataset's base file name (i.e. with no date/time suffix) if (toks->GetEntries() > 2) { ReadFileName = ((TObjString *) toks->At(2))->String(); } else { ReadFileName = fDataSet->GetBaseFileName(GetDataType(), run); } delete toks; if (ReadFileName != FileName) { //copy line tmp_file << line.Data() << endl; } } else { //copy line tmp_file << line.Data() << endl; } } line.ReadLine(fRunlist); } CloseAvailableRunsFile(); TString fRunlist_path; AssignAndDelete(fRunlist_path, gSystem->ConcatFileName(fDataSet->GetDataSetDir(), GetFileName())); //keep lock on runsfile if( !runlist_lock.Lock( fRunlist_path.Data() ) ) return; //close temp file tmp_file.close(); //copy temporary file to KVFiles directory, overwrite previous gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE); //set access permissions to 664 gSystem->Chmod(fRunlist_path.Data(), CHMODE(6,6,4)); //delete temp file gSystem->Unlink(tmp_file_path); //unlock runsfile runlist_lock.Release(); }
//_____________________________________________________________________________ void ProofSimpleFile::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // Number of histograms (needed in terminate) Ssiz_t iopt = kNPOS; if (fInput->FindObject("ProofSimpleFile_NHist")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimpleFile_NHist")); fNhist = (p) ? (Int_t) p->GetVal() : fNhist; } else if ((iopt = option.Index("nhist=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi(); } // The file for merging fProofFile = new TProofOutputFile("SimpleFile.root", "M"); TNamed *out = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE"); if (out) fProofFile->SetOutputFileName(out->GetTitle()); TDirectory *savedir = gDirectory; fFile = fProofFile->OpenFile("RECREATE"); if (fFile && fFile->IsZombie()) SafeDelete(fFile); savedir->cd(); // Cannot continue if (!fFile) { TString amsg = TString::Format("ProofSimpleFile::SlaveBegin: could not create '%s':" " instance is invalid!", fProofFile->GetName()); Abort(amsg, kAbortProcess); return; } // Histos arrays if (CreateHistoArrays() != 0) { Abort("ProofSimpleFile::SlaveBegin: could not create histograms", kAbortProcess); return; } // Create directory if (!(fFileDir = fFile->mkdir("blue"))) { Abort("ProofSimpleFile::SlaveBegin: could not create directory 'blue' in file!", kAbortProcess); return; } // Create the histograms for (Int_t i=0; i < fNhist; i++) { fHistTop[i] = new TH1F(Form("ht%d",i), Form("ht%d",i), 100, -3., 3.); fHistTop[i]->SetFillColor(kRed); fHistTop[i]->SetDirectory(fFile); fHistDir[i] = new TH1F(Form("hd%d",i), Form("hd%d",i), 100, -3., 3.); fHistDir[i]->SetFillColor(kBlue); fHistDir[i]->SetDirectory(fFileDir); } // Set random seed fRandom = new TRandom3(0); }
void Config() { // Libraries required by geant321 #if defined(__CINT__) gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_PHYSICS/include"); gSystem->Load("libgeant321"); LoadPhotos(); #endif new TGeant3TGeo("C++ Interface to Geant3"); //======================================================================= // Create the output file AliRunLoader* rl=0x0; cout<<"Config.C: Creating Run Loader ..."<<endl; rl = AliRunLoader::Open("galice.root", AliConfig::GetDefaultEventFolderName(), "recreate"); if (rl == 0x0) { gAlice->Fatal("Config.C","Can not instatiate the Run Loader"); return; } rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(5000); gAlice->SetRunLoader(rl); if ( TString("VAR_TRIGGER_CONFIGURATION").Length() > 0 ) { AliSimulation::Instance()->SetTriggerConfig("VAR_TRIGGER_CONFIGURATION"); cout<<"Trigger configuration is set to VAR_TRIGGER_CONFIGURATION" << std::endl; } // //======================================================================= // ************* STEERING parameters FOR ALICE SIMULATION ************** // --- Specify event type to be tracked through the ALICE setup // --- All positions are in cm, angles in degrees, and P and E in GeV gMC->SetProcess("DCAY",1); gMC->SetProcess("PAIR",1); gMC->SetProcess("COMP",1); gMC->SetProcess("PHOT",1); gMC->SetProcess("PFIS",0); gMC->SetProcess("DRAY",0); gMC->SetProcess("ANNI",1); gMC->SetProcess("BREM",1); gMC->SetProcess("MUNU",1); gMC->SetProcess("CKOV",1); gMC->SetProcess("HADR",1); gMC->SetProcess("LOSS",2); gMC->SetProcess("MULS",1); gMC->SetProcess("RAYL",1); Float_t cut = 1.e-3; // 1MeV cut by default Float_t tofmax = 1.e10; gMC->SetCut("CUTGAM", cut); gMC->SetCut("CUTELE", cut); gMC->SetCut("CUTNEU", cut); gMC->SetCut("CUTHAD", cut); gMC->SetCut("CUTMUO", cut); gMC->SetCut("BCUTE", cut); gMC->SetCut("BCUTM", cut); gMC->SetCut("DCUTE", cut); gMC->SetCut("DCUTM", cut); gMC->SetCut("PPCUTM", cut); gMC->SetCut("TOFMAX", tofmax); //======================// // Set External decayer // //======================// TVirtualMCDecayer* decayer = new AliDecayerPythia; /* FIXME: put back polarization switch ? if (polar == kNO_pol){ decayer = new AliDecayerPythia(); } else if (polar == kTH_pol){ decayer = new AliDecayerPolarized(1.,AliDecayerPolarized::kHelicity,AliDecayerPolarized::kMuon); } else if (polar == kT_pol){ decayer = new AliDecayerPolarized(1.,AliDecayerPolarized::kColSop,AliDecayerPolarized::kMuon); } else if (polar == kLH_pol){ decayer = new AliDecayerPolarized(-1.,AliDecayerPolarized::kHelicity,AliDecayerPolarized::kMuon); } else if (polar == kL_pol){ decayer = new AliDecayerPolarized(-1.,AliDecayerPolarized::kColSop,AliDecayerPolarized::kMuon); } */ decayer->SetForceDecay(kAll); decayer->Init(); gMC->SetExternalDecayer(decayer); //=========================// // Generator Configuration // //=========================// //AliGenerator* gener = CreateGenerator(); std::cout << "VAR_GENERATOR settings " << std::endl; gROOT->LoadMacro("VAR_GENERATOR.C+"); AliGenerator* gener = VAR_GENERATOR(); TString slibs = gSystem->GetLibraries(); TObjArray* olibs = slibs.Tokenize(" "); TObjString* s; TIter next(olibs); std::cout << "List of libraries=" << std::endl; while ( ( s = static_cast<TObjString*>(next())) ) { std::cout << s->String().Data() << std::endl; } gener->SetOrigin(0., 0., 0.); // Taken from OCDB gener->SetSigma(VAR_VERTEX_SIGMA_X, VAR_VERTEX_SIGMA_Y, 0.); // Sigma in (X,Y,Z) (cm) on IP position, sigmaz taken from OCDB gener->SetVertexSmear(kPerEvent); gener->Init(); gener->Print(); rl->CdGAFile(); Int_t iABSO = 1; Int_t iDIPO = 1; Int_t iFMD = 1; Int_t iFRAME = 1; Int_t iHALL = 1; Int_t iITS = 1; Int_t iMAG = 1; Int_t iMUON = 1; Int_t iPIPE = 1; Int_t iSHIL = 1; Int_t iT0 = 1; Int_t iVZERO = 1; Int_t iZDC = 0; Int_t iAD = 1; //=================== Alice BODY parameters ============================= AliBODY *BODY = new AliBODY("BODY", "Alice envelop"); if (iMAG) { //=================== MAG parameters ============================ // --- Start with Magnet since detector layouts may be depending --- // --- on the selected Magnet dimensions --- AliMAG *MAG = new AliMAG("MAG", "Magnet"); } if (iABSO) { //=================== ABSO parameters ============================ AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber"); } if (iDIPO) { //=================== DIPO parameters ============================ AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3"); } if (iHALL) { //=================== HALL parameters ============================ AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall"); } if (iFRAME) { //=================== FRAME parameters ============================ AliFRAMEv3 *FRAME = new AliFRAMEv3("FRAME", "Space Frame"); FRAME->SetHoles(1); } if (iSHIL) { //=================== SHIL parameters ============================ AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3"); } if (iPIPE) { //=================== PIPE parameters ============================ AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe"); } if (iITS) { //=================== ITS parameters ============================ AliITS *ITS = new AliITSv11("ITS","ITS v11"); } if (iZDC) { //=================== ZDC parameters ============================ AliZDC *ZDC = new AliZDCv4("ZDC", "normal ZDC"); ZDC->SetLumiLength(0.); ZDC->SetVCollSideCAperture(2.8); ZDC->SetVCollSideCApertureNeg(2.8); } if (iFMD) { //=================== FMD parameters ============================ AliFMD *FMD = new AliFMDv1("FMD", "normal FMD"); } if (iMUON) { //=================== MUON parameters =========================== // New MUONv1 version (geometry defined via builders) AliMUON *MUON = new AliMUONv1("MUON", "default"); MUON->SetTriggerEffCells(1); MUON->SetTriggerResponseV1(2); } if (iT0) { //=================== T0 parameters ============================ AliT0 *T0 = new AliT0v1("T0", "T0 Detector"); } if (iVZERO) { //=================== ACORDE parameters ============================ AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO"); } if (iAD) { //=================== AD parameters ============================ AliAD *AD = new AliADv1("AD", "normal AD"); } }
int main(int argc, const char** argv) { if (argc==2 && (string(argv[1]) == "-h" || string(argv[1]) == "--help")) { cout << " PURPOSE" << endl; cout << " This is a simple program counting the number of events having been recorded for each HLT path, given a JSON file" << endl; cout << "" << endl; cout << " OPTIONS:" << endl; cout << " -h, --help: display the help" << endl; cout << " --type some_type: desired counting (some_type must be one of 'Datasets', 'HLT', 'L1T', 'TCDS', 'Streams')" << endl; cout << " --hlttype some_hlttype: needed in the case of HLT (some_hlttype must be one of 'accept', 'error', 'pass L1 seed', 'pass prescaler', 'reject', 'avg_prescale')" << endl; cout << " --minrun 123456: count starting from this run" << endl; cout << " --maxrun 123456: count up to this run" << endl; cout << " --human: \"human readable\" output" << endl; cout << " --rate: print rates instead of counts" << endl; cout << " --time: print total running time in seconds instead of counts" << endl; cout << " --json: JSON to use for counting events (default: " << jsonfile << ")" << endl; cout << " --basedir: path to the DQM files (default: " << basedir << ")" << endl; cout << " --output: path to the output file (default: " << outputfile << ")" << endl; cout << " --rebin xx: merge xx bins together in the output file (default: " << rebin << ")" << endl; cout << " --scalerate 1000: if >0, scale rates to this target collision rate (in Hz), using the online luminosity (default: " << lumifactor << ")" << endl; cout << " --pattern pattern1,pattern2,...: comma-separated list of patterns to match to paths (in the format of TRegexp) (default: " << pattern << ")" << endl; cout << " --extrapolate: correct for missing lumi sections" << endl; cout << endl; cout << "See also https://twiki.cern.ch/twiki/bin/view/CMS/HITriggerTool for more information." << endl; return 1; } // parse options int minrun = 0; int maxrun = 999999; bool hum = false; for (int i=1; i<argc; i++) { string arg(argv[i]); if (arg=="--human") {hum = true;} else if (arg=="--rate") {dorate = true;} else if (arg=="--time") {dotime = true;} else if (arg=="--type"&&argc>i+1) {i++; theType = argv[i];} else if (arg=="--hlttype"&&argc>i+1) {i++; theHlttype = argv[i];} else if (arg=="--json"&&argc>i+1) {i++; jsonfile = argv[i];} else if (arg=="--basedir"&&argc>i+1) {i++; basedir = argv[i];} else if (arg=="--output"&&argc>i+1) {i++; outputfile = argv[i];} else if (arg=="--rebin"&&argc>i+1) {i++; rebin = atoi(argv[i]);} else if (arg=="--minrun"&&argc>i+1) {i++; minrun = atoi(argv[i]);} else if (arg=="--maxrun"&&argc>i+1) {i++; maxrun = atoi(argv[i]);} else if (arg=="--scalerate"&&argc>i+1) {i++; lumifactor = magicfactor*atof(argv[i]);} else if (arg=="--pattern"&&argc>i+1) {i++; pattern = argv[i];} else if (arg=="--extrapolate") {extrapol = true;} else cout << "Unsupported option " << argv[i] << endl; } // produce the vector of TRegexp TString tok; Ssiz_t from = 0; while (pattern.Tokenize(tok, from, ",")) { patterns.push_back(TRegexp(tok)); } nooutput = (outputfile == "NONE"); // check consistency if (dorate && dotime) { cout << "Error, cannot compute the rate and the time at the same time. Please pick only one of the two flags." << endl; return 1; } if (lumifactor>0) dorate = true; if (maxrun <= 285478 && jsonfile == jsonfile_8tev) jsonfile = jsonfile_5tev; if (minrun >= 285478 && jsonfile == jsonfile_5tev) jsonfile = jsonfile_8tev; if (minrun >= 285478) lumifactor *= magicfactor_8tev / magicfactor_5tev; cout << "Will count events by " << theType; if (string(theType) == "HLT") cout << ":" << theHlttype; cout << endl << "Counting between runs " << minrun << " and " << maxrun << ", according to the JSON file " << jsonfile << endl; cout << "Using the DQM files in " << basedir << endl << endl; map<string, vector<tripletI> > map_counts; // main counters map<string, vector<tripletI> > map_counts_aux; // used to count lumis (with --rate option) or counts without prescale (with --hlttype avg_prescale) vector<tripletD> v_ref; // rate of the ref trigger // parse the JSON file and extract the list of lumi ranges per run number lumirange lumis = json2lumi(jsonfile.Data()); // for each run, count events for (lumirange::iterator it = lumis.begin(); it != lumis.end(); it++) { if (it->first<minrun || it->first>maxrun) continue; if (dorate) { counts(it->first, it->second.first, it->second.second, theType, map_counts, v_ref, theHlttype, false, true); counts(it->first, it->second.first, it->second.second, theType, map_counts_aux, v_ref, theHlttype, true, false); } else if (theHlttype == "avg_prescale") { counts(it->first, it->second.first, it->second.second, theType, map_counts, v_ref, "pass prescaler", false, true); counts(it->first, it->second.first, it->second.second, theType, map_counts_aux, v_ref, "pass L1 seed", false, false); } else { counts(it->first, it->second.first, it->second.second, theType, map_counts, v_ref, theHlttype, dotime); } } // print results TFile *f = NULL; if (!nooutput) f = new TFile(outputfile.c_str(), "RECREATE"); cout << "HLT path\t\t" << theType; if (theType == "HLT") cout << ":" << theHlttype; if (dotime) cout << ": running time [s]"; if (dorate) cout << ": average rate [Hz]"; cout << endl; // create std::set of pairs of (run,lumi) set<pair<int,int> > theset = makeset(map_counts); // associate a unique bin number to each (run,lumi) pair map<pair<int,int>,int> themap = makemap(theset); makehist_lumi(v_ref, themap); map<string, vector<tripletI> >::iterator it_nLS = map_counts.begin(); for (it_nLS = map_counts.begin(); it_nLS != map_counts.end(); it_nLS++) { TH1F *hist = makehist(it_nLS->first.c_str(), it_nLS->second, map_counts_aux[it_nLS->first], v_ref, themap, theHlttype == "avg_prescale", hum); } if (f && f->IsOpen()) { f->Write(); f->Close(); } return 1; }
void make_SIDIS_scripts( const char *inputfilename ){ double PI = TMath::Pi(); double Mp = 0.938272; int itgt; int nevents=100000; int fieldclamp=0; int ckov_flag = 1; double Ibeam, Ltgt, Ptgt; double xrast, yrast; double Ebeam, thbb, Dbb, thsbs, Dsbs, Dhcal, Drich; double SBS_magfield; double pmin_SBS, pmin_BB; ifstream inputfile(inputfilename); //inputfile >> nevents; inputfile >> itgt; //0 = LH2, 1 = LD2, 2 = H2 gas, 3 = 3He gas: inputfile >> fieldclamp; inputfile >> ckov_flag; inputfile >> Ibeam >> Ltgt >> Ptgt; inputfile >> xrast >> yrast; inputfile >> Ebeam >> thbb >> Dbb >> thsbs >> Dsbs; inputfile >> SBS_magfield; inputfile >> pmin_SBS >> pmin_BB; Dhcal = Dsbs + 4.0; Drich = Dsbs + 2.5; //The files we want to create are: pi+/-, K+/-, pi0, with upbending and downbending configurations for the charged species. // This means 9 files. //Now, let's compute angle generation limits: we know that at D = 1.5 meters, xptar acceptance is ~ +/- 0.4, yptar acceptance // ~+/-0.2 (conservatively). double dxptar_BB = 0.35 * 1.5/Dbb; double dyptar_BB = 0.15 * 1.5/Dbb; double BBthetamin = thbb - atan(dyptar_BB)*180.0/PI; double pxhat_spec = dxptar_BB/sqrt(1.0+pow(dxptar_BB,2) + pow(dyptar_BB,2) ); double pyhat_spec = -dyptar_BB/sqrt(1.0+pow(dxptar_BB,2) + pow(dyptar_BB,2) ); double pzhat_spec = 1.0/sqrt(1.0+pow(dxptar_BB,2) + pow(dyptar_BB,2) ); double pxhat_lab = pxhat_spec; double pyhat_lab = pyhat_spec*cos(thbb*PI/180.0) - pzhat_spec * sin(thbb*PI/180.0); double pzhat_lab = pyhat_spec*sin(thbb*PI/180.0) + pzhat_spec * cos(thbb*PI/180.0); // cout << "pzhat_spec, pzhat_lab = " << pzhat_spec << ", " << pzhat_lab << endl; double BBthetamax = 180.0/PI * acos(pzhat_lab); // cout << "BigBite thetamax = " << BBthetamax << endl; //Phi max/min computed from smallest in-plane angle, largest out-of-plane pyhat_spec = dyptar_BB/sqrt(1.0+pow(dxptar_BB,2)+pow(dyptar_BB,2)); pxhat_spec = -dxptar_BB/sqrt(1.0+pow(dxptar_BB,2)+pow(dyptar_BB,2)); pyhat_lab = pyhat_spec*cos(thbb*PI/180.0) - pzhat_spec * sin(thbb*PI/180.0); double BBphimin = 180.0/PI * atan2( -pxhat_spec, pyhat_lab ); double BBphimax = 360.0 + 180.0/PI * atan2( pxhat_spec, pyhat_lab ); double dxptar_SBS = 0.3 * 2.45/Dsbs; double dyptar_SBS = 0.1 * 2.45/Dsbs; double SBSthetamin = thsbs - atan(dyptar_SBS)*180.0/PI; pxhat_spec = dxptar_SBS/sqrt(1.0+pow(dxptar_SBS,2)+pow(dyptar_SBS,2)); pyhat_spec = dyptar_SBS/sqrt(1.0+pow(dxptar_SBS,2)+pow(dyptar_SBS,2)); pzhat_spec = 1.0/sqrt(1.0+pow(dxptar_SBS,2)+pow(dyptar_SBS,2)); pxhat_lab = pxhat_spec; pyhat_lab = pyhat_spec*cos(thsbs*PI/180.0) + pzhat_spec*sin(thsbs*PI/180.0); pzhat_lab = -pyhat_spec*sin(thsbs*PI/180.0) + pzhat_spec*cos(thsbs*PI/180.0); double SBSthetamax = 180.0/PI * acos( pzhat_lab ); pyhat_spec = -dyptar_SBS/sqrt(1.0+pow(dxptar_SBS,2)+pow(dyptar_SBS,2)); pxhat_spec = dxptar_SBS/sqrt(1.0+pow(dxptar_SBS,2)+pow(dyptar_SBS,2)); pyhat_lab = pyhat_spec*cos(thsbs*PI/180.0) + pzhat_spec*sin(thsbs*PI/180.0); double SBSphimin = 180.0/PI*atan2( -pxhat_spec, pyhat_lab ); double SBSphimax = 180.0/PI*atan2( pxhat_spec, pyhat_lab ); TString outfilename = "sidis_"; TString hadrons[5] = {"km_", "pim_", "pi0_", "pip_", "kp_"}; TString hadroncmd[5] = {"K-", "pi-", "pi0", "pi+", "K+" }; TString targets[4] = {"LH2", "LD2", "H2", "3He" }; for(int ihadron=-2; ihadron<=2; ihadron++){ for(int sbspol=-1; sbspol<=1; sbspol += 2 ){ outfilename = "sidis_"; outfilename += hadrons[ihadron+2]; if( sbspol*ihadron > 0 ){ outfilename += "upbend_"; } else if( sbspol*ihadron < 0 ){ outfilename += "downbend_"; } char cthD[80]; sprintf(cthD,"_ebeam%gGeV_thbb%gdeg_thsbs%gdeg_Dbb%gm_Dsbs%gm",Ebeam, thbb, thsbs, Dbb, Dsbs ); outfilename += targets[itgt]; outfilename += cthD; outfilename += ".mac"; ofstream outputfile(outfilename.Data()); ifstream template_macro("sidis_template.mac"); TString currentline; while( currentline.ReadLine(template_macro) ){ TObjArray *tokens = currentline.Tokenize(" "); TString cmd_prefix = ( (TObjString*) (*tokens)[0] )->GetString(); // cout << "read line, ntokens = " << tokens->GetEntries() << ": "; // for(int i=0; i<tokens->GetEntries(); i++){ // TString token = ( (TObjString*) (*tokens)[i] )->GetString(); // cout << token.Data() << ", "; // } // cout << endl; int ntokens = tokens->GetEntries(); TString value=" ", unit=" "; TString cmd_temp; if( cmd_prefix == "/g4sbs/beamcur" ){ //value = " "; //value += Ibeam; value.Form(" %5.3g",Ibeam); unit = " muA"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/target" ) { value = " "; value += targets[itgt]; //value.Form( " %s",targets[itgt] ); unit = ""; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/targpres" ){ //value = " "; //value += Ptgt; value.Form(" %5.3g",Ptgt); unit = " atmosphere"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/targlen" ){ //value = " "; //value += Ltgt; value.Form( " %5.3g", Ltgt); unit = " cm"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/rasterx" ){ // value = " "; //value += xrast; value.Form(" %5.3g", xrast); unit = " mm"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/rastery" ){ //value = " "; //value += yrast; value.Form(" %5.3g", yrast); unit = " mm"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/hadron" ){ value = " "; value += hadroncmd[ihadron+2]; //value.Form(" %s",hadroncmd[ihadron+2]); unit = ""; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/beamE" ){ //value = " "; //value += Ebeam; value.Form(" %5.3g",Ebeam); unit = " GeV"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/bbang" ){ //value = " "; //value += thbb; value.Form(" %5.3g", thbb); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/bbdist" ){ //value = " "; //value += Dbb; value.Form(" %5.3g", Dbb); unit = " m"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/hcalang"){ //value = " "; //value += thsbs; value.Form(" %5.3g", thsbs); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/hcaldist"){ //value = " "; //value += Dhcal; value.Form(" %5.3g",Dhcal); unit = " m"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/48D48dist" ){ //value = " "; //value += Dsbs; value.Form(" %5.3g", Dsbs); unit = " m"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/sbsmagfield" ){ //value = " "; //value += SBS_magfield*sbspol; value.Form(" %5.3g", SBS_magfield*sbspol); unit = " tesla"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/sbsclampopt" ){ //value = " "; //value += fieldclamp; value.Form(" %d",fieldclamp); unit = ""; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/richdist" ){ //value = " "; //value += Drich; value.Form(" %5.3g", Drich); unit = " m"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/thmin" ){ //value = " "; //value += BBthetamin; value.Form(" %5.3g", BBthetamin); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/phmin" ){ //value = " "; //value += BBphimin; value.Form(" %5.3g",BBphimin); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/thmax" ){ //value = " "; //value += BBthetamax; value.Form(" %5.3g",BBthetamax); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/phmax" ){ //value = " "; //value += BBphimax; value.Form(" %5.3g", BBphimax); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/hthmin" ){ //value = " "; //value += SBSthetamin; value.Form(" %5.3g", SBSthetamin); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/hthmax" ){ // value = " "; // value += SBSthetamax; value.Form(" %5.3g", SBSthetamax); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/hphmin" ){ // value = " "; // value += SBSphimin; value.Form(" %5.3g", SBSphimin); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/hphmax" ){ // value = " "; // value += SBSphimax; value.Form(" %5.3g", SBSphimax); unit = " deg"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/eemin" ){ // value = " "; // value += pmin_BB; value.Form(" %5.3g", pmin_BB); unit = " GeV"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/eemax" ){ double Eemax = Ebeam/(1.0 + Ebeam/Mp*(1.0-cos(BBthetamin*PI/180.0))); // value = " "; // value += Eemax; value.Form(" %5.3g", Eemax); unit = " GeV"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/ehmin" ){ double Ehmin = pmin_SBS; // value = " "; // value += Ehmin; value.Form( " %5.3g", Ehmin); unit = " GeV"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else if( cmd_prefix == "/g4sbs/ehmax" ){ double Ehmax = Ebeam - pmin_BB; // value = " "; // value += Ehmax; value.Form(" %5.3g", Ehmax); unit = " GeV"; cmd_temp = cmd_prefix + value + unit; outputfile << cmd_temp.Data() << endl; } else { outputfile << currentline.Data() << endl; } } if( ckov_flag == 0 ){ outputfile << "/process/inactivate Cerenkov" << endl; } TString rootfilename = outfilename; rootfilename.ReplaceAll(".mac",".root"); // outputfile << "/g4sbs/filename " << rootfilename.Data() << endl; // outputfile << "/g4sbs/run " << nevents << endl; } } }
void plotauto(TString infilename) { TString plname = infilename+".ps"; TCanvas* cc = new TCanvas("validate","validate",500,370); cc->Print(plname+"["); TText tt; tt.SetTextColor(2); tt.SetTextSize(0.02); gStyle->SetMarkerSize(0.1); gStyle->SetTitleSize(0.15,"ff"); gStyle->SetTitleTextColor(4); std::vector < TString > vnames; vnames.push_back("Sim_HitEn"); vnames.push_back("Sim_HitTime"); vnames.push_back("Sim_posXY"); vnames.push_back("Sim_posXZ"); vnames.push_back("Sim_posYZ"); vnames.push_back("Sim_posRZ"); std::vector <TString> exts; exts.push_back(""); exts.push_back("_posZ"); exts.push_back("_negZ"); TH1F* h; TH2F* hh; TKey *key; TIter next; TKey *key2; TIter next2; TFile* infile = new TFile(infilename, "read"); // overall geometry TDirectory* td = (TDirectory*) infile->Get("ALLCollections"); cc->Clear(); cc->Divide(3,3); cc->cd(1); hh = (TH2F*) td->Get("ALLCollections_overallhitZR"); hh->Draw("box"); cc->cd(2); int icol=1; bool first=true; TLegend* tl = new TLegend(0., 0., 1, 1); next = td->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("ALL") ) continue; if ( hn.Contains("_Log") ) continue; hh->SetLineColor(icol); if ( first ) {hh->Draw("box"); first=false;} else hh->Draw("same;box"); icol++; if (icol==10) icol=1; TString ss = hn.ReplaceAll( "_overallhitZR", ""); tl->AddEntry(hh, ss , "l"); } } // the legend cc->cd(3); tl->Draw(); cc->cd(4); hh = (TH2F*) td->Get("ALLCollections_Log_overallhitZR"); hh->Draw("box"); cc->cd(5); icol=1; first=true; next = td->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("ALL" ) ) continue; if ( ! hn.Contains("_Log_") ) continue; hh->SetLineColor(icol); if ( first ) {hh->Draw("box"); first=false;} else hh->Draw("same;box"); icol++; if (icol==10) icol=1; } } cc->cd(7); hh = (TH2F*) td->Get("ALLCollections_LogLog_overallhitZR"); hh->Draw("box"); cc->cd(8); icol=1; first=true; next = td->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("ALL" ) ) continue; if ( ! hn.Contains("_LogLog_") ) continue; hh->SetLineColor(icol); if ( first ) {hh->Draw("box"); first=false;} else hh->Draw("same;box"); icol++; if (icol==10) icol=1; } } cc->Print(plname); // now collection-by-collection next = infile->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TDirectory")) { td = (TDirectory*)key->ReadObj(); TString dirname = td->GetName(); if ( dirname=="ALLCollections" ) continue; // is it an endcap collection? bool isEndcap = td->Get(dirname+"_hitXY_posZ"); // first overall geometry cc->Clear(); cc->Divide(3,2); cc->cd(1); ( (TH2F*) td->Get(dirname+"_hitEn"))->Draw("box"); cc->cd(4)->SetLogy(); ( (TH2F*) td->Get(dirname+"_hitTime"))->Draw("box"); if ( isEndcap ) { cc->cd(2); ( (TH2F*) td->Get(dirname+"_hitXY_posZ"))->Draw("box"); cc->cd(3); ( (TH2F*) td->Get(dirname+"_hitXY_negZ"))->Draw("box"); cc->cd(5); ((TH2F*) td->Get(dirname+"_hitZR_posZ"))->Draw("box"); cc->cd(6); ((TH2F*) td->Get(dirname+"_hitZR_negZ"))->Draw("box"); } else { cc->cd(2); ( (TH2F*) td->Get(dirname+"_hitXY"))->Draw("box"); cc->cd(3); ( (TH2F*) td->Get(dirname+"_hitZR"))->Draw("box"); } cc->Print(plname); // then the cell indices // work out how many indices/variables we're dealing with std::vector < TString > indices; std::vector < TString > variables; next2 = td->GetListOfKeys(); while ((key2 = (TKey*)next2())) { cll = gROOT->GetClass(key2->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*) key2->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("Indx") ) { TString ss = hn.ReplaceAll(dirname+"_", ""); TString asas = ((TObjString*) (ss.Tokenize("_") -> At(0)))->GetString(); if ( find( indices.begin(), indices.end(), asas )==indices.end() ) indices.push_back(asas); asas = ((TObjString*) (ss.Tokenize("_") -> At(1)))->GetString(); if ( find( variables.begin(), variables.end(), asas )==variables.end() ) variables.push_back(asas); } } } if ( indices.size()==0 || variables.size()==0 ) continue; for (int inp=0; inp<2; inp++) { if ( !isEndcap && inp==1 ) continue; cc->Clear(); cc->Divide(indices.size(), variables.size()); int ic=1; next2 = td->GetListOfKeys(); while ((key2 = (TKey*)next2())) { cll = gROOT->GetClass(key2->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*) key2->ReadObj(); TString hn = hh->GetName(); if ( isEndcap ) { if ( inp==0 && ! hn.Contains("posZ") ) continue; else if ( inp==1 && ! hn.Contains("negZ") ) continue; } if ( hn.Contains("Indx") ) { TString asas = ((TObjString*) (hn.Tokenize("_") -> At(1)))->GetString(); asas = asas(4,asas.Length()); cc->cd(ic++); hh->Draw("box"); } } } cc->cd(); for ( size_t k=0; k<variables.size(); k++) { tt.DrawTextNDC( 0.0, 0.9 - (1.0*k)/(variables.size()), variables[k] ); } for ( size_t k=0; k<indices.size(); k++) { tt.DrawTextNDC( 0.05 + (1.0*k)/(indices.size()), 0.02, indices[k].ReplaceAll("Indx","Indx_") ); } tt.DrawTextNDC( 0.1, 0.99, dirname); if ( isEndcap ) { if (inp==0 ) tt.DrawTextNDC( 0.35, 0.99, "posZ"); else tt.DrawTextNDC( 0.35, 0.99, "negZ"); } cc->Print(plname); } } } infile->Close(); cc->Print(plname+"]"); }
void SetupTrackCutsDieleData(AliDielectron *diele, Int_t cutDefinition); void SetupPairCutsDieleData(AliDielectron *diele, Int_t cutDefinition); void InitHistogramsDieleData(AliDielectron *diele, Int_t cutDefinition); void InitCFDieleData(AliDielectron *diele, Int_t cutDefinition); void SetupV0Cuts(AliDielectron *diele, Int_t cutDefinition); //blabla //blabla TString namesDieleData=("basicQ+ITS012+p>.8+nostrongexclusionPID;basicQ+ITS012+p>.8+noexclusionPID+nomassprefilter;basicQ+ITS012+p>.8+noexclusionPID+nomassprefilter_differentmixing");//;basicQ+ITS012+p>.8+noexclusionPID+nomassprefilter+activevolumecut");//;noITS");//;basicQ+ITS012+p>.8+noexclusionPID+nomassprefilterTOFifavail");//;basicQ+SPDany+pt>1+PID;basicQ+ITS012+pt>1+PID;basicQ+SPDany+pt>1+noexclPIDforcontrolpurpose;basicQ+SPDfirst+p>1.+PID;basicQ+SPDfirst+noPIDcuts+nopairing");// basicQ+SPDany+pt>1+p>1.2+PIDrequirementsHFEnoexclPIDforcontrolpurpose;basicQ+SPDany+pt>1+p>1.2+PIDrequirementsHFE+PID;basicQ+SPDany+p>1.+PID"); //TString namesDieleData=("basicQ+SPDfirst+pt>1+PID"); TObjArray *arrNamesDieleData=namesDieleData.Tokenize(";"); const Int_t nDie=arrNamesDieleData->GetEntries(); AliDielectron* ConfigJpsi2ee(Int_t cutDefinition) { // // Setup the instance of AliDielectron // // create the actual framework object TString name=Form("%02d",cutDefinition);; if (cutDefinition<arrNamesDieleData->GetEntriesFast()){ name=arrNamesDieleData->At(cutDefinition)->GetName(); } AliDielectron *diele = new AliDielectron(Form("%s",name.Data()), Form("Track cuts: %s",name.Data())); //setter to enable/disable KF-package diele->SetUseKF(kFALSE); // estimators filename
Bool_t KVDataSetManager::ReadAvailableDatasetsFile() { //Opens and reads file containing cached info on available datasets, and sets //the availability of the concerned datasets. //Returns kTRUE if all goes well. //Returns kFALSE if no cache exists or if file cannot be opened. if(OpenAvailableDatasetsFile()){ Info("ReadAvailableDataSetsFile", "Reading cached information in file %s", fCacheFileName.Data()); //read file TString line; line.ReadLine(fDatasets); while (fDatasets.good()) { TObjArray *toks = line.Tokenize(": ,"); //first entry is dataset name TString datasetname = ((TObjString *) toks->At(0))->String(); KVDataSet *dataset = GetDataSet(datasetname.Data()); if(dataset) { //check dataset is known to local version of KaliVeda //in case of remote repository, there may be datasets in the remote repository which are not defined here if (toks->GetEntries() > 1 && dataset->CheckUserCanAccess()) { //AVAILABLE DATASET dataset->SetAvailable(); fNavailable++; for (register int i = 1; i < toks->GetEntries(); i++) { //each following entry is a subdirectory name dataset->AddAvailableDataType(((TObjString *) toks->At(i))->String(). Data()); } } else { //UNAVAILABLE DATASET (no subdirs) dataset->SetAvailable(kFALSE); } } delete toks; line.ReadLine(fDatasets); } //close file fDatasets.close(); fDatasets.clear(); if (fNavailable) { TIter next(&fDataSets); //now set up array of available datasets' indices if (fIndex) delete[]fIndex; fIndex = new Int_t[fNavailable]; Int_t i, j; i = j = 0; KVDataSet *ds; while ((ds = (KVDataSet *) next())) { if (ds->IsAvailable()) { fIndex[i] = j; i++; } j++; } } //all is OK return kTRUE; } //we could not find/open the cache file return kFALSE; }
void DrawAllHistos(TString filename,Bool_t isMC,TString format){ // setTDRStyle("logredblue"); std::vector<TH1F*> h1vec; std::vector<TH2F*> h2vec; h1vec.clear(); h2vec.clear(); TFile *file = TFile::Open(filename); // to get the names of the conditions TObjArray *conditions_from_name = filename.Tokenize("_"); TString sa = conditions_from_name->At(1)->GetName(); TString sb = conditions_from_name->At(3)->GetName(); sb.ReplaceAll(".root",""); file->cd(); TDirectory *stardir = gDirectory; TObject *thesourcedir; TIter nextdir(stardir->GetListOfKeys()); while((thesourcedir=nextdir())){ TString dirName = thesourcedir->GetName(); stardir->cd(dirName); TDirectory *current_sourcedir = gDirectory; TH1::AddDirectory(kFALSE); std::cout << "*************************" <<std::endl; std::cout << "Reading Directory: " << dirName <<std::endl; TObject *obj; TIter next(current_sourcedir->GetListOfKeys()); while ((obj=next())) { TString objName =obj->GetName(); if(objName.Contains("pfx")) continue; if (objName.Contains("h2") && !objName.Contains("pfx")) { //std::cout << "Reading: " << obj->GetName() <<std::endl; TH2F* h2 = (TH2F*)file->Get(dirName+"/"+objName); h2->SetName(objName+dirName); h2vec.push_back(h2); TCanvas *c = new TCanvas(h2->GetName(),h2->GetName(),800,600); c->cd(); gPad->SetTopMargin(0.08); gPad->SetRightMargin(0.15); h2->SetStats(kFALSE); h2->Draw("colz"); c->Draw(); c->cd(); TProfile *hpfx_tmp = (TProfile*) h2->ProfileX("_pfx",1,-1,"o"); hpfx_tmp->SetStats(kFALSE); //hpfx_tmp->SetMarkerColor(kBlack); hpfx_tmp->SetMarkerColor(kRed); hpfx_tmp->SetMarkerSize(1.2); hpfx_tmp->SetMarkerStyle(20); hpfx_tmp->Draw("psame"); c->Draw(); cmsPrel(60.,sa,sb, isMC); TString canvName = h2->GetName(); c->cd()->SetLogz(); c->SaveAs(canvName+"."+format); } else { TH1F* h1 = (TH1F*)file->Get(dirName+"/"+objName); h1->SetName(objName+dirName); h1vec.push_back(h1); TCanvas *c = new TCanvas(h1->GetName(),h1->GetName(),600,600); c->cd()->SetLogy(); h1->SetMarkerColor(kBlack); h1->SetMarkerStyle(20); h1->SetLineWidth(1.5); h1->SetFillColor(393); //h1->SetFillStyle(3005); h1->Draw("hist"); h1->Draw("e1same"); c->Draw(); TObject *statObj; TPaveStats *stats; statObj = h1->GetListOfFunctions()->FindObject("stats"); stats= static_cast<TPaveStats*>(statObj); stats->SetFillColor(10); stats->SetLineWidth(1); stats->SetShadowColor(0); stats->SetTextFont(42); stats->SetTextSize(0.025); //stats->SetLineColor(LineColors); //stats->SetTextColor(LineColors); stats->SetX1NDC(0.75); stats->SetY1NDC(0.72); stats->SetX2NDC(0.97); stats->SetY2NDC(0.92); stats->Draw("same"); cmsPrel(60.,sa,sb,isMC); TString canvName = h1->GetName(); c->SaveAs(canvName+"."+format); } } } }