From: Stephen Sanders (ssanders@ku.edu)
Date: Thu Oct 31 2002 - 13:13:06 EST
Hi Christian, The current code should only run through the if--else sequence if a file specific to the run number if not found. This sequence tries to point to an appropriate "default" calibration. However, I like your solution to avoid having to change "defaults" since is is always the closest available calibration with a lower run number that is wanted. I'd be happy if you commit your changes since they should be transparent and will avoid having to keep updating these files in the future. Regards, Steve On Thursday, October 31, 2002, at 12:49 PM, Christian Holm Christensen wrote: > Hi all (in particular Steve and Hiro), > > Is there any reason why some of the calibration files in > > <prefix>/share/brat/params/mult > > are not used? In > > data/calib/Br{Tile,Si}Calibration.cxx > > the methods > > Br{Tile,Si}TmpCalibration::ReadAsciiFile(Int_t runno) > > as series of `if' statements selects one of the files from > > <prefix>/share/brat/params/mult > > but not all are used. Another way to do all this, is to utilise > ROOT's `TSystemDirectory', like > > // Open the directory > TSystemDirectory dir(Form("%s/params/mult", pathMan->GetDataDir()); > > // get a list of files (inodes) in that directory > TList* files = dir->GetListOfFiles(); > if (!list) { > Error("ReadASCIIFile", "Couldn't open the calib directory"); > return; > } > > // Make an array to store the runnumbers in > TArrayI runNos(10); > Int_t current = 0; > > // Loop over the inodes > TSystemFile* sfile = 0; > files.Sort(); > TIter next(files); > while ((sfile = (TSystemFile*)next())) { > // If it's a folder (directory) or doesn't contain `BrCalibr' in > // it's name, then continue > if (sfile->IsFolder()) continue; > TString name(sfile->GetName()); > if (!name.Contains("BrCalibr")) continue; > > // Find the `_' that seperates the run number from the rest, and > // remove everything up to and including that `_' > Ssiz_t idx = name.Index('_'); > name.Remove(0, idex+1); > > // Find the `.' that starts the last part of the file, and remove > // everything after that > idx = name.Index('.'); > name.Remove(idx); > > // Expand the array if needed > if (runNos.fN <= current + 1 ) > runNos.Set(runNos.fN * 2); > > // Add the runnumber to the list. > runNos[current++] = strtol(name.Data(), NULL, 0); > } > > // Search through the array, looking for the closest match (less > // than or equal). > Int_t real = TMath::BinarySearch(runNos.fN, runNos.fArray, runno); > > // Make the filename, and open the file > sprintf(fname, "%s/params/mult/BrCalibrMult_%d.dat", > pathMan->GetDataDir(), runNos[real]); > file.open(fname); > > In this way, you don't have to change the code each time a new file is > added. If you like this idea, then I'll commit to CVS for both the > TMA and SMA code (I've already implemented it in my working directory). > > Yours, > > ____ | Christian Holm Christensen > |_| | ------------------------------------------------------------- > | | Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91 > _| DK-2200 Copenhagen N Cell: (+45) 24 61 85 91 > _| Denmark Office: (+45) 353 25 305 > ____| Email: cholm@nbi.dk Web: www.nbi.dk/~cholm > | |
This archive was generated by hypermail 2.1.5 : Thu Oct 31 2002 - 13:13:48 EST