Modifications to ITS standalone tracker: 1) improve efficiency at low pt for p-p...
[u/mrichter/AliRoot.git] / HMPID / Hshuttle.C
1 void Hshuttle(Int_t runTime=1500)
2 {// this macro is to simulate the functionality of SHUTTLE.
3   gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
4 //  AliTestShuttle::SetMainCDB(TString("local://$HOME/CDB"));
5 //  AliTestShuttle::SetMainCDB(TString("local://$HOME"));
6   AliTestShuttle::SetMainCDB(TString("local://$ALICE_ROOT"));
7   
8   TMap *pDcsMap = new TMap;       pDcsMap->SetOwner(1);          //DCS archive map
9   
10   AliTestShuttle* pShuttle = new AliTestShuttle(0,0,1000000);   
11 //  pShuttle->SetInputRunType("PHYSICS");
12 //  pShuttle->SetInputRunType("CALIBRATION");
13   pShuttle->SetInputRunType("PHYSICS");
14   SimPed();   
15   for(Int_t ldc=51;ldc<=52;ldc++) 
16   {
17    if(ldc==51) {for(Int_t iddl=0;iddl<=7;iddl++)  pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP",Form("HmpidPedDdl%02i.txt",iddl),Form("LDC%i",ldc),Form("HmpidPedDdl%02i.txt",iddl));}
18    if(ldc==52) {for(Int_t iddl=8;iddl<=13;iddl++) pShuttle->AddInputFile(AliTestShuttle::kDAQ,"HMP",Form("HmpidPedDdl%02i.txt",iddl),Form("LDC%i",ldc),Form("HmpidPedDdl%02i.txt",iddl));}
19   }
20   SimMap(pDcsMap,runTime); pShuttle->SetDCSInput(pDcsMap);                                    //DCS map
21   
22   AliPreprocessor* pp = new AliHMPIDPreprocessor(pShuttle); pShuttle->Process();              //here goes preprocessor  
23 //  delete pp;   
24
25   DrawInput(pDcsMap); DrawOutput();
26   gSystem->Exec("rm -rf HmpidPedDdl*.txt");
27
28 }//Hshuttle()
29 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 void SimPed()
31 {
32   Int_t iDDLmin=0,iDDLmax=13;
33   Int_t nSigmas = 3;                                            // value stored in the ddl files of pedestals
34   ofstream out;
35   for(Int_t ddl=iDDLmin;ddl<=iDDLmax;ddl++){
36     out.open(Form("HmpidPedDdl%02i.txt",ddl));
37     out << Form("%8s %2d\n","RunNumber",      999);             //read run number
38     out << Form("%8s %2d\n","LdcId" ,         999);             //read LDC Id
39     out << Form("%8s %2d\n","TimeStamp",      999);             //read time stamp
40     out << Form("%8s %2d\n","TotNumEvt",      999);             //read number of total events processed
41     out << Form("%8s %2d\n","TotDDLEvt",      999);             //read number of bad events for DDL # nDDL processed
42     out << Form("%8s %2d\n","NumBadEvt",      999);             //read number of bad events for DDL # nDDL processed
43     out << Form("%8s %2f\n","NBadE(%)",       999.9);           //read number of bad events (in %) for DDL # nDDL processed
44     out << Form("%8s %2.2d\n","SigCut",      nSigmas);          //# of sigma cuts
45     for(Int_t row=1;row<=24;row++)
46       for(Int_t dil=1;dil<=10;dil++)
47         for(Int_t adr=0;adr<=47;adr++){
48           Float_t mean  = 150+200*gRandom->Rndm();
49           Float_t sigma = 1+0.3*gRandom->Gaus();
50           Int_t inhard=((Int_t(mean+nSigmas*sigma))<<9)+Int_t(mean); //right calculation, xchecked with Paolo 8/4/2008
51           out << Form("%2i %2i %2i %5.3f %5.3f %4.4x \n",row,dil,adr,mean,sigma,inhard);
52         }
53
54     out.close();
55   }
56   Printf("HMPID - All %i DDL pedestal files created successfully",iDDLmax-iDDLmin+1);
57 }
58 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59 void SimMap(TMap *pDcsMap,Int_t runTime=1500)
60 {
61   Int_t stepTime=100; //time interval between measurements
62   Int_t startTime=0;
63
64  // phototube current (microAmper)
65  
66   Float_t aArgonCell[] = {2.392914534,1.052269816,0.426667392,0.266823828,0.230182067,0.237871274,0.273670882,0.321822613,0.386860102,0.467150569,0.542086422,0.587703943,0.620307803,0.64317745,0.654298306,0.65143925,0.668053627,0.687757671,0.705103695,0.734520793,0.757498145,0.795069814,0.830174983,0.863526344,0.907381952,0.957449734,0.983424425,1.016224384,1.041821599,1.059507251};
67
68   Float_t aArgonRef[] = {1.149247766,0.496981889,0.186563596,0.10783793,0.085225783,0.084287018,0.095322073,0.109832592,0.130130395,0.157257095,0.180872142,0.196021155,0.205875158,0.212933287,0.217398748,0.218543261,0.223784506,0.233313993,0.243647426,0.254273385,0.270319641,0.288991749,0.310744852,0.333126128,0.359347552,0.383723944,0.412809372,0.432352483,0.455913931,0.477137864}; 
69
70
71   Float_t aFreonCell[] = {0.000104553,0.00011161,0.0002890787,0.0002893622,0.00025613,0.020953063,0.068830326,0.127829805,0.193517566,0.273626387,0.35040611,0.41024375,0.45290783,0.492588729,0.522967756,0.552341878,0.582529366,0.615325809,0.647942483,0.683176041,0.721948683,0.7626279,0.804566145,0.847852349,0.891971886,0.937028468,0.977787018,1.017553926,1.050016046,1.078630805}; 
72
73
74   Float_t aFreonRef[] = {1.125558376,0.475898296,0.178687423,0.100295901,0.078788362,0.077350542,0.087279864,0.101818182,0.121531218,0.147556156,0.170467392,0.184769839,0.194379449,0.202385217,0.209258303,0.215506181,0.222740307,0.231011033,0.241791919,0.253416091,0.2687684,0.286887407,0.310744882,0.332763016,0.356916934,0.383346796,0.409290999,0.433670729,0.454144865,0.474498451};
75
76   TObjArray *pWaveLenght[30], *pArgonCell[30], *pArgonRef[30], *pFreonCell[30], *pFreonRef[30];
77
78   for(Int_t i=0; i<30; i++){
79       
80       pWaveLenght[i] = new TObjArray; pWaveLenght[i]->SetOwner(1);
81       pArgonCell[i]  = new TObjArray; pArgonCell[i]->SetOwner(1);
82       pArgonRef[i]   = new TObjArray; pArgonRef[i]->SetOwner(1);
83       pFreonCell[i]  = new TObjArray; pFreonCell[i]->SetOwner(1);
84       pFreonRef[i]   = new TObjArray; pFreonRef[i]->SetOwner(1);
85
86       pWaveLenght[i]->Add(new AliDCSValue((Float_t)(160+2*i),0));        // wavelenght (nm)
87       pArgonCell[i]->Add(new AliDCSValue((Float_t)(aArgonCell[i]),0));
88       pArgonRef[i]->Add(new AliDCSValue((Float_t)(aArgonRef[i]),0));
89       pFreonRef[i]->Add(new AliDCSValue((Float_t)(aFreonRef[i]),0));
90       pFreonCell[i]->Add(new AliDCSValue((Float_t)(aFreonCell[i]),0));     
91
92
93       pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_INFR/HMP_INFR_TRANPLANT/HMP_INFR_TRANPLANT_MEASURE.mesure%i.waveLenght",i)),pWaveLenght[i]);
94       pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_INFR/HMP_INFR_TRANPLANT/HMP_INFR_TRANPLANT_MEASURE.mesure%i.argonCell",i)),pArgonCell[i]);
95       pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_INFR/HMP_INFR_TRANPLANT/HMP_INFR_TRANPLANT_MEASURE.mesure%i.argonReference",i)),pArgonRef[i]);
96       pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_INFR/HMP_INFR_TRANPLANT/HMP_INFR_TRANPLANT_MEASURE.mesure%i.c6f14Cell",i)),pFreonCell[i]);
97       pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_INFR/HMP_INFR_TRANPLANT/HMP_INFR_TRANPLANT_MEASURE.mesure%i.c6f14Reference",i)),pFreonRef[i]);    
98      }
99   
100   TObjArray *pHV[7];
101   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
102     TObjArray *pPCH4=new TObjArray;  pPCH4->SetOwner(1);
103     TObjArray *pPenv=new TObjArray;  pPenv->SetOwner(1);
104     pHV[iCh]=new TObjArray; pHV[iCh]->SetOwner(1);
105     for(Int_t time=0;time<runTime;time+=stepTime) {
106        pPCH4->Add(new AliDCSValue((Float_t)4.0,time));               //sample CH4 pressure [mBar] differential respect to atm
107        pPenv->Add(new AliDCSValue((Float_t)1000.0 ,time));               //also atm. pressure set to the same value
108 //       pHV[iCh]->Add(new AliDCSValue((Float_t)(1930+iCh*20),time));   //sample chamber HV [V]
109        pHV[iCh]->Add(new AliDCSValue((Float_t)(2050),time));   //sample chamber HV [V]
110     }
111     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWPC.actual.value"           ,iCh,iCh,iCh    )),pPCH4);         //CH4 pressure wrt atm
112     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_ENV/HMP_ENV_PENV.actual.value"                                               )),pPenv);         //atm pressure
113     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC0/HMP_MP%i_SEC0_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]);      //HV SEC0
114     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC1/HMP_MP%i_SEC1_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]);      //HV SEC1
115     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC2/HMP_MP%i_SEC2_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]);      //HV SEC2 
116     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC3/HMP_MP%i_SEC3_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]);      //HV SEC3 
117     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC4/HMP_MP%i_SEC4_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]);      //HV SEC4 
118     pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC5/HMP_MP%i_SEC5_HV.actual.vMon",iCh,iCh,iCh,iCh)),pHV[iCh]);      //HV SEC5 
119
120     for(Int_t iRad=0;iRad<3;iRad++){//radiators loop
121       TObjArray *pT1=new TObjArray; pT1->SetOwner(1);
122       TObjArray *pT2=new TObjArray; pT2->SetOwner(1);
123       for (Int_t time=0;time<runTime;time+=stepTime)  pT1->Add(new AliDCSValue((Float_t)(13.0+gRandom->Rndm()),time));  //sample inlet temperature                    Nmean=1.292 @ 13 degrees
124       for (Int_t time=0;time<runTime;time+=stepTime)  pT2->Add(new AliDCSValue((Float_t)(18.0+gRandom->Rndm()),time));  //sample outlet temperature
125       pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp",iCh,iCh,iRad)) ,pT1);               //Temperature in  Rad 
126       pDcsMap->Add(new TObjString(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp",iCh,iCh,iRad)),pT2);               //Temperature out Rad
127     }//radiators loop
128   }//chambers loop
129 }//SimMap()
130 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
131 void DrawInput(TMap *pDcsMap)
132 {
133   
134   TCanvas *c=new TCanvas("cc","Input data",800,800); c->Divide(3,3);
135   
136   AliDCSValue *pVal; Int_t cnt;
137   
138   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
139     if(iCh==6) c->cd(1);  if(iCh==5) c->cd(2);                          
140     if(iCh==4) c->cd(4);  if(iCh==3) c->cd(5);  if(iCh==2) c->cd(6);
141                           if(iCh==1) c->cd(8);  if(iCh==0) c->cd(9); 
142                           
143     TObjArray *pHV=(TObjArray*)pDcsMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_PW/HMP_MP%i_SEC0/HMP_MP%i_SEC0_HV.actual.vMon",iCh,iCh,iCh,iCh)); //HV
144     TObjArray *pP =(TObjArray*)pDcsMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_GAS/HMP_MP%i_GAS_PMWC.actual.value",iCh,iCh,iCh)); //P
145     TGraph *pGrHV=new TGraph; pGrHV->SetMarkerStyle(5); TIter nextHV(pHV);
146     TGraph *pGrP =new TGraph; pGrP ->SetMarkerStyle(5); TIter nextP (pP );
147     
148     for(Int_t iRad=0;iRad<3;iRad++){
149       TObjArray *pT1=(TObjArray*)pDcsMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iIn_Temp",iCh,iCh,iRad));  TIter nextT1(pT1);
150       TObjArray *pT2=(TObjArray*)pDcsMap->GetValue(Form("HMP_DET/HMP_MP%i/HMP_MP%i_LIQ_LOOP.actual.sensors.Rad%iOut_Temp",iCh,iCh,iRad)); TIter nextT2(pT2);
151       TGraph *pGrT1=new TGraph; pGrT1->SetMarkerStyle(5); 
152       TGraph *pGrT2=new TGraph; pGrT2->SetMarkerStyle(5); 
153       pGrT1->SetMaximum(40);
154       pGrT2->SetMaximum(40);
155       cnt=0; while((pVal=(AliDCSValue*)nextT1())) pGrT1->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
156       cnt=0; while((pVal=(AliDCSValue*)nextT2())) pGrT2->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());
157       if(iRad==0) pGrT1->Draw("AP"); else pGrT1->Draw("same");
158       pGrT2->Draw("same");
159     }//radiators loop
160   }//chambers loop  
161 }//DrawInput()
162 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
163 void DrawOutput()
164 {
165   AliCDBManager::Instance()->SetDefaultStorage("local://$HOME"); AliCDBManager::Instance()->SetRun(0);
166   AliCDBEntry *pQthreEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Qthre");
167   AliCDBEntry *pNmeanEnt =AliCDBManager::Instance()->Get("HMPID/Calib/Nmean");
168   AliCDBEntry *pDaqSigEnt=AliCDBManager::Instance()->Get("HMPID/Calib/DaqSig");
169   
170   if(!pQthreEnt || !pNmeanEnt || !pDaqSigEnt) return;
171   
172   TObjArray *pNmean =(TObjArray*)pNmeanEnt ->GetObject(); 
173   TObjArray *pQthre =(TObjArray*)pQthreEnt ->GetObject(); 
174   TObjArray *pDaqSig=(TObjArray*)pDaqSigEnt->GetObject();
175    
176   TF1 *pRad0,*pRad1,*pRad2;  
177   TCanvas *c2=new TCanvas("c2","Output",800,800); c2->Divide(3,3);
178   
179   TH1F *pSig[7];
180   
181   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
182     TMatrix *pM=(TMatrix*)pDaqSig->At(iCh);
183     
184     pSig[iCh]=new TH1F(Form("sig%i",iCh),"Sigma;[QDC]",100,-5,20); //pSig[iCh]->SetLineColor(iCh+kRed);
185     for(Int_t padx=0;padx<160;padx++) for(Int_t pady=0;pady<144;pady++) pSig[iCh]->Fill((*pM)(padx,pady));
186     
187     c2->cd(7);    if(iCh==0) pSig[iCh]->Draw(); else pSig[iCh]->Draw("same");
188     
189     if(iCh==6) c2->cd(1);  if(iCh==5) c2->cd(2);                          
190     if(iCh==4) c2->cd(4);  if(iCh==3) c2->cd(5);  if(iCh==2) c2->cd(6);
191                            if(iCh==1) c2->cd(8);  if(iCh==0) c2->cd(9); 
192                           
193     TF1 *pRad0=(TF1*)pNmean->At(iCh*3+0); pRad0->Draw();  pRad0->GetXaxis()->SetTimeDisplay(kTRUE); pRad0->GetYaxis()->SetRangeUser(1.28,1.3);
194     TF1 *pRad1=(TF1*)pNmean->At(iCh*3+1); pRad1->Draw("same");
195     TF1 *pRad2=(TF1*)pNmean->At(iCh*3+2); pRad2->Draw("same");
196   }//chambers loop    
197 }//DrawOutput()
198 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++