]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/ITS/AliITSQAtrendAlign.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGPP / ITS / AliITSQAtrendAlign.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TH1F.h>
3 #include <TH2F.h>
4 #include <TF1.h>
5 #include <TProfile.h>
6 #include <TPad.h>
7 #include <TGraphErrors.h>
8 #include <TROOT.h>
9 #include <TFile.h>
10 #include <TTree.h>
11 #include <TGrid.h>
12 #include <TGridResult.h>
13 #include <TMath.h>
14 #include <TSystem.h>
15 #include <TNtuple.h>
16 #include <TCanvas.h>
17 #include <TStyle.h>
18 #include <TLatex.h>
19 #include <TLegend.h>
20 #include <TLegendEntry.h>
21 #include <Riostream.h>
22 #include "AliITSgeomTGeo.h"
23 #include <TLine.h>
24 #include "AliCDBManager.h"
25 #include "AliCDBEntry.h"
26 #include "AliITSCalibration.h"
27 #include "AliITSOnlineCalibrationSPDhandler.h"
28 #include "AliITSBadChannelsSSD.h"
29 #include "AliITSBadChannelsSSDv2.h"
30 #include "AliITSgeomTGeo.h"
31 #include <TObjArray.h>
32 #endif
33
34 TString pdfFileNames="";
35 void MakePlots(Int_t run1=-1,Int_t run2=99999999,TString ntupleFileName="TrendingITSAlign_norm.root");
36 void ReadOldSSDBadChannels(TObjArray *array, AliITSBadChannelsSSDv2 *badChannelsSSD);
37 void AliITSQAtrendAlign(TString runListFile="QA_Trend_list.txt",TString ntupleFileName="TrendingITSAlign_norm.root");
38
39 ////////////////////////////////////////////////////////////////
40 //   Please, read this comment before using this macro 
41 //
42 //   INPUT FILE: a text file (by default QA_Trend_list.txt) which contains
43 //   a list of the complete path+file name of the QAresults root files 
44 //   (without the alien:// prefix).
45 //   One file per line. The order is irrelevant.
46 //
47 //   USAGE:
48 //
49 //   Function AliITSQAtrendAlign():  
50 //   it looks for a local root file named TrendingITSAlign_norm.root,
51 //   where the ntuples used to build the trending plots are
52 //   stored. This file is used to generate incrementally the ntuple contents:
53 //   when you add a new entry in the QA_Trend_list.txt file and you have a
54 //   local copy of the TrendingITSAlign_norm.root file, only the additional run will
55 //   be processed. The whole list is processed only the first time you use the
56 //   macro. 
57 //   For each run, the macro performs a gaussian fit of the xlocal and zlocal 
58 //   residuals from QA train of each module of each ITS layer; 
59 //   then evaluates the fractions of modules  
60 //   whose xlocal and zlocal residual mean and sigma are smaller than chosen 
61 //   threshold values; the fractions are normalized to the number of good modules 
62 //   directly read from OCDB fpor each run. 
63 //   Please, bear in mind that this macro is RAM-intensive: all the
64 //   ntuples are kept in memory. It is better to add few runs to the list at 
65 //   each time, according to the RAM of your computer. 
66 //   The function AliITSQAtrendAlign does not produce any plot.
67 //
68 //   Function MakePlots(run1,run2):
69 //   it produces the plots. For each canvas a PDF file is created.
70 //   A PDF file with all the canvases merged is also produced, named by default TrendingITSAlign_norm.root
71 //   The first two arguments define a range for the runs to be displayed
72 //   These two arguments are optional: by default, all the runs
73 //   found in the ntuples are displayed
74 ////////////////////////////////////////////////////////////////
75
76 /* $Id$ */
77
78 //_____________________________________________________________________//
79 void ReadOldSSDBadChannels(TObjArray *array, 
80                                                    AliITSBadChannelsSSDv2 *badChannelsSSD) {
81         Int_t fNMod = array->GetEntries();
82         cout<<"Converting old calibration object for bad channels..."<<endl;
83         for (Int_t iModule = 0; iModule < fNMod; iModule++) {
84                 //for (Int_t iModule = 0; iModule < 1; iModule++) {
85                 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
86                 TArrayI arrayPSide = bad->GetBadPChannelsList();
87                 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) 
88                         badChannelsSSD->AddBadChannelP(iModule,
89                                                                                    iPCounter,
90                                                                                    (Char_t)arrayPSide.At(iPCounter));
91         
92                 TArrayI arrayNSide = bad->GetBadNChannelsList();
93                 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) 
94                         badChannelsSSD->AddBadChannelN(iModule,
95                                                                                    iNCounter,
96                                                                                    (Char_t)arrayNSide.At(iNCounter));
97                 
98         }//loop over modules      
99 }
100
101 //_____________________________________________________________________//
102
103
104 void AliITSQAtrendAlign(TString runListFile,TString ntupleFileName){
105
106   TGrid::Connect("alien:");
107
108   const Int_t nVariables=169;
109   TNtuple* ntits=new TNtuple("ntitsalign","ITS ALIGN trending","nrun:SDDfracModmux20_3:errSDDfracModmux20_3:SDDfracModmux50_3:errSDDfracModmux50_3:SDDfracModmux100_3:errSDDfracModmux100_3:SDDfracModsigx100_3:errSDDfracModsigx100_3:SDDfracModsigx200_3:errSDDfracModsigx200_3:SDDfracModsigx300_3:errSDDfracModsigx300_3:SDDfracModmuxlr20_3:errSDDfracModmuxlr20_3:SDDfracModmuxlr50_3:errSDDfracModmuxlr50_3:SDDfracModmuxlr100_3:errSDDfracModmuxlr100_3:SDDfracModexcx100_3:errSDDfracModexcx100_3:SDDfracModexcx200_3:errSDDfracModexcx200_3:SDDfracModexcx300_3:errSDDfracModexcx300_3:SDDfracModmuz50_3:errSDDfracModmuz50_3:SDDfracModmuz100_3:errSDDfracModmuz100_3:SDDfracModmuz300_3:errSDDfracModmuz300_3:SDDfracModsigz100_3:errSDDfracModsigz100_3:SDDfracModsigz300_3:errSDDfracModsigz300_3:SDDfracModsigz500_3:errSDDfracModsigz500_3:SDDfracModmux20_4:errSDDfracModmux20_4:SDDfracModmux50_4:errSDDfracModmux50_4:SDDfracModmux100_4:errSDDfracModmux100_4:SDDfracModsigx100_4:errSDDfracModsigx100_4:SDDfracModsigx200_4:errSDDfracModsigx200_4:SDDfracModsigx300_4:errSDDfracModsigx300_4:SDDfracModmuxlr20_4:errSDDfracModmuxlr20_4:SDDfracModmuxlr50_4:errSDDfracModmuxlr50_4:SDDfracModmuxlr100_4:errSDDfracModmuxlr100_4:SDDfracModexcx100_4:errSDDfracModexcx100_4:SDDfracModexcx200_4:errSDDfracModexcx200_4:SDDfracModexcx300_4:errSDDfracModexcx300_4:SDDfracModmuz50_4:errSDDfracModmuz50_4:SDDfracModmuz100_4:errSDDfracModmuz100_4:SDDfracModmuz300_4:errSDDfracModmuz300_4:SDDfracModsigz100_4:errSDDfracModsigz100_4:SDDfracModsigz300_4:errSDDfracModsigz300_4:SDDfracModsigz500_4:errSDDfracModsigz500_4:SPDfracModmux20_1:errSPDfracModmux20_1:SPDfracModmux50_1:errSPDfracModmux50_1:SPDfracModmux100_1:errSPDfracModmux100_1:SPDfracModsigx100_1:errSPDfracModsigx100_1:SPDfracModsigx200_1:errSPDfracModsigx200_1:SPDfracModsigx300_1:errSPDfracModsigx300_1:SPDfracModmuz50_1:errSPDfracModmuz50_1:SPDfracModmuz100_1:errSPDfracModmuz100_1:SPDfracModmuz300_1:errSPDfracModmuz300_1:SPDfracModsigz100_1:errSPDfracModsigz100_1:SPDfracModsigz300_1:errSPDfracModsigz300_1:SPDfracModsigz500_1:errSPDfracModsigz500_1:SPDfracModmux20_2:errSPDfracModmux20_2:SPDfracModmux50_2:errSPDfracModmux50_2:SPDfracModmux100_2:errSPDfracModmux100_2:SPDfracModsigx100_2:errSPDfracModsigx100_2:SPDfracModsigx200_2:errSPDfracModsigx200_2:SPDfracModsigx300_2:errSPDfracModsigx300_2:SPDfracModmuz50_2:errSPDfracModmuz50_2:SPDfracModmuz100_2:errSPDfracModmuz100_2:SPDfracModmuz300_2:errSPDfracModmuz300_2:SPDfracModsigz100_2:errSPDfracModsigz100_2:SPDfracModsigz300_2:errSPDfracModsigz300_2:SPDfracModsigz500_2:errSPDfracModsigz500_2:SSDfracModmux20_5:errSSDfracModmux20_5:SSDfracModmux50_5:errSSDfracModmux50_5:SSDfracModmux100_5:errSSDfracModmux100_5:SSDfracModsigx100_5:errSSDfracModsigx100_5:SSDfracModsigx200_5:errSSDfracModsigx200_5:SSDfracModsigx300_5:errSSDfracModsigx300_5:SSDfracModmuz50_5:errSSDfracModmuz50_5:SSDfracModmuz100_5:errSSDfracModmuz100_5:SSDfracModmuz300_5:errSSDfracModmuz300_5:SSDfracModsigz100_5:errSSDfracModsigz100_5:SSDfracModsigz300_5:errSSDfracModsigz300_5:SSDfracModsigz500_5:errSSDfracModsigz500_5:SSDfracModmux20_6:errSSDfracModmux20_6:SSDfracModmux50_6:errSSDfracModmux50_6:SSDfracModmux100_6:errSSDfracModmux100_6:SSDfracModsigx100_6:errSSDfracModsigx100_6:SSDfracModsigx200_6:errSSDfracModsigx200_6:SSDfracModsigx300_6:errSSDfracModsigx300_6:SSDfracModmuz50_6:errSSDfracModmuz50_6:SSDfracModmuz100_6:errSSDfracModmuz100_6:SSDfracModmuz300_6:errSSDfracModmuz300_6:SSDfracModsigz100_6:errSSDfracModsigz100_6:SSDfracModsigz300_6:errSSDfracModsigz300_6:SSDfracModsigz500_6:errSSDfracModsigz500_6");
110   Float_t xnt[nVariables];
111
112   // inizializzazione variabili OCDB
113         
114         AliCDBManager* man = AliCDBManager::Instance();
115         man->SetDefaultStorage("alien://folder=/alice/data/2011/OCDB");
116         AliCDBEntry *entrySDD;
117         AliITSCalibration *cal = NULL;
118         TObjArray *calSDD;
119 //
120         
121   TBits* readRun=new TBits(999999);
122   readRun->ResetAllBits();
123
124     if(!gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",ntupleFileName.Data()))){  // esiste gia' un file con l'ntupla ...
125       TFile* oldfil=new TFile(ntupleFileName.Data());                             // che viene letta per aggiungere altre entries ....
126       TNtuple* ntmp=(TNtuple*)oldfil->Get("ntitsalign");
127                 
128       Bool_t isOK=kFALSE;
129       if(ntmp){
130         //      cout << "old ntu = " << ntmp->GetNvar() << ", new ntu  " <<  ntits->GetNvar() << endl;
131         if(ntmp->GetNvar()==ntits->GetNvar()){
132           isOK=kTRUE;
133           TObjArray* arr1=(TObjArray*)ntits->GetListOfBranches();
134           TObjArray* arr2=(TObjArray*)ntmp->GetListOfBranches();
135           for(Int_t iV=0; iV<ntmp->GetNvar(); iV++){
136             TString vnam1=arr1->At(iV)->GetName();
137             TString vnam2=arr2->At(iV)->GetName();
138             if(vnam1!=vnam2) isOK=kFALSE;
139             ntmp->SetBranchAddress(vnam2.Data(),&xnt[iV]);
140           }
141           if(isOK){
142             for(Int_t nE=0; nE<ntmp->GetEntries(); nE++){
143               ntmp->GetEvent(nE);
144               Int_t theRun=(Int_t)(xnt[0]+0.0001);
145               readRun->SetBitNumber(theRun);
146               ntits->Fill(xnt);
147             }
148           }
149         }
150       }
151       if(!isOK){
152         printf("Ntuple in local file not OK -> will be recreated\n");
153       }
154       oldfil->Close();
155       delete oldfil;
156     }
157         
158 #define MAX_LINES 200
159 #define MAX_LINE_LEN 255
160         
161         char strings[MAX_LINES][MAX_LINE_LEN];
162         ifstream in(runListFile.Data());
163         int j = 0;
164         Int_t nrun=0;
165         Int_t runNumb[MAX_LINES];
166         Bool_t goout = kFALSE;
167         while ( in ) {
168                 in.getline(strings[j], MAX_LINE_LEN);
169                 TString aux(strings[j]);
170                 Int_t lentrail=0;
171                 if(aux.Contains("LHC11h/") || aux.Contains("LHC11e/")){
172                         lentrail = 27;
173                 }
174                 else if(aux.Contains("LHC11h_2/")){
175                         lentrail = 29;
176                 }
177                 else {
178                         if(!aux.IsNull())printf("Unrecognised path name %s \n",aux.Data());
179                         goout = kTRUE;
180                 }
181                 if(goout)break;
182                 if(aux.Length()<lentrail)continue;
183                 aux=aux.Remove(0,lentrail);
184                 aux=aux.Remove(6,aux.Length());  
185                 runNumb[j]=atoi(aux.Data());
186                 printf("%d ) - path %s \n",runNumb[j],strings[j]);
187                 j++;
188                 nrun++;
189         }
190         
191         // loop on runs
192         
193         printf("\n *******************   Loop on runs *********** \n");
194
195         Int_t twice=0;
196
197         for(Int_t jru=0;jru<nrun;jru++) {
198                 printf("jru=%d - run number= %d \n",jru,runNumb[jru]);
199                 Int_t iRun=runNumb[jru];
200                 if(readRun->TestBitNumber(iRun))printf("Run %d - already processed\n",iRun);
201                 if(readRun->TestBitNumber(iRun))continue;
202                 //cout << "Value from file is " <<t << endl;
203
204                 if(jru>0){
205                         for(Int_t jru2=0;jru2<jru;jru2++) {
206                                 if(runNumb[jru2]==runNumb[jru]){
207                                         printf("Run %d - twice in the list - skipped\n",runNumb[jru]);
208                                         twice=1;
209                                 }
210                         }
211                 }
212                 if(twice==1){twice=0;continue;}
213                 
214                 printf("%s\n",strings[jru]);
215                 
216                 if(!gGrid||!gGrid->IsConnected()) {
217     printf("gGrid not found! exit macro\n");
218     return;
219                 }
220                 TFile *f=TFile::Open(Form("alien://%s",strings[jru])); 
221
222       TDirectoryFile *df=(TDirectoryFile*)f->Get("ITSAlignQA");
223       if(!df){
224         printf("Run %d ITSAlignQA MISSING -> Exit\n",iRun);
225         continue;
226       }
227       TList *l = (TList*)df->Get("clistITSAlignQA");
228       if(!df){
229         printf("Run %d clistITSAlignQA TList MISSING -> Exit\n",iRun);
230         continue;
231       }
232
233       TH1F* hev=(TH1F*)l->FindObject("hNEvents");  // histo 1d numero di eventi processati
234       Int_t nTotEvents=hev->GetBinContent(2);
235       Int_t nTrigEvents=hev->GetBinContent(3);
236        printf("Run %d Number of Events = %d Triggered=%d\n",iRun,nTotEvents,nTrigEvents);
237       if(nTotEvents==0) continue;
238
239       // working variables 
240       Int_t nModmux20_1=0; 
241       Int_t nModmux50_1=0;
242       Int_t nModmux100_1=0;
243       Int_t nModsigx100_1=0; 
244       Int_t nModsigx200_1=0;
245       Int_t nModsigx300_1=0;
246       Int_t nModmuz50_1=0;
247       Int_t nModmuz100_1=0;
248       Int_t nModmuz300_1=0;
249       Int_t nModsigz100_1=0;
250       Int_t nModsigz300_1=0;
251       Int_t nModsigz500_1=0;
252
253       Int_t nModmux20_2=0; 
254       Int_t nModmux50_2=0;
255       Int_t nModmux100_2=0;
256       Int_t nModsigx100_2=0; 
257       Int_t nModsigx200_2=0;
258       Int_t nModsigx300_2=0;
259       Int_t nModmuz50_2=0;
260       Int_t nModmuz100_2=0;
261       Int_t nModmuz300_2=0;
262       Int_t nModsigz100_2=0;
263       Int_t nModsigz300_2=0;
264       Int_t nModsigz500_2=0;
265
266       Int_t nModmux20_3=0; 
267       Int_t nModmux50_3=0;
268       Int_t nModmux100_3=0;
269       Int_t nModsigx100_3=0; 
270       Int_t nModsigx200_3=0;
271       Int_t nModsigx300_3=0;
272       Int_t nModmuxlr20_3=0;
273       Int_t nModmuxlr50_3=0;
274       Int_t nModmuxlr100_3=0;
275       Int_t nModexcx100_3=0;
276       Int_t nModexcx200_3=0;
277       Int_t nModexcx300_3=0;
278       Int_t nModmuz50_3=0;
279       Int_t nModmuz100_3=0;
280       Int_t nModmuz300_3=0;
281       Int_t nModsigz100_3=0;
282       Int_t nModsigz300_3=0;
283       Int_t nModsigz500_3=0;
284
285       Int_t nModmux20_4=0; 
286       Int_t nModmux50_4=0;
287       Int_t nModmux100_4=0;
288       Int_t nModsigx100_4=0;
289       Int_t nModsigx200_4=0;
290       Int_t nModsigx300_4=0;
291       Int_t nModmuxlr20_4=0;
292       Int_t nModmuxlr50_4=0;
293       Int_t nModmuxlr100_4=0;
294       Int_t nModexcx100_4=0;
295       Int_t nModexcx200_4=0;
296       Int_t nModexcx300_4=0;
297       Int_t nModmuz50_4=0;
298       Int_t nModmuz100_4=0;
299       Int_t nModmuz300_4=0;
300       Int_t nModsigz100_4=0;
301       Int_t nModsigz300_4=0;
302       Int_t nModsigz500_4=0;
303
304       Int_t nModmux20_5=0; 
305       Int_t nModmux50_5=0;
306       Int_t nModmux100_5=0;
307       Int_t nModsigx100_5=0;
308       Int_t nModsigx200_5=0;
309       Int_t nModsigx300_5=0;
310       Int_t nModmuz50_5=0;
311       Int_t nModmuz100_5=0;
312       Int_t nModmuz300_5=0;
313       Int_t nModsigz100_5=0;
314       Int_t nModsigz300_5=0;
315       Int_t nModsigz500_5=0;
316
317       Int_t nModmux20_6=0; 
318       Int_t nModmux50_6=0;
319       Int_t nModmux100_6=0;
320       Int_t nModsigx100_6=0;
321       Int_t nModsigx200_6=0;
322       Int_t nModsigx300_6=0;
323       Int_t nModmuz50_6=0;
324       Int_t nModmuz100_6=0;
325       Int_t nModmuz300_6=0;
326       Int_t nModsigz100_6=0;
327       Int_t nModsigz300_6=0;
328       Int_t nModsigz500_6=0;
329    
330       // mio pezzo lettura e fit
331
332     for(Int_t nmod=0; nmod<240; nmod++){  // loop on SPD modules
333       
334       TString nameResXvsX=Form("hSPDResidX%d",nmod);
335       TH2F *histoResXvsX=(TH2F*)l->FindObject(nameResXvsX);
336       TH1D *histoResX=histoResXvsX->ProjectionY();
337
338       TString nameResZvsZ=Form("hSPDResidZ%d",nmod);
339       TH2F *histoResZvsZ=(TH2F*)l->FindObject(nameResZvsZ);
340       TH1D *histoResZ=histoResZvsZ->ProjectionY();
341
342       TF1 *gg_x = new TF1("gg_x","gaus",-0.050, 0.050);
343       TF1 *gg_z = new TF1("gg_z","gaus",-0.15,0.15);
344
345       if(histoResX->GetEntries()){
346         histoResX->Fit("gg_x","RQ0");
347         if(nmod<80){  // layer 1
348           if(TMath::Abs(gg_x->GetParameter(1))*10000<5.) nModmux20_1+=1; // micron
349           if(TMath::Abs(gg_x->GetParameter(1))*10000<10.) nModmux50_1+=1; 
350           if(TMath::Abs(gg_x->GetParameter(1))*10000<50.) nModmux100_1+=1; 
351           if(gg_x->GetParameter(2)*10000<50.) nModsigx100_1+=1;  
352           if(gg_x->GetParameter(2)*10000<70.) nModsigx200_1+=1;  
353           if(gg_x->GetParameter(2)*10000<200.) nModsigx300_1+=1;  
354         }
355         else { // layer 2
356           if(TMath::Abs(gg_x->GetParameter(1))*10000<10.) nModmux20_2+=1; // micron
357           if(TMath::Abs(gg_x->GetParameter(1))*10000<20.) nModmux50_2+=1; 
358           if(TMath::Abs(gg_x->GetParameter(1))*10000<50.) nModmux100_2+=1; 
359           if(gg_x->GetParameter(2)*10000<130.) nModsigx100_2+=1;  
360           if(gg_x->GetParameter(2)*10000<160.) nModsigx200_2+=1;  
361           if(gg_x->GetParameter(2)*10000<200.) nModsigx300_2+=1;  
362         }
363       }
364   
365       
366       if(histoResZ->GetEntries()){
367         histoResZ->Fit("gg_z","RQ0");
368         if(nmod<80){  // layer 1
369           if(TMath::Abs(gg_z->GetParameter(1))*10000<10.) nModmuz50_1+=1;
370           if(TMath::Abs(gg_z->GetParameter(1))*10000<20.) nModmuz100_1+=1;
371           if(TMath::Abs(gg_z->GetParameter(1))*10000<50.) nModmuz300_1+=1;
372           if(gg_z->GetParameter(2)*10000<150.) nModsigz100_1+=1;  
373           if(gg_z->GetParameter(2)*10000<160.) nModsigz300_1+=1;  
374           if(gg_z->GetParameter(2)*10000<200.) nModsigz500_1+=1;  
375         }
376
377         else { // layer 2
378           if(TMath::Abs(gg_z->GetParameter(1))*10000<10.) nModmuz50_2+=1;
379           if(TMath::Abs(gg_z->GetParameter(1))*10000<20.) nModmuz100_2+=1;
380           if(TMath::Abs(gg_z->GetParameter(1))*10000<50.) nModmuz300_2+=1;
381           if(gg_z->GetParameter(2)*10000<180.) nModsigz100_2+=1;  
382           if(gg_z->GetParameter(2)*10000<190.) nModsigz300_2+=1;  
383           if(gg_z->GetParameter(2)*10000<250.) nModsigz500_2+=1;  
384         }
385       }
386
387     } // loop on SPD modules -- end 
388
389     for(Int_t nmod=240; nmod<500; nmod++){  // loop on SDD modules
390       
391       TString nameResXvsX=Form("hSDDResidXvsX%d",nmod);
392       TH2F *histoResXvsX=(TH2F*)l->FindObject(nameResXvsX);
393       TH1D *histoResX=histoResXvsX->ProjectionY();
394       TH1D *histoResX_l=histoResXvsX->ProjectionY("residual xloc<0",1,20);
395       TH1D *histoResX_r=histoResXvsX->ProjectionY("residual xloc>0",21,40);
396
397       TString nameResZvsZ=Form("hSDDResidZvsZ%d",nmod);
398       TH2F *histoResZvsZ=(TH2F*)l->FindObject(nameResZvsZ);
399       TH1D *histoResZ=histoResZvsZ->ProjectionY();
400
401       //      TString nameResZvsX=Form("hSDDResidZvsX%d",nmod);
402       //      TH2F *histoResZvsX=(TH2F*)l->FindObject(nameResZvsX);
403
404       TF1 *gg_x = new TF1("gg_x","gaus",-0.050, 0.050);
405       TF1 *gg_l = new TF1("gg_l","gaus",-0.050, 0.050);
406       TF1 *gg_r = new TF1("gg_r","gaus",-0.050, 0.050);
407       TF1 *gg_z = new TF1("gg_z","gaus",-0.15,0.15);
408
409       if(histoResX->GetEntries()){
410         histoResX->Fit("gg_x","RQ0");
411         if(nmod<324){  // layer 3
412           if(TMath::Abs(gg_x->GetParameter(1))*10000<20.) nModmux20_3+=1; // micron
413           if(TMath::Abs(gg_x->GetParameter(1))*10000<50.) nModmux50_3+=1; 
414           if(TMath::Abs(gg_x->GetParameter(1))*10000<100.) nModmux100_3+=1; 
415           if(gg_x->GetParameter(2)*10000<200.) nModsigx100_3+=1;  
416           if(gg_x->GetParameter(2)*10000<250.) nModsigx200_3+=1;  
417           if(gg_x->GetParameter(2)*10000<400.) nModsigx300_3+=1;  
418         }
419         else { // layer 4
420           if(TMath::Abs(gg_x->GetParameter(1))*10000<20.) nModmux20_4+=1; // micron
421           if(TMath::Abs(gg_x->GetParameter(1))*10000<50.) nModmux50_4+=1; 
422           if(TMath::Abs(gg_x->GetParameter(1))*10000<100.) nModmux100_4+=1; 
423           if(gg_x->GetParameter(2)*10000<200.) nModsigx100_4+=1;  
424           if(gg_x->GetParameter(2)*10000<250.) nModsigx200_4+=1;  
425           if(gg_x->GetParameter(2)*10000<400.) nModsigx300_4+=1;  
426         }
427       }
428   
429       if(histoResX_l->GetEntries()&&histoResX_r->GetEntries()){
430         histoResX_l->Fit("gg_l","RQ0");
431         histoResX_r->Fit("gg_r","RQ0");
432         if(nmod<324){  // layer 3
433           if(TMath::Abs(gg_l->GetParameter(1)*10000-gg_r->GetParameter(1)*10000)<20.) nModmuxlr20_3+=1;
434           if(TMath::Abs(gg_l->GetParameter(1)*10000-gg_r->GetParameter(1)*10000)<50.) nModmuxlr50_3+=1;
435           if(TMath::Abs(gg_l->GetParameter(1)*10000-gg_r->GetParameter(1)*10000)<100.) nModmuxlr100_3+=1;
436         }
437         else { // layer 4
438           if(TMath::Abs(gg_l->GetParameter(1)*10000-gg_r->GetParameter(1)*10000)<20.) nModmuxlr20_4+=1;
439           if(TMath::Abs(gg_l->GetParameter(1)*10000-gg_r->GetParameter(1)*10000)<50.) nModmuxlr50_4+=1;
440           if(TMath::Abs(gg_l->GetParameter(1)*10000-gg_r->GetParameter(1)*10000)<100.) nModmuxlr100_4+=1;
441         }
442       }
443       
444       if(histoResZ->GetEntries()){
445         histoResZ->Fit("gg_z","RQ0");
446         if(nmod<324){  // layer 3
447           if(TMath::Abs(gg_z->GetParameter(1))*10000<30.) nModmuz50_3+=1;
448           if(TMath::Abs(gg_z->GetParameter(1))*10000<50.) nModmuz100_3+=1;
449           if(TMath::Abs(gg_z->GetParameter(1))*10000<100.) nModmuz300_3+=1;
450           if(gg_z->GetParameter(2)*10000<150.) nModsigz100_3+=1;  
451           if(gg_z->GetParameter(2)*10000<200.) nModsigz300_3+=1;  
452           if(gg_z->GetParameter(2)*10000<350.) nModsigz500_3+=1;  
453         }
454
455         else { // layer 4
456           if(TMath::Abs(gg_z->GetParameter(1))*10000<30.) nModmuz50_4+=1;
457           if(TMath::Abs(gg_z->GetParameter(1))*10000<50.) nModmuz100_4+=1;
458           if(TMath::Abs(gg_z->GetParameter(1))*10000<100.) nModmuz300_4+=1;
459           if(gg_z->GetParameter(2)*10000<250.) nModsigz100_4+=1;  
460           if(gg_z->GetParameter(2)*10000<300.) nModsigz300_4+=1;  
461           if(gg_z->GetParameter(2)*10000<450.) nModsigz500_4+=1;  
462         }
463       }
464
465
466       Double_t min=-10000.0;
467       Double_t max=10000.0;
468       
469         TProfile *profResXvsX = histoResXvsX->ProfileX();
470         if(profResXvsX->GetEntries()>0){
471           max=profResXvsX->GetBinContent(1);
472           min=profResXvsX->GetBinContent(1);
473           for(Int_t jj=0;jj<39;jj++){
474             if(profResXvsX->GetBinContent(jj+1)>max) max = profResXvsX->GetBinContent(jj+1);
475             if(profResXvsX->GetBinContent(jj+1)<min) min = profResXvsX->GetBinContent(jj+1);
476           }     
477           
478           if(nmod<324){  // layer 3
479             if(TMath::Abs(max-min)*10000.<100) nModexcx100_3+=1;
480             if(TMath::Abs(max-min)*10000.<200) nModexcx200_3+=1;
481             if(TMath::Abs(max-min)*10000.<300) nModexcx300_3+=1;
482           }
483           
484           else { // layer 4
485             if(TMath::Abs(max-min)*10000.<100) nModexcx100_4+=1;
486             if(TMath::Abs(max-min)*10000.<200) nModexcx200_4+=1;
487             if(TMath::Abs(max-min)*10000.<300) nModexcx300_4+=1;
488           }
489         }
490
491     } // loop on SDD modules -- end
492
493     for(Int_t nmod=500; nmod<2198; nmod++){  // loop on SSD modules
494       
495       TString nameResXvsX=Form("hSSDResidX%d",nmod);
496       TH2F *histoResXvsX=(TH2F*)l->FindObject(nameResXvsX);
497       TH1D *histoResX=histoResXvsX->ProjectionY();
498
499       TString nameResZvsZ=Form("hSSDResidZ%d",nmod);
500       TH2F *histoResZvsZ=(TH2F*)l->FindObject(nameResZvsZ);
501       TH1D *histoResZ=histoResZvsZ->ProjectionY();
502
503       TF1 *gg_x = new TF1("gg_x","gaus",-0.050, 0.050);
504       TF1 *gg_z = new TF1("gg_z","gaus",-0.15,0.15);
505
506       if(histoResX->GetEntries()){
507         histoResX->Fit("gg_x","RQ0");
508         if(nmod<1248){  // layer 5
509           if(TMath::Abs(gg_x->GetParameter(1))*10000<20.) nModmux20_5+=1; // micron
510           if(TMath::Abs(gg_x->GetParameter(1))*10000<40.) nModmux50_5+=1; 
511           if(TMath::Abs(gg_x->GetParameter(1))*10000<100.) nModmux100_5+=1; 
512           if(gg_x->GetParameter(2)*10000<70.) nModsigx100_5+=1;  
513           if(gg_x->GetParameter(2)*10000<100.) nModsigx200_5+=1;  
514           if(gg_x->GetParameter(2)*10000<300.) nModsigx300_5+=1;  
515         }
516         else { // layer 6
517           if(TMath::Abs(gg_x->GetParameter(1))*10000<20.) nModmux20_6+=1; // micron
518           if(TMath::Abs(gg_x->GetParameter(1))*10000<40.) nModmux50_6+=1; 
519           if(TMath::Abs(gg_x->GetParameter(1))*10000<100.) nModmux100_6+=1; 
520           if(gg_x->GetParameter(2)*10000<200.) nModsigx100_6+=1;  
521           if(gg_x->GetParameter(2)*10000<300.) nModsigx200_6+=1;  
522           if(gg_x->GetParameter(2)*10000<400.) nModsigx300_6+=1;  
523         }
524       }
525   
526       
527       if(histoResZ->GetEntries()){
528         histoResZ->Fit("gg_z","RQ0");
529         if(nmod<1248){  // layer 5
530           if(TMath::Abs(gg_z->GetParameter(1))*10000<50.) nModmuz50_5+=1;
531           if(TMath::Abs(gg_z->GetParameter(1))*10000<100.) nModmuz100_5+=1;
532           if(TMath::Abs(gg_z->GetParameter(1))*10000<300.) nModmuz300_5+=1;
533           if(gg_z->GetParameter(2)*10000<1000.) nModsigz100_5+=1;  
534           if(gg_z->GetParameter(2)*10000<1100.) nModsigz300_5+=1;  
535           if(gg_z->GetParameter(2)*10000<1500.) nModsigz500_5+=1;  
536         }
537
538         else { // layer 6
539           if(TMath::Abs(gg_z->GetParameter(1))*10000<50.) nModmuz50_6+=1;
540           if(TMath::Abs(gg_z->GetParameter(1))*10000<100.) nModmuz100_6+=1;
541           if(TMath::Abs(gg_z->GetParameter(1))*10000<300.) nModmuz300_6+=1;
542           if(gg_z->GetParameter(2)*10000<1000.) nModsigz100_6+=1;  
543           if(gg_z->GetParameter(2)*10000<1100.) nModsigz300_6+=1;  
544           if(gg_z->GetParameter(2)*10000<1500.) nModsigz500_6+=1;  
545         }
546       }
547
548     } // loop on SSD modules -- end
549
550                 Int_t count1 = 0;
551                 Int_t count2 = 0;
552                 Int_t count3 = 0;
553                 Int_t count4 = 0;
554                 Int_t count5 = 0;
555                 Int_t count6 = 0;
556                 
557 //              Int_t nPSideChannelsTotal = 0, nNSideChannelsTotal = 0;
558 //              Int_t nBadPSideChannelsTotal = 0, nBadNSideChannelsTotal = 0;
559                 Int_t nBadPSideChannels = 0, nBadNSideChannels = 0;
560                 Int_t layer = 0, ladder = 0, module = 0;
561 //              Int_t nPSideChannelsLayer5 = 0, nNSideChannelsLayer5 = 0;
562 //              Int_t nPSideChannelsLayer6 = 0, nNSideChannelsLayer6 = 0;
563 //              Int_t nPSideChannelsLayer5Total = 0, nNSideChannelsLayer5Total = 0;
564 //              Int_t nPSideChannelsLayer6Total = 0, nNSideChannelsLayer6Total = 0;
565 //              Int_t nBadPSideChannelsLayer5Total = 0,  nBadNSideChannelsLayer5Total = 0;
566 //              Int_t nBadPSideChannelsLayer6Total = 0,  nBadNSideChannelsLayer6Total = 0;
567 //              Int_t badPmodule5 = 0, badNmodule5 = 0, badPmodule6 = 0, badNmodule6 = 0;
568                 
569                 // lettura moduli SDD Ok da OCDB
570                 man->SetRun(iRun);
571                 entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
572                 calSDD = (TObjArray *)entrySDD->GetObject();
573                 for(Int_t i=0;i<84;i++){cal = (AliITSCalibration*) 
574                         calSDD->At(i); if(cal->IsBad())count3++;}
575                 for(Int_t i=84;i<calSDD->GetEntries();i++){cal = (AliITSCalibration*) 
576                         calSDD->At(i); if(cal->IsBad())count4++;}
577 //              cout << endl << endl << count3 << " " << count4 << endl;
578                 
579     // ntuple filling
580     Int_t index=0;
581     // 0
582     xnt[index++]=(Float_t)iRun;
583     // 1 SDD L3
584     xnt[index++]=nModmux20_3/(84.-count3);
585     xnt[index++]=TMath::Sqrt(nModmux20_3)/(84.-count3);
586     xnt[index++]=nModmux50_3/(84.-count3);
587     xnt[index++]=TMath::Sqrt(nModmux50_3)/(84.-count3);
588     xnt[index++]=nModmux100_3/(84.-count3);
589     xnt[index++]=TMath::Sqrt(nModmux100_3)/(84.-count3);
590     xnt[index++]=nModsigx100_3/(84.-count3);
591     xnt[index++]=TMath::Sqrt(nModsigx100_3)/(84.-count3);
592     xnt[index++]=nModsigx200_3/(84.-count3);
593     xnt[index++]=TMath::Sqrt(nModsigx200_3)/(84.-count3);
594     xnt[index++]=nModsigx300_3/(84.-count3);
595     xnt[index++]=TMath::Sqrt(nModsigx300_3)/(84.-count3);
596     xnt[index++]=nModmuxlr20_3/(84.-count3);
597     xnt[index++]=TMath::Sqrt(nModmuxlr20_3)/(84.-count3);
598     xnt[index++]=nModmuxlr50_3/(84.-count3);
599     xnt[index++]=TMath::Sqrt(nModmuxlr50_3)/(84.-count3);
600     xnt[index++]=nModmuxlr100_3/(84.-count3);
601     xnt[index++]=TMath::Sqrt(nModmuxlr100_3)/(84.-count3);
602     xnt[index++]=nModexcx100_3/(84.-count3);
603     xnt[index++]=TMath::Sqrt(nModexcx100_3)/(84.-count3);
604     xnt[index++]=nModexcx200_3/(84.-count3);
605     xnt[index++]=TMath::Sqrt(nModexcx200_3)/(84.-count3);
606     xnt[index++]=nModexcx300_3/(84.-count3);
607     xnt[index++]=TMath::Sqrt(nModexcx300_3)/(84.-count3);
608     xnt[index++]=nModmuz50_3/(84.-count3);
609     xnt[index++]=TMath::Sqrt(nModmuz50_3)/(84.-count3);
610     xnt[index++]=nModmuz100_3/(84.-count3);
611     xnt[index++]=TMath::Sqrt(nModmuz100_3)/(84.-count3);
612     xnt[index++]=nModmuz300_3/(84.-count3);
613     xnt[index++]=TMath::Sqrt(nModmuz300_3)/(84.-count3);
614     xnt[index++]=nModsigz100_3/(84.-count3);
615     xnt[index++]=TMath::Sqrt(nModsigz100_3)/(84.-count3);
616     xnt[index++]=nModsigz300_3/(84.-count3);
617     xnt[index++]=TMath::Sqrt(nModsigz300_3)/(84.-count3);
618     xnt[index++]=nModsigz500_3/(84.-count3);
619     xnt[index++]=TMath::Sqrt(nModsigz500_3)/(84.-count3);
620     // 37 SDD L4
621     xnt[index++]=nModmux20_4/(176.-count4);
622     xnt[index++]=TMath::Sqrt(nModmux20_4)/(176.-count4);
623     xnt[index++]=nModmux50_4/(176.-count4);
624     xnt[index++]=TMath::Sqrt(nModmux50_4)/(176.-count4);
625     xnt[index++]=nModmux100_4/(176.-count4);
626     xnt[index++]=TMath::Sqrt(nModmux100_4)/(176.-count4);
627     xnt[index++]=nModsigx100_4/(176.-count4);
628     xnt[index++]=TMath::Sqrt(nModsigx100_4)/(176.-count4);
629     xnt[index++]=nModsigx200_4/(176.-count4);
630     xnt[index++]=TMath::Sqrt(nModsigx200_4)/(176.-count4);
631     xnt[index++]=nModsigx300_4/(176.-count4);
632     xnt[index++]=TMath::Sqrt(nModsigx300_4)/(176.-count4);
633     xnt[index++]=nModmuxlr20_4/(176.-count4);
634     xnt[index++]=TMath::Sqrt(nModmuxlr20_4)/(176.-count4);
635     xnt[index++]=nModmuxlr50_4/(176.-count4);
636     xnt[index++]=TMath::Sqrt(nModmuxlr50_4)/(176.-count4);
637     xnt[index++]=nModmuxlr100_4/(176.-count4);
638     xnt[index++]=TMath::Sqrt(nModmuxlr100_4)/(176.-count4);
639     xnt[index++]=nModexcx100_4/(176.-count4);
640     xnt[index++]=TMath::Sqrt(nModexcx100_4)/(176.-count4);
641     xnt[index++]=nModexcx200_4/(176.-count4);
642     xnt[index++]=TMath::Sqrt(nModexcx200_4)/(176.-count4);
643     xnt[index++]=nModexcx300_4/(176.-count4);
644     xnt[index++]=TMath::Sqrt(nModexcx300_4)/(176.-count4);
645     xnt[index++]=nModmuz50_4/(176.-count4);
646     xnt[index++]=TMath::Sqrt(nModmuz50_4)/(176.-count4);
647     xnt[index++]=nModmuz100_4/(176.-count4);
648     xnt[index++]=TMath::Sqrt(nModmuz100_4)/(176.-count4);
649     xnt[index++]=nModmuz300_4/(176.-count4);
650     xnt[index++]=TMath::Sqrt(nModmuz300_4)/(176.-count4);
651     xnt[index++]=nModsigz100_4/(176.-count4);
652     xnt[index++]=TMath::Sqrt(nModsigz100_4)/(176.-count4);
653     xnt[index++]=nModsigz300_4/(176.-count4);
654     xnt[index++]=TMath::Sqrt(nModsigz300_4)/(176.-count4);
655     xnt[index++]=nModsigz500_4/(176.-count4);
656     xnt[index++]=TMath::Sqrt(nModsigz500_4)/(176.-count4);
657     // 73 SPD L1
658                 // lettura moduli SPD bad da OCDB               
659                 AliITSOnlineCalibrationSPDhandler *h = new AliITSOnlineCalibrationSPDhandler();
660                 h->ReadDeadFromDB(iRun,"alien://folder=/alice/data/2011/OCDB");
661 //              Int_t nDeadModules[2]={0,0}; // n dead inner and outer
662 //              Double_t fractions[2]={0.,0.}; // fraction of dead modules
663                 // # dead modules inner layer
664                 for(Int_t i=0; i<80; i++) count1+=h->GetNrBad(i)/(5*8192);
665                 // # dead modules outer layer
666                 for(Int_t jj=80; jj<240; jj++) count2+=h->GetNrBad(jj)/(5*8192);
667                 
668     xnt[index++]=nModmux20_1/(80.-count1);
669     xnt[index++]=TMath::Sqrt(nModmux20_1)/(80.-count1);
670     xnt[index++]=nModmux50_1/(80.-count1);
671     xnt[index++]=TMath::Sqrt(nModmux50_1)/(80.-count1);
672     xnt[index++]=nModmux100_1/(80.-count1);
673     xnt[index++]=TMath::Sqrt(nModmux100_1)/(80.-count1);
674     xnt[index++]=nModsigx100_1/(80.-count1);
675     xnt[index++]=TMath::Sqrt(nModsigx100_1)/(80.-count1);
676     xnt[index++]=nModsigx200_1/(80.-count1);
677     xnt[index++]=TMath::Sqrt(nModsigx200_1)/(80.-count1);
678     xnt[index++]=nModsigx300_1/(80.-count1);
679     xnt[index++]=TMath::Sqrt(nModsigx300_1)/(80.-count1);
680     xnt[index++]=nModmuz50_1/(80.-count1);
681     xnt[index++]=TMath::Sqrt(nModmuz50_1)/(80.-count1);
682     xnt[index++]=nModmuz100_1/(80.-count1);
683     xnt[index++]=TMath::Sqrt(nModmuz100_1)/(80.-count1);
684     xnt[index++]=nModmuz300_1/(80.-count1);
685     xnt[index++]=TMath::Sqrt(nModmuz300_1)/(80.-count1);
686     xnt[index++]=nModsigz100_1/(80.-count1);
687     xnt[index++]=TMath::Sqrt(nModsigz100_1)/(80.-count1);
688     xnt[index++]=nModsigz300_1/(80.-count1);
689     xnt[index++]=TMath::Sqrt(nModsigz300_1)/(80.-count1);
690     xnt[index++]=nModsigz500_1/(80.-count1);
691     xnt[index++]=TMath::Sqrt(nModsigz500_1)/(80.-count1);
692     // 97 SPD L2
693     xnt[index++]=nModmux20_2/(160.-count2);
694     xnt[index++]=TMath::Sqrt(nModmux20_2)/(160.-count2);
695     xnt[index++]=nModmux50_2/(160.-count2);
696     xnt[index++]=TMath::Sqrt(nModmux50_2)/(160.-count2);
697     xnt[index++]=nModmux100_2/(160.-count2);
698     xnt[index++]=TMath::Sqrt(nModmux100_2)/(160.-count2);
699     xnt[index++]=nModsigx100_2/(160.-count2);
700     xnt[index++]=TMath::Sqrt(nModsigx100_2)/(160.-count2);
701     xnt[index++]=nModsigx200_2/(160.-count2);
702     xnt[index++]=TMath::Sqrt(nModsigx200_2)/(160.-count2);
703     xnt[index++]=nModsigx300_2/(160.-count2);
704     xnt[index++]=TMath::Sqrt(nModsigx300_2)/(160.-count2);
705     xnt[index++]=nModmuz50_2/(160.-count2);
706     xnt[index++]=TMath::Sqrt(nModmuz50_2)/(160.-count2);
707     xnt[index++]=nModmuz100_2/(160.-count2);
708     xnt[index++]=TMath::Sqrt(nModmuz100_2)/(160.-count2);
709     xnt[index++]=nModmuz300_2/(160.-count2);
710     xnt[index++]=TMath::Sqrt(nModmuz300_2)/(160.-count2);
711     xnt[index++]=nModsigz100_2/(160.-count2);
712     xnt[index++]=TMath::Sqrt(nModsigz100_2)/(160.-count2);
713     xnt[index++]=nModsigz300_2/(160.-count2);
714     xnt[index++]=TMath::Sqrt(nModsigz300_2)/(160.-count2);
715     xnt[index++]=nModsigz500_2/(160.-count2);
716     xnt[index++]=TMath::Sqrt(nModsigz500_2)/(160.-count2);
717     // 121 SSD L5
718                 // lettura moduli SSD bad da OCDB
719                 const Int_t fgkSSDMODULES = 1698;
720                 static const Int_t fgkDefaultNStripsSSD = 768;
721                 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
722                 AliCDBEntry *entryBadChannelsSSD = man->Get("ITS/Calib/BadChannelsSSD");
723                 TObject *empty = (TObject *)entryBadChannelsSSD->GetObject();
724                 TString objectname = empty->GetName();
725                 if(objectname=="TObjArray") {
726                         TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
727                         ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
728                 }       
729                 else if(objectname=="AliITSBadChannelsSSDv2") {
730                         cout<<"Reading the new format of the calibration file..."<<endl;
731                         badChannelsSSD = (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
732                 }
733                 nBadPSideChannels = 0; 
734                 nBadNSideChannels = 0;
735                 layer = 0; 
736                 ladder = 0; 
737                 module = 0;
738                 for(Int_t i = 0; i < fgkSSDMODULES; i++) { // loop sui moduli
739                         AliITSgeomTGeo::GetModuleId(i+500,layer,ladder,module);
740                         nBadPSideChannels = 0, nBadNSideChannels = 0;
741                         
742                         Int_t badChannel = 0;
743                         for(Int_t ja = 0; ja < fgkDefaultNStripsSSD; ja++) {   // loop sulle strips del modulo 
744                                 badChannel = (Int_t)(badChannelsSSD->GetBadChannelP(i,ja));   // bad channels P side
745                                 //cout<<"Module: "<<i+500<< " Strip: "<<j<<" - "<<badChannel<<endl;
746                                 if(badChannel != 0) nBadPSideChannels += 1;
747                                 
748                                 badChannel = (Int_t)(badChannelsSSD->GetBadChannelN(i,ja));  // bad channels N side
749                                 //cout<<"Module: "<<i+500<< " Strip: "<<fgkDefaultNStripsSSD+j+1<<" - "<<badChannel<<endl;
750                                 if(badChannel != 0) nBadNSideChannels += 1;
751                         } // end loop sulle strip del modulo
752                         
753                         // determinazione numero moduli morti sui due lati per ogni layer       
754                         if(nBadNSideChannels == 768  && nBadPSideChannels == 768){
755                                 if(layer == 5){
756                                         count5++;
757                                 }
758                                 else {
759                                         count6++;
760                                 }
761                         }
762                 } // endl loop sui moduli
763                         
764     xnt[index++]=nModmux20_5/(748.-count5);
765     xnt[index++]=TMath::Sqrt(nModmux20_5)/(748.-count5);
766     xnt[index++]=nModmux50_5/(748.-count5);
767     xnt[index++]=TMath::Sqrt(nModmux50_5)/(748.-count5);
768     xnt[index++]=nModmux100_5/(748.-count5);
769     xnt[index++]=TMath::Sqrt(nModmux100_5)/(748.-count5);
770     xnt[index++]=nModsigx100_5/(748.-count5);
771     xnt[index++]=TMath::Sqrt(nModsigx100_5)/(748.-count5);
772     xnt[index++]=nModsigx200_5/(748.-count5);
773     xnt[index++]=TMath::Sqrt(nModsigx200_5)/(748.-count5);
774     xnt[index++]=nModsigx300_5/(748.-count5);
775     xnt[index++]=TMath::Sqrt(nModsigx300_5)/(748.-count5);
776     xnt[index++]=nModmuz50_5/(748.-count5);
777     xnt[index++]=TMath::Sqrt(nModmuz50_5)/(748.-count5);
778     xnt[index++]=nModmuz100_5/(748.-count5);
779     xnt[index++]=TMath::Sqrt(nModmuz100_5)/(748.-count5);
780     xnt[index++]=nModmuz300_5/(748.-count5);
781     xnt[index++]=TMath::Sqrt(nModmuz300_5)/(748.-count5);
782     xnt[index++]=nModsigz100_5/(748.-count5);
783     xnt[index++]=TMath::Sqrt(nModsigz100_5)/(748.-count5);
784     xnt[index++]=nModsigz300_5/(748.-count5);
785     xnt[index++]=TMath::Sqrt(nModsigz300_5)/(748.-count5);
786     xnt[index++]=nModsigz500_5/(748.-count5);
787     xnt[index++]=TMath::Sqrt(nModsigz500_5)/(748.-count5);
788     // 145 SSD L6
789     xnt[index++]=nModmux20_6/(950.-count6);
790     xnt[index++]=TMath::Sqrt(nModmux20_6)/(950.-count6);
791     xnt[index++]=nModmux50_6/(950.-count6);
792     xnt[index++]=TMath::Sqrt(nModmux50_6)/(950.-count6);
793     xnt[index++]=nModmux100_6/(950.-count6);
794     xnt[index++]=TMath::Sqrt(nModmux100_6)/(950.-count6);
795     xnt[index++]=nModsigx100_6/(950.-count6);
796     xnt[index++]=TMath::Sqrt(nModsigx100_6)/(950.-count6);
797     xnt[index++]=nModsigx200_6/(950.-count6);
798     xnt[index++]=TMath::Sqrt(nModsigx200_6)/(950.-count6);
799     xnt[index++]=nModsigx300_6/(950.-count6);
800     xnt[index++]=TMath::Sqrt(nModsigx300_6)/(950.-count6);
801     xnt[index++]=nModmuz50_6/(950.-count6);
802     xnt[index++]=TMath::Sqrt(nModmuz50_6)/(950.-count6);
803     xnt[index++]=nModmuz100_6/(950.-count6);
804     xnt[index++]=TMath::Sqrt(nModmuz100_6)/(950.-count6);
805     xnt[index++]=nModmuz300_6/(950.-count6);
806     xnt[index++]=TMath::Sqrt(nModmuz300_6)/(950.-count6);
807     xnt[index++]=nModsigz100_6/(950.-count6);
808     xnt[index++]=TMath::Sqrt(nModsigz100_6)/(950.-count6);
809     xnt[index++]=nModsigz300_6/(950.-count6);
810     xnt[index++]=TMath::Sqrt(nModsigz300_6)/(950.-count6);
811     xnt[index++]=nModsigz500_6/(950.-count6);
812     xnt[index++]=TMath::Sqrt(nModsigz500_6)/(950.-count6);
813     // 168 - fine SSD L6
814     ntits->Fill(xnt);
815     //          cout<<"\n\nirun sDD"<<iRun<<endl<<endl;
816
817         } // loop on runs
818
819     TFile* outfil=new TFile(ntupleFileName.Data(),"recreate");
820     outfil->cd();
821     ntits->Write();
822     outfil->Close();
823     delete outfil;
824
825     //    MakePlots(ntupleFileName);
826 }
827
828
829
830 void MakePlots(Int_t run1,Int_t run2,TString ntupleFileName){
831   if(run1>=run2){
832     printf("******   ERROR: invalid run range %d - %d\n",run1,run2);
833     return;
834   }
835   TFile* fil=new TFile(ntupleFileName.Data(),"read");
836   if(!fil){
837     printf("File with ntuple does not exist\n");
838     return;
839   }
840   TNtuple* ntits=(TNtuple*)fil->Get("ntitsalign");
841
842   Float_t nrun;
843
844   Float_t SDDfracModmux20_3,SDDfracModmux50_3,SDDfracModmux100_3,SDDfracModsigx100_3,SDDfracModsigx200_3,SDDfracModsigx300_3;
845   Float_t SDDfracModmuxlr20_3,SDDfracModmuxlr50_3,SDDfracModmuxlr100_3,SDDfracModexcx100_3,SDDfracModexcx200_3,SDDfracModexcx300_3;
846   Float_t SDDfracModmuz50_3,SDDfracModmuz100_3,SDDfracModmuz300_3,SDDfracModsigz100_3,SDDfracModsigz300_3,SDDfracModsigz500_3;
847   Float_t errSDDfracModmux20_3,errSDDfracModmux50_3,errSDDfracModmux100_3,errSDDfracModsigx100_3,errSDDfracModsigx200_3,errSDDfracModsigx300_3;
848   Float_t errSDDfracModmuxlr20_3,errSDDfracModmuxlr50_3,errSDDfracModmuxlr100_3,errSDDfracModexcx100_3,errSDDfracModexcx200_3,errSDDfracModexcx300_3;
849   Float_t errSDDfracModmuz50_3,errSDDfracModmuz100_3,errSDDfracModmuz300_3,errSDDfracModsigz100_3,errSDDfracModsigz300_3,errSDDfracModsigz500_3;
850
851   Float_t SDDfracModmux20_4,SDDfracModmux50_4,SDDfracModmux100_4,SDDfracModsigx100_4,SDDfracModsigx200_4,SDDfracModsigx300_4;
852   Float_t SDDfracModmuxlr20_4,SDDfracModmuxlr50_4,SDDfracModmuxlr100_4,SDDfracModexcx100_4,SDDfracModexcx200_4,SDDfracModexcx300_4;
853   Float_t SDDfracModmuz50_4,SDDfracModmuz100_4,SDDfracModmuz300_4,SDDfracModsigz100_4,SDDfracModsigz300_4,SDDfracModsigz500_4;
854   Float_t errSDDfracModmux20_4,errSDDfracModmux50_4,errSDDfracModmux100_4,errSDDfracModsigx100_4,errSDDfracModsigx200_4,errSDDfracModsigx300_4;
855   Float_t errSDDfracModmuxlr20_4,errSDDfracModmuxlr50_4,errSDDfracModmuxlr100_4,errSDDfracModexcx100_4,errSDDfracModexcx200_4,errSDDfracModexcx300_4;
856   Float_t errSDDfracModmuz50_4,errSDDfracModmuz100_4,errSDDfracModmuz300_4,errSDDfracModsigz100_4,errSDDfracModsigz300_4,errSDDfracModsigz500_4;
857
858   Float_t SPDfracModmux20_1,SPDfracModmux50_1,SPDfracModmux100_1,SPDfracModsigx100_1,SPDfracModsigx200_1,SPDfracModsigx300_1;
859   Float_t SPDfracModmuz50_1,SPDfracModmuz100_1,SPDfracModmuz300_1,SPDfracModsigz100_1,SPDfracModsigz300_1,SPDfracModsigz500_1;
860   Float_t errSPDfracModmux20_1,errSPDfracModmux50_1,errSPDfracModmux100_1,errSPDfracModsigx100_1,errSPDfracModsigx200_1,errSPDfracModsigx300_1;
861   Float_t errSPDfracModmuz50_1,errSPDfracModmuz100_1,errSPDfracModmuz300_1,errSPDfracModsigz100_1,errSPDfracModsigz300_1,errSPDfracModsigz500_1;
862   Float_t SPDfracModmux20_2,SPDfracModmux50_2,SPDfracModmux100_2,SPDfracModsigx100_2,SPDfracModsigx200_2,SPDfracModsigx300_2;
863   Float_t SPDfracModmuz50_2,SPDfracModmuz100_2,SPDfracModmuz300_2,SPDfracModsigz100_2,SPDfracModsigz300_2,SPDfracModsigz500_2;
864   Float_t errSPDfracModmux20_2,errSPDfracModmux50_2,errSPDfracModmux100_2,errSPDfracModsigx100_2,errSPDfracModsigx200_2,errSPDfracModsigx300_2;
865   Float_t errSPDfracModmuz50_2,errSPDfracModmuz100_2,errSPDfracModmuz300_2,errSPDfracModsigz100_2,errSPDfracModsigz300_2,errSPDfracModsigz500_2;
866
867   Float_t SSDfracModmux20_5,SSDfracModmux50_5,SSDfracModmux100_5,SSDfracModsigx100_5,SSDfracModsigx200_5,SSDfracModsigx300_5;
868   Float_t SSDfracModmuz50_5,SSDfracModmuz100_5,SSDfracModmuz300_5,SSDfracModsigz100_5,SSDfracModsigz300_5,SSDfracModsigz500_5;
869   Float_t errSSDfracModmux20_5,errSSDfracModmux50_5,errSSDfracModmux100_5,errSSDfracModsigx100_5,errSSDfracModsigx200_5,errSSDfracModsigx300_5;
870   Float_t errSSDfracModmuz50_5,errSSDfracModmuz100_5,errSSDfracModmuz300_5,errSSDfracModsigz100_5,errSSDfracModsigz300_5,errSSDfracModsigz500_5;
871   Float_t SSDfracModmux20_6,SSDfracModmux50_6,SSDfracModmux100_6,SSDfracModsigx100_6,SSDfracModsigx200_6,SSDfracModsigx300_6;
872   Float_t SSDfracModmuz50_6,SSDfracModmuz100_6,SSDfracModmuz300_6,SSDfracModsigz100_6,SSDfracModsigz300_6,SSDfracModsigz500_6;
873   Float_t errSSDfracModmux20_6,errSSDfracModmux50_6,errSSDfracModmux100_6,errSSDfracModsigx100_6,errSSDfracModsigx200_6,errSSDfracModsigx300_6;
874   Float_t errSSDfracModmuz50_6,errSSDfracModmuz100_6,errSSDfracModmuz300_6,errSSDfracModsigz100_6,errSSDfracModsigz300_6,errSSDfracModsigz500_6;
875
876   ntits->SetBranchAddress("nrun",&nrun);                                         // SDD
877   ntits->SetBranchAddress("SDDfracModmux20_3",&SDDfracModmux20_3);
878   ntits->SetBranchAddress("errSDDfracModmux20_3",&errSDDfracModmux20_3);
879   ntits->SetBranchAddress("SDDfracModmux50_3",&SDDfracModmux50_3);
880   ntits->SetBranchAddress("errSDDfracModmux50_3",&errSDDfracModmux50_3);
881   ntits->SetBranchAddress("SDDfracModmux100_3",&SDDfracModmux100_3);
882   ntits->SetBranchAddress("errSDDfracModmux100_3",&errSDDfracModmux100_3);
883   ntits->SetBranchAddress("SDDfracModsigx100_3",&SDDfracModsigx100_3);
884   ntits->SetBranchAddress("errSDDfracModsigx100_3",&errSDDfracModsigx100_3);
885   ntits->SetBranchAddress("SDDfracModsigx200_3",&SDDfracModsigx200_3);
886   ntits->SetBranchAddress("errSDDfracModsigx200_3",&errSDDfracModsigx200_3);
887   ntits->SetBranchAddress("SDDfracModsigx300_3",&SDDfracModsigx300_3);
888   ntits->SetBranchAddress("errSDDfracModsigx300_3",&errSDDfracModsigx300_3);
889   ntits->SetBranchAddress("SDDfracModmuxlr20_3",&SDDfracModmuxlr20_3);
890   ntits->SetBranchAddress("errSDDfracModmuxlr20_3",&errSDDfracModmuxlr20_3);
891   ntits->SetBranchAddress("SDDfracModmuxlr50_3",&SDDfracModmuxlr50_3);
892   ntits->SetBranchAddress("errSDDfracModmuxlr50_3",&errSDDfracModmuxlr50_3);
893   ntits->SetBranchAddress("SDDfracModmuxlr100_3",&SDDfracModmuxlr100_3);
894   ntits->SetBranchAddress("errSDDfracModmuxlr100_3",&errSDDfracModmuxlr100_3);
895   ntits->SetBranchAddress("SDDfracModexcx100_3",&SDDfracModexcx100_3);
896   ntits->SetBranchAddress("errSDDfracModexcx100_3",&errSDDfracModexcx100_3);
897   ntits->SetBranchAddress("SDDfracModexcx200_3",&SDDfracModexcx200_3);
898   ntits->SetBranchAddress("errSDDfracModexcx200_3",&errSDDfracModexcx200_3);
899   ntits->SetBranchAddress("SDDfracModexcx300_3",&SDDfracModexcx300_3);
900   ntits->SetBranchAddress("errSDDfracModexcx300_3",&errSDDfracModexcx300_3);
901   ntits->SetBranchAddress("SDDfracModmuz50_3",&SDDfracModmuz50_3);
902   ntits->SetBranchAddress("errSDDfracModmuz50_3",&errSDDfracModmuz50_3);
903   ntits->SetBranchAddress("SDDfracModmuz100_3",&SDDfracModmuz100_3);
904   ntits->SetBranchAddress("errSDDfracModmuz100_3",&errSDDfracModmuz100_3);
905   ntits->SetBranchAddress("SDDfracModmuz300_3",&SDDfracModmuz300_3);
906   ntits->SetBranchAddress("errSDDfracModmuz300_3",&errSDDfracModmuz300_3);
907   ntits->SetBranchAddress("SDDfracModsigz100_3",&SDDfracModsigz100_3);
908   ntits->SetBranchAddress("errSDDfracModsigz100_3",&errSDDfracModsigz100_3);
909   ntits->SetBranchAddress("SDDfracModsigz300_3",&SDDfracModsigz300_3);
910   ntits->SetBranchAddress("errSDDfracModsigz300_3",&errSDDfracModsigz300_3);
911   ntits->SetBranchAddress("SDDfracModsigz500_3",&SDDfracModsigz500_3);
912   ntits->SetBranchAddress("errSDDfracModsigz500_3",&errSDDfracModsigz500_3);
913   ntits->SetBranchAddress("SDDfracModmux20_4",&SDDfracModmux20_4);
914   ntits->SetBranchAddress("errSDDfracModmux20_4",&errSDDfracModmux20_4);
915   ntits->SetBranchAddress("SDDfracModmux50_4",&SDDfracModmux50_4);
916   ntits->SetBranchAddress("errSDDfracModmux50_4",&errSDDfracModmux50_4);
917   ntits->SetBranchAddress("SDDfracModmux100_4",&SDDfracModmux100_4);
918   ntits->SetBranchAddress("errSDDfracModmux100_4",&errSDDfracModmux100_4);
919   ntits->SetBranchAddress("SDDfracModsigx100_4",&SDDfracModsigx100_4);
920   ntits->SetBranchAddress("errSDDfracModsigx100_4",&errSDDfracModsigx100_4);
921   ntits->SetBranchAddress("SDDfracModsigx200_4",&SDDfracModsigx200_4);
922   ntits->SetBranchAddress("errSDDfracModsigx200_4",&errSDDfracModsigx200_4);
923   ntits->SetBranchAddress("SDDfracModsigx300_4",&SDDfracModsigx300_4);
924   ntits->SetBranchAddress("errSDDfracModsigx300_4",&errSDDfracModsigx300_4);
925   ntits->SetBranchAddress("SDDfracModmuxlr20_4",&SDDfracModmuxlr20_4);
926   ntits->SetBranchAddress("errSDDfracModmuxlr20_4",&errSDDfracModmuxlr20_4);
927   ntits->SetBranchAddress("SDDfracModmuxlr50_4",&SDDfracModmuxlr50_4);
928   ntits->SetBranchAddress("errSDDfracModmuxlr50_4",&errSDDfracModmuxlr50_4);
929   ntits->SetBranchAddress("SDDfracModmuxlr100_4",&SDDfracModmuxlr100_4);
930   ntits->SetBranchAddress("errSDDfracModmuxlr100_4",&errSDDfracModmuxlr100_4);
931   ntits->SetBranchAddress("SDDfracModexcx100_4",&SDDfracModexcx100_4);
932   ntits->SetBranchAddress("errSDDfracModexcx100_4",&errSDDfracModexcx100_4);
933   ntits->SetBranchAddress("SDDfracModexcx200_4",&SDDfracModexcx200_4);
934   ntits->SetBranchAddress("errSDDfracModexcx200_4",&errSDDfracModexcx200_4);
935   ntits->SetBranchAddress("SDDfracModexcx300_4",&SDDfracModexcx300_4);
936   ntits->SetBranchAddress("errSDDfracModexcx300_4",&errSDDfracModexcx300_4);
937   ntits->SetBranchAddress("SDDfracModmuz50_4",&SDDfracModmuz50_4);
938   ntits->SetBranchAddress("errSDDfracModmuz50_4",&errSDDfracModmuz50_4);
939   ntits->SetBranchAddress("SDDfracModmuz100_4",&SDDfracModmuz100_4);
940   ntits->SetBranchAddress("errSDDfracModmuz100_4",&errSDDfracModmuz100_4);
941   ntits->SetBranchAddress("SDDfracModmuz300_4",&SDDfracModmuz300_4);
942   ntits->SetBranchAddress("errSDDfracModmuz300_4",&errSDDfracModmuz300_4);
943   ntits->SetBranchAddress("SDDfracModsigz100_4",&SDDfracModsigz100_4);
944   ntits->SetBranchAddress("errSDDfracModsigz100_4",&errSDDfracModsigz100_4);
945   ntits->SetBranchAddress("SDDfracModsigz300_4",&SDDfracModsigz300_4);
946   ntits->SetBranchAddress("errSDDfracModsigz300_4",&errSDDfracModsigz300_4);
947   ntits->SetBranchAddress("SDDfracModsigz500_4",&SDDfracModsigz500_4);
948   ntits->SetBranchAddress("errSDDfracModsigz500_4",&errSDDfracModsigz500_4);
949
950   ntits->SetBranchAddress("SPDfracModmux20_1",&SPDfracModmux20_1);                                  // SPD
951   ntits->SetBranchAddress("errSPDfracModmux20_1",&errSPDfracModmux20_1);
952   ntits->SetBranchAddress("SPDfracModmux50_1",&SPDfracModmux50_1);
953   ntits->SetBranchAddress("errSPDfracModmux50_1",&errSPDfracModmux50_1);
954   ntits->SetBranchAddress("SPDfracModmux100_1",&SPDfracModmux100_1);
955   ntits->SetBranchAddress("errSPDfracModmux100_1",&errSPDfracModmux100_1);
956   ntits->SetBranchAddress("SPDfracModsigx100_1",&SPDfracModsigx100_1);
957   ntits->SetBranchAddress("errSPDfracModsigx100_1",&errSPDfracModsigx100_1);
958   ntits->SetBranchAddress("SPDfracModsigx200_1",&SPDfracModsigx200_1);
959   ntits->SetBranchAddress("errSPDfracModsigx200_1",&errSPDfracModsigx200_1);
960   ntits->SetBranchAddress("SPDfracModsigx300_1",&SPDfracModsigx300_1);
961   ntits->SetBranchAddress("errSPDfracModsigx300_1",&errSPDfracModsigx300_1);
962   ntits->SetBranchAddress("SPDfracModmuz50_1",&SPDfracModmuz50_1);
963   ntits->SetBranchAddress("errSPDfracModmuz50_1",&errSPDfracModmuz50_1);
964   ntits->SetBranchAddress("SPDfracModmuz100_1",&SPDfracModmuz100_1);
965   ntits->SetBranchAddress("errSPDfracModmuz100_1",&errSPDfracModmuz100_1);
966   ntits->SetBranchAddress("SPDfracModmuz300_1",&SPDfracModmuz300_1);
967   ntits->SetBranchAddress("errSPDfracModmuz300_1",&errSPDfracModmuz300_1);
968   ntits->SetBranchAddress("SPDfracModsigz100_1",&SPDfracModsigz100_1);
969   ntits->SetBranchAddress("errSPDfracModsigz100_1",&errSPDfracModsigz100_1);
970   ntits->SetBranchAddress("SPDfracModsigz300_1",&SPDfracModsigz300_1);
971   ntits->SetBranchAddress("errSPDfracModsigz300_1",&errSPDfracModsigz300_1);
972   ntits->SetBranchAddress("SPDfracModsigz500_1",&SPDfracModsigz500_1);
973   ntits->SetBranchAddress("errSPDfracModsigz500_1",&errSPDfracModsigz500_1);
974   ntits->SetBranchAddress("SPDfracModmux20_2",&SPDfracModmux20_2);
975   ntits->SetBranchAddress("errSPDfracModmux20_2",&errSPDfracModmux20_2);
976   ntits->SetBranchAddress("SPDfracModmux50_2",&SPDfracModmux50_2);
977   ntits->SetBranchAddress("errSPDfracModmux50_2",&errSPDfracModmux50_2);
978   ntits->SetBranchAddress("SPDfracModmux100_2",&SPDfracModmux100_2);
979   ntits->SetBranchAddress("errSPDfracModmux100_2",&errSPDfracModmux100_2);
980   ntits->SetBranchAddress("SPDfracModsigx100_2",&SPDfracModsigx100_2);
981   ntits->SetBranchAddress("errSPDfracModsigx100_2",&errSPDfracModsigx100_2);
982   ntits->SetBranchAddress("SPDfracModsigx200_2",&SPDfracModsigx200_2);
983   ntits->SetBranchAddress("errSPDfracModsigx200_2",&errSPDfracModsigx200_2);
984   ntits->SetBranchAddress("SPDfracModsigx300_2",&SPDfracModsigx300_2);
985   ntits->SetBranchAddress("errSPDfracModsigx300_2",&errSPDfracModsigx300_2);
986   ntits->SetBranchAddress("SPDfracModmuz50_2",&SPDfracModmuz50_2);
987   ntits->SetBranchAddress("errSPDfracModmuz50_2",&errSPDfracModmuz50_2);
988   ntits->SetBranchAddress("SPDfracModmuz100_2",&SPDfracModmuz100_2);
989   ntits->SetBranchAddress("errSPDfracModmuz100_2",&errSPDfracModmuz100_2);
990   ntits->SetBranchAddress("SPDfracModmuz300_2",&SPDfracModmuz300_2);
991   ntits->SetBranchAddress("errSPDfracModmuz300_2",&errSPDfracModmuz300_2);
992   ntits->SetBranchAddress("SPDfracModsigz100_2",&SPDfracModsigz100_2);
993   ntits->SetBranchAddress("errSPDfracModsigz100_2",&errSPDfracModsigz100_2);
994   ntits->SetBranchAddress("SPDfracModsigz300_2",&SPDfracModsigz300_2);
995   ntits->SetBranchAddress("errSPDfracModsigz300_2",&errSPDfracModsigz300_2);
996   ntits->SetBranchAddress("SPDfracModsigz500_2",&SPDfracModsigz500_2);
997   ntits->SetBranchAddress("errSPDfracModsigz500_2",&errSPDfracModsigz500_2);
998
999   ntits->SetBranchAddress("SSDfracModmux20_5",&SSDfracModmux20_5);                                   // SSD
1000   ntits->SetBranchAddress("errSSDfracModmux20_5",&errSSDfracModmux20_5);
1001   ntits->SetBranchAddress("SSDfracModmux50_5",&SSDfracModmux50_5);
1002   ntits->SetBranchAddress("errSSDfracModmux50_5",&errSSDfracModmux50_5);
1003   ntits->SetBranchAddress("SSDfracModmux100_5",&SSDfracModmux100_5);
1004   ntits->SetBranchAddress("errSSDfracModmux100_5",&errSSDfracModmux100_5);
1005   ntits->SetBranchAddress("SSDfracModsigx100_5",&SSDfracModsigx100_5);
1006   ntits->SetBranchAddress("errSSDfracModsigx100_5",&errSSDfracModsigx100_5);
1007   ntits->SetBranchAddress("SSDfracModsigx200_5",&SSDfracModsigx200_5);
1008   ntits->SetBranchAddress("errSSDfracModsigx200_5",&errSSDfracModsigx200_5);
1009   ntits->SetBranchAddress("SSDfracModsigx300_5",&SSDfracModsigx300_5);
1010   ntits->SetBranchAddress("errSSDfracModsigx300_5",&errSSDfracModsigx300_5);
1011   ntits->SetBranchAddress("SSDfracModmuz50_5",&SSDfracModmuz50_5);
1012   ntits->SetBranchAddress("errSSDfracModmuz50_5",&errSSDfracModmuz50_5);
1013   ntits->SetBranchAddress("SSDfracModmuz100_5",&SSDfracModmuz100_5);
1014   ntits->SetBranchAddress("errSSDfracModmuz100_5",&errSSDfracModmuz100_5);
1015   ntits->SetBranchAddress("SSDfracModmuz300_5",&SSDfracModmuz300_5);
1016   ntits->SetBranchAddress("errSSDfracModmuz300_5",&errSSDfracModmuz300_5);
1017   ntits->SetBranchAddress("SSDfracModsigz100_5",&SSDfracModsigz100_5);
1018   ntits->SetBranchAddress("errSSDfracModsigz100_5",&errSSDfracModsigz100_5);
1019   ntits->SetBranchAddress("SSDfracModsigz300_5",&SSDfracModsigz300_5);
1020   ntits->SetBranchAddress("errSSDfracModsigz300_5",&errSSDfracModsigz300_5);
1021   ntits->SetBranchAddress("SSDfracModsigz500_5",&SSDfracModsigz500_5);
1022   ntits->SetBranchAddress("errSSDfracModsigz500_5",&errSSDfracModsigz500_5);
1023   ntits->SetBranchAddress("SSDfracModmux20_6",&SSDfracModmux20_6);
1024   ntits->SetBranchAddress("errSSDfracModmux20_6",&errSSDfracModmux20_6);
1025   ntits->SetBranchAddress("SSDfracModmux50_6",&SSDfracModmux50_6);
1026   ntits->SetBranchAddress("errSSDfracModmux50_6",&errSSDfracModmux50_6);
1027   ntits->SetBranchAddress("SSDfracModmux100_6",&SSDfracModmux100_6);
1028   ntits->SetBranchAddress("errSSDfracModmux100_6",&errSSDfracModmux100_6);
1029   ntits->SetBranchAddress("SSDfracModsigx100_6",&SSDfracModsigx100_6);
1030   ntits->SetBranchAddress("errSSDfracModsigx100_6",&errSSDfracModsigx100_6);
1031   ntits->SetBranchAddress("SSDfracModsigx200_6",&SSDfracModsigx200_6);
1032   ntits->SetBranchAddress("errSSDfracModsigx200_6",&errSSDfracModsigx200_6);
1033   ntits->SetBranchAddress("SSDfracModsigx300_6",&SSDfracModsigx300_6);
1034   ntits->SetBranchAddress("errSSDfracModsigx300_6",&errSSDfracModsigx300_6);
1035   ntits->SetBranchAddress("SSDfracModmuz50_6",&SSDfracModmuz50_6);
1036   ntits->SetBranchAddress("errSSDfracModmuz50_6",&errSSDfracModmuz50_6);
1037   ntits->SetBranchAddress("SSDfracModmuz100_6",&SSDfracModmuz100_6);
1038   ntits->SetBranchAddress("errSSDfracModmuz100_6",&errSSDfracModmuz100_6);
1039   ntits->SetBranchAddress("SSDfracModmuz300_6",&SSDfracModmuz300_6);
1040   ntits->SetBranchAddress("errSSDfracModmuz300_6",&errSSDfracModmuz300_6);
1041   ntits->SetBranchAddress("SSDfracModsigz100_6",&SSDfracModsigz100_6);
1042   ntits->SetBranchAddress("errSSDfracModsigz100_6",&errSSDfracModsigz100_6);
1043   ntits->SetBranchAddress("SSDfracModsigz300_6",&SSDfracModsigz300_6);
1044   ntits->SetBranchAddress("errSSDfracModsigz300_6",&errSSDfracModsigz300_6);
1045   ntits->SetBranchAddress("SSDfracModsigz500_6",&SSDfracModsigz500_6);
1046   ntits->SetBranchAddress("errSSDfracModsigz500_6",&errSSDfracModsigz500_6);
1047
1048   // Sort entries according to run number in the chosen range
1049   // Same order is assumed for all the subsequent ntuples
1050   Int_t nr=ntits->GetEntries();
1051   Int_t *myIndex = new Int_t [nr];
1052   Int_t *noRuns = new Int_t [nr];
1053   Int_t kRunsToPlot=0;
1054   printf("Processing runs from %d up to %d\n",run1,run2);
1055   for(Int_t i=0; i<nr;i++){
1056     ntits->GetEvent(i);
1057     Int_t intrun = static_cast<Int_t>(nrun+0.01);
1058     if(intrun>=run1 && intrun<=run2){
1059       printf("Accepting run number %d in position %d\n",intrun,kRunsToPlot);
1060       noRuns[i]=intrun;
1061       kRunsToPlot++;
1062     }
1063     else {
1064       noRuns[i]=run2+10;  
1065       printf("Rejecting run number %d - out of range\n",intrun);
1066     }
1067   }
1068   TMath::Sort(nr,noRuns,myIndex,kFALSE);
1069   printf("Total number of runs accepted for display %d\n",kRunsToPlot);
1070   if(kRunsToPlot==0)return;
1071   for(Int_t i=0;i<kRunsToPlot;i++)printf("Position %d ) Run: %d\n",i,noRuns[myIndex[i]]);
1072
1073   TH1F* hfmux20_3=new TH1F("hfmux20_3","",kRunsToPlot,0.,kRunsToPlot);
1074   TH1F* hfmux50_3=new TH1F("hfmux50_3","",kRunsToPlot,0.,kRunsToPlot);
1075   TH1F* hfmux100_3=new TH1F("hfmux100_3","",kRunsToPlot,0.,kRunsToPlot);
1076   TH1F* hfsigx100_3=new TH1F("hfsigx100_3","",kRunsToPlot,0.,kRunsToPlot);
1077   TH1F* hfsigx200_3=new TH1F("hfsigx200_3","",kRunsToPlot,0.,kRunsToPlot);
1078   TH1F* hfsigx300_3=new TH1F("hfsigx300_3","",kRunsToPlot,0.,kRunsToPlot);
1079   TH1F* hfmuxlr20_3=new TH1F("hfmuxlr20_3","",kRunsToPlot,0.,kRunsToPlot);
1080   TH1F* hfmuxlr50_3=new TH1F("hfmuxlr50_3","",kRunsToPlot,0.,kRunsToPlot);
1081   TH1F* hfmuxlr100_3=new TH1F("hfmuxlr100_3","",kRunsToPlot,0.,kRunsToPlot);
1082   TH1F* hfexcx100_3=new TH1F("hfexcx100_3","",kRunsToPlot,0.,kRunsToPlot);
1083   TH1F* hfexcx200_3=new TH1F("hfexcx200_3","",kRunsToPlot,0.,kRunsToPlot);
1084   TH1F* hfexcx300_3=new TH1F("hfexcx300_3","",kRunsToPlot,0.,kRunsToPlot);
1085   TH1F* hfmuz50_3=new TH1F("hfmuz50_3","",kRunsToPlot,0.,kRunsToPlot);
1086   TH1F* hfmuz100_3=new TH1F("hfmuz100_3","",kRunsToPlot,0.,kRunsToPlot);
1087   TH1F* hfmuz300_3=new TH1F("hfmuz300_3","",kRunsToPlot,0.,kRunsToPlot);
1088   TH1F* hfsigz100_3=new TH1F("hfsigz100_3","",kRunsToPlot,0.,kRunsToPlot);
1089   TH1F* hfsigz300_3=new TH1F("hfsigz300_3","",kRunsToPlot,0.,kRunsToPlot);
1090   TH1F* hfsigz500_3=new TH1F("hfsigz500_3","",kRunsToPlot,0.,kRunsToPlot);
1091
1092   TH1F* hfmux20_4=new TH1F("hfmux20_4","",kRunsToPlot,0.,kRunsToPlot);
1093   TH1F* hfmux50_4=new TH1F("hfmux50_4","",kRunsToPlot,0.,kRunsToPlot);
1094   TH1F* hfmux100_4=new TH1F("hfmux100_4","",kRunsToPlot,0.,kRunsToPlot);
1095   TH1F* hfsigx100_4=new TH1F("hfsigx100_4","",kRunsToPlot,0.,kRunsToPlot);
1096   TH1F* hfsigx200_4=new TH1F("hfsigx200_4","",kRunsToPlot,0.,kRunsToPlot);
1097   TH1F* hfsigx300_4=new TH1F("hfsigx300_4","",kRunsToPlot,0.,kRunsToPlot);
1098   TH1F* hfmuxlr20_4=new TH1F("hfmuxlr20_4","",kRunsToPlot,0.,kRunsToPlot);
1099   TH1F* hfmuxlr50_4=new TH1F("hfmuxlr50_4","",kRunsToPlot,0.,kRunsToPlot);
1100   TH1F* hfmuxlr100_4=new TH1F("hfmuxlr100_4","",kRunsToPlot,0.,kRunsToPlot);
1101   TH1F* hfexcx100_4=new TH1F("hfexcx100_4","",kRunsToPlot,0.,kRunsToPlot);
1102   TH1F* hfexcx200_4=new TH1F("hfexcx200_4","",kRunsToPlot,0.,kRunsToPlot);
1103   TH1F* hfexcx300_4=new TH1F("hfexcx300_4","",kRunsToPlot,0.,kRunsToPlot);
1104   TH1F* hfmuz50_4=new TH1F("hfmuz50_4","",kRunsToPlot,0.,kRunsToPlot);
1105   TH1F* hfmuz100_4=new TH1F("hfmuz100_4","",kRunsToPlot,0.,kRunsToPlot);
1106   TH1F* hfmuz300_4=new TH1F("hfmuz300_4","",kRunsToPlot,0.,kRunsToPlot);
1107   TH1F* hfsigz100_4=new TH1F("hfsigz100_4","",kRunsToPlot,0.,kRunsToPlot);
1108   TH1F* hfsigz300_4=new TH1F("hfsigz300_4","",kRunsToPlot,0.,kRunsToPlot);
1109   TH1F* hfsigz500_4=new TH1F("hfsigz500_4","",kRunsToPlot,0.,kRunsToPlot);
1110
1111   TH1F* hfmux20_1=new TH1F("hfmux20_1","",kRunsToPlot,0.,kRunsToPlot);
1112   TH1F* hfmux50_1=new TH1F("hfmux50_1","",kRunsToPlot,0.,kRunsToPlot);
1113   TH1F* hfmux100_1=new TH1F("hfmux100_1","",kRunsToPlot,0.,kRunsToPlot);
1114   TH1F* hfsigx100_1=new TH1F("hfsigx100_1","",kRunsToPlot,0.,kRunsToPlot);
1115   TH1F* hfsigx200_1=new TH1F("hfsigx200_1","",kRunsToPlot,0.,kRunsToPlot);
1116   TH1F* hfsigx300_1=new TH1F("hfsigx300_1","",kRunsToPlot,0.,kRunsToPlot);
1117   TH1F* hfmuz50_1=new TH1F("hfmuz50_1","",kRunsToPlot,0.,kRunsToPlot);
1118   TH1F* hfmuz100_1=new TH1F("hfmuz100_1","",kRunsToPlot,0.,kRunsToPlot);
1119   TH1F* hfmuz300_1=new TH1F("hfmuz300_1","",kRunsToPlot,0.,kRunsToPlot);
1120   TH1F* hfsigz100_1=new TH1F("hfsigz100_1","",kRunsToPlot,0.,kRunsToPlot);
1121   TH1F* hfsigz300_1=new TH1F("hfsigz300_1","",kRunsToPlot,0.,kRunsToPlot);
1122   TH1F* hfsigz500_1=new TH1F("hfsigz500_1","",kRunsToPlot,0.,kRunsToPlot);
1123
1124   TH1F* hfmux20_2=new TH1F("hfmux20_2","",kRunsToPlot,0.,kRunsToPlot);
1125   TH1F* hfmux50_2=new TH1F("hfmux50_2","",kRunsToPlot,0.,kRunsToPlot);
1126   TH1F* hfmux100_2=new TH1F("hfmux100_2","",kRunsToPlot,0.,kRunsToPlot);
1127   TH1F* hfsigx100_2=new TH1F("hfsigx100_2","",kRunsToPlot,0.,kRunsToPlot);
1128   TH1F* hfsigx200_2=new TH1F("hfsigx200_2","",kRunsToPlot,0.,kRunsToPlot);
1129   TH1F* hfsigx300_2=new TH1F("hfsigx300_2","",kRunsToPlot,0.,kRunsToPlot);
1130   TH1F* hfmuz50_2=new TH1F("hfmuz50_2","",kRunsToPlot,0.,kRunsToPlot);
1131   TH1F* hfmuz100_2=new TH1F("hfmuz100_2","",kRunsToPlot,0.,kRunsToPlot);
1132   TH1F* hfmuz300_2=new TH1F("hfmuz300_2","",kRunsToPlot,0.,kRunsToPlot);
1133   TH1F* hfsigz100_2=new TH1F("hfsigz100_2","",kRunsToPlot,0.,kRunsToPlot);
1134   TH1F* hfsigz300_2=new TH1F("hfsigz300_2","",kRunsToPlot,0.,kRunsToPlot);
1135   TH1F* hfsigz500_2=new TH1F("hfsigz500_2","",kRunsToPlot,0.,kRunsToPlot);
1136
1137   TH1F* hfmux20_5=new TH1F("hfmux20_5","",kRunsToPlot,0.,kRunsToPlot);
1138   TH1F* hfmux50_5=new TH1F("hfmux50_5","",kRunsToPlot,0.,kRunsToPlot);
1139   TH1F* hfmux100_5=new TH1F("hfmux100_5","",kRunsToPlot,0.,kRunsToPlot);
1140   TH1F* hfsigx100_5=new TH1F("hfsigx100_5","",kRunsToPlot,0.,kRunsToPlot);
1141   TH1F* hfsigx200_5=new TH1F("hfsigx200_5","",kRunsToPlot,0.,kRunsToPlot);
1142   TH1F* hfsigx300_5=new TH1F("hfsigx300_5","",kRunsToPlot,0.,kRunsToPlot);
1143   TH1F* hfmuz50_5=new TH1F("hfmuz50_5","",kRunsToPlot,0.,kRunsToPlot);
1144   TH1F* hfmuz100_5=new TH1F("hfmuz100_5","",kRunsToPlot,0.,kRunsToPlot);
1145   TH1F* hfmuz300_5=new TH1F("hfmuz300_5","",kRunsToPlot,0.,kRunsToPlot);
1146   TH1F* hfsigz100_5=new TH1F("hfsigz100_5","",kRunsToPlot,0.,kRunsToPlot);
1147   TH1F* hfsigz300_5=new TH1F("hfsigz300_5","",kRunsToPlot,0.,kRunsToPlot);
1148   TH1F* hfsigz500_5=new TH1F("hfsigz500_5","",kRunsToPlot,0.,kRunsToPlot);
1149
1150   TH1F* hfmux20_6=new TH1F("hfmux20_6","",kRunsToPlot,0.,kRunsToPlot);
1151   TH1F* hfmux50_6=new TH1F("hfmux50_6","",kRunsToPlot,0.,kRunsToPlot);
1152   TH1F* hfmux100_6=new TH1F("hfmux100_6","",kRunsToPlot,0.,kRunsToPlot);
1153   TH1F* hfsigx100_6=new TH1F("hfsigx100_6","",kRunsToPlot,0.,kRunsToPlot);
1154   TH1F* hfsigx200_6=new TH1F("hfsigx200_6","",kRunsToPlot,0.,kRunsToPlot);
1155   TH1F* hfsigx300_6=new TH1F("hfsigx300_6","",kRunsToPlot,0.,kRunsToPlot);
1156   TH1F* hfmuz50_6=new TH1F("hfmuz50_6","",kRunsToPlot,0.,kRunsToPlot);
1157   TH1F* hfmuz100_6=new TH1F("hfmuz100_6","",kRunsToPlot,0.,kRunsToPlot);
1158   TH1F* hfmuz300_6=new TH1F("hfmuz300_6","",kRunsToPlot,0.,kRunsToPlot);
1159   TH1F* hfsigz100_6=new TH1F("hfsigz100_6","",kRunsToPlot,0.,kRunsToPlot);
1160   TH1F* hfsigz300_6=new TH1F("hfsigz300_6","",kRunsToPlot,0.,kRunsToPlot);
1161   TH1F* hfsigz500_6=new TH1F("hfsigz500_6","",kRunsToPlot,0.,kRunsToPlot);
1162
1163
1164   for(Int_t i=0; i<kRunsToPlot;i++){
1165     ntits->GetEvent(myIndex[i]);
1166
1167     hfmux20_3->SetBinContent(i+1,SDDfracModmux20_3);
1168 //    hfmux20_3->SetBinError(i+1,errSDDfracModmux20_3);
1169     hfmux20_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1170     hfmux50_3->SetBinContent(i+1,SDDfracModmux50_3);
1171 //    hfmux50_3->SetBinError(i+1,errSDDfracModmux50_3);
1172     hfmux50_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1173     hfmux100_3->SetBinContent(i+1,SDDfracModmux100_3);
1174 //    hfmux100_3->SetBinError(i+1,errSDDfracModmux100_3);
1175     hfmux100_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1176     hfsigx100_3->SetBinContent(i+1,SDDfracModsigx100_3);
1177 //    hfsigx100_3->SetBinError(i+1,errSDDfracModsigx100_3);
1178     hfsigx100_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1179     hfsigx200_3->SetBinContent(i+1,SDDfracModsigx200_3);
1180 //    hfsigx200_3->SetBinError(i+1,errSDDfracModsigx200_3);
1181     hfsigx200_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1182     hfsigx300_3->SetBinContent(i+1,SDDfracModsigx300_3);
1183 //    hfsigx300_3->SetBinError(i+1,errSDDfracModsigx300_3);
1184     hfsigx300_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1185     hfmuxlr20_3->SetBinContent(i+1,SDDfracModmuxlr20_3);
1186 //    hfmuxlr20_3->SetBinError(i+1,errSDDfracModmuxlr20_3);
1187     hfmuxlr20_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1188     hfmuxlr50_3->SetBinContent(i+1,SDDfracModmuxlr50_3);
1189 //    hfmuxlr50_3->SetBinError(i+1,errSDDfracModmux50_3);
1190     hfmuxlr50_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1191     hfmuxlr100_3->SetBinContent(i+1,SDDfracModmux100_3);
1192 //    hfmuxlr100_3->SetBinError(i+1,errSDDfracModmux100_3);
1193     hfmuxlr100_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1194     hfexcx100_3->SetBinContent(i+1,SDDfracModexcx100_3);
1195 //    hfexcx100_3->SetBinError(i+1,errSDDfracModexcx100_3);
1196     hfexcx100_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1197     hfexcx200_3->SetBinContent(i+1,SDDfracModexcx200_3);
1198 //    hfexcx200_3->SetBinError(i+1,errSDDfracModexcx200_3);
1199     hfexcx200_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1200     hfexcx300_3->SetBinContent(i+1,SDDfracModexcx300_3);
1201 //    hfexcx300_3->SetBinError(i+1,errSDDfracModexcx300_3);
1202     hfexcx300_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1203     hfmuz50_3->SetBinContent(i+1,SDDfracModmuz50_3);
1204 //    hfmuz50_3->SetBinError(i+1,errSDDfracModmuz50_3);
1205     hfmuz50_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1206     hfmuz100_3->SetBinContent(i+1,SDDfracModmuz100_3);
1207 //    hfmuz100_3->SetBinError(i+1,errSDDfracModmuz100_3);
1208     hfmuz100_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1209     hfmuz300_3->SetBinContent(i+1,SDDfracModmuz300_3);
1210 //    hfmuz300_3->SetBinError(i+1,errSDDfracModmuz300_3);
1211     hfmuz300_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1212     hfsigz100_3->SetBinContent(i+1,SDDfracModsigz100_3);
1213 //    hfsigz100_3->SetBinError(i+1,errSDDfracModsigz100_3);
1214     hfsigz100_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1215     hfsigz300_3->SetBinContent(i+1,SDDfracModsigz300_3);
1216 //    hfsigz300_3->SetBinError(i+1,errSDDfracModsigz300_3);
1217     hfsigz300_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1218     hfsigz500_3->SetBinContent(i+1,SDDfracModsigz500_3);
1219 //    hfsigz500_3->SetBinError(i+1,errSDDfracModsigz500_3);
1220     hfsigz500_3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1221
1222     hfmux20_4->SetBinContent(i+1,SDDfracModmux20_4);
1223 //    hfmux20_4->SetBinError(i+1,errSDDfracModmux20_4);
1224     hfmux20_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1225     hfmux50_4->SetBinContent(i+1,SDDfracModmux50_4);
1226 //    hfmux50_4->SetBinError(i+1,errSDDfracModmux50_4);
1227     hfmux50_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1228     hfmux100_4->SetBinContent(i+1,SDDfracModmux100_4);
1229 //    hfmux100_4->SetBinError(i+1,errSDDfracModmux100_4);
1230     hfmux100_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1231     hfsigx100_4->SetBinContent(i+1,SDDfracModsigx100_4);
1232 //    hfsigx100_4->SetBinError(i+1,errSDDfracModsigx100_4);
1233     hfsigx100_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1234     hfsigx200_4->SetBinContent(i+1,SDDfracModsigx200_4);
1235 //    hfsigx200_4->SetBinError(i+1,errSDDfracModsigx200_4);
1236     hfsigx200_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1237     hfsigx300_4->SetBinContent(i+1,SDDfracModsigx300_4);
1238 //    hfsigx300_4->SetBinError(i+1,errSDDfracModsigx300_4);
1239     hfsigx300_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1240     hfmuxlr20_4->SetBinContent(i+1,SDDfracModmuxlr20_4);
1241 //    hfmuxlr20_4->SetBinError(i+1,errSDDfracModmuxlr20_4);
1242     hfmuxlr20_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1243     hfmuxlr50_4->SetBinContent(i+1,SDDfracModmuxlr50_4);
1244 //    hfmuxlr50_4->SetBinError(i+1,errSDDfracModmux50_4);
1245     hfmuxlr50_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1246     hfmuxlr100_4->SetBinContent(i+1,SDDfracModmux100_4);
1247 //    hfmuxlr100_4->SetBinError(i+1,errSDDfracModmux100_4);
1248     hfmuxlr100_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1249     hfexcx100_4->SetBinContent(i+1,SDDfracModexcx100_4);
1250 //    hfexcx100_4->SetBinError(i+1,errSDDfracModexcx100_4);
1251     hfexcx100_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1252     hfexcx200_4->SetBinContent(i+1,SDDfracModexcx200_4);
1253 //    hfexcx200_4->SetBinError(i+1,errSDDfracModexcx200_4);
1254     hfexcx200_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1255     hfexcx300_4->SetBinContent(i+1,SDDfracModexcx300_4);
1256 //    hfexcx300_4->SetBinError(i+1,errSDDfracModexcx300_4);
1257     hfexcx300_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1258     hfmuz50_4->SetBinContent(i+1,SDDfracModmuz50_4);
1259 //    hfmuz50_4->SetBinError(i+1,errSDDfracModmuz50_4);
1260     hfmuz50_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1261     hfmuz100_4->SetBinContent(i+1,SDDfracModmuz100_4);
1262 //    hfmuz100_4->SetBinError(i+1,errSDDfracModmuz100_4);
1263     hfmuz100_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1264     hfmuz300_4->SetBinContent(i+1,SDDfracModmuz300_4);
1265 //    hfmuz300_4->SetBinError(i+1,errSDDfracModmuz300_4);
1266     hfmuz300_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1267     hfsigz100_4->SetBinContent(i+1,SDDfracModsigz100_4);
1268 //    hfsigz100_4->SetBinError(i+1,errSDDfracModsigz100_4);
1269     hfsigz100_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1270     hfsigz300_4->SetBinContent(i+1,SDDfracModsigz300_4);
1271 //    hfsigz300_4->SetBinError(i+1,errSDDfracModsigz300_4);
1272     hfsigz300_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1273     hfsigz500_4->SetBinContent(i+1,SDDfracModsigz500_4);
1274 //    hfsigz500_4->SetBinError(i+1,errSDDfracModsigz500_4);
1275     hfsigz500_4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1276
1277     hfmux20_1->SetBinContent(i+1,SPDfracModmux20_1);
1278 //    hfmux20_1->SetBinError(i+1,errSPDfracModmux20_1);
1279     hfmux20_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1280     hfmux50_1->SetBinContent(i+1,SPDfracModmux50_1);
1281 //    hfmux50_1->SetBinError(i+1,errSPDfracModmux50_1);
1282     hfmux50_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1283     hfmux100_1->SetBinContent(i+1,SPDfracModmux100_1);
1284 //    hfmux100_1->SetBinError(i+1,errSPDfracModmux100_1);
1285     hfmux100_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1286     hfsigx100_1->SetBinContent(i+1,SPDfracModsigx100_1);
1287 //    hfsigx100_1->SetBinError(i+1,errSPDfracModsigx100_1);
1288     hfsigx100_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1289     hfsigx200_1->SetBinContent(i+1,SPDfracModsigx200_1);
1290 //    hfsigx200_1->SetBinError(i+1,errSPDfracModsigx200_1);
1291     hfsigx200_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1292     hfsigx300_1->SetBinContent(i+1,SPDfracModsigx300_1);
1293 //    hfsigx300_1->SetBinError(i+1,errSPDfracModsigx300_1);
1294     hfsigx300_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1295     hfmuz50_1->SetBinContent(i+1,SPDfracModmuz50_1);
1296 //    hfmuz50_1->SetBinError(i+1,errSPDfracModmuz50_1);
1297     hfmuz50_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1298     hfmuz100_1->SetBinContent(i+1,SPDfracModmuz100_1);
1299 //    hfmuz100_1->SetBinError(i+1,errSPDfracModmuz100_1);
1300     hfmuz100_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1301     hfmuz300_1->SetBinContent(i+1,SPDfracModmuz300_1);
1302 //    hfmuz300_1->SetBinError(i+1,errSPDfracModmuz300_1);
1303     hfmuz300_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1304     hfsigz100_1->SetBinContent(i+1,SPDfracModsigz100_1);
1305 //    hfsigz100_1->SetBinError(i+1,errSPDfracModsigz100_1);
1306     hfsigz100_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1307     hfsigz300_1->SetBinContent(i+1,SPDfracModsigz300_1);
1308 //    hfsigz300_1->SetBinError(i+1,errSPDfracModsigz300_1);
1309     hfsigz300_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1310     hfsigz500_1->SetBinContent(i+1,SPDfracModsigz500_1);
1311 //    hfsigz500_1->SetBinError(i+1,errSPDfracModsigz500_1);
1312     hfsigz500_1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1313
1314     hfmux20_2->SetBinContent(i+1,SPDfracModmux20_2);
1315 //    hfmux20_2->SetBinError(i+1,errSPDfracModmux20_2);
1316     hfmux20_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1317     hfmux50_2->SetBinContent(i+1,SPDfracModmux50_2);
1318 //    hfmux50_2->SetBinError(i+1,errSPDfracModmux50_2);
1319     hfmux50_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1320     hfmux100_2->SetBinContent(i+1,SPDfracModmux100_2);
1321 //    hfmux100_2->SetBinError(i+1,errSPDfracModmux100_2);
1322     hfmux100_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1323     hfsigx100_2->SetBinContent(i+1,SPDfracModsigx100_2);
1324 //    hfsigx100_2->SetBinError(i+1,errSPDfracModsigx100_2);
1325     hfsigx100_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1326     hfsigx200_2->SetBinContent(i+1,SPDfracModsigx200_2);
1327 //    hfsigx200_2->SetBinError(i+1,errSPDfracModsigx200_2);
1328     hfsigx200_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1329     hfsigx300_2->SetBinContent(i+1,SPDfracModsigx300_2);
1330 //    hfsigx300_2->SetBinError(i+1,errSPDfracModsigx300_2);
1331     hfsigx300_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1332     hfmuz50_2->SetBinContent(i+1,SPDfracModmuz50_2);
1333 //    hfmuz50_2->SetBinError(i+1,errSPDfracModmuz50_2);
1334     hfmuz50_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1335     hfmuz100_2->SetBinContent(i+1,SPDfracModmuz100_2);
1336 //    hfmuz100_2->SetBinError(i+1,errSPDfracModmuz100_2);
1337     hfmuz100_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1338     hfmuz300_2->SetBinContent(i+1,SPDfracModmuz300_2);
1339 //    hfmuz300_2->SetBinError(i+1,errSPDfracModmuz300_2);
1340     hfmuz300_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1341     hfsigz100_2->SetBinContent(i+1,SPDfracModsigz100_2);
1342 //    hfsigz100_2->SetBinError(i+1,errSPDfracModsigz100_2);
1343     hfsigz100_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1344     hfsigz300_2->SetBinContent(i+1,SPDfracModsigz300_2);
1345 //    hfsigz300_2->SetBinError(i+1,errSPDfracModsigz300_2);
1346     hfsigz300_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1347     hfsigz500_2->SetBinContent(i+1,SPDfracModsigz500_2);
1348 //    hfsigz500_2->SetBinError(i+1,errSPDfracModsigz500_2);
1349     hfsigz500_2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1350
1351     hfmux20_5->SetBinContent(i+1,SSDfracModmux20_5);
1352 //    hfmux20_5->SetBinError(i+1,errSSDfracModmux20_5);
1353     hfmux20_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1354     hfmux50_5->SetBinContent(i+1,SSDfracModmux50_5);
1355 //    hfmux50_5->SetBinError(i+1,errSSDfracModmux50_5);
1356     hfmux50_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1357     hfmux100_5->SetBinContent(i+1,SSDfracModmux100_5);
1358 //    hfmux100_5->SetBinError(i+1,errSSDfracModmux100_5);
1359     hfmux100_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1360     hfsigx100_5->SetBinContent(i+1,SSDfracModsigx100_5);
1361 //    hfsigx100_5->SetBinError(i+1,errSSDfracModsigx100_5);
1362     hfsigx100_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1363     hfsigx200_5->SetBinContent(i+1,SSDfracModsigx200_5);
1364 //    hfsigx200_5->SetBinError(i+1,errSSDfracModsigx200_5);
1365     hfsigx200_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1366     hfsigx300_5->SetBinContent(i+1,SSDfracModsigx300_5);
1367 //    hfsigx300_5->SetBinError(i+1,errSSDfracModsigx300_5);
1368     hfsigx300_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1369     hfmuz50_5->SetBinContent(i+1,SSDfracModmuz50_5);
1370 //    hfmuz50_5->SetBinError(i+1,errSSDfracModmuz50_5);
1371     hfmuz50_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1372     hfmuz100_5->SetBinContent(i+1,SSDfracModmuz100_5);
1373 //    hfmuz100_5->SetBinError(i+1,errSSDfracModmuz100_5);
1374     hfmuz100_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1375     hfmuz300_5->SetBinContent(i+1,SSDfracModmuz300_5);
1376 //    hfmuz300_5->SetBinError(i+1,errSSDfracModmuz300_5);
1377     hfmuz300_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1378     hfsigz100_5->SetBinContent(i+1,SSDfracModsigz100_5);
1379 //    hfsigz100_5->SetBinError(i+1,errSSDfracModsigz100_5);
1380     hfsigz100_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1381     hfsigz300_5->SetBinContent(i+1,SSDfracModsigz300_5);
1382 //    hfsigz300_5->SetBinError(i+1,errSSDfracModsigz300_5);
1383     hfsigz300_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1384     hfsigz500_5->SetBinContent(i+1,SSDfracModsigz500_5);
1385 //    hfsigz500_5->SetBinError(i+1,errSSDfracModsigz500_5);
1386     hfsigz500_5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1387
1388     hfmux20_6->SetBinContent(i+1,SSDfracModmux20_6);
1389 //    hfmux20_6->SetBinError(i+1,errSSDfracModmux20_6);
1390     hfmux20_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1391     hfmux50_6->SetBinContent(i+1,SSDfracModmux50_6);
1392 //    hfmux50_6->SetBinError(i+1,errSSDfracModmux50_6);
1393     hfmux50_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1394     hfmux100_6->SetBinContent(i+1,SSDfracModmux100_6);
1395 //    hfmux100_6->SetBinError(i+1,errSSDfracModmux100_6);
1396     hfmux100_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1397     hfsigx100_6->SetBinContent(i+1,SSDfracModsigx100_6);
1398 //    hfsigx100_6->SetBinError(i+1,errSSDfracModsigx100_6);
1399     hfsigx100_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1400     hfsigx200_6->SetBinContent(i+1,SSDfracModsigx200_6);
1401 //    hfsigx200_6->SetBinError(i+1,errSSDfracModsigx200_6);
1402     hfsigx200_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1403     hfsigx300_6->SetBinContent(i+1,SSDfracModsigx300_6);
1404 //    hfsigx300_6->SetBinError(i+1,errSSDfracModsigx300_6);
1405     hfsigx300_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1406     hfmuz50_6->SetBinContent(i+1,SSDfracModmuz50_6);
1407 //    hfmuz50_6->SetBinError(i+1,errSSDfracModmuz50_6);
1408     hfmuz50_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1409     hfmuz100_6->SetBinContent(i+1,SSDfracModmuz100_6);
1410 //    hfmuz100_6->SetBinError(i+1,errSSDfracModmuz100_6);
1411     hfmuz100_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1412     hfmuz300_6->SetBinContent(i+1,SSDfracModmuz300_6);
1413 //    hfmuz300_6->SetBinError(i+1,errSSDfracModmuz300_6);
1414     hfmuz300_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1415     hfsigz100_6->SetBinContent(i+1,SSDfracModsigz100_6);
1416 //    hfsigz100_6->SetBinError(i+1,errSSDfracModsigz100_6);
1417     hfsigz100_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1418     hfsigz300_6->SetBinContent(i+1,SSDfracModsigz300_6);
1419 //    hfsigz300_6->SetBinError(i+1,errSSDfracModsigz300_6);
1420     hfsigz300_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1421     hfsigz500_6->SetBinContent(i+1,SSDfracModsigz500_6);
1422 //    hfsigz500_6->SetBinError(i+1,errSSDfracModsigz500_6);
1423     hfsigz500_6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
1424
1425
1426   }
1427
1428   gROOT->SetStyle("Plain");
1429   //  gStyle->SetOptTitle(0);
1430   gStyle->SetOptStat(0);
1431   gStyle->SetFillColor(0);
1432   gStyle->SetTextFont(32);
1433
1434   
1435
1436   TCanvas* c1=new TCanvas("c1","SDD Layer 3", 1200,800);
1437   c1->Divide(1,2);
1438   c1->cd(1);
1439   hfmux20_3->SetTitle("fraction(| #mu x-residual | < threshold) - layer 3");
1440   hfmux20_3->SetLineColor(2);
1441   hfmux20_3->SetMarkerStyle(31);
1442   hfmux20_3->SetMarkerSize(2);
1443   hfmux20_3->SetMarkerColor(2);
1444   hfmux20_3->SetMinimum(0.);
1445   hfmux20_3->SetMaximum(1.2);
1446   hfmux20_3->GetXaxis()->SetTitle("run number");
1447   hfmux20_3->GetYaxis()->SetTitleOffset(1.2);
1448   //  hfmux20_3->GetYaxis()->SetTitle("%");
1449   hfmux20_3->Draw("P");
1450   hfmux50_3->SetLineColor(4);
1451   hfmux50_3->SetMarkerStyle(21);
1452   hfmux50_3->SetMarkerColor(4);
1453   hfmux50_3->Draw("same P");
1454   hfmux100_3->SetLineColor(6);
1455   hfmux100_3->SetMarkerStyle(22);
1456   hfmux100_3->SetMarkerColor(6);
1457   hfmux100_3->Draw("same P");
1458
1459         // quiqui
1460         TLine *l3 = new TLine(0.,0.877,kRunsToPlot,0.877);
1461         l3->SetLineStyle(2);
1462         l3->SetLineWidth(2);    
1463 //      l3->Draw();
1464   TLegend* leg=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1465   TLegendEntry* enta=leg->AddEntry(hfmux20_3,"|#mu res x | < 20 #mum","PL"); // P: marker, L; line
1466   enta->SetTextColor(hfmux20_3->GetMarkerColor());
1467   TLegendEntry* entb=leg->AddEntry(hfmux50_3,"|#mu res x | < 50 #mum","PL"); // P: marker, L; line
1468   entb->SetTextColor(hfmux50_3->GetMarkerColor());
1469   TLegendEntry* entc=leg->AddEntry(hfmux100_3,"|#mu res x | < 100 #mum","PL"); // P: marker, L; line
1470   entc->SetTextColor(hfmux100_3->GetMarkerColor());
1471   leg->SetFillStyle(0);
1472   leg->Draw();
1473   //  c1->Update();
1474
1475   c1->cd(2);
1476   hfmuxlr20_3->SetTitle("fraction(| #muL - #muR | < threshold) - layer 3");
1477   hfmuxlr20_3->SetLineColor(2);
1478   hfmuxlr20_3->SetMarkerStyle(31);
1479   hfmuxlr20_3->SetMarkerSize(2);
1480   hfmuxlr20_3->SetMarkerColor(2);
1481   hfmuxlr20_3->SetMinimum(0.);
1482   hfmuxlr20_3->SetMaximum(1.2);
1483   hfmuxlr20_3->GetXaxis()->SetTitle("run number");
1484   hfmuxlr20_3->GetYaxis()->SetTitleOffset(1.2);
1485   //  hfmuxlr20_3->GetYaxis()->SetTitle("%");
1486   hfmuxlr20_3->Draw("P");
1487   hfmuxlr50_3->SetLineColor(4);
1488   hfmuxlr50_3->SetMarkerStyle(21);
1489   hfmuxlr50_3->SetMarkerColor(4);
1490   hfmuxlr50_3->Draw("same P");
1491   hfmuxlr100_3->SetLineColor(6);
1492   hfmuxlr100_3->SetMarkerStyle(22);
1493   hfmuxlr100_3->SetMarkerColor(6);
1494   hfmuxlr100_3->Draw("same P");
1495         
1496 //      l3->Draw();
1497
1498   TLegend* leg2=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1499   TLegendEntry* ent2a=leg2->AddEntry(hfmuxlr20_3,"|#muL - #muR| < 20 #mum","PL"); // P: marker, L; line
1500   ent2a->SetTextColor(hfmuxlr20_3->GetMarkerColor());
1501   TLegendEntry* ent2b=leg2->AddEntry(hfmuxlr50_3,"|#muL - #muR| < 50 #mum","PL"); // P: marker, L; line
1502   ent2b->SetTextColor(hfmuxlr50_3->GetMarkerColor());
1503   TLegendEntry* ent2c=leg2->AddEntry(hfmuxlr100_3,"|#muL - #muR| < 100 #mum","PL"); // P: marker, L; line
1504   ent2c->SetTextColor(hfmuxlr100_3->GetMarkerColor());
1505   leg2->SetFillStyle(0);
1506   leg2->Draw();
1507
1508         c1->SaveAs("SDD_resx_L3");
1509 //      pdfFileNames+=" SDD_resx_L3";
1510         c1->Update();
1511
1512   TCanvas* c2=new TCanvas("c2","SDD Layer 4", 1200,800);
1513   c2->Divide(1,2);
1514   c2->cd(1);
1515   hfmux20_4->SetTitle("fraction(| #mu x-residual | < threshold) - layer 4");
1516   hfmux20_4->SetLineColor(2);
1517   hfmux20_4->SetMarkerStyle(31);
1518   hfmux20_4->SetMarkerSize(2);
1519   hfmux20_4->SetMarkerColor(2);
1520   hfmux20_4->SetMinimum(0.);
1521   hfmux20_4->SetMaximum(1.2);
1522   hfmux20_4->GetXaxis()->SetTitle("run number");
1523   hfmux20_4->GetYaxis()->SetTitleOffset(1.2);
1524   //  hfmux20_4->GetYaxis()->SetTitle("%");
1525   hfmux20_4->Draw("P");
1526   hfmux50_4->SetLineColor(4);
1527   hfmux50_4->SetMarkerStyle(21);
1528   hfmux50_4->SetMarkerColor(4);
1529   hfmux50_4->Draw("same P");
1530   hfmux100_4->SetLineColor(6);
1531   hfmux100_4->SetMarkerStyle(22);
1532   hfmux100_4->SetMarkerColor(6);
1533   hfmux100_4->Draw("same P");
1534         TLine *l4 = new TLine(0.,0.839,kRunsToPlot,0.839);
1535         l4->SetLineStyle(2);
1536         l4->SetLineWidth(2);    
1537 //      l4->Draw();
1538         
1539   TLegend* legg=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1540   TLegendEntry* entta=legg->AddEntry(hfmux20_4,"|#mu res x | < 20 #mum","PL"); // P: marker, L; line
1541   entta->SetTextColor(hfmux20_4->GetMarkerColor());
1542   TLegendEntry* enttb=legg->AddEntry(hfmux50_4,"|#mu res x | < 50 #mum","PL"); // P: marker, L; line
1543   enttb->SetTextColor(hfmux50_4->GetMarkerColor());
1544   TLegendEntry* enttc=legg->AddEntry(hfmux100_4,"|#mu res x | < 100 #mum","PL"); // P: marker, L; line
1545   enttc->SetTextColor(hfmux100_4->GetMarkerColor());
1546   legg->SetFillStyle(0);
1547   legg->Draw();
1548   //  c2->Update();
1549
1550   c2->cd(2);
1551   hfmuxlr20_4->SetTitle("fraction(| #muL - #muR | < threshold) - layer 4");
1552   hfmuxlr20_4->SetLineColor(2);
1553   hfmuxlr20_4->SetMarkerStyle(31);
1554   hfmuxlr20_4->SetMarkerSize(2);
1555   hfmuxlr20_4->SetMarkerColor(2);
1556   hfmuxlr20_4->SetMinimum(0.);
1557   hfmuxlr20_4->SetMaximum(1.2);
1558   hfmuxlr20_4->GetXaxis()->SetTitle("run number");
1559   hfmuxlr20_4->GetYaxis()->SetTitleOffset(1.2);
1560   //  hfmuxlr20_4->GetYaxis()->SetTitle("%");
1561   hfmuxlr20_4->Draw("P");
1562   hfmuxlr50_4->SetLineColor(4);
1563   hfmuxlr50_4->SetMarkerStyle(21);
1564   hfmuxlr50_4->SetMarkerColor(4);
1565   hfmuxlr50_4->Draw("same P");
1566   hfmuxlr100_4->SetLineColor(6);
1567   hfmuxlr100_4->SetMarkerStyle(22);
1568   hfmuxlr100_4->SetMarkerColor(6);
1569   hfmuxlr100_4->Draw("same P");
1570
1571 //      l4->Draw();
1572         
1573   TLegend* legg2=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1574   TLegendEntry* entt2a=legg2->AddEntry(hfmuxlr20_4,"|#muL - #muR| < 20 #mum","PL"); // P: marker, L; line
1575   entt2a->SetTextColor(hfmuxlr20_4->GetMarkerColor());
1576   TLegendEntry* entt2b=legg2->AddEntry(hfmuxlr50_4,"|#muL - #muR| < 50 #mum","PL"); // P: marker, L; line
1577   entt2b->SetTextColor(hfmuxlr50_4->GetMarkerColor());
1578   TLegendEntry* entt2c=legg2->AddEntry(hfmuxlr100_4,"|#muL - #muR| < 100 #mum","PL"); // P: marker, L; line
1579   entt2c->SetTextColor(hfmuxlr100_4->GetMarkerColor());
1580   legg2->SetFillStyle(0);
1581   legg2->Draw();
1582
1583         c2->SaveAs("SDD_resx_L4");
1584 //      pdfFileNames+=" SDD_resx_L4";
1585     c2->Update();
1586         
1587   //////////qui
1588
1589  TCanvas* c3=new TCanvas("c3","SDD z residuals", 1200,800);
1590   c3->Divide(1,2);
1591   c3->cd(1);
1592   hfmuz50_3->SetTitle("fraction(| #mu z-residual | < threshold) - layer 3");
1593   hfmuz50_3->SetLineColor(2);
1594   hfmuz50_3->SetMarkerStyle(31);
1595   hfmuz50_3->SetMarkerSize(2);
1596   hfmuz50_3->SetMarkerColor(2);
1597   hfmuz50_3->SetMinimum(0.);
1598   hfmuz50_3->SetMaximum(1.2);
1599   hfmuz50_3->GetXaxis()->SetTitle("run number");
1600   hfmuz50_3->GetYaxis()->SetTitleOffset(1.2);
1601   //  hfmuz50_3->GetYaxis()->SetTitle("%");
1602   hfmuz50_3->Draw("P");
1603   hfmuz100_3->SetLineColor(4);
1604   hfmuz100_3->SetMarkerStyle(21);
1605   hfmuz100_3->SetMarkerColor(4);
1606   hfmuz100_3->Draw("same P");
1607   hfmuz300_3->SetLineColor(6);
1608   hfmuz300_3->SetMarkerStyle(22);
1609   hfmuz300_3->SetMarkerColor(6);
1610   hfmuz300_3->Draw("same P");
1611 //      l3->Draw();
1612   TLegend* lege=new TLegend(0.5,0.15,0.88,0.35); // x1, y1, x2, y2
1613   TLegendEntry* ent_a=lege->AddEntry(hfmuz50_3,"|#mu res z| < 30 #mum","PL"); // P: marker, L; line
1614   ent_a->SetTextColor(hfmuz50_3->GetMarkerColor());
1615   TLegendEntry* ent_b=lege->AddEntry(hfmuz100_3,"|#mu res z| < 50 #mum","PL"); // P: marker, L; line
1616   ent_b->SetTextColor(hfmuz100_3->GetMarkerColor());
1617   TLegendEntry* ent_c=lege->AddEntry(hfmuz300_3,"|#mu res z| < 100 #mum","PL"); // P: marker, L; line
1618   ent_c->SetTextColor(hfmuz300_3->GetMarkerColor());
1619   lege->SetFillStyle(0);
1620   lege->Draw();
1621   //  c3->Update();
1622
1623   c3->cd(2);
1624   hfmuz50_4->SetTitle("fraction(| #mu z-residual | < threshold) - layer 4");
1625   hfmuz50_4->SetLineColor(2);
1626   hfmuz50_4->SetMarkerStyle(31);
1627   hfmuz50_4->SetMarkerSize(2);
1628   hfmuz50_4->SetMarkerColor(2);
1629   hfmuz50_4->SetMinimum(0.);
1630   hfmuz50_4->SetMaximum(1.2);
1631   hfmuz50_4->GetXaxis()->SetTitle("run number");
1632   hfmuz50_4->GetYaxis()->SetTitleOffset(1.2);
1633   //  hfmuz50_4->GetYaxis()->SetTitle("%");
1634   hfmuz50_4->Draw("P");
1635   hfmuz100_4->SetLineColor(4);
1636   hfmuz100_4->SetMarkerStyle(21);
1637   hfmuz100_4->SetMarkerColor(4);
1638   hfmuz100_4->Draw("same P");
1639   hfmuz300_4->SetLineColor(6);
1640   hfmuz300_4->SetMarkerStyle(22);
1641   hfmuz300_4->SetMarkerColor(6);
1642   hfmuz300_4->Draw("same P");
1643 //      l4->Draw();
1644   TLegend* leggi=new TLegend(0.5,0.15,0.88,0.35); // x1, y1, x2, y2
1645   TLegendEntry* en_ta=leggi->AddEntry(hfmuz50_4,"|#mu res z| < 30 #mum","PL"); // P: marker, L; line
1646   en_ta->SetTextColor(hfmuz50_4->GetMarkerColor());
1647   TLegendEntry* en_tb=leggi->AddEntry(hfmuz100_4,"|#mu res z| < 50 #mum","PL"); // P: marker, L; line
1648   en_tb->SetTextColor(hfmuz100_4->GetMarkerColor());
1649   TLegendEntry* en_tc=leggi->AddEntry(hfmuz300_4,"|#mu res z| < 100 #mum","PL"); // P: marker, L; line
1650   en_tc->SetTextColor(hfmuz300_4->GetMarkerColor());
1651   leggi->SetFillStyle(0);
1652   leggi->Draw();
1653         c3->SaveAs("SDD_resz");
1654 //      pdfFileNames+=" SDD_resz";
1655   c3->Update();
1656
1657   //////////////////////////////////////////////// SPD ////////////////////////////////////////////////////
1658
1659  TCanvas* c4=new TCanvas("c4","SPD x residuals", 1200,800);
1660   c4->Divide(1,2);
1661   c4->cd(1);
1662   hfmux20_1->SetTitle("fraction(| #mu x-residual | < threshold) - layer 1");
1663   hfmux20_1->SetLineColor(2);
1664   hfmux20_1->SetMarkerStyle(31);
1665   hfmux20_1->SetMarkerSize(2);
1666   hfmux20_1->SetMarkerColor(2);
1667   hfmux20_1->SetMinimum(0.);
1668   hfmux20_1->SetMaximum(1.2);
1669   hfmux20_1->GetXaxis()->SetTitle("run number");
1670   hfmux20_1->GetYaxis()->SetTitleOffset(1.2);
1671   //  hfmux20_1->GetYaxis()->SetTitle("%");
1672   hfmux20_1->Draw("P");
1673   hfmux50_1->SetLineColor(4);
1674   hfmux50_1->SetMarkerStyle(21);
1675   hfmux50_1->SetMarkerColor(4);
1676   hfmux50_1->Draw("same P");
1677   hfmux100_1->SetLineColor(6);
1678   hfmux100_1->SetMarkerStyle(22);
1679   hfmux100_1->SetMarkerColor(6);
1680   hfmux100_1->Draw("same P");
1681         TLine *l1 = new TLine(0.,0.625,kRunsToPlot,0.625);
1682         l1->SetLineStyle(2);
1683         l1->SetLineWidth(2);    
1684 //      l1->Draw();
1685         
1686   TLegend* lege1=new TLegend(0.5,0.15,0.88,0.35); // x1, y1, x2, y2
1687   TLegendEntry* ent_a1=lege1->AddEntry(hfmux20_1,"|#mu res x| < 5 #mum","PL"); // P: marker, L; line
1688   ent_a1->SetTextColor(hfmux20_1->GetMarkerColor());
1689   TLegendEntry* ent_b1=lege1->AddEntry(hfmux50_1,"|#mu res x| < 10 #mum","PL"); // P: marker, L; line
1690   ent_b1->SetTextColor(hfmux50_1->GetMarkerColor());
1691   TLegendEntry* ent_c1=lege1->AddEntry(hfmux100_1,"|#mu res x| < 50 #mum","PL"); // P: marker, L; line
1692   ent_c1->SetTextColor(hfmux100_1->GetMarkerColor());
1693   lege1->SetFillStyle(0);
1694   lege1->Draw();
1695   //  c4->Update();
1696
1697   c4->cd(2);
1698   hfmux20_2->SetTitle("fraction(| #mu x-residual | < threshold) - layer 2");
1699   hfmux20_2->SetLineColor(2);
1700   hfmux20_2->SetMarkerStyle(31);
1701   hfmux20_2->SetMarkerSize(2);
1702   hfmux20_2->SetMarkerColor(2);
1703   hfmux20_2->SetMinimum(0.);
1704   hfmux20_2->SetMaximum(1.2);
1705   hfmux20_2->GetXaxis()->SetTitle("run number");
1706   hfmux20_2->GetYaxis()->SetTitleOffset(1.2);
1707   //  hfmux20_2->GetYaxis()->SetTitle("%");
1708   hfmux20_2->Draw("P");
1709   hfmux50_2->SetLineColor(4);
1710   hfmux50_2->SetMarkerStyle(21);
1711   hfmux50_2->SetMarkerColor(4);
1712   hfmux50_2->Draw("same P");
1713   hfmux100_2->SetLineColor(6);
1714   hfmux100_2->SetMarkerStyle(22);
1715   hfmux100_2->SetMarkerColor(6);
1716   hfmux100_2->Draw("same P");
1717         TLine *l2 = new TLine(0.,0.631,kRunsToPlot,0.631);
1718         l2->SetLineStyle(2);
1719         l2->SetLineWidth(2);    
1720 //      l2->Draw();
1721         
1722   TLegend* leggi1=new TLegend(0.5,0.15,0.88,0.35); // x1, y1, x2, y2
1723   TLegendEntry* en_ta1=leggi1->AddEntry(hfmux20_2,"|#mu res x| < 10 #mum","PL"); // P: marker, L; line
1724   en_ta1->SetTextColor(hfmux20_2->GetMarkerColor());
1725   TLegendEntry* en_tb1=leggi1->AddEntry(hfmux50_2,"|#mu res x| < 20 #mum","PL"); // P: marker, L; line
1726   en_tb1->SetTextColor(hfmux50_2->GetMarkerColor());
1727   TLegendEntry* en_tc1=leggi1->AddEntry(hfmux100_2,"|#mu res x| < 50 #mum","PL"); // P: marker, L; line
1728   en_tc1->SetTextColor(hfmux100_2->GetMarkerColor());
1729   leggi1->SetFillStyle(0);
1730   leggi1->Draw();
1731         c4->SaveAs("SPD_resx");
1732 //      pdfFileNames+=" SPD_resx";
1733   c4->Update();
1734
1735  TCanvas* c5=new TCanvas("c5","SPD z residuals", 1200,800);
1736   c5->Divide(1,2);
1737   c5->cd(1);
1738   hfmuz50_1->SetTitle("fraction(| #mu z-residual | < threshold) - layer 1");
1739   hfmuz50_1->SetLineColor(2);
1740   hfmuz50_1->SetMarkerStyle(31);
1741   hfmuz50_1->SetMarkerColor(2);
1742   hfmuz50_1->SetMinimum(0.);
1743   hfmuz50_1->SetMaximum(1.2);
1744   hfmuz50_1->GetXaxis()->SetTitle("run number");
1745   hfmuz50_1->GetYaxis()->SetTitleOffset(1.2);
1746   //  hfmuz50_1->GetYaxis()->SetTitle("%");
1747   hfmuz50_1->Draw("P");
1748   hfmuz100_1->SetLineColor(4);
1749   hfmuz100_1->SetMarkerStyle(21);
1750   hfmuz100_1->SetMarkerColor(4);
1751   hfmuz100_1->Draw("same P");
1752   hfmuz300_1->SetLineColor(6);
1753   hfmuz300_1->SetMarkerStyle(22);
1754   hfmuz300_1->SetMarkerColor(6);
1755   hfmuz300_1->Draw("same P");
1756 //      l1->Draw();
1757
1758   TLegend* lege2=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1759   TLegendEntry* ent_a2=lege2->AddEntry(hfmuz50_1,"|#mu res z| < 10 #mum","PL"); // P: marker, L; line
1760   ent_a2->SetTextColor(hfmuz50_1->GetMarkerColor());
1761   TLegendEntry* ent_b2=lege2->AddEntry(hfmuz100_1,"|#mu res z| < 20 #mum","PL"); // P: marker, L; line
1762   ent_b2->SetTextColor(hfmuz100_1->GetMarkerColor());
1763   TLegendEntry* ent_c2=lege2->AddEntry(hfmuz300_1,"|#mu res z| < 50 #mum","PL"); // P: marker, L; line
1764   ent_c2->SetTextColor(hfmuz300_1->GetMarkerColor());
1765   lege2->SetFillStyle(0);
1766   lege2->Draw();
1767   //  c3->Update();
1768
1769   c5->cd(2);
1770   hfmuz50_2->SetTitle("fraction(| #mu z-residual | < threshold) - layer 2");
1771   hfmuz50_2->SetLineColor(2);
1772   hfmuz50_2->SetMarkerStyle(31);
1773   hfmuz50_2->SetMarkerSize(2);
1774   hfmuz50_2->SetMarkerColor(2);
1775   hfmuz50_2->SetMinimum(0.);
1776   hfmuz50_2->SetMaximum(1.2);
1777   hfmuz50_2->GetXaxis()->SetTitle("run number");
1778   hfmuz50_2->GetYaxis()->SetTitleOffset(1.2);
1779   //  hfmuz50_2->GetYaxis()->SetTitle("%");
1780   hfmuz50_2->Draw("P");
1781   hfmuz100_2->SetLineColor(4);
1782   hfmuz100_2->SetMarkerStyle(21);
1783   hfmuz100_2->SetMarkerColor(4);
1784   hfmuz100_2->Draw("same P");
1785   hfmuz300_2->SetLineColor(6);
1786   hfmuz300_2->SetMarkerStyle(22);
1787   hfmuz300_2->SetMarkerColor(6);
1788   hfmuz300_2->Draw("same P");
1789 //      l2->Draw();
1790
1791   TLegend* leggi2=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1792   TLegendEntry* en_ta2=leggi2->AddEntry(hfmuz50_2,"|#mu res z| < 10 #mum","PL"); // P: marker, L; line
1793   en_ta2->SetTextColor(hfmuz50_2->GetMarkerColor());
1794   TLegendEntry* en_tb2=leggi2->AddEntry(hfmuz100_2,"|#mu res z| < 20 #mum","PL"); // P: marker, L; line
1795   en_tb2->SetTextColor(hfmuz100_2->GetMarkerColor());
1796   TLegendEntry* en_tc2=leggi2->AddEntry(hfmuz300_2,"|#mu res z| < 50 #mum","PL"); // P: marker, L; line
1797   en_tc2->SetTextColor(hfmuz300_2->GetMarkerColor());
1798   leggi2->SetFillStyle(0);
1799   leggi2->Draw();
1800         c5->SaveAs("SPD_resz");
1801 //      pdfFileNames+=" SPD_resz";
1802   c5->Update();
1803
1804   //////////////////////////////////////////////// SSD ////////////////////////////////////////////////////
1805
1806  TCanvas* c6=new TCanvas("c6","SSD x residuals", 1200,800);
1807   c6->Divide(1,2);
1808   c6->cd(1);
1809   hfmux20_5->SetTitle("fraction(| #mu x-residual | < threshold) - layer 5");
1810   hfmux20_5->SetLineColor(2);
1811   hfmux20_5->SetMarkerStyle(31);
1812   hfmux20_5->SetMarkerSize(2);
1813   hfmux20_5->SetMarkerColor(2);
1814   hfmux20_5->SetMinimum(0.);
1815   hfmux20_5->SetMaximum(1.2);
1816   hfmux20_5->GetXaxis()->SetTitle("run number");
1817   hfmux20_5->GetYaxis()->SetTitleOffset(1.2);
1818   //  hfmux20_5->GetYaxis()->SetTitle("%");
1819   hfmux20_5->Draw("P");
1820   hfmux50_5->SetLineColor(4);
1821   hfmux50_5->SetMarkerStyle(21);
1822   hfmux50_5->SetMarkerColor(4);
1823   hfmux50_5->Draw("same P");
1824   hfmux100_5->SetLineColor(6);
1825   hfmux100_5->SetMarkerStyle(22);
1826   hfmux100_5->SetMarkerColor(6);
1827   hfmux100_5->Draw("same P");
1828         TLine *l5 = new TLine(0.,0.915,kRunsToPlot,0.915);
1829         l5->SetLineStyle(2);
1830         l5->SetLineWidth(2);    
1831 //      l5->Draw();
1832         
1833   TLegend* lege3=new TLegend(0.5,0.15,0.88,0.35); // x1, y1, x2, y2
1834   TLegendEntry* ent_a3=lege3->AddEntry(hfmux20_5,"|#mu res x| < 20 #mum","PL"); // P: marker, L; line
1835   ent_a3->SetTextColor(hfmux20_5->GetMarkerColor());
1836   TLegendEntry* ent_b3=lege3->AddEntry(hfmux50_5,"|#mu res x| < 40 #mum","PL"); // P: marker, L; line
1837   ent_b3->SetTextColor(hfmux50_5->GetMarkerColor());
1838   TLegendEntry* ent_c3=lege3->AddEntry(hfmux100_5,"|#mu res x| < 100 #mum","PL"); // P: marker, L; line
1839   ent_c3->SetTextColor(hfmux100_5->GetMarkerColor());
1840   lege3->SetFillStyle(0);
1841   lege3->Draw();
1842   //  c6->Update();
1843
1844   c6->cd(2);
1845   hfmux20_6->SetTitle("fraction(| #mu x-residual | < threshold) - layer 6");
1846   hfmux20_6->SetLineColor(2);
1847   hfmux20_6->SetMarkerStyle(31);
1848   hfmux20_6->SetMarkerSize(2);
1849   hfmux20_6->SetMarkerColor(2);
1850   hfmux20_6->SetMinimum(0.);
1851   hfmux20_6->SetMaximum(1.2);
1852   hfmux20_6->GetXaxis()->SetTitle("run number");
1853   hfmux20_6->GetYaxis()->SetTitleOffset(1.2);
1854   //  hfmux20_6->GetYaxis()->SetTitle("%");
1855   hfmux20_6->Draw("P");
1856   hfmux50_6->SetLineColor(4);
1857   hfmux50_6->SetMarkerStyle(21);
1858   hfmux50_6->SetMarkerColor(4);
1859   hfmux50_6->Draw("same P");
1860   hfmux100_6->SetLineColor(6);
1861   hfmux100_6->SetMarkerStyle(22);
1862   hfmux100_6->SetMarkerColor(6);
1863   hfmux100_6->Draw("same P");
1864         TLine *l6 = new TLine(0.,0.881,kRunsToPlot,0.881);
1865         l6->SetLineStyle(2);
1866         l6->SetLineWidth(2);    
1867 //      l6->Draw();
1868         
1869   TLegend* leggi3=new TLegend(0.5,0.15,0.88,0.35); // x1, y1, x2, y2
1870   TLegendEntry* en_ta3=leggi3->AddEntry(hfmux20_6,"|#mu res x| < 20 #mum","PL"); // P: marker, L; line
1871   en_ta3->SetTextColor(hfmux20_6->GetMarkerColor());
1872   TLegendEntry* en_tb3=leggi3->AddEntry(hfmux50_6,"|#mu res x| < 40 #mum","PL"); // P: marker, L; line
1873   en_tb3->SetTextColor(hfmux50_6->GetMarkerColor());
1874   TLegendEntry* en_tc3=leggi3->AddEntry(hfmux100_6,"|#mu res x| < 100 #mum","PL"); // P: marker, L; line
1875   en_tc3->SetTextColor(hfmux100_6->GetMarkerColor());
1876   leggi3->SetFillStyle(0);
1877   leggi3->Draw();
1878         c6->SaveAs("SSD_resx");
1879 //      pdfFileNames+=" SSD_resx";
1880   c6->Update();
1881
1882  TCanvas* c7=new TCanvas("c7","SSD z residuals", 1200,800);
1883   c7->Divide(1,2);
1884   c7->cd(1);
1885   hfmuz50_5->SetTitle("fraction(| #mu z-residual | < threshold) - layer 5");
1886   hfmuz50_5->SetLineColor(2);
1887   hfmuz50_5->SetMarkerStyle(31);
1888   hfmuz50_5->SetMarkerSize(2);
1889   hfmuz50_5->SetMarkerColor(2);
1890   hfmuz50_5->SetMinimum(0.);
1891   hfmuz50_5->SetMaximum(1.2);
1892   hfmuz50_5->GetXaxis()->SetTitle("run number");
1893   hfmuz50_5->GetYaxis()->SetTitleOffset(1.2);
1894   //  hfmuz50_5->GetYaxis()->SetTitle("%");
1895   hfmuz50_5->Draw("P");
1896   hfmuz100_5->SetLineColor(4);
1897   hfmuz100_5->SetMarkerStyle(21);
1898   hfmuz100_5->SetMarkerColor(4);
1899   hfmuz100_5->Draw("same P");
1900   hfmuz300_5->SetLineColor(6);
1901   hfmuz300_5->SetMarkerStyle(22);
1902   hfmuz300_5->SetMarkerColor(6);
1903   hfmuz300_5->Draw("same P");
1904 //      l5->Draw();
1905
1906   TLegend* lege4=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1907   TLegendEntry* ent_a4=lege4->AddEntry(hfmuz50_5,"|#mu res z| < 50 #mum","PL"); // P: marker, L; line
1908   ent_a4->SetTextColor(hfmuz50_5->GetMarkerColor());
1909   TLegendEntry* ent_b4=lege4->AddEntry(hfmuz100_5,"|#mu res z| < 100 #mum","PL"); // P: marker, L; line
1910   ent_b4->SetTextColor(hfmuz100_5->GetMarkerColor());
1911   TLegendEntry* ent_c4=lege4->AddEntry(hfmuz300_5,"|#mu res z| < 300 #mum","PL"); // P: marker, L; line
1912   ent_c4->SetTextColor(hfmuz300_5->GetMarkerColor());
1913   lege4->SetFillStyle(0);
1914   lege4->Draw();
1915   //  c7->Update();
1916
1917   c7->cd(2);
1918   hfmuz50_6->SetTitle("fraction(| #mu z-residual | < threshold) - layer 6");
1919   hfmuz50_6->SetLineColor(2);
1920   hfmuz50_6->SetMarkerStyle(31);
1921   hfmuz50_6->SetMarkerSize(2);
1922   hfmuz50_6->SetMarkerColor(2);
1923   hfmuz50_6->SetMinimum(0.);
1924   hfmuz50_6->SetMaximum(1.2);
1925   hfmuz50_6->GetXaxis()->SetTitle("run number");
1926   hfmuz50_6->GetYaxis()->SetTitleOffset(1.2);
1927   //  hfmuz50_6->GetYaxis()->SetTitle("%");
1928   hfmuz50_6->Draw("P");
1929   hfmuz100_6->SetLineColor(4);
1930   hfmuz100_6->SetMarkerStyle(21);
1931   hfmuz100_6->SetMarkerColor(4);
1932   hfmuz100_6->Draw("same P");
1933   hfmuz300_6->SetLineColor(6);
1934   hfmuz300_6->SetMarkerStyle(22);
1935   hfmuz300_6->SetMarkerColor(6);
1936   hfmuz300_6->Draw("same P");
1937 //      l6->Draw();
1938   TLegend* leggi4=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1939   TLegendEntry* en_ta4=leggi4->AddEntry(hfmuz50_6,"|#mu res z| < 50 #mum","PL"); // P: marker, L; line
1940   en_ta4->SetTextColor(hfmuz50_6->GetMarkerColor());
1941   TLegendEntry* en_tb4=leggi4->AddEntry(hfmuz100_6,"|#mu res z| < 100 #mum","PL"); // P: marker, L; line
1942   en_tb4->SetTextColor(hfmuz100_6->GetMarkerColor());
1943   TLegendEntry* en_tc4=leggi4->AddEntry(hfmuz300_6,"|#mu res z| < 300 #mum","PL"); // P: marker, L; line
1944   en_tc4->SetTextColor(hfmuz300_6->GetMarkerColor());
1945   leggi4->SetFillStyle(0);
1946   leggi4->Draw();
1947         c7->SaveAs("SSD_resz");
1948 //      pdfFileNames+=" SSD_resz";
1949   c7->Update();
1950   
1951
1952         // -------------------------- plot sigma --------------------------------------
1953         // -------------------------- SPD  x -------------------------------------
1954         
1955         TCanvas* c8=new TCanvas("c8","SPD x res width", 1200,800);
1956         c8->Divide(1,2);
1957         c8->cd(1);
1958         hfsigx100_1->SetTitle("fraction(#sigma x-residual < threshold) - layer 1");
1959         hfsigx100_1->SetLineColor(2);
1960         hfsigx100_1->SetMarkerStyle(31);
1961         hfsigx100_1->SetMarkerSize(2);
1962         hfsigx100_1->SetMarkerColor(2);
1963         hfsigx100_1->SetMinimum(0.);
1964         hfsigx100_1->SetMaximum(1.2);
1965         hfsigx100_1->GetXaxis()->SetTitle("run number");
1966         hfsigx100_1->GetYaxis()->SetTitleOffset(1.2);
1967         //  hfsigx100_1->GetYaxis()->SetTitle("%");
1968         hfsigx100_1->Draw("P");
1969         hfsigx200_1->SetLineColor(4);
1970         hfsigx200_1->SetMarkerStyle(21);
1971         hfsigx200_1->SetMarkerColor(4);
1972         hfsigx200_1->Draw("same P");
1973         hfsigx300_1->SetLineColor(6);
1974         hfsigx300_1->SetMarkerStyle(22);
1975         hfsigx300_1->SetMarkerColor(6);
1976         hfsigx300_1->Draw("same P");
1977 //      l1->Draw();
1978         
1979         TLegend* lege2s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
1980         TLegendEntry* ent_a2s=lege2s->AddEntry(hfsigx100_1,"|#sigma res x| < 50 #mum","PL"); // P: marker, L; line
1981         ent_a2s->SetTextColor(hfsigx100_1->GetMarkerColor());
1982         TLegendEntry* ent_b2s=lege2s->AddEntry(hfsigx200_1,"|#sigma res x| < 70 #mum","PL"); // P: marker, L; line
1983         ent_b2s->SetTextColor(hfsigx200_1->GetMarkerColor());
1984         TLegendEntry* ent_c2s=lege2s->AddEntry(hfsigx300_1,"|#sigma res x| < 200 #mum","PL"); // P: marker, L; line
1985         ent_c2s->SetTextColor(hfsigx300_1->GetMarkerColor());
1986         lege2s->SetFillStyle(0);
1987         lege2s->Draw();
1988         
1989         c8->cd(2);
1990         hfsigx100_2->SetTitle("fraction(#sigma x-residual < threshold) - layer 2");
1991         hfsigx100_2->SetLineColor(2);
1992         hfsigx100_2->SetMarkerStyle(31);
1993         hfsigx100_2->SetMarkerSize(2);
1994         hfsigx100_2->SetMarkerColor(2);
1995         hfsigx100_2->SetMinimum(0.);
1996         hfsigx100_2->SetMaximum(1.2);
1997         hfsigx100_2->GetXaxis()->SetTitle("run number");
1998         hfsigx100_2->GetYaxis()->SetTitleOffset(1.2);
1999         //  hfsigx100_2->GetYaxis()->SetTitle("%");
2000         hfsigx100_2->Draw("P");
2001         hfsigx200_2->SetLineColor(4);
2002         hfsigx200_2->SetMarkerStyle(21);
2003         hfsigx200_2->SetMarkerColor(4);
2004         hfsigx200_2->Draw("same P");
2005         hfsigx300_2->SetLineColor(6);
2006         hfsigx300_2->SetMarkerStyle(22);
2007         hfsigx300_2->SetMarkerColor(6);
2008         hfsigx300_2->Draw("same P");
2009 //      l2->Draw();
2010         
2011         TLegend* leggi2s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2012         TLegendEntry* en_ta2s=leggi2s->AddEntry(hfsigx100_2,"#sigma res x < 130 #mum","PL"); // P: marker, L; line
2013         en_ta2s->SetTextColor(hfsigx100_2->GetMarkerColor());
2014         TLegendEntry* en_tb2s=leggi2s->AddEntry(hfsigx200_2,"#sigma res x < 160 #mum","PL"); // P: marker, L; line
2015         en_tb2s->SetTextColor(hfsigx200_2->GetMarkerColor());
2016         TLegendEntry* en_tc2s=leggi2s->AddEntry(hfsigx300_2,"#sigma res x < 200 #mum","PL"); // P: marker, L; line
2017         en_tc2s->SetTextColor(hfsigx300_2->GetMarkerColor());
2018         leggi2s->SetFillStyle(0);
2019         leggi2s->Draw();
2020         c8->SaveAs("SPD_sigx");
2021 //      pdfFileNames+=" SPD_sigx";
2022         c8->Update();
2023         
2024         // -------------------------- SPD  z -------------------------------------
2025         
2026         TCanvas* c9=new TCanvas("c9","SPD z res width", 1200,800);
2027         c9->Divide(1,2);
2028         c9->cd(1);
2029         hfsigz100_1->SetTitle("fraction(#sigma z-residual < threshold) - layer 1");
2030         hfsigz100_1->SetLineColor(2);
2031         hfsigz100_1->SetMarkerStyle(31);
2032         hfsigz100_1->SetMarkerSize(2);
2033         hfsigz100_1->SetMarkerColor(2);
2034         hfsigz100_1->SetMinimum(0.);
2035         hfsigz100_1->SetMaximum(1.2);
2036         hfsigz100_1->GetXaxis()->SetTitle("run number");
2037         hfsigz100_1->GetYaxis()->SetTitleOffset(1.2);
2038         //  hfsigz100_1->GetYaxis()->SetTitle("%");
2039         hfsigz100_1->Draw("P");
2040         hfsigz300_1->SetLineColor(4);
2041         hfsigz300_1->SetMarkerStyle(21);
2042         hfsigz300_1->SetMarkerColor(4);
2043         hfsigz300_1->Draw("same P");
2044         hfsigz500_1->SetLineColor(6);
2045         hfsigz500_1->SetMarkerStyle(22);
2046         hfsigz500_1->SetMarkerColor(6);
2047         hfsigz500_1->Draw("same P");
2048 //      l1->Draw();
2049         TLegend* lege20s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2050         TLegendEntry* ent_a20s=lege20s->AddEntry(hfsigz100_1,"#sigma res z < 130 #mum","PL"); // P: marker, L; line
2051         ent_a20s->SetTextColor(hfsigz100_1->GetMarkerColor());
2052         TLegendEntry* ent_b20s=lege20s->AddEntry(hfsigz300_1,"#sigma res z < 160 #mum","PL"); // P: marker, L; line
2053         ent_b20s->SetTextColor(hfsigz300_1->GetMarkerColor());
2054         TLegendEntry* ent_c20s=lege20s->AddEntry(hfsigz500_1,"#sigma res z < 200 #mum","PL"); // P: marker, L; line
2055         ent_c20s->SetTextColor(hfsigz500_1->GetMarkerColor());
2056         lege20s->SetFillStyle(0);
2057         lege20s->Draw();
2058         
2059         c9->cd(2);
2060         hfsigz100_2->SetTitle("fraction(#sigma z-residual < threshold) - layer 2");
2061         hfsigz100_2->SetLineColor(2);
2062         hfsigz100_2->SetMarkerStyle(31);
2063         hfsigz100_2->SetMarkerSize(2);
2064         hfsigz100_2->SetMarkerColor(2);
2065         hfsigz100_2->SetMinimum(0.);
2066         hfsigz100_2->SetMaximum(1.2);
2067         hfsigz100_2->GetXaxis()->SetTitle("run number");
2068         hfsigz100_2->GetYaxis()->SetTitleOffset(1.2);
2069         //  hfsigz100_2->GetYaxis()->SetTitle("%");
2070         hfsigz100_2->Draw("P");
2071         hfsigz300_2->SetLineColor(4);
2072         hfsigz300_2->SetMarkerStyle(21);
2073         hfsigz300_2->SetMarkerColor(4);
2074         hfsigz300_2->Draw("same P");
2075         hfsigz500_2->SetLineColor(6);
2076         hfsigz500_2->SetMarkerStyle(22);
2077         hfsigz500_2->SetMarkerColor(6);
2078         hfsigz500_2->Draw("same P");
2079 //      l2->Draw();
2080         TLegend* leggi21s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2081         TLegendEntry* en_ta21s=leggi21s->AddEntry(hfsigz100_2,"#sigma res z < 180 #mum","PL"); // P: marker, L; line
2082         en_ta21s->SetTextColor(hfsigz100_2->GetMarkerColor());
2083         TLegendEntry* en_tb21s=leggi21s->AddEntry(hfsigz300_2,"#sigma res z < 190 #mum","PL"); // P: marker, L; line
2084         en_tb21s->SetTextColor(hfsigz300_2->GetMarkerColor());
2085         TLegendEntry* en_tc21s=leggi21s->AddEntry(hfsigz500_2,"#sigma res z < 250 #mum","PL"); // P: marker, L; line
2086         en_tc21s->SetTextColor(hfsigz500_2->GetMarkerColor());
2087         leggi21s->SetFillStyle(0);
2088         leggi21s->Draw();
2089         c9->SaveAs("SPD_sigz");
2090 //      pdfFileNames+=" SPD_sigz";
2091         c9->Update();
2092
2093         //---------------------------- SDD x ----------------------------------------
2094
2095         TCanvas* c10=new TCanvas("c10","SDD x res width", 1200,800);
2096         c10->Divide(1,2);
2097         c10->cd(1);
2098         hfsigx100_3->SetTitle("fraction(#sigma x-residual < threshold) - layer 3");
2099         hfsigx100_3->SetLineColor(2);
2100         hfsigx100_3->SetMarkerStyle(31);
2101         hfsigx100_3->SetMarkerSize(2);
2102         hfsigx100_3->SetMarkerColor(2);
2103         hfsigx100_3->SetMinimum(0.);
2104         hfsigx100_3->SetMaximum(1.2);
2105         hfsigx100_3->GetXaxis()->SetTitle("run number");
2106         hfsigx100_3->GetYaxis()->SetTitleOffset(1.2);
2107         //  hfsigx100_3->GetYaxis()->SetTitle("%");
2108         hfsigx100_3->Draw("P");
2109         hfsigx200_3->SetLineColor(4);
2110         hfsigx200_3->SetMarkerStyle(21);
2111         hfsigx200_3->SetMarkerColor(4);
2112         hfsigx200_3->Draw("same P");
2113         hfsigx300_3->SetLineColor(6);
2114         hfsigx300_3->SetMarkerStyle(22);
2115         hfsigx300_3->SetMarkerColor(6);
2116         hfsigx300_3->Draw("same P");
2117 //      l3->Draw();
2118         TLegend* lege22s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2119         TLegendEntry* ent_a22s=lege22s->AddEntry(hfsigx100_3,"#sigma res x < 200 #mum","PL"); // P: marker, L; line
2120         ent_a22s->SetTextColor(hfsigx100_3->GetMarkerColor());
2121         TLegendEntry* ent_b22s=lege22s->AddEntry(hfsigx200_3,"#sigma res x < 250 #mum","PL"); // P: marker, L; line
2122         ent_b22s->SetTextColor(hfsigx200_3->GetMarkerColor());
2123         TLegendEntry* ent_c22s=lege22s->AddEntry(hfsigx300_3,"#sigma res x < 400 #mum","PL"); // P: marker, L; line
2124         ent_c22s->SetTextColor(hfsigx300_3->GetMarkerColor());
2125         lege22s->SetFillStyle(0);
2126         lege22s->Draw();
2127         
2128         c10->cd(2);
2129         hfsigx100_4->SetTitle("fraction(#sigma x-residual < threshold) - layer 4");
2130         hfsigx100_4->SetLineColor(2);
2131         hfsigx100_4->SetMarkerStyle(31);
2132         hfsigx100_4->SetMarkerSize(2);
2133         hfsigx100_4->SetMarkerColor(2);
2134         hfsigx100_4->SetMinimum(0.);
2135         hfsigx100_4->SetMaximum(1.2);
2136         hfsigx100_4->GetXaxis()->SetTitle("run number");
2137         hfsigx100_4->GetYaxis()->SetTitleOffset(1.2);
2138         //  hfsigx100_4->GetYaxis()->SetTitle("%");
2139         hfsigx100_4->Draw("P");
2140         hfsigx200_4->SetLineColor(4);
2141         hfsigx200_4->SetMarkerStyle(21);
2142         hfsigx200_4->SetMarkerColor(4);
2143         hfsigx200_4->Draw("same P");
2144         hfsigx300_4->SetLineColor(6);
2145         hfsigx300_4->SetMarkerStyle(22);
2146         hfsigx300_4->SetMarkerColor(6);
2147         hfsigx300_4->Draw("same P");
2148 //      l4->Draw();
2149         TLegend* leggi23s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2150         TLegendEntry* en_ta23s=leggi23s->AddEntry(hfsigx100_4,"#sigma res x < 200 #mum","PL"); // P: marker, L; line
2151         en_ta23s->SetTextColor(hfsigx100_4->GetMarkerColor());
2152         TLegendEntry* en_tb23s=leggi23s->AddEntry(hfsigx200_4,"#sigma res x < 250 #mum","PL"); // P: marker, L; line
2153         en_tb23s->SetTextColor(hfsigx200_4->GetMarkerColor());
2154         TLegendEntry* en_tc23s=leggi23s->AddEntry(hfsigx300_4,"#sigma res x < 400 #mum","PL"); // P: marker, L; line
2155         en_tc23s->SetTextColor(hfsigx300_4->GetMarkerColor());
2156         leggi23s->SetFillStyle(0);
2157         leggi23s->Draw();
2158         c10->SaveAs("SDD_sigx");
2159 //      pdfFileNames+=" SDD_sigx";
2160         c10->Update();
2161         
2162         // -------------------------- SDD  z -------------------------------------
2163         
2164         TCanvas* c11=new TCanvas("c11","SDD z res width", 1200,800);
2165         c11->Divide(1,2);
2166         c11->cd(1);
2167         hfsigz100_3->SetTitle("fraction(#sigma z-residual < threshold) - layer 3");
2168         hfsigz100_3->SetLineColor(2);
2169         hfsigz100_3->SetMarkerStyle(31);
2170         hfsigz100_3->SetMarkerSize(2);
2171         hfsigz100_3->SetMarkerColor(2);
2172         hfsigz100_3->SetMinimum(0.);
2173         hfsigz100_3->SetMaximum(1.2);
2174         hfsigz100_3->GetXaxis()->SetTitle("run number");
2175         hfsigz100_3->GetYaxis()->SetTitleOffset(1.2);
2176         //  hfsigz100_3->GetYaxis()->SetTitle("%");
2177         hfsigz100_3->Draw("P");
2178         hfsigz300_3->SetLineColor(4);
2179         hfsigz300_3->SetMarkerStyle(21);
2180         hfsigz300_3->SetMarkerColor(4);
2181         hfsigz300_3->Draw("same P");
2182         hfsigz500_3->SetLineColor(6);
2183         hfsigz500_3->SetMarkerStyle(22);
2184         hfsigz500_3->SetMarkerColor(6);
2185         hfsigz500_3->Draw("same P");
2186 //      l3->Draw();
2187         TLegend* lege24s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2188         TLegendEntry* ent_a24s=lege24s->AddEntry(hfsigz100_3,"#sigma res z < 150 #mum","PL"); // P: marker, L; line
2189         ent_a24s->SetTextColor(hfsigz100_3->GetMarkerColor());
2190         TLegendEntry* ent_b24s=lege24s->AddEntry(hfsigz300_3,"#sigma res z < 200 #mum","PL"); // P: marker, L; line
2191         ent_b24s->SetTextColor(hfsigz300_3->GetMarkerColor());
2192         TLegendEntry* ent_c24s=lege24s->AddEntry(hfsigz500_3,"#sigma res z < 350 #mum","PL"); // P: marker, L; line
2193         ent_c24s->SetTextColor(hfsigz500_3->GetMarkerColor());
2194         lege24s->SetFillStyle(0);
2195         lege24s->Draw();
2196         
2197         c11->cd(2);
2198         hfsigz100_4->SetTitle("fraction(#sigma z-residual < threshold) - layer 4");
2199         hfsigz100_4->SetLineColor(2);
2200         hfsigz100_4->SetMarkerStyle(31);
2201         hfsigz100_4->SetMarkerSize(2);
2202         hfsigz100_4->SetMarkerColor(2);
2203         hfsigz100_4->SetMinimum(0.);
2204         hfsigz100_4->SetMaximum(1.2);
2205         hfsigz100_4->GetXaxis()->SetTitle("run number");
2206         hfsigz100_4->GetYaxis()->SetTitleOffset(1.2);
2207         //  hfsigz100_4->GetYaxis()->SetTitle("%");
2208         hfsigz100_4->Draw("P");
2209         hfsigz300_4->SetLineColor(4);
2210         hfsigz300_4->SetMarkerStyle(21);
2211         hfsigz300_4->SetMarkerColor(4);
2212         hfsigz300_4->Draw("same P");
2213         hfsigz500_4->SetLineColor(6);
2214         hfsigz500_4->SetMarkerStyle(22);
2215         hfsigz500_4->SetMarkerColor(6);
2216         hfsigz500_4->Draw("same P");
2217 //      l4->Draw();
2218         TLegend* leggi25s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2219         TLegendEntry* en_ta25s=leggi25s->AddEntry(hfsigz100_4,"#sigma res z < 250 #mum","PL"); // P: marker, L; line
2220         en_ta25s->SetTextColor(hfsigz100_4->GetMarkerColor());
2221         TLegendEntry* en_tb25s=leggi25s->AddEntry(hfsigz300_4,"#sigma res z < 300 #mum","PL"); // P: marker, L; line
2222         en_tb25s->SetTextColor(hfsigz300_4->GetMarkerColor());
2223         TLegendEntry* en_tc25s=leggi25s->AddEntry(hfsigz500_4,"#sigma res | < 450 #mum","PL"); // P: marker, L; line
2224         en_tc25s->SetTextColor(hfsigz500_4->GetMarkerColor());
2225         leggi25s->SetFillStyle(0);
2226         leggi25s->Draw();
2227         c11->SaveAs("SDD_sigz");
2228 //      pdfFileNames+=" SDD_sigz";
2229         c11->Update();
2230
2231         //---------------------------- SSD x ----------------------------------------
2232
2233         TCanvas* c12=new TCanvas("c12","SSD x res width", 1200,800);
2234         c12->Divide(1,2);
2235         c12->cd(1);
2236         hfsigx100_5->SetTitle("fraction(#sigma x-residual < threshold) - layer 5");
2237         hfsigx100_5->SetLineColor(2);
2238         hfsigx100_5->SetMarkerStyle(31);
2239         hfsigx100_5->SetMarkerSize(2);
2240         hfsigx100_5->SetMarkerColor(2);
2241         hfsigx100_5->SetMinimum(0.);
2242         hfsigx100_5->SetMaximum(1.2);
2243         hfsigx100_5->GetXaxis()->SetTitle("run number");
2244         hfsigx100_5->GetYaxis()->SetTitleOffset(1.2);
2245         //  hfsigx100_5->GetYaxis()->SetTitle("%");
2246         hfsigx100_5->Draw("P");
2247         hfsigx200_5->SetLineColor(4);
2248         hfsigx200_5->SetMarkerStyle(21);
2249         hfsigx200_5->SetMarkerColor(4);
2250         hfsigx200_5->Draw("same P");
2251         hfsigx300_5->SetLineColor(6);
2252         hfsigx300_5->SetMarkerStyle(22);
2253         hfsigx300_5->SetMarkerColor(6);
2254         hfsigx300_5->Draw("same P");
2255 //      l5->Draw();
2256         TLegend* lege26s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2257         TLegendEntry* ent_a26s=lege26s->AddEntry(hfsigx100_5,"#sigma res x < 70 #mum","PL"); // P: marker, L; line
2258         ent_a26s->SetTextColor(hfsigx100_5->GetMarkerColor());
2259         TLegendEntry* ent_b26s=lege26s->AddEntry(hfsigx200_5,"#sigma res x < 100 #mum","PL"); // P: marker, L; line
2260         ent_b26s->SetTextColor(hfsigx200_5->GetMarkerColor());
2261         TLegendEntry* ent_c26s=lege26s->AddEntry(hfsigx300_5,"#sigma res x < 300 #mum","PL"); // P: marker, L; line
2262         ent_c26s->SetTextColor(hfsigx300_5->GetMarkerColor());
2263         lege26s->SetFillStyle(0);
2264         lege26s->Draw();
2265         
2266         c12->cd(2);
2267         hfsigx100_6->SetTitle("fraction(#sigma x-residual < threshold) - layer 6");
2268         hfsigx100_6->SetLineColor(2);
2269         hfsigx100_6->SetMarkerStyle(31);
2270         hfsigx100_6->SetMarkerSize(2);
2271         hfsigx100_6->SetMarkerColor(2);
2272         hfsigx100_6->SetMinimum(0.);
2273         hfsigx100_6->SetMaximum(1.2);
2274         hfsigx100_6->GetXaxis()->SetTitle("run number");
2275         hfsigx100_6->GetYaxis()->SetTitleOffset(1.2);
2276         //  hfsigx100_6->GetYaxis()->SetTitle("%");
2277         hfsigx100_6->Draw("P");
2278         hfsigx200_6->SetLineColor(4);
2279         hfsigx200_6->SetMarkerStyle(21);
2280         hfsigx200_6->SetMarkerColor(4);
2281         hfsigx200_6->Draw("same P");
2282         hfsigx300_6->SetLineColor(6);
2283         hfsigx300_6->SetMarkerStyle(22);
2284         hfsigx300_6->SetMarkerColor(6);
2285         hfsigx300_6->Draw("same P");
2286 //      l6->Draw();
2287         TLegend* leggi27s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2288         TLegendEntry* en_ta27s=leggi27s->AddEntry(hfsigx100_6,"#sigma res x < 200 #mum","PL"); // P: marker, L; line
2289         en_ta27s->SetTextColor(hfsigx100_6->GetMarkerColor());
2290         TLegendEntry* en_tb27s=leggi27s->AddEntry(hfsigx200_6,"#sigma res x < 300 #mum","PL"); // P: marker, L; line
2291         en_tb27s->SetTextColor(hfsigx200_6->GetMarkerColor());
2292         TLegendEntry* en_tc27s=leggi27s->AddEntry(hfsigx300_6,"#sigma res x < 400 #mum","PL"); // P: marker, L; line
2293         en_tc27s->SetTextColor(hfsigx300_6->GetMarkerColor());
2294         leggi27s->SetFillStyle(0);
2295         leggi27s->Draw();
2296         c12->SaveAs("SSD_sigx");
2297 //      pdfFileNames+=" SSD_sigx";
2298         c12->Update();
2299         
2300         // -------------------------- SSD  z -------------------------------------
2301         
2302         TCanvas* c13=new TCanvas("c13","SSD z res width", 1200,800);
2303         c13->Divide(1,2);
2304         c13->cd(1);
2305         hfsigz100_5->SetTitle("fraction(#sigma z-residual < threshold) - layer 5");
2306         hfsigz100_5->SetLineColor(2);
2307         hfsigz100_5->SetMarkerStyle(31);
2308         hfsigz100_5->SetMarkerSize(2);
2309         hfsigz100_5->SetMarkerColor(2);
2310         hfsigz100_5->SetMinimum(0.);
2311         hfsigz100_5->SetMaximum(1.2);
2312         hfsigz100_5->GetXaxis()->SetTitle("run number");
2313         hfsigz100_5->GetYaxis()->SetTitleOffset(1.2);
2314         //  hfsigz100_5->GetYaxis()->SetTitle("%");
2315         hfsigz100_5->Draw("P");
2316         hfsigz300_5->SetLineColor(4);
2317         hfsigz300_5->SetMarkerStyle(21);
2318         hfsigz300_5->SetMarkerColor(4);
2319         hfsigz300_5->Draw("same P");
2320         hfsigz500_5->SetLineColor(6);
2321         hfsigz500_5->SetMarkerStyle(22);
2322         hfsigz500_5->SetMarkerColor(6);
2323         hfsigz500_5->Draw("same P");
2324 //      l5->Draw();
2325         TLegend* lege28s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2326         TLegendEntry* ent_a28s=lege28s->AddEntry(hfsigz100_5,"#sigma res z < 1000 #mum","PL"); // P: marker, L; line
2327         ent_a28s->SetTextColor(hfsigz100_5->GetMarkerColor());
2328         TLegendEntry* ent_b28s=lege28s->AddEntry(hfsigz300_5,"#sigma res z < 1100 #mum","PL"); // P: marker, L; line
2329         ent_b28s->SetTextColor(hfsigz300_5->GetMarkerColor());
2330         TLegendEntry* ent_c28s=lege28s->AddEntry(hfsigz500_5,"#sigma res z < 1500 #mum","PL"); // P: marker, L; line
2331         ent_c28s->SetTextColor(hfsigz500_5->GetMarkerColor());
2332         lege28s->SetFillStyle(0);
2333         lege28s->Draw();
2334         
2335         c13->cd(2);
2336         hfsigz100_6->SetTitle("fraction(#sigma z-residual < threshold) - layer 6");
2337         hfsigz100_6->SetLineColor(2);
2338         hfsigz100_6->SetMarkerStyle(31);
2339         hfsigz100_6->SetMarkerSize(2);
2340         hfsigz100_6->SetMarkerColor(2);
2341         hfsigz100_6->SetMinimum(0.);
2342         hfsigz100_6->SetMaximum(1.2);
2343         hfsigz100_6->GetXaxis()->SetTitle("run number");
2344         hfsigz100_6->GetYaxis()->SetTitleOffset(1.2);
2345         //  hfsigz100_6->GetYaxis()->SetTitle("%");
2346         hfsigz100_6->Draw("P");
2347         hfsigz300_6->SetLineColor(4);
2348         hfsigz300_6->SetMarkerStyle(21);
2349         hfsigz300_6->SetMarkerColor(4);
2350         hfsigz300_6->Draw("same P");
2351         hfsigz500_6->SetLineColor(6);
2352         hfsigz500_6->SetMarkerStyle(22);
2353         hfsigz500_6->SetMarkerColor(6);
2354         hfsigz500_6->Draw("same P");
2355 //      l6->Draw();
2356         TLegend* leggi29s=new TLegend(0.5,0.80,0.88,1.00); // x1, y1, x2, y2
2357         TLegendEntry* en_ta29s=leggi29s->AddEntry(hfsigz100_6,"#sigma res z < 1000 #mum","PL"); // P: marker, L; line
2358         en_ta29s->SetTextColor(hfsigz100_6->GetMarkerColor());
2359         TLegendEntry* en_tb29s=leggi29s->AddEntry(hfsigz300_6,"#sigma res z < 1100 #mum","PL"); // P: marker, L; line
2360         en_tb29s->SetTextColor(hfsigz300_6->GetMarkerColor());
2361         TLegendEntry* en_tc29s=leggi29s->AddEntry(hfsigz500_6,"#sigma res z  < 1500 #mum","PL"); // P: marker, L; line
2362         en_tc29s->SetTextColor(hfsigz500_6->GetMarkerColor());
2363         leggi29s->SetFillStyle(0);
2364         leggi29s->Draw();
2365         c13->SaveAs("SSD_sigz");
2366 //      pdfFileNames+=" SSD_sigz";
2367         c13->Update();
2368   
2369    // order pdf files
2370         pdfFileNames+=" SPD_resx";
2371         pdfFileNames+=" SPD_sigx";
2372         pdfFileNames+=" SPD_resz";
2373         pdfFileNames+=" SPD_sigz";
2374         pdfFileNames+=" SDD_resx_L3";
2375         pdfFileNames+=" SDD_resx_L4";
2376         pdfFileNames+=" SDD_sigx";
2377         pdfFileNames+=" SDD_resz";
2378         pdfFileNames+=" SDD_sigz";
2379         pdfFileNames+=" SSD_resx";
2380         pdfFileNames+=" SSD_sigx";
2381         pdfFileNames+=" SSD_resz";
2382         pdfFileNames+=" SSD_sigz";
2383         
2384    // merge the pdf files
2385   TString command("gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged");
2386   command=command+"ITS_Align_trend_norm.pdf "+pdfFileNames;
2387   gSystem->Exec(command.Data());
2388   printf(" Merging the pdf file:  %s \n",command.Data());
2389   delete [] myIndex;
2390   delete [] noRuns;
2391
2392 }