void AddSample(TMap &lookup, const char *key, const char* datadir, const char * pattern, const char *sampletype, const char *dataformat){ // // Add sample entry to the lookup table // TObjArray *infos = new TObjArray(); infos->AddAt(new TObjString(datadir), 0); infos->AddAt(new TObjString(pattern), 1); infos->AddAt(new TObjString(sampletype), 2); infos->AddAt(new TObjString(dataformat), 3); lookup.Add(new TObjString(key), infos); }
//_______________________________________ 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 AddFit(TH2* h2d) { // // Fit in slices and draw mean and sigma // TF1 *f1 = new TF1("f1", "gaus"); f1->SetRange(-1.5,1.5); TObjArray aSlices; h2d->FitSlicesY(f1, 0,-1, 0, "QNR",&aSlices); aSlices.SetOwner(1); TH1* hMean=(TH1*)aSlices.At(1); TH1* hSigma=(TH1*)aSlices.At(2); TH1* hChi2=(TH1*)aSlices.At(3); hChi2->Scale(1./10.); aSlices.AddAt(0x0,1); aSlices.AddAt(0x0,2); aSlices.AddAt(0x0,3); hMean->SetMarkerStyle(20); hMean->SetMarkerSize(0.3); hMean->SetOption("same"); h2d->GetListOfFunctions()->Add(hMean); hSigma->SetMarkerStyle(20); hSigma->SetMarkerSize(0.3); hSigma->SetOption("same"); hSigma->SetMarkerColor(kMagenta); h2d->GetListOfFunctions()->Add(hSigma); hChi2->SetOption("same"); hChi2->SetMarkerColor(kMagenta + 2); hChi2->SetLineColor(kMagenta + 2); h2d->GetListOfFunctions()->Add(hChi2); TLine *l=0x0; l=new TLine(h2d->GetXaxis()->GetXmin(),0,h2d->GetXaxis()->GetXmax(),0); l->SetLineStyle(2); h2d->GetListOfFunctions()->Add(l); l=new TLine(h2d->GetXaxis()->GetXmin(),1,h2d->GetXaxis()->GetXmax(),1); l->SetLineStyle(2); h2d->GetListOfFunctions()->Add(l); }
bool FindDataSample(const TMap &lookup, TObjArray &sampleinfis){ // // Find Data sample in the list of samples // TObjArray *entry = dynamic_cast<TObjArray *>(lookup.GetValue(g_sample.Data())); if(!entry){ printf("Sample %s not found in the list of samples", g_sample.Data()); return false; } // Copy to output container sampleinfis.SetOwner(kFALSE); for(int ival = 0; ival < 4; ival++) sampleinfis.AddAt(entry->At(ival), ival); return true; }
/// \brief Cache MC production trees, store summary information in formated text files -> root trees /// \param dataType - /// \param fileList void CacheTestMCProductions(TString dataType, const char *fileList=NULL){ AliExternalInfo info; info.fLoadMetadata=kFALSE; TObjArray* periodList = NULL; TArrayI nRuns; if (fileList!=NULL) { periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n"); nRuns.Set(periodList->GetEntries()); }else{ TTree * tree = info.GetTree("MonALISA.ProductionMC","",""); Int_t nProd=tree->GetEntries(); periodList = new TObjArray(nProd); nRuns.Set(nProd); TLeaf *leaf = tree->GetLeaf("Tag"); TLeaf *leafRuns = tree->GetLeaf("Number_of_runs"); for (Int_t iProd=0; iProd<nProd; iProd++){ tree->GetEntry(iProd); TString prodName=((char*)leaf->GetValuePointer()); if (prodName.Contains("LHC")==0) continue; periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd); nRuns[iProd]=leafRuns->GetValue(); } delete tree; } for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){ TObjString * pName= (TObjString*)periodList->At(iPeriod); if (pName==NULL) continue; TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC"); if (tree){ Int_t entries=tree->Draw("run","1","goff"); TString sInfo=periodList->At(iPeriod)->GetName(); sInfo+="\t"; sInfo+=dataType; sInfo+="\t"; sInfo+=TString::Format("%d\t",entries); sInfo+=TString::Format("%d\t",nRuns[iPeriod]); for (Int_t j=0; j<entries; j++) { sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]); ::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]); } sInfo+="0"; ::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data()); delete tree; }else{ ::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]); } } }
void KVGANILDataReader::SetUserTree(TTree* T, Option_t* opt) { // To fill a TTree with the data in the current file, create a TTree: // TFile* file = new TFile("run1.root","recreate"); // TTree* T = new TTree("Run1", "Raw data for Run1"); // and then call this method: SetUserTree(T) // If you read all events of the file, the TTree will be automatically filled // with data : // while( runfile->GetNextEvent() ) ; // // Two different TTree structures are available, depending on the option string: // // opt = "arrays": [default] // // The TTree will have the following structure: // // *Br 0 :NbParFired : NbParFired/I = number of fired parameters in event // *............................................................................* // *Br 1 :ParNum : ParNum[NbParFired]/i = array of indices of fired parameters // *............................................................................* // *Br 2 :ParVal : ParVal[NbParFired]/s = array of values of fired parameters // // This structure is the fastest to fill and produces the smallest file sizes. // In order to be able to directly access the parameters as if option "leaves" were used // (i.e. one branch/leaf for each parameter), we add two aliases for each parameter to // the tree: // PARNAME = value of parameter if present in event // PARNAME_M = number of times parameter appears in event // Assuming that each parameter only appears at most once in each event, i.e. PARNAME_M=0 or 1, // then // root[0] T->Draw("PARNAME", "PARNAME_M") // will histogram the value of PARNAME for each event in which it is present. // (if the selection condition "PARNAME_M" is not used, the histogram will also be filled with a 0 // for each event in which PARNAME does not appear). // N.B. the PARNAME alias is in fact the sum of the values of PARNAME in each event. // If PARNAME_M>1 in some events, it is not the individual values but their sum which will // be histogrammed in this case. // // Thus, if the data file has parameters called "PAR_1" and "PAR_2", // the following command will work // // root[0] T->Draw("PAR_1:PAR_2", "PAR_1_M&&PAR_2_M", "col") // // even though no branches "PAR_1" or "PAR_2" exist. // // // // opt = "leaves": // // The TTree will have a branch/leaf for each parameter. This option is slower and produces // larger files. // // If the option string contains both "arrays" and "leaves", then both structures will be used // (in this case there is a high redundancy, as each parameter is stored twice). // // The full list of parameters is stored in a TObjArray in the list returned by TTree::GetUserInfo(). // Each parameter is represented by a TNamed object. // In order to retrieve the name of the parameter with index 674 (e.g. taken from branch ParNum), // do: // TObjArray* parlist = (TObjArray*) T->GetUserInfo()->FindObject("ParameterList"); // cout << "Par 674 name = " << (*parlist)[674]->GetName() << endl; // // // Automatic creation & filling of Scalers TTree // // give an option string containing "scalers", i.e. "leaves,scalers", or "ARRAYS+SCALERS", etc. // a TTree with name 'Scalers' will be created, all scaler buffers will be written in it. TString option = opt; option.ToUpper(); make_arrays = option.Contains("ARRAYS"); make_leaves = option.Contains("LEAVES"); Bool_t make_scalers = option.Contains("SCALERS"); if(make_scalers){ fGanilData->SetScalerBuffersManagement(GTGanilData::kAutoWriteScaler); } fUserTree = T; if( make_arrays ){ Int_t maxParFired = GetRawDataParameters()->GetEntries(); ParVal = new UShort_t[maxParFired]; ParNum = new UInt_t[maxParFired]; fUserTree->Branch("NbParFired", &NbParFired, "NbParFired/I"); fUserTree->Branch("ParNum", ParNum, "ParNum[NbParFired]/i"); fUserTree->Branch("ParVal", ParVal, "ParVal[NbParFired]/s"); } if( make_leaves ){ TIter next_rawpar( GetRawDataParameters() ); KVACQParam* acqpar; while( (acqpar = (KVACQParam*)next_rawpar()) ){ TString leaf; leaf.Form("%s/S", acqpar->GetName()); // for parameters with <=8 bits only use 1 byte for storage if(acqpar->GetNbBits()<=8) leaf += "1"; fUserTree->Branch( acqpar->GetName(), *(acqpar->ConnectData()), leaf.Data() ); } } #if ROOT_VERSION_CODE > ROOT_VERSION(5,25,4) #if ROOT_VERSION_CODE < ROOT_VERSION(5,26,1) // The TTree::OptimizeBaskets mechanism is disabled, as for ROOT versions < 5.26/00b // this lead to a memory leak fUserTree->SetAutoFlush(0); #endif #endif // add list of parameter names in fUserTree->GetUserInfos() // and if option="arrays" add aliases for each parameter & its multiplicity // TObjArray has to be as big as the largest parameter number in the list // of raw data parameters. So first loop over parameters to find max param number. UInt_t maxpar = 0; TIter next(GetRawDataParameters()); KVACQParam* par; while( (par=(KVACQParam*)next()) ) if (par->GetNumber()>maxpar) maxpar=par->GetNumber(); TObjArray *parlist = new TObjArray(maxpar,1); parlist->SetName("ParameterList"); next.Reset(); while( (par = (KVACQParam*)next()) ){ parlist->AddAt( new TNamed( par->GetName(), Form("index=%d",par->GetNumber()) ), par->GetNumber() ); if( make_arrays ){ fUserTree->SetAlias( par->GetName(), Form("Sum$((ParNum==%d)*ParVal)", par->GetNumber() ) ); fUserTree->SetAlias( Form("%s_M", par->GetName()), Form("Sum$(ParNum==%d)", par->GetNumber() ) ); } } fUserTree->GetUserInfo()->Add(parlist); }
void PlotPubHisto(TObjArray histograms,TEnv *params){ // This is a modification of the AddHistos macro // Number of histos to plot: Int_t ntot = histograms.GetEntries(); // Check we have what we expect (the order should be: data, qcd, wjets, etc...) for(Int_t i = 0; i<ntot; i++){ if(histograms[i]==0) { cout<<"Error in AddHistos: histogram "<<i<<" is a NULL pointer!"<<endl; return; } TH1F * hthis = (TH1F*) histograms[i]; // include the overflow/underflow bins: int numbins = hthis->GetNbinsX(); //this is the last bin plotted double hicontent = hthis->GetBinContent(numbins); double overflow = hthis->GetBinContent(numbins+1);// this bin contains the overflow double locontent = hthis->GetBinContent(1);// this is the first bin plotted double underflow = hthis->GetBinContent(0);// this bin contains the underflow if (underflow>0 || overflow>0){ //printf("%-20s numbins=%4i hicontent=%4.2f over=%4.2f locontent=%4.2f underflow=%4.2f \n", // title.Data(),numbins,hicontent,overflow,locontent,underflow); } hthis->SetBinContent(numbins,hicontent+overflow); hthis->SetBinContent(1,locontent+underflow); } // define a few additional line styles: gStyle->SetLineStyleString(5,"20 12 4 12"); gStyle->SetLineStyleString(6,"20 12 4 12 4 12 4 12"); gStyle->SetLineStyleString(7,"20 20"); gStyle->SetLineStyleString(8,"20 12 4 12 4 12"); gStyle->SetLineStyleString(9,"80 25"); gStyle->SetLineStyleString(10,"50 10 10 10"); gStyle->SetLineStyleString(17,"30 25"); gStyle->SetLineStyleString(20,"60 20"); gStyle->SetLineStyleString(21,"60 20 20 20"); int lineStyle[20]; for(int i=0;i<20;i++) { lineStyle[i]=i; } // the first histogram in the list: TH1F *h0=((TH1F*) histograms[0])->Clone(); // histogram output filename TString oFileName=params->GetValue("Histo.Output.Filename","bogus.eps"); // figure out the number of signals Int_t nsig=1; if(params->Defined("Histo.Signal.Title.1")) nsig=1; if(params->Defined("Histo.Signal.Title.2")) nsig=2; if(params->Defined("Histo.Signal.Title.3")) nsig=3; cout << " I will use nsig = " << nsig << " signal sources" << endl; // Do the cumulative summing, except for the data TObjArray addedhistos; addedhistos.Clear(); TObjArray signalhistos; signalhistos.Clear(); TString sampletitles[20]; Int_t nbkg=0; for(Int_t i = 1; i<ntot; i++){// i runs over histograms[i], so data is for i=0 ostringstream baseSrcName; baseSrcName << "Files." << i+1 << ".";// Counting starts at 1: Files.1.Name: Data TString bSrcName(baseSrcName.str().c_str()); // skip some if we want to show them as lines TString htitle=params->GetValue(bSrcName+"Title",""); sampletitles[i-1]=htitle; if(params->GetValue("Histo.ShowSignalSeparately",0)==1 && // skip the last two if the signal title is not defined: ( ( !(params->Defined("Histo.Signal.Title")||params->Defined("Histo.Signal.Title.1")) && i>=ntot-nsig) // skip the signal if the signal title is defined || params->GetValue("Histo.Signal.Title",".")==htitle || params->GetValue("Histo.Signal.Title.1",".")==htitle || params->GetValue("Histo.Signal.Title.2",".")==htitle || params->GetValue("Histo.Signal.Title.3",".")==htitle ) ) { TH1F * hthis = (TH1F*) histograms[i]->Clone(); cout<<" Found signal in location "<<i+1<<" with name "<<htitle.Data()<<endl; signalhistos.Add(hthis); } else { TH1F * hthis = (TH1F*) histograms[i]->Clone(); addedhistos.Add(hthis); // Fill in the new TObjArray with a copy //cout << " Adding bkg " << i << " " << htitle.Data() << " " << hthis->Integral() << endl; // add all of the backgrounds if (i>1) {// i=0 is the data, and we must start with the second // background to add the previous TH1F * hprevious = (TH1F*) addedhistos[i-2]; if ( hthis->GetXaxis()->GetNbins() != hprevious->GetXaxis()->GetNbins() ) { // Protection against _whoran histogram. // We cannot add two histograms with different numbers of bins! cout<<"Error in AddHistos: incompatible number of bins!"<<endl; return; } hthis->Add(hprevious); // Do the addition addedhistos.RemoveAt(i-1); // And substitute whatever we had addedhistos.AddAt(hthis,i-1); nbkg++; //cout << "Substituing bkg " << i << " + " << i-1 << " in addedhistos["<< i-1 <<"]" << endl; } } // end of: if adding histograms } cout << " nbkg = " << nbkg << endl; // Rebin histos if necessary, but first calculate KS: TH1F *hbkg = (TH1F*) addedhistos[nbkg]; double KS = h0->KolmogorovTest(hbkg); double chi2ndf = h0->Chi2Test(hbkg, "UWUFOFCHI2/NDF"); //cout << title.Data() << " KS = " << KS << " chi2/NDF = " << chi2ndf << endl; // Rebin? Set nrebin = 0 to NOT do rebinning. // Will rebin only histos whose maximum x axis value exceeds 20. // Anything with less will most probably be already made of integers, so no // need to rebin that! Int_t nbinsx = h0->GetXaxis()->GetNbins(); Int_t nbinsy = 100; Int_t nrebin = 5; if ( nbinsx > 750 && nbinsx <= 1000) nrebin = 30; if ( nbinsx > 400 && nbinsx <= 750 ) nrebin = 25;//20 if ( nbinsx > 300 && nbinsx <= 400 ) nrebin = 25;//15 if ( nbinsx > 200 && nbinsx <= 300 ) nrebin = 25;//15 if ( nbinsx > 150 && nbinsx <= 200 ) nrebin = 10;//10 if ( nbinsx > 100 && nbinsx <= 150 ) nrebin = 10;//10 if ( nbinsx > 50 && nbinsx <= 100 ) nrebin = 10;//10 if ( nbinsx > 20 && nbinsx <= 50 ) nrebin = 2; if ( nbinsx <= 20 ) nrebin = 1; printf(" Saw nbins =%4i, rebinning by nrebin =%2i to final %3i bins \n",nbinsx,nrebin,int(nbinsx/nrebin)); if ( nrebin != 0 ) { h0->Rebin(nrebin); // data for (Int_t i = 0; i<=nbkg; i++){ TH1F * h = (TH1F*) addedhistos[i]; h->Rebin(nrebin); } for (Int_t i = 0; i<nsig; i++){ TH1F * h = (TH1F*) signalhistos[i]; h->Rebin(nrebin); } } // default text size: 0.045 // make it bigger for the paper float textSize = 0.045; if(params->GetValue("Histo.Preliminary","yes")==TString("paper")) textSize=0.07; if(params->Defined("Histo.TextSize")) textSize=params->GetValue("Histo.TextSize",0.07); // Now, check largest dimensions so that we can plot all histograms at once. Float_t xmin=9999., xmax=-9999., ymin=9999., ymax=-9999.; for(Int_t i = 0; i<=nbkg; i++){ TH1F * h = (TH1F*) addedhistos[i]; ostringstream baseSrcName; baseSrcName << "Files." << i+1 << "."; TString bSrcName(baseSrcName.str().c_str()); TAxis *axis = h->GetXaxis(); if( axis->GetXmin() < xmin ) xmin = axis->GetXmin(); if( axis->GetXmax() > xmax ) xmax = axis->GetXmax(); if( h->GetMinimum() < ymin ) ymin = h->GetMinimum(); if( h->GetMaximum() > ymax ) ymax = h->GetMaximum(); } ymax = TMath::Nint(ymax*1.25+1); // Make enough room for the big legend TString title = h0->GetTitle(); // // now check if we should simply use the ranges that was passed to us. if(params->Defined("Histo.Xmin")) xmin = params->GetValue("Histo.Xmin",0.); if(params->Defined("Histo.Xmax")) xmax = params->GetValue("Histo.Xmax",0.); if(params->Defined("Histo.Ymin")) ymin = params->GetValue("Histo.Ymin",0.); if(params->Defined("Histo.Ymax")) ymax = params->GetValue("Histo.Ymax",0.); // Now make the frame: TH2F * frame = new TH2F("frame","",nbinsx,xmin,xmax,nbinsy,ymin,ymax); cout<<" frame has xmin "<<xmin<<", xmax "<<xmax<<", ymax "<<ymax<<endl; // get the x- and y-axis titles TString ytitle=params->GetValue("Histo.YTitle",""); if ( params->Defined("Histo.XTitle")) { frame->SetXTitle(params->GetValue("Histo.XTitle","")); } else { frame->SetXTitle(h0->GetTitle()); } frame->SetYTitle(ytitle.Data()); // also set the text size for the X and Y axis titles and numbers // do this globally for the style we are using float axisLabelSize=textSize; frame->GetXaxis()->SetLabelSize(axisLabelSize); frame->GetYaxis()->SetLabelSize(axisLabelSize); frame->GetXaxis()->SetTitleSize(axisLabelSize); frame->GetYaxis()->SetTitleSize(axisLabelSize); frame->SetStats(false); // reduce the axis title offset if the fonts are very large if(textSize>0.055) frame->GetXaxis()->SetTitleOffset(1.0); // also change the X axis title offset to move it farther away from the numbers if(params->Defined("Histo.XTitle.Offset")) { float xtitoffset=params->GetValue("Histo.XTitle.Offset",1.0); frame->GetXaxis()->SetTitleOffset(xtitoffset); } // also change the y axis title offset to move it farther away from the numbers frame->GetYaxis()->SetTitleOffset(1.0); // reduce the axis title offset if the fonts are very large if(textSize>0.055) frame->GetYaxis()->SetTitleOffset(1.0); // set the axes divisions frame->GetXaxis()->SetNdivisions(505,true); if(params->Defined("Histo.XNdivisions")) frame->GetXaxis()->SetNdivisions(params->GetValue("Histo.XNdivisions",505),kTRUE); if(params->Defined("Histo.YNdivisions")) frame->GetYaxis()->SetNdivisions(params->GetValue("Histo.YNdivisions",505),kTRUE); // make sure the X axis title and Y axis title are in black! frame->GetXaxis()->SetTitleColor(1); frame->GetYaxis()->SetTitleColor(1); // Could plot in log scale... //gPad->SetLogy(); // finally: Draw frame->Draw(); // Draw the background ones: for(Int_t i=nbkg; i>=0; i--){ TH1F * h = (TH1F*) addedhistos[i]; h->SetStats(kFALSE); ostringstream baseSrcName; baseSrcName << "Files." << i+2 << ".";// to account for the data which is Files.1 TString bSrcName(baseSrcName.str().c_str()); Int_t hcolor=params->GetValue(bSrcName+"Color",1); h->SetLineColor(1); h->SetFillColor(hcolor); if (i==nbkg) printf(" Data Yield = %5.2f ; SumBkg = %5.2f ; Data-SumBkg diff = %5.2f%% \n", h0->Integral(),h->Integral(),(h0->Integral()-h->Integral())*100./h0->Integral()); printf(" plotting bkg i=%2i name=%20.20s file=%2i integral=%5.1f color=%2i\n", i,sampletitles[i].Data(),i+2,h->Integral(),hcolor); int fillStyle=params->GetValue(bSrcName+"FillStyle",1001); h->SetFillStyle(fillStyle); h->DrawCopy("Hist,Same"); } // // and draw the signal ones // draw them in reverse order so that the last one will be on top. //for(Int_t i=ntot-3; i<ntot; i++){ for(Int_t i=nsig-1; i>=0; i--){ ostringstream baseSrcName; baseSrcName << "Files." << ntot+1-nsig+i << "."; TString bSrcName(baseSrcName.str().c_str()); Int_t hcolor=params->GetValue(bSrcName+"Color",1); TH1F * h = (TH1F*) signalhistos[i]; if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=90")) h->Add (h, 1.07874865 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=100")) h->Add (h, 1.62317373 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=110")) h->Add (h, 2.31347600 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=120")) h->Add (h, 3.25275183 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=130")) h->Add (h, 4.54142919 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=140")) h->Add (h, 6.19195046 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=150")) h->Add (h, 8.38307290 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=160")) h->Add (h, 11.31721008 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=170")) h->Add (h, 14.85376469 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=180")) h->Add (h, 19.54537459 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=190")) h->Add (h, 25.44594010 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=200")) h->Add (h, 32.94784356 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=220")) h->Add (h, 54.09499080 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=240")) h->Add (h, 86.85079034 -1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=260")) h->Add (h, 136.31406761-1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=280")) h->Add (h, 210.70375053-1.000); else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=300")) h->Add (h, 319.79533099-1.000); printf(" plotting sig i=%2i name=%20.20s file=%2i integral=%5.1f color=%2i\n", i,sampletitles[ntot-1-nsig+i].Data(),ntot+1-nsig+i,h->Integral(),hcolor); // create a white background around each line (helps readibility): TH1F *h1=h->Clone(); h1->SetStats(kFALSE); h1->SetLineWidth(6); h1->SetLineColor(0);h1->SetFillColor(0); h1->SetLineStyle(1); h1->SetFillStyle(0); h1->Draw("HIST,SAME"); // now draw the proper line: h->SetStats(kFALSE); h->SetLineWidth(6); h->SetLineColor(hcolor);h->SetFillColor(0); Int_t hlinestyle = params->GetValue(bSrcName+"LineStyle",1); h->SetLineStyle(hlinestyle); h->SetFillStyle(0); // finally, draw! h->Draw("HIST,SAME"); } // end of: drawing signal as separate lines // Data is special: // change the default size of the little bar at the end of the error bar here gStyle->SetEndErrorSize(3); // also, maybe don't display the error bars along the X axis: //gStyle->SetErrorX(0); // X error bars not displayed gStyle->SetErrorX(0.5); // X error bars have width of a bin // now set the rest h0->SetMarkerSize(2); // if there are too many points (>80), keep the marker size smaller if(h0->GetNbinsX()>=50) h0->SetMarkerSize(1); //if(h0->GetNbinsX()>=100) h0->SetMarkerSize(1); h0->SetLineWidth(3); h0->SetMarkerStyle(8); h0->SetMarkerColor(1); h0->Draw("E1,SAME"); // Print some comparison: //ostringstream basefactor; //basefactor << "Files." << nbkg+3 << "." << "Factor"; //TString timesfactor(basefactor.str().c_str()); //Double_t nprod = params->GetValue(timesfactor,1.000); //printf("Data Yield = %5.2f ; SumBkg = %5.2f ; SumBkg+Sig = %5.2f ; Data-SumBkg diff = %5.2f%% \n", // h0->Integral(),hbkg2->Integral,(hbkg2->Integral()+(signalhistos[0]->Integral()/nprod), // (h0->Integral()-hbkg2->Integral)*100./h0->Integral())); // // Print D0 and lumi: // TText *t1 = new TText(); t1->SetTextFont(62); t1->SetTextColor(1); t1->SetNDC(); t1->SetTextAlign(12); t1->SetTextSize(textSize); TString prelim="D\328 Preliminary"; if(oFileName.EndsWith(".eps")) { prelim="D\349 Preliminary L=3.7 fb^-1#"; } else if(oFileName.EndsWith(".gif")) { prelim="D\328 Preliminary L=3.7 fb^-1#"; } t1->DrawTextNDC(0.13,0.965,prelim.Data()); // a counter of how much text we have added from the top int nAddTextLines=0; // any additional text? for(int iText=1;iText<20;iText++) { ostringstream baseTextName; baseTextName << "Histo.AddText." << iText; TString bTextName(baseTextName.str().c_str()); if(params->Defined(bTextName)) { // we are adding a line of text TLatex *t2 = new TLatex(); t2->SetTextFont(62); t2->SetTextColor(13); t2->SetTextAlign(32); t2->SetNDC(); t2->SetTextSize(textSize); TString addText(params->GetValue(bTextName,".")); float x0=0.94; float y0=0.96-(nAddTextLines)*0.05; // check if the user specified an alternative location for the text if(params->Defined(bTextName+".X0")) x0=params->GetValue(bTextName+".X0",0.94); if(params->Defined(bTextName+".Y0")) y0=params->GetValue(bTextName+".Y0",0.8); if(params->Defined(bTextName+".TextSize")) t2->SetTextSize(params->GetValue(bTextName+".TextSize",textSize)); // and increment the counter keeping track of how much we added, // but only if the user didn't move the label around. if(!params->Defined(bTextName+".X0")) nAddTextLines++; printf("AddText %4.2f %4.2f %s\n",x0,y0,addText.Data()); t2->DrawLatex(x0,y0,addText.Data()); } }// end additional text // now draw the frame axis again so that we can see the tick marks frame->Draw("sameaxis"); // Legend: TString showLegend(params->GetValue("Histo.ShowLegend",".")); if( showLegend != "no" ){ float lgdxmin=.65, lgdxmax=.90, lgdymin=.50, lgdymax=.91; if(showLegend=="yes" || showLegend=="right") { } else if (showLegend=="left"){ lgdxmin=.16; lgdxmax=.42; } TLegend *lgd = new TLegend(lgdxmin,lgdymin,lgdxmax,lgdymax); // This line makes the legend transparent (not grey, ewwww!): lgd->SetBorderSize(0); lgd->SetTextSize(textSize*0.9);// 10% less size lgd->SetTextFont(62); lgd->SetFillColor(0); // Plot the legend in reverse order (but data goes first): NiceAddEntry(lgd,h0,params->GetValue("Files.1.Title","Data"),"PL"); for(Int_t i = nbkg; i>=0; i--){ TH1F * h = (TH1F*) addedhistos[i]; TString lgd_entry= sampletitles[i]; // sampletitles runs from 0 (firstbkg) to ntot-1 NiceAddEntry(lgd,h,lgd_entry.Data(),"F"); } for(Int_t i = nsig-1; i>=0; i--){ TH1F * h = (TH1F*) signalhistos[i]; TString lgd_entry = sampletitles[i+nbkg+1]; // sampletitles runs from 0 (firstbkg) to ntot-1 ostringstream basefactor; basefactor << "Files." << i+nbkg+3 << "." << "Factor"; TString timesfactor(basefactor.str().c_str()); Double_t nprod = params->GetValue(timesfactor,1.000); if (nprod != 1.0 ) lgd_entry.Form("%s x%2.0f",lgd_entry.Data(),nprod); //cout << i+nbkg+3 << " " << nprod << " " << lgd_entry.Data() << endl; NiceAddEntry(lgd,h,lgd_entry.Data(),"L"); } lgd->Draw("SAME"); }// show legend // Draw the KS: TLatex *ks = new TLatex(); ks->SetTextFont(62); ks->SetTextColor(1); TString ks_val = Form("KS = %3.2f",KS); ks->SetTextAlign(11); ks->SetTextSize(0.03); // ks->SetTextAngle(90); ks->DrawTextNDC(0.83,0.93,ks_val.Data()); TString chi2_val = Form("#chi^{2}/ndf = %3.1f",chi2ndf); ks->SetNDC(true); ks->DrawLatex(0.83,0.97,chi2_val.Data()); // // Voila! // }
//---------------------------------------------------------------------- void AliITSDigitPlot(Int_t istart=0,Int_t iend=-1, const char *filename="galice.root"){ // Macro to plot digits from many events // Inputs: // Int_t istart Starting event number // Int_t iend Last event number, =-1 all // Outputs: // none. // Return: // none. if (gClassTable->GetID("AliRun") < 0) { gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C"); } if(gAlice){ delete AliRunLoader::Instance(); delete gAlice; gAlice=0; } // end if gAlice Int_t nevents=0,nmodules=0,retval=0; Int_t i,j,module,dig,ndig,row,column,signal,det; AliITS *its = 0; AliITSgeom *gm = 0; AliRunLoader *rl = 0; AliITSLoader *ld = 0; TTree *treeD = 0; TBranch *br = 0; TClonesArray *digits = 0; AliITSdigit *d = 0; TObjArray *digDet = 0; Char_t *branchname[3] = {"ITSDigitsSPD","ITSDigitsSDD","ITSDigitsSSD"}; // rl = AliRunLoader::Open(filename); if(!rl){ cerr<<"Error, can not open file "<<filename<<endl; return; } // end if !rl retval = rl->LoadgAlice(); if (retval){ cerr<<"Error, LoadgAlice returned error"<<endl; return; } gAlice = rl->GetAliRun(); retval = rl->LoadHeader(); if (retval){ cerr<<"Error, LoadHeader returned error"<<endl; return; } // end if ld = (AliITSLoader*) rl->GetLoader("ITSLoader"); if(!ld){ cerr<<"Error, ITS loader not found"<<endl; return; } // end if its = (AliITS*) gAlice->GetModule("ITS"); if(!its){ cerr <<"Error, No AliDetector ITS found on file"<<endl; return; } // end if gm = its->GetITSgeom(); if(!gm){ cerr <<"Error, AliITSgeom not initilized in module ITS"<<endl; return; } // end if nevents = rl->GetNumberOfEvents(); if(iend>nevents) iend = nevents; if(iend<0) iend = nevents; if(iend<=istart){delete rl; return;} nmodules = gm->GetIndexMax(); ld->GetDigitsDataLoader()->Load("read"); treeD = ld->TreeD(); if(!treeD){ cerr <<"Error, could not get TreeD="<<treeD << endl; return; } // end if !treeD digDet = new TObjArray(3); its->SetDefaults(); for(det=0;det<3;det++){ digDet->AddAt(new TClonesArray(its->GetDetTypeSim()-> GetDigitClassName(det),1000),det); br = treeD->GetBranch(branchname[det]); br->SetAddress(&((*digDet)[det])); } // end for det // SetUPHistograms(); // for(i=istart;i<iend;i++){ rl->GetEvent(i); treeD = ld->TreeD(); for(det=0;det<3;det++){ ((TClonesArray*)(digDet->At(det)))->Clear(); br = treeD->GetBranch(branchname[det]); br->SetAddress(&((*digDet)[det])); } // end for det for(module=0;module<nmodules;module++){ for(j=0;j<3;j++) ((TClonesArray*)(digDet->At(j)))->Clear(); treeD->GetEvent(module); digits = (TClonesArray*) (digDet->At(0)); // SPD only. ndig = digits->GetEntriesFast(); for(dig=0;dig<ndig;dig++){ d = (AliITSdigit*) digits->At(dig); row = d->GetCoord1(); column = d->GetCoord1(); signal = d->GetSignal(); //cout <<"event="<<i<< " ndig="<< ndig<< " mod=" //<<module<<" row="<<row<<" col="<<column<< " sig=" //<<signal<<endl; FillHistograms(module,row,column,signal); } // end for mod } // end for module } // end for i DisplayHistograms(); delete digits; return; }
/// Cache MC production information void CacheTrendingProductions(TString dataType){ AliExternalInfo info; info.fLoadMetadata=kFALSE; TObjArray* periodList = NULL, *idList=NULL; // TTree * tree = info.GetTree("MonALISA.ProductionCycle","",""); Int_t nProd=tree->GetEntries(); periodList = new TObjArray(nProd); idList= new TObjArray(nProd); TLeaf *leafTag = tree->GetLeaf("Tag"); TLeaf *leafID = tree->GetLeaf("ID"); for (Int_t iProd=0; iProd<nProd; iProd++){ tree->GetEntry(iProd); TString prodName=((char*)leafTag->GetValuePointer()); TString idName =TString::Format("%d",TMath::Nint(leafID->GetValue())); if (prodName.Contains("LHC")==0) continue; periodList->AddAt(new TObjString(prodName),iProd); idList->AddAt(new TObjString(idName),iProd); } delete tree; // for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++) { TObjString * pName= (TObjString*)idList->At(iPeriod); if (pName==NULL) continue; TTree* treeP = info.GetTreeProdCycleByID(idList->At(iPeriod)->GetName()); if (treeP==NULL) continue; TLeaf *leafOutput = treeP->GetLeaf("outputdir"); Int_t nRuns= treeP->GetEntries(); treeP->GetEntry(0); TString path=((char*)leafOutput->GetValuePointer()); TObjArray *pArray = path.Tokenize("/"); if (pArray==NULL) continue; Int_t nElems=pArray->GetEntries(); if (nElems<4) continue; TString aperiod=pArray->At(3)->GetName(); TString apass =pArray->At(nElems-1)->GetName(); delete pArray; ::Info("CacheTrendingProductions","%s\t%s\t%s\t%s\t%d",idList->At(iPeriod)->GetName(),path.Data(), aperiod.Data(),apass.Data(),nRuns); delete treeP; TTree* treeQA = info.GetTree(dataType.Data(),aperiod.Data(),apass.Data()); if (treeQA){ Int_t entries=treeQA->Draw("run","1","goff"); TString sInfo=aperiod; sInfo+="\t"; sInfo+=apass; sInfo+="\t"; sInfo+=dataType; sInfo+="\t"; sInfo+=TString::Format("%d\t",entries); sInfo+=TString::Format("%d\t",nRuns); for (Int_t j=0; j<entries; j++) { sInfo+=TString::Format("%2.0f,",treeQA->GetV1()[j]); ::Info("CacheTrendingProductionsRun:","%s\t%s\t%s\t%d\t%d\t%2.0f",aperiod.Data(),apass.Data(),dataType.Data(),entries,nRuns,treeQA->GetV1()[j]); } sInfo+="0"; ::Info("CacheTrendingProductionsPeriod:","%s\n",sInfo.Data()); delete treeQA; }else{ ::Error("CacheTrendingProductionsPeriod:","%s\t%s\t%s\t-1\t%d\t0",aperiod.Data(),apass.Data(), dataType.Data(),nRuns); } } }