]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/Hshuttle.C
Correct the comments
[u/mrichter/AliRoot.git] / HMPID / Hshuttle.C
1 void Hshuttle(Int_t runTime=1500)
2 {
3 // this macro is to simulate the functionality of SHUTTLE.
4 // Here the list of DCS aliases is created and packed in TMap of structure "alias name" - TObjArray of AliDCSValue; AliDCSValue is a pair value-time stamp     
5 // currently simulated: freon temperature 2 per radiator (inlet,outlet)
6 //                      methane pressure 1 per chamber   
7   gSystem->Load("libTestShuttle.so");
8   
9   AliTestShuttle::SetMainCDB(TString("local://$HOME"));
10   
11   TMap        *pDcsMap = new TMap;       pDcsMap->SetOwner(1);          //DCS archive map
12
13   SimMap(pDcsMap,runTime);
14   TestShuttle(pDcsMap);  
15   TCanvas *c=new TCanvas("cc","ff",600,600);  
16   DrawInput(c,pDcsMap);
17   DrawOutput();
18 }//Hshuttle()
19 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20 void SimMap(TMap *pDcsMap,Int_t runTime=1500)
21 {
22   Int_t stepTime=100; //time interval between mesuraments
23   Int_t startTime=0;
24   
25   
26   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
27     TObjArray *pP=new TObjArray;  pP->SetOwner(1);
28     TObjArray *pHV=new TObjArray; pHV->SetOwner(1); 
29     for(Int_t time=0;time<runTime;time+=stepTime)  pP->Add(new AliDCSValue((Float_t)1005.0 ,time));   //sample CH4 pressure [mBar]
30                                                    pHV->Add(new AliDCSValue((Float_t)2010.0,time));   //sample chamber HV [V]
31       
32     pDcsMap->Add(new TObjString(Form(AliHMPIDPreprocessor::fP,iCh,iCh,iCh)),pP); 
33     pDcsMap->Add(new TObjString(Form(AliHMPIDPreprocessor::fHV,iCh,iCh,iCh)),pHV); 
34         
35     for(Int_t iRad=0;iRad<3;iRad++){//radiators loop
36       TObjArray *pT1=new TObjArray; pT1->SetOwner(1); 
37       TObjArray *pT2=new TObjArray; pT2->SetOwner(1); 
38       for (Int_t time=0;time<runTime;time+=stepTime)  pT1->Add(new AliDCSValue(13,time));  //sample inlet temperature    Nmean=1.292 @ 13 degrees
39       for (Int_t time=0;time<runTime;time+=stepTime)  pT2->Add(new AliDCSValue(13,time));  //sample outlet temperature
40       pDcsMap->Add(new TObjString(Form(AliHMPIDPreprocessor::fT1,iCh,iCh,iRad)) ,pT1); 
41       pDcsMap->Add(new TObjString(Form(AliHMPIDPreprocessor::fT2,iCh,iCh,iRad)),pT2);
42     }//radiators loop    
43   }//chambers loop
44 }//SimMap()
45 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46 void TestShuttle(TMap *pDcsMap)
47 {
48   AliTestShuttle* pShuttle = new AliTestShuttle(0,0,1000000);   
49   pShuttle->SetDCSInput(pDcsMap);                                                    //DCS map
50   AliPreprocessor* pp = new AliHMPIDPreprocessor(pShuttle);                           //actual ipreprocessor is created here
51   pShuttle->Process();                                                               //run SHUTTLE simulator
52   delete pp;
53 }
54 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55 void DrawInput(TCanvas *c,TMap *pDcsMap)
56 {
57   c->Divide(3,3);
58   
59   AliDCSValue *pVal; Int_t cnt=0;
60   
61   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
62     if(iCh==6) c->cd(1);  if(iCh==5) c->cd(2);                          
63     if(iCh==4) c->cd(4);  if(iCh==3) c->cd(5);  if(iCh==2) c->cd(6);
64                           if(iCh==1) c->cd(8);  if(iCh==0) c->cd(9); 
65                           
66     TObjArray *pHV=(TObjArray*)pDcsMap->GetValue(Form(AliHMPIDPreprocessor::fHV,iCh,iCh,iCh,iCh)); //HV
67     TObjArray *pP =(TObjArray*)pDcsMap->GetValue(Form(AliHMPIDPreprocessor::fP,iCh,iCh,iCh)); //P
68     TGraph *pGr=new TGraph; pGr->SetMarkerStyle(5);
69     
70     TIter nextp(pP); cnt=0; while((pVal=(AliDCSValue*)nextp())){ pGr->SetPoint(cnt++,pVal->GetTimeStamp(),pVal->GetFloat());}//P
71
72     
73     pGr->Draw("AP");
74   }  
75 }
76 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
77 void DrawOutput()
78 {
79   AliCDBManager::Instance()->SetDefaultStorage("local://$HOME");
80   AliCDBEntry *pQthreEnt=AliCDBManager::Instance()->Get("HMPID/Calib/Qthre",0);
81   AliCDBEntry *pNmeanEnt=AliCDBManager::Instance()->Get("HMPID/Calib/Nmean",0);
82   
83   if(!pQthreEnt || ! pNmeanEnt) return;
84   
85   TObjArray *pNmean=(TObjArray*)pNmeanEnt->GetObject(); 
86   TObjArray *pQthre=(TObjArray*)pQthreEnt->GetObject(); 
87   
88   TF1 *pRad0,*pRad1,*pRad2;  
89   TCanvas *c2=new TCanvas("c2","Nmean"); c2->Divide(3,3);
90   
91   
92   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
93     if(iCh==6) c2->cd(1);  if(iCh==5) c2->cd(2);                          
94     if(iCh==4) c2->cd(4);  if(iCh==3) c2->cd(5);  if(iCh==2) c2->cd(6);
95                            if(iCh==1) c2->cd(8);  if(iCh==0) c2->cd(9); 
96                           
97     TF1 *pRad0=(TF1*)pNmean->At(iCh*3+0); pRad0->Draw();  pRad0->GetXaxis()->SetTimeDisplay(kTRUE); pRad0->GetYaxis()->SetRangeUser(1.28,1.3);
98     TF1 *pRad1=(TF1*)pNmean->At(iCh*3+1); pRad1->Draw("same");
99     TF1 *pRad2=(TF1*)pNmean->At(iCh*3+2); pRad2->Draw("same");
100   }//chambers loop  
101 }