File indexing completed on 2025-08-05 08:19:45
0001
0002
0003
0004
0005
0006
0007
0008 #include <fun4all/Fun4AllUtils.h>
0009
0010
0011
0012
0013 #include <GlobalVariables.C>
0014
0015
0016
0017
0018 #include <Trkr_TpcReadoutInit.C>
0019
0020 #include <cdbobjects/CDBTTree.h>
0021 #include <ffamodules/CDBInterface.h>
0022
0023
0024
0025
0026
0027
0028
0029 #include <phool/recoConsts.h>
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #include <stdio.h>
0040
0041
0042
0043
0044
0045
0046
0047 R__LOAD_LIBRARY(libtpc.so)
0048
0049
0050
0051 R__LOAD_LIBRARY(libphool.so)
0052 R__LOAD_LIBRARY(libcdbobjects.so)
0053
0054
0055 double driftGET( const int arun = 51279 );
0056 bool CheckHV( const int arun = 51279 );
0057
0058 using std::cout;
0059 using std::endl;
0060
0061
0062
0063
0064 void drift(){
0065
0066
0067
0068 TGraph *gdriftrun = new TGraph();
0069 gdriftrun ->SetMarkerStyle(20);
0070 gdriftrun ->SetMarkerSize(0.9);
0071 gdriftrun ->SetMarkerColor(kBlue);
0072 gdriftrun ->SetLineColor(kBlue);
0073
0074 double drifts[2000] = {0};
0075 const int NPHASE = 9;
0076 int iphase = 0;
0077 const char* phasename[NPHASE] = {"6x6","28x28","56x56","111x111 8/9","111x111 8/11","","BP#downarrow","",""};
0078 int lastruns[NPHASE] = {49722,50025,50458,50936,51109,51191,51301,51495,51617};
0079 double phaseN[NPHASE] = {0};
0080 double phaseA[NPHASE] = {0};
0081 double phaseNhv[NPHASE] = {0};
0082 double phaseAhv[NPHASE] = {0};
0083 double lowest[NPHASE] = {0};
0084 for (int iph=0;iph<NPHASE;iph++){ lowest[iph] = 99.; }
0085
0086
0087
0088 for (int i=0;i<2000;i++){
0089
0090 int irun = 49700+i;
0091 double val = driftGET(irun);
0092
0093 if (irun<=49722){ iphase=0; } else
0094 if (irun<=50025){ iphase=1; } else
0095 if (irun<=50458){ iphase=2; } else
0096 if (irun<=50936){ iphase=3; } else
0097 if (irun<=51109){ iphase=4; } else
0098 if (irun<=51191){ iphase=5; } else
0099 if (irun<=51301){ iphase=6; } else
0100 if (irun<=51495){ iphase=7; } else
0101 { iphase=8; }
0102
0103 bool CorrectHV = CheckHV(irun);
0104
0105 drifts[i] = val;
0106 if (val>0.){
0107 gdriftrun ->SetPoint(gdriftrun->GetN(),irun,val);
0108 phaseA[iphase] += val;
0109 phaseN[iphase] += 1.0;
0110
0111
0112
0113
0114 if (val<lowest[iphase]) lowest[iphase]=val;
0115 }
0116 }
0117
0118 int nrunstot = 0;
0119 int nrunstothv = 0;
0120 for (int iph=0;iph<NPHASE;iph++){
0121 if (phaseN[iph]>0){
0122 nrunstot += phaseN[iph];
0123 nrunstothv += phaseNhv[iph];
0124 phaseA[iph] /= phaseN[iph];
0125
0126
0127 }
0128 }
0129 cout<<"Nruns with custom <v> found = "<<nrunstot<<endl;
0130
0131
0132 int ican=-1,itext=-1,iline=-1,ivline=-1,iframe=-1;
0133 TCanvas *ccan[100];
0134 TH1F *frame[100];
0135 TLatex *text[1000];
0136 TLine *line[100];
0137 TLine *vline[100];
0138 for (int i=0;i<1000;i++){
0139 text[i] = new TLatex();
0140 text[i] ->SetNDC();
0141 text[i] ->SetTextFont(42);
0142 text[i] ->SetTextSize(0.05);
0143 text[i] ->SetTextAlign(33);
0144 line[i] = new TLine();
0145 line[i] ->SetLineColor(1);
0146 line[i] ->SetLineStyle(2);
0147 line[i] ->SetLineWidth(2);
0148 vline[i]= new TLine(0,-1,0,1);
0149 vline[i]->SetLineColor(17);
0150 vline[i]->SetLineWidth(2);
0151 }
0152 gROOT->SetStyle("Modern");
0153 gStyle->SetOptStat(0);
0154 gStyle->SetTitleAlign(13);
0155 gStyle->SetTitleFontSize(0.08);
0156 gStyle->SetTitleX(0.20);
0157 gStyle->SetTitleY(0.98);
0158 gStyle->SetPadRightMargin(0.01);
0159 gStyle->SetPadTopMargin(0.01);
0160 gStyle->SetPadBottomMargin(0.08);
0161 gStyle->SetPadLeftMargin(0.12);
0162 gStyle->SetTitleSize(0.03,"xyzt");
0163 gStyle->SetLabelSize(0.03,"xyzt");
0164
0165
0166
0167
0168
0169 ++ican; ccan[ican] = new TCanvas(Form("ccan%d",ican),Form("ccan%d",ican),20+ican*30,30+ican*30,0.7*1100,0.7*850);
0170 ccan[ican]->cd(); ccan[ican]->Divide(1,1,0.0001,0.0001);
0171 ccan[ican]->cd(1);
0172 gdriftrun->Draw("AP");
0173 for (int iph=0;iph<NPHASE;iph++){
0174 ++itext; text[itext]->SetNDC(kFALSE); text[itext]->SetTextAlign(23); text[itext]->SetTextSize(0.03);
0175 text[itext]->DrawLatex(lastruns[iph]-20,0.996*lowest[iph],Form("%.5f",phaseA[iph]));
0176
0177
0178
0179 ++itext; text[itext]->SetNDC(kFALSE); text[itext]->SetTextAlign(21); text[itext]->SetTextSize(0.03);
0180 text[itext]->SetTextAngle(90);
0181 text[itext]->DrawLatex(lastruns[iph],0.0067,Form("%s",phasename[iph]));
0182 }
0183 ccan[ican]->cd(); ccan[ican]->Update();
0184 ccan[ican]->Print("drift.ps(");
0185
0186
0187
0188 ccan[ican]->Print("drift.ps]");
0189 int iSuccess = gSystem->Exec("ps2pdf drift.ps drift.pdf");
0190 cout<<"isuccess="<<iSuccess<<endl;
0191 if (iSuccess==-1){
0192 cout<<"drift.pdf produced, deleting drift.ps file..."<<endl;
0193 TString sexec = TString("/bin/rm drift.ps");
0194 cout<<sexec.Data()<<endl;
0195 gSystem ->Exec(sexec.Data());
0196 }
0197 cout<<"Done..."<<endl;
0198
0199 cout<<"Writing drift.root..."<<endl;
0200 TFile *fout = new TFile("drift.root","RECREATE");
0201 fout->cd();
0202 gdriftrun->Write("gdriftrun");
0203 fout->Close();
0204
0205 }
0206
0207
0208
0209
0210
0211 bool CheckHV( const int irun = 51279 ){
0212 if (irun>=49706&&irun<=49713){ return true; } else
0213 if (irun>=50006&&irun<=50014){ return true; } else
0214 if (irun>=50021&&irun<=50025){ return true; } else
0215 if (irun>=50438&&irun<=50440){ return true; } else
0216 if (irun>=50444&&irun<=50449){ return true; } else
0217 if (irun>=50916&&irun<=50921){ return true; } else
0218 if (irun>=50933&&irun<=50936){ return true; } else
0219 if (irun>=51099&&irun<=51107){ return true; }
0220
0221
0222
0223
0224 return false;
0225 }
0226
0227
0228
0229 double driftGET( const int runnumber = 51279 ){
0230
0231 TpcReadoutInit( runnumber );
0232 double driftOLD = G4TPC::tpc_drift_velocity_reco;
0233
0234 auto rc = recoConsts::instance();
0235 rc->set_IntFlag("RUNNUMBER", runnumber);
0236
0237 Enable::CDB = true;
0238 rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0239 rc->set_uint64Flag("TIMESTAMP", 6);
0240
0241
0242
0243
0244 double driftCDB = 0;
0245 rc->set_uint64Flag("TIMESTAMP",runnumber);
0246 CDBInterface* cdb = CDBInterface::instance();
0247 std::string tpc_dv_calib_dir = cdb->getUrl("TPC_DRIFT_VELOCITY");
0248 if (!tpc_dv_calib_dir.empty()){
0249
0250 CDBTTree *cdbttree = new CDBTTree(tpc_dv_calib_dir);
0251 cdbttree->LoadCalibrations();
0252 driftCDB = cdbttree->GetSingleFloatValue("tpc_drift_velocity");
0253 cout<<"DRIFT: RunNum="<<runnumber<<"\t driftOLD=" << driftOLD << "\t driftCDB=" << driftCDB << endl;
0254
0255
0256
0257 } else {
0258
0259 }
0260
0261 return driftCDB;
0262 }
0263