53 produces<ValueMap<DeDxData> >();
56 string estimatorName = iConfig.
getParameter<
string>(
"estimator");
66 m_trajTrackAssociationTag = consumes<TrajTrackAssociationCollection>(iConfig.
getParameter<
edm::InputTag>(
"trajectoryTrackAssociation"));
70 MeVperADCPixel = iConfig.
getParameter<
double>(
"MeVperADCPixel");
71 MeVperADCStrip = iConfig.
getParameter<
double>(
"MeVperADCStrip");
74 useCalibration = iConfig.
getParameter<
bool>(
"UseCalibration");
75 m_calibrationPath = iConfig.
getParameter<
string>(
"calibrationPath");
77 if(!usePixel && !useStrip)
78 edm::LogWarning(
"DeDxHitsProducer") <<
"Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
90 if(MODsColl.size()!=0)
return;
96 auto const &
Det = tkGeom->dets();
97 for(
unsigned int i=0;
i<
Det.size();
i++){
103 double Thick=-1, Dist=-1, Norma=-1;
105 Dist = StripDetUnit->position().mag();
106 Thick = StripDetUnit->surface().bounds().thickness();
107 Norma = MeVperADCStrip/Thick;
108 }
else if(PixelDetUnit){
109 Dist = PixelDetUnit->position().mag();
110 Thick = PixelDetUnit->surface().bounds().thickness();
111 Norma = MeVperADCPixel/Thick;
120 MODsColl[MOD->
DetId] = MOD;
123 MakeCalibrationMap();
134 iEvent.
getByToken(m_trajTrackAssociationTag, trajTrackAssociationHandle);
138 iEvent.
getByToken(m_tracksTag,trackCollectionHandle);
140 size_t n = TrajToTrackMap.
size();
141 std::vector<DeDxData> dedxEstimate(n);
151 vector<DeDxTools::RawHits> hits;
154 const vector<TrajectoryMeasurement> & measurements = traj->measurements();
155 for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
157 if( !trajState.
isValid())
continue;
161 double cosine = trackDirection.
z()/trackDirection.
mag();
164 if(!useStrip)
continue;
174 mono.
detId= matchedHit->monoId();
175 stereo.
detId= matchedHit->stereoId();
180 if(!useStrip)
continue;
186 mono.
detId= projectedHit->originalId();
188 hits.push_back(mono);
189 }
else if(
const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit)){
190 if(!useStrip)
continue;
196 mono.
detId= singleHit->geographicalId();
198 hits.push_back(mono);
199 }
else if(
const SiStripRecHit1D* single1DHit=dynamic_cast<const SiStripRecHit1D*>(recHit)){
200 if(!useStrip)
continue;
206 mono.
detId= single1DHit->geographicalId();
208 hits.push_back(mono);
209 }
else if(
const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
210 if(!usePixel)
continue;
216 pixel.
charge = pixelHit->cluster()->charge();
218 pixel.
detId= pixelHit->geographicalId();
219 hits.push_back(pixel);
224 int NClusterSaturating = 0;
225 for(
size_t i=0;
i < hits.size();
i++)
230 dedxHits.push_back(
DeDxHit( charge, MOD->
Distance, pathLen, hits[
i].detId) );
232 if(hits[i].NSaturating>0)NClusterSaturating++;
235 sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
236 std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
240 val_and_error.second = NClusterSaturating;
242 dedxEstimate[
j] =
DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
244 filler.
insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
249 iEvent.
put(trackDeDxEstimateAssociation);
256 if(!useCalibration)
return;
258 TChain* t1 =
new TChain(
"SiStripCalib/APVGain");
259 t1->Add(m_calibrationPath.c_str());
261 unsigned int tree_DetId;
262 unsigned char tree_APVId;
265 t1->SetBranchAddress(
"DetId" ,&tree_DetId );
266 t1->SetBranchAddress(
"APVId" ,&tree_APVId );
267 t1->SetBranchAddress(
"Gain" ,&tree_Gain );
271 for (
unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
272 t1->GetEntry(ientry);
274 MOD->
Gain = tree_Gain;
283 const uint32_t &
DetId)
286 const vector<uint8_t>& Ampls = Cluster->
amplitudes();
292 Saturating_Strips = 0;
293 for(
unsigned int i=0;
i<Ampls.size();
i++){
294 int CalibratedCharge = Ampls[
i];
299 CalibratedCharge = (int)(CalibratedCharge / MOD->
Gain );
300 if(CalibratedCharge>=1024){
301 CalibratedCharge = 255;
302 }
else if(CalibratedCharge>=255){
303 CalibratedCharge = 254;
307 toReturn+=CalibratedCharge;
308 if(CalibratedCharge>=254)Saturating_Strips++;
T getParameter(std::string const &) const
DeDxEstimatorProducer(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
LocalVector localDirection() const
void insert(const H &h, I begin, I end)
std::vector< DeDxHit > DeDxHitCollection
uint32_t rawId() const
get the raw id
virtual void beginRun(edm::Run const &run, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Abs< T >::type abs(const T &t)
void MakeCalibrationMap()
size_type size() const
map size
key_type key() const
Accessor for product key.
T const * product() const
virtual void produce(edm::Event &, const edm::EventSetup &) override
const_iterator begin() const
first iterator over the map (read only)
const std::vector< uint8_t > & amplitudes() const
int getCharge(const SiStripCluster *Cluster, int &Saturating_Strips, const uint32_t &)