Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:46

0001 void afebMacro(){
0002 gROOT->SetBatch();
0003 //set global parameters
0004 gROOT->ProcessLine(".L GenFuncMacro.C");
0005 
0006 //get myFile. this is for batch processecing 
0007 //copies the name of any file beginning with "c" from the /tmp/csccalib directory. 
0008 char *myFileName;  //new file name for directory name
0009 char *myFilePath; //for accessing file by root 
0010 void *dirp = gSystem->OpenDirectory("/tmp/csccalib"); //read tmp directory
0011 char *afile; //temp file name
0012 while(afile = gSystem->GetDirEntry(dirp)) { //parse directory
0013    char *bfile[0] = afile[0]; //new temp file name
0014    if (bfile[0]=='c') { //if file begins with c
0015      printf("file: %s\n",afile); //check name
0016      myFileName = afile; //set for out of scope processing
0017    }
0018    myFilePath = Form("/tmp/csccalib/%s", myFileName);
0019 }
0020 
0021 int nDDU  = 1;
0022 int nCham =  5;
0023 int nLayer = 6;
0024 
0025 //style-ize all canvases
0026 gStyle->SetCanvasColor(0); 
0027 gStyle->SetPadColor(0);
0028 gStyle->SetPadBorderMode(0);
0029 gStyle->SetCanvasBorderMode(0);
0030 gStyle->SetFrameBorderMode(0);
0031 gStyle->SetStatH(0.2);
0032 gStyle->SetStatW(0.3);
0033 
0034 directoryCheck();
0035 
0036 //open file generated from analyzer
0037 std::cout << "opening: " << myFileName << std::endl; 
0038 TFile *myFile = TFile::Open(myFilePath);
0039 
0040 Calibration->Draw("cham");
0041 int nCham = htemp->GetXaxis()->GetXmax();
0042 
0043 //this is one big section of linux directory processing
0044 //if this is edited, be careful! it's easy to mess up. 
0045 gSystem->cd("/afs/cern.ch/cms/CSC/html/csccalib/");
0046 
0047 //create "images" folder. 
0048 makeDirectory("images");
0049 gSystem->cd("images");
0050  //create subdirectory Gains
0051 makeDirectory("AFEBAnalysis");
0052 gSystem->cd("AFEBAnalysis");
0053 //create subdirectory for run
0054 //TString rmline = Form("rm -r %s", myFile->GetName() ) ;
0055 //std::cout << "executing: " << rmline << std::endl;
0056 //gSystem->Exec(rmline);
0057 Int_t bool_dir_bin = gSystem->mkdir(myFileName);//0 if there is no directory of this name, -1 if there is 
0058 if (bool_dir_bin == -1){
0059    std::cout << "directory " << myFileName << " already exists. remove directory and try again." << std::endl;
0060    std::cout << "please wait while ROOT aborts and exits." << std::endl;
0061    gSystem->Abort();
0062  }
0063 
0064 makeDirectory(myFileName);   
0065 gSystem->cd(myFileName);  
0066 
0067 //make graph subdirectories 
0068 std::vector<TString> graphID_str(0);
0069 TIter next (myFile->GetListOfKeys() );
0070 TKey *key;
0071 while ( (key=(TKey*)next() ) ) {
0072   TString name = key->GetName();
0073   TString nClass = key->GetClassName();
0074   //  std::cout << name << "  " << nClass << std::endl;
0075   TString chamID = name.Remove(5);
0076   //std::cout << chamID << std::endl;
0077   TString chamID_direc = chamID + "_AfebDacGraphs";
0078   Int_t bool_dir_check = gSystem->mkdir(chamID_direc); 
0079   if (bool_dir_check == 0){
0080     graphID_str.push_back(chamID); 
0081   }
0082   makeDirectory(chamID_direc); 
0083   }//while  
0084 
0085 gSystem->cd("../../../"); 
0086 GetAFEBDACGraphs(myFileName, myFilePath, graphID_str);
0087 GetOtherGraphs(myFileName, myFilePath, graphID_str);
0088 
0089 myFile->Close();
0090 TFile *myFile2 = new TFile(file2, "read"); 
0091 TString fileName2 = myFile2->GetName();
0092 
0093 directoryCheck();
0094 gSystem->cd("images/AFEBAnalysis");
0095 makeDirectory(fileName2);
0096 gSystem->cd(fileName2);
0097 //make graph subdirectories 
0098 std::vector<TString> graphID_str2(0);
0099 TIter next (myFile2->GetListOfKeys() );
0100 TKey *key;
0101 while ( (key=(TKey*)next() ) ) {
0102   TString name = key->GetName();
0103   TString nClass = key->GetClassName();
0104   // std::cout << name << "  " << nClass << std::endl;
0105   TString chamID = name.Remove(5);
0106   std::cout << chamID << std::endl;
0107   TString chamID_direc = chamID + "_ConnectivityGraphs";
0108   Int_t bool_dir_check = gSystem->mkdir(chamID_direc); 
0109   if (bool_dir_check == 0 && chamID != "Layer"){
0110     graphID_str2.push_back(chamID); 
0111   }
0112   makeDirectory(chamID_direc); 
0113   }//while  
0114 gSystem->cd("../../../"); 
0115 GetConnectGraphs(myFile2,fileName2, graphID_str2);
0116 directoryCheck();
0117 }
0118 
0119 void GetAFEBDACGraphs(TFile *myFile, TString fileName, std::vector<TString> chID){
0120 gSystem->cd("images/AFEBAnalysis");
0121 gSystem->cd(fileName);
0122 
0123 for (int CHndx=0; CHndx<chID.size(); ++CHndx){
0124 TString chamID = chID.at(CHndx);
0125 //std::cout << "chambers: " << chamID << std::endl;
0126 TString direcName =  chamID + "_AfebDacGraphs"; 
0127 TH2F *AFEBDACGraph; 
0128 TCanvas *AFEBDacCanvas =  new TCanvas("AFEBDacCanvas","AFEBDacCanvas", 1100,700); 
0129 //AFEBDacCanvas->Divide(3,6);
0130 gSystem->cd(direcName);
0131   for (int indx1=1;indx1<10; ++indx1){ 
0132     TString GraphName = Form("0%d_Anode_AfebDac",indx1); 
0133     TString GraphName = chamID+ "0" + indx1 + "_Anode_AfebDac"; 
0134     AFEBDACGraph = (TH2F*)myFile->Get(GraphName);  
0135     AFEBDACGraph->GetYaxis()->SetLimits(0,0.5);
0136     AFEBDACGraph->GetXaxis()->SetLimits(0,20);
0137     AFEBDACGraph->GetXaxis()->SetTitleSize(0.06);
0138     AFEBDACGraph->GetXaxis()->SetTitleOffset(0.7);
0139     AFEBDACGraph->GetYaxis()->SetTitleSize(0.06);
0140     AFEBDACGraph->GetYaxis()->SetTitleOffset(0.7);
0141     AFEBDacCanvas->cd(indx1); 
0142     AFEBDACGraph->Draw(); 
0143     PrintAsGif(AFEBDacCanvas, GraphName);
0144   } 
0145   for (int indx2=0;indx2<9; ++indx2){  
0146     TString GraphName = Form("1%d_Anode_AfebDac",indx2);  
0147     TString GraphName = chamID+ "1" + indx2 + "_Anode_AfebDac"; 
0148     AFEBDACGraph = (TH2F*)myFile->Get(GraphName); 
0149     AFEBDACGraph->GetYaxis()->SetLimits(0,0.5);
0150     AFEBDACGraph->GetXaxis()->SetLimits(0,20);
0151     AFEBDACGraph->GetXaxis()->SetTitleSize(0.06);
0152     AFEBDACGraph->GetXaxis()->SetTitleOffset(0.7);
0153     AFEBDACGraph->GetYaxis()->SetTitleSize(0.06);
0154     AFEBDACGraph->GetYaxis()->SetTitleOffset(0.7);
0155     AFEBDacCanvas->cd(10+indx2);  
0156     AFEBDACGraph->Draw(); 
0157     PrintAsGif(AFEBDacCanvas, GraphName);
0158   }  
0159   gSystem->cd("../");
0160   
0161 }//Chamber Loop
0162 gSystem->cd("../../../");
0163 directoryCheck(); 
0164 }
0165 
0166 void GetOtherGraphs(TFile *myFile, TString fileName, std::vector<TString> chID){
0167 gSystem->cd("images/AFEBAnalysis");
0168 gSystem->cd(fileName);
0169 
0170 TH2F *chi2perNDF;
0171 TH2F *NDF;
0172 TH2F *NoisePar;
0173 TH2F *ThreshPar;
0174 TH2F *FirstTime;
0175 TH1F *ChanEff;
0176 
0177 TCanvas *NDFCanv;
0178 TCanvas *ParCanv;
0179 TCanvas *EffCanv;
0180 
0181 for (int CHndx=0; CHndx<chID.size(); ++CHndx){
0182 TString chamID = chID.at(CHndx);
0183 //std::cout << "chamber: " << chamID << std::endl;
0184 
0185 //NDF's
0186 TString direcName =  chamID + "_SpecificsGraphs";
0187 makeDirectory(direcName);
0188 gSystem->cd(direcName);
0189 
0190 TString NDFGraphName = chamID + "_Anode_AfebNDF" ;
0191 TString NDFchi2GraphName = chamID + "_Anode_AfebChi2perNDF" ;
0192 TString NoiseParGraphName = chamID + "_Anode_AfebNoisePar" ;
0193 TString ThreshParGraphName = chamID + "_Anode_AfebThrPar" ;
0194 TString FirstTimeGraphName = chamID + "_Anode_First_Time" ;
0195 TString ChanEffGraphName = chamID + "_Anode_Chan_Eff" ;
0196 
0197 NDFCanv = new TCanvas ("NDFChamCanv", "NDFChamCanv", 1100, 700);
0198 NDFCanv->Divide(1,2);
0199 NDFCanv->cd(1);
0200 NDF = (TH2F*)myFile->Get(NDFGraphName);  
0201 NDF->Draw();
0202 NDFCanv->cd(2);
0203 chi2perNDF = (TH2F*)myFile->Get(NDFchi2GraphName); 
0204 chi2perNDF->GetYaxis()->SetLimits(0,0.5);
0205 chi2perNDF->GetXaxis()->SetLimits(0,20);
0206 chi2perNDF->GetXaxis()->SetTitleSize(0.06);
0207 chi2perNDF->GetXaxis()->SetTitleOffset(0.7);
0208 chi2perNDF->GetYaxis()->SetTitleSize(0.06);
0209 chi2perNDF->GetYaxis()->SetTitleOffset(0.7); 
0210 chi2perNDF->Draw();
0211 
0212 ParCanv = new TCanvas ("ParChamCanv", "ParChamCanv", 1100, 700);
0213 ParCanv->Divide(1,2);
0214 ParCanv->cd(1);
0215 
0216 NoisePar = (TH2F*)myFile->Get(NoiseParGraphName);  
0217 NoisePar->GetYaxis()->SetLimits(0,0.5);
0218 NoisePar->GetXaxis()->SetLimits(0,20);
0219 NoisePar->GetXaxis()->SetTitleSize(0.06);
0220 NoisePar->GetXaxis()->SetTitleOffset(0.7);
0221 NoisePar->GetYaxis()->SetTitleSize(0.06);
0222 NoisePar->GetYaxis()->SetTitleOffset(0.7); 
0223 NoisePar->Draw();
0224 
0225 ParCanv->cd(2);
0226 ThreshPar = (TH2F*)myFile->Get(ThreshParGraphName);  
0227 ThreshPar->GetYaxis()->SetLimits(0,0.5);
0228 ThreshPar->GetXaxis()->SetLimits(0,20);
0229 ThreshPar->GetXaxis()->SetTitleSize(0.06);
0230 ThreshPar->GetXaxis()->SetTitleOffset(0.7);
0231 ThreshPar->GetYaxis()->SetTitleSize(0.06);
0232 ThreshPar->GetYaxis()->SetTitleOffset(0.7); 
0233 ThreshPar->Draw();
0234 
0235 EffCanv = new TCanvas ("EffChamCanv", "EffChamCanv", 1100, 700);
0236 EffCanv->Divide(1,2);
0237 EffCanv->cd(1);
0238 ChanEff = (TH1F*)myFile->Get(ChanEffGraphName);  
0239 ChanEff->GetYaxis()->SetLimits(0,0.5);
0240 ChanEff->GetXaxis()->SetLimits(0,20);
0241 ChanEff->GetXaxis()->SetTitleSize(0.06);
0242 ChanEff->GetXaxis()->SetTitleOffset(0.7);
0243 ChanEff->GetYaxis()->SetTitleSize(0.06);
0244 ChanEff->GetYaxis()->SetTitleOffset(0.7); 
0245 ChanEff->Draw();
0246 
0247 EffCanv->cd(2);
0248 FirstTime = (TH2F*)myFile->Get(FirstTimeGraphName);  
0249 FirstTime->GetYaxis()->SetLimits(0,0.5);
0250 FirstTime->GetXaxis()->SetLimits(0,20);
0251 FirstTime->GetXaxis()->SetTitleSize(0.06);
0252 FirstTime->GetXaxis()->SetTitleOffset(0.7);
0253 FirstTime->GetYaxis()->SetTitleSize(0.06);
0254 FirstTime->GetYaxis()->SetTitleOffset(0.7); 
0255 FirstTime->Draw();
0256 
0257 PrintAsGif(ParCanv, "ParChamCanv");
0258 PrintAsGif(NDFCanv, "NDFChamCanv");
0259 PrintAsGif(EffCanv, "EffChamCanv");
0260 gSystem->cd("../");
0261 }//chamber loop
0262 
0263 gSystem->cd("../../../");
0264 directoryCheck();
0265 }
0266 
0267 void GetConnectGraphs(TFile *myFile2, TString fileName2, std::vector<TString> chID2){
0268 gSystem->cd("images/AFEBAnalysis");
0269 gSystem->cd(fileName2);
0270 
0271 TH1F *LayNmbPulseGraph;
0272 TCanvas *LayNmbPulseCanv;
0273 
0274 LayNmbPulseCanv = new TCanvas ("LayNmbPulseChamCanv", "LayNmbPulseChamCanv", 1100, 700);
0275 LayNmbPulseCanv->cd();
0276 LayNmbPulseGraph = (TH1F*)myFile2->Get("Layer_Nmb_Pulses");  
0277 LayNmbPulseGraph->Draw();
0278 
0279 PrintAsGif(LayNmbPulseCanv, "LayNmbPulseChamCanv");
0280 
0281 TH2F *AnodeFirstTime;
0282 
0283 TH1F *AnodeEff;
0284 TH1F *AnodeLayerNonPair;
0285 TH1F *AnodeLayerPair;
0286 
0287 TH1F *AnodeWireEff;
0288 TH1F *AnodeWireNonPair;
0289 TH1F *AnodeWirePair;
0290 
0291 TCanvas *FirstTimeCanv;
0292 TCanvas *LayerCanv;
0293 TCanvas *WireCanv;
0294 
0295 for (int CHndx=0; CHndx<chID2.size(); ++CHndx){
0296 TString chamID = chID2.at(CHndx);
0297 TString chamID_direc = chamID + "_ConnectivityGraphs";
0298 gSystem->cd(chamID_direc);
0299 FirstTimeCanv = new TCanvas ("FirstTime", "FirstTime", 1100, 700);
0300 TString AnodeFirstTimeGraphName = chamID + "_Anode_First_Time" ;
0301 
0302 LayerCanv = new TCanvas ("LayerEff_Crosstalk", "LayerEff_Crosstalk", 1100, 700);
0303 LayerCanv->Divide(1,3);
0304 TString AnodeEffGraphName = chamID + "_Anode_Eff" ; 
0305 TString AnodeLayerNonPairGraphName = chamID + "_Anode_NonPair_Layer_Crosstalk" ; 
0306 TString AnodeLayerPairGraphName = chamID + "_Anode_Pair_Layer_Crosstalk" ; 
0307 
0308 WireCanv = new TCanvas ("WireEff_Crosstalk", "WireEff_Crosstalk", 1100, 700);
0309 WireCanv->Divide(1,3);
0310 TString AnodeWireEffGraphName = chamID + "_Anode_Wire_Eff" ; 
0311 TString AnodeWireNonPairGraphName = chamID + "_Anode_Wire_NonPair_Crosstalk" ; 
0312 TString AnodeWirePairGraphName = chamID + "_Anode_Wire__Pair_Crosstalk" ; 
0313 
0314 AnodeFirstTime= (TH2F*)myFile2->Get(AnodeFirstTimeGraphName);   
0315 FirstTimeCanv->cd();
0316 AnodeFirstTime->GetYaxis()->SetLimits(0,0.5);
0317 AnodeFirstTime->GetXaxis()->SetLimits(0,20);
0318 AnodeFirstTime->GetXaxis()->SetTitleSize(0.06);
0319 AnodeFirstTime->GetXaxis()->SetTitleOffset(0.7);
0320 AnodeFirstTime->GetYaxis()->SetTitleSize(0.06);
0321 AnodeFirstTime->GetYaxis()->SetTitleOffset(0.7); 
0322 AnodeFirstTime->Draw();
0323 PrintAsGif(FirstTimeCanv, "FirstTime");
0324 
0325 AnodeEff = (TH1F*)myFile2->Get(AnodeEffGraphName);   
0326 LayerCanv->cd(1);
0327 AnodeEff->GetYaxis()->SetLimits(0,0.5);
0328 AnodeEff->GetXaxis()->SetLimits(0,20);
0329 AnodeEff->GetXaxis()->SetTitleSize(0.06);
0330 AnodeEff->GetXaxis()->SetTitleOffset(0.7);
0331 AnodeEff->GetYaxis()->SetTitleSize(0.06);
0332 AnodeEff->GetYaxis()->SetTitleOffset(0.7); 
0333 AnodeEff->Draw();
0334 
0335 AnodeLayerNonPair = (TH1F*)myFile2->Get(AnodeLayerNonPairGraphName);   
0336 LayerCanv->cd(2);
0337 AnodeLayerNonPair->GetYaxis()->SetLimits(0,0.5);
0338 AnodeLayerNonPair->GetXaxis()->SetLimits(0,20);
0339 AnodeLayerNonPair->GetXaxis()->SetTitleSize(0.06);
0340 AnodeLayerNonPair->GetXaxis()->SetTitleOffset(0.7);
0341 AnodeLayerNonPair->GetYaxis()->SetTitleSize(0.06);
0342 AnodeLayerNonPair->GetYaxis()->SetTitleOffset(0.7); 
0343 AnodeLayerNonPair->Draw();
0344 
0345 AnodeLayerPair = (TH1F*)myFile2->Get(AnodeLayerPairGraphName);   
0346 LayerCanv->cd(3);
0347 AnodeLayerPair->GetYaxis()->SetLimits(0,0.5);
0348 AnodeLayerPair->GetXaxis()->SetLimits(0,20);
0349 AnodeLayerPair->GetXaxis()->SetTitleSize(0.06);
0350 AnodeLayerPair->GetXaxis()->SetTitleOffset(0.7);
0351 AnodeLayerPair->GetYaxis()->SetTitleSize(0.06);
0352 AnodeLayerPair->GetYaxis()->SetTitleOffset(0.7); 
0353 AnodeLayerPair->Draw();
0354 PrintAsGif(LayerCanv, "LayerEff_Crosstalk");
0355 
0356 AnodeWireEff = (TH1F*)myFile2->Get(AnodeWireEffGraphName);    
0357 WireCanv->cd(1);
0358 AnodeWireEff->GetYaxis()->SetLimits(0,0.5);
0359 AnodeWireEff->GetXaxis()->SetLimits(0,20);
0360 AnodeWireEff->GetXaxis()->SetTitleSize(0.06);
0361 AnodeWireEff->GetXaxis()->SetTitleOffset(0.7);
0362 AnodeWireEff->GetYaxis()->SetTitleSize(0.06);
0363 AnodeWireEff->GetYaxis()->SetTitleOffset(0.7); 
0364 AnodeWireEff->Draw();
0365 
0366 //AnodeWireNonPair = (TH1F*)myFile2->Get(AnodeWireNonPairGraphName);   
0367 //WireCanv->cd(2);
0368 //AnodeWireNonPair->GetYaxis()->SetLimits(0,0.5);
0369 //AnodeWireNonPair->GetXaxis()->SetLimits(0,20);
0370 //AnodeWireNonPair->GetXaxis()->SetTitleSize(0.06);
0371 //AnodeWireNonPair->GetXaxis()->SetTitleOffset(0.7);
0372 //AnodeWireNonPair->GetYaxis()->SetTitleSize(0.06);
0373 //AnodeWireNonPair->GetYaxis()->SetTitleOffset(0.7); 
0374 //AnodeWireNonPair->Draw();
0375 
0376 //AnodeWirePair = (TH1F*)myFile2->Get(AnodeWirePairGraphName);  
0377 //WireCanv->cd(3);
0378 //AnodeWirePair->GetYaxis()->SetLimits(0,0.5);
0379 //AnodeWirePair->GetXaxis()->SetLimits(0,20);
0380 //AnodeWirePair->GetXaxis()->SetTitleSize(0.06);
0381 //AnodeWirePair->GetXaxis()->SetTitleOffset(0.7);
0382 //AnodeWirePair->GetYaxis()->SetTitleSize(0.06);
0383 //AnodeWirePair->GetYaxis()->SetTitleOffset(0.7); 
0384 //AnodeWirePair->Draw();
0385 PrintAsGif(WireCanv, "WireEff_Crosstalk"); 
0386 gSystem->cd("../");
0387 }
0388 
0389 gSystem->cd("../../../"); 
0390 directoryCheck(); 
0391 }