81 #include "TEntryList.h"
83 #include "TStatToolkit.h"
89 #include "TStopwatch.h"
107 TString
tcor(
"-pulCorr");
188 TVectorD vec0,vec1,vec2;
190 TString fitvar=
"P_T.fElements";
191 TCut out(
"abs(P_T.fElements/P_T_Mean.fElements-1.001)<.002");
192 TCut fitadd(
"P_T.fElements>446");
194 fstring+=
"(sector>=0&§or<9)++";
195 fstring+=
"(sector>=9&§or<18)++";
196 fstring+=
"(sector>=18&§or<27)++";
197 fstring+=
"(sector>=27&§or<36)++";
198 fstring+=
"(sector>=36&§or<45)++";
199 fstring+=
"(sector>=45&§or<54)++";
200 fstring+=
"(sector>=54&§or<63)++";
201 fstring+=
"(sector>=63&§or<72)";
203 TString *pulOff =stat.FitPlane(
tree,fitvar.Data(),fstring.Data(),(out+fitadd).GetTitle(),
chi2,
npoints,vec0,
mat);
205 tree->SetAlias(
"pul0",pulOff->Data());
206 tree->SetAlias(
"pulCorr",
"P_T.fElements-pul0");
207 tree->SetAlias(
"pulOut",out.GetTitle());
233 fstring+=
"(side*inn)++";
236 fstring+=
"(side*gyr)++";
238 fstring+=
"(side*gxr)++";
243 fstring+=
"(side*lxr)++";
244 fstring+=
"(inn*lxr)++";
245 fstring+=
"(side*inn*lxr)++";
246 fstring+=
"(lxr^2)++";
247 fstring+=
"(side*lxr^2)++";
248 fstring+=
"(inn*lxr^2)++";
249 fstring+=
"(inn*side*lxr^2)++";
253 tree->SetAlias(
"f0",fit0->Data());
256 printf(
"Chi2/npoints\t=%f\n",TMath::Sqrt(chi2/npoints));
257 fit0->Tokenize(
"++")->Print();
259 printf(
"Global tendencies extraction\n");
263 TString tmpstr = fstring;
267 TString fitInOut(
"0");
277 for(Int_t i=0;i<arr->GetEntriesFast();i++){
278 if (!arr->At(i))
continue;
279 TString *fitstr =
new TString(arr->At(i)->GetName());
282 Bool_t isRot = fitstr->Contains(
"sin(")+fitstr->Contains(
"cos(");
283 Bool_t isLX = fitstr->Contains(
"lxr");
284 Bool_t isIn = fitstr->Contains(
"inn");
285 Bool_t isGXY = fitstr->Contains(
"gxr")+fitstr->Contains(
"gyr");
286 if (fitstr->Contains(
"tl^2")){
288 fitTL+=(*fitstr)+
"*";
293 fitGXY+=(*fitstr)+
"*";
294 fitGXY+=vecFit0[i+1];
297 if (isLX&&!isRot&&!isIn){
299 fitLX+=(*fitstr)+
"*";
305 fitInOut+=(*fitstr)+
"*";
306 fitInOut+=vecFit0[i+1];
311 tree->SetAlias(
"fInOut",fitInOut.Data());
312 tree->SetAlias(
"fLX",fitLX.Data());
313 tree->SetAlias(
"fGXY",fitGXY.Data());
314 tree->SetAlias(
"fOff",fitOff.Data());
316 tree->SetAlias(
"fTL",fitTL.Data());
322 fstring+=
"(sin(atan2(gy.fElements,gx.fElements)))++";
323 fstring+=
"(cos(atan2(gy.fElements,gx.fElements)))++";
325 fstring+=
"(sin(atan2(gy.fElements,gx.fElements)*2))++";
326 fstring+=
"(cos(atan2(gy.fElements,gx.fElements)*2))++";
327 fstring+=
"(sin(atan2(gy.fElements,gx.fElements)*3))++";
328 fstring+=
"(cos(atan2(gy.fElements,gx.fElements)*3))++";
330 fstring+=
"(sin(atan2(gy.fElements,gx.fElements)*2))*lxr++";
331 fstring+=
"(cos(atan2(gy.fElements,gx.fElements)*2))*lxr++";
332 fstring+=
"(sin(atan2(gy.fElements,gx.fElements)*3))*lxr++";
333 fstring+=
"(cos(atan2(gy.fElements,gx.fElements)*3))*lxr++";
337 tree->SetAlias(
"f1",fit1->Data());
340 printf(
"Chi2/npoints\t=%f\n",TMath::Sqrt(chi2/npoints));
341 fit1->Tokenize(
"++")->Print();
346 fstring+=
"(side*sin(atan2(gy.fElements,gx.fElements)))++";
347 fstring+=
"(side*cos(atan2(gy.fElements,gx.fElements)))++";
349 fstring+=
"(side*sin(atan2(gy.fElements,gx.fElements)*2))++";
350 fstring+=
"(side*cos(atan2(gy.fElements,gx.fElements)*2))++";
351 fstring+=
"(side*sin(atan2(gy.fElements,gx.fElements)*3))++";
352 fstring+=
"(side*cos(atan2(gy.fElements,gx.fElements)*3))++";
354 fstring+=
"(side*sin(atan2(gy.fElements,gx.fElements)*2))*lxr++";
355 fstring+=
"(side*cos(atan2(gy.fElements,gx.fElements)*2))*lxr++";
356 fstring+=
"(side*sin(atan2(gy.fElements,gx.fElements)*3))*lxr++";
357 fstring+=
"(side*cos(atan2(gy.fElements,gx.fElements)*3))*lxr++";
362 printf(
"Chi2/npoints\t=%f\n",TMath::Sqrt(chi2/npoints));
363 fit2->Tokenize(
"++")->Print();
364 tree->SetAlias(
"f2",fit2->Data());
368 calPad0 = makePad->
GetCalPad(
"f0",
"1",
"ffit0");
369 calPad1 = makePad->
GetCalPad(
"f1",
"1",
"ffit1");
370 calPad2 = makePad->
GetCalPad(
"f2",
"1",
"ffit2");
371 calPadInOut = makePad->
GetCalPad(
"fInOut",
"1",
"fInOut");
372 calPadLX = makePad->
GetCalPad(
"fLX",
"1",
"fLX");
373 calPadTL = makePad->
GetCalPad(
"fTL",
"1",
"fTL");
375 calPadGXY = makePad->
GetCalPad(
"fGXY",
"1",
"fGXY");
376 calPadOff = makePad->
GetCalPad(
"fOff",
"1",
"fOff");
406 printf(
"-1. MaQkeFitPulser\n");
412 printf(
"0. GetCalPads\n");
414 calPadCor = makePad->
GetCalPad(
"tcor",
"1",
"tcor");
415 calPadOut = makePad->
GetCalPad(
"1",
"!((cutA||cutC)&&abs(ly.fElements/lx.fElements)<0.16)",
"out");
416 calPadIn = makePad->
GetCalPad(
"dt",
"1",
"timeIn");
418 calPadF1 = calPadIn->
GlobalFit(
"timeF1", calPadOut,kFALSE,0,0,0.8);
419 calPadQIn = makePad->
GetCalPad(
"qa*(sector%36<18)+qc*(sector%36>17)",
"1",
"qIn");
422 printf(
"1. Create outlyer map\n");
428 for (Int_t isector=0;isector<72; isector++){
435 printf(
"2. Fit sector parabolas\n");
438 calPadF1 = calPadIn->
GlobalFit(
"timeF1", calPadOut,kFALSE,0,0,0.9);
439 calPadF2 = calPadIn->
GlobalFit(
"timeF2", calPadOut,kFALSE,1,0,0.9);
440 calPadQF1 = calPadQIn->
GlobalFit(
"qF1", calPadOut,kFALSE,1);
441 calPadQF2 = calPadQIn->
GlobalFit(
"qF2", calPadOut,kFALSE,1);
446 printf(
"3. Update outlyer map\n");
447 for (Int_t isector=0;isector<72; isector++){
458 printf(
"4. Redo fit of the of parabola \n");
464 calPadF1 = calPadInCor->
GlobalFit(
"timeF1", calPadOut,kFALSE,0,0.9);
465 calPadF2 = calPadInCor->
GlobalFit(
"timeF2", calPadOut,kFALSE,1,0.9);
466 calPadQF1 = calPadQIn->
GlobalFit(
"qF1", calPadOut,kFALSE,0,0,0.9);
467 calPadQF2 = calPadQIn->
GlobalFit(
"qF2", calPadOut,kFALSE,1,0,0.9);
503 TFile * fstore =
new TFile(
oname,
"recreate");
504 if (calPadIn) calPadIn->Write(
"timeIn");
505 if (calPadF1) calPadF1->Write(
"timeF1");
506 if (calPadF2) calPadF2->Write(
"timeF2");
508 if (calPadQIn) calPadQIn->Write(
"qIn");
509 if (calPadQF1) calPadQF1->Write(
"qF1");
510 if (calPadQF2) calPadQF2->Write(
"qF2");
512 if (calPadCor) calPadCor->Write(
"tcor");
513 if (calPadOut) calPadOut->Write(
"out");
515 if (calPad0) calPad0->Write(
"ffit0");
516 if (calPad1) calPad1->Write(
"ffit1");
517 if (calPad2) calPad2->Write(
"ffit2");
518 if (calPadInOut)calPadInOut->Write(
"fInOut");
519 if (calPadLX) calPadLX->Write(
"fLX");
520 if (calPadTL) calPadTL->Write(
"fTL");
521 if (calPadQ) calPadQ->Write(
"fQ");
522 if (calPadGXY) calPadGXY->Write(
"fGXY");
523 if (calPadOff) calPadOff->Write(
"fOff");
524 if (calPadRes) calPadRes->Write(
"Result");
534 if (calPadIn) preprocesor->
AddComponent(calPadIn->Clone());
535 if (calPadF1) preprocesor->
AddComponent(calPadF1->Clone());
536 if (calPadF2) preprocesor->
AddComponent(calPadF2->Clone());
538 if (calPadQIn) preprocesor->
AddComponent(calPadQIn->Clone());
539 if (calPadQF1) preprocesor->
AddComponent(calPadQF1->Clone());
540 if (calPadQF2) preprocesor->
AddComponent(calPadQF2->Clone());
542 if (calPadCor) preprocesor->
AddComponent(calPadCor->Clone());
543 if (calPadOut) preprocesor->
AddComponent(calPadOut->Clone());
545 if (calPad0) preprocesor->
AddComponent(calPad0->Clone());
546 if (calPad1) preprocesor->
AddComponent(calPad1->Clone());
547 if (calPad2) preprocesor->
AddComponent(calPad2->Clone());
548 if (calPadInOut)preprocesor->
AddComponent(calPadInOut->Clone());
549 if (calPadLX) preprocesor->
AddComponent(calPadLX->Clone());
550 if (calPadTL) preprocesor->
AddComponent(calPadTL->Clone());
551 if (calPadQ) preprocesor->
AddComponent(calPadQ->Clone());
552 if (calPadGXY) preprocesor->
AddComponent(calPadGXY->Clone());
553 if (calPadOff) preprocesor->
AddComponent(calPadOff->Clone());
554 if (calPadRes) preprocesor->
AddComponent(calPadRes->Clone());
570 tree->SetAlias(
"side",
"1-(sector%36>17)*2");
571 tree->SetAlias(
"dt",
"(ta)*(sector%36<18)+(tc)*(sector%36>17)+tcor");
572 tree->SetAlias(
"cutA",
"qa>30&&qa<400&&abs(ta)<2&&ra>0.5&&ra<2");
573 tree->SetAlias(
"cutC",
"qc>30&&qc<400&&abs(tc)<2&&rc>0.5&&rc<2");
574 tree->SetAlias(
"cutF",
"((row.fElements+pad.fElements+sector)%19==0)");
575 tree->SetAlias(
"cutCE",
"V.out.fElements");
579 tree->SetAlias(
"inn",
"sector<36");
580 tree->SetAlias(
"gxr",
"(gx.fElements/250.)");
581 tree->SetAlias(
"gyr",
"(gy.fElements/250.)");
582 tree->SetAlias(
"lxr",
"(lx.fElements-133.41)/250.");
583 tree->SetAlias(
"qp",
"((sector%36<18)*sqrt(qa)/10.+(sector%36>17)*sqrt(qc)/10.)");
584 tree->SetAlias(
"tl",
"(ly.fElements/lx.fElements)/0.17");
591 tree->SetAlias(
"tcor",
"tcor.fElements");
592 tree->SetAlias(
"side",
"1-(sector%36>17)*2");
593 tree->SetAlias(
"dt",
"timeIn.fElements");
595 tree->SetAlias(
"cutA",
"out.fElements==1");
596 tree->SetAlias(
"cutC",
"out.fElements==1");
597 tree->SetAlias(
"cutF",
"((row.fElements+pad.fElements+sector.fElements)%19==0)");
599 tree->SetAlias(
"cutCE",
"out.fElements<0.5");
603 tree->SetAlias(
"inn",
"sector<36");
604 tree->SetAlias(
"gxr",
"(gx.fElements/250.)");
605 tree->SetAlias(
"gyr",
"(gy.fElements/250.)");
606 tree->SetAlias(
"lxr",
"(lx.fElements-133.41)/250.");
607 tree->SetAlias(
"qp",
"(sqrt(qIn.fElements)/10.+(out.fElements>0.5))");
608 tree->SetAlias(
"tl",
"(ly.fElements/lx.fElements)/0.17");
617 calPadRes0->
Add(calPad2,-1);
618 calPadRes = calPadRes0->
GlobalFit(
"Result", calPadOut,kTRUE,1,0.9);
622 Float_t tlmedian = calPadTL->
GetMedian();
623 for (Int_t isector=0;isector<72; isector++){
636 calPadRes->
Add(calPadCor,-1);
653 padtime->SetName(
"CE_T");
654 padRMS->SetName(
"CE_RMS");
655 padq->SetName(
"CE_Q");
662 pultime->SetName(
"P_T");
663 pulRMS->SetName(
"P_RMS");
664 pulq->SetName(
"P_Q");
697 finput.open(list, ios_base::in);
702 elist =
new TEntryList(
"elist",
"elist");
703 tree->Draw(Form(
">>elist%d",counter),
"1",
"entrylist");
705 while(finput.good()) {
706 finput >> currentFile;
707 printf(
"Getting file%s\n",currentFile.Data());
708 TFile * fC =
new TFile(currentFile.Data());
709 TTree * treeC = (TTree*) fC->Get(
"calPads");
710 makePad->
AddFriend(treeC,Form(
"T%d",counter));
712 TString cutStrF1=Form(
"abs(T%d.timeIn.fElements-T%d.timeF1.fElements)<1.5",counter,counter);
713 TEntryList *celist =
new TEntryList(Form(
"listF1%d",counter),Form(
"listF1%d",counter));
714 tree->Draw(Form(
">>listF1%d",counter),cutStrF1,
"entrylist");
715 if (celist->GetN()>0)
elist->Add(celist);
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
AliTPCCalROC * GetCalROC(Int_t sector) const
const TObjArray * GetCalPadRMS() const
GUI for the AliTPCCalibViewer used for the calibration monitor All functionalities of the AliTPCCalib...
TFile f("CalibObjects.root")
Float_t GetValue(UInt_t row, UInt_t pad) const
AliTPCCalibViewerGUI * viewer
const TObjArray * GetCalPadT0() const
Double_t GetMedian(AliTPCCalPad *outlierPad=0, AliTPCCalROC::EPadType padType=AliTPCCalROC::kAll) const
TFriendElement * AddFriend(const char *treename, const char *filename)
Class for viewing/visualizing TPC calibration data.
AliTPCCalibViewer * GetViewer()
void AddFiles(char *list)
const TObjArray * GetCalPadRMS() const
AliTPCCalibViewer * makePad
Implementation of the TPC pulser calibration.
void RebuildCE(char *finname, char *pulname)
const TObjArray * GetCalPadT0() const
void SetValue(UInt_t row, UInt_t pad, Float_t vd)
AliTPCCalPad * calPadInOut
static TObjArray * ShowGUI(const char *fileName=0)
UInt_t GetNchannels() const
AliTPCCalPad * GetCalPad(const char *desiredData, const char *cuts="", const char *calPadName="NoName") const
void DumpToFile(const char *fileName)
Preprocessor class for HLT and DAQ.
const TObjArray * GetCalPadQ() const
Implementation of the TPC Central Electrode calibration.
void AddComponent(TObject *obj)
AliTPCCalPad * GlobalFit(const char *padName, AliTPCCalPad *Padoutliers=0, Bool_t robust=kFALSE, Int_t fitType=1, Double_t chi2Threshold=5, Double_t robustFraction=0.7, Double_t err=1, TObjArray *fitParArr=0x0, TObjArray *fitCovArr=0x0, AliTPCCalROC::EPadType padType=AliTPCCalROC::kAll)
const TObjArray * GetCalPadQ() const