Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:44

0001 #ifndef COMMONHELPERFUNCTIONS_H
0002 #define COMMONHELPERFUNCTIONS_H
0003 
0004   #include <iostream>
0005   #include <fstream>
0006   #include "TString.h"
0007   #include "TObjString.h"
0008   #include <vector>
0009   #include <map>
0010   #include <utility>
0011 
0012   struct Layer{
0013     Layer(): nCells(0), energy(0.), avX(0.), avY(0.) {}
0014     int nCells;
0015     double energy;
0016     double avX;
0017     double avY;
0018   } ;
0019   
0020   struct RunInfo{
0021     RunInfo(): runNr(0), species(""), pdg(0), energy(0), vop(0), vbr(0), lgSet(0), hgSet(0), posX(0), posY(0), assemblyNr(0){}
0022     int runNr;
0023     TString species;
0024     int pdg;
0025     float energy;
0026     float vop;
0027     float vbr;
0028     int lgSet;
0029     int hgSet;
0030     float posX;
0031     float posY;
0032     int assemblyNr;
0033   } ;
0034 
0035   TString GetStringFromRunInfo(RunInfo, Int_t);
0036 
0037   //__________________________________________________________________________________________________________
0038   //__________________ Read run infos from text file _________________________________________________________
0039   //__________________________________________________________________________________________________________    
0040   // specialData: 0 - std. TB, 1 - SPE data ORNL
0041   inline std::map<int,RunInfo> readRunInfosFromFile(TString runListFileName, int debug, int specialData = 0 ){
0042     std::map<int,RunInfo> runs;
0043     //std::cout << "INFO: You have given the following run list file: " << runListFileName.Data() << std::endl;
0044     std::ifstream runListFile;
0045     runListFile.open(runListFileName,std::ios_base::in);
0046     if (!runListFile) {
0047       std::cout << "ERROR: file " << runListFileName.Data() << " not found!" << std::endl;
0048       return runs;
0049     }
0050 
0051     for( TString tempLine; tempLine.ReadLine(runListFile, kTRUE); ) {
0052       // check if line should be considered
0053       if (tempLine.BeginsWith("%") || tempLine.BeginsWith("#")){
0054         continue;
0055       }
0056       if (debug > 1) std::cout << tempLine.Data() << std::endl;
0057 
0058       // Separate the string according to tabulators
0059       TObjArray *tempArr  = tempLine.Tokenize(",");
0060       if(tempArr->GetEntries()<1){
0061         if (debug > 1) std::cout << "nothing to be done" << std::endl;
0062         delete tempArr;
0063         continue;
0064       } 
0065 
0066       // Put them to the correct variables    
0067       RunInfo tempRun;
0068       tempRun.runNr    = ((TString)((TObjString*)tempArr->At(0))->GetString()).Atoi();
0069       tempRun.species  =  (TString)((TObjString*)tempArr->At(1))->GetString();
0070       tempRun.pdg      = ((TString)((TObjString*)tempArr->At(2))->GetString()).Atoi();
0071       tempRun.energy   = ((TString)((TObjString*)tempArr->At(3))->GetString()).Atof();
0072       tempRun.vop      = ((TString)((TObjString*)tempArr->At(4))->GetString()).Atof();
0073       tempRun.vbr      = ((TString)((TObjString*)tempArr->At(5))->GetString()).Atof();
0074       tempRun.hgSet    = ((TString)((TObjString*)tempArr->At(6))->GetString()).Atoi();
0075       tempRun.lgSet    = ((TString)((TObjString*)tempArr->At(7))->GetString()).Atoi();
0076       tempRun.posX    = ((TString)((TObjString*)tempArr->At(8))->GetString()).Atoi();
0077       tempRun.posY    = ((TString)((TObjString*)tempArr->At(9))->GetString()).Atoi();
0078       if (specialData == 1) tempRun.assemblyNr = ((TString)((TObjString*)tempArr->At(10))->GetString()).Atoi();
0079                   
0080       if (debug > 1) std::cout << "Run " << tempRun.runNr << "\t species: " << tempRun.species << "\t energy: "  << tempRun.energy << "\t Vop: " << tempRun.vop << "\t Vov: " << tempRun.vop-tempRun.vbr << "\t Xbeam: " << tempRun.posX<< "\t Ybeam: " << tempRun.posY<< std::endl;
0081       runs[tempRun.runNr]=tempRun;
0082     }
0083     std::cout << "registered " << runs.size() << " runs from  "<< runListFileName.Data() << std::endl;
0084     return runs;
0085   };
0086 
0087   Double_t ReturnMipPlotRangeDepVov(double Vov, bool isHG){
0088     if (isHG){
0089       if (Vov < 2)
0090         return 550.;
0091       else if (Vov < 3)
0092         return 750.;
0093       else if (Vov < 4)
0094         return 950.;
0095       else if (Vov < 5)
0096         return 1150.;
0097       else
0098         return 1350.;
0099     } else {
0100       if (Vov < 2)
0101         return 85.;
0102       else if (Vov < 3)
0103         return 105.;
0104       else if (Vov < 4)
0105         return 125.;
0106       else if (Vov < 5)
0107         return 145.;
0108       else
0109         return 165.;      
0110     }
0111   }
0112   
0113 
0114   
0115   
0116 #endif