Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 void saturationMacro(){
0002 gROOT->SetBatch();
0003 gROOT->ProcessLine(".L GenFuncMacro.C");
0004 
0005 //get myFile. this is for batch processecing 
0006 //copies the name of any file beginning with "c" from the /tmp/csccalib directory. 
0007 char *myFileName;  //new file name for directory name
0008 char *myFilePath; //for accessing file by root 
0009 void *dirp = gSystem->OpenDirectory("/tmp/csccalib"); //read tmp directory
0010 char *afile; //temp file name
0011 while(afile = gSystem->GetDirEntry(dirp)) { //parse directory
0012    char *bfile[0] = afile[0]; //new temp file name
0013    if (bfile[0]=='c') { //if file begins with c
0014      printf("file: %s\n",afile); //check name
0015      myFileName = afile; //set for out of scope processing
0016    }
0017    myFilePath = Form("/tmp/csccalib/%s", myFileName);
0018 }
0019 
0020 //set global parameters
0021 int nDDU  = 1;
0022 int nCham =  1;
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 std::cout << "opening: " << myFileName << std::endl; 
0035 TFile *myFile = TFile::Open(myFilePath);
0036 //get number of chambers per DDU, don't save graph. reatains value for NEntires. 
0037 Calibration->Draw("cham");
0038 int nCham = htemp->GetXaxis()->GetXmax();
0039 
0040 //this is one big section of linux directory processing
0041 //if this is edited, be careful! it's easy to mess up. 
0042 gSystem->cd("/afs/cern.ch/cms/CSC/html/csccalib/");
0043 
0044 //system is in folder "test". check:  
0045 directoryCheck();
0046 //create "images" folder. 
0047 makeDirectory("images");
0048 gSystem->cd("images");
0049  //create subdirectory Gains
0050 makeDirectory("Saturation");
0051 gSystem->cd("Saturation");
0052 //create subdirectory for run
0053 makeDirectory(fileName);
0054 gSystem->cd(fileName);
0055 gSystem->cd("../../../");
0056 
0057 //be in test before processing
0058 directoryCheck(); 
0059 
0060 myFile->Close();
0061 
0062 gSytle->SetOptStat(0);
0063 GetSaturation(myFileName, myFilePath); 
0064 GetSaturationGraphs(myFileName, myFilePath, nDDU, nCham); 
0065 gSytle->SetOptStat(1);
0066 
0067 directoryCheck();
0068 gSystem->cd("/afs/cern.ch/user/c/csccalib/scratch0/CMSSW_1_1_1/src/OnlineDB/CSCCondDB/test");
0069 gROOT->ProcessLine(".q"); 
0070 } 
0071 
0072 //this creates an array which can then be accessed
0073 //proper usage: 
0074 //  int idArray[9];
0075 //  GetChamberIDs(idArray);
0076 //  std::cout << "id for chamber 0: " << idArray[0] << std::endl;
0077 void GetChamberIDs(int IDArray[9]){
0078 TCanvas *IDcanv = new TCanvas ("idGraph", "idGraph");
0079 IDcanv->cd();
0080 TH1F *idDummy = new TH1F("idDummy", "idDummy", 10, 220000000, 221000000);
0081 idDummy->Draw();
0082 for (int chamber=0; chamber<9; ++chamber){
0083   TString idCut = Form ("cham==%d", chamber);
0084   Calibration->Project("idDummy", "id", idCut);
0085   Int_t idNum = idDummy->GetMean();
0086   IDArray[chamber]=idNum;
0087 }
0088 }
0089 
0090 GetSaturation(TString myFileName, TString myFilePath){
0091 gSystem->cd("images/Saturation");
0092 gSystem->cd(fileName);
0093 TFile *myFile = TFile::Open(myFilePath);
0094 
0095 TH1F *Saturation;
0096 TCanvas *SaturationCanvas =  new TCanvas("SaturationVsCharge", "SaturationVsCharge",1100,700);
0097 Saturation = (TH1F*)myFile->Get("Saturation");  
0098 SaturationCanvas->cd(); 
0099 Saturation->GetXaxis()->SetTitle("Charge"); 
0100 Saturation->GetYaxis()->SetTitle("ADC"); 
0101 Saturation->Draw();
0102 SaturationCanvas->Update();  
0103 PrintAsGif(SaturationCanvas, "SaturationVsCharge");
0104 gSystem->cd("../../../");
0105 directoryCheck();
0106 myFile->Close();
0107 }
0108 
0109 GetSaturationGraphs(TString myFileName, TString myFilePath, int nDDU, int nCham){
0110 gSystem->cd("images/Saturation");
0111 gSystem->cd(fileName);
0112 makeDirectory("ChamberGraphs");
0113 gSystem->cd("ChamberGraphs");
0114 TFile *myFile = TFile::Open(myFilePath);
0115 TH1F *SaturationGraph;
0116 TCanvas *SaturationGraphsCanvas;
0117 for (int i=0; i<nDDU; ++i){
0118   int idArray[9];
0119   GetChamberIDs(idArray);
0120   for (int j=0; j<nCham; ++j){
0121     TString SaturationGraphsCanvasName = Form("SaturationVSCharge_Chamber_%d",idArray[j]);
0122     SaturationGraphsCanvas = new TCanvas(SaturationGraphsCanvasName, SaturationGraphsCanvasName, 1100,700);
0123     SaturationGraphsCanvas->Divide(2,3);
0124     for (int k=1; k<6; ++k){
0125       TString SatGraphName = Form ("Saturation%d%d",j,k);
0126       SaturationGraph = (TH1F*)myFile->Get(SatGraphName);  
0127       SaturationGraphsCanvas->cd(k); 
0128       SaturationGraph->GetXaxis()->SetTitle("Charge"); 
0129       SaturationGraph->GetYaxis()->SetTitle("ADC"); 
0130       SaturationGraph->GetXaxis()->SetTitleSize(0.06);
0131       SaturationGraph->GetXaxis()->SetTitleOffset(0.7);
0132       SaturationGraph->GetYaxis()->SetTitleSize(0.06);
0133       SaturationGraph->GetYaxis()->SetTitleOffset(0.7);
0134       SaturationGraph->GetXaxis()->SetLabelSize(0.06);
0135       SaturationGraph->GetYaxis()->SetLabelSize(0.06);
0136       SaturationGraph->SetMarkerStyle(20);
0137       SaturationGraph->SetMarkerSize(0.8);
0138       SaturationGraph->Draw();
0139     }//"strips" loop
0140     SaturationGraphsCanvas->Update(); 
0141     PrintAsGif(SaturationGraphsCanvas, SaturationGraphsCanvasName);
0142   }//chamber loop  
0143 }//DDU loop
0144 myFile->Close();
0145 gSystem->cd("../../../../");
0146 directoryCheck();
0147 }//GetSaturationGraphs()