int main () { calibXMLwriter barrelWriter(EcalBarrel); CaloMiscalibMapEcal map ; std::string barrelfile ="/afs/cern.ch/user/p/presotto/CMSSW_1_6_0/src/CalibCalorimetry/CaloMiscalibTools/data/ecal_barrel_startup.xml" ; map.prefillMap () ; MiscalibReaderFromXMLEcalBarrel barrelreader (map) ; if (!barrelfile.empty ()) barrelreader.parseXMLMiscalibFile (barrelfile) ; EcalIntercalibConstants* constants = new EcalIntercalibConstants (map.get ()) ; EcalIntercalibConstantMap imap = constants->getMap () ; std::string barrelfile2 ="EBcalib.xml" ; CaloMiscalibMapEcal map2; map2.prefillMap (); MiscalibReaderFromXMLEcalBarrel barrelreader2 (map2) ; if (!barrelfile2.empty ()) barrelreader2.parseXMLMiscalibFile (barrelfile2) ; EcalIntercalibConstants* constants2 = new EcalIntercalibConstants (map2.get ()) ; EcalIntercalibConstantMap imap2 = constants2->getMap () ; for (int eta =-85;eta<=85;++eta) for (int phi = 1; phi<=360;++phi) { if (!EBDetId::validDetId(eta,phi)) continue; EBDetId eb (eta,phi,EBDetId::ETAPHIMODE); barrelWriter.writeLine (eb, *(imap.find(eb.rawId())) * *(imap2.find(eb.rawId()))); } }
int main (int argc, char* argv[]) { std::cout << "parsing cfg file: " << argv[1] << std::endl ; trivialParser configParams (static_cast<std::string> (argv[1])) ; int IMAEEradStart = static_cast<int> (configParams.getVal ("IMAEEradStart")) ; int IMAEEradEnd = static_cast<int> (configParams.getVal ("IMAEEradEnd")) ; int IMAEEradWidth = static_cast<int> (configParams.getVal ("IMAEEradWidth")) ; int IMAEEphiStart = static_cast<int> (configParams.getVal ("IMAEEphiStart")) ; int IMAEEphiEnd = static_cast<int> (configParams.getVal ("IMAEEphiEnd")) ; // std::cerr << "[PG] IMAEEradStart = " << IMAEEradStart << std::endl ; // std::cerr << "[PG] IMAEEradEnd = " << IMAEEradEnd << std::endl ; // std::cerr << "[PG] IMAEEradWidth = " << IMAEEradWidth << std::endl ; // std::cerr << "[PG] IMAEEphiStart = " << IMAEEphiStart << std::endl ; // std::cerr << "[PG] IMAEEphiEnd = " << IMAEEphiEnd << std::endl ; // std::cerr << "[PG] IMAEEphiWidth = " << IMAEEphiWidth << std::endl ; std::string coeffFolder = argv[2] ; std::map<int, EcalIntercalibConstantMap> recalibrators ; //PG FIXME c'e' il copy ctor della CaloMiscalibMapEcal? //PG loop on EB rad indexes for (int radIndex = IMAEEradStart ; radIndex < IMAEEradEnd ; radIndex += IMAEEradWidth) { int currentIndex = radIndex ; int nextIndex = radIndex + IMAEEradWidth ; //PG compute the values of the limits //PG FIXME questo forse non e' sufficiente, bisogna anche considerare il caso //PG FIXME in cui currentIndex e' positivo e effradIndex start no //PG FIXME lo stesso vale per l'end e il nexindex //PG FIXME lo stesso vale per gli script perl // int effradIndexStart = currentIndex - IMAEEradWidth ; // if (effradIndexStart < 0) { effradIndexStart = 0 ; } // int effradIndexEnd = nextIndex + IMAEEradWidth ; // if (effradIndexEnd > 50) { effradIndexEnd = 50 ; } //PG build the filename std::stringstream nomeFile ; nomeFile << coeffFolder << "/EEcalibCoeff_" << currentIndex << "-" << nextIndex << ".xml" ; std::string fileName = nomeFile.str () ; // std::cerr << "PG nomefile: " << fileName << std::endl ; //PG open the XML file CaloMiscalibMapEcal map ; map.prefillMap () ; MiscalibReaderFromXMLEcalEndcap endcapreader (map) ; if (!fileName.empty ()) endcapreader.parseXMLMiscalibFile (fileName) ; EcalIntercalibConstants* constants = new EcalIntercalibConstants (map.get ()) ; recalibrators[currentIndex] = constants->getMap () ; } //PG loop on EB rad indexes //PG prepare the XML to be saved //PG this command outputs an XML file with a fixed name calibXMLwriter endcapWriter (EcalEndcap) ; //PG loop on EB rad slices for (std::map<int, EcalIntercalibConstantMap>::const_iterator itMap = recalibrators.begin () ; itMap != recalibrators.end () ; ++itMap) { //PG compute the values of the limits //PG FIXME questo forse non e' sufficiente, bisogna anche considerare il caso //PG FIXME in cui currentIndex e' positivo e effradIndex start no //PG FIXME lo stesso vale per l'end e il nexindex //PG FIXME lo stesso vale per gli script perl //PG non so scegliere da dove partire, questo e' un disastro //PG il problema e' dei bordi //PG forse la cosa migliore e' salvare i xml file con un nome che dica dei coeff buoni, //PG non di quelli calcolati - direi che e' la cosa giusta //PG loop over x for (int ix = 0 ; ix < 100 ; ++ix) //PG loop over y for (int iy = 0 ; iy < 100 ; ++iy) { //PG select the subregion of interest if (EEregionCheck (ix,iy, itMap->first,itMap->first+IMAEEradWidth, IMAEEphiStart,IMAEEphiEnd) ) continue ; //PG check whether the detid is buildable if (!EEDetId::validDetId (ix,iy,1)) { std::cerr << "[WARN] elemento " << ix << " " << iy << " 1" << " scartato" << std::endl ; continue ; } EEDetId det = EEDetId (ix,iy,1,EEDetId::XYMODE) ; std::cerr << "[INFO] writing " << ix << " " << iy << " 1" << " " << *(itMap->second.find (det.rawId ())) << std::endl ; endcapWriter.writeLine (det,*(itMap->second.find (det.rawId ()))); } //PG loop over x, loop over y } /* TODOS - inizio con EB - leggi l'intervallo di validita' - cerca i XML file in funzione di quello che sta scritto nel parser (qui bisogna conoscere gia' la cartella e costruire i nomi allo stesso modo, questo e' un punto debole) - apri un XML interface per ciascun file XML e leggine sono quello che serve - riversalo nel XML finale - check the includes */ }
int main (int argc, char* argv[]) { int EEradStart = 15 ; int EEradEnd = 50 ; int EEphiStart = 15 ; int EEphiEnd = 45 ; std::string endcapfile = argv[1] ; std::string calibEndcapfile = argv[2] ; std::string filename = "coeffcompareEE.root" ; if (argc > 3) { if (argc < 7) { std::cerr << "Too few (or too many) arguments passed" << std::endl ; exit (1) ; } EEradStart = atoi (argv[3]) ; EEradEnd = atoi (argv[4]) ; EEphiStart = atoi (argv[5]) ; EEphiEnd = atoi (argv[6]) ; } if (argc == 8) filename = argv[7] ; // std::string endcapfile = "/afs/cern.ch/user/g/govoni/scratch1/CMSSW/CALIB/CMSSW_1_6_0/src/CalibCalorimetry/CaloMiscalibTools/data/ecal_endcap_startup.xml" ; // std::string calibEndcapfile = "/afs/cern.ch/user/g/govoni/scratch1/CMSSW/CALIB/CMSSW_1_6_0/src/CalibCalorimetry/CaloMiscalibTools/data/inv_ecal_endcap_startup.xml" ; //PG get the miscalibration files for EB and EE //PG ------------------------------------------ CaloMiscalibMapEcal EEscalibMap ; EEscalibMap.prefillMap () ; MiscalibReaderFromXMLEcalEndcap endcapreader (EEscalibMap) ; if (!endcapfile.empty ()) endcapreader.parseXMLMiscalibFile (endcapfile) ; EcalIntercalibConstants* EEconstants = new EcalIntercalibConstants (EEscalibMap.get ()) ; EcalIntercalibConstants::EcalIntercalibConstantMap iEEscalibMap = EEconstants->getMap () ; //MF prende i vecchi coeff //PG get the recalibration files for EB and EE //PG ----------------------------------------- CaloMiscalibMapEcal EEcalibMap ; EEcalibMap.prefillMap () ; MiscalibReaderFromXMLEcalEndcap calibEndcapreader (EEcalibMap) ; if (!calibEndcapfile.empty ()) calibEndcapreader.parseXMLMiscalibFile (calibEndcapfile) ; EcalIntercalibConstants* EECconstants = new EcalIntercalibConstants (EEcalibMap.get ()) ; EcalIntercalibConstants::EcalIntercalibConstantMap iEEcalibMap = EECconstants->getMap () ; //MF prende i vecchi coeff //PG fill the histograms //PG ------------------- TH1F EEPCompareCoeffDistr ("EEPCompareCoeffDistr","EEPCompareCoeffDistr",5000,0,2) ; TH2F EEPCompareCoeffMap ("EEPCompareCoeffMap","EEPCompareCoeffMap",101,0,101,101,0,101) ; TH2F EEPCompareCoeffEtaTrend ("EEPCompareCoeffEtaTrend", "EEPCompareCoeffEtaTrend", 51,0,50,500,0,2) ; TProfile EEPCompareCoeffEtaProfile ("EEPCompareCoeffEtaProfile", "EEPCompareCoeffEtaProfile", 51,0,50,0,2) ; TH1F EEPCompareCoeffDistr_R1 ("EEPCompareCoeff_R1","EEPCompareCoeff_R1",1000,0,2) ; TH1F EEPCompareCoeffDistr_R2 ("EEPCompareCoeff_R2","EEPCompareCoeff_R2",1000,0,2) ; TH1F EEPCompareCoeffDistr_R3 ("EEPCompareCoeff_R3","EEPCompareCoeff_R3",1000,0,2) ; TH1F EEPCompareCoeffDistr_R4 ("EEPCompareCoeff_R4","EEPCompareCoeff_R4",1000,0,2) ; TH1F EEPCompareCoeffDistr_R5 ("EEPCompareCoeff_R5","EEPCompareCoeff_R5",1000,0,2) ; // ECAL endcap + for (int ix = 1 ; ix <= 100 ; ++ix) for (int iy = 1 ; iy <= 100 ; ++iy) { int rad = static_cast<int> (sqrt ((ix - 50) * (ix - 50) + (iy - 50) * (iy - 50))) ; if (rad < EEradStart || rad > EEradEnd) continue ; double phiTemp = atan2 (iy - 50, ix - 50) ; if (phiTemp < 0) phiTemp += 2 * PI_GRECO ; int phi = static_cast<int> ( phiTemp * 180 / PI_GRECO) ; if (phi < EEphiStart || phi > EEphiEnd) continue ; if (!EEDetId::validDetId (ix,iy,1)) continue ; EEDetId det = EEDetId (ix, iy, 1, EEDetId::XYMODE) ; double factor = (iEEcalibMap.find (det.rawId ()))->second * (iEEscalibMap.find (det.rawId ()))->second ; EEPCompareCoeffDistr.Fill (factor) ; EEPCompareCoeffMap.Fill (ix,iy,factor) ; EEPCompareCoeffEtaTrend.Fill (rad,factor) ; EEPCompareCoeffEtaProfile.Fill (rad,factor) ; if (abs(rad) < 22) continue ; else if (abs(rad) < 27) EEPCompareCoeffDistr_R1.Fill (factor) ; else if (abs(rad) < 32) EEPCompareCoeffDistr_R2.Fill (factor) ; else if (abs(rad) < 37) EEPCompareCoeffDistr_R3.Fill (factor) ; else if (abs(rad) < 42) EEPCompareCoeffDistr_R4.Fill (factor) ; else EEPCompareCoeffDistr_R5.Fill (factor) ; } // ECAL endcap + // ECAL endcap- TH1F EEMCompareCoeffDistr ("EEMCompareCoeffDistr","EEMCompareCoeffDistr",200,0,2) ; TH2F EEMCompareCoeffMap ("EEMCompareCoeffMap","EEMCompareCoeffMap",100,0,100,100,0,100) ; TH2F EEMCompareCoeffEtaTrend ("EEMCompareCoeffEtaTrend", "EEMCompareCoeffEtaTrend", 51,0,50,500,0,2) ; TProfile EEMCompareCoeffEtaProfile ("EEMCompareCoeffEtaProfile", "EEMCompareCoeffEtaProfile", 51,0,50,0,2) ; // ECAL endcap - for (int ix = 1 ; ix <= 100 ; ++ix) for (int iy = 1 ; iy <= 100 ; ++iy) { int rad = static_cast<int> (sqrt ((ix - 50) * (ix - 50) + (iy - 50) * (iy - 50))) ; if (rad < EEradStart || rad > EEradEnd) continue ; double phiTemp = atan2 (iy - 50, ix - 50) ; if (phiTemp < 0) phiTemp += 2 * PI_GRECO ; int phi = static_cast<int> ( phiTemp * 180 / PI_GRECO) ; if (!EEDetId::validDetId (ix,iy,-1)) continue ; EEDetId det = EEDetId (ix, iy, -1, EEDetId::XYMODE) ; double factor = (iEEcalibMap.find (det.rawId ()))->second * (iEEscalibMap.find (det.rawId ()))->second ; EEMCompareCoeffDistr.Fill (factor) ; EEMCompareCoeffMap.Fill (ix,iy,factor) ; EEMCompareCoeffEtaTrend.Fill (rad,factor) ; EEMCompareCoeffEtaProfile.Fill (rad,factor) ; } // ECAL endcap - TFile out (filename.c_str (),"recreate") ; EEMCompareCoeffMap.Write() ; EEMCompareCoeffDistr.Write() ; EEMCompareCoeffEtaTrend.Write () ; EEMCompareCoeffEtaProfile.Write () ; EEPCompareCoeffMap.Write() ; EEPCompareCoeffDistr.Write() ; EEPCompareCoeffEtaTrend.Write () ; EEPCompareCoeffEtaProfile.Write () ; EEPCompareCoeffDistr_R1.Write () ; EEPCompareCoeffDistr_R2.Write () ; EEPCompareCoeffDistr_R3.Write () ; EEPCompareCoeffDistr_R4.Write () ; EEPCompareCoeffDistr_R5.Write () ; out.Close() ; }